@wordpress/components 28.11.0 → 28.13.1-next.082ed6819.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 +68 -0
- package/build/autocomplete/autocompleter-ui.js +1 -0
- package/build/autocomplete/autocompleter-ui.js.map +1 -1
- package/build/border-box-control/border-box-control/component.js +1 -0
- 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 +2 -1
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/border-control/border-control/hook.js +3 -1
- package/build/border-control/border-control/hook.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +1 -1
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/types.js.map +1 -1
- package/build/box-control/all-input-control.js +1 -0
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/axial-input-controls.js +1 -0
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/box-control/input-controls.js +1 -0
- package/build/box-control/input-controls.js.map +1 -1
- package/build/color-palette/index.js +2 -0
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-copy-button.js +6 -4
- package/build/color-picker/color-copy-button.js.map +1 -1
- package/build/color-picker/component.js +1 -0
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/styles.js +21 -28
- package/build/color-picker/styles.js.map +1 -1
- package/build/combobox-control/index.js +17 -12
- package/build/combobox-control/index.js.map +1 -1
- package/build/composite/hover.js +1 -1
- package/build/composite/hover.js.map +1 -1
- package/build/composite/typeahead.js +1 -1
- package/build/composite/typeahead.js.map +1 -1
- package/build/dashicon/types.js.map +1 -1
- package/build/dimension-control/index.js +7 -0
- package/build/dimension-control/index.js.map +1 -1
- package/build/disabled/index.js +8 -1
- package/build/disabled/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +2 -0
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/font-size-picker/font-size-picker-toggle-group.js +1 -0
- package/build/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build/font-size-picker/index.js +7 -0
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-file-upload/index.js +7 -1
- package/build/form-file-upload/index.js.map +1 -1
- package/build/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/gradient-picker/index.js +34 -32
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js.map +1 -1
- package/build/guide/page-control.js +1 -0
- package/build/guide/page-control.js.map +1 -1
- package/build/menu/styles.js +16 -16
- package/build/menu/styles.js.map +1 -1
- package/build/menu-item/index.js +1 -0
- package/build/menu-item/index.js.map +1 -1
- package/build/modal/index.js +2 -2
- package/build/modal/index.js.map +1 -1
- package/build/notice/index.js +2 -0
- package/build/notice/index.js.map +1 -1
- package/build/palette-edit/index.js +5 -0
- package/build/palette-edit/index.js.map +1 -1
- package/build/panel/body.js +1 -0
- package/build/panel/body.js.map +1 -1
- package/build/popover/index.js +4 -1
- package/build/popover/index.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/radio-group/radio.js +6 -0
- package/build/radio-group/radio.js.map +1 -1
- package/build/radio-group/types.js.map +1 -1
- package/build/range-control/index.js +11 -0
- package/build/range-control/index.js.map +1 -1
- package/build/range-control/types.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +14 -31
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +13 -4
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js +11 -9
- package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot.js +1 -8
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/fill.js +7 -24
- package/build/slot-fill/fill.js.map +1 -1
- package/build/slot-fill/index.js +5 -10
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/provider.js +2 -2
- package/build/slot-fill/provider.js.map +1 -1
- package/build/slot-fill/slot.js +37 -77
- package/build/slot-fill/slot.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/snackbar/index.js +2 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/tabs/tablist.js +13 -2
- package/build/tabs/tablist.js.map +1 -1
- package/build/text-control/index.js +7 -0
- package/build/text-control/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +10 -1
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/component.js +1 -0
- package/build/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js +1 -1
- package/build/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build/toggle-group-control/types.js.map +1 -1
- package/build/utils/deprecated-36px-size.js +3 -2
- package/build/utils/deprecated-36px-size.js.map +1 -1
- package/build-module/autocomplete/autocompleter-ui.js +1 -0
- package/build-module/autocomplete/autocompleter-ui.js.map +1 -1
- package/build-module/border-box-control/border-box-control/component.js +1 -0
- 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 +2 -1
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/border-control/border-control/hook.js +3 -1
- package/build-module/border-control/border-control/hook.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +1 -1
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/types.js.map +1 -1
- package/build-module/box-control/all-input-control.js +1 -0
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js +1 -0
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/box-control/input-controls.js +1 -0
- package/build-module/box-control/input-controls.js.map +1 -1
- package/build-module/color-palette/index.js +2 -0
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +6 -4
- package/build-module/color-picker/color-copy-button.js.map +1 -1
- package/build-module/color-picker/component.js +1 -0
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/styles.js +20 -27
- package/build-module/color-picker/styles.js.map +1 -1
- package/build-module/combobox-control/index.js +18 -13
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/composite/hover.js +1 -1
- package/build-module/composite/hover.js.map +1 -1
- package/build-module/composite/typeahead.js +1 -1
- package/build-module/composite/typeahead.js.map +1 -1
- package/build-module/dashicon/types.js.map +1 -1
- package/build-module/dimension-control/index.js +7 -0
- package/build-module/dimension-control/index.js.map +1 -1
- package/build-module/disabled/index.js +8 -1
- package/build-module/disabled/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +2 -0
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-toggle-group.js +1 -0
- package/build-module/font-size-picker/font-size-picker-toggle-group.js.map +1 -1
- package/build-module/font-size-picker/index.js +7 -0
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-file-upload/index.js +7 -1
- package/build-module/form-file-upload/index.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/gradient-picker/index.js +34 -32
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js.map +1 -1
- package/build-module/guide/page-control.js +1 -0
- package/build-module/guide/page-control.js.map +1 -1
- package/build-module/menu/styles.js +16 -16
- package/build-module/menu/styles.js.map +1 -1
- package/build-module/menu-item/index.js +1 -0
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/modal/index.js +2 -2
- package/build-module/modal/index.js.map +1 -1
- package/build-module/notice/index.js +2 -0
- package/build-module/notice/index.js.map +1 -1
- package/build-module/palette-edit/index.js +5 -0
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/panel/body.js +1 -0
- package/build-module/panel/body.js.map +1 -1
- package/build-module/popover/index.js +4 -1
- package/build-module/popover/index.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/radio-group/radio.js +6 -0
- package/build-module/radio-group/radio.js.map +1 -1
- package/build-module/radio-group/types.js.map +1 -1
- package/build-module/range-control/index.js +11 -0
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/range-control/types.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +15 -32
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +13 -4
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js +11 -9
- package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +2 -9
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/fill.js +7 -24
- package/build-module/slot-fill/fill.js.map +1 -1
- package/build-module/slot-fill/index.js +5 -8
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/provider.js +2 -3
- package/build-module/slot-fill/provider.js.map +1 -1
- package/build-module/slot-fill/slot.js +38 -78
- package/build-module/slot-fill/slot.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/snackbar/index.js +2 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/tabs/tablist.js +13 -2
- package/build-module/tabs/tablist.js.map +1 -1
- package/build-module/text-control/index.js +7 -0
- package/build-module/text-control/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +10 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/component.js +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-icon/component.js.map +1 -1
- package/build-module/toggle-group-control/types.js.map +1 -1
- package/build-module/utils/deprecated-36px-size.js +3 -2
- package/build-module/utils/deprecated-36px-size.js.map +1 -1
- package/build-style/style-rtl.css +15 -36
- package/build-style/style.css +15 -36
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts.map +1 -1
- 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 +1 -0
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/border-control/border-control/hook.d.ts.map +1 -1
- package/build-types/border-control/border-control-dropdown/component.d.ts.map +1 -1
- package/build-types/border-control/border-control-style-picker/component.d.ts.map +1 -1
- package/build-types/border-control/stories/index.story.d.ts +10 -5
- package/build-types/border-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-control/types.d.ts +7 -0
- package/build-types/border-control/types.d.ts.map +1 -1
- package/build-types/box-control/all-input-control.d.ts.map +1 -1
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
- package/build-types/box-control/input-controls.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +2 -1
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/checkbox-control/stories/index.story.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-indicator/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/color-copy-button.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +2 -4
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/combobox-control/index.d.ts +1 -0
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/typeahead.d.ts.map +1 -1
- package/build-types/confirm-dialog/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/dashicon/types.d.ts +1 -1
- package/build-types/dashicon/types.d.ts.map +1 -1
- package/build-types/date-time/stories/date-time.story.d.ts.map +1 -1
- package/build-types/date-time/stories/date.story.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/dimension-control/index.d.ts +1 -0
- package/build-types/dimension-control/index.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts +8 -1
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/drop-zone/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/external-link/stories/index.story.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-toggle-group.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/form-file-upload/index.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +32 -32
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/types.d.ts +1 -5
- package/build-types/gradient-picker/types.d.ts.map +1 -1
- package/build-types/guide/page-control.d.ts.map +1 -1
- package/build-types/h-stack/stories/index.story.d.ts.map +1 -1
- package/build-types/heading/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/stories/index.story.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -2
- package/build-types/menu/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-group/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/menu-item/stories/index.story.d.ts.map +1 -1
- package/build-types/menu-items-choice/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigator/stories/index.story.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/panel/body.d.ts.map +1 -1
- package/build-types/placeholder/stories/index.story.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/stories/index.story.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/progress-bar/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-control/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/radio.d.ts +4 -2
- package/build-types/radio-group/radio.d.ts.map +1 -1
- package/build-types/radio-group/stories/index.story.d.ts.map +1 -1
- package/build-types/radio-group/types.d.ts +5 -1
- package/build-types/radio-group/types.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +3 -1
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/stories/index.story.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +7 -0
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/responsive-wrapper/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts +3 -7
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +5 -12
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/provider.d.ts.map +1 -1
- package/build-types/slot-fill/slot.d.ts +1 -1
- package/build-types/slot-fill/slot.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +15 -18
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/slot-fill/use-slot.d.ts +1 -1
- package/build-types/slot-fill/use-slot.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts.map +1 -1
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/stories/list.story.d.ts.map +1 -1
- package/build-types/spinner/stories/index.story.d.ts.map +1 -1
- package/build-types/tabs/tablist.d.ts.map +1 -1
- package/build-types/text/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +1 -0
- package/build-types/text-control/index.d.ts.map +1 -1
- package/build-types/text-control/stories/index.story.d.ts.map +1 -1
- package/build-types/text-highlight/stories/index.story.d.ts.map +1 -1
- package/build-types/textarea-control/stories/index.story.d.ts.map +1 -1
- package/build-types/tip/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-control/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-group-control/stories/index.story.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts +2 -0
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toggle-group-control/types.d.ts +7 -0
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/stories/index.story.d.ts.map +1 -1
- package/build-types/truncate/stories/index.story.d.ts.map +1 -1
- package/build-types/unit-control/stories/index.story.d.ts.map +1 -1
- package/build-types/utils/deprecated-36px-size.d.ts +3 -2
- package/build-types/utils/deprecated-36px-size.d.ts.map +1 -1
- package/build-types/v-stack/stories/index.story.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/autocomplete/autocompleter-ui.tsx +1 -0
- package/src/base-control/stories/index.story.tsx +2 -1
- 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 +1 -0
- package/src/border-control/border-control/hook.ts +2 -0
- package/src/border-control/border-control-dropdown/component.tsx +1 -1
- package/src/border-control/types.ts +7 -0
- package/src/box-control/all-input-control.tsx +1 -0
- package/src/box-control/axial-input-controls.tsx +1 -0
- package/src/box-control/input-controls.tsx +1 -0
- package/src/checkbox-control/stories/index.story.tsx +2 -1
- package/src/circular-option-picker/stories/index.story.tsx +2 -1
- package/src/color-indicator/stories/index.story.tsx +2 -1
- package/src/color-palette/index.tsx +5 -1
- package/src/color-palette/stories/index.story.tsx +2 -1
- package/src/color-picker/color-copy-button.tsx +8 -10
- package/src/color-picker/component.tsx +1 -0
- package/src/color-picker/stories/index.story.tsx +2 -1
- package/src/color-picker/styles.ts +0 -13
- package/src/combobox-control/README.md +1 -0
- package/src/combobox-control/index.tsx +19 -13
- package/src/combobox-control/stories/index.story.tsx +3 -1
- package/src/combobox-control/style.scss +0 -6
- package/src/combobox-control/test/index.tsx +7 -1
- package/src/composite/hover.tsx +1 -1
- package/src/composite/typeahead.tsx +3 -1
- package/src/confirm-dialog/stories/index.story.tsx +2 -1
- package/src/custom-gradient-picker/stories/index.story.tsx +2 -1
- package/src/custom-select-control/stories/index.story.tsx +2 -1
- package/src/custom-select-control-v2/stories/index.story.tsx +2 -1
- package/src/dashicon/types.ts +0 -2
- package/src/date-time/stories/date-time.story.tsx +2 -1
- package/src/date-time/stories/date.story.tsx +2 -1
- package/src/date-time/stories/time.story.tsx +2 -1
- package/src/dimension-control/README.md +1 -0
- package/src/dimension-control/index.tsx +8 -0
- package/src/dimension-control/stories/index.story.tsx +1 -0
- package/src/dimension-control/test/__snapshots__/index.test.js.snap +24 -24
- package/src/dimension-control/test/index.test.js +7 -1
- package/src/disabled/README.md +9 -7
- package/src/disabled/index.tsx +8 -1
- package/src/disabled/stories/index.story.tsx +1 -0
- package/src/drop-zone/stories/index.story.tsx +2 -1
- package/src/dropdown/stories/index.story.tsx +2 -1
- package/src/dropdown-menu/stories/index.story.tsx +2 -1
- package/src/duotone-picker/duotone-picker.tsx +2 -0
- package/src/external-link/stories/index.story.tsx +2 -1
- package/src/font-size-picker/README.md +1 -0
- package/src/font-size-picker/font-size-picker-toggle-group.tsx +1 -0
- package/src/font-size-picker/index.tsx +8 -0
- package/src/font-size-picker/stories/index.story.tsx +1 -0
- package/src/font-size-picker/test/index.tsx +5 -1
- package/src/form-file-upload/index.tsx +13 -1
- package/src/form-file-upload/stories/index.story.tsx +2 -1
- package/src/form-token-field/stories/index.story.tsx +2 -1
- package/src/form-token-field/style.scss +8 -12
- package/src/form-token-field/token.tsx +1 -0
- package/src/gradient-picker/README.md +107 -69
- package/src/gradient-picker/docs-manifest.json +5 -0
- package/src/gradient-picker/index.tsx +34 -32
- package/src/gradient-picker/stories/index.story.tsx +2 -1
- package/src/gradient-picker/types.ts +3 -5
- package/src/guide/page-control.tsx +1 -0
- package/src/guide/style.scss +4 -6
- package/src/h-stack/stories/index.story.tsx +2 -1
- package/src/heading/stories/index.story.tsx +2 -1
- package/src/higher-order/with-constrained-tabbing/README.md +13 -3
- package/src/higher-order/with-focus-return/README.md +9 -2
- package/src/input-control/stories/index.story.tsx +2 -1
- package/src/menu/stories/index.story.tsx +2 -1
- package/src/menu/styles.ts +1 -1
- package/src/menu-group/stories/index.story.tsx +2 -1
- package/src/menu-item/index.tsx +1 -0
- package/src/menu-item/stories/index.story.tsx +2 -1
- package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
- package/src/menu-items-choice/stories/index.story.tsx +2 -1
- package/src/modal/index.tsx +2 -2
- package/src/modal/stories/index.story.tsx +3 -2
- package/src/navigator/stories/index.story.tsx +2 -1
- package/src/notice/index.tsx +2 -0
- package/src/notice/stories/index.story.tsx +7 -2
- package/src/notice/test/__snapshots__/index.tsx.snap +4 -4
- package/src/number-control/stories/index.story.tsx +2 -1
- package/src/palette-edit/index.tsx +5 -0
- package/src/panel/body.tsx +1 -0
- package/src/placeholder/stories/index.story.tsx +1 -0
- package/src/popover/index.tsx +3 -0
- package/src/popover/stories/index.story.tsx +2 -1
- package/src/private-apis.ts +0 -2
- package/src/progress-bar/stories/index.story.tsx +2 -1
- package/src/radio-control/stories/index.story.tsx +2 -1
- package/src/radio-group/README.md +8 -8
- package/src/radio-group/radio.tsx +7 -0
- package/src/radio-group/stories/index.story.tsx +16 -4
- package/src/radio-group/types.ts +6 -1
- package/src/range-control/README.md +4 -3
- package/src/range-control/index.tsx +11 -0
- package/src/range-control/stories/index.story.tsx +9 -1
- package/src/range-control/test/index.tsx +7 -1
- package/src/range-control/types.ts +7 -0
- package/src/responsive-wrapper/stories/index.story.tsx +2 -1
- package/src/search-control/stories/index.story.tsx +2 -1
- package/src/select-control/stories/index.story.tsx +2 -1
- package/src/slot-fill/README.md +26 -15
- package/src/slot-fill/bubbles-virtually/fill.tsx +18 -28
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +26 -16
- package/src/slot-fill/bubbles-virtually/slot.tsx +13 -9
- package/src/slot-fill/bubbles-virtually/use-slot.ts +3 -26
- package/src/slot-fill/fill.ts +7 -22
- package/src/slot-fill/index.tsx +5 -7
- package/src/slot-fill/provider.tsx +8 -17
- package/src/slot-fill/slot.tsx +48 -85
- package/src/slot-fill/types.ts +14 -51
- package/src/snackbar/index.tsx +2 -1
- package/src/snackbar/stories/index.story.tsx +2 -1
- package/src/snackbar/stories/list.story.tsx +2 -1
- package/src/snackbar/style.scss +7 -16
- package/src/spinner/stories/index.story.tsx +2 -1
- package/src/tabs/tablist.tsx +13 -2
- package/src/text/stories/index.story.tsx +2 -1
- package/src/text-control/README.md +1 -0
- package/src/text-control/index.tsx +8 -0
- package/src/text-control/stories/index.story.tsx +3 -1
- package/src/text-control/test/text-control.tsx +7 -1
- package/src/text-highlight/stories/index.story.tsx +2 -1
- package/src/textarea-control/stories/index.story.tsx +2 -1
- package/src/tip/stories/index.story.tsx +2 -1
- package/src/toggle-control/stories/index.story.tsx +2 -1
- package/src/toggle-group-control/stories/index.story.tsx +3 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -12
- package/src/toggle-group-control/test/index.tsx +7 -1
- package/src/toggle-group-control/toggle-group-control/README.md +2 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +11 -1
- package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option/component.tsx +1 -0
- package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-icon/component.tsx +1 -1
- package/src/toggle-group-control/types.ts +7 -0
- package/src/tools-panel/stories/index.story.tsx +3 -0
- package/src/tooltip/stories/index.story.tsx +2 -1
- package/src/tree-grid/stories/index.story.tsx +2 -1
- package/src/tree-select/stories/index.story.tsx +2 -1
- package/src/truncate/stories/index.story.tsx +2 -1
- package/src/unit-control/stories/index.story.tsx +2 -1
- package/src/utils/deprecated-36px-size.ts +8 -2
- package/src/v-stack/stories/index.story.tsx +2 -1
- package/src/visually-hidden/stories/index.story.tsx +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/slot-fill/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Slot
|
|
1
|
+
# Slot/Fill
|
|
2
2
|
|
|
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
|
|
3
|
+
`Slot` and `Fill` are a pair of components which enable developers to render React UI 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 multiple `Fill`s rendered in different parts of the application.
|
|
4
4
|
|
|
5
|
-
Slot
|
|
5
|
+
Slot/Fill was originally inspired by the [`react-slot-fill` library](https://github.com/camwest/react-slot-fill).
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
At the root of your application, you must render a `SlotFillProvider` which coordinates Slot and Fill rendering.
|
|
9
|
+
At the root of your application, you must render a `SlotFillProvider` which coordinates `Slot` and `Fill` rendering.
|
|
10
10
|
|
|
11
|
-
Then, render a Slot component anywhere in your application, giving it a name.
|
|
11
|
+
Then, render a `Slot` component anywhere in your application, giving it a `name`. The `name` is either a `string` or a symbol. Symbol names are useful for slots that are supposed to be private, accessible only to clients that have access to the symbol value.
|
|
12
12
|
|
|
13
|
-
Any Fill will
|
|
13
|
+
Any `Fill` will render its UI in this `Slot` space, even if rendered elsewhere in the application.
|
|
14
14
|
|
|
15
|
-
You can either use the Fill component directly, or a wrapper component
|
|
15
|
+
You can either use the `Fill` component directly, or create a wrapper component (as in the following example) to hide the slot name from the consumer.
|
|
16
16
|
|
|
17
17
|
```jsx
|
|
18
18
|
import {
|
|
@@ -43,7 +43,7 @@ const MySlotFillProvider = () => {
|
|
|
43
43
|
};
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
There is also `createSlotFill` helper method which was created to simplify the process of matching the corresponding `Slot` and `Fill` components:
|
|
46
|
+
There is also the `createSlotFill` helper method which was created to simplify the process of matching the corresponding `Slot` and `Fill` components:
|
|
47
47
|
|
|
48
48
|
```jsx
|
|
49
49
|
const { Fill, Slot } = createSlotFill( 'Toolbar' );
|
|
@@ -59,18 +59,27 @@ const Toolbar = () => (
|
|
|
59
59
|
|
|
60
60
|
## Props
|
|
61
61
|
|
|
62
|
-
The `SlotFillProvider` component does not accept any props.
|
|
62
|
+
The `SlotFillProvider` component does not accept any props (except `children`).
|
|
63
63
|
|
|
64
64
|
Both `Slot` and `Fill` accept a `name` string prop, where a `Slot` with a given `name` will render the `children` of any associated `Fill`s.
|
|
65
65
|
|
|
66
|
-
`Slot` accepts a `bubblesVirtually` prop which changes the event bubbling behaviour:
|
|
66
|
+
`Slot` accepts a `bubblesVirtually` prop which changes the method how the `Fill` children are rendered. With `bubblesVirtually`, the `Fill` is rendered using a React portal. That affects the event bubbling and React context propagation behaviour:
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
- If `bubblesVirtually` is set to true, events will bubble to their virtual parent in the React elements hierarchy instead.
|
|
68
|
+
### `bubblesVirtually=false`
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
- events will bubble to their parents on the DOM hierarchy (native event bubbling)
|
|
71
|
+
- the React elements inside the `Fill` will be rendered with React context of the `Slot`
|
|
72
|
+
- renders the `Fill` elements directly, inside a `Fragment`, with no wrapper DOM element
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
### `bubblesVirtually=true`
|
|
75
|
+
|
|
76
|
+
- events will bubble to their virtual (React) parent in the React elements hierarchy
|
|
77
|
+
- the React elements inside the `Fill` will keep the React context of the `Fill` and its parents
|
|
78
|
+
- renders a wrapper DOM element inside which the `Fill` elements are rendered (used as an argument for React `createPortal`)
|
|
79
|
+
|
|
80
|
+
`Slot` with `bubblesVirtually=true` renders a wrapper DOM element (a `div` by default) and accepts additional props that customize this element, like `className` or `style`. You can also replace the `div` with another element by passing an `as` prop.
|
|
81
|
+
|
|
82
|
+
`Slot` **without** `bubblesVirtually` accepts an optional `children` prop, which is a function that receives `fills` array as a param. It allows you to perform additional processing: render a placeholder when there are no fills, or render a wrapper only when there are fills.
|
|
74
83
|
|
|
75
84
|
_Example_:
|
|
76
85
|
|
|
@@ -90,7 +99,9 @@ const Toolbar = ( { isMobile } ) => (
|
|
|
90
99
|
);
|
|
91
100
|
```
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
Additional information (props) can also be passed from a `Slot` to a `Fill` by a combination of:
|
|
103
|
+
1. Adding a `fillProps` prop to the `Slot`.
|
|
104
|
+
2. Passing a function as `children` to the `Fill`. This function will receive the `fillProps` as an argument.
|
|
94
105
|
|
|
95
106
|
```jsx
|
|
96
107
|
const { Fill, Slot } = createSlotFill( 'Toolbar' );
|
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useObservableValue } from '@wordpress/compose';
|
|
5
|
+
import {
|
|
6
|
+
useContext,
|
|
7
|
+
useReducer,
|
|
8
|
+
useRef,
|
|
9
|
+
useEffect,
|
|
10
|
+
createPortal,
|
|
11
|
+
} from '@wordpress/element';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
14
|
* Internal dependencies
|
|
8
15
|
*/
|
|
9
|
-
import
|
|
16
|
+
import SlotFillContext from './slot-fill-context';
|
|
10
17
|
import StyleProvider from '../../style-provider';
|
|
11
18
|
import type { FillComponentProps } from '../types';
|
|
12
19
|
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
useEffect( () => {
|
|
18
|
-
mountedRef.current = true;
|
|
19
|
-
return () => {
|
|
20
|
-
mountedRef.current = false;
|
|
21
|
-
};
|
|
22
|
-
}, [] );
|
|
23
|
-
|
|
24
|
-
return () => {
|
|
25
|
-
if ( mountedRef.current ) {
|
|
26
|
-
setState( {} );
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default function Fill( props: FillComponentProps ) {
|
|
32
|
-
const { name, children } = props;
|
|
33
|
-
const { registerFill, unregisterFill, ...slot } = useSlot( name );
|
|
34
|
-
const rerender = useForceUpdate();
|
|
20
|
+
export default function Fill( { name, children }: FillComponentProps ) {
|
|
21
|
+
const registry = useContext( SlotFillContext );
|
|
22
|
+
const slot = useObservableValue( registry.slots, name );
|
|
23
|
+
const [ , rerender ] = useReducer( () => [], [] );
|
|
35
24
|
const ref = useRef( { rerender } );
|
|
36
25
|
|
|
37
26
|
useEffect( () => {
|
|
38
27
|
// We register fills so we can keep track of their existence.
|
|
39
28
|
// Some Slot implementations need to know if there're already fills
|
|
40
29
|
// registered so they can choose to render themselves or not.
|
|
41
|
-
|
|
30
|
+
const refValue = ref.current;
|
|
31
|
+
registry.registerFill( name, refValue );
|
|
42
32
|
return () => {
|
|
43
|
-
unregisterFill(
|
|
33
|
+
registry.unregisterFill( name, refValue );
|
|
44
34
|
};
|
|
45
|
-
}, [
|
|
35
|
+
}, [ registry, name ] );
|
|
46
36
|
|
|
47
|
-
if ( ! slot
|
|
37
|
+
if ( ! slot || ! slot.ref.current ) {
|
|
48
38
|
return null;
|
|
49
39
|
}
|
|
50
40
|
|
|
@@ -34,15 +34,23 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
|
|
|
34
34
|
|
|
35
35
|
const unregisterSlot: SlotFillBubblesVirtuallyContext[ 'unregisterSlot' ] =
|
|
36
36
|
( name, ref ) => {
|
|
37
|
+
const slot = slots.get( name );
|
|
38
|
+
if ( ! slot ) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
// Make sure we're not unregistering a slot registered by another element
|
|
38
43
|
// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
|
|
39
|
-
if (
|
|
40
|
-
|
|
44
|
+
if ( slot.ref !== ref ) {
|
|
45
|
+
return;
|
|
41
46
|
}
|
|
47
|
+
|
|
48
|
+
slots.delete( name );
|
|
42
49
|
};
|
|
43
50
|
|
|
44
51
|
const updateSlot: SlotFillBubblesVirtuallyContext[ 'updateSlot' ] = (
|
|
45
52
|
name,
|
|
53
|
+
ref,
|
|
46
54
|
fillProps
|
|
47
55
|
) => {
|
|
48
56
|
const slot = slots.get( name );
|
|
@@ -50,6 +58,10 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
|
|
|
50
58
|
return;
|
|
51
59
|
}
|
|
52
60
|
|
|
61
|
+
if ( slot.ref !== ref ) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
if ( isShallowEqual( slot.fillProps, fillProps ) ) {
|
|
54
66
|
return;
|
|
55
67
|
}
|
|
@@ -58,7 +70,7 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
|
|
|
58
70
|
const slotFills = fills.get( name );
|
|
59
71
|
if ( slotFills ) {
|
|
60
72
|
// Force update fills.
|
|
61
|
-
slotFills.forEach( ( fill ) => fill.
|
|
73
|
+
slotFills.forEach( ( fill ) => fill.rerender() );
|
|
62
74
|
}
|
|
63
75
|
};
|
|
64
76
|
|
|
@@ -69,20 +81,18 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
|
|
|
69
81
|
fills.set( name, [ ...( fills.get( name ) || [] ), ref ] );
|
|
70
82
|
};
|
|
71
83
|
|
|
72
|
-
const unregisterFill: SlotFillBubblesVirtuallyContext[ '
|
|
73
|
-
name,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
84
|
+
const unregisterFill: SlotFillBubblesVirtuallyContext[ 'unregisterFill' ] =
|
|
85
|
+
( name, ref ) => {
|
|
86
|
+
const fillsForName = fills.get( name );
|
|
87
|
+
if ( ! fillsForName ) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
fills.set(
|
|
92
|
+
name,
|
|
93
|
+
fillsForName.filter( ( fillRef ) => fillRef !== ref )
|
|
94
|
+
);
|
|
95
|
+
};
|
|
86
96
|
|
|
87
97
|
return {
|
|
88
98
|
slots,
|
|
@@ -35,29 +35,33 @@ function Slot(
|
|
|
35
35
|
as,
|
|
36
36
|
// `children` is not allowed. However, if it is passed,
|
|
37
37
|
// it will be displayed as is, so remove `children`.
|
|
38
|
-
// @ts-ignore
|
|
39
38
|
children,
|
|
40
39
|
...restProps
|
|
41
40
|
} = props;
|
|
42
41
|
|
|
43
42
|
const { registerSlot, unregisterSlot, ...registry } =
|
|
44
43
|
useContext( SlotFillContext );
|
|
44
|
+
|
|
45
45
|
const ref = useRef< HTMLElement >( null );
|
|
46
46
|
|
|
47
|
+
// We don't want to unregister and register the slot whenever
|
|
48
|
+
// `fillProps` change, which would cause the fill to be re-mounted. Instead,
|
|
49
|
+
// we can just update the slot (see hook below).
|
|
50
|
+
// For more context, see https://github.com/WordPress/gutenberg/pull/44403#discussion_r994415973
|
|
51
|
+
const fillPropsRef = useRef( fillProps );
|
|
52
|
+
useLayoutEffect( () => {
|
|
53
|
+
fillPropsRef.current = fillProps;
|
|
54
|
+
}, [ fillProps ] );
|
|
55
|
+
|
|
47
56
|
useLayoutEffect( () => {
|
|
48
|
-
registerSlot( name, ref,
|
|
57
|
+
registerSlot( name, ref, fillPropsRef.current );
|
|
49
58
|
return () => {
|
|
50
59
|
unregisterSlot( name, ref );
|
|
51
60
|
};
|
|
52
|
-
// We don't want to unregister and register the slot whenever
|
|
53
|
-
// `fillProps` change, which would cause the fill to be re-mounted. Instead,
|
|
54
|
-
// we can just update the slot (see hook below).
|
|
55
|
-
// For more context, see https://github.com/WordPress/gutenberg/pull/44403#discussion_r994415973
|
|
56
61
|
}, [ registerSlot, unregisterSlot, name ] );
|
|
57
|
-
|
|
58
|
-
// useLayoutEffect.
|
|
62
|
+
|
|
59
63
|
useLayoutEffect( () => {
|
|
60
|
-
registry.updateSlot( name,
|
|
64
|
+
registry.updateSlot( name, ref, fillPropsRef.current );
|
|
61
65
|
} );
|
|
62
66
|
|
|
63
67
|
return (
|
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useContext } from '@wordpress/element';
|
|
5
5
|
import { useObservableValue } from '@wordpress/compose';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import SlotFillContext from './slot-fill-context';
|
|
11
|
-
import type {
|
|
12
|
-
SlotFillBubblesVirtuallyFillRef,
|
|
13
|
-
SlotFillBubblesVirtuallySlotRef,
|
|
14
|
-
FillProps,
|
|
15
|
-
SlotKey,
|
|
16
|
-
} from '../types';
|
|
11
|
+
import type { SlotKey } from '../types';
|
|
17
12
|
|
|
18
13
|
export default function useSlot( name: SlotKey ) {
|
|
19
14
|
const registry = useContext( SlotFillContext );
|
|
20
15
|
const slot = useObservableValue( registry.slots, name );
|
|
21
|
-
|
|
22
|
-
const api = useMemo(
|
|
23
|
-
() => ( {
|
|
24
|
-
updateSlot: ( fillProps: FillProps ) =>
|
|
25
|
-
registry.updateSlot( name, fillProps ),
|
|
26
|
-
unregisterSlot: ( ref: SlotFillBubblesVirtuallySlotRef ) =>
|
|
27
|
-
registry.unregisterSlot( name, ref ),
|
|
28
|
-
registerFill: ( ref: SlotFillBubblesVirtuallyFillRef ) =>
|
|
29
|
-
registry.registerFill( name, ref ),
|
|
30
|
-
unregisterFill: ( ref: SlotFillBubblesVirtuallyFillRef ) =>
|
|
31
|
-
registry.unregisterFill( name, ref ),
|
|
32
|
-
} ),
|
|
33
|
-
[ name, registry ]
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
...slot,
|
|
38
|
-
...api,
|
|
39
|
-
};
|
|
16
|
+
return { ...slot };
|
|
40
17
|
}
|
package/src/slot-fill/fill.ts
CHANGED
|
@@ -11,7 +11,7 @@ import useSlot from './use-slot';
|
|
|
11
11
|
import type { FillComponentProps } from './types';
|
|
12
12
|
|
|
13
13
|
export default function Fill( { name, children }: FillComponentProps ) {
|
|
14
|
-
const
|
|
14
|
+
const registry = useContext( SlotFillContext );
|
|
15
15
|
const slot = useSlot( name );
|
|
16
16
|
|
|
17
17
|
const ref = useRef( {
|
|
@@ -21,32 +21,17 @@ export default function Fill( { name, children }: FillComponentProps ) {
|
|
|
21
21
|
|
|
22
22
|
useLayoutEffect( () => {
|
|
23
23
|
const refValue = ref.current;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [] );
|
|
24
|
+
refValue.name = name;
|
|
25
|
+
registry.registerFill( name, refValue );
|
|
26
|
+
return () => registry.unregisterFill( name, refValue );
|
|
27
|
+
}, [ registry, name ] );
|
|
29
28
|
|
|
30
29
|
useLayoutEffect( () => {
|
|
31
30
|
ref.current.children = children;
|
|
32
31
|
if ( slot ) {
|
|
33
|
-
slot.
|
|
32
|
+
slot.rerender();
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
37
|
-
}, [ children ] );
|
|
38
|
-
|
|
39
|
-
useLayoutEffect( () => {
|
|
40
|
-
if ( name === ref.current.name ) {
|
|
41
|
-
// Ignore initial effect.
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
unregisterFill( ref.current.name, ref.current );
|
|
45
|
-
ref.current.name = name;
|
|
46
|
-
registerFill( name, ref.current );
|
|
47
|
-
// The useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
48
|
-
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
49
|
-
}, [ name ] );
|
|
34
|
+
}, [ slot, children ] );
|
|
50
35
|
|
|
51
36
|
return null;
|
|
52
37
|
}
|
package/src/slot-fill/index.tsx
CHANGED
|
@@ -84,17 +84,15 @@ export function createSlotFill( key: SlotKey ) {
|
|
|
84
84
|
props: DistributiveOmit< SlotComponentProps, 'name' >
|
|
85
85
|
) => <Slot name={ key } { ...props } />;
|
|
86
86
|
SlotComponent.displayName = `${ baseName }Slot`;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated 6.8.0
|
|
89
|
+
* Please use `slotFill.name` instead of `slotFill.Slot.__unstableName`.
|
|
90
|
+
*/
|
|
87
91
|
SlotComponent.__unstableName = key;
|
|
88
92
|
|
|
89
93
|
return {
|
|
94
|
+
name: key,
|
|
90
95
|
Fill: FillComponent,
|
|
91
96
|
Slot: SlotComponent,
|
|
92
97
|
};
|
|
93
98
|
}
|
|
94
|
-
|
|
95
|
-
export const createPrivateSlotFill = ( name: string ) => {
|
|
96
|
-
const privateKey = Symbol( name );
|
|
97
|
-
const privateSlotFill = createSlotFill( privateKey );
|
|
98
|
-
|
|
99
|
-
return { privateKey, ...privateSlotFill };
|
|
100
|
-
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { Component } from '@wordpress/element';
|
|
5
4
|
import { useState } from '@wordpress/element';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -11,20 +10,17 @@ import SlotFillContext from './context';
|
|
|
11
10
|
import type {
|
|
12
11
|
FillComponentProps,
|
|
13
12
|
BaseSlotFillContext,
|
|
14
|
-
BaseSlotComponentProps,
|
|
15
13
|
SlotFillProviderProps,
|
|
16
14
|
SlotKey,
|
|
15
|
+
Rerenderable,
|
|
17
16
|
} from './types';
|
|
18
17
|
|
|
19
18
|
function createSlotRegistry(): BaseSlotFillContext {
|
|
20
|
-
const slots: Record< SlotKey,
|
|
19
|
+
const slots: Record< SlotKey, Rerenderable > = {};
|
|
21
20
|
const fills: Record< SlotKey, FillComponentProps[] > = {};
|
|
22
21
|
let listeners: Array< () => void > = [];
|
|
23
22
|
|
|
24
|
-
function registerSlot(
|
|
25
|
-
name: SlotKey,
|
|
26
|
-
slot: Component< BaseSlotComponentProps >
|
|
27
|
-
) {
|
|
23
|
+
function registerSlot( name: SlotKey, slot: Rerenderable ) {
|
|
28
24
|
const previousSlot = slots[ name ];
|
|
29
25
|
slots[ name ] = slot;
|
|
30
26
|
triggerListeners();
|
|
@@ -38,7 +34,7 @@ function createSlotRegistry(): BaseSlotFillContext {
|
|
|
38
34
|
// assigned into the instance, such that its own rendering of children
|
|
39
35
|
// will be empty (the new Slot will subsume all fills for this name).
|
|
40
36
|
if ( previousSlot ) {
|
|
41
|
-
previousSlot.
|
|
37
|
+
previousSlot.rerender();
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
|
|
@@ -47,10 +43,7 @@ function createSlotRegistry(): BaseSlotFillContext {
|
|
|
47
43
|
forceUpdateSlot( name );
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
function unregisterSlot(
|
|
51
|
-
name: SlotKey,
|
|
52
|
-
instance: Component< BaseSlotComponentProps >
|
|
53
|
-
) {
|
|
46
|
+
function unregisterSlot( name: SlotKey, instance: Rerenderable ) {
|
|
54
47
|
// If a previous instance of a Slot by this name unmounts, do nothing,
|
|
55
48
|
// as the slot and its fills should only be removed for the current
|
|
56
49
|
// known instance.
|
|
@@ -68,15 +61,13 @@ function createSlotRegistry(): BaseSlotFillContext {
|
|
|
68
61
|
forceUpdateSlot( name );
|
|
69
62
|
}
|
|
70
63
|
|
|
71
|
-
function getSlot(
|
|
72
|
-
name: SlotKey
|
|
73
|
-
): Component< BaseSlotComponentProps > | undefined {
|
|
64
|
+
function getSlot( name: SlotKey ): Rerenderable | undefined {
|
|
74
65
|
return slots[ name ];
|
|
75
66
|
}
|
|
76
67
|
|
|
77
68
|
function getFills(
|
|
78
69
|
name: SlotKey,
|
|
79
|
-
slotInstance:
|
|
70
|
+
slotInstance: Rerenderable
|
|
80
71
|
): FillComponentProps[] {
|
|
81
72
|
// Fills should only be returned for the current instance of the slot
|
|
82
73
|
// in which they occupy.
|
|
@@ -90,7 +81,7 @@ function createSlotRegistry(): BaseSlotFillContext {
|
|
|
90
81
|
const slot = getSlot( name );
|
|
91
82
|
|
|
92
83
|
if ( slot ) {
|
|
93
|
-
slot.
|
|
84
|
+
slot.rerender();
|
|
94
85
|
}
|
|
95
86
|
}
|
|
96
87
|
|
package/src/slot-fill/slot.tsx
CHANGED
|
@@ -7,8 +7,11 @@ import type { ReactElement, ReactNode, Key } from 'react';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
+
useContext,
|
|
11
|
+
useEffect,
|
|
12
|
+
useReducer,
|
|
13
|
+
useRef,
|
|
10
14
|
Children,
|
|
11
|
-
Component,
|
|
12
15
|
cloneElement,
|
|
13
16
|
isEmptyElement,
|
|
14
17
|
} from '@wordpress/element';
|
|
@@ -17,7 +20,7 @@ import {
|
|
|
17
20
|
* Internal dependencies
|
|
18
21
|
*/
|
|
19
22
|
import SlotFillContext from './context';
|
|
20
|
-
import type {
|
|
23
|
+
import type { SlotComponentProps } from './types';
|
|
21
24
|
|
|
22
25
|
/**
|
|
23
26
|
* Whether the argument is a function.
|
|
@@ -29,90 +32,50 @@ function isFunction( maybeFunc: any ): maybeFunc is Function {
|
|
|
29
32
|
return typeof maybeFunc === 'function';
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
super.forceUpdate();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
render() {
|
|
70
|
-
const { children, name, fillProps = {}, getFills } = this.props;
|
|
71
|
-
const fills: ReactNode[] = ( getFills( name, this ) ?? [] )
|
|
72
|
-
.map( ( fill ) => {
|
|
73
|
-
const fillChildren = isFunction( fill.children )
|
|
74
|
-
? fill.children( fillProps )
|
|
75
|
-
: fill.children;
|
|
76
|
-
return Children.map( fillChildren, ( child, childIndex ) => {
|
|
77
|
-
if ( ! child || typeof child === 'string' ) {
|
|
78
|
-
return child;
|
|
79
|
-
}
|
|
80
|
-
let childKey: Key = childIndex;
|
|
81
|
-
if (
|
|
82
|
-
typeof child === 'object' &&
|
|
83
|
-
'key' in child &&
|
|
84
|
-
child?.key
|
|
85
|
-
) {
|
|
86
|
-
childKey = child.key;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return cloneElement( child as ReactElement, {
|
|
90
|
-
key: childKey,
|
|
91
|
-
} );
|
|
35
|
+
function Slot( props: Omit< SlotComponentProps, 'bubblesVirtually' > ) {
|
|
36
|
+
const registry = useContext( SlotFillContext );
|
|
37
|
+
const [ , rerender ] = useReducer( () => [], [] );
|
|
38
|
+
const ref = useRef( { rerender } );
|
|
39
|
+
|
|
40
|
+
const { name, children, fillProps = {} } = props;
|
|
41
|
+
|
|
42
|
+
useEffect( () => {
|
|
43
|
+
const refValue = ref.current;
|
|
44
|
+
registry.registerSlot( name, refValue );
|
|
45
|
+
return () => registry.unregisterSlot( name, refValue );
|
|
46
|
+
}, [ registry, name ] );
|
|
47
|
+
|
|
48
|
+
const fills: ReactNode[] = ( registry.getFills( name, ref.current ) ?? [] )
|
|
49
|
+
.map( ( fill ) => {
|
|
50
|
+
const fillChildren = isFunction( fill.children )
|
|
51
|
+
? fill.children( fillProps )
|
|
52
|
+
: fill.children;
|
|
53
|
+
return Children.map( fillChildren, ( child, childIndex ) => {
|
|
54
|
+
if ( ! child || typeof child === 'string' ) {
|
|
55
|
+
return child;
|
|
56
|
+
}
|
|
57
|
+
let childKey: Key = childIndex;
|
|
58
|
+
if (
|
|
59
|
+
typeof child === 'object' &&
|
|
60
|
+
'key' in child &&
|
|
61
|
+
child?.key
|
|
62
|
+
) {
|
|
63
|
+
childKey = child.key;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return cloneElement( child as ReactElement, {
|
|
67
|
+
key: childKey,
|
|
92
68
|
} );
|
|
93
|
-
} )
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
69
|
+
} );
|
|
70
|
+
} )
|
|
71
|
+
.filter(
|
|
72
|
+
// In some cases fills are rendered only when some conditions apply.
|
|
73
|
+
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
74
|
+
// it allows us to render wrappers only when the fills are actually present.
|
|
75
|
+
( element ) => ! isEmptyElement( element )
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return <>{ isFunction( children ) ? children( fills ) : fills }</>;
|
|
103
79
|
}
|
|
104
80
|
|
|
105
|
-
const Slot = ( props: Omit< SlotComponentProps, 'bubblesVirtually' > ) => (
|
|
106
|
-
<SlotFillContext.Consumer>
|
|
107
|
-
{ ( { registerSlot, unregisterSlot, getFills } ) => (
|
|
108
|
-
<SlotComponent
|
|
109
|
-
{ ...props }
|
|
110
|
-
registerSlot={ registerSlot }
|
|
111
|
-
unregisterSlot={ unregisterSlot }
|
|
112
|
-
getFills={ getFills }
|
|
113
|
-
/>
|
|
114
|
-
) }
|
|
115
|
-
</SlotFillContext.Consumer>
|
|
116
|
-
);
|
|
117
|
-
|
|
118
81
|
export default Slot;
|