@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
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { ROOT_MENU } from './constants';
|
|
10
|
-
|
|
11
|
-
import type { NavigationContext as NavigationContextType } from './types';
|
|
12
|
-
|
|
13
|
-
const noop = () => {};
|
|
14
|
-
const defaultIsEmpty = () => false;
|
|
15
|
-
const defaultGetter = () => undefined;
|
|
16
|
-
|
|
17
|
-
export const NavigationContext = createContext< NavigationContextType >( {
|
|
18
|
-
activeItem: undefined,
|
|
19
|
-
activeMenu: ROOT_MENU,
|
|
20
|
-
setActiveMenu: noop,
|
|
21
|
-
|
|
22
|
-
navigationTree: {
|
|
23
|
-
items: {},
|
|
24
|
-
getItem: defaultGetter,
|
|
25
|
-
addItem: noop,
|
|
26
|
-
removeItem: noop,
|
|
27
|
-
|
|
28
|
-
menus: {},
|
|
29
|
-
getMenu: defaultGetter,
|
|
30
|
-
addMenu: noop,
|
|
31
|
-
removeMenu: noop,
|
|
32
|
-
childMenu: {},
|
|
33
|
-
traverseMenu: noop,
|
|
34
|
-
isMenuEmpty: defaultIsEmpty,
|
|
35
|
-
},
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
NavigationContext.displayName = 'NavigationContext';
|
|
39
|
-
|
|
40
|
-
export const useNavigationContext = () => useContext( NavigationContext );
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import type { NavigationGroupContext as NavigationGroupContextType } from '../types';
|
|
10
|
-
|
|
11
|
-
export const NavigationGroupContext =
|
|
12
|
-
createContext< NavigationGroupContextType >( { group: undefined } );
|
|
13
|
-
NavigationGroupContext.displayName = 'NavigationGroupContext';
|
|
14
|
-
|
|
15
|
-
export const useNavigationGroupContext = () =>
|
|
16
|
-
useContext( NavigationGroupContext );
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { NavigationGroupContext } from './context';
|
|
15
|
-
import { GroupTitleUI } from '../styles/navigation-styles';
|
|
16
|
-
import { useNavigationContext } from '../context';
|
|
17
|
-
|
|
18
|
-
import type { NavigationGroupProps } from '../types';
|
|
19
|
-
|
|
20
|
-
let uniqueId = 0;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @deprecated Use `Navigator` instead.
|
|
24
|
-
*/
|
|
25
|
-
export function NavigationGroup( {
|
|
26
|
-
children,
|
|
27
|
-
className,
|
|
28
|
-
title,
|
|
29
|
-
}: NavigationGroupProps ) {
|
|
30
|
-
const [ groupId ] = useState( `group-${ ++uniqueId }` );
|
|
31
|
-
const {
|
|
32
|
-
navigationTree: { items },
|
|
33
|
-
} = useNavigationContext();
|
|
34
|
-
|
|
35
|
-
const context = { group: groupId };
|
|
36
|
-
|
|
37
|
-
// Keep the children rendered to make sure invisible items are included in the navigation tree.
|
|
38
|
-
if (
|
|
39
|
-
! Object.values( items ).some(
|
|
40
|
-
( item ) => item.group === groupId && item._isVisible
|
|
41
|
-
)
|
|
42
|
-
) {
|
|
43
|
-
return (
|
|
44
|
-
<NavigationGroupContext.Provider value={ context }>
|
|
45
|
-
{ children }
|
|
46
|
-
</NavigationGroupContext.Provider>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const groupTitleId = `components-navigation__group-title-${ groupId }`;
|
|
51
|
-
const classes = clsx( 'components-navigation__group', className );
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<NavigationGroupContext.Provider value={ context }>
|
|
55
|
-
<li className={ classes }>
|
|
56
|
-
{ title && (
|
|
57
|
-
<GroupTitleUI
|
|
58
|
-
className="components-navigation__group-title"
|
|
59
|
-
id={ groupTitleId }
|
|
60
|
-
level={ 3 }
|
|
61
|
-
>
|
|
62
|
-
{ title }
|
|
63
|
-
</GroupTitleUI>
|
|
64
|
-
) }
|
|
65
|
-
<ul aria-labelledby={ groupTitleId } role="group">
|
|
66
|
-
{ children }
|
|
67
|
-
</ul>
|
|
68
|
-
</li>
|
|
69
|
-
</NavigationGroupContext.Provider>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export default NavigationGroup;
|
package/src/navigation/index.tsx
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import deprecated from '@wordpress/deprecated';
|
|
10
|
-
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
11
|
-
import { isRTL } from '@wordpress/i18n';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { getAnimateClassName } from '../animate';
|
|
17
|
-
import { ROOT_MENU } from './constants';
|
|
18
|
-
import { NavigationContext } from './context';
|
|
19
|
-
import { NavigationUI } from './styles/navigation-styles';
|
|
20
|
-
import { useCreateNavigationTree } from './use-create-navigation-tree';
|
|
21
|
-
|
|
22
|
-
import type {
|
|
23
|
-
NavigationProps,
|
|
24
|
-
NavigationContext as NavigationContextType,
|
|
25
|
-
} from './types';
|
|
26
|
-
|
|
27
|
-
const noop = () => {};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Render a navigation list with optional groupings and hierarchy.
|
|
31
|
-
*
|
|
32
|
-
* @deprecated Use `Navigator` instead.
|
|
33
|
-
*
|
|
34
|
-
* ```jsx
|
|
35
|
-
* import {
|
|
36
|
-
* __experimentalNavigation as Navigation,
|
|
37
|
-
* __experimentalNavigationGroup as NavigationGroup,
|
|
38
|
-
* __experimentalNavigationItem as NavigationItem,
|
|
39
|
-
* __experimentalNavigationMenu as NavigationMenu,
|
|
40
|
-
* } from '@wordpress/components';
|
|
41
|
-
*
|
|
42
|
-
* const MyNavigation = () => (
|
|
43
|
-
* <Navigation>
|
|
44
|
-
* <NavigationMenu title="Home">
|
|
45
|
-
* <NavigationGroup title="Group 1">
|
|
46
|
-
* <NavigationItem item="item-1" title="Item 1" />
|
|
47
|
-
* <NavigationItem item="item-2" title="Item 2" />
|
|
48
|
-
* </NavigationGroup>
|
|
49
|
-
* <NavigationGroup title="Group 2">
|
|
50
|
-
* <NavigationItem
|
|
51
|
-
* item="item-3"
|
|
52
|
-
* navigateToMenu="category"
|
|
53
|
-
* title="Category"
|
|
54
|
-
* />
|
|
55
|
-
* </NavigationGroup>
|
|
56
|
-
* </NavigationMenu>
|
|
57
|
-
*
|
|
58
|
-
* <NavigationMenu
|
|
59
|
-
* backButtonLabel="Home"
|
|
60
|
-
* menu="category"
|
|
61
|
-
* parentMenu="root"
|
|
62
|
-
* title="Category"
|
|
63
|
-
* >
|
|
64
|
-
* <NavigationItem badge="1" item="child-1" title="Child 1" />
|
|
65
|
-
* <NavigationItem item="child-2" title="Child 2" />
|
|
66
|
-
* </NavigationMenu>
|
|
67
|
-
* </Navigation>
|
|
68
|
-
* );
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export function Navigation( {
|
|
72
|
-
activeItem,
|
|
73
|
-
activeMenu = ROOT_MENU,
|
|
74
|
-
children,
|
|
75
|
-
className,
|
|
76
|
-
onActivateMenu = noop,
|
|
77
|
-
}: NavigationProps ) {
|
|
78
|
-
const [ menu, setMenu ] = useState( activeMenu );
|
|
79
|
-
const [ slideOrigin, setSlideOrigin ] = useState< 'left' | 'right' >();
|
|
80
|
-
const navigationTree = useCreateNavigationTree();
|
|
81
|
-
const defaultSlideOrigin = isRTL() ? 'right' : 'left';
|
|
82
|
-
|
|
83
|
-
deprecated( 'wp.components.Navigation (and all subcomponents)', {
|
|
84
|
-
since: '6.8',
|
|
85
|
-
version: '7.1',
|
|
86
|
-
alternative: 'wp.components.Navigator',
|
|
87
|
-
} );
|
|
88
|
-
|
|
89
|
-
const setActiveMenu: NavigationContextType[ 'setActiveMenu' ] = (
|
|
90
|
-
menuId,
|
|
91
|
-
slideInOrigin = defaultSlideOrigin
|
|
92
|
-
) => {
|
|
93
|
-
if ( ! navigationTree.getMenu( menuId ) ) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setSlideOrigin( slideInOrigin );
|
|
98
|
-
setMenu( menuId );
|
|
99
|
-
onActivateMenu( menuId );
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// Used to prevent the sliding animation on mount
|
|
103
|
-
const isMountedRef = useRef( false );
|
|
104
|
-
useEffect( () => {
|
|
105
|
-
if ( ! isMountedRef.current ) {
|
|
106
|
-
isMountedRef.current = true;
|
|
107
|
-
}
|
|
108
|
-
}, [] );
|
|
109
|
-
|
|
110
|
-
useEffect( () => {
|
|
111
|
-
if ( activeMenu !== menu ) {
|
|
112
|
-
setActiveMenu( activeMenu );
|
|
113
|
-
}
|
|
114
|
-
// Not adding deps for now, as it would require either a larger refactor or some questionable workarounds.
|
|
115
|
-
// See https://github.com/WordPress/gutenberg/pull/41612 for context.
|
|
116
|
-
}, [ activeMenu ] );
|
|
117
|
-
|
|
118
|
-
const context = {
|
|
119
|
-
activeItem,
|
|
120
|
-
activeMenu: menu,
|
|
121
|
-
setActiveMenu,
|
|
122
|
-
navigationTree,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const classes = clsx( 'components-navigation', className );
|
|
126
|
-
const animateClassName = getAnimateClassName( {
|
|
127
|
-
type: 'slide-in',
|
|
128
|
-
origin: slideOrigin,
|
|
129
|
-
} );
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<NavigationUI className={ classes }>
|
|
133
|
-
<div
|
|
134
|
-
key={ menu }
|
|
135
|
-
className={
|
|
136
|
-
animateClassName
|
|
137
|
-
? clsx( {
|
|
138
|
-
[ animateClassName ]:
|
|
139
|
-
isMountedRef.current && slideOrigin,
|
|
140
|
-
} )
|
|
141
|
-
: undefined
|
|
142
|
-
}
|
|
143
|
-
>
|
|
144
|
-
<NavigationContext.Provider value={ context }>
|
|
145
|
-
{ children }
|
|
146
|
-
</NavigationContext.Provider>
|
|
147
|
-
</div>
|
|
148
|
-
</NavigationUI>
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export default Navigation;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { ItemBadgeUI, ItemTitleUI } from '../styles/navigation-styles';
|
|
5
|
-
|
|
6
|
-
import type { NavigationItemBaseContentProps } from '../types';
|
|
7
|
-
|
|
8
|
-
export default function NavigationItemBaseContent(
|
|
9
|
-
props: NavigationItemBaseContentProps
|
|
10
|
-
) {
|
|
11
|
-
const { badge, title } = props;
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
{ title && (
|
|
16
|
-
<ItemTitleUI
|
|
17
|
-
className="components-navigation__item-title"
|
|
18
|
-
as="span"
|
|
19
|
-
>
|
|
20
|
-
{ title }
|
|
21
|
-
</ItemTitleUI>
|
|
22
|
-
) }
|
|
23
|
-
|
|
24
|
-
{ badge && (
|
|
25
|
-
<ItemBadgeUI className="components-navigation__item-badge">
|
|
26
|
-
{ badge }
|
|
27
|
-
</ItemBadgeUI>
|
|
28
|
-
) }
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { useNavigationContext } from '../context';
|
|
15
|
-
import { useNavigationTreeItem } from './use-navigation-tree-item';
|
|
16
|
-
import { ItemBaseUI } from '../styles/navigation-styles';
|
|
17
|
-
|
|
18
|
-
import type { NavigationItemBaseProps } from '../types';
|
|
19
|
-
|
|
20
|
-
let uniqueId = 0;
|
|
21
|
-
|
|
22
|
-
export default function NavigationItemBase( props: NavigationItemBaseProps ) {
|
|
23
|
-
// Also avoid to pass the `title` and `href` props to the ItemBaseUI styled component.
|
|
24
|
-
const { children, className, title, href, ...restProps } = props;
|
|
25
|
-
|
|
26
|
-
const [ itemId ] = useState( `item-${ ++uniqueId }` );
|
|
27
|
-
|
|
28
|
-
useNavigationTreeItem( itemId, props );
|
|
29
|
-
const { navigationTree } = useNavigationContext();
|
|
30
|
-
|
|
31
|
-
if ( ! navigationTree.getItem( itemId )?._isVisible ) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const classes = clsx( 'components-navigation__item', className );
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<ItemBaseUI className={ classes } { ...restProps }>
|
|
39
|
-
{ children }
|
|
40
|
-
</ItemBaseUI>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
|
|
10
|
-
import { isRTL } from '@wordpress/i18n';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import Button from '../../button';
|
|
16
|
-
import { useNavigationContext } from '../context';
|
|
17
|
-
import { ItemUI, ItemIconUI } from '../styles/navigation-styles';
|
|
18
|
-
import NavigationItemBaseContent from './base-content';
|
|
19
|
-
import NavigationItemBase from './base';
|
|
20
|
-
|
|
21
|
-
import type { NavigationItemProps } from '../types';
|
|
22
|
-
|
|
23
|
-
const noop = () => {};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Use `Navigator` instead.
|
|
27
|
-
*/
|
|
28
|
-
export function NavigationItem( props: NavigationItemProps ) {
|
|
29
|
-
const {
|
|
30
|
-
badge,
|
|
31
|
-
children,
|
|
32
|
-
className,
|
|
33
|
-
href,
|
|
34
|
-
item,
|
|
35
|
-
navigateToMenu,
|
|
36
|
-
onClick = noop,
|
|
37
|
-
title,
|
|
38
|
-
icon,
|
|
39
|
-
hideIfTargetMenuEmpty,
|
|
40
|
-
isText,
|
|
41
|
-
...restProps
|
|
42
|
-
} = props;
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
activeItem,
|
|
46
|
-
setActiveMenu,
|
|
47
|
-
navigationTree: { isMenuEmpty },
|
|
48
|
-
} = useNavigationContext();
|
|
49
|
-
|
|
50
|
-
// If hideIfTargetMenuEmpty prop is true
|
|
51
|
-
// And the menu we are supposed to navigate to
|
|
52
|
-
// Is marked as empty, then we skip rendering the item.
|
|
53
|
-
if (
|
|
54
|
-
hideIfTargetMenuEmpty &&
|
|
55
|
-
navigateToMenu &&
|
|
56
|
-
isMenuEmpty( navigateToMenu )
|
|
57
|
-
) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const isActive = item && activeItem === item;
|
|
62
|
-
|
|
63
|
-
const classes = clsx( className, {
|
|
64
|
-
'is-active': isActive,
|
|
65
|
-
} );
|
|
66
|
-
|
|
67
|
-
const onItemClick: React.MouseEventHandler<
|
|
68
|
-
HTMLButtonElement | HTMLAnchorElement
|
|
69
|
-
> = ( event ) => {
|
|
70
|
-
if ( navigateToMenu ) {
|
|
71
|
-
setActiveMenu( navigateToMenu );
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
onClick( event );
|
|
75
|
-
};
|
|
76
|
-
const navigationIcon = isRTL() ? chevronLeft : chevronRight;
|
|
77
|
-
const baseProps = children ? props : { ...props, onClick: undefined };
|
|
78
|
-
const itemProps = isText
|
|
79
|
-
? restProps
|
|
80
|
-
: {
|
|
81
|
-
as: Button,
|
|
82
|
-
__next40pxDefaultSize:
|
|
83
|
-
'as' in restProps ? restProps.as === undefined : true,
|
|
84
|
-
href,
|
|
85
|
-
onClick: onItemClick,
|
|
86
|
-
'aria-current': isActive ? 'page' : undefined,
|
|
87
|
-
...restProps,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<NavigationItemBase { ...baseProps } className={ classes }>
|
|
92
|
-
{ children || (
|
|
93
|
-
<ItemUI { ...itemProps }>
|
|
94
|
-
{ icon && (
|
|
95
|
-
<ItemIconUI>
|
|
96
|
-
<Icon icon={ icon } />
|
|
97
|
-
</ItemIconUI>
|
|
98
|
-
) }
|
|
99
|
-
|
|
100
|
-
<NavigationItemBaseContent
|
|
101
|
-
title={ title }
|
|
102
|
-
badge={ badge }
|
|
103
|
-
/>
|
|
104
|
-
|
|
105
|
-
{ navigateToMenu && <Icon icon={ navigationIcon } /> }
|
|
106
|
-
</ItemUI>
|
|
107
|
-
) }
|
|
108
|
-
</NavigationItemBase>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export default NavigationItem;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useEffect } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useNavigationContext } from '../context';
|
|
10
|
-
import { useNavigationGroupContext } from '../group/context';
|
|
11
|
-
import { useNavigationMenuContext } from '../menu/context';
|
|
12
|
-
import { normalizedSearch } from '../utils';
|
|
13
|
-
|
|
14
|
-
import type { NavigationItemProps } from '../types';
|
|
15
|
-
|
|
16
|
-
export const useNavigationTreeItem = (
|
|
17
|
-
itemId: string,
|
|
18
|
-
props: NavigationItemProps
|
|
19
|
-
) => {
|
|
20
|
-
const {
|
|
21
|
-
activeMenu,
|
|
22
|
-
navigationTree: { addItem, removeItem },
|
|
23
|
-
} = useNavigationContext();
|
|
24
|
-
const { group } = useNavigationGroupContext();
|
|
25
|
-
const { menu, search } = useNavigationMenuContext();
|
|
26
|
-
|
|
27
|
-
useEffect( () => {
|
|
28
|
-
const isMenuActive = activeMenu === menu;
|
|
29
|
-
const isItemVisible =
|
|
30
|
-
! search ||
|
|
31
|
-
( props.title !== undefined &&
|
|
32
|
-
normalizedSearch( props.title, search ) );
|
|
33
|
-
|
|
34
|
-
addItem( itemId, {
|
|
35
|
-
...props,
|
|
36
|
-
group,
|
|
37
|
-
menu,
|
|
38
|
-
_isVisible: isMenuActive && isItemVisible,
|
|
39
|
-
} );
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
removeItem( itemId );
|
|
43
|
-
};
|
|
44
|
-
// Not adding deps for now, as it would require either a larger refactor.
|
|
45
|
-
// See https://github.com/WordPress/gutenberg/pull/41639
|
|
46
|
-
}, [ activeMenu, search ] );
|
|
47
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import type { NavigationMenuContext as NavigationMenuContextType } from '../types';
|
|
10
|
-
|
|
11
|
-
export const NavigationMenuContext = createContext< NavigationMenuContextType >(
|
|
12
|
-
{
|
|
13
|
-
menu: undefined,
|
|
14
|
-
search: '',
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
NavigationMenuContext.displayName = 'NavigationMenuContext';
|
|
18
|
-
|
|
19
|
-
export const useNavigationMenuContext = () =>
|
|
20
|
-
useContext( NavigationMenuContext );
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { ROOT_MENU } from '../constants';
|
|
15
|
-
import { NavigationMenuContext } from './context';
|
|
16
|
-
import { useNavigationContext } from '../context';
|
|
17
|
-
import { useNavigationTreeMenu } from './use-navigation-tree-menu';
|
|
18
|
-
import NavigationBackButton from '../back-button';
|
|
19
|
-
import NavigationMenuTitle from './menu-title';
|
|
20
|
-
import NavigationSearchNoResultsFound from './search-no-results-found';
|
|
21
|
-
import { NavigableMenu } from '../../navigable-container';
|
|
22
|
-
import { MenuUI } from '../styles/navigation-styles';
|
|
23
|
-
|
|
24
|
-
import type { NavigationMenuProps } from '../types';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated Use `Navigator` instead.
|
|
28
|
-
*/
|
|
29
|
-
export function NavigationMenu( props: NavigationMenuProps ) {
|
|
30
|
-
const {
|
|
31
|
-
backButtonLabel,
|
|
32
|
-
children,
|
|
33
|
-
className,
|
|
34
|
-
hasSearch,
|
|
35
|
-
menu = ROOT_MENU,
|
|
36
|
-
onBackButtonClick,
|
|
37
|
-
onSearch: setControlledSearch,
|
|
38
|
-
parentMenu,
|
|
39
|
-
search: controlledSearch,
|
|
40
|
-
isSearchDebouncing,
|
|
41
|
-
title,
|
|
42
|
-
titleAction,
|
|
43
|
-
} = props;
|
|
44
|
-
const [ uncontrolledSearch, setUncontrolledSearch ] = useState( '' );
|
|
45
|
-
useNavigationTreeMenu( props );
|
|
46
|
-
const { activeMenu } = useNavigationContext();
|
|
47
|
-
|
|
48
|
-
const context = {
|
|
49
|
-
menu,
|
|
50
|
-
search: uncontrolledSearch,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Keep the children rendered to make sure invisible items are included in the navigation tree.
|
|
54
|
-
if ( activeMenu !== menu ) {
|
|
55
|
-
return (
|
|
56
|
-
<NavigationMenuContext.Provider value={ context }>
|
|
57
|
-
{ children }
|
|
58
|
-
</NavigationMenuContext.Provider>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const isControlledSearch = !! setControlledSearch;
|
|
63
|
-
const search = isControlledSearch ? controlledSearch : uncontrolledSearch;
|
|
64
|
-
const onSearch = isControlledSearch
|
|
65
|
-
? setControlledSearch
|
|
66
|
-
: setUncontrolledSearch;
|
|
67
|
-
|
|
68
|
-
const menuTitleId = `components-navigation__menu-title-${ menu }`;
|
|
69
|
-
const classes = clsx( 'components-navigation__menu', className );
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<NavigationMenuContext.Provider value={ context }>
|
|
73
|
-
<MenuUI className={ classes }>
|
|
74
|
-
{ ( parentMenu || onBackButtonClick ) && (
|
|
75
|
-
<NavigationBackButton
|
|
76
|
-
backButtonLabel={ backButtonLabel }
|
|
77
|
-
parentMenu={ parentMenu }
|
|
78
|
-
onClick={ onBackButtonClick }
|
|
79
|
-
/>
|
|
80
|
-
) }
|
|
81
|
-
|
|
82
|
-
{ title && (
|
|
83
|
-
<NavigationMenuTitle
|
|
84
|
-
hasSearch={ hasSearch }
|
|
85
|
-
onSearch={ onSearch }
|
|
86
|
-
search={ search }
|
|
87
|
-
title={ title }
|
|
88
|
-
titleAction={ titleAction }
|
|
89
|
-
/>
|
|
90
|
-
) }
|
|
91
|
-
|
|
92
|
-
<NavigableMenu>
|
|
93
|
-
<ul aria-labelledby={ menuTitleId }>
|
|
94
|
-
{ children }
|
|
95
|
-
{ search && ! isSearchDebouncing && (
|
|
96
|
-
<NavigationSearchNoResultsFound search={ search } />
|
|
97
|
-
) }
|
|
98
|
-
</ul>
|
|
99
|
-
</NavigableMenu>
|
|
100
|
-
</MenuUI>
|
|
101
|
-
</NavigationMenuContext.Provider>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default NavigationMenu;
|