@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/spacer/README.md
CHANGED
|
@@ -33,87 +33,93 @@ function Example() {
|
|
|
33
33
|
|
|
34
34
|
## Props
|
|
35
35
|
|
|
36
|
-
### `
|
|
37
|
-
|
|
38
|
-
Adjusts all margins.
|
|
39
|
-
|
|
40
|
-
- Required: No
|
|
41
|
-
|
|
42
|
-
### `marginY`: `number`
|
|
36
|
+
### `children`: `ReactNode`
|
|
43
37
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- Required: No
|
|
47
|
-
|
|
48
|
-
### `marginX`: `number`
|
|
49
|
-
|
|
50
|
-
Adjusts left and right margins, potentially overriding the value from the more generic `margin` prop.
|
|
38
|
+
The children elements.
|
|
51
39
|
|
|
52
|
-
-
|
|
40
|
+
- Required: No
|
|
53
41
|
|
|
54
|
-
### `
|
|
42
|
+
### `margin`: `number`
|
|
55
43
|
|
|
56
|
-
Adjusts
|
|
44
|
+
Adjusts all margins.
|
|
57
45
|
|
|
58
|
-
-
|
|
46
|
+
- Required: No
|
|
59
47
|
|
|
60
48
|
### `marginBottom`: `number`
|
|
61
49
|
|
|
62
50
|
Adjusts bottom margin, potentially overriding the value from the more generic `margin` and `marginY` props.
|
|
63
51
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
52
|
+
- Required: No
|
|
53
|
+
- Default: `2`
|
|
66
54
|
|
|
67
55
|
### `marginLeft`: `number`
|
|
68
56
|
|
|
69
57
|
Adjusts left margin, potentially overriding the value from the more generic `margin` and `marginX` props.
|
|
70
58
|
|
|
71
|
-
-
|
|
59
|
+
- Required: No
|
|
72
60
|
|
|
73
61
|
### `marginRight`: `number`
|
|
74
62
|
|
|
75
63
|
Adjusts right margin, potentially overriding the value from the more generic `margin` and `marginX` props.
|
|
76
64
|
|
|
77
|
-
-
|
|
65
|
+
- Required: No
|
|
78
66
|
|
|
79
|
-
### `
|
|
67
|
+
### `marginTop`: `number`
|
|
80
68
|
|
|
81
|
-
Adjusts
|
|
69
|
+
Adjusts top margin, potentially overriding the value from the more generic `margin` and `marginY` props.
|
|
82
70
|
|
|
83
|
-
-
|
|
71
|
+
- Required: No
|
|
84
72
|
|
|
85
|
-
### `
|
|
73
|
+
### `marginX`: `number`
|
|
86
74
|
|
|
87
|
-
Adjusts
|
|
75
|
+
Adjusts left and right margins, potentially overriding the value from the more generic `margin` prop.
|
|
88
76
|
|
|
89
|
-
-
|
|
77
|
+
- Required: No
|
|
90
78
|
|
|
91
|
-
### `
|
|
79
|
+
### `marginY`: `number`
|
|
92
80
|
|
|
93
|
-
Adjusts
|
|
81
|
+
Adjusts top and bottom margins, potentially overriding the value from the more generic `margin` prop.
|
|
94
82
|
|
|
95
|
-
-
|
|
83
|
+
- Required: No
|
|
96
84
|
|
|
97
|
-
### `
|
|
85
|
+
### `padding`: `number`
|
|
98
86
|
|
|
99
|
-
Adjusts
|
|
87
|
+
Adjusts all padding.
|
|
100
88
|
|
|
101
|
-
-
|
|
89
|
+
- Required: No
|
|
102
90
|
|
|
103
91
|
### `paddingBottom`: `number`
|
|
104
92
|
|
|
105
93
|
Adjusts bottom padding, potentially overriding the value from the more generic `padding` and `paddingY` props.
|
|
106
94
|
|
|
107
|
-
-
|
|
95
|
+
- Required: No
|
|
108
96
|
|
|
109
97
|
### `paddingLeft`: `number`
|
|
110
98
|
|
|
111
99
|
Adjusts left padding, potentially overriding the value from the more generic `padding` and `paddingX` props.
|
|
112
100
|
|
|
113
|
-
-
|
|
101
|
+
- Required: No
|
|
114
102
|
|
|
115
103
|
### `paddingRight`: `number`
|
|
116
104
|
|
|
117
105
|
Adjusts right padding, potentially overriding the value from the more generic `padding` and `paddingX` props.
|
|
118
106
|
|
|
119
|
-
-
|
|
107
|
+
- Required: No
|
|
108
|
+
|
|
109
|
+
### `paddingTop`: `number`
|
|
110
|
+
|
|
111
|
+
Adjusts top padding, potentially overriding the value from the more generic `padding` and `paddingY` props.
|
|
112
|
+
|
|
113
|
+
- Required: No
|
|
114
|
+
|
|
115
|
+
### `paddingX`: `number`
|
|
116
|
+
|
|
117
|
+
Adjusts left and right padding, potentially overriding the value from the more generic `padding` prop.
|
|
118
|
+
|
|
119
|
+
- Required: No
|
|
120
|
+
|
|
121
|
+
### `paddingY`: `number`
|
|
122
|
+
|
|
123
|
+
Adjusts top and bottom padding, potentially overriding the value from the more generic `padding` prop.
|
|
124
|
+
|
|
125
|
+
- Required: No
|
package/src/spacer/component.tsx
CHANGED
|
@@ -9,10 +9,10 @@ import type { ForwardedRef } from 'react';
|
|
|
9
9
|
import { contextConnect, WordPressComponentProps } from '../ui/context';
|
|
10
10
|
import { View } from '../view';
|
|
11
11
|
import { useSpacer } from './hook';
|
|
12
|
-
import type {
|
|
12
|
+
import type { SpacerProps } from './types';
|
|
13
13
|
|
|
14
14
|
function UnconnectedSpacer(
|
|
15
|
-
props: WordPressComponentProps<
|
|
15
|
+
props: WordPressComponentProps< SpacerProps, 'div' >,
|
|
16
16
|
forwardedRef: ForwardedRef< any >
|
|
17
17
|
) {
|
|
18
18
|
const spacerProps = useSpacer( props );
|
package/src/spacer/hook.ts
CHANGED
|
@@ -9,12 +9,14 @@ import { css } from '@emotion/react';
|
|
|
9
9
|
import { useContextSystem, WordPressComponentProps } from '../ui/context';
|
|
10
10
|
import { space } from '../ui/utils/space';
|
|
11
11
|
import { rtl, useCx } from '../utils';
|
|
12
|
-
import type {
|
|
12
|
+
import type { SpacerProps } from './types';
|
|
13
13
|
|
|
14
14
|
const isDefined = < T >( o: T ): o is Exclude< T, null | undefined > =>
|
|
15
15
|
typeof o !== 'undefined' && o !== null;
|
|
16
16
|
|
|
17
|
-
export function useSpacer(
|
|
17
|
+
export function useSpacer(
|
|
18
|
+
props: WordPressComponentProps< SpacerProps, 'div' >
|
|
19
|
+
) {
|
|
18
20
|
const {
|
|
19
21
|
className,
|
|
20
22
|
margin,
|
package/src/spacer/index.ts
CHANGED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Spacer } from '../index';
|
|
10
|
+
|
|
11
|
+
describe( 'props', () => {
|
|
12
|
+
beforeEach( () => {
|
|
13
|
+
render( <Spacer data-testid="spacer" /> );
|
|
14
|
+
} );
|
|
15
|
+
|
|
16
|
+
test( 'should render correctly', () => {
|
|
17
|
+
expect( screen.getByTestId( 'spacer' ) ).toMatchSnapshot();
|
|
18
|
+
} );
|
|
19
|
+
|
|
20
|
+
test( 'should render margin', () => {
|
|
21
|
+
render( <Spacer margin={ 5 } data-testid="customized-spacer" /> );
|
|
22
|
+
expect(
|
|
23
|
+
screen.getByTestId( 'customized-spacer' )
|
|
24
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
test( 'should render marginX', () => {
|
|
28
|
+
render( <Spacer marginX={ 5 } data-testid="customized-spacer" /> );
|
|
29
|
+
expect(
|
|
30
|
+
screen.getByTestId( 'customized-spacer' )
|
|
31
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
test( 'should render marginY', () => {
|
|
35
|
+
render( <Spacer marginY={ 5 } data-testid="customized-spacer" /> );
|
|
36
|
+
expect(
|
|
37
|
+
screen.getByTestId( 'customized-spacer' )
|
|
38
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
39
|
+
} );
|
|
40
|
+
|
|
41
|
+
test( 'should render marginTop', () => {
|
|
42
|
+
render( <Spacer marginTop={ 5 } data-testid="customized-spacer" /> );
|
|
43
|
+
expect(
|
|
44
|
+
screen.getByTestId( 'customized-spacer' )
|
|
45
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
46
|
+
} );
|
|
47
|
+
|
|
48
|
+
test( 'should render marginBottom', () => {
|
|
49
|
+
render( <Spacer marginBottom={ 5 } data-testid="customized-spacer" /> );
|
|
50
|
+
expect(
|
|
51
|
+
screen.getByTestId( 'customized-spacer' )
|
|
52
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
test( 'should render marginLeft', () => {
|
|
56
|
+
render( <Spacer marginLeft={ 5 } data-testid="customized-spacer" /> );
|
|
57
|
+
expect(
|
|
58
|
+
screen.getByTestId( 'customized-spacer' )
|
|
59
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
test( 'should render marginRight', () => {
|
|
63
|
+
render( <Spacer marginRight={ 5 } data-testid="customized-spacer" /> );
|
|
64
|
+
expect(
|
|
65
|
+
screen.getByTestId( 'customized-spacer' )
|
|
66
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
test( 'should override margin props from less to more specific', () => {
|
|
70
|
+
render(
|
|
71
|
+
<Spacer
|
|
72
|
+
margin={ 10 }
|
|
73
|
+
marginX={ 3 }
|
|
74
|
+
marginRight={ 5 }
|
|
75
|
+
marginBottom={ 1 }
|
|
76
|
+
data-testid="customized-spacer"
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
expect(
|
|
80
|
+
screen.getByTestId( 'customized-spacer' )
|
|
81
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
82
|
+
} );
|
|
83
|
+
|
|
84
|
+
test( 'should render padding', () => {
|
|
85
|
+
render( <Spacer padding={ 5 } data-testid="customized-spacer" /> );
|
|
86
|
+
expect(
|
|
87
|
+
screen.getByTestId( 'customized-spacer' )
|
|
88
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
89
|
+
} );
|
|
90
|
+
|
|
91
|
+
test( 'should render paddingX', () => {
|
|
92
|
+
render( <Spacer paddingX={ 5 } data-testid="customized-spacer" /> );
|
|
93
|
+
expect(
|
|
94
|
+
screen.getByTestId( 'customized-spacer' )
|
|
95
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
test( 'should render paddingY', () => {
|
|
99
|
+
render( <Spacer paddingY={ 5 } data-testid="customized-spacer" /> );
|
|
100
|
+
expect(
|
|
101
|
+
screen.getByTestId( 'customized-spacer' )
|
|
102
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
test( 'should render paddingTop', () => {
|
|
106
|
+
render( <Spacer paddingTop={ 5 } data-testid="customized-spacer" /> );
|
|
107
|
+
expect(
|
|
108
|
+
screen.getByTestId( 'customized-spacer' )
|
|
109
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
110
|
+
} );
|
|
111
|
+
|
|
112
|
+
test( 'should render paddingBottom', () => {
|
|
113
|
+
render(
|
|
114
|
+
<Spacer paddingBottom={ 5 } data-testid="customized-spacer" />
|
|
115
|
+
);
|
|
116
|
+
expect(
|
|
117
|
+
screen.getByTestId( 'customized-spacer' )
|
|
118
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
119
|
+
} );
|
|
120
|
+
|
|
121
|
+
test( 'should render paddingLeft', () => {
|
|
122
|
+
render( <Spacer paddingLeft={ 5 } data-testid="customized-spacer" /> );
|
|
123
|
+
expect(
|
|
124
|
+
screen.getByTestId( 'customized-spacer' )
|
|
125
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
126
|
+
} );
|
|
127
|
+
|
|
128
|
+
test( 'should render paddingRight', () => {
|
|
129
|
+
render( <Spacer paddingRight={ 5 } data-testid="customized-spacer" /> );
|
|
130
|
+
expect(
|
|
131
|
+
screen.getByTestId( 'customized-spacer' )
|
|
132
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
133
|
+
} );
|
|
134
|
+
|
|
135
|
+
test( 'should override padding props from less to more specific', () => {
|
|
136
|
+
render(
|
|
137
|
+
<Spacer
|
|
138
|
+
padding={ 10 }
|
|
139
|
+
paddingY={ 2 }
|
|
140
|
+
paddingTop={ 5 }
|
|
141
|
+
paddingLeft={ 3 }
|
|
142
|
+
data-testid="customized-spacer"
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
expect(
|
|
146
|
+
screen.getByTestId( 'customized-spacer' )
|
|
147
|
+
).toMatchStyleDiffSnapshot( screen.getByTestId( 'spacer' ) );
|
|
148
|
+
} );
|
|
149
|
+
} );
|
package/src/spacer/types.ts
CHANGED
|
@@ -8,67 +8,79 @@ import type { ReactNode } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { SpaceInput } from '../ui/utils/space';
|
|
10
10
|
|
|
11
|
-
export type
|
|
11
|
+
export type SpacerProps = {
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
margin?: SpaceInput;
|
|
16
|
-
/**
|
|
17
|
-
* Adjusts top and bottom margins.
|
|
18
|
-
*/
|
|
19
|
-
marginY?: SpaceInput;
|
|
20
|
-
/**
|
|
21
|
-
* Adjusts left and right margins.
|
|
13
|
+
* The children elements.
|
|
22
14
|
*/
|
|
23
|
-
|
|
15
|
+
children?: ReactNode;
|
|
24
16
|
/**
|
|
25
|
-
* Adjusts
|
|
17
|
+
* Adjusts all margins.
|
|
26
18
|
*/
|
|
27
|
-
|
|
19
|
+
margin?: SpaceInput;
|
|
28
20
|
/**
|
|
29
|
-
* Adjusts bottom
|
|
21
|
+
* Adjusts bottom margin, potentially overriding the value from the more
|
|
22
|
+
* generic `margin` and `marginY` props.
|
|
30
23
|
*
|
|
31
24
|
* @default 2
|
|
32
25
|
*/
|
|
33
26
|
marginBottom?: SpaceInput;
|
|
34
27
|
/**
|
|
35
|
-
* Adjusts left
|
|
28
|
+
* Adjusts left margin, potentially overriding the value from the more
|
|
29
|
+
* generic `margin` and `marginX` props.
|
|
36
30
|
*/
|
|
37
31
|
marginLeft?: SpaceInput;
|
|
38
32
|
/**
|
|
39
|
-
* Adjusts right
|
|
33
|
+
* Adjusts right margin, potentially overriding the value from the more
|
|
34
|
+
* generic `margin` and `marginX` props.
|
|
40
35
|
*/
|
|
41
36
|
marginRight?: SpaceInput;
|
|
42
37
|
/**
|
|
43
|
-
* Adjusts
|
|
38
|
+
* Adjusts top margin, potentially overriding the value from the more
|
|
39
|
+
* generic `margin` and `marginY` props.
|
|
44
40
|
*/
|
|
45
|
-
|
|
41
|
+
marginTop?: SpaceInput;
|
|
46
42
|
/**
|
|
47
|
-
* Adjusts
|
|
43
|
+
* Adjusts left and right margins, potentially overriding the value from the
|
|
44
|
+
* more generic `margin` prop.
|
|
48
45
|
*/
|
|
49
|
-
|
|
46
|
+
marginX?: SpaceInput;
|
|
50
47
|
/**
|
|
51
|
-
* Adjusts
|
|
48
|
+
* Adjusts top and bottom margins, potentially overriding the value from the
|
|
49
|
+
* more generic `margin` prop.
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
marginY?: SpaceInput;
|
|
54
52
|
/**
|
|
55
|
-
* Adjusts
|
|
53
|
+
* Adjusts all padding.
|
|
56
54
|
*/
|
|
57
|
-
|
|
55
|
+
padding?: SpaceInput;
|
|
58
56
|
/**
|
|
59
|
-
* Adjusts bottom padding
|
|
57
|
+
* Adjusts bottom padding, potentially overriding the value from the more
|
|
58
|
+
* generic `padding` and `paddingY` props.
|
|
60
59
|
*/
|
|
61
60
|
paddingBottom?: SpaceInput;
|
|
62
61
|
/**
|
|
63
|
-
* Adjusts left padding
|
|
62
|
+
* Adjusts left padding, potentially overriding the value from the more
|
|
63
|
+
* generic `padding` and `paddingX` props.
|
|
64
64
|
*/
|
|
65
65
|
paddingLeft?: SpaceInput;
|
|
66
66
|
/**
|
|
67
|
-
* Adjusts right padding
|
|
67
|
+
* Adjusts right padding, potentially overriding the value from the more
|
|
68
|
+
* generic `padding` and `paddingX` props.
|
|
68
69
|
*/
|
|
69
70
|
paddingRight?: SpaceInput;
|
|
70
71
|
/**
|
|
71
|
-
*
|
|
72
|
+
* Adjusts top padding, potentially overriding the value from the more
|
|
73
|
+
* generic `padding` and `paddingY` props.
|
|
72
74
|
*/
|
|
73
|
-
|
|
75
|
+
paddingTop?: SpaceInput;
|
|
76
|
+
/**
|
|
77
|
+
* Adjusts left and right padding, potentially overriding the value from the
|
|
78
|
+
* more generic `padding` prop.
|
|
79
|
+
*/
|
|
80
|
+
paddingX?: SpaceInput;
|
|
81
|
+
/**
|
|
82
|
+
* Adjusts top and bottom padding, potentially overriding the value from the
|
|
83
|
+
* more generic `padding` prop.
|
|
84
|
+
*/
|
|
85
|
+
paddingY?: SpaceInput;
|
|
74
86
|
};
|
package/src/tab-panel/README.md
CHANGED
|
@@ -144,7 +144,7 @@ Optionally provide a tab name for a tab to be selected upon mounting of componen
|
|
|
144
144
|
|
|
145
145
|
#### children
|
|
146
146
|
|
|
147
|
-
A function which renders the tabviews given the selected tab. The function is passed the active tab object as an argument as defined the
|
|
147
|
+
A function which renders the tabviews given the selected tab. The function is passed the active tab object as an argument as defined the tabs prop.
|
|
148
148
|
The element to which the tooltip should anchor.
|
|
149
149
|
|
|
150
150
|
- Type: (`Object`) => `Element`
|
|
@@ -23,16 +23,16 @@ const MyTextHighlight = () => (
|
|
|
23
23
|
|
|
24
24
|
The component accepts the following props.
|
|
25
25
|
|
|
26
|
-
###
|
|
26
|
+
### `highlight`: `string`
|
|
27
27
|
|
|
28
|
-
The string
|
|
28
|
+
The string to search for and highlight within the `text`. Case insensitive. Multiple matches.
|
|
29
29
|
|
|
30
|
-
- Type: `String`
|
|
31
30
|
- Required: Yes
|
|
31
|
+
- Default: `''`
|
|
32
32
|
|
|
33
|
-
###
|
|
33
|
+
### `text`: `string`
|
|
34
34
|
|
|
35
|
-
The string to
|
|
35
|
+
The string of text to be tested for occurrences of then given `highlight`.
|
|
36
36
|
|
|
37
|
-
- Type: `String`
|
|
38
37
|
- Required: Yes
|
|
38
|
+
- Default: `''`
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { escapeRegExp } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createInterpolateElement } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import type { TextHighlightProps } from './types';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Highlights occurrences of a given string within another string of text. Wraps
|
|
18
|
+
* each match with a `<mark>` tag which provides browser default styling.
|
|
19
|
+
*
|
|
20
|
+
* ```jsx
|
|
21
|
+
* import { TextHighlight } from '@wordpress/components';
|
|
22
|
+
*
|
|
23
|
+
* const MyTextHighlight = () => (
|
|
24
|
+
* <TextHighlight
|
|
25
|
+
* text="Why do we like Gutenberg? Because Gutenberg is the best!"
|
|
26
|
+
* highlight="Gutenberg"
|
|
27
|
+
* />
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const TextHighlight = ( props: TextHighlightProps ) => {
|
|
32
|
+
const { text = '', highlight = '' } = props;
|
|
33
|
+
const trimmedHighlightText = highlight.trim();
|
|
34
|
+
|
|
35
|
+
if ( ! trimmedHighlightText ) {
|
|
36
|
+
return <>{ text }</>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const regex = new RegExp(
|
|
40
|
+
`(${ escapeRegExp( trimmedHighlightText ) })`,
|
|
41
|
+
'gi'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return createInterpolateElement( text.replace( regex, '<mark>$&</mark>' ), {
|
|
45
|
+
mark: <mark />,
|
|
46
|
+
} );
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default TextHighlight;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import TextHighlight from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof TextHighlight > = {
|
|
12
|
+
component: TextHighlight,
|
|
13
|
+
title: 'Components/TextHighlight',
|
|
14
|
+
parameters: {
|
|
15
|
+
controls: {
|
|
16
|
+
expanded: true,
|
|
17
|
+
},
|
|
18
|
+
docs: { source: { state: 'open' } },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export default meta;
|
|
22
|
+
|
|
23
|
+
const Template: ComponentStory< typeof TextHighlight > = ( args ) => {
|
|
24
|
+
return <TextHighlight { ...args } />;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default: ComponentStory< typeof TextHighlight > = Template.bind(
|
|
28
|
+
{}
|
|
29
|
+
);
|
|
30
|
+
Default.args = {
|
|
31
|
+
text: 'We call the new editor Gutenberg. The entire editing experience has been rebuilt for media rich pages and posts.',
|
|
32
|
+
highlight: 'Gutenberg',
|
|
33
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import TextHighlight from '..';
|
|
10
|
+
|
|
11
|
+
const getMarks = ( container: Element ) =>
|
|
12
|
+
// Use querySelectorAll because the `mark` role is not officially supported
|
|
13
|
+
// yet. This should be changed to `getByRole` when it is.
|
|
14
|
+
Array.from( container.querySelectorAll( 'mark' ) );
|
|
15
|
+
|
|
16
|
+
const defaultText =
|
|
17
|
+
'We call the new editor Gutenberg. The entire editing experience has been rebuilt for media rich pages and posts.';
|
|
18
|
+
|
|
19
|
+
describe( 'TextHighlight', () => {
|
|
20
|
+
describe( 'Basic rendering', () => {
|
|
21
|
+
it.each( [ [ 'Gutenberg' ], [ 'media' ] ] )(
|
|
22
|
+
'should highlight the singular occurance of the text "%s" in the text if it exists',
|
|
23
|
+
( highlight ) => {
|
|
24
|
+
const { container } = render(
|
|
25
|
+
<TextHighlight
|
|
26
|
+
text={ defaultText }
|
|
27
|
+
highlight={ highlight }
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const highlightedEls = getMarks( container );
|
|
32
|
+
|
|
33
|
+
highlightedEls.forEach( ( el ) => {
|
|
34
|
+
expect( el ).toHaveTextContent(
|
|
35
|
+
new RegExp( `^${ highlight }$` )
|
|
36
|
+
);
|
|
37
|
+
} );
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
it( 'should highlight multiple occurances of the string every time it exists in the text', () => {
|
|
42
|
+
const highlight = 'edit';
|
|
43
|
+
|
|
44
|
+
const { container } = render(
|
|
45
|
+
<TextHighlight text={ defaultText } highlight={ highlight } />
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const highlightedEls = getMarks( container );
|
|
49
|
+
|
|
50
|
+
expect( highlightedEls ).toHaveLength( 2 );
|
|
51
|
+
|
|
52
|
+
highlightedEls.forEach( ( el ) => {
|
|
53
|
+
expect( el.textContent ).toEqual(
|
|
54
|
+
expect.stringContaining( highlight )
|
|
55
|
+
);
|
|
56
|
+
} );
|
|
57
|
+
} );
|
|
58
|
+
|
|
59
|
+
it( 'should highlight occurances of a string regardless of capitalisation', () => {
|
|
60
|
+
// Note that `The` occurs twice in the default text, once in
|
|
61
|
+
// lowercase and once capitalized.
|
|
62
|
+
const highlight = 'The';
|
|
63
|
+
|
|
64
|
+
const { container } = render(
|
|
65
|
+
<TextHighlight text={ defaultText } highlight={ highlight } />
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const highlightedEls = getMarks( container );
|
|
69
|
+
|
|
70
|
+
expect( highlightedEls ).toHaveLength( 2 );
|
|
71
|
+
|
|
72
|
+
// Make sure the matcher is case insensitive, since the test should
|
|
73
|
+
// match regardless of the case of the string.
|
|
74
|
+
const regex = new RegExp( highlight, 'i' );
|
|
75
|
+
|
|
76
|
+
highlightedEls.forEach( ( el ) => {
|
|
77
|
+
expect( el.innerHTML ).toMatch( regex );
|
|
78
|
+
} );
|
|
79
|
+
} );
|
|
80
|
+
|
|
81
|
+
it( 'should not highlight a string that is not in the text', () => {
|
|
82
|
+
const highlight = 'Antidisestablishmentarianism';
|
|
83
|
+
|
|
84
|
+
const { container } = render(
|
|
85
|
+
<TextHighlight text={ defaultText } highlight={ highlight } />
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const highlightedEls = getMarks( container );
|
|
89
|
+
|
|
90
|
+
expect( highlightedEls ).toHaveLength( 0 );
|
|
91
|
+
} );
|
|
92
|
+
} );
|
|
93
|
+
} );
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TextHighlightProps = {
|
|
2
|
+
/**
|
|
3
|
+
* The string to search for and highlight within the `text`. Case
|
|
4
|
+
* insensitive. Multiple matches.
|
|
5
|
+
*
|
|
6
|
+
* @default ''
|
|
7
|
+
*/
|
|
8
|
+
highlight: string;
|
|
9
|
+
/**
|
|
10
|
+
* The string of text to be tested for occurrences of then given
|
|
11
|
+
* `highlight`.
|
|
12
|
+
*
|
|
13
|
+
* @default ''
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Icon, tip } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { TipProps } from './types';
|
|
10
|
+
|
|
11
|
+
export function Tip( props: TipProps ) {
|
|
12
|
+
const { children } = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="components-tip">
|
|
16
|
+
<Icon icon={ tip } />
|
|
17
|
+
<p>{ children }</p>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default Tip;
|