@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
|
@@ -11,15 +11,15 @@ import { useMemo } from '@wordpress/element';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
-
import { useContextSystem } from '../ui/context';
|
|
14
|
+
import { useContextSystem, WordPressComponentProps } from '../ui/context';
|
|
15
15
|
import * as styles from './styles';
|
|
16
16
|
import { TRUNCATE_ELLIPSIS, TRUNCATE_TYPE, truncateContent } from './utils';
|
|
17
17
|
import { useCx } from '../utils/hooks/use-cx';
|
|
18
|
+
import type { TruncateProps } from './types';
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export default function useTruncate( props ) {
|
|
20
|
+
export default function useTruncate(
|
|
21
|
+
props: WordPressComponentProps< TruncateProps, 'span' >
|
|
22
|
+
) {
|
|
23
23
|
const {
|
|
24
24
|
className,
|
|
25
25
|
children,
|
|
@@ -33,7 +33,7 @@ export default function useTruncate( props ) {
|
|
|
33
33
|
const cx = useCx();
|
|
34
34
|
|
|
35
35
|
const truncatedContent = truncateContent(
|
|
36
|
-
typeof children === 'string' ?
|
|
36
|
+
typeof children === 'string' ? children : '',
|
|
37
37
|
{
|
|
38
38
|
ellipsis,
|
|
39
39
|
ellipsizeMode,
|
|
@@ -45,9 +45,7 @@ export default function useTruncate( props ) {
|
|
|
45
45
|
const shouldTruncate = ellipsizeMode === TRUNCATE_TYPE.auto;
|
|
46
46
|
|
|
47
47
|
const classes = useMemo( () => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
sx.numberOfLines = css`
|
|
48
|
+
const truncateLines = css`
|
|
51
49
|
-webkit-box-orient: vertical;
|
|
52
50
|
-webkit-line-clamp: ${ numberOfLines };
|
|
53
51
|
display: -webkit-box;
|
|
@@ -56,7 +54,7 @@ export default function useTruncate( props ) {
|
|
|
56
54
|
|
|
57
55
|
return cx(
|
|
58
56
|
shouldTruncate && ! numberOfLines && styles.Truncate,
|
|
59
|
-
shouldTruncate && !! numberOfLines &&
|
|
57
|
+
shouldTruncate && !! numberOfLines && truncateLines,
|
|
60
58
|
className
|
|
61
59
|
);
|
|
62
60
|
}, [ className, cx, numberOfLines, shouldTruncate ] );
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Truncate } from '..';
|
|
10
|
+
|
|
11
|
+
const meta: ComponentMeta< typeof Truncate > = {
|
|
12
|
+
component: Truncate,
|
|
13
|
+
title: 'Components (Experimental)/Truncate',
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: { control: { type: 'text' } },
|
|
16
|
+
as: { control: { type: 'text' } },
|
|
17
|
+
},
|
|
18
|
+
parameters: {
|
|
19
|
+
controls: {
|
|
20
|
+
expanded: true,
|
|
21
|
+
},
|
|
22
|
+
docs: { source: { state: 'open' } },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
const defaultText =
|
|
28
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut facilisis dictum tortor, eu tincidunt justo scelerisque tincidunt. Duis semper dui id augue malesuada, ut feugiat nisi aliquam. Vestibulum venenatis diam sem, finibus dictum massa semper in. Nulla facilisi. Nunc vulputate faucibus diam, in lobortis arcu ornare vel. In dignissim nunc sed facilisis finibus. Etiam imperdiet mattis arcu, sed rutrum sapien blandit gravida. Aenean sollicitudin neque eget enim blandit, sit amet rutrum leo vehicula. Nunc malesuada ultricies eros ut faucibus. Aliquam erat volutpat. Nulla nec feugiat risus. Vivamus iaculis dui aliquet ante ultricies feugiat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Vivamus nec pretium velit, sit amet consectetur ante. Praesent porttitor ex eget fermentum mattis.';
|
|
29
|
+
|
|
30
|
+
const Template: ComponentStory< typeof Truncate > = ( args ) => {
|
|
31
|
+
return <Truncate { ...args } />;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Default: ComponentStory< typeof Truncate > = Template.bind( {} );
|
|
35
|
+
Default.args = {
|
|
36
|
+
numberOfLines: 2,
|
|
37
|
+
children: defaultText,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const CharacterCount: ComponentStory< typeof Truncate > = Template.bind(
|
|
41
|
+
{}
|
|
42
|
+
);
|
|
43
|
+
CharacterCount.args = {
|
|
44
|
+
limit: 23,
|
|
45
|
+
children: defaultText,
|
|
46
|
+
ellipsizeMode: 'tail',
|
|
47
|
+
ellipsis: '[---]',
|
|
48
|
+
};
|
|
49
|
+
CharacterCount.storyName = 'Truncate by character count';
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ import { Truncate } from '..';
|
|
|
11
11
|
describe( 'props', () => {
|
|
12
12
|
test( 'should render correctly', () => {
|
|
13
13
|
const { container } = render( <Truncate>Lorem ipsum.</Truncate> );
|
|
14
|
-
expect( container.firstChild
|
|
14
|
+
expect( container.firstChild?.textContent ).toEqual( 'Lorem ipsum.' );
|
|
15
15
|
} );
|
|
16
16
|
|
|
17
17
|
test( 'should render limit', () => {
|
|
@@ -20,7 +20,7 @@ describe( 'props', () => {
|
|
|
20
20
|
Lorem ipsum.
|
|
21
21
|
</Truncate>
|
|
22
22
|
);
|
|
23
|
-
expect( container.firstChild
|
|
23
|
+
expect( container.firstChild?.textContent ).toEqual( 'L…' );
|
|
24
24
|
} );
|
|
25
25
|
|
|
26
26
|
test( 'should render custom ellipsis', () => {
|
|
@@ -29,7 +29,7 @@ describe( 'props', () => {
|
|
|
29
29
|
Lorem ipsum.
|
|
30
30
|
</Truncate>
|
|
31
31
|
);
|
|
32
|
-
expect( container.firstChild
|
|
32
|
+
expect( container.firstChild?.textContent ).toEqual( 'Lorem!!!' );
|
|
33
33
|
} );
|
|
34
34
|
|
|
35
35
|
test( 'should render custom ellipsizeMode', () => {
|
|
@@ -38,6 +38,6 @@ describe( 'props', () => {
|
|
|
38
38
|
Lorem ipsum.
|
|
39
39
|
</Truncate>
|
|
40
40
|
);
|
|
41
|
-
expect( container.firstChild
|
|
41
|
+
expect( container.firstChild?.textContent ).toEqual( 'Lo!!!m.' );
|
|
42
42
|
} );
|
|
43
43
|
} );
|
package/src/truncate/types.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
|
|
3
|
-
export
|
|
6
|
+
export type TruncateEllipsizeMode =
|
|
7
|
+
| 'auto'
|
|
8
|
+
| 'head'
|
|
9
|
+
| 'tail'
|
|
10
|
+
| 'middle'
|
|
11
|
+
| 'none';
|
|
12
|
+
|
|
13
|
+
export type TruncateProps = {
|
|
4
14
|
/**
|
|
5
|
-
* The ellipsis string when `
|
|
15
|
+
* The ellipsis string when truncating the text by the `limit` prop's value.
|
|
6
16
|
*
|
|
7
|
-
* @default '
|
|
17
|
+
* @default '…'
|
|
8
18
|
*/
|
|
9
19
|
ellipsis?: string;
|
|
10
20
|
/**
|
|
11
|
-
* Determines where to truncate. For example, we can truncate text right in
|
|
21
|
+
* Determines where to truncate. For example, we can truncate text right in
|
|
22
|
+
* the middle. To do this, we need to set `ellipsizeMode` to `middle` and a
|
|
23
|
+
* text `limit`.
|
|
12
24
|
*
|
|
13
25
|
* * `auto`: Trims content at the end automatically without a `limit`.
|
|
14
26
|
* * `head`: Trims content at the beginning. Requires a `limit`.
|
|
@@ -17,19 +29,25 @@ export interface Props {
|
|
|
17
29
|
*
|
|
18
30
|
* @default 'auto'
|
|
19
31
|
*/
|
|
20
|
-
ellipsizeMode?:
|
|
32
|
+
ellipsizeMode?: TruncateEllipsizeMode;
|
|
21
33
|
/**
|
|
22
|
-
* Determines the max characters
|
|
34
|
+
* Determines the max number of characters to be displayed before the rest
|
|
35
|
+
* of the text gets truncated. Requires `ellipsizeMode` to assume values
|
|
36
|
+
* different from `auto` and `none`.
|
|
23
37
|
*
|
|
24
38
|
* @default 0
|
|
25
39
|
*/
|
|
26
40
|
limit?: number;
|
|
27
41
|
/**
|
|
28
|
-
* Clamps the text content to the specified `numberOfLines`, adding
|
|
42
|
+
* Clamps the text content to the specified `numberOfLines`, adding an
|
|
43
|
+
* ellipsis at the end. Note: this feature ignores the value of the
|
|
44
|
+
* `ellipsis` prop and always displays the default `…` ellipsis.
|
|
45
|
+
*
|
|
46
|
+
* @default 0
|
|
29
47
|
*/
|
|
30
48
|
numberOfLines?: number;
|
|
31
49
|
/**
|
|
32
50
|
* The children elements.
|
|
33
51
|
*/
|
|
34
|
-
children:
|
|
35
|
-
}
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { isValueDefined } from '../utils/values';
|
|
5
|
+
import type { TruncateProps } from './types';
|
|
5
6
|
|
|
6
7
|
export const TRUNCATE_ELLIPSIS = '…';
|
|
7
8
|
export const TRUNCATE_TYPE = {
|
|
@@ -10,7 +11,7 @@ export const TRUNCATE_TYPE = {
|
|
|
10
11
|
middle: 'middle',
|
|
11
12
|
tail: 'tail',
|
|
12
13
|
none: 'none',
|
|
13
|
-
};
|
|
14
|
+
} as const;
|
|
14
15
|
|
|
15
16
|
export const TRUNCATE_DEFAULT_PROPS = {
|
|
16
17
|
ellipsis: TRUNCATE_ELLIPSIS,
|
|
@@ -21,13 +22,12 @@ export const TRUNCATE_DEFAULT_PROPS = {
|
|
|
21
22
|
|
|
22
23
|
// Source
|
|
23
24
|
// https://github.com/kahwee/truncate-middle
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export function truncateMiddle( word, headLength, tailLength, ellipsis ) {
|
|
25
|
+
export function truncateMiddle(
|
|
26
|
+
word: string,
|
|
27
|
+
headLength: number,
|
|
28
|
+
tailLength: number,
|
|
29
|
+
ellipsis: string
|
|
30
|
+
) {
|
|
31
31
|
if ( typeof word !== 'string' ) {
|
|
32
32
|
return '';
|
|
33
33
|
}
|
|
@@ -38,7 +38,9 @@ export function truncateMiddle( word, headLength, tailLength, ellipsis ) {
|
|
|
38
38
|
// eslint-disable-next-line no-bitwise
|
|
39
39
|
const backLength = ~~tailLength;
|
|
40
40
|
/* istanbul ignore next */
|
|
41
|
-
const truncateStr =
|
|
41
|
+
const truncateStr = isValueDefined( ellipsis )
|
|
42
|
+
? ellipsis
|
|
43
|
+
: TRUNCATE_ELLIPSIS;
|
|
42
44
|
|
|
43
45
|
if (
|
|
44
46
|
( frontLength === 0 && backLength === 0 ) ||
|
|
@@ -57,12 +59,10 @@ export function truncateMiddle( word, headLength, tailLength, ellipsis ) {
|
|
|
57
59
|
);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
export function truncateContent( words = '', props ) {
|
|
62
|
+
export function truncateContent(
|
|
63
|
+
words: string = '',
|
|
64
|
+
props: Omit< TruncateProps, 'children' >
|
|
65
|
+
) {
|
|
66
66
|
const mergedProps = { ...TRUNCATE_DEFAULT_PROPS, ...props };
|
|
67
67
|
const { ellipsis, ellipsizeMode, limit } = mergedProps;
|
|
68
68
|
|
|
@@ -70,8 +70,8 @@ export function truncateContent( words = '', props ) {
|
|
|
70
70
|
return words;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
let truncateHead;
|
|
74
|
-
let truncateTail;
|
|
73
|
+
let truncateHead: number;
|
|
74
|
+
let truncateTail: number;
|
|
75
75
|
|
|
76
76
|
switch ( ellipsizeMode ) {
|
|
77
77
|
case TRUNCATE_TYPE.head:
|
package/src/utils/math.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { clamp } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Parses and retrieves a number value.
|
|
8
3
|
*
|
|
@@ -61,6 +56,20 @@ function getPrecision( value ) {
|
|
|
61
56
|
return split[ 1 ] !== undefined ? split[ 1 ].length : 0;
|
|
62
57
|
}
|
|
63
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Clamps a value based on a min/max range.
|
|
61
|
+
*
|
|
62
|
+
* @param {number} value The value.
|
|
63
|
+
* @param {number} min The minimum range.
|
|
64
|
+
* @param {number} max The maximum range.
|
|
65
|
+
*
|
|
66
|
+
* @return {number} The clamped value.
|
|
67
|
+
*/
|
|
68
|
+
export function clamp( value, min, max ) {
|
|
69
|
+
const baseValue = getNumber( value );
|
|
70
|
+
return Math.max( min, Math.min( baseValue, max ) );
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
/**
|
|
65
74
|
* Clamps a value based on a min/max range with rounding
|
|
66
75
|
*
|
package/src/utils/test/math.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { add, subtract, roundClamp } from '../math';
|
|
4
|
+
import { add, clamp, subtract, roundClamp } from '../math';
|
|
5
5
|
|
|
6
6
|
describe( 'add', () => {
|
|
7
7
|
it( 'should add string and number values', () => {
|
|
@@ -37,6 +37,27 @@ describe( 'subtract', () => {
|
|
|
37
37
|
} );
|
|
38
38
|
} );
|
|
39
39
|
|
|
40
|
+
describe( 'clamp', () => {
|
|
41
|
+
it( 'should clamp a value between min and max', () => {
|
|
42
|
+
expect( clamp( 10, 1, 10 ) ).toBe( 10 );
|
|
43
|
+
expect( clamp( 1, 1, 10 ) ).toBe( 1 );
|
|
44
|
+
expect( clamp( 0, 1, 10 ) ).toBe( 1 );
|
|
45
|
+
|
|
46
|
+
expect( clamp( 50, 1, 10 ) ).toBe( 10 );
|
|
47
|
+
expect( clamp( 50, -10, 10 ) ).toBe( 10 );
|
|
48
|
+
expect( clamp( -50, -10, 10 ) ).toBe( -10 );
|
|
49
|
+
|
|
50
|
+
expect( clamp( Infinity, -10, 10 ) ).toBe( 10 );
|
|
51
|
+
expect( clamp( -Infinity, -10, 10 ) ).toBe( -10 );
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
it( 'should clamp number or string values', () => {
|
|
55
|
+
expect( clamp( '50', 1, 10 ) ).toBe( 10 );
|
|
56
|
+
expect( clamp( '50', -10, 10 ) ).toBe( 10 );
|
|
57
|
+
expect( clamp( -50, -10, '10' ) ).toBe( -10 );
|
|
58
|
+
} );
|
|
59
|
+
} );
|
|
60
|
+
|
|
40
61
|
describe( 'roundClamp', () => {
|
|
41
62
|
it( 'should clamp a value between min and max', () => {
|
|
42
63
|
expect( roundClamp( 10, 1, 10 ) ).toBe( 10 );
|
package/src/v-stack/README.md
CHANGED
|
@@ -29,9 +29,7 @@ function Example() {
|
|
|
29
29
|
|
|
30
30
|
## Props
|
|
31
31
|
|
|
32
|
-
##### alignment
|
|
33
|
-
|
|
34
|
-
**Type**: `HStackAlignment`,`CSS['alignItems']`
|
|
32
|
+
##### `alignment`: `HStackAlignment | CSSProperties['alignItems']`
|
|
35
33
|
|
|
36
34
|
Determines how the child elements are aligned.
|
|
37
35
|
|
|
@@ -47,35 +45,25 @@ Determines how the child elements are aligned.
|
|
|
47
45
|
- `edge`: Aligns content to the edges of the container.
|
|
48
46
|
- `stretch`: Stretches content to the edges of the container.
|
|
49
47
|
|
|
50
|
-
##### direction
|
|
51
|
-
|
|
52
|
-
**Type**: `FlexDirection`
|
|
48
|
+
##### `direction`: `FlexDirection`
|
|
53
49
|
|
|
54
50
|
The direction flow of the children content can be adjusted with `direction`. `column` will align children vertically and `row` will align children horizontally.
|
|
55
51
|
|
|
56
|
-
##### expanded
|
|
57
|
-
|
|
58
|
-
**Type**: `boolean`
|
|
52
|
+
##### `expanded`: `boolean`
|
|
59
53
|
|
|
60
54
|
Expands to the maximum available width (if horizontal) or height (if vertical).
|
|
61
55
|
|
|
62
|
-
##### justify
|
|
63
|
-
|
|
64
|
-
**Type**: `CSS['justifyContent']`
|
|
56
|
+
##### `justify`: `CSSProperties['justifyContent']`
|
|
65
57
|
|
|
66
58
|
Horizontally aligns content if the `direction` is `row`, or vertically aligns content if the `direction` is `column`.
|
|
67
59
|
In the example below, `flex-start` will align the children content to the left.
|
|
68
60
|
|
|
69
|
-
##### spacing
|
|
70
|
-
|
|
71
|
-
**Type**: `CSS['width']`
|
|
61
|
+
##### `spacing`: `CSSProperties['width']`
|
|
72
62
|
|
|
73
63
|
The amount of space between each child element. Spacing in between each child can be adjusted by using `spacing`.
|
|
74
64
|
The value of `spacing` works as a multiplier to the library's grid system (base of `4px`).
|
|
75
65
|
|
|
76
|
-
##### wrap
|
|
77
|
-
|
|
78
|
-
**Type**: `boolean`
|
|
66
|
+
##### `wrap`: `boolean`
|
|
79
67
|
|
|
80
68
|
Determines if children should wrap.
|
|
81
69
|
|
|
@@ -1,26 +1,31 @@
|
|
|
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 { useVStack } from './hook';
|
|
12
|
+
import type { VStackProps } from './types';
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function VStack( props, forwardedRef ) {
|
|
14
|
+
function UnconnectedVStack(
|
|
15
|
+
props: WordPressComponentProps< VStackProps, 'div' >,
|
|
16
|
+
forwardedRef: ForwardedRef< any >
|
|
17
|
+
) {
|
|
13
18
|
const vStackProps = useVStack( props );
|
|
14
19
|
|
|
15
20
|
return <View { ...vStackProps } ref={ forwardedRef } />;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
/**
|
|
19
|
-
* `VStack` (or Vertical Stack) is a layout component that arranges child
|
|
24
|
+
* `VStack` (or Vertical Stack) is a layout component that arranges child
|
|
25
|
+
* elements in a vertical line.
|
|
20
26
|
*
|
|
21
27
|
* `VStack` can render anything inside.
|
|
22
28
|
*
|
|
23
|
-
* @example
|
|
24
29
|
* ```jsx
|
|
25
30
|
* import {
|
|
26
31
|
* __experimentalText as Text,
|
|
@@ -38,6 +43,6 @@ function VStack( props, forwardedRef ) {
|
|
|
38
43
|
* }
|
|
39
44
|
* ```
|
|
40
45
|
*/
|
|
41
|
-
const
|
|
46
|
+
export const VStack = contextConnect( UnconnectedVStack, 'VStack' );
|
|
42
47
|
|
|
43
|
-
export default
|
|
48
|
+
export default VStack;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useContextSystem } from '../ui/context';
|
|
4
|
+
import { useContextSystem, WordPressComponentProps } from '../ui/context';
|
|
5
5
|
import { useHStack } from '../h-stack';
|
|
6
|
+
import type { VStackProps } from './types';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export function useVStack( props ) {
|
|
8
|
+
export function useVStack(
|
|
9
|
+
props: WordPressComponentProps< VStackProps, 'div' >
|
|
10
|
+
) {
|
|
12
11
|
const { expanded = false, ...otherProps } = useContextSystem(
|
|
13
12
|
props,
|
|
14
13
|
'VStack'
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { View } from '../../view';
|
|
10
|
+
import { VStack } from '..';
|
|
11
|
+
|
|
12
|
+
const meta: ComponentMeta< typeof VStack > = {
|
|
13
|
+
component: VStack,
|
|
14
|
+
title: 'Components (Experimental)/VStack',
|
|
15
|
+
argTypes: {
|
|
16
|
+
alignment: { control: { type: 'text' } },
|
|
17
|
+
as: { control: { type: 'text' } },
|
|
18
|
+
direction: { control: { type: 'text' } },
|
|
19
|
+
justify: { control: { type: 'text' } },
|
|
20
|
+
spacing: { control: { type: 'text' } },
|
|
21
|
+
},
|
|
22
|
+
parameters: {
|
|
23
|
+
controls: { expanded: true },
|
|
24
|
+
docs: { source: { state: 'open' } },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
|
|
29
|
+
const Template: ComponentStory< typeof VStack > = ( props ) => {
|
|
30
|
+
return (
|
|
31
|
+
<VStack { ...props }>
|
|
32
|
+
<View>One</View>
|
|
33
|
+
<View>Two</View>
|
|
34
|
+
<View>Three</View>
|
|
35
|
+
<View>Four</View>
|
|
36
|
+
<View>Five</View>
|
|
37
|
+
</VStack>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Default = Template.bind( {} );
|
|
File without changes
|
|
File without changes
|
package/src/v-stack/types.ts
CHANGED
|
@@ -8,7 +8,27 @@ import type { CSSProperties } from 'react';
|
|
|
8
8
|
*/
|
|
9
9
|
import type { HStackAlignment, Props as HStackProps } from '../h-stack/types';
|
|
10
10
|
|
|
11
|
-
export type
|
|
11
|
+
export type VStackProps = HStackProps & {
|
|
12
|
+
/**
|
|
13
|
+
* Determines how the child elements are aligned.
|
|
14
|
+
*
|
|
15
|
+
* - `top`: Aligns content to the top.
|
|
16
|
+
* - `topLeft`: Aligns content to the top/left.
|
|
17
|
+
* - `topRight`: Aligns content to the top/right.
|
|
18
|
+
* - `left`: Aligns content to the left.
|
|
19
|
+
* - `center`: Aligns content to the center.
|
|
20
|
+
* - `right`: Aligns content to the right.
|
|
21
|
+
* - `bottom`: Aligns content to the bottom.
|
|
22
|
+
* - `bottomLeft`: Aligns content to the bottom/left.
|
|
23
|
+
* - `bottomRight`: Aligns content to the bottom/right.
|
|
24
|
+
* - `edge`: Aligns content to the edges of the container.
|
|
25
|
+
* - `stretch`: Stretches content to the edges of the container.
|
|
26
|
+
*/
|
|
12
27
|
alignment?: HStackAlignment | CSSProperties[ 'alignItems' ];
|
|
28
|
+
/**
|
|
29
|
+
* The amount of space between each child element. Spacing in between each
|
|
30
|
+
* child can be adjusted by using `spacing`. The value of `spacing` works as
|
|
31
|
+
* a multiplier to the library's grid system (base of `4px`).
|
|
32
|
+
*/
|
|
13
33
|
spacing?: CSSProperties[ 'width' ];
|
|
14
34
|
};
|