@wordpress/components 23.5.0 → 23.6.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 +40 -7
- package/build/animate/index.js +3 -1
- package/build/animate/index.js.map +1 -1
- package/build/animation/index.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +5 -5
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/autocomplete/index.js +25 -91
- package/build/autocomplete/index.js.map +1 -1
- package/build/autocomplete/types.js +6 -0
- package/build/autocomplete/types.js.map +1 -0
- package/build/custom-gradient-picker/gradient-bar/control-points.js +2 -0
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/index.js +2 -0
- package/build/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js +2 -0
- package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build/custom-gradient-picker/index.js +2 -0
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/serializer.js +1 -0
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/custom-gradient-picker/utils.js +2 -0
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/dimension-control/index.js +31 -5
- package/build/dimension-control/index.js.map +1 -1
- package/build/dimension-control/sizes.js +2 -4
- package/build/dimension-control/sizes.js.map +1 -1
- package/build/dimension-control/types.js +6 -0
- package/build/dimension-control/types.js.map +1 -0
- package/build/flex/flex/hook.js +3 -3
- package/build/flex/flex/hook.js.map +1 -1
- package/build/font-size-picker/index.js +2 -1
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-token-field/index.js +1 -1
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +2 -0
- package/build/gradient-picker/index.js.map +1 -1
- package/build/guide/icons.js.map +1 -1
- package/build/guide/index.js +46 -8
- package/build/guide/index.js.map +1 -1
- package/build/guide/page-control.js.map +1 -1
- package/build/guide/page.js.map +1 -1
- package/build/guide/types.js +6 -0
- package/build/guide/types.js.map +1 -0
- package/build/h-stack/utils.js +5 -5
- package/build/h-stack/utils.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js +33 -3
- package/build/higher-order/navigate-regions/index.js.map +1 -1
- package/build/higher-order/with-fallback-styles/index.js +2 -2
- package/build/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build/higher-order/with-filters/index.js +31 -7
- package/build/higher-order/with-filters/index.js.map +1 -1
- package/build/higher-order/with-focus-return/index.js +10 -10
- package/build/higher-order/with-focus-return/index.js.map +1 -1
- package/build/higher-order/with-notices/index.js +28 -25
- package/build/higher-order/with-notices/index.js.map +1 -1
- package/build/higher-order/with-notices/types.js +6 -0
- package/build/higher-order/with-notices/types.js.map +1 -0
- package/build/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build/icon/index.js +1 -8
- package/build/icon/index.js.map +1 -1
- package/build/index.native.js +18 -9
- package/build/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/cell.native.js +1 -1
- package/build/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet-text-control/index.native.js +4 -3
- package/build/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build/navigation/back-button/index.js +6 -5
- package/build/navigation/back-button/index.js.map +1 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/context.js +7 -4
- package/build/navigation/context.js.map +1 -1
- package/build/navigation/group/context.js.map +1 -1
- package/build/navigation/group/index.js +5 -1
- package/build/navigation/group/index.js.map +1 -1
- package/build/navigation/index.js +49 -3
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/base-content.js +0 -1
- package/build/navigation/item/base-content.js.map +1 -1
- package/build/navigation/item/base.js.map +1 -1
- package/build/navigation/item/index.js +5 -1
- package/build/navigation/item/index.js.map +1 -1
- package/build/navigation/item/use-navigation-tree-item.js +1 -1
- package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build/navigation/menu/context.js.map +1 -1
- package/build/navigation/menu/index.js +5 -1
- package/build/navigation/menu/index.js.map +1 -1
- package/build/navigation/menu/menu-title-search.js +8 -6
- package/build/navigation/menu/menu-title-search.js.map +1 -1
- package/build/navigation/menu/menu-title.js +4 -2
- package/build/navigation/menu/menu-title.js.map +1 -1
- package/build/navigation/menu/search-no-results-found.js.map +1 -1
- package/build/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build/navigation/styles/navigation-styles.js +36 -36
- package/build/navigation/styles/navigation-styles.js.map +1 -1
- package/build/navigation/types.js +6 -0
- package/build/navigation/types.js.map +1 -0
- package/build/navigation/use-create-navigation-tree.js +7 -0
- package/build/navigation/use-create-navigation-tree.js.map +1 -1
- package/build/navigation/use-navigation-tree-nodes.js +3 -5
- package/build/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build/navigation/utils.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +5 -3
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/number-control/index.js +1 -3
- package/build/number-control/index.js.map +1 -1
- package/build/palette-edit/index.js +67 -27
- package/build/palette-edit/index.js.map +1 -1
- package/build/palette-edit/types.js +6 -0
- package/build/palette-edit/types.js.map +1 -0
- package/build/panel/body.js +15 -17
- package/build/panel/body.js.map +1 -1
- package/build/placeholder/index.js.map +1 -1
- package/build/query-controls/author-select.js +0 -4
- package/build/query-controls/author-select.js.map +1 -1
- package/build/query-controls/category-select.js +0 -4
- package/build/query-controls/category-select.js.map +1 -1
- package/build/query-controls/terms.js +30 -15
- package/build/query-controls/terms.js.map +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +4 -4
- package/build/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build/responsive-wrapper/index.js +12 -13
- package/build/responsive-wrapper/index.js.map +1 -1
- package/build/select-control/index.js +19 -16
- package/build/select-control/index.js.map +1 -1
- package/build/toolbar/toolbar-button/index.js +32 -10
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/toolbar/toolbar-button/toolbar-button-container.js +12 -4
- package/build/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
- package/build/toolbar/toolbar-button/types.js +6 -0
- package/build/toolbar/toolbar-button/types.js.map +1 -0
- package/build/toolbar/toolbar-context/index.js +4 -2
- package/build/toolbar/toolbar-context/index.js.map +1 -1
- package/build/tooltip/index.js +18 -6
- package/build/tooltip/index.js.map +1 -1
- package/build/tree-select/index.js.map +1 -1
- package/build/ui/context/get-styled-class-name-from-key.js +2 -2
- package/build/ui/context/get-styled-class-name-from-key.js.map +1 -1
- package/build/utils/font.js +3 -7
- package/build/utils/font.js.map +1 -1
- package/build/v-stack/hook.js +2 -0
- package/build/v-stack/hook.js.map +1 -1
- package/build-module/animate/index.js +3 -1
- package/build-module/animate/index.js.map +1 -1
- package/build-module/animation/index.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +6 -6
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/autocomplete/index.js +28 -94
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/autocomplete/types.js +2 -0
- package/build-module/autocomplete/types.js.map +1 -0
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -0
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/index.js +1 -0
- package/build-module/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js +2 -0
- package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +1 -0
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +1 -0
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/custom-gradient-picker/utils.js +2 -0
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/dimension-control/index.js +28 -3
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/dimension-control/sizes.js +6 -5
- package/build-module/dimension-control/sizes.js.map +1 -1
- package/build-module/dimension-control/types.js +2 -0
- package/build-module/dimension-control/types.js.map +1 -0
- package/build-module/flex/flex/hook.js +3 -3
- package/build-module/flex/flex/hook.js.map +1 -1
- package/build-module/font-size-picker/index.js +2 -1
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-token-field/index.js +1 -1
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +1 -0
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/guide/icons.js.map +1 -1
- package/build-module/guide/index.js +45 -8
- package/build-module/guide/index.js.map +1 -1
- package/build-module/guide/page-control.js.map +1 -1
- package/build-module/guide/page.js +4 -0
- package/build-module/guide/page.js.map +1 -1
- package/build-module/guide/types.js +2 -0
- package/build-module/guide/types.js.map +1 -0
- package/build-module/h-stack/utils.js +5 -5
- package/build-module/h-stack/utils.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js +33 -3
- package/build-module/higher-order/navigate-regions/index.js.map +1 -1
- package/build-module/higher-order/with-fallback-styles/index.js +2 -2
- package/build-module/higher-order/with-fallback-styles/index.js.map +1 -1
- package/build-module/higher-order/with-filters/index.js +31 -7
- package/build-module/higher-order/with-filters/index.js.map +1 -1
- package/build-module/higher-order/with-focus-return/index.js +10 -10
- package/build-module/higher-order/with-focus-return/index.js.map +1 -1
- package/build-module/higher-order/with-notices/index.js +29 -26
- package/build-module/higher-order/with-notices/index.js.map +1 -1
- package/build-module/higher-order/with-notices/types.js +2 -0
- package/build-module/higher-order/with-notices/types.js.map +1 -0
- package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build-module/icon/index.js +2 -9
- package/build-module/icon/index.js.map +1 -1
- package/build-module/index.native.js +1 -0
- package/build-module/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-text-control/index.native.js +4 -3
- package/build-module/mobile/bottom-sheet-text-control/index.native.js.map +1 -1
- package/build-module/navigation/back-button/index.js +4 -3
- package/build-module/navigation/back-button/index.js.map +1 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/context.js +7 -4
- package/build-module/navigation/context.js.map +1 -1
- package/build-module/navigation/group/context.js +4 -0
- package/build-module/navigation/group/context.js.map +1 -1
- package/build-module/navigation/group/index.js +2 -1
- package/build-module/navigation/group/index.js.map +1 -1
- package/build-module/navigation/index.js +46 -3
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/base-content.js +0 -1
- package/build-module/navigation/item/base-content.js.map +1 -1
- package/build-module/navigation/item/base.js.map +1 -1
- package/build-module/navigation/item/index.js +2 -1
- package/build-module/navigation/item/index.js.map +1 -1
- package/build-module/navigation/item/use-navigation-tree-item.js +1 -1
- package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build-module/navigation/menu/context.js +4 -0
- package/build-module/navigation/menu/context.js.map +1 -1
- package/build-module/navigation/menu/index.js +2 -1
- package/build-module/navigation/menu/index.js.map +1 -1
- package/build-module/navigation/menu/menu-title-search.js +8 -6
- package/build-module/navigation/menu/menu-title-search.js.map +1 -1
- package/build-module/navigation/menu/menu-title.js +4 -2
- package/build-module/navigation/menu/menu-title.js.map +1 -1
- package/build-module/navigation/menu/search-no-results-found.js.map +1 -1
- package/build-module/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build-module/navigation/styles/navigation-styles.js +36 -36
- package/build-module/navigation/styles/navigation-styles.js.map +1 -1
- package/build-module/navigation/types.js +2 -0
- package/build-module/navigation/types.js.map +1 -0
- package/build-module/navigation/use-create-navigation-tree.js +7 -0
- package/build-module/navigation/use-create-navigation-tree.js.map +1 -1
- package/build-module/navigation/use-navigation-tree-nodes.js +2 -2
- package/build-module/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build-module/navigation/utils.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +5 -3
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/number-control/index.js +1 -3
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/palette-edit/index.js +65 -27
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/palette-edit/types.js +2 -0
- package/build-module/palette-edit/types.js.map +1 -0
- package/build-module/panel/body.js +12 -12
- package/build-module/panel/body.js.map +1 -1
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/query-controls/author-select.js +0 -4
- package/build-module/query-controls/author-select.js.map +1 -1
- package/build-module/query-controls/category-select.js +1 -5
- package/build-module/query-controls/category-select.js.map +1 -1
- package/build-module/query-controls/terms.js +29 -16
- package/build-module/query-controls/terms.js.map +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js +5 -5
- package/build-module/resizable-box/resize-tooltip/styles/resize-tooltip.styles.js.map +1 -1
- package/build-module/responsive-wrapper/index.js +12 -12
- package/build-module/responsive-wrapper/index.js.map +1 -1
- package/build-module/select-control/index.js +20 -17
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/toolbar/toolbar-button/index.js +32 -9
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js +12 -4
- package/build-module/toolbar/toolbar-button/toolbar-button-container.js.map +1 -1
- package/build-module/toolbar/toolbar-button/types.js +2 -0
- package/build-module/toolbar/toolbar-button/types.js.map +1 -0
- package/build-module/toolbar/toolbar-context/index.js +4 -2
- package/build-module/toolbar/toolbar-context/index.js.map +1 -1
- package/build-module/tooltip/index.js +16 -6
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tree-select/index.js.map +1 -1
- package/build-module/ui/context/get-styled-class-name-from-key.js +1 -1
- package/build-module/ui/context/get-styled-class-name-from-key.js.map +1 -1
- package/build-module/utils/font.js +3 -6
- package/build-module/utils/font.js.map +1 -1
- package/build-module/v-stack/hook.js +2 -0
- package/build-module/v-stack/hook.js.map +1 -1
- package/build-style/style-rtl.css +14 -11
- package/build-style/style.css +14 -11
- package/build-types/alignment-matrix-control/types.d.ts +4 -4
- package/build-types/alignment-matrix-control/types.d.ts.map +1 -1
- package/build-types/angle-picker-control/types.d.ts +2 -2
- package/build-types/angle-picker-control/types.d.ts.map +1 -1
- package/build-types/animate/index.d.ts +2 -2
- package/build-types/animate/index.d.ts.map +1 -1
- package/build-types/animation/index.d.ts +8 -1
- package/build-types/animation/index.d.ts.map +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts +4 -0
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -0
- package/build-types/autocomplete/get-default-use-items.d.ts +3 -0
- package/build-types/autocomplete/get-default-use-items.d.ts.map +1 -0
- package/build-types/autocomplete/index.d.ts +23 -0
- package/build-types/autocomplete/index.d.ts.map +1 -0
- package/build-types/autocomplete/test/index.d.ts +2 -0
- package/build-types/autocomplete/test/index.d.ts.map +1 -0
- package/build-types/autocomplete/types.d.ts +201 -0
- package/build-types/autocomplete/types.d.ts.map +1 -0
- package/build-types/base-control/types.d.ts +2 -2
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts +3 -3
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +8 -8
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/border-box-control/utils.d.ts +5 -5
- package/build-types/border-box-control/utils.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts +3 -3
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/hook.d.ts +2 -2
- package/build-types/border-control/border-control-dropdown/hook.d.ts.map +1 -1
- package/build-types/border-control/styles.d.ts +4 -4
- package/build-types/border-control/styles.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +6 -6
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +6 -6
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/button/deprecated.d.ts +6 -6
- package/build-types/button/types.d.ts +10 -10
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/button-group/types.d.ts +1 -1
- package/build-types/button-group/types.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +1 -1
- package/build-types/card/card/hook.d.ts.map +1 -1
- package/build-types/card/types.d.ts +10 -10
- package/build-types/card/types.d.ts.map +1 -1
- package/build-types/checkbox-control/types.d.ts +1 -1
- package/build-types/checkbox-control/types.d.ts.map +1 -1
- package/build-types/circular-option-picker/types.d.ts +4 -4
- package/build-types/circular-option-picker/types.d.ts.map +1 -1
- package/build-types/color-indicator/types.d.ts +1 -1
- package/build-types/color-indicator/types.d.ts.map +1 -1
- package/build-types/color-list-picker/types.d.ts +2 -2
- package/build-types/color-list-picker/types.d.ts.map +1 -1
- package/build-types/color-palette/types.d.ts +7 -7
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-palette/utils.d.ts +1 -1
- package/build-types/color-palette/utils.d.ts.map +1 -1
- package/build-types/color-picker/legacy-adapter.d.ts +1 -1
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -3
- package/build-types/color-picker/types.d.ts +2 -2
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/color-picker/use-deprecated-props.d.ts +2 -2
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
- package/build-types/combobox-control/types.d.ts +2 -2
- package/build-types/combobox-control/types.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts +4 -4
- package/build-types/confirm-dialog/types.d.ts +5 -5
- package/build-types/confirm-dialog/types.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +25 -0
- package/build-types/custom-gradient-picker/constants.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts +8 -0
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +25 -0
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +10 -0
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts +138 -0
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/index.d.ts +7 -0
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/serializer.d.ts +17 -0
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +11 -0
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/utils.d.ts +5 -0
- package/build-types/custom-gradient-picker/utils.d.ts.map +1 -0
- package/build-types/custom-select-control/styles.d.ts +1 -1
- package/build-types/custom-select-control/styles.d.ts.map +1 -1
- package/build-types/dashicon/types.d.ts +2 -2
- package/build-types/dashicon/types.d.ts.map +1 -1
- package/build-types/date-time/date-time/styles.d.ts +1 -4
- package/build-types/date-time/date-time/styles.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +1 -1
- package/build-types/date-time/types.d.ts +4 -4
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts +28 -0
- package/build-types/dimension-control/index.d.ts.map +1 -0
- package/build-types/dimension-control/sizes.d.ts +26 -0
- package/build-types/dimension-control/sizes.d.ts.map +1 -0
- package/build-types/dimension-control/stories/index.d.ts +12 -0
- package/build-types/dimension-control/stories/index.d.ts.map +1 -0
- package/build-types/dimension-control/types.d.ts +47 -0
- package/build-types/dimension-control/types.d.ts.map +1 -0
- package/build-types/divider/types.d.ts +1 -1
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/draggable/types.d.ts +1 -1
- package/build-types/draggable/types.d.ts.map +1 -1
- package/build-types/drop-zone/types.d.ts +2 -2
- package/build-types/drop-zone/types.d.ts.map +1 -1
- package/build-types/dropdown/types.d.ts +3 -3
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/elevation/types.d.ts +1 -1
- package/build-types/elevation/types.d.ts.map +1 -1
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/external-link/types.d.ts +1 -1
- package/build-types/external-link/types.d.ts.map +1 -1
- package/build-types/flex/types.d.ts +4 -4
- package/build-types/flex/types.d.ts.map +1 -1
- package/build-types/focal-point-picker/types.d.ts +7 -7
- package/build-types/focal-point-picker/types.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/stories/index.d.ts.map +1 -1
- package/build-types/font-size-picker/types.d.ts +9 -5
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/form-file-upload/types.d.ts +1 -1
- package/build-types/form-file-upload/types.d.ts.map +1 -1
- package/build-types/form-toggle/types.d.ts +1 -1
- package/build-types/form-toggle/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.d.ts +6 -0
- package/build-types/form-token-field/stories/index.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts +1 -1
- package/build-types/form-token-field/styles.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +1 -1
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +12 -0
- package/build-types/gradient-picker/index.d.ts.map +1 -0
- package/build-types/grid/types.d.ts +2 -2
- package/build-types/grid/types.d.ts.map +1 -1
- package/build-types/guide/icons.d.ts +5 -0
- package/build-types/guide/icons.d.ts.map +1 -0
- package/build-types/guide/index.d.ts +37 -0
- package/build-types/guide/index.d.ts.map +1 -0
- package/build-types/guide/page-control.d.ts +4 -0
- package/build-types/guide/page-control.d.ts.map +1 -0
- package/build-types/guide/page.d.ts +7 -0
- package/build-types/guide/page.d.ts.map +1 -0
- package/build-types/guide/stories/index.d.ts +9 -0
- package/build-types/guide/stories/index.d.ts.map +1 -0
- package/build-types/guide/test/index.d.ts +2 -0
- package/build-types/guide/test/index.d.ts.map +1 -0
- package/build-types/guide/types.d.ts +65 -0
- package/build-types/guide/types.d.ts.map +1 -0
- package/build-types/h-stack/types.d.ts +6 -6
- package/build-types/h-stack/types.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts +1 -1
- package/build-types/heading/types.d.ts +2 -2
- package/build-types/heading/types.d.ts.map +1 -1
- package/build-types/higher-order/navigate-regions/index.d.ts +46 -0
- package/build-types/higher-order/navigate-regions/index.d.ts.map +1 -0
- package/build-types/higher-order/with-fallback-styles/index.d.ts +44 -0
- package/build-types/higher-order/with-fallback-styles/index.d.ts.map +1 -0
- package/build-types/higher-order/with-filters/index.d.ts +89 -0
- package/build-types/higher-order/with-filters/index.d.ts.map +1 -0
- package/build-types/higher-order/with-filters/test/index.d.ts +2 -0
- package/build-types/higher-order/with-filters/test/index.d.ts.map +1 -0
- package/build-types/higher-order/with-focus-outside/index.d.ts +1 -1
- package/build-types/higher-order/with-focus-return/index.d.ts +20 -0
- package/build-types/higher-order/with-focus-return/index.d.ts.map +1 -0
- package/build-types/higher-order/with-focus-return/test/index.d.ts +2 -0
- package/build-types/higher-order/with-focus-return/test/index.d.ts.map +1 -0
- package/build-types/higher-order/with-notices/index.d.ts +37 -0
- package/build-types/higher-order/with-notices/index.d.ts.map +1 -0
- package/build-types/higher-order/with-notices/test/index.d.ts +2 -0
- package/build-types/higher-order/with-notices/test/index.d.ts.map +1 -0
- package/build-types/higher-order/with-notices/types.d.ts +34 -0
- package/build-types/higher-order/with-notices/types.d.ts.map +1 -0
- package/build-types/higher-order/with-spoken-messages/index.d.ts +13 -2
- package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
- package/build-types/higher-order/with-spoken-messages/test/index.d.ts +2 -0
- package/build-types/higher-order/with-spoken-messages/test/index.d.ts.map +1 -0
- package/build-types/icon/index.d.ts +10 -6
- package/build-types/icon/index.d.ts.map +1 -1
- package/build-types/icon/test/index.d.ts +2 -0
- package/build-types/icon/test/index.d.ts.map +1 -0
- package/build-types/input-control/reducer/actions.d.ts +15 -15
- package/build-types/input-control/reducer/actions.d.ts.map +1 -1
- package/build-types/input-control/reducer/state.d.ts +1 -1
- package/build-types/input-control/reducer/state.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +4 -4
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +7 -7
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +1 -1
- package/build-types/item-group/types.d.ts +2 -2
- package/build-types/item-group/types.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/types.d.ts +3 -3
- package/build-types/keyboard-shortcuts/types.d.ts.map +1 -1
- package/build-types/menu-group/types.d.ts +1 -1
- package/build-types/menu-group/types.d.ts.map +1 -1
- package/build-types/menu-item/index.d.ts +1 -1
- package/build-types/menu-items-choice/types.d.ts +2 -2
- package/build-types/menu-items-choice/types.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +1 -1
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/navigable-container/container.d.ts +1 -1
- package/build-types/navigable-container/menu.d.ts +1 -1
- package/build-types/navigable-container/tabbable.d.ts +1 -1
- package/build-types/navigation/back-button/index.d.ts +5 -0
- package/build-types/navigation/back-button/index.d.ts.map +1 -0
- package/build-types/navigation/constants.d.ts +3 -0
- package/build-types/navigation/constants.d.ts.map +1 -0
- package/build-types/navigation/context.d.ts +5 -0
- package/build-types/navigation/context.d.ts.map +1 -0
- package/build-types/navigation/group/context.d.ts +8 -0
- package/build-types/navigation/group/context.d.ts.map +1 -0
- package/build-types/navigation/group/index.d.ts +5 -0
- package/build-types/navigation/group/index.d.ts.map +1 -0
- package/build-types/navigation/index.d.ts +46 -0
- package/build-types/navigation/index.d.ts.map +1 -0
- package/build-types/navigation/item/base-content.d.ts +4 -0
- package/build-types/navigation/item/base-content.d.ts.map +1 -0
- package/build-types/navigation/item/base.d.ts +4 -0
- package/build-types/navigation/item/base.d.ts.map +1 -0
- package/build-types/navigation/item/index.d.ts +5 -0
- package/build-types/navigation/item/index.d.ts.map +1 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts +3 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +1 -0
- package/build-types/navigation/menu/context.d.ts +8 -0
- package/build-types/navigation/menu/context.d.ts.map +1 -0
- package/build-types/navigation/menu/index.d.ts +5 -0
- package/build-types/navigation/menu/index.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title-search.d.ts +4 -0
- package/build-types/navigation/menu/menu-title-search.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title.d.ts +4 -0
- package/build-types/navigation/menu/menu-title.d.ts.map +1 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts +4 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts.map +1 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +3 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +1 -0
- package/build-types/navigation/stories/index.d.ts +18 -0
- package/build-types/navigation/stories/index.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts +7 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/default.d.ts +10 -0
- package/build-types/navigation/stories/utils/default.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/group.d.ts +10 -0
- package/build-types/navigation/stories/utils/group.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts +10 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts +10 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/search.d.ts +10 -0
- package/build-types/navigation/stories/utils/search.d.ts.map +1 -0
- package/build-types/navigation/styles/navigation-styles.d.ts +58 -0
- package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -0
- package/build-types/navigation/test/index.d.ts +2 -0
- package/build-types/navigation/test/index.d.ts.map +1 -0
- package/build-types/navigation/types.d.ts +267 -0
- package/build-types/navigation/types.d.ts.map +1 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts +15 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts.map +1 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts +11 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +1 -0
- package/build-types/navigation/utils.d.ts +3 -0
- package/build-types/navigation/utils.d.ts.map +1 -0
- package/build-types/navigator/navigator-back-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +1 -1
- package/build-types/navigator/types.d.ts +12 -12
- package/build-types/navigator/types.d.ts.map +1 -1
- package/build-types/notice/types.d.ts +7 -7
- package/build-types/notice/types.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/types.d.ts +1 -1
- package/build-types/number-control/types.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +37 -0
- package/build-types/palette-edit/index.d.ts.map +1 -0
- package/build-types/palette-edit/stories/index.d.ts +13 -0
- package/build-types/palette-edit/stories/index.d.ts.map +1 -0
- package/build-types/palette-edit/styles.d.ts +51 -0
- package/build-types/palette-edit/styles.d.ts.map +1 -0
- package/build-types/palette-edit/test/index.d.ts +2 -0
- package/build-types/palette-edit/test/index.d.ts.map +1 -0
- package/build-types/palette-edit/types.d.ts +114 -0
- package/build-types/palette-edit/types.d.ts.map +1 -0
- package/build-types/panel/body.d.ts +9 -0
- package/build-types/panel/body.d.ts.map +1 -0
- package/build-types/panel/stories/index.d.ts +19 -0
- package/build-types/panel/stories/index.d.ts.map +1 -0
- package/build-types/panel/test/body.d.ts +2 -0
- package/build-types/panel/test/body.d.ts.map +1 -0
- package/build-types/panel/types.d.ts +73 -3
- package/build-types/panel/types.d.ts.map +1 -1
- package/build-types/placeholder/index.d.ts +1 -1
- package/build-types/placeholder/index.d.ts.map +1 -1
- package/build-types/placeholder/types.d.ts +2 -2
- package/build-types/placeholder/types.d.ts.map +1 -1
- package/build-types/popover/limit-shift.d.ts +2 -2
- package/build-types/popover/limit-shift.d.ts.map +1 -1
- package/build-types/popover/types.d.ts +10 -10
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts +2 -2
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/query-controls/category-select.d.ts.map +1 -1
- package/build-types/query-controls/terms.d.ts.map +1 -1
- package/build-types/query-controls/types.d.ts +12 -12
- package/build-types/query-controls/types.d.ts.map +1 -1
- package/build-types/radio-control/types.d.ts +1 -1
- package/build-types/radio-control/types.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts +1 -1
- package/build-types/radio-group/radio/index.d.ts +1 -1
- package/build-types/range-control/index.d.ts +2 -2
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +17 -17
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/label.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/label.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/styles/resize-tooltip.styles.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +2 -2
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/responsive-wrapper/index.d.ts.map +1 -1
- package/build-types/responsive-wrapper/stories/index.d.ts +10 -0
- package/build-types/responsive-wrapper/stories/index.d.ts.map +1 -1
- package/build-types/responsive-wrapper/types.d.ts +3 -3
- package/build-types/responsive-wrapper/types.d.ts.map +1 -1
- package/build-types/sandbox/types.d.ts +1 -1
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/scrollable/types.d.ts +2 -2
- package/build-types/scrollable/types.d.ts.map +1 -1
- package/build-types/search-control/types.d.ts +1 -1
- package/build-types/search-control/types.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts +2 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/stories/index.d.ts +3 -3
- package/build-types/select-control/stories/index.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +44 -20
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/shortcut/types.d.ts +1 -1
- package/build-types/shortcut/types.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts +1 -1
- package/build-types/slot-fill/provider.d.ts +1 -0
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/snackbar/types.d.ts +3 -3
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/spacer/types.d.ts +1 -1
- package/build-types/spacer/types.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/style-provider/types.d.ts +1 -1
- package/build-types/style-provider/types.d.ts.map +1 -1
- package/build-types/surface/types.d.ts +2 -2
- package/build-types/surface/types.d.ts.map +1 -1
- package/build-types/tab-panel/types.d.ts +5 -5
- package/build-types/tab-panel/types.d.ts.map +1 -1
- package/build-types/text/types.d.ts +3 -3
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +1 -1
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/text-highlight/types.d.ts +1 -1
- package/build-types/text-highlight/types.d.ts.map +1 -1
- package/build-types/textarea-control/types.d.ts +1 -1
- package/build-types/textarea-control/types.d.ts.map +1 -1
- package/build-types/theme/types.d.ts +3 -3
- package/build-types/theme/types.d.ts.map +1 -1
- package/build-types/tip/types.d.ts +1 -1
- package/build-types/tip/types.d.ts.map +1 -1
- package/build-types/toggle-control/types.d.ts +1 -1
- package/build-types/toggle-control/types.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +10 -10
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/types.d.ts +1 -1
- package/build-types/toolbar/toolbar/types.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +165 -11
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts +6 -1
- package/build-types/toolbar/toolbar-button/toolbar-button-container.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/types.d.ts +45 -0
- package/build-types/toolbar/toolbar-button/types.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-context/index.d.ts +6 -1
- package/build-types/toolbar/toolbar-context/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +1 -1
- package/build-types/toolbar/toolbar-item/index.d.ts +1 -1
- package/build-types/tools-panel/types.d.ts +11 -11
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tree-grid/types.d.ts +5 -5
- package/build-types/tree-grid/types.d.ts.map +1 -1
- package/build-types/tree-select/index.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +4 -10
- package/build-types/tree-select/types.d.ts.map +1 -1
- package/build-types/truncate/types.d.ts +2 -2
- package/build-types/truncate/types.d.ts.map +1 -1
- package/build-types/ui/context/context-connect.d.ts +1 -1
- package/build-types/ui/context/context-connect.d.ts.map +1 -1
- package/build-types/ui/context/wordpress-component.d.ts +3 -3
- package/build-types/ui/context/wordpress-component.d.ts.map +1 -1
- package/build-types/ui/control-group/types.d.ts +2 -2
- package/build-types/ui/control-group/types.d.ts.map +1 -1
- package/build-types/ui/control-label/types.d.ts +1 -1
- package/build-types/ui/control-label/types.d.ts.map +1 -1
- package/build-types/ui/form-group/form-group-content.d.ts +1 -1
- package/build-types/ui/form-group/form-group-help.d.ts +1 -1
- package/build-types/ui/form-group/form-group-label.d.ts +1 -1
- package/build-types/ui/form-group/types.d.ts +5 -5
- package/build-types/ui/form-group/types.d.ts.map +1 -1
- package/build-types/ui/form-group/use-form-group.d.ts +3 -3
- package/build-types/ui/spinner/component.d.ts +1 -1
- package/build-types/ui/tooltip/content.d.ts +1 -1
- package/build-types/ui/tooltip/types.d.ts +2 -2
- package/build-types/ui/tooltip/types.d.ts.map +1 -1
- package/build-types/ui/utils/font-size.d.ts +1 -1
- package/build-types/ui/utils/font-size.d.ts.map +1 -1
- package/build-types/ui/utils/space.d.ts +1 -1
- package/build-types/ui/utils/space.d.ts.map +1 -1
- package/build-types/ui/utils/types.d.ts +4 -4
- package/build-types/ui/utils/types.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +5 -5
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/breakpoint-values.d.ts +1 -1
- package/build-types/utils/colors-values.d.ts +1 -1
- package/build-types/utils/config-values.d.ts +9 -9
- package/build-types/utils/events.d.ts +1 -1
- package/build-types/utils/events.d.ts.map +1 -1
- package/build-types/utils/font-values.d.ts +1 -1
- package/build-types/utils/font.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
- package/build-types/utils/types.d.ts +4 -4
- package/build-types/utils/types.d.ts.map +1 -1
- package/build-types/v-stack/component.d.ts +1 -4
- package/build-types/v-stack/component.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/build-types/v-stack/stories/index.d.ts +1 -4
- package/build-types/v-stack/stories/index.d.ts.map +1 -1
- package/build-types/v-stack/types.d.ts +5 -3
- package/build-types/v-stack/types.d.ts.map +1 -1
- package/build-types/view/types.d.ts +1 -1
- package/build-types/view/types.d.ts.map +1 -1
- package/build-types/visually-hidden/types.d.ts +1 -1
- package/build-types/visually-hidden/types.d.ts.map +1 -1
- package/build-types/z-stack/types.d.ts +1 -1
- package/build-types/z-stack/types.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/animate/index.js +3 -1
- package/src/autocomplete/README.md +51 -0
- package/src/autocomplete/{autocompleter-ui.js → autocompleter-ui.tsx} +21 -10
- package/src/autocomplete/{get-default-use-items.js → get-default-use-items.tsx} +11 -6
- package/src/autocomplete/{index.js → index.tsx} +77 -111
- package/src/autocomplete/test/{index.js → index.tsx} +31 -20
- package/src/autocomplete/types.ts +220 -0
- package/src/border-control/test/index.js +0 -2
- package/src/button/style.scss +12 -1
- package/src/button/types.ts +2 -2
- package/src/circular-option-picker/types.ts +1 -1
- package/src/color-palette/test/__snapshots__/index.tsx.snap +16 -14
- package/src/custom-gradient-picker/gradient-bar/control-points.js +2 -0
- package/src/custom-gradient-picker/gradient-bar/index.js +2 -0
- package/src/custom-gradient-picker/gradient-bar/utils.js +2 -0
- package/src/custom-gradient-picker/index.js +2 -0
- package/src/custom-gradient-picker/serializer.js +2 -0
- package/src/custom-gradient-picker/utils.js +2 -0
- package/src/dimension-control/README.md +22 -55
- package/src/dimension-control/index.tsx +101 -0
- package/src/dimension-control/{sizes.js → sizes.ts} +8 -5
- package/src/dimension-control/stories/index.tsx +48 -0
- package/src/dimension-control/types.ts +48 -0
- package/src/flex/flex/hook.ts +2 -2
- package/src/font-size-picker/README.md +26 -20
- package/src/font-size-picker/index.tsx +2 -1
- package/src/font-size-picker/stories/index.tsx +1 -0
- package/src/font-size-picker/test/index.tsx +23 -0
- package/src/font-size-picker/types.ts +4 -0
- package/src/form-token-field/index.tsx +4 -1
- package/src/form-token-field/stories/index.tsx +13 -0
- package/src/form-token-field/test/index.tsx +80 -0
- package/src/gradient-picker/index.js +2 -0
- package/src/guide/README.md +17 -15
- package/src/guide/{icons.js → icons.tsx} +1 -1
- package/src/guide/{index.js → index.tsx} +47 -7
- package/src/guide/{page-control.js → page-control.tsx} +2 -1
- package/src/guide/{page.js → page.tsx} +8 -1
- package/src/guide/stories/{index.js → index.tsx} +11 -5
- package/src/guide/test/{index.js → index.tsx} +22 -4
- package/src/guide/types.ts +68 -0
- package/src/h-stack/README.md +2 -2
- package/src/h-stack/types.ts +2 -2
- package/src/h-stack/utils.ts +3 -3
- package/src/higher-order/navigate-regions/{index.js → index.tsx} +47 -11
- package/src/higher-order/with-fallback-styles/{index.js → index.tsx} +22 -5
- package/src/higher-order/with-filters/{index.js → index.tsx} +44 -12
- package/src/higher-order/with-filters/test/{index.js → index.tsx} +5 -1
- package/src/higher-order/with-focus-return/index.tsx +74 -0
- package/src/higher-order/with-focus-return/test/{index.js → index.tsx} +2 -2
- package/src/higher-order/with-notices/README.md +4 -1
- package/src/higher-order/with-notices/index.tsx +116 -0
- package/src/higher-order/with-notices/test/{index.js → index.tsx} +11 -6
- package/src/higher-order/with-notices/types.ts +35 -0
- package/src/higher-order/with-spoken-messages/test/{index.js → index.tsx} +2 -1
- package/src/icon/index.tsx +11 -15
- package/src/icon/test/{index.js → index.tsx} +6 -2
- package/src/index.native.js +1 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js +1 -1
- package/src/mobile/bottom-sheet/cell.native.js +1 -1
- package/src/mobile/bottom-sheet-text-control/README.md +8 -1
- package/src/mobile/bottom-sheet-text-control/index.native.js +2 -1
- package/src/mobile/link-settings/test/link-settings-navigation.native.js +1 -1
- package/src/navigation/README.md +16 -2
- package/src/navigation/back-button/{index.js → index.tsx} +22 -6
- package/src/navigation/{context.js → context.tsx} +8 -5
- package/src/navigation/group/context.tsx +15 -0
- package/src/navigation/group/{index.js → index.tsx} +9 -1
- package/src/navigation/{index.js → index.tsx} +63 -7
- package/src/navigation/item/{base-content.js → base-content.tsx} +5 -2
- package/src/navigation/item/{base.js → base.tsx} +3 -1
- package/src/navigation/item/{index.js → index.tsx} +8 -2
- package/src/navigation/item/{use-navigation-tree-item.js → use-navigation-tree-item.tsx} +9 -2
- package/src/navigation/menu/context.tsx +18 -0
- package/src/navigation/menu/{index.js → index.tsx} +5 -1
- package/src/navigation/menu/{menu-title-search.js → menu-title-search.tsx} +11 -7
- package/src/navigation/menu/{menu-title.js → menu-title.tsx} +5 -3
- package/src/navigation/menu/{search-no-results-found.js → search-no-results-found.tsx} +5 -1
- package/src/navigation/menu/{use-navigation-tree-menu.js → use-navigation-tree-menu.tsx} +3 -1
- package/src/navigation/stories/index.tsx +53 -0
- package/src/navigation/stories/utils/{controlled-state.js → controlled-state.tsx} +32 -13
- package/src/navigation/stories/utils/{default.js → default.tsx} +20 -6
- package/src/navigation/stories/utils/{group.js → group.tsx} +21 -7
- package/src/navigation/stories/utils/{hide-if-empty.js → hide-if-empty.tsx} +19 -6
- package/src/navigation/stories/utils/{more-examples.js → more-examples.tsx} +30 -12
- package/src/navigation/stories/utils/{search.js → search.tsx} +21 -7
- package/src/navigation/test/{index.js → index.tsx} +17 -4
- package/src/navigation/types.ts +325 -0
- package/src/navigation/{use-create-navigation-tree.js → use-create-navigation-tree.tsx} +37 -25
- package/src/navigation/{use-navigation-tree-nodes.js → use-navigation-tree-nodes.tsx} +10 -6
- package/src/navigation/{utils.js → utils.tsx} +2 -2
- package/src/navigator/navigator-screen/component.tsx +13 -7
- package/src/navigator/test/index.tsx +65 -22
- package/src/number-control/index.tsx +0 -2
- package/src/palette-edit/{index.js → index.tsx} +115 -48
- package/src/palette-edit/stories/index.tsx +82 -0
- package/src/palette-edit/test/{index.js → index.tsx} +15 -3
- package/src/palette-edit/types.ts +126 -0
- package/src/panel/README.md +53 -35
- package/src/panel/{body.js → body.tsx} +31 -17
- package/src/panel/stories/{index.js → index.tsx} +16 -6
- package/src/panel/test/{body.js → body.tsx} +12 -17
- package/src/panel/types.ts +78 -0
- package/src/placeholder/index.tsx +2 -6
- package/src/placeholder/test/index.tsx +1 -1
- package/src/placeholder/types.ts +2 -2
- package/src/popover/test/index.tsx +5 -2
- package/src/query-controls/author-select.tsx +1 -6
- package/src/query-controls/category-select.tsx +1 -6
- package/src/query-controls/terms.ts +29 -18
- package/src/range-control/index.tsx +2 -6
- package/src/range-control/types.ts +3 -3
- package/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.ts +2 -1
- package/src/responsive-wrapper/README.md +8 -2
- package/src/responsive-wrapper/index.tsx +18 -17
- package/src/responsive-wrapper/stories/index.tsx +41 -0
- package/src/responsive-wrapper/style.scss +5 -11
- package/src/responsive-wrapper/types.ts +2 -2
- package/src/select-control/index.tsx +16 -16
- package/src/select-control/stories/index.tsx +24 -12
- package/src/select-control/types.ts +68 -40
- package/src/tab-panel/types.ts +4 -4
- package/src/toolbar/toolbar-button/README.md +13 -1
- package/src/toolbar/toolbar-button/{index.js → index.tsx} +55 -20
- package/src/toolbar/toolbar-button/toolbar-button-container.tsx +13 -0
- package/src/toolbar/toolbar-button/types.ts +46 -0
- package/src/toolbar/toolbar-context/index.ts +15 -0
- package/src/tooltip/index.js +11 -1
- package/src/tree-select/index.tsx +5 -2
- package/src/tree-select/types.ts +6 -13
- package/src/ui/context/get-styled-class-name-from-key.ts +1 -1
- package/src/utils/font.js +1 -6
- package/src/v-stack/README.md +2 -2
- package/src/v-stack/hook.ts +6 -4
- package/src/v-stack/stories/index.tsx +28 -7
- package/src/v-stack/test/__snapshots__/index.tsx.snap +20 -18
- package/src/v-stack/types.ts +5 -3
- package/tsconfig.json +1 -14
- package/tsconfig.tsbuildinfo +1 -1
- package/src/dimension-control/index.js +0 -73
- package/src/higher-order/with-focus-return/index.js +0 -64
- package/src/higher-order/with-notices/index.js +0 -104
- package/src/navigation/group/context.js +0 -9
- package/src/navigation/menu/context.js +0 -11
- package/src/navigation/stories/index.js +0 -33
- package/src/toolbar/toolbar-button/toolbar-button-container.js +0 -6
- package/src/toolbar/toolbar-context/index.js +0 -10
- /package/src/animation/{index.js → index.tsx} +0 -0
- /package/src/higher-order/with-filters/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- /package/src/higher-order/with-spoken-messages/{index.js → index.tsx} +0 -0
- /package/src/navigation/{constants.js → constants.tsx} +0 -0
- /package/src/navigation/styles/{navigation-styles.js → navigation-styles.tsx} +0 -0
- /package/src/panel/test/__snapshots__/{body.js.snap → body.tsx.snap} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/tree-select/index.tsx"],"names":["getSelectOptions","tree","level","flatMap","treeNode","value","id","label","repeat","name","children","TreeSelect","noOptionLabel","onChange","selectedId","props","options","filter","option"],"mappings":";;;;;;;;;;AAGA;;;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,gBAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/tree-select/index.tsx"],"names":["getSelectOptions","tree","level","flatMap","treeNode","value","id","label","repeat","name","children","TreeSelect","noOptionLabel","onChange","selectedId","props","options","filter","option"],"mappings":";;;;;;;;;;AAGA;;;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,gBAAT,CACCC,IADD,EAG+C;AAAA,MAD9CC,KAC8C,uEADtC,CACsC;AAC9C,SAAOD,IAAI,CAACE,OAAL,CAAgBC,QAAF,IAAgB,CACpC;AACCC,IAAAA,KAAK,EAAED,QAAQ,CAACE,EADjB;AAECC,IAAAA,KAAK,EACJ,SAASC,MAAT,CAAiBN,KAAK,GAAG,CAAzB,IAA+B,kCAAgBE,QAAQ,CAACK,IAAzB;AAHjC,GADoC,EAMpC,GAAGT,gBAAgB,CAAEI,QAAQ,CAACM,QAAT,IAAqB,EAAvB,EAA2BR,KAAK,GAAG,CAAnC,CANiB,CAA9B,CAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEO,SAASS,UAAT,OAOc;AAAA,MAPO;AAC3BJ,IAAAA,KAD2B;AAE3BK,IAAAA,aAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,UAJ2B;AAK3Bb,IAAAA,IAAI,GAAG,EALoB;AAM3B,OAAGc;AANwB,GAOP;AACpB,QAAMC,OAAO,GAAG,sBAAS,MAAM;AAC9B,WAAO,CACNJ,aAAa,IAAI;AAAEP,MAAAA,KAAK,EAAE,EAAT;AAAaE,MAAAA,KAAK,EAAEK;AAApB,KADX,EAEN,GAAGZ,gBAAgB,CAAEC,IAAF,CAFb,EAGLgB,MAHK,CAGWC,MAAR,IAA8C,CAAC,CAAEA,MAHpD,CAAP;AAIA,GALe,EAKb,CAAEN,aAAF,EAAiBX,IAAjB,CALa,CAAhB;AAOA,SACC,4BAAC,4BAAD;AACQM,IAAAA,KADR;AACeS,IAAAA,OADf;AACwBH,IAAAA,QADxB;AAEC,IAAA,KAAK,EAAGC;AAFT,KAGMC,KAHN,EADD;AAOA;;eAEcJ,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { SelectControl } from '../select-control';\nimport type { TreeSelectProps, Tree, Truthy } from './types';\n\nfunction getSelectOptions(\n\ttree: Tree[],\n\tlevel = 0\n): NonNullable< TreeSelectProps[ 'options' ] > {\n\treturn tree.flatMap( ( treeNode ) => [\n\t\t{\n\t\t\tvalue: treeNode.id,\n\t\t\tlabel:\n\t\t\t\t'\\u00A0'.repeat( level * 3 ) + decodeEntities( treeNode.name ),\n\t\t},\n\t\t...getSelectOptions( treeNode.children || [], level + 1 ),\n\t] );\n}\n\n/**\n * TreeSelect component is used to generate select input fields.\n *\n * @example\n * ```jsx\n * import { TreeSelect } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyTreeSelect = () => {\n * \tconst [ page, setPage ] = useState( 'p21' );\n *\n * \treturn (\n * \t\t<TreeSelect\n * \t\t\tlabel=\"Parent page\"\n * \t\t\tnoOptionLabel=\"No parent page\"\n * \t\t\tonChange={ ( newPage ) => setPage( newPage ) }\n * \t\t\tselectedId={ page }\n * \t\t\ttree={ [\n * \t\t\t\t{\n * \t\t\t\t\tname: 'Page 1',\n * \t\t\t\t\tid: 'p1',\n * \t\t\t\t\tchildren: [\n * \t\t\t\t\t\t{ name: 'Descend 1 of page 1', id: 'p11' },\n * \t\t\t\t\t\t{ name: 'Descend 2 of page 1', id: 'p12' },\n * \t\t\t\t\t],\n * \t\t\t\t},\n * \t\t\t\t{\n * \t\t\t\t\tname: 'Page 2',\n * \t\t\t\t\tid: 'p2',\n * \t\t\t\t\tchildren: [\n * \t\t\t\t\t\t{\n * \t\t\t\t\t\t\tname: 'Descend 1 of page 2',\n * \t\t\t\t\t\t\tid: 'p21',\n * \t\t\t\t\t\t\tchildren: [\n * \t\t\t\t\t\t\t\t{\n * \t\t\t\t\t\t\t\t\tname: 'Descend 1 of Descend 1 of page 2',\n * \t\t\t\t\t\t\t\t\tid: 'p211',\n * \t\t\t\t\t\t\t\t},\n * \t\t\t\t\t\t\t],\n * \t\t\t\t\t\t},\n * \t\t\t\t\t],\n * \t\t\t\t},\n * \t\t\t] }\n * \t\t/>\n * \t);\n * }\n * ```\n */\n\nexport function TreeSelect( {\n\tlabel,\n\tnoOptionLabel,\n\tonChange,\n\tselectedId,\n\ttree = [],\n\t...props\n}: TreeSelectProps ) {\n\tconst options = useMemo( () => {\n\t\treturn [\n\t\t\tnoOptionLabel && { value: '', label: noOptionLabel },\n\t\t\t...getSelectOptions( tree ),\n\t\t].filter( < T, >( option: T ): option is Truthy< T > => !! option );\n\t}, [ noOptionLabel, tree ] );\n\n\treturn (\n\t\t<SelectControl\n\t\t\t{ ...{ label, options, onChange } }\n\t\t\tvalue={ selectedId }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nexport default TreeSelect;\n"]}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getStyledClassNameFromKey = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _changeCase = require("change-case");
|
|
11
11
|
|
|
12
12
|
var _memize = _interopRequireDefault(require("memize"));
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ var _memize = _interopRequireDefault(require("memize"));
|
|
|
22
22
|
* @return The generated CSS className.
|
|
23
23
|
*/
|
|
24
24
|
function getStyledClassName(namespace) {
|
|
25
|
-
const kebab = (0,
|
|
25
|
+
const kebab = (0, _changeCase.paramCase)(namespace);
|
|
26
26
|
return `components-${kebab}`;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/ui/context/get-styled-class-name-from-key.ts"],"names":["getStyledClassName","namespace","kebab","getStyledClassNameFromKey"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA6BC,SAA7B,EAAyD;AACxD,QAAMC,KAAK,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/ui/context/get-styled-class-name-from-key.ts"],"names":["getStyledClassName","namespace","kebab","getStyledClassNameFromKey"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA6BC,SAA7B,EAAyD;AACxD,QAAMC,KAAK,GAAG,2BAAWD,SAAX,CAAd;AACA,SAAQ,cAAcC,KAAO,EAA7B;AACA;;AAEM,MAAMC,yBAAyB,GAAG,qBAASH,kBAAT,CAAlC","sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\nimport memoize from 'memize';\n\n/**\n * Generates the connected component CSS className based on the namespace.\n *\n * @param namespace The name of the connected component.\n * @return The generated CSS className.\n */\nfunction getStyledClassName( namespace: string ): string {\n\tconst kebab = kebabCase( namespace );\n\treturn `components-${ kebab }`;\n}\n\nexport const getStyledClassNameFromKey = memoize( getStyledClassName );\n"]}
|
package/build/utils/font.js
CHANGED
|
@@ -7,14 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.font = font;
|
|
9
9
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
10
|
var _fontValues = _interopRequireDefault(require("./font-values"));
|
|
13
11
|
|
|
14
|
-
/**
|
|
15
|
-
* External dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* Internal dependencies
|
|
20
14
|
*/
|
|
@@ -25,6 +19,8 @@ var _fontValues = _interopRequireDefault(require("./font-values"));
|
|
|
25
19
|
* @return {string} Font rule value
|
|
26
20
|
*/
|
|
27
21
|
function font(value) {
|
|
28
|
-
|
|
22
|
+
var _FONT$value;
|
|
23
|
+
|
|
24
|
+
return (_FONT$value = _fontValues.default[value]) !== null && _FONT$value !== void 0 ? _FONT$value : '';
|
|
29
25
|
}
|
|
30
26
|
//# sourceMappingURL=font.js.map
|
package/build/utils/font.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/utils/font.js"],"names":["font","value","FONT"],"mappings":";;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/utils/font.js"],"names":["font","value","FONT"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACO,SAASA,IAAT,CAAeC,KAAf,EAAuB;AAAA;;AAC7B,wBAAOC,oBAAMD,KAAN,CAAP,qDAAwB,EAAxB;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport FONT from './font-values';\n\n/**\n *\n * @param {keyof FONT} value Path of value from `FONT`\n * @return {string} Font rule value\n */\nexport function font( value ) {\n\treturn FONT[ value ] ?? '';\n}\n"]}
|
package/build/v-stack/hook.js
CHANGED
|
@@ -15,11 +15,13 @@ var _hStack = require("../h-stack");
|
|
|
15
15
|
function useVStack(props) {
|
|
16
16
|
const {
|
|
17
17
|
expanded = false,
|
|
18
|
+
alignment = 'stretch',
|
|
18
19
|
...otherProps
|
|
19
20
|
} = (0, _context.useContextSystem)(props, 'VStack');
|
|
20
21
|
const hStackProps = (0, _hStack.useHStack)({
|
|
21
22
|
direction: 'column',
|
|
22
23
|
expanded,
|
|
24
|
+
alignment,
|
|
23
25
|
...otherProps
|
|
24
26
|
});
|
|
25
27
|
return hStackProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/v-stack/hook.ts"],"names":["useVStack","props","expanded","otherProps","hStackProps","direction"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAKO,SAASA,SAAT,CACNC,KADM,EAEL;AACD,QAAM;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/v-stack/hook.ts"],"names":["useVStack","props","expanded","alignment","otherProps","hStackProps","direction"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAKO,SAASA,SAAT,CACNC,KADM,EAEL;AACD,QAAM;AACLC,IAAAA,QAAQ,GAAG,KADN;AAELC,IAAAA,SAAS,GAAG,SAFP;AAGL,OAAGC;AAHE,MAIF,+BAAkBH,KAAlB,EAAyB,QAAzB,CAJJ;AAMA,QAAMI,WAAW,GAAG,uBAAW;AAC9BC,IAAAA,SAAS,EAAE,QADmB;AAE9BJ,IAAAA,QAF8B;AAG9BC,IAAAA,SAH8B;AAI9B,OAAGC;AAJ2B,GAAX,CAApB;AAOA,SAAOC,WAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { useContextSystem, WordPressComponentProps } from '../ui/context';\nimport { useHStack } from '../h-stack';\nimport type { VStackProps } from './types';\n\nexport function useVStack(\n\tprops: WordPressComponentProps< VStackProps, 'div' >\n) {\n\tconst {\n\t\texpanded = false,\n\t\talignment = 'stretch',\n\t\t...otherProps\n\t} = useContextSystem( props, 'VStack' );\n\n\tconst hStackProps = useHStack( {\n\t\tdirection: 'column',\n\t\texpanded,\n\t\talignment,\n\t\t...otherProps,\n\t} );\n\n\treturn hStackProps;\n}\n"]}
|
|
@@ -26,7 +26,7 @@ function getDefaultOrigin(type) {
|
|
|
26
26
|
/**
|
|
27
27
|
* @param {GetAnimateOptions} options
|
|
28
28
|
*
|
|
29
|
-
* @return {string |
|
|
29
|
+
* @return {string | undefined} ClassName that applies the animations
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
|
|
@@ -51,6 +51,8 @@ export function getAnimateClassName(options) {
|
|
|
51
51
|
if (type === 'slide-in') {
|
|
52
52
|
return classnames('components-animate__slide-in', 'is-from-' + origin);
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
return undefined;
|
|
54
56
|
} // @ts-ignore Reason: Planned for deprecation
|
|
55
57
|
|
|
56
58
|
export default function Animate(_ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/animate/index.js"],"names":["classnames","getDefaultOrigin","type","getAnimateClassName","options","origin","yAxis","xAxis","split","Animate","children","className"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,KAAK,QAAT,GAAoB,KAApB,GAA4B,MAAnC;AACA;AACD;;AAEA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,mBAAT,CAA8BC,OAA9B,EAAwC;AAC9C,MAAKA,OAAO,CAACF,IAAR,KAAiB,SAAtB,EAAkC;AACjC,WAAOF,UAAU,CAAE,6BAAF,CAAjB;AACA;;AAED,QAAM;AAAEE,IAAAA,IAAF;AAAQG,IAAAA,MAAM,GAAGJ,gBAAgB,CAAEC,IAAF;AAAjC,MAA8CE,OAApD;;AAEA,MAAKF,IAAI,KAAK,QAAd,EAAyB;AACxB,UAAM,CAAEI,KAAF,EAASC,KAAK,GAAG,QAAjB,IAA8BF,MAAM,CAACG,KAAP,CAAc,GAAd,CAApC;AACA,WAAOR,UAAU,CAAE,4BAAF,EAAgC;AAChD,OAAE,aAAaO,KAAf,GAAwBA,KAAK,KAAK,QADc;AAEhD,OAAE,aAAaD,KAAf,GAAwBA,KAAK,KAAK;AAFc,KAAhC,CAAjB;AAIA;;AAED,MAAKJ,IAAI,KAAK,UAAd,EAA2B;AAC1B,WAAOF,UAAU,CAChB,8BADgB,EAEhB,aAAaK,MAFG,CAAjB;AAIA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/animate/index.js"],"names":["classnames","getDefaultOrigin","type","getAnimateClassName","options","origin","yAxis","xAxis","split","undefined","Animate","children","className"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,KAAK,QAAT,GAAoB,KAApB,GAA4B,MAAnC;AACA;AACD;;AAEA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASC,mBAAT,CAA8BC,OAA9B,EAAwC;AAC9C,MAAKA,OAAO,CAACF,IAAR,KAAiB,SAAtB,EAAkC;AACjC,WAAOF,UAAU,CAAE,6BAAF,CAAjB;AACA;;AAED,QAAM;AAAEE,IAAAA,IAAF;AAAQG,IAAAA,MAAM,GAAGJ,gBAAgB,CAAEC,IAAF;AAAjC,MAA8CE,OAApD;;AAEA,MAAKF,IAAI,KAAK,QAAd,EAAyB;AACxB,UAAM,CAAEI,KAAF,EAASC,KAAK,GAAG,QAAjB,IAA8BF,MAAM,CAACG,KAAP,CAAc,GAAd,CAApC;AACA,WAAOR,UAAU,CAAE,4BAAF,EAAgC;AAChD,OAAE,aAAaO,KAAf,GAAwBA,KAAK,KAAK,QADc;AAEhD,OAAE,aAAaD,KAAf,GAAwBA,KAAK,KAAK;AAFc,KAAhC,CAAjB;AAIA;;AAED,MAAKJ,IAAI,KAAK,UAAd,EAA2B;AAC1B,WAAOF,UAAU,CAChB,8BADgB,EAEhB,aAAaK,MAFG,CAAjB;AAIA;;AAED,SAAOI,SAAP;AACA,C,CAED;;AACA,eAAe,SAASC,OAAT,OAAqD;AAAA,MAAnC;AAAER,IAAAA,IAAF;AAAQE,IAAAA,OAAO,GAAG,EAAlB;AAAsBO,IAAAA;AAAtB,GAAmC;AACnE,SAAOA,QAAQ,CAAE;AAChBC,IAAAA,SAAS,EAAET,mBAAmB,CAAE;AAAED,MAAAA,IAAF;AAAQ,SAAGE;AAAX,KAAF;AADd,GAAF,CAAf;AAGA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * @typedef {'top' | 'top left' | 'top right' | 'middle' | 'middle left' | 'middle right' | 'bottom' | 'bottom left' | 'bottom right'} AppearOrigin\n * @typedef {'left' | 'right'} SlideInOrigin\n * @typedef {{ type: 'appear'; origin?: AppearOrigin }} AppearOptions\n * @typedef {{ type: 'slide-in'; origin?: SlideInOrigin }} SlideInOptions\n * @typedef {{ type: 'loading' }} LoadingOptions\n * @typedef {AppearOptions | SlideInOptions | LoadingOptions} GetAnimateOptions\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {GetAnimateOptions['type']} type The animation type\n * @return {'top' | 'left'} Default origin\n */\nfunction getDefaultOrigin( type ) {\n\treturn type === 'appear' ? 'top' : 'left';\n}\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @param {GetAnimateOptions} options\n *\n * @return {string | undefined} ClassName that applies the animations\n */\nexport function getAnimateClassName( options ) {\n\tif ( options.type === 'loading' ) {\n\t\treturn classnames( 'components-animate__loading' );\n\t}\n\n\tconst { type, origin = getDefaultOrigin( type ) } = options;\n\n\tif ( type === 'appear' ) {\n\t\tconst [ yAxis, xAxis = 'center' ] = origin.split( ' ' );\n\t\treturn classnames( 'components-animate__appear', {\n\t\t\t[ 'is-from-' + xAxis ]: xAxis !== 'center',\n\t\t\t[ 'is-from-' + yAxis ]: yAxis !== 'middle',\n\t\t} );\n\t}\n\n\tif ( type === 'slide-in' ) {\n\t\treturn classnames(\n\t\t\t'components-animate__slide-in',\n\t\t\t'is-from-' + origin\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n// @ts-ignore Reason: Planned for deprecation\nexport default function Animate( { type, options = {}, children } ) {\n\treturn children( {\n\t\tclassName: getAnimateClassName( { type, ...options } ),\n\t} );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/animation/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/animation/index.tsx"],"names":["motion","__unstableMotion","AnimatePresence","__unstableAnimatePresence"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA,SACCA,MAAM,IAAIC,gBADX,EAECC,eAAe,IAAIC,yBAFpB,QAGO,eAHP","sourcesContent":["/**\n * Framer Motion is used to create animated, interactive interfaces. The package is roughly ~30kb so\n * this should ideally be loaded once across all Gutenberg packages. To give ourselves more flexibility\n * in trying animation options, we avoid making this public API.\n *\n * @see https://www.framer.com/docs/animation/\n */\n\n// eslint-disable-next-line no-restricted-imports\nexport {\n\tmotion as __unstableMotion,\n\tAnimatePresence as __unstableAnimatePresence,\n} from 'framer-motion';\n"]}
|
|
@@ -8,7 +8,9 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useLayoutEffect, useRef, useEffect, useState } from '@wordpress/element';
|
|
11
|
+
import { useLayoutEffect, useRef, useEffect, useState } from '@wordpress/element'; // Error expected because `@wordpress/rich-text` is not yet fully typed.
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
|
|
12
14
|
import { useAnchor } from '@wordpress/rich-text';
|
|
13
15
|
import { useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
14
16
|
/**
|
|
@@ -34,16 +36,14 @@ export function getAutoCompleterUI(autocompleter) {
|
|
|
34
36
|
onSelect,
|
|
35
37
|
onReset,
|
|
36
38
|
reset,
|
|
37
|
-
value,
|
|
38
39
|
contentRef
|
|
39
40
|
} = _ref;
|
|
40
41
|
const [items] = useItems(filterValue);
|
|
41
42
|
const popoverAnchor = useAnchor({
|
|
42
|
-
editableContentElement: contentRef.current
|
|
43
|
-
value
|
|
43
|
+
editableContentElement: contentRef.current
|
|
44
44
|
});
|
|
45
45
|
const [needsA11yCompat, setNeedsA11yCompat] = useState(false);
|
|
46
|
-
const popoverRef = useRef();
|
|
46
|
+
const popoverRef = useRef(null);
|
|
47
47
|
const popoverRefs = useMergeRefs([popoverRef, useRefEffect(node => {
|
|
48
48
|
if (!contentRef.current) return; // If the popover is rendered in a different document than
|
|
49
49
|
// the content, we need to duplicate the options list in the
|
|
@@ -59,7 +59,7 @@ export function getAutoCompleterUI(autocompleter) {
|
|
|
59
59
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
60
|
}, [items]);
|
|
61
61
|
|
|
62
|
-
if (
|
|
62
|
+
if (items.length === 0) {
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"names":["classnames","useLayoutEffect","useRef","useEffect","useState","useAnchor","useMergeRefs","useRefEffect","getDefaultUseItems","Button","Popover","VisuallyHidden","createPortal","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","instanceId","listBoxId","className","selectedIndex","onChangeOptions","onSelect","onReset","reset","contentRef","items","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","length","ListBox","Component","map","option","index","key","isDisabled","label","body","ref","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,eADD,EAECC,MAFD,EAGCC,SAHD,EAICC,QAJD,QAKO,oBALP,C,CAMA;AACA;;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,EAAuBC,YAAvB,QAA2C,oBAA3C;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,YAAT,QAA6B,WAA7B;AAGA,OAAO,SAASC,kBAAT,CAA6BC,aAA7B,EAA0D;AAChE,QAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAd,GACdD,aAAa,CAACC,QADA,GAEdP,kBAAkB,CAAEM,aAAF,CAFrB;;AAIA,WAASE,eAAT,OAW0B;AAAA,QAXA;AACzBC,MAAAA,WADyB;AAEzBC,MAAAA,UAFyB;AAGzBC,MAAAA,SAHyB;AAIzBC,MAAAA,SAJyB;AAKzBC,MAAAA,aALyB;AAMzB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A,KATD;;AAUAG,IAAAA,QAAQ,CAACC,gBAAT,CAA2B,WAA3B,EAAwCL,QAAxC;AACAI,IAAAA,QAAQ,CAACC,gBAAT,CAA2B,YAA3B,EAAyCL,QAAzC;AACA,WAAO,MAAM;AACZI,MAAAA,QAAQ,CAACE,mBAAT,CAA8B,WAA9B,EAA2CN,QAA3C;AACAI,MAAAA,QAAQ,CAACE,mBAAT,CAA8B,YAA9B,EAA4CN,QAA5C;AACA,KAHD,CAbgB,CAiBhB;AACA;AACA;AACA,GApBQ,EAoBN,CAAED,OAAF,CApBM,CAAT;AAqBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseRef,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\n// Error expected because `@wordpress/rich-text` is not yet fully typed.\n// @ts-expect-error\nimport { useAnchor } from '@wordpress/rich-text';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport getDefaultUseItems from './get-default-use-items';\nimport Button from '../button';\nimport Popover from '../popover';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { createPortal } from 'react-dom';\nimport type { AutocompleterUIProps, WPCompleter } from './types';\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tinstanceId,\n\t\tlistBoxId,\n\t\tclassName,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tonReset,\n\t\treset,\n\t\tcontentRef,\n\t}: AutocompleterUIProps ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst popoverAnchor = useAnchor( {\n\t\t\teditableContentElement: contentRef.current,\n\t\t} );\n\n\t\tconst [ needsA11yCompat, setNeedsA11yCompat ] = useState( false );\n\t\tconst popoverRef = useRef< HTMLElement >( null );\n\t\tconst popoverRefs = useMergeRefs( [\n\t\t\tpopoverRef,\n\t\t\tuseRefEffect(\n\t\t\t\t( node ) => {\n\t\t\t\t\tif ( ! contentRef.current ) return;\n\n\t\t\t\t\t// If the popover is rendered in a different document than\n\t\t\t\t\t// the content, we need to duplicate the options list in the\n\t\t\t\t\t// content document so that it's available to the screen\n\t\t\t\t\t// readers, which check the DOM ID based aira-* attributes.\n\t\t\t\t\tsetNeedsA11yCompat(\n\t\t\t\t\t\tnode.ownerDocument !== contentRef.current.ownerDocument\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t[ contentRef ]\n\t\t\t),\n\t\t] );\n\n\t\tuseOnClickOutside( popoverRef, reset );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t}, [ items ] );\n\n\t\tif ( items.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst ListBox = ( {\n\t\t\tComponent = 'div',\n\t\t}: {\n\t\t\tComponent?: React.ElementType;\n\t\t} ) => (\n\t\t\t<Component\n\t\t\t\tid={ listBoxId }\n\t\t\t\trole=\"listbox\"\n\t\t\t\tclassName=\"components-autocomplete__results\"\n\t\t\t>\n\t\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ option.key }\n\t\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ option.label }\n\t\t\t\t\t</Button>\n\t\t\t\t) ) }\n\t\t\t</Component>\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Popover\n\t\t\t\t\tfocusOnMount={ false }\n\t\t\t\t\tonClose={ onReset }\n\t\t\t\t\tplacement=\"top-start\"\n\t\t\t\t\tclassName=\"components-autocomplete__popover\"\n\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\tref={ popoverRefs }\n\t\t\t\t>\n\t\t\t\t\t<ListBox />\n\t\t\t\t</Popover>\n\t\t\t\t{ contentRef.current &&\n\t\t\t\t\tneedsA11yCompat &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<ListBox Component={ VisuallyHidden } />,\n\t\t\t\t\t\tcontentRef.current.ownerDocument.body\n\t\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nfunction useOnClickOutside(\n\tref: React.RefObject< HTMLElement >,\n\thandler: AutocompleterUIProps[ 'reset' ]\n) {\n\tuseEffect( () => {\n\t\tconst listener = ( event: MouseEvent | TouchEvent ) => {\n\t\t\t// Do nothing if clicking ref's element or descendent elements, or if the ref is not referencing an element\n\t\t\tif (\n\t\t\t\t! ref.current ||\n\t\t\t\tref.current.contains( event.target as Node )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\thandler( event );\n\t\t};\n\t\tdocument.addEventListener( 'mousedown', listener );\n\t\tdocument.addEventListener( 'touchstart', listener );\n\t\treturn () => {\n\t\t\tdocument.removeEventListener( 'mousedown', listener );\n\t\t\tdocument.removeEventListener( 'touchstart', listener );\n\t\t};\n\t\t// Disable reason: `ref` is a ref object and should not be included in a\n\t\t// hook's dependency list.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ handler ] );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/autocomplete/get-default-use-items.
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/autocomplete/get-default-use-items.tsx"],"names":["removeAccents","debounce","useLayoutEffect","useState","escapeRegExp","filterOptions","search","options","maxResults","filtered","i","length","option","keywords","label","isMatch","some","keyword","test","push","getDefaultUseItems","autocompleter","filterValue","items","setItems","isDebounced","loadOptions","promise","Promise","resolve","then","optionsData","canceled","keyedOptions","map","optionData","optionIndex","key","name","value","getOptionLabel","getOptionKeywords","isDisabled","isOptionDisabled","RegExp","cancel"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,gBAA1B;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,eAAT,EAA0BC,QAA1B,QAA0C,oBAA1C;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,kBAA7B;;AAGA,SAASC,aAAT,CACCC,MADD,EAIE;AAAA,MAFDC,OAEC,uEAF+B,EAE/B;AAAA,MADDC,UACC,uEADY,EACZ;AACD,QAAMC,QAAQ,GAAG,EAAjB;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,OAAO,CAACI,MAA7B,EAAqCD,CAAC,EAAtC,EAA2C;AAC1C,UAAME,MAAM,GAAGL,OAAO,CAAEG,CAAF,CAAtB,CAD0C,CAG1C;;AACA,QAAI;AAAEG,MAAAA,QAAQ,GAAG;AAAb,QAAoBD,MAAxB;;AACA,QAAK,aAAa,OAAOA,MAAM,CAACE,KAAhC,EAAwC;AACvCD,MAAAA,QAAQ,GAAG,CAAE,GAAGA,QAAL,EAAeD,MAAM,CAACE,KAAtB,CAAX;AACA;;AAED,UAAMC,OAAO,GAAGF,QAAQ,CAACG,IAAT,CAAiBC,OAAF,IAC9BX,MAAM,CAACY,IAAP,CAAalB,aAAa,CAAEiB,OAAF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,gBAAd,CACAR,UADA,CADS,GAIT;AAf6B,WAAjC,CADoB,CAArB,CAJ0B,CAwB1B;;AACA,gBAAM7B,MAAM,GAAG,IAAIsC,MAAJ,CACd,kBAAkBxC,YAAY,CAAEkB,WAAF,CADhB,EAEd,GAFc,CAAf;AAIAE,UAAAA,QAAQ,CAAEnB,aAAa,CAAEC,MAAF,EAAU2B,YAAV,CAAf,CAAR;AACA,SAlCkC,CAAnC;AAoCA,eAAON,OAAP;AACA,OAvC0B,EAwC3BF,WAAW,GAAG,GAAH,GAAS,CAxCO,CAA5B;AA2CA,YAAME,OAAO,GAAGD,WAAW,EAA3B;AAEA,aAAO,MAAM;AACZA,QAAAA,WAAW,CAACmB,MAAZ;;AACA,YAAKlB,OAAL,EAAe;AACdA,UAAAA,OAAO,CAACK,QAAR,GAAmB,IAAnB;AACA;AACD,OALD;AAMA,KArDc,EAqDZ,CAAEV,WAAF,CArDY,CAAf;AAuDA,WAAO,CAAEC,KAAF,CAAP;AACA,GArED;AAsEA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { escapeRegExp } from '../utils/strings';\nimport type { CancelablePromise, KeyedOption, WPCompleter } from './types';\n\nfunction filterOptions(\n\tsearch: RegExp,\n\toptions: Array< KeyedOption > = [],\n\tmaxResults = 10\n) {\n\tconst filtered = [];\n\tfor ( let i = 0; i < options.length; i++ ) {\n\t\tconst option = options[ i ];\n\n\t\t// Merge label into keywords.\n\t\tlet { keywords = [] } = option;\n\t\tif ( 'string' === typeof option.label ) {\n\t\t\tkeywords = [ ...keywords, option.label ];\n\t\t}\n\n\t\tconst isMatch = keywords.some( ( keyword ) =>\n\t\t\tsearch.test( removeAccents( keyword ) )\n\t\t);\n\t\tif ( ! isMatch ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfiltered.push( option );\n\n\t\t// Abort early if max reached.\n\t\tif ( filtered.length === maxResults ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn filtered;\n}\n\nexport default function getDefaultUseItems( autocompleter: WPCompleter ) {\n\treturn ( filterValue: string ) => {\n\t\tconst [ items, setItems ] = useState< Array< KeyedOption > >( [] );\n\t\t/*\n\t\t * We support both synchronous and asynchronous retrieval of completer options\n\t\t * but internally treat all as async so we maintain a single, consistent code path.\n\t\t *\n\t\t * Because networks can be slow, and the internet is wonderfully unpredictable,\n\t\t * we don't want two promises updating the state at once. This ensures that only\n\t\t * the most recent promise will act on `optionsData`. This doesn't use the state\n\t\t * because `setState` is batched, and so there's no guarantee that setting\n\t\t * `activePromise` in the state would result in it actually being in `this.state`\n\t\t * before the promise resolves and we check to see if this is the active promise or not.\n\t\t */\n\t\tuseLayoutEffect( () => {\n\t\t\tconst { options, isDebounced } = autocompleter;\n\t\t\tconst loadOptions = debounce(\n\t\t\t\t() => {\n\t\t\t\t\tconst promise: CancelablePromise = Promise.resolve(\n\t\t\t\t\t\ttypeof options === 'function'\n\t\t\t\t\t\t\t? options( filterValue )\n\t\t\t\t\t\t\t: options\n\t\t\t\t\t).then( ( optionsData ) => {\n\t\t\t\t\t\tif ( promise.canceled ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst keyedOptions = optionsData.map(\n\t\t\t\t\t\t\t( optionData, optionIndex ) => ( {\n\t\t\t\t\t\t\t\tkey: `${ autocompleter.name }-${ optionIndex }`,\n\t\t\t\t\t\t\t\tvalue: optionData,\n\t\t\t\t\t\t\t\tlabel: autocompleter.getOptionLabel(\n\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tkeywords: autocompleter.getOptionKeywords\n\t\t\t\t\t\t\t\t\t? autocompleter.getOptionKeywords(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\t\tisDisabled: autocompleter.isOptionDisabled\n\t\t\t\t\t\t\t\t\t? autocompleter.isOptionDisabled(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Create a regular expression to filter the options.\n\t\t\t\t\t\tconst search = new RegExp(\n\t\t\t\t\t\t\t'(?:\\\\b|\\\\s|^)' + escapeRegExp( filterValue ),\n\t\t\t\t\t\t\t'i'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetItems( filterOptions( search, keyedOptions ) );\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn promise;\n\t\t\t\t},\n\t\t\t\tisDebounced ? 250 : 0\n\t\t\t);\n\n\t\t\tconst promise = loadOptions();\n\n\t\t\treturn () => {\n\t\t\t\tloadOptions.cancel();\n\t\t\t\tif ( promise ) {\n\t\t\t\t\tpromise.canceled = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}, [ filterValue ] );\n\n\t\treturn [ items ] as const;\n\t};\n}\n"]}
|
|
@@ -11,7 +11,9 @@ import removeAccents from 'remove-accents';
|
|
|
11
11
|
import { renderToString, useEffect, useState, useRef, useMemo } from '@wordpress/element';
|
|
12
12
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
13
13
|
import { useInstanceId, useDebounce, useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
14
|
-
import { create, slice, insert, isCollapsed, getTextContent
|
|
14
|
+
import { create, slice, insert, isCollapsed, getTextContent // Error expected because `@wordpress/rich-text` is not yet fully typed.
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
} from '@wordpress/rich-text';
|
|
15
17
|
import { speak } from '@wordpress/a11y';
|
|
16
18
|
/**
|
|
17
19
|
* Internal dependencies
|
|
@@ -19,84 +21,8 @@ import { speak } from '@wordpress/a11y';
|
|
|
19
21
|
|
|
20
22
|
import { getAutoCompleterUI } from './autocompleter-ui';
|
|
21
23
|
import { escapeRegExp } from '../utils/strings';
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
* A raw completer option.
|
|
25
|
-
*
|
|
26
|
-
* @typedef {*} CompleterOption
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @callback FnGetOptions
|
|
31
|
-
*
|
|
32
|
-
* @return {(CompleterOption[]|Promise.<CompleterOption[]>)} The completer options or a promise for them.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @callback FnGetOptionKeywords
|
|
37
|
-
* @param {CompleterOption} option a completer option.
|
|
38
|
-
*
|
|
39
|
-
* @return {string[]} list of key words to search.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @callback FnIsOptionDisabled
|
|
44
|
-
* @param {CompleterOption} option a completer option.
|
|
45
|
-
*
|
|
46
|
-
* @return {string[]} whether or not the given option is disabled.
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @callback FnGetOptionLabel
|
|
51
|
-
* @param {CompleterOption} option a completer option.
|
|
52
|
-
*
|
|
53
|
-
* @return {(string|Array.<(string|WPElement)>)} list of react components to render.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @callback FnAllowContext
|
|
58
|
-
* @param {string} before the string before the auto complete trigger and query.
|
|
59
|
-
* @param {string} after the string after the autocomplete trigger and query.
|
|
60
|
-
*
|
|
61
|
-
* @return {boolean} true if the completer can handle.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Object} OptionCompletion
|
|
66
|
-
* @property {'insert-at-caret'|'replace'} action the intended placement of the completion.
|
|
67
|
-
* @property {OptionCompletionValue} value the completion value.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* A completion value.
|
|
72
|
-
*
|
|
73
|
-
* @typedef {(string|WPElement|Object)} OptionCompletionValue
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @callback FnGetOptionCompletion
|
|
78
|
-
* @param {CompleterOption} value the value of the completer option.
|
|
79
|
-
* @param {string} query the text value of the autocomplete query.
|
|
80
|
-
*
|
|
81
|
-
* @return {(OptionCompletion|OptionCompletionValue)} the completion for the given option. If an
|
|
82
|
-
* OptionCompletionValue is returned, the
|
|
83
|
-
* completion action defaults to `insert-at-caret`.
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @typedef {Object} WPCompleter
|
|
88
|
-
* @property {string} name a way to identify a completer, useful for selective overriding.
|
|
89
|
-
* @property {?string} className A class to apply to the popup menu.
|
|
90
|
-
* @property {string} triggerPrefix the prefix that will display the menu.
|
|
91
|
-
* @property {(CompleterOption[]|FnGetOptions)} options the completer options or a function to get them.
|
|
92
|
-
* @property {?FnGetOptionKeywords} getOptionKeywords get the keywords for a given option.
|
|
93
|
-
* @property {?FnIsOptionDisabled} isOptionDisabled get whether or not the given option is disabled.
|
|
94
|
-
* @property {FnGetOptionLabel} getOptionLabel get the label for a given option.
|
|
95
|
-
* @property {?FnAllowContext} allowContext filter the context under which the autocomplete activates.
|
|
96
|
-
* @property {FnGetOptionCompletion} getOptionCompletion get the completion associated with a given option.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
function useAutocomplete(_ref) {
|
|
24
|
+
const EMPTY_FILTERED_OPTIONS = [];
|
|
25
|
+
export function useAutocomplete(_ref) {
|
|
100
26
|
let {
|
|
101
27
|
record,
|
|
102
28
|
onChange,
|
|
@@ -107,13 +33,17 @@ function useAutocomplete(_ref) {
|
|
|
107
33
|
const debouncedSpeak = useDebounce(speak, 500);
|
|
108
34
|
const instanceId = useInstanceId(useAutocomplete);
|
|
109
35
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
110
|
-
const [filteredOptions, setFilteredOptions] = useState(
|
|
36
|
+
const [filteredOptions, setFilteredOptions] = useState(EMPTY_FILTERED_OPTIONS);
|
|
111
37
|
const [filterValue, setFilterValue] = useState('');
|
|
112
38
|
const [autocompleter, setAutocompleter] = useState(null);
|
|
113
39
|
const [AutocompleterUI, setAutocompleterUI] = useState(null);
|
|
114
40
|
const backspacing = useRef(false);
|
|
115
41
|
|
|
116
42
|
function insertCompletion(replacement) {
|
|
43
|
+
if (autocompleter === null) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
117
47
|
const end = record.start;
|
|
118
48
|
const start = end - autocompleter.triggerPrefix.length - filterValue.length;
|
|
119
49
|
const toInsert = create({
|
|
@@ -133,21 +63,23 @@ function useAutocomplete(_ref) {
|
|
|
133
63
|
|
|
134
64
|
if (getOptionCompletion) {
|
|
135
65
|
const completion = getOptionCompletion(option.value, filterValue);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
value
|
|
139
|
-
}
|
|
66
|
+
|
|
67
|
+
const isCompletionObject = obj => {
|
|
68
|
+
return obj !== null && typeof obj === 'object' && 'action' in obj && obj.action !== undefined && 'value' in obj && obj.value !== undefined;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const completionObject = isCompletionObject(completion) ? completion : {
|
|
140
72
|
action: 'insert-at-caret',
|
|
141
73
|
value: completion
|
|
142
|
-
}
|
|
74
|
+
};
|
|
143
75
|
|
|
144
|
-
if ('replace' === action) {
|
|
145
|
-
onReplace([value]); // When replacing, the component will unmount, so don't reset
|
|
76
|
+
if ('replace' === completionObject.action) {
|
|
77
|
+
onReplace([completionObject.value]); // When replacing, the component will unmount, so don't reset
|
|
146
78
|
// state (below) on an unmounted component.
|
|
147
79
|
|
|
148
80
|
return;
|
|
149
|
-
} else if ('insert-at-caret' === action) {
|
|
150
|
-
insertCompletion(value);
|
|
81
|
+
} else if ('insert-at-caret' === completionObject.action) {
|
|
82
|
+
insertCompletion(completionObject.value);
|
|
151
83
|
}
|
|
152
84
|
} // Reset autocomplete state after insertion rather than before
|
|
153
85
|
// so insertion events don't cause the completion menu to redisplay.
|
|
@@ -158,7 +90,7 @@ function useAutocomplete(_ref) {
|
|
|
158
90
|
|
|
159
91
|
function reset() {
|
|
160
92
|
setSelectedIndex(0);
|
|
161
|
-
setFilteredOptions(
|
|
93
|
+
setFilteredOptions(EMPTY_FILTERED_OPTIONS);
|
|
162
94
|
setFilterValue('');
|
|
163
95
|
setAutocompleter(null);
|
|
164
96
|
setAutocompleterUI(null);
|
|
@@ -325,7 +257,7 @@ function useAutocomplete(_ref) {
|
|
|
325
257
|
const query = match && match[1];
|
|
326
258
|
setAutocompleter(completer);
|
|
327
259
|
setAutocompleterUI(() => completer !== autocompleter ? getAutoCompleterUI(completer) : AutocompleterUI);
|
|
328
|
-
setFilterValue(query); // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
|
|
260
|
+
setFilterValue(query === null ? '' : query); // Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.
|
|
329
261
|
// See https://github.com/WordPress/gutenberg/pull/41820
|
|
330
262
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
331
263
|
}, [textContent]);
|
|
@@ -336,7 +268,7 @@ function useAutocomplete(_ref) {
|
|
|
336
268
|
className
|
|
337
269
|
} = autocompleter || {};
|
|
338
270
|
const isExpanded = !!autocompleter && filteredOptions.length > 0;
|
|
339
|
-
const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` :
|
|
271
|
+
const listBoxId = isExpanded ? `components-autocomplete-listbox-${instanceId}` : undefined;
|
|
340
272
|
const activeId = isExpanded ? `components-autocomplete-item-${instanceId}-${selectedKey}` : null;
|
|
341
273
|
const hasSelection = record.start !== undefined;
|
|
342
274
|
return {
|
|
@@ -370,7 +302,7 @@ function useLastDifferentValue(value) {
|
|
|
370
302
|
}
|
|
371
303
|
|
|
372
304
|
export function useAutocompleteProps(options) {
|
|
373
|
-
const ref = useRef();
|
|
305
|
+
const ref = useRef(null);
|
|
374
306
|
const onKeyDownRef = useRef();
|
|
375
307
|
const {
|
|
376
308
|
record
|
|
@@ -387,7 +319,9 @@ export function useAutocompleteProps(options) {
|
|
|
387
319
|
onKeyDownRef.current = onKeyDown;
|
|
388
320
|
const mergedRefs = useMergeRefs([ref, useRefEffect(element => {
|
|
389
321
|
function _onKeyDown(event) {
|
|
390
|
-
|
|
322
|
+
var _onKeyDownRef$current;
|
|
323
|
+
|
|
324
|
+
(_onKeyDownRef$current = onKeyDownRef.current) === null || _onKeyDownRef$current === void 0 ? void 0 : _onKeyDownRef$current.call(onKeyDownRef, event);
|
|
391
325
|
}
|
|
392
326
|
|
|
393
327
|
element.addEventListener('keydown', _onKeyDown);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/autocomplete/index.js"],"names":["removeAccents","renderToString","useEffect","useState","useRef","useMemo","__","_n","sprintf","useInstanceId","useDebounce","useMergeRefs","useRefEffect","create","slice","insert","isCollapsed","getTextContent","speak","getAutoCompleterUI","escapeRegExp","EMPTY_ARRAY","useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","action","undefined","reset","announce","options","onChangeOptions","handleKeyDown","event","current","key","defaultPrevented","isComposing","keyCode","preventDefault","textContent","completer","find","allowContext","index","lastIndexOf","textWithoutTrigger","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useLastDifferentValue","history","Set","add","size","delete","Array","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","children","Autocomplete","isSelected","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,gBAA1B;AAEA;AACA;AACA;;AACA,SACCC,cADD,EAECC,SAFD,EAGCC,QAHD,EAICC,MAJD,EAKCC,OALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,aADD,EAECC,WAFD,EAGCC,YAHD,EAICC,YAJD,QAKO,oBALP;AAMA,SACCC,MADD,EAECC,KAFD,EAGCC,MAHD,EAICC,WAJD,EAKCC,cALD,QAMO,sBANP;AAOA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASC,eAAT,OAMI;AAAA,MANsB;AACzBC,IAAAA,MADyB;AAEzBC,IAAAA,QAFyB;AAGzBC,IAAAA,SAHyB;AAIzBC,IAAAA,UAJyB;AAKzBC,IAAAA;AALyB,GAMtB;AACH,QAAMC,cAAc,GAAGlB,WAAW,CAAEQ,KAAF,EAAS,GAAT,CAAlC;AACA,QAAMW,UAAU,GAAGpB,aAAa,CAAEa,eAAF,CAAhC;AACA,QAAM,CAAEQ,aAAF,EAAiBC,gBAAjB,IAAsC5B,QAAQ,CAAE,CAAF,CAApD;AACA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AAAA,GAAG,EAAEG,UADC;AAENM,IAAAA,QAAQ,EAAEnB,OAFJ;AAGN,yBAAqBJ,SAAS,GAAG,MAAH,GAAYpC,SAHpC;AAIN,iBAAaoC,SAJP;AAKN,6BAAyBC;AALnB,GAAP;AAOA;AAED,eAAe,SAASuB,YAAT,QAA8D;AAAA,MAAvC;AAAED,IAAAA,QAAF;AAAYE,IAAAA,UAAZ;AAAwB,OAAG1D;AAA3B,GAAuC;AAC5E,QAAM;AAAEqC,IAAAA,OAAF;AAAW,OAAGsB;AAAd,MAAwBhG,eAAe,CAAEqC,OAAF,CAA7C;AACA,SACC,8BACGwD,QAAQ,CAAEG,KAAF,CADX,EAEGD,UAAU,IAAIrB,OAFjB,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * A raw completer option.\n *\n * @typedef {*} CompleterOption\n */\n\n/**\n * @callback FnGetOptions\n *\n * @return {(CompleterOption[]|Promise.<CompleterOption[]>)} The completer options or a promise for them.\n */\n\n/**\n * @callback FnGetOptionKeywords\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} list of key words to search.\n */\n\n/**\n * @callback FnIsOptionDisabled\n * @param {CompleterOption} option a completer option.\n *\n * @return {string[]} whether or not the given option is disabled.\n */\n\n/**\n * @callback FnGetOptionLabel\n * @param {CompleterOption} option a completer option.\n *\n * @return {(string|Array.<(string|WPElement)>)} list of react components to render.\n */\n\n/**\n * @callback FnAllowContext\n * @param {string} before the string before the auto complete trigger and query.\n * @param {string} after the string after the autocomplete trigger and query.\n *\n * @return {boolean} true if the completer can handle.\n */\n\n/**\n * @typedef {Object} OptionCompletion\n * @property {'insert-at-caret'|'replace'} action the intended placement of the completion.\n * @property {OptionCompletionValue} value the completion value.\n */\n\n/**\n * A completion value.\n *\n * @typedef {(string|WPElement|Object)} OptionCompletionValue\n */\n\n/**\n * @callback FnGetOptionCompletion\n * @param {CompleterOption} value the value of the completer option.\n * @param {string} query the text value of the autocomplete query.\n *\n * @return {(OptionCompletion|OptionCompletionValue)} the completion for the given option. If an\n * \t\t\t\t\t\t\t\t\t\t\t\t\t OptionCompletionValue is returned, the\n * \t\t\t\t\t\t\t\t\t\t\t\t\t completion action defaults to `insert-at-caret`.\n */\n\n/**\n * @typedef {Object} WPCompleter\n * @property {string} name a way to identify a completer, useful for selective overriding.\n * @property {?string} className A class to apply to the popup menu.\n * @property {string} triggerPrefix the prefix that will display the menu.\n * @property {(CompleterOption[]|FnGetOptions)} options the completer options or a function to get them.\n * @property {?FnGetOptionKeywords} getOptionKeywords get the keywords for a given option.\n * @property {?FnIsOptionDisabled} isOptionDisabled get whether or not the given option is disabled.\n * @property {FnGetOptionLabel} getOptionLabel get the label for a given option.\n * @property {?FnAllowContext} allowContext filter the context under which the autocomplete activates.\n * @property {FnGetOptionCompletion} getOptionCompletion get the completion associated with a given option.\n */\n\nfunction useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\tconst [ filteredOptions, setFilteredOptions ] = useState( EMPTY_ARRAY );\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState( null );\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState( null );\n\tconst backspacing = useRef( false );\n\n\tfunction insertCompletion( replacement ) {\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst { action, value } =\n\t\t\t\tundefined === completion.action ||\n\t\t\t\tundefined === completion.value\n\t\t\t\t\t? { action: 'insert-at-caret', value: completion }\n\t\t\t\t\t: completion;\n\n\t\t\tif ( 'replace' === action ) {\n\t\t\t\tonReplace( [ value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === action ) {\n\t\t\t\tinsertCompletion( value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( EMPTY_ARRAY );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event ) {\n\t\tbackspacing.current = event.key === 'Backspace';\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowDown':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'Escape':\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Enter':\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled key should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\t// textContent is a primitive (string), memoizing is not strictly necessary\n\t// but this is a preemptive performance improvement, since the autocompleter\n\t// is a potential bottleneck for the editor type metric.\n\tconst textContent = useMemo( () => {\n\t\tif ( isCollapsed( record ) ) {\n\t\t\treturn getTextContent( slice( record, 0 ) );\n\t\t}\n\t}, [ record ] );\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst completer = completers?.find(\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = textContent.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing.current &&\n\t\t\t\t\ttextWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textAfterSelection = getTextContent(\n\t\t\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext(\n\t\t\t\t\t\ttextContent.slice( 0, index ),\n\t\t\t\t\t\ttextAfterSelection\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst text = removeAccents( textContent );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query );\n\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ textContent ] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: null;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nfunction useLastDifferentValue( value ) {\n\tconst history = useRef( new Set() );\n\n\thistory.current.add( value );\n\n\t// Keep the history size to 2.\n\tif ( history.current.size > 2 ) {\n\t\thistory.current.delete( Array.from( history.current )[ 0 ] );\n\t}\n\n\treturn Array.from( history.current )[ 0 ];\n}\n\nexport function useAutocompleteProps( options ) {\n\tconst ref = useRef();\n\tconst onKeyDownRef = useRef();\n\tconst { record } = options;\n\tconst previousRecord = useLastDifferentValue( record );\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tuseRefEffect( ( element ) => {\n\t\t\tfunction _onKeyDown( event ) {\n\t\t\t\tonKeyDownRef.current( event );\n\t\t\t}\n\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t};\n\t\t}, [] ),\n\t] );\n\n\t// We only want to show the popover if the user has typed something.\n\tconst didUserInput = record.text !== previousRecord?.text;\n\n\tif ( ! didUserInput ) {\n\t\treturn { ref: mergedRefs };\n\t}\n\n\treturn {\n\t\tref: mergedRefs,\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( { children, isSelected, ...options } ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/autocomplete/index.tsx"],"names":["removeAccents","renderToString","useEffect","useState","useRef","useMemo","__","_n","sprintf","useInstanceId","useDebounce","useMergeRefs","useRefEffect","create","slice","insert","isCollapsed","getTextContent","speak","getAutoCompleterUI","escapeRegExp","EMPTY_FILTERED_OPTIONS","useAutocomplete","record","onChange","onReplace","completers","contentRef","debouncedSpeak","instanceId","selectedIndex","setSelectedIndex","filteredOptions","setFilteredOptions","filterValue","setFilterValue","autocompleter","setAutocompleter","AutocompleterUI","setAutocompleterUI","backspacing","insertCompletion","replacement","end","start","triggerPrefix","length","toInsert","html","select","option","getOptionCompletion","isDisabled","completion","value","isCompletionObject","obj","action","undefined","completionObject","reset","announce","options","onChangeOptions","handleKeyDown","event","current","key","defaultPrevented","isComposing","keyCode","preventDefault","textContent","completer","find","allowContext","index","lastIndexOf","textWithoutTrigger","tooDistantFromTrigger","mismatch","wordsFromTrigger","split","hasOneTriggerWord","matchingWhileBackspacing","textAfterSelection","test","safeTrigger","text","match","RegExp","query","selectedKey","className","isExpanded","listBoxId","activeId","hasSelection","onKeyDown","popover","useLastDifferentValue","history","Set","add","size","delete","Array","from","useAutocompleteProps","ref","onKeyDownRef","previousRecord","mergedRefs","element","_onKeyDown","addEventListener","removeEventListener","didUserInput","children","Autocomplete","isSelected","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,gBAA1B;AAEA;AACA;AACA;;AACA,SACCC,cADD,EAECC,SAFD,EAGCC,QAHD,EAICC,MAJD,EAKCC,OALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,aADD,EAECC,WAFD,EAGCC,YAHD,EAICC,YAJD,QAKO,oBALP;AAMA,SACCC,MADD,EAECC,KAFD,EAGCC,MAHD,EAICC,WAJD,EAKCC,cALD,CAMC;AACA;AAPD,OAQO,sBARP;AASA,SAASC,KAAT,QAAsB,iBAAtB;AAEA;AACA;AACA;;AACA,SAASC,kBAAT,QAAmC,oBAAnC;AACA,SAASC,YAAT,QAA6B,kBAA7B;AAYA,MAAMC,sBAAqC,GAAG,EAA9C;AAEA,OAAO,SAASC,eAAT,OAMmB;AAAA,MANO;AAChCC,IAAA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AC5C,OAAb,GAAuBgC,SAAvB;AAEA,QAAMc,UAAU,GAAGrG,YAAY,CAAE,CAChCkG,GADgC,EAEhCjG,YAAY,CAAIqG,OAAF,IAA4B;AACzC,aAASC,UAAT,CAAqBjD,KAArB,EAA4C;AAAA;;AAC3C,+BAAA6C,YAAY,CAAC5C,OAAb,qFAAA4C,YAAY,EAAY7C,KAAZ,CAAZ;AACA;;AACDgD,IAAAA,OAAO,CAACE,gBAAR,CAA0B,SAA1B,EAAqCD,UAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACG,mBAAR,CAA6B,SAA7B,EAAwCF,UAAxC;AACA,KAFD;AAGA,GARW,EAQT,EARS,CAFoB,CAAF,CAA/B,CAXqE,CAwBrE;;AACA,QAAMG,YAAY,GAAG9F,MAAM,CAACiE,IAAP,MAAgBuB,cAAhB,aAAgBA,cAAhB,uBAAgBA,cAAc,CAAEvB,IAAhC,CAArB;;AAEA,MAAK,CAAE6B,YAAP,EAAsB;AACrB,WAAO;AAAER,MAAAA,GAAG,EAAEG;AAAP,KAAP;AACA;;AAED,SAAO;AACNH,IAAAA,GAAG,EAAEG,UADC;AAENM,IAAAA,QAAQ,EAAEnB,OAFJ;AAGN,yBAAqBJ,SAAS,GAAG,MAAH,GAAYrC,SAHpC;AAIN,iBAAaqC,SAJP;AAKN,6BAAyBC;AALnB,GAAP;AAOA;AAED,eAAe,SAASuB,YAAT,QAIQ;AAAA,MAJe;AACrCD,IAAAA,QADqC;AAErCE,IAAAA,UAFqC;AAGrC,OAAG1D;AAHkC,GAIf;AACtB,QAAM;AAAEqC,IAAAA,OAAF;AAAW,OAAGsB;AAAd,MAAwBnG,eAAe,CAAEwC,OAAF,CAA7C;AACA,SACC,8BACGwD,QAAQ,CAAEG,KAAF,CADX,EAEGD,UAAU,IAAIrB,OAFjB,CADD;AAMA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\trenderToString,\n\tuseEffect,\n\tuseState,\n\tuseRef,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tuseInstanceId,\n\tuseDebounce,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport {\n\tcreate,\n\tslice,\n\tinsert,\n\tisCollapsed,\n\tgetTextContent,\n\t// Error expected because `@wordpress/rich-text` is not yet fully typed.\n\t// @ts-expect-error\n} from '@wordpress/rich-text';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getAutoCompleterUI } from './autocompleter-ui';\nimport { escapeRegExp } from '../utils/strings';\nimport type {\n\tAutocompleteProps,\n\tAutocompleterUIProps,\n\tInsertOption,\n\tKeyedOption,\n\tOptionCompletion,\n\tReplaceOption,\n\tUseAutocompleteProps,\n\tWPCompleter,\n} from './types';\n\nconst EMPTY_FILTERED_OPTIONS: KeyedOption[] = [];\n\nexport function useAutocomplete( {\n\trecord,\n\tonChange,\n\tonReplace,\n\tcompleters,\n\tcontentRef,\n}: UseAutocompleteProps ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst instanceId = useInstanceId( useAutocomplete );\n\tconst [ selectedIndex, setSelectedIndex ] = useState( 0 );\n\n\tconst [ filteredOptions, setFilteredOptions ] = useState<\n\t\tArray< KeyedOption >\n\t>( EMPTY_FILTERED_OPTIONS );\n\tconst [ filterValue, setFilterValue ] =\n\t\tuseState< AutocompleterUIProps[ 'filterValue' ] >( '' );\n\tconst [ autocompleter, setAutocompleter ] = useState< WPCompleter | null >(\n\t\tnull\n\t);\n\tconst [ AutocompleterUI, setAutocompleterUI ] = useState<\n\t\t( ( props: AutocompleterUIProps ) => JSX.Element | null ) | null\n\t>( null );\n\n\tconst backspacing = useRef( false );\n\n\tfunction insertCompletion( replacement: React.ReactNode ) {\n\t\tif ( autocompleter === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst end = record.start;\n\t\tconst start =\n\t\t\tend - autocompleter.triggerPrefix.length - filterValue.length;\n\t\tconst toInsert = create( { html: renderToString( replacement ) } );\n\n\t\tonChange( insert( record, toInsert, start, end ) );\n\t}\n\n\tfunction select( option: KeyedOption ) {\n\t\tconst { getOptionCompletion } = autocompleter || {};\n\n\t\tif ( option.isDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( getOptionCompletion ) {\n\t\t\tconst completion = getOptionCompletion( option.value, filterValue );\n\n\t\t\tconst isCompletionObject = (\n\t\t\t\tobj: OptionCompletion\n\t\t\t): obj is InsertOption | ReplaceOption => {\n\t\t\t\treturn (\n\t\t\t\t\tobj !== null &&\n\t\t\t\t\ttypeof obj === 'object' &&\n\t\t\t\t\t'action' in obj &&\n\t\t\t\t\tobj.action !== undefined &&\n\t\t\t\t\t'value' in obj &&\n\t\t\t\t\tobj.value !== undefined\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tconst completionObject = isCompletionObject( completion )\n\t\t\t\t? completion\n\t\t\t\t: ( {\n\t\t\t\t\t\taction: 'insert-at-caret',\n\t\t\t\t\t\tvalue: completion,\n\t\t\t\t } as InsertOption );\n\n\t\t\tif ( 'replace' === completionObject.action ) {\n\t\t\t\tonReplace( [ completionObject.value ] );\n\t\t\t\t// When replacing, the component will unmount, so don't reset\n\t\t\t\t// state (below) on an unmounted component.\n\t\t\t\treturn;\n\t\t\t} else if ( 'insert-at-caret' === completionObject.action ) {\n\t\t\t\tinsertCompletion( completionObject.value );\n\t\t\t}\n\t\t}\n\n\t\t// Reset autocomplete state after insertion rather than before\n\t\t// so insertion events don't cause the completion menu to redisplay.\n\t\treset();\n\t}\n\n\tfunction reset() {\n\t\tsetSelectedIndex( 0 );\n\t\tsetFilteredOptions( EMPTY_FILTERED_OPTIONS );\n\t\tsetFilterValue( '' );\n\t\tsetAutocompleter( null );\n\t\tsetAutocompleterUI( null );\n\t}\n\n\tfunction announce( options: Array< KeyedOption > ) {\n\t\tif ( ! debouncedSpeak ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( !! options.length ) {\n\t\t\tdebouncedSpeak(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\toptions.length\n\t\t\t\t\t),\n\t\t\t\t\toptions.length\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else {\n\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t}\n\t}\n\n\t/**\n\t * Load options for an autocompleter.\n\t *\n\t * @param {Array} options\n\t */\n\tfunction onChangeOptions( options: Array< KeyedOption > ) {\n\t\tsetSelectedIndex(\n\t\t\toptions.length === filteredOptions.length ? selectedIndex : 0\n\t\t);\n\t\tsetFilteredOptions( options );\n\t\tannounce( options );\n\t}\n\n\tfunction handleKeyDown( event: KeyboardEvent ) {\n\t\tbackspacing.current = event.key === 'Backspace';\n\n\t\tif ( ! autocompleter ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( filteredOptions.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tevent.defaultPrevented ||\n\t\t\t// Ignore keydowns from IMEs\n\t\t\tevent.isComposing ||\n\t\t\t// Workaround for Mac Safari where the final Enter/Backspace of an IME composition\n\t\t\t// is `isComposing=false`, even though it's technically still part of the composition.\n\t\t\t// These can only be detected by keyCode.\n\t\t\tevent.keyCode === 229\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tswitch ( event.key ) {\n\t\t\tcase 'ArrowUp':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex === 0\n\t\t\t\t\t\t? filteredOptions.length\n\t\t\t\t\t\t: selectedIndex ) - 1\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowDown':\n\t\t\t\tsetSelectedIndex(\n\t\t\t\t\t( selectedIndex + 1 ) % filteredOptions.length\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'Escape':\n\t\t\t\tsetAutocompleter( null );\n\t\t\t\tsetAutocompleterUI( null );\n\t\t\t\tevent.preventDefault();\n\t\t\t\tbreak;\n\n\t\t\tcase 'Enter':\n\t\t\t\tselect( filteredOptions[ selectedIndex ] );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ArrowLeft':\n\t\t\tcase 'ArrowRight':\n\t\t\t\treset();\n\t\t\t\treturn;\n\n\t\t\tdefault:\n\t\t\t\treturn;\n\t\t}\n\n\t\t// Any handled key should prevent original behavior. This relies on\n\t\t// the early return in the default case.\n\t\tevent.preventDefault();\n\t}\n\n\t// textContent is a primitive (string), memoizing is not strictly necessary\n\t// but this is a preemptive performance improvement, since the autocompleter\n\t// is a potential bottleneck for the editor type metric.\n\tconst textContent = useMemo( () => {\n\t\tif ( isCollapsed( record ) ) {\n\t\t\treturn getTextContent( slice( record, 0 ) );\n\t\t}\n\t}, [ record ] );\n\n\tuseEffect( () => {\n\t\tif ( ! textContent ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst completer = completers?.find(\n\t\t\t( { triggerPrefix, allowContext } ) => {\n\t\t\t\tconst index = textContent.lastIndexOf( triggerPrefix );\n\n\t\t\t\tif ( index === -1 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textWithoutTrigger = textContent.slice(\n\t\t\t\t\tindex + triggerPrefix.length\n\t\t\t\t);\n\n\t\t\t\tconst tooDistantFromTrigger = textWithoutTrigger.length > 50; // 50 chars seems to be a good limit.\n\t\t\t\t// This is a final barrier to prevent the effect from completing with\n\t\t\t\t// an extremely long string, which causes the editor to slow-down\n\t\t\t\t// significantly. This could happen, for example, if `matchingWhileBackspacing`\n\t\t\t\t// is true and one of the \"words\" end up being too long. If that's the case,\n\t\t\t\t// it will be caught by this guard.\n\t\t\t\tif ( tooDistantFromTrigger ) return false;\n\n\t\t\t\tconst mismatch = filteredOptions.length === 0;\n\t\t\t\tconst wordsFromTrigger = textWithoutTrigger.split( /\\s/ );\n\t\t\t\t// We need to allow the effect to run when not backspacing and if there\n\t\t\t\t// was a mismatch. i.e when typing a trigger + the match string or when\n\t\t\t\t// clicking in an existing trigger word on the page. We do that if we\n\t\t\t\t// detect that we have one word from trigger in the current textual context.\n\t\t\t\t//\n\t\t\t\t// Ex.: \"Some text @a\" <-- \"@a\" will be detected as the trigger word and\n\t\t\t\t// allow the effect to run. It will run until there's a mismatch.\n\t\t\t\tconst hasOneTriggerWord = wordsFromTrigger.length === 1;\n\t\t\t\t// This is used to allow the effect to run when backspacing and if\n\t\t\t\t// \"touching\" a word that \"belongs\" to a trigger. We consider a \"trigger\n\t\t\t\t// word\" any word up to the limit of 3 from the trigger character.\n\t\t\t\t// Anything beyond that is ignored if there's a mismatch. This allows\n\t\t\t\t// us to \"escape\" a mismatch when backspacing, but still imposing some\n\t\t\t\t// sane limits.\n\t\t\t\t//\n\t\t\t\t// Ex: \"Some text @marcelo sekkkk\" <--- \"kkkk\" caused a mismatch, but\n\t\t\t\t// if the user presses backspace here, it will show the completion popup again.\n\t\t\t\tconst matchingWhileBackspacing =\n\t\t\t\t\tbackspacing.current &&\n\t\t\t\t\ttextWithoutTrigger.split( /\\s/ ).length <= 3;\n\n\t\t\t\tif (\n\t\t\t\t\tmismatch &&\n\t\t\t\t\t! ( matchingWhileBackspacing || hasOneTriggerWord )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tconst textAfterSelection = getTextContent(\n\t\t\t\t\tslice( record, undefined, getTextContent( record ).length )\n\t\t\t\t);\n\n\t\t\t\tif (\n\t\t\t\t\tallowContext &&\n\t\t\t\t\t! allowContext(\n\t\t\t\t\t\ttextContent.slice( 0, index ),\n\t\t\t\t\t\ttextAfterSelection\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\t/^\\s/.test( textWithoutTrigger ) ||\n\t\t\t\t\t/\\s\\s+$/.test( textWithoutTrigger )\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn /[\\u0000-\\uFFFF]*$/.test( textWithoutTrigger );\n\t\t\t}\n\t\t);\n\n\t\tif ( ! completer ) {\n\t\t\tif ( autocompleter ) reset();\n\t\t\treturn;\n\t\t}\n\n\t\tconst safeTrigger = escapeRegExp( completer.triggerPrefix );\n\t\tconst text = removeAccents( textContent );\n\t\tconst match = text\n\t\t\t.slice( text.lastIndexOf( completer.triggerPrefix ) )\n\t\t\t.match( new RegExp( `${ safeTrigger }([\\u0000-\\uFFFF]*)$` ) );\n\t\tconst query = match && match[ 1 ];\n\n\t\tsetAutocompleter( completer );\n\t\tsetAutocompleterUI( () =>\n\t\t\tcompleter !== autocompleter\n\t\t\t\t? getAutoCompleterUI( completer )\n\t\t\t\t: AutocompleterUI\n\t\t);\n\t\tsetFilterValue( query === null ? '' : query );\n\t\t// Temporarily disabling exhaustive-deps to avoid introducing unexpected side effecst.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ textContent ] );\n\n\tconst { key: selectedKey = '' } = filteredOptions[ selectedIndex ] || {};\n\tconst { className } = autocompleter || {};\n\tconst isExpanded = !! autocompleter && filteredOptions.length > 0;\n\tconst listBoxId = isExpanded\n\t\t? `components-autocomplete-listbox-${ instanceId }`\n\t\t: undefined;\n\tconst activeId = isExpanded\n\t\t? `components-autocomplete-item-${ instanceId }-${ selectedKey }`\n\t\t: null;\n\tconst hasSelection = record.start !== undefined;\n\n\treturn {\n\t\tlistBoxId,\n\t\tactiveId,\n\t\tonKeyDown: handleKeyDown,\n\t\tpopover: hasSelection && AutocompleterUI && (\n\t\t\t<AutocompleterUI\n\t\t\t\tclassName={ className }\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tinstanceId={ instanceId }\n\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\tonChangeOptions={ onChangeOptions }\n\t\t\t\tonSelect={ select }\n\t\t\t\tvalue={ record }\n\t\t\t\tcontentRef={ contentRef }\n\t\t\t\treset={ reset }\n\t\t\t/>\n\t\t),\n\t};\n}\n\nfunction useLastDifferentValue( value: UseAutocompleteProps[ 'record' ] ) {\n\tconst history = useRef< Set< typeof value > >( new Set() );\n\n\thistory.current.add( value );\n\n\t// Keep the history size to 2.\n\tif ( history.current.size > 2 ) {\n\t\thistory.current.delete( Array.from( history.current )[ 0 ] );\n\t}\n\n\treturn Array.from( history.current )[ 0 ];\n}\n\nexport function useAutocompleteProps( options: UseAutocompleteProps ) {\n\tconst ref = useRef< HTMLElement >( null );\n\tconst onKeyDownRef = useRef< ( event: KeyboardEvent ) => void >();\n\tconst { record } = options;\n\tconst previousRecord = useLastDifferentValue( record );\n\tconst { popover, listBoxId, activeId, onKeyDown } = useAutocomplete( {\n\t\t...options,\n\t\tcontentRef: ref,\n\t} );\n\tonKeyDownRef.current = onKeyDown;\n\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tuseRefEffect( ( element: HTMLElement ) => {\n\t\t\tfunction _onKeyDown( event: KeyboardEvent ) {\n\t\t\t\tonKeyDownRef.current?.( event );\n\t\t\t}\n\t\t\telement.addEventListener( 'keydown', _onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', _onKeyDown );\n\t\t\t};\n\t\t}, [] ),\n\t] );\n\n\t// We only want to show the popover if the user has typed something.\n\tconst didUserInput = record.text !== previousRecord?.text;\n\n\tif ( ! didUserInput ) {\n\t\treturn { ref: mergedRefs };\n\t}\n\n\treturn {\n\t\tref: mergedRefs,\n\t\tchildren: popover,\n\t\t'aria-autocomplete': listBoxId ? 'list' : undefined,\n\t\t'aria-owns': listBoxId,\n\t\t'aria-activedescendant': activeId,\n\t};\n}\n\nexport default function Autocomplete( {\n\tchildren,\n\tisSelected,\n\t...options\n}: AutocompleteProps ) {\n\tconst { popover, ...props } = useAutocomplete( options );\n\treturn (\n\t\t<>\n\t\t\t{ children( props ) }\n\t\t\t{ isSelected && popover }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|