@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","isShallowEqual","observableMap","SlotFillContext","jsx","_jsx","createSlotRegistry","slots","fills","registerSlot","name","ref","fillProps","slot","get","set","unregisterSlot","delete","updateSlot","slotFills","forEach","fill","
|
|
1
|
+
{"version":3,"names":["useState","isShallowEqual","observableMap","SlotFillContext","jsx","_jsx","createSlotRegistry","slots","fills","registerSlot","name","ref","fillProps","slot","get","set","unregisterSlot","delete","updateSlot","slotFills","forEach","fill","rerender","registerFill","unregisterFill","fillsForName","filter","fillRef","SlotFillProvider","children","registry","Provider","value"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { observableMap } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\nimport type {\n\tSlotFillProviderProps,\n\tSlotFillBubblesVirtuallyContext,\n} from '../types';\n\nfunction createSlotRegistry(): SlotFillBubblesVirtuallyContext {\n\tconst slots: SlotFillBubblesVirtuallyContext[ 'slots' ] = observableMap();\n\tconst fills: SlotFillBubblesVirtuallyContext[ 'fills' ] = observableMap();\n\n\tconst registerSlot: SlotFillBubblesVirtuallyContext[ 'registerSlot' ] = (\n\t\tname,\n\t\tref,\n\t\tfillProps\n\t) => {\n\t\tconst slot = slots.get( name );\n\n\t\tslots.set( name, {\n\t\t\t...slot,\n\t\t\tref: ref || slot?.ref,\n\t\t\tfillProps: fillProps || slot?.fillProps || {},\n\t\t} );\n\t};\n\n\tconst unregisterSlot: SlotFillBubblesVirtuallyContext[ 'unregisterSlot' ] =\n\t\t( name, ref ) => {\n\t\t\tconst slot = slots.get( name );\n\t\t\tif ( ! slot ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Make sure we're not unregistering a slot registered by another element\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412\n\t\t\tif ( slot.ref !== ref ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tslots.delete( name );\n\t\t};\n\n\tconst updateSlot: SlotFillBubblesVirtuallyContext[ 'updateSlot' ] = (\n\t\tname,\n\t\tref,\n\t\tfillProps\n\t) => {\n\t\tconst slot = slots.get( name );\n\t\tif ( ! slot ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( slot.ref !== ref ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isShallowEqual( slot.fillProps, fillProps ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tslot.fillProps = fillProps;\n\t\tconst slotFills = fills.get( name );\n\t\tif ( slotFills ) {\n\t\t\t// Force update fills.\n\t\t\tslotFills.forEach( ( fill ) => fill.rerender() );\n\t\t}\n\t};\n\n\tconst registerFill: SlotFillBubblesVirtuallyContext[ 'registerFill' ] = (\n\t\tname,\n\t\tref\n\t) => {\n\t\tfills.set( name, [ ...( fills.get( name ) || [] ), ref ] );\n\t};\n\n\tconst unregisterFill: SlotFillBubblesVirtuallyContext[ 'unregisterFill' ] =\n\t\t( name, ref ) => {\n\t\t\tconst fillsForName = fills.get( name );\n\t\t\tif ( ! fillsForName ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfills.set(\n\t\t\t\tname,\n\t\t\t\tfillsForName.filter( ( fillRef ) => fillRef !== ref )\n\t\t\t);\n\t\t};\n\n\treturn {\n\t\tslots,\n\t\tfills,\n\t\tregisterSlot,\n\t\tupdateSlot,\n\t\tunregisterSlot,\n\t\tregisterFill,\n\t\tunregisterFill,\n\t};\n}\n\nexport default function SlotFillProvider( {\n\tchildren,\n}: SlotFillProviderProps ) {\n\tconst [ registry ] = useState( createSlotRegistry );\n\treturn (\n\t\t<SlotFillContext.Provider value={ registry }>\n\t\t\t{ children }\n\t\t</SlotFillContext.Provider>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,OAAOC,cAAc,MAAM,6BAA6B;AACxD,SAASC,aAAa,QAAQ,oBAAoB;;AAElD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMlD,SAASC,kBAAkBA,CAAA,EAAoC;EAC9D,MAAMC,KAAiD,GAAGL,aAAa,CAAC,CAAC;EACzE,MAAMM,KAAiD,GAAGN,aAAa,CAAC,CAAC;EAEzE,MAAMO,YAA+D,GAAGA,CACvEC,IAAI,EACJC,GAAG,EACHC,SAAS,KACL;IACJ,MAAMC,IAAI,GAAGN,KAAK,CAACO,GAAG,CAAEJ,IAAK,CAAC;IAE9BH,KAAK,CAACQ,GAAG,CAAEL,IAAI,EAAE;MAChB,GAAGG,IAAI;MACPF,GAAG,EAAEA,GAAG,IAAIE,IAAI,EAAEF,GAAG;MACrBC,SAAS,EAAEA,SAAS,IAAIC,IAAI,EAAED,SAAS,IAAI,CAAC;IAC7C,CAAE,CAAC;EACJ,CAAC;EAED,MAAMI,cAAmE,GACxEA,CAAEN,IAAI,EAAEC,GAAG,KAAM;IAChB,MAAME,IAAI,GAAGN,KAAK,CAACO,GAAG,CAAEJ,IAAK,CAAC;IAC9B,IAAK,CAAEG,IAAI,EAAG;MACb;IACD;;IAEA;IACA;IACA,IAAKA,IAAI,CAACF,GAAG,KAAKA,GAAG,EAAG;MACvB;IACD;IAEAJ,KAAK,CAACU,MAAM,CAAEP,IAAK,CAAC;EACrB,CAAC;EAEF,MAAMQ,UA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CAAE,GAAG9B,QAAQ,CAAEM,kBAAmB,CAAC;EACnD,oBACCD,IAAA,CAACF,eAAe,CAAC4B,QAAQ;IAACC,KAAK,EAAGF,QAAU;IAAAD,QAAA,EACzCA;EAAQ,CACe,CAAC;AAE7B","ignoreList":[]}
|
|
@@ -21,7 +21,6 @@ function Slot(props, forwardedRef) {
|
|
|
21
21
|
as,
|
|
22
22
|
// `children` is not allowed. However, if it is passed,
|
|
23
23
|
// it will be displayed as is, so remove `children`.
|
|
24
|
-
// @ts-ignore
|
|
25
24
|
children,
|
|
26
25
|
...restProps
|
|
27
26
|
} = props;
|
|
@@ -31,20 +30,23 @@ function Slot(props, forwardedRef) {
|
|
|
31
30
|
...registry
|
|
32
31
|
} = useContext(SlotFillContext);
|
|
33
32
|
const ref = useRef(null);
|
|
33
|
+
|
|
34
|
+
// We don't want to unregister and register the slot whenever
|
|
35
|
+
// `fillProps` change, which would cause the fill to be re-mounted. Instead,
|
|
36
|
+
// we can just update the slot (see hook below).
|
|
37
|
+
// For more context, see https://github.com/WordPress/gutenberg/pull/44403#discussion_r994415973
|
|
38
|
+
const fillPropsRef = useRef(fillProps);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
fillPropsRef.current = fillProps;
|
|
41
|
+
}, [fillProps]);
|
|
34
42
|
useLayoutEffect(() => {
|
|
35
|
-
registerSlot(name, ref,
|
|
43
|
+
registerSlot(name, ref, fillPropsRef.current);
|
|
36
44
|
return () => {
|
|
37
45
|
unregisterSlot(name, ref);
|
|
38
46
|
};
|
|
39
|
-
// We don't want to unregister and register the slot whenever
|
|
40
|
-
// `fillProps` change, which would cause the fill to be re-mounted. Instead,
|
|
41
|
-
// we can just update the slot (see hook below).
|
|
42
|
-
// For more context, see https://github.com/WordPress/gutenberg/pull/44403#discussion_r994415973
|
|
43
47
|
}, [registerSlot, unregisterSlot, name]);
|
|
44
|
-
// fillProps may be an update that interacts with the layout, so we
|
|
45
|
-
// useLayoutEffect.
|
|
46
48
|
useLayoutEffect(() => {
|
|
47
|
-
registry.updateSlot(name,
|
|
49
|
+
registry.updateSlot(name, ref, fillPropsRef.current);
|
|
48
50
|
});
|
|
49
51
|
return /*#__PURE__*/_jsx(View, {
|
|
50
52
|
as: as,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useLayoutEffect","useContext","forwardRef","useMergeRefs","View","SlotFillContext","jsx","_jsx","Slot","props","forwardedRef","name","fillProps","as","children","restProps","registerSlot","unregisterSlot","registry","ref","updateSlot"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tuseContext,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { View } from '../../view';\nimport SlotFillContext from './slot-fill-context';\nimport type { WordPressComponentProps } from '../../context';\nimport type { SlotComponentProps } from '../types';\n\nfunction Slot(\n\tprops: WordPressComponentProps<\n\t\tOmit< SlotComponentProps, 'bubblesVirtually' >,\n\t\t'div'\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\tname,\n\t\tfillProps = {},\n\t\tas,\n\t\t// `children` is not allowed. However, if it is passed,\n\t\t// it will be displayed as is, so remove `children`.\n\t\
|
|
1
|
+
{"version":3,"names":["useRef","useLayoutEffect","useContext","forwardRef","useMergeRefs","View","SlotFillContext","jsx","_jsx","Slot","props","forwardedRef","name","fillProps","as","children","restProps","registerSlot","unregisterSlot","registry","ref","fillPropsRef","current","updateSlot"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/slot.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseLayoutEffect,\n\tuseContext,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { View } from '../../view';\nimport SlotFillContext from './slot-fill-context';\nimport type { WordPressComponentProps } from '../../context';\nimport type { SlotComponentProps } from '../types';\n\nfunction Slot(\n\tprops: WordPressComponentProps<\n\t\tOmit< SlotComponentProps, 'bubblesVirtually' >,\n\t\t'div'\n\t>,\n\tforwardedRef: ForwardedRef< any >\n) {\n\tconst {\n\t\tname,\n\t\tfillProps = {},\n\t\tas,\n\t\t// `children` is not allowed. However, if it is passed,\n\t\t// it will be displayed as is, so remove `children`.\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tconst { registerSlot, unregisterSlot, ...registry } =\n\t\tuseContext( SlotFillContext );\n\n\tconst ref = useRef< HTMLElement >( null );\n\n\t// We don't want to unregister and register the slot whenever\n\t// `fillProps` change, which would cause the fill to be re-mounted. Instead,\n\t// we can just update the slot (see hook below).\n\t// For more context, see https://github.com/WordPress/gutenberg/pull/44403#discussion_r994415973\n\tconst fillPropsRef = useRef( fillProps );\n\tuseLayoutEffect( () => {\n\t\tfillPropsRef.current = fillProps;\n\t}, [ fillProps ] );\n\n\tuseLayoutEffect( () => {\n\t\tregisterSlot( name, ref, fillPropsRef.current );\n\t\treturn () => {\n\t\t\tunregisterSlot( name, ref );\n\t\t};\n\t}, [ registerSlot, unregisterSlot, name ] );\n\n\tuseLayoutEffect( () => {\n\t\tregistry.updateSlot( name, ref, fillPropsRef.current );\n\t} );\n\n\treturn (\n\t\t<View\n\t\t\tas={ as }\n\t\t\tref={ useMergeRefs( [ forwardedRef, ref ] ) }\n\t\t\t{ ...restProps }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( Slot );\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,MAAM,EACNC,eAAe,EACfC,UAAU,EACVC,UAAU,QACJ,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC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
|
/**
|
|
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
|
/**
|
|
@@ -11,15 +11,8 @@ import SlotFillContext from './slot-fill-context';
|
|
|
11
11
|
export default function useSlot(name) {
|
|
12
12
|
const registry = useContext(SlotFillContext);
|
|
13
13
|
const slot = useObservableValue(registry.slots, name);
|
|
14
|
-
const api = useMemo(() => ({
|
|
15
|
-
updateSlot: fillProps => registry.updateSlot(name, fillProps),
|
|
16
|
-
unregisterSlot: ref => registry.unregisterSlot(name, ref),
|
|
17
|
-
registerFill: ref => registry.registerFill(name, ref),
|
|
18
|
-
unregisterFill: ref => registry.unregisterFill(name, ref)
|
|
19
|
-
}), [name, registry]);
|
|
20
14
|
return {
|
|
21
|
-
...slot
|
|
22
|
-
...api
|
|
15
|
+
...slot
|
|
23
16
|
};
|
|
24
17
|
}
|
|
25
18
|
//# sourceMappingURL=use-slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useContext","useObservableValue","SlotFillContext","useSlot","name","registry","slot","slots"],"sources":["@wordpress/components/src/slot-fill/bubbles-virtually/use-slot.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { useObservableValue } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './slot-fill-context';\nimport type { SlotKey } from '../types';\n\nexport default function useSlot( name: SlotKey ) {\n\tconst registry = useContext( SlotFillContext );\n\tconst slot = useObservableValue( registry.slots, name );\n\treturn { ...slot };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,kBAAkB,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AAGjD,eAAe,SAASC,OAAOA,CAAEC,IAAa,EAAG;EAChD,MAAMC,QAAQ,GAAGL,UAAU,CAAEE,eAAgB,CAAC;EAC9C,MAAMI,IAAI,GAAGL,kBAAkB,CAAEI,QAAQ,CAACE,KAAK,EAAEH,IAAK,CAAC;EACvD,OAAO;IAAE,GAAGE;EAAK,CAAC;AACnB","ignoreList":[]}
|
|
@@ -12,10 +12,7 @@ export default function Fill({
|
|
|
12
12
|
name,
|
|
13
13
|
children
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
16
|
-
registerFill,
|
|
17
|
-
unregisterFill
|
|
18
|
-
} = useContext(SlotFillContext);
|
|
15
|
+
const registry = useContext(SlotFillContext);
|
|
19
16
|
const slot = useSlot(name);
|
|
20
17
|
const ref = useRef({
|
|
21
18
|
name,
|
|
@@ -23,30 +20,16 @@ export default function Fill({
|
|
|
23
20
|
});
|
|
24
21
|
useLayoutEffect(() => {
|
|
25
22
|
const refValue = ref.current;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, []);
|
|
23
|
+
refValue.name = name;
|
|
24
|
+
registry.registerFill(name, refValue);
|
|
25
|
+
return () => registry.unregisterFill(name, refValue);
|
|
26
|
+
}, [registry, name]);
|
|
31
27
|
useLayoutEffect(() => {
|
|
32
28
|
ref.current.children = children;
|
|
33
29
|
if (slot) {
|
|
34
|
-
slot.
|
|
30
|
+
slot.rerender();
|
|
35
31
|
}
|
|
36
|
-
|
|
37
|
-
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
38
|
-
}, [children]);
|
|
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]);
|
|
32
|
+
}, [slot, children]);
|
|
50
33
|
return null;
|
|
51
34
|
}
|
|
52
35
|
//# sourceMappingURL=fill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useContext","useLayoutEffect","useRef","SlotFillContext","useSlot","Fill","name","children","
|
|
1
|
+
{"version":3,"names":["useContext","useLayoutEffect","useRef","SlotFillContext","useSlot","Fill","name","children","registry","slot","ref","refValue","current","registerFill","unregisterFill","rerender"],"sources":["@wordpress/components/src/slot-fill/fill.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useContext, useLayoutEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport useSlot from './use-slot';\nimport type { FillComponentProps } from './types';\n\nexport default function Fill( { name, children }: FillComponentProps ) {\n\tconst registry = useContext( SlotFillContext );\n\tconst slot = useSlot( name );\n\n\tconst ref = useRef( {\n\t\tname,\n\t\tchildren,\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tconst refValue = ref.current;\n\t\trefValue.name = name;\n\t\tregistry.registerFill( name, refValue );\n\t\treturn () => registry.unregisterFill( name, refValue );\n\t}, [ registry, name ] );\n\n\tuseLayoutEffect( () => {\n\t\tref.current.children = children;\n\t\tif ( slot ) {\n\t\t\tslot.rerender();\n\t\t}\n\t}, [ slot, children ] );\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,eAAe,EAAEC,MAAM,QAAQ,oBAAoB;;AAExE;AACA;AACA;AACA,OAAOC,eAAe,MAAM,WAAW;AACvC,OAAOC,OAAO,MAAM,YAAY;AAGhC,eAAe,SAASC,IAAIA,CAAE;EAAEC,IAAI;EAAEC;AAA6B,CAAC,EAAG;EACtE,MAAMC,QAAQ,GAAGR,UAAU,CAAEG,eAAgB,CAAC;EAC9C,MAAMM,IAAI,GAAGL,OAAO,CAAEE,IAAK,CAAC;EAE5B,MAAMI,GAAG,GAAGR,MAAM,CAAE;IACnBI,IAAI;IACJC;EACD,CAAE,CAAC;EAEHN,eAAe,CAAE,MAAM;IACtB,MAAMU,QAAQ,GAAGD,GAAG,CAACE,OAAO;IAC5BD,QAAQ,CAACL,IAAI,GAAGA,IAAI;IACpBE,QAAQ,CAACK,YAAY,CAAEP,IAAI,EAAEK,QAAS,CAAC;IACvC,OAAO,MAAMH,QAAQ,CAACM,cAAc,CAAER,IAAI,EAAEK,QAAS,CAAC;EACvD,CAAC,EAAE,CAAEH,QAAQ,EAAEF,IAAI,CAAG,CAAC;EAEvBL,eAAe,CAAE,MAAM;IACtBS,GAAG,CAACE,OAAO,CAACL,QAAQ,GAAGA,QAAQ;IAC/B,IAAKE,IAAI,EAAG;MACXA,IAAI,CAACM,QAAQ,CAAC,CAAC;IAChB;EACD,CAAC,EAAE,CAAEN,IAAI,EAAEF,QAAQ,CAAG,CAAC;EAEvB,OAAO,IAAI;AACZ","ignoreList":[]}
|
|
@@ -77,18 +77,15 @@ export function createSlotFill(key) {
|
|
|
77
77
|
...props
|
|
78
78
|
});
|
|
79
79
|
SlotComponent.displayName = `${baseName}Slot`;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated 6.8.0
|
|
82
|
+
* Please use `slotFill.name` instead of `slotFill.Slot.__unstableName`.
|
|
83
|
+
*/
|
|
80
84
|
SlotComponent.__unstableName = key;
|
|
81
85
|
return {
|
|
86
|
+
name: key,
|
|
82
87
|
Fill: FillComponent,
|
|
83
88
|
Slot: SlotComponent
|
|
84
89
|
};
|
|
85
90
|
}
|
|
86
|
-
export const createPrivateSlotFill = name => {
|
|
87
|
-
const privateKey = Symbol(name);
|
|
88
|
-
const privateSlotFill = createSlotFill(privateKey);
|
|
89
|
-
return {
|
|
90
|
-
privateKey,
|
|
91
|
-
...privateSlotFill
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useContext","BaseFill","BaseSlot","BubblesVirtuallyFill","BubblesVirtuallySlot","BubblesVirtuallySlotFillProvider","SlotFillProvider","SlotFillContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","default","useSlot","useSlotFills","Fill","props","children","UnforwardedSlot","ref","bubblesVirtually","restProps","Slot","Provider","passthrough","parent","isDefault","displayName","createSlotFill","key","baseName","description","FillComponent","name","SlotComponent","__unstableName"
|
|
1
|
+
{"version":3,"names":["forwardRef","useContext","BaseFill","BaseSlot","BubblesVirtuallyFill","BubblesVirtuallySlot","BubblesVirtuallySlotFillProvider","SlotFillProvider","SlotFillContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","default","useSlot","useSlotFills","Fill","props","children","UnforwardedSlot","ref","bubblesVirtually","restProps","Slot","Provider","passthrough","parent","isDefault","displayName","createSlotFill","key","baseName","description","FillComponent","name","SlotComponent","__unstableName"],"sources":["@wordpress/components/src/slot-fill/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BaseFill from './fill';\nimport BaseSlot from './slot';\nimport BubblesVirtuallyFill from './bubbles-virtually/fill';\nimport BubblesVirtuallySlot from './bubbles-virtually/slot';\nimport BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';\nimport SlotFillProvider from './provider';\nimport SlotFillContext from './bubbles-virtually/slot-fill-context';\nimport type { WordPressComponentProps } from '../context';\n\nexport { default as useSlot } from './bubbles-virtually/use-slot';\nexport { default as useSlotFills } from './bubbles-virtually/use-slot-fills';\nimport type {\n\tDistributiveOmit,\n\tFillComponentProps,\n\tSlotComponentProps,\n\tSlotFillProviderProps,\n\tSlotKey,\n} from './types';\n\nexport function Fill( props: FillComponentProps ) {\n\t// We're adding both Fills here so they can register themselves before\n\t// their respective slot has been registered. Only the Fill that has a slot\n\t// will render. The other one will return null.\n\treturn (\n\t\t<>\n\t\t\t<BaseFill { ...props } />\n\t\t\t<BubblesVirtuallyFill { ...props } />\n\t\t</>\n\t);\n}\n\nexport function UnforwardedSlot(\n\tprops: SlotComponentProps &\n\t\tOmit< WordPressComponentProps< {}, 'div' >, 'className' >,\n\tref: ForwardedRef< any >\n) {\n\tconst { bubblesVirtually, ...restProps } = props;\n\tif ( bubblesVirtually ) {\n\t\treturn <BubblesVirtuallySlot { ...restProps } ref={ ref } />;\n\t}\n\treturn <BaseSlot { ...restProps } />;\n}\nexport const Slot = forwardRef( UnforwardedSlot );\n\nexport function Provider( {\n\tchildren,\n\tpassthrough = false,\n}: SlotFillProviderProps ) {\n\tconst parent = useContext( SlotFillContext );\n\tif ( ! parent.isDefault && passthrough ) {\n\t\treturn <>{ children }</>;\n\t}\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<BubblesVirtuallySlotFillProvider>\n\t\t\t\t{ children }\n\t\t\t</BubblesVirtuallySlotFillProvider>\n\t\t</SlotFillProvider>\n\t);\n}\nProvider.displayName = 'SlotFillProvider';\n\nexport function createSlotFill( key: SlotKey ) {\n\tconst baseName = typeof key === 'symbol' ? key.description : key;\n\tconst FillComponent = ( props: Omit< FillComponentProps, 'name' > ) => (\n\t\t<Fill name={ key } { ...props } />\n\t);\n\tFillComponent.displayName = `${ baseName }Fill`;\n\n\tconst SlotComponent = (\n\t\tprops: DistributiveOmit< SlotComponentProps, 'name' >\n\t) => <Slot name={ key } { ...props } />;\n\tSlotComponent.displayName = `${ baseName }Slot`;\n\t/**\n\t * @deprecated 6.8.0\n\t * Please use `slotFill.name` instead of `slotFill.Slot.__unstableName`.\n\t */\n\tSlotComponent.__unstableName = key;\n\n\treturn {\n\t\tname: key,\n\t\tFill: FillComponent,\n\t\tSlot: SlotComponent,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAAS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,UAAU,CAAEO,eAAgB,CAAC;EAC5C,IAAK,CAAEoB,MAAM,CAACC,SAAS,IAAIF,WAAW,EAAG;IACxC,oBAAOjB,IAAA,CAAAE,SAAA;MAAAQ,QAAA,EAAIA;IAAQ,CAAI,CAAC;EACzB;EACA,oBACCV,IAAA,CAACH,gBAAgB;IAAAa,QAAA,eAChBV,IAAA,CAACJ,gCAAgC;MAAAc,QAAA,EAC9BA;IAAQ,CACuB;EAAC,CAClB,CAAC;AAErB;AACAM,QAAQ,CAACI,WAAW,GAAG,kBAAkB;AAEzC,OAAO,SAASC,cAAcA,CAAEC,GAAY,EAAG;EAC9C,MAAMC,QAAQ,GAAG,OAAOD,GAAG,KAAK,QAAQ,GAAGA,GAAG,CAACE,WAAW,GAAGF,GAAG;EAChE,MAAMG,aAAa,GAAKhB,KAAyC,iBAChET,IAAA,CAACQ,IAAI;IAACkB,IAAI,EAAGJ,GAAK;IAAA,GAAMb;EAAK,CAAI,CACjC;EACDgB,aAAa,CAACL,WAAW,GAAG,GAAIG,QAAQ,MAAO;EAE/C,MAAMI,aAAa,GAClBlB,KAAqD,iBACjDT,IAAA,CAACe,IAAI;IAACW,IAAI,EAAGJ,GAAK;IAAA,GAAMb;EAAK,CAAI,CAAC;EACvCkB,aAAa,CAACP,WAAW,GAAG,GAAIG,QAAQ,MAAO;EAC/C;AACD;AACA;AACA;EACCI,aAAa,CAACC,cAAc,GAAGN,GAAG;EAElC,OAAO;IACNI,IAAI,EAAEJ,GAAG;IACTd,IAAI,EAAEiB,aAAa;IACnBV,IAAI,EAAEY;EACP,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
4
|
import { useState } from '@wordpress/element';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -27,7 +26,7 @@ function createSlotRegistry() {
|
|
|
27
26
|
// assigned into the instance, such that its own rendering of children
|
|
28
27
|
// will be empty (the new Slot will subsume all fills for this name).
|
|
29
28
|
if (previousSlot) {
|
|
30
|
-
previousSlot.
|
|
29
|
+
previousSlot.rerender();
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
function registerFill(name, instance) {
|
|
@@ -63,7 +62,7 @@ function createSlotRegistry() {
|
|
|
63
62
|
function forceUpdateSlot(name) {
|
|
64
63
|
const slot = getSlot(name);
|
|
65
64
|
if (slot) {
|
|
66
|
-
slot.
|
|
65
|
+
slot.rerender();
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
function triggerListeners() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","SlotFillContext","jsx","_jsx","createSlotRegistry","slots","fills","listeners","registerSlot","name","slot","previousSlot","triggerListeners","forceUpdateSlot","
|
|
1
|
+
{"version":3,"names":["useState","SlotFillContext","jsx","_jsx","createSlotRegistry","slots","fills","listeners","registerSlot","name","slot","previousSlot","triggerListeners","forceUpdateSlot","rerender","registerFill","instance","unregisterSlot","unregisterFill","_fills$name$filter","filter","fill","getSlot","getFills","slotInstance","forEach","listener","subscribe","push","l","SlotFillProvider","children","contextValue","Provider","value"],"sources":["@wordpress/components/src/slot-fill/provider.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport type {\n\tFillComponentProps,\n\tBaseSlotFillContext,\n\tSlotFillProviderProps,\n\tSlotKey,\n\tRerenderable,\n} from './types';\n\nfunction createSlotRegistry(): BaseSlotFillContext {\n\tconst slots: Record< SlotKey, Rerenderable > = {};\n\tconst fills: Record< SlotKey, FillComponentProps[] > = {};\n\tlet listeners: Array< () => void > = [];\n\n\tfunction registerSlot( name: SlotKey, slot: Rerenderable ) {\n\t\tconst previousSlot = slots[ name ];\n\t\tslots[ name ] = slot;\n\t\ttriggerListeners();\n\n\t\t// Sometimes the fills are registered after the initial render of slot\n\t\t// But before the registerSlot call, we need to rerender the slot.\n\t\tforceUpdateSlot( name );\n\n\t\t// If a new instance of a slot is being mounted while another with the\n\t\t// same name exists, force its update _after_ the new slot has been\n\t\t// assigned into the instance, such that its own rendering of children\n\t\t// will be empty (the new Slot will subsume all fills for this name).\n\t\tif ( previousSlot ) {\n\t\t\tpreviousSlot.rerender();\n\t\t}\n\t}\n\n\tfunction registerFill( name: SlotKey, instance: FillComponentProps ) {\n\t\tfills[ name ] = [ ...( fills[ name ] || [] ), instance ];\n\t\tforceUpdateSlot( name );\n\t}\n\n\tfunction unregisterSlot( name: SlotKey, instance: Rerenderable ) {\n\t\t// If a previous instance of a Slot by this name unmounts, do nothing,\n\t\t// as the slot and its fills should only be removed for the current\n\t\t// known instance.\n\t\tif ( slots[ name ] !== instance ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdelete slots[ name ];\n\t\ttriggerListeners();\n\t}\n\n\tfunction unregisterFill( name: SlotKey, instance: FillComponentProps ) {\n\t\tfills[ name ] =\n\t\t\tfills[ name ]?.filter( ( fill ) => fill !== instance ) ?? [];\n\t\tforceUpdateSlot( name );\n\t}\n\n\tfunction getSlot( name: SlotKey ): Rerenderable | undefined {\n\t\treturn slots[ name ];\n\t}\n\n\tfunction getFills(\n\t\tname: SlotKey,\n\t\tslotInstance: Rerenderable\n\t): FillComponentProps[] {\n\t\t// Fills should only be returned for the current instance of the slot\n\t\t// in which they occupy.\n\t\tif ( slots[ name ] !== slotInstance ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn fills[ name ];\n\t}\n\n\tfunction forceUpdateSlot( name: SlotKey ) {\n\t\tconst slot = getSlot( name );\n\n\t\tif ( slot ) {\n\t\t\tslot.rerender();\n\t\t}\n\t}\n\n\tfunction triggerListeners() {\n\t\tlisteners.forEach( ( listener ) => listener() );\n\t}\n\n\tfunction subscribe( listener: () => void ) {\n\t\tlisteners.push( listener );\n\n\t\treturn () => {\n\t\t\tlisteners = listeners.filter( ( l ) => l !== listener );\n\t\t};\n\t}\n\n\treturn {\n\t\tregisterSlot,\n\t\tunregisterSlot,\n\t\tregisterFill,\n\t\tunregisterFill,\n\t\tgetSlot,\n\t\tgetFills,\n\t\tsubscribe,\n\t};\n}\n\nexport function SlotFillProvider( { children }: SlotFillProviderProps ) {\n\tconst [ contextValue ] = useState( createSlotRegistry );\n\treturn (\n\t\t<SlotFillContext.Provider value={ contextValue }>\n\t\t\t{ children }\n\t\t</SlotFillContext.Provider>\n\t);\n}\n\nexport default SlotFillProvider;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AASxC,SAASC,kBAAkBA,CAAA,EAAwB;EAClD,MAAMC,KAAsC,GAAG,CAAC,CAAC;EACjD,MAAMC,KAA8C,GAAG,CAAC,CAAC;EACzD,IAAIC,SAA8B,GAAG,EAAE;EAEvC,SAASC,YAAYA,CAAEC,IAAa,EAAEC,IAAkB,EAAG;IAC1D,MAAMC,YAAY,GAAGN,KAAK,CAAEI,IAAI,CAAE;IAClCJ,KAAK,CAAEI,IAAI,CAAE,GAAGC,IAAI;IACpBE,gBAAgB,CAAC,CAAC;;IAElB;IACA;IACAC,eAAe,CAAEJ,IAAK,CAAC;;IAEvB;IACA;IACA;IACA;IACA,IAAKE,YAAY,EAAG;MACnBA,YAAY,CAACG,QAAQ,CAAC,CAAC;IACxB;EACD;EAEA,SAASC,YAAYA,CAAEN,IAAa,EAAEO,QAA4B,EAAG;IACpEV,KAAK,CAAEG,IAAI,CAAE,GAAG,CAAE,IAAKH,KAAK,CAAEG,IAAI,CAAE,IAAI,EAAE,CAAE,EAAEO,QAAQ,CAAE;IACxDH,eAAe,CAAEJ,IAAK,CAAC;EACxB;EAEA,SAASQ,cAAcA,CAAER,IAAa,EAAEO,QAAsB,EAAG;IAChE;IACA;IACA;IACA,IAAKX,KAAK,CAAEI,IAAI,CAAE,KAAKO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;IACRI;EACD,CAAC;AACF;AAEA,OAAO,SAASG,gBAAgBA,CAAE;EAAEC;AAAgC,CAAC,EAAG;EACvE,MAAM,CAAEC,YAAY,CAAE,GAAGhC,QAAQ,CAAEI,kBAAmB,CAAC;EACvD,oBACCD,IAAA,CAACF,eAAe,CAACgC,QAAQ;IAACC,KAAK,EAAGF,YAAc;IAAAD,QAAA,EAC7CA;EAAQ,CACe,CAAC;AAE7B;AAEA,eAAeD,gBAAgB","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { useContext, useEffect, useReducer, useRef, Children, cloneElement, isEmptyElement } from '@wordpress/element';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
@@ -21,85 +21,45 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
21
21
|
function isFunction(maybeFunc) {
|
|
22
22
|
return typeof maybeFunc === 'function';
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
forceUpdate() {
|
|
55
|
-
if (this.isUnmounted) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
super.forceUpdate();
|
|
59
|
-
}
|
|
60
|
-
render() {
|
|
61
|
-
var _getFills;
|
|
62
|
-
const {
|
|
63
|
-
children,
|
|
64
|
-
name,
|
|
65
|
-
fillProps = {},
|
|
66
|
-
getFills
|
|
67
|
-
} = this.props;
|
|
68
|
-
const fills = ((_getFills = getFills(name, this)) !== null && _getFills !== void 0 ? _getFills : []).map(fill => {
|
|
69
|
-
const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
70
|
-
return Children.map(fillChildren, (child, childIndex) => {
|
|
71
|
-
if (!child || typeof child === 'string') {
|
|
72
|
-
return child;
|
|
73
|
-
}
|
|
74
|
-
let childKey = childIndex;
|
|
75
|
-
if (typeof child === 'object' && 'key' in child && child?.key) {
|
|
76
|
-
childKey = child.key;
|
|
77
|
-
}
|
|
78
|
-
return cloneElement(child, {
|
|
79
|
-
key: childKey
|
|
80
|
-
});
|
|
24
|
+
function Slot(props) {
|
|
25
|
+
var _registry$getFills;
|
|
26
|
+
const registry = useContext(SlotFillContext);
|
|
27
|
+
const [, rerender] = useReducer(() => [], []);
|
|
28
|
+
const ref = useRef({
|
|
29
|
+
rerender
|
|
30
|
+
});
|
|
31
|
+
const {
|
|
32
|
+
name,
|
|
33
|
+
children,
|
|
34
|
+
fillProps = {}
|
|
35
|
+
} = props;
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const refValue = ref.current;
|
|
38
|
+
registry.registerSlot(name, refValue);
|
|
39
|
+
return () => registry.unregisterSlot(name, refValue);
|
|
40
|
+
}, [registry, name]);
|
|
41
|
+
const fills = ((_registry$getFills = registry.getFills(name, ref.current)) !== null && _registry$getFills !== void 0 ? _registry$getFills : []).map(fill => {
|
|
42
|
+
const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
43
|
+
return Children.map(fillChildren, (child, childIndex) => {
|
|
44
|
+
if (!child || typeof child === 'string') {
|
|
45
|
+
return child;
|
|
46
|
+
}
|
|
47
|
+
let childKey = childIndex;
|
|
48
|
+
if (typeof child === 'object' && 'key' in child && child?.key) {
|
|
49
|
+
childKey = child.key;
|
|
50
|
+
}
|
|
51
|
+
return cloneElement(child, {
|
|
52
|
+
key: childKey
|
|
81
53
|
});
|
|
82
|
-
}).filter(
|
|
83
|
-
// In some cases fills are rendered only when some conditions apply.
|
|
84
|
-
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
85
|
-
// it allows us to render wrappers only when the fills are actually present.
|
|
86
|
-
element => !isEmptyElement(element));
|
|
87
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
88
|
-
children: isFunction(children) ? children(fills) : fills
|
|
89
54
|
});
|
|
90
|
-
}
|
|
55
|
+
}).filter(
|
|
56
|
+
// In some cases fills are rendered only when some conditions apply.
|
|
57
|
+
// This ensures that we only use non-empty fills when rendering, i.e.,
|
|
58
|
+
// it allows us to render wrappers only when the fills are actually present.
|
|
59
|
+
element => !isEmptyElement(element));
|
|
60
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
61
|
+
children: isFunction(children) ? children(fills) : fills
|
|
62
|
+
});
|
|
91
63
|
}
|
|
92
|
-
const Slot = props => /*#__PURE__*/_jsx(SlotFillContext.Consumer, {
|
|
93
|
-
children: ({
|
|
94
|
-
registerSlot,
|
|
95
|
-
unregisterSlot,
|
|
96
|
-
getFills
|
|
97
|
-
}) => /*#__PURE__*/_jsx(SlotComponent, {
|
|
98
|
-
...props,
|
|
99
|
-
registerSlot: registerSlot,
|
|
100
|
-
unregisterSlot: unregisterSlot,
|
|
101
|
-
getFills: getFills
|
|
102
|
-
})
|
|
103
|
-
});
|
|
104
64
|
export default Slot;
|
|
105
65
|
//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useContext","useEffect","useReducer","useRef","Children","cloneElement","isEmptyElement","SlotFillContext","Fragment","_Fragment","jsx","_jsx","isFunction","maybeFunc","Slot","props","_registry$getFills","registry","rerender","ref","name","children","fillProps","refValue","current","registerSlot","unregisterSlot","fills","getFills","map","fill","fillChildren","child","childIndex","childKey","key","filter","element"],"sources":["@wordpress/components/src/slot-fill/slot.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, ReactNode, Key } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseContext,\n\tuseEffect,\n\tuseReducer,\n\tuseRef,\n\tChildren,\n\tcloneElement,\n\tisEmptyElement,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport type { SlotComponentProps } from './types';\n\n/**\n * Whether the argument is a function.\n *\n * @param maybeFunc The argument to check.\n * @return True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc: any ): maybeFunc is Function {\n\treturn typeof maybeFunc === 'function';\n}\n\nfunction Slot( props: Omit< SlotComponentProps, 'bubblesVirtually' > ) {\n\tconst registry = useContext( SlotFillContext );\n\tconst [ , rerender ] = useReducer( () => [], [] );\n\tconst ref = useRef( { rerender } );\n\n\tconst { name, children, fillProps = {} } = props;\n\n\tuseEffect( () => {\n\t\tconst refValue = ref.current;\n\t\tregistry.registerSlot( name, refValue );\n\t\treturn () => registry.unregisterSlot( name, refValue );\n\t}, [ registry, name ] );\n\n\tconst fills: ReactNode[] = ( registry.getFills( name, ref.current ) ?? [] )\n\t\t.map( ( fill ) => {\n\t\t\tconst fillChildren = isFunction( fill.children )\n\t\t\t\t? fill.children( fillProps )\n\t\t\t\t: fill.children;\n\t\t\treturn Children.map( fillChildren, ( child, childIndex ) => {\n\t\t\t\tif ( ! child || typeof child === 'string' ) {\n\t\t\t\t\treturn child;\n\t\t\t\t}\n\t\t\t\tlet childKey: Key = childIndex;\n\t\t\t\tif (\n\t\t\t\t\ttypeof child === 'object' &&\n\t\t\t\t\t'key' in child &&\n\t\t\t\t\tchild?.key\n\t\t\t\t) {\n\t\t\t\t\tchildKey = child.key;\n\t\t\t\t}\n\n\t\t\t\treturn cloneElement( child as ReactElement, {\n\t\t\t\t\tkey: childKey,\n\t\t\t\t} );\n\t\t\t} );\n\t\t} )\n\t\t.filter(\n\t\t\t// In some cases fills are rendered only when some conditions apply.\n\t\t\t// This ensures that we only use non-empty fills when rendering, i.e.,\n\t\t\t// it allows us to render wrappers only when the fills are actually present.\n\t\t\t( element ) => ! isEmptyElement( element )\n\t\t);\n\n\treturn <>{ isFunction( children ) ? children( fills ) : fills }</>;\n}\n\nexport default Slot;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,UAAU,EACVC,SAAS,EACTC,UAAU,EACVC,MAAM,EACNC,QAAQ,EACRC,YAAY,EACZC,cAAc,QACR,oBAAoB;;AAE3B;AACA;AACA;AACA,OAAOC,eAAe,MAAM,WAAW;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAGxC;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,UAAUA,CAAEC,SAAc,EAA0B;EAC5D,OAAO,OAAOA,SAAS,KAAK,UAAU;AACvC;AAEA,SAASC,IAAIA,CAAEC,KAAqD,EAAG;EAAA,IAAAC,kBAAA;EACtE,MAAMC,QAAQ,GAAGjB,UAAU,CAAEO,eAAgB,CAAC;EAC9C,MAAM,GAAIW,QAAQ,CAAE,GAAGhB,UAAU,CAAE,MAAM,EAAE,EAAE,EAAG,CAAC;EACjD,MAAMiB,GAAG,GAAGhB,MAAM,CAAE;IAAEe;EAAS,CAAE,CAAC;EAElC,MAAM;IAAEE,IAAI;IAAEC,QAAQ;IAAEC,SAAS,GAAG,CAAC;EAAE,CAAC,GAAGP,KAAK;EAEhDd,SAAS,CAAE,MAAM;IAChB,MAAMsB,QAAQ,GAAGJ,GAAG,CAACK,OAAO;IAC5BP,QAAQ,CAACQ,YAAY,CAAEL,IAAI,EAAEG,QAAS,CAAC;IACvC,OAAO,MAAMN,QAAQ,CAACS,cAAc,CAAEN,IAAI,EAAEG,QAAS,CAAC;EACvD,CAAC,EAAE,CAAEN,QAAQ,EAAEG,IAAI,CAAG,CAAC;EAEvB,MAAMO,KAAkB,GAAG,EAAAX,kBAAA,GAAEC,QAAQ,CAACW,QAAQ,CAAER,IAAI,EAAED,GAAG,CAACK,OAAQ,CAAC,cAAAR,kBAAA,cAAAA,kBAAA,GAAI,EAAE,EACvEa,GAAG,CAAIC,IAAI,IAAM;IACjB,MAAMC,YAAY,GAAGnB,UAAU,CAAEkB,IAAI,CAACT,QAAS,CAAC,GAC7CS,IAAI,CAACT,QAAQ,CAAEC,SAAU,CAAC,GAC1BQ,IAAI,CAACT,QAAQ;IAChB,OAAOjB,QAAQ,CAACyB,GAAG,CAAEE,YAAY,EAAE,CAAEC,KAAK,EAAEC,UAAU,KAAM;MAC3D,IAAK,CAAED,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAG;QAC3C,OAAOA,KAAK;MACb;MACA,IAAIE,QAAa,GAAGD,UAAU;MAC9B,IACC,OAAOD,KAAK,KAAK,QAAQ,IACzB,KAAK,IAAIA,KAAK,IACdA,KAAK,EAAEG,GAAG,EACT;QACDD,QAAQ,GAAGF,KAAK,CAACG,GAAG;MACrB;MAEA,OAAO9B,YAAY,CAAE2B,KAAK,EAAkB;QAC3CG,GAAG,EAAED;MACN,CAAE,CAAC;IACJ,CAAE,CAAC;EACJ,CAAE,CAAC,CACFE,MAAM;EACN;EACA;EACA;EACEC,OAAO,IAAM,CAAE/B,cAAc,CAAE+B,OAAQ,CAC1C,CAAC;EAEF,oBAAO1B,IAAA,CAAAF,SAAA;IAAAY,QAAA,EAAIT,UAAU,CAAES,QAAS,CAAC,GAAGA,QAAQ,CAAEM,KAAM,CAAC,GAAGA;EAAK,CAAI,CAAC;AACnE;AAEA,eAAeb,IAAI","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/slot-fill/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type {
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/slot-fill/types.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactNode, RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type { ObservableMap } from '@wordpress/compose';\n\nexport type DistributiveOmit< T, K extends keyof any > = T extends any\n\t? Omit< T, K >\n\t: never;\n\nexport type SlotKey = string | symbol;\n\nexport type FillProps = Record< string, any >;\n\ntype SlotPropBase = {\n\t/**\n\t * Slot name.\n\t */\n\tname: SlotKey;\n\n\t/**\n\t * props to pass from `Slot` to `Fill`.\n\t *\n\t * @default {}\n\t */\n\tfillProps?: FillProps;\n};\n\nexport type SlotComponentProps =\n\t| ( SlotPropBase & {\n\t\t\t/**\n\t\t\t * By default, events will bubble to their parents on the DOM hierarchy (native event bubbling).\n\t\t\t * If set to true, events will bubble to their virtual parent in the React elements hierarchy instead,\n\t\t\t * also accept an optional `className`, `id`, etc. to add to the slot container.\n\t\t\t */\n\t\t\tbubblesVirtually: true;\n\n\t\t\t/**\n\t\t\t * A function that returns nodes to be rendered.\n\t\t\t * Supported only when `bubblesVirtually` is `false`.\n\t\t\t */\n\t\t\tchildren?: never;\n\n\t\t\t/**\n\t\t\t * Additional className for the `Slot` component.\n\t\t\t * Supported only when `bubblesVirtually` is `true`.\n\t\t\t */\n\t\t\tclassName?: string;\n\n\t\t\t/**\n\t\t\t * Additional styles for the `Slot` component.\n\t\t\t * Supported only when `bubblesVirtually` is `true`.\n\t\t\t */\n\t\t\tstyle?: React.CSSProperties;\n\t } )\n\t| ( SlotPropBase & {\n\t\t\t/**\n\t\t\t * By default, events will bubble to their parents on the DOM hierarchy (native event bubbling).\n\t\t\t * If set to true, events will bubble to their virtual parent in the React elements hierarchy instead,\n\t\t\t * also accept an optional `className`, `id`, etc. to add to the slot container.\n\t\t\t */\n\t\t\tbubblesVirtually?: false;\n\n\t\t\t/**\n\t\t\t * A function that returns nodes to be rendered.\n\t\t\t * Supported only when `bubblesVirtually` is `false`.\n\t\t\t */\n\t\t\tchildren?: ( fills: ReactNode ) => ReactNode;\n\n\t\t\t/**\n\t\t\t * Additional className for the `Slot` component.\n\t\t\t * Supported only when `bubblesVirtually` is `true`.\n\t\t\t */\n\t\t\tclassName?: never;\n\n\t\t\t/**\n\t\t\t * Additional styles for the `Slot` component.\n\t\t\t * Supported only when `bubblesVirtually` is `true`.\n\t\t\t */\n\t\t\tstyle?: never;\n\t } );\n\nexport type FillComponentProps = {\n\t/**\n\t * The name of the slot to fill into.\n\t */\n\tname: SlotKey;\n\n\t/**\n\t * Children elements or render function.\n\t */\n\tchildren?: ReactNode | ( ( fillProps: FillProps ) => ReactNode );\n};\n\nexport type SlotFillProviderProps = {\n\t/**\n\t * The children elements.\n\t */\n\tchildren: ReactNode;\n\n\t/**\n\t * Whether to pass slots to the parent provider if existent.\n\t */\n\tpassthrough?: boolean;\n};\n\nexport type SlotRef = RefObject< HTMLElement >;\nexport type Rerenderable = { rerender: () => void };\n\nexport type SlotFillBubblesVirtuallyContext = {\n\tslots: ObservableMap< SlotKey, { ref: SlotRef; fillProps: FillProps } >;\n\tfills: ObservableMap< SlotKey, Rerenderable[] >;\n\tregisterSlot: ( name: SlotKey, ref: SlotRef, fillProps: FillProps ) => void;\n\tunregisterSlot: ( name: SlotKey, ref: SlotRef ) => void;\n\tupdateSlot: ( name: SlotKey, ref: SlotRef, fillProps: FillProps ) => void;\n\tregisterFill: ( name: SlotKey, ref: Rerenderable ) => void;\n\tunregisterFill: ( name: SlotKey, ref: Rerenderable ) => void;\n\n\t/**\n\t * This helps the provider know if it's using the default context value or not.\n\t */\n\tisDefault?: boolean;\n};\n\nexport type BaseSlotFillContext = {\n\tregisterSlot: ( name: SlotKey, slot: Rerenderable ) => void;\n\tunregisterSlot: ( name: SlotKey, slot: Rerenderable ) => void;\n\tregisterFill: ( name: SlotKey, instance: FillComponentProps ) => void;\n\tunregisterFill: ( name: SlotKey, instance: FillComponentProps ) => void;\n\tgetSlot: ( name: SlotKey ) => Rerenderable | undefined;\n\tgetFills: (\n\t\tname: SlotKey,\n\t\tslotInstance: Rerenderable\n\t) => FillComponentProps[];\n\tsubscribe: ( listener: () => void ) => () => void;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -122,8 +122,9 @@ function UnforwardedSnackbar({
|
|
|
122
122
|
url
|
|
123
123
|
}, index) => {
|
|
124
124
|
return /*#__PURE__*/_jsx(Button, {
|
|
125
|
+
__next40pxDefaultSize: true,
|
|
125
126
|
href: url,
|
|
126
|
-
variant: "
|
|
127
|
+
variant: "link",
|
|
127
128
|
onClick: event => onActionClick(event, onClick),
|
|
128
129
|
className: "components-snackbar__action",
|
|
129
130
|
children: label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","speak","useEffect","useLayoutEffect","useRef","forwardRef","renderToString","__","warning","Button","jsx","_jsx","jsxs","_jsxs","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","UnforwardedSnackbar","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","ref","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","callbacksRef","timeoutHandle","setTimeout","clearTimeout","classes","length","globalThis","SCRIPT_DEBUG","snackbarContentClassnames","undefined","tabIndex","role","onKeyPress","map","label","url","index","href","variant","Snackbar"],"sources":["@wordpress/components/src/snackbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport {\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tforwardRef,\n\trenderToString,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { SnackbarProps } from './types';\nimport type { NoticeAction } from '../notice/types';\nimport type { WordPressComponentProps } from '../context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent< HTMLButtonElement >,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// The `onDismiss/onRemove` can have unstable references,\n\t// trigger side-effect cleanup, and reset timers.\n\tconst callbacksRef = useRef( { onDismiss, onRemove } );\n\tuseLayoutEffect( () => {\n\t\tcallbacksRef.current = { onDismiss, onRemove };\n\t} );\n\n\tuseEffect( () => {\n\t\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tcallbacksRef.current.onDismiss?.();\n\t\t\t\tcallbacksRef.current.onRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ explicitDismiss ] );\n\n\tconst classes = clsx( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have one action. Use Notice if your message requires many actions.'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = clsx( 'components-snackbar__content', {\n\t\t'components-snackbar__content-with-icon': !! icon,\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : undefined }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={\n\t\t\t\t! explicitDismiss ? __( 'Dismiss this notice' ) : undefined\n\t\t\t}\n\t\t\tdata-testid=\"snackbar\"\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"
|
|
1
|
+
{"version":3,"names":["clsx","speak","useEffect","useLayoutEffect","useRef","forwardRef","renderToString","__","warning","Button","jsx","_jsx","jsxs","_jsxs","NOTICE_TIMEOUT","useSpokenMessage","message","politeness","spokenMessage","UnforwardedSnackbar","className","children","actions","onRemove","icon","explicitDismiss","onDismiss","listRef","ref","dismissMe","event","preventDefault","current","focus","onActionClick","onClick","stopPropagation","callbacksRef","timeoutHandle","setTimeout","clearTimeout","classes","length","globalThis","SCRIPT_DEBUG","snackbarContentClassnames","undefined","tabIndex","role","onKeyPress","map","label","url","index","__next40pxDefaultSize","href","variant","Snackbar"],"sources":["@wordpress/components/src/snackbar/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ForwardedRef, KeyboardEvent, MouseEvent } from 'react';\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport {\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tforwardRef,\n\trenderToString,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport type { SnackbarProps } from './types';\nimport type { NoticeAction } from '../notice/types';\nimport type { WordPressComponentProps } from '../context';\n\nconst NOTICE_TIMEOUT = 10000;\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n *\n * @param message Message to announce.\n * @param politeness Politeness to announce.\n */\nfunction useSpokenMessage(\n\tmessage: SnackbarProps[ 'spokenMessage' ],\n\tpoliteness: NonNullable< SnackbarProps[ 'politeness' ] >\n) {\n\tconst spokenMessage =\n\t\ttypeof message === 'string' ? message : renderToString( message );\n\n\tuseEffect( () => {\n\t\tif ( spokenMessage ) {\n\t\t\tspeak( spokenMessage, politeness );\n\t\t}\n\t}, [ spokenMessage, politeness ] );\n}\n\nfunction UnforwardedSnackbar(\n\t{\n\t\tclassName,\n\t\tchildren,\n\t\tspokenMessage = children,\n\t\tpoliteness = 'polite',\n\t\tactions = [],\n\t\tonRemove,\n\t\ticon = null,\n\t\texplicitDismiss = false,\n\t\t// onDismiss is a callback executed when the snackbar is dismissed.\n\t\t// It is distinct from onRemove, which _looks_ like a callback but is\n\t\t// actually the function to call to remove the snackbar from the UI.\n\t\tonDismiss,\n\t\tlistRef,\n\t}: WordPressComponentProps< SnackbarProps, 'div' >,\n\tref: ForwardedRef< any >\n) {\n\tfunction dismissMe( event: KeyboardEvent | MouseEvent ) {\n\t\tif ( event && event.preventDefault ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\n\t\t// Prevent focus loss by moving it to the list element.\n\t\tlistRef?.current?.focus();\n\n\t\tonDismiss?.();\n\t\tonRemove?.();\n\t}\n\n\tfunction onActionClick(\n\t\tevent: MouseEvent< HTMLButtonElement >,\n\t\tonClick: NoticeAction[ 'onClick' ]\n\t) {\n\t\tevent.stopPropagation();\n\n\t\tonRemove?.();\n\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\tuseSpokenMessage( spokenMessage, politeness );\n\n\t// The `onDismiss/onRemove` can have unstable references,\n\t// trigger side-effect cleanup, and reset timers.\n\tconst callbacksRef = useRef( { onDismiss, onRemove } );\n\tuseLayoutEffect( () => {\n\t\tcallbacksRef.current = { onDismiss, onRemove };\n\t} );\n\n\tuseEffect( () => {\n\t\t// Only set up the timeout dismiss if we're not explicitly dismissing.\n\t\tconst timeoutHandle = setTimeout( () => {\n\t\t\tif ( ! explicitDismiss ) {\n\t\t\t\tcallbacksRef.current.onDismiss?.();\n\t\t\t\tcallbacksRef.current.onRemove?.();\n\t\t\t}\n\t\t}, NOTICE_TIMEOUT );\n\n\t\treturn () => clearTimeout( timeoutHandle );\n\t}, [ explicitDismiss ] );\n\n\tconst classes = clsx( className, 'components-snackbar', {\n\t\t'components-snackbar-explicit-dismiss': !! explicitDismiss,\n\t} );\n\tif ( actions && actions.length > 1 ) {\n\t\t// We need to inform developers that snackbar only accepts 1 action.\n\t\twarning(\n\t\t\t'Snackbar can only have one action. Use Notice if your message requires many actions.'\n\t\t);\n\t\t// return first element only while keeping it inside an array\n\t\tactions = [ actions[ 0 ] ];\n\t}\n\n\tconst snackbarContentClassnames = clsx( 'components-snackbar__content', {\n\t\t'components-snackbar__content-with-icon': !! icon,\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ classes }\n\t\t\tonClick={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\ttabIndex={ 0 }\n\t\t\trole={ ! explicitDismiss ? 'button' : undefined }\n\t\t\tonKeyPress={ ! explicitDismiss ? dismissMe : undefined }\n\t\t\taria-label={\n\t\t\t\t! explicitDismiss ? __( 'Dismiss this notice' ) : undefined\n\t\t\t}\n\t\t\tdata-testid=\"snackbar\"\n\t\t>\n\t\t\t<div className={ snackbarContentClassnames }>\n\t\t\t\t{ icon && (\n\t\t\t\t\t<div className=\"components-snackbar__icon\">{ icon }</div>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ actions.map( ( { label, onClick, url }, index ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\t\thref={ url }\n\t\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\tevent: MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t) => onActionClick( event, onClick ) }\n\t\t\t\t\t\t\tclassName=\"components-snackbar__action\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t\t{ explicitDismiss && (\n\t\t\t\t\t<span\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\taria-label={ __( 'Dismiss this notice' ) }\n\t\t\t\t\t\ttabIndex={ 0 }\n\t\t\t\t\t\tclassName=\"components-snackbar__dismiss-button\"\n\t\t\t\t\t\tonClick={ dismissMe }\n\t\t\t\t\t\tonKeyPress={ dismissMe }\n\t\t\t\t\t>\n\t\t\t\t\t\t✕\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * A Snackbar displays a succinct message that is cleared out after a small delay.\n *\n * It can also offer the user options, like viewing a published post.\n * But these options should also be available elsewhere in the UI.\n *\n * ```jsx\n * const MySnackbarNotice = () => (\n * <Snackbar>Post published successfully.</Snackbar>\n * );\n * ```\n */\nexport const Snackbar = forwardRef( UnforwardedSnackbar );\n\nexport default Snackbar;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SACCC,SAAS,EACTC,eAAe,EACfC,MAAM,EACNC,UAAU,EACVC,cAAc,QACR,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,OAAOC,OAAO,MAAM,oBAAoB;;AAExC;AACA;AACA;AACA,OAAOC,MAAM,MAAM,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAK/B,MAAMC,cAAc,GAAG,KAAK;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACxBC,OAAyC,EACzCC,UAAwD,EACvD;EACD,MAAMC,aAAa,GAClB,OAAOF,OAAO,KAAK,QAAQ,GAAGA,OAAO,GAAGV,cAAc,CAAEU,OAAQ,CAAC;EAElEd,SAAS,CAAE,MAAM;IAChB,IAAKgB,aAAa,EAAG;MACpBjB,KAAK,CAAEiB,aAAa,EAAED,UAAW,CAAC;IACnC;EACD,CAAC,EAAE,CAAEC,aAAa,EAAED,UAAU,CAAG,CAAC;AACnC;AAEA,SAASE,mBAAmBA,CAC3B;EACCC,SAAS;EACTC,QAAQ;EACRH,aAAa,GAAGG,QAAQ;EACxBJ,UAAU,GAAG,QAAQ;EACrBK,OAAO,GAAG,EAAE;EACZC,QAAQ;EACRC,IAAI,GAAG,IAAI;EACXC,eAAe,GAAG,KAAK;EACvB;EACA;EACA;EACAC,S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,cAAazC,EAAE,CAAE,qBAAsB,CAAG;QAC1CwC,QAAQ,EAAG,CAAG;QACd3B,SAAS,EAAC,qCAAqC;QAC/Ce,OAAO,EAAGN,SAAW;QACrBoB,UAAU,EAAGpB,SAAW;QAAAR,QAAA,EACxB;MAED,CAAM,CACN;IAAA,CACG;EAAC,CACF,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMoC,QAAQ,GAAGpD,UAAU,CAAEc,mBAAoB,CAAC;AAEzD,eAAesC,QAAQ","ignoreList":[]}
|
|
@@ -47,10 +47,21 @@ function useScrollRectIntoView(parent, rect, {
|
|
|
47
47
|
const childRightEdge = childLeft + childWidth;
|
|
48
48
|
const rightOverflow = childRightEdge + margin - parentRightEdge;
|
|
49
49
|
const leftOverflow = parentScroll - (childLeft - margin);
|
|
50
|
+
let scrollLeft = null;
|
|
50
51
|
if (leftOverflow > 0) {
|
|
51
|
-
|
|
52
|
+
scrollLeft = parentScroll - leftOverflow;
|
|
52
53
|
} else if (rightOverflow > 0) {
|
|
53
|
-
|
|
54
|
+
scrollLeft = parentScroll + rightOverflow;
|
|
55
|
+
}
|
|
56
|
+
if (scrollLeft !== null) {
|
|
57
|
+
/**
|
|
58
|
+
* The optional chaining is used here to avoid unit test failures.
|
|
59
|
+
* It can be removed when JSDOM supports `Element` scroll methods.
|
|
60
|
+
* See: https://github.com/WordPress/gutenberg/pull/66498#issuecomment-2441146096
|
|
61
|
+
*/
|
|
62
|
+
parent.scroll?.({
|
|
63
|
+
left: scrollLeft
|
|
64
|
+
});
|
|
54
65
|
}
|
|
55
66
|
}, [margin, parent, rect]);
|
|
56
67
|
}
|