@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/src/popover/index.js
CHANGED
|
@@ -128,6 +128,7 @@ const Popover = (
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
const arrowRef = useRef( null );
|
|
131
|
+
const anchorRefFallback = useRef( null );
|
|
131
132
|
const isMobileViewport = useViewportMatch( 'medium', '<' );
|
|
132
133
|
const isExpanded = expandOnMobile && isMobileViewport;
|
|
133
134
|
const hasArrow = ! isExpanded && ! noArrow;
|
|
@@ -148,14 +149,17 @@ const Popover = (
|
|
|
148
149
|
} else if ( anchorRect && anchorRect?.ownerDocument ) {
|
|
149
150
|
return anchorRect.ownerDocument;
|
|
150
151
|
} else if ( getAnchorRect ) {
|
|
151
|
-
return
|
|
152
|
+
return (
|
|
153
|
+
getAnchorRect( anchorRefFallback.current )?.ownerDocument ??
|
|
154
|
+
document
|
|
155
|
+
);
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
return document;
|
|
155
159
|
}, [ anchorRef, anchorRect, getAnchorRect ] );
|
|
156
160
|
|
|
157
161
|
/**
|
|
158
|
-
* Offsets the
|
|
162
|
+
* Offsets the position of the popover when the anchor is inside an iframe.
|
|
159
163
|
*/
|
|
160
164
|
const frameOffset = useMemo( () => {
|
|
161
165
|
const { defaultView } = ownerDocument;
|
|
@@ -203,7 +207,6 @@ const Popover = (
|
|
|
203
207
|
: undefined,
|
|
204
208
|
hasArrow ? arrow( { element: arrowRef } ) : undefined,
|
|
205
209
|
].filter( ( m ) => !! m );
|
|
206
|
-
const anchorRefFallback = useRef( null );
|
|
207
210
|
const slotName = useContext( slotNameContext ) || __unstableSlotName;
|
|
208
211
|
const slot = useSlot( slotName );
|
|
209
212
|
|
|
@@ -275,7 +278,7 @@ const Popover = (
|
|
|
275
278
|
} else if ( getAnchorRect ) {
|
|
276
279
|
usedRef = {
|
|
277
280
|
getBoundingClientRect() {
|
|
278
|
-
const rect = getAnchorRect();
|
|
281
|
+
const rect = getAnchorRect( anchorRefFallback.current );
|
|
279
282
|
return new window.DOMRect(
|
|
280
283
|
rect.x ?? rect.left,
|
|
281
284
|
rect.y ?? rect.top,
|
|
@@ -109,75 +109,100 @@ const MyRangeControl = () => {
|
|
|
109
109
|
};
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
## Props
|
|
113
113
|
|
|
114
114
|
The set of props accepted by the component will be specified below.
|
|
115
115
|
Props not included in this set will be applied to the input elements.
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
### `afterIcon`: `string|Function|WPComponent|null`
|
|
118
118
|
|
|
119
|
-
If this property is added,
|
|
119
|
+
If this property is added, an [Icon component](/packages/components/src/icon/README.md) will be rendered after the slider with the icon equal to `afterIcon`.
|
|
120
|
+
|
|
121
|
+
For more information on `IconType` see the [Icon component](/packages/components/src/icon/index.tsx#L23).
|
|
122
|
+
|
|
123
|
+
- Required: No
|
|
124
|
+
- Platform: Web
|
|
125
|
+
|
|
126
|
+
### `allowReset`: `boolean`
|
|
127
|
+
|
|
128
|
+
If this property is true, a button to reset the slider is rendered.
|
|
120
129
|
|
|
121
|
-
- Type: `String`
|
|
122
130
|
- Required: No
|
|
131
|
+
- Default: `false`
|
|
123
132
|
- Platform: Web | Mobile
|
|
124
133
|
|
|
125
|
-
|
|
134
|
+
### `beforeIcon`: `string|Function|WPComponent|null`
|
|
126
135
|
|
|
127
|
-
If this property is added,
|
|
136
|
+
If this property is added, an [Icon component](/packages/components/src/icon/README.md) will be rendered before the slider with the icon equal to `beforeIcon`.
|
|
137
|
+
|
|
138
|
+
For more information on `IconType` see the [Icon component](/packages/components/src/icon/index.tsx#L23).
|
|
128
139
|
|
|
129
|
-
- Type: `String|WPElement`
|
|
130
140
|
- Required: No
|
|
131
141
|
- Platform: Web
|
|
132
142
|
|
|
133
|
-
|
|
143
|
+
### `color`: `CSSProperties['color']`
|
|
134
144
|
|
|
135
|
-
|
|
145
|
+
CSS color string for the `RangeControl` wrapper.
|
|
136
146
|
|
|
137
|
-
- Type: `String`
|
|
138
147
|
- Required: No
|
|
139
148
|
- Platform: Web
|
|
140
149
|
|
|
141
|
-
|
|
150
|
+
### `currentInput`: `number`
|
|
142
151
|
|
|
143
|
-
|
|
152
|
+
The current input to use as a fallback if `value` is currently `undefined`.
|
|
144
153
|
|
|
145
|
-
- Type: `String`
|
|
146
154
|
- Required: No
|
|
147
155
|
- Platform: Web
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
### `disabled`: `boolean`
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
Disables the `input`, preventing new values from being applied.
|
|
152
160
|
|
|
153
|
-
- Type: `Boolean`
|
|
154
161
|
- Required: No
|
|
155
|
-
- Platform: Web
|
|
162
|
+
- Platform: Web
|
|
156
163
|
|
|
157
|
-
#### disabled
|
|
158
164
|
|
|
159
|
-
|
|
165
|
+
### `help`: `string|WPElement`
|
|
166
|
+
|
|
167
|
+
If this property is added, a help text will be generated using help property as the content.
|
|
160
168
|
|
|
161
|
-
- Type: `Boolean`
|
|
162
169
|
- Required: No
|
|
163
170
|
- Platform: Web
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
### `hideLabelFromVision`: `boolean`
|
|
173
|
+
|
|
174
|
+
Provides control over whether the label will only be visible to screen readers.
|
|
175
|
+
|
|
176
|
+
- Required: No
|
|
177
|
+
|
|
178
|
+
### `icon`: `string`
|
|
179
|
+
|
|
180
|
+
An icon to be shown above the slider next to its container title.
|
|
181
|
+
|
|
182
|
+
- Required: No
|
|
183
|
+
- Platform: Mobile
|
|
184
|
+
|
|
185
|
+
### `initialPosition`: `number`
|
|
166
186
|
|
|
167
187
|
If no value exists this prop contains the slider starting position.
|
|
168
188
|
|
|
169
|
-
- Type: `Number`
|
|
170
189
|
- Required: No
|
|
171
190
|
- Platform: Web | Mobile
|
|
172
191
|
|
|
173
|
-
|
|
192
|
+
### `isShiftStepEnabled`: `boolean`
|
|
174
193
|
|
|
175
194
|
Passed as a prop to the `NumberControl` component and is only applicable if `withInputField` is true. If true, while the number input has focus, pressing `UP` or `DOWN` along with the `SHIFT` key will change the value by the `shiftStep` value.
|
|
176
195
|
|
|
177
|
-
- Type: `Boolean`
|
|
178
196
|
- Required: No
|
|
179
197
|
|
|
180
|
-
|
|
198
|
+
### `label`: `string`
|
|
199
|
+
|
|
200
|
+
If this property is added, a label will be generated using label property as the content.
|
|
201
|
+
|
|
202
|
+
- Required: No
|
|
203
|
+
- Platform: Web | Mobile
|
|
204
|
+
|
|
205
|
+
### `marks`: `Array|boolean`
|
|
181
206
|
|
|
182
207
|
Renders a visual representation of `step` ticks. Custom mark indicators can be provided by an `Array`.
|
|
183
208
|
|
|
@@ -204,49 +229,72 @@ const marks = [
|
|
|
204
229
|
];
|
|
205
230
|
|
|
206
231
|
const MyRangeControl() {
|
|
207
|
-
return (<RangeControl marks={ marks } min={ 0 } max={ 10 } step={ 1 } />)
|
|
232
|
+
return ( <RangeControl marks={ marks } min={ 0 } max={ 10 } step={ 1 } /> )
|
|
208
233
|
}
|
|
209
234
|
```
|
|
210
235
|
|
|
211
|
-
- Type: `Array|Boolean`
|
|
212
236
|
- Required: No
|
|
213
237
|
- Platform: Web
|
|
214
238
|
|
|
215
|
-
|
|
239
|
+
### `onBlur`: `FocusEventHandler< HTMLInputElement >`
|
|
240
|
+
|
|
241
|
+
Callback for when `RangeControl` input loses focus.
|
|
242
|
+
|
|
243
|
+
- Required: No
|
|
244
|
+
- Platform: Web
|
|
245
|
+
|
|
246
|
+
### `onChange`: `( value?: number ) => void`
|
|
216
247
|
|
|
217
248
|
A function that receives the new value. The value will be less than `max` and more than `min` unless a reset (enabled by `allowReset`) has occurred. In which case the value will be either that of `resetFallbackValue` if it has been specified or otherwise `undefined`.
|
|
218
249
|
|
|
219
|
-
-
|
|
220
|
-
- Required: Yes
|
|
250
|
+
- Required: No
|
|
221
251
|
- Platform: Web | Mobile
|
|
222
252
|
|
|
223
|
-
|
|
253
|
+
### `onFocus`: `FocusEventHandler< HTMLInputElement >`
|
|
254
|
+
|
|
255
|
+
Callback for when `RangeControl` input gains focus.
|
|
256
|
+
|
|
257
|
+
- Required: No
|
|
258
|
+
- Platform: Web
|
|
259
|
+
|
|
260
|
+
### `onMouseLeave`: `MouseEventHandler< HTMLInputElement >`
|
|
261
|
+
|
|
262
|
+
Callback for when mouse exits the `RangeControl`.
|
|
263
|
+
|
|
264
|
+
- Required: No
|
|
265
|
+
- Platform: Web
|
|
266
|
+
|
|
267
|
+
### `onMouseMove`: `MouseEventHandler< HTMLInputElement >`
|
|
268
|
+
|
|
269
|
+
Callback for when mouse moves within the `RangeControl`.
|
|
270
|
+
|
|
271
|
+
- Required: No
|
|
272
|
+
- Platform: Web
|
|
273
|
+
|
|
274
|
+
### `min`: `number`
|
|
224
275
|
|
|
225
276
|
The minimum `value` allowed.
|
|
226
277
|
|
|
227
|
-
- Type: `Number`
|
|
228
278
|
- Required: No
|
|
229
279
|
- Default: 0
|
|
230
280
|
- Platform: Web | Mobile
|
|
231
281
|
|
|
232
|
-
|
|
282
|
+
### `max`: `number`
|
|
233
283
|
|
|
234
284
|
The maximum `value` allowed.
|
|
235
285
|
|
|
236
|
-
- Type: `Number`
|
|
237
286
|
- Required: No
|
|
238
287
|
- Default: 100
|
|
239
288
|
- Platform: Web | Mobile
|
|
240
289
|
|
|
241
|
-
|
|
290
|
+
### `railColor`: `CSSProperties[ 'color' ]`
|
|
242
291
|
|
|
243
|
-
|
|
292
|
+
CSS color string to customize the rail element's background.
|
|
244
293
|
|
|
245
|
-
- Type: `String`
|
|
246
294
|
- Required: No
|
|
247
295
|
- Platform: Web
|
|
248
296
|
|
|
249
|
-
|
|
297
|
+
### `renderTooltipContent`: ( value ) => value
|
|
250
298
|
|
|
251
299
|
A way to customize the rendered UI of the value. Example:
|
|
252
300
|
|
|
@@ -258,89 +306,69 @@ const MyRangeControl() {
|
|
|
258
306
|
}
|
|
259
307
|
```
|
|
260
308
|
|
|
261
|
-
- Type: `Function`
|
|
262
309
|
- Required: No
|
|
263
310
|
- Platform: Web
|
|
264
311
|
|
|
265
|
-
|
|
312
|
+
### `resetFallbackValue`: `number`
|
|
266
313
|
|
|
267
314
|
The value to revert to if the Reset button is clicked (enabled by `allowReset`)
|
|
268
315
|
|
|
269
|
-
- Type: `Number`
|
|
270
|
-
- Required: No
|
|
271
|
-
- Platform: Web
|
|
272
|
-
|
|
273
|
-
#### showTooltip
|
|
274
|
-
|
|
275
|
-
Forcing the Tooltip UI to show or hide. This is overriden to `false` when `step` is set to the special string value `any`.
|
|
276
|
-
|
|
277
|
-
- Type: `Boolean`
|
|
278
316
|
- Required: No
|
|
279
317
|
- Platform: Web
|
|
280
318
|
|
|
281
|
-
|
|
319
|
+
### `separatorType`: `'none' | 'fullWidth' | 'topFullWidth'`
|
|
282
320
|
|
|
283
|
-
|
|
321
|
+
Define if separator line under/above control row should be disabled or full width. By default it is placed below excluding underline the control icon.
|
|
284
322
|
|
|
285
|
-
- Type: `Number | "any"`
|
|
286
323
|
- Required: No
|
|
287
|
-
- Platform:
|
|
324
|
+
- Platform: Mobile
|
|
288
325
|
|
|
289
|
-
|
|
326
|
+
### `shiftStep`: `number`
|
|
290
327
|
|
|
291
328
|
Passed as a prop to the `NumberControl` component and is only applicable if `withInputField` and `isShiftStepEnabled` are both true and while the number input has focus. Acts as a multiplier of `step`.
|
|
292
329
|
|
|
293
|
-
- Type: `Number`
|
|
294
330
|
- Required: No
|
|
295
331
|
|
|
296
|
-
|
|
332
|
+
### `showTooltip`: `boolean`
|
|
297
333
|
|
|
298
|
-
|
|
334
|
+
Forcing the Tooltip UI to show or hide. This is overridden to `false` when `step` is set to the special string value `any`.
|
|
299
335
|
|
|
300
|
-
- Type: `String`
|
|
301
336
|
- Required: No
|
|
302
337
|
- Platform: Web
|
|
303
338
|
|
|
304
|
-
|
|
339
|
+
### `step`: `number | 'any'`
|
|
305
340
|
|
|
306
|
-
The
|
|
307
|
-
|
|
308
|
-
- Type: `Number`
|
|
309
|
-
- Required: Yes
|
|
310
|
-
- Platform: Web | Mobile
|
|
341
|
+
The minimum amount by which `value` changes. It is also a factor in validation as `value` must be a multiple of `step` (offset by `min`) to be valid. Accepts the special string value `any` that voids the validation constraint and overrides both `withInputField` and `showTooltip` props to `false`.
|
|
311
342
|
|
|
312
|
-
|
|
343
|
+
- Required: No
|
|
344
|
+
- Platform: Web
|
|
345
|
+
### `trackColor`: `CSSProperties[ 'color' ]`
|
|
313
346
|
|
|
314
|
-
|
|
347
|
+
CSS color string to customize the track element's background.
|
|
315
348
|
|
|
316
|
-
- Type: `Boolean`
|
|
317
349
|
- Required: No
|
|
318
350
|
- Platform: Web
|
|
319
351
|
|
|
320
|
-
|
|
352
|
+
### `type`: `string`
|
|
321
353
|
|
|
322
|
-
|
|
354
|
+
Define if the value selection should present a stepper control or a slider control in the bottom sheet on mobile. To use the stepper set the type value as `stepper`. Defaults to slider if no option is provided.
|
|
323
355
|
|
|
324
|
-
- Type: `String`
|
|
325
356
|
- Required: No
|
|
326
357
|
- Platform: Mobile
|
|
327
358
|
|
|
328
|
-
|
|
359
|
+
### `value`: `number`
|
|
329
360
|
|
|
330
|
-
|
|
361
|
+
The current value of the range slider.
|
|
331
362
|
|
|
332
|
-
- Type: `String Enum`
|
|
333
|
-
- Values: `none` | `fullWidth` | `topFullWidth`
|
|
334
363
|
- Required: No
|
|
335
|
-
- Platform: Mobile
|
|
364
|
+
- Platform: Web | Mobile
|
|
336
365
|
|
|
337
|
-
|
|
366
|
+
### `withInputField`: `boolean`
|
|
338
367
|
|
|
339
|
-
|
|
368
|
+
Determines if the `input` number field will render next to the RangeControl. This is overridden to `false` when `step` is set to the special string value `any`.
|
|
340
369
|
|
|
341
|
-
- Type: `String`
|
|
342
370
|
- Required: No
|
|
343
|
-
- Platform:
|
|
371
|
+
- Platform: Web
|
|
344
372
|
|
|
345
373
|
## Related components
|
|
346
374
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
4
|
import classnames from 'classnames';
|
|
5
|
+
import type { ChangeEvent, FocusEvent, ForwardedRef } from 'react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { __, isRTL } from '@wordpress/i18n';
|
|
11
11
|
import { useRef, useState, forwardRef } from '@wordpress/element';
|
|
12
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
12
|
+
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -35,71 +35,74 @@ import {
|
|
|
35
35
|
Wrapper,
|
|
36
36
|
} from './styles/range-control-styles';
|
|
37
37
|
|
|
38
|
+
import type { RangeControlProps } from './types';
|
|
39
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
40
|
+
|
|
38
41
|
const noop = () => {};
|
|
39
42
|
|
|
40
|
-
function
|
|
41
|
-
|
|
43
|
+
function UnforwardedRangeControl< IconProps = unknown >(
|
|
44
|
+
props: WordPressComponentProps<
|
|
45
|
+
RangeControlProps< IconProps >,
|
|
46
|
+
'input',
|
|
47
|
+
false
|
|
48
|
+
>,
|
|
49
|
+
forwardedRef: ForwardedRef< HTMLInputElement >
|
|
50
|
+
) {
|
|
51
|
+
const {
|
|
42
52
|
afterIcon,
|
|
43
53
|
allowReset = false,
|
|
44
54
|
beforeIcon,
|
|
45
55
|
className,
|
|
46
|
-
currentInput,
|
|
47
56
|
color: colorProp = COLORS.ui.theme,
|
|
57
|
+
currentInput,
|
|
48
58
|
disabled = false,
|
|
49
59
|
help,
|
|
60
|
+
hideLabelFromVision = false,
|
|
50
61
|
initialPosition,
|
|
51
62
|
isShiftStepEnabled = true,
|
|
52
63
|
label,
|
|
53
|
-
hideLabelFromVision = false,
|
|
54
64
|
marks = false,
|
|
55
65
|
max = 100,
|
|
56
66
|
min = 0,
|
|
57
67
|
onBlur = noop,
|
|
58
68
|
onChange = noop,
|
|
59
69
|
onFocus = noop,
|
|
60
|
-
onMouseMove = noop,
|
|
61
70
|
onMouseLeave = noop,
|
|
71
|
+
onMouseMove = noop,
|
|
62
72
|
railColor,
|
|
63
|
-
resetFallbackValue,
|
|
64
73
|
renderTooltipContent = ( v ) => v,
|
|
65
|
-
|
|
74
|
+
resetFallbackValue,
|
|
66
75
|
shiftStep = 10,
|
|
76
|
+
showTooltip: showTooltipProp,
|
|
67
77
|
step = 1,
|
|
68
78
|
trackColor,
|
|
69
79
|
value: valueProp,
|
|
70
80
|
withInputField = true,
|
|
71
|
-
...
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
) {
|
|
81
|
+
...otherProps
|
|
82
|
+
} = props;
|
|
83
|
+
|
|
75
84
|
const [ value, setValue ] = useControlledRangeValue( {
|
|
76
85
|
min,
|
|
77
86
|
max,
|
|
78
|
-
value: valueProp,
|
|
87
|
+
value: valueProp ?? null,
|
|
79
88
|
initial: initialPosition,
|
|
80
89
|
} );
|
|
81
90
|
const isResetPendent = useRef( false );
|
|
82
91
|
|
|
92
|
+
let hasTooltip = showTooltipProp;
|
|
93
|
+
let hasInputField = withInputField;
|
|
94
|
+
|
|
83
95
|
if ( step === 'any' ) {
|
|
84
96
|
// The tooltip and number input field are hidden when the step is "any"
|
|
85
97
|
// because the decimals get too lengthy to fit well.
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
hasTooltip = false;
|
|
99
|
+
hasInputField = false;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
|
-
const [ showTooltip, setShowTooltip ] = useState(
|
|
102
|
+
const [ showTooltip, setShowTooltip ] = useState( hasTooltip );
|
|
91
103
|
const [ isFocused, setIsFocused ] = useState( false );
|
|
92
104
|
|
|
93
|
-
const inputRef = useRef();
|
|
94
|
-
|
|
95
|
-
const setRef = ( nodeRef ) => {
|
|
96
|
-
inputRef.current = nodeRef;
|
|
97
|
-
|
|
98
|
-
if ( ref ) {
|
|
99
|
-
ref( nodeRef );
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
105
|
+
const inputRef = useRef< HTMLInputElement >();
|
|
103
106
|
const isCurrentlyFocused = inputRef.current?.matches( ':focus' );
|
|
104
107
|
const isThumbFocused = ! disabled && isFocused;
|
|
105
108
|
|
|
@@ -107,11 +110,11 @@ function RangeControl(
|
|
|
107
110
|
const currentValue = value !== undefined ? value : currentInput;
|
|
108
111
|
|
|
109
112
|
const inputSliderValue = isValueReset ? '' : currentValue;
|
|
110
|
-
|
|
111
113
|
const rangeFillValue = isValueReset ? ( max - min ) / 2 + min : value;
|
|
112
114
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
+
const fillValue = isValueReset
|
|
116
|
+
? 50
|
|
117
|
+
: ( ( value - min ) / ( max - min ) ) * 100;
|
|
115
118
|
const fillValueOffset = `${ clamp( fillValue, 0, 100 ) }%`;
|
|
116
119
|
|
|
117
120
|
const classes = classnames( 'components-range-control', className );
|
|
@@ -121,27 +124,32 @@ function RangeControl(
|
|
|
121
124
|
!! marks && 'is-marked'
|
|
122
125
|
);
|
|
123
126
|
|
|
124
|
-
const id = useInstanceId(
|
|
127
|
+
const id = useInstanceId(
|
|
128
|
+
UnforwardedRangeControl,
|
|
129
|
+
'inspector-range-control'
|
|
130
|
+
);
|
|
125
131
|
const describedBy = !! help ? `${ id }__help` : undefined;
|
|
126
|
-
const enableTooltip =
|
|
132
|
+
const enableTooltip = hasTooltip !== false && Number.isFinite( value );
|
|
127
133
|
|
|
128
|
-
const handleOnRangeChange = ( event ) => {
|
|
134
|
+
const handleOnRangeChange = ( event: ChangeEvent< HTMLInputElement > ) => {
|
|
129
135
|
const nextValue = parseFloat( event.target.value );
|
|
130
136
|
setValue( nextValue );
|
|
131
137
|
onChange( nextValue );
|
|
132
138
|
};
|
|
133
139
|
|
|
134
|
-
const handleOnChange = (
|
|
135
|
-
nextValue = parseFloat(
|
|
140
|
+
const handleOnChange = ( next: string ) => {
|
|
141
|
+
let nextValue = parseFloat( next );
|
|
136
142
|
setValue( nextValue );
|
|
143
|
+
|
|
137
144
|
/*
|
|
138
145
|
* Calls onChange only when nextValue is numeric
|
|
139
146
|
* otherwise may queue a reset for the blur event.
|
|
140
147
|
*/
|
|
141
148
|
if ( ! isNaN( nextValue ) ) {
|
|
142
149
|
if ( nextValue < min || nextValue > max ) {
|
|
143
|
-
nextValue = floatClamp( nextValue, min, max );
|
|
150
|
+
nextValue = floatClamp( nextValue, min, max ) as number;
|
|
144
151
|
}
|
|
152
|
+
|
|
145
153
|
onChange( nextValue );
|
|
146
154
|
isResetPendent.current = false;
|
|
147
155
|
} else if ( allowReset ) {
|
|
@@ -157,8 +165,8 @@ function RangeControl(
|
|
|
157
165
|
};
|
|
158
166
|
|
|
159
167
|
const handleOnReset = () => {
|
|
160
|
-
let resetValue = parseFloat( resetFallbackValue );
|
|
161
|
-
let onChangeResetValue = resetValue;
|
|
168
|
+
let resetValue: number | null = parseFloat( `${ resetFallbackValue }` );
|
|
169
|
+
let onChangeResetValue: number | undefined = resetValue;
|
|
162
170
|
|
|
163
171
|
if ( isNaN( resetValue ) ) {
|
|
164
172
|
resetValue = null;
|
|
@@ -186,13 +194,13 @@ function RangeControl(
|
|
|
186
194
|
const handleShowTooltip = () => setShowTooltip( true );
|
|
187
195
|
const handleHideTooltip = () => setShowTooltip( false );
|
|
188
196
|
|
|
189
|
-
const handleOnBlur = ( event ) => {
|
|
197
|
+
const handleOnBlur = ( event: FocusEvent< HTMLInputElement > ) => {
|
|
190
198
|
onBlur( event );
|
|
191
199
|
setIsFocused( false );
|
|
192
200
|
handleHideTooltip();
|
|
193
201
|
};
|
|
194
202
|
|
|
195
|
-
const handleOnFocus = ( event ) => {
|
|
203
|
+
const handleOnFocus = ( event: FocusEvent< HTMLInputElement > ) => {
|
|
196
204
|
onFocus( event );
|
|
197
205
|
setIsFocused( true );
|
|
198
206
|
handleShowTooltip();
|
|
@@ -207,7 +215,7 @@ function RangeControl(
|
|
|
207
215
|
className={ classes }
|
|
208
216
|
label={ label }
|
|
209
217
|
hideLabelFromVision={ hideLabelFromVision }
|
|
210
|
-
id={ id }
|
|
218
|
+
id={ `${ id }` }
|
|
211
219
|
help={ help }
|
|
212
220
|
>
|
|
213
221
|
<Root className="components-range-control__root">
|
|
@@ -222,11 +230,11 @@ function RangeControl(
|
|
|
222
230
|
marks={ !! marks }
|
|
223
231
|
>
|
|
224
232
|
<InputRange
|
|
225
|
-
{ ...
|
|
233
|
+
{ ...otherProps }
|
|
226
234
|
className="components-range-control__slider"
|
|
227
235
|
describedBy={ describedBy }
|
|
228
236
|
disabled={ disabled }
|
|
229
|
-
id={ id }
|
|
237
|
+
id={ `${ id }` }
|
|
230
238
|
label={ label }
|
|
231
239
|
max={ max }
|
|
232
240
|
min={ min }
|
|
@@ -235,9 +243,9 @@ function RangeControl(
|
|
|
235
243
|
onFocus={ handleOnFocus }
|
|
236
244
|
onMouseMove={ onMouseMove }
|
|
237
245
|
onMouseLeave={ onMouseLeave }
|
|
238
|
-
ref={
|
|
246
|
+
ref={ useMergeRefs( [ inputRef, forwardedRef ] ) }
|
|
239
247
|
step={ step }
|
|
240
|
-
value={ inputSliderValue }
|
|
248
|
+
value={ inputSliderValue ?? undefined }
|
|
241
249
|
/>
|
|
242
250
|
<RangeRail
|
|
243
251
|
aria-hidden={ true }
|
|
@@ -280,7 +288,7 @@ function RangeControl(
|
|
|
280
288
|
<Icon icon={ afterIcon } />
|
|
281
289
|
</AfterIconWrapper>
|
|
282
290
|
) }
|
|
283
|
-
{
|
|
291
|
+
{ hasInputField && (
|
|
284
292
|
<InputNumber
|
|
285
293
|
aria-label={ label }
|
|
286
294
|
className="components-range-control__number"
|
|
@@ -314,6 +322,28 @@ function RangeControl(
|
|
|
314
322
|
);
|
|
315
323
|
}
|
|
316
324
|
|
|
317
|
-
|
|
325
|
+
/**
|
|
326
|
+
* RangeControls are used to make selections from a range of incremental values.
|
|
327
|
+
*
|
|
328
|
+
* ```jsx
|
|
329
|
+
* import { RangeControl } from '@wordpress/components';
|
|
330
|
+
* import { useState } from '@wordpress/element';
|
|
331
|
+
*
|
|
332
|
+
* const MyRangeControl = () => {
|
|
333
|
+
* const [ isChecked, setChecked ] = useState( true );
|
|
334
|
+
* return (
|
|
335
|
+
* <RangeControl
|
|
336
|
+
* help="Please select how transparent you would like this."
|
|
337
|
+
* initialPosition={50}
|
|
338
|
+
* label="Opacity"
|
|
339
|
+
* max={100}
|
|
340
|
+
* min={0}
|
|
341
|
+
* onChange={() => {}}
|
|
342
|
+
* />
|
|
343
|
+
* );
|
|
344
|
+
* };
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
export const RangeControl = forwardRef( UnforwardedRangeControl );
|
|
318
348
|
|
|
319
|
-
export default
|
|
349
|
+
export default RangeControl;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
@@ -10,10 +9,16 @@ import { forwardRef } from '@wordpress/element';
|
|
|
10
9
|
import { InputRange as BaseInputRange } from './styles/range-control-styles';
|
|
11
10
|
import { useDebouncedHoverInteraction } from './utils';
|
|
12
11
|
|
|
12
|
+
import type { InputRangeProps } from './types';
|
|
13
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
14
|
+
|
|
13
15
|
const noop = () => {};
|
|
14
16
|
|
|
15
17
|
function InputRange(
|
|
16
|
-
|
|
18
|
+
props: WordPressComponentProps< InputRangeProps, 'input' >,
|
|
19
|
+
ref: React.ForwardedRef< HTMLInputElement >
|
|
20
|
+
) {
|
|
21
|
+
const {
|
|
17
22
|
describedBy,
|
|
18
23
|
label,
|
|
19
24
|
onHideTooltip = noop,
|
|
@@ -21,10 +26,9 @@ function InputRange(
|
|
|
21
26
|
onMouseMove = noop,
|
|
22
27
|
onShowTooltip = noop,
|
|
23
28
|
value,
|
|
24
|
-
...
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
) {
|
|
29
|
+
...otherProps
|
|
30
|
+
} = props;
|
|
31
|
+
|
|
28
32
|
const hoverInteractions = useDebouncedHoverInteraction( {
|
|
29
33
|
onHide: onHideTooltip,
|
|
30
34
|
onMouseLeave,
|
|
@@ -34,7 +38,7 @@ function InputRange(
|
|
|
34
38
|
|
|
35
39
|
return (
|
|
36
40
|
<BaseInputRange
|
|
37
|
-
{ ...
|
|
41
|
+
{ ...otherProps }
|
|
38
42
|
{ ...hoverInteractions }
|
|
39
43
|
aria-describedby={ describedBy }
|
|
40
44
|
aria-label={ label }
|