@wordpress/components 33.1.1-next.v.202605131006.0 → 34.0.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 +30 -1
- package/build/autocomplete/index.cjs +5 -4
- package/build/autocomplete/index.cjs.map +3 -3
- package/build/border-control/border-control-dropdown/component.cjs +33 -33
- package/build/border-control/border-control-dropdown/component.cjs.map +3 -3
- package/build/box-control/index.cjs +0 -6
- package/build/box-control/index.cjs.map +2 -2
- package/build/box-control/utils.cjs +0 -38
- package/build/box-control/utils.cjs.map +3 -3
- package/build/custom-gradient-picker/gradient-bar/index.cjs.map +2 -2
- package/build/disabled/index.cjs +1 -1
- package/build/disabled/index.cjs.map +2 -2
- package/build/draggable/index.cjs +101 -7
- package/build/draggable/index.cjs.map +3 -3
- package/build/form-token-field/index.cjs +41 -7
- package/build/form-token-field/index.cjs.map +2 -2
- package/build/higher-order/with-notices/index.cjs +3 -15
- package/build/higher-order/with-notices/index.cjs.map +2 -2
- package/build/index.cjs +0 -17
- package/build/index.cjs.map +2 -2
- package/build/input-control/input-base.cjs +31 -34
- package/build/input-control/input-base.cjs.map +2 -2
- package/build/notice/index.cjs +33 -35
- package/build/notice/index.cjs.map +2 -2
- package/build/popover/index.cjs +12 -0
- package/build/popover/index.cjs.map +2 -2
- package/build/responsive-wrapper/index.cjs +4 -3
- package/build/responsive-wrapper/index.cjs.map +2 -2
- package/build/tabs/styles.cjs +5 -5
- package/build/tabs/styles.cjs.map +2 -2
- package/build/tooltip/index.cjs +2 -1
- package/build/tooltip/index.cjs.map +2 -2
- package/build-module/autocomplete/index.mjs +6 -5
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/border-control/border-control-dropdown/component.mjs +34 -34
- package/build-module/border-control/border-control-dropdown/component.mjs.map +2 -2
- package/build-module/box-control/index.mjs +0 -2
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/box-control/utils.mjs +0 -27
- package/build-module/box-control/utils.mjs.map +2 -2
- package/build-module/custom-gradient-picker/gradient-bar/index.mjs.map +2 -2
- package/build-module/disabled/index.mjs +1 -1
- package/build-module/disabled/index.mjs.map +2 -2
- package/build-module/draggable/index.mjs +101 -7
- package/build-module/draggable/index.mjs.map +3 -3
- package/build-module/form-token-field/index.mjs +41 -7
- package/build-module/form-token-field/index.mjs.map +2 -2
- package/build-module/higher-order/with-notices/index.mjs +4 -16
- package/build-module/higher-order/with-notices/index.mjs.map +2 -2
- package/build-module/index.mjs +87 -99
- package/build-module/index.mjs.map +2 -2
- package/build-module/input-control/input-base.mjs +31 -34
- package/build-module/input-control/input-base.mjs.map +2 -2
- package/build-module/notice/index.mjs +34 -36
- package/build-module/notice/index.mjs.map +2 -2
- package/build-module/popover/index.mjs +12 -0
- package/build-module/popover/index.mjs.map +2 -2
- package/build-module/responsive-wrapper/index.mjs +4 -3
- package/build-module/responsive-wrapper/index.mjs.map +2 -2
- package/build-module/tabs/styles.mjs +5 -5
- package/build-module/tabs/styles.mjs.map +2 -2
- package/build-module/tooltip/index.mjs +2 -1
- package/build-module/tooltip/index.mjs.map +2 -2
- package/build-style/style-rtl.css +64 -66
- package/build-style/style.css +64 -66
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/badge/stories/e2e/index.story.d.ts +7 -0
- package/build-types/badge/stories/e2e/index.story.d.ts.map +1 -0
- package/build-types/border-box-control/border-box-control/hook.d.ts +24 -10
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +26 -12
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +24 -10
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +25 -11
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +24 -10
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +23 -9
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +0 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +3 -4
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +0 -13
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts +1 -0
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +25 -11
- package/build-types/card/card/hook.d.ts.map +1 -1
- package/build-types/card/card-body/hook.d.ts +25 -11
- package/build-types/card/card-body/hook.d.ts.map +1 -1
- package/build-types/card/card-divider/hook.d.ts +26 -12
- package/build-types/card/card-divider/hook.d.ts.map +1 -1
- package/build-types/card/card-footer/hook.d.ts +25 -11
- package/build-types/card/card-footer/hook.d.ts.map +1 -1
- package/build-types/card/card-header/hook.d.ts +25 -11
- package/build-types/card/card-header/hook.d.ts.map +1 -1
- package/build-types/card/card-media/hook.d.ts +25 -11
- package/build-types/card/card-media/hook.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -4
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/styles.d.ts +4 -12
- package/build-types/custom-select-control-v2/styles.d.ts.map +1 -1
- package/build-types/date-time/time-picker/styles.d.ts +4 -4
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/draggable/stories/index.story.d.ts +4 -5
- package/build-types/draggable/stories/index.story.d.ts.map +1 -1
- package/build-types/draggable/types.d.ts +4 -0
- package/build-types/draggable/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +25 -11
- package/build-types/elevation/hook.d.ts.map +1 -1
- package/build-types/flex/flex/hook.d.ts +25 -11
- package/build-types/flex/flex/hook.d.ts.map +1 -1
- package/build-types/flex/flex-block/hook.d.ts +25 -11
- package/build-types/flex/flex-block/hook.d.ts.map +1 -1
- package/build-types/flex/flex-item/hook.d.ts +25 -11
- package/build-types/flex/flex-item/hook.d.ts.map +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +25 -11
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/h-stack/hook.d.ts +25 -11
- package/build-types/h-stack/hook.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts +25 -11
- package/build-types/heading/hook.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/index.d.ts +1 -3
- package/build-types/higher-order/with-filters/index.d.ts +1 -6
- package/build-types/higher-order/with-filters/index.d.ts.map +1 -1
- package/build-types/higher-order/with-notices/index.d.ts +2 -4
- package/build-types/higher-order/with-notices/index.d.ts.map +1 -1
- package/build-types/icon/stories/index.story.d.ts +0 -6
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -6
- package/build-types/index.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +1 -1
- package/build-types/item-group/item/hook.d.ts +25 -11
- package/build-types/item-group/item/hook.d.ts.map +1 -1
- package/build-types/item-group/item-group/hook.d.ts +25 -11
- package/build-types/item-group/item-group/hook.d.ts.map +1 -1
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu/styles.d.ts +7 -21
- package/build-types/menu/styles.d.ts.map +1 -1
- package/build-types/modal/use-modal-exit-animation.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +26 -12
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +26 -12
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/types.d.ts +1 -2
- package/build-types/notice/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -1
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +2 -2
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +2 -3
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/stories/index.story.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -1
- package/build-types/range-control/types.d.ts +1 -5
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/responsive-wrapper/index.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +25 -11
- package/build-types/scrollable/hook.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +2 -2
- package/build-types/snackbar/types.d.ts +2 -2
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +25 -11
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/surface/hook.d.ts +25 -11
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts +0 -6
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +0 -6
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts +3 -9
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/text/hook.d.ts +25 -11
- package/build-types/text/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +25 -11
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +25 -11
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +25 -11
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +25 -11
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/utils/get-node-text.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +25 -11
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts +4 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +27 -25
- package/src/autocomplete/README.md +1 -1
- package/src/autocomplete/index.tsx +25 -7
- package/src/badge/stories/e2e/index.story.tsx +21 -0
- package/src/border-control/border-control-dropdown/component.tsx +36 -37
- package/src/box-control/index.tsx +0 -1
- package/src/box-control/utils.ts +0 -43
- package/src/button/stories/e2e/index.story.tsx +11 -0
- package/src/composite/stories/index.story.tsx +0 -1
- package/src/custom-gradient-picker/gradient-bar/index.tsx +1 -1
- package/src/disabled/index.tsx +1 -1
- package/src/draggable/index.tsx +32 -10
- package/src/draggable/stories/index.story.tsx +11 -6
- package/src/draggable/style.module.scss +29 -0
- package/src/draggable/types.ts +4 -0
- package/src/form-file-upload/README.md +1 -1
- package/src/form-token-field/index.tsx +84 -8
- package/src/form-token-field/test/index.tsx +189 -0
- package/src/h-stack/hook.tsx +1 -1
- package/src/higher-order/with-notices/index.tsx +4 -21
- package/src/higher-order/with-notices/test/index.tsx +0 -18
- package/src/icon/stories/index.story.tsx +2 -14
- package/src/index.ts +0 -6
- package/src/input-control/input-base.tsx +2 -2
- package/src/menu/README.md +7 -7
- package/src/menu/stories/index.story.tsx +0 -1
- package/src/menu/test/index.tsx +9 -4
- package/src/modal/style.scss +2 -1
- package/src/notice/README.md +1 -2
- package/src/notice/index.tsx +57 -64
- package/src/notice/style.scss +49 -41
- package/src/notice/test/__snapshots__/index.tsx.snap +23 -23
- package/src/notice/test/index.tsx +5 -5
- package/src/notice/types.ts +1 -2
- package/src/popover/index.tsx +29 -1
- package/src/popover/test/index.tsx +138 -1
- package/src/popover/types.ts +2 -4
- package/src/range-control/stories/index.story.tsx +0 -1
- package/src/range-control/types.ts +1 -5
- package/src/responsive-wrapper/index.tsx +7 -3
- package/src/snackbar/README.md +1 -1
- package/src/snackbar/types.ts +2 -2
- package/src/style.scss +0 -1
- package/src/tab-panel/stories/index.story.tsx +2 -13
- package/src/tab-panel/style.scss +36 -14
- package/src/tabs/README.md +1 -1
- package/src/tabs/stories/index.story.tsx +2 -14
- package/src/tabs/styles.ts +3 -8
- package/src/tabs/tablist.tsx +1 -1
- package/src/tooltip/index.tsx +7 -1
- package/src/tree-grid/test/cell.tsx +0 -1
- package/src/tree-grid/test/roving-tab-index-item.tsx +0 -1
- package/src/tree-select/README.md +1 -1
- package/src/utils/get-node-text.ts +7 -1
- package/src/validated-form-controls/control-with-error.tsx +6 -1
- package/build/navigation/back-button/index.cjs +0 -86
- package/build/navigation/back-button/index.cjs.map +0 -7
- package/build/navigation/constants.cjs +0 -34
- package/build/navigation/constants.cjs.map +0 -7
- package/build/navigation/context.cjs +0 -58
- package/build/navigation/context.cjs.map +0 -7
- package/build/navigation/group/context.cjs +0 -38
- package/build/navigation/group/context.cjs.map +0 -7
- package/build/navigation/group/index.cjs +0 -88
- package/build/navigation/group/index.cjs.map +0 -7
- package/build/navigation/index.cjs +0 -113
- package/build/navigation/index.cjs.map +0 -7
- package/build/navigation/item/base-content.cjs +0 -44
- package/build/navigation/item/base-content.cjs.map +0 -7
- package/build/navigation/item/base.cjs +0 -66
- package/build/navigation/item/base.cjs.map +0 -7
- package/build/navigation/item/index.cjs +0 -119
- package/build/navigation/item/index.cjs.map +0 -7
- package/build/navigation/item/use-navigation-tree-item.cjs +0 -64
- package/build/navigation/item/use-navigation-tree-item.cjs.map +0 -7
- package/build/navigation/menu/context.cjs +0 -39
- package/build/navigation/menu/context.cjs.map +0 -7
- package/build/navigation/menu/index.cjs +0 -114
- package/build/navigation/menu/index.cjs.map +0 -7
- package/build/navigation/menu/menu-title-search.cjs +0 -111
- package/build/navigation/menu/menu-title-search.cjs.map +0 -7
- package/build/navigation/menu/menu-title.cjs +0 -104
- package/build/navigation/menu/menu-title.cjs.map +0 -7
- package/build/navigation/menu/search-no-results-found.cjs +0 -48
- package/build/navigation/menu/search-no-results-found.cjs.map +0 -7
- package/build/navigation/menu/use-navigation-tree-menu.cjs +0 -51
- package/build/navigation/menu/use-navigation-tree-menu.cjs.map +0 -7
- package/build/navigation/styles/navigation-styles.cjs +0 -170
- package/build/navigation/styles/navigation-styles.cjs.map +0 -7
- package/build/navigation/types.cjs +0 -19
- package/build/navigation/types.cjs.map +0 -7
- package/build/navigation/use-create-navigation-tree.cjs +0 -103
- package/build/navigation/use-create-navigation-tree.cjs.map +0 -7
- package/build/navigation/use-navigation-tree-nodes.cjs +0 -60
- package/build/navigation/use-navigation-tree-nodes.cjs.map +0 -7
- package/build/navigation/utils.cjs +0 -45
- package/build/navigation/utils.cjs.map +0 -7
- package/build-module/navigation/back-button/index.mjs +0 -51
- package/build-module/navigation/back-button/index.mjs.map +0 -7
- package/build-module/navigation/constants.mjs +0 -8
- package/build-module/navigation/constants.mjs.map +0 -7
- package/build-module/navigation/context.mjs +0 -32
- package/build-module/navigation/context.mjs.map +0 -7
- package/build-module/navigation/group/context.mjs +0 -12
- package/build-module/navigation/group/context.mjs.map +0 -7
- package/build-module/navigation/group/index.mjs +0 -53
- package/build-module/navigation/group/index.mjs.map +0 -7
- package/build-module/navigation/index.mjs +0 -78
- package/build-module/navigation/index.mjs.map +0 -7
- package/build-module/navigation/item/base-content.mjs +0 -23
- package/build-module/navigation/item/base-content.mjs.map +0 -7
- package/build-module/navigation/item/base.mjs +0 -35
- package/build-module/navigation/item/base.mjs.map +0 -7
- package/build-module/navigation/item/index.mjs +0 -84
- package/build-module/navigation/item/index.mjs.map +0 -7
- package/build-module/navigation/item/use-navigation-tree-item.mjs +0 -39
- package/build-module/navigation/item/use-navigation-tree-item.mjs.map +0 -7
- package/build-module/navigation/menu/context.mjs +0 -13
- package/build-module/navigation/menu/context.mjs.map +0 -7
- package/build-module/navigation/menu/index.mjs +0 -79
- package/build-module/navigation/menu/index.mjs.map +0 -7
- package/build-module/navigation/menu/menu-title-search.mjs +0 -80
- package/build-module/navigation/menu/menu-title-search.mjs.map +0 -7
- package/build-module/navigation/menu/menu-title.mjs +0 -73
- package/build-module/navigation/menu/menu-title.mjs.map +0 -7
- package/build-module/navigation/menu/search-no-results-found.mjs +0 -27
- package/build-module/navigation/menu/search-no-results-found.mjs.map +0 -7
- package/build-module/navigation/menu/use-navigation-tree-menu.mjs +0 -26
- package/build-module/navigation/menu/use-navigation-tree-menu.mjs.map +0 -7
- package/build-module/navigation/styles/navigation-styles.mjs +0 -124
- package/build-module/navigation/styles/navigation-styles.mjs.map +0 -7
- package/build-module/navigation/types.mjs +0 -1
- package/build-module/navigation/types.mjs.map +0 -7
- package/build-module/navigation/use-create-navigation-tree.mjs +0 -78
- package/build-module/navigation/use-create-navigation-tree.mjs.map +0 -7
- package/build-module/navigation/use-navigation-tree-nodes.mjs +0 -35
- package/build-module/navigation/use-navigation-tree-nodes.mjs.map +0 -7
- package/build-module/navigation/utils.mjs +0 -9
- package/build-module/navigation/utils.mjs.map +0 -7
- package/build-types/navigation/back-button/index.d.ts +0 -7
- package/build-types/navigation/back-button/index.d.ts.map +0 -1
- package/build-types/navigation/constants.d.ts +0 -3
- package/build-types/navigation/constants.d.ts.map +0 -1
- package/build-types/navigation/context.d.ts +0 -4
- package/build-types/navigation/context.d.ts.map +0 -1
- package/build-types/navigation/group/context.d.ts +0 -7
- package/build-types/navigation/group/context.d.ts.map +0 -1
- package/build-types/navigation/group/index.d.ts +0 -7
- package/build-types/navigation/group/index.d.ts.map +0 -1
- package/build-types/navigation/index.d.ts +0 -46
- package/build-types/navigation/index.d.ts.map +0 -1
- package/build-types/navigation/item/base-content.d.ts +0 -3
- package/build-types/navigation/item/base-content.d.ts.map +0 -1
- package/build-types/navigation/item/base.d.ts +0 -3
- package/build-types/navigation/item/base.d.ts.map +0 -1
- package/build-types/navigation/item/index.d.ts +0 -7
- package/build-types/navigation/item/index.d.ts.map +0 -1
- package/build-types/navigation/item/use-navigation-tree-item.d.ts +0 -3
- package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +0 -1
- package/build-types/navigation/menu/context.d.ts +0 -7
- package/build-types/navigation/menu/context.d.ts.map +0 -1
- package/build-types/navigation/menu/index.d.ts +0 -7
- package/build-types/navigation/menu/index.d.ts.map +0 -1
- package/build-types/navigation/menu/menu-title-search.d.ts +0 -3
- package/build-types/navigation/menu/menu-title-search.d.ts.map +0 -1
- package/build-types/navigation/menu/menu-title.d.ts +0 -3
- package/build-types/navigation/menu/menu-title.d.ts.map +0 -1
- package/build-types/navigation/menu/search-no-results-found.d.ts +0 -3
- package/build-types/navigation/menu/search-no-results-found.d.ts.map +0 -1
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +0 -3
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +0 -1
- package/build-types/navigation/stories/index.story.d.ts +0 -23
- package/build-types/navigation/stories/index.story.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/controlled-state.d.ts +0 -7
- package/build-types/navigation/stories/utils/controlled-state.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/default.d.ts +0 -10
- package/build-types/navigation/stories/utils/default.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/group.d.ts +0 -10
- package/build-types/navigation/stories/utils/group.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts +0 -10
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/more-examples.d.ts +0 -10
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +0 -1
- package/build-types/navigation/stories/utils/search.d.ts +0 -10
- package/build-types/navigation/stories/utils/search.d.ts.map +0 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +0 -55
- package/build-types/navigation/styles/navigation-styles.d.ts.map +0 -1
- package/build-types/navigation/test/index.d.ts +0 -2
- package/build-types/navigation/test/index.d.ts.map +0 -1
- package/build-types/navigation/types.d.ts +0 -266
- package/build-types/navigation/types.d.ts.map +0 -1
- package/build-types/navigation/use-create-navigation-tree.d.ts +0 -15
- package/build-types/navigation/use-create-navigation-tree.d.ts.map +0 -1
- package/build-types/navigation/use-navigation-tree-nodes.d.ts +0 -10
- package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +0 -1
- package/build-types/navigation/utils.d.ts +0 -3
- package/build-types/navigation/utils.d.ts.map +0 -1
- package/src/draggable/style.scss +0 -21
- package/src/navigation/README.md +0 -267
- package/src/navigation/back-button/index.tsx +0 -73
- package/src/navigation/constants.tsx +0 -2
- package/src/navigation/context.tsx +0 -40
- package/src/navigation/group/context.tsx +0 -16
- package/src/navigation/group/index.tsx +0 -73
- package/src/navigation/index.tsx +0 -152
- package/src/navigation/item/base-content.tsx +0 -31
- package/src/navigation/item/base.tsx +0 -42
- package/src/navigation/item/index.tsx +0 -112
- package/src/navigation/item/use-navigation-tree-item.tsx +0 -47
- package/src/navigation/menu/context.tsx +0 -20
- package/src/navigation/menu/index.tsx +0 -105
- package/src/navigation/menu/menu-title-search.tsx +0 -99
- package/src/navigation/menu/menu-title.tsx +0 -100
- package/src/navigation/menu/search-no-results-found.tsx +0 -34
- package/src/navigation/menu/use-navigation-tree-menu.tsx +0 -29
- package/src/navigation/stories/index.story.tsx +0 -62
- package/src/navigation/stories/style.css +0 -25
- package/src/navigation/stories/utils/controlled-state.tsx +0 -149
- package/src/navigation/stories/utils/default.tsx +0 -92
- package/src/navigation/stories/utils/group.tsx +0 -61
- package/src/navigation/stories/utils/hide-if-empty.tsx +0 -66
- package/src/navigation/stories/utils/more-examples.tsx +0 -162
- package/src/navigation/stories/utils/search.tsx +0 -91
- package/src/navigation/styles/navigation-styles.tsx +0 -197
- package/src/navigation/test/index.tsx +0 -347
- package/src/navigation/types.ts +0 -325
- package/src/navigation/use-create-navigation-tree.tsx +0 -110
- package/src/navigation/use-navigation-tree-nodes.tsx +0 -31
- package/src/navigation/utils.tsx +0 -11
package/src/draggable/index.tsx
CHANGED
|
@@ -8,16 +8,28 @@ import type { DragEvent } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
import { throttle } from '@wordpress/compose';
|
|
10
10
|
import { useEffect, useRef } from '@wordpress/element';
|
|
11
|
+
import { getWpCompatOverlaySlot } from '@wordpress/ui';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
14
15
|
*/
|
|
15
16
|
import type { DraggableProps } from './types';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
import styles from './style.module.scss';
|
|
18
|
+
|
|
19
|
+
// Legacy class names preserved alongside the CSS-module hashed ones for
|
|
20
|
+
// backwards compatibility. `filter(Boolean)` strips `undefined` from Jest's
|
|
21
|
+
// CSS-module mock.
|
|
22
|
+
const dragImageClasses = [
|
|
23
|
+
styles[ 'invisible-drag-image' ],
|
|
24
|
+
'components-draggable__invisible-drag-image',
|
|
25
|
+
].filter( Boolean );
|
|
26
|
+
const cloneWrapperClasses = [
|
|
27
|
+
styles.clone,
|
|
28
|
+
'components-draggable__clone',
|
|
29
|
+
].filter( Boolean );
|
|
30
|
+
// Global class — shared with external code (e.g. block-editor keyboard drag).
|
|
20
31
|
const bodyClass = 'is-dragging-components-draggable';
|
|
32
|
+
const clonePadding = 0;
|
|
21
33
|
|
|
22
34
|
/**
|
|
23
35
|
* `Draggable` is a Component that provides a way to set up a cross-browser
|
|
@@ -99,6 +111,10 @@ export function Draggable( {
|
|
|
99
111
|
*/
|
|
100
112
|
function start( event: DragEvent ) {
|
|
101
113
|
const { ownerDocument } = event.target as HTMLElement;
|
|
114
|
+
// Only use the slot when it lives in the same document as the
|
|
115
|
+
// dragged element, so coordinate resolution stays in one space.
|
|
116
|
+
const slot = getWpCompatOverlaySlot();
|
|
117
|
+
const compatSlot = slot?.ownerDocument === ownerDocument ? slot : null;
|
|
102
118
|
|
|
103
119
|
event.dataTransfer.setData(
|
|
104
120
|
transferDataType,
|
|
@@ -116,12 +132,18 @@ export function Draggable( {
|
|
|
116
132
|
// right after. event.dataTransfer.setDragImage is not supported yet in
|
|
117
133
|
// IE, we need to check for its existence first.
|
|
118
134
|
if ( 'function' === typeof event.dataTransfer.setDragImage ) {
|
|
119
|
-
dragImage.classList.add(
|
|
135
|
+
dragImage.classList.add( ...dragImageClasses );
|
|
136
|
+
// Invisible — stays at the document body, no slot needed.
|
|
120
137
|
ownerDocument.body.appendChild( dragImage );
|
|
121
138
|
event.dataTransfer.setDragImage( dragImage, 0, 0 );
|
|
122
139
|
}
|
|
123
140
|
|
|
124
|
-
cloneWrapper.classList.add(
|
|
141
|
+
cloneWrapper.classList.add( ...cloneWrapperClasses );
|
|
142
|
+
|
|
143
|
+
const inSlotClass = styles[ 'is-in-compat-slot' ];
|
|
144
|
+
if ( compatSlot && inSlotClass ) {
|
|
145
|
+
cloneWrapper.classList.add( inSlotClass );
|
|
146
|
+
}
|
|
125
147
|
|
|
126
148
|
if ( cloneClassname ) {
|
|
127
149
|
cloneWrapper.classList.add( cloneClassname );
|
|
@@ -141,8 +163,7 @@ export function Draggable( {
|
|
|
141
163
|
clonedDragComponent.innerHTML = dragComponentRef.current.innerHTML;
|
|
142
164
|
cloneWrapper.appendChild( clonedDragComponent );
|
|
143
165
|
|
|
144
|
-
|
|
145
|
-
ownerDocument.body.appendChild( cloneWrapper );
|
|
166
|
+
( compatSlot ?? ownerDocument.body ).appendChild( cloneWrapper );
|
|
146
167
|
} else {
|
|
147
168
|
const element = ownerDocument.getElementById(
|
|
148
169
|
elementId
|
|
@@ -173,8 +194,9 @@ export function Draggable( {
|
|
|
173
194
|
|
|
174
195
|
cloneWrapper.appendChild( clone );
|
|
175
196
|
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
if ( compatSlot ) {
|
|
198
|
+
compatSlot.appendChild( cloneWrapper );
|
|
199
|
+
} else if ( appendToOwnerDocument ) {
|
|
178
200
|
ownerDocument.body.appendChild( cloneWrapper );
|
|
179
201
|
} else {
|
|
180
202
|
elementWrapper?.appendChild( cloneWrapper );
|
|
@@ -32,7 +32,13 @@ const meta: Meta< typeof Draggable > = {
|
|
|
32
32
|
},
|
|
33
33
|
parameters: {
|
|
34
34
|
controls: { expanded: true },
|
|
35
|
-
docs: {
|
|
35
|
+
docs: {
|
|
36
|
+
source: { code: '' },
|
|
37
|
+
// Render in its own iframe — Storybook's docs-page wrappers
|
|
38
|
+
// create transform-based containing blocks that break the
|
|
39
|
+
// clone's `position: fixed` resolution.
|
|
40
|
+
story: { inline: false, height: '250px' },
|
|
41
|
+
},
|
|
36
42
|
componentStatus: {
|
|
37
43
|
status: 'use-with-caution',
|
|
38
44
|
whereUsed: 'global',
|
|
@@ -115,11 +121,10 @@ export const Default: StoryFn< typeof Draggable > = DefaultTemplate.bind( {} );
|
|
|
115
121
|
Default.args = {};
|
|
116
122
|
|
|
117
123
|
/**
|
|
118
|
-
* `appendToOwnerDocument`
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* element to be rendered behind other elements.
|
|
124
|
+
* `appendToOwnerDocument` appends the dragged element's clone to the owner
|
|
125
|
+
* document's body instead of the element's parent, which is useful when an
|
|
126
|
+
* ancestor's stacking context (e.g. its `z-index`) would otherwise place the
|
|
127
|
+
* clone behind other content.
|
|
123
128
|
*/
|
|
124
129
|
export const AppendElementToOwnerDocument: StoryFn< typeof Draggable > =
|
|
125
130
|
DefaultTemplate.bind( {} );
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/z-index" as *;
|
|
2
|
+
|
|
3
|
+
.invisible-drag-image {
|
|
4
|
+
position: fixed;
|
|
5
|
+
/* stylelint-disable-next-line plugin/use-logical-properties-and-values -- Offscreen drag-image stand-in; flipping with writing direction has no benefit. */
|
|
6
|
+
left: -1000px;
|
|
7
|
+
height: 50px;
|
|
8
|
+
width: 50px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.clone {
|
|
12
|
+
position: fixed;
|
|
13
|
+
padding: 0; // Matches the `clonePadding` JS constant.
|
|
14
|
+
background: transparent;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Fallback for clones placed outside the compat overlay slot — the
|
|
19
|
+
// slot's stacking context handles ordering inside it.
|
|
20
|
+
.clone:not(.is-in-compat-slot) {
|
|
21
|
+
z-index: z-index(".components-draggable__clone");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Global selector — external code (e.g. block-editor keyboard drag)
|
|
25
|
+
// toggles the same body class.
|
|
26
|
+
:global(body.is-dragging-components-draggable) {
|
|
27
|
+
cursor: move; /* Fallback for IE/Edge < 14 */
|
|
28
|
+
cursor: grabbing !important;
|
|
29
|
+
}
|
package/src/draggable/types.ts
CHANGED
|
@@ -21,6 +21,10 @@ export type DraggableProps = {
|
|
|
21
21
|
* Whether to append the cloned element to the `ownerDocument` body.
|
|
22
22
|
* By default, elements sourced by id are appended to the element's wrapper.
|
|
23
23
|
*
|
|
24
|
+
* Has no effect when the `@wordpress/ui` compat overlay slot is in use in
|
|
25
|
+
* the same document — the clone goes into the slot instead. Cross-document
|
|
26
|
+
* drags fall back to this prop's regular semantics.
|
|
27
|
+
*
|
|
24
28
|
* @default false
|
|
25
29
|
*/
|
|
26
30
|
appendToOwnerDocument?: boolean;
|
|
@@ -65,7 +65,7 @@ Whether to allow multiple selection of files or not.
|
|
|
65
65
|
|
|
66
66
|
### `onChange`
|
|
67
67
|
|
|
68
|
-
- Type: `ChangeEventHandler<HTMLInputElement> | undefined`
|
|
68
|
+
- Type: `ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined`
|
|
69
69
|
- Required: Yes
|
|
70
70
|
|
|
71
71
|
Callback function passed directly to the `input` file element.
|
|
@@ -253,7 +253,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
253
253
|
break;
|
|
254
254
|
case 'Space':
|
|
255
255
|
if ( tokenizeOnSpace ) {
|
|
256
|
-
preventDefault = addCurrentToken(
|
|
256
|
+
preventDefault = addCurrentToken( {
|
|
257
|
+
preventDefaultOnFailedValidation: false,
|
|
258
|
+
} );
|
|
257
259
|
}
|
|
258
260
|
break;
|
|
259
261
|
case 'Escape':
|
|
@@ -320,7 +322,65 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
320
322
|
const tokenValue = items[ items.length - 1 ] || '';
|
|
321
323
|
|
|
322
324
|
if ( items.length > 1 ) {
|
|
323
|
-
|
|
325
|
+
const tokensToProcess = items.slice( 0, -1 );
|
|
326
|
+
|
|
327
|
+
// Pre-check: would any segment be rejected by
|
|
328
|
+
// `__experimentalValidateInput`? Empties and duplicates of the
|
|
329
|
+
// current selection are intentional skips, not failures.
|
|
330
|
+
const willFailValidation = ( segment: string ) => {
|
|
331
|
+
const transformed = saveTransform( segment );
|
|
332
|
+
return (
|
|
333
|
+
!! transformed &&
|
|
334
|
+
! valueContainsToken( transformed ) &&
|
|
335
|
+
! __experimentalValidateInput( transformed )
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
const hasFailures = tokensToProcess.some( willFailValidation );
|
|
339
|
+
|
|
340
|
+
// When there are failures, also commit the trailing in-progress
|
|
341
|
+
// segment so the user is left with only the items that need
|
|
342
|
+
// fixing, instead of mixing the trailing segment with the failed
|
|
343
|
+
// ones (which would block tokenization on Enter or comma).
|
|
344
|
+
const addedTokens = addNewTokens(
|
|
345
|
+
hasFailures ? items : tokensToProcess
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
if ( hasFailures ) {
|
|
349
|
+
// Derive rejected segments from `addedTokens` so this stays
|
|
350
|
+
// in sync with `addNewTokens`'s filter chain.
|
|
351
|
+
const rejected = items.filter( ( token ) => {
|
|
352
|
+
const transformed = saveTransform( token );
|
|
353
|
+
if ( ! transformed ) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
if ( addedTokens.has( transformed ) ) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
if ( valueContainsToken( transformed ) ) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
return ! __experimentalValidateInput( transformed );
|
|
363
|
+
} );
|
|
364
|
+
|
|
365
|
+
// Reuse the separator the user actually used (the last one
|
|
366
|
+
// in `text`) so we don't rewrite their input: comma-separated
|
|
367
|
+
// paste under `tokenizeOnSpace` stays comma-separated, and
|
|
368
|
+
// typed space under `tokenizeOnSpace` stays a space. Falls
|
|
369
|
+
// back to the mode-appropriate separator only when no
|
|
370
|
+
// separator characters are present in `text`.
|
|
371
|
+
const usedSeparators = text.match( /[ ,\t]/g );
|
|
372
|
+
const separatorChar =
|
|
373
|
+
usedSeparators?.[ usedSeparators.length - 1 ] ??
|
|
374
|
+
( tokenizeOnSpace ? ' ' : ',' );
|
|
375
|
+
// Preserve a trailing separator when the input ended with
|
|
376
|
+
// one, so the user can keep typing past a failed-validation
|
|
377
|
+
// space without their separator disappearing.
|
|
378
|
+
const trailing = tokenValue === '' ? separatorChar : '';
|
|
379
|
+
const remaining = rejected.join( separatorChar ) + trailing;
|
|
380
|
+
setIncompleteTokenValue( remaining );
|
|
381
|
+
onInputChange( remaining );
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
324
384
|
}
|
|
325
385
|
setIncompleteTokenValue( tokenValue );
|
|
326
386
|
onInputChange( tokenValue );
|
|
@@ -417,7 +477,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
417
477
|
addNewToken( incompleteTokenValue );
|
|
418
478
|
}
|
|
419
479
|
|
|
420
|
-
|
|
480
|
+
// Comma is always a separator (typed in onKeyPress, never as input).
|
|
481
|
+
// Pasted commas go through onInputChangeHandler, which validates.
|
|
482
|
+
return true;
|
|
421
483
|
}
|
|
422
484
|
|
|
423
485
|
function moveInputToIndex( index: number ) {
|
|
@@ -454,7 +516,9 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
454
516
|
}
|
|
455
517
|
}
|
|
456
518
|
|
|
457
|
-
function addCurrentToken(
|
|
519
|
+
function addCurrentToken( {
|
|
520
|
+
preventDefaultOnFailedValidation = true,
|
|
521
|
+
} = {} ) {
|
|
458
522
|
let preventDefault = false;
|
|
459
523
|
const selectedSuggestion = getSelectedSuggestion();
|
|
460
524
|
|
|
@@ -462,20 +526,22 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
462
526
|
addNewToken( selectedSuggestion );
|
|
463
527
|
preventDefault = true;
|
|
464
528
|
} else if ( inputHasValidValue() ) {
|
|
465
|
-
addNewToken( incompleteTokenValue );
|
|
466
|
-
preventDefault =
|
|
529
|
+
const passedValidation = addNewToken( incompleteTokenValue );
|
|
530
|
+
preventDefault =
|
|
531
|
+
passedValidation || preventDefaultOnFailedValidation;
|
|
467
532
|
}
|
|
468
533
|
|
|
469
534
|
return preventDefault;
|
|
470
535
|
}
|
|
471
536
|
|
|
472
|
-
function addNewTokens( tokens: string[] ) {
|
|
537
|
+
function addNewTokens( tokens: string[] ): Set< string > {
|
|
473
538
|
const tokensToAdd = [
|
|
474
539
|
...new Set(
|
|
475
540
|
tokens
|
|
476
541
|
.map( saveTransform )
|
|
477
542
|
.filter( Boolean )
|
|
478
543
|
.filter( ( token ) => ! valueContainsToken( token ) )
|
|
544
|
+
.filter( ( token ) => __experimentalValidateInput( token ) )
|
|
479
545
|
),
|
|
480
546
|
];
|
|
481
547
|
|
|
@@ -484,12 +550,20 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
484
550
|
newValue.splice( getIndexOfInput(), 0, ...tokensToAdd );
|
|
485
551
|
onChange( newValue );
|
|
486
552
|
}
|
|
553
|
+
|
|
554
|
+
return new Set( tokensToAdd );
|
|
487
555
|
}
|
|
488
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Validates and adds `token`. Returns `true` if validation passed,
|
|
559
|
+
* `false` if it was rejected by `__experimentalValidateInput`. A `true`
|
|
560
|
+
* return does not guarantee the token was added: `addNewTokens` may
|
|
561
|
+
* still drop it as a duplicate or after `saveTransform` returns empty.
|
|
562
|
+
*/
|
|
489
563
|
function addNewToken( token: string ) {
|
|
490
564
|
if ( ! __experimentalValidateInput( token ) ) {
|
|
491
565
|
speak( messages.__experimentalInvalid, 'assertive' );
|
|
492
|
-
return;
|
|
566
|
+
return false;
|
|
493
567
|
}
|
|
494
568
|
addNewTokens( [ token ] );
|
|
495
569
|
speak( messages.added, 'assertive' );
|
|
@@ -502,6 +576,8 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
502
576
|
if ( isActive && ! tokenizeOnBlur ) {
|
|
503
577
|
focus();
|
|
504
578
|
}
|
|
579
|
+
|
|
580
|
+
return true;
|
|
505
581
|
}
|
|
506
582
|
|
|
507
583
|
function deleteToken( token: string | TokenItem ) {
|
|
@@ -1929,6 +1929,195 @@ describe( 'FormTokenField', () => {
|
|
|
1929
1929
|
expect( onChangeSpy ).toHaveBeenCalledTimes( 2 );
|
|
1930
1930
|
expectTokensToBeInTheDocument( [ 'cherry', 'Cranberry' ] );
|
|
1931
1931
|
} );
|
|
1932
|
+
|
|
1933
|
+
it( 'should still preventDefault on Enter when validation rejects the value', async () => {
|
|
1934
|
+
const user = userEvent.setup();
|
|
1935
|
+
|
|
1936
|
+
const onChangeSpy = jest.fn();
|
|
1937
|
+
const onSubmitSpy = jest.fn( ( e: React.FormEvent ) =>
|
|
1938
|
+
e.preventDefault()
|
|
1939
|
+
);
|
|
1940
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
1941
|
+
/^[A-Z]/.test( tokenText );
|
|
1942
|
+
|
|
1943
|
+
render(
|
|
1944
|
+
<form onSubmit={ onSubmitSpy }>
|
|
1945
|
+
<FormTokenFieldWithState
|
|
1946
|
+
onChange={ onChangeSpy }
|
|
1947
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
1948
|
+
/>
|
|
1949
|
+
</form>
|
|
1950
|
+
);
|
|
1951
|
+
|
|
1952
|
+
const input = screen.getByRole( 'combobox' );
|
|
1953
|
+
|
|
1954
|
+
// Type 'hello' — lowercase, fails validation.
|
|
1955
|
+
// Press Enter — should NOT submit the parent form.
|
|
1956
|
+
await user.type( input, 'hello[Enter]' );
|
|
1957
|
+
expect( onChangeSpy ).not.toHaveBeenCalled();
|
|
1958
|
+
expect( onSubmitSpy ).not.toHaveBeenCalled();
|
|
1959
|
+
expect( input ).toHaveValue( 'hello' );
|
|
1960
|
+
} );
|
|
1961
|
+
|
|
1962
|
+
it( 'should not preventDefault on space when validation fails and `tokenizeOnSpace` is true', async () => {
|
|
1963
|
+
const user = userEvent.setup();
|
|
1964
|
+
|
|
1965
|
+
const onChangeSpy = jest.fn();
|
|
1966
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
1967
|
+
/^[A-Z]/.test( tokenText );
|
|
1968
|
+
|
|
1969
|
+
render(
|
|
1970
|
+
<FormTokenFieldWithState
|
|
1971
|
+
onChange={ onChangeSpy }
|
|
1972
|
+
tokenizeOnSpace
|
|
1973
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
1974
|
+
/>
|
|
1975
|
+
);
|
|
1976
|
+
|
|
1977
|
+
const input = screen.getByRole( 'combobox' );
|
|
1978
|
+
|
|
1979
|
+
// Type 'hello ', lowercase, fails validation.
|
|
1980
|
+
// The space should be typed into the input (not prevented), and
|
|
1981
|
+
// the trailing space should be preserved by the rejoin so the
|
|
1982
|
+
// user can keep typing past the failed-validation space.
|
|
1983
|
+
await user.type( input, 'hello ' );
|
|
1984
|
+
expect( onChangeSpy ).not.toHaveBeenCalled();
|
|
1985
|
+
expect( input ).toHaveValue( 'hello ' );
|
|
1986
|
+
|
|
1987
|
+
// User can keep typing past the failed-validation space.
|
|
1988
|
+
await user.type( input, 'w' );
|
|
1989
|
+
expect( input ).toHaveValue( 'hello w' );
|
|
1990
|
+
|
|
1991
|
+
// Clear and type 'Hello ', capital letter, passes validation.
|
|
1992
|
+
// The space should be prevented, and a token should be created.
|
|
1993
|
+
await user.clear( input );
|
|
1994
|
+
await user.type( input, 'Hello ' );
|
|
1995
|
+
expect( onChangeSpy ).toHaveBeenCalledTimes( 1 );
|
|
1996
|
+
expect( onChangeSpy ).toHaveBeenCalledWith( [ 'Hello' ] );
|
|
1997
|
+
expectTokensToBeInTheDocument( [ 'Hello' ] );
|
|
1998
|
+
} );
|
|
1999
|
+
|
|
2000
|
+
it( 'should filter out invalid tokens when pasting with separators', async () => {
|
|
2001
|
+
const user = userEvent.setup();
|
|
2002
|
+
|
|
2003
|
+
const onChangeSpy = jest.fn();
|
|
2004
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
2005
|
+
/^[A-Z]/.test( tokenText );
|
|
2006
|
+
|
|
2007
|
+
render(
|
|
2008
|
+
<FormTokenFieldWithState
|
|
2009
|
+
onChange={ onChangeSpy }
|
|
2010
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
2011
|
+
/>
|
|
2012
|
+
);
|
|
2013
|
+
|
|
2014
|
+
const input = screen.getByRole( 'combobox' );
|
|
2015
|
+
|
|
2016
|
+
// Paste values separated by comma, only valid ones should be added.
|
|
2017
|
+
// Uses paste (not type) because comma keystrokes go through
|
|
2018
|
+
// handleCommaKey, while pasted text goes through
|
|
2019
|
+
// onInputChangeHandler which splits by separator.
|
|
2020
|
+
await user.click( input );
|
|
2021
|
+
await user.paste( 'Apple,banana,Cherry,' );
|
|
2022
|
+
expect( onChangeSpy ).toHaveBeenCalledWith( [ 'Apple', 'Cherry' ] );
|
|
2023
|
+
expectTokensToBeInTheDocument( [ 'Apple', 'Cherry' ] );
|
|
2024
|
+
expectTokensNotToBeInTheDocument( [ 'banana' ] );
|
|
2025
|
+
expect( input ).toHaveValue( 'banana,' );
|
|
2026
|
+
} );
|
|
2027
|
+
|
|
2028
|
+
it( 'should leave all segments in the input when none pass validation on paste', async () => {
|
|
2029
|
+
const user = userEvent.setup();
|
|
2030
|
+
|
|
2031
|
+
const onChangeSpy = jest.fn();
|
|
2032
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
2033
|
+
/^[A-Z]/.test( tokenText );
|
|
2034
|
+
|
|
2035
|
+
render(
|
|
2036
|
+
<FormTokenFieldWithState
|
|
2037
|
+
onChange={ onChangeSpy }
|
|
2038
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
2039
|
+
/>
|
|
2040
|
+
);
|
|
2041
|
+
|
|
2042
|
+
const input = screen.getByRole( 'combobox' );
|
|
2043
|
+
|
|
2044
|
+
await user.click( input );
|
|
2045
|
+
await user.paste( 'apple,banana,cherry,' );
|
|
2046
|
+
|
|
2047
|
+
expect( onChangeSpy ).not.toHaveBeenCalled();
|
|
2048
|
+
expect( input ).toHaveValue( 'apple,banana,cherry,' );
|
|
2049
|
+
} );
|
|
2050
|
+
|
|
2051
|
+
it( 'should commit a trailing valid segment and leave only failed segments in the input when pasting without a trailing separator', async () => {
|
|
2052
|
+
const user = userEvent.setup();
|
|
2053
|
+
|
|
2054
|
+
const onChangeSpy = jest.fn();
|
|
2055
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
2056
|
+
/^[A-Z]/.test( tokenText );
|
|
2057
|
+
|
|
2058
|
+
render(
|
|
2059
|
+
<FormTokenFieldWithState
|
|
2060
|
+
onChange={ onChangeSpy }
|
|
2061
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
2062
|
+
/>
|
|
2063
|
+
);
|
|
2064
|
+
|
|
2065
|
+
const input = screen.getByRole( 'combobox' );
|
|
2066
|
+
|
|
2067
|
+
await user.click( input );
|
|
2068
|
+
await user.paste( 'Apple,banana,Cherry' );
|
|
2069
|
+
|
|
2070
|
+
expect( onChangeSpy ).toHaveBeenCalledWith( [ 'Apple', 'Cherry' ] );
|
|
2071
|
+
expectTokensToBeInTheDocument( [ 'Apple', 'Cherry' ] );
|
|
2072
|
+
expect( input ).toHaveValue( 'banana' );
|
|
2073
|
+
} );
|
|
2074
|
+
|
|
2075
|
+
it( 'should not leave a duplicate of an existing token in the input when pasting comma-separated values', async () => {
|
|
2076
|
+
const user = userEvent.setup();
|
|
2077
|
+
|
|
2078
|
+
const onChangeSpy = jest.fn();
|
|
2079
|
+
|
|
2080
|
+
render(
|
|
2081
|
+
<FormTokenFieldWithState
|
|
2082
|
+
onChange={ onChangeSpy }
|
|
2083
|
+
initialValue={ [ 'Apple' ] }
|
|
2084
|
+
/>
|
|
2085
|
+
);
|
|
2086
|
+
|
|
2087
|
+
const input = screen.getByRole( 'combobox' );
|
|
2088
|
+
|
|
2089
|
+
await user.click( input );
|
|
2090
|
+
await user.paste( 'Apple,Cherry,' );
|
|
2091
|
+
|
|
2092
|
+
expect( onChangeSpy ).toHaveBeenCalledWith( [ 'Apple', 'Cherry' ] );
|
|
2093
|
+
expectTokensToBeInTheDocument( [ 'Apple', 'Cherry' ] );
|
|
2094
|
+
expect( input ).toHaveValue( '' );
|
|
2095
|
+
} );
|
|
2096
|
+
|
|
2097
|
+
it( 'should not leave a duplicate of an existing token in the input when pasting comma-separated values with `__experimentalValidateInput`', async () => {
|
|
2098
|
+
const user = userEvent.setup();
|
|
2099
|
+
|
|
2100
|
+
const onChangeSpy = jest.fn();
|
|
2101
|
+
const startsWithCapitalLetter = ( tokenText: string ) =>
|
|
2102
|
+
/^[A-Z]/.test( tokenText );
|
|
2103
|
+
|
|
2104
|
+
render(
|
|
2105
|
+
<FormTokenFieldWithState
|
|
2106
|
+
onChange={ onChangeSpy }
|
|
2107
|
+
initialValue={ [ 'Apple' ] }
|
|
2108
|
+
__experimentalValidateInput={ startsWithCapitalLetter }
|
|
2109
|
+
/>
|
|
2110
|
+
);
|
|
2111
|
+
|
|
2112
|
+
const input = screen.getByRole( 'combobox' );
|
|
2113
|
+
|
|
2114
|
+
await user.click( input );
|
|
2115
|
+
await user.paste( 'Apple,Cherry,' );
|
|
2116
|
+
|
|
2117
|
+
expect( onChangeSpy ).toHaveBeenCalledWith( [ 'Apple', 'Cherry' ] );
|
|
2118
|
+
expectTokensToBeInTheDocument( [ 'Apple', 'Cherry' ] );
|
|
2119
|
+
expect( input ).toHaveValue( '' );
|
|
2120
|
+
} );
|
|
1932
2121
|
} );
|
|
1933
2122
|
|
|
1934
2123
|
describe( 'maxLength', () => {
|
package/src/h-stack/hook.tsx
CHANGED
|
@@ -29,7 +29,7 @@ export function useHStack( props: WordPressComponentProps< Props, 'div' > ) {
|
|
|
29
29
|
const _isSpacer = hasConnectNamespace( child, [ 'Spacer' ] );
|
|
30
30
|
|
|
31
31
|
if ( _isSpacer ) {
|
|
32
|
-
const childElement = child as ReactElement
|
|
32
|
+
const childElement = child as ReactElement< typeof FlexItem >;
|
|
33
33
|
const _key = childElement.key || `hstack-${ index }`;
|
|
34
34
|
|
|
35
35
|
return <FlexItem isBlock key={ _key } { ...childElement.props } />;
|
|
@@ -6,7 +6,7 @@ import { v4 as uuid } from 'uuid';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
10
10
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -45,10 +45,7 @@ import type { WithNoticeProps } from './types';
|
|
|
45
45
|
* @return Wrapped component.
|
|
46
46
|
*/
|
|
47
47
|
export default createHigherOrderComponent( ( OriginalComponent ) => {
|
|
48
|
-
function Component(
|
|
49
|
-
props: { [ key: string ]: any },
|
|
50
|
-
ref: React.ForwardedRef< any >
|
|
51
|
-
) {
|
|
48
|
+
return function Component( props: { [ key: string ]: any } ) {
|
|
52
49
|
const [ noticeList, setNoticeList ] = useState<
|
|
53
50
|
WithNoticeProps[ 'noticeList' ]
|
|
54
51
|
>( [] );
|
|
@@ -97,20 +94,6 @@ export default createHigherOrderComponent( ( OriginalComponent ) => {
|
|
|
97
94
|
),
|
|
98
95
|
};
|
|
99
96
|
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
) : (
|
|
103
|
-
<OriginalComponent { ...propsOut } />
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let isForwardRef: boolean;
|
|
108
|
-
// @ts-expect-error - `render` will only be present when OriginalComponent was wrapped with forwardRef().
|
|
109
|
-
const { render } = OriginalComponent;
|
|
110
|
-
// Returns a forwardRef if OriginalComponent appears to be a forwardRef.
|
|
111
|
-
if ( typeof render === 'function' ) {
|
|
112
|
-
isForwardRef = true;
|
|
113
|
-
return forwardRef( Component );
|
|
114
|
-
}
|
|
115
|
-
return Component;
|
|
97
|
+
return <OriginalComponent { ...propsOut } />;
|
|
98
|
+
};
|
|
116
99
|
}, 'withNotices' );
|
|
@@ -33,14 +33,6 @@ function noticesFrom( list: string[] ) {
|
|
|
33
33
|
return list.map( ( item ) => ( { id: item, content: item } ) );
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function isComponentLike( object: any ) {
|
|
37
|
-
return typeof object === 'function';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isForwardRefLike( { render: renderMethod }: any ) {
|
|
41
|
-
return typeof renderMethod === 'function';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
36
|
const content = 'Base content';
|
|
45
37
|
|
|
46
38
|
const BaseComponent = ( {
|
|
@@ -80,16 +72,6 @@ const TestNoticeOperations = withNotices(
|
|
|
80
72
|
} )
|
|
81
73
|
);
|
|
82
74
|
|
|
83
|
-
describe( 'withNotices return type', () => {
|
|
84
|
-
it( 'should be a component given a component', () => {
|
|
85
|
-
expect( isComponentLike( TestComponent ) ).toBe( true );
|
|
86
|
-
} );
|
|
87
|
-
|
|
88
|
-
it( 'should be a forwardRef given a forwardRef', () => {
|
|
89
|
-
expect( isForwardRefLike( TestNoticeOperations ) ).toBe( true );
|
|
90
|
-
} );
|
|
91
|
-
} );
|
|
92
|
-
|
|
93
75
|
describe( 'withNotices operations', () => {
|
|
94
76
|
function setup( props: any = {} ) {
|
|
95
77
|
const handle = createRef< any >();
|
|
@@ -1,31 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import type { Meta, StoryFn } from '@storybook/react-vite';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { SVG, Path } from '@wordpress/primitives';
|
|
10
3
|
import { wordpress } from '@wordpress/icons';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
4
|
import Icon from '..';
|
|
16
5
|
import { VStack } from '../../v-stack';
|
|
17
6
|
|
|
18
7
|
const meta: Meta< typeof Icon > = {
|
|
19
|
-
tags: [ 'manifest' ],
|
|
20
8
|
title: 'Components/Icon',
|
|
21
9
|
component: Icon,
|
|
22
10
|
parameters: {
|
|
23
11
|
controls: { expanded: true },
|
|
24
12
|
docs: { canvas: { sourceState: 'shown' } },
|
|
25
13
|
componentStatus: {
|
|
26
|
-
status: '
|
|
14
|
+
status: 'use-with-caution',
|
|
27
15
|
whereUsed: 'global',
|
|
28
|
-
notes: '
|
|
16
|
+
notes: 'When rendering SVGs, use `Icon` from `@wordpress/ui` instead.',
|
|
29
17
|
},
|
|
30
18
|
},
|
|
31
19
|
};
|
package/src/index.ts
CHANGED
|
@@ -45,7 +45,6 @@ export {
|
|
|
45
45
|
/** @deprecated Import `BoxControl` instead. */
|
|
46
46
|
default as __experimentalBoxControl,
|
|
47
47
|
default as BoxControl,
|
|
48
|
-
applyValueToSides as __experimentalApplyValueToSides,
|
|
49
48
|
} from './box-control';
|
|
50
49
|
export { default as Button } from './button';
|
|
51
50
|
export { default as ButtonGroup } from './button-group';
|
|
@@ -118,11 +117,6 @@ export { default as MenuItemsChoice } from './menu-items-choice';
|
|
|
118
117
|
export { default as Modal } from './modal';
|
|
119
118
|
export { default as ScrollLock } from './scroll-lock';
|
|
120
119
|
export { NavigableMenu, TabbableContainer } from './navigable-container';
|
|
121
|
-
export { default as __experimentalNavigation } from './navigation';
|
|
122
|
-
export { default as __experimentalNavigationBackButton } from './navigation/back-button';
|
|
123
|
-
export { default as __experimentalNavigationGroup } from './navigation/group';
|
|
124
|
-
export { default as __experimentalNavigationItem } from './navigation/item';
|
|
125
|
-
export { default as __experimentalNavigationMenu } from './navigation/menu';
|
|
126
120
|
export {
|
|
127
121
|
/** @deprecated Import `Navigator` instead. */
|
|
128
122
|
NavigatorProvider as __experimentalNavigatorProvider,
|