Skip to content

Commit

Permalink
fix click away listener api link
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed Jan 24, 2022
1 parent fc46e7b commit 9e9c877
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/src/modules/utils/replaceHtmlLinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ describe('replaceHtmlLinks', () => {
<li><a href="/api/tabs-list-unstyled/"><code>&lt;TabListUnstyled /&gt;</code></a></li>
<li><a href="/api/tab-panel-unstyled/"><code>&lt;TabListUnstyled /&gt;</code></a></li>
<li><a href="/api/unstable-trap-focus/"><code>&lt;UnstableTrapFocus /&gt;</code></a></li>
<li><a href="/api/click-away-listener/"><code>&lt;UnstableTrapFocus /&gt;</code></a></li>
<li><a href="/api/icon-button/"><code>&lt;IconButton /&gt;</code></a></li>
<li><a href="/api/loading-button/"><code>&lt;LoadingButton /&gt;</code></a></li>
<li><a href="/api/data-grid/data-grid/">DataGrid</a></li>
Expand All @@ -224,6 +225,7 @@ describe('replaceHtmlLinks', () => {
<li><a href="/base/api/tabs-list-unstyled/"><code>&lt;TabListUnstyled /&gt;</code></a></li>
<li><a href="/base/api/tab-panel-unstyled/"><code>&lt;TabListUnstyled /&gt;</code></a></li>
<li><a href="/base/api/unstable-trap-focus/"><code>&lt;UnstableTrapFocus /&gt;</code></a></li>
<li><a href="/base/api/click-away-listener/"><code>&lt;UnstableTrapFocus /&gt;</code></a></li>
<li><a href="/material/api/icon-button/"><code>&lt;IconButton /&gt;</code></a></li>
<li><a href="/material/api/loading-button/"><code>&lt;LoadingButton /&gt;</code></a></li>
<li><a href="/x/api/data-grid/data-grid/">DataGrid</a></li>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/replaceHtmlLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const replaceAPILinks = (html: string) => {
'href=$1"$2/base/api/$3$4"',
)
.replace(
/href=(\\*?)"(\/[a-z]{2})?\/api\/(unstable-trap-focus)([^"]*)"/gm,
/href=(\\*?)"(\/[a-z]{2})?\/api\/(unstable-trap-focus|click-away-listener)([^"]*)"/gm,
'href=$1"$2/base/api/$3$4"',
)
.replace(
Expand Down
2 changes: 2 additions & 0 deletions docs/src/modules/utils/replaceMarkdownLinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('replaceMarkdownLinks', () => {
[TabPanelUnstyled](/api/tab-panel-unstyled)
[TabsListUnstyled](/api/tabs-list-unstyled)
[Unstable_TrapFocus](/api/unstable-trap-focus)
[ClickAwayListener](/api/click-away-listener)
[IconButton](/api/icon-button)
[LoadingButton](/api/loading-button)
[DataGrid](/api/data-grid/data-grid)
Expand All @@ -217,6 +218,7 @@ describe('replaceMarkdownLinks', () => {
[TabPanelUnstyled](/base/api/tab-panel-unstyled)
[TabsListUnstyled](/base/api/tabs-list-unstyled)
[Unstable_TrapFocus](/base/api/unstable-trap-focus)
[ClickAwayListener](/base/api/click-away-listener)
[IconButton](/material/api/icon-button)
[LoadingButton](/material/api/loading-button)
[DataGrid](/x/api/data-grid/data-grid)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/replaceMarkdownLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const replaceAPILinks = (markdown: string) => {
return markdown
.replace(/\(\/api\/data-grid([^)]*)\)/gm, '(/x/api/data-grid$1)')
.replace(/\(\/api\/([^"/]+-unstyled)([^)]*)\)/gm, '(/base/api/$1$2)')
.replace(/\(\/api\/(unstable-trap-focus)([^)]*)\)/gm, '(/base/api/$1$2)')
.replace(/\(\/api\/(unstable-trap-focus|click-away-listener)([^)]*)\)/gm, '(/base/api/$1$2)')
.replace(
/\(\/api\/(loading-button|tab-list|tab-panel|date-picker|date-time-picker|time-picker|calendar-picker|calendar-picker-skeleton|desktop-picker|mobile-date-picker|month-picker|pickers-day|static-date-picker|year-picker|masonry|timeline|timeline-connector|timeline-content|timeline-dot|timeline-item|timeline-opposite-content|timeline-separator|unstable-trap-focus|tree-item|tree-view)([^)]*)\)/gm,
'(/material/api/$1$2)',
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules/utils/replaceUrl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ describe('replaceUrl', () => {
expect(replaceAPILinks(`/api/tabs-list-unstyled/`)).to.equal(`/base/api/tabs-list-unstyled/`);
expect(replaceAPILinks(`/api/tabs-unstyled/`)).to.equal(`/base/api/tabs-unstyled/`);
expect(replaceAPILinks(`/api/unstable-trap-focus/`)).to.equal(`/base/api/unstable-trap-focus/`);
expect(replaceAPILinks(`/api/click-away-listener/`)).to.equal(`/base/api/click-away-listener/`);
expect(replaceAPILinks(`/api/data-grid/data-grid/`)).to.equal(`/x/api/data-grid/data-grid/`);
expect(replaceAPILinks(`/system/basic/`)).to.equal(`/system/basic/`);
});
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/replaceUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const replaceAPILinks = (url: string) => {
.replace(/\/api\/data-grid(.*)/, '/x/api/data-grid$1')
.replace(/\/api\/(no-ssr|portal|textarea-autosize)/, '/base/api/$1')
.replace(/\/api\/([^/]+-unstyled)(.*)/, '/base/api/$1$2')
.replace(/\/api\/(unstable-trap-focus)(.*)/, '/base/api/$1$2');
.replace(/\/api\/(unstable-trap-focus|click-away-listener)(.*)/, '/base/api/$1$2');

if (isNewLocation(url)) {
return url;
Expand Down

0 comments on commit 9e9c877

Please sign in to comment.