@wordpress/components 28.8.3 → 28.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -3
- package/build/autocomplete/index.js +4 -1
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +3 -14
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-control/border-control/component.js +1 -2
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +2 -14
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/styles.js +13 -13
- package/build/border-control/styles.js.map +1 -1
- package/build/border-control/types.js.map +1 -1
- package/build/box-control/index.js +4 -4
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/composite/group-label.js +7 -1
- package/build/composite/group-label.js.map +1 -1
- package/build/composite/group.js +7 -1
- package/build/composite/group.js.map +1 -1
- package/build/composite/hover.js +8 -2
- package/build/composite/hover.js.map +1 -1
- package/build/composite/index.js +5 -1
- package/build/composite/index.js.map +1 -1
- package/build/composite/item.js +16 -1
- package/build/composite/item.js.map +1 -1
- package/build/composite/row.js +7 -1
- package/build/composite/row.js.map +1 -1
- package/build/composite/typeahead.js +8 -2
- package/build/composite/typeahead.js.map +1 -1
- package/build/date-time/date/index.js +4 -2
- package/build/date-time/date/index.js.map +1 -1
- package/build/index.js +36 -5
- package/build/index.js.map +1 -1
- package/build/navigator/index.js +128 -32
- package/build/navigator/index.js.map +1 -1
- package/build/navigator/legacy.js +179 -0
- package/build/navigator/legacy.js.map +1 -0
- package/build/navigator/{navigator-provider → navigator}/component.js +5 -40
- package/build/navigator/navigator/component.js.map +1 -0
- package/build/navigator/navigator-back-button/component.js +2 -38
- package/build/navigator/navigator-back-button/component.js.map +1 -1
- package/build/navigator/navigator-back-button/hook.js +1 -1
- package/build/navigator/navigator-back-button/hook.js.map +1 -1
- package/build/navigator/navigator-button/component.js +2 -37
- package/build/navigator/navigator-button/component.js.map +1 -1
- package/build/navigator/navigator-button/hook.js +1 -1
- package/build/navigator/navigator-button/hook.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +40 -62
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/navigator-screen/use-screen-animate-presence.js +114 -0
- package/build/navigator/navigator-screen/use-screen-animate-presence.js.map +1 -0
- package/build/navigator/navigator-to-parent-button/component.js +3 -7
- package/build/navigator/navigator-to-parent-button/component.js.map +1 -1
- package/build/navigator/styles.js +78 -35
- package/build/navigator/styles.js.map +1 -1
- package/build/navigator/types.js.map +1 -1
- package/build/navigator/use-navigator.js +4 -1
- package/build/navigator/use-navigator.js.map +1 -1
- package/build/search-control/index.js +5 -2
- package/build/search-control/index.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tablist.js +61 -28
- package/build/tabs/tablist.js.map +1 -1
- package/build/tabs/use-track-overflow.js +73 -0
- package/build/tabs/use-track-overflow.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control/as-button-group.js +4 -2
- package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +9 -3
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +73 -8
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +10 -19
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -9
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/toggle-group-control/types.js.map +1 -1
- package/build/utils/element-rect.js +22 -13
- package/build/utils/element-rect.js.map +1 -1
- package/build/utils/hooks/use-on-value-update.js +3 -7
- package/build/utils/hooks/use-on-value-update.js.map +1 -1
- package/build-module/autocomplete/index.js +4 -1
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +3 -14
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-control/border-control/component.js +1 -2
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +2 -14
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/styles.js +13 -13
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/border-control/types.js.map +1 -1
- package/build-module/box-control/index.js +4 -4
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/composite/group-label.js +7 -1
- package/build-module/composite/group-label.js.map +1 -1
- package/build-module/composite/group.js +7 -1
- package/build-module/composite/group.js.map +1 -1
- package/build-module/composite/hover.js +8 -2
- package/build-module/composite/hover.js.map +1 -1
- package/build-module/composite/index.js +5 -1
- package/build-module/composite/index.js.map +1 -1
- package/build-module/composite/item.js +16 -1
- package/build-module/composite/item.js.map +1 -1
- package/build-module/composite/row.js +7 -1
- package/build-module/composite/row.js.map +1 -1
- package/build-module/composite/typeahead.js +8 -2
- package/build-module/composite/typeahead.js.map +1 -1
- package/build-module/date-time/date/index.js +4 -2
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/index.js +14 -4
- package/build-module/index.js.map +1 -1
- package/build-module/navigator/index.js +130 -5
- package/build-module/navigator/index.js.map +1 -1
- package/build-module/navigator/legacy.js +167 -0
- package/build-module/navigator/legacy.js.map +1 -0
- package/build-module/navigator/{navigator-provider → navigator}/component.js +4 -39
- package/build-module/navigator/navigator/component.js.map +1 -0
- package/build-module/navigator/navigator-back-button/component.js +1 -37
- package/build-module/navigator/navigator-back-button/component.js.map +1 -1
- package/build-module/navigator/navigator-back-button/hook.js +1 -1
- package/build-module/navigator/navigator-back-button/hook.js.map +1 -1
- package/build-module/navigator/navigator-button/component.js +1 -36
- package/build-module/navigator/navigator-button/component.js.map +1 -1
- package/build-module/navigator/navigator-button/hook.js +1 -1
- package/build-module/navigator/navigator-button/hook.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +39 -61
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/use-screen-animate-presence.js +106 -0
- package/build-module/navigator/navigator-screen/use-screen-animate-presence.js.map +1 -0
- package/build-module/navigator/navigator-to-parent-button/component.js +2 -6
- package/build-module/navigator/navigator-to-parent-button/component.js.map +1 -1
- package/build-module/navigator/styles.js +77 -33
- package/build-module/navigator/styles.js.map +1 -1
- package/build-module/navigator/types.js.map +1 -1
- package/build-module/navigator/use-navigator.js +4 -1
- package/build-module/navigator/use-navigator.js.map +1 -1
- package/build-module/search-control/index.js +5 -2
- package/build-module/search-control/index.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tablist.js +62 -29
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/tabs/use-track-overflow.js +67 -0
- package/build-module/tabs/use-track-overflow.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.js +4 -2
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +9 -3
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +76 -10
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +12 -22
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -8
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/toggle-group-control/types.js.map +1 -1
- package/build-module/utils/element-rect.js +22 -12
- package/build-module/utils/element-rect.js.map +1 -1
- package/build-module/utils/hooks/use-on-value-update.js +3 -6
- package/build-module/utils/hooks/use-on-value-update.js.map +1 -1
- package/build-style/style-rtl.css +26 -13
- package/build-style/style.css +26 -13
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +5 -15
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +2 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +3 -2
- package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +3 -2
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts +2 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts +15 -30
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +12 -7
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +4 -4
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +3 -3
- package/build-types/composite/group-label.d.ts.map +1 -1
- package/build-types/composite/index.d.ts.map +1 -1
- package/build-types/composite/item.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts +22 -0
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/test/index.d.ts +2 -0
- package/build-types/composite/test/index.d.ts.map +1 -0
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/index.d.ts +23 -4
- package/build-types/index.d.ts.map +1 -1
- package/build-types/navigator/index.d.ts +171 -5
- package/build-types/navigator/index.d.ts.map +1 -1
- package/build-types/navigator/legacy.d.ts +226 -0
- package/build-types/navigator/legacy.d.ts.map +1 -0
- package/build-types/navigator/navigator/component.d.ts +3 -0
- package/build-types/navigator/navigator/component.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts +0 -35
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +0 -34
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +0 -35
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/use-screen-animate-presence.d.ts +16 -0
- package/build-types/navigator/navigator-screen/use-screen-animate-presence.d.ts.map +1 -0
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +0 -4
- package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
- package/build-types/navigator/stories/index.story.d.ts +5 -5
- package/build-types/navigator/stories/index.story.d.ts.map +1 -1
- package/build-types/navigator/styles.d.ts +20 -7
- package/build-types/navigator/styles.d.ts.map +1 -1
- package/build-types/navigator/types.d.ts +19 -1
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/navigator/use-navigator.d.ts +4 -1
- package/build-types/navigator/use-navigator.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts +7 -0
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +2 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/tabs/use-track-overflow.d.ts +17 -0
- package/build-types/tabs/use-track-overflow.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +0 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +2 -1
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/utils/element-rect.d.ts +8 -0
- package/build-types/utils/element-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-on-value-update.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/autocomplete/index.tsx +4 -1
- package/src/border-box-control/border-box-control/README.md +22 -26
- package/src/border-box-control/border-box-control/component.tsx +3 -14
- package/src/border-box-control/stories/index.story.tsx +2 -1
- package/src/border-control/border-control/README.md +26 -36
- package/src/border-control/border-control/component.tsx +1 -2
- package/src/border-control/border-control-dropdown/component.tsx +1 -15
- package/src/border-control/stories/index.story.tsx +4 -10
- package/src/border-control/styles.ts +0 -1
- package/src/border-control/test/index.js +2 -15
- package/src/border-control/types.ts +12 -7
- package/src/box-control/README.md +9 -12
- package/src/box-control/index.tsx +4 -4
- package/src/box-control/stories/index.story.tsx +1 -1
- package/src/box-control/types.ts +3 -3
- package/src/composite/group-label.tsx +7 -5
- package/src/composite/group.tsx +7 -7
- package/src/composite/hover.tsx +7 -7
- package/src/composite/index.tsx +6 -1
- package/src/composite/item.tsx +19 -1
- package/src/composite/legacy/test/index.tsx +22 -21
- package/src/composite/row.tsx +7 -7
- package/src/composite/stories/index.story.tsx +42 -0
- package/src/composite/test/index.tsx +123 -0
- package/src/composite/typeahead.tsx +7 -7
- package/src/date-time/date/index.tsx +2 -0
- package/src/dropdown/stories/index.story.tsx +1 -0
- package/src/dropdown/style.scss +10 -13
- package/src/dropdown-menu/stories/index.story.tsx +3 -0
- package/src/index.ts +19 -1
- package/src/menu-group/style.scss +4 -1
- package/src/menu-items-choice/style.scss +2 -0
- package/src/navigator/README.md +176 -0
- package/src/navigator/index.tsx +131 -0
- package/src/navigator/legacy.ts +169 -0
- package/src/navigator/{navigator-provider → navigator}/component.tsx +6 -44
- package/src/navigator/navigator-back-button/component.tsx +1 -37
- package/src/navigator/navigator-back-button/hook.ts +1 -1
- package/src/navigator/navigator-button/component.tsx +1 -36
- package/src/navigator/navigator-button/hook.ts +1 -1
- package/src/navigator/navigator-screen/component.tsx +48 -76
- package/src/navigator/navigator-screen/use-screen-animate-presence.ts +177 -0
- package/src/navigator/navigator-to-parent-button/component.tsx +2 -7
- package/src/navigator/stories/index.story.tsx +55 -54
- package/src/navigator/styles.ts +112 -41
- package/src/navigator/test/index.tsx +47 -47
- package/src/navigator/types.ts +19 -1
- package/src/navigator/use-navigator.ts +4 -1
- package/src/search-control/index.tsx +2 -2
- package/src/select-control/stories/index.story.tsx +14 -1
- package/src/tabs/stories/index.story.tsx +106 -0
- package/src/tabs/styles.ts +54 -20
- package/src/tabs/tablist.tsx +60 -26
- package/src/tabs/use-track-overflow.ts +76 -0
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +208 -44
- package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +18 -10
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +21 -9
- package/src/toggle-group-control/toggle-group-control/component.tsx +114 -6
- package/src/toggle-group-control/toggle-group-control/styles.ts +41 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +10 -27
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +0 -11
- package/src/toggle-group-control/types.ts +3 -1
- package/src/tools-panel/tools-panel/README.md +10 -10
- package/src/utils/element-rect.ts +32 -15
- package/src/utils/hooks/use-on-value-update.ts +3 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/build/navigator/navigator-provider/component.js.map +0 -1
- package/build/utils/hooks/use-event.js +0 -41
- package/build/utils/hooks/use-event.js.map +0 -1
- package/build-module/navigator/navigator-provider/component.js.map +0 -1
- package/build-module/utils/hooks/use-event.js +0 -35
- package/build-module/utils/hooks/use-event.js.map +0 -1
- package/build-types/navigator/navigator-provider/component.d.ts +0 -37
- package/build-types/navigator/navigator-provider/component.d.ts.map +0 -1
- package/build-types/utils/hooks/use-event.d.ts +0 -20
- package/build-types/utils/hooks/use-event.d.ts.map +0 -1
- package/src/navigator/index.ts +0 -6
- package/src/navigator/navigator-back-button/README.md +0 -15
- package/src/navigator/navigator-button/README.md +0 -38
- package/src/navigator/navigator-provider/README.md +0 -94
- package/src/navigator/navigator-screen/README.md +0 -33
- package/src/navigator/navigator-to-parent-button/README.md +0 -17
- package/src/utils/hooks/use-event.ts +0 -38
package/src/navigator/styles.ts
CHANGED
|
@@ -3,69 +3,140 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { css, keyframes } from '@emotion/react';
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const navigatorWrapper = css`
|
|
7
|
+
position: relative;
|
|
7
8
|
/* Prevents horizontal overflow while animating screen transitions */
|
|
8
|
-
overflow-x:
|
|
9
|
-
/*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
overflow-x: clip;
|
|
10
|
+
/*
|
|
11
|
+
* Mark this DOM subtree as isolated when it comes to layout calculations,
|
|
12
|
+
* providing performance benefits.
|
|
12
13
|
*/
|
|
13
|
-
contain:
|
|
14
|
+
contain: layout;
|
|
15
|
+
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: 1fr;
|
|
18
|
+
grid-template-rows: 1fr;
|
|
19
|
+
align-items: start;
|
|
14
20
|
`;
|
|
15
21
|
|
|
16
|
-
const
|
|
17
|
-
|
|
22
|
+
const fadeIn = keyframes( {
|
|
23
|
+
from: {
|
|
18
24
|
opacity: 0,
|
|
19
|
-
transform: `translateX( 50px )`,
|
|
20
25
|
},
|
|
21
|
-
'100%': { opacity: 1, transform: 'none' },
|
|
22
26
|
} );
|
|
23
27
|
|
|
24
|
-
const
|
|
25
|
-
|
|
28
|
+
const fadeOut = keyframes( {
|
|
29
|
+
to: {
|
|
26
30
|
opacity: 0,
|
|
27
|
-
transform: `translateX( -50px )`,
|
|
28
31
|
},
|
|
29
|
-
'100%': { opacity: 1, transform: 'none' },
|
|
30
32
|
} );
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
export const slideFromRight = keyframes( {
|
|
35
|
+
from: {
|
|
36
|
+
transform: 'translateX(100px)',
|
|
37
|
+
},
|
|
38
|
+
} );
|
|
39
|
+
|
|
40
|
+
export const slideToLeft = keyframes( {
|
|
41
|
+
to: {
|
|
42
|
+
transform: 'translateX(-80px)',
|
|
43
|
+
},
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
export const slideFromLeft = keyframes( {
|
|
47
|
+
from: {
|
|
48
|
+
transform: 'translateX(-100px)',
|
|
49
|
+
},
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
export const slideToRight = keyframes( {
|
|
53
|
+
to: {
|
|
54
|
+
transform: 'translateX(80px)',
|
|
55
|
+
},
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
const FADE = {
|
|
59
|
+
DURATION: 70,
|
|
60
|
+
EASING: 'linear',
|
|
61
|
+
DELAY: {
|
|
62
|
+
IN: 70,
|
|
63
|
+
OUT: 40,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const SLIDE = {
|
|
67
|
+
DURATION: 300,
|
|
68
|
+
EASING: 'cubic-bezier(0.33, 0, 0, 1)',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const TOTAL_ANIMATION_DURATION = {
|
|
72
|
+
IN: Math.max( FADE.DURATION + FADE.DELAY.IN, SLIDE.DURATION ),
|
|
73
|
+
OUT: Math.max( FADE.DURATION + FADE.DELAY.OUT, SLIDE.DURATION ),
|
|
36
74
|
};
|
|
37
75
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
export const ANIMATION_END_NAMES = {
|
|
77
|
+
end: {
|
|
78
|
+
in: slideFromRight.name,
|
|
79
|
+
out: slideToLeft.name,
|
|
80
|
+
},
|
|
81
|
+
start: {
|
|
82
|
+
in: slideFromLeft.name,
|
|
83
|
+
out: slideToRight.name,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
46
86
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
87
|
+
const ANIMATION = {
|
|
88
|
+
end: {
|
|
89
|
+
in: css`
|
|
90
|
+
${ FADE.DURATION }ms ${ FADE.EASING } ${ FADE.DELAY
|
|
91
|
+
.IN }ms both ${ fadeIn }, ${ SLIDE.DURATION }ms ${ SLIDE.EASING } both ${ slideFromRight }
|
|
92
|
+
`,
|
|
93
|
+
out: css`
|
|
94
|
+
${ FADE.DURATION }ms ${ FADE.EASING } ${ FADE.DELAY
|
|
95
|
+
.OUT }ms both ${ fadeOut }, ${ SLIDE.DURATION }ms ${ SLIDE.EASING } both ${ slideToLeft }
|
|
96
|
+
`,
|
|
97
|
+
},
|
|
98
|
+
start: {
|
|
99
|
+
in: css`
|
|
100
|
+
${ FADE.DURATION }ms ${ FADE.EASING } ${ FADE.DELAY
|
|
101
|
+
.IN }ms both ${ fadeIn }, ${ SLIDE.DURATION }ms ${ SLIDE.EASING } both ${ slideFromLeft }
|
|
102
|
+
`,
|
|
103
|
+
out: css`
|
|
104
|
+
${ FADE.DURATION }ms ${ FADE.EASING } ${ FADE.DELAY
|
|
105
|
+
.OUT }ms both ${ fadeOut }, ${ SLIDE.DURATION }ms ${ SLIDE.EASING } both ${ slideToRight }
|
|
106
|
+
`,
|
|
107
|
+
},
|
|
108
|
+
} as const;
|
|
109
|
+
export const navigatorScreenAnimation = css`
|
|
110
|
+
z-index: 1;
|
|
51
111
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
will-change: transform, opacity;
|
|
56
|
-
animation-name: ${ animationName };
|
|
112
|
+
&[data-animation-type='out'] {
|
|
113
|
+
z-index: 0;
|
|
114
|
+
}
|
|
57
115
|
|
|
58
|
-
|
|
59
|
-
|
|
116
|
+
@media not ( prefers-reduced-motion ) {
|
|
117
|
+
&:not( [data-skip-animation] ) {
|
|
118
|
+
${ ( [ 'start', 'end' ] as const ).map( ( direction ) =>
|
|
119
|
+
( [ 'in', 'out' ] as const ).map(
|
|
120
|
+
( type ) => css`
|
|
121
|
+
&[data-animation-direction='${ direction }'][data-animation-type='${ type }'] {
|
|
122
|
+
animation: ${ ANIMATION[ direction ][ type ] };
|
|
123
|
+
}
|
|
124
|
+
`
|
|
125
|
+
)
|
|
126
|
+
) }
|
|
60
127
|
}
|
|
61
|
-
|
|
62
|
-
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
63
130
|
|
|
64
|
-
export const navigatorScreen =
|
|
131
|
+
export const navigatorScreen = css`
|
|
65
132
|
/* Ensures horizontal overflow is visually accessible */
|
|
66
133
|
overflow-x: auto;
|
|
67
134
|
/* In case the root has a height, it should not be exceeded */
|
|
68
135
|
max-height: 100%;
|
|
136
|
+
box-sizing: border-box;
|
|
137
|
+
|
|
138
|
+
position: relative;
|
|
69
139
|
|
|
70
|
-
|
|
140
|
+
grid-column: 1 / -1;
|
|
141
|
+
grid-row: 1 / -1;
|
|
71
142
|
`;
|
|
@@ -14,14 +14,8 @@ import { useState } from '@wordpress/element';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import Button from '../../button';
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
NavigatorScreen,
|
|
20
|
-
NavigatorButton,
|
|
21
|
-
NavigatorBackButton,
|
|
22
|
-
NavigatorToParentButton,
|
|
23
|
-
useNavigator,
|
|
24
|
-
} from '..';
|
|
17
|
+
import { Navigator, useNavigator } from '..';
|
|
18
|
+
import { NavigatorToParentButton } from '../legacy';
|
|
25
19
|
import type { NavigateOptions } from '../types';
|
|
26
20
|
|
|
27
21
|
const INVALID_HTML_ATTRIBUTE = {
|
|
@@ -76,11 +70,11 @@ function CustomNavigatorButton( {
|
|
|
76
70
|
path,
|
|
77
71
|
onClick,
|
|
78
72
|
...props
|
|
79
|
-
}: Omit< ComponentPropsWithoutRef< typeof
|
|
73
|
+
}: Omit< ComponentPropsWithoutRef< typeof Navigator.Button >, 'onClick' > & {
|
|
80
74
|
onClick?: CustomTestOnClickHandler;
|
|
81
75
|
} ) {
|
|
82
76
|
return (
|
|
83
|
-
<
|
|
77
|
+
<Navigator.Button
|
|
84
78
|
onClick={ () => {
|
|
85
79
|
// Used to spy on the values passed to `navigator.goTo`.
|
|
86
80
|
onClick?.( { type: 'goTo', path } );
|
|
@@ -95,7 +89,7 @@ function CustomNavigatorGoToBackButton( {
|
|
|
95
89
|
path,
|
|
96
90
|
onClick,
|
|
97
91
|
...props
|
|
98
|
-
}: Omit< ComponentPropsWithoutRef< typeof
|
|
92
|
+
}: Omit< ComponentPropsWithoutRef< typeof Navigator.Button >, 'onClick' > & {
|
|
99
93
|
onClick?: CustomTestOnClickHandler;
|
|
100
94
|
} ) {
|
|
101
95
|
const { goTo } = useNavigator();
|
|
@@ -115,7 +109,7 @@ function CustomNavigatorGoToSkipFocusButton( {
|
|
|
115
109
|
path,
|
|
116
110
|
onClick,
|
|
117
111
|
...props
|
|
118
|
-
}: Omit< ComponentPropsWithoutRef< typeof
|
|
112
|
+
}: Omit< ComponentPropsWithoutRef< typeof Navigator.Button >, 'onClick' > & {
|
|
119
113
|
onClick?: CustomTestOnClickHandler;
|
|
120
114
|
} ) {
|
|
121
115
|
const { goTo } = useNavigator();
|
|
@@ -134,11 +128,14 @@ function CustomNavigatorGoToSkipFocusButton( {
|
|
|
134
128
|
function CustomNavigatorBackButton( {
|
|
135
129
|
onClick,
|
|
136
130
|
...props
|
|
137
|
-
}: Omit<
|
|
131
|
+
}: Omit<
|
|
132
|
+
ComponentPropsWithoutRef< typeof Navigator.BackButton >,
|
|
133
|
+
'onClick'
|
|
134
|
+
> & {
|
|
138
135
|
onClick?: CustomTestOnClickHandler;
|
|
139
136
|
} ) {
|
|
140
137
|
return (
|
|
141
|
-
<
|
|
138
|
+
<Navigator.BackButton
|
|
142
139
|
onClick={ () => {
|
|
143
140
|
// Used to spy on the values passed to `navigator.goBack`.
|
|
144
141
|
onClick?.( { type: 'goBack' } );
|
|
@@ -151,7 +148,10 @@ function CustomNavigatorBackButton( {
|
|
|
151
148
|
function CustomNavigatorToParentButton( {
|
|
152
149
|
onClick,
|
|
153
150
|
...props
|
|
154
|
-
}: Omit<
|
|
151
|
+
}: Omit<
|
|
152
|
+
ComponentPropsWithoutRef< typeof Navigator.BackButton >,
|
|
153
|
+
'onClick'
|
|
154
|
+
> & {
|
|
155
155
|
onClick?: CustomTestOnClickHandler;
|
|
156
156
|
} ) {
|
|
157
157
|
return (
|
|
@@ -194,13 +194,13 @@ const ProductScreen = ( {
|
|
|
194
194
|
const { params } = useNavigator();
|
|
195
195
|
|
|
196
196
|
return (
|
|
197
|
-
<
|
|
197
|
+
<Navigator.Screen path={ PATHS.PRODUCT_PATTERN }>
|
|
198
198
|
<p>{ SCREEN_TEXT.product }</p>
|
|
199
199
|
<p>Product ID is { params.productId }</p>
|
|
200
200
|
<CustomNavigatorBackButton onClick={ onBackButtonClick }>
|
|
201
201
|
{ BUTTON_TEXT.back }
|
|
202
202
|
</CustomNavigatorBackButton>
|
|
203
|
-
</
|
|
203
|
+
</Navigator.Screen>
|
|
204
204
|
);
|
|
205
205
|
};
|
|
206
206
|
|
|
@@ -215,8 +215,8 @@ const MyNavigation = ( {
|
|
|
215
215
|
const [ outerInputValue, setOuterInputValue ] = useState( '' );
|
|
216
216
|
return (
|
|
217
217
|
<>
|
|
218
|
-
<
|
|
219
|
-
<
|
|
218
|
+
<Navigator initialPath={ initialPath }>
|
|
219
|
+
<Navigator.Screen path={ PATHS.HOME }>
|
|
220
220
|
<p>{ SCREEN_TEXT.home }</p>
|
|
221
221
|
{ /*
|
|
222
222
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -254,9 +254,9 @@ const MyNavigation = ( {
|
|
|
254
254
|
>
|
|
255
255
|
{ BUTTON_TEXT.toInvalidHtmlPathScreen }
|
|
256
256
|
</CustomNavigatorButton>
|
|
257
|
-
</
|
|
257
|
+
</Navigator.Screen>
|
|
258
258
|
|
|
259
|
-
<
|
|
259
|
+
<Navigator.Screen path={ PATHS.CHILD }>
|
|
260
260
|
<p>{ SCREEN_TEXT.child }</p>
|
|
261
261
|
{ /*
|
|
262
262
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -286,30 +286,30 @@ const MyNavigation = ( {
|
|
|
286
286
|
} }
|
|
287
287
|
value={ innerInputValue }
|
|
288
288
|
/>
|
|
289
|
-
</
|
|
289
|
+
</Navigator.Screen>
|
|
290
290
|
|
|
291
|
-
<
|
|
291
|
+
<Navigator.Screen path={ PATHS.NESTED }>
|
|
292
292
|
<p>{ SCREEN_TEXT.nested }</p>
|
|
293
293
|
<CustomNavigatorBackButton
|
|
294
294
|
onClick={ onNavigatorButtonClick }
|
|
295
295
|
>
|
|
296
296
|
{ BUTTON_TEXT.back }
|
|
297
297
|
</CustomNavigatorBackButton>
|
|
298
|
-
</
|
|
298
|
+
</Navigator.Screen>
|
|
299
299
|
|
|
300
300
|
<ProductScreen onBackButtonClick={ onNavigatorButtonClick } />
|
|
301
301
|
|
|
302
|
-
<
|
|
302
|
+
<Navigator.Screen path={ PATHS.INVALID_HTML_ATTRIBUTE }>
|
|
303
303
|
<p>{ SCREEN_TEXT.invalidHtmlPath }</p>
|
|
304
304
|
<CustomNavigatorBackButton
|
|
305
305
|
onClick={ onNavigatorButtonClick }
|
|
306
306
|
>
|
|
307
307
|
{ BUTTON_TEXT.back }
|
|
308
308
|
</CustomNavigatorBackButton>
|
|
309
|
-
</
|
|
309
|
+
</Navigator.Screen>
|
|
310
310
|
|
|
311
|
-
{ /* A `
|
|
312
|
-
</
|
|
311
|
+
{ /* A `Navigator.Screen` with `path={ PATHS.NOT_FOUND }` is purposefully not included. */ }
|
|
312
|
+
</Navigator>
|
|
313
313
|
|
|
314
314
|
<label htmlFor="test-input-outer">Outer input</label>
|
|
315
315
|
<input
|
|
@@ -334,8 +334,8 @@ const MyHierarchicalNavigation = ( {
|
|
|
334
334
|
} ) => {
|
|
335
335
|
return (
|
|
336
336
|
<>
|
|
337
|
-
<
|
|
338
|
-
<
|
|
337
|
+
<Navigator initialPath={ initialPath }>
|
|
338
|
+
<Navigator.Screen path={ PATHS.HOME }>
|
|
339
339
|
<p>{ SCREEN_TEXT.home }</p>
|
|
340
340
|
{ /*
|
|
341
341
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -349,9 +349,9 @@ const MyHierarchicalNavigation = ( {
|
|
|
349
349
|
>
|
|
350
350
|
{ BUTTON_TEXT.toChildScreen }
|
|
351
351
|
</CustomNavigatorButton>
|
|
352
|
-
</
|
|
352
|
+
</Navigator.Screen>
|
|
353
353
|
|
|
354
|
-
<
|
|
354
|
+
<Navigator.Screen path={ PATHS.CHILD }>
|
|
355
355
|
<p>{ SCREEN_TEXT.child }</p>
|
|
356
356
|
{ /*
|
|
357
357
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -370,9 +370,9 @@ const MyHierarchicalNavigation = ( {
|
|
|
370
370
|
>
|
|
371
371
|
{ BUTTON_TEXT.back }
|
|
372
372
|
</CustomNavigatorBackButton>
|
|
373
|
-
</
|
|
373
|
+
</Navigator.Screen>
|
|
374
374
|
|
|
375
|
-
<
|
|
375
|
+
<Navigator.Screen path={ PATHS.NESTED }>
|
|
376
376
|
<p>{ SCREEN_TEXT.nested }</p>
|
|
377
377
|
<CustomNavigatorBackButton
|
|
378
378
|
onClick={ onNavigatorButtonClick }
|
|
@@ -385,14 +385,14 @@ const MyHierarchicalNavigation = ( {
|
|
|
385
385
|
>
|
|
386
386
|
{ BUTTON_TEXT.backUsingGoTo }
|
|
387
387
|
</CustomNavigatorGoToBackButton>
|
|
388
|
-
</
|
|
388
|
+
</Navigator.Screen>
|
|
389
389
|
<CustomNavigatorGoToSkipFocusButton
|
|
390
390
|
path={ PATHS.NESTED }
|
|
391
391
|
onClick={ onNavigatorButtonClick }
|
|
392
392
|
>
|
|
393
393
|
{ BUTTON_TEXT.goToWithSkipFocus }
|
|
394
394
|
</CustomNavigatorGoToSkipFocusButton>
|
|
395
|
-
</
|
|
395
|
+
</Navigator>
|
|
396
396
|
</>
|
|
397
397
|
);
|
|
398
398
|
};
|
|
@@ -406,8 +406,8 @@ const MyDeprecatedNavigation = ( {
|
|
|
406
406
|
} ) => {
|
|
407
407
|
return (
|
|
408
408
|
<>
|
|
409
|
-
<
|
|
410
|
-
<
|
|
409
|
+
<Navigator initialPath={ initialPath }>
|
|
410
|
+
<Navigator.Screen path={ PATHS.HOME }>
|
|
411
411
|
<p>{ SCREEN_TEXT.home }</p>
|
|
412
412
|
{ /*
|
|
413
413
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -421,9 +421,9 @@ const MyDeprecatedNavigation = ( {
|
|
|
421
421
|
>
|
|
422
422
|
{ BUTTON_TEXT.toChildScreen }
|
|
423
423
|
</CustomNavigatorButton>
|
|
424
|
-
</
|
|
424
|
+
</Navigator.Screen>
|
|
425
425
|
|
|
426
|
-
<
|
|
426
|
+
<Navigator.Screen path={ PATHS.CHILD }>
|
|
427
427
|
<p>{ SCREEN_TEXT.child }</p>
|
|
428
428
|
{ /*
|
|
429
429
|
* A button useful to test focus restoration. This button is the first
|
|
@@ -442,17 +442,17 @@ const MyDeprecatedNavigation = ( {
|
|
|
442
442
|
>
|
|
443
443
|
{ BUTTON_TEXT.back }
|
|
444
444
|
</CustomNavigatorToParentButton>
|
|
445
|
-
</
|
|
445
|
+
</Navigator.Screen>
|
|
446
446
|
|
|
447
|
-
<
|
|
447
|
+
<Navigator.Screen path={ PATHS.NESTED }>
|
|
448
448
|
<p>{ SCREEN_TEXT.nested }</p>
|
|
449
449
|
<CustomNavigatorToParentButtonAlternative
|
|
450
450
|
onClick={ onNavigatorButtonClick }
|
|
451
451
|
>
|
|
452
452
|
{ BUTTON_TEXT.back }
|
|
453
453
|
</CustomNavigatorToParentButtonAlternative>
|
|
454
|
-
</
|
|
455
|
-
</
|
|
454
|
+
</Navigator.Screen>
|
|
455
|
+
</Navigator>
|
|
456
456
|
</>
|
|
457
457
|
);
|
|
458
458
|
};
|
|
@@ -643,10 +643,10 @@ describe( 'Navigator', () => {
|
|
|
643
643
|
} );
|
|
644
644
|
|
|
645
645
|
it( 'should warn if the `path` prop does not follow the required format', () => {
|
|
646
|
-
render( <
|
|
646
|
+
render( <Navigator.Screen path="not-valid">Test</Navigator.Screen> );
|
|
647
647
|
|
|
648
648
|
expect( console ).toHaveWarnedWith(
|
|
649
|
-
'wp.components.
|
|
649
|
+
'wp.components.Navigator.Screen: the `path` should follow a URL-like scheme; it should start with and be separated by the `/` character.'
|
|
650
650
|
);
|
|
651
651
|
} );
|
|
652
652
|
|
|
@@ -880,7 +880,7 @@ describe( 'Navigator', () => {
|
|
|
880
880
|
|
|
881
881
|
// Rendering `NavigatorToParentButton` logs a deprecation notice
|
|
882
882
|
expect( console ).toHaveWarnedWith(
|
|
883
|
-
'wp.components.NavigatorToParentButton is deprecated since version 6.7. Please use wp.components.
|
|
883
|
+
'wp.components.NavigatorToParentButton is deprecated since version 6.7. Please use wp.components.Navigator.BackButton instead.'
|
|
884
884
|
);
|
|
885
885
|
} );
|
|
886
886
|
|
package/src/navigator/types.ts
CHANGED
|
@@ -86,7 +86,7 @@ export type NavigatorContext = Navigator & {
|
|
|
86
86
|
match?: string;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
export type
|
|
89
|
+
export type NavigatorProps = {
|
|
90
90
|
/**
|
|
91
91
|
* The initial active path.
|
|
92
92
|
*/
|
|
@@ -100,6 +100,24 @@ export type NavigatorProviderProps = {
|
|
|
100
100
|
export type NavigatorScreenProps = {
|
|
101
101
|
/**
|
|
102
102
|
* The screen's path, matched against the current path stored in the navigator.
|
|
103
|
+
*
|
|
104
|
+
* `Navigator` assumes that screens are organized hierarchically according
|
|
105
|
+
* to their `path`, which should follow a URL-like scheme where each path
|
|
106
|
+
* segment starts with and is separated by the `/` character.
|
|
107
|
+
*
|
|
108
|
+
* `Navigator` will treat "back" navigations as going to the parent screen —
|
|
109
|
+
* it is, therefore, the responsibility of the consumer of the component to
|
|
110
|
+
* create the correct screen hierarchy.
|
|
111
|
+
*
|
|
112
|
+
* For example:
|
|
113
|
+
* - `/` is the root of all paths. There should always be a screen with
|
|
114
|
+
* `path="/"`;
|
|
115
|
+
* - `/parent/child` is a child of `/parent`;
|
|
116
|
+
* - `/parent/child/grand-child` is a child of `/parent/child`;
|
|
117
|
+
* - `/parent/:param` is a child of `/parent` as well;
|
|
118
|
+
* - if the current screen has a `path="/parent/child/grand-child"`, when
|
|
119
|
+
* going "back" `Navigator` will try to recursively navigate the path
|
|
120
|
+
* hierarchy until a matching screen (or the root `/`) is found.
|
|
103
121
|
*/
|
|
104
122
|
path: string;
|
|
105
123
|
/**
|
|
@@ -10,7 +10,10 @@ import { NavigatorContext } from './context';
|
|
|
10
10
|
import type { Navigator } from './types';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Retrieves a `navigator` instance.
|
|
13
|
+
* Retrieves a `navigator` instance. This hook provides advanced functionality,
|
|
14
|
+
* such as imperatively navigating to a new location (with options like
|
|
15
|
+
* navigating back or skipping focus restoration) and accessing the current
|
|
16
|
+
* location and path parameters.
|
|
14
17
|
*/
|
|
15
18
|
export function useNavigator(): Navigator {
|
|
16
19
|
const { location, params, goTo, goBack, goToParent } =
|
|
@@ -67,7 +67,7 @@ function UnforwardedSearchControl(
|
|
|
67
67
|
) {
|
|
68
68
|
// @ts-expect-error The `disabled` prop is not yet supported in the SearchControl component.
|
|
69
69
|
// Work with the design team (@WordPress/gutenberg-design) if you need this feature.
|
|
70
|
-
|
|
70
|
+
const { disabled, ...filteredRestProps } = restProps;
|
|
71
71
|
|
|
72
72
|
const searchRef = useRef< HTMLInputElement >( null );
|
|
73
73
|
const instanceId = useInstanceId(
|
|
@@ -117,7 +117,7 @@ function UnforwardedSearchControl(
|
|
|
117
117
|
/>
|
|
118
118
|
</SuffixItemWrapper>
|
|
119
119
|
}
|
|
120
|
-
{ ...
|
|
120
|
+
{ ...filteredRestProps }
|
|
121
121
|
/>
|
|
122
122
|
</ContextSystemProvider>
|
|
123
123
|
);
|
|
@@ -12,6 +12,7 @@ import { useState } from '@wordpress/element';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import SelectControl from '../';
|
|
15
|
+
import { InputControlPrefixWrapper } from '../../input-control/input-prefix-wrapper';
|
|
15
16
|
|
|
16
17
|
const meta: Meta< typeof SelectControl > = {
|
|
17
18
|
title: 'Components/SelectControl',
|
|
@@ -64,6 +65,7 @@ const SelectControlWithState: StoryFn< typeof SelectControl > = ( props ) => {
|
|
|
64
65
|
export const Default = SelectControlWithState.bind( {} );
|
|
65
66
|
Default.args = {
|
|
66
67
|
__nextHasNoMarginBottom: true,
|
|
68
|
+
label: 'Label',
|
|
67
69
|
options: [
|
|
68
70
|
{ value: '', label: 'Select an Option', disabled: true },
|
|
69
71
|
{ value: 'a', label: 'Option A' },
|
|
@@ -76,7 +78,6 @@ export const WithLabelAndHelpText = SelectControlWithState.bind( {} );
|
|
|
76
78
|
WithLabelAndHelpText.args = {
|
|
77
79
|
...Default.args,
|
|
78
80
|
help: 'Help text to explain the select control.',
|
|
79
|
-
label: 'Value',
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
/**
|
|
@@ -86,6 +87,7 @@ WithLabelAndHelpText.args = {
|
|
|
86
87
|
export const WithCustomChildren = SelectControlWithState.bind( {} );
|
|
87
88
|
WithCustomChildren.args = {
|
|
88
89
|
__nextHasNoMarginBottom: true,
|
|
90
|
+
label: 'Label',
|
|
89
91
|
children: (
|
|
90
92
|
<>
|
|
91
93
|
<option value="option-1">Option 1</option>
|
|
@@ -104,8 +106,19 @@ WithCustomChildren.args = {
|
|
|
104
106
|
),
|
|
105
107
|
};
|
|
106
108
|
|
|
109
|
+
/**
|
|
110
|
+
* By default, the prefix is aligned with the edge of the input border, with no padding.
|
|
111
|
+
* If you want to apply standard padding in accordance with the size variant, wrap the element in the `<InputControlPrefixWrapper>` component.
|
|
112
|
+
*/
|
|
113
|
+
export const WithPrefix = SelectControlWithState.bind( {} );
|
|
114
|
+
WithPrefix.args = {
|
|
115
|
+
...Default.args,
|
|
116
|
+
prefix: <InputControlPrefixWrapper>Prefix:</InputControlPrefixWrapper>,
|
|
117
|
+
};
|
|
118
|
+
|
|
107
119
|
export const Minimal = SelectControlWithState.bind( {} );
|
|
108
120
|
Minimal.args = {
|
|
109
121
|
...Default.args,
|
|
110
122
|
variant: 'minimal',
|
|
123
|
+
hideLabelFromVision: true,
|
|
111
124
|
};
|
|
@@ -70,6 +70,112 @@ const Template: StoryFn< typeof Tabs > = ( props ) => {
|
|
|
70
70
|
|
|
71
71
|
export const Default = Template.bind( {} );
|
|
72
72
|
|
|
73
|
+
export const SizeAndOverflowPlayground: StoryFn< typeof Tabs > = ( props ) => {
|
|
74
|
+
const [ fullWidth, setFullWidth ] = useState( false );
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
<div style={ { maxWidth: '40rem', marginBottom: '1rem' } }>
|
|
78
|
+
<p>
|
|
79
|
+
This story helps understand how the TabList component
|
|
80
|
+
behaves under different conditions. The container below
|
|
81
|
+
(with the dotted red border) can be horizontally resized,
|
|
82
|
+
and it has a bit of padding to be out of the way of the
|
|
83
|
+
TabList.
|
|
84
|
+
</p>
|
|
85
|
+
<p>
|
|
86
|
+
The button will toggle between full width (adding{ ' ' }
|
|
87
|
+
<code>width: 100%</code>) and the default width.
|
|
88
|
+
</p>
|
|
89
|
+
<p>Try the following:</p>
|
|
90
|
+
<ul>
|
|
91
|
+
<li>
|
|
92
|
+
<strong>Small container</strong> that causes tabs to
|
|
93
|
+
overflow with scroll.
|
|
94
|
+
</li>
|
|
95
|
+
<li>
|
|
96
|
+
<strong>Large container</strong> that exceeds the normal
|
|
97
|
+
width of the tabs.
|
|
98
|
+
<ul>
|
|
99
|
+
<li>
|
|
100
|
+
<strong>
|
|
101
|
+
With <code>width: 100%</code>
|
|
102
|
+
</strong>{ ' ' }
|
|
103
|
+
set on the TabList (tabs fill up the space).
|
|
104
|
+
</li>
|
|
105
|
+
<li>
|
|
106
|
+
<strong>
|
|
107
|
+
Without <code>width: 100%</code>
|
|
108
|
+
</strong>{ ' ' }
|
|
109
|
+
(defaults to <code>auto</code>) set on the
|
|
110
|
+
TabList (tabs take up space proportional to
|
|
111
|
+
their content).
|
|
112
|
+
</li>
|
|
113
|
+
</ul>
|
|
114
|
+
</li>
|
|
115
|
+
</ul>
|
|
116
|
+
</div>
|
|
117
|
+
<Button
|
|
118
|
+
style={ { marginBottom: '1rem' } }
|
|
119
|
+
variant="primary"
|
|
120
|
+
onClick={ () => setFullWidth( ! fullWidth ) }
|
|
121
|
+
>
|
|
122
|
+
{ fullWidth
|
|
123
|
+
? 'Remove width: 100% from TabList'
|
|
124
|
+
: 'Set width: 100% in TabList' }
|
|
125
|
+
</Button>
|
|
126
|
+
<Tabs { ...props }>
|
|
127
|
+
<div
|
|
128
|
+
style={ {
|
|
129
|
+
width: '20rem',
|
|
130
|
+
border: '2px dotted red',
|
|
131
|
+
padding: '1rem',
|
|
132
|
+
resize: 'horizontal',
|
|
133
|
+
overflow: 'auto',
|
|
134
|
+
} }
|
|
135
|
+
>
|
|
136
|
+
<Tabs.TabList
|
|
137
|
+
style={ {
|
|
138
|
+
maxWidth: '100%',
|
|
139
|
+
width: fullWidth ? '100%' : undefined,
|
|
140
|
+
} }
|
|
141
|
+
>
|
|
142
|
+
<Tabs.Tab tabId="tab1">
|
|
143
|
+
Label with multiple words
|
|
144
|
+
</Tabs.Tab>
|
|
145
|
+
<Tabs.Tab tabId="tab2">Short</Tabs.Tab>
|
|
146
|
+
<Tabs.Tab tabId="tab3">
|
|
147
|
+
Hippopotomonstrosesquippedaliophobia
|
|
148
|
+
</Tabs.Tab>
|
|
149
|
+
<Tabs.Tab tabId="tab4">Tab 4</Tabs.Tab>
|
|
150
|
+
<Tabs.Tab tabId="tab5">Tab 5</Tabs.Tab>
|
|
151
|
+
</Tabs.TabList>
|
|
152
|
+
</div>
|
|
153
|
+
<Tabs.TabPanel tabId="tab1">
|
|
154
|
+
<p>Selected tab: Tab 1</p>
|
|
155
|
+
<p>(Label with multiple words)</p>
|
|
156
|
+
</Tabs.TabPanel>
|
|
157
|
+
<Tabs.TabPanel tabId="tab2">
|
|
158
|
+
<p>Selected tab: Tab 2</p>
|
|
159
|
+
<p>(Short)</p>
|
|
160
|
+
</Tabs.TabPanel>
|
|
161
|
+
<Tabs.TabPanel tabId="tab3">
|
|
162
|
+
<p>Selected tab: Tab 3</p>
|
|
163
|
+
<p>(Hippopotomonstrosesquippedaliophobia)</p>
|
|
164
|
+
</Tabs.TabPanel>
|
|
165
|
+
<Tabs.TabPanel tabId="tab4">
|
|
166
|
+
<p>Selected tab: Tab 4</p>
|
|
167
|
+
</Tabs.TabPanel>
|
|
168
|
+
<Tabs.TabPanel tabId="tab5">
|
|
169
|
+
<p>Selected tab: Tab 5</p>
|
|
170
|
+
</Tabs.TabPanel>
|
|
171
|
+
</Tabs>
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
};
|
|
175
|
+
SizeAndOverflowPlayground.args = {
|
|
176
|
+
defaultTabId: 'tab4',
|
|
177
|
+
};
|
|
178
|
+
|
|
73
179
|
const VerticalTemplate: StoryFn< typeof Tabs > = ( props ) => {
|
|
74
180
|
return (
|
|
75
181
|
<Tabs orientation="vertical" { ...props }>
|