@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { MouseEventHandler } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useCallback, useRef, useEffect, useState } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { useControlledState } from '../utils/hooks';
|
|
15
|
+
import { clamp } from '../utils/math';
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
UseControlledRangeValueArgs,
|
|
19
|
+
UseDebouncedHoverInteractionArgs,
|
|
20
|
+
} from './types';
|
|
21
|
+
|
|
22
|
+
const noop = () => {};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A float supported clamp function for a specific value.
|
|
26
|
+
*
|
|
27
|
+
* @param value The value to clamp.
|
|
28
|
+
* @param min The minimum value.
|
|
29
|
+
* @param max The maximum value.
|
|
30
|
+
*
|
|
31
|
+
* @return A (float) number
|
|
32
|
+
*/
|
|
33
|
+
export function floatClamp( value: number | null, min: number, max: number ) {
|
|
34
|
+
if ( typeof value !== 'number' ) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return parseFloat( `${ clamp( value, min, max ) }` );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Hook to store a clamped value, derived from props.
|
|
43
|
+
*
|
|
44
|
+
* @param settings
|
|
45
|
+
* @return The controlled value and the value setter.
|
|
46
|
+
*/
|
|
47
|
+
export function useControlledRangeValue(
|
|
48
|
+
settings: UseControlledRangeValueArgs
|
|
49
|
+
) {
|
|
50
|
+
const { min, max, value: valueProp, initial } = settings;
|
|
51
|
+
const [ state, setInternalState ] = useControlledState(
|
|
52
|
+
floatClamp( valueProp, min, max ),
|
|
53
|
+
{ initial, fallback: null }
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const setState = useCallback(
|
|
57
|
+
( nextValue: number | null ) => {
|
|
58
|
+
if ( nextValue === null ) {
|
|
59
|
+
setInternalState( null );
|
|
60
|
+
} else {
|
|
61
|
+
setInternalState( floatClamp( nextValue, min, max ) );
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[ min, max ]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// `state` can't be an empty string because we specified a fallback value of
|
|
68
|
+
// `null` in `useControlledState`
|
|
69
|
+
return [ state as Exclude< typeof state, '' >, setState ] as const;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Hook to encapsulate the debouncing "hover" to better handle the showing
|
|
74
|
+
* and hiding of the Tooltip.
|
|
75
|
+
*
|
|
76
|
+
* @param settings
|
|
77
|
+
* @return Bound properties for use on a React.Node.
|
|
78
|
+
*/
|
|
79
|
+
export function useDebouncedHoverInteraction(
|
|
80
|
+
settings: UseDebouncedHoverInteractionArgs
|
|
81
|
+
) {
|
|
82
|
+
const {
|
|
83
|
+
onHide = noop,
|
|
84
|
+
onMouseLeave = noop as MouseEventHandler,
|
|
85
|
+
onMouseMove = noop as MouseEventHandler,
|
|
86
|
+
onShow = noop,
|
|
87
|
+
timeout = 300,
|
|
88
|
+
} = settings;
|
|
89
|
+
|
|
90
|
+
const [ show, setShow ] = useState( false );
|
|
91
|
+
const timeoutRef = useRef< number | undefined >();
|
|
92
|
+
|
|
93
|
+
const setDebouncedTimeout = useCallback(
|
|
94
|
+
( callback ) => {
|
|
95
|
+
window.clearTimeout( timeoutRef.current );
|
|
96
|
+
|
|
97
|
+
timeoutRef.current = window.setTimeout( callback, timeout );
|
|
98
|
+
},
|
|
99
|
+
[ timeout ]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const handleOnMouseMove = useCallback( ( event ) => {
|
|
103
|
+
onMouseMove( event );
|
|
104
|
+
|
|
105
|
+
setDebouncedTimeout( () => {
|
|
106
|
+
if ( ! show ) {
|
|
107
|
+
setShow( true );
|
|
108
|
+
onShow();
|
|
109
|
+
}
|
|
110
|
+
} );
|
|
111
|
+
}, [] );
|
|
112
|
+
|
|
113
|
+
const handleOnMouseLeave = useCallback( ( event ) => {
|
|
114
|
+
onMouseLeave( event );
|
|
115
|
+
|
|
116
|
+
setDebouncedTimeout( () => {
|
|
117
|
+
setShow( false );
|
|
118
|
+
onHide();
|
|
119
|
+
} );
|
|
120
|
+
}, [] );
|
|
121
|
+
|
|
122
|
+
useEffect( () => {
|
|
123
|
+
return () => {
|
|
124
|
+
window.clearTimeout( timeoutRef.current );
|
|
125
|
+
};
|
|
126
|
+
} );
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
onMouseMove: handleOnMouseMove,
|
|
130
|
+
onMouseLeave: handleOnMouseLeave,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
5
5
|
import { useResizeObserver } from '@wordpress/compose';
|
|
6
6
|
|
|
7
|
-
const { clearTimeout, setTimeout } = window;
|
|
8
7
|
const noop = () => {};
|
|
9
8
|
|
|
10
9
|
export type Axis = 'x' | 'y';
|
|
@@ -97,10 +96,10 @@ export function useResizeLabel( {
|
|
|
97
96
|
|
|
98
97
|
const debounceUnsetMoveXY = () => {
|
|
99
98
|
if ( moveTimeoutRef.current ) {
|
|
100
|
-
clearTimeout( moveTimeoutRef.current );
|
|
99
|
+
window.clearTimeout( moveTimeoutRef.current );
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
moveTimeoutRef.current = setTimeout( unsetMoveXY, fadeTimeout );
|
|
102
|
+
moveTimeoutRef.current = window.setTimeout( unsetMoveXY, fadeTimeout );
|
|
104
103
|
};
|
|
105
104
|
|
|
106
105
|
useEffect( () => {
|
package/src/scrollable/README.md
CHANGED
|
@@ -9,7 +9,7 @@ This feature is still experimental. “Experimental” means this is an early im
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
11
|
```jsx
|
|
12
|
-
import {__experimentalScrollable as Scrollable } from '@wordpress/components';
|
|
12
|
+
import { __experimentalScrollable as Scrollable } from '@wordpress/components';
|
|
13
13
|
|
|
14
14
|
function Example() {
|
|
15
15
|
return (
|
|
@@ -22,17 +22,23 @@ function Example() {
|
|
|
22
22
|
|
|
23
23
|
## Props
|
|
24
24
|
|
|
25
|
-
### `
|
|
25
|
+
### `children`: `ReactNode`
|
|
26
|
+
|
|
27
|
+
The children elements.
|
|
26
28
|
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
- Required: Yes
|
|
30
|
+
|
|
31
|
+
### `scrollDirection`: `string`
|
|
30
32
|
|
|
31
33
|
Renders a scrollbar for a specific axis when content overflows.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
- Required: No
|
|
36
|
+
- Default: `y`
|
|
37
|
+
- Allowed values: `x`, `y`, `auto`
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
- Default: `false`
|
|
39
|
+
### `smoothScroll`: `boolean`
|
|
37
40
|
|
|
38
41
|
Enables (CSS) smooth scrolling.
|
|
42
|
+
|
|
43
|
+
- Required: No
|
|
44
|
+
- Default: `false`
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
4
|
-
import { contextConnect } from '../ui/context';
|
|
9
|
+
import { contextConnect, WordPressComponentProps } from '../ui/context';
|
|
5
10
|
import { View } from '../view';
|
|
6
11
|
import { useScrollable } from './hook';
|
|
12
|
+
import type { ScrollableProps } from './types';
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function Scrollable( props, forwardedRef ) {
|
|
14
|
+
function UnconnectedScrollable(
|
|
15
|
+
props: WordPressComponentProps< ScrollableProps, 'div' >,
|
|
16
|
+
forwardedRef: ForwardedRef< any >
|
|
17
|
+
) {
|
|
13
18
|
const scrollableProps = useScrollable( props );
|
|
14
19
|
|
|
15
20
|
return <View { ...scrollableProps } ref={ forwardedRef } />;
|
|
@@ -18,7 +23,6 @@ function Scrollable( props, forwardedRef ) {
|
|
|
18
23
|
/**
|
|
19
24
|
* `Scrollable` is a layout component that content in a scrollable container.
|
|
20
25
|
*
|
|
21
|
-
* @example
|
|
22
26
|
* ```jsx
|
|
23
27
|
* import { __experimentalScrollable as Scrollable } from `@wordpress/components`;
|
|
24
28
|
*
|
|
@@ -31,7 +35,6 @@ function Scrollable( props, forwardedRef ) {
|
|
|
31
35
|
* }
|
|
32
36
|
* ```
|
|
33
37
|
*/
|
|
38
|
+
export const Scrollable = contextConnect( UnconnectedScrollable, 'Scrollable' );
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export default ConnectedScrollable;
|
|
40
|
+
export default Scrollable;
|
|
@@ -6,16 +6,14 @@ import { useMemo } from '@wordpress/element';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useContextSystem } from '../ui/context';
|
|
9
|
+
import { useContextSystem, WordPressComponentProps } from '../ui/context';
|
|
10
10
|
import * as styles from './styles';
|
|
11
11
|
import { useCx } from '../utils/hooks/use-cx';
|
|
12
|
+
import type { ScrollableProps } from './types';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
/* eslint-enable jsdoc/valid-types */
|
|
18
|
-
export function useScrollable( props ) {
|
|
14
|
+
export function useScrollable(
|
|
15
|
+
props: WordPressComponentProps< ScrollableProps, 'div' >
|
|
16
|
+
) {
|
|
19
17
|
const {
|
|
20
18
|
className,
|
|
21
19
|
scrollDirection = 'y',
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -12,58 +12,49 @@ import { useRef } from '@wordpress/element';
|
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { View } from '../../view';
|
|
15
|
-
import { Scrollable } from '
|
|
15
|
+
import { Scrollable } from '..';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const meta: ComponentMeta< typeof Scrollable > = {
|
|
18
18
|
component: Scrollable,
|
|
19
19
|
title: 'Components (Experimental)/Scrollable',
|
|
20
|
+
argTypes: {
|
|
21
|
+
as: {
|
|
22
|
+
control: { type: 'text' },
|
|
23
|
+
},
|
|
24
|
+
children: {
|
|
25
|
+
control: { type: null },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
20
28
|
parameters: {
|
|
21
|
-
|
|
29
|
+
controls: {
|
|
30
|
+
expanded: true,
|
|
31
|
+
},
|
|
32
|
+
docs: { source: { state: 'open' } },
|
|
22
33
|
},
|
|
23
34
|
};
|
|
35
|
+
export default meta;
|
|
24
36
|
|
|
25
|
-
|
|
26
|
-
const targetRef = useRef( null );
|
|
37
|
+
const Template: ComponentStory< typeof Scrollable > = ( { ...args } ) => {
|
|
38
|
+
const targetRef = useRef< HTMLInputElement >( null );
|
|
27
39
|
|
|
28
40
|
const onButtonClick = () => {
|
|
29
41
|
targetRef.current?.focus();
|
|
30
42
|
};
|
|
31
43
|
|
|
32
|
-
const otherProps = {
|
|
33
|
-
smoothScroll: boolean(
|
|
34
|
-
'Scrollable: smoothScroll (hint: move focus in the scrollable container)',
|
|
35
|
-
false
|
|
36
|
-
),
|
|
37
|
-
scrollDirection: select(
|
|
38
|
-
'Scrollable: scrollDirection',
|
|
39
|
-
{
|
|
40
|
-
x: 'x',
|
|
41
|
-
y: 'y',
|
|
42
|
-
auto: 'auto',
|
|
43
|
-
},
|
|
44
|
-
'y'
|
|
45
|
-
),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
44
|
const containerWidth = 300;
|
|
49
45
|
const containerHeight = 400;
|
|
50
46
|
|
|
51
47
|
return (
|
|
52
48
|
<Scrollable
|
|
53
49
|
style={ { height: containerHeight, width: containerWidth } }
|
|
54
|
-
{ ...
|
|
50
|
+
{ ...args }
|
|
55
51
|
>
|
|
56
52
|
<View
|
|
57
53
|
style={ {
|
|
58
54
|
backgroundColor: '#eee',
|
|
59
55
|
height:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
: 1000,
|
|
63
|
-
width:
|
|
64
|
-
otherProps.scrollDirection === 'y'
|
|
65
|
-
? containerWidth
|
|
66
|
-
: 1000,
|
|
56
|
+
args.scrollDirection === 'x' ? containerHeight : 1000,
|
|
57
|
+
width: args.scrollDirection === 'y' ? containerWidth : 1000,
|
|
67
58
|
position: 'relative',
|
|
68
59
|
} }
|
|
69
60
|
>
|
|
@@ -74,10 +65,8 @@ export const _default = () => {
|
|
|
74
65
|
ref={ targetRef }
|
|
75
66
|
style={ {
|
|
76
67
|
position: 'absolute',
|
|
77
|
-
bottom:
|
|
78
|
-
|
|
79
|
-
right:
|
|
80
|
-
otherProps.scrollDirection === 'y' ? 'initial' : 0,
|
|
68
|
+
bottom: args.scrollDirection === 'x' ? 'initial' : 0,
|
|
69
|
+
right: 0,
|
|
81
70
|
} }
|
|
82
71
|
type="text"
|
|
83
72
|
value="Focus me"
|
|
@@ -86,3 +75,9 @@ export const _default = () => {
|
|
|
86
75
|
</Scrollable>
|
|
87
76
|
);
|
|
88
77
|
};
|
|
78
|
+
|
|
79
|
+
export const Default: ComponentStory< typeof Scrollable > = Template.bind( {} );
|
|
80
|
+
Default.args = {
|
|
81
|
+
smoothScroll: false,
|
|
82
|
+
scrollDirection: 'y',
|
|
83
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Scrollable } from '../index';
|
|
10
|
+
|
|
11
|
+
describe( 'props', () => {
|
|
12
|
+
beforeEach( () => {
|
|
13
|
+
render(
|
|
14
|
+
<Scrollable data-testid="scrollable">
|
|
15
|
+
WordPress.org - Code is Poetry
|
|
16
|
+
</Scrollable>
|
|
17
|
+
);
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
test( 'should render correctly', () => {
|
|
21
|
+
expect( screen.getByTestId( 'scrollable' ) ).toMatchSnapshot();
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
test( 'should render smoothScroll', () => {
|
|
25
|
+
render(
|
|
26
|
+
<Scrollable smoothScroll data-testid="smooth-scrollable">
|
|
27
|
+
WordPress.org - Code is Poetry
|
|
28
|
+
</Scrollable>
|
|
29
|
+
);
|
|
30
|
+
expect(
|
|
31
|
+
screen.getByTestId( 'smooth-scrollable' )
|
|
32
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'scrollable' ) );
|
|
33
|
+
} );
|
|
34
|
+
} );
|
package/src/scrollable/types.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
1
6
|
export type ScrollableDirection = 'x' | 'y' | 'auto';
|
|
2
7
|
|
|
3
|
-
export type
|
|
8
|
+
export type ScrollableProps = {
|
|
9
|
+
/**
|
|
10
|
+
* The children elements.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
4
13
|
/**
|
|
5
14
|
* Renders a scrollbar for a specific axis when content overflows.
|
|
6
15
|
*
|
|
@@ -13,8 +22,4 @@ export type Props = {
|
|
|
13
22
|
* @default false
|
|
14
23
|
*/
|
|
15
24
|
smoothScroll?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The children elements.
|
|
18
|
-
*/
|
|
19
|
-
children: React.ReactNode;
|
|
20
25
|
};
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import SelectControl from '..';
|
|
10
11
|
|
|
12
|
+
const setupUser = () =>
|
|
13
|
+
userEvent.setup( {
|
|
14
|
+
advanceTimers: jest.advanceTimersByTime,
|
|
15
|
+
} );
|
|
16
|
+
|
|
11
17
|
describe( 'SelectControl', () => {
|
|
12
18
|
it( 'should not render when no options or children are provided', () => {
|
|
13
|
-
|
|
19
|
+
render( <SelectControl /> );
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
// use `queryByRole` to avoid throwing an error with `getByRole`
|
|
22
|
+
expect( screen.queryByRole( 'combobox' ) ).not.toBeInTheDocument();
|
|
16
23
|
} );
|
|
17
24
|
|
|
18
25
|
it( 'should not render its children', async () => {
|
|
26
|
+
const user = setupUser();
|
|
19
27
|
const handleChangeMock = jest.fn();
|
|
20
28
|
|
|
21
29
|
render(
|
|
@@ -30,13 +38,12 @@ describe( 'SelectControl', () => {
|
|
|
30
38
|
</SelectControl>
|
|
31
39
|
);
|
|
32
40
|
|
|
33
|
-
expect(
|
|
41
|
+
expect(
|
|
42
|
+
screen.getByRole( 'option', { name: 'Option 1' } )
|
|
43
|
+
).toBeInTheDocument();
|
|
34
44
|
|
|
35
|
-
const selectElement = screen.
|
|
36
|
-
|
|
37
|
-
fireEvent.change( selectElement, {
|
|
38
|
-
target: { value: 'option-group-option-1' },
|
|
39
|
-
} );
|
|
45
|
+
const selectElement = screen.getByRole( 'combobox' );
|
|
46
|
+
await user.selectOptions( selectElement, 'option-group-option-1' );
|
|
40
47
|
|
|
41
48
|
expect( handleChangeMock ).toHaveBeenCalledWith(
|
|
42
49
|
'option-group-option-1',
|
|
@@ -45,6 +52,7 @@ describe( 'SelectControl', () => {
|
|
|
45
52
|
} );
|
|
46
53
|
|
|
47
54
|
it( 'should not render its options', async () => {
|
|
55
|
+
const user = setupUser();
|
|
48
56
|
const handleChangeMock = jest.fn();
|
|
49
57
|
|
|
50
58
|
render(
|
|
@@ -66,13 +74,12 @@ describe( 'SelectControl', () => {
|
|
|
66
74
|
/>
|
|
67
75
|
);
|
|
68
76
|
|
|
69
|
-
expect(
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
expect(
|
|
78
|
+
screen.getByRole( 'option', { name: 'Option 1' } )
|
|
79
|
+
).toBeInTheDocument();
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
} );
|
|
81
|
+
const selectElement = screen.getByRole( 'combobox' );
|
|
82
|
+
await user.selectOptions( selectElement, 'option-2' );
|
|
76
83
|
|
|
77
84
|
expect( handleChangeMock ).toHaveBeenCalledWith(
|
|
78
85
|
'option-2',
|
package/src/shortcut/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { isString, isObject } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/** @typedef {string | { display: string, ariaLabel: string }} Shortcut */
|
|
7
2
|
/**
|
|
8
3
|
* @typedef Props
|
|
@@ -22,11 +17,11 @@ function Shortcut( { shortcut, className } ) {
|
|
|
22
17
|
let displayText;
|
|
23
18
|
let ariaLabel;
|
|
24
19
|
|
|
25
|
-
if (
|
|
20
|
+
if ( typeof shortcut === 'string' ) {
|
|
26
21
|
displayText = shortcut;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
if (
|
|
24
|
+
if ( shortcut !== null && typeof shortcut === 'object' ) {
|
|
30
25
|
displayText = shortcut.display;
|
|
31
26
|
ariaLabel = shortcut.ariaLabel;
|
|
32
27
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { omit } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
@@ -12,8 +7,8 @@ import Provider from './provider';
|
|
|
12
7
|
|
|
13
8
|
export { Fill, Provider };
|
|
14
9
|
|
|
15
|
-
export function Slot(
|
|
16
|
-
return <BaseSlot { ...
|
|
10
|
+
export function Slot( { bubblesVirtually, ...restProps } ) {
|
|
11
|
+
return <BaseSlot { ...restProps } />;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
export function createSlotFill( name ) {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { without } from 'lodash';
|
|
6
|
-
|
|
7
2
|
/**
|
|
8
3
|
* WordPress dependencies
|
|
9
4
|
*/
|
|
@@ -78,7 +73,8 @@ export default class SlotFillProvider extends Component {
|
|
|
78
73
|
}
|
|
79
74
|
|
|
80
75
|
unregisterFill( name, instance ) {
|
|
81
|
-
this.fills[ name ] =
|
|
76
|
+
this.fills[ name ] =
|
|
77
|
+
this.fills[ name ]?.filter( ( fill ) => fill !== instance ) ?? [];
|
|
82
78
|
this.forceUpdateSlot( name );
|
|
83
79
|
}
|
|
84
80
|
|
|
@@ -115,7 +111,7 @@ export default class SlotFillProvider extends Component {
|
|
|
115
111
|
this.listeners.push( listener );
|
|
116
112
|
|
|
117
113
|
return () => {
|
|
118
|
-
this.listeners =
|
|
114
|
+
this.listeners = this.listeners.filter( ( l ) => l !== listener );
|
|
119
115
|
};
|
|
120
116
|
}
|
|
121
117
|
|
package/src/slot-fill/slot.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { isString, map } from 'lodash';
|
|
6
|
-
|
|
7
2
|
/**
|
|
8
3
|
* WordPress dependencies
|
|
9
4
|
*/
|
|
@@ -72,25 +67,27 @@ class SlotComponent extends Component {
|
|
|
72
67
|
render() {
|
|
73
68
|
const { children, name, fillProps = {}, getFills } = this.props;
|
|
74
69
|
|
|
75
|
-
const fills =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
70
|
+
const fills = ( getFills( name, this ) ?? [] )
|
|
71
|
+
.map( ( fill ) => {
|
|
72
|
+
const fillChildren = isFunction( fill.children )
|
|
73
|
+
? fill.children( fillProps )
|
|
74
|
+
: fill.children;
|
|
75
|
+
|
|
76
|
+
return Children.map( fillChildren, ( child, childIndex ) => {
|
|
77
|
+
if ( ! child || typeof child === 'string' ) {
|
|
78
|
+
return child;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const childKey = child.key || childIndex;
|
|
82
|
+
return cloneElement( child, { key: childKey } );
|
|
83
|
+
} );
|
|
84
|
+
} )
|
|
85
|
+
.filter(
|
|
86
|
+
// In some cases fills are rendered only when some conditions apply.
|
|
87
|
+
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
88
|
+
// it allows us to render wrappers only when the fills are actually present.
|
|
89
|
+
( element ) => ! isEmptyElement( element )
|
|
90
|
+
);
|
|
94
91
|
|
|
95
92
|
return <>{ isFunction( children ) ? children( fills ) : fills }</>;
|
|
96
93
|
}
|