@wordpress/components 19.14.0 → 19.15.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 +51 -12
- package/build/autocomplete/get-default-use-items.js +5 -1
- package/build/autocomplete/get-default-use-items.js.map +1 -1
- package/build/autocomplete/index.js +5 -1
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/box-control/index.js +1 -1
- package/build/box-control/index.js.map +1 -1
- package/build/color-picker/hex-input.js +5 -4
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/index.native.js +35 -34
- package/build/color-picker/index.native.js.map +1 -1
- package/build/color-picker/input-with-slider.js +3 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/styles.js +31 -43
- package/build/color-picker/styles.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js +22 -31
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/combobox-control/index.js +14 -6
- package/build/combobox-control/index.js.map +1 -1
- package/build/combobox-control/styles.js +39 -0
- package/build/combobox-control/styles.js.map +1 -0
- package/build/dropdown-menu/index.js +5 -5
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu/index.native.js +5 -5
- package/build/dropdown-menu/index.native.js.map +1 -1
- package/build/elevation/hook.js +5 -5
- package/build/elevation/hook.js.map +1 -1
- package/build/external-link/index.js +1 -3
- package/build/external-link/index.js.map +1 -1
- package/build/focal-point-picker/grid.js +2 -7
- package/build/focal-point-picker/grid.js.map +1 -1
- package/build/focal-point-picker/index.native.js +8 -8
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/focal-point-picker/tooltip/index.native.js +11 -12
- package/build/focal-point-picker/tooltip/index.native.js.map +1 -1
- package/build/form-token-field/index.js +22 -7
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/styles.js +40 -0
- package/build/form-token-field/styles.js.map +1 -0
- package/build/form-token-field/suggestions-list.js +2 -7
- package/build/form-token-field/suggestions-list.js.map +1 -1
- package/build/grid/component.js +7 -8
- package/build/grid/component.js.map +1 -1
- package/build/grid/hook.js +1 -5
- package/build/grid/hook.js.map +1 -1
- package/build/grid/index.js.map +1 -1
- package/build/grid/utils.js +4 -7
- package/build/grid/utils.js.map +1 -1
- package/build/h-stack/component.js +5 -9
- package/build/h-stack/component.js.map +1 -1
- package/build/h-stack/hook.js +8 -10
- package/build/h-stack/hook.js.map +1 -1
- package/build/h-stack/index.js.map +1 -1
- package/build/h-stack/utils.js +7 -18
- package/build/h-stack/utils.js.map +1 -1
- package/build/icon/index.js.map +1 -1
- package/build/menu-item/index.js +1 -3
- package/build/menu-item/index.js.map +1 -1
- package/build/mobile/focal-point-settings-panel/index.native.js +1 -1
- package/build/mobile/focal-point-settings-panel/index.native.js.map +1 -1
- package/build/mobile/image/index.native.js +4 -2
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/modal/index.js +17 -3
- package/build/modal/index.js.map +1 -1
- package/build/navigation/index.js +4 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/item/base.js +3 -0
- package/build/navigation/item/base.js.map +1 -1
- package/build/popover/index.js +4 -4
- package/build/popover/index.js.map +1 -1
- package/build/range-control/index.js +54 -40
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/input-range.js +5 -7
- package/build/range-control/input-range.js.map +1 -1
- package/build/range-control/mark.js +5 -7
- package/build/range-control/mark.js.map +1 -1
- package/build/range-control/rail.js +10 -16
- package/build/range-control/rail.js.map +1 -1
- package/build/range-control/styles/range-control-styles.js +62 -62
- package/build/range-control/styles/range-control-styles.js.map +1 -1
- package/build/range-control/tooltip.js +5 -7
- package/build/range-control/tooltip.js.map +1 -1
- package/build/range-control/types.js +6 -0
- package/build/range-control/types.js.map +1 -0
- package/build/range-control/utils.js +22 -29
- package/build/range-control/utils.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +2 -7
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/scrollable/component.js +7 -8
- package/build/scrollable/component.js.map +1 -1
- package/build/scrollable/hook.js +0 -8
- package/build/scrollable/hook.js.map +1 -1
- package/build/scrollable/index.js.map +1 -1
- package/build/scrollable/styles.js +7 -7
- package/build/scrollable/styles.js.map +1 -1
- package/build/shortcut/index.js +2 -8
- package/build/shortcut/index.js.map +1 -1
- package/build/slot-fill/index.native.js +6 -8
- package/build/slot-fill/index.native.js.map +1 -1
- package/build/slot-fill/provider.js +4 -8
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +4 -8
- package/build/slot-fill/slot.js.map +1 -1
- package/build/spacer/component.js.map +1 -1
- package/build/spacer/hook.js +2 -2
- package/build/spacer/hook.js.map +1 -1
- package/build/spacer/index.js.map +1 -1
- package/build/text-highlight/index.js +22 -5
- package/build/text-highlight/index.js.map +1 -1
- package/build/text-highlight/types.js +6 -0
- package/build/text-highlight/types.js.map +1 -0
- package/build/tip/index.js +5 -11
- package/build/tip/index.js.map +1 -1
- package/build/tip/types.js +6 -0
- package/build/tip/types.js.map +1 -0
- package/build/toolbar-group/index.js +3 -3
- package/build/toolbar-group/index.js.map +1 -1
- package/build/tree-select/index.js +2 -2
- package/build/tree-select/index.js.map +1 -1
- package/build/ui/utils/get-valid-children.js.map +1 -1
- package/build/visually-hidden/component.js +12 -13
- package/build/visually-hidden/component.js.map +1 -1
- package/build/visually-hidden/index.js.map +1 -1
- package/build/visually-hidden/styles.js +3 -1
- package/build/visually-hidden/styles.js.map +1 -1
- package/build/visually-hidden/types.js +6 -0
- package/build/visually-hidden/types.js.map +1 -0
- package/build-module/autocomplete/get-default-use-items.js +3 -2
- package/build-module/autocomplete/get-default-use-items.js.map +1 -1
- package/build-module/autocomplete/index.js +3 -2
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/box-control/index.js +1 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/color-picker/hex-input.js +4 -3
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/index.native.js +36 -35
- package/build-module/color-picker/index.native.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +3 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/styles.js +23 -40
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js +22 -31
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/combobox-control/index.js +14 -7
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/combobox-control/styles.js +27 -0
- package/build-module/combobox-control/styles.js.map +1 -0
- package/build-module/dropdown-menu/index.js +5 -4
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu/index.native.js +5 -4
- package/build-module/dropdown-menu/index.native.js.map +1 -1
- package/build-module/elevation/hook.js +5 -5
- package/build-module/elevation/hook.js.map +1 -1
- package/build-module/external-link/index.js +1 -2
- package/build-module/external-link/index.js.map +1 -1
- package/build-module/focal-point-picker/grid.js +2 -6
- package/build-module/focal-point-picker/grid.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +8 -8
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/focal-point-picker/tooltip/index.native.js +11 -12
- package/build-module/focal-point-picker/tooltip/index.native.js.map +1 -1
- package/build-module/form-token-field/index.js +20 -6
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/styles.js +28 -0
- package/build-module/form-token-field/styles.js.map +1 -0
- package/build-module/form-token-field/suggestions-list.js +2 -7
- package/build-module/form-token-field/suggestions-list.js.map +1 -1
- package/build-module/grid/component.js +7 -8
- package/build-module/grid/component.js.map +1 -1
- package/build-module/grid/hook.js +1 -5
- package/build-module/grid/hook.js.map +1 -1
- package/build-module/grid/index.js.map +1 -1
- package/build-module/grid/utils.js +3 -8
- package/build-module/grid/utils.js.map +1 -1
- package/build-module/h-stack/component.js +3 -7
- package/build-module/h-stack/component.js.map +1 -1
- package/build-module/h-stack/hook.js +10 -12
- package/build-module/h-stack/hook.js.map +1 -1
- package/build-module/h-stack/index.js.map +1 -1
- package/build-module/h-stack/utils.js +7 -19
- package/build-module/h-stack/utils.js.map +1 -1
- package/build-module/icon/index.js.map +1 -1
- package/build-module/menu-item/index.js +1 -2
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/mobile/focal-point-settings-panel/index.native.js +2 -2
- package/build-module/mobile/focal-point-settings-panel/index.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +3 -2
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/modal/index.js +19 -5
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigation/index.js +4 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/item/base.js +3 -0
- package/build-module/navigation/item/base.js.map +1 -1
- package/build-module/popover/index.js +4 -4
- package/build-module/popover/index.js.map +1 -1
- package/build-module/range-control/index.js +54 -40
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/input-range.js +5 -6
- package/build-module/range-control/input-range.js.map +1 -1
- package/build-module/range-control/mark.js +5 -6
- package/build-module/range-control/mark.js.map +1 -1
- package/build-module/range-control/rail.js +10 -15
- package/build-module/range-control/rail.js.map +1 -1
- package/build-module/range-control/styles/range-control-styles.js +62 -64
- package/build-module/range-control/styles/range-control-styles.js.map +1 -1
- package/build-module/range-control/tooltip.js +5 -6
- package/build-module/range-control/tooltip.js.map +1 -1
- package/build-module/range-control/types.js +2 -0
- package/build-module/range-control/types.js.map +1 -0
- package/build-module/range-control/utils.js +22 -29
- package/build-module/range-control/utils.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +2 -6
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/scrollable/component.js +7 -8
- package/build-module/scrollable/component.js.map +1 -1
- package/build-module/scrollable/hook.js +0 -8
- package/build-module/scrollable/hook.js.map +1 -1
- package/build-module/scrollable/index.js.map +1 -1
- package/build-module/scrollable/styles.js +7 -7
- package/build-module/scrollable/styles.js.map +1 -1
- package/build-module/shortcut/index.js +2 -7
- package/build-module/shortcut/index.js.map +1 -1
- package/build-module/slot-fill/index.native.js +6 -7
- package/build-module/slot-fill/index.native.js.map +1 -1
- package/build-module/slot-fill/provider.js +4 -7
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +4 -7
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/spacer/component.js.map +1 -1
- package/build-module/spacer/hook.js +2 -2
- package/build-module/spacer/hook.js.map +1 -1
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/text-highlight/index.js +23 -6
- package/build-module/text-highlight/index.js.map +1 -1
- package/build-module/text-highlight/types.js +2 -0
- package/build-module/text-highlight/types.js.map +1 -0
- package/build-module/tip/index.js +6 -10
- package/build-module/tip/index.js.map +1 -1
- package/build-module/tip/types.js +2 -0
- package/build-module/tip/types.js.map +1 -0
- package/build-module/toolbar-group/index.js +3 -2
- package/build-module/toolbar-group/index.js.map +1 -1
- package/build-module/tree-select/index.js +3 -3
- package/build-module/tree-select/index.js.map +1 -1
- package/build-module/ui/utils/get-valid-children.js.map +1 -1
- package/build-module/visually-hidden/component.js +12 -13
- package/build-module/visually-hidden/component.js.map +1 -1
- package/build-module/visually-hidden/index.js.map +1 -1
- package/build-module/visually-hidden/styles.js +3 -1
- package/build-module/visually-hidden/styles.js.map +1 -1
- package/build-module/visually-hidden/types.js +2 -0
- package/build-module/visually-hidden/types.js.map +1 -0
- package/build-style/style-rtl.css +13 -19
- package/build-style/style.css +13 -19
- package/build-types/border-control/border-control/hook.d.ts +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +30 -31
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/external-link/index.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/styles.d.ts +14 -0
- package/build-types/form-token-field/styles.d.ts.map +1 -0
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +7 -0
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/grid/component.d.ts +3 -3
- package/build-types/grid/component.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +5 -2
- package/build-types/grid/hook.d.ts.map +1 -1
- package/build-types/grid/index.d.ts +2 -2
- package/build-types/grid/index.d.ts.map +1 -1
- package/build-types/grid/stories/index.d.ts +9 -0
- package/build-types/grid/stories/index.d.ts.map +1 -0
- package/build-types/grid/test/grid.d.ts +2 -0
- package/build-types/grid/test/grid.d.ts.map +1 -0
- package/build-types/grid/types.d.ts +16 -15
- package/build-types/grid/types.d.ts.map +1 -1
- package/build-types/grid/utils.d.ts +50 -69
- package/build-types/grid/utils.d.ts.map +1 -1
- package/build-types/h-stack/component.d.ts +3 -2
- package/build-types/h-stack/component.d.ts.map +1 -1
- package/build-types/h-stack/hook.d.ts +5 -3
- package/build-types/h-stack/hook.d.ts.map +1 -1
- package/build-types/h-stack/index.d.ts +2 -2
- package/build-types/h-stack/index.d.ts.map +1 -1
- package/build-types/h-stack/stories/index.d.ts +9 -0
- package/build-types/h-stack/stories/index.d.ts.map +1 -0
- package/build-types/h-stack/test/index.d.ts +2 -0
- package/build-types/h-stack/test/index.d.ts.map +1 -0
- package/build-types/h-stack/utils.d.ts +8 -4
- package/build-types/h-stack/utils.d.ts.map +1 -1
- package/build-types/icon/index.d.ts +1 -1
- package/build-types/icon/index.d.ts.map +1 -1
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +54 -29
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/input-range.d.ts +7 -10
- package/build-types/range-control/input-range.d.ts.map +1 -1
- package/build-types/range-control/mark.d.ts +4 -7
- package/build-types/range-control/mark.d.ts.map +1 -1
- package/build-types/range-control/rail.d.ts +4 -9
- package/build-types/range-control/rail.d.ts.map +1 -1
- package/build-types/range-control/stories/index.d.ts +48 -0
- package/build-types/range-control/stories/index.d.ts.map +1 -0
- package/build-types/range-control/styles/range-control-styles.d.ts +32 -40
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/range-control/test/index.d.ts +2 -0
- package/build-types/range-control/test/index.d.ts.map +1 -0
- package/build-types/range-control/tooltip.d.ts +4 -11
- package/build-types/range-control/tooltip.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +302 -0
- package/build-types/range-control/types.d.ts.map +1 -0
- package/build-types/range-control/utils.d.ts +15 -33
- package/build-types/range-control/utils.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/scrollable/component.d.ts +3 -3
- package/build-types/scrollable/component.d.ts.map +1 -1
- package/build-types/scrollable/hook.d.ts +5 -2
- package/build-types/scrollable/hook.d.ts.map +1 -1
- package/build-types/scrollable/index.d.ts +2 -2
- package/build-types/scrollable/index.d.ts.map +1 -1
- package/build-types/scrollable/stories/index.d.ts +9 -0
- package/build-types/scrollable/stories/index.d.ts.map +1 -0
- package/build-types/scrollable/styles.d.ts +7 -7
- package/build-types/scrollable/styles.d.ts.map +1 -1
- package/build-types/scrollable/test/index.d.ts +2 -0
- package/build-types/scrollable/test/index.d.ts.map +1 -0
- package/build-types/scrollable/types.d.ts +9 -6
- package/build-types/scrollable/types.d.ts.map +1 -1
- package/build-types/shortcut/index.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/spacer/component.d.ts +2 -2
- package/build-types/spacer/component.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +2 -2
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/spacer/index.d.ts +1 -1
- package/build-types/spacer/index.d.ts.map +1 -1
- package/build-types/spacer/test/index.d.ts +2 -0
- package/build-types/spacer/test/index.d.ts.map +1 -0
- package/build-types/spacer/types.d.ts +41 -29
- package/build-types/spacer/types.d.ts.map +1 -1
- package/build-types/text-highlight/index.d.ts +23 -0
- package/build-types/text-highlight/index.d.ts.map +1 -0
- package/build-types/text-highlight/stories/index.d.ts +12 -0
- package/build-types/text-highlight/stories/index.d.ts.map +1 -0
- package/build-types/text-highlight/test/index.d.ts +2 -0
- package/build-types/text-highlight/test/index.d.ts.map +1 -0
- package/build-types/text-highlight/types.d.ts +17 -0
- package/build-types/text-highlight/types.d.ts.map +1 -0
- package/build-types/tip/index.d.ts +5 -14
- package/build-types/tip/index.d.ts.map +1 -1
- package/build-types/tip/stories/index.d.ts +12 -0
- package/build-types/tip/stories/index.d.ts.map +1 -0
- package/build-types/tip/types.d.ts +11 -0
- package/build-types/tip/types.d.ts.map +1 -0
- package/build-types/ui/form-group/form-group.d.ts +1 -1
- package/build-types/ui/form-group/types.d.ts +1 -1
- package/build-types/ui/form-group/types.d.ts.map +1 -1
- package/build-types/ui/form-group/use-form-group.d.ts +3 -3
- package/build-types/ui/utils/get-valid-children.d.ts +2 -2
- package/build-types/ui/utils/get-valid-children.d.ts.map +1 -1
- package/build-types/visually-hidden/component.d.ts +8 -10
- package/build-types/visually-hidden/component.d.ts.map +1 -1
- package/build-types/visually-hidden/index.d.ts +1 -1
- package/build-types/visually-hidden/index.d.ts.map +1 -1
- package/build-types/visually-hidden/stories/index.d.ts +14 -0
- package/build-types/visually-hidden/stories/index.d.ts.map +1 -0
- package/build-types/visually-hidden/styles.d.ts +5 -2
- package/build-types/visually-hidden/styles.d.ts.map +1 -1
- package/build-types/visually-hidden/test/index.d.ts +2 -0
- package/build-types/visually-hidden/test/index.d.ts.map +1 -0
- package/build-types/visually-hidden/types.d.ts +11 -0
- package/build-types/visually-hidden/types.d.ts.map +1 -0
- package/package.json +17 -17
- package/src/autocomplete/get-default-use-items.js +3 -2
- package/src/autocomplete/index.js +3 -2
- package/src/border-control/border-control/hook.ts +1 -1
- package/src/box-control/index.js +1 -1
- package/src/button/README.md +1 -1
- package/src/color-picker/hex-input.tsx +3 -2
- package/src/color-picker/index.native.js +20 -27
- package/src/color-picker/input-with-slider.tsx +2 -0
- package/src/color-picker/styles.ts +0 -5
- package/src/color-picker/use-deprecated-props.ts +24 -43
- package/src/combobox-control/index.js +15 -7
- package/src/combobox-control/stories/index.js +3 -2
- package/src/combobox-control/style.scss +1 -1
- package/src/combobox-control/styles.ts +27 -0
- package/src/dropdown-menu/index.js +3 -4
- package/src/dropdown-menu/index.native.js +3 -5
- package/src/elevation/hook.js +3 -3
- package/src/external-link/index.tsx +10 -4
- package/src/focal-point-picker/grid.js +2 -5
- package/src/focal-point-picker/index.native.js +8 -8
- package/src/focal-point-picker/tooltip/index.native.js +10 -11
- package/src/form-token-field/index.tsx +45 -24
- package/src/form-token-field/style.scss +2 -7
- package/src/form-token-field/styles.ts +32 -0
- package/src/form-token-field/suggestions-list.tsx +2 -4
- package/src/form-token-field/types.ts +7 -0
- package/src/grid/README.md +33 -19
- package/src/grid/{component.js → component.tsx} +13 -9
- package/src/grid/{hook.js → hook.ts} +5 -5
- package/src/grid/{index.js → index.ts} +0 -0
- package/src/grid/stories/index.tsx +72 -0
- package/src/grid/test/{grid.js → grid.tsx} +4 -4
- package/src/grid/types.ts +16 -17
- package/src/grid/{utils.js → utils.ts} +9 -7
- package/src/guide/style.scss +1 -0
- package/src/h-stack/{component.js → component.tsx} +8 -8
- package/src/h-stack/{hook.js → hook.tsx} +21 -16
- package/src/h-stack/{index.js → index.ts} +0 -0
- package/src/h-stack/stories/index.tsx +92 -0
- package/src/h-stack/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/h-stack/test/{index.js → index.tsx} +0 -0
- package/src/h-stack/{utils.js → utils.ts} +14 -14
- package/src/higher-order/navigate-regions/README.md +4 -1
- package/src/icon/index.tsx +1 -1
- package/src/menu-item/index.js +1 -2
- package/src/mobile/focal-point-settings-panel/index.native.js +2 -2
- package/src/mobile/image/index.native.js +3 -2
- package/src/modal/index.js +21 -2
- package/src/modal/stories/index.js +17 -1
- package/src/modal/style.scss +9 -18
- package/src/navigation/index.js +3 -0
- package/src/navigation/item/base.js +2 -1
- package/src/popover/README.md +2 -2
- package/src/popover/index.js +7 -4
- package/src/range-control/README.md +107 -79
- package/src/range-control/{index.js → index.tsx} +78 -48
- package/src/range-control/{input-range.js → input-range.tsx} +11 -7
- package/src/range-control/{mark.js → mark.tsx} +15 -9
- package/src/range-control/{rail.js → rail.tsx} +40 -23
- package/src/range-control/stories/index.tsx +244 -0
- package/src/range-control/styles/{range-control-styles.js → range-control-styles.ts} +28 -24
- package/src/range-control/test/index.tsx +311 -0
- package/src/range-control/{tooltip.js → tooltip.tsx} +19 -14
- package/src/range-control/types.ts +326 -0
- package/src/range-control/utils.ts +132 -0
- package/src/resizable-box/resize-tooltip/utils.ts +2 -3
- package/src/scrollable/README.md +14 -8
- package/src/scrollable/{component.js → component.tsx} +13 -10
- package/src/scrollable/{hook.js → hook.ts} +5 -7
- package/src/scrollable/{index.js → index.ts} +0 -0
- package/src/scrollable/stories/{index.js → index.tsx} +29 -34
- package/src/scrollable/{styles.js → styles.ts} +0 -0
- package/src/scrollable/test/__snapshots__/{index.js.snap → index.tsx.snap} +1 -0
- package/src/scrollable/test/index.tsx +34 -0
- package/src/scrollable/types.ts +10 -5
- package/src/select-control/test/select-control.tsx +22 -15
- package/src/shortcut/index.js +2 -7
- package/src/slot-fill/index.native.js +2 -7
- package/src/slot-fill/provider.js +3 -7
- package/src/slot-fill/slot.js +21 -24
- package/src/spacer/README.md +43 -37
- package/src/spacer/component.tsx +2 -2
- package/src/spacer/hook.ts +4 -2
- package/src/spacer/index.ts +1 -1
- package/src/spacer/test/__snapshots__/{index.js.snap → index.tsx.snap} +1 -0
- package/src/spacer/test/index.tsx +149 -0
- package/src/spacer/types.ts +41 -29
- package/src/tab-panel/README.md +1 -1
- package/src/text-highlight/README.md +6 -6
- package/src/text-highlight/index.tsx +49 -0
- package/src/text-highlight/stories/index.tsx +33 -0
- package/src/text-highlight/test/index.tsx +93 -0
- package/src/text-highlight/types.ts +16 -0
- package/src/tip/index.tsx +22 -0
- package/src/tip/stories/index.tsx +33 -0
- package/src/tip/types.ts +11 -0
- package/src/toolbar-group/index.js +1 -2
- package/src/tree-select/index.tsx +3 -3
- package/src/ui/form-group/types.ts +1 -1
- package/src/ui/utils/get-valid-children.ts +4 -2
- package/src/visually-hidden/{component.js → component.tsx} +23 -15
- package/src/visually-hidden/{index.js → index.ts} +0 -0
- package/src/visually-hidden/stories/index.tsx +66 -0
- package/src/visually-hidden/{styles.js → styles.ts} +6 -2
- package/src/visually-hidden/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/visually-hidden/test/index.tsx +17 -0
- package/src/visually-hidden/types.ts +11 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/grid/stories/index.js +0 -49
- package/src/h-stack/stories/index.js +0 -22
- package/src/range-control/stories/index.js +0 -180
- package/src/range-control/test/index.js +0 -320
- package/src/range-control/utils.js +0 -131
- package/src/scrollable/test/index.js +0 -31
- package/src/spacer/test/index.js +0 -146
- package/src/text-highlight/index.js +0 -28
- package/src/text-highlight/stories/index.js +0 -28
- package/src/text-highlight/test/index.js +0 -120
- package/src/tip/index.js +0 -24
- package/src/tip/stories/index.js +0 -26
- package/src/visually-hidden/stories/index.js +0 -42
- package/src/visually-hidden/test/index.js +0 -19
package/build/modal/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/modal/index.js"],"names":["openModalCount","Modal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","__experimentalHideHeader","ref","instanceId","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","focusOutsideProps","ariaHelper","hideApp","current","document","body","classList","add","remove","showApp","handleEscapeKeyDown","event","keyCode","ESCAPE","defaultPrevented","preventDefault","
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/modal/index.js"],"names":["openModalCount","Modal","props","forwardedRef","bodyOpenClassName","role","title","focusOnMount","shouldCloseOnEsc","shouldCloseOnClickOutside","isDismissible","aria","labelledby","describedby","onRequestClose","icon","closeButtonLabel","children","style","overlayClassName","className","contentLabel","onKeyDown","isFullScreen","__experimentalHideHeader","ref","instanceId","headingId","focusOnMountRef","constrainedTabbingRef","focusReturnRef","focusOutsideProps","hasScrolledContent","setHasScrolledContent","ariaHelper","hideApp","current","document","body","classList","add","remove","showApp","handleEscapeKeyDown","event","keyCode","ESCAPE","defaultPrevented","preventDefault","onContentContainerScroll","e","scrollY","target","scrollTop","close"],"mappings":";;;;;;;;;AAUA;;;;AALA;;AAaA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;;;AAnCA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;;AAqBA;AACA;AACA;AAKA;AACA,IAAIA,cAAc,GAAG,CAArB;;AAEA,SAASC,KAAT,CAAgBC,KAAhB,EAAuBC,YAAvB,EAAsC;AACrC,QAAM;AACLC,IAAAA,iBAAiB,GAAG,YADf;AAELC,IAAAA,IAAI,GAAG,QAFF;AAGLC,IAAAA,KAAK,GAAG,IAHH;AAILC,IAAAA,YAAY,GAAG,IAJV;AAKLC,IAAAA,gBAAgB,GAAG,IALd;AAMLC,IAAAA,yBAAyB,GAAG,IANvB;AAOLC,IAAAA,aAAa,GAAG,IAPX;;AAQL;AACAC,IAAAA,IAAI,GAAG;AACNC,MAAAA,UAAU,EAAE,IADN;AAENC,MAAAA,WAAW,EAAE;AAFP,KATF;AAaLC,IAAAA,cAbK;AAc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AAQ,EAAC;AAlBV,KAmBQJ,yBAAyB,GAC7BsB,iBAD6B,GAE7B,EArBJ;AAsBC,IAAA,SAAS,EAAGT;AAtBb,MAwBC;AACC,IAAA,SAAS,EAAG,yBAAY,2BAAZ,EAAyC;AACpD,qBAAeE,wBADqC;AAEpD,8BAAwBQ;AAF4B,KAAzC,CADb;AAKC,IAAA,IAAI,EAAC,UALN;AAMC,IAAA,QAAQ,EAAGiB;AANZ,KAQG,CAAEzB,wBAAF,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,IAAI,IACL;AACC,IAAA,SAAS,EAAC,kCADX;AAEC;AAFD,KAIGA,IAJH,CAFF,EASGT,KAAK,IACN;AACC,IAAA,EAAE,EAAGqB,SADN;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGrB,KAJH,CAVF,CADD,EAmBGI,aAAa,IACd,4BAAC,eAAD;AACC,IAAA,OAAO,EAAGI,cADX;AAEC,IAAA,IAAI,EAAGwC,YAFR;AAGC,IAAA,KAAK,EACJtC,gBAAgB,IAChB,cAAI,cAAJ;AALF,IApBF,CATF,EAwCGC,QAxCH,CAxBD,CADD,CARD,CAFM,EAgFNoB,QAAQ,CAACC,IAhFH,CAAP;AAkFA;;eAEc,yBAAYrC,KAAZ,C","sourcesContent":["// @ts-nocheck\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tforwardRef,\n} from '@wordpress/element';\nimport {\n\tuseInstanceId,\n\tuseFocusReturn,\n\tuseFocusOnMount,\n\t__experimentalUseFocusOutside as useFocusOutside,\n\tuseConstrainedTabbing,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport * as ariaHelper from './aria-helper';\nimport Button from '../button';\nimport StyleProvider from '../style-provider';\n\n// Used to count the number of open modals.\nlet openModalCount = 0;\n\nfunction Modal( props, forwardedRef ) {\n\tconst {\n\t\tbodyOpenClassName = 'modal-open',\n\t\trole = 'dialog',\n\t\ttitle = null,\n\t\tfocusOnMount = true,\n\t\tshouldCloseOnEsc = true,\n\t\tshouldCloseOnClickOutside = true,\n\t\tisDismissible = true,\n\t\t/* Accessibility. */\n\t\taria = {\n\t\t\tlabelledby: null,\n\t\t\tdescribedby: null,\n\t\t},\n\t\tonRequestClose,\n\t\ticon,\n\t\tcloseButtonLabel,\n\t\tchildren,\n\t\tstyle,\n\t\toverlayClassName,\n\t\tclassName,\n\t\tcontentLabel,\n\t\tonKeyDown,\n\t\tisFullScreen = false,\n\t\t__experimentalHideHeader = false,\n\t} = props;\n\n\tconst ref = useRef();\n\tconst instanceId = useInstanceId( Modal );\n\tconst headingId = title\n\t\t? `components-modal-header-${ instanceId }`\n\t\t: aria.labelledby;\n\tconst focusOnMountRef = useFocusOnMount( focusOnMount );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( onRequestClose );\n\n\tconst [ hasScrolledContent, setHasScrolledContent ] = useState( false );\n\n\tuseEffect( () => {\n\t\topenModalCount++;\n\n\t\tif ( openModalCount === 1 ) {\n\t\t\tariaHelper.hideApp( ref.current );\n\t\t\tdocument.body.classList.add( bodyOpenClassName );\n\t\t}\n\n\t\treturn () => {\n\t\t\topenModalCount--;\n\n\t\t\tif ( openModalCount === 0 ) {\n\t\t\t\tdocument.body.classList.remove( bodyOpenClassName );\n\t\t\t\tariaHelper.showApp();\n\t\t\t}\n\t\t};\n\t}, [ bodyOpenClassName ] );\n\n\tfunction handleEscapeKeyDown( event ) {\n\t\tif (\n\t\t\tshouldCloseOnEsc &&\n\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t! event.defaultPrevented\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\tif ( onRequestClose ) {\n\t\t\t\tonRequestClose( event );\n\t\t\t}\n\t\t}\n\t}\n\n\tconst onContentContainerScroll = useCallback(\n\t\t( e ) => {\n\t\t\tconst scrollY = e?.target?.scrollTop ?? -1;\n\n\t\t\tif ( ! hasScrolledContent && scrollY > 0 ) {\n\t\t\t\tsetHasScrolledContent( true );\n\t\t\t} else if ( hasScrolledContent && scrollY <= 0 ) {\n\t\t\t\tsetHasScrolledContent( false );\n\t\t\t}\n\t\t},\n\t\t[ hasScrolledContent ]\n\t);\n\n\treturn createPortal(\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tref={ useMergeRefs( [ ref, forwardedRef ] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-modal__screen-overlay',\n\t\t\t\toverlayClassName\n\t\t\t) }\n\t\t\tonKeyDown={ handleEscapeKeyDown }\n\t\t>\n\t\t\t<StyleProvider document={ document }>\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'components-modal__frame',\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'is-full-screen': isFullScreen,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tstyle={ style }\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tconstrainedTabbingRef,\n\t\t\t\t\t\tfocusReturnRef,\n\t\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\trole={ role }\n\t\t\t\t\taria-label={ contentLabel }\n\t\t\t\t\taria-labelledby={ contentLabel ? null : headingId }\n\t\t\t\t\taria-describedby={ aria.describedby }\n\t\t\t\t\ttabIndex=\"-1\"\n\t\t\t\t\t{ ...( shouldCloseOnClickOutside\n\t\t\t\t\t\t? focusOutsideProps\n\t\t\t\t\t\t: {} ) }\n\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( 'components-modal__content', {\n\t\t\t\t\t\t\t'hide-header': __experimentalHideHeader,\n\t\t\t\t\t\t\t'has-scrolled-content': hasScrolledContent,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t\trole=\"document\"\n\t\t\t\t\t\tonScroll={ onContentContainerScroll }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! __experimentalHideHeader && (\n\t\t\t\t\t\t\t<div className=\"components-modal__header\">\n\t\t\t\t\t\t\t\t<div className=\"components-modal__header-heading-container\">\n\t\t\t\t\t\t\t\t\t{ icon && (\n\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__icon-container\"\n\t\t\t\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ icon }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t\t\t<h1\n\t\t\t\t\t\t\t\t\t\t\tid={ headingId }\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"components-modal__header-heading\"\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t{ isDismissible && (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tonClick={ onRequestClose }\n\t\t\t\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\tcloseButtonLabel ||\n\t\t\t\t\t\t\t\t\t\t\t__( 'Close dialog' )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</StyleProvider>\n\t\t</div>,\n\t\tdocument.body\n\t);\n}\n\nexport default forwardRef( Modal );\n"]}
|
|
@@ -71,7 +71,10 @@ function Navigation(_ref) {
|
|
|
71
71
|
(0, _element.useEffect)(() => {
|
|
72
72
|
if (activeMenu !== menu) {
|
|
73
73
|
setActiveMenu(activeMenu);
|
|
74
|
-
}
|
|
74
|
+
} // Ignore exhaustive-deps here, as it would require either a larger refactor or some questionable workarounds.
|
|
75
|
+
// See https://github.com/WordPress/gutenberg/pull/41612 for context.
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
|
|
75
78
|
}, [activeMenu]);
|
|
76
79
|
const context = {
|
|
77
80
|
activeItem,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigation/index.js"],"names":["noop","Navigation","activeItem","activeMenu","ROOT_MENU","children","className","onActivateMenu","menu","setMenu","slideOrigin","setSlideOrigin","navigationTree","defaultSlideOrigin","setActiveMenu","menuId","slideInOrigin","getMenu","isMounted","current","context","classes","animateClassName","type","origin"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,UADmC;AAEnCC,IAAAA,UAAU,GAAGC,oBAFsB;AAGnCC,IAAAA,QAHmC;AAInCC,IAAAA,SAJmC;AAKnCC,IAAAA,cAAc,GAAGP;AALkB,GAMhC;AACH,QAAM,CAAEQ,IAAF,EAAQC,OAAR,IAAoB,uBAAUN,UAAV,CAA1B;AACA,QAAM,CAAEO,WAAF,EAAeC,cAAf,IAAkC,wBAAxC;AACA,QAAMC,cAAc,GAAG,uDAAvB;AACA,QAAMC,kBAAkB,GAAG,qBAAU,OAAV,GAAoB,MAA/C;;AAEA,QAAMC,aAAa,GAAG,UAAEC,MAAF,EAAkD;AAAA,QAAxCC,aAAwC,uEAAxBH,kBAAwB;;AACvE,QAAK,CAAED,cAAc,CAACK,OAAf,CAAwBF,MAAxB,CAAP,EAA0C;AACzC;AACA;;AAEDJ,IAAAA,cAAc,CAAEK,aAAF,CAAd;AACAP,IAAAA,OAAO,CAAEM,MAAF,CAAP;AACAR,IAAAA,cAAc,CAAEQ,MAAF,CAAd;AACA,GARD,CANG,CAgBH;;;AACA,QAAMG,SAAS,GAAG,qBAAQ,KAAR,CAAlB;AACA,0BAAW,MAAM;AAChB,QAAK,CAAEA,SAAS,CAACC,OAAjB,EAA2B;AAC1BD,MAAAA,SAAS,CAACC,OAAV,GAAoB,IAApB;AACA;AACD,GAJD,EAIG,EAJH;AAMA,0BAAW,MAAM;AAChB,QAAKhB,UAAU,KAAKK,IAApB,EAA2B;AAC1BM,MAAAA,aAAa,CAAEX,UAAF,CAAb;AACA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigation/index.js"],"names":["noop","Navigation","activeItem","activeMenu","ROOT_MENU","children","className","onActivateMenu","menu","setMenu","slideOrigin","setSlideOrigin","navigationTree","defaultSlideOrigin","setActiveMenu","menuId","slideInOrigin","getMenu","isMounted","current","context","classes","animateClassName","type","origin"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAOA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,UADmC;AAEnCC,IAAAA,UAAU,GAAGC,oBAFsB;AAGnCC,IAAAA,QAHmC;AAInCC,IAAAA,SAJmC;AAKnCC,IAAAA,c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A,SAAS,EAAGW;AAA1B,KACC;AACC,IAAA,GAAG,EAAGb,IADP;AAEC,IAAA,SAAS,EAAG,yBAAY;AACvB,OAAEc,gBAAF,GAAsBJ,SAAS,CAACC,OAAV,IAAqBT;AADpB,KAAZ;AAFb,KAMC,4BAAC,0BAAD,CAAmB,QAAnB;AAA4B,IAAA,KAAK,EAAGU;AAApC,KACGf,QADH,CAND,CADD,CADD;AAcA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getAnimateClassName } from '../animate';\nimport { ROOT_MENU } from './constants';\nimport { NavigationContext } from './context';\nimport { NavigationUI } from './styles/navigation-styles';\nimport { useCreateNavigationTree } from './use-create-navigation-tree';\n\nconst noop = () => {};\n\nexport default function Navigation( {\n\tactiveItem,\n\tactiveMenu = ROOT_MENU,\n\tchildren,\n\tclassName,\n\tonActivateMenu = noop,\n} ) {\n\tconst [ menu, setMenu ] = useState( activeMenu );\n\tconst [ slideOrigin, setSlideOrigin ] = useState();\n\tconst navigationTree = useCreateNavigationTree();\n\tconst defaultSlideOrigin = isRTL() ? 'right' : 'left';\n\n\tconst setActiveMenu = ( menuId, slideInOrigin = defaultSlideOrigin ) => {\n\t\tif ( ! navigationTree.getMenu( menuId ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetSlideOrigin( slideInOrigin );\n\t\tsetMenu( menuId );\n\t\tonActivateMenu( menuId );\n\t};\n\n\t// Used to prevent the sliding animation on mount\n\tconst isMounted = useRef( false );\n\tuseEffect( () => {\n\t\tif ( ! isMounted.current ) {\n\t\t\tisMounted.current = true;\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( activeMenu !== menu ) {\n\t\t\tsetActiveMenu( activeMenu );\n\t\t}\n\t\t// Ignore exhaustive-deps here, as it would require either a larger refactor or some questionable workarounds.\n\t\t// See https://github.com/WordPress/gutenberg/pull/41612 for context.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ activeMenu ] );\n\n\tconst context = {\n\t\tactiveItem,\n\t\tactiveMenu: menu,\n\t\tsetActiveMenu,\n\t\tnavigationTree,\n\t};\n\n\tconst classes = classnames( 'components-navigation', className );\n\tconst animateClassName = getAnimateClassName( {\n\t\ttype: 'slide-in',\n\t\torigin: slideOrigin,\n\t} );\n\n\treturn (\n\t\t<NavigationUI className={ classes }>\n\t\t\t<div\n\t\t\t\tkey={ menu }\n\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t[ animateClassName ]: isMounted.current && slideOrigin,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<NavigationContext.Provider value={ context }>\n\t\t\t\t\t{ children }\n\t\t\t\t</NavigationContext.Provider>\n\t\t\t</div>\n\t\t</NavigationUI>\n\t);\n}\n"]}
|
|
@@ -35,9 +35,12 @@ let uniqueId = 0;
|
|
|
35
35
|
function NavigationItemBase(props) {
|
|
36
36
|
var _navigationTree$getIt;
|
|
37
37
|
|
|
38
|
+
// Also avoid to pass the `title` and `href` props to the ItemBaseUI styled component.
|
|
38
39
|
const {
|
|
39
40
|
children,
|
|
40
41
|
className,
|
|
42
|
+
title,
|
|
43
|
+
href,
|
|
41
44
|
...restProps
|
|
42
45
|
} = props;
|
|
43
46
|
const [itemId] = (0, _element.useState)(`item-${++uniqueId}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/navigation/item/base.js"],"names":["uniqueId","NavigationItemBase","props","children","className","restProps","itemId","navigationTree","getItem","_isVisible","classes"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAUA;;AACA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAKA,IAAIA,QAAQ,GAAG,CAAf;;AAEe,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AACnD,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/navigation/item/base.js"],"names":["uniqueId","NavigationItemBase","props","children","className","title","href","restProps","itemId","navigationTree","getItem","_isVisible","classes"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAUA;;AACA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAKA,IAAIA,QAAQ,GAAG,CAAf;;AAEe,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AACnD;AACA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,SAAZ;AAAuBC,IAAAA,KAAvB;AAA8BC,IAAAA,IAA9B;AAAoC,OAAGC;AAAvC,MAAqDL,KAA3D;AAEA,QAAM,CAAEM,MAAF,IAAa,uBAAW,QAAQ,EAAER,QAAU,EAA/B,CAAnB;AAEA,oDAAuBQ,MAAvB,EAA+BN,KAA/B;AACA,QAAM;AAAEO,IAAAA;AAAF,MAAqB,oCAA3B;;AAEA,MAAK,2BAAEA,cAAc,CAACC,OAAf,CAAwBF,MAAxB,CAAF,kDAAE,sBAAkCG,UAApC,CAAL,EAAsD;AACrD,WAAO,IAAP;AACA;;AAED,QAAMC,OAAO,GAAG,yBAAY,6BAAZ,EAA2CR,SAA3C,CAAhB;AAEA,SACC,4BAAC,4BAAD;AAAY,IAAA,SAAS,EAAGQ;AAAxB,KAAuCL,SAAvC,GACGJ,QADH,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useNavigationContext } from '../context';\nimport { useNavigationTreeItem } from './use-navigation-tree-item';\nimport { ItemBaseUI } from '../styles/navigation-styles';\n\nlet uniqueId = 0;\n\nexport default function NavigationItemBase( props ) {\n\t// Also avoid to pass the `title` and `href` props to the ItemBaseUI styled component.\n\tconst { children, className, title, href, ...restProps } = props;\n\n\tconst [ itemId ] = useState( `item-${ ++uniqueId }` );\n\n\tuseNavigationTreeItem( itemId, props );\n\tconst { navigationTree } = useNavigationContext();\n\n\tif ( ! navigationTree.getItem( itemId )?._isVisible ) {\n\t\treturn null;\n\t}\n\n\tconst classes = classnames( 'components-navigation__item', className );\n\n\treturn (\n\t\t<ItemBaseUI className={ classes } { ...restProps }>\n\t\t\t{ children }\n\t\t</ItemBaseUI>\n\t);\n}\n"]}
|
package/build/popover/index.js
CHANGED
|
@@ -132,6 +132,7 @@ const Popover = (_ref, ref) => {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
const arrowRef = (0, _element.useRef)(null);
|
|
135
|
+
const anchorRefFallback = (0, _element.useRef)(null);
|
|
135
136
|
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
136
137
|
const isExpanded = expandOnMobile && isMobileViewport;
|
|
137
138
|
const hasArrow = !isExpanded && !noArrow;
|
|
@@ -151,13 +152,13 @@ const Popover = (_ref, ref) => {
|
|
|
151
152
|
} else if (getAnchorRect) {
|
|
152
153
|
var _getAnchorRect$ownerD, _getAnchorRect;
|
|
153
154
|
|
|
154
|
-
return (_getAnchorRect$ownerD = (_getAnchorRect = getAnchorRect()) === null || _getAnchorRect === void 0 ? void 0 : _getAnchorRect.ownerDocument) !== null && _getAnchorRect$ownerD !== void 0 ? _getAnchorRect$ownerD : document;
|
|
155
|
+
return (_getAnchorRect$ownerD = (_getAnchorRect = getAnchorRect(anchorRefFallback.current)) === null || _getAnchorRect === void 0 ? void 0 : _getAnchorRect.ownerDocument) !== null && _getAnchorRect$ownerD !== void 0 ? _getAnchorRect$ownerD : document;
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
return document;
|
|
158
159
|
}, [anchorRef, anchorRect, getAnchorRect]);
|
|
159
160
|
/**
|
|
160
|
-
* Offsets the
|
|
161
|
+
* Offsets the position of the popover when the anchor is inside an iframe.
|
|
161
162
|
*/
|
|
162
163
|
|
|
163
164
|
const frameOffset = (0, _element.useMemo)(() => {
|
|
@@ -210,7 +211,6 @@ const Popover = (_ref, ref) => {
|
|
|
210
211
|
}) : undefined, hasArrow ? (0, _reactDom.arrow)({
|
|
211
212
|
element: arrowRef
|
|
212
213
|
}) : undefined].filter(m => !!m);
|
|
213
|
-
const anchorRefFallback = (0, _element.useRef)(null);
|
|
214
214
|
|
|
215
215
|
const slotName = (0, _element.useContext)(slotNameContext) || __unstableSlotName;
|
|
216
216
|
|
|
@@ -284,7 +284,7 @@ const Popover = (_ref, ref) => {
|
|
|
284
284
|
getBoundingClientRect() {
|
|
285
285
|
var _rect$x, _rect$y, _rect$width, _rect$height;
|
|
286
286
|
|
|
287
|
-
const rect = getAnchorRect();
|
|
287
|
+
const rect = getAnchorRect(anchorRefFallback.current);
|
|
288
288
|
return new window.DOMRect((_rect$x = rect.x) !== null && _rect$x !== void 0 ? _rect$x : rect.left, (_rect$y = rect.y) !== null && _rect$y !== void 0 ? _rect$y : rect.top, (_rect$width = rect.width) !== null && _rect$width !== void 0 ? _rect$width : rect.right - rect.left, (_rect$height = rect.height) !== null && _rect$height !== void 0 ? _rect$height : rect.bottom - rect.top);
|
|
289
289
|
}
|
|
290
290
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/popover/index.js"],"names":["SLOT_NAME","slotNameContext","positionToPlacement","position","x","y","z","split","includes","suffix","placementToAnimationOrigin","placement","a","b","Popover","ref","range","animate","headerTitle","onClose","children","className","noArrow","isAlternate","offset","focusOnMount","anchorRef","anchorRect","getAnchorRect","expandOnMobile","onFocusOutside","__unstableSlotName","__unstableObserveElement","__unstableForcePosition","__unstableShift","contentProps","since","version","arrowRef","isMobileViewport","isExpanded","hasArrow","usedPlacement","ownerDocument","top","startContainer","current","document","frameOffset","defaultView","frameElement","undefined","iframeRect","getBoundingClientRect","name","fn","left","middlewares","apply","sizeProps","height","refs","floating","Object","assign","firstChild","style","maxHeight","overflow","crossAxis","limiter","padding","element","filter","m","anchorRefFallback","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","reference","strategy","update","placementData","middlewareData","arrow","arrowData","middleware","staticSide","right","bottom","mergedRefs","usedRef","topRect","bottomRect","window","DOMRect","width","rect","observer","MutationObserver","observe","attributes","disconnect","addEventListener","removeEventListener","animateClassName","origin","content","Number","isNaN","close","PopoverContainer","PopoverSlot","Slot","__unstableSlotNameProvider","Provider"],"mappings":";;;;;;;;;AAmBA;;;;AAfA;;AACA;;AAsBA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAzCA;;AACA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,SAAlB;AAEA,MAAMC,eAAe,GAAG,6BAAxB;;AAEA,MAAMC,mBAAmB,GAAKC,QAAF,IAAgB;AAC3C,QAAM,CAAEC,CAAF,EAAKC,CAAL,EAAQC,CAAR,IAAcH,QAAQ,CAACI,KAAT,CAAgB,GAAhB,CAApB;;AAEA,MAAK,CAAE,KAAF,EAAS,QAAT,EAAoBC,QAApB,CAA8BJ,CAA9B,CAAL,EAAyC;AACxC,QAAIK,MAAM,GAAG,EAAb;;AACA,QAAO,CAAC,CAAEH,CAAH,IAAQA,CAAC,KAAK,MAAhB,IAA4BD,CAAC,KAAK,OAAvC,EAAiD;AAChDI,MAAAA,MAAM,GAAG,QAAT;AACA,KAFD,MAEO,IAAO,CAAC,CAAEH,CAAH,IAAQA,CAAC,KAAK,OAAhB,IAA6BD,CAAC,KAAK,MAAxC,EAAiD;AACvDI,MAAAA,MAAM,GAAG,MAAT;AACA;;AACD,WAAOL,CAAC,GAAGK,MAAX;AACA;;AAED,SAAOJ,CAAP;AACA,CAdD;;AAgBA,MAAMK,0BAA0B,GAAKC,SAAF,IAAiB;AACnD,QAAM,CAAEC,CAAF,EAAKC,CAAL,IAAWF,SAAS,CAACJ,KAAV,CAAiB,GAAjB,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rC;AAAZ,KAAkCqC,OAAlC,CAAP;AACA,CA1TD;;AA4TA,MAAMI,gBAAgB,GAAG,yBAAYtG,OAAZ,CAAzB;;AAEA,SAASuG,WAAT,QAA4CtG,GAA5C,EAAkD;AAAA,MAA5B;AAAEuC,IAAAA,IAAI,GAAGtD;AAAT,GAA4B;AACjD,SACC,4BAAC,cAAD;AACC,IAAA,gBAAgB,MADjB;AAEC,IAAA,IAAI,EAAGsD,IAFR;AAGC,IAAA,SAAS,EAAC,cAHX;AAIC,IAAA,GAAG,EAAGvC;AAJP,IADD;AAQA;;AAEDqG,gBAAgB,CAACE,IAAjB,GAAwB,yBAAYD,WAAZ,CAAxB;AACAD,gBAAgB,CAACG,0BAAjB,GAA8CtH,eAAe,CAACuH,QAA9D;eAEeJ,gB","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip,\n\tshift,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tlimitShift,\n\tsize,\n} from '@floating-ui/react-dom';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { getAnimateClassName } from '../animate';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\nconst slotNameContext = createContext();\n\nconst positionToPlacement = ( position ) => {\n\tconst [ x, y, z ] = position.split( ' ' );\n\n\tif ( [ 'top', 'bottom' ].includes( x ) ) {\n\t\tlet suffix = '';\n\t\tif ( ( !! z && z === 'left' ) || y === 'right' ) {\n\t\t\tsuffix = '-start';\n\t\t} else if ( ( !! z && z === 'right' ) || y === 'left' ) {\n\t\t\tsuffix = '-end';\n\t\t}\n\t\treturn x + suffix;\n\t}\n\n\treturn y;\n};\n\nconst placementToAnimationOrigin = ( placement ) => {\n\tconst [ a, b ] = placement.split( '-' );\n\n\tlet x, y;\n\tif ( a === 'top' || a === 'bottom' ) {\n\t\tx = a === 'top' ? 'bottom' : 'top';\n\t\ty = 'middle';\n\t\tif ( b === 'start' ) {\n\t\t\ty = 'left';\n\t\t} else if ( b === 'end' ) {\n\t\t\ty = 'right';\n\t\t}\n\t}\n\n\tif ( a === 'left' || a === 'right' ) {\n\t\tx = 'center';\n\t\ty = a === 'left' ? 'right' : 'left';\n\t\tif ( b === 'start' ) {\n\t\t\tx = 'top';\n\t\t} else if ( b === 'end' ) {\n\t\t\tx = 'bottom';\n\t\t}\n\t}\n\n\treturn x + ' ' + y;\n};\n\nconst Popover = (\n\t{\n\t\trange,\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tisAlternate,\n\t\tposition,\n\t\tplacement = 'bottom-start',\n\t\toffset,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\t__unstableObserveElement,\n\t\t__unstableForcePosition,\n\t\t__unstableShift = false,\n\t\t...contentProps\n\t},\n\tref\n) => {\n\tif ( range ) {\n\t\tdeprecated( 'range prop in Popover component', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef( null );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst usedPlacement = position\n\t\t? positionToPlacement( position )\n\t\t: placement;\n\n\tconst ownerDocument = useMemo( () => {\n\t\tif ( anchorRef?.top ) {\n\t\t\treturn anchorRef?.top.ownerDocument;\n\t\t} else if ( anchorRef?.startContainer ) {\n\t\t\treturn anchorRef.startContainer.ownerDocument;\n\t\t} else if ( anchorRef?.current ) {\n\t\t\treturn anchorRef.current.ownerDocument;\n\t\t} else if ( anchorRef ) {\n\t\t\t// This one should be deprecated.\n\t\t\treturn anchorRef.ownerDocument;\n\t\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\t\treturn anchorRect.ownerDocument;\n\t\t} else if ( getAnchorRect ) {\n\t\t\treturn getAnchorRect()?.ownerDocument ?? document;\n\t\t}\n\n\t\treturn document;\n\t}, [ anchorRef, anchorRect, getAnchorRect ] );\n\n\t/**\n\t * Offsets the the position of the popover when the anchor is inside an iframe.\n\t */\n\tconst frameOffset = useMemo( () => {\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst { frameElement } = defaultView;\n\n\t\tif ( ! frameElement || ownerDocument === document ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst iframeRect = frameElement.getBoundingClientRect();\n\t\treturn {\n\t\t\tname: 'iframeOffset',\n\t\t\tfn( { x, y } ) {\n\t\t\t\treturn {\n\t\t\t\t\tx: x + iframeRect.left,\n\t\t\t\t\ty: y + iframeRect.top,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}, [ ownerDocument ] );\n\n\tconst middlewares = [\n\t\tframeOffset,\n\t\toffset ? offsetMiddleware( offset ) : undefined,\n\t\t__unstableForcePosition ? undefined : flip(),\n\t\t__unstableForcePosition\n\t\t\t? undefined\n\t\t\t: size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { height } = sizeProps;\n\t\t\t\t\t\tif ( ! refs.floating.current ) return;\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( refs.floating.current.firstChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ height }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } ),\n\t\t__unstableShift\n\t\t\t? shift( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: limitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\thasArrow ? arrow( { element: arrowRef } ) : undefined,\n\t].filter( ( m ) => !! m );\n\tconst anchorRefFallback = useRef( null );\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tconst onDialogClose = ( type, event ) => {\n\t\t// Ideally the popover should have just a single onClose prop and\n\t\t// not three props that potentially do the same thing.\n\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\tonFocusOutside( event );\n\t\t} else if ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\tx,\n\t\ty,\n\t\treference,\n\t\tfloating,\n\t\tstrategy,\n\t\trefs,\n\t\tupdate,\n\t\tplacement: placementData,\n\t\tmiddlewareData: { arrow: arrowData = {} },\n\t} = useFloating( {\n\t\tplacement: usedPlacement,\n\t\tmiddleware: middlewares,\n\t} );\n\tconst staticSide = {\n\t\ttop: 'bottom',\n\t\tright: 'left',\n\t\tbottom: 'top',\n\t\tleft: 'right',\n\t}[ placementData.split( '-' )[ 0 ] ];\n\tconst mergedRefs = useMergeRefs( [ floating, dialogRef, ref ] );\n\n\t// Updates references\n\tuseLayoutEffect( () => {\n\t\t// No ref or position have been passed\n\t\tlet usedRef;\n\t\tif ( anchorRef?.top ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\tconst topRect = anchorRef.top.getBoundingClientRect();\n\t\t\t\t\tconst bottomRect = anchorRef.bottom.getBoundingClientRect();\n\t\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\t\ttopRect.x,\n\t\t\t\t\t\ttopRect.y,\n\t\t\t\t\t\ttopRect.width,\n\t\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( anchorRef?.current ) {\n\t\t\tusedRef = anchorRef.current;\n\t\t} else if ( anchorRef ) {\n\t\t\tusedRef = anchorRef;\n\t\t} else if ( anchorRect ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\treturn anchorRect;\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( getAnchorRect ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\tconst rect = getAnchorRect();\n\t\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( anchorRefFallback.current ) {\n\t\t\tusedRef = anchorRefFallback.current;\n\t\t}\n\n\t\tif ( ! usedRef ) {\n\t\t\treturn;\n\t\t}\n\n\t\treference( usedRef );\n\n\t\tif ( ! refs.floating.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn autoUpdate( usedRef, refs.floating.current, update );\n\t}, [ anchorRef, anchorRect, getAnchorRect ] );\n\n\t// This is only needed for a smoth transition when moving blocks.\n\tuseLayoutEffect( () => {\n\t\tif ( ! __unstableObserveElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( update );\n\t\tobserver.observe( __unstableObserveElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ __unstableObserveElement ] );\n\n\t// If we're using getAnchorRect, we need to update the position as we scroll the iframe.\n\tuseLayoutEffect( () => {\n\t\tif ( ownerDocument === document ) {\n\t\t\treturn;\n\t\t}\n\n\t\townerDocument.addEventListener( 'scroll', update );\n\t\treturn () => ownerDocument.removeEventListener( 'scroll', update );\n\t}, [ ownerDocument ] );\n\n\t/** @type {false | string} */\n\tconst animateClassName =\n\t\t!! animate &&\n\t\tgetAnimateClassName( {\n\t\t\ttype: 'appear',\n\t\t\torigin: placementToAnimationOrigin( placementData ),\n\t\t} );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-popover',\n\t\t\t\tclassName,\n\t\t\t\tanimateClassName,\n\t\t\t\t{\n\t\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t\t'is-alternate': isAlternate,\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedRefs }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex=\"-1\"\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\tleft: Number.isNaN( x ) ? 0 : x,\n\t\t\t\t\t\t\ttop: Number.isNaN( y ) ? 0 : y,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-popover__arrow\"\n\t\t\t\t\tref={ arrowRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\t! arrowData?.x || Number.isNaN( arrowData?.x )\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: arrowData.x,\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\t! arrowData?.y || Number.isNaN( arrowData?.y )\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: arrowData.y,\n\t\t\t\t\t\tright: undefined,\n\t\t\t\t\t\tbottom: undefined,\n\t\t\t\t\t\t[ staticSide ]: '-4px',\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\nconst PopoverContainer = forwardRef( Popover );\n\nfunction PopoverSlot( { name = SLOT_NAME }, ref ) {\n\treturn (\n\t\t<Slot\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nPopoverContainer.Slot = forwardRef( PopoverSlot );\nPopoverContainer.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default PopoverContainer;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/popover/index.js"],"names":["SLOT_NAME","slotNameContext","positionToPlacement","position","x","y","z","split","includes","suffix","placementToAnimationOrigin","placement","a","b","Popover","ref","range","animate","headerTitle","onClose","children","className","noArrow","isAlternate","offset","focusOnMount","anchorRef","anchorRect","getAnchorRect","expandOnMobile","onFocusOutside","__unstableSlotName","__unstableObserveElement","__unstableForcePosition","__unstableShift","contentProps","since","version","arrowRef","anchorRefFallback","isMobileViewport","isExpanded","hasArrow","usedPlacement","ownerDocument","top","startContainer","current","document","frameOffset","defaultView","frameElement","undefined","iframeRect","getBoundingClientRect","name","fn","left","middlewares","apply","sizeProps","height","refs","floating","Object","assign","firstChild","style","maxHeight","overflow","crossAxis","limiter","padding","element","filter","m","slotName","slot","onDialogClose","type","event","dialogRef","dialogProps","__unstableOnClose","reference","strategy","update","placementData","middlewareData","arrow","arrowData","middleware","staticSide","right","bottom","mergedRefs","usedRef","topRect","bottomRect","window","DOMRect","width","rect","observer","MutationObserver","observe","attributes","disconnect","addEventListener","removeEventListener","animateClassName","origin","content","Number","isNaN","close","PopoverContainer","PopoverSlot","Slot","__unstableSlotNameProvider","Provider"],"mappings":";;;;;;;;;AAmBA;;;;AAfA;;AACA;;AAsBA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAzCA;;AACA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,SAAlB;AAEA,MAAMC,eAAe,GAAG,6BAAxB;;AAEA,MAAMC,mBAAmB,GAAKC,QAAF,IAAgB;AAC3C,QAAM,CAAEC,CAAF,EAAKC,CAAL,EAAQC,CAAR,IAAcH,QAAQ,CAACI,KAAT,CAAgB,GAAhB,CAApB;;AAEA,MAAK,CAAE,KAAF,EAAS,QAAT,EAAoBC,QAApB,CAA8BJ,CAA9B,CAAL,EAAyC;AACxC,QAAIK,MAAM,GAAG,EAAb;;AACA,QAAO,CAAC,CAAEH,CAAH,IAAQA,CAAC,KAAK,MAAhB,IAA4BD,CAAC,KAAK,OAAvC,EAAiD;AAChDI,MAAAA,MAAM,GAAG,QAAT;AACA,KAFD,MAEO,IAAO,CAAC,CAAEH,CAAH,IAAQA,CAAC,KAAK,OAAh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AAE1C,SAVD;AAWP,OAAEwC,UAAF,GAAgB;AAXT;AAHT,IAvCF,CAHD;;AA+DA,MAAKf,IAAI,CAAC9D,GAAV,EAAgB;AACfiG,IAAAA,OAAO,GAAG,4BAAC,cAAD;AAAM,MAAA,IAAI,EAAGpC;AAAb,OAA0BoC,OAA1B,CAAV;AACA;;AAED,MAAKtF,SAAS,IAAIC,UAAlB,EAA+B;AAC9B,WAAOqF,OAAP;AACA;;AAED,SAAO;AAAM,IAAA,GAAG,EAAGzE;AAAZ,KAAkCyE,OAAlC,CAAP;AACA,CA7TD;;AA+TA,MAAMI,gBAAgB,GAAG,yBAAYtG,OAAZ,CAAzB;;AAEA,SAASuG,WAAT,QAA4CtG,GAA5C,EAAkD;AAAA,MAA5B;AAAEwC,IAAAA,IAAI,GAAGvD;AAAT,GAA4B;AACjD,SACC,4BAAC,cAAD;AACC,IAAA,gBAAgB,MADjB;AAEC,IAAA,IAAI,EAAGuD,IAFR;AAGC,IAAA,SAAS,EAAC,cAHX;AAIC,IAAA,GAAG,EAAGxC;AAJP,IADD;AAQA;;AAEDqG,gBAAgB,CAACE,IAAjB,GAAwB,yBAAYD,WAAZ,CAAxB;AACAD,gBAAgB,CAACG,0BAAjB,GAA8CtH,eAAe,CAACuH,QAA9D;eAEeJ,gB","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport {\n\tuseFloating,\n\tflip,\n\tshift,\n\tautoUpdate,\n\tarrow,\n\toffset as offsetMiddleware,\n\tlimitShift,\n\tsize,\n} from '@floating-ui/react-dom';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tforwardRef,\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n} from '@wordpress/element';\nimport {\n\tuseViewportMatch,\n\tuseMergeRefs,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { getAnimateClassName } from '../animate';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nconst SLOT_NAME = 'Popover';\n\nconst slotNameContext = createContext();\n\nconst positionToPlacement = ( position ) => {\n\tconst [ x, y, z ] = position.split( ' ' );\n\n\tif ( [ 'top', 'bottom' ].includes( x ) ) {\n\t\tlet suffix = '';\n\t\tif ( ( !! z && z === 'left' ) || y === 'right' ) {\n\t\t\tsuffix = '-start';\n\t\t} else if ( ( !! z && z === 'right' ) || y === 'left' ) {\n\t\t\tsuffix = '-end';\n\t\t}\n\t\treturn x + suffix;\n\t}\n\n\treturn y;\n};\n\nconst placementToAnimationOrigin = ( placement ) => {\n\tconst [ a, b ] = placement.split( '-' );\n\n\tlet x, y;\n\tif ( a === 'top' || a === 'bottom' ) {\n\t\tx = a === 'top' ? 'bottom' : 'top';\n\t\ty = 'middle';\n\t\tif ( b === 'start' ) {\n\t\t\ty = 'left';\n\t\t} else if ( b === 'end' ) {\n\t\t\ty = 'right';\n\t\t}\n\t}\n\n\tif ( a === 'left' || a === 'right' ) {\n\t\tx = 'center';\n\t\ty = a === 'left' ? 'right' : 'left';\n\t\tif ( b === 'start' ) {\n\t\t\tx = 'top';\n\t\t} else if ( b === 'end' ) {\n\t\t\tx = 'bottom';\n\t\t}\n\t}\n\n\treturn x + ' ' + y;\n};\n\nconst Popover = (\n\t{\n\t\trange,\n\t\tanimate = true,\n\t\theaderTitle,\n\t\tonClose,\n\t\tchildren,\n\t\tclassName,\n\t\tnoArrow = true,\n\t\tisAlternate,\n\t\tposition,\n\t\tplacement = 'bottom-start',\n\t\toffset,\n\t\tfocusOnMount = 'firstElement',\n\t\tanchorRef,\n\t\tanchorRect,\n\t\tgetAnchorRect,\n\t\texpandOnMobile,\n\t\tonFocusOutside,\n\t\t__unstableSlotName = SLOT_NAME,\n\t\t__unstableObserveElement,\n\t\t__unstableForcePosition,\n\t\t__unstableShift = false,\n\t\t...contentProps\n\t},\n\tref\n) => {\n\tif ( range ) {\n\t\tdeprecated( 'range prop in Popover component', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t} );\n\t}\n\n\tconst arrowRef = useRef( null );\n\tconst anchorRefFallback = useRef( null );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isExpanded = expandOnMobile && isMobileViewport;\n\tconst hasArrow = ! isExpanded && ! noArrow;\n\tconst usedPlacement = position\n\t\t? positionToPlacement( position )\n\t\t: placement;\n\n\tconst ownerDocument = useMemo( () => {\n\t\tif ( anchorRef?.top ) {\n\t\t\treturn anchorRef?.top.ownerDocument;\n\t\t} else if ( anchorRef?.startContainer ) {\n\t\t\treturn anchorRef.startContainer.ownerDocument;\n\t\t} else if ( anchorRef?.current ) {\n\t\t\treturn anchorRef.current.ownerDocument;\n\t\t} else if ( anchorRef ) {\n\t\t\t// This one should be deprecated.\n\t\t\treturn anchorRef.ownerDocument;\n\t\t} else if ( anchorRect && anchorRect?.ownerDocument ) {\n\t\t\treturn anchorRect.ownerDocument;\n\t\t} else if ( getAnchorRect ) {\n\t\t\treturn (\n\t\t\t\tgetAnchorRect( anchorRefFallback.current )?.ownerDocument ??\n\t\t\t\tdocument\n\t\t\t);\n\t\t}\n\n\t\treturn document;\n\t}, [ anchorRef, anchorRect, getAnchorRect ] );\n\n\t/**\n\t * Offsets the position of the popover when the anchor is inside an iframe.\n\t */\n\tconst frameOffset = useMemo( () => {\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst { frameElement } = defaultView;\n\n\t\tif ( ! frameElement || ownerDocument === document ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst iframeRect = frameElement.getBoundingClientRect();\n\t\treturn {\n\t\t\tname: 'iframeOffset',\n\t\t\tfn( { x, y } ) {\n\t\t\t\treturn {\n\t\t\t\t\tx: x + iframeRect.left,\n\t\t\t\t\ty: y + iframeRect.top,\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t}, [ ownerDocument ] );\n\n\tconst middlewares = [\n\t\tframeOffset,\n\t\toffset ? offsetMiddleware( offset ) : undefined,\n\t\t__unstableForcePosition ? undefined : flip(),\n\t\t__unstableForcePosition\n\t\t\t? undefined\n\t\t\t: size( {\n\t\t\t\t\tapply( sizeProps ) {\n\t\t\t\t\t\tconst { height } = sizeProps;\n\t\t\t\t\t\tif ( ! refs.floating.current ) return;\n\t\t\t\t\t\t// Reduce the height of the popover to the available space.\n\t\t\t\t\t\tObject.assign( refs.floating.current.firstChild.style, {\n\t\t\t\t\t\t\tmaxHeight: `${ height }px`,\n\t\t\t\t\t\t\toverflow: 'auto',\n\t\t\t\t\t\t} );\n\t\t\t\t\t},\n\t\t\t } ),\n\t\t__unstableShift\n\t\t\t? shift( {\n\t\t\t\t\tcrossAxis: true,\n\t\t\t\t\tlimiter: limitShift(),\n\t\t\t\t\tpadding: 1, // Necessary to avoid flickering at the edge of the viewport.\n\t\t\t } )\n\t\t\t: undefined,\n\t\thasArrow ? arrow( { element: arrowRef } ) : undefined,\n\t].filter( ( m ) => !! m );\n\tconst slotName = useContext( slotNameContext ) || __unstableSlotName;\n\tconst slot = useSlot( slotName );\n\n\tconst onDialogClose = ( type, event ) => {\n\t\t// Ideally the popover should have just a single onClose prop and\n\t\t// not three props that potentially do the same thing.\n\t\tif ( type === 'focus-outside' && onFocusOutside ) {\n\t\t\tonFocusOutside( event );\n\t\t} else if ( onClose ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst [ dialogRef, dialogProps ] = useDialog( {\n\t\tfocusOnMount,\n\t\t__unstableOnClose: onDialogClose,\n\t\tonClose: onDialogClose,\n\t} );\n\n\tconst {\n\t\tx,\n\t\ty,\n\t\treference,\n\t\tfloating,\n\t\tstrategy,\n\t\trefs,\n\t\tupdate,\n\t\tplacement: placementData,\n\t\tmiddlewareData: { arrow: arrowData = {} },\n\t} = useFloating( {\n\t\tplacement: usedPlacement,\n\t\tmiddleware: middlewares,\n\t} );\n\tconst staticSide = {\n\t\ttop: 'bottom',\n\t\tright: 'left',\n\t\tbottom: 'top',\n\t\tleft: 'right',\n\t}[ placementData.split( '-' )[ 0 ] ];\n\tconst mergedRefs = useMergeRefs( [ floating, dialogRef, ref ] );\n\n\t// Updates references\n\tuseLayoutEffect( () => {\n\t\t// No ref or position have been passed\n\t\tlet usedRef;\n\t\tif ( anchorRef?.top ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\tconst topRect = anchorRef.top.getBoundingClientRect();\n\t\t\t\t\tconst bottomRect = anchorRef.bottom.getBoundingClientRect();\n\t\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\t\ttopRect.x,\n\t\t\t\t\t\ttopRect.y,\n\t\t\t\t\t\ttopRect.width,\n\t\t\t\t\t\tbottomRect.bottom - topRect.top\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( anchorRef?.current ) {\n\t\t\tusedRef = anchorRef.current;\n\t\t} else if ( anchorRef ) {\n\t\t\tusedRef = anchorRef;\n\t\t} else if ( anchorRect ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\treturn anchorRect;\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( getAnchorRect ) {\n\t\t\tusedRef = {\n\t\t\t\tgetBoundingClientRect() {\n\t\t\t\t\tconst rect = getAnchorRect( anchorRefFallback.current );\n\t\t\t\t\treturn new window.DOMRect(\n\t\t\t\t\t\trect.x ?? rect.left,\n\t\t\t\t\t\trect.y ?? rect.top,\n\t\t\t\t\t\trect.width ?? rect.right - rect.left,\n\t\t\t\t\t\trect.height ?? rect.bottom - rect.top\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\t\t} else if ( anchorRefFallback.current ) {\n\t\t\tusedRef = anchorRefFallback.current;\n\t\t}\n\n\t\tif ( ! usedRef ) {\n\t\t\treturn;\n\t\t}\n\n\t\treference( usedRef );\n\n\t\tif ( ! refs.floating.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn autoUpdate( usedRef, refs.floating.current, update );\n\t}, [ anchorRef, anchorRect, getAnchorRect ] );\n\n\t// This is only needed for a smoth transition when moving blocks.\n\tuseLayoutEffect( () => {\n\t\tif ( ! __unstableObserveElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( update );\n\t\tobserver.observe( __unstableObserveElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ __unstableObserveElement ] );\n\n\t// If we're using getAnchorRect, we need to update the position as we scroll the iframe.\n\tuseLayoutEffect( () => {\n\t\tif ( ownerDocument === document ) {\n\t\t\treturn;\n\t\t}\n\n\t\townerDocument.addEventListener( 'scroll', update );\n\t\treturn () => ownerDocument.removeEventListener( 'scroll', update );\n\t}, [ ownerDocument ] );\n\n\t/** @type {false | string} */\n\tconst animateClassName =\n\t\t!! animate &&\n\t\tgetAnimateClassName( {\n\t\t\ttype: 'appear',\n\t\t\torigin: placementToAnimationOrigin( placementData ),\n\t\t} );\n\n\t// Disable reason: We care to capture the _bubbled_ events from inputs\n\t// within popover as inferring close intent.\n\n\tlet content = (\n\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'components-popover',\n\t\t\t\tclassName,\n\t\t\t\tanimateClassName,\n\t\t\t\t{\n\t\t\t\t\t'is-expanded': isExpanded,\n\t\t\t\t\t'is-alternate': isAlternate,\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ ...contentProps }\n\t\t\tref={ mergedRefs }\n\t\t\t{ ...dialogProps }\n\t\t\ttabIndex=\"-1\"\n\t\t\tstyle={\n\t\t\t\tisExpanded\n\t\t\t\t\t? undefined\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tposition: strategy,\n\t\t\t\t\t\t\tleft: Number.isNaN( x ) ? 0 : x,\n\t\t\t\t\t\t\ttop: Number.isNaN( y ) ? 0 : y,\n\t\t\t\t\t }\n\t\t\t}\n\t\t>\n\t\t\t{ isExpanded && <ScrollLock /> }\n\t\t\t{ isExpanded && (\n\t\t\t\t<div className=\"components-popover__header\">\n\t\t\t\t\t<span className=\"components-popover__header-title\">\n\t\t\t\t\t\t{ headerTitle }\n\t\t\t\t\t</span>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"components-popover__close\"\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"components-popover__content\">{ children }</div>\n\t\t\t{ hasArrow && (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"components-popover__arrow\"\n\t\t\t\t\tref={ arrowRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tleft:\n\t\t\t\t\t\t\t! arrowData?.x || Number.isNaN( arrowData?.x )\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: arrowData.x,\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\t! arrowData?.y || Number.isNaN( arrowData?.y )\n\t\t\t\t\t\t\t\t? 0\n\t\t\t\t\t\t\t\t: arrowData.y,\n\t\t\t\t\t\tright: undefined,\n\t\t\t\t\t\tbottom: undefined,\n\t\t\t\t\t\t[ staticSide ]: '-4px',\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n\n\tif ( slot.ref ) {\n\t\tcontent = <Fill name={ slotName }>{ content }</Fill>;\n\t}\n\n\tif ( anchorRef || anchorRect ) {\n\t\treturn content;\n\t}\n\n\treturn <span ref={ anchorRefFallback }>{ content }</span>;\n};\n\nconst PopoverContainer = forwardRef( Popover );\n\nfunction PopoverSlot( { name = SLOT_NAME }, ref ) {\n\treturn (\n\t\t<Slot\n\t\t\tbubblesVirtually\n\t\t\tname={ name }\n\t\t\tclassName=\"popover-slot\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nPopoverContainer.Slot = forwardRef( PopoverSlot );\nPopoverContainer.__unstableSlotNameProvider = slotNameContext.Provider;\n\nexport default PopoverContainer;\n"]}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.RangeControl = void 0;
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
@@ -37,8 +37,6 @@ var _tooltip = _interopRequireDefault(require("./tooltip"));
|
|
|
37
37
|
|
|
38
38
|
var _rangeControlStyles = require("./styles/range-control-styles");
|
|
39
39
|
|
|
40
|
-
// @ts-nocheck
|
|
41
|
-
|
|
42
40
|
/**
|
|
43
41
|
* External dependencies
|
|
44
42
|
*/
|
|
@@ -52,82 +50,74 @@ var _rangeControlStyles = require("./styles/range-control-styles");
|
|
|
52
50
|
*/
|
|
53
51
|
const noop = () => {};
|
|
54
52
|
|
|
55
|
-
function
|
|
53
|
+
function UnforwardedRangeControl(props, forwardedRef) {
|
|
56
54
|
var _inputRef$current;
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
const {
|
|
59
57
|
afterIcon,
|
|
60
58
|
allowReset = false,
|
|
61
59
|
beforeIcon,
|
|
62
60
|
className,
|
|
63
|
-
currentInput,
|
|
64
61
|
color: colorProp = _utils.COLORS.ui.theme,
|
|
62
|
+
currentInput,
|
|
65
63
|
disabled = false,
|
|
66
64
|
help,
|
|
65
|
+
hideLabelFromVision = false,
|
|
67
66
|
initialPosition,
|
|
68
67
|
isShiftStepEnabled = true,
|
|
69
68
|
label,
|
|
70
|
-
hideLabelFromVision = false,
|
|
71
69
|
marks = false,
|
|
72
70
|
max = 100,
|
|
73
71
|
min = 0,
|
|
74
72
|
onBlur = noop,
|
|
75
73
|
onChange = noop,
|
|
76
74
|
onFocus = noop,
|
|
77
|
-
onMouseMove = noop,
|
|
78
75
|
onMouseLeave = noop,
|
|
76
|
+
onMouseMove = noop,
|
|
79
77
|
railColor,
|
|
80
|
-
resetFallbackValue,
|
|
81
78
|
renderTooltipContent = v => v,
|
|
82
|
-
|
|
79
|
+
resetFallbackValue,
|
|
83
80
|
shiftStep = 10,
|
|
81
|
+
showTooltip: showTooltipProp,
|
|
84
82
|
step = 1,
|
|
85
83
|
trackColor,
|
|
86
84
|
value: valueProp,
|
|
87
85
|
withInputField = true,
|
|
88
|
-
...
|
|
89
|
-
} =
|
|
86
|
+
...otherProps
|
|
87
|
+
} = props;
|
|
90
88
|
const [value, setValue] = (0, _utils2.useControlledRangeValue)({
|
|
91
89
|
min,
|
|
92
90
|
max,
|
|
93
|
-
value: valueProp,
|
|
91
|
+
value: valueProp !== null && valueProp !== void 0 ? valueProp : null,
|
|
94
92
|
initial: initialPosition
|
|
95
93
|
});
|
|
96
94
|
const isResetPendent = (0, _element.useRef)(false);
|
|
95
|
+
let hasTooltip = showTooltipProp;
|
|
96
|
+
let hasInputField = withInputField;
|
|
97
97
|
|
|
98
98
|
if (step === 'any') {
|
|
99
99
|
// The tooltip and number input field are hidden when the step is "any"
|
|
100
100
|
// because the decimals get too lengthy to fit well.
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
hasTooltip = false;
|
|
102
|
+
hasInputField = false;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
const [showTooltip, setShowTooltip] = (0, _element.useState)(
|
|
105
|
+
const [showTooltip, setShowTooltip] = (0, _element.useState)(hasTooltip);
|
|
106
106
|
const [isFocused, setIsFocused] = (0, _element.useState)(false);
|
|
107
107
|
const inputRef = (0, _element.useRef)();
|
|
108
|
-
|
|
109
|
-
const setRef = nodeRef => {
|
|
110
|
-
inputRef.current = nodeRef;
|
|
111
|
-
|
|
112
|
-
if (ref) {
|
|
113
|
-
ref(nodeRef);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
108
|
const isCurrentlyFocused = (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.matches(':focus');
|
|
118
109
|
const isThumbFocused = !disabled && isFocused;
|
|
119
110
|
const isValueReset = value === null;
|
|
120
111
|
const currentValue = value !== undefined ? value : currentInput;
|
|
121
112
|
const inputSliderValue = isValueReset ? '' : currentValue;
|
|
122
113
|
const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;
|
|
123
|
-
const
|
|
124
|
-
const fillValue = isValueReset ? 50 : calculatedFillValue;
|
|
114
|
+
const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;
|
|
125
115
|
const fillValueOffset = `${(0, _math.clamp)(fillValue, 0, 100)}%`;
|
|
126
116
|
const classes = (0, _classnames.default)('components-range-control', className);
|
|
127
117
|
const wrapperClasses = (0, _classnames.default)('components-range-control__wrapper', !!marks && 'is-marked');
|
|
128
|
-
const id = (0, _compose.useInstanceId)(
|
|
118
|
+
const id = (0, _compose.useInstanceId)(UnforwardedRangeControl, 'inspector-range-control');
|
|
129
119
|
const describedBy = !!help ? `${id}__help` : undefined;
|
|
130
|
-
const enableTooltip =
|
|
120
|
+
const enableTooltip = hasTooltip !== false && Number.isFinite(value);
|
|
131
121
|
|
|
132
122
|
const handleOnRangeChange = event => {
|
|
133
123
|
const nextValue = parseFloat(event.target.value);
|
|
@@ -135,8 +125,8 @@ function RangeControl(_ref, ref) {
|
|
|
135
125
|
onChange(nextValue);
|
|
136
126
|
};
|
|
137
127
|
|
|
138
|
-
const handleOnChange =
|
|
139
|
-
nextValue = parseFloat(
|
|
128
|
+
const handleOnChange = next => {
|
|
129
|
+
let nextValue = parseFloat(next);
|
|
140
130
|
setValue(nextValue);
|
|
141
131
|
/*
|
|
142
132
|
* Calls onChange only when nextValue is numeric
|
|
@@ -163,7 +153,7 @@ function RangeControl(_ref, ref) {
|
|
|
163
153
|
};
|
|
164
154
|
|
|
165
155
|
const handleOnReset = () => {
|
|
166
|
-
let resetValue = parseFloat(resetFallbackValue);
|
|
156
|
+
let resetValue = parseFloat(`${resetFallbackValue}`);
|
|
167
157
|
let onChangeResetValue = resetValue;
|
|
168
158
|
|
|
169
159
|
if (isNaN(resetValue)) {
|
|
@@ -212,7 +202,7 @@ function RangeControl(_ref, ref) {
|
|
|
212
202
|
className: classes,
|
|
213
203
|
label: label,
|
|
214
204
|
hideLabelFromVision: hideLabelFromVision,
|
|
215
|
-
id: id
|
|
205
|
+
id: `${id}`,
|
|
216
206
|
help: help
|
|
217
207
|
}, (0, _element.createElement)(_rangeControlStyles.Root, {
|
|
218
208
|
className: "components-range-control__root"
|
|
@@ -222,11 +212,11 @@ function RangeControl(_ref, ref) {
|
|
|
222
212
|
className: wrapperClasses,
|
|
223
213
|
color: colorProp,
|
|
224
214
|
marks: !!marks
|
|
225
|
-
}, (0, _element.createElement)(_inputRange.default, (0, _extends2.default)({},
|
|
215
|
+
}, (0, _element.createElement)(_inputRange.default, (0, _extends2.default)({}, otherProps, {
|
|
226
216
|
className: "components-range-control__slider",
|
|
227
217
|
describedBy: describedBy,
|
|
228
218
|
disabled: disabled,
|
|
229
|
-
id: id
|
|
219
|
+
id: `${id}`,
|
|
230
220
|
label: label,
|
|
231
221
|
max: max,
|
|
232
222
|
min: min,
|
|
@@ -235,9 +225,9 @@ function RangeControl(_ref, ref) {
|
|
|
235
225
|
onFocus: handleOnFocus,
|
|
236
226
|
onMouseMove: onMouseMove,
|
|
237
227
|
onMouseLeave: onMouseLeave,
|
|
238
|
-
ref:
|
|
228
|
+
ref: (0, _compose.useMergeRefs)([inputRef, forwardedRef]),
|
|
239
229
|
step: step,
|
|
240
|
-
value: inputSliderValue
|
|
230
|
+
value: inputSliderValue !== null && inputSliderValue !== void 0 ? inputSliderValue : undefined
|
|
241
231
|
})), (0, _element.createElement)(_rail.default, {
|
|
242
232
|
"aria-hidden": true,
|
|
243
233
|
disabled: disabled,
|
|
@@ -272,7 +262,7 @@ function RangeControl(_ref, ref) {
|
|
|
272
262
|
value: value
|
|
273
263
|
})), afterIcon && (0, _element.createElement)(_rangeControlStyles.AfterIconWrapper, null, (0, _element.createElement)(_icon.default, {
|
|
274
264
|
icon: afterIcon
|
|
275
|
-
})),
|
|
265
|
+
})), hasInputField && (0, _element.createElement)(_rangeControlStyles.InputNumber, {
|
|
276
266
|
"aria-label": label,
|
|
277
267
|
className: "components-range-control__number",
|
|
278
268
|
disabled: disabled,
|
|
@@ -293,8 +283,32 @@ function RangeControl(_ref, ref) {
|
|
|
293
283
|
onClick: handleOnReset
|
|
294
284
|
}, (0, _i18n.__)('Reset')))));
|
|
295
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* RangeControls are used to make selections from a range of incremental values.
|
|
288
|
+
*
|
|
289
|
+
* ```jsx
|
|
290
|
+
* import { RangeControl } from '@wordpress/components';
|
|
291
|
+
* import { useState } from '@wordpress/element';
|
|
292
|
+
*
|
|
293
|
+
* const MyRangeControl = () => {
|
|
294
|
+
* const [ isChecked, setChecked ] = useState( true );
|
|
295
|
+
* return (
|
|
296
|
+
* <RangeControl
|
|
297
|
+
* help="Please select how transparent you would like this."
|
|
298
|
+
* initialPosition={50}
|
|
299
|
+
* label="Opacity"
|
|
300
|
+
* max={100}
|
|
301
|
+
* min={0}
|
|
302
|
+
* onChange={() => {}}
|
|
303
|
+
* />
|
|
304
|
+
* );
|
|
305
|
+
* };
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
|
|
296
309
|
|
|
297
|
-
const
|
|
298
|
-
|
|
310
|
+
const RangeControl = (0, _element.forwardRef)(UnforwardedRangeControl);
|
|
311
|
+
exports.RangeControl = RangeControl;
|
|
312
|
+
var _default = RangeControl;
|
|
299
313
|
exports.default = _default;
|
|
300
314
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/components/src/range-control/index.js"],"names":["noop","RangeControl","ref","afterIcon","allowReset","beforeIcon","className","currentInput","color","colorProp","COLORS","ui","theme","disabled","help","initialPosition","isShiftStepEnabled","label","hideLabelFromVision","marks","max","min","onBlur","onChange","onFocus","onMouseMove","onMouseLeave","railColor","resetFallbackValue","renderTooltipContent","v","showTooltip","showTooltipProp","shiftStep","step","trackColor","value","valueProp","withInputField","props","setValue","initial","isResetPendent","setShowTooltip","isFocused","setIsFocused","inputRef","setRef","nodeRef","current","isCurrentlyFocused","matches","isThumbFocused","isValueReset","currentValue","undefined","inputSliderValue","rangeFillValue","calculatedFillValue","fillValue","fillValueOffset","classes","wrapperClasses","id","describedBy","enableTooltip","Number","isFinite","handleOnRangeChange","event","nextValue","parseFloat","target","handleOnChange","isNaN","handleOnInputNumberBlur","handleOnReset","resetValue","onChangeResetValue","handleShowTooltip","handleHideTooltip","handleOnBlur","handleOnFocus","offsetStyle","width","ForwardedComponent"],"mappings":";;;;;;;;;AAUA;;;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAsBA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,YAAT,OAiCCC,GAjCD,EAkCE;AAAA;;AAAA,MAjCD;AACCC,IAAAA,SADD;AAECC,IAAAA,UAAU,GAAG,KAFd;AAGCC,IAAAA,UAHD;AAICC,IAAAA,SAJD;AAKCC,IAAAA,YALD;AAMCC,IAAAA,KAAK,EAAEC,SAAS,GAAGC,cAAOC,EAAP,CAAUC,KAN9B;AAOCC,IAAAA,QAAQ,GAAG,KAPZ;AAQCC,IAAAA,IARD;AASCC,IAAAA,eATD;AAUCC,IAAAA,kBAAkB,GAAG,IAVtB;AAWCC,IAAAA,KAXD;AAYCC,IAAAA,mBAAmB,GAAG,KAZvB;AAaCC,IAAAA,KAAK,GAAG,KAbT;AA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WANT;AAOC,IAAA,KAAK,EAAG/C;AAPT,IAhDF,CAND,EAiEGjC,SAAS,IACV,4BAAC,oCAAD,QACC,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGA;AAAb,IADD,CAlEF,EAsEGmC,cAAc,IACf,4BAAC,+BAAD;AACC,kBAAarB,KADd;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,QAAQ,EAAGJ,QAHZ;AAIC,IAAA,SAAS,EAAC,SAJX;AAKC,IAAA,kBAAkB,EAAGG,kBALtB;AAMC,IAAA,GAAG,EAAGI,GANP;AAOC,IAAA,GAAG,EAAGC,GAPP;AAQC,IAAA,MAAM,EAAGsD,uBARV;AASC,IAAA,QAAQ,EAAGF,cATZ;AAUC,IAAA,SAAS,EAAGxC,SAVb;AAWC,IAAA,IAAI,EAAGC,IAXR;AAYC,IAAA,KAAK,EAAGsB;AAZT,IAvEF,EAsFGpD,UAAU,IACX,4BAAC,sCAAD,QACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,QAAQ,EAAGS,QAAQ,IAAIuB,KAAK,KAAKmB,SAFlC;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,IAAA,OAAO,MAJR;AAKC,IAAA,OAAO,EAAGqB;AALX,KAOG,cAAI,OAAJ,CAPH,CADD,CAvFF,CAPD,CADD;AA8GA;;AAED,MAAMS,kBAAkB,GAAG,yBAAYpF,YAAZ,CAA3B;eAEeoF,kB","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport {\n\tActionRightWrapper,\n\tAfterIconWrapper,\n\tBeforeIconWrapper,\n\tInputNumber,\n\tRoot,\n\tTrack,\n\tThumbWrapper,\n\tThumb,\n\tWrapper,\n} from './styles/range-control-styles';\n\nconst noop = () => {};\n\nfunction RangeControl(\n\t{\n\t\tafterIcon,\n\t\tallowReset = false,\n\t\tbeforeIcon,\n\t\tclassName,\n\t\tcurrentInput,\n\t\tcolor: colorProp = COLORS.ui.theme,\n\t\tdisabled = false,\n\t\thelp,\n\t\tinitialPosition,\n\t\tisShiftStepEnabled = true,\n\t\tlabel,\n\t\thideLabelFromVision = false,\n\t\tmarks = false,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\tonBlur = noop,\n\t\tonChange = noop,\n\t\tonFocus = noop,\n\t\tonMouseMove = noop,\n\t\tonMouseLeave = noop,\n\t\trailColor,\n\t\tresetFallbackValue,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tshowTooltip: showTooltipProp,\n\t\tshiftStep = 10,\n\t\tstep = 1,\n\t\ttrackColor,\n\t\tvalue: valueProp,\n\t\twithInputField = true,\n\t\t...props\n\t},\n\tref\n) {\n\tconst [ value, setValue ] = useControlledRangeValue( {\n\t\tmin,\n\t\tmax,\n\t\tvalue: valueProp,\n\t\tinitial: initialPosition,\n\t} );\n\tconst isResetPendent = useRef( false );\n\n\tif ( step === 'any' ) {\n\t\t// The tooltip and number input field are hidden when the step is \"any\"\n\t\t// because the decimals get too lengthy to fit well.\n\t\tshowTooltipProp = false;\n\t\twithInputField = false;\n\t}\n\n\tconst [ showTooltip, setShowTooltip ] = useState( showTooltipProp );\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\tconst inputRef = useRef();\n\n\tconst setRef = ( nodeRef ) => {\n\t\tinputRef.current = nodeRef;\n\n\t\tif ( ref ) {\n\t\t\tref( nodeRef );\n\t\t}\n\t};\n\n\tconst isCurrentlyFocused = inputRef.current?.matches( ':focus' );\n\tconst isThumbFocused = ! disabled && isFocused;\n\n\tconst isValueReset = value === null;\n\tconst currentValue = value !== undefined ? value : currentInput;\n\n\tconst inputSliderValue = isValueReset ? '' : currentValue;\n\n\tconst rangeFillValue = isValueReset ? ( max - min ) / 2 + min : value;\n\n\tconst calculatedFillValue = ( ( value - min ) / ( max - min ) ) * 100;\n\tconst fillValue = isValueReset ? 50 : calculatedFillValue;\n\tconst fillValueOffset = `${ clamp( fillValue, 0, 100 ) }%`;\n\n\tconst classes = classnames( 'components-range-control', className );\n\n\tconst wrapperClasses = classnames(\n\t\t'components-range-control__wrapper',\n\t\t!! marks && 'is-marked'\n\t);\n\n\tconst id = useInstanceId( RangeControl, 'inspector-range-control' );\n\tconst describedBy = !! help ? `${ id }__help` : undefined;\n\tconst enableTooltip = showTooltipProp !== false && Number.isFinite( value );\n\n\tconst handleOnRangeChange = ( event ) => {\n\t\tconst nextValue = parseFloat( event.target.value );\n\t\tsetValue( nextValue );\n\t\tonChange( nextValue );\n\t};\n\n\tconst handleOnChange = ( nextValue ) => {\n\t\tnextValue = parseFloat( nextValue );\n\t\tsetValue( nextValue );\n\t\t/*\n\t\t * Calls onChange only when nextValue is numeric\n\t\t * otherwise may queue a reset for the blur event.\n\t\t */\n\t\tif ( ! isNaN( nextValue ) ) {\n\t\t\tif ( nextValue < min || nextValue > max ) {\n\t\t\t\tnextValue = floatClamp( nextValue, min, max );\n\t\t\t}\n\t\t\tonChange( nextValue );\n\t\t\tisResetPendent.current = false;\n\t\t} else if ( allowReset ) {\n\t\t\tisResetPendent.current = true;\n\t\t}\n\t};\n\n\tconst handleOnInputNumberBlur = () => {\n\t\tif ( isResetPendent.current ) {\n\t\t\thandleOnReset();\n\t\t\tisResetPendent.current = false;\n\t\t}\n\t};\n\n\tconst handleOnReset = () => {\n\t\tlet resetValue = parseFloat( resetFallbackValue );\n\t\tlet onChangeResetValue = resetValue;\n\n\t\tif ( isNaN( resetValue ) ) {\n\t\t\tresetValue = null;\n\t\t\tonChangeResetValue = undefined;\n\t\t}\n\n\t\tsetValue( resetValue );\n\n\t\t/**\n\t\t * Previously, this callback would always receive undefined as\n\t\t * an argument. This behavior is unexpected, specifically\n\t\t * when resetFallbackValue is defined.\n\t\t *\n\t\t * The value of undefined is not ideal. Passing it through\n\t\t * to internal <input /> elements would change it from a\n\t\t * controlled component to an uncontrolled component.\n\t\t *\n\t\t * For now, to minimize unexpected regressions, we're going to\n\t\t * preserve the undefined callback argument, except when a\n\t\t * resetFallbackValue is defined.\n\t\t */\n\t\tonChange( onChangeResetValue );\n\t};\n\n\tconst handleShowTooltip = () => setShowTooltip( true );\n\tconst handleHideTooltip = () => setShowTooltip( false );\n\n\tconst handleOnBlur = ( event ) => {\n\t\tonBlur( event );\n\t\tsetIsFocused( false );\n\t\thandleHideTooltip();\n\t};\n\n\tconst handleOnFocus = ( event ) => {\n\t\tonFocus( event );\n\t\tsetIsFocused( true );\n\t\thandleShowTooltip();\n\t};\n\n\tconst offsetStyle = {\n\t\t[ isRTL() ? 'right' : 'left' ]: fillValueOffset,\n\t};\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName={ classes }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ id }\n\t\t\thelp={ help }\n\t\t>\n\t\t\t<Root className=\"components-range-control__root\">\n\t\t\t\t{ beforeIcon && (\n\t\t\t\t\t<BeforeIconWrapper>\n\t\t\t\t\t\t<Icon icon={ beforeIcon } />\n\t\t\t\t\t</BeforeIconWrapper>\n\t\t\t\t) }\n\t\t\t\t<Wrapper\n\t\t\t\t\tclassName={ wrapperClasses }\n\t\t\t\t\tcolor={ colorProp }\n\t\t\t\t\tmarks={ !! marks }\n\t\t\t\t>\n\t\t\t\t\t<InputRange\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\tclassName=\"components-range-control__slider\"\n\t\t\t\t\t\tdescribedBy={ describedBy }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\t\tonChange={ handleOnRangeChange }\n\t\t\t\t\t\tonFocus={ handleOnFocus }\n\t\t\t\t\t\tonMouseMove={ onMouseMove }\n\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\tref={ setRef }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ inputSliderValue }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeRail\n\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tmarks={ marks }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\trailColor={ railColor }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ rangeFillValue }\n\t\t\t\t\t/>\n\t\t\t\t\t<Track\n\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\tclassName=\"components-range-control__track\"\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tstyle={ { width: fillValueOffset } }\n\t\t\t\t\t\ttrackColor={ trackColor }\n\t\t\t\t\t/>\n\t\t\t\t\t<ThumbWrapper style={ offsetStyle } disabled={ disabled }>\n\t\t\t\t\t\t<Thumb\n\t\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\t\tisFocused={ isThumbFocused }\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ThumbWrapper>\n\t\t\t\t\t{ enableTooltip && (\n\t\t\t\t\t\t<SimpleTooltip\n\t\t\t\t\t\t\tclassName=\"components-range-control__tooltip\"\n\t\t\t\t\t\t\tinputRef={ inputRef }\n\t\t\t\t\t\t\ttooltipPosition=\"bottom\"\n\t\t\t\t\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\t\t\t\t\tshow={ isCurrentlyFocused || showTooltip }\n\t\t\t\t\t\t\tstyle={ offsetStyle }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Wrapper>\n\t\t\t\t{ afterIcon && (\n\t\t\t\t\t<AfterIconWrapper>\n\t\t\t\t\t\t<Icon icon={ afterIcon } />\n\t\t\t\t\t</AfterIconWrapper>\n\t\t\t\t) }\n\t\t\t\t{ withInputField && (\n\t\t\t\t\t<InputNumber\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\tclassName=\"components-range-control__number\"\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\tisShiftStepEnabled={ isShiftStepEnabled }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnInputNumberBlur }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tshiftStep={ shiftStep }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ inputSliderValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowReset && (\n\t\t\t\t\t<ActionRightWrapper>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"components-range-control__reset\"\n\t\t\t\t\t\t\tdisabled={ disabled || value === undefined }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</ActionRightWrapper>\n\t\t\t\t) }\n\t\t\t</Root>\n\t\t</BaseControl>\n\t);\n}\n\nconst ForwardedComponent = forwardRef( RangeControl );\n\nexport default ForwardedComponent;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/components/src/range-control/index.tsx"],"names":["noop","UnforwardedRangeControl","props","forwardedRef","afterIcon","allowReset","beforeIcon","className","color","colorProp","COLORS","ui","theme","currentInput","disabled","help","hideLabelFromVision","initialPosition","isShiftStepEnabled","label","marks","max","min","onBlur","onChange","onFocus","onMouseLeave","onMouseMove","railColor","renderTooltipContent","v","resetFallbackValue","shiftStep","showTooltip","showTooltipProp","step","trackColor","value","valueProp","withInputField","otherProps","setValue","initial","isResetPendent","hasTooltip","hasInputField","setShowTooltip","isFocused","setIsFocused","inputRef","isCurrentlyFocused","current","matches","isThumbFocused","isValueReset","currentValue","undefined","inputSliderValue","rangeFillValue","fillValue","fillValueOffset","classes","wrapperClasses","id","describedBy","enableTooltip","Number","isFinite","handleOnRangeChange","event","nextValue","parseFloat","target","handleOnChange","next","isNaN","handleOnInputNumberBlur","handleOnReset","resetValue","onChangeResetValue","handleShowTooltip","handleHideTooltip","handleOnBlur","handleOnFocus","offsetStyle","width","RangeControl"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAMA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAzBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AAyBA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,uBAAT,CACCC,KADD,EAMCC,YAND,EAOE;AAAA;;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,UAAU,GAAG,KAFR;AAGLC,IAAAA,UAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,KAAK,EAAEC,SAAS,GAAGC,cAAOC,EAAP,CAAUC,KALxB;AAMLC,IAAAA,YANK;AAOLC,IAAAA,QAAQ,GAAG,KAPN;AAQLC,IAAAA,IARK;AASLC,IAAAA,mBAAmB,GAAG,KATjB;AAULC,IAAAA,eAVK;AAWLC,IAAAA,kBAAkB,GAAG,IAXhB;AAYLC,IAAAA,KAZK;AAaLC,IAAAA,KAAK,GAAG,KAb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,kBAAkB,IAAIjB,WAL9B;AAMC,IAAA,KAAK,EAAGmD,WANT;AAOC,IAAA,KAAK,EAAG/C;AAPT,IAhDF,CAND,EAiEGjC,SAAS,IACV,4BAAC,oCAAD,QACC,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGA;AAAb,IADD,CAlEF,EAsEGyC,aAAa,IACd,4BAAC,+BAAD;AACC,kBAAa1B,KADd;AAEC,IAAA,SAAS,EAAC,kCAFX;AAGC,IAAA,QAAQ,EAAGL,QAHZ;AAIC,IAAA,SAAS,EAAC,SAJX;AAKC,IAAA,kBAAkB,EAAGI,kBALtB;AAMC,IAAA,GAAG,EAAGG,GANP;AAOC,IAAA,GAAG,EAAGC,GAPP;AAQC,IAAA,MAAM,EAAGsD,uBARV;AASC,IAAA,QAAQ,EAAGH,cATZ;AAUC,IAAA,SAAS,EAAGzC,SAVb;AAWC,IAAA,IAAI,EAAGG,IAXR;AAYC,IAAA,KAAK,EAAGsB;AAZT,IAvEF,EAsFGpD,UAAU,IACX,4BAAC,sCAAD,QACC,4BAAC,eAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,QAAQ,EAAGS,QAAQ,IAAIuB,KAAK,KAAKmB,SAFlC;AAGC,IAAA,OAAO,EAAC,WAHT;AAIC,IAAA,OAAO,MAJR;AAKC,IAAA,OAAO,EAAGqB;AALX,KAOG,cAAI,OAAJ,CAPH,CADD,CAvFF,CAPD,CADD;AA8GA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMS,YAAY,GAAG,yBAAYrF,uBAAZ,CAArB;;eAEQqF,Y","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport type { ChangeEvent, FocusEvent, ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport {\n\tActionRightWrapper,\n\tAfterIconWrapper,\n\tBeforeIconWrapper,\n\tInputNumber,\n\tRoot,\n\tTrack,\n\tThumbWrapper,\n\tThumb,\n\tWrapper,\n} from './styles/range-control-styles';\n\nimport type { RangeControlProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst noop = () => {};\n\nfunction UnforwardedRangeControl< IconProps = unknown >(\n\tprops: WordPressComponentProps<\n\t\tRangeControlProps< IconProps >,\n\t\t'input',\n\t\tfalse\n\t>,\n\tforwardedRef: ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\tafterIcon,\n\t\tallowReset = false,\n\t\tbeforeIcon,\n\t\tclassName,\n\t\tcolor: colorProp = COLORS.ui.theme,\n\t\tcurrentInput,\n\t\tdisabled = false,\n\t\thelp,\n\t\thideLabelFromVision = false,\n\t\tinitialPosition,\n\t\tisShiftStepEnabled = true,\n\t\tlabel,\n\t\tmarks = false,\n\t\tmax = 100,\n\t\tmin = 0,\n\t\tonBlur = noop,\n\t\tonChange = noop,\n\t\tonFocus = noop,\n\t\tonMouseLeave = noop,\n\t\tonMouseMove = noop,\n\t\trailColor,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tresetFallbackValue,\n\t\tshiftStep = 10,\n\t\tshowTooltip: showTooltipProp,\n\t\tstep = 1,\n\t\ttrackColor,\n\t\tvalue: valueProp,\n\t\twithInputField = true,\n\t\t...otherProps\n\t} = props;\n\n\tconst [ value, setValue ] = useControlledRangeValue( {\n\t\tmin,\n\t\tmax,\n\t\tvalue: valueProp ?? null,\n\t\tinitial: initialPosition,\n\t} );\n\tconst isResetPendent = useRef( false );\n\n\tlet hasTooltip = showTooltipProp;\n\tlet hasInputField = withInputField;\n\n\tif ( step === 'any' ) {\n\t\t// The tooltip and number input field are hidden when the step is \"any\"\n\t\t// because the decimals get too lengthy to fit well.\n\t\thasTooltip = false;\n\t\thasInputField = false;\n\t}\n\n\tconst [ showTooltip, setShowTooltip ] = useState( hasTooltip );\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\n\tconst inputRef = useRef< HTMLInputElement >();\n\tconst isCurrentlyFocused = inputRef.current?.matches( ':focus' );\n\tconst isThumbFocused = ! disabled && isFocused;\n\n\tconst isValueReset = value === null;\n\tconst currentValue = value !== undefined ? value : currentInput;\n\n\tconst inputSliderValue = isValueReset ? '' : currentValue;\n\tconst rangeFillValue = isValueReset ? ( max - min ) / 2 + min : value;\n\n\tconst fillValue = isValueReset\n\t\t? 50\n\t\t: ( ( value - min ) / ( max - min ) ) * 100;\n\tconst fillValueOffset = `${ clamp( fillValue, 0, 100 ) }%`;\n\n\tconst classes = classnames( 'components-range-control', className );\n\n\tconst wrapperClasses = classnames(\n\t\t'components-range-control__wrapper',\n\t\t!! marks && 'is-marked'\n\t);\n\n\tconst id = useInstanceId(\n\t\tUnforwardedRangeControl,\n\t\t'inspector-range-control'\n\t);\n\tconst describedBy = !! help ? `${ id }__help` : undefined;\n\tconst enableTooltip = hasTooltip !== false && Number.isFinite( value );\n\n\tconst handleOnRangeChange = ( event: ChangeEvent< HTMLInputElement > ) => {\n\t\tconst nextValue = parseFloat( event.target.value );\n\t\tsetValue( nextValue );\n\t\tonChange( nextValue );\n\t};\n\n\tconst handleOnChange = ( next: string ) => {\n\t\tlet nextValue = parseFloat( next );\n\t\tsetValue( nextValue );\n\n\t\t/*\n\t\t * Calls onChange only when nextValue is numeric\n\t\t * otherwise may queue a reset for the blur event.\n\t\t */\n\t\tif ( ! isNaN( nextValue ) ) {\n\t\t\tif ( nextValue < min || nextValue > max ) {\n\t\t\t\tnextValue = floatClamp( nextValue, min, max ) as number;\n\t\t\t}\n\n\t\t\tonChange( nextValue );\n\t\t\tisResetPendent.current = false;\n\t\t} else if ( allowReset ) {\n\t\t\tisResetPendent.current = true;\n\t\t}\n\t};\n\n\tconst handleOnInputNumberBlur = () => {\n\t\tif ( isResetPendent.current ) {\n\t\t\thandleOnReset();\n\t\t\tisResetPendent.current = false;\n\t\t}\n\t};\n\n\tconst handleOnReset = () => {\n\t\tlet resetValue: number | null = parseFloat( `${ resetFallbackValue }` );\n\t\tlet onChangeResetValue: number | undefined = resetValue;\n\n\t\tif ( isNaN( resetValue ) ) {\n\t\t\tresetValue = null;\n\t\t\tonChangeResetValue = undefined;\n\t\t}\n\n\t\tsetValue( resetValue );\n\n\t\t/**\n\t\t * Previously, this callback would always receive undefined as\n\t\t * an argument. This behavior is unexpected, specifically\n\t\t * when resetFallbackValue is defined.\n\t\t *\n\t\t * The value of undefined is not ideal. Passing it through\n\t\t * to internal <input /> elements would change it from a\n\t\t * controlled component to an uncontrolled component.\n\t\t *\n\t\t * For now, to minimize unexpected regressions, we're going to\n\t\t * preserve the undefined callback argument, except when a\n\t\t * resetFallbackValue is defined.\n\t\t */\n\t\tonChange( onChangeResetValue );\n\t};\n\n\tconst handleShowTooltip = () => setShowTooltip( true );\n\tconst handleHideTooltip = () => setShowTooltip( false );\n\n\tconst handleOnBlur = ( event: FocusEvent< HTMLInputElement > ) => {\n\t\tonBlur( event );\n\t\tsetIsFocused( false );\n\t\thandleHideTooltip();\n\t};\n\n\tconst handleOnFocus = ( event: FocusEvent< HTMLInputElement > ) => {\n\t\tonFocus( event );\n\t\tsetIsFocused( true );\n\t\thandleShowTooltip();\n\t};\n\n\tconst offsetStyle = {\n\t\t[ isRTL() ? 'right' : 'left' ]: fillValueOffset,\n\t};\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName={ classes }\n\t\t\tlabel={ label }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\tid={ `${ id }` }\n\t\t\thelp={ help }\n\t\t>\n\t\t\t<Root className=\"components-range-control__root\">\n\t\t\t\t{ beforeIcon && (\n\t\t\t\t\t<BeforeIconWrapper>\n\t\t\t\t\t\t<Icon icon={ beforeIcon } />\n\t\t\t\t\t</BeforeIconWrapper>\n\t\t\t\t) }\n\t\t\t\t<Wrapper\n\t\t\t\t\tclassName={ wrapperClasses }\n\t\t\t\t\tcolor={ colorProp }\n\t\t\t\t\tmarks={ !! marks }\n\t\t\t\t>\n\t\t\t\t\t<InputRange\n\t\t\t\t\t\t{ ...otherProps }\n\t\t\t\t\t\tclassName=\"components-range-control__slider\"\n\t\t\t\t\t\tdescribedBy={ describedBy }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tid={ `${ id }` }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\t\tonChange={ handleOnRangeChange }\n\t\t\t\t\t\tonFocus={ handleOnFocus }\n\t\t\t\t\t\tonMouseMove={ onMouseMove }\n\t\t\t\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\t\t\t\tref={ useMergeRefs( [ inputRef, forwardedRef ] ) }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ inputSliderValue ?? undefined }\n\t\t\t\t\t/>\n\t\t\t\t\t<RangeRail\n\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tmarks={ marks }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\trailColor={ railColor }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ rangeFillValue }\n\t\t\t\t\t/>\n\t\t\t\t\t<Track\n\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\tclassName=\"components-range-control__track\"\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tstyle={ { width: fillValueOffset } }\n\t\t\t\t\t\ttrackColor={ trackColor }\n\t\t\t\t\t/>\n\t\t\t\t\t<ThumbWrapper style={ offsetStyle } disabled={ disabled }>\n\t\t\t\t\t\t<Thumb\n\t\t\t\t\t\t\taria-hidden={ true }\n\t\t\t\t\t\t\tisFocused={ isThumbFocused }\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ThumbWrapper>\n\t\t\t\t\t{ enableTooltip && (\n\t\t\t\t\t\t<SimpleTooltip\n\t\t\t\t\t\t\tclassName=\"components-range-control__tooltip\"\n\t\t\t\t\t\t\tinputRef={ inputRef }\n\t\t\t\t\t\t\ttooltipPosition=\"bottom\"\n\t\t\t\t\t\t\trenderTooltipContent={ renderTooltipContent }\n\t\t\t\t\t\t\tshow={ isCurrentlyFocused || showTooltip }\n\t\t\t\t\t\t\tstyle={ offsetStyle }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Wrapper>\n\t\t\t\t{ afterIcon && (\n\t\t\t\t\t<AfterIconWrapper>\n\t\t\t\t\t\t<Icon icon={ afterIcon } />\n\t\t\t\t\t</AfterIconWrapper>\n\t\t\t\t) }\n\t\t\t\t{ hasInputField && (\n\t\t\t\t\t<InputNumber\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\tclassName=\"components-range-control__number\"\n\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\tinputMode=\"decimal\"\n\t\t\t\t\t\tisShiftStepEnabled={ isShiftStepEnabled }\n\t\t\t\t\t\tmax={ max }\n\t\t\t\t\t\tmin={ min }\n\t\t\t\t\t\tonBlur={ handleOnInputNumberBlur }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tshiftStep={ shiftStep }\n\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\tvalue={ inputSliderValue }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ allowReset && (\n\t\t\t\t\t<ActionRightWrapper>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"components-range-control__reset\"\n\t\t\t\t\t\t\tdisabled={ disabled || value === undefined }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\tonClick={ handleOnReset }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</ActionRightWrapper>\n\t\t\t\t) }\n\t\t\t</Root>\n\t\t</BaseControl>\n\t);\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ isChecked, setChecked ] = useState( true );\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={50}\n * label=\"Opacity\"\n * max={100}\n * min={0}\n * onChange={() => {}}\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef( UnforwardedRangeControl );\n\nexport default RangeControl;\n"]}
|
|
@@ -15,8 +15,6 @@ var _rangeControlStyles = require("./styles/range-control-styles");
|
|
|
15
15
|
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
|
|
18
|
-
// @ts-nocheck
|
|
19
|
-
|
|
20
18
|
/**
|
|
21
19
|
* WordPress dependencies
|
|
22
20
|
*/
|
|
@@ -26,8 +24,8 @@ var _utils = require("./utils");
|
|
|
26
24
|
*/
|
|
27
25
|
const noop = () => {};
|
|
28
26
|
|
|
29
|
-
function InputRange(
|
|
30
|
-
|
|
27
|
+
function InputRange(props, ref) {
|
|
28
|
+
const {
|
|
31
29
|
describedBy,
|
|
32
30
|
label,
|
|
33
31
|
onHideTooltip = noop,
|
|
@@ -35,15 +33,15 @@ function InputRange(_ref, ref) {
|
|
|
35
33
|
onMouseMove = noop,
|
|
36
34
|
onShowTooltip = noop,
|
|
37
35
|
value,
|
|
38
|
-
...
|
|
39
|
-
} =
|
|
36
|
+
...otherProps
|
|
37
|
+
} = props;
|
|
40
38
|
const hoverInteractions = (0, _utils.useDebouncedHoverInteraction)({
|
|
41
39
|
onHide: onHideTooltip,
|
|
42
40
|
onMouseLeave,
|
|
43
41
|
onMouseMove,
|
|
44
42
|
onShow: onShowTooltip
|
|
45
43
|
});
|
|
46
|
-
return (0, _element.createElement)(_rangeControlStyles.InputRange, (0, _extends2.default)({},
|
|
44
|
+
return (0, _element.createElement)(_rangeControlStyles.InputRange, (0, _extends2.default)({}, otherProps, hoverInteractions, {
|
|
47
45
|
"aria-describedby": describedBy,
|
|
48
46
|
"aria-label": label,
|
|
49
47
|
"aria-hidden": false,
|