@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/build/tooltip/index.cjs
CHANGED
|
@@ -93,7 +93,8 @@ function UnforwardedTooltip(props, ref) {
|
|
|
93
93
|
render: children
|
|
94
94
|
}) : children;
|
|
95
95
|
}
|
|
96
|
-
function addDescribedById(
|
|
96
|
+
function addDescribedById(el) {
|
|
97
|
+
const element = el;
|
|
97
98
|
return describedById && mounted && element.props["aria-describedby"] === void 0 && element.props["aria-label"] !== text ? (0, import_element.cloneElement)(element, {
|
|
98
99
|
"aria-describedby": describedById
|
|
99
100
|
}) : element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/tooltip/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Children, useContext, forwardRef, cloneElement } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\nimport { TooltipInternalContext } from './context';\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const TOOLTIP_DELAY = 700;\nconst CONTEXT_VALUE = {\n isNestedInTooltip: true\n};\nfunction UnforwardedTooltip(props, ref) {\n const {\n children,\n className,\n delay = TOOLTIP_DELAY,\n hideOnClick = true,\n placement,\n position,\n shortcut,\n text,\n ...restProps\n } = props;\n const {\n isNestedInTooltip\n } = useContext(TooltipInternalContext);\n const baseId = useInstanceId(Tooltip, 'tooltip');\n const describedById = text || shortcut ? baseId : undefined;\n const isOnlyChild = Children.count(children) === 1;\n // console error if more than one child element is added\n if (!isOnlyChild) {\n if ('development' === process.env.NODE_ENV) {\n // eslint-disable-next-line no-console\n console.error('wp-components.Tooltip should be called with only a single child element.');\n }\n }\n\n // Compute tooltip's placement:\n // - give priority to `placement` prop, if defined\n // - otherwise, compute it from the legacy `position` prop (if defined)\n // - finally, fallback to the default placement: 'top'\n let computedPlacement;\n if (placement !== undefined) {\n computedPlacement = placement;\n } else if (position !== undefined) {\n computedPlacement = positionToPlacement(position);\n deprecated('`position` prop in wp.components.tooltip', {\n since: '6.4',\n alternative: '`placement` prop'\n });\n }\n computedPlacement = computedPlacement || 'top';\n const tooltipStore = Ariakit.useTooltipStore({\n placement: computedPlacement,\n showTimeout: delay\n });\n const mounted = Ariakit.useStoreState(tooltipStore, 'mounted');\n if (isNestedInTooltip) {\n return isOnlyChild ? /*#__PURE__*/_jsx(Ariakit.Role, {\n ...restProps,\n render: children\n }) : children;\n }\n\n // TODO: this is a temporary workaround to minimize the effects of the\n // Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to\n // the tooltip anchor anymore since 0.4.0, so we need to add it manually.\n // The `aria-describedby` attribute is added only if the anchor doesn't have\n // one already, and if the tooltip text is not the same as the anchor's\n // `aria-label`\n // See: https://github.com/WordPress/gutenberg/pull/64066\n // See: https://github.com/WordPress/gutenberg/pull/65989\n function addDescribedById(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,kBAAiB;AACjB,qBAA8B;AAC9B,qBAA+D;AAC/D,wBAAuB;AACvB,sBAAqB;AACrB,mBAAoC;AACpC,qBAAuC;AAKvC,yBAA2C;AACpC,IAAM,gBAAgB;AAC7B,IAAM,gBAAgB;AAAA,EACpB,mBAAmB;AACrB;AACA,SAAS,mBAAmB,OAAO,KAAK;AACtC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM;AAAA,IACJ;AAAA,EACF,QAAI,2BAAW,qCAAsB;AACrC,QAAM,aAAS,8BAAcA,UAAS,SAAS;AAC/C,QAAM,gBAAgB,QAAQ,WAAW,SAAS;AAClD,QAAM,cAAc,wBAAS,MAAM,QAAQ,MAAM;AAEjD,MAAI,CAAC,aAAa;AAChB,QAAI,kBAAkB,QAAQ,IAAI,UAAU;AAE1C,cAAQ,MAAM,0EAA0E;AAAA,IAC1F;AAAA,EACF;AAMA,MAAI;AACJ,MAAI,cAAc,QAAW;AAC3B,wBAAoB;AAAA,EACtB,WAAW,aAAa,QAAW;AACjC,4BAAoB,kCAAoB,QAAQ;AAChD,0BAAAC,SAAW,4CAA4C;AAAA,MACrD,OAAO;AAAA,MACP,aAAa;AAAA,IACf,CAAC;AAAA,EACH;AACA,sBAAoB,qBAAqB;AACzC,QAAM,eAAuB,wBAAgB;AAAA,IAC3C,WAAW;AAAA,IACX,aAAa;AAAA,EACf,CAAC;AACD,QAAM,UAAkB,sBAAc,cAAc,SAAS;AAC7D,MAAI,mBAAmB;AACrB,WAAO,cAA2B,uCAAAC,KAAa,cAAM;AAAA,MACnD,GAAG;AAAA,MACH,QAAQ;AAAA,IACV,CAAC,IAAI;AAAA,EACP;AAUA,WAAS,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\nimport { useInstanceId } from '@wordpress/compose';\nimport { Children, useContext, forwardRef, cloneElement } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\nimport Shortcut from '../shortcut';\nimport { positionToPlacement } from '../popover/utils';\nimport { TooltipInternalContext } from './context';\n\n/**\n * Time over anchor to wait before showing tooltip\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nexport const TOOLTIP_DELAY = 700;\nconst CONTEXT_VALUE = {\n isNestedInTooltip: true\n};\nfunction UnforwardedTooltip(props, ref) {\n const {\n children,\n className,\n delay = TOOLTIP_DELAY,\n hideOnClick = true,\n placement,\n position,\n shortcut,\n text,\n ...restProps\n } = props;\n const {\n isNestedInTooltip\n } = useContext(TooltipInternalContext);\n const baseId = useInstanceId(Tooltip, 'tooltip');\n const describedById = text || shortcut ? baseId : undefined;\n const isOnlyChild = Children.count(children) === 1;\n // console error if more than one child element is added\n if (!isOnlyChild) {\n if ('development' === process.env.NODE_ENV) {\n // eslint-disable-next-line no-console\n console.error('wp-components.Tooltip should be called with only a single child element.');\n }\n }\n\n // Compute tooltip's placement:\n // - give priority to `placement` prop, if defined\n // - otherwise, compute it from the legacy `position` prop (if defined)\n // - finally, fallback to the default placement: 'top'\n let computedPlacement;\n if (placement !== undefined) {\n computedPlacement = placement;\n } else if (position !== undefined) {\n computedPlacement = positionToPlacement(position);\n deprecated('`position` prop in wp.components.tooltip', {\n since: '6.4',\n alternative: '`placement` prop'\n });\n }\n computedPlacement = computedPlacement || 'top';\n const tooltipStore = Ariakit.useTooltipStore({\n placement: computedPlacement,\n showTimeout: delay\n });\n const mounted = Ariakit.useStoreState(tooltipStore, 'mounted');\n if (isNestedInTooltip) {\n return isOnlyChild ? /*#__PURE__*/_jsx(Ariakit.Role, {\n ...restProps,\n render: children\n }) : children;\n }\n\n // TODO: this is a temporary workaround to minimize the effects of the\n // Ariakit upgrade. Ariakit doesn't pass the `aria-describedby` prop to\n // the tooltip anchor anymore since 0.4.0, so we need to add it manually.\n // The `aria-describedby` attribute is added only if the anchor doesn't have\n // one already, and if the tooltip text is not the same as the anchor's\n // `aria-label`\n // See: https://github.com/WordPress/gutenberg/pull/64066\n // See: https://github.com/WordPress/gutenberg/pull/65989\n function addDescribedById(el) {\n const element = el;\n return describedById && mounted && element.props['aria-describedby'] === undefined && element.props['aria-label'] !== text ? cloneElement(element, {\n 'aria-describedby': describedById\n }) : element;\n }\n return /*#__PURE__*/_jsxs(TooltipInternalContext.Provider, {\n value: CONTEXT_VALUE,\n children: [/*#__PURE__*/_jsx(Ariakit.TooltipAnchor, {\n onClick: hideOnClick ? tooltipStore.hide : undefined,\n store: tooltipStore,\n render: isOnlyChild ? addDescribedById(children) : undefined,\n ref: ref,\n children: isOnlyChild ? undefined : children\n }), isOnlyChild && (text || shortcut) && /*#__PURE__*/_jsxs(Ariakit.Tooltip, {\n ...restProps,\n className: clsx('components-tooltip', className),\n unmountOnHide: true,\n gutter: 4,\n id: describedById,\n overflowPadding: 0.5,\n store: tooltipStore,\n children: [text, shortcut && /*#__PURE__*/_jsx(Shortcut, {\n className: text ? 'components-tooltip__shortcut' : '',\n shortcut: shortcut\n })]\n })]\n });\n}\nexport const Tooltip = forwardRef(UnforwardedTooltip);\nexport default Tooltip;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,kBAAiB;AACjB,qBAA8B;AAC9B,qBAA+D;AAC/D,wBAAuB;AACvB,sBAAqB;AACrB,mBAAoC;AACpC,qBAAuC;AAKvC,yBAA2C;AACpC,IAAM,gBAAgB;AAC7B,IAAM,gBAAgB;AAAA,EACpB,mBAAmB;AACrB;AACA,SAAS,mBAAmB,OAAO,KAAK;AACtC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM;AAAA,IACJ;AAAA,EACF,QAAI,2BAAW,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MAAc,iBAAS;AAAA,MAC3E,GAAG;AAAA,MACH,eAAW,YAAAC,SAAK,sBAAsB,SAAS;AAAA,MAC/C,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,IAAI;AAAA,MACJ,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,UAAU,CAAC,MAAM,YAAyB,uCAAAF,KAAK,gBAAAG,SAAU;AAAA,QACvD,WAAW,OAAO,iCAAiC;AAAA,QACnD;AAAA,MACF,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAML,eAAU,2BAAW,kBAAkB;AACpD,IAAO,kBAAQA;",
|
|
6
6
|
"names": ["Tooltip", "deprecated", "_jsx", "_jsxs", "clsx", "Shortcut"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// packages/components/src/autocomplete/index.tsx
|
|
2
2
|
import { renderToString, useEffect, useMemo, useReducer, useRef } from "@wordpress/element";
|
|
3
|
-
import { useInstanceId, useMergeRefs, useRefEffect } from "@wordpress/compose";
|
|
3
|
+
import { useInstanceId, useMergeRefs, useRefEffect, privateApis as composePrivateApis } from "@wordpress/compose";
|
|
4
4
|
import { create, slice, insert, isCollapsed, getTextContent } from "@wordpress/rich-text";
|
|
5
5
|
import { speak } from "@wordpress/a11y";
|
|
6
6
|
import { isAppleOS } from "@wordpress/keycodes";
|
|
@@ -8,7 +8,11 @@ import { AutocompleterUI } from "./autocompleter-ui.mjs";
|
|
|
8
8
|
import { getAutocompleteMatch } from "./get-autocomplete-match.mjs";
|
|
9
9
|
import { withIgnoreIMEEvents } from "../utils/with-ignore-ime-events.mjs";
|
|
10
10
|
import getNodeText from "../utils/get-node-text.mjs";
|
|
11
|
+
import { unlock } from "../lock-unlock.mjs";
|
|
11
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
var {
|
|
14
|
+
subscribeDelegatedListener
|
|
15
|
+
} = unlock(composePrivateApis);
|
|
12
16
|
var EMPTY_FILTERED_OPTIONS = [];
|
|
13
17
|
var AUTOCOMPLETE_HOOK_REFERENCE = {};
|
|
14
18
|
function getCompletionObject(completion) {
|
|
@@ -274,10 +278,7 @@ function useAutocompleteProps(options) {
|
|
|
274
278
|
function _onKeyDown(event) {
|
|
275
279
|
onKeyDownRef.current?.(event);
|
|
276
280
|
}
|
|
277
|
-
element
|
|
278
|
-
return () => {
|
|
279
|
-
element.removeEventListener("keydown", _onKeyDown);
|
|
280
|
-
};
|
|
281
|
+
return subscribeDelegatedListener(element, "keydown", _onKeyDown, true);
|
|
281
282
|
}, [])]);
|
|
282
283
|
const didUserInput = record.text !== previousRecord?.text;
|
|
283
284
|
if (!didUserInput) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/autocomplete/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { create, slice, insert, isCollapsed, getTextContent } from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { AutocompleterUI } from './autocompleter-ui';\nimport { getAutocompleteMatch } from './get-autocomplete-match';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport getNodeText from '../utils/get-node-text';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst EMPTY_FILTERED_OPTIONS = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\nfunction getCompletionObject(completion) {\n if (completion !== null && typeof completion === 'object' && 'action' in completion && completion.action !== undefined && 'value' in completion && completion.value !== undefined) {\n return completion;\n }\n return {\n action: 'insert-at-caret',\n value: completion\n };\n}\nconst initialState = {\n selectedIndex: 0,\n filteredOptions: EMPTY_FILTERED_OPTIONS,\n filterValue: '',\n autocompleter: null\n};\nfunction autocompleteReducer(state, action) {\n switch (action.type) {\n case 'RESET':\n return initialState;\n case 'SELECT':\n return {\n ...state,\n selectedIndex: action.index\n };\n case 'OPTIONS':\n return {\n ...state,\n filteredOptions: action.options,\n selectedIndex: action.options.length === state.filteredOptions.length ? state.selectedIndex : 0\n };\n case 'MATCH':\n return {\n ...state,\n autocompleter: action.completer,\n filterValue: action.query\n };\n }\n}\nexport function useAutocomplete({\n record,\n onChange,\n onReplace,\n completers,\n contentRef\n}) {\n const instanceId = useInstanceId(AUTOCOMPLETE_HOOK_REFERENCE);\n const [state, dispatch] = useReducer(autocompleteReducer, initialState);\n const {\n selectedIndex,\n filteredOptions,\n filterValue,\n autocompleter\n } = state;\n const backspacingRef = useRef(false);\n const prevRecordTextRef = useRef('');\n const lastCompletionRef = useRef(null);\n function insertCompletion(replacement) {\n if (autocompleter === null) {\n return '';\n }\n const end = record.start;\n const start = end - autocompleter.triggerPrefix.length - filterValue.length;\n const toInsert = create({\n html: renderToString(replacement)\n });\n onChange(insert(record, toInsert, start, end));\n return getTextContent(toInsert);\n }\n function select(option) {\n if (option.isDisabled || !autocompleter) {\n return;\n }\n const {\n getOptionCompletion\n } = autocompleter;\n if (!getOptionCompletion) {\n dispatch({\n type: 'RESET'\n });\n contentRef.current?.focus();\n return;\n }\n const completionObject = getCompletionObject(getOptionCompletion(option.value, filterValue));\n if ('replace' === completionObject.action) {\n onReplace([completionObject.value]);\n // When replacing, the component will unmount, so don't reset\n // state (below) on an unmounted component.\n return;\n }\n if ('insert-at-caret' === completionObject.action) {\n const completionText = insertCompletion(completionObject.value);\n // When the completion value starts with the trigger prefix\n // (e.g. @username), the trigger stays in the text and would\n // re-activate the autocompleter. Store the completed text so\n // the effect can suppress the stale re-match.\n if (completionText.startsWith(autocompleter.triggerPrefix)) {\n const afterPrefix = completionText.slice(autocompleter.triggerPrefix.length);\n if (afterPrefix) {\n lastCompletionRef.current = {\n name: autocompleter.name,\n value: afterPrefix\n };\n }\n }\n }\n\n // Reset autocomplete state after insertion rather than before\n // so insertion events don't cause the completion menu to redisplay.\n dispatch({\n type: 'RESET'\n });\n\n // Make sure that the content remains focused after making a selection\n // and that the text cursor position is not lost.\n contentRef.current?.focus();\n }\n function onChangeOptions(options) {\n dispatch({\n type: 'OPTIONS',\n options\n });\n }\n function handleKeyDown(event) {\n backspacingRef.current = event.key === 'Backspace';\n if (!autocompleter) {\n return;\n }\n if (filteredOptions.length === 0) {\n return;\n }\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const offset = event.key === 'ArrowUp' ? -1 : 1;\n const newIndex = (selectedIndex + offset + filteredOptions.length) % filteredOptions.length;\n dispatch({\n type: 'SELECT',\n index: newIndex\n });\n // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n if (isAppleOS()) {\n speak(getNodeText(filteredOptions[newIndex].label), 'assertive');\n }\n break;\n }\n case 'Escape':\n dispatch({\n type: 'RESET'\n });\n event.preventDefault();\n break;\n case 'Enter':\n select(filteredOptions[selectedIndex]);\n break;\n case 'ArrowLeft':\n case 'ArrowRight':\n dispatch({\n type: 'RESET'\n });\n return;\n default:\n return;\n }\n\n // Any handled key should prevent original behavior. This relies on\n // the early return in the default case.\n event.preventDefault();\n }\n\n // textContent is a primitive (string), memoizing is not strictly necessary\n // but this is a preemptive performance improvement, since the autocompleter\n // is a potential bottleneck for the editor type metric.\n const textContent = useMemo(() => {\n if (isCollapsed(record)) {\n return getTextContent(slice(record, 0));\n }\n return '';\n }, [record]);\n useEffect(() => {\n const isTextChange = record.text !== prevRecordTextRef.current;\n prevRecordTextRef.current = record.text;\n function getTextAfterSelection() {\n return textContent ? getTextContent(slice(record, undefined, getTextContent(record).length)) : '';\n }\n const match = getAutocompleteMatch(textContent, completers, {\n matchCount: filteredOptions.length,\n isBackspacing: backspacingRef.current,\n getTextAfterSelection,\n lastCompletion: lastCompletionRef.current\n });\n if (!match) {\n if (autocompleter) {\n dispatch({\n type: 'RESET'\n });\n }\n return;\n }\n const {\n completer,\n filterValue: query\n } = match;\n\n // Don't re-activate a dismissed autocompleter on cursor-only\n // movement. `textContent` (text before cursor) changes with the\n // caret, so the effect re-runs, but `record.text` does not.\n // Complements the render-time `didUserInput` gate in\n // `useAutocompleteProps` for callers using this hook directly.\n if (!autocompleter && !isTextChange) {\n return;\n }\n\n // Clear stale completion ref when the user types a new trigger\n // for the same completer (the previous completion is no longer\n // relevant). Must be after the cursor-only check so that mere\n // cursor movement doesn't discard the suppression state.\n if (lastCompletionRef.current && lastCompletionRef.current.name === completer.name) {\n lastCompletionRef.current = null;\n }\n dispatch({\n type: 'MATCH',\n completer,\n query\n });\n // We want to avoid introducing unexpected side effects.\n // See https://github.com/WordPress/gutenberg/pull/41820\n }, [textContent]);\n const {\n key: selectedKey = ''\n } = filteredOptions[selectedIndex] || {};\n const {\n className\n } = autocompleter || {};\n const isExpanded = !!autocompleter && filteredOptions.length > 0;\n const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` : undefined;\n const activeId = isExpanded ? `components-autocomplete-item-${instanceId}-${selectedKey}` : null;\n const hasSelection = record.start !== undefined;\n const showPopover = !!textContent && hasSelection && !!autocompleter;\n return {\n listBoxId,\n activeId,\n onKeyDown: withIgnoreIMEEvents(handleKeyDown),\n popover: showPopover && /*#__PURE__*/_jsx(AutocompleterUI, {\n autocompleter: autocompleter,\n className: className,\n filterValue: filterValue,\n instanceId: instanceId,\n listBoxId: listBoxId,\n selectedIndex: selectedIndex,\n onChangeOptions: onChangeOptions,\n onSelect: select,\n contentRef: contentRef,\n reset: () => dispatch({\n type: 'RESET'\n })\n }, autocompleter.name + autocompleter.triggerPrefix)\n };\n}\n\n/**\n * Checks whether two records represent the same user-visible state\n * (same text content and cursor position).\n */\nfunction recordValuesMatch(a, b) {\n return a.text === b.text && a.start === b.start && a.end === b.end;\n}\n\n/**\n * Tracks the last record whose value differed from the current one.\n * Used to determine whether the user has actually typed something\n */\nexport function useLastDifferentValue(value) {\n const history = useRef([]);\n const lastEntry = history.current[history.current.length - 1];\n\n // Only add to history if the value is meaningfully different from\n // the most recent entry (analogous to Set.add being a no-op for\n // duplicate references in the original implementation).\n if (!lastEntry || !recordValuesMatch(value, lastEntry)) {\n history.current.push(value);\n }\n\n // Keep the history size to 2.\n if (history.current.length > 2) {\n history.current.shift();\n }\n return history.current[0];\n}\nexport function useAutocompleteProps(options) {\n const ref = useRef(null);\n const onKeyDownRef = useRef(undefined);\n const {\n record\n } = options;\n const previousRecord = useLastDifferentValue(record);\n const {\n popover,\n listBoxId,\n activeId,\n onKeyDown\n } = useAutocomplete({\n ...options,\n contentRef: ref\n });\n onKeyDownRef.current = onKeyDown;\n const mergedRefs = useMergeRefs([ref, useRefEffect(element => {\n function _onKeyDown(event) {\n onKeyDownRef.current?.(event);\n }\n element.addEventListener('keydown', _onKeyDown);\n return () => {\n element.removeEventListener('keydown', _onKeyDown);\n };\n }, [])]);\n\n // We only want to show the popover if the user has typed something.\n const didUserInput = record.text !== previousRecord?.text;\n if (!didUserInput) {\n return {\n ref: mergedRefs\n };\n }\n return {\n ref: mergedRefs,\n children: popover,\n 'aria-autocomplete': listBoxId ? 'list' : undefined,\n 'aria-owns': listBoxId,\n 'aria-activedescendant': activeId\n };\n}\nexport default function Autocomplete({\n children,\n isSelected,\n ...options\n}) {\n const {\n popover,\n ...props\n } = useAutocomplete(options);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children(props), isSelected && popover]\n });\n}"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,gBAAgB,WAAW,SAAS,YAAY,cAAc;AACvE,SAAS,eAAe,cAAc,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useEffect, useMemo, useReducer, useRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs, useRefEffect, privateApis as composePrivateApis } from '@wordpress/compose';\nimport { create, slice, insert, isCollapsed, getTextContent } from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\nimport { isAppleOS } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { AutocompleterUI } from './autocompleter-ui';\nimport { getAutocompleteMatch } from './get-autocomplete-match';\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\nimport getNodeText from '../utils/get-node-text';\nimport { unlock } from '../lock-unlock';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst {\n subscribeDelegatedListener\n} = unlock(composePrivateApis);\nconst EMPTY_FILTERED_OPTIONS = [];\n\n// Used for generating the instance ID\nconst AUTOCOMPLETE_HOOK_REFERENCE = {};\nfunction getCompletionObject(completion) {\n if (completion !== null && typeof completion === 'object' && 'action' in completion && completion.action !== undefined && 'value' in completion && completion.value !== undefined) {\n return completion;\n }\n return {\n action: 'insert-at-caret',\n value: completion\n };\n}\nconst initialState = {\n selectedIndex: 0,\n filteredOptions: EMPTY_FILTERED_OPTIONS,\n filterValue: '',\n autocompleter: null\n};\nfunction autocompleteReducer(state, action) {\n switch (action.type) {\n case 'RESET':\n return initialState;\n case 'SELECT':\n return {\n ...state,\n selectedIndex: action.index\n };\n case 'OPTIONS':\n return {\n ...state,\n filteredOptions: action.options,\n selectedIndex: action.options.length === state.filteredOptions.length ? state.selectedIndex : 0\n };\n case 'MATCH':\n return {\n ...state,\n autocompleter: action.completer,\n filterValue: action.query\n };\n }\n}\nexport function useAutocomplete({\n record,\n onChange,\n onReplace,\n completers,\n contentRef\n}) {\n const instanceId = useInstanceId(AUTOCOMPLETE_HOOK_REFERENCE);\n const [state, dispatch] = useReducer(autocompleteReducer, initialState);\n const {\n selectedIndex,\n filteredOptions,\n filterValue,\n autocompleter\n } = state;\n const backspacingRef = useRef(false);\n const prevRecordTextRef = useRef('');\n const lastCompletionRef = useRef(null);\n function insertCompletion(replacement) {\n if (autocompleter === null) {\n return '';\n }\n const end = record.start;\n const start = end - autocompleter.triggerPrefix.length - filterValue.length;\n const toInsert = create({\n html: renderToString(replacement)\n });\n onChange(insert(record, toInsert, start, end));\n return getTextContent(toInsert);\n }\n function select(option) {\n if (option.isDisabled || !autocompleter) {\n return;\n }\n const {\n getOptionCompletion\n } = autocompleter;\n if (!getOptionCompletion) {\n dispatch({\n type: 'RESET'\n });\n contentRef.current?.focus();\n return;\n }\n const completionObject = getCompletionObject(getOptionCompletion(option.value, filterValue));\n if ('replace' === completionObject.action) {\n onReplace([completionObject.value]);\n // When replacing, the component will unmount, so don't reset\n // state (below) on an unmounted component.\n return;\n }\n if ('insert-at-caret' === completionObject.action) {\n const completionText = insertCompletion(completionObject.value);\n // When the completion value starts with the trigger prefix\n // (e.g. @username), the trigger stays in the text and would\n // re-activate the autocompleter. Store the completed text so\n // the effect can suppress the stale re-match.\n if (completionText.startsWith(autocompleter.triggerPrefix)) {\n const afterPrefix = completionText.slice(autocompleter.triggerPrefix.length);\n if (afterPrefix) {\n lastCompletionRef.current = {\n name: autocompleter.name,\n value: afterPrefix\n };\n }\n }\n }\n\n // Reset autocomplete state after insertion rather than before\n // so insertion events don't cause the completion menu to redisplay.\n dispatch({\n type: 'RESET'\n });\n\n // Make sure that the content remains focused after making a selection\n // and that the text cursor position is not lost.\n contentRef.current?.focus();\n }\n function onChangeOptions(options) {\n dispatch({\n type: 'OPTIONS',\n options\n });\n }\n function handleKeyDown(event) {\n backspacingRef.current = event.key === 'Backspace';\n if (!autocompleter) {\n return;\n }\n if (filteredOptions.length === 0) {\n return;\n }\n if (event.defaultPrevented) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const offset = event.key === 'ArrowUp' ? -1 : 1;\n const newIndex = (selectedIndex + offset + filteredOptions.length) % filteredOptions.length;\n dispatch({\n type: 'SELECT',\n index: newIndex\n });\n // See the related PR as to why this is necessary: https://github.com/WordPress/gutenberg/pull/54902.\n if (isAppleOS()) {\n speak(getNodeText(filteredOptions[newIndex].label), 'assertive');\n }\n break;\n }\n case 'Escape':\n dispatch({\n type: 'RESET'\n });\n event.preventDefault();\n break;\n case 'Enter':\n select(filteredOptions[selectedIndex]);\n break;\n case 'ArrowLeft':\n case 'ArrowRight':\n dispatch({\n type: 'RESET'\n });\n return;\n default:\n return;\n }\n\n // Any handled key should prevent original behavior. This relies on\n // the early return in the default case.\n event.preventDefault();\n }\n\n // textContent is a primitive (string), memoizing is not strictly necessary\n // but this is a preemptive performance improvement, since the autocompleter\n // is a potential bottleneck for the editor type metric.\n const textContent = useMemo(() => {\n if (isCollapsed(record)) {\n return getTextContent(slice(record, 0));\n }\n return '';\n }, [record]);\n useEffect(() => {\n const isTextChange = record.text !== prevRecordTextRef.current;\n prevRecordTextRef.current = record.text;\n function getTextAfterSelection() {\n return textContent ? getTextContent(slice(record, undefined, getTextContent(record).length)) : '';\n }\n const match = getAutocompleteMatch(textContent, completers, {\n matchCount: filteredOptions.length,\n isBackspacing: backspacingRef.current,\n getTextAfterSelection,\n lastCompletion: lastCompletionRef.current\n });\n if (!match) {\n if (autocompleter) {\n dispatch({\n type: 'RESET'\n });\n }\n return;\n }\n const {\n completer,\n filterValue: query\n } = match;\n\n // Don't re-activate a dismissed autocompleter on cursor-only\n // movement. `textContent` (text before cursor) changes with the\n // caret, so the effect re-runs, but `record.text` does not.\n // Complements the render-time `didUserInput` gate in\n // `useAutocompleteProps` for callers using this hook directly.\n if (!autocompleter && !isTextChange) {\n return;\n }\n\n // Clear stale completion ref when the user types a new trigger\n // for the same completer (the previous completion is no longer\n // relevant). Must be after the cursor-only check so that mere\n // cursor movement doesn't discard the suppression state.\n if (lastCompletionRef.current && lastCompletionRef.current.name === completer.name) {\n lastCompletionRef.current = null;\n }\n dispatch({\n type: 'MATCH',\n completer,\n query\n });\n // We want to avoid introducing unexpected side effects.\n // See https://github.com/WordPress/gutenberg/pull/41820\n }, [textContent]);\n const {\n key: selectedKey = ''\n } = filteredOptions[selectedIndex] || {};\n const {\n className\n } = autocompleter || {};\n const isExpanded = !!autocompleter && filteredOptions.length > 0;\n const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` : undefined;\n const activeId = isExpanded ? `components-autocomplete-item-${instanceId}-${selectedKey}` : null;\n const hasSelection = record.start !== undefined;\n const showPopover = !!textContent && hasSelection && !!autocompleter;\n return {\n listBoxId,\n activeId,\n onKeyDown: withIgnoreIMEEvents(handleKeyDown),\n popover: showPopover && /*#__PURE__*/_jsx(AutocompleterUI, {\n autocompleter: autocompleter,\n className: className,\n filterValue: filterValue,\n instanceId: instanceId,\n listBoxId: listBoxId,\n selectedIndex: selectedIndex,\n onChangeOptions: onChangeOptions,\n onSelect: select,\n contentRef: contentRef,\n reset: () => dispatch({\n type: 'RESET'\n })\n }, autocompleter.name + autocompleter.triggerPrefix)\n };\n}\n\n/**\n * Checks whether two records represent the same user-visible state\n * (same text content and cursor position).\n */\nfunction recordValuesMatch(a, b) {\n return a.text === b.text && a.start === b.start && a.end === b.end;\n}\n\n/**\n * Tracks the last record whose value differed from the current one.\n * Used to determine whether the user has actually typed something\n */\nexport function useLastDifferentValue(value) {\n const history = useRef([]);\n const lastEntry = history.current[history.current.length - 1];\n\n // Only add to history if the value is meaningfully different from\n // the most recent entry (analogous to Set.add being a no-op for\n // duplicate references in the original implementation).\n if (!lastEntry || !recordValuesMatch(value, lastEntry)) {\n history.current.push(value);\n }\n\n // Keep the history size to 2.\n if (history.current.length > 2) {\n history.current.shift();\n }\n return history.current[0];\n}\nexport function useAutocompleteProps(options) {\n const ref = useRef(null);\n const onKeyDownRef = useRef(undefined);\n const {\n record\n } = options;\n const previousRecord = useLastDifferentValue(record);\n const {\n popover,\n listBoxId,\n activeId,\n onKeyDown\n } = useAutocomplete({\n ...options,\n contentRef: ref\n });\n onKeyDownRef.current = onKeyDown;\n const mergedRefs = useMergeRefs([ref, useRefEffect(element => {\n function _onKeyDown(event) {\n onKeyDownRef.current?.(event);\n }\n // Capture phase. When the autocomplete popover is open,\n // Up/Down/Enter/Escape must navigate the completion list \u2014\n // they shouldn't be consumed by ancestor handlers (e.g.\n // block-editor's writing-flow) for block navigation, block\n // splitting, or \"move out of parent\" actions. Those handlers\n // fire at bubble phase and gate on `event.defaultPrevented`,\n // so firing in capture lets us preventDefault first when the\n // popover is active.\n return subscribeDelegatedListener(element, 'keydown', _onKeyDown, true);\n }, [])]);\n\n // We only want to show the popover if the user has typed something.\n const didUserInput = record.text !== previousRecord?.text;\n if (!didUserInput) {\n return {\n ref: mergedRefs\n };\n }\n return {\n ref: mergedRefs,\n children: popover,\n 'aria-autocomplete': listBoxId ? 'list' : undefined,\n 'aria-owns': listBoxId,\n 'aria-activedescendant': activeId\n };\n}\nexport default function Autocomplete({\n children,\n isSelected,\n ...options\n}) {\n const {\n popover,\n ...props\n } = useAutocomplete(options);\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [children(props), isSelected && popover]\n });\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB,WAAW,SAAS,YAAY,cAAc;AACvE,SAAS,eAAe,cAAc,cAAc,eAAe,0BAA0B;AAC7F,SAAS,QAAQ,OAAO,QAAQ,aAAa,sBAAsB;AACnE,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAK1B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,iBAAiB;AACxB,SAAS,cAAc;AACvB,SAAS,OAAO,MAAM,YAAY,WAAW,QAAQ,aAAa;AAClE,IAAM;AAAA,EACJ;AACF,IAAI,OAAO,kBAAkB;AAC7B,IAAM,yBAAyB,CAAC;AAGhC,IAAM,8BAA8B,CAAC;AACrC,SAAS,oBAAoB,YAAY;AACvC,MAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,YAAY,cAAc,WAAW,WAAW,UAAa,WAAW,cAAc,WAAW,UAAU,QAAW;AACjL,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,QAAQ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AAQ,MAAM;AAAA,EACxB;AACA,SAAO,QAAQ,QAAQ,CAAC;AAC1B;AACO,SAAS,qBAAqB,SAAS;AAC5C,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,eAAe,OAAO,MAAS;AACrC,QAAM;AAAA,IACJ;AAAA,EACF,IAAI;AACJ,QAAM,iBAAiB,sBAAsB,MAAM;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,gBAAgB;AAAA,IAClB,GAAG;AAAA,IACH,YAAY;AAAA,EACd,CAAC;AACD,eAAa,UAAU;AACvB,QAAM,aAAa,aAAa,CAAC,KAAK,aAAa,aAAW;AAC5D,aAAS,WAAW,OAAO;AACzB,mBAAa,UAAU,KAAK;AAAA,IAC9B;AASA,WAAO,2BAA2B,SAAS,WAAW,YAAY,IAAI;AAAA,EACxE,GAAG,CAAC,CAAC,CAAC,CAAC;AAGP,QAAM,eAAe,OAAO,SAAS,gBAAgB;AACrD,MAAI,CAAC,cAAc;AACjB,WAAO;AAAA,MACL,KAAK;AAAA,IACP;AAAA,EACF;AACA,SAAO;AAAA,IACL,KAAK;AAAA,IACL,UAAU;AAAA,IACV,qBAAqB,YAAY,SAAS;AAAA,IAC1C,aAAa;AAAA,IACb,yBAAyB;AAAA,EAC3B;AACF;AACe,SAAR,aAA8B;AAAA,EACnC;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM;AAAA,IACJ;AAAA,IACA,GAAG;AAAA,EACL,IAAI,gBAAgB,OAAO;AAC3B,SAAoB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAC,SAAS,KAAK,GAAG,cAAc,OAAO;AAAA,EACnD,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,7 +10,7 @@ import { contextConnect } from "../../context/index.mjs";
|
|
|
10
10
|
import { useBorderControlDropdown } from "./hook.mjs";
|
|
11
11
|
import DropdownContentWrapper from "../../dropdown/dropdown-content-wrapper.mjs";
|
|
12
12
|
import { isMultiplePaletteArray } from "../../color-palette/utils.mjs";
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
var getAriaLabelColorValue = (colorValue) => {
|
|
15
15
|
return colorValue.replace(/^var\((.+)\)$/, "$1");
|
|
16
16
|
};
|
|
@@ -99,6 +99,8 @@ var BorderControlDropdown = (props, forwardedRef) => {
|
|
|
99
99
|
resetButtonWrapperClassName,
|
|
100
100
|
size,
|
|
101
101
|
__unstablePopoverProps,
|
|
102
|
+
onToggle: onToggleProp,
|
|
103
|
+
// Remove from `otherProps` to avoid type errors (native HTML `onToggle` vs `Dropdown` `onToggle`).
|
|
102
104
|
...otherProps
|
|
103
105
|
} = useBorderControlDropdown(props);
|
|
104
106
|
const {
|
|
@@ -127,40 +129,38 @@ var BorderControlDropdown = (props, forwardedRef) => {
|
|
|
127
129
|
})
|
|
128
130
|
})
|
|
129
131
|
});
|
|
130
|
-
const renderContent = () => /* @__PURE__ */
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
onChange: onStyleChange
|
|
149
|
-
})]
|
|
150
|
-
}), /* @__PURE__ */ _jsx("div", {
|
|
151
|
-
className: resetButtonWrapperClassName,
|
|
152
|
-
children: /* @__PURE__ */ _jsx(Button, {
|
|
153
|
-
variant: "tertiary",
|
|
154
|
-
onClick: () => {
|
|
155
|
-
onReset();
|
|
156
|
-
},
|
|
157
|
-
disabled: !enableResetButton,
|
|
158
|
-
accessibleWhenDisabled: true,
|
|
159
|
-
__next40pxDefaultSize: true,
|
|
160
|
-
children: __("Reset")
|
|
161
|
-
})
|
|
132
|
+
const renderContent = () => /* @__PURE__ */ _jsxs(DropdownContentWrapper, {
|
|
133
|
+
paddingSize: "medium",
|
|
134
|
+
children: [/* @__PURE__ */ _jsxs(VStack, {
|
|
135
|
+
className: popoverControlsClassName,
|
|
136
|
+
spacing: 6,
|
|
137
|
+
children: [/* @__PURE__ */ _jsx(ColorPalette, {
|
|
138
|
+
className: popoverContentClassName,
|
|
139
|
+
value: color,
|
|
140
|
+
onChange: onColorChange,
|
|
141
|
+
colors,
|
|
142
|
+
disableCustomColors,
|
|
143
|
+
__experimentalIsRenderedInSidebar,
|
|
144
|
+
clearable: false,
|
|
145
|
+
enableAlpha
|
|
146
|
+
}), enableStyle && isStyleSettable && /* @__PURE__ */ _jsx(BorderControlStylePicker, {
|
|
147
|
+
label: __("Style"),
|
|
148
|
+
value: style,
|
|
149
|
+
onChange: onStyleChange
|
|
162
150
|
})]
|
|
163
|
-
})
|
|
151
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
152
|
+
className: resetButtonWrapperClassName,
|
|
153
|
+
children: /* @__PURE__ */ _jsx(Button, {
|
|
154
|
+
variant: "tertiary",
|
|
155
|
+
onClick: () => {
|
|
156
|
+
onReset();
|
|
157
|
+
},
|
|
158
|
+
disabled: !enableResetButton,
|
|
159
|
+
accessibleWhenDisabled: true,
|
|
160
|
+
__next40pxDefaultSize: true,
|
|
161
|
+
children: __("Reset")
|
|
162
|
+
})
|
|
163
|
+
})]
|
|
164
164
|
});
|
|
165
165
|
return /* @__PURE__ */ _jsx(Dropdown, {
|
|
166
166
|
renderToggle,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/border-control/border-control-dropdown/component.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { VStack } from '../../v-stack';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport { jsx as _jsx, jsxs as _jsxs
|
|
5
|
-
"mappings": ";AAOA,SAAS,IAAI,eAAe;AAK5B,OAAO,8BAA8B;AACrC,OAAO,YAAY;AACnB,OAAO,oBAAoB;AAC3B,OAAO,kBAAkB;AACzB,OAAO,cAAc;AACrB,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,OAAO,4BAA4B;AACnC,SAAS,8BAA8B;AACvC,SAAS,OAAO,MAAM,QAAQ,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderControlStylePicker from '../border-control-style-picker';\nimport Button from '../../button';\nimport ColorIndicator from '../../color-indicator';\nimport ColorPalette from '../../color-palette';\nimport Dropdown from '../../dropdown';\nimport { VStack } from '../../v-stack';\nimport { contextConnect } from '../../context';\nimport { useBorderControlDropdown } from './hook';\nimport DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';\nimport { isMultiplePaletteArray } from '../../color-palette/utils';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst getAriaLabelColorValue = colorValue => {\n // Leave hex values as-is. Remove the `var()` wrapper from CSS vars.\n return colorValue.replace(/^var\\((.+)\\)$/, '$1');\n};\nconst getColorObject = (colorValue, colors) => {\n if (!colorValue || !colors) {\n return;\n }\n if (isMultiplePaletteArray(colors)) {\n // Multiple origins\n let matchedColor;\n colors.some(origin => origin.colors.some(color => {\n if (color.color === colorValue) {\n matchedColor = color;\n return true;\n }\n return false;\n }));\n return matchedColor;\n }\n\n // Single origin\n return colors.find(color => color.color === colorValue);\n};\nconst getToggleAriaLabel = (colorValue, colorObject, style, isStyleEnabled) => {\n if (isStyleEnabled) {\n if (colorObject) {\n const ariaLabelValue = getAriaLabelColorValue(colorObject.color);\n return style ? sprintf(\n // translators: 1: The name of the color e.g. \"vivid red\". 2: The color's hex code e.g.: \"#f00:\". 3: The current border style selection e.g. \"solid\".\n __('Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\". The currently selected style is \"%3$s\".'), colorObject.name, ariaLabelValue, style) : sprintf(\n // translators: 1: The name of the color e.g. \"vivid red\". 2: The color's hex code e.g.: \"#f00:\".\n __('Border color and style picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'), colorObject.name, ariaLabelValue);\n }\n if (colorValue) {\n const ariaLabelValue = getAriaLabelColorValue(colorValue);\n return style ? sprintf(\n // translators: 1: The color's hex code e.g.: \"#f00:\". 2: The current border style selection e.g. \"solid\".\n __('Border color and style picker. The currently selected color has a value of \"%1$s\". The currently selected style is \"%2$s\".'), ariaLabelValue, style) : sprintf(\n // translators: %s: The color's hex code e.g: \"#f00\".\n __('Border color and style picker. The currently selected color has a value of \"%s\".'), ariaLabelValue);\n }\n return __('Border color and style picker.');\n }\n if (colorObject) {\n return sprintf(\n // translators: 1: The name of the color e.g. \"vivid red\". 2: The color's hex code e.g: \"#f00\".\n __('Border color picker. The currently selected color is called \"%1$s\" and has a value of \"%2$s\".'), colorObject.name, getAriaLabelColorValue(colorObject.color));\n }\n if (colorValue) {\n return sprintf(\n // translators: %s: The color's hex code e.g: \"#f00\".\n __('Border color picker. The currently selected color has a value of \"%s\".'), getAriaLabelColorValue(colorValue));\n }\n return __('Border color picker.');\n};\nconst BorderControlDropdown = (props, forwardedRef) => {\n const {\n __experimentalIsRenderedInSidebar,\n border,\n colors,\n disableCustomColors,\n enableAlpha,\n enableStyle,\n indicatorClassName,\n indicatorWrapperClassName,\n isStyleSettable,\n onReset,\n onColorChange,\n onStyleChange,\n popoverContentClassName,\n popoverControlsClassName,\n resetButtonWrapperClassName,\n size,\n __unstablePopoverProps,\n onToggle: onToggleProp,\n // Remove from `otherProps` to avoid type errors (native HTML `onToggle` vs `Dropdown` `onToggle`).\n ...otherProps\n } = useBorderControlDropdown(props);\n const {\n color,\n style\n } = border || {};\n const colorObject = getColorObject(color, colors);\n const toggleAriaLabel = getToggleAriaLabel(color, colorObject, style, enableStyle);\n const enableResetButton = color || style && style !== 'none';\n const dropdownPosition = __experimentalIsRenderedInSidebar ? 'bottom left' : undefined;\n const renderToggle = ({\n onToggle\n }) => /*#__PURE__*/_jsx(Button, {\n onClick: onToggle,\n variant: \"tertiary\",\n \"aria-label\": toggleAriaLabel,\n tooltipPosition: dropdownPosition,\n label: __('Border color and style picker'),\n showTooltip: true,\n __next40pxDefaultSize: size === '__unstable-large',\n children: /*#__PURE__*/_jsx(\"span\", {\n className: indicatorWrapperClassName,\n children: /*#__PURE__*/_jsx(ColorIndicator, {\n className: indicatorClassName,\n colorValue: color\n })\n })\n });\n const renderContent = () => /*#__PURE__*/_jsxs(DropdownContentWrapper, {\n paddingSize: \"medium\",\n children: [/*#__PURE__*/_jsxs(VStack, {\n className: popoverControlsClassName,\n spacing: 6,\n children: [/*#__PURE__*/_jsx(ColorPalette, {\n className: popoverContentClassName,\n value: color,\n onChange: onColorChange,\n colors,\n disableCustomColors,\n __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,\n clearable: false,\n enableAlpha: enableAlpha\n }), enableStyle && isStyleSettable && /*#__PURE__*/_jsx(BorderControlStylePicker, {\n label: __('Style'),\n value: style,\n onChange: onStyleChange\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: resetButtonWrapperClassName,\n children: /*#__PURE__*/_jsx(Button, {\n variant: \"tertiary\",\n onClick: () => {\n onReset();\n },\n disabled: !enableResetButton,\n accessibleWhenDisabled: true,\n __next40pxDefaultSize: true,\n children: __('Reset')\n })\n })]\n });\n return /*#__PURE__*/_jsx(Dropdown, {\n renderToggle: renderToggle,\n renderContent: renderContent,\n popoverProps: {\n ...__unstablePopoverProps\n },\n ...otherProps,\n ref: forwardedRef\n });\n};\nconst ConnectedBorderControlDropdown = contextConnect(BorderControlDropdown, 'BorderControlDropdown');\nexport default ConnectedBorderControlDropdown;"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,IAAI,eAAe;AAK5B,OAAO,8BAA8B;AACrC,OAAO,YAAY;AACnB,OAAO,oBAAoB;AAC3B,OAAO,kBAAkB;AACzB,OAAO,cAAc;AACrB,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,gCAAgC;AACzC,OAAO,4BAA4B;AACnC,SAAS,8BAA8B;AACvC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,yBAAyB,gBAAc;AAE3C,SAAO,WAAW,QAAQ,iBAAiB,IAAI;AACjD;AACA,IAAM,iBAAiB,CAAC,YAAY,WAAW;AAC7C,MAAI,CAAC,cAAc,CAAC,QAAQ;AAC1B;AAAA,EACF;AACA,MAAI,uBAAuB,MAAM,GAAG;AAElC,QAAI;AACJ,WAAO,KAAK,YAAU,OAAO,OAAO,KAAK,WAAS;AAChD,UAAI,MAAM,UAAU,YAAY;AAC9B,uBAAe;AACf,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC,CAAC;AACF,WAAO;AAAA,EACT;AAGA,SAAO,OAAO,KAAK,WAAS,MAAM,UAAU,UAAU;AACxD;AACA,IAAM,qBAAqB,CAAC,YAAY,aAAa,OAAO,mBAAmB;AAC7E,MAAI,gBAAgB;AAClB,QAAI,aAAa;AACf,YAAM,iBAAiB,uBAAuB,YAAY,KAAK;AAC/D,aAAO,QAAQ;AAAA;AAAA,QAEf,GAAG,iJAAiJ;AAAA,QAAG,YAAY;AAAA,QAAM;AAAA,QAAgB;AAAA,MAAK,IAAI;AAAA;AAAA,QAElM,GAAG,yGAAyG;AAAA,QAAG,YAAY;AAAA,QAAM;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@ -13,7 +13,6 @@ import { DEFAULT_VALUES, isValueMixed, isValuesDefined, getAllowedSides } from "
|
|
|
13
13
|
import { useControlledState } from "../utils/hooks/index.mjs";
|
|
14
14
|
import { maybeWarnDeprecated36pxSize } from "../utils/deprecated-36px-size.mjs";
|
|
15
15
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
import { applyValueToSides } from "./utils.mjs";
|
|
17
16
|
var defaultInputProps = {
|
|
18
17
|
min: 0
|
|
19
18
|
};
|
|
@@ -141,7 +140,6 @@ function BoxControl({
|
|
|
141
140
|
}
|
|
142
141
|
var box_control_default = BoxControl;
|
|
143
142
|
export {
|
|
144
|
-
applyValueToSides,
|
|
145
143
|
box_control_default as default
|
|
146
144
|
};
|
|
147
145
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/box-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport { InputWrapper, ResetButton, LinkedButtonWrapper } from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport { DEFAULT_VALUES, isValueMixed, isValuesDefined, getAllowedSides } from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst defaultInputProps = {\n min: 0\n};\nconst noop = () => {};\nfunction useUniqueId(idProp) {\n const instanceId = useInstanceId(BoxControl, 'inspector-box-control');\n return idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl({\n __next40pxDefaultSize = false,\n id: idProp,\n inputProps = defaultInputProps,\n onChange = noop,\n label = __('Box Control'),\n values: valuesProp,\n units,\n sides,\n splitOnAxis = false,\n allowReset = true,\n resetValues = DEFAULT_VALUES,\n presets,\n presetKey,\n onMouseOver,\n onMouseOut\n}) {\n const [values, setValues] = useControlledState(valuesProp, {\n fallback: DEFAULT_VALUES\n });\n const inputValues = values || DEFAULT_VALUES;\n const hasInitialValue = isValuesDefined(valuesProp);\n const hasOneSide = sides?.length === 1;\n const [isDirty, setIsDirty] = useState(hasInitialValue);\n const [isLinked, setIsLinked] = useState(!hasInitialValue || !isValueMixed(inputValues) || hasOneSide);\n\n // Tracking selected units via internal state allows filtering of CSS unit\n // only values from being saved while maintaining preexisting unit selection\n // behaviour. Filtering CSS only values prevents invalid style values.\n const [selectedUnits, setSelectedUnits] = useState({\n top: parseQuantityAndUnitFromRawValue(valuesProp?.top)[1],\n right: parseQuantityAndUnitFromRawValue(valuesProp?.right)[1],\n bottom: parseQuantityAndUnitFromRawValue(valuesProp?.bottom)[1],\n left: parseQuantityAndUnitFromRawValue(valuesProp?.left)[1]\n });\n const id = useUniqueId(idProp);\n const headingId = `${id}-heading`;\n const toggleLinked = () => {\n setIsLinked(!isLinked);\n };\n const handleOnChange = nextValues => {\n onChange(nextValues);\n setValues(nextValues);\n setIsDirty(true);\n };\n const handleOnReset = () => {\n onChange(resetValues);\n setValues(resetValues);\n setSelectedUnits(resetValues);\n setIsDirty(false);\n };\n const inputControlProps = {\n onMouseOver,\n onMouseOut,\n ...inputProps,\n onChange: handleOnChange,\n isLinked,\n units,\n selectedUnits,\n setSelectedUnits,\n sides,\n values: inputValues,\n __next40pxDefaultSize,\n presets,\n presetKey\n };\n maybeWarnDeprecated36pxSize({\n componentName: 'BoxControl',\n __next40pxDefaultSize,\n size: undefined\n });\n const sidesToRender = getAllowedSides(sides);\n if (presets && !presetKey || !presets && presetKey) {\n const definedProp = presets ? 'presets' : 'presetKey';\n const missingProp = presets ? 'presetKey' : 'presets';\n globalThis.SCRIPT_DEBUG === true ? warning(`wp.components.BoxControl: the '${missingProp}' prop is required when the '${definedProp}' prop is defined.`) : void 0;\n }\n return /*#__PURE__*/_jsxs(Grid, {\n id: id,\n columns: 3,\n templateColumns: \"1fr min-content min-content\",\n role: \"group\",\n \"aria-labelledby\": headingId,\n children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n id: headingId,\n children: label\n }), isLinked && /*#__PURE__*/_jsx(InputWrapper, {\n children: /*#__PURE__*/_jsx(InputControl, {\n side: \"all\",\n ...inputControlProps\n })\n }), !hasOneSide && /*#__PURE__*/_jsx(LinkedButtonWrapper, {\n children: /*#__PURE__*/_jsx(LinkedButton, {\n onClick: toggleLinked,\n isLinked: isLinked\n })\n }), !isLinked && splitOnAxis && ['vertical', 'horizontal'].map(axis =>\n /*#__PURE__*/\n // Disable reason: the parent component is handling the __next40pxDefaultSize prop\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(InputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), !isLinked && !splitOnAxis && Array.from(sidesToRender).map(axis =>\n /*#__PURE__*/\n // Disable reason: the parent component is handling the __next40pxDefaultSize prop\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(InputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), allowReset && /*#__PURE__*/_jsx(ResetButton, {\n className: \"component-box-control__reset-button\",\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n disabled: !isDirty,\n children: __('Reset')\n })]\n });\n}\nexport
|
|
5
|
-
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,OAAO,aAAa;AAKpB,SAAS,mBAAmB;AAC5B,OAAO,kBAAkB;AACzB,OAAO,kBAAkB;AACzB,SAAS,YAAY;AACrB,SAAS,cAAc,aAAa,2BAA2B;AAC/D,SAAS,wCAAwC;AACjD,SAAS,gBAAgB,cAAc,iBAAiB,uBAAuB;AAC/E,SAAS,0BAA0B;AACnC,SAAS,mCAAmC;AAC5C,SAAS,OAAO,MAAM,QAAQ,aAAa;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport InputControl from './input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport { InputWrapper, ResetButton, LinkedButtonWrapper } from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport { DEFAULT_VALUES, isValueMixed, isValuesDefined, getAllowedSides } from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst defaultInputProps = {\n min: 0\n};\nconst noop = () => {};\nfunction useUniqueId(idProp) {\n const instanceId = useInstanceId(BoxControl, 'inspector-box-control');\n return idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl\n * __next40pxDefaultSize\n * values={ values }\n * onChange={ setValues }\n * />\n * );\n * };\n * ```\n */\nfunction BoxControl({\n __next40pxDefaultSize = false,\n id: idProp,\n inputProps = defaultInputProps,\n onChange = noop,\n label = __('Box Control'),\n values: valuesProp,\n units,\n sides,\n splitOnAxis = false,\n allowReset = true,\n resetValues = DEFAULT_VALUES,\n presets,\n presetKey,\n onMouseOver,\n onMouseOut\n}) {\n const [values, setValues] = useControlledState(valuesProp, {\n fallback: DEFAULT_VALUES\n });\n const inputValues = values || DEFAULT_VALUES;\n const hasInitialValue = isValuesDefined(valuesProp);\n const hasOneSide = sides?.length === 1;\n const [isDirty, setIsDirty] = useState(hasInitialValue);\n const [isLinked, setIsLinked] = useState(!hasInitialValue || !isValueMixed(inputValues) || hasOneSide);\n\n // Tracking selected units via internal state allows filtering of CSS unit\n // only values from being saved while maintaining preexisting unit selection\n // behaviour. Filtering CSS only values prevents invalid style values.\n const [selectedUnits, setSelectedUnits] = useState({\n top: parseQuantityAndUnitFromRawValue(valuesProp?.top)[1],\n right: parseQuantityAndUnitFromRawValue(valuesProp?.right)[1],\n bottom: parseQuantityAndUnitFromRawValue(valuesProp?.bottom)[1],\n left: parseQuantityAndUnitFromRawValue(valuesProp?.left)[1]\n });\n const id = useUniqueId(idProp);\n const headingId = `${id}-heading`;\n const toggleLinked = () => {\n setIsLinked(!isLinked);\n };\n const handleOnChange = nextValues => {\n onChange(nextValues);\n setValues(nextValues);\n setIsDirty(true);\n };\n const handleOnReset = () => {\n onChange(resetValues);\n setValues(resetValues);\n setSelectedUnits(resetValues);\n setIsDirty(false);\n };\n const inputControlProps = {\n onMouseOver,\n onMouseOut,\n ...inputProps,\n onChange: handleOnChange,\n isLinked,\n units,\n selectedUnits,\n setSelectedUnits,\n sides,\n values: inputValues,\n __next40pxDefaultSize,\n presets,\n presetKey\n };\n maybeWarnDeprecated36pxSize({\n componentName: 'BoxControl',\n __next40pxDefaultSize,\n size: undefined\n });\n const sidesToRender = getAllowedSides(sides);\n if (presets && !presetKey || !presets && presetKey) {\n const definedProp = presets ? 'presets' : 'presetKey';\n const missingProp = presets ? 'presetKey' : 'presets';\n globalThis.SCRIPT_DEBUG === true ? warning(`wp.components.BoxControl: the '${missingProp}' prop is required when the '${definedProp}' prop is defined.`) : void 0;\n }\n return /*#__PURE__*/_jsxs(Grid, {\n id: id,\n columns: 3,\n templateColumns: \"1fr min-content min-content\",\n role: \"group\",\n \"aria-labelledby\": headingId,\n children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n id: headingId,\n children: label\n }), isLinked && /*#__PURE__*/_jsx(InputWrapper, {\n children: /*#__PURE__*/_jsx(InputControl, {\n side: \"all\",\n ...inputControlProps\n })\n }), !hasOneSide && /*#__PURE__*/_jsx(LinkedButtonWrapper, {\n children: /*#__PURE__*/_jsx(LinkedButton, {\n onClick: toggleLinked,\n isLinked: isLinked\n })\n }), !isLinked && splitOnAxis && ['vertical', 'horizontal'].map(axis =>\n /*#__PURE__*/\n // Disable reason: the parent component is handling the __next40pxDefaultSize prop\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(InputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), !isLinked && !splitOnAxis && Array.from(sidesToRender).map(axis =>\n /*#__PURE__*/\n // Disable reason: the parent component is handling the __next40pxDefaultSize prop\n // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n _jsx(InputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), allowReset && /*#__PURE__*/_jsx(ResetButton, {\n className: \"component-box-control__reset-button\",\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n disabled: !isDirty,\n children: __('Reset')\n })]\n });\n}\nexport default BoxControl;"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,OAAO,aAAa;AAKpB,SAAS,mBAAmB;AAC5B,OAAO,kBAAkB;AACzB,OAAO,kBAAkB;A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AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH,CAAC,GAAG,CAAC,YAAY,eAAe,CAAC,YAAY,YAAY,EAAE,IAAI;AAAA;AAAA;AAAA,MAI/D,qBAAK,cAAc;AAAA,QACjB,MAAM;AAAA,QACN,GAAG;AAAA,MACL,GAAG,IAAI;AAAA,KAAC,GAAG,CAAC,YAAY,CAAC,eAAe,MAAM,KAAK,aAAa,EAAE,IAAI;AAAA;AAAA;AAAA,MAItE,qBAAK,cAAc;AAAA,QACjB,MAAM;AAAA,QACN,GAAG;AAAA,MACL,GAAG,IAAI;AAAA,KAAC,GAAG,cAA2B,qBAAK,aAAa;AAAA,MACtD,WAAW;AAAA,MACX,SAAS;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU,CAAC;AAAA,MACX,UAAU,GAAG,OAAO;AAAA,IACtB,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACA,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// packages/components/src/box-control/utils.ts
|
|
2
|
-
import deprecated from "@wordpress/deprecated";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
3
|
var CUSTOM_VALUE_SETTINGS = {
|
|
5
4
|
px: {
|
|
@@ -175,31 +174,6 @@ function normalizeSides(sides) {
|
|
|
175
174
|
}
|
|
176
175
|
return filteredSides;
|
|
177
176
|
}
|
|
178
|
-
function applyValueToSides(currentValues, newValue, sides) {
|
|
179
|
-
deprecated("applyValueToSides", {
|
|
180
|
-
since: "6.8",
|
|
181
|
-
version: "7.0"
|
|
182
|
-
});
|
|
183
|
-
const newValues = {
|
|
184
|
-
...currentValues
|
|
185
|
-
};
|
|
186
|
-
if (sides?.length) {
|
|
187
|
-
sides.forEach((side) => {
|
|
188
|
-
if (side === "vertical") {
|
|
189
|
-
newValues.top = newValue;
|
|
190
|
-
newValues.bottom = newValue;
|
|
191
|
-
} else if (side === "horizontal") {
|
|
192
|
-
newValues.left = newValue;
|
|
193
|
-
newValues.right = newValue;
|
|
194
|
-
} else {
|
|
195
|
-
newValues[side] = newValue;
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
} else {
|
|
199
|
-
ALL_SIDES.forEach((side) => newValues[side] = newValue);
|
|
200
|
-
}
|
|
201
|
-
return newValues;
|
|
202
|
-
}
|
|
203
177
|
function getAllowedSides(sides) {
|
|
204
178
|
const allowedSides = new Set(!sides ? ALL_SIDES : []);
|
|
205
179
|
sides?.forEach((allowedSide) => {
|
|
@@ -241,7 +215,6 @@ export {
|
|
|
241
215
|
CUSTOM_VALUE_SETTINGS,
|
|
242
216
|
DEFAULT_VALUES,
|
|
243
217
|
LABELS,
|
|
244
|
-
applyValueToSides,
|
|
245
218
|
getAllUnitFallback,
|
|
246
219
|
getAllowedSides,
|
|
247
220
|
getMergedValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/box-control/utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport
|
|
5
|
-
"mappings": ";AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nexport const CUSTOM_VALUE_SETTINGS = {\n px: {\n max: 300,\n step: 1\n },\n '%': {\n max: 100,\n step: 1\n },\n vw: {\n max: 100,\n step: 1\n },\n vh: {\n max: 100,\n step: 1\n },\n em: {\n max: 10,\n step: 0.1\n },\n rm: {\n max: 10,\n step: 0.1\n },\n svw: {\n max: 100,\n step: 1\n },\n lvw: {\n max: 100,\n step: 1\n },\n dvw: {\n max: 100,\n step: 1\n },\n svh: {\n max: 100,\n step: 1\n },\n lvh: {\n max: 100,\n step: 1\n },\n dvh: {\n max: 100,\n step: 1\n },\n vi: {\n max: 100,\n step: 1\n },\n svi: {\n max: 100,\n step: 1\n },\n lvi: {\n max: 100,\n step: 1\n },\n dvi: {\n max: 100,\n step: 1\n },\n vb: {\n max: 100,\n step: 1\n },\n svb: {\n max: 100,\n step: 1\n },\n lvb: {\n max: 100,\n step: 1\n },\n dvb: {\n max: 100,\n step: 1\n },\n vmin: {\n max: 100,\n step: 1\n },\n svmin: {\n max: 100,\n step: 1\n },\n lvmin: {\n max: 100,\n step: 1\n },\n dvmin: {\n max: 100,\n step: 1\n },\n vmax: {\n max: 100,\n step: 1\n },\n svmax: {\n max: 100,\n step: 1\n },\n lvmax: {\n max: 100,\n step: 1\n },\n dvmax: {\n max: 100,\n step: 1\n }\n};\nexport const LABELS = {\n all: __('All sides'),\n top: __('Top side'),\n bottom: __('Bottom side'),\n left: __('Left side'),\n right: __('Right side'),\n vertical: __('Top and bottom sides'),\n horizontal: __('Left and right sides')\n};\nexport const DEFAULT_VALUES = {\n top: undefined,\n right: undefined,\n bottom: undefined,\n left: undefined\n};\nexport const ALL_SIDES = ['top', 'right', 'bottom', 'left'];\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param arr Array of items to check.\n * @return The item with the most occurrences.\n */\nfunction mode(arr) {\n return arr.sort((a, b) => arr.filter(v => v === a).length - arr.filter(v => v === b).length).pop();\n}\n\n/**\n * Gets the merged input value and unit from values data.\n *\n * @param values Box values.\n * @param availableSides Available box sides to evaluate.\n *\n * @return A value + unit for the 'all' input.\n */\nexport function getMergedValue(values = {}, availableSides = ALL_SIDES) {\n const sides = normalizeSides(availableSides);\n if (sides.every(side => values[side] === values[sides[0]])) {\n return values[sides[0]];\n }\n return undefined;\n}\n\n/**\n * Checks if the values are mixed.\n *\n * @param values Box values.\n * @param availableSides Available box sides to evaluate.\n * @return Whether the values are mixed.\n */\nexport function isValueMixed(values = {}, availableSides = ALL_SIDES) {\n const sides = normalizeSides(availableSides);\n return sides.some(side => values[side] !== values[sides[0]]);\n}\n\n/**\n * Determine the most common unit selection to use as a fallback option.\n *\n * @param selectedUnits Current unit selections for individual sides.\n * @return Most common unit selection.\n */\nexport function getAllUnitFallback(selectedUnits) {\n if (!selectedUnits || typeof selectedUnits !== 'object') {\n return undefined;\n }\n const filteredUnits = Object.values(selectedUnits).filter(Boolean);\n return mode(filteredUnits);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param values Box values.\n *\n * @return Whether values are mixed.\n */\nexport function isValuesDefined(values) {\n return values && Object.values(values).filter(\n // Switching units when input is empty causes values only\n // containing units. This gives false positive on mixed values\n // unless filtered.\n value => !!value && /\\d/.test(value)).length > 0;\n}\n\n/**\n * Normalizes provided sides configuration to an array containing only top,\n * right, bottom and left. This essentially just maps `horizontal` or `vertical`\n * to their appropriate sides to facilitate correctly determining value for\n * all input control.\n *\n * @param sides Available sides for box control.\n * @return Normalized sides configuration.\n */\nexport function normalizeSides(sides) {\n const filteredSides = [];\n if (!sides?.length) {\n return ALL_SIDES;\n }\n if (sides.includes('vertical')) {\n filteredSides.push(...['top', 'bottom']);\n } else if (sides.includes('horizontal')) {\n filteredSides.push(...['left', 'right']);\n } else {\n const newSides = ALL_SIDES.filter(side => sides.includes(side));\n filteredSides.push(...newSides);\n }\n return filteredSides;\n}\n\n/**\n * Return the allowed sides based on the sides configuration.\n *\n * @param sides Sides configuration.\n * @return Allowed sides.\n */\nexport function getAllowedSides(sides) {\n const allowedSides = new Set(!sides ? ALL_SIDES : []);\n sides?.forEach(allowedSide => {\n if (allowedSide === 'vertical') {\n allowedSides.add('top');\n allowedSides.add('bottom');\n } else if (allowedSide === 'horizontal') {\n allowedSides.add('right');\n allowedSides.add('left');\n } else {\n allowedSides.add(allowedSide);\n }\n });\n return allowedSides;\n}\n\n/**\n * Checks if a value is a preset value.\n *\n * @param value The value to check.\n * @param presetKey The preset key to check against.\n * @return Whether the value is a preset value.\n */\nexport function isValuePreset(value, presetKey) {\n return value.startsWith(`var:preset|${presetKey}|`);\n}\n\n/**\n * Returns the index of the preset value in the presets array.\n *\n * @param value The value to check.\n * @param presetKey The preset key to check against.\n * @param presets The array of presets to search.\n * @return The index of the preset value in the presets array.\n */\nexport function getPresetIndexFromValue(value, presetKey, presets) {\n if (!isValuePreset(value, presetKey)) {\n return undefined;\n }\n const match = value.match(new RegExp(`^var:preset\\\\|${presetKey}\\\\|(.+)$`));\n if (!match) {\n return undefined;\n }\n const slug = match[1];\n const index = presets.findIndex(preset => {\n return preset.slug === slug;\n });\n return index !== -1 ? index : undefined;\n}\n\n/**\n * Returns the preset value from the index.\n *\n * @param index The index of the preset value in the presets array.\n * @param presetKey The preset key to check against.\n * @param presets The array of presets to search.\n * @return The preset value from the index.\n */\nexport function getPresetValueFromIndex(index, presetKey, presets) {\n const preset = presets[index];\n return `var:preset|${presetKey}|${preset.slug}`;\n}"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAMZ,IAAM,wBAAwB;AAAA,EACnC,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,IAAI;AAAA,IACF,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH,KAAK;AAAA,IACL,MAAM;AAAA,EACR;AAAA,EACA,KAAK;AAAA,IACH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
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/custom-gradient-picker/gradient-bar/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { useRef, useReducer } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ControlPoints from './control-points';\nimport { getHorizontalRelativeGradientPosition } from './utils';\nimport { MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT } from './constants';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst customGradientBarReducer = (state, action) => {\n switch (action.type) {\n case 'MOVE_INSERTER':\n if (state.id === 'IDLE' || state.id === 'MOVING_INSERTER') {\n return {\n id: 'MOVING_INSERTER',\n insertPosition: action.insertPosition\n };\n }\n break;\n case 'STOP_INSERTER_MOVE':\n if (state.id === 'MOVING_INSERTER') {\n return {\n id: 'IDLE'\n };\n }\n break;\n case 'OPEN_INSERTER':\n if (state.id === 'MOVING_INSERTER') {\n return {\n id: 'INSERTING_CONTROL_POINT',\n insertPosition: state.insertPosition\n };\n }\n break;\n case 'CLOSE_INSERTER':\n if (state.id === 'INSERTING_CONTROL_POINT') {\n return {\n id: 'IDLE'\n };\n }\n break;\n case 'START_CONTROL_CHANGE':\n if (state.id === 'IDLE') {\n return {\n id: 'MOVING_CONTROL_POINT'\n };\n }\n break;\n case 'STOP_CONTROL_CHANGE':\n if (state.id === 'MOVING_CONTROL_POINT') {\n return {\n id: 'IDLE'\n };\n }\n break;\n }\n return state;\n};\nconst customGradientBarReducerInitialState = {\n id: 'IDLE'\n};\nexport default function CustomGradientBar({\n background,\n hasGradient,\n value: controlPoints,\n onChange,\n disableInserter = false,\n disableAlpha = false,\n __experimentalIsRenderedInSidebar = false\n}) {\n const gradientMarkersContainerDomRef = useRef(null);\n const [gradientBarState, gradientBarStateDispatch] = useReducer(customGradientBarReducer, customGradientBarReducerInitialState);\n const onMouseEnterAndMove = event => {\n if (!gradientMarkersContainerDomRef.current) {\n return;\n }\n const insertPosition = getHorizontalRelativeGradientPosition(event.clientX, gradientMarkersContainerDomRef.current);\n\n // If the insert point is close to an existing control point don't show it.\n if (controlPoints.some(({\n position\n }) => {\n return Math.abs(insertPosition - position) < MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT;\n })) {\n if (gradientBarState.id === 'MOVING_INSERTER') {\n gradientBarStateDispatch({\n type: 'STOP_INSERTER_MOVE'\n });\n }\n return;\n }\n gradientBarStateDispatch({\n type: 'MOVE_INSERTER',\n insertPosition\n });\n };\n const onMouseLeave = () => {\n gradientBarStateDispatch({\n type: 'STOP_INSERTER_MOVE'\n });\n };\n const isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';\n const isInsertingControlPoint = gradientBarState.id === 'INSERTING_CONTROL_POINT';\n return /*#__PURE__*/_jsxs(\"div\", {\n className: clsx('components-custom-gradient-picker__gradient-bar', {\n 'has-gradient': hasGradient\n }),\n onMouseEnter: onMouseEnterAndMove,\n onMouseMove: onMouseEnterAndMove,\n onMouseLeave: onMouseLeave,\n children: [/*#__PURE__*/_jsx(\"div\", {\n className: \"components-custom-gradient-picker__gradient-bar-background\",\n style: {\n background,\n opacity: hasGradient ? 1 : 0.4\n }\n }), /*#__PURE__*/_jsxs(\"div\", {\n ref: gradientMarkersContainerDomRef,\n className: \"components-custom-gradient-picker__markers-container\",\n children: [!disableInserter && (isMovingInserter || isInsertingControlPoint) && /*#__PURE__*/_jsx(ControlPoints.InsertPoint, {\n __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,\n disableAlpha: disableAlpha,\n insertPosition: gradientBarState.insertPosition,\n value: controlPoints,\n onChange: onChange,\n onOpenInserter: () => {\n gradientBarStateDispatch({\n type: 'OPEN_INSERTER'\n });\n },\n onCloseInserter: () => {\n gradientBarStateDispatch({\n type: 'CLOSE_INSERTER'\n });\n }\n }), /*#__PURE__*/_jsx(ControlPoints, {\n __experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,\n disableAlpha: disableAlpha,\n disableRemove: disableInserter,\n gradientPickerDomRef: gradientMarkersContainerDomRef,\n ignoreMarkerPosition: isInsertingControlPoint ? gradientBarState.insertPosition : undefined,\n value: controlPoints,\n onChange: onChange,\n onStartControlPointChange: () => {\n gradientBarStateDispatch({\n type: 'START_CONTROL_CHANGE'\n });\n },\n onStopControlPointChange: () => {\n gradientBarStateDispatch({\n type: 'STOP_CONTROL_CHANGE'\n });\n }\n })]\n })]\n });\n}"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,QAAQ,kBAAkB;AAKnC,OAAO,mBAAmB;AAC1B,SAAS,6CAA6C;AACtD,SAAS,mDAAmD;AAC5D,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,2BAA2B,CAAC,OAAO,WAAW;AAClD,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,UAAI,MAAM,OAAO,UAAU,MAAM,OAAO,mBAAmB;AACzD,eAAO;AAAA,UACL,IAAI;AAAA,UACJ,gBAAgB,OAAO;AAAA,QACzB;AAAA,MACF;AACA;AAAA,IACF,KAAK;AACH,UAAI,MAAM,OAAO,mBAAmB;AAClC,eAAO;AAAA,UACL,IAAI;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF,KAAK;AACH,UAAI,MAAM,OAAO,mBAAmB;AAClC,eAAO;AAAA,UACL,IAAI;AAAA,UACJ,gBAAgB,MAAM;AAAA,QACxB;AAAA,MACF;AACA;AAAA,IACF,KAAK;AACH,UAAI,MAAM,OAAO,2BAA2B;AAC1C,eAAO;AAAA,UACL,IAAI;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF,KAAK;AACH,UAAI,MA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AU,CAAc,qBAAK,OAAO;AAAA,MAClC,WAAW;AAAA,MACX,OAAO;AAAA,QACL;AAAA,QACA,SAAS,cAAc,IAAI;AAAA,MAC7B;AAAA,IACF,CAAC,GAAgB,sBAAM,OAAO;AAAA,MAC5B,KAAK;AAAA,MACL,WAAW;AAAA,MACX,UAAU,CAAC,CAAC,oBAAoB,oBAAoB,4BAAyC,qBAAK,cAAc,aAAa;AAAA,QAC3H;AAAA,QACA;AAAA,QACA,gBAAgB,iBAAiB;AAAA,QACjC,OAAO;AAAA,QACP;AAAA,QACA,gBAAgB,MAAM;AACpB,mCAAyB;AAAA,YACvB,MAAM;AAAA,UACR,CAAC;AAAA,QACH;AAAA,QACA,iBAAiB,MAAM;AACrB,mCAAyB;AAAA,YACvB,MAAM;AAAA,UACR,CAAC;AAAA,QACH;AAAA,MACF,CAAC,GAAgB,qBAAK,eAAe;AAAA,QACnC;AAAA,QACA;AAAA,QACA,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,sBAAsB,0BAA0B,iBAAiB,iBAAiB;AAAA,QAClF,OAAO;AAAA,QACP;AAAA,QACA,2BAA2B,MAAM;AAC/B,mCAAyB;AAAA,YACvB,MAAM;AAAA,UACR,CAAC;AAAA,QACH;AAAA,QACA,0BAA0B,MAAM;AAC9B,mCAAyB;AAAA,YACvB,MAAM;AAAA,UACR,CAAC;AAAA,QACH;AAAA,MACF,CAAC,CAAC;AAAA,IACJ,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,7 +18,7 @@ function Disabled({
|
|
|
18
18
|
value: isDisabled,
|
|
19
19
|
children: /* @__PURE__ */ _jsx("div", {
|
|
20
20
|
// @ts-ignore Reason: inert is a recent HTML attribute
|
|
21
|
-
inert: isDisabled ?
|
|
21
|
+
inert: isDisabled ? true : void 0,
|
|
22
22
|
className: isDisabled ? cx(disabledStyles, className, "components-disabled") : void 0,
|
|
23
23
|
...props,
|
|
24
24
|
children
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/disabled/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { disabledStyles } from './styles/disabled-styles';\nimport { useCx } from '../utils';\nimport Context from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst {\n Consumer,\n Provider\n} = Context;\n\n/**\n * `Disabled` is a component which disables descendant tabbable elements and\n * prevents pointer interaction.\n *\n * _Note: this component may not behave as expected in browsers that don't\n * support the `inert` HTML attribute. We recommend adding the official WICG\n * polyfill when using this component in your project._\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n *\n * ```jsx\n * import { Button, Disabled, TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDisabled = () => {\n * \tconst [ isDisabled, setIsDisabled ] = useState( true );\n *\n *\tlet input = (\n *\t\t<TextControl\n *\t\t\t__next40pxDefaultSize\n *\t\t\tlabel=\"Input\"\n *\t\t\tonChange={ () => {} }\n *\t\t/>\n *\t);\n * \tif ( isDisabled ) {\n * \t\tinput = <Disabled>{ input }</Disabled>;\n * \t}\n *\n * \tconst toggleDisabled = () => {\n * \t\tsetIsDisabled( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ input }\n * \t\t\t<Button variant=\"primary\" onClick={ toggleDisabled }>\n * \t\t\t\tToggle Disabled\n * \t\t\t</Button>\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nfunction Disabled({\n className,\n children,\n isDisabled = true,\n ...props\n}) {\n const cx = useCx();\n return /*#__PURE__*/_jsx(Provider, {\n value: isDisabled,\n children: /*#__PURE__*/_jsx(\"div\", {\n // @ts-ignore Reason: inert is a recent HTML attribute\n inert: isDisabled ?
|
|
5
|
-
"mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,OAAO,aAAa;AACpB,SAAS,OAAO,YAAY;AAC5B,IAAM;AAAA,EACJ;AAAA,EACA;AACF,IAAI;AA6CJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAG;AACD,QAAM,KAAK,MAAM;AACjB,SAAoB,qBAAK,UAAU;AAAA,IACjC,OAAO;AAAA,IACP,UAAuB,qBAAK,OAAO;AAAA;AAAA,MAEjC,OAAO,aAAa,
|
|
4
|
+
"sourcesContent": ["import { disabledStyles } from './styles/disabled-styles';\nimport { useCx } from '../utils';\nimport Context from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst {\n Consumer,\n Provider\n} = Context;\n\n/**\n * `Disabled` is a component which disables descendant tabbable elements and\n * prevents pointer interaction.\n *\n * _Note: this component may not behave as expected in browsers that don't\n * support the `inert` HTML attribute. We recommend adding the official WICG\n * polyfill when using this component in your project._\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n *\n * ```jsx\n * import { Button, Disabled, TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDisabled = () => {\n * \tconst [ isDisabled, setIsDisabled ] = useState( true );\n *\n *\tlet input = (\n *\t\t<TextControl\n *\t\t\t__next40pxDefaultSize\n *\t\t\tlabel=\"Input\"\n *\t\t\tonChange={ () => {} }\n *\t\t/>\n *\t);\n * \tif ( isDisabled ) {\n * \t\tinput = <Disabled>{ input }</Disabled>;\n * \t}\n *\n * \tconst toggleDisabled = () => {\n * \t\tsetIsDisabled( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ input }\n * \t\t\t<Button variant=\"primary\" onClick={ toggleDisabled }>\n * \t\t\t\tToggle Disabled\n * \t\t\t</Button>\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nfunction Disabled({\n className,\n children,\n isDisabled = true,\n ...props\n}) {\n const cx = useCx();\n return /*#__PURE__*/_jsx(Provider, {\n value: isDisabled,\n children: /*#__PURE__*/_jsx(\"div\", {\n // @ts-ignore Reason: inert is a recent HTML attribute\n inert: isDisabled ? true : undefined,\n className: isDisabled ? cx(disabledStyles, className, 'components-disabled') : undefined,\n ...props,\n children: children\n })\n });\n}\nDisabled.Context = Context;\nDisabled.Consumer = Consumer;\nexport default Disabled;"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,OAAO,aAAa;AACpB,SAAS,OAAO,YAAY;AAC5B,IAAM;AAAA,EACJ;AAAA,EACA;AACF,IAAI;AA6CJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAG;AACD,QAAM,KAAK,MAAM;AACjB,SAAoB,qBAAK,UAAU;AAAA,IACjC,OAAO;AAAA,IACP,UAAuB,qBAAK,OAAO;AAAA;AAAA,MAEjC,OAAO,aAAa,OAAO;AAAA,MAC3B,WAAW,aAAa,GAAG,gBAAgB,WAAW,qBAAqB,IAAI;AAAA,MAC/E,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,UAAU;AACnB,SAAS,WAAW;AACpB,IAAO,mBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|