@wordpress/components 19.13.0 → 19.14.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 +38 -1
- package/build/alignment-matrix-control/utils.js +1 -7
- package/build/alignment-matrix-control/utils.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +4 -2
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.native.js +9 -3
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/autocomplete/index.js +4 -2
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +2 -1
- package/build/border-box-control/border-box-control/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +2 -1
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-control/border-control/component.js +40 -4
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/box-control/utils.js +3 -3
- package/build/box-control/utils.js.map +1 -1
- package/build/color-indicator/index.js +27 -10
- package/build/color-indicator/index.js.map +1 -1
- package/build/color-indicator/types.js +6 -0
- package/build/color-indicator/types.js.map +1 -0
- package/build/color-palette/index.js +2 -1
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/component.js +6 -9
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/input-with-slider.js +1 -2
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/styles.js +34 -16
- package/build/color-picker/styles.js.map +1 -1
- package/build/custom-gradient-picker/index.js +8 -8
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/index.native.js +8 -9
- package/build/custom-gradient-picker/index.native.js.map +1 -1
- package/build/custom-gradient-picker/serializer.js +4 -7
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/date-time/date/index.js +3 -1
- package/build/date-time/date/index.js.map +1 -1
- package/build/date-time/date-time/index.js +3 -1
- package/build/date-time/date-time/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +42 -29
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/elevation/hook.js +13 -13
- package/build/elevation/hook.js.map +1 -1
- package/build/focal-point-picker/index.native.js +4 -4
- package/build/focal-point-picker/index.native.js.map +1 -1
- package/build/form-toggle/index.js +28 -5
- package/build/form-toggle/index.js.map +1 -1
- package/build/form-toggle/types.js +6 -0
- package/build/form-toggle/types.js.map +1 -0
- package/build/h-stack/utils.js +3 -3
- package/build/h-stack/utils.js.map +1 -1
- package/build/heading/component.js +0 -1
- package/build/heading/component.js.map +1 -1
- package/build/heading/hook.js.map +1 -1
- package/build/heading/types.js +6 -0
- package/build/heading/types.js.map +1 -0
- package/build/mobile/bottom-sheet/keyboard-avoiding-view.native.js +0 -1
- package/build/mobile/bottom-sheet/keyboard-avoiding-view.native.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +4 -4
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +2 -4
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/navigation/group/index.js +4 -7
- package/build/navigation/group/index.js.map +1 -1
- package/build/navigation/item/base.js +3 -3
- package/build/navigation/item/base.js.map +1 -1
- package/build/navigation/item/use-navigation-tree-item.js +2 -1
- package/build/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build/navigation/menu/menu-title-search.js +1 -7
- package/build/navigation/menu/menu-title-search.js.map +1 -1
- package/build/navigation/menu/search-no-results-found.js +1 -7
- package/build/navigation/menu/search-no-results-found.js.map +1 -1
- package/build/navigation/use-navigation-tree-nodes.js +18 -10
- package/build/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build/navigation/utils.js +4 -2
- package/build/navigation/utils.js.map +1 -1
- package/build/range-control/index.js +3 -3
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/utils.js +3 -7
- package/build/range-control/utils.js.map +1 -1
- package/build/spacer/component.js +5 -5
- package/build/spacer/component.js.map +1 -1
- package/build/spinner/index.js +26 -13
- package/build/spinner/index.js.map +1 -1
- package/build/spinner/styles.js +10 -10
- package/build/spinner/styles.js.map +1 -1
- package/build/truncate/component.js +7 -8
- package/build/truncate/component.js.map +1 -1
- package/build/truncate/hook.js +3 -10
- package/build/truncate/hook.js.map +1 -1
- package/build/truncate/index.js.map +1 -1
- package/build/truncate/styles.js +1 -1
- package/build/truncate/styles.js.map +1 -1
- package/build/truncate/utils.js +3 -16
- package/build/truncate/utils.js.map +1 -1
- package/build/utils/math.js +17 -7
- package/build/utils/math.js.map +1 -1
- package/build/v-stack/component.js +9 -9
- package/build/v-stack/component.js.map +1 -1
- package/build/v-stack/hook.js +0 -5
- package/build/v-stack/hook.js.map +1 -1
- package/build/v-stack/index.js.map +1 -1
- package/build-module/alignment-matrix-control/utils.js +1 -6
- package/build-module/alignment-matrix-control/utils.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +4 -2
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.native.js +9 -3
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/autocomplete/index.js +4 -2
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +2 -1
- package/build-module/border-box-control/border-box-control/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +2 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-control/border-control/component.js +38 -3
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/box-control/utils.js +4 -4
- package/build-module/box-control/utils.js.map +1 -1
- package/build-module/color-indicator/index.js +29 -8
- package/build-module/color-indicator/index.js.map +1 -1
- package/build-module/color-indicator/types.js +2 -0
- package/build-module/color-indicator/types.js.map +1 -0
- package/build-module/color-palette/index.js +2 -1
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/component.js +7 -8
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +1 -2
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/styles.js +28 -14
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +8 -7
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/index.native.js +8 -8
- package/build-module/custom-gradient-picker/index.native.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +4 -6
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/date-time/date/index.js +3 -1
- package/build-module/date-time/date/index.js.map +1 -1
- package/build-module/date-time/date-time/index.js +3 -1
- package/build-module/date-time/date-time/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +42 -29
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/elevation/hook.js +12 -12
- package/build-module/elevation/hook.js.map +1 -1
- package/build-module/focal-point-picker/index.native.js +1 -1
- package/build-module/focal-point-picker/index.native.js.map +1 -1
- package/build-module/form-toggle/index.js +30 -6
- package/build-module/form-toggle/index.js.map +1 -1
- package/build-module/form-toggle/types.js +2 -0
- package/build-module/form-toggle/types.js.map +1 -0
- package/build-module/h-stack/utils.js +3 -3
- package/build-module/h-stack/utils.js.map +1 -1
- package/build-module/heading/component.js +0 -1
- package/build-module/heading/component.js.map +1 -1
- package/build-module/heading/hook.js.map +1 -1
- package/build-module/heading/types.js +2 -0
- package/build-module/heading/types.js.map +1 -0
- package/build-module/mobile/bottom-sheet/keyboard-avoiding-view.native.js +0 -1
- package/build-module/mobile/bottom-sheet/keyboard-avoiding-view.native.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +4 -3
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +2 -3
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/navigation/group/index.js +3 -6
- package/build-module/navigation/group/index.js.map +1 -1
- package/build-module/navigation/item/base.js +2 -2
- package/build-module/navigation/item/base.js.map +1 -1
- package/build-module/navigation/item/use-navigation-tree-item.js +2 -1
- package/build-module/navigation/item/use-navigation-tree-item.js.map +1 -1
- package/build-module/navigation/menu/menu-title-search.js +1 -6
- package/build-module/navigation/menu/menu-title-search.js.map +1 -1
- package/build-module/navigation/menu/search-no-results-found.js +1 -6
- package/build-module/navigation/menu/search-no-results-found.js.map +1 -1
- package/build-module/navigation/use-navigation-tree-nodes.js +18 -9
- package/build-module/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build-module/navigation/utils.js +2 -2
- package/build-module/navigation/utils.js.map +1 -1
- package/build-module/range-control/index.js +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/utils.js +1 -5
- package/build-module/range-control/utils.js.map +1 -1
- package/build-module/spacer/component.js +3 -4
- package/build-module/spacer/component.js.map +1 -1
- package/build-module/spinner/index.js +22 -13
- package/build-module/spinner/index.js.map +1 -1
- package/build-module/spinner/styles.js +10 -10
- package/build-module/spinner/styles.js.map +1 -1
- package/build-module/truncate/component.js +7 -8
- package/build-module/truncate/component.js.map +1 -1
- package/build-module/truncate/hook.js +3 -10
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/truncate/index.js.map +1 -1
- package/build-module/truncate/styles.js +1 -1
- package/build-module/truncate/styles.js.map +1 -1
- package/build-module/truncate/utils.js +3 -16
- package/build-module/truncate/utils.js.map +1 -1
- package/build-module/utils/math.js +15 -6
- package/build-module/utils/math.js.map +1 -1
- package/build-module/v-stack/component.js +9 -9
- package/build-module/v-stack/component.js.map +1 -1
- package/build-module/v-stack/hook.js +0 -5
- package/build-module/v-stack/hook.js.map +1 -1
- package/build-module/v-stack/index.js.map +1 -1
- package/build-style/style-rtl.css +16 -0
- package/build-style/style.css +16 -0
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/component.d.ts +36 -2
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.d.ts +33 -0
- package/build-types/border-control/stories/index.d.ts.map +1 -0
- package/build-types/color-indicator/index.d.ts +16 -5
- package/build-types/color-indicator/index.d.ts.map +1 -1
- package/build-types/color-indicator/stories/index.d.ts +12 -0
- package/build-types/color-indicator/stories/index.d.ts.map +1 -0
- package/build-types/color-indicator/test/index.d.ts +2 -0
- package/build-types/color-indicator/test/index.d.ts.map +1 -0
- package/build-types/color-indicator/types.d.ts +12 -0
- package/build-types/color-indicator/types.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +4 -2
- package/build-types/color-palette/styles.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +17 -0
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts +1 -1
- package/build-types/date-time/date/index.d.ts.map +1 -1
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/types.d.ts +6 -0
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/form-toggle/index.d.ts +29 -0
- package/build-types/form-toggle/index.d.ts.map +1 -0
- package/build-types/form-toggle/stories/index.d.ts +12 -0
- package/build-types/form-toggle/stories/index.d.ts.map +1 -0
- package/build-types/form-toggle/test/index.d.ts +2 -0
- package/build-types/form-toggle/test/index.d.ts.map +1 -0
- package/build-types/form-toggle/types.d.ts +22 -0
- package/build-types/form-toggle/types.d.ts.map +1 -0
- package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts +3 -0
- package/build-types/form-token-field/test/lib/token-field-wrapper.d.ts.map +1 -1
- package/build-types/heading/component.d.ts +1 -2
- package/build-types/heading/component.d.ts.map +1 -1
- package/build-types/heading/hook.d.ts +1 -28
- package/build-types/heading/hook.d.ts.map +1 -1
- package/build-types/heading/stories/index.d.ts.map +1 -1
- package/build-types/heading/test/index.d.ts +2 -0
- package/build-types/heading/test/index.d.ts.map +1 -0
- package/build-types/heading/types.d.ts +16 -0
- package/build-types/heading/types.d.ts.map +1 -0
- package/build-types/range-control/utils.d.ts.map +1 -1
- package/build-types/spacer/component.d.ts +2 -3
- package/build-types/spacer/component.d.ts.map +1 -1
- package/build-types/spacer/stories/index.d.ts +12 -0
- package/build-types/spacer/stories/index.d.ts.map +1 -0
- package/build-types/spinner/index.d.ts +16 -15
- package/build-types/spinner/index.d.ts.map +1 -1
- package/build-types/spinner/stories/index.d.ts +13 -0
- package/build-types/spinner/stories/index.d.ts.map +1 -0
- package/build-types/spinner/styles.d.ts +4 -3
- package/build-types/spinner/styles.d.ts.map +1 -1
- package/build-types/text/types.d.ts +1 -1
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/truncate/component.d.ts +3 -3
- package/build-types/truncate/component.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +5 -2
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/truncate/index.d.ts +2 -2
- package/build-types/truncate/index.d.ts.map +1 -1
- package/build-types/truncate/stories/index.d.ts +13 -0
- package/build-types/truncate/stories/index.d.ts.map +1 -0
- package/build-types/truncate/styles.d.ts +1 -1
- package/build-types/truncate/styles.d.ts.map +1 -1
- package/build-types/truncate/test/index.d.ts +2 -0
- package/build-types/truncate/test/index.d.ts.map +1 -0
- package/build-types/truncate/types.d.ts +22 -11
- package/build-types/truncate/types.d.ts.map +1 -1
- package/build-types/truncate/utils.d.ts +17 -28
- package/build-types/truncate/utils.d.ts.map +1 -1
- package/build-types/ui/form-group/use-form-group.d.ts +2 -2
- package/build-types/utils/math.d.ts +10 -0
- package/build-types/utils/math.d.ts.map +1 -1
- package/build-types/v-stack/component.d.ts +5 -4
- package/build-types/v-stack/component.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +5 -3
- package/build-types/v-stack/hook.d.ts.map +1 -1
- package/build-types/v-stack/index.d.ts +2 -2
- package/build-types/v-stack/index.d.ts.map +1 -1
- package/build-types/v-stack/stories/index.d.ts +9 -0
- package/build-types/v-stack/stories/index.d.ts.map +1 -0
- package/build-types/v-stack/test/index.d.ts +2 -0
- package/build-types/v-stack/test/index.d.ts.map +1 -0
- package/build-types/v-stack/types.d.ts +21 -1
- package/build-types/v-stack/types.d.ts.map +1 -1
- package/package.json +18 -17
- package/src/alignment-matrix-control/utils.js +1 -6
- package/src/autocomplete/autocompleter-ui.js +4 -1
- package/src/autocomplete/autocompleter-ui.native.js +8 -2
- package/src/autocomplete/index.js +4 -8
- package/src/border-box-control/border-box-control/component.tsx +1 -0
- package/src/border-box-control/border-box-control-split-controls/component.tsx +1 -0
- package/src/border-control/border-control/component.tsx +41 -4
- package/src/border-control/stories/index.tsx +150 -0
- package/src/box-control/utils.js +4 -4
- package/src/color-indicator/README.md +7 -9
- package/src/color-indicator/index.tsx +47 -0
- package/src/color-indicator/stories/index.tsx +37 -0
- package/src/color-indicator/test/__snapshots__/index.tsx.snap +11 -0
- package/src/color-indicator/test/{index.js → index.tsx} +4 -4
- package/src/color-indicator/types.ts +12 -0
- package/src/color-palette/index.js +5 -1
- package/src/color-picker/component.tsx +12 -11
- package/src/color-picker/input-with-slider.tsx +2 -2
- package/src/color-picker/styles.ts +20 -1
- package/src/custom-gradient-picker/index.js +4 -11
- package/src/custom-gradient-picker/index.native.js +3 -11
- package/src/custom-gradient-picker/serializer.js +5 -11
- package/src/date-time/README.md +7 -0
- package/src/date-time/date/index.tsx +2 -0
- package/src/date-time/date-time/index.tsx +2 -0
- package/src/date-time/types.ts +7 -0
- package/src/dimension-control/README.md +5 -2
- package/src/dimension-control/test/index.test.js +7 -7
- package/src/duotone-picker/duotone-picker.js +58 -37
- package/src/duotone-picker/style.scss +19 -0
- package/src/elevation/hook.js +8 -8
- package/src/flex/flex/README.md +5 -10
- package/src/flex/flex-item/README.md +1 -1
- package/src/focal-point-picker/index.native.js +1 -1
- package/src/form-toggle/README.md +10 -11
- package/src/form-toggle/index.tsx +71 -0
- package/src/form-toggle/stories/index.tsx +52 -0
- package/src/form-toggle/test/__snapshots__/index.tsx.snap +54 -0
- package/src/form-toggle/test/index.tsx +102 -0
- package/src/form-toggle/types.ts +22 -0
- package/src/form-token-field/test/index.js +6 -9
- package/src/form-token-field/test/lib/token-field-wrapper.tsx +2 -2
- package/src/h-stack/utils.js +3 -3
- package/src/heading/README.md +4 -3
- package/src/heading/component.tsx +2 -2
- package/src/heading/hook.ts +1 -42
- package/src/heading/stories/index.tsx +5 -1
- package/src/heading/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/heading/test/index.tsx +68 -0
- package/src/heading/types.ts +29 -0
- package/src/input-control/test/index.js +106 -31
- package/src/mobile/bottom-sheet/keyboard-avoiding-view.native.js +2 -7
- package/src/mobile/link-picker/index.native.js +2 -3
- package/src/mobile/segmented-control/index.native.js +6 -5
- package/src/navigation/group/index.js +8 -3
- package/src/navigation/item/base.js +3 -2
- package/src/navigation/item/use-navigation-tree-item.js +2 -0
- package/src/navigation/menu/menu-title-search.js +3 -6
- package/src/navigation/menu/search-no-results-found.js +3 -6
- package/src/navigation/use-navigation-tree-nodes.js +11 -10
- package/src/navigation/utils.js +2 -2
- package/src/number-control/stories/index.js +24 -24
- package/src/range-control/index.js +1 -1
- package/src/range-control/utils.js +1 -4
- package/src/slot-fill/test/slot.js +2 -3
- package/src/spacer/component.tsx +3 -4
- package/src/spacer/stories/index.tsx +70 -0
- package/src/spinner/{index.js → index.tsx} +23 -9
- package/src/spinner/stories/index.tsx +32 -0
- package/src/spinner/{styles.js → styles.ts} +0 -0
- package/src/style.scss +1 -0
- package/src/text/types.ts +1 -1
- package/src/truncate/README.md +16 -12
- package/src/truncate/{component.js → component.tsx} +13 -9
- package/src/truncate/{hook.js → hook.ts} +8 -10
- package/src/truncate/{index.js → index.ts} +0 -0
- package/src/truncate/stories/index.tsx +49 -0
- package/src/truncate/{styles.js → styles.ts} +0 -0
- package/src/truncate/test/{index.js → index.tsx} +4 -4
- package/src/truncate/types.ts +28 -10
- package/src/truncate/{utils.js → utils.ts} +19 -19
- package/src/utils/math.js +14 -5
- package/src/utils/test/math.js +22 -1
- package/src/v-stack/README.md +6 -18
- package/src/v-stack/{component.js → component.tsx} +15 -10
- package/src/v-stack/{hook.js → hook.ts} +5 -6
- package/src/v-stack/{index.js → index.ts} +0 -0
- package/src/v-stack/stories/index.tsx +41 -0
- package/src/v-stack/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/v-stack/test/{index.js → index.tsx} +0 -0
- package/src/v-stack/types.ts +21 -1
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/border-control/stories/index.js +0 -119
- package/src/color-indicator/index.js +0 -16
- package/src/color-indicator/stories/index.js +0 -22
- package/src/color-indicator/test/__snapshots__/index.js.snap +0 -13
- package/src/form-toggle/index.js +0 -38
- package/src/form-toggle/stories/index.js +0 -28
- package/src/form-toggle/test/index.js +0 -74
- package/src/heading/test/index.js +0 -67
- package/src/spacer/stories/index.js +0 -59
- package/src/spinner/stories/index.js +0 -43
- package/src/truncate/stories/index.js +0 -38
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { SafeAreaView, TouchableOpacity, View } from 'react-native';
|
|
5
5
|
import Clipboard from '@react-native-clipboard/clipboard';
|
|
6
|
-
import { lowerCase, startsWith } from 'lodash';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
@@ -26,7 +25,7 @@ import styles from './styles.scss';
|
|
|
26
25
|
export const createDirectEntry = ( value ) => {
|
|
27
26
|
let type = 'URL';
|
|
28
27
|
|
|
29
|
-
const protocol =
|
|
28
|
+
const protocol = getProtocol( value )?.toLowerCase() || '';
|
|
30
29
|
|
|
31
30
|
if ( protocol.includes( 'mailto' ) ) {
|
|
32
31
|
type = 'mailto';
|
|
@@ -36,7 +35,7 @@ export const createDirectEntry = ( value ) => {
|
|
|
36
35
|
type = 'tel';
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
if ( startsWith(
|
|
38
|
+
if ( value?.startsWith( '#' ) ) {
|
|
40
39
|
type = 'internal';
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
Animated,
|
|
10
10
|
Easing,
|
|
11
11
|
} from 'react-native';
|
|
12
|
-
import { values, map, reduce } from 'lodash';
|
|
13
12
|
/**
|
|
14
13
|
* WordPress dependencies
|
|
15
14
|
*/
|
|
@@ -101,11 +100,13 @@ const SegmentedControls = ( {
|
|
|
101
100
|
const { paddingLeft: offset } = isIOS
|
|
102
101
|
? styles.containerIOS
|
|
103
102
|
: styles.container;
|
|
104
|
-
const widths =
|
|
103
|
+
const widths = Object.values( segmentsDimensions ).map(
|
|
104
|
+
( dimension ) => dimension.width
|
|
105
|
+
);
|
|
105
106
|
const widthsDistance = widths.slice( 0, index );
|
|
106
|
-
const widthsDistanceSum = reduce(
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const widthsDistanceSum = widthsDistance.reduce(
|
|
108
|
+
( sum, n ) => sum + n,
|
|
109
|
+
0
|
|
109
110
|
);
|
|
110
111
|
|
|
111
112
|
const endValue = index === 0 ? 0 : widthsDistanceSum;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { find, uniqueId } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -16,8 +15,10 @@ import { NavigationGroupContext } from './context';
|
|
|
16
15
|
import { GroupTitleUI } from '../styles/navigation-styles';
|
|
17
16
|
import { useNavigationContext } from '../context';
|
|
18
17
|
|
|
18
|
+
let uniqueId = 0;
|
|
19
|
+
|
|
19
20
|
export default function NavigationGroup( { children, className, title } ) {
|
|
20
|
-
const [ groupId ] = useState( uniqueId
|
|
21
|
+
const [ groupId ] = useState( `group-${ ++uniqueId }` );
|
|
21
22
|
const {
|
|
22
23
|
navigationTree: { items },
|
|
23
24
|
} = useNavigationContext();
|
|
@@ -25,7 +26,11 @@ export default function NavigationGroup( { children, className, title } ) {
|
|
|
25
26
|
const context = { group: groupId };
|
|
26
27
|
|
|
27
28
|
// Keep the children rendered to make sure invisible items are included in the navigation tree.
|
|
28
|
-
if (
|
|
29
|
+
if (
|
|
30
|
+
! Object.values( items ).some(
|
|
31
|
+
( item ) => item.group === groupId && item._isVisible
|
|
32
|
+
)
|
|
33
|
+
) {
|
|
29
34
|
return (
|
|
30
35
|
<NavigationGroupContext.Provider value={ context }>
|
|
31
36
|
{ children }
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { uniqueId } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -16,10 +15,12 @@ import { useNavigationContext } from '../context';
|
|
|
16
15
|
import { useNavigationTreeItem } from './use-navigation-tree-item';
|
|
17
16
|
import { ItemBaseUI } from '../styles/navigation-styles';
|
|
18
17
|
|
|
18
|
+
let uniqueId = 0;
|
|
19
|
+
|
|
19
20
|
export default function NavigationItemBase( props ) {
|
|
20
21
|
const { children, className, ...restProps } = props;
|
|
21
22
|
|
|
22
|
-
const [ itemId ] = useState( uniqueId
|
|
23
|
+
const [ itemId ] = useState( `item-${ ++uniqueId }` );
|
|
23
24
|
|
|
24
25
|
useNavigationTreeItem( itemId, props );
|
|
25
26
|
const { navigationTree } = useNavigationContext();
|
|
@@ -34,5 +34,7 @@ export const useNavigationTreeItem = ( itemId, props ) => {
|
|
|
34
34
|
return () => {
|
|
35
35
|
removeItem( itemId );
|
|
36
36
|
};
|
|
37
|
+
// Ignore exhaustive-deps rule for now. See https://github.com/WordPress/gutenberg/pull/41639
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
39
|
}, [ activeMenu, search ] );
|
|
38
40
|
};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { filter } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -49,7 +44,9 @@ function MenuTitleSearch( {
|
|
|
49
44
|
return;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
const count =
|
|
47
|
+
const count = Object.values( items ).filter(
|
|
48
|
+
( item ) => item._isVisible
|
|
49
|
+
).length;
|
|
53
50
|
const resultsFoundMessage = sprintf(
|
|
54
51
|
/* translators: %d: number of results. */
|
|
55
52
|
_n( '%d result found.', '%d results found.', count ),
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { filter } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -19,7 +14,9 @@ export default function NavigationSearchNoResultsFound( { search } ) {
|
|
|
19
14
|
navigationTree: { items },
|
|
20
15
|
} = useNavigationContext();
|
|
21
16
|
|
|
22
|
-
const resultsCount =
|
|
17
|
+
const resultsCount = Object.values( items ).filter(
|
|
18
|
+
( item ) => item._isVisible
|
|
19
|
+
).length;
|
|
23
20
|
|
|
24
21
|
if ( ! search || !! resultsCount ) {
|
|
25
22
|
return null;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { omit } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -13,14 +8,20 @@ export const useNavigationTreeNodes = () => {
|
|
|
13
8
|
|
|
14
9
|
const getNode = ( key ) => nodes[ key ];
|
|
15
10
|
|
|
16
|
-
const addNode = ( key, value ) =>
|
|
17
|
-
|
|
11
|
+
const addNode = ( key, value ) => {
|
|
12
|
+
const { children, ...newNode } = value;
|
|
13
|
+
return setNodes( ( original ) => ( {
|
|
18
14
|
...original,
|
|
19
|
-
[ key ]:
|
|
15
|
+
[ key ]: newNode,
|
|
20
16
|
} ) );
|
|
17
|
+
};
|
|
21
18
|
|
|
22
|
-
const removeNode = ( key ) =>
|
|
23
|
-
setNodes( ( original ) =>
|
|
19
|
+
const removeNode = ( key ) => {
|
|
20
|
+
return setNodes( ( original ) => {
|
|
21
|
+
const { [ key ]: removedNode, ...remainingNodes } = original;
|
|
22
|
+
return remainingNodes;
|
|
23
|
+
} );
|
|
24
|
+
};
|
|
24
25
|
|
|
25
26
|
return { nodes, getNode, addNode, removeNode };
|
|
26
27
|
};
|
package/src/navigation/utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import removeAccents from 'remove-accents';
|
|
5
5
|
|
|
6
6
|
// @see packages/block-editor/src/components/inserter/search-items.js
|
|
7
7
|
export const normalizeInput = ( input ) =>
|
|
8
|
-
|
|
8
|
+
removeAccents( input ).replace( /^\//, '' ).toLowerCase();
|
|
9
9
|
|
|
10
10
|
export const normalizedSearch = ( title, search ) =>
|
|
11
11
|
-1 !== normalizeInput( title ).indexOf( normalizeInput( search ) );
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { boolean, number, text } from '@storybook/addon-knobs';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -16,29 +11,21 @@ import NumberControl from '../';
|
|
|
16
11
|
export default {
|
|
17
12
|
title: 'Components (Experimental)/NumberControl',
|
|
18
13
|
component: NumberControl,
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
argTypes: {
|
|
15
|
+
size: {
|
|
16
|
+
control: {
|
|
17
|
+
type: 'select',
|
|
18
|
+
options: [ 'default', 'small', '__unstable-large' ],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
onChange: { action: 'onChange' },
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
function
|
|
25
|
+
function Template( { onChange, ...props } ) {
|
|
25
26
|
const [ value, setValue ] = useState( '0' );
|
|
26
27
|
const [ isValidValue, setIsValidValue ] = useState( true );
|
|
27
28
|
|
|
28
|
-
const props = {
|
|
29
|
-
disabled: boolean( 'disabled', false ),
|
|
30
|
-
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
|
|
31
|
-
isPressEnterToChange: boolean( 'isPressEnterToChange', false ),
|
|
32
|
-
isShiftStepEnabled: boolean( 'isShiftStepEnabled', true ),
|
|
33
|
-
label: text( 'label', 'Number' ),
|
|
34
|
-
min: number( 'min', 0 ),
|
|
35
|
-
max: number( 'max', 100 ),
|
|
36
|
-
placeholder: text( 'placeholder', '0' ),
|
|
37
|
-
required: boolean( 'required', false ),
|
|
38
|
-
shiftStep: number( 'shiftStep', 10 ),
|
|
39
|
-
step: text( 'step', '1' ),
|
|
40
|
-
};
|
|
41
|
-
|
|
42
29
|
return (
|
|
43
30
|
<>
|
|
44
31
|
<NumberControl
|
|
@@ -47,6 +34,7 @@ function Example() {
|
|
|
47
34
|
onChange={ ( v, extra ) => {
|
|
48
35
|
setValue( v );
|
|
49
36
|
setIsValidValue( extra.event.target.validity.valid );
|
|
37
|
+
onChange( v, extra );
|
|
50
38
|
} }
|
|
51
39
|
/>
|
|
52
40
|
<p>Is valid? { isValidValue ? 'Yes' : 'No' }</p>
|
|
@@ -54,6 +42,18 @@ function Example() {
|
|
|
54
42
|
);
|
|
55
43
|
}
|
|
56
44
|
|
|
57
|
-
export const
|
|
58
|
-
|
|
45
|
+
export const Default = Template.bind( {} );
|
|
46
|
+
Default.args = {
|
|
47
|
+
disabled: false,
|
|
48
|
+
hideLabelFromVision: false,
|
|
49
|
+
isPressEnterToChange: false,
|
|
50
|
+
isShiftStepEnabled: true,
|
|
51
|
+
label: 'Number',
|
|
52
|
+
min: 0,
|
|
53
|
+
max: 100,
|
|
54
|
+
placeholder: '0',
|
|
55
|
+
required: false,
|
|
56
|
+
shiftStep: 10,
|
|
57
|
+
size: 'default',
|
|
58
|
+
step: '1',
|
|
59
59
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
-
import { clamp } from 'lodash';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* WordPress dependencies
|
|
@@ -20,6 +19,7 @@ import Button from '../button';
|
|
|
20
19
|
import Icon from '../icon';
|
|
21
20
|
import { COLORS } from '../utils';
|
|
22
21
|
import { floatClamp, useControlledRangeValue } from './utils';
|
|
22
|
+
import { clamp } from '../utils/math';
|
|
23
23
|
import InputRange from './input-range';
|
|
24
24
|
import RangeRail from './rail';
|
|
25
25
|
import SimpleTooltip from './tooltip';
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { clamp } from 'lodash';
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
@@ -13,6 +9,7 @@ import { useCallback, useRef, useEffect, useState } from '@wordpress/element';
|
|
|
13
9
|
* Internal dependencies
|
|
14
10
|
*/
|
|
15
11
|
import { useControlledState } from '../utils/hooks';
|
|
12
|
+
import { clamp } from '../utils/math';
|
|
16
13
|
|
|
17
14
|
const noop = () => {};
|
|
18
15
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { isEmpty } from 'lodash';
|
|
5
4
|
import { render, fireEvent } from '@testing-library/react';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -120,9 +119,9 @@ describe( 'Slot', () => {
|
|
|
120
119
|
<div>
|
|
121
120
|
<Slot name="chicken">
|
|
122
121
|
{ ( fills ) =>
|
|
123
|
-
|
|
122
|
+
[ ...fills ].length ? (
|
|
124
123
|
<blockquote>{ fills }</blockquote>
|
|
125
|
-
)
|
|
124
|
+
) : null
|
|
126
125
|
}
|
|
127
126
|
</Slot>
|
|
128
127
|
</div>
|
package/src/spacer/component.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { View } from '../view';
|
|
|
11
11
|
import { useSpacer } from './hook';
|
|
12
12
|
import type { Props } from './types';
|
|
13
13
|
|
|
14
|
-
function
|
|
14
|
+
function UnconnectedSpacer(
|
|
15
15
|
props: WordPressComponentProps< Props, 'div' >,
|
|
16
16
|
forwardedRef: ForwardedRef< any >
|
|
17
17
|
) {
|
|
@@ -25,7 +25,6 @@ function Spacer(
|
|
|
25
25
|
*
|
|
26
26
|
* `Spacer` comes with a bunch of shorthand props to adjust `margin` and `padding`. The values of these props work as a multiplier to the library's grid system (base of `4px`).
|
|
27
27
|
*
|
|
28
|
-
* @example
|
|
29
28
|
* ```jsx
|
|
30
29
|
* import { Spacer } from `@wordpress/components`
|
|
31
30
|
*
|
|
@@ -43,6 +42,6 @@ function Spacer(
|
|
|
43
42
|
* }
|
|
44
43
|
* ```
|
|
45
44
|
*/
|
|
46
|
-
const
|
|
45
|
+
export const Spacer = contextConnect( UnconnectedSpacer, 'Spacer' );
|
|
47
46
|
|
|
48
|
-
export default
|
|
47
|
+
export default Spacer;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Spacer } from '..';
|
|
10
|
+
|
|
11
|
+
const controls = [
|
|
12
|
+
'margin',
|
|
13
|
+
'marginY',
|
|
14
|
+
'marginX',
|
|
15
|
+
'marginTop',
|
|
16
|
+
'marginBottom',
|
|
17
|
+
'marginLeft',
|
|
18
|
+
'marginRight',
|
|
19
|
+
|
|
20
|
+
'padding',
|
|
21
|
+
'paddingY',
|
|
22
|
+
'paddingX',
|
|
23
|
+
'paddingTop',
|
|
24
|
+
'paddingBottom',
|
|
25
|
+
'paddingLeft',
|
|
26
|
+
'paddingRight',
|
|
27
|
+
].reduce(
|
|
28
|
+
( acc, prop ) => ( { ...acc, [ prop ]: { control: { type: 'text' } } } ),
|
|
29
|
+
{}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const meta: ComponentMeta< typeof Spacer > = {
|
|
33
|
+
component: Spacer,
|
|
34
|
+
title: 'Components (Experimental)/Spacer',
|
|
35
|
+
argTypes: {
|
|
36
|
+
as: { control: { type: 'text' } },
|
|
37
|
+
children: {
|
|
38
|
+
control: { type: 'text' },
|
|
39
|
+
},
|
|
40
|
+
...controls,
|
|
41
|
+
},
|
|
42
|
+
parameters: {
|
|
43
|
+
controls: {
|
|
44
|
+
expanded: true,
|
|
45
|
+
},
|
|
46
|
+
docs: { source: { state: 'open' } },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
export default meta;
|
|
50
|
+
|
|
51
|
+
const BlackBox = () => (
|
|
52
|
+
<div
|
|
53
|
+
style={ { backgroundColor: 'black', width: '100px', height: '100px' } }
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const Template: ComponentStory< typeof Spacer > = ( { onChange, ...args } ) => {
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<BlackBox />
|
|
61
|
+
<Spacer { ...args } />
|
|
62
|
+
<BlackBox />
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const Default: ComponentStory< typeof Spacer > = Template.bind( {} );
|
|
68
|
+
Default.args = {
|
|
69
|
+
children: 'This is the spacer',
|
|
70
|
+
};
|
|
@@ -2,24 +2,23 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
+
import type { ForwardedRef } from 'react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
10
|
import { StyledSpinner, SpinnerTrack, SpinnerIndicator } from './styles';
|
|
11
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @property {string} [className] Class name
|
|
14
|
+
* WordPress dependencies
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
import { forwardRef } from '@wordpress/element';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export default function Spinner( { className, ...props } ) {
|
|
18
|
+
export function UnforwardedSpinner(
|
|
19
|
+
{ className, ...props }: WordPressComponentProps< {}, 'svg', false >,
|
|
20
|
+
forwardedRef: ForwardedRef< any >
|
|
21
|
+
) {
|
|
23
22
|
return (
|
|
24
23
|
<StyledSpinner
|
|
25
24
|
className={ classNames( 'components-spinner', className ) }
|
|
@@ -28,6 +27,7 @@ export default function Spinner( { className, ...props } ) {
|
|
|
28
27
|
role="presentation"
|
|
29
28
|
focusable="false"
|
|
30
29
|
{ ...props }
|
|
30
|
+
ref={ forwardedRef }
|
|
31
31
|
>
|
|
32
32
|
{ /* Gray circular background */ }
|
|
33
33
|
<SpinnerTrack
|
|
@@ -45,3 +45,17 @@ export default function Spinner( { className, ...props } ) {
|
|
|
45
45
|
</StyledSpinner>
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* `Spinner` is a component used to notify users that their action is being processed.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```js
|
|
53
|
+
* import { Spinner } from '@wordpress/components';
|
|
54
|
+
*
|
|
55
|
+
* function Example() {
|
|
56
|
+
* return <Spinner />;
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export const Spinner = forwardRef( UnforwardedSpinner );
|
|
61
|
+
export default Spinner;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import Spinner from '../';
|
|
10
|
+
import { space } from '../../ui/utils/space';
|
|
11
|
+
|
|
12
|
+
const meta: ComponentMeta< typeof Spinner > = {
|
|
13
|
+
title: 'Components/Spinner',
|
|
14
|
+
component: Spinner,
|
|
15
|
+
parameters: {
|
|
16
|
+
controls: {
|
|
17
|
+
expanded: true,
|
|
18
|
+
},
|
|
19
|
+
docs: { source: { state: 'open' } },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
const Template: ComponentStory< typeof Spinner > = ( args ) => {
|
|
25
|
+
return <Spinner { ...args } />;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Default: ComponentStory< typeof Spinner > = Template.bind( {} );
|
|
29
|
+
|
|
30
|
+
// The Spinner can be resized to any size, but the stroke width will remain unchanged.
|
|
31
|
+
export const CustomSize: ComponentStory< typeof Spinner > = Template.bind( {} );
|
|
32
|
+
CustomSize.args = { style: { width: space( 20 ), height: space( 20 ) } };
|
|
File without changes
|
package/src/style.scss
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
@import "./drop-zone/style.scss";
|
|
18
18
|
@import "./dropdown/style.scss";
|
|
19
19
|
@import "./dropdown-menu/style.scss";
|
|
20
|
+
@import "./duotone-picker/style.scss";
|
|
20
21
|
@import "./font-size-picker/style.scss";
|
|
21
22
|
@import "./form-toggle/style.scss";
|
|
22
23
|
@import "./form-token-field/style.scss";
|
package/src/text/types.ts
CHANGED
package/src/truncate/README.md
CHANGED
|
@@ -24,15 +24,14 @@ function Example() {
|
|
|
24
24
|
|
|
25
25
|
## Props
|
|
26
26
|
|
|
27
|
-
##### ellipsis
|
|
27
|
+
##### `ellipsis`: `string`
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The ellipsis string when truncating the text by the `limit` prop's value.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
- Required: No
|
|
32
|
+
- Default: `…`
|
|
32
33
|
|
|
33
|
-
##### ellipsizeMode
|
|
34
|
-
|
|
35
|
-
**Type**: `"auto"`,`"head"`,`"tail"`,`"middle"`
|
|
34
|
+
##### `ellipsizeMode`: `'auto' | 'head' | 'tail' | 'middle' | 'none'`
|
|
36
35
|
|
|
37
36
|
Determines where to truncate. For example, we can truncate text right in the middle. To do this, we need to set `ellipsizeMode` to `middle` and a text `limit`.
|
|
38
37
|
|
|
@@ -41,17 +40,22 @@ Determines where to truncate. For example, we can truncate text right in the mid
|
|
|
41
40
|
- `middle`: Trims content in the middle. Requires a `limit`.
|
|
42
41
|
- `tail`: Trims content at the end. Requires a `limit`.
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
- Required: No
|
|
44
|
+
- Default: `auto`
|
|
45
|
+
|
|
46
|
+
##### `limit`: `number`
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
Determines the max number of characters to be displayed before the rest of the text gets truncated. Requires `ellipsizeMode` to assume values different from `auto` and `none`.
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
- Required: No
|
|
51
|
+
- Default: `0`
|
|
49
52
|
|
|
50
|
-
##### numberOfLines
|
|
53
|
+
##### `numberOfLines`: `number`
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
Clamps the text content to the specified `numberOfLines`, adding an ellipsis at the end. Note: this feature ignores the value of the `ellipsis` prop and always displays the default `…` ellipsis.
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
- Required: No
|
|
58
|
+
- Default: `0`
|
|
55
59
|
|
|
56
60
|
```jsx
|
|
57
61
|
import { __experimentalTruncate as Truncate } from '@wordpress/components';
|
|
@@ -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 useTruncate from './hook';
|
|
12
|
+
import type { TruncateProps } from './types';
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function Truncate( props, forwardedRef ) {
|
|
14
|
+
function UnconnectedTruncate(
|
|
15
|
+
props: WordPressComponentProps< TruncateProps, 'span' >,
|
|
16
|
+
forwardedRef: ForwardedRef< any >
|
|
17
|
+
) {
|
|
13
18
|
const truncateProps = useTruncate( props );
|
|
14
19
|
|
|
15
20
|
return <View as="span" { ...truncateProps } ref={ forwardedRef } />;
|
|
@@ -21,7 +26,6 @@ function Truncate( props, forwardedRef ) {
|
|
|
21
26
|
* `Subheading` is used to render text content. However,`Truncate` is
|
|
22
27
|
* available for custom implementations.
|
|
23
28
|
*
|
|
24
|
-
* @example
|
|
25
29
|
* ```jsx
|
|
26
30
|
* import { __experimentalTruncate as Truncate } from `@wordpress/components`;
|
|
27
31
|
*
|
|
@@ -36,6 +40,6 @@ function Truncate( props, forwardedRef ) {
|
|
|
36
40
|
* }
|
|
37
41
|
* ```
|
|
38
42
|
*/
|
|
39
|
-
const
|
|
43
|
+
export const Truncate = contextConnect( UnconnectedTruncate, 'Truncate' );
|
|
40
44
|
|
|
41
|
-
export default
|
|
45
|
+
export default Truncate;
|