@wordpress/components 19.11.0 → 19.12.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 +36 -0
- package/README.md +1 -1
- package/build/alignment-matrix-control/index.js +5 -2
- package/build/alignment-matrix-control/index.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.js +1 -1
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/autocomplete/autocompleter-ui.native.js +2 -2
- package/build/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build/autocomplete/index.js +12 -10
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control/hook.js +2 -2
- package/build/border-box-control/border-box-control/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +2 -0
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/hook.js +13 -4
- package/build/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build/border-box-control/border-box-control-visualizer/hook.js +6 -2
- package/build/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build/border-box-control/styles.js +21 -11
- package/build/border-box-control/styles.js.map +1 -1
- package/build/border-control/border-control/hook.js +2 -2
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/color-palette/index.js +9 -2
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/index.native.js +4 -1
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/color-copy-button.js +87 -0
- package/build/color-picker/color-copy-button.js.map +1 -0
- package/build/color-picker/component.js +5 -15
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js +18 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/styles.js +11 -11
- package/build/color-picker/styles.js.map +1 -1
- package/build/custom-gradient-picker/utils.js +1 -1
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/date-time/{date.js → date/index.js} +51 -12
- package/build/date-time/date/index.js.map +1 -0
- package/build/date-time/date/styles.js +70 -0
- package/build/date-time/date/styles.js.map +1 -0
- package/build/date-time/{utils.js → date/utils.js} +0 -0
- package/build/date-time/date/utils.js.map +1 -0
- package/build/date-time/date-time/index.js +175 -0
- package/build/date-time/date-time/index.js.map +1 -0
- package/build/date-time/date-time/styles.js +32 -0
- package/build/date-time/date-time/styles.js.map +1 -0
- package/build/date-time/index.js +2 -109
- package/build/date-time/index.js.map +1 -1
- package/build/date-time/time/index.js +322 -0
- package/build/date-time/time/index.js.map +1 -0
- package/build/date-time/time/styles.js +139 -0
- package/build/date-time/time/styles.js.map +1 -0
- package/build/date-time/{timezone.js → time/timezone.js} +4 -2
- package/build/date-time/time/timezone.js.map +1 -0
- package/build/draggable/index.native.js +10 -5
- package/build/draggable/index.native.js.map +1 -1
- package/build/dropdown/index.js +4 -1
- package/build/dropdown/index.js.map +1 -1
- package/build/input-control/index.js +9 -4
- package/build/input-control/index.js.map +1 -1
- package/build/input-control/input-field.js +1 -26
- package/build/input-control/input-field.js.map +1 -1
- package/build/input-control/reducer/reducer.js +36 -24
- package/build/input-control/reducer/reducer.js.map +1 -1
- package/build/input-control/reducer/state.js +0 -1
- package/build/input-control/reducer/state.js.map +1 -1
- package/build/input-control/utils.js +45 -0
- package/build/input-control/utils.js.map +1 -1
- package/build/popover/index.js +40 -33
- package/build/popover/index.js.map +1 -1
- package/build/search-control/index.js +4 -6
- package/build/search-control/index.js.map +1 -1
- package/build/select-control/index.js +3 -1
- package/build/select-control/index.js.map +1 -1
- package/build/spacer/hook.js +11 -3
- package/build/spacer/hook.js.map +1 -1
- package/build/surface/component.js +7 -7
- package/build/surface/component.js.map +1 -1
- package/build/surface/hook.js +8 -11
- package/build/surface/hook.js.map +1 -1
- package/build/surface/index.js.map +1 -1
- package/build/surface/styles.js +8 -48
- package/build/surface/styles.js.map +1 -1
- package/build/textarea-control/index.js +40 -6
- package/build/textarea-control/index.js.map +1 -1
- package/build/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build/textarea-control/types.js +6 -0
- package/build/textarea-control/types.js.map +1 -0
- package/build/utils/hooks/index.js +0 -8
- package/build/utils/hooks/index.js.map +1 -1
- package/build-module/alignment-matrix-control/index.js +5 -2
- package/build-module/alignment-matrix-control/index.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +1 -1
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.native.js +2 -2
- package/build-module/autocomplete/autocompleter-ui.native.js.map +1 -1
- package/build-module/autocomplete/index.js +13 -11
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control/hook.js +2 -2
- package/build-module/border-box-control/border-box-control/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +2 -0
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/hook.js +11 -4
- package/build-module/border-box-control/border-box-control-split-controls/hook.js.map +1 -1
- package/build-module/border-box-control/border-box-control-visualizer/hook.js +4 -2
- package/build-module/border-box-control/border-box-control-visualizer/hook.js.map +1 -1
- package/build-module/border-box-control/styles.js +13 -8
- package/build-module/border-box-control/styles.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +2 -2
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/color-palette/index.js +7 -5
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +4 -1
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +73 -0
- package/build-module/color-picker/color-copy-button.js.map +1 -0
- package/build-module/color-picker/component.js +6 -15
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js +18 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/styles.js +9 -9
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/custom-gradient-picker/utils.js +1 -1
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/date-time/{date.js → date/index.js} +46 -14
- package/build-module/date-time/date/index.js.map +1 -0
- package/build-module/date-time/date/styles.js +61 -0
- package/build-module/date-time/date/styles.js.map +1 -0
- package/build-module/date-time/{utils.js → date/utils.js} +0 -0
- package/build-module/date-time/date/utils.js.map +1 -0
- package/build-module/date-time/date-time/index.js +144 -0
- package/build-module/date-time/date-time/index.js.map +1 -0
- package/build-module/date-time/date-time/styles.js +22 -0
- package/build-module/date-time/date-time/styles.js.map +1 -0
- package/build-module/date-time/index.js +1 -105
- package/build-module/date-time/index.js.map +1 -1
- package/build-module/date-time/time/index.js +302 -0
- package/build-module/date-time/time/index.js.map +1 -0
- package/build-module/date-time/time/styles.js +118 -0
- package/build-module/date-time/time/styles.js.map +1 -0
- package/build-module/date-time/{timezone.js → time/timezone.js} +3 -2
- package/build-module/date-time/time/timezone.js.map +1 -0
- package/build-module/draggable/index.native.js +10 -5
- package/build-module/draggable/index.native.js.map +1 -1
- package/build-module/dropdown/index.js +4 -1
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/input-control/index.js +8 -4
- package/build-module/input-control/index.js.map +1 -1
- package/build-module/input-control/input-field.js +1 -25
- package/build-module/input-control/input-field.js.map +1 -1
- package/build-module/input-control/reducer/reducer.js +38 -26
- package/build-module/input-control/reducer/reducer.js.map +1 -1
- package/build-module/input-control/reducer/state.js +0 -1
- package/build-module/input-control/reducer/state.js.map +1 -1
- package/build-module/input-control/utils.js +48 -2
- package/build-module/input-control/utils.js.map +1 -1
- package/build-module/popover/index.js +40 -33
- package/build-module/popover/index.js.map +1 -1
- package/build-module/search-control/index.js +6 -7
- package/build-module/search-control/index.js.map +1 -1
- package/build-module/select-control/index.js +3 -1
- package/build-module/select-control/index.js.map +1 -1
- package/build-module/spacer/hook.js +10 -2
- package/build-module/spacer/hook.js.map +1 -1
- package/build-module/surface/component.js +7 -7
- package/build-module/surface/component.js.map +1 -1
- package/build-module/surface/hook.js +8 -11
- package/build-module/surface/hook.js.map +1 -1
- package/build-module/surface/index.js.map +1 -1
- package/build-module/surface/styles.js +8 -48
- package/build-module/surface/styles.js.map +1 -1
- package/build-module/textarea-control/index.js +36 -5
- package/build-module/textarea-control/index.js.map +1 -1
- package/build-module/textarea-control/styles/textarea-control-styles.js +3 -3
- package/build-module/textarea-control/styles/textarea-control-styles.js.map +1 -1
- package/build-module/textarea-control/types.js +2 -0
- package/build-module/textarea-control/types.js.map +1 -0
- package/build-module/utils/hooks/index.js +0 -1
- package/build-module/utils/hooks/index.js.map +1 -1
- package/build-style/style-rtl.css +13 -188
- package/build-style/style.css +13 -191
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +1 -0
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts +3 -2
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/card/types.d.ts +1 -1
- package/build-types/card/types.d.ts.map +1 -1
- package/build-types/checkbox-control/test/index.d.ts +2 -0
- package/build-types/checkbox-control/test/index.d.ts.map +1 -0
- package/build-types/color-palette/index.d.ts +1 -0
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/{date-time → color-palette}/test/utils.d.ts +0 -0
- package/build-types/color-palette/test/utils.d.ts.map +1 -0
- package/build-types/color-picker/color-copy-button.d.ts +4 -0
- package/build-types/color-picker/color-copy-button.d.ts.map +1 -0
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +8 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/date-time/{date.d.ts → date/index.d.ts} +3 -2
- package/build-types/date-time/date/index.d.ts.map +1 -0
- package/build-types/date-time/date/styles.d.ts +23 -0
- package/build-types/date-time/date/styles.d.ts.map +1 -0
- package/build-types/date-time/date/test/index.d.ts +2 -0
- package/build-types/date-time/date/test/index.d.ts.map +1 -0
- package/build-types/date-time/date/test/utils.d.ts +2 -0
- package/build-types/date-time/date/test/utils.d.ts.map +1 -0
- package/build-types/date-time/{utils.d.ts → date/utils.d.ts} +0 -0
- package/build-types/date-time/date/utils.d.ts.map +1 -0
- package/build-types/date-time/date-time/index.d.ts +33 -0
- package/build-types/date-time/date-time/index.d.ts.map +1 -0
- package/build-types/date-time/date-time/styles.d.ts +6 -0
- package/build-types/date-time/date-time/styles.d.ts.map +1 -0
- package/build-types/date-time/index.d.ts +2 -28
- package/build-types/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/stories/{index.d.ts → date-time.d.ts} +2 -2
- package/build-types/date-time/stories/date-time.d.ts.map +1 -0
- package/build-types/date-time/{time.d.ts → time/index.d.ts} +2 -2
- package/build-types/date-time/time/index.d.ts.map +1 -0
- package/build-types/date-time/time/styles.d.ts +111 -0
- package/build-types/date-time/time/styles.d.ts.map +1 -0
- package/build-types/date-time/time/test/index.d.ts +2 -0
- package/build-types/date-time/time/test/index.d.ts.map +1 -0
- package/build-types/date-time/{timezone.d.ts → time/timezone.d.ts} +0 -0
- package/build-types/date-time/time/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +14 -15
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/reducer/reducer.d.ts +5 -3
- package/build-types/input-control/reducer/reducer.d.ts.map +1 -1
- package/build-types/input-control/reducer/state.d.ts +2 -2
- package/build-types/input-control/reducer/state.d.ts.map +1 -1
- package/build-types/input-control/utils.d.ts +17 -0
- package/build-types/input-control/utils.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +1 -0
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/surface/component.d.ts +3 -2
- package/build-types/surface/component.d.ts.map +1 -1
- package/build-types/surface/hook.d.ts +4 -4
- package/build-types/surface/hook.d.ts.map +1 -1
- package/build-types/surface/index.d.ts +2 -2
- package/build-types/surface/index.d.ts.map +1 -1
- package/build-types/surface/stories/index.d.ts +12 -0
- package/build-types/surface/stories/index.d.ts.map +1 -0
- package/build-types/surface/styles.d.ts +10 -21
- package/build-types/surface/styles.d.ts.map +1 -1
- package/build-types/surface/test/index.d.ts +2 -0
- package/build-types/surface/test/index.d.ts.map +1 -0
- package/build-types/surface/types.d.ts +1 -1
- package/build-types/surface/types.d.ts.map +1 -1
- package/build-types/textarea-control/index.d.ts +29 -0
- package/build-types/textarea-control/index.d.ts.map +1 -0
- package/build-types/textarea-control/stories/index.d.ts +12 -0
- package/build-types/textarea-control/stories/index.d.ts.map +1 -0
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts +6 -0
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -0
- package/build-types/textarea-control/types.d.ts +26 -0
- package/build-types/textarea-control/types.d.ts.map +1 -0
- package/build-types/utils/hooks/index.d.ts +0 -1
- package/package.json +18 -18
- package/src/alignment-matrix-control/index.js +4 -2
- package/src/autocomplete/autocompleter-ui.js +1 -1
- package/src/autocomplete/autocompleter-ui.native.js +2 -2
- package/src/autocomplete/index.js +21 -9
- package/src/border-box-control/border-box-control/hook.ts +2 -2
- package/src/border-box-control/border-box-control-split-controls/component.tsx +2 -0
- package/src/border-box-control/border-box-control-split-controls/hook.ts +18 -4
- package/src/border-box-control/border-box-control-visualizer/hook.ts +5 -2
- package/src/border-box-control/styles.ts +6 -2
- package/src/border-control/border-control/hook.ts +8 -2
- package/src/box-control/test/index.js +120 -109
- package/src/card/types.ts +1 -1
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +42 -0
- package/src/checkbox-control/test/index.tsx +109 -0
- package/src/color-palette/index.js +11 -4
- package/src/color-palette/index.native.js +3 -0
- package/src/color-palette/stories/index.js +25 -1
- package/src/color-palette/test/utils.ts +24 -0
- package/src/color-picker/color-copy-button.tsx +76 -0
- package/src/color-picker/component.tsx +18 -38
- package/src/color-picker/hex-input.tsx +16 -0
- package/src/color-picker/styles.ts +5 -1
- package/src/color-picker/types.ts +9 -0
- package/src/custom-gradient-picker/utils.js +1 -1
- package/src/date-time/README.md +16 -0
- package/src/date-time/{datepicker.scss → date/datepicker.scss} +0 -0
- package/src/date-time/{date.tsx → date/index.tsx} +38 -15
- package/src/date-time/date/style.scss +75 -0
- package/src/date-time/date/styles.ts +55 -0
- package/src/date-time/{test/date.tsx → date/test/index.tsx} +1 -1
- package/src/date-time/{test → date/test}/utils.ts +0 -0
- package/src/date-time/{utils.ts → date/utils.ts} +0 -0
- package/src/date-time/date-time/index.tsx +217 -0
- package/src/date-time/date-time/styles.ts +8 -0
- package/src/date-time/index.ts +9 -0
- package/src/date-time/stories/{index.tsx → date-time.tsx} +1 -1
- package/src/date-time/style.scss +1 -262
- package/src/date-time/time/index.tsx +356 -0
- package/src/date-time/time/styles.ts +119 -0
- package/src/date-time/{test/time.tsx → time/test/index.tsx} +85 -38
- package/src/date-time/{timezone.tsx → time/timezone.tsx} +5 -2
- package/src/date-time/types.ts +16 -18
- package/src/draggable/index.native.js +14 -3
- package/src/draggable/test/index.native.js +130 -0
- package/src/dropdown/index.js +5 -1
- package/src/input-control/index.tsx +8 -2
- package/src/input-control/input-field.tsx +10 -30
- package/src/input-control/reducer/reducer.ts +40 -26
- package/src/input-control/reducer/state.ts +2 -3
- package/src/input-control/utils.ts +55 -1
- package/src/popover/index.js +42 -27
- package/src/query-controls/README.md +1 -1
- package/src/search-control/index.js +6 -7
- package/src/select-control/README.md +11 -0
- package/src/select-control/index.tsx +6 -1
- package/src/select-control/types.ts +1 -1
- package/src/slot-fill/README.md +1 -1
- package/src/spacer/hook.ts +13 -13
- package/src/surface/README.md +15 -15
- package/src/surface/{component.js → component.tsx} +13 -7
- package/src/surface/{hook.js → hook.ts} +13 -12
- package/src/surface/{index.js → index.ts} +0 -0
- package/src/surface/stories/index.tsx +40 -0
- package/src/surface/{styles.js → styles.ts} +15 -44
- package/src/surface/test/__snapshots__/{index.js.snap → index.tsx.snap} +0 -0
- package/src/surface/test/{index.js → index.tsx} +2 -1
- package/src/surface/types.ts +1 -1
- package/src/textarea-control/README.md +14 -20
- package/src/textarea-control/index.tsx +86 -0
- package/src/textarea-control/stories/index.tsx +58 -0
- package/src/textarea-control/styles/{textarea-control-styles.js → textarea-control-styles.ts} +0 -0
- package/src/textarea-control/types.ts +30 -0
- package/src/utils/hooks/index.js +0 -1
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-picker/color-display.js +0 -184
- package/build/color-picker/color-display.js.map +0 -1
- package/build/date-time/date.js.map +0 -1
- package/build/date-time/time.js +0 -289
- package/build/date-time/time.js.map +0 -1
- package/build/date-time/timezone.js.map +0 -1
- package/build/date-time/utils.js.map +0 -1
- package/build/utils/hooks/use-combined-ref.js +0 -32
- package/build/utils/hooks/use-combined-ref.js.map +0 -1
- package/build-module/color-picker/color-display.js +0 -170
- package/build-module/color-picker/color-display.js.map +0 -1
- package/build-module/date-time/date.js.map +0 -1
- package/build-module/date-time/time.js +0 -271
- package/build-module/date-time/time.js.map +0 -1
- package/build-module/date-time/timezone.js.map +0 -1
- package/build-module/date-time/utils.js.map +0 -1
- package/build-module/utils/hooks/use-combined-ref.js +0 -28
- package/build-module/utils/hooks/use-combined-ref.js.map +0 -1
- package/build-types/color-picker/color-display.d.ts +0 -14
- package/build-types/color-picker/color-display.d.ts.map +0 -1
- package/build-types/date-time/date.d.ts.map +0 -1
- package/build-types/date-time/stories/index.d.ts.map +0 -1
- package/build-types/date-time/test/date.d.ts +0 -2
- package/build-types/date-time/test/date.d.ts.map +0 -1
- package/build-types/date-time/test/time.d.ts +0 -2
- package/build-types/date-time/test/time.d.ts.map +0 -1
- package/build-types/date-time/test/utils.d.ts.map +0 -1
- package/build-types/date-time/time.d.ts.map +0 -1
- package/build-types/date-time/timezone.d.ts.map +0 -1
- package/build-types/date-time/utils.d.ts.map +0 -1
- package/build-types/utils/hooks/use-combined-ref.d.ts +0 -8
- package/build-types/utils/hooks/use-combined-ref.d.ts.map +0 -1
- package/src/color-picker/color-display.tsx +0 -169
- package/src/date-time/index.tsx +0 -196
- package/src/date-time/time.tsx +0 -321
- package/src/surface/stories/index.js +0 -46
- package/src/textarea-control/index.js +0 -45
- package/src/textarea-control/stories/index.js +0 -48
- package/src/utils/hooks/use-combined-ref.ts +0 -28
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Surface } from '..';
|
|
10
|
+
import { Text } from '../../text';
|
|
11
|
+
|
|
12
|
+
const meta: ComponentMeta< typeof Surface > = {
|
|
13
|
+
component: Surface,
|
|
14
|
+
title: 'Components (Experimental)/Surface',
|
|
15
|
+
argTypes: {
|
|
16
|
+
children: { control: { type: null } },
|
|
17
|
+
as: { control: { type: 'text' } },
|
|
18
|
+
},
|
|
19
|
+
parameters: {
|
|
20
|
+
controls: {
|
|
21
|
+
expanded: true,
|
|
22
|
+
},
|
|
23
|
+
docs: { source: { state: 'open' } },
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
const Template: ComponentStory< typeof Surface > = ( args ) => {
|
|
29
|
+
return (
|
|
30
|
+
<Surface
|
|
31
|
+
{ ...args }
|
|
32
|
+
style={ { padding: 20, maxWidth: 400, margin: '20vh auto' } }
|
|
33
|
+
>
|
|
34
|
+
<Text>Code is Poetry</Text>
|
|
35
|
+
</Surface>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Default: ComponentStory< typeof Surface > = Template.bind( {} );
|
|
40
|
+
Default.args = {};
|
|
@@ -7,6 +7,7 @@ import { css } from '@emotion/react';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { CONFIG, COLORS } from '../utils';
|
|
10
|
+
import type { SurfaceVariant, SurfaceProps } from './types';
|
|
10
11
|
|
|
11
12
|
export const Surface = css`
|
|
12
13
|
background-color: ${ CONFIG.surfaceColor };
|
|
@@ -18,19 +19,15 @@ export const background = css`
|
|
|
18
19
|
background-color: ${ CONFIG.surfaceBackgroundColor };
|
|
19
20
|
`;
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* @param {Object} props
|
|
23
|
-
* @param {boolean} [props.borderBottom]
|
|
24
|
-
* @param {boolean} [props.borderLeft]
|
|
25
|
-
* @param {boolean} [props.borderRight]
|
|
26
|
-
* @param {boolean} [props.borderTop]
|
|
27
|
-
*/
|
|
28
22
|
export function getBorders( {
|
|
29
23
|
borderBottom,
|
|
30
24
|
borderLeft,
|
|
31
25
|
borderRight,
|
|
32
26
|
borderTop,
|
|
33
|
-
}
|
|
27
|
+
}: Pick<
|
|
28
|
+
SurfaceProps,
|
|
29
|
+
'borderBottom' | 'borderLeft' | 'borderRight' | 'borderTop'
|
|
30
|
+
> ) {
|
|
34
31
|
const borderStyle = `1px solid ${ CONFIG.surfaceBorderColor }`;
|
|
35
32
|
|
|
36
33
|
return css( {
|
|
@@ -51,16 +48,10 @@ export const tertiary = css`
|
|
|
51
48
|
background: ${ CONFIG.surfaceBackgroundTertiaryColor };
|
|
52
49
|
`;
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
* @param {string} surfaceBackgroundSize
|
|
56
|
-
*/
|
|
57
|
-
const customBackgroundSize = ( surfaceBackgroundSize ) =>
|
|
51
|
+
const customBackgroundSize = ( surfaceBackgroundSize: string ) =>
|
|
58
52
|
[ surfaceBackgroundSize, surfaceBackgroundSize ].join( ' ' );
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
* @param {string} surfaceBackgroundSizeDotted
|
|
62
|
-
*/
|
|
63
|
-
const dottedBackground1 = ( surfaceBackgroundSizeDotted ) =>
|
|
54
|
+
const dottedBackground1 = ( surfaceBackgroundSizeDotted: string ) =>
|
|
64
55
|
[
|
|
65
56
|
'90deg',
|
|
66
57
|
[ CONFIG.surfaceBackgroundColor, surfaceBackgroundSizeDotted ].join(
|
|
@@ -69,10 +60,7 @@ const dottedBackground1 = ( surfaceBackgroundSizeDotted ) =>
|
|
|
69
60
|
'transparent 1%',
|
|
70
61
|
].join( ',' );
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
* @param {string} surfaceBackgroundSizeDotted
|
|
74
|
-
*/
|
|
75
|
-
const dottedBackground2 = ( surfaceBackgroundSizeDotted ) =>
|
|
63
|
+
const dottedBackground2 = ( surfaceBackgroundSizeDotted: string ) =>
|
|
76
64
|
[
|
|
77
65
|
[ CONFIG.surfaceBackgroundColor, surfaceBackgroundSizeDotted ].join(
|
|
78
66
|
' '
|
|
@@ -80,10 +68,7 @@ const dottedBackground2 = ( surfaceBackgroundSizeDotted ) =>
|
|
|
80
68
|
'transparent 1%',
|
|
81
69
|
].join( ',' );
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
* @param {string} surfaceBackgroundSizeDotted
|
|
85
|
-
*/
|
|
86
|
-
const dottedBackgroundCombined = ( surfaceBackgroundSizeDotted ) =>
|
|
71
|
+
const dottedBackgroundCombined = ( surfaceBackgroundSizeDotted: string ) =>
|
|
87
72
|
[
|
|
88
73
|
`linear-gradient( ${ dottedBackground1(
|
|
89
74
|
surfaceBackgroundSizeDotted
|
|
@@ -94,14 +79,9 @@ const dottedBackgroundCombined = ( surfaceBackgroundSizeDotted ) =>
|
|
|
94
79
|
CONFIG.surfaceBorderBoldColor,
|
|
95
80
|
].join( ',' );
|
|
96
81
|
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
* @param {string} surfaceBackgroundSize
|
|
100
|
-
* @param {string} surfaceBackgroundSizeDotted
|
|
101
|
-
*/
|
|
102
82
|
export const getDotted = (
|
|
103
|
-
surfaceBackgroundSize,
|
|
104
|
-
surfaceBackgroundSizeDotted
|
|
83
|
+
surfaceBackgroundSize: string,
|
|
84
|
+
surfaceBackgroundSizeDotted: string
|
|
105
85
|
) => css`
|
|
106
86
|
background: ${ dottedBackgroundCombined( surfaceBackgroundSizeDotted ) };
|
|
107
87
|
background-size: ${ customBackgroundSize( surfaceBackgroundSize ) };
|
|
@@ -123,11 +103,7 @@ const gridBackgroundCombined = [
|
|
|
123
103
|
`linear-gradient( ${ gridBackground2 } )`,
|
|
124
104
|
].join( ',' );
|
|
125
105
|
|
|
126
|
-
|
|
127
|
-
* @param {string} surfaceBackgroundSize
|
|
128
|
-
* @return {import('@emotion/react').SerializedStyles} CSS.
|
|
129
|
-
*/
|
|
130
|
-
export const getGrid = ( surfaceBackgroundSize ) => {
|
|
106
|
+
export const getGrid = ( surfaceBackgroundSize: string ) => {
|
|
131
107
|
return css`
|
|
132
108
|
background: ${ CONFIG.surfaceBackgroundColor };
|
|
133
109
|
background-image: ${ gridBackgroundCombined };
|
|
@@ -135,15 +111,10 @@ export const getGrid = ( surfaceBackgroundSize ) => {
|
|
|
135
111
|
`;
|
|
136
112
|
};
|
|
137
113
|
|
|
138
|
-
/**
|
|
139
|
-
* @param {'dotted' | 'grid' | 'primary' | 'secondary' | 'tertiary'} variant
|
|
140
|
-
* @param {string} surfaceBackgroundSize
|
|
141
|
-
* @param {string} surfaceBackgroundSizeDotted
|
|
142
|
-
*/
|
|
143
114
|
export const getVariant = (
|
|
144
|
-
variant,
|
|
145
|
-
surfaceBackgroundSize,
|
|
146
|
-
surfaceBackgroundSizeDotted
|
|
115
|
+
variant: SurfaceVariant,
|
|
116
|
+
surfaceBackgroundSize: string,
|
|
117
|
+
surfaceBackgroundSizeDotted: string
|
|
147
118
|
) => {
|
|
148
119
|
switch ( variant ) {
|
|
149
120
|
case 'dotted': {
|
|
File without changes
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { render } from '@testing-library/react';
|
|
5
|
+
import type { RenderResult } from '@testing-library/react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -9,7 +10,7 @@ import { render } from '@testing-library/react';
|
|
|
9
10
|
import { Surface } from '../index';
|
|
10
11
|
|
|
11
12
|
describe( 'props', () => {
|
|
12
|
-
let base;
|
|
13
|
+
let base: RenderResult;
|
|
13
14
|
beforeEach( () => {
|
|
14
15
|
base = render( <Surface>Surface</Surface> );
|
|
15
16
|
} );
|
package/src/surface/types.ts
CHANGED
|
@@ -100,47 +100,41 @@ The set of props accepted by the component will be specified below.
|
|
|
100
100
|
|
|
101
101
|
Props not included in this set will be applied to the textarea element.
|
|
102
102
|
|
|
103
|
-
####
|
|
103
|
+
#### `help`: `string | WPElement`
|
|
104
104
|
|
|
105
|
-
If this property is added, a
|
|
105
|
+
If this property is added, a help text will be generated using help property as the content.
|
|
106
106
|
|
|
107
|
-
- Type: `String`
|
|
108
107
|
- Required: No
|
|
109
108
|
|
|
110
|
-
#### hideLabelFromVision
|
|
109
|
+
#### `hideLabelFromVision`: `boolean`
|
|
111
110
|
|
|
112
111
|
If true, the label will only be visible to screen readers.
|
|
113
112
|
|
|
114
|
-
- Type: `Boolean`
|
|
115
113
|
- Required: No
|
|
116
114
|
|
|
117
|
-
####
|
|
115
|
+
#### `label`: `string`
|
|
118
116
|
|
|
119
|
-
If this property is added, a
|
|
117
|
+
If this property is added, a label will be generated using label property as the content.
|
|
120
118
|
|
|
121
|
-
- Type: `String|WPElement`
|
|
122
119
|
- Required: No
|
|
123
120
|
|
|
124
|
-
####
|
|
121
|
+
#### `onChange`: `( value: string ) => void`
|
|
125
122
|
|
|
126
|
-
|
|
123
|
+
A function that receives the new value of the textarea each time it changes.
|
|
127
124
|
|
|
128
|
-
-
|
|
129
|
-
- Required: No
|
|
130
|
-
- Default: 4
|
|
125
|
+
- Required: Yes
|
|
131
126
|
|
|
132
|
-
####
|
|
127
|
+
#### `rows`: `number`
|
|
133
128
|
|
|
134
|
-
The
|
|
129
|
+
The number of rows the textarea should contain.
|
|
135
130
|
|
|
136
|
-
-
|
|
137
|
-
-
|
|
131
|
+
- Required: No
|
|
132
|
+
- Default: 4
|
|
138
133
|
|
|
139
|
-
####
|
|
134
|
+
#### `value`: `string`
|
|
140
135
|
|
|
141
|
-
|
|
136
|
+
The current value of the textarea.
|
|
142
137
|
|
|
143
|
-
- Type: `function`
|
|
144
138
|
- Required: Yes
|
|
145
139
|
|
|
146
140
|
## Related components
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ChangeEvent } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import BaseControl from '../base-control';
|
|
15
|
+
import { StyledTextarea } from './styles/textarea-control-styles';
|
|
16
|
+
import type { TextareaControlProps } from './types';
|
|
17
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* TextareaControls are TextControls that allow for multiple lines of text, and
|
|
21
|
+
* wrap overflow text onto a new line. They are a fixed height and scroll
|
|
22
|
+
* vertically when the cursor reaches the bottom of the field.
|
|
23
|
+
*
|
|
24
|
+
* ```jsx
|
|
25
|
+
* import { TextareaControl } from '@wordpress/components';
|
|
26
|
+
* import { useState } from '@wordpress/element';
|
|
27
|
+
*
|
|
28
|
+
* const MyTextareaControl = () => {
|
|
29
|
+
* const [ text, setText ] = useState( '' );
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <TextareaControl
|
|
33
|
+
* label="Text"
|
|
34
|
+
* help="Enter some text"
|
|
35
|
+
* value={ text }
|
|
36
|
+
* onChange={ ( value ) => setText( value ) }
|
|
37
|
+
* />
|
|
38
|
+
* );
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function TextareaControl(
|
|
43
|
+
// ref is omitted until we have `WordPressComponentPropsWithoutRef` or add
|
|
44
|
+
// ref forwarding to TextareaControl.
|
|
45
|
+
props: Omit<
|
|
46
|
+
WordPressComponentProps< TextareaControlProps, 'textarea', false >,
|
|
47
|
+
'ref'
|
|
48
|
+
>
|
|
49
|
+
) {
|
|
50
|
+
const {
|
|
51
|
+
label,
|
|
52
|
+
hideLabelFromVision,
|
|
53
|
+
value,
|
|
54
|
+
help,
|
|
55
|
+
onChange,
|
|
56
|
+
rows = 4,
|
|
57
|
+
className,
|
|
58
|
+
...additionalProps
|
|
59
|
+
} = props;
|
|
60
|
+
const instanceId = useInstanceId( TextareaControl );
|
|
61
|
+
const id = `inspector-textarea-control-${ instanceId }`;
|
|
62
|
+
const onChangeValue = ( event: ChangeEvent< HTMLTextAreaElement > ) =>
|
|
63
|
+
onChange( event.target.value );
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<BaseControl
|
|
67
|
+
label={ label }
|
|
68
|
+
hideLabelFromVision={ hideLabelFromVision }
|
|
69
|
+
id={ id }
|
|
70
|
+
help={ help }
|
|
71
|
+
className={ className }
|
|
72
|
+
>
|
|
73
|
+
<StyledTextarea
|
|
74
|
+
className="components-textarea-control__input"
|
|
75
|
+
id={ id }
|
|
76
|
+
rows={ rows }
|
|
77
|
+
onChange={ onChangeValue }
|
|
78
|
+
aria-describedby={ !! help ? id + '__help' : undefined }
|
|
79
|
+
value={ value }
|
|
80
|
+
{ ...additionalProps }
|
|
81
|
+
/>
|
|
82
|
+
</BaseControl>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default TextareaControl;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import TextareaControl from '..';
|
|
15
|
+
|
|
16
|
+
const meta: ComponentMeta< typeof TextareaControl > = {
|
|
17
|
+
component: TextareaControl,
|
|
18
|
+
title: 'Components/TextareaControl',
|
|
19
|
+
argTypes: {
|
|
20
|
+
onChange: { action: 'onChange' },
|
|
21
|
+
label: { control: { type: 'text' } },
|
|
22
|
+
help: { control: { type: 'text' } },
|
|
23
|
+
value: { control: { type: null } },
|
|
24
|
+
},
|
|
25
|
+
parameters: {
|
|
26
|
+
controls: {
|
|
27
|
+
expanded: true,
|
|
28
|
+
},
|
|
29
|
+
docs: { source: { state: 'open' } },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
const Template: ComponentStory< typeof TextareaControl > = ( {
|
|
35
|
+
onChange,
|
|
36
|
+
...args
|
|
37
|
+
} ) => {
|
|
38
|
+
const [ value, setValue ] = useState( '' );
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<TextareaControl
|
|
42
|
+
{ ...args }
|
|
43
|
+
value={ value }
|
|
44
|
+
onChange={ ( v ) => {
|
|
45
|
+
setValue( v );
|
|
46
|
+
onChange( v );
|
|
47
|
+
} }
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Default: ComponentStory< typeof TextareaControl > = Template.bind(
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
Default.args = {
|
|
56
|
+
label: 'Text',
|
|
57
|
+
help: 'Enter some text',
|
|
58
|
+
};
|
package/src/textarea-control/styles/{textarea-control-styles.js → textarea-control-styles.ts}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { TextareaHTMLAttributes } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { BaseControlProps } from '../base-control/types';
|
|
10
|
+
|
|
11
|
+
export type TextareaControlProps = Pick<
|
|
12
|
+
BaseControlProps,
|
|
13
|
+
'hideLabelFromVision' | 'help' | 'label'
|
|
14
|
+
> & {
|
|
15
|
+
/**
|
|
16
|
+
* A function that receives the new value of the textarea each time it
|
|
17
|
+
* changes.
|
|
18
|
+
*/
|
|
19
|
+
onChange: ( value: string ) => void;
|
|
20
|
+
/**
|
|
21
|
+
* The current value of the textarea.
|
|
22
|
+
*/
|
|
23
|
+
value: string;
|
|
24
|
+
/**
|
|
25
|
+
* The number of rows the textarea should contain.
|
|
26
|
+
*
|
|
27
|
+
* @default 4
|
|
28
|
+
*/
|
|
29
|
+
rows?: TextareaHTMLAttributes< HTMLTextAreaElement >[ 'rows' ];
|
|
30
|
+
};
|
package/src/utils/hooks/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as useControlledState } from './use-controlled-state';
|
|
2
2
|
export { default as useUpdateEffect } from './use-update-effect';
|
|
3
|
-
export { useCombinedRef } from './use-combined-ref';
|
|
4
3
|
export { useControlledValue } from './use-controlled-value';
|
|
5
4
|
export { useCx } from './use-cx';
|
|
6
5
|
export { useLatestRef } from './use-latest-ref';
|