@wordpress/components 28.10.0 → 28.12.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 +61 -0
- package/build/autocomplete/autocompleter-ui.js +2 -6
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.native.js +2 -4
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/autocomplete/index.js +4 -5
- package/build/autocomplete/index.js.map +1 -1
- package/build/base-control/types.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +1 -0
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +6 -0
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-control/border-control/component.js +1 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +6 -0
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +13 -13
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/color-palette/index.js +1 -1
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/index.native.js +1 -2
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/index.native.js +0 -1
- package/build/color-picker/index.native.js.map +1 -1
- package/build/composite/legacy/index.js +5 -2
- package/build/composite/legacy/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/date-time/date/index.js +0 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +6 -6
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/form-file-upload/index.js +5 -1
- package/build/form-file-upload/index.js.map +1 -1
- package/build/form-token-field/index.js +0 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/suggestions-list.js +7 -3
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/guide/page-control.js +1 -0
- package/build/guide/page-control.js.map +1 -1
- package/build/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
- package/build/menu/checkbox-item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/context.js +2 -2
- package/build/menu/context.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/group-label.js +5 -5
- package/build/menu/group-label.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/group.js +5 -5
- package/build/menu/group.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/index.js +38 -38
- package/build/menu/index.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item-help-text.js +3 -3
- package/build/menu/item-help-text.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item-label.js +3 -3
- package/build/menu/item-label.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/item.js +7 -7
- package/build/menu/item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
- package/build/menu/radio-item.js.map +1 -0
- package/build/{dropdown-menu-v2 → menu}/separator.js +6 -6
- package/build/menu/separator.js.map +1 -0
- package/build/menu/styles.js +150 -0
- package/build/menu/styles.js.map +1 -0
- package/build/menu/types.js.map +1 -0
- package/build/menu/use-temporary-focus-visible-fix.js.map +1 -0
- package/build/menu-item/index.js +1 -0
- package/build/menu-item/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/build/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/build/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/build/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +1 -3
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/picker-screen.native.js +1 -3
- package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build/mobile/image/index.native.js +1 -3
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +2 -5
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +6 -18
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +2 -6
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build/navigation/index.js +1 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/use-navigation-tree-item.js +2 -2
- package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build/navigation/menu/menu-title-search.js +2 -2
- package/build/navigation/menu/menu-title-search.js.map +1 -1
- package/build/navigation/menu/use-navigation-tree-menu.js +2 -2
- package/build/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build/notice/index.js +2 -0
- package/build/notice/index.js.map +1 -1
- package/build/palette-edit/index.js +9 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/palette-edit/styles.js +13 -28
- package/build/palette-edit/styles.js.map +1 -1
- package/build/panel/body.js +1 -0
- package/build/panel/body.js.map +1 -1
- package/build/popover/index.js +4 -1
- package/build/popover/index.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/index.js +3 -1
- package/build/radio-group/index.js.map +1 -1
- package/build/radio-group/radio.js +6 -0
- package/build/radio-group/radio.js.map +1 -1
- package/build/radio-group/types.js.map +1 -1
- package/build/sandbox/index.js +3 -6
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +1 -3
- package/build/sandbox/index.native.js.map +1 -1
- package/build/search-control/index.native.js +1 -3
- package/build/search-control/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js +1 -2
- package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build/slot-fill/fill.js +3 -6
- package/build/slot-fill/fill.js.map +1 -1
- package/build/snackbar/index.js +2 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/spacer/hook.js +5 -3
- package/build/spacer/hook.js.map +1 -1
- package/build/tab-panel/index.js +4 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tabs/index.js +48 -113
- package/build/tabs/index.js.map +1 -1
- package/build/tabs/styles.js +12 -12
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tab.js +23 -6
- package/build/tabs/tab.js.map +1 -1
- package/build/tabs/tablist.js +37 -14
- package/build/tabs/tablist.js.map +1 -1
- package/build/tabs/types.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +3 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toolbar/toolbar/index.js +3 -0
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +1 -1
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +0 -2
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/tooltip/index.native.js +5 -15
- package/build/tooltip/index.native.js.map +1 -1
- package/build/unit-control/index.native.js +2 -6
- package/build/unit-control/index.native.js.map +1 -1
- package/build/utils/deprecated-36px-size.js +27 -0
- package/build/utils/deprecated-36px-size.js.map +1 -0
- package/build/utils/element-rect.js +13 -2
- package/build/utils/element-rect.js.map +1 -1
- package/build/utils/hooks/use-animated-offset-rect.js +3 -2
- package/build/utils/hooks/use-animated-offset-rect.js.map +1 -1
- package/build/utils/hooks/use-update-effect.js +0 -2
- package/build/utils/hooks/use-update-effect.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +2 -6
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.native.js +2 -4
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/autocomplete/index.js +4 -5
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/base-control/types.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +1 -0
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +6 -0
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-control/border-control/component.js +1 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +7 -0
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +13 -13
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/color-palette/index.js +1 -1
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +1 -2
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/index.native.js +0 -1
- package/build-module/color-picker/index.native.js.map +1 -1
- package/build-module/composite/legacy/index.js +5 -2
- package/build-module/composite/legacy/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/date-time/date/index.js +0 -1
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +7 -7
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/form-file-upload/index.js +5 -1
- package/build-module/form-file-upload/index.js.map +1 -1
- package/build-module/form-token-field/index.js +0 -3
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/suggestions-list.js +7 -3
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/guide/page-control.js +1 -0
- package/build-module/guide/page-control.js.map +1 -1
- package/build-module/{dropdown-menu-v2 → menu}/checkbox-item.js +8 -8
- package/build-module/menu/checkbox-item.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/context.js +1 -1
- package/build-module/menu/context.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/group-label.js +5 -5
- package/build-module/menu/group-label.js.map +1 -0
- package/build-module/menu/group.js +21 -0
- package/build-module/menu/group.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/index.js +46 -46
- package/build-module/menu/index.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item-help-text.js +2 -2
- package/build-module/menu/item-help-text.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item-label.js +2 -2
- package/build-module/menu/item-label.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/item.js +7 -7
- package/build-module/menu/item.js.map +1 -0
- package/build-module/{dropdown-menu-v2 → menu}/radio-item.js +8 -8
- package/build-module/menu/radio-item.js.map +1 -0
- package/build-module/menu/separator.js +22 -0
- package/build-module/menu/separator.js.map +1 -0
- package/build-module/menu/styles.js +143 -0
- package/build-module/menu/styles.js.map +1 -0
- package/build-module/menu/types.js.map +1 -0
- package/build-module/menu/use-temporary-focus-visible-fix.js.map +1 -0
- package/build-module/menu-item/index.js +1 -0
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/build-module/mobile/bottom-sheet/range-cell.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/build-module/mobile/bottom-sheet/stepper-cell/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/build-module/mobile/bottom-sheet-select-control/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +1 -3
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/picker-screen.native.js +1 -3
- package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +1 -3
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +2 -5
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +6 -18
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +2 -6
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build-module/navigation/index.js +1 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/use-navigation-tree-item.js +2 -2
- package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build-module/navigation/menu/menu-title-search.js +2 -2
- package/build-module/navigation/menu/menu-title-search.js.map +1 -1
- package/build-module/navigation/menu/use-navigation-tree-menu.js +2 -2
- package/build-module/navigation/menu/use-navigation-tree-menu.js.map +1 -1
- package/build-module/notice/index.js +2 -0
- package/build-module/notice/index.js.map +1 -1
- package/build-module/palette-edit/index.js +11 -4
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/palette-edit/styles.js +13 -29
- package/build-module/palette-edit/styles.js.map +1 -1
- package/build-module/panel/body.js +1 -0
- package/build-module/panel/body.js.map +1 -1
- package/build-module/popover/index.js +4 -1
- package/build-module/popover/index.js.map +1 -1
- package/build-module/private-apis.js +3 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/index.js +3 -1
- package/build-module/radio-group/index.js.map +1 -1
- package/build-module/radio-group/radio.js +6 -0
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/radio-group/types.js.map +1 -1
- package/build-module/sandbox/index.js +3 -6
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +1 -3
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/search-control/index.native.js +1 -3
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js +1 -2
- package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +3 -6
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/snackbar/index.js +2 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/spacer/hook.js +5 -3
- package/build-module/spacer/hook.js.map +1 -1
- package/build-module/tab-panel/index.js +4 -1
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tabs/index.js +47 -112
- package/build-module/tabs/index.js.map +1 -1
- package/build-module/tabs/styles.js +11 -11
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tab.js +21 -6
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/tabs/tablist.js +37 -14
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/tabs/types.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +3 -2
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +3 -0
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +0 -2
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/tooltip/index.native.js +5 -15
- package/build-module/tooltip/index.native.js.map +1 -1
- package/build-module/unit-control/index.native.js +2 -6
- package/build-module/unit-control/index.native.js.map +1 -1
- package/build-module/utils/deprecated-36px-size.js +19 -0
- package/build-module/utils/deprecated-36px-size.js.map +1 -0
- package/build-module/utils/element-rect.js +13 -2
- package/build-module/utils/element-rect.js.map +1 -1
- package/build-module/utils/hooks/use-animated-offset-rect.js +3 -2
- package/build-module/utils/hooks/use-animated-offset-rect.js.map +1 -1
- package/build-module/utils/hooks/use-update-effect.js +0 -2
- package/build-module/utils/hooks/use-update-effect.js.map +1 -1
- package/build-style/style-rtl.css +21 -35
- package/build-style/style.css +21 -35
- package/build-types/animate/stories/index.story.d.ts.map +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- package/build-types/base-control/types.d.ts +3 -0
- package/build-types/base-control/types.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -0
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/card/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/legacy/index.d.ts.map +1 -1
- package/build-types/composite/stories/index.story.d.ts.map +1 -1
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/draggable/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/external-link/stories/index.story.d.ts.map +1 -1
- package/build-types/form-file-upload/index.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/guide/page-control.d.ts.map +1 -1
- package/build-types/heading/stories/index.story.d.ts.map +1 -1
- package/build-types/item-group/stories/index.story.d.ts +1 -1
- package/build-types/item-group/stories/index.story.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/stories/index.story.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -2
- package/build-types/menu/checkbox-item.d.ts +3 -0
- package/build-types/menu/checkbox-item.d.ts.map +1 -0
- package/build-types/menu/context.d.ts +6 -0
- package/build-types/menu/context.d.ts.map +1 -0
- package/build-types/menu/group-label.d.ts +3 -0
- package/build-types/menu/group-label.d.ts.map +1 -0
- package/build-types/menu/group.d.ts +3 -0
- package/build-types/menu/group.d.ts.map +1 -0
- package/build-types/menu/index.d.ts +40 -0
- package/build-types/menu/index.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/item-help-text.d.ts +1 -1
- package/build-types/menu/item-help-text.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/item-label.d.ts +1 -1
- package/build-types/menu/item-label.d.ts.map +1 -0
- package/build-types/menu/item.d.ts +3 -0
- package/build-types/menu/item.d.ts.map +1 -0
- package/build-types/menu/radio-item.d.ts +3 -0
- package/build-types/menu/radio-item.d.ts.map +1 -0
- package/build-types/menu/separator.d.ts +3 -0
- package/build-types/menu/separator.d.ts.map +1 -0
- package/build-types/menu/stories/index.story.d.ts +16 -0
- package/build-types/menu/stories/index.story.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/styles.d.ts +13 -13
- package/build-types/menu/styles.d.ts.map +1 -0
- package/build-types/menu/test/index.d.ts.map +1 -0
- package/build-types/{dropdown-menu-v2 → menu}/types.d.ts +22 -21
- package/build-types/menu/types.d.ts.map +1 -0
- package/build-types/menu/use-temporary-focus-visible-fix.d.ts.map +1 -0
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigable-container/stories/navigable-menu.story.d.ts.map +1 -1
- package/build-types/navigable-container/stories/tabbable-container.story.d.ts.map +1 -1
- package/build-types/navigation/index.d.ts.map +1 -1
- package/build-types/navigator/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/palette-edit/styles.d.ts +0 -256
- package/build-types/palette-edit/styles.d.ts.map +1 -1
- package/build-types/panel/body.d.ts.map +1 -1
- package/build-types/panel/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/index.story.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/index.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts +4 -2
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/types.d.ts +5 -1
- package/build-types/radio-group/types.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/stories/index.story.d.ts.map +1 -1
- package/build-types/scroll-lock/stories/index.story.d.ts.map +1 -1
- package/build-types/shortcut/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts.map +1 -1
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/stories/list.story.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/spinner/stories/index.story.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tab-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/index.d.ts +21 -8
- package/build-types/tabs/index.d.ts.map +1 -1
- package/build-types/tabs/stories/index.story.d.ts +1 -1
- package/build-types/tabs/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts +6 -3
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +0 -3
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/tabs/types.d.ts +85 -48
- package/build-types/tabs/types.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts.map +1 -1
- package/build-types/text-highlight/stories/index.story.d.ts.map +1 -1
- package/build-types/theme/stories/index.story.d.ts.map +1 -1
- package/build-types/tip/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/truncate/stories/index.story.d.ts.map +1 -1
- package/build-types/utils/deprecated-36px-size.d.ts +6 -0
- package/build-types/utils/deprecated-36px-size.d.ts.map +1 -0
- package/build-types/utils/element-rect.d.ts +1 -1
- package/build-types/utils/element-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts +8 -1
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-update-effect.d.ts.map +1 -1
- package/build-types/visually-hidden/stories/index.story.d.ts.map +1 -1
- package/package.json +21 -20
- package/src/alignment-matrix-control/README.md +1 -2
- package/src/angle-picker-control/README.md +1 -2
- package/src/animate/stories/index.story.tsx +2 -1
- package/src/autocomplete/autocompleter-ui.native.js +2 -4
- package/src/autocomplete/autocompleter-ui.tsx +2 -6
- package/src/autocomplete/index.tsx +4 -5
- package/src/base-control/README.md +58 -47
- package/src/base-control/docs-manifest.json +12 -0
- package/src/base-control/stories/index.story.tsx +4 -0
- package/src/base-control/types.ts +3 -0
- package/src/border-box-control/border-box-control/README.md +1 -0
- package/src/border-box-control/border-box-control/component.tsx +1 -0
- package/src/border-box-control/border-box-control/hook.ts +7 -0
- package/src/border-box-control/stories/index.story.tsx +1 -0
- package/src/border-box-control/test/index.tsx +1 -0
- package/src/border-control/border-control/README.md +1 -0
- package/src/border-control/border-control/component.tsx +1 -0
- package/src/border-control/border-control/hook.ts +7 -1
- package/src/border-control/border-control-dropdown/component.tsx +25 -13
- package/src/border-control/stories/index.story.tsx +1 -0
- package/src/border-control/test/index.js +1 -0
- package/src/button/stories/index.story.tsx +2 -1
- package/src/card/stories/index.story.tsx +2 -1
- package/src/color-palette/index.native.js +1 -2
- package/src/color-palette/index.tsx +1 -1
- package/src/color-palette/style.scss +2 -4
- package/src/color-picker/index.native.js +0 -1
- package/src/composite/legacy/index.tsx +5 -2
- package/src/composite/stories/index.story.tsx +2 -1
- package/src/confirm-dialog/stories/index.story.tsx +2 -1
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
- package/src/date-time/date/index.tsx +0 -1
- package/src/disabled/stories/index.story.tsx +2 -1
- package/src/draggable/stories/index.story.tsx +2 -1
- package/src/dropdown/stories/index.story.tsx +2 -1
- package/src/external-link/stories/index.story.tsx +2 -1
- package/src/font-size-picker/index.native.js +7 -7
- package/src/form-file-upload/index.tsx +7 -1
- package/src/form-token-field/index.tsx +0 -3
- package/src/form-token-field/style.scss +12 -13
- package/src/form-token-field/suggestions-list.tsx +6 -0
- package/src/form-token-field/token.tsx +1 -0
- package/src/guide/page-control.tsx +1 -0
- package/src/guide/style.scss +4 -6
- package/src/heading/stories/index.story.tsx +2 -1
- package/src/item-group/stories/index.story.tsx +8 -4
- package/src/keyboard-shortcuts/stories/index.story.tsx +2 -1
- package/src/{dropdown-menu-v2 → menu}/README.md +34 -34
- package/src/{dropdown-menu-v2 → menu}/checkbox-item.tsx +14 -14
- package/src/menu/context.tsx +13 -0
- package/src/{dropdown-menu-v2 → menu}/group-label.tsx +8 -8
- package/src/menu/group.tsx +26 -0
- package/src/{dropdown-menu-v2 → menu}/index.tsx +65 -70
- package/src/{dropdown-menu-v2 → menu}/item-help-text.tsx +3 -7
- package/src/{dropdown-menu-v2 → menu}/item-label.tsx +3 -7
- package/src/{dropdown-menu-v2 → menu}/item.tsx +13 -13
- package/src/{dropdown-menu-v2 → menu}/radio-item.tsx +14 -14
- package/src/menu/separator.tsx +27 -0
- package/src/menu/stories/index.story.tsx +543 -0
- package/src/{dropdown-menu-v2 → menu}/styles.ts +17 -17
- package/src/{dropdown-menu-v2 → menu}/test/index.tsx +145 -225
- package/src/{dropdown-menu-v2 → menu}/types.ts +24 -23
- package/src/menu-item/index.tsx +1 -0
- package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -5
- package/src/mobile/bottom-sheet/range-cell.native.js +1 -1
- package/src/mobile/bottom-sheet/stepper-cell/index.native.js +1 -1
- package/src/mobile/bottom-sheet/sub-sheet/index.native.js +1 -3
- package/src/mobile/bottom-sheet-select-control/index.native.js +2 -2
- package/src/mobile/color-settings/index.native.js +1 -3
- package/src/mobile/color-settings/picker-screen.native.js +1 -3
- package/src/mobile/image/index.native.js +1 -3
- package/src/mobile/keyboard-avoiding-view/index.ios.js +1 -3
- package/src/mobile/link-picker/link-picker-results.native.js +2 -5
- package/src/mobile/link-picker/link-picker-screen.native.js +1 -3
- package/src/mobile/link-settings/index.native.js +6 -18
- package/src/mobile/link-settings/link-settings-screen.native.js +1 -3
- package/src/mobile/segmented-control/index.native.js +2 -6
- package/src/mobile/utils/use-unit-converter-to-mobile.native.js +2 -6
- package/src/modal/stories/index.story.tsx +2 -1
- package/src/navigable-container/stories/navigable-menu.story.tsx +2 -1
- package/src/navigable-container/stories/tabbable-container.story.tsx +2 -1
- package/src/navigation/index.tsx +1 -2
- package/src/navigation/item/use-navigation-tree-item.tsx +2 -2
- package/src/navigation/menu/menu-title-search.tsx +2 -2
- package/src/navigation/menu/use-navigation-tree-menu.tsx +2 -2
- package/src/navigator/stories/index.story.tsx +2 -1
- package/src/notice/index.tsx +2 -0
- package/src/notice/stories/index.story.tsx +7 -2
- package/src/notice/test/__snapshots__/index.tsx.snap +4 -4
- package/src/palette-edit/index.tsx +9 -5
- package/src/palette-edit/styles.ts +1 -67
- package/src/panel/body.tsx +1 -0
- package/src/panel/stories/index.story.tsx +2 -1
- package/src/popover/index.tsx +3 -0
- package/src/popover/stories/index.story.tsx +2 -1
- package/src/private-apis.ts +3 -3
- package/src/progress-bar/stories/index.story.tsx +2 -1
- package/src/radio-group/README.md +8 -8
- package/src/radio-group/index.tsx +2 -0
- package/src/radio-group/radio.tsx +7 -0
- package/src/radio-group/stories/index.story.tsx +16 -4
- package/src/radio-group/types.ts +6 -1
- package/src/resizable-box/stories/index.story.tsx +2 -1
- package/src/sandbox/index.native.js +1 -3
- package/src/sandbox/index.tsx +3 -6
- package/src/sandbox/stories/index.story.tsx +2 -1
- package/src/scroll-lock/stories/index.story.tsx +2 -1
- package/src/search-control/index.native.js +1 -3
- package/src/shortcut/stories/index.story.tsx +2 -1
- package/src/slot-fill/bubbles-virtually/slot.tsx +1 -2
- package/src/slot-fill/fill.ts +3 -6
- package/src/slot-fill/stories/index.story.tsx +2 -1
- package/src/snackbar/index.tsx +2 -1
- package/src/snackbar/stories/index.story.tsx +2 -1
- package/src/snackbar/stories/list.story.tsx +2 -1
- package/src/snackbar/style.scss +7 -16
- package/src/spacer/hook.ts +3 -2
- package/src/spinner/stories/index.story.tsx +2 -1
- package/src/tab-panel/index.tsx +3 -0
- package/src/tab-panel/stories/index.story.tsx +2 -1
- package/src/tab-panel/style.scss +1 -3
- package/src/tabs/README.md +63 -21
- package/src/tabs/index.tsx +112 -189
- package/src/tabs/stories/index.story.tsx +5 -2
- package/src/tabs/styles.ts +13 -5
- package/src/tabs/tab.tsx +23 -3
- package/src/tabs/tablist.tsx +44 -17
- package/src/tabs/test/index.tsx +131 -118
- package/src/tabs/types.ts +89 -49
- package/src/text/stories/index.story.tsx +2 -1
- package/src/text-highlight/stories/index.story.tsx +2 -1
- package/src/theme/stories/index.story.tsx +2 -1
- package/src/tip/stories/index.story.tsx +2 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -1
- package/src/toolbar/toolbar/index.tsx +3 -0
- package/src/tools-panel/tools-panel-header/component.tsx +1 -1
- package/src/tools-panel/tools-panel-item/hook.ts +0 -2
- package/src/tooltip/index.native.js +5 -15
- package/src/tooltip/stories/index.story.tsx +2 -1
- package/src/tree-grid/stories/index.story.tsx +2 -1
- package/src/truncate/stories/index.story.tsx +2 -1
- package/src/unit-control/index.native.js +2 -6
- package/src/utils/deprecated-36px-size.ts +27 -0
- package/src/utils/element-rect.ts +14 -2
- package/src/utils/hooks/use-animated-offset-rect.ts +13 -1
- package/src/utils/hooks/use-update-effect.js +0 -2
- package/src/visually-hidden/stories/index.story.tsx +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-v2/checkbox-item.js.map +0 -1
- package/build/dropdown-menu-v2/context.js.map +0 -1
- package/build/dropdown-menu-v2/group-label.js.map +0 -1
- package/build/dropdown-menu-v2/group.js.map +0 -1
- package/build/dropdown-menu-v2/index.js.map +0 -1
- package/build/dropdown-menu-v2/item-help-text.js.map +0 -1
- package/build/dropdown-menu-v2/item-label.js.map +0 -1
- package/build/dropdown-menu-v2/item.js.map +0 -1
- package/build/dropdown-menu-v2/radio-item.js.map +0 -1
- package/build/dropdown-menu-v2/separator.js.map +0 -1
- package/build/dropdown-menu-v2/styles.js +0 -150
- package/build/dropdown-menu-v2/styles.js.map +0 -1
- package/build/dropdown-menu-v2/types.js.map +0 -1
- package/build/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-module/dropdown-menu-v2/checkbox-item.js.map +0 -1
- package/build-module/dropdown-menu-v2/context.js.map +0 -1
- package/build-module/dropdown-menu-v2/group-label.js.map +0 -1
- package/build-module/dropdown-menu-v2/group.js +0 -21
- package/build-module/dropdown-menu-v2/group.js.map +0 -1
- package/build-module/dropdown-menu-v2/index.js.map +0 -1
- package/build-module/dropdown-menu-v2/item-help-text.js.map +0 -1
- package/build-module/dropdown-menu-v2/item-label.js.map +0 -1
- package/build-module/dropdown-menu-v2/item.js.map +0 -1
- package/build-module/dropdown-menu-v2/radio-item.js.map +0 -1
- package/build-module/dropdown-menu-v2/separator.js +0 -22
- package/build-module/dropdown-menu-v2/separator.js.map +0 -1
- package/build-module/dropdown-menu-v2/styles.js +0 -143
- package/build-module/dropdown-menu-v2/styles.js.map +0 -1
- package/build-module/dropdown-menu-v2/types.js.map +0 -1
- package/build-module/dropdown-menu-v2/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-types/dropdown-menu-v2/checkbox-item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/checkbox-item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/context.d.ts +0 -6
- package/build-types/dropdown-menu-v2/context.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/group-label.d.ts +0 -3
- package/build-types/dropdown-menu-v2/group-label.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/group.d.ts +0 -3
- package/build-types/dropdown-menu-v2/group.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/index.d.ts +0 -40
- package/build-types/dropdown-menu-v2/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item-help-text.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item-label.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/radio-item.d.ts +0 -3
- package/build-types/dropdown-menu-v2/radio-item.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/separator.d.ts +0 -3
- package/build-types/dropdown-menu-v2/separator.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +0 -16
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/styles.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/test/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/types.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2/use-temporary-focus-visible-fix.d.ts.map +0 -1
- package/src/dropdown-menu-v2/context.tsx +0 -13
- package/src/dropdown-menu-v2/group.tsx +0 -26
- package/src/dropdown-menu-v2/separator.tsx +0 -27
- package/src/dropdown-menu-v2/stories/index.story.tsx +0 -639
- /package/build/{dropdown-menu-v2 → menu}/types.js +0 -0
- /package/build/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
- /package/build-module/{dropdown-menu-v2 → menu}/types.js +0 -0
- /package/build-module/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.js +0 -0
- /package/build-types/{dropdown-menu-v2 → menu}/test/index.d.ts +0 -0
- /package/build-types/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.d.ts +0 -0
- /package/src/{dropdown-menu-v2 → menu}/use-temporary-focus-visible-fix.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_element","_compose","_slotFill","_style","_interopRequireDefault","_jsxRuntime","RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","createContext","onHandleScreenTouch","Fill","Slot","createSlotFill","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","useState","previousKeyboardVisible","usePrevious","useEffect","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","useRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","useContext","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","jsxs","Fragment","cloneElement","ref","onLayout","jsx","View","style","Text","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","useMemo","Provider","onTouchStart","undefined","pointerEvents","StyleSheet","absoluteFill","testID","_default","exports","default"],"sources":["@wordpress/components/src/tooltip/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched.\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ visible ] );\n\n\t// Manage visibility animation.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show.\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard.\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible.\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t\t// Disable reason: deferring this refactor to the native team.\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes.\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself.\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\t// Disable reason: deferring this refactor to the native team.\n\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAaA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAkC,IAAAM,WAAA,GAAAN,OAAA;AA/BlC;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;;AAIA,MAAMO,wBAAwB,GAAG,EAAE;AACnC,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,cAAc,GAAG,IAAAC,sBAAa,EAAE;EACrCC,mBAAmB,EAAEA,CAAA,KAAM,CAAC;AAC7B,CAAE,CAAC;AACH,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,wBAAc,EAAE,SAAU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":["_reactNative","require","_element","_compose","_slotFill","_style","_interopRequireDefault","_jsxRuntime","RIGHT_ALIGN_ARROW_OFFSET","TOOLTIP_VERTICAL_OFFSET","TooltipContext","createContext","onHandleScreenTouch","Fill","Slot","createSlotFill","useKeyboardVisibility","keyboardVisible","setKeyboardVisible","useState","previousKeyboardVisible","usePrevious","useEffect","showListener","Keyboard","addListener","keyboardHideEvent","Platform","select","android","ios","hideListener","remove","Tooltip","children","position","text","visible","initialVisible","referenceElementRef","useRef","animationValue","Animated","Value","current","horizontalPosition","split","setVisible","animating","setAnimating","hidden","previousVisible","referenceLayout","setReferenceLayout","height","width","x","y","tooltipLayout","setTooltipLayout","useContext","startAnimation","getReferenceElementPosition","frameListener","timing","toValue","duration","useNativeDriver","delay","easing","Easing","out","quad","start","tooltipStyles","styles","tooltip","left","Math","floor","top","tooltipBoxStyles","tooltip__box","elevation","opacity","shadowColor","tooltip__shadow","color","shadowOffset","shadowOpacity","shadowRadius","transform","translateY","interpolate","inputRange","outputRange","arrowStyles","tooltip__arrow","requestAnimationFrame","measure","_x","_y","pageX","pageY","getTooltipLayout","nativeEvent","layout","jsxs","Fragment","cloneElement","ref","onLayout","jsx","View","style","Text","tooltip__text","TooltipSlot","rest","handleScreenTouch","setHandleScreenTouch","callback","handleTouchStart","value","useMemo","Provider","onTouchStart","undefined","pointerEvents","StyleSheet","absoluteFill","testID","_default","exports","default"],"sources":["@wordpress/components/src/tooltip/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tAnimated,\n\tEasing,\n\tKeyboard,\n\tPlatform,\n\tStyleSheet,\n\tText,\n\tView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcloneElement,\n\tcreateContext,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { usePrevious } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { createSlotFill } from '../slot-fill';\nimport styles from './style.scss';\n\nconst RIGHT_ALIGN_ARROW_OFFSET = 16;\nconst TOOLTIP_VERTICAL_OFFSET = 2;\n\nconst TooltipContext = createContext( {\n\tonHandleScreenTouch: () => {},\n} );\nconst { Fill, Slot } = createSlotFill( 'Tooltip' );\n\nconst useKeyboardVisibility = () => {\n\tconst [ keyboardVisible, setKeyboardVisible ] = useState( false );\n\tconst previousKeyboardVisible = usePrevious( keyboardVisible );\n\n\tuseEffect( () => {\n\t\tconst showListener = Keyboard.addListener( 'keyboardDidShow', () => {\n\t\t\tif ( previousKeyboardVisible !== true ) {\n\t\t\t\tsetKeyboardVisible( true );\n\t\t\t}\n\t\t} );\n\t\tconst keyboardHideEvent = Platform.select( {\n\t\t\tandroid: 'keyboardDidHide',\n\t\t\tios: 'keyboardWillHide',\n\t\t} );\n\t\tconst hideListener = Keyboard.addListener( keyboardHideEvent, () => {\n\t\t\tif ( previousKeyboardVisible !== false ) {\n\t\t\t\tsetKeyboardVisible( false );\n\t\t\t}\n\t\t} );\n\t\treturn () => {\n\t\t\tshowListener.remove();\n\t\t\thideListener.remove();\n\t\t};\n\t\t// See https://github.com/WordPress/gutenberg/pull/41166\n\t}, [] );\n\n\treturn keyboardVisible;\n};\n\nconst Tooltip = ( {\n\tchildren,\n\tposition = 'top',\n\ttext,\n\tvisible: initialVisible = false,\n} ) => {\n\tconst referenceElementRef = useRef( null );\n\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\tconst [ , horizontalPosition = 'center' ] = position.split( ' ' );\n\tconst [ visible, setVisible ] = useState( initialVisible );\n\tconst [ animating, setAnimating ] = useState( false );\n\tconst hidden = ! visible && ! animating;\n\tconst previousVisible = usePrevious( visible );\n\tconst [ referenceLayout, setReferenceLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t\tx: 0,\n\t\ty: 0,\n\t} );\n\tconst [ tooltipLayout, setTooltipLayout ] = useState( {\n\t\theight: 0,\n\t\twidth: 0,\n\t} );\n\tconst { onHandleScreenTouch } = useContext( TooltipContext );\n\tconst keyboardVisible = useKeyboardVisibility();\n\n\t// Register callback to dismiss the tooltip whenever the screen is touched.\n\tuseEffect( () => {\n\t\tif ( visible ) {\n\t\t\tonHandleScreenTouch( () => {\n\t\t\t\tsetAnimating( true );\n\t\t\t\tsetVisible( false );\n\t\t\t} );\n\t\t}\n\t\treturn () => onHandleScreenTouch( null );\n\t\t// See https://github.com/WordPress/gutenberg/pull/41166\n\t}, [ visible ] );\n\n\t// Manage visibility animation.\n\tuseEffect( () => {\n\t\tif (\n\t\t\t// Initial render and visibility enabled, animate show.\n\t\t\t( typeof previousVisible === 'undefined' && visible ) ||\n\t\t\t// Previously visible, animate hide\n\t\t\t( previousVisible && previousVisible !== visible )\n\t\t) {\n\t\t\tsetAnimating( true );\n\t\t\tstartAnimation();\n\t\t}\n\t\t// See https://github.com/WordPress/gutenberg/pull/41166\n\t}, [ visible ] );\n\n\t// Manage tooltip visibility and position in relation to keyboard.\n\tuseEffect( () => {\n\t\tif ( ! visible ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update tooltip position if keyboard is visible.\n\t\tif ( keyboardVisible ) {\n\t\t\tgetReferenceElementPosition();\n\t\t}\n\n\t\t// Hide tooltip if keyboard hides\n\t\tif ( typeof previousVisible !== 'undefined' && ! keyboardVisible ) {\n\t\t\tsetAnimating( true );\n\t\t\tsetVisible( false );\n\t\t}\n\t\t// See https://github.com/WordPress/gutenberg/pull/41166\n\t}, [ visible, keyboardVisible ] );\n\n\t// Manage tooltip position during keyboard frame changes.\n\tuseEffect( () => {\n\t\tconst frameListener = Keyboard.addListener(\n\t\t\t'keyboardWillChangeFrame',\n\t\t\t() => {\n\t\t\t\tif ( visible ) {\n\t\t\t\t\tgetReferenceElementPosition();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tframeListener.remove();\n\t\t};\n\t}, [ visible ] );\n\n\tconst startAnimation = () => {\n\t\tAnimated.timing( animationValue, {\n\t\t\ttoValue: visible ? 1 : 0,\n\t\t\tduration: visible ? 300 : 150,\n\t\t\tuseNativeDriver: true,\n\t\t\tdelay: visible ? 500 : 0,\n\t\t\teasing: Easing.out( Easing.quad ),\n\t\t} ).start( () => {\n\t\t\tsetAnimating( false );\n\t\t} );\n\t};\n\n\tconst tooltipStyles = [\n\t\tstyles.tooltip,\n\t\t{\n\t\t\tleft:\n\t\t\t\treferenceLayout.x +\n\t\t\t\tMath.floor( referenceLayout.width / 2 ) -\n\t\t\t\t( horizontalPosition === 'right'\n\t\t\t\t\t? RIGHT_ALIGN_ARROW_OFFSET\n\t\t\t\t\t: Math.floor( tooltipLayout.width / 2 ) ),\n\t\t\ttop:\n\t\t\t\treferenceLayout.y -\n\t\t\t\ttooltipLayout.height -\n\t\t\t\tTOOLTIP_VERTICAL_OFFSET,\n\t\t},\n\t];\n\tconst tooltipBoxStyles = [\n\t\tstyles.tooltip__box,\n\t\thorizontalPosition === 'right' && styles[ 'tooltip--rightAlign' ],\n\t\t{\n\t\t\televation: 2,\n\t\t\topacity: animationValue,\n\t\t\tshadowColor: styles.tooltip__shadow?.color,\n\t\t\tshadowOffset: { height: 2, width: 0 },\n\t\t\tshadowOpacity: 0.25,\n\t\t\tshadowRadius: 2,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [ visible ? 4 : -8, -8 ],\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n\tconst arrowStyles = [\n\t\tstyles.tooltip__arrow,\n\t\thorizontalPosition === 'right' &&\n\t\t\tstyles[ 'tooltip__arrow--rightAlign' ],\n\t];\n\n\tconst getReferenceElementPosition = () => {\n\t\t// rAF allows render to complete before calculating layout\n\t\t// eslint-disable-next-line no-undef\n\t\trequestAnimationFrame( () => {\n\t\t\tif ( ! referenceElementRef.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treferenceElementRef.current.measure(\n\t\t\t\t( _x, _y, width, height, pageX, pageY ) => {\n\t\t\t\t\tsetReferenceLayout( {\n\t\t\t\t\t\theight,\n\t\t\t\t\t\twidth,\n\t\t\t\t\t\tx: pageX,\n\t\t\t\t\t\ty: pageY,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t);\n\t\t} );\n\t};\n\tconst getTooltipLayout = ( { nativeEvent } ) => {\n\t\tconst { height, width } = nativeEvent.layout;\n\t\tsetTooltipLayout( { height, width } );\n\t};\n\n\tif ( hidden ) {\n\t\treturn children;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ cloneElement( children, {\n\t\t\t\tref: referenceElementRef,\n\t\t\t\tonLayout: getReferenceElementPosition,\n\t\t\t} ) }\n\t\t\t<Fill>\n\t\t\t\t<View onLayout={ getTooltipLayout } style={ tooltipStyles }>\n\t\t\t\t\t<Animated.View style={ tooltipBoxStyles }>\n\t\t\t\t\t\t<Text style={ styles.tooltip__text }>{ text }</Text>\n\t\t\t\t\t\t<View style={ arrowStyles } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nconst TooltipSlot = ( { children, ...rest } ) => {\n\tconst [ handleScreenTouch, setHandleScreenTouch ] = useState( null );\n\tconst onHandleScreenTouch = ( callback ) => {\n\t\t// Must use function to set state below as `callback` is a function itself.\n\t\tsetHandleScreenTouch( () => callback );\n\t};\n\tconst handleTouchStart = () => {\n\t\thandleScreenTouch();\n\t\tsetHandleScreenTouch( null );\n\t};\n\t// Memoize context value to avoid unnecessary rerenders of the Provider's children\n\t// See https://github.com/WordPress/gutenberg/pull/41166\n\tconst value = useMemo( () => ( { onHandleScreenTouch } ) );\n\n\treturn (\n\t\t<TooltipContext.Provider value={ value }>\n\t\t\t<View\n\t\t\t\tonTouchStart={\n\t\t\t\t\ttypeof handleScreenTouch === 'function'\n\t\t\t\t\t\t? handleTouchStart\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tpointerEvents=\"box-none\"\n\t\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\t\ttestID=\"tooltip-overlay\"\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t\t<Slot { ...rest } />\n\t\t\t</View>\n\t\t</TooltipContext.Provider>\n\t);\n};\n\nTooltip.Slot = TooltipSlot;\n\nexport default Tooltip;\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAaA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAC,sBAAA,CAAAL,OAAA;AAAkC,IAAAM,WAAA,GAAAN,OAAA;AA/BlC;AACA;AACA;;AAWA;AACA;AACA;;AAYA;AACA;AACA;;AAIA,MAAMO,wBAAwB,GAAG,EAAE;AACnC,MAAMC,uBAAuB,GAAG,CAAC;AAEjC,MAAMC,cAAc,GAAG,IAAAC,sBAAa,EAAE;EACrCC,mBAAmB,EAAEA,CAAA,KAAM,CAAC;AAC7B,CAAE,CAAC;AACH,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,GAAG,IAAAC,wBAAc,EAAE,SAAU,CAAC;AAElD,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACnC,MAAM,CAAEC,eAAe,EAAEC,kBAAkB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EACjE,MAAMC,uBAAuB,GAAG,IAAAC,oBAAW,EAAEJ,eAAgB,CAAC;EAE9D,IAAAK,kBAAS,EAAE,MAAM;IAChB,MAAMC,YAAY,GAAGC,qBAAQ,CAACC,WAAW,CAAE,iBAAiB,EAAE,MAAM;MACnE,IAAKL,uBAAuB,KAAK,IAAI,EAAG;QACvCF,kBAAkB,CAAE,IAAK,CAAC;MAC3B;IACD,CAAE,CAAC;IACH,MAAMQ,iBAAiB,GAAGC,qBAAQ,CAACC,MAAM,CAAE;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,CAAC;EACD;EACA;EACA,MAAMG,KAAK,GAAG,IAAAC,gBAAO,EAAE,OAAQ;IAAEhH;EAAoB,CAAC,CAAG,CAAC;EAE1D,oBACC,IAAAL,WAAA,CAAAyG,GAAA,EAACtG,cAAc,CAACmH,QAAQ;IAACF,KAAK,EAAGA,KAAO;IAAAzF,QAAA,eACvC,IAAA3B,WAAA,CAAAoG,IAAA,EAAC3G,YAAA,CAAAiH,IAAI;MACJa,YAAY,EACX,OAAOP,iBAAiB,KAAK,UAAU,GACpCG,gBAAgB,GAChBK,SACH;MACDC,aAAa,EAAC,UAAU;MACxBd,KAAK,EAAGe,uBAAU,CAACC,YAAc;MACjCC,MAAM,EAAC,iBAAiB;MAAAjG,QAAA,GAEtBA,QAAQ,eACV,IAAA3B,WAAA,CAAAyG,GAAA,EAAClG,IAAI;QAAA,GAAMwG;MAAI,CAAI,CAAC;IAAA,CACf;EAAC,CACiB,CAAC;AAE5B,CAAC;AAEDrF,OAAO,CAACnB,IAAI,GAAGuG,WAAW;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEZrG,OAAO","ignoreList":[]}
|
|
@@ -54,10 +54,8 @@ function UnitControl({
|
|
|
54
54
|
if (pickerRef?.current) {
|
|
55
55
|
pickerRef.current.presentPicker();
|
|
56
56
|
}
|
|
57
|
-
//
|
|
58
|
-
// It would be great if this could be done in the context of
|
|
57
|
+
// It would be great if the deps could be addressed in the context of
|
|
59
58
|
// https://github.com/WordPress/gutenberg/pull/39218
|
|
60
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
59
|
}, [pickerRef?.current]);
|
|
62
60
|
const currentInputValue = currentInput === null ? value : currentInput;
|
|
63
61
|
const initialControlValue = isFinite(currentInputValue) ? currentInputValue : initialPosition;
|
|
@@ -86,10 +84,8 @@ function UnitControl({
|
|
|
86
84
|
return unitButton;
|
|
87
85
|
}, [onPickerPresent, accessibilityLabel, accessibilityHint, unitButtonTextStyle, unit, units]);
|
|
88
86
|
const getAnchor = (0, _element.useCallback)(() => anchorNodeRef?.current ? (0, _reactNative.findNodeHandle)(anchorNodeRef?.current) : undefined,
|
|
89
|
-
//
|
|
90
|
-
// It would be great if this could be done in the context of
|
|
87
|
+
// It would be great if the deps could be addressed in the context of
|
|
91
88
|
// https://github.com/WordPress/gutenberg/pull/39218
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
89
|
[anchorNodeRef?.current]);
|
|
94
90
|
const getDecimal = step => {
|
|
95
91
|
// Return the decimal offset based on the step size.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_rangeCell","_interopRequireDefault","_stepperCell","_picker","_style","_utils","_element","_compose","_i18n","_jsxRuntime","UnitControl","currentInput","label","value","onChange","onUnitChange","initialPosition","min","max","separatorType","units","CSS_UNITS","unit","getStylesFromColorScheme","props","pickerRef","useRef","anchorNodeRef","onPickerPresent","useCallback","current","presentPicker","currentInputValue","initialControlValue","isFinite","unitButtonTextStyle","styles","unitButtonText","unitButtonTextDark","accessibilityLabel","sprintf","__","accessibilityHint","Platform","OS","renderUnitButton","useMemo","unitButton","jsx","View","style","children","Text","hasUnits","length","TouchableWithoutFeedback","onPress","accessibilityRole","getAnchor","findNodeHandle","undefined","getDecimal","step","stepToString","splitStep","toString","split","renderUnitPicker","jsxs","unitMenu","ref","default","options","hideCancelButton","leftAlign","_activeUnit$step","activeUnit","find","option","decimalNum","Fragment","defaultValue","shouldDisplayTextInput","openUnitPicker","unitLabel","getAccessibleLabelForUnit","minimumValue","maximumValue","_default","exports","memo","withPreferredColorScheme"],"sources":["@wordpress/components/src/unit-control/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tText,\n\tView,\n\tTouchableWithoutFeedback,\n\tPlatform,\n\tfindNodeHandle,\n} from 'react-native';\n\n/**\n * Internal dependencies\n */\nimport RangeCell from '../mobile/bottom-sheet/range-cell';\nimport StepperCell from '../mobile/bottom-sheet/stepper-cell';\nimport Picker from '../mobile/picker';\nimport styles from './style.scss';\nimport { CSS_UNITS, hasUnits, getAccessibleLabelForUnit } from './utils';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useMemo, memo } from '@wordpress/element';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\n\nfunction UnitControl( {\n\tcurrentInput,\n\tlabel,\n\tvalue,\n\tonChange,\n\tonUnitChange,\n\tinitialPosition,\n\tmin,\n\tmax,\n\tseparatorType,\n\tunits = CSS_UNITS,\n\tunit,\n\tgetStylesFromColorScheme,\n\t...props\n} ) {\n\tconst pickerRef = useRef();\n\tconst anchorNodeRef = useRef();\n\n\tconst onPickerPresent = useCallback( () => {\n\t\tif ( pickerRef?.current ) {\n\t\t\tpickerRef.current.presentPicker();\n\t\t}\n\t\t// Disable reason: this should be fixed by the native team.\n\t\t// It would be great if this could be done in the context of\n\t\t// https://github.com/WordPress/gutenberg/pull/39218\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ pickerRef?.current ] );\n\n\tconst currentInputValue = currentInput === null ? value : currentInput;\n\tconst initialControlValue = isFinite( currentInputValue )\n\t\t? currentInputValue\n\t\t: initialPosition;\n\n\tconst unitButtonTextStyle = getStylesFromColorScheme(\n\t\tstyles.unitButtonText,\n\t\tstyles.unitButtonTextDark\n\t);\n\n\t/* translators: accessibility text. Inform about current unit value. %s: Current unit value. */\n\tconst accessibilityLabel = sprintf( __( 'Current unit is %s' ), unit );\n\n\tconst accessibilityHint =\n\t\tPlatform.OS === 'ios'\n\t\t\t? __( 'Double tap to open Action Sheet with available options' )\n\t\t\t: __( 'Double tap to open Bottom Sheet with available options' );\n\n\tconst renderUnitButton = useMemo( () => {\n\t\tconst unitButton = (\n\t\t\t<View style={ styles.unitButton }>\n\t\t\t\t<Text style={ unitButtonTextStyle }>{ unit }</Text>\n\t\t\t</View>\n\t\t);\n\n\t\tif ( hasUnits( units ) && units?.length > 1 ) {\n\t\t\treturn (\n\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\tonPress={ onPickerPresent }\n\t\t\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t>\n\t\t\t\t\t{ unitButton }\n\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t);\n\t\t}\n\n\t\treturn unitButton;\n\t}, [\n\t\tonPickerPresent,\n\t\taccessibilityLabel,\n\t\taccessibilityHint,\n\t\tunitButtonTextStyle,\n\t\tunit,\n\t\tunits,\n\t] );\n\n\tconst getAnchor = useCallback(\n\t\t() =>\n\t\t\tanchorNodeRef?.current\n\t\t\t\t? findNodeHandle( anchorNodeRef?.current )\n\t\t\t\t: undefined,\n\t\t// Disable reason: this should be fixed by the native team.\n\t\t// It would be great if this could be done in the context of\n\t\t// https://github.com/WordPress/gutenberg/pull/39218\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[ anchorNodeRef?.current ]\n\t);\n\n\tconst getDecimal = ( step ) => {\n\t\t// Return the decimal offset based on the step size.\n\t\t// if step size is 0.1 we expect the offset to be 1.\n\t\t// for example 12 + 0.1 we would expect the see 12.1 (not 12.10 or 12 );\n\t\t// steps are defined in the CSS_UNITS and they vary from unit to unit.\n\t\tconst stepToString = step;\n\t\tconst splitStep = stepToString.toString().split( '.' );\n\t\treturn splitStep[ 1 ] ? splitStep[ 1 ].length : 0;\n\t};\n\n\tconst renderUnitPicker = useCallback( () => {\n\t\t// Keeping for legacy reasons, although `false` should not be a valid\n\t\t// value for the `units` prop anymore.\n\t\tif ( units === false ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (\n\t\t\t<View style={ styles.unitMenu } ref={ anchorNodeRef }>\n\t\t\t\t{ renderUnitButton }\n\t\t\t\t{ hasUnits( units ) && units?.length > 1 ? (\n\t\t\t\t\t<Picker\n\t\t\t\t\t\tref={ pickerRef }\n\t\t\t\t\t\toptions={ units }\n\t\t\t\t\t\tonChange={ onUnitChange }\n\t\t\t\t\t\thideCancelButton\n\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\tgetAnchor={ getAnchor }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</View>\n\t\t);\n\t}, [ pickerRef, units, onUnitChange, getAnchor, renderUnitButton ] );\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\tconst decimalNum = getDecimal( step );\n\n\treturn (\n\t\t<>\n\t\t\t{ unit !== '%' ? (\n\t\t\t\t<StepperCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tmin={ min }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tdefaultValue={ initialControlValue }\n\t\t\t\t\tshouldDisplayTextInput\n\t\t\t\t\tdecimalNum={ decimalNum }\n\t\t\t\t\topenUnitPicker={ onPickerPresent }\n\t\t\t\t\tunitLabel={ getAccessibleLabelForUnit( unit ) }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ renderUnitPicker() }\n\t\t\t\t</StepperCell>\n\t\t\t) : (\n\t\t\t\t<RangeCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tminimumValue={ min }\n\t\t\t\t\tmaximumValue={ max }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tunit={ unit }\n\t\t\t\t\tdefaultValue={ initialControlValue }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tdecimalNum={ decimalNum }\n\t\t\t\t\topenUnitPicker={ onPickerPresent }\n\t\t\t\t\tunitLabel={ getAccessibleLabelForUnit( unit ) }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ renderUnitPicker() }\n\t\t\t\t</RangeCell>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport { useCustomUnits } from './utils';\nexport default memo( withPreferredColorScheme( UnitControl ) );\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAA8C,IAAAU,WAAA,GAAAV,OAAA;AAzB9C;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAKA,SAASW,WAAWA,CAAE;EACrBC,YAAY;EACZC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,YAAY;EACZC,eAAe;EACfC,GAAG;EACHC,GAAG;EACHC,aAAa;EACbC,KAAK,GAAGC,gBAAS;EACjBC,IAAI;EACJC,wBAAwB;EACxB,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAC,CAAC;EAC1B,MAAMC,aAAa,GAAG,IAAAD,eAAM,EAAC,CAAC;EAE9B,MAAME,eAAe,GAAG,IAAAC,oBAAW,EAAE,MAAM;IAC1C,IAAKJ,SAAS,EAAEK,OAAO,EAAG;MACzBL,SAAS,CAACK,OAAO,CAACC,aAAa,CAAC,CAAC;IAClC;IACA;IACA;IACA;IACA;EACD,CAAC,EAAE,CAAEN,SAAS,EAAEK,OAAO,CAAG,CAAC;EAE3B,MA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D,IAAI,EAAGA,IAAM;MACbxC,IAAI,EAAGA,IAAM;MACb2D,YAAY,EAAGhD,mBAAqB;MACpCd,aAAa,EAAGA,aAAe;MAC/B4D,UAAU,EAAGA,UAAY;MACzBI,cAAc,EAAGvD,eAAiB;MAClCwD,SAAS,EAAG,IAAAC,gCAAyB,EAAE/D,IAAK,CAAG;MAAA,GAC1CE,KAAK;MAAA2B,QAAA,EAERgB,gBAAgB,CAAC;IAAC,CACV;EACX,CACA,CAAC;AAEL;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAGc,IAAAmB,aAAI,EAAE,IAAAC,iCAAwB,EAAEjF,WAAY,CAAE,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_rangeCell","_interopRequireDefault","_stepperCell","_picker","_style","_utils","_element","_compose","_i18n","_jsxRuntime","UnitControl","currentInput","label","value","onChange","onUnitChange","initialPosition","min","max","separatorType","units","CSS_UNITS","unit","getStylesFromColorScheme","props","pickerRef","useRef","anchorNodeRef","onPickerPresent","useCallback","current","presentPicker","currentInputValue","initialControlValue","isFinite","unitButtonTextStyle","styles","unitButtonText","unitButtonTextDark","accessibilityLabel","sprintf","__","accessibilityHint","Platform","OS","renderUnitButton","useMemo","unitButton","jsx","View","style","children","Text","hasUnits","length","TouchableWithoutFeedback","onPress","accessibilityRole","getAnchor","findNodeHandle","undefined","getDecimal","step","stepToString","splitStep","toString","split","renderUnitPicker","jsxs","unitMenu","ref","default","options","hideCancelButton","leftAlign","_activeUnit$step","activeUnit","find","option","decimalNum","Fragment","defaultValue","shouldDisplayTextInput","openUnitPicker","unitLabel","getAccessibleLabelForUnit","minimumValue","maximumValue","_default","exports","memo","withPreferredColorScheme"],"sources":["@wordpress/components/src/unit-control/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tText,\n\tView,\n\tTouchableWithoutFeedback,\n\tPlatform,\n\tfindNodeHandle,\n} from 'react-native';\n\n/**\n * Internal dependencies\n */\nimport RangeCell from '../mobile/bottom-sheet/range-cell';\nimport StepperCell from '../mobile/bottom-sheet/stepper-cell';\nimport Picker from '../mobile/picker';\nimport styles from './style.scss';\nimport { CSS_UNITS, hasUnits, getAccessibleLabelForUnit } from './utils';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useMemo, memo } from '@wordpress/element';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { __, sprintf } from '@wordpress/i18n';\n\nfunction UnitControl( {\n\tcurrentInput,\n\tlabel,\n\tvalue,\n\tonChange,\n\tonUnitChange,\n\tinitialPosition,\n\tmin,\n\tmax,\n\tseparatorType,\n\tunits = CSS_UNITS,\n\tunit,\n\tgetStylesFromColorScheme,\n\t...props\n} ) {\n\tconst pickerRef = useRef();\n\tconst anchorNodeRef = useRef();\n\n\tconst onPickerPresent = useCallback( () => {\n\t\tif ( pickerRef?.current ) {\n\t\t\tpickerRef.current.presentPicker();\n\t\t}\n\t\t// It would be great if the deps could be addressed in the context of\n\t\t// https://github.com/WordPress/gutenberg/pull/39218\n\t}, [ pickerRef?.current ] );\n\n\tconst currentInputValue = currentInput === null ? value : currentInput;\n\tconst initialControlValue = isFinite( currentInputValue )\n\t\t? currentInputValue\n\t\t: initialPosition;\n\n\tconst unitButtonTextStyle = getStylesFromColorScheme(\n\t\tstyles.unitButtonText,\n\t\tstyles.unitButtonTextDark\n\t);\n\n\t/* translators: accessibility text. Inform about current unit value. %s: Current unit value. */\n\tconst accessibilityLabel = sprintf( __( 'Current unit is %s' ), unit );\n\n\tconst accessibilityHint =\n\t\tPlatform.OS === 'ios'\n\t\t\t? __( 'Double tap to open Action Sheet with available options' )\n\t\t\t: __( 'Double tap to open Bottom Sheet with available options' );\n\n\tconst renderUnitButton = useMemo( () => {\n\t\tconst unitButton = (\n\t\t\t<View style={ styles.unitButton }>\n\t\t\t\t<Text style={ unitButtonTextStyle }>{ unit }</Text>\n\t\t\t</View>\n\t\t);\n\n\t\tif ( hasUnits( units ) && units?.length > 1 ) {\n\t\t\treturn (\n\t\t\t\t<TouchableWithoutFeedback\n\t\t\t\t\tonPress={ onPickerPresent }\n\t\t\t\t\taccessibilityLabel={ accessibilityLabel }\n\t\t\t\t\taccessibilityRole=\"button\"\n\t\t\t\t\taccessibilityHint={ accessibilityHint }\n\t\t\t\t>\n\t\t\t\t\t{ unitButton }\n\t\t\t\t</TouchableWithoutFeedback>\n\t\t\t);\n\t\t}\n\n\t\treturn unitButton;\n\t}, [\n\t\tonPickerPresent,\n\t\taccessibilityLabel,\n\t\taccessibilityHint,\n\t\tunitButtonTextStyle,\n\t\tunit,\n\t\tunits,\n\t] );\n\n\tconst getAnchor = useCallback(\n\t\t() =>\n\t\t\tanchorNodeRef?.current\n\t\t\t\t? findNodeHandle( anchorNodeRef?.current )\n\t\t\t\t: undefined,\n\t\t// It would be great if the deps could be addressed in the context of\n\t\t// https://github.com/WordPress/gutenberg/pull/39218\n\t\t[ anchorNodeRef?.current ]\n\t);\n\n\tconst getDecimal = ( step ) => {\n\t\t// Return the decimal offset based on the step size.\n\t\t// if step size is 0.1 we expect the offset to be 1.\n\t\t// for example 12 + 0.1 we would expect the see 12.1 (not 12.10 or 12 );\n\t\t// steps are defined in the CSS_UNITS and they vary from unit to unit.\n\t\tconst stepToString = step;\n\t\tconst splitStep = stepToString.toString().split( '.' );\n\t\treturn splitStep[ 1 ] ? splitStep[ 1 ].length : 0;\n\t};\n\n\tconst renderUnitPicker = useCallback( () => {\n\t\t// Keeping for legacy reasons, although `false` should not be a valid\n\t\t// value for the `units` prop anymore.\n\t\tif ( units === false ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn (\n\t\t\t<View style={ styles.unitMenu } ref={ anchorNodeRef }>\n\t\t\t\t{ renderUnitButton }\n\t\t\t\t{ hasUnits( units ) && units?.length > 1 ? (\n\t\t\t\t\t<Picker\n\t\t\t\t\t\tref={ pickerRef }\n\t\t\t\t\t\toptions={ units }\n\t\t\t\t\t\tonChange={ onUnitChange }\n\t\t\t\t\t\thideCancelButton\n\t\t\t\t\t\tleftAlign\n\t\t\t\t\t\tgetAnchor={ getAnchor }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</View>\n\t\t);\n\t}, [ pickerRef, units, onUnitChange, getAnchor, renderUnitButton ] );\n\n\tlet step = props.step;\n\n\t/*\n\t * If no step prop has been passed, lookup the active unit and\n\t * try to get step from `units`, or default to a value of `1`\n\t */\n\tif ( ! step && units ) {\n\t\tconst activeUnit = units.find( ( option ) => option.value === unit );\n\t\tstep = activeUnit?.step ?? 1;\n\t}\n\n\tconst decimalNum = getDecimal( step );\n\n\treturn (\n\t\t<>\n\t\t\t{ unit !== '%' ? (\n\t\t\t\t<StepperCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tmax={ max }\n\t\t\t\t\tmin={ min }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tdefaultValue={ initialControlValue }\n\t\t\t\t\tshouldDisplayTextInput\n\t\t\t\t\tdecimalNum={ decimalNum }\n\t\t\t\t\topenUnitPicker={ onPickerPresent }\n\t\t\t\t\tunitLabel={ getAccessibleLabelForUnit( unit ) }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ renderUnitPicker() }\n\t\t\t\t</StepperCell>\n\t\t\t) : (\n\t\t\t\t<RangeCell\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tminimumValue={ min }\n\t\t\t\t\tmaximumValue={ max }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tstep={ step }\n\t\t\t\t\tunit={ unit }\n\t\t\t\t\tdefaultValue={ initialControlValue }\n\t\t\t\t\tseparatorType={ separatorType }\n\t\t\t\t\tdecimalNum={ decimalNum }\n\t\t\t\t\topenUnitPicker={ onPickerPresent }\n\t\t\t\t\tunitLabel={ getAccessibleLabelForUnit( unit ) }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t{ renderUnitPicker() }\n\t\t\t\t</RangeCell>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport { useCustomUnits } from './utils';\nexport default memo( withPreferredColorScheme( UnitControl ) );\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,OAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAKA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAA8C,IAAAU,WAAA,GAAAV,OAAA;AAzB9C;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAKA,SAASW,WAAWA,CAAE;EACrBC,YAAY;EACZC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,YAAY;EACZC,eAAe;EACfC,GAAG;EACHC,GAAG;EACHC,aAAa;EACbC,KAAK,GAAGC,gBAAS;EACjBC,IAAI;EACJC,wBAAwB;EACxB,GAAGC;AACJ,CAAC,EAAG;EACH,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAC,CAAC;EAC1B,MAAMC,aAAa,GAAG,IAAAD,eAAM,EAAC,CAAC;EAE9B,MAAME,eAAe,GAAG,IAAAC,oBAAW,EAAE,MAAM;IAC1C,IAAKJ,SAAS,EAAEK,OAAO,EAAG;MACzBL,SAAS,CAACK,OAAO,CAACC,aAAa,CAAC,CAAC;IAClC;IACA;IACA;EACD,CAAC,EAAE,CAAEN,SAAS,EAAEK,OAAO,CAAG,CAAC;EAE3B,MAAME,iBAAiB,GAAGrB,YAAY,KAAK,IAAI,GAAGE,KAAK,GAAG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hD,mBAAqB;MACpCd,aAAa,EAAGA,aAAe;MAC/B4D,UAAU,EAAGA,UAAY;MACzBI,cAAc,EAAGvD,eAAiB;MAClCwD,SAAS,EAAG,IAAAC,gCAAyB,EAAE/D,IAAK,CAAG;MAAA,GAC1CE,KAAK;MAAA2B,QAAA,EAERgB,gBAAgB,CAAC;IAAC,CACV;EACX,CACA,CAAC;AAEL;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAGc,IAAAmB,aAAI,EAAE,IAAAC,iCAAwB,EAAEjF,WAAY,CAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.maybeWarnDeprecated36pxSize = maybeWarnDeprecated36pxSize;
|
|
8
|
+
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function maybeWarnDeprecated36pxSize({
|
|
14
|
+
componentName,
|
|
15
|
+
__next40pxDefaultSize,
|
|
16
|
+
size
|
|
17
|
+
}) {
|
|
18
|
+
if (__next40pxDefaultSize || size !== undefined && size !== 'default') {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
(0, _deprecated.default)(`36px default size for wp.components.${componentName}`, {
|
|
22
|
+
since: '6.8',
|
|
23
|
+
version: '7.1',
|
|
24
|
+
hint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=deprecated-36px-size.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_deprecated","_interopRequireDefault","require","maybeWarnDeprecated36pxSize","componentName","__next40pxDefaultSize","size","undefined","deprecated","since","version","hint"],"sources":["@wordpress/components/src/utils/deprecated-36px-size.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\nexport function maybeWarnDeprecated36pxSize( {\n\tcomponentName,\n\t__next40pxDefaultSize,\n\tsize,\n}: {\n\tcomponentName: string;\n\t__next40pxDefaultSize: boolean | undefined;\n\tsize: string | undefined;\n} ) {\n\tif (\n\t\t__next40pxDefaultSize ||\n\t\t( size !== undefined && size !== 'default' )\n\t) {\n\t\treturn;\n\t}\n\n\tdeprecated( `36px default size for wp.components.${ componentName }`, {\n\t\tsince: '6.8',\n\t\tversion: '7.1',\n\t\thint: 'Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version.',\n\t} );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGO,SAASC,2BAA2BA,CAAE;EAC5CC,aAAa;EACbC,qBAAqB;EACrBC;AAKD,CAAC,EAAG;EACH,IACCD,qBAAqB,IACnBC,IAAI,KAAKC,SAAS,IAAID,IAAI,KAAK,SAAW,EAC3C;IACD;EACD;EAEA,IAAAE,mBAAU,EAAE,uCAAwCJ,aAAa,EAAG,EAAE;IACrEK,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE,KAAK;IACdC,IAAI,EAAE;EACP,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -96,11 +96,13 @@ const POLL_RATE = 100;
|
|
|
96
96
|
* to measure again after a frame, and if that fails, it will poll every 100
|
|
97
97
|
* milliseconds until it succeeds.
|
|
98
98
|
*/
|
|
99
|
-
function useTrackElementOffsetRect(targetElement) {
|
|
99
|
+
function useTrackElementOffsetRect(targetElement, deps = []) {
|
|
100
100
|
const [indicatorPosition, setIndicatorPosition] = (0, _element.useState)(NULL_ELEMENT_OFFSET_RECT);
|
|
101
101
|
const intervalRef = (0, _element.useRef)();
|
|
102
102
|
const measure = (0, _compose.useEvent)(() => {
|
|
103
|
-
|
|
103
|
+
// Check that the targetElement is still attached to the DOM, in case
|
|
104
|
+
// it was removed since the last `measure` call.
|
|
105
|
+
if (targetElement && targetElement.isConnected) {
|
|
104
106
|
const elementOffsetRect = getElementOffsetRect(targetElement);
|
|
105
107
|
if (elementOffsetRect) {
|
|
106
108
|
setIndicatorPosition(elementOffsetRect);
|
|
@@ -127,6 +129,15 @@ function useTrackElementOffsetRect(targetElement) {
|
|
|
127
129
|
setIndicatorPosition(NULL_ELEMENT_OFFSET_RECT);
|
|
128
130
|
}
|
|
129
131
|
}, [setElement, targetElement]);
|
|
132
|
+
|
|
133
|
+
// Escape hatch to force a remeasurement when something else changes rather
|
|
134
|
+
// than the target elements' ref or size (for example, the target element
|
|
135
|
+
// can change its position within the tablist).
|
|
136
|
+
(0, _element.useLayoutEffect)(() => {
|
|
137
|
+
measure();
|
|
138
|
+
// `measure` is a stable function, so it's safe to omit it from the deps array.
|
|
139
|
+
// deps can't be statically analyzed by ESLint
|
|
140
|
+
}, deps);
|
|
130
141
|
return indicatorPosition;
|
|
131
142
|
}
|
|
132
143
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","NULL_ELEMENT_OFFSET_RECT","exports","element","undefined","top","right","bottom","left","width","height","getElementOffsetRect","_offsetParent$getBoun","_offsetParent$scrollL","_offsetParent$scrollT","rect","getBoundingClientRect","offsetParent","offsetParentRect","offsetParentScrollX","scrollLeft","offsetParentScrollY","scrollTop","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","indicatorPosition","setIndicatorPosition","useState","intervalRef","useRef","measure","useEvent","elementOffsetRect","clearInterval","current","setElement","useResizeObserver","requestAnimationFrame","setInterval","useLayoutEffect"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The element the rect belongs to.\n\t */\n\telement: HTMLElement | undefined;\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\telement: undefined,\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParent = element.offsetParent;\n\tconst offsetParentRect =\n\t\toffsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;\n\tconst offsetParentScrollX = offsetParent?.scrollLeft ?? 0;\n\tconst offsetParentScrollY = offsetParent?.scrollTop ?? 0;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\telement,\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\t// 3. Adjust for the scroll position of the offset parent.\n\t\ttop:\n\t\t\t( rect.top - offsetParentRect?.top ) * scaleY + offsetParentScrollY,\n\t\tright:\n\t\t\t( offsetParentRect?.right - rect.right ) * scaleX -\n\t\t\toffsetParentScrollX,\n\t\tbottom:\n\t\t\t( offsetParentRect?.bottom - rect.bottom ) * scaleY -\n\t\t\toffsetParentScrollY,\n\t\tleft:\n\t\t\t( rect.left - offsetParentRect?.left ) * scaleX +\n\t\t\toffsetParentScrollX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * When no element is provided (`null` or `undefined`), the hook will return\n * a \"null\" rect, in which all values are `0` and `element` is `undefined`.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\tif ( targetElement ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tsetElement( targetElement );\n\t\tif ( ! targetElement ) {\n\t\t\tsetIndicatorPosition( NULL_ELEMENT_OFFSET_RECT );\n\t\t}\n\t}, [ setElement, targetElement ] );\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;AACO,MAAME,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACvCE,OAAO,EAAEC,SAAS;EAClBC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACT,CAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CACnCR,OAAoB,EACY;EAAA,IAAAS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EA,aAAa,EAAG;MACtBE,oBAAoB,CAAEhC,wBAAyB,CAAC;IACjD;EACD,CAAC,EAAE,CAAEyC,UAAU,EAAEX,aAAa,CAAG,CAAC;EAElC,OAAOC,iBAAiB;AACzB;;AAEA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","NULL_ELEMENT_OFFSET_RECT","exports","element","undefined","top","right","bottom","left","width","height","getElementOffsetRect","_offsetParent$getBoun","_offsetParent$scrollL","_offsetParent$scrollT","rect","getBoundingClientRect","offsetParent","offsetParentRect","offsetParentScrollX","scrollLeft","offsetParentScrollY","scrollTop","computedWidth","parseFloat","getComputedStyle","computedHeight","scaleX","scaleY","POLL_RATE","useTrackElementOffsetRect","targetElement","deps","indicatorPosition","setIndicatorPosition","useState","intervalRef","useRef","measure","useEvent","isConnected","elementOffsetRect","clearInterval","current","setElement","useResizeObserver","requestAnimationFrame","setInterval","useLayoutEffect"],"sources":["@wordpress/components/src/utils/element-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useRef, useState } from '@wordpress/element';\nimport { useEvent, useResizeObserver } from '@wordpress/compose';\n\n/**\n * The position and dimensions of an element, relative to its offset parent.\n */\nexport type ElementOffsetRect = {\n\t/**\n\t * The element the rect belongs to.\n\t */\n\telement: HTMLElement | undefined;\n\t/**\n\t * The distance from the top edge of the offset parent to the top edge of\n\t * the element.\n\t */\n\ttop: number;\n\t/**\n\t * The distance from the right edge of the offset parent to the right edge\n\t * of the element.\n\t */\n\tright: number;\n\t/**\n\t * The distance from the bottom edge of the offset parent to the bottom edge\n\t * of the element.\n\t */\n\tbottom: number;\n\t/**\n\t * The distance from the left edge of the offset parent to the left edge of\n\t * the element.\n\t */\n\tleft: number;\n\t/**\n\t * The width of the element.\n\t */\n\twidth: number;\n\t/**\n\t * The height of the element.\n\t */\n\theight: number;\n};\n\n/**\n * An `ElementOffsetRect` object with all values set to zero.\n */\nexport const NULL_ELEMENT_OFFSET_RECT = {\n\telement: undefined,\n\ttop: 0,\n\tright: 0,\n\tbottom: 0,\n\tleft: 0,\n\twidth: 0,\n\theight: 0,\n} satisfies ElementOffsetRect;\n\n/**\n * Returns the position and dimensions of an element, relative to its offset\n * parent, with subpixel precision. Values reflect the real measures before any\n * potential scaling distortions along the X and Y axes.\n *\n * Useful in contexts where plain `getBoundingClientRect` calls or `ResizeObserver`\n * entries are not suitable, such as when the element is transformed, and when\n * `element.offset<Top|Left|Width|Height>` methods are not precise enough.\n *\n * **Note:** in some contexts, like when the scale is 0, this method will fail\n * because it's impossible to calculate a scaling ratio. When that happens, it\n * will return `undefined`.\n */\nexport function getElementOffsetRect(\n\telement: HTMLElement\n): ElementOffsetRect | undefined {\n\t// Position and dimension values computed with `getBoundingClientRect` have\n\t// subpixel precision, but are affected by distortions since they represent\n\t// the \"real\" measures, or in other words, the actual final values as rendered\n\t// by the browser.\n\tconst rect = element.getBoundingClientRect();\n\tif ( rect.width === 0 || rect.height === 0 ) {\n\t\treturn;\n\t}\n\tconst offsetParent = element.offsetParent;\n\tconst offsetParentRect =\n\t\toffsetParent?.getBoundingClientRect() ?? NULL_ELEMENT_OFFSET_RECT;\n\tconst offsetParentScrollX = offsetParent?.scrollLeft ?? 0;\n\tconst offsetParentScrollY = offsetParent?.scrollTop ?? 0;\n\n\t// Computed widths and heights have subpixel precision, and are not affected\n\t// by distortions.\n\tconst computedWidth = parseFloat( getComputedStyle( element ).width );\n\tconst computedHeight = parseFloat( getComputedStyle( element ).height );\n\n\t// We can obtain the current scale factor for the element by comparing \"computed\"\n\t// dimensions with the \"real\" ones.\n\tconst scaleX = computedWidth / rect.width;\n\tconst scaleY = computedHeight / rect.height;\n\n\treturn {\n\t\telement,\n\t\t// To obtain the adjusted values for the position:\n\t\t// 1. Compute the element's position relative to the offset parent.\n\t\t// 2. Correct for the scale factor.\n\t\t// 3. Adjust for the scroll position of the offset parent.\n\t\ttop:\n\t\t\t( rect.top - offsetParentRect?.top ) * scaleY + offsetParentScrollY,\n\t\tright:\n\t\t\t( offsetParentRect?.right - rect.right ) * scaleX -\n\t\t\toffsetParentScrollX,\n\t\tbottom:\n\t\t\t( offsetParentRect?.bottom - rect.bottom ) * scaleY -\n\t\t\toffsetParentScrollY,\n\t\tleft:\n\t\t\t( rect.left - offsetParentRect?.left ) * scaleX +\n\t\t\toffsetParentScrollX,\n\t\t// Computed dimensions don't need any adjustments.\n\t\twidth: computedWidth,\n\t\theight: computedHeight,\n\t};\n}\n\nconst POLL_RATE = 100;\n\n/**\n * Tracks the position and dimensions of an element, relative to its offset\n * parent. The element can be changed dynamically.\n *\n * When no element is provided (`null` or `undefined`), the hook will return\n * a \"null\" rect, in which all values are `0` and `element` is `undefined`.\n *\n * **Note:** sometimes, the measurement will fail (see `getElementOffsetRect`'s\n * documentation for more details). When that happens, this hook will attempt\n * to measure again after a frame, and if that fails, it will poll every 100\n * milliseconds until it succeeds.\n */\nexport function useTrackElementOffsetRect(\n\ttargetElement: HTMLElement | undefined | null,\n\tdeps: unknown[] = []\n) {\n\tconst [ indicatorPosition, setIndicatorPosition ] =\n\t\tuseState< ElementOffsetRect >( NULL_ELEMENT_OFFSET_RECT );\n\tconst intervalRef = useRef< ReturnType< typeof setInterval > >();\n\n\tconst measure = useEvent( () => {\n\t\t// Check that the targetElement is still attached to the DOM, in case\n\t\t// it was removed since the last `measure` call.\n\t\tif ( targetElement && targetElement.isConnected ) {\n\t\t\tconst elementOffsetRect = getElementOffsetRect( targetElement );\n\t\t\tif ( elementOffsetRect ) {\n\t\t\t\tsetIndicatorPosition( elementOffsetRect );\n\t\t\t\tclearInterval( intervalRef.current );\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else {\n\t\t\tclearInterval( intervalRef.current );\n\t\t}\n\t\treturn false;\n\t} );\n\n\tconst setElement = useResizeObserver( () => {\n\t\tif ( ! measure() ) {\n\t\t\trequestAnimationFrame( () => {\n\t\t\t\tif ( ! measure() ) {\n\t\t\t\t\tintervalRef.current = setInterval( measure, POLL_RATE );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tsetElement( targetElement );\n\t\tif ( ! targetElement ) {\n\t\t\tsetIndicatorPosition( NULL_ELEMENT_OFFSET_RECT );\n\t\t}\n\t}, [ setElement, targetElement ] );\n\n\t// Escape hatch to force a remeasurement when something else changes rather\n\t// than the target elements' ref or size (for example, the target element\n\t// can change its position within the tablist).\n\tuseLayoutEffect( () => {\n\t\tmeasure();\n\t\t// `measure` is a stable function, so it's safe to omit it from the deps array.\n\t\t// deps can't be statically analyzed by ESLint\n\t}, deps );\n\n\treturn indicatorPosition;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;;AAoCA;AACA;AACA;AACO,MAAME,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACvCE,OAAO,EAAEC,SAAS;EAClBC,GAAG,EAAE,CAAC;EACNC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,IAAI,EAAE,CAAC;EACPC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE;AACT,CAA6B;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,oBAAoBA,CACnCR,OAAoB,EACY;EAAA,IAAAS,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EAChC;EACA;EACA;EACA;EACA,MAAMC,IAAI,GAAGZ,OAAO,CAACa,qBAAqB,CAAC,CAAC;EAC5C,IAAKD,IAAI,CAACN,KAAK,KAAK,CAAC,IAAIM,IAAI,CAACL,MAAM,KAAK,CAAC,EAAG;IAC5C;EACD;EACA,MAAMO,YAAY,GAAGd,OAAO,CAACc,YAAY;EACzC,MAAMC,gBAAgB,IAAAN,qBAAA,G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OC,iBAAiB;AACzB;;AAEA","ignoreList":[]}
|
|
@@ -50,10 +50,11 @@ container,
|
|
|
50
50
|
rect, {
|
|
51
51
|
prefix = 'subelement',
|
|
52
52
|
dataAttribute = `${prefix}-animated`,
|
|
53
|
-
transitionEndFilter = () => true
|
|
53
|
+
transitionEndFilter = () => true,
|
|
54
|
+
roundRect = false
|
|
54
55
|
} = {}) {
|
|
55
56
|
const setProperties = (0, _compose.useEvent)(() => {
|
|
56
|
-
Object.keys(rect).forEach(property => property !== 'element' && container?.style.setProperty(`--${prefix}-${property}`, String(rect[property])));
|
|
57
|
+
Object.keys(rect).forEach(property => property !== 'element' && container?.style.setProperty(`--${prefix}-${property}`, String(roundRect ? Math.floor(rect[property]) : rect[property])));
|
|
57
58
|
});
|
|
58
59
|
(0, _element.useLayoutEffect)(() => {
|
|
59
60
|
setProperties();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_useOnValueUpdate","useAnimatedOffsetRect","container","rect","prefix","dataAttribute","transitionEndFilter","setProperties","useEvent","Object","keys","forEach","property","style","setProperty","String","useLayoutEffect","useOnValueUpdate","element","previousValue","setAttribute","onTransitionEnd","event","removeAttribute","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/utils/hooks/use-animated-offset-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useLayoutEffect } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport type { ElementOffsetRect } from '../element-rect';\nimport { useOnValueUpdate } from './use-on-value-update';\n\n/**\n * A utility used to animate something in a container component based on the \"offset\n * rect\" (position relative to the container and size) of a subelement. For example,\n * this is useful to render an indicator for the selected option of a component, and\n * to animate it when the selected option changes.\n *\n * Takes in a container element and the up-to-date \"offset rect\" of the target\n * subelement, obtained with `useTrackElementOffsetRect`. Then it does the following:\n *\n * - Adds CSS variables with rect information to the container, so that the indicator\n * can be rendered and animated with them. These are kept up-to-date, enabling CSS\n * transitions on change.\n * - Sets an attribute (`data-subelement-animated` by default) when the tracked\n * element changes, so that the target (e.g. the indicator) can be animated to its\n * new size and position.\n * - Removes the attribute when the animation is done.\n *\n * The need for the attribute is due to the fact that the rect might update in\n * situations other than when the tracked element changes, e.g. the tracked element\n * might be resized. In such cases, there is no need to animate the indicator, and\n * the change in size or position of the indicator needs to be reflected immediately.\n */\nexport function useAnimatedOffsetRect(\n\t/**\n\t * The container element.\n\t */\n\tcontainer: HTMLElement | undefined,\n\t/**\n\t * The rect of the tracked element.\n\t */\n\trect: ElementOffsetRect,\n\t{\n\t\tprefix = 'subelement',\n\t\tdataAttribute = `${ prefix }-animated`,\n\t\ttransitionEndFilter = () => true,\n\t}: {\n\t\t/**\n\t\t * The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the\n\t\t * CSS variables will be `--selected-top`, `--selected-left`, etc.\n\t\t * @default 'subelement'\n\t\t */\n\t\tprefix?: string;\n\t\t/**\n\t\t * The name of the data attribute used to indicate that the animation is in\n\t\t * progress. The `data-` prefix is added automatically.\n\t\t *\n\t\t * For example, if `dataAttribute` is `indicator-animated`, the attribute will\n\t\t * be `data-indicator-animated`.\n\t\t * @default `${ prefix }-animated`\n\t\t */\n\t\tdataAttribute?: string;\n\t\t/**\n\t\t * A function that is called with the transition event and returns a boolean\n\t\t * indicating whether the animation should be stopped. The default is a function\n\t\t * that always returns `true`.\n\t\t *\n\t\t * For example, if the animated element is the `::before` pseudo-element, the\n\t\t * function can be written as `( event ) => event.pseudoElement === '::before'`.\n\t\t * @default () => true\n\t\t */\n\t\ttransitionEndFilter?: ( event: TransitionEvent ) => boolean;\n\t} = {}\n) {\n\tconst setProperties = useEvent( () => {\n\t\t( Object.keys( rect ) as Array< keyof typeof rect > ).forEach(\n\t\t\t( property ) =>\n\t\t\t\tproperty !== 'element' &&\n\t\t\t\tcontainer?.style.setProperty(\n\t\t\t\t\t`--${ prefix }-${ property }`,\n\t\t\t\t\tString( rect[ property ] )\n\t\t\t\t)\n\t\t);\n\t} );\n\tuseLayoutEffect( () => {\n\t\tsetProperties();\n\t}, [ rect, setProperties ] );\n\tuseOnValueUpdate( rect.element, ( { previousValue } ) => {\n\t\t// Only enable the animation when moving from one element to another.\n\t\tif ( rect.element && previousValue ) {\n\t\t\tcontainer?.setAttribute( `data-${ dataAttribute }`, '' );\n\t\t}\n\t} );\n\tuseLayoutEffect( () => {\n\t\tfunction onTransitionEnd( event: TransitionEvent ) {\n\t\t\tif ( transitionEndFilter( event ) ) {\n\t\t\t\tcontainer?.removeAttribute( `data-${ dataAttribute }` );\n\t\t\t}\n\t\t}\n\t\tcontainer?.addEventListener( 'transitionend', onTransitionEnd );\n\t\treturn () =>\n\t\t\tcontainer?.removeEventListener( 'transitionend', onTransitionEnd );\n\t}, [ dataAttribute, container, transitionEndFilter ] );\n}\n/* eslint-enable jsdoc/require-param */\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAXA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA;AACpC;AACD;AACA;AACCC,SAAkC;AAClC;AACD;AACA;AACCC,IAAuB,EACvB;EACCC,MAAM,GAAG,YAAY;EACrBC,aAAa,GAAG,GAAID,MAAM,WAAY;EACtCE,mBAAmB,GAAGA,CAAA,KAAM;
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_useOnValueUpdate","useAnimatedOffsetRect","container","rect","prefix","dataAttribute","transitionEndFilter","roundRect","setProperties","useEvent","Object","keys","forEach","property","style","setProperty","String","Math","floor","useLayoutEffect","useOnValueUpdate","element","previousValue","setAttribute","onTransitionEnd","event","removeAttribute","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/utils/hooks/use-animated-offset-rect.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param */\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useLayoutEffect } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport type { ElementOffsetRect } from '../element-rect';\nimport { useOnValueUpdate } from './use-on-value-update';\n\n/**\n * A utility used to animate something in a container component based on the \"offset\n * rect\" (position relative to the container and size) of a subelement. For example,\n * this is useful to render an indicator for the selected option of a component, and\n * to animate it when the selected option changes.\n *\n * Takes in a container element and the up-to-date \"offset rect\" of the target\n * subelement, obtained with `useTrackElementOffsetRect`. Then it does the following:\n *\n * - Adds CSS variables with rect information to the container, so that the indicator\n * can be rendered and animated with them. These are kept up-to-date, enabling CSS\n * transitions on change.\n * - Sets an attribute (`data-subelement-animated` by default) when the tracked\n * element changes, so that the target (e.g. the indicator) can be animated to its\n * new size and position.\n * - Removes the attribute when the animation is done.\n *\n * The need for the attribute is due to the fact that the rect might update in\n * situations other than when the tracked element changes, e.g. the tracked element\n * might be resized. In such cases, there is no need to animate the indicator, and\n * the change in size or position of the indicator needs to be reflected immediately.\n */\nexport function useAnimatedOffsetRect(\n\t/**\n\t * The container element.\n\t */\n\tcontainer: HTMLElement | undefined,\n\t/**\n\t * The rect of the tracked element.\n\t */\n\trect: ElementOffsetRect,\n\t{\n\t\tprefix = 'subelement',\n\t\tdataAttribute = `${ prefix }-animated`,\n\t\ttransitionEndFilter = () => true,\n\t\troundRect = false,\n\t}: {\n\t\t/**\n\t\t * The prefix used for the CSS variables, e.g. if `prefix` is `selected`, the\n\t\t * CSS variables will be `--selected-top`, `--selected-left`, etc.\n\t\t * @default 'subelement'\n\t\t */\n\t\tprefix?: string;\n\t\t/**\n\t\t * The name of the data attribute used to indicate that the animation is in\n\t\t * progress. The `data-` prefix is added automatically.\n\t\t *\n\t\t * For example, if `dataAttribute` is `indicator-animated`, the attribute will\n\t\t * be `data-indicator-animated`.\n\t\t * @default `${ prefix }-animated`\n\t\t */\n\t\tdataAttribute?: string;\n\t\t/**\n\t\t * A function that is called with the transition event and returns a boolean\n\t\t * indicating whether the animation should be stopped. The default is a function\n\t\t * that always returns `true`.\n\t\t *\n\t\t * For example, if the animated element is the `::before` pseudo-element, the\n\t\t * function can be written as `( event ) => event.pseudoElement === '::before'`.\n\t\t * @default () => true\n\t\t */\n\t\ttransitionEndFilter?: ( event: TransitionEvent ) => boolean;\n\t\t/**\n\t\t * Whether the `rect` measurements should be rounded down when applied\n\t\t * to the CSS variables. This can be useful to avoid blurry animations or\n\t\t * to avoid subpixel rendering issues.\n\t\t * @default false\n\t\t */\n\t\troundRect?: boolean;\n\t} = {}\n) {\n\tconst setProperties = useEvent( () => {\n\t\t( Object.keys( rect ) as Array< keyof typeof rect > ).forEach(\n\t\t\t( property ) =>\n\t\t\t\tproperty !== 'element' &&\n\t\t\t\tcontainer?.style.setProperty(\n\t\t\t\t\t`--${ prefix }-${ property }`,\n\t\t\t\t\tString(\n\t\t\t\t\t\troundRect\n\t\t\t\t\t\t\t? Math.floor( rect[ property ] )\n\t\t\t\t\t\t\t: rect[ property ]\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t);\n\t} );\n\tuseLayoutEffect( () => {\n\t\tsetProperties();\n\t}, [ rect, setProperties ] );\n\tuseOnValueUpdate( rect.element, ( { previousValue } ) => {\n\t\t// Only enable the animation when moving from one element to another.\n\t\tif ( rect.element && previousValue ) {\n\t\t\tcontainer?.setAttribute( `data-${ dataAttribute }`, '' );\n\t\t}\n\t} );\n\tuseLayoutEffect( () => {\n\t\tfunction onTransitionEnd( event: TransitionEvent ) {\n\t\t\tif ( transitionEndFilter( event ) ) {\n\t\t\t\tcontainer?.removeAttribute( `data-${ dataAttribute }` );\n\t\t\t}\n\t\t}\n\t\tcontainer?.addEventListener( 'transitionend', onTransitionEnd );\n\t\treturn () =>\n\t\t\tcontainer?.removeEventListener( 'transitionend', onTransitionEnd );\n\t}, [ dataAttribute, container,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B,aAAa,EAAG,EAAE,EAAG,CAAC;IACzD;EACD,CAAE,CAAC;EACH,IAAAc,wBAAe,EAAE,MAAM;IACtB,SAASK,eAAeA,CAAEC,KAAsB,EAAG;MAClD,IAAKnB,mBAAmB,CAAEmB,KAAM,CAAC,EAAG;QACnCvB,SAAS,EAAEwB,eAAe,CAAE,QAASrB,aAAa,EAAI,CAAC;MACxD;IACD;IACAH,SAAS,EAAEyB,gBAAgB,CAAE,eAAe,EAAEH,eAAgB,CAAC;IAC/D,OAAO,MACNtB,SAAS,EAAE0B,mBAAmB,CAAE,eAAe,EAAEJ,eAAgB,CAAC;EACpE,CAAC,EAAE,CAAEnB,aAAa,EAAEH,SAAS,EAAEI,mBAAmB,CAAG,CAAC;AACvD;AACA","ignoreList":[]}
|
|
@@ -25,11 +25,9 @@ function useUpdateEffect(effect, deps) {
|
|
|
25
25
|
}
|
|
26
26
|
mountedRef.current = true;
|
|
27
27
|
return undefined;
|
|
28
|
-
// Disable reasons:
|
|
29
28
|
// 1. This hook needs to pass a dep list that isn't an array literal
|
|
30
29
|
// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings
|
|
31
30
|
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
32
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
31
|
}, deps);
|
|
34
32
|
(0, _element.useEffect)(() => () => {
|
|
35
33
|
mountedRef.current = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mountedRef","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mountedRef.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmountedRef.current = true;\n\t\treturn undefined;\n\t\t//
|
|
1
|
+
{"version":3,"names":["_element","require","useUpdateEffect","effect","deps","mountedRef","useRef","useEffect","current","undefined","_default","exports","default"],"sources":["@wordpress/components/src/utils/hooks/use-update-effect.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\n/**\n * A `React.useEffect` that will not run on the first render.\n * Source:\n * https://github.com/ariakit/ariakit/blob/main/packages/ariakit-react-core/src/utils/hooks.ts\n *\n * @param {import('react').EffectCallback} effect\n * @param {import('react').DependencyList} deps\n */\nfunction useUpdateEffect( effect, deps ) {\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tif ( mountedRef.current ) {\n\t\t\treturn effect();\n\t\t}\n\t\tmountedRef.current = true;\n\t\treturn undefined;\n\t\t// 1. This hook needs to pass a dep list that isn't an array literal\n\t\t// 2. `effect` is missing from the array, and will need to be added carefully to avoid additional warnings\n\t\t// see https://github.com/WordPress/gutenberg/pull/41166\n\t}, deps );\n\n\tuseEffect(\n\t\t() => () => {\n\t\t\tmountedRef.current = false;\n\t\t},\n\t\t[]\n\t);\n}\n\nexport default useUpdateEffect;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACxC,MAAMC,UAAU,GAAG,IAAAC,eAAM,EAAE,KAAM,CAAC;EAClC,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAKF,UAAU,CAACG,OAAO,EAAG;MACzB,OAAOL,MAAM,CAAC,CAAC;IAChB;IACAE,UAAU,CAACG,OAAO,GAAG,IAAI;IACzB,OAAOC,SAAS;IAChB;IACA;IACA;EACD,CAAC,EAAEL,IAAK,CAAC;EAET,IAAAG,kBAAS,EACR,MAAM,MAAM;IACXF,UAAU,CAACG,OAAO,GAAG,KAAK;EAC3B,CAAC,EACD,EACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}
|
|
@@ -103,9 +103,8 @@ export function getAutoCompleterUI(autocompleter) {
|
|
|
103
103
|
useLayoutEffect(() => {
|
|
104
104
|
onChangeOptions(items);
|
|
105
105
|
announce(items);
|
|
106
|
-
//
|
|
106
|
+
// We want to avoid introducing unexpected side effects.
|
|
107
107
|
// See https://github.com/WordPress/gutenberg/pull/41820
|
|
108
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
108
|
}, [items]);
|
|
110
109
|
if (items.length === 0) {
|
|
111
110
|
return null;
|
|
@@ -154,9 +153,6 @@ function useOnClickOutside(ref, handler) {
|
|
|
154
153
|
document.removeEventListener('mousedown', listener);
|
|
155
154
|
document.removeEventListener('touchstart', listener);
|
|
156
155
|
};
|
|
157
|
-
|
|
158
|
-
// hook's dependency list.
|
|
159
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
160
|
-
}, [handler]);
|
|
156
|
+
}, [handler, ref]);
|
|
161
157
|
}
|
|
162
158
|
//# sourceMappingURL=autocompleter-ui.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useLayoutEffect","useRef","useEffect","useState","useAnchor","useDebounce","useMergeRefs","useRefEffect","speak","__","_n","sprintf","getDefaultUseItems","Button","Popover","VisuallyHidden","createPortal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ListBox","items","onSelect","selectedIndex","instanceId","listBoxId","className","Component","id","role","children","map","option","index","key","accessibleWhenDisabled","disabled","isDisabled","variant","undefined","onClick","label","getAutoCompleterUI","autocompleter","_autocompleter$useIte","useItems","AutocompleterUI","filterValue","onChangeOptions","onReset","reset","contentRef","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","debouncedSpeak","announce","options","length","focusOnMount","onClose","placement","anchor","ref","body","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseRef,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport { useAnchor } from '@wordpress/rich-text';\nimport { useDebounce, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { __, _n, sprintf } from '@wordpress/i18n';\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, KeyedOption, WPCompleter } from './types';\n\ntype ListBoxProps = {\n\titems: KeyedOption[];\n\tonSelect: ( option: KeyedOption ) => void;\n\tselectedIndex: number;\n\tinstanceId: number;\n\tlistBoxId: string | undefined;\n\tclassName?: string;\n\tComponent?: React.ElementType;\n};\n\nfunction ListBox( {\n\titems,\n\tonSelect,\n\tselectedIndex,\n\tinstanceId,\n\tlistBoxId,\n\tclassName,\n\tComponent = 'div',\n}: ListBoxProps ) {\n\treturn (\n\t\t<Component\n\t\t\tid={ listBoxId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"components-autocomplete__results\"\n\t\t>\n\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t<Button\n\t\t\t\t\tkey={ option.key }\n\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Unused, for backwards compatibility.\n\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvariant={ index === selectedIndex ? 'primary' : undefined }\n\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t>\n\t\t\t\t\t{ option.label }\n\t\t\t\t</Button>\n\t\t\t) ) }\n\t\t</Component>\n\t);\n}\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems =\n\t\tautocompleter.useItems ?? 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 ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\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 aria-* 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\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\t\tfunction announce( options: Array< KeyedOption > ) {\n\t\t\tif ( ! debouncedSpeak ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( !! options.length ) {\n\t\t\t\tif ( filterValue ) {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Initial %d result loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'Initial %d results loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t\t}\n\t\t}\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tannounce( 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\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\t\titems={ items }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t/>\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\n\t\t\t\t\t\t\titems={ items }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tComponent={ VisuallyHidden }\n\t\t\t\t\t\t/>,\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,eAAe,EACfC,MAAM,EACNC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,WAAW,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC5E,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAazC,SAASC,OAAOA,CAAE;EACjBC,KAAK;EACLC,QAAQ;EACRC,aAAa;EACbC,UAAU;EACVC,SAAS;EACTC,SAAS;EACTC,SAAS,GAAG;AACC,CAAC,EAAG;EACjB,oBACCZ,IAAA,CAACY,SAAS;IACTC,EAAE,EAAGH,SAAW;IAChBI,IAAI,EAAC,SAAS;IACdH,SAAS,EAAC,kCAAkC;IAAAI,QAAA,EAE1CT,KAAK,CAACU,GAAG,CAAE,CAAEC,MAAM,EAAEC,KAAK,kBAC3BlB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Q,CAACE,mBAAmB,CAAE,WAAW,EAAEN,QAAS,CAAC;MACrDI,QAAQ,CAACE,mBAAmB,CAAE,YAAY,EAAEN,QAAS,CAAC;IACvD,CAAC;IACD;IACA;IACA;EACD,CAAC,EAAE,CAAED,OAAO,CAAG,CAAC;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useLayoutEffect","useRef","useEffect","useState","useAnchor","useDebounce","useMergeRefs","useRefEffect","speak","__","_n","sprintf","getDefaultUseItems","Button","Popover","VisuallyHidden","createPortal","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ListBox","items","onSelect","selectedIndex","instanceId","listBoxId","className","Component","id","role","children","map","option","index","key","accessibleWhenDisabled","disabled","isDisabled","variant","undefined","onClick","label","getAutoCompleterUI","autocompleter","_autocompleter$useIte","useItems","AutocompleterUI","filterValue","onChangeOptions","onReset","reset","contentRef","popoverAnchor","editableContentElement","current","needsA11yCompat","setNeedsA11yCompat","popoverRef","popoverRefs","node","ownerDocument","useOnClickOutside","debouncedSpeak","announce","options","length","focusOnMount","onClose","placement","anchor","ref","body","handler","listener","event","contains","target","document","addEventListener","removeEventListener"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseRef,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\nimport { useAnchor } from '@wordpress/rich-text';\nimport { useDebounce, useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { __, _n, sprintf } from '@wordpress/i18n';\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, KeyedOption, WPCompleter } from './types';\n\ntype ListBoxProps = {\n\titems: KeyedOption[];\n\tonSelect: ( option: KeyedOption ) => void;\n\tselectedIndex: number;\n\tinstanceId: number;\n\tlistBoxId: string | undefined;\n\tclassName?: string;\n\tComponent?: React.ElementType;\n};\n\nfunction ListBox( {\n\titems,\n\tonSelect,\n\tselectedIndex,\n\tinstanceId,\n\tlistBoxId,\n\tclassName,\n\tComponent = 'div',\n}: ListBoxProps ) {\n\treturn (\n\t\t<Component\n\t\t\tid={ listBoxId }\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"components-autocomplete__results\"\n\t\t>\n\t\t\t{ items.map( ( option, index ) => (\n\t\t\t\t<Button\n\t\t\t\t\tkey={ option.key }\n\t\t\t\t\tid={ `components-autocomplete-item-${ instanceId }-${ option.key }` }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\taria-selected={ index === selectedIndex }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\tdisabled={ option.isDisabled }\n\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t'components-autocomplete__result',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Unused, for backwards compatibility.\n\t\t\t\t\t\t\t'is-selected': index === selectedIndex,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvariant={ index === selectedIndex ? 'primary' : undefined }\n\t\t\t\t\tonClick={ () => onSelect( option ) }\n\t\t\t\t>\n\t\t\t\t\t{ option.label }\n\t\t\t\t</Button>\n\t\t\t) ) }\n\t\t</Component>\n\t);\n}\n\nexport function getAutoCompleterUI( autocompleter: WPCompleter ) {\n\tconst useItems =\n\t\tautocompleter.useItems ?? 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 ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\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 aria-* 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\tconst debouncedSpeak = useDebounce( speak, 500 );\n\n\t\tfunction announce( options: Array< KeyedOption > ) {\n\t\t\tif ( ! debouncedSpeak ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( !! options.length ) {\n\t\t\t\tif ( filterValue ) {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tdebouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %d: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'Initial %d result loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'Initial %d results loaded. Type to filter all available results. Use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\toptions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdebouncedSpeak( __( 'No results.' ), 'assertive' );\n\t\t\t}\n\t\t}\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tannounce( items );\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t}, [ items ] );\n\n\t\tif ( items.length === 0 ) {\n\t\t\treturn null;\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\t\titems={ items }\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t/>\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\n\t\t\t\t\t\t\titems={ items }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tselectedIndex={ selectedIndex }\n\t\t\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t\t\t\tlistBoxId={ listBoxId }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tComponent={ VisuallyHidden }\n\t\t\t\t\t\t/>,\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}, [ handler, ref ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,eAAe,EACfC,MAAM,EACNC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,WAAW,EAAEC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC5E,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,WAAW;AAC9B,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,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C,EACnCE,OAAwC,EACvC;EACDzE,SAAS,CAAE,MAAM;IAChB,MAAM0E,QAAQ,GAAKC,KAA8B,IAAM;MACtD;MACA,IACC,CAAEJ,GAAG,CAAChB,OAAO,IACbgB,GAAG,CAAChB,OAAO,CAACqB,QAAQ,CAAED,KAAK,CAACE,MAAe,CAAC,EAC3C;QACD;MACD;MACAJ,OAAO,CAAEE,KAAM,CAAC;IACjB,CAAC;IACDG,QAAQ,CAACC,gBAAgB,CAAE,WAAW,EAAEL,QAAS,CAAC;IAClDI,QAAQ,CAACC,gBAAgB,CAAE,YAAY,EAAEL,QAAS,CAAC;IACnD,OAAO,MAAM;MACZI,QAAQ,CAACE,mBAAmB,CAAE,WAAW,EAAEN,QAAS,CAAC;MACrDI,QAAQ,CAACE,mBAAmB,CAAE,YAAY,EAAEN,QAAS,CAAC;IACvD,CAAC;EACF,CAAC,EAAE,CAAED,OAAO,EAAEF,GAAG,CAAG,CAAC;AACtB","ignoreList":[]}
|
|
@@ -56,9 +56,8 @@ export function getAutoCompleterUI(autocompleter) {
|
|
|
56
56
|
} else if (isVisible && text.length === 0) {
|
|
57
57
|
startAnimation(false);
|
|
58
58
|
}
|
|
59
|
-
//
|
|
59
|
+
// We want to avoid introducing unexpected side effects.
|
|
60
60
|
// See https://github.com/WordPress/gutenberg/pull/41820
|
|
61
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
62
61
|
}, [items, isVisible, text]);
|
|
63
62
|
const activeItemStyles = usePreferredColorSchemeStyle(styles['components-autocomplete__item-active'], styles['components-autocomplete__item-active-dark']);
|
|
64
63
|
const iconStyles = usePreferredColorSchemeStyle(styles['components-autocomplete__icon'], styles['components-autocomplete__icon-active-dark']);
|
|
@@ -79,9 +78,8 @@ export function getAutoCompleterUI(autocompleter) {
|
|
|
79
78
|
}
|
|
80
79
|
});
|
|
81
80
|
},
|
|
82
|
-
//
|
|
81
|
+
// We want to avoid introducing unexpected side effects.
|
|
83
82
|
// See https://github.com/WordPress/gutenberg/pull/41820
|
|
84
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
85
83
|
[isVisible]);
|
|
86
84
|
const contentStyles = {
|
|
87
85
|
transform: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Animated","StyleSheet","Text","TouchableOpacity","ScrollView","useLayoutEffect","useEffect","useRef","useState","useCallback","__","sprintf","usePreferredColorSchemeStyle","BackgroundView","getDefaultUseItems","styles","Icon","__unstableAutocompletionItemsFill","AutocompletionItemsFill","jsx","_jsx","jsxs","_jsxs","compose","stylesCompose","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","children","style","testID","ref","horizontal","contentContainerStyle","showsHorizontalScrollIndicator","keyboardShouldPersistTaps","accessibilityLabel","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","activeOpacity","onPress","title","size"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\nimport Icon from '../icon';\nimport { __unstableAutocompletionItemsFill as AutocompletionItemsFill } from '../mobile/autocompletion-items';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\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, isVisible, text ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\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\t[ isVisible ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\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\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\ttestID=\"autocompleter\"\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t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AAI,EAAGD,UAAY;sBACnBM,IAAI,EAAG,EAAI;sBACXrB,KAAK,EAAGc;oBAAW,CACnB;kBAAC,CACG,CAAC,eACPlE,IAAA,CAAClB,IAAI;oBAACsE,KAAK,EAAGa,SAAW;oBAAAd,QAAA,EACtBU,MAAM,EAAEhD,KAAK,EAAE2D;kBAAK,CACjB,CAAC;gBAAA,GAvBDV,KAwBW,CAAC;cAErB,CAAE;YAAC,CACQ;UAAC,CACE;QAAC,CACH;MAAC,CACX;IAAC,CACiB,CAAC;EAE5B;EAEA,OAAOtD,eAAe;AACvB;AAEA,eAAeH,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["View","Animated","StyleSheet","Text","TouchableOpacity","ScrollView","useLayoutEffect","useEffect","useRef","useState","useCallback","__","sprintf","usePreferredColorSchemeStyle","BackgroundView","getDefaultUseItems","styles","Icon","__unstableAutocompletionItemsFill","AutocompletionItemsFill","jsx","_jsx","jsxs","_jsxs","compose","stylesCompose","getAutoCompleterUI","autocompleter","useItems","AutocompleterUI","filterValue","selectedIndex","onChangeOptions","onSelect","value","reset","items","filteredItems","filter","item","isDisabled","scrollViewRef","animationValue","Value","current","isVisible","setIsVisible","text","length","scrollTo","x","animated","startAnimation","activeItemStyles","iconStyles","activeIconStyles","textStyles","activeTextStyles","show","timing","toValue","duration","useNativeDriver","start","finished","contentStyles","transform","translateY","interpolate","inputRange","outputRange","height","children","style","testID","ref","horizontal","contentContainerStyle","showsHorizontalScrollIndicator","keyboardShouldPersistTaps","accessibilityLabel","map","option","index","isActive","itemStyle","textStyle","iconStyle","iconSource","icon","src","activeOpacity","onPress","title","size"],"sources":["@wordpress/components/src/autocomplete/autocompleter-ui.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tView,\n\tAnimated,\n\tStyleSheet,\n\tText,\n\tTouchableOpacity,\n\tScrollView,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseLayoutEffect,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tuseCallback,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BackgroundView from './background-view';\nimport getDefaultUseItems from './get-default-use-items';\nimport styles from './style.scss';\nimport Icon from '../icon';\nimport { __unstableAutocompletionItemsFill as AutocompletionItemsFill } from '../mobile/autocompletion-items';\n\nconst { compose: stylesCompose } = StyleSheet;\n\nexport function getAutoCompleterUI( autocompleter ) {\n\tconst useItems = autocompleter.useItems\n\t\t? autocompleter.useItems\n\t\t: getDefaultUseItems( autocompleter );\n\n\tfunction AutocompleterUI( {\n\t\tfilterValue,\n\t\tselectedIndex,\n\t\tonChangeOptions,\n\t\tonSelect,\n\t\tvalue,\n\t\treset,\n\t} ) {\n\t\tconst [ items ] = useItems( filterValue );\n\t\tconst filteredItems = items.filter( ( item ) => ! item.isDisabled );\n\t\tconst scrollViewRef = useRef();\n\t\tconst animationValue = useRef( new Animated.Value( 0 ) ).current;\n\t\tconst [ isVisible, setIsVisible ] = useState( false );\n\t\tconst { text } = value;\n\n\t\tuseEffect( () => {\n\t\t\tif ( ! isVisible && text.length > 0 ) {\n\t\t\t\tsetIsVisible( true );\n\t\t\t}\n\t\t}, [ isVisible, text ] );\n\n\t\tuseLayoutEffect( () => {\n\t\t\tonChangeOptions( items );\n\t\t\tscrollViewRef.current?.scrollTo( { x: 0, animated: false } );\n\n\t\t\tif ( isVisible && text.length > 0 ) {\n\t\t\t\tstartAnimation( true );\n\t\t\t} else if ( isVisible && text.length === 0 ) {\n\t\t\t\tstartAnimation( false );\n\t\t\t}\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t}, [ items, isVisible, text ] );\n\n\t\tconst activeItemStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__item-active' ],\n\t\t\tstyles[ 'components-autocomplete__item-active-dark' ]\n\t\t);\n\n\t\tconst iconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst activeIconStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__icon-active ' ],\n\t\t\tstyles[ 'components-autocomplete__icon-active-dark' ]\n\t\t);\n\n\t\tconst textStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text' ],\n\t\t\tstyles[ 'components-autocomplete__text-dark' ]\n\t\t);\n\n\t\tconst activeTextStyles = usePreferredColorSchemeStyle(\n\t\t\tstyles[ 'components-autocomplete__text-active' ],\n\t\t\tstyles[ 'components-autocomplete__text-active-dark' ]\n\t\t);\n\n\t\tconst startAnimation = useCallback(\n\t\t\t( show ) => {\n\t\t\t\tAnimated.timing( animationValue, {\n\t\t\t\t\ttoValue: show ? 1 : 0,\n\t\t\t\t\tduration: show ? 200 : 100,\n\t\t\t\t\tuseNativeDriver: true,\n\t\t\t\t} ).start( ( { finished } ) => {\n\t\t\t\t\tif ( finished && ! show && isVisible ) {\n\t\t\t\t\t\tsetIsVisible( false );\n\t\t\t\t\t\treset();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t// We want to avoid introducing unexpected side effects.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/41820\n\t\t\t[ isVisible ]\n\t\t);\n\n\t\tconst contentStyles = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: animationValue.interpolate( {\n\t\t\t\t\t\tinputRange: [ 0, 1 ],\n\t\t\t\t\t\toutputRange: [\n\t\t\t\t\t\t\tstyles[ 'components-autocomplete' ].height,\n\t\t\t\t\t\t\t0,\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\n\t\tif ( ! filteredItems.length > 0 || ! isVisible ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<AutocompletionItemsFill>\n\t\t\t\t<View style={ styles[ 'components-autocomplete' ] }>\n\t\t\t\t\t<Animated.View style={ contentStyles }>\n\t\t\t\t\t\t<BackgroundView>\n\t\t\t\t\t\t\t<ScrollView\n\t\t\t\t\t\t\t\ttestID=\"autocompleter\"\n\t\t\t\t\t\t\t\tref={ scrollViewRef }\n\t\t\t\t\t\t\t\thorizontal\n\t\t\t\t\t\t\t\tcontentContainerStyle={\n\t\t\t\t\t\t\t\t\tstyles[ 'components-autocomplete__content' ]\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\t\t\t\taccessibilityLabel={\n\t\t\t\t\t\t\t\t\t// translators: Slash inserter autocomplete results\n\t\t\t\t\t\t\t\t\t__( 'Slash inserter results' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ filteredItems.map( ( option, index ) => {\n\t\t\t\t\t\t\t\t\tconst isActive = index === selectedIndex;\n\t\t\t\t\t\t\t\t\tconst itemStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__item'\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tisActive && activeItemStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst textStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ttextStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeTextStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconStyle = stylesCompose(\n\t\t\t\t\t\t\t\t\t\ticonStyles,\n\t\t\t\t\t\t\t\t\t\tisActive && activeIconStyles\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tconst iconSource =\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon?.src ||\n\t\t\t\t\t\t\t\t\t\toption?.value?.icon;\n\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<TouchableOpacity\n\t\t\t\t\t\t\t\t\t\t\tactiveOpacity={ 0.5 }\n\t\t\t\t\t\t\t\t\t\t\tstyle={ itemStyle }\n\t\t\t\t\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\t\t\t\t\tonPress={ () => onSelect( option ) }\n\t\t\t\t\t\t\t\t\t\t\taccessibilityLabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Block name e.g. \"Image block\"\n\t\t\t\t\t\t\t\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\t\t\t\t\t\t\t\toption?.value?.title\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyles[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'components-autocomplete__icon'\n\t\t\t\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ iconSource }\n\t\t\t\t\t\t\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\t\tstyle={ iconStyle }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</View>\n\t\t\t\t\t\t\t\t\t\t\t<Text style={ textStyle }>\n\t\t\t\t\t\t\t\t\t\t\t\t{ option?.value?.title }\n\t\t\t\t\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t\t\t\t</TouchableOpacity>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t</ScrollView>\n\t\t\t\t\t\t</BackgroundView>\n\t\t\t\t\t</Animated.View>\n\t\t\t\t</View>\n\t\t\t</AutocompletionItemsFill>\n\t\t);\n\t}\n\n\treturn AutocompleterUI;\n}\n\nexport default getAutoCompleterUI;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,IAAI,EACJC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,QACJ,cAAc;;AAErB;AACA;AACA;AACA,SACCC,eAAe,EACfC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,WAAW,QACL,oBAAoB;AAC3B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,4BAA4B,QAAQ,oBAAoB;;AAEjE;AACA;AACA;AACA,OAAOC,cAAc,MAAM,mBAAmB;AAC9C,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,MAAM,MAAM,cAAc;AACjC,OAAOC,IAAI,MAAM,SAAS;AAC1B,SAASC,iCAAiC,IAAIC,uBAAuB,QAAQ,gCAAgC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE9G,MAAM;EAAEC,OAAO,EAAEC;AAAc,CAAC,GAAGvB,UAAU;AAE7C,OAAO,SAASwB,kBAAkBA,CAAEC,aAAa,EAAG;EACnD,MAAMC,QAAQ,GAAGD,aAAa,CAACC,QAAQ,GACpCD,aAAa,CAACC,QAAQ,GACtBb,kBAAkB,CAAEY,aAAc,CAAC;EAEtC,SAASE,eAAeA,CAAE;IACzBC,WAAW;IACXC,aAAa;IACbC,eAAe;IACfC,QAAQ;IACRC,KAAK;IACLC;EACD,CAAC,EAAG;IACH,MAAM,CAAEC,KAAK,CAAE,GAAGR,QAAQ,CAAEE,WAAY,CAAC;IACzC,MAAMO,aAAa,GAAGD,KAAK,CAACE,MAAM,CAAIC,IAAI,IAAM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HnD,IAAA,CAACrB,IAAI;oBACJyE,KAAK,EACJzD,MAAM,CACL,+BAA+B,CAEhC;oBAAAwD,QAAA,eAEDnD,IAAA,CAACJ,IAAI;sBACJwE,IAAI,EAAGD,UAAY;sBACnBM,IAAI,EAAG,EAAI;sBACXrB,KAAK,EAAGc;oBAAW,CACnB;kBAAC,CACG,CAAC,eACPlE,IAAA,CAAClB,IAAI;oBAACsE,KAAK,EAAGa,SAAW;oBAAAd,QAAA,EACtBU,MAAM,EAAEhD,KAAK,EAAE2D;kBAAK,CACjB,CAAC;gBAAA,GAvBDV,KAwBW,CAAC;cAErB,CAAE;YAAC,CACQ;UAAC,CACE;QAAC,CACH;MAAC,CACX;IAAC,CACiB,CAAC;EAE5B;EAEA,OAAOtD,eAAe;AACvB;AAEA,eAAeH,kBAAkB","ignoreList":[]}
|
|
@@ -64,7 +64,7 @@ export function useAutocomplete({
|
|
|
64
64
|
const [filterValue, setFilterValue] = useState('');
|
|
65
65
|
const [autocompleter, setAutocompleter] = useState(null);
|
|
66
66
|
const [AutocompleterUI, setAutocompleterUI] = useState(null);
|
|
67
|
-
const
|
|
67
|
+
const backspacingRef = useRef(false);
|
|
68
68
|
function insertCompletion(replacement) {
|
|
69
69
|
if (autocompleter === null) {
|
|
70
70
|
return;
|
|
@@ -124,7 +124,7 @@ export function useAutocomplete({
|
|
|
124
124
|
setFilteredOptions(options);
|
|
125
125
|
}
|
|
126
126
|
function handleKeyDown(event) {
|
|
127
|
-
|
|
127
|
+
backspacingRef.current = event.key === 'Backspace';
|
|
128
128
|
if (!autocompleter) {
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
@@ -239,7 +239,7 @@ export function useAutocomplete({
|
|
|
239
239
|
//
|
|
240
240
|
// Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but
|
|
241
241
|
// if the user presses backspace here, it will show the completion popup again.
|
|
242
|
-
const matchingWhileBackspacing =
|
|
242
|
+
const matchingWhileBackspacing = backspacingRef.current && wordsFromTrigger.length <= 3;
|
|
243
243
|
if (mismatch && !(matchingWhileBackspacing || hasOneTriggerWord)) {
|
|
244
244
|
if (autocompleter) {
|
|
245
245
|
reset();
|
|
@@ -272,9 +272,8 @@ export function useAutocomplete({
|
|
|
272
272
|
setAutocompleter(completer);
|
|
273
273
|
setAutocompleterUI(() => completer !== autocompleter ? getAutoCompleterUI(completer) : AutocompleterUI);
|
|
274
274
|
setFilterValue(query === null ? '' : query);
|
|
275
|
-
//
|
|
275
|
+
// We want to avoid introducing unexpected side effects.
|
|
276
276
|
// See https://github.com/WordPress/gutenberg/pull/41820
|
|
277
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
278
277
|
}, [textContent]);
|
|
279
278
|
const {
|
|
280
279
|
key: selectedKey = ''
|