@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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { SyntheticEvent } from 'react';
|
|
4
|
+
import type { SyntheticEvent, ChangeEvent, PointerEvent } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useReducer } from '@wordpress/element';
|
|
9
|
+
import { useReducer, useLayoutEffect, useRef } from '@wordpress/element';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
initialStateReducer,
|
|
19
19
|
} from './state';
|
|
20
20
|
import * as actions from './actions';
|
|
21
|
+
import type { InputChangeCallback } from '../types';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Prepares initialState for the reducer.
|
|
@@ -108,9 +109,7 @@ function inputControlStateReducer(
|
|
|
108
109
|
break;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
nextState._event = action.payload.event;
|
|
113
|
-
}
|
|
112
|
+
nextState._event = action.payload.event;
|
|
114
113
|
|
|
115
114
|
/**
|
|
116
115
|
* Send the nextState + action to the composedReducers via
|
|
@@ -131,13 +130,15 @@ function inputControlStateReducer(
|
|
|
131
130
|
* This technique uses the "stateReducer" design pattern:
|
|
132
131
|
* https://kentcdodds.com/blog/the-state-reducer-pattern/
|
|
133
132
|
*
|
|
134
|
-
* @param stateReducer
|
|
135
|
-
* @param initialState
|
|
133
|
+
* @param stateReducer An external state reducer.
|
|
134
|
+
* @param initialState The initial state for the reducer.
|
|
135
|
+
* @param onChangeHandler A handler for the onChange event.
|
|
136
136
|
* @return State, dispatch, and a collection of actions.
|
|
137
137
|
*/
|
|
138
138
|
export function useInputControlStateReducer(
|
|
139
139
|
stateReducer: StateReducer = initialStateReducer,
|
|
140
|
-
initialState: Partial< InputState > = initialInputControlState
|
|
140
|
+
initialState: Partial< InputState > = initialInputControlState,
|
|
141
|
+
onChangeHandler: InputChangeCallback
|
|
141
142
|
) {
|
|
142
143
|
const [ state, dispatch ] = useReducer< StateReducer >(
|
|
143
144
|
inputControlStateReducer( stateReducer ),
|
|
@@ -148,15 +149,6 @@ export function useInputControlStateReducer(
|
|
|
148
149
|
nextValue: actions.ChangeEventAction[ 'payload' ][ 'value' ],
|
|
149
150
|
event: actions.ChangeEventAction[ 'payload' ][ 'event' ]
|
|
150
151
|
) => {
|
|
151
|
-
/**
|
|
152
|
-
* Persist allows for the (Synthetic) event to be used outside of
|
|
153
|
-
* this function call.
|
|
154
|
-
* https://reactjs.org/docs/events.html#event-pooling
|
|
155
|
-
*/
|
|
156
|
-
if ( event && event.persist ) {
|
|
157
|
-
event.persist();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
152
|
dispatch( {
|
|
161
153
|
type,
|
|
162
154
|
payload: { value: nextValue, event },
|
|
@@ -166,15 +158,6 @@ export function useInputControlStateReducer(
|
|
|
166
158
|
const createKeyEvent = ( type: actions.KeyEventAction[ 'type' ] ) => (
|
|
167
159
|
event: actions.KeyEventAction[ 'payload' ][ 'event' ]
|
|
168
160
|
) => {
|
|
169
|
-
/**
|
|
170
|
-
* Persist allows for the (Synthetic) event to be used outside of
|
|
171
|
-
* this function call.
|
|
172
|
-
* https://reactjs.org/docs/events.html#event-pooling
|
|
173
|
-
*/
|
|
174
|
-
if ( event && event.persist ) {
|
|
175
|
-
event.persist();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
161
|
dispatch( { type, payload: { event } } );
|
|
179
162
|
};
|
|
180
163
|
|
|
@@ -201,6 +184,37 @@ export function useInputControlStateReducer(
|
|
|
201
184
|
const pressDown = createKeyEvent( actions.PRESS_DOWN );
|
|
202
185
|
const pressEnter = createKeyEvent( actions.PRESS_ENTER );
|
|
203
186
|
|
|
187
|
+
const currentState = useRef( state );
|
|
188
|
+
const refProps = useRef( { value: initialState.value, onChangeHandler } );
|
|
189
|
+
useLayoutEffect( () => {
|
|
190
|
+
currentState.current = state;
|
|
191
|
+
refProps.current = { value: initialState.value, onChangeHandler };
|
|
192
|
+
} );
|
|
193
|
+
useLayoutEffect( () => {
|
|
194
|
+
if (
|
|
195
|
+
currentState.current._event !== undefined &&
|
|
196
|
+
state.value !== refProps.current.value &&
|
|
197
|
+
! state.isDirty
|
|
198
|
+
) {
|
|
199
|
+
refProps.current.onChangeHandler( state.value ?? '', {
|
|
200
|
+
event: currentState.current._event as
|
|
201
|
+
| ChangeEvent< HTMLInputElement >
|
|
202
|
+
| PointerEvent< HTMLInputElement >,
|
|
203
|
+
} );
|
|
204
|
+
}
|
|
205
|
+
}, [ state.value, state.isDirty ] );
|
|
206
|
+
useLayoutEffect( () => {
|
|
207
|
+
if (
|
|
208
|
+
initialState.value !== currentState.current.value &&
|
|
209
|
+
! currentState.current.isDirty
|
|
210
|
+
) {
|
|
211
|
+
dispatch( {
|
|
212
|
+
type: actions.RESET,
|
|
213
|
+
payload: { value: initialState.value },
|
|
214
|
+
} );
|
|
215
|
+
}
|
|
216
|
+
}, [ initialState.value ] );
|
|
217
|
+
|
|
204
218
|
return {
|
|
205
219
|
change,
|
|
206
220
|
commit,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { Reducer } from 'react';
|
|
4
|
+
import type { Reducer, SyntheticEvent } from 'react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -9,7 +9,7 @@ import type { Reducer } from 'react';
|
|
|
9
9
|
import type { InputAction } from './actions';
|
|
10
10
|
|
|
11
11
|
export interface InputState {
|
|
12
|
-
_event
|
|
12
|
+
_event?: SyntheticEvent;
|
|
13
13
|
error: unknown;
|
|
14
14
|
initialValue?: string;
|
|
15
15
|
isDirty: boolean;
|
|
@@ -24,7 +24,6 @@ export type StateReducer = Reducer< InputState, InputAction >;
|
|
|
24
24
|
export const initialStateReducer: StateReducer = ( state: InputState ) => state;
|
|
25
25
|
|
|
26
26
|
export const initialInputControlState: InputState = {
|
|
27
|
-
_event: {},
|
|
28
27
|
error: null,
|
|
29
28
|
initialValue: '',
|
|
30
29
|
isDirty: false,
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { FocusEventHandler } from 'react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useEffect,
|
|
11
|
+
useLayoutEffect,
|
|
12
|
+
useRef,
|
|
13
|
+
useState,
|
|
14
|
+
} from '@wordpress/element';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import type { InputChangeCallback } from './types';
|
|
5
20
|
|
|
6
21
|
/**
|
|
7
22
|
* Gets a CSS cursor value based on a drag direction.
|
|
@@ -52,3 +67,42 @@ export function useDragCursor(
|
|
|
52
67
|
|
|
53
68
|
return dragCursor;
|
|
54
69
|
}
|
|
70
|
+
|
|
71
|
+
export function useDraft( props: {
|
|
72
|
+
value: string | undefined;
|
|
73
|
+
onBlur?: FocusEventHandler;
|
|
74
|
+
onChange: InputChangeCallback;
|
|
75
|
+
} ) {
|
|
76
|
+
const refPreviousValue = useRef( props.value );
|
|
77
|
+
const [ draft, setDraft ] = useState< {
|
|
78
|
+
value?: string;
|
|
79
|
+
isStale?: boolean;
|
|
80
|
+
} >( {} );
|
|
81
|
+
const value = draft.value !== undefined ? draft.value : props.value;
|
|
82
|
+
|
|
83
|
+
// Determines when to discard the draft value to restore controlled status.
|
|
84
|
+
// To do so, it tracks the previous value and marks the draft value as stale
|
|
85
|
+
// after each render.
|
|
86
|
+
useLayoutEffect( () => {
|
|
87
|
+
const { current: previousValue } = refPreviousValue;
|
|
88
|
+
refPreviousValue.current = props.value;
|
|
89
|
+
if ( draft.value !== undefined && ! draft.isStale )
|
|
90
|
+
setDraft( { ...draft, isStale: true } );
|
|
91
|
+
else if ( draft.isStale && props.value !== previousValue )
|
|
92
|
+
setDraft( {} );
|
|
93
|
+
}, [ props.value, draft ] );
|
|
94
|
+
|
|
95
|
+
const onChange: InputChangeCallback = ( nextValue, extra ) => {
|
|
96
|
+
// Mutates the draft value to avoid an extra effect run.
|
|
97
|
+
setDraft( ( current ) =>
|
|
98
|
+
Object.assign( current, { value: nextValue, isStale: false } )
|
|
99
|
+
);
|
|
100
|
+
props.onChange( nextValue, extra );
|
|
101
|
+
};
|
|
102
|
+
const onBlur: FocusEventHandler = ( event ) => {
|
|
103
|
+
setDraft( {} );
|
|
104
|
+
props.onBlur?.( event );
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return { value, onBlur, onChange };
|
|
108
|
+
}
|
package/src/popover/index.js
CHANGED
|
@@ -115,6 +115,7 @@ const Popover = (
|
|
|
115
115
|
__unstableSlotName = SLOT_NAME,
|
|
116
116
|
__unstableObserveElement,
|
|
117
117
|
__unstableForcePosition,
|
|
118
|
+
__unstableShift = false,
|
|
118
119
|
...contentProps
|
|
119
120
|
},
|
|
120
121
|
ref
|
|
@@ -134,26 +135,29 @@ const Popover = (
|
|
|
134
135
|
? positionToPlacement( position )
|
|
135
136
|
: placement;
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
* Offsets the the position of the popover when the anchor is inside an iframe.
|
|
139
|
-
*/
|
|
140
|
-
const frameOffset = useMemo( () => {
|
|
141
|
-
let ownerDocument = document;
|
|
138
|
+
const ownerDocument = useMemo( () => {
|
|
142
139
|
if ( anchorRef?.top ) {
|
|
143
|
-
|
|
140
|
+
return anchorRef?.top.ownerDocument;
|
|
144
141
|
} else if ( anchorRef?.startContainer ) {
|
|
145
|
-
|
|
142
|
+
return anchorRef.startContainer.ownerDocument;
|
|
146
143
|
} else if ( anchorRef?.current ) {
|
|
147
|
-
|
|
144
|
+
return anchorRef.current.ownerDocument;
|
|
148
145
|
} else if ( anchorRef ) {
|
|
149
146
|
// This one should be deprecated.
|
|
150
|
-
|
|
147
|
+
return anchorRef.ownerDocument;
|
|
151
148
|
} else if ( anchorRect && anchorRect?.ownerDocument ) {
|
|
152
|
-
|
|
149
|
+
return anchorRect.ownerDocument;
|
|
153
150
|
} else if ( getAnchorRect ) {
|
|
154
|
-
|
|
151
|
+
return getAnchorRect()?.ownerDocument ?? document;
|
|
155
152
|
}
|
|
156
153
|
|
|
154
|
+
return document;
|
|
155
|
+
}, [ anchorRef, anchorRect, getAnchorRect ] );
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Offsets the the position of the popover when the anchor is inside an iframe.
|
|
159
|
+
*/
|
|
160
|
+
const frameOffset = useMemo( () => {
|
|
157
161
|
const { defaultView } = ownerDocument;
|
|
158
162
|
const { frameElement } = defaultView;
|
|
159
163
|
|
|
@@ -171,7 +175,7 @@ const Popover = (
|
|
|
171
175
|
};
|
|
172
176
|
},
|
|
173
177
|
};
|
|
174
|
-
}, [
|
|
178
|
+
}, [ ownerDocument ] );
|
|
175
179
|
|
|
176
180
|
const middlewares = [
|
|
177
181
|
frameOffset,
|
|
@@ -180,21 +184,23 @@ const Popover = (
|
|
|
180
184
|
__unstableForcePosition
|
|
181
185
|
? undefined
|
|
182
186
|
: size( {
|
|
183
|
-
apply(
|
|
187
|
+
apply( sizeProps ) {
|
|
188
|
+
const { height } = sizeProps;
|
|
184
189
|
if ( ! refs.floating.current ) return;
|
|
185
|
-
|
|
190
|
+
// Reduce the height of the popover to the available space.
|
|
186
191
|
Object.assign( refs.floating.current.firstChild.style, {
|
|
187
|
-
maxWidth: `${ width }px`,
|
|
188
192
|
maxHeight: `${ height }px`,
|
|
189
193
|
overflow: 'auto',
|
|
190
194
|
} );
|
|
191
195
|
},
|
|
192
196
|
} ),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
__unstableShift
|
|
198
|
+
? shift( {
|
|
199
|
+
crossAxis: true,
|
|
200
|
+
limiter: limitShift(),
|
|
201
|
+
padding: 1, // Necessary to avoid flickering at the edge of the viewport.
|
|
202
|
+
} )
|
|
203
|
+
: undefined,
|
|
198
204
|
hasArrow ? arrow( { element: arrowRef } ) : undefined,
|
|
199
205
|
].filter( ( m ) => !! m );
|
|
200
206
|
const anchorRefFallback = useRef( null );
|
|
@@ -270,13 +276,12 @@ const Popover = (
|
|
|
270
276
|
usedRef = {
|
|
271
277
|
getBoundingClientRect() {
|
|
272
278
|
const rect = getAnchorRect();
|
|
273
|
-
return
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
};
|
|
279
|
+
return new window.DOMRect(
|
|
280
|
+
rect.x ?? rect.left,
|
|
281
|
+
rect.y ?? rect.top,
|
|
282
|
+
rect.width ?? rect.right - rect.left,
|
|
283
|
+
rect.height ?? rect.bottom - rect.top
|
|
284
|
+
);
|
|
280
285
|
},
|
|
281
286
|
};
|
|
282
287
|
} else if ( anchorRefFallback.current ) {
|
|
@@ -309,6 +314,16 @@ const Popover = (
|
|
|
309
314
|
};
|
|
310
315
|
}, [ __unstableObserveElement ] );
|
|
311
316
|
|
|
317
|
+
// If we're using getAnchorRect, we need to update the position as we scroll the iframe.
|
|
318
|
+
useLayoutEffect( () => {
|
|
319
|
+
if ( ownerDocument === document ) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
ownerDocument.addEventListener( 'scroll', update );
|
|
324
|
+
return () => ownerDocument.removeEventListener( 'scroll', update );
|
|
325
|
+
}, [ ownerDocument ] );
|
|
326
|
+
|
|
312
327
|
/** @type {false | string} */
|
|
313
328
|
const animateClassName =
|
|
314
329
|
!! animate &&
|
|
@@ -179,7 +179,7 @@ A function that receives the new author value. If this is not specified, the aut
|
|
|
179
179
|
|
|
180
180
|
#### onCategoryChange
|
|
181
181
|
|
|
182
|
-
A function that receives the new
|
|
182
|
+
A function that receives the new category value. If this is not specified, the category controls are not included.
|
|
183
183
|
|
|
184
184
|
- Type: `Function`
|
|
185
185
|
- Required: No
|
|
@@ -6,17 +6,16 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
9
|
+
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { Icon, search, closeSmall } from '@wordpress/icons';
|
|
12
|
-
import { forwardRef } from '@wordpress/element';
|
|
12
|
+
import { forwardRef, useRef } from '@wordpress/element';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import { Button } from '../';
|
|
18
18
|
import BaseControl from '../base-control';
|
|
19
|
-
import { useCombinedRef } from '../utils';
|
|
20
19
|
|
|
21
20
|
function SearchControl(
|
|
22
21
|
{
|
|
@@ -30,10 +29,10 @@ function SearchControl(
|
|
|
30
29
|
help,
|
|
31
30
|
onClose,
|
|
32
31
|
},
|
|
33
|
-
|
|
32
|
+
forwardedRef
|
|
34
33
|
) {
|
|
34
|
+
const searchRef = useRef();
|
|
35
35
|
const instanceId = useInstanceId( SearchControl );
|
|
36
|
-
const searchInput = useCombinedRef( ref );
|
|
37
36
|
const id = `components-search-control-${ instanceId }`;
|
|
38
37
|
|
|
39
38
|
const renderRightButton = () => {
|
|
@@ -54,7 +53,7 @@ function SearchControl(
|
|
|
54
53
|
label={ __( 'Reset search' ) }
|
|
55
54
|
onClick={ () => {
|
|
56
55
|
onChange( '' );
|
|
57
|
-
|
|
56
|
+
searchRef.current.focus();
|
|
58
57
|
} }
|
|
59
58
|
/>
|
|
60
59
|
);
|
|
@@ -73,7 +72,7 @@ function SearchControl(
|
|
|
73
72
|
>
|
|
74
73
|
<div className="components-search-control__input-wrapper">
|
|
75
74
|
<input
|
|
76
|
-
ref={
|
|
75
|
+
ref={ useMergeRefs( [ searchRef, forwardedRef ] ) }
|
|
77
76
|
className="components-search-control__input"
|
|
78
77
|
id={ id }
|
|
79
78
|
type="search"
|
|
@@ -98,6 +98,7 @@ const MySelectControl = () => {
|
|
|
98
98
|
{ label: 'Small', value: '25%' },
|
|
99
99
|
] }
|
|
100
100
|
onChange={ ( newSize ) => setSize( newSize ) }
|
|
101
|
+
__nextHasNoMarginBottom
|
|
101
102
|
/>
|
|
102
103
|
);
|
|
103
104
|
};
|
|
@@ -119,6 +120,7 @@ Render a user interface to select multiple users from a list.
|
|
|
119
120
|
{ value: 'b', label: 'User B' },
|
|
120
121
|
{ value: 'c', label: 'User c' },
|
|
121
122
|
] }
|
|
123
|
+
__nextHasNoMarginBottom
|
|
122
124
|
/>
|
|
123
125
|
```
|
|
124
126
|
|
|
@@ -133,6 +135,7 @@ const [ item, setItem ] = useState( '' );
|
|
|
133
135
|
label={ __( 'Select an item:' ) }
|
|
134
136
|
value={ item } // e.g: value = 'a'
|
|
135
137
|
onChange={ ( selection ) => { setItem( selection ) } }
|
|
138
|
+
__nextHasNoMarginBottom
|
|
136
139
|
>
|
|
137
140
|
<optgroup label="Theropods">
|
|
138
141
|
<option value="Tyrannosaurus">Tyrannosaurus</option>
|
|
@@ -215,6 +218,14 @@ If multiple is false the value received is a single value with the new selected
|
|
|
215
218
|
- Type: `function`
|
|
216
219
|
- Required: Yes
|
|
217
220
|
|
|
221
|
+
### __nextHasNoMarginBottom
|
|
222
|
+
|
|
223
|
+
Start opting into the new margin-free styles that will become the default in a future version.
|
|
224
|
+
|
|
225
|
+
- Type: `Boolean`
|
|
226
|
+
- Required: No
|
|
227
|
+
- Default: `false`
|
|
228
|
+
|
|
218
229
|
## Related components
|
|
219
230
|
|
|
220
231
|
- To select one option from a set, and you want to show them all the available options at once, use the `Radio` component.
|
|
@@ -47,6 +47,7 @@ function UnforwardedSelectControl(
|
|
|
47
47
|
children,
|
|
48
48
|
prefix,
|
|
49
49
|
suffix,
|
|
50
|
+
__nextHasNoMarginBottom = false,
|
|
50
51
|
...props
|
|
51
52
|
}: WordPressComponentProps< SelectControlProps, 'select', false >,
|
|
52
53
|
ref: ForwardedRef< HTMLSelectElement >
|
|
@@ -85,7 +86,11 @@ function UnforwardedSelectControl(
|
|
|
85
86
|
|
|
86
87
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
87
88
|
return (
|
|
88
|
-
<BaseControl
|
|
89
|
+
<BaseControl
|
|
90
|
+
help={ help }
|
|
91
|
+
id={ id }
|
|
92
|
+
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
|
|
93
|
+
>
|
|
89
94
|
<InputBase
|
|
90
95
|
className={ classes }
|
|
91
96
|
disabled={ disabled }
|
|
@@ -20,7 +20,7 @@ export interface SelectControlProps
|
|
|
20
20
|
| 'size'
|
|
21
21
|
| 'suffix'
|
|
22
22
|
>,
|
|
23
|
-
Pick< BaseControlProps, 'help' > {
|
|
23
|
+
Pick< BaseControlProps, 'help' | '__nextHasNoMarginBottom' > {
|
|
24
24
|
/**
|
|
25
25
|
* If this property is added, multiple values can be selected. The value passed should be an array.
|
|
26
26
|
*
|
package/src/slot-fill/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Slot and Fill are a pair of components which enable developers to render elsewhere in a React element tree, a pattern often referred to as "portal" rendering. It is a pattern for component extensibility, where a single Slot may be occupied by an indeterminate number of Fills elsewhere in the application.
|
|
4
4
|
|
|
5
|
-
Slot Fill is heavily inspired by the [`react-slot-fill` library](https://github.com/camwest/react-slot-fill), but uses React's own portal rendering API
|
|
5
|
+
Slot Fill is heavily inspired by the [`react-slot-fill` library](https://github.com/camwest/react-slot-fill), but uses React's own portal rendering API.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
package/src/spacer/hook.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
*/
|
|
9
9
|
import { useContextSystem, WordPressComponentProps } from '../ui/context';
|
|
10
10
|
import { space } from '../ui/utils/space';
|
|
11
|
-
import { useCx } from '../utils
|
|
11
|
+
import { rtl, useCx } from '../utils';
|
|
12
12
|
import type { Props } from './types';
|
|
13
13
|
|
|
14
14
|
const isDefined = < T >( o: T ): o is Exclude< T, null | undefined > =>
|
|
@@ -60,13 +60,13 @@ export function useSpacer( props: WordPressComponentProps< Props, 'div' > ) {
|
|
|
60
60
|
margin-bottom: ${ space( marginBottom ) };
|
|
61
61
|
`,
|
|
62
62
|
isDefined( marginLeft ) &&
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
rtl( {
|
|
64
|
+
marginLeft: space( marginLeft ),
|
|
65
|
+
} )(),
|
|
66
66
|
isDefined( marginRight ) &&
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
rtl( {
|
|
68
|
+
marginRight: space( marginRight ),
|
|
69
|
+
} )(),
|
|
70
70
|
isDefined( padding ) &&
|
|
71
71
|
css`
|
|
72
72
|
padding: ${ space( padding ) };
|
|
@@ -90,13 +90,13 @@ export function useSpacer( props: WordPressComponentProps< Props, 'div' > ) {
|
|
|
90
90
|
padding-bottom: ${ space( paddingBottom ) };
|
|
91
91
|
`,
|
|
92
92
|
isDefined( paddingLeft ) &&
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
rtl( {
|
|
94
|
+
paddingLeft: space( paddingLeft ),
|
|
95
|
+
} )(),
|
|
96
96
|
isDefined( paddingRight ) &&
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
rtl( {
|
|
98
|
+
paddingRight: space( paddingRight ),
|
|
99
|
+
} )(),
|
|
100
100
|
className
|
|
101
101
|
);
|
|
102
102
|
|
package/src/surface/README.md
CHANGED
|
@@ -13,7 +13,7 @@ In the example below, notice how the `Surface` renders in white (or dark gray if
|
|
|
13
13
|
```jsx
|
|
14
14
|
import {
|
|
15
15
|
__experimentalSurface as Surface,
|
|
16
|
-
__experimentalText as Text
|
|
16
|
+
__experimentalText as Text,
|
|
17
17
|
} from '@wordpress/components';
|
|
18
18
|
|
|
19
19
|
function Example() {
|
|
@@ -27,46 +27,46 @@ function Example() {
|
|
|
27
27
|
|
|
28
28
|
## Props
|
|
29
29
|
|
|
30
|
-
### `backgroundSize`: number
|
|
30
|
+
### `backgroundSize`: `number`
|
|
31
31
|
|
|
32
|
-
-
|
|
33
|
-
-
|
|
32
|
+
- Required: No
|
|
33
|
+
- Default: `12`
|
|
34
34
|
|
|
35
35
|
Determines the grid size for "dotted" and "grid" variants.
|
|
36
36
|
|
|
37
37
|
### `borderBottom`: `boolean`
|
|
38
38
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
39
|
+
- Required: No
|
|
40
|
+
- Default: `false`
|
|
41
41
|
|
|
42
42
|
Renders a bottom border.
|
|
43
43
|
|
|
44
44
|
### `borderLeft`: `boolean`
|
|
45
45
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
46
|
+
- Required: No
|
|
47
|
+
- Default: `false`
|
|
48
48
|
|
|
49
49
|
Renders a left border.
|
|
50
50
|
|
|
51
51
|
### `borderRight`: `boolean`
|
|
52
52
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
53
|
+
- Required: No
|
|
54
|
+
- Default: `false`
|
|
55
55
|
|
|
56
56
|
Renders a right border.
|
|
57
57
|
|
|
58
58
|
### `borderTop`: `boolean`
|
|
59
59
|
|
|
60
|
-
-
|
|
61
|
-
-
|
|
60
|
+
- Required: No
|
|
61
|
+
- Default: `false`
|
|
62
62
|
|
|
63
63
|
Renders a top border.
|
|
64
64
|
|
|
65
65
|
### `variant`: `string`
|
|
66
66
|
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
67
|
+
- Required: No
|
|
68
|
+
- Default: `false`
|
|
69
|
+
- Allowed values: `primary`, `secondary`, `tertiary`, `dotted`, `grid`
|
|
70
70
|
|
|
71
71
|
Modifies the background color of `Surface`.
|
|
72
72
|
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ForwardedRef } from 'react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { contextConnect } from '../ui/context';
|
|
5
10
|
import { View } from '../view';
|
|
6
11
|
import { useSurface } from './hook';
|
|
12
|
+
import type { SurfaceProps } from './types';
|
|
13
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function Surface( props, forwardedRef ) {
|
|
15
|
+
function UnconnectedSurface(
|
|
16
|
+
props: WordPressComponentProps< SurfaceProps, 'div' >,
|
|
17
|
+
forwardedRef: ForwardedRef< any >
|
|
18
|
+
) {
|
|
13
19
|
const surfaceProps = useSurface( props );
|
|
14
20
|
|
|
15
21
|
return <View { ...surfaceProps } ref={ forwardedRef } />;
|
|
@@ -35,6 +41,6 @@ function Surface( props, forwardedRef ) {
|
|
|
35
41
|
* }
|
|
36
42
|
* ```
|
|
37
43
|
*/
|
|
38
|
-
const
|
|
44
|
+
export const Surface = contextConnect( UnconnectedSurface, 'Surface' );
|
|
39
45
|
|
|
40
|
-
export default
|
|
46
|
+
export default Surface;
|
|
@@ -9,11 +9,12 @@ import { useMemo } from '@wordpress/element';
|
|
|
9
9
|
import { useContextSystem } from '../ui/context';
|
|
10
10
|
import * as styles from './styles';
|
|
11
11
|
import { useCx } from '../utils/hooks/use-cx';
|
|
12
|
+
import type { SurfaceProps } from './types';
|
|
13
|
+
import type { WordPressComponentProps } from '../ui/context';
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export function useSurface( props ) {
|
|
15
|
+
export function useSurface(
|
|
16
|
+
props: WordPressComponentProps< SurfaceProps, 'div' >
|
|
17
|
+
) {
|
|
17
18
|
const {
|
|
18
19
|
backgroundSize = 12,
|
|
19
20
|
borderBottom = false,
|
|
@@ -28,14 +29,14 @@ export function useSurface( props ) {
|
|
|
28
29
|
const cx = useCx();
|
|
29
30
|
|
|
30
31
|
const classes = useMemo( () => {
|
|
31
|
-
const sx = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
32
|
+
const sx = {
|
|
33
|
+
borders: styles.getBorders( {
|
|
34
|
+
borderBottom,
|
|
35
|
+
borderLeft,
|
|
36
|
+
borderRight,
|
|
37
|
+
borderTop,
|
|
38
|
+
} ),
|
|
39
|
+
};
|
|
39
40
|
|
|
40
41
|
return cx(
|
|
41
42
|
styles.Surface,
|
|
File without changes
|