@wordpress/components 37.0.1-next.v.202607070741.0 → 38.0.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/AGENTS.md +2 -2
- package/CHANGELOG.md +65 -1
- package/build/angle-picker-control/index.cjs +0 -1
- package/build/angle-picker-control/index.cjs.map +2 -2
- package/build/autocomplete/index.cjs +6 -4
- package/build/autocomplete/index.cjs.map +3 -3
- package/build/border-box-control/styles.cjs +9 -9
- package/build/border-box-control/styles.cjs.map +2 -2
- package/build/color-palette/styles.cjs +1 -1
- package/build/color-palette/styles.cjs.map +2 -2
- package/build/color-picker/component.cjs +14 -5
- package/build/color-picker/component.cjs.map +2 -2
- package/build/color-picker/hex-input.cjs +0 -1
- package/build/color-picker/hex-input.cjs.map +2 -2
- package/build/color-picker/input-with-slider.cjs +0 -1
- package/build/color-picker/input-with-slider.cjs.map +2 -2
- package/build/color-picker/picker.cjs +95 -23
- package/build/color-picker/picker.cjs.map +2 -2
- package/build/confirm-dialog/component.cjs +86 -4
- package/build/confirm-dialog/component.cjs.map +3 -3
- package/build/content-editable-control/docs-manifest.json +5 -0
- package/build/content-editable-control/index.cjs +181 -0
- package/build/content-editable-control/index.cjs.map +7 -0
- package/build/{theme → content-editable-control}/types.cjs +1 -1
- package/build/{theme → content-editable-control}/types.cjs.map +1 -1
- package/build/custom-select-control/index.cjs +1 -2
- package/build/custom-select-control/index.cjs.map +2 -2
- package/build/custom-select-control-v2/custom-select.cjs +0 -1
- package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
- package/build/date-time/date-picker/styles.cjs +8 -8
- package/build/date-time/date-picker/styles.cjs.map +2 -2
- package/build/date-time/time-picker/index.cjs +0 -2
- package/build/date-time/time-picker/index.cjs.map +2 -2
- package/build/date-time/time-picker/time-input/index.cjs +0 -2
- package/build/date-time/time-picker/time-input/index.cjs.map +2 -2
- package/build/disabled/index.cjs +87 -4
- package/build/disabled/index.cjs.map +4 -4
- package/build/form-token-field/index.cjs +87 -2
- package/build/form-token-field/index.cjs.map +3 -3
- package/build/gradient-picker/index.cjs +26 -20
- package/build/gradient-picker/index.cjs.map +2 -2
- package/build/heading/hook.cjs +1 -1
- package/build/heading/hook.cjs.map +1 -1
- package/build/input-control/index.cjs +4 -14
- package/build/input-control/index.cjs.map +2 -2
- package/build/input-control/input-base.cjs +2 -6
- package/build/input-control/input-base.cjs.map +2 -2
- package/build/input-control/styles/input-control-styles.cjs +25 -39
- package/build/input-control/styles/input-control-styles.cjs.map +2 -2
- package/build/menu/group-label.cjs +2 -1
- package/build/menu/group-label.cjs.map +2 -2
- package/build/number-control/index.cjs +1 -11
- package/build/number-control/index.cjs.map +2 -2
- package/build/palette-edit/styles.cjs +9 -9
- package/build/palette-edit/styles.cjs.map +2 -2
- package/build/private-apis.cjs +3 -2
- package/build/private-apis.cjs.map +3 -3
- package/build/range-control/index.cjs +0 -2
- package/build/range-control/index.cjs.map +2 -2
- package/build/sandbox/index.cjs +96 -73
- package/build/sandbox/index.cjs.map +3 -3
- package/build/search-control/index.cjs +93 -11
- package/build/search-control/index.cjs.map +4 -4
- package/build/select-control/index.cjs +0 -2
- package/build/select-control/index.cjs.map +2 -2
- package/build/select-control/styles/select-control-styles.cjs +9 -16
- package/build/select-control/styles/select-control-styles.cjs.map +2 -2
- package/build/slot-fill/fill.cjs.map +2 -2
- package/build/spacer/hook.cjs +150 -14
- package/build/spacer/hook.cjs.map +4 -4
- package/build/toggle-group-control/toggle-group-control/component.cjs +91 -8
- package/build/toggle-group-control/toggle-group-control/component.cjs.map +4 -4
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs +98 -17
- package/build/toggle-group-control/toggle-group-control-option-base/component.cjs.map +4 -4
- package/build/tools-panel/tools-panel/component.cjs +6 -0
- package/build/tools-panel/tools-panel/component.cjs.map +2 -2
- package/build/tools-panel/tools-panel/hook.cjs +87 -11
- package/build/tools-panel/tools-panel/hook.cjs.map +4 -4
- package/build/tools-panel/tools-panel-header/component.cjs +87 -2
- package/build/tools-panel/tools-panel-header/component.cjs.map +3 -3
- package/build/tools-panel/tools-panel-header/hook.cjs +90 -20
- package/build/tools-panel/tools-panel-header/hook.cjs.map +4 -4
- package/build/tools-panel/tools-panel-item/hook.cjs +88 -9
- package/build/tools-panel/tools-panel-item/hook.cjs.map +4 -4
- package/build/unit-control/index.cjs +0 -1
- package/build/unit-control/index.cjs.map +2 -2
- package/build/utils/base-label.cjs +1 -1
- package/build/utils/base-label.cjs.map +2 -2
- package/build/utils/config-values.cjs +1 -3
- package/build/utils/config-values.cjs.map +2 -2
- package/build/utils/font-values.cjs +1 -1
- package/build/utils/font-values.cjs.map +1 -1
- package/build/validated-form-controls/components/content-editable-control.cjs +84 -0
- package/build/validated-form-controls/components/content-editable-control.cjs.map +7 -0
- package/build/validated-form-controls/components/index.cjs +2 -0
- package/build/validated-form-controls/components/index.cjs.map +2 -2
- package/build/validated-form-controls/components/input-control.cjs +0 -1
- package/build/validated-form-controls/components/input-control.cjs.map +2 -2
- package/build/validated-form-controls/components/number-control.cjs +0 -1
- package/build/validated-form-controls/components/number-control.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +4 -4
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/angle-picker-control/index.mjs +0 -1
- package/build-module/angle-picker-control/index.mjs.map +2 -2
- package/build-module/autocomplete/index.mjs +8 -6
- package/build-module/autocomplete/index.mjs.map +2 -2
- package/build-module/border-box-control/styles.mjs +9 -9
- package/build-module/border-box-control/styles.mjs.map +2 -2
- package/build-module/color-palette/styles.mjs +1 -1
- package/build-module/color-palette/styles.mjs.map +2 -2
- package/build-module/color-picker/component.mjs +14 -5
- package/build-module/color-picker/component.mjs.map +2 -2
- package/build-module/color-picker/hex-input.mjs +0 -1
- package/build-module/color-picker/hex-input.mjs.map +2 -2
- package/build-module/color-picker/input-with-slider.mjs +0 -1
- package/build-module/color-picker/input-with-slider.mjs.map +2 -2
- package/build-module/color-picker/picker.mjs +96 -24
- package/build-module/color-picker/picker.mjs.map +2 -2
- package/build-module/confirm-dialog/component.mjs +86 -4
- package/build-module/confirm-dialog/component.mjs.map +3 -3
- package/build-module/content-editable-control/docs-manifest.json +5 -0
- package/build-module/content-editable-control/index.mjs +146 -0
- package/build-module/content-editable-control/index.mjs.map +7 -0
- package/build-module/custom-select-control/index.mjs +1 -2
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs +0 -1
- package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
- package/build-module/date-time/date-picker/styles.mjs +8 -8
- package/build-module/date-time/date-picker/styles.mjs.map +2 -2
- package/build-module/date-time/time-picker/index.mjs +0 -2
- package/build-module/date-time/time-picker/index.mjs.map +2 -2
- package/build-module/date-time/time-picker/time-input/index.mjs +0 -2
- package/build-module/date-time/time-picker/time-input/index.mjs.map +2 -2
- package/build-module/disabled/index.mjs +87 -4
- package/build-module/disabled/index.mjs.map +3 -3
- package/build-module/form-token-field/index.mjs +88 -3
- package/build-module/form-token-field/index.mjs.map +3 -3
- package/build-module/gradient-picker/index.mjs +26 -20
- package/build-module/gradient-picker/index.mjs.map +2 -2
- package/build-module/heading/hook.mjs +1 -1
- package/build-module/heading/hook.mjs.map +1 -1
- package/build-module/input-control/index.mjs +4 -14
- package/build-module/input-control/index.mjs.map +2 -2
- package/build-module/input-control/input-base.mjs +2 -6
- package/build-module/input-control/input-base.mjs.map +2 -2
- package/build-module/input-control/styles/input-control-styles.mjs +25 -39
- package/build-module/input-control/styles/input-control-styles.mjs.map +2 -2
- package/build-module/menu/group-label.mjs +2 -1
- package/build-module/menu/group-label.mjs.map +2 -2
- package/build-module/number-control/index.mjs +1 -11
- package/build-module/number-control/index.mjs.map +2 -2
- package/build-module/palette-edit/styles.mjs +9 -9
- package/build-module/palette-edit/styles.mjs.map +2 -2
- package/build-module/private-apis.mjs +4 -3
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/range-control/index.mjs +0 -2
- package/build-module/range-control/index.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +84 -72
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/search-control/index.mjs +93 -11
- package/build-module/search-control/index.mjs.map +3 -3
- package/build-module/select-control/index.mjs +0 -2
- package/build-module/select-control/index.mjs.map +2 -2
- package/build-module/select-control/styles/select-control-styles.mjs +9 -16
- package/build-module/select-control/styles/select-control-styles.mjs.map +2 -2
- package/build-module/slot-fill/fill.mjs.map +2 -2
- package/build-module/spacer/hook.mjs +140 -14
- package/build-module/spacer/hook.mjs.map +3 -3
- package/build-module/toggle-group-control/toggle-group-control/component.mjs +92 -9
- package/build-module/toggle-group-control/toggle-group-control/component.mjs.map +3 -3
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs +99 -18
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel/component.mjs +6 -0
- package/build-module/tools-panel/tools-panel/component.mjs.map +2 -2
- package/build-module/tools-panel/tools-panel/hook.mjs +87 -11
- package/build-module/tools-panel/tools-panel/hook.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-header/component.mjs +87 -2
- package/build-module/tools-panel/tools-panel-header/component.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-header/hook.mjs +90 -20
- package/build-module/tools-panel/tools-panel-header/hook.mjs.map +3 -3
- package/build-module/tools-panel/tools-panel-item/hook.mjs +89 -10
- package/build-module/tools-panel/tools-panel-item/hook.mjs.map +3 -3
- package/build-module/unit-control/index.mjs +0 -1
- package/build-module/unit-control/index.mjs.map +2 -2
- package/build-module/utils/base-label.mjs +1 -1
- package/build-module/utils/base-label.mjs.map +2 -2
- package/build-module/utils/config-values.mjs +1 -3
- package/build-module/utils/config-values.mjs.map +2 -2
- package/build-module/utils/font-values.mjs +1 -1
- package/build-module/utils/font-values.mjs.map +1 -1
- package/build-module/validated-form-controls/components/content-editable-control.mjs +49 -0
- package/build-module/validated-form-controls/components/content-editable-control.mjs.map +7 -0
- package/build-module/validated-form-controls/components/index.mjs +1 -0
- package/build-module/validated-form-controls/components/index.mjs.map +2 -2
- package/build-module/validated-form-controls/components/input-control.mjs +0 -1
- package/build-module/validated-form-controls/components/input-control.mjs.map +2 -2
- package/build-module/validated-form-controls/components/number-control.mjs +0 -1
- package/build-module/validated-form-controls/components/number-control.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +4 -4
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-style/style-rtl.css +70 -81
- package/build-style/style.css +70 -81
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts +1 -1
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/index.d.ts +8 -4
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -3
- package/build-types/border-box-control/border-box-control/component.d.ts.map +1 -1
- package/build-types/border-box-control/stories/index.story.d.ts +1 -3
- package/build-types/border-box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/border-box-control/styles.d.ts.map +1 -1
- package/build-types/border-box-control/types.d.ts +1 -15
- package/build-types/border-box-control/types.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-control.d.ts +3 -0
- package/build-types/box-control/input-control.d.ts.map +1 -0
- package/build-types/box-control/styles/box-control-styles.d.ts +4 -8
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +1 -8
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/button/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/calendar/date-range-calendar/index.d.ts +1 -1
- package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -1
- package/build-types/calendar/utils/use-localization-props.d.ts +6 -2
- package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -1
- package/build-types/card/context.d.ts +3 -0
- package/build-types/card/context.d.ts.map +1 -0
- package/build-types/card/styles.d.ts +3 -3
- package/build-types/card/styles.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker-actions.d.ts +1 -1
- package/build-types/circular-option-picker/circular-option-picker-actions.d.ts.map +1 -1
- package/build-types/circular-option-picker/circular-option-picker.d.ts +8 -13
- package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +17 -1
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -6
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/color-picker/types.d.ts +2 -0
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/composite/legacy/stories/utils.d.ts.map +1 -1
- package/build-types/confirm-dialog/component.d.ts.map +1 -1
- package/build-types/content-editable-control/index.d.ts +31 -0
- package/build-types/content-editable-control/index.d.ts.map +1 -0
- package/build-types/content-editable-control/stories/index.story.d.ts +13 -0
- package/build-types/content-editable-control/stories/index.story.d.ts.map +1 -0
- package/build-types/content-editable-control/test/index.d.ts +2 -0
- package/build-types/content-editable-control/test/index.d.ts.map +1 -0
- package/build-types/content-editable-control/types.d.ts +32 -0
- package/build-types/content-editable-control/types.d.ts.map +1 -0
- package/build-types/context/context-system-provider.d.ts +21 -2
- package/build-types/context/context-system-provider.d.ts.map +1 -1
- package/build-types/context/wordpress-component.d.ts +2 -1
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +3 -2
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/index.d.ts +1 -1
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/serializer.d.ts +3 -3
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/custom-select-control/types.d.ts +1 -8
- package/build-types/custom-select-control/types.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +2 -1
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/item.d.ts.map +1 -1
- package/build-types/date-time/date/index.d.ts +23 -0
- package/build-types/date-time/date/index.d.ts.map +1 -0
- package/build-types/date-time/date/styles.d.ts +45 -0
- package/build-types/date-time/date/styles.d.ts.map +1 -0
- package/build-types/date-time/date/test/index.d.ts +2 -0
- package/build-types/date-time/date/test/index.d.ts.map +1 -0
- package/build-types/date-time/date/test/use-lilius.d.ts +2 -0
- package/build-types/date-time/date/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date/use-lilius/index.d.ts +169 -0
- package/build-types/date-time/date/use-lilius/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/index.d.ts +1 -1
- package/build-types/date-time/date-picker/index.d.ts.map +1 -1
- package/build-types/date-time/time/index.d.ts +27 -0
- package/build-types/date-time/time/index.d.ts.map +1 -0
- package/build-types/date-time/time/styles.d.ts +93 -0
- package/build-types/date-time/time/styles.d.ts.map +1 -0
- package/build-types/date-time/time/test/index.d.ts +2 -0
- package/build-types/date-time/time/test/index.d.ts.map +1 -0
- package/build-types/date-time/time/time-input/index.d.ts +4 -0
- package/build-types/date-time/time/time-input/index.d.ts.map +1 -0
- package/build-types/date-time/time/time-input/test/index.d.ts +2 -0
- package/build-types/date-time/time/time-input/test/index.d.ts.map +1 -0
- package/build-types/date-time/time/timezone.d.ts +7 -0
- package/build-types/date-time/time/timezone.d.ts.map +1 -0
- package/build-types/date-time/time-picker/index.d.ts +3 -2
- package/build-types/date-time/time-picker/index.d.ts.map +1 -1
- package/build-types/date-time/time-picker/styles.d.ts +4 -8
- package/build-types/date-time/time-picker/styles.d.ts.map +1 -1
- package/build-types/date-time/time-picker/time-input/index.d.ts +1 -1
- package/build-types/date-time/time-picker/time-input/index.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts +4 -4
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +10 -0
- package/build-types/divider/styles.d.ts.map +1 -0
- package/build-types/draggable/index.d.ts +1 -1
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/drop-zone/provider.d.ts +1 -1
- package/build-types/drop-zone/provider.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -1
- package/build-types/duotone-picker/custom-duotone-bar.d.ts +1 -1
- package/build-types/duotone-picker/custom-duotone-bar.d.ts.map +1 -1
- package/build-types/flex/styles.d.ts +17 -0
- package/build-types/flex/styles.d.ts.map +1 -0
- package/build-types/focal-point-picker/controls.d.ts +1 -1
- package/build-types/focal-point-picker/controls.d.ts.map +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -4
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts +12 -2
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/font-size-picker/stories/e2e/index.story.d.ts +12 -1
- package/build-types/font-size-picker/stories/e2e/index.story.d.ts.map +1 -1
- package/build-types/font-size-picker/types.d.ts +2 -15
- package/build-types/font-size-picker/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts +1 -1
- package/build-types/form-token-field/suggestions-list.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +1 -0
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/test/index.d.ts +2 -0
- package/build-types/gradient-picker/test/index.d.ts.map +1 -0
- package/build-types/gradient-picker/types.d.ts +19 -4
- package/build-types/gradient-picker/types.d.ts.map +1 -1
- package/build-types/guide/index.d.ts +1 -1
- package/build-types/guide/index.d.ts.map +1 -1
- package/build-types/guide/page-control.d.ts +1 -1
- package/build-types/guide/page-control.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/index.d.ts +3 -3
- package/build-types/higher-order/with-fallback-styles/index.d.ts.map +1 -1
- package/build-types/input-control/index.d.ts +0 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-base.d.ts.map +1 -1
- package/build-types/input-control/stories/index.story.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -8
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +15 -29
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/keyboard-shortcuts/index.d.ts +1 -1
- package/build-types/keyboard-shortcuts/index.d.ts.map +1 -1
- package/build-types/menu/group-label.d.ts.map +1 -1
- package/build-types/menu-items-choice/index.d.ts +1 -1
- package/build-types/menu-items-choice/index.d.ts.map +1 -1
- package/build-types/mobile/image/constants.d.ts +5 -0
- package/build-types/mobile/image/constants.d.ts.map +1 -0
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/navigation/back-button/index.d.ts +7 -0
- package/build-types/navigation/back-button/index.d.ts.map +1 -0
- package/build-types/navigation/constants.d.ts +3 -0
- package/build-types/navigation/constants.d.ts.map +1 -0
- package/build-types/navigation/context.d.ts +4 -0
- package/build-types/navigation/context.d.ts.map +1 -0
- package/build-types/navigation/group/context.d.ts +7 -0
- package/build-types/navigation/group/context.d.ts.map +1 -0
- package/build-types/navigation/group/index.d.ts +7 -0
- package/build-types/navigation/group/index.d.ts.map +1 -0
- package/build-types/navigation/index.d.ts +46 -0
- package/build-types/navigation/index.d.ts.map +1 -0
- package/build-types/navigation/item/base-content.d.ts +3 -0
- package/build-types/navigation/item/base-content.d.ts.map +1 -0
- package/build-types/navigation/item/base.d.ts +3 -0
- package/build-types/navigation/item/base.d.ts.map +1 -0
- package/build-types/navigation/item/index.d.ts +7 -0
- package/build-types/navigation/item/index.d.ts.map +1 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts +3 -0
- package/build-types/navigation/item/use-navigation-tree-item.d.ts.map +1 -0
- package/build-types/navigation/menu/context.d.ts +7 -0
- package/build-types/navigation/menu/context.d.ts.map +1 -0
- package/build-types/navigation/menu/index.d.ts +7 -0
- package/build-types/navigation/menu/index.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title-search.d.ts +3 -0
- package/build-types/navigation/menu/menu-title-search.d.ts.map +1 -0
- package/build-types/navigation/menu/menu-title.d.ts +3 -0
- package/build-types/navigation/menu/menu-title.d.ts.map +1 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts +3 -0
- package/build-types/navigation/menu/search-no-results-found.d.ts.map +1 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts +3 -0
- package/build-types/navigation/menu/use-navigation-tree-menu.d.ts.map +1 -0
- package/build-types/navigation/stories/index.story.d.ts +23 -0
- package/build-types/navigation/stories/index.story.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts +7 -0
- package/build-types/navigation/stories/utils/controlled-state.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/default.d.ts +10 -0
- package/build-types/navigation/stories/utils/default.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/group.d.ts +10 -0
- package/build-types/navigation/stories/utils/group.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts +10 -0
- package/build-types/navigation/stories/utils/hide-if-empty.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts +10 -0
- package/build-types/navigation/stories/utils/more-examples.d.ts.map +1 -0
- package/build-types/navigation/stories/utils/search.d.ts +10 -0
- package/build-types/navigation/stories/utils/search.d.ts.map +1 -0
- package/build-types/navigation/styles/navigation-styles.d.ts +55 -0
- package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -0
- package/build-types/navigation/test/index.d.ts +2 -0
- package/build-types/navigation/test/index.d.ts.map +1 -0
- package/build-types/navigation/types.d.ts +266 -0
- package/build-types/navigation/types.d.ts.map +1 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts +15 -0
- package/build-types/navigation/use-create-navigation-tree.d.ts.map +1 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts +10 -0
- package/build-types/navigation/use-navigation-tree-nodes.d.ts.map +1 -0
- package/build-types/navigation/utils.d.ts +3 -0
- package/build-types/navigation/utils.d.ts.map +1 -0
- package/build-types/navigator/navigator-screen/use-screen-animate-presence.d.ts +1 -1
- package/build-types/navigator/navigator-screen/use-screen-animate-presence.d.ts.map +1 -1
- package/build-types/notice/index.d.ts +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/list.d.ts +1 -1
- package/build-types/notice/list.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +1 -2
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +1 -2
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/types.d.ts +0 -7
- package/build-types/number-control/types.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/query-controls/author-select.d.ts +1 -1
- package/build-types/query-controls/author-select.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +2 -4
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +1 -2
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +2 -16
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/responsive-wrapper/index.d.ts +1 -1
- package/build-types/responsive-wrapper/index.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts +34 -0
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/types.d.ts +11 -0
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/search-control/index.d.ts.map +1 -1
- package/build-types/search-control/types.d.ts +1 -1
- package/build-types/search-control/types.d.ts.map +1 -1
- package/build-types/select-control/index.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +9 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/slot-fill/fill.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -1
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/stories/index.story.d.ts +1 -6
- package/build-types/slot-fill/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/list.d.ts +1 -1
- package/build-types/snackbar/list.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +2 -4
- package/build-types/spacer/hook.d.ts.map +1 -1
- package/build-types/spacer/stories/index.story.d.ts +1 -6
- package/build-types/spacer/stories/index.story.d.ts.map +1 -1
- package/build-types/surface/styles.d.ts +11 -0
- package/build-types/surface/styles.d.ts.map +1 -0
- package/build-types/text/types.d.ts +4 -4
- package/build-types/text/types.d.ts.map +1 -1
- package/build-types/text/utils.d.ts +1 -1
- package/build-types/text/utils.d.ts.map +1 -1
- package/build-types/theme/styles.d.ts +10 -0
- package/build-types/theme/styles.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts +0 -1
- 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-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/types.d.ts +0 -7
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tree-grid/roving-tab-index.d.ts +1 -1
- package/build-types/tree-grid/roving-tab-index.d.ts.map +1 -1
- package/build-types/tree-grid/stories/index.story.d.ts.map +1 -1
- package/build-types/tree-select/types.d.ts +1 -8
- package/build-types/tree-select/types.d.ts.map +1 -1
- package/build-types/truncate/styles.d.ts +2 -0
- package/build-types/truncate/styles.d.ts.map +1 -0
- package/build-types/unit-control/index.d.ts +2 -4
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -2
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +1 -15
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/utils/config-values.d.ts +1 -2
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts +1 -1
- package/build-types/utils/hooks/use-animated-offset-rect.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-state.d.ts +6 -0
- package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts +1 -1
- package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
- package/build-types/utils/rtl.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/content-editable-control.d.ts +16 -0
- package/build-types/validated-form-controls/components/content-editable-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/index.d.ts +1 -0
- package/build-types/validated-form-controls/components/index.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/input-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +2 -4
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/content-editable-control.story.d.ts +9 -0
- package/build-types/validated-form-controls/components/stories/content-editable-control.story.d.ts.map +1 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts +5 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/build-types/validated-form-controls/test/content-editable-control.d.ts +2 -0
- package/build-types/validated-form-controls/test/content-editable-control.d.ts.map +1 -0
- package/build-types/validated-form-controls/validity-indicator.d.ts +1 -1
- package/build-types/validated-form-controls/validity-indicator.d.ts.map +1 -1
- package/build-types/visually-hidden/test/index.d.ts +2 -0
- package/build-types/visually-hidden/test/index.d.ts.map +1 -0
- package/package.json +30 -30
- package/src/angle-picker-control/index.tsx +0 -1
- package/src/autocomplete/index.tsx +20 -11
- package/src/autocomplete/style.scss +1 -0
- package/src/badge/stories/index.story.tsx +1 -1
- package/src/base-control/README.md +2 -2
- package/src/base-control/stories/index.story.tsx +1 -1
- package/src/border-box-control/styles.ts +6 -2
- package/src/border-box-control/types.ts +4 -15
- package/src/box-control/types.ts +4 -8
- package/src/button/stories/e2e/index.story.tsx +10 -2
- package/src/button/stories/index.story.tsx +1 -1
- package/src/button/style.scss +32 -27
- package/src/button-group/style.scss +1 -6
- package/src/calendar/style.scss +1 -1
- package/src/card/stories/index.story.tsx +1 -1
- package/src/card/test/__snapshots__/index.tsx.snap +1 -1
- package/src/checkbox-control/stories/index.story.tsx +1 -1
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +1 -1
- package/src/color-indicator/test/__snapshots__/index.tsx.snap +1 -1
- package/src/color-palette/styles.ts +1 -1
- package/src/color-picker/component.tsx +23 -19
- package/src/color-picker/hex-input.tsx +0 -1
- package/src/color-picker/input-with-slider.tsx +0 -1
- package/src/color-picker/picker.tsx +144 -21
- package/src/color-picker/test/index.tsx +502 -0
- package/src/color-picker/types.ts +2 -0
- package/src/combobox-control/style.scss +2 -2
- package/src/confirm-dialog/component.tsx +2 -4
- package/src/confirm-dialog/stories/index.story.tsx +1 -1
- package/src/confirm-dialog/style.module.scss +7 -0
- package/src/confirm-dialog/test/index.tsx +5 -0
- package/src/content-editable-control/README.md +88 -0
- package/src/content-editable-control/docs-manifest.json +5 -0
- package/src/content-editable-control/index.tsx +110 -0
- package/src/content-editable-control/stories/index.story.tsx +32 -0
- package/src/content-editable-control/style.module.scss +34 -0
- package/src/content-editable-control/test/index.tsx +176 -0
- package/src/content-editable-control/types.ts +35 -0
- package/src/context/test/__snapshots__/context-system-provider.js.snap +1 -1
- package/src/context/wordpress-component.ts +7 -2
- package/src/custom-gradient-picker/test/index.tsx +111 -1
- package/src/custom-select-control/index.tsx +1 -2
- package/src/custom-select-control/stories/index.story.tsx +1 -1
- package/src/custom-select-control/test/__snapshots__/index.tsx.snap +6 -0
- package/src/custom-select-control/test/index.tsx +23 -0
- package/src/custom-select-control/types.ts +1 -8
- package/src/custom-select-control-v2/custom-select.tsx +1 -5
- package/src/custom-select-control-v2/stories/index.story.tsx +1 -1
- package/src/date-time/date-picker/styles.ts +1 -1
- package/src/date-time/time-picker/index.tsx +0 -2
- package/src/date-time/time-picker/time-input/index.tsx +0 -2
- package/src/disabled/index.tsx +7 -5
- package/src/disabled/style.module.scss +15 -0
- package/src/disabled/test/index.tsx +6 -4
- package/src/dropdown-menu/style.scss +1 -1
- package/src/elevation/stories/index.story.tsx +1 -1
- package/src/elevation/test/__snapshots__/index.tsx.snap +1 -1
- package/src/external-link/stories/index.story.tsx +1 -1
- package/src/external-link/style.scss +7 -13
- package/src/flex/stories/index.story.tsx +1 -1
- package/src/flex/test/__snapshots__/index.tsx.snap +1 -1
- package/src/font-size-picker/types.ts +6 -15
- package/src/form-toggle/test/__snapshots__/index.tsx.snap +1 -1
- package/src/form-token-field/index.tsx +5 -4
- package/src/form-token-field/style.module.scss +6 -0
- package/src/form-token-field/style.scss +2 -2
- package/src/gradient-picker/README.md +21 -3
- package/src/gradient-picker/index.tsx +43 -28
- package/src/gradient-picker/stories/index.story.tsx +41 -5
- package/src/gradient-picker/test/index.tsx +148 -0
- package/src/gradient-picker/types.ts +24 -4
- package/src/h-stack/stories/index.story.tsx +1 -1
- package/src/h-stack/test/__snapshots__/index.tsx.snap +1 -1
- package/src/heading/hook.ts +1 -1
- package/src/heading/stories/index.story.tsx +1 -1
- package/src/heading/test/__snapshots__/index.tsx.snap +1 -1
- package/src/higher-order/with-filters/test/__snapshots__/index.tsx.snap +1 -1
- package/src/icon/stories/index.story.tsx +1 -1
- package/src/input-control/README.md +0 -8
- package/src/input-control/index.tsx +4 -16
- package/src/input-control/input-base.tsx +4 -8
- package/src/input-control/stories/index.story.tsx +2 -4
- package/src/input-control/styles/input-control-styles.tsx +1 -19
- package/src/input-control/test/__snapshots__/index.js.snap +11 -0
- package/src/input-control/test/index.js +29 -7
- package/src/input-control/types.ts +15 -30
- package/src/item-group/test/__snapshots__/index.js.snap +1 -1
- package/src/menu/README.md +2 -2
- package/src/menu/group-label.tsx +2 -1
- package/src/menu-group/style.scss +1 -1
- package/src/menu-item/style.scss +1 -1
- package/src/menu-item/test/__snapshots__/index.js.snap +1 -1
- package/src/modal/stories/index.story.tsx +2 -5
- package/src/modal/style.scss +1 -1
- package/src/modal/test/index.tsx +42 -0
- package/src/notice/stories/index.story.tsx +1 -1
- package/src/notice/test/__snapshots__/index.tsx.snap +1 -1
- package/src/number-control/README.md +0 -8
- package/src/number-control/index.tsx +1 -12
- package/src/number-control/stories/index.story.tsx +1 -3
- package/src/number-control/test/index.tsx +1 -1
- package/src/number-control/types.ts +0 -7
- package/src/palette-edit/styles.ts +1 -1
- package/src/panel/stories/index.story.tsx +4 -4
- package/src/panel/style.scss +2 -5
- package/src/panel/test/__snapshots__/body.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/header.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/index.tsx.snap +1 -1
- package/src/panel/test/__snapshots__/row.tsx.snap +1 -1
- package/src/placeholder/style.scss +1 -1
- package/src/private-apis.ts +4 -2
- package/src/range-control/index.tsx +0 -2
- package/src/range-control/types.ts +2 -15
- package/src/sandbox/index.tsx +165 -98
- package/src/sandbox/test/index.tsx +63 -1
- package/src/sandbox/types.ts +11 -0
- package/src/scrollable/test/__snapshots__/index.tsx.snap +1 -1
- package/src/search-control/index.tsx +23 -21
- package/src/search-control/style.module.scss +16 -0
- package/src/search-control/test/index.tsx +8 -0
- package/src/search-control/types.ts +1 -1
- package/src/select-control/index.tsx +0 -2
- package/src/select-control/stories/index.story.tsx +1 -1
- package/src/select-control/styles/select-control-styles.ts +0 -7
- package/src/select-control/test/__snapshots__/select-control.tsx.snap +11 -0
- package/src/select-control/test/select-control.tsx +37 -0
- package/src/select-control/types.ts +8 -2
- package/src/shortcut/test/__snapshots__/index.tsx.snap +1 -1
- package/src/slot-fill/fill.tsx +3 -9
- package/src/slot-fill/stories/index.story.tsx +52 -10
- package/src/slot-fill/test/__snapshots__/slot.js.snap +1 -1
- package/src/slot-fill/test/slot.js +53 -11
- package/src/spacer/hook.ts +93 -77
- package/src/spacer/stories/index.story.tsx +8 -6
- package/src/spacer/style.module.scss +25 -0
- package/src/spacer/test/__snapshots__/index.tsx.snap +3 -223
- package/src/spacer/test/index.tsx +106 -110
- package/src/tab-panel/stories/index.story.tsx +1 -1
- package/src/tab-panel/style.scss +1 -1
- package/src/tabs/stories/index.story.tsx +1 -1
- package/src/text/stories/index.story.tsx +1 -1
- package/src/text/test/__snapshots__/index.tsx.snap +1 -1
- package/src/text/types.ts +5 -5
- package/src/text-control/style.scss +1 -1
- package/src/textarea-control/stories/index.story.tsx +1 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +37 -715
- package/src/toggle-group-control/test/index.tsx +33 -3
- package/src/toggle-group-control/toggle-group-control/component.tsx +11 -16
- package/src/toggle-group-control/toggle-group-control/style.module.scss +63 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +22 -24
- package/src/toggle-group-control/toggle-group-control-option-base/style.module.scss +88 -0
- package/src/toggle-group-control/types.ts +0 -7
- package/src/toolbar/toolbar-button/style.scss +1 -1
- package/src/tools-panel/style.module.scss +117 -0
- package/src/tools-panel/test/index.tsx +105 -39
- package/src/tools-panel/tools-panel/component.tsx +12 -1
- package/src/tools-panel/tools-panel/hook.ts +13 -15
- package/src/tools-panel/tools-panel-header/component.tsx +6 -2
- package/src/tools-panel/tools-panel-header/hook.ts +7 -25
- package/src/tools-panel/tools-panel-item/hook.ts +16 -34
- package/src/tooltip/stories/index.story.tsx +1 -1
- package/src/tooltip/test/index.tsx +1 -1
- package/src/tree-grid/stories/index.story.tsx +0 -2
- package/src/tree-grid/test/__snapshots__/cell.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/index.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/roving-tab-index-item.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/roving-tab-index.tsx.snap +1 -1
- package/src/tree-grid/test/__snapshots__/row.tsx.snap +1 -1
- package/src/tree-select/README.md +1 -1
- package/src/tree-select/types.ts +1 -8
- package/src/unit-control/index.tsx +0 -1
- package/src/unit-control/types.ts +1 -18
- package/src/utils/base-label.ts +1 -1
- package/src/utils/config-values.js +1 -2
- package/src/utils/font-values.js +1 -1
- package/src/utils/theme-variables.scss +1 -0
- package/src/v-stack/stories/index.story.tsx +1 -1
- package/src/v-stack/test/__snapshots__/index.tsx.snap +1 -1
- package/src/validated-form-controls/components/content-editable-control.tsx +88 -0
- package/src/validated-form-controls/components/index.ts +1 -0
- package/src/validated-form-controls/components/input-control.tsx +2 -10
- package/src/validated-form-controls/components/number-control.tsx +2 -10
- package/src/validated-form-controls/components/stories/content-editable-control.story.tsx +56 -0
- package/src/validated-form-controls/components/stories/overview.story.tsx +51 -0
- package/src/validated-form-controls/control-with-error.tsx +10 -1
- package/src/validated-form-controls/style.scss +9 -2
- package/src/validated-form-controls/test/content-editable-control.tsx +71 -0
- package/src/validated-form-controls/test/control-with-error.tsx +42 -0
- package/src/view/test/__snapshots__/index.js.snap +1 -1
- package/src/visually-hidden/stories/index.story.tsx +1 -1
- package/build/confirm-dialog/styles.cjs +0 -42
- package/build/confirm-dialog/styles.cjs.map +0 -7
- package/build/disabled/styles/disabled-styles.cjs +0 -42
- package/build/disabled/styles/disabled-styles.cjs.map +0 -7
- package/build/form-token-field/styles.cjs +0 -49
- package/build/form-token-field/styles.cjs.map +0 -7
- package/build/search-control/styles.cjs +0 -74
- package/build/search-control/styles.cjs.map +0 -7
- package/build/theme/color-algorithms.cjs +0 -131
- package/build/theme/color-algorithms.cjs.map +0 -7
- package/build/theme/index.cjs +0 -160
- package/build/theme/index.cjs.map +0 -7
- package/build/toggle-group-control/toggle-group-control/styles.cjs +0 -53
- package/build/toggle-group-control/toggle-group-control/styles.cjs.map +0 -7
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs +0 -94
- package/build/toggle-group-control/toggle-group-control-option-base/styles.cjs.map +0 -7
- package/build/tools-panel/styles.cjs +0 -129
- package/build/tools-panel/styles.cjs.map +0 -7
- package/build/utils/deprecated-36px-size.cjs +0 -56
- package/build/utils/deprecated-36px-size.cjs.map +0 -7
- package/build/utils/use-deprecated-props.cjs +0 -41
- package/build/utils/use-deprecated-props.cjs.map +0 -7
- package/build-module/confirm-dialog/styles.mjs +0 -17
- package/build-module/confirm-dialog/styles.mjs.map +0 -7
- package/build-module/disabled/styles/disabled-styles.mjs +0 -17
- package/build-module/disabled/styles/disabled-styles.mjs.map +0 -7
- package/build-module/form-token-field/styles.mjs +0 -14
- package/build-module/form-token-field/styles.mjs.map +0 -7
- package/build-module/search-control/styles.mjs +0 -38
- package/build-module/search-control/styles.mjs.map +0 -7
- package/build-module/theme/color-algorithms.mjs +0 -94
- package/build-module/theme/color-algorithms.mjs.map +0 -7
- package/build-module/theme/index.mjs +0 -129
- package/build-module/theme/index.mjs.map +0 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs +0 -27
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs.map +0 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs +0 -56
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.mjs.map +0 -7
- package/build-module/tools-panel/styles.mjs +0 -84
- package/build-module/tools-panel/styles.mjs.map +0 -7
- package/build-module/utils/deprecated-36px-size.mjs +0 -21
- package/build-module/utils/deprecated-36px-size.mjs.map +0 -7
- package/build-module/utils/use-deprecated-props.mjs +0 -16
- package/build-module/utils/use-deprecated-props.mjs.map +0 -7
- package/src/confirm-dialog/styles.ts +0 -18
- package/src/disabled/styles/disabled-styles.tsx +0 -23
- package/src/form-token-field/styles.ts +0 -15
- package/src/search-control/styles.ts +0 -27
- package/src/theme/README.md +0 -47
- package/src/theme/color-algorithms.ts +0 -142
- package/src/theme/index.tsx +0 -80
- package/src/theme/stories/index.story.tsx +0 -127
- package/src/theme/style.module.scss +0 -4
- package/src/theme/test/color-algorithms.ts +0 -100
- package/src/theme/test/index.tsx +0 -151
- package/src/theme/types.ts +0 -61
- package/src/toggle-group-control/toggle-group-control/styles.ts +0 -84
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +0 -109
- package/src/tools-panel/styles.ts +0 -176
- package/src/utils/deprecated-36px-size.ts +0 -30
- package/src/utils/use-deprecated-props.ts +0 -14
- /package/build-module/{theme → content-editable-control}/types.mjs +0 -0
- /package/build-module/{theme → content-editable-control}/types.mjs.map +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/range-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n __shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef(null);\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` — which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n __unstableInputWidth: space(20),\n __next40pxDefaultSize: true,\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO,eAAe;AAChI,SAAS,aAAa;AACtB,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA;AAAA,IAEJ,yBAAyB;AAAA,IACzB,uBAAuB;AAAA,IACvB
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useRef, useState, forwardRef } from '@wordpress/element';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BaseControl from '../base-control';\nimport Button from '../button';\nimport Icon from '../icon';\nimport { COLORS } from '../utils';\nimport { floatClamp, useControlledRangeValue } from './utils';\nimport { clamp } from '../utils/math';\nimport InputRange from './input-range';\nimport RangeRail from './rail';\nimport SimpleTooltip from './tooltip';\nimport { ActionRightWrapper, AfterIconWrapper, BeforeIconWrapper, InputNumber, Root, Track, ThumbWrapper, Thumb, Wrapper } from './styles/range-control-styles';\nimport { space } from '../utils/space';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Computes the value that `RangeControl` should reset to when pressing\n * the reset button.\n */\nfunction computeResetValue({\n resetFallbackValue,\n initialPosition\n}) {\n if (resetFallbackValue !== undefined) {\n return !Number.isNaN(resetFallbackValue) ? resetFallbackValue : null;\n }\n if (initialPosition !== undefined) {\n return !Number.isNaN(initialPosition) ? initialPosition : null;\n }\n return null;\n}\nfunction UnforwardedRangeControl(props, forwardedRef) {\n const {\n // Prevent passing legacy props to internal component.\n __nextHasNoMarginBottom: _,\n __next40pxDefaultSize: _next40pxDefaultSize,\n afterIcon,\n allowReset = false,\n beforeIcon,\n className,\n color: colorProp = COLORS.theme.accent,\n currentInput,\n disabled = false,\n help,\n hideLabelFromVision = false,\n initialPosition,\n isShiftStepEnabled = true,\n label,\n marks = false,\n max = 100,\n min = 0,\n onBlur = noop,\n onChange = noop,\n onFocus = noop,\n onMouseLeave = noop,\n onMouseMove = noop,\n railColor,\n renderTooltipContent = v => v,\n resetFallbackValue,\n shiftStep = 10,\n showTooltip: showTooltipProp,\n step = 1,\n trackColor,\n value: valueProp,\n withInputField = true,\n ...otherProps\n } = props;\n const [value, setValue] = useControlledRangeValue({\n min,\n max,\n value: valueProp ?? null,\n initial: initialPosition\n });\n const isResetPendent = useRef(false);\n let hasTooltip = showTooltipProp;\n let hasInputField = withInputField;\n if (step === 'any') {\n // The tooltip and number input field are hidden when the step is \"any\"\n // because the decimals get too lengthy to fit well.\n hasTooltip = false;\n hasInputField = false;\n }\n const [showTooltip, setShowTooltip] = useState(hasTooltip);\n const [isFocused, setIsFocused] = useState(false);\n const inputRef = useRef(null);\n const isCurrentlyFocused = inputRef.current?.matches(':focus');\n const isThumbFocused = !disabled && isFocused;\n const isValueReset = value === null;\n const currentValue = value !== undefined ? value : currentInput;\n const inputSliderValue = isValueReset ? '' : currentValue;\n const rangeFillValue = isValueReset ? (max - min) / 2 + min : value;\n const fillValue = isValueReset ? 50 : (value - min) / (max - min) * 100;\n const fillValueOffset = `${clamp(fillValue, 0, 100)}%`;\n const classes = clsx('components-range-control', className);\n const wrapperClasses = clsx('components-range-control__wrapper', !!marks && 'is-marked');\n const id = useInstanceId(UnforwardedRangeControl, 'inspector-range-control');\n const describedBy = !!help ? `${id}__help` : undefined;\n const enableTooltip = hasTooltip !== false && Number.isFinite(value);\n const handleOnRangeChange = event => {\n const nextValue = parseFloat(event.target.value);\n setValue(nextValue);\n onChange(nextValue);\n };\n const handleOnChange = next => {\n // @ts-expect-error TODO: Investigate if it's problematic for setValue() to\n // potentially receive a NaN when next is undefined.\n let nextValue = parseFloat(next);\n setValue(nextValue);\n\n /*\n * Calls onChange only when nextValue is numeric\n * otherwise may queue a reset for the blur event.\n */\n if (!isNaN(nextValue)) {\n if (nextValue < min || nextValue > max) {\n nextValue = floatClamp(nextValue, min, max);\n }\n onChange(nextValue);\n isResetPendent.current = false;\n } else if (allowReset) {\n isResetPendent.current = true;\n }\n };\n const handleOnInputNumberBlur = () => {\n if (isResetPendent.current) {\n handleOnReset();\n isResetPendent.current = false;\n }\n };\n const handleOnReset = () => {\n // Reset to `resetFallbackValue` if defined, otherwise set internal value\n // to `null` — which, if propagated to the `value` prop, will cause\n // the value to be reset to the `initialPosition` prop if defined.\n const resetValue = Number.isNaN(resetFallbackValue) ? null : resetFallbackValue ?? null;\n setValue(resetValue);\n\n /**\n * Previously, this callback would always receive undefined as\n * an argument. This behavior is unexpected, specifically\n * when resetFallbackValue is defined.\n *\n * The value of undefined is not ideal. Passing it through\n * to internal <input /> elements would change it from a\n * controlled component to an uncontrolled component.\n *\n * For now, to minimize unexpected regressions, we're going to\n * preserve the undefined callback argument, except when a\n * resetFallbackValue is defined.\n */\n onChange(resetValue ?? undefined);\n };\n const handleShowTooltip = () => setShowTooltip(true);\n const handleHideTooltip = () => setShowTooltip(false);\n const handleOnBlur = event => {\n onBlur(event);\n setIsFocused(false);\n handleHideTooltip();\n };\n const handleOnFocus = event => {\n onFocus(event);\n setIsFocused(true);\n handleShowTooltip();\n };\n const offsetStyle = {\n [isRTL() ? 'right' : 'left']: fillValueOffset\n };\n return /*#__PURE__*/_jsx(BaseControl, {\n className: classes,\n label: label,\n hideLabelFromVision: hideLabelFromVision,\n id: `${id}`,\n help: help,\n children: /*#__PURE__*/_jsxs(Root, {\n className: \"components-range-control__root\",\n children: [beforeIcon && /*#__PURE__*/_jsx(BeforeIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: beforeIcon\n })\n }), /*#__PURE__*/_jsxs(Wrapper, {\n className: wrapperClasses,\n color: colorProp,\n marks: !!marks,\n children: [/*#__PURE__*/_jsx(InputRange, {\n ...otherProps,\n className: \"components-range-control__slider\",\n describedBy: describedBy,\n disabled: disabled,\n id: `${id}`,\n label: label,\n max: max,\n min: min,\n onBlur: handleOnBlur,\n onChange: handleOnRangeChange,\n onFocus: handleOnFocus,\n onMouseMove: onMouseMove,\n onMouseLeave: onMouseLeave,\n ref: useMergeRefs([inputRef, forwardedRef]),\n step: step,\n value: inputSliderValue ?? undefined\n }), /*#__PURE__*/_jsx(RangeRail, {\n \"aria-hidden\": true,\n disabled: disabled,\n marks: marks,\n max: max,\n min: min,\n railColor: railColor,\n step: step,\n value: rangeFillValue\n }), /*#__PURE__*/_jsx(Track, {\n \"aria-hidden\": true,\n className: \"components-range-control__track\",\n disabled: disabled,\n style: {\n width: fillValueOffset\n },\n trackColor: trackColor\n }), /*#__PURE__*/_jsx(ThumbWrapper, {\n className: \"components-range-control__thumb-wrapper\",\n style: offsetStyle,\n disabled: disabled,\n children: /*#__PURE__*/_jsx(Thumb, {\n \"aria-hidden\": true,\n isFocused: isThumbFocused,\n disabled: disabled\n })\n }), enableTooltip && /*#__PURE__*/_jsx(SimpleTooltip, {\n className: \"components-range-control__tooltip\",\n inputRef: inputRef,\n tooltipPlacement: \"bottom\",\n renderTooltipContent: renderTooltipContent,\n show: isCurrentlyFocused || showTooltip,\n style: offsetStyle,\n value: value\n })]\n }), afterIcon && /*#__PURE__*/_jsx(AfterIconWrapper, {\n children: /*#__PURE__*/_jsx(Icon, {\n icon: afterIcon\n })\n }), hasInputField && /*#__PURE__*/_jsx(InputNumber, {\n \"aria-label\": label,\n className: \"components-range-control__number\",\n disabled: disabled,\n inputMode: \"decimal\",\n isShiftStepEnabled: isShiftStepEnabled,\n max: max,\n min: min,\n onBlur: handleOnInputNumberBlur,\n onChange: handleOnChange,\n shiftStep: shiftStep,\n __unstableInputWidth: space(20),\n step: step\n // @ts-expect-error TODO: Investigate if the `null` value is necessary\n ,\n value: inputSliderValue\n }), allowReset && /*#__PURE__*/_jsx(ActionRightWrapper, {\n children: /*#__PURE__*/_jsx(Button, {\n className: \"components-range-control__reset\"\n // If the RangeControl itself is disabled, the reset button shouldn't be in the tab sequence.\n ,\n accessibleWhenDisabled: !disabled\n // The reset button should be disabled if RangeControl itself is disabled,\n // or if the current `value` is equal to the value that would be currently\n // assigned when clicking the button.\n ,\n disabled: disabled || value === computeResetValue({\n resetFallbackValue,\n initialPosition\n }),\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n children: __('Reset')\n })\n })]\n })\n });\n}\n\n/**\n * RangeControls are used to make selections from a range of incremental values.\n *\n * ```jsx\n * import { RangeControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyRangeControl = () => {\n * const [ value, setValue ] = useState();\n * return (\n * <RangeControl\n * help=\"Please select how transparent you would like this.\"\n * initialPosition={ 50 }\n * label=\"Opacity\"\n * max={ 100 }\n * min={ 0 }\n * value={ value }\n * onChange={ setValue }\n * />\n * );\n * };\n * ```\n */\nexport const RangeControl = forwardRef(UnforwardedRangeControl);\nRangeControl.displayName = 'RangeControl';\nexport default RangeControl;"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAIjB,SAAS,IAAI,aAAa;AAC1B,SAAS,QAAQ,UAAU,kBAAkB;AAC7C,SAAS,eAAe,oBAAoB;AAK5C,OAAO,iBAAiB;AACxB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY,+BAA+B;AACpD,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,mBAAmB;AAC1B,SAAS,oBAAoB,kBAAkB,mBAAmB,aAAa,MAAM,OAAO,cAAc,OAAO,eAAe;AAChI,SAAS,aAAa;AACtB,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAAG;AACD,MAAI,uBAAuB,QAAW;AACpC,WAAO,CAAC,OAAO,MAAM,kBAAkB,IAAI,qBAAqB;AAAA,EAClE;AACA,MAAI,oBAAoB,QAAW;AACjC,WAAO,CAAC,OAAO,MAAM,eAAe,IAAI,kBAAkB;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,wBAAwB,OAAO,cAAc;AACpD,QAAM;AAAA;AAAA,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AK,eAAe;AAAA,UACpD,WAAW;AAAA,UACX;AAAA,UACA,kBAAkB;AAAA,UAClB;AAAA,UACA,MAAM,sBAAsB;AAAA,UAC5B,OAAO;AAAA,UACP;AAAA,QACF,CAAC,CAAC;AAAA,MACJ,CAAC,GAAG,aAA0B,qBAAK,kBAAkB;AAAA,QACnD,UAAuB,qBAAK,MAAM;AAAA,UAChC,MAAM;AAAA,QACR,CAAC;AAAA,MACH,CAAC,GAAG,iBAA8B,qBAAK,aAAa;AAAA,QAClD,cAAc;AAAA,QACd,WAAW;AAAA,QACX;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA,QAAQ;AAAA,QACR,UAAU;AAAA,QACV;AAAA,QACA,sBAAsB,MAAM,EAAE;AAAA,QAC9B;AAAA,QAGA,OAAO;AAAA,MACT,CAAC,GAAG,cAA2B,qBAAK,oBAAoB;AAAA,QACtD,UAAuB,qBAAK,QAAQ;AAAA,UAClC,WAAW;AAAA,UAGX,wBAAwB,CAAC;AAAA,UAKzB,UAAU,YAAY,UAAU,kBAAkB;AAAA,YAChD;AAAA,YACA;AAAA,UACF,CAAC;AAAA,UACD,SAAS;AAAA,UACT,MAAM;AAAA,UACN,SAAS;AAAA,UACT,UAAU,GAAG,OAAO;AAAA,QACtB,CAAC;AAAA,MACH,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA,EACH,CAAC;AACH;AAyBO,IAAM,eAAe,WAAW,uBAAuB;AAC9D,aAAa,cAAc;AAC3B,IAAO,wBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// packages/components/src/sandbox/index.tsx
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import { renderToString, useRef, useState, useEffect, useMemo } from "@wordpress/element";
|
|
3
4
|
import { useFocusableIframe, useMergeRefs } from "@wordpress/compose";
|
|
4
5
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -7,10 +8,13 @@ var observeAndResizeJS = function() {
|
|
|
7
8
|
const {
|
|
8
9
|
MutationObserver
|
|
9
10
|
} = window;
|
|
10
|
-
if (!MutationObserver || !
|
|
11
|
+
if (!MutationObserver || !window.parent) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
function sendResize() {
|
|
15
|
+
if (!document.body) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
const clientBoundingRect = document.body.getBoundingClientRect();
|
|
15
19
|
window.parent.postMessage({
|
|
16
20
|
action: "resize",
|
|
@@ -18,34 +22,53 @@ var observeAndResizeJS = function() {
|
|
|
18
22
|
height: clientBoundingRect.height
|
|
19
23
|
}, "*");
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
function connect() {
|
|
26
|
+
const {
|
|
27
|
+
body
|
|
28
|
+
} = document;
|
|
29
|
+
if (!body) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const observer = new MutationObserver(sendResize);
|
|
33
|
+
observer.observe(body, {
|
|
34
|
+
attributes: true,
|
|
35
|
+
attributeOldValue: false,
|
|
36
|
+
characterData: true,
|
|
37
|
+
characterDataOldValue: false,
|
|
38
|
+
childList: true,
|
|
39
|
+
subtree: true
|
|
40
|
+
});
|
|
41
|
+
function removeViewportStyles(ruleOrNode) {
|
|
42
|
+
if (ruleOrNode.style) {
|
|
43
|
+
["width", "height", "minHeight", "maxHeight"].forEach(function(style2) {
|
|
44
|
+
if (/^\d*\.?\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style2])) {
|
|
45
|
+
ruleOrNode.style[style2] = "";
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
38
49
|
}
|
|
50
|
+
Array.prototype.forEach.call(document.querySelectorAll("[style]"), removeViewportStyles);
|
|
51
|
+
Array.prototype.forEach.call(document.styleSheets, function(stylesheet) {
|
|
52
|
+
let rules;
|
|
53
|
+
try {
|
|
54
|
+
rules = stylesheet.cssRules || stylesheet.rules;
|
|
55
|
+
} catch {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
Array.prototype.forEach.call(rules, removeViewportStyles);
|
|
59
|
+
});
|
|
60
|
+
body.style.position = "absolute";
|
|
61
|
+
body.style.width = "100%";
|
|
62
|
+
body.setAttribute("data-resizable-iframe-connected", "");
|
|
63
|
+
sendResize();
|
|
39
64
|
}
|
|
40
|
-
|
|
41
|
-
Array.prototype.forEach.call(document.styleSheets, function(stylesheet) {
|
|
42
|
-
Array.prototype.forEach.call(stylesheet.cssRules || stylesheet.rules, removeViewportStyles);
|
|
43
|
-
});
|
|
44
|
-
document.body.style.position = "absolute";
|
|
45
|
-
document.body.style.width = "100%";
|
|
46
|
-
document.body.setAttribute("data-resizable-iframe-connected", "");
|
|
47
|
-
sendResize();
|
|
65
|
+
window.addEventListener("load", sendResize, true);
|
|
48
66
|
window.addEventListener("resize", sendResize, true);
|
|
67
|
+
if (document.body) {
|
|
68
|
+
connect();
|
|
69
|
+
} else {
|
|
70
|
+
document.addEventListener("DOMContentLoaded", connect);
|
|
71
|
+
}
|
|
49
72
|
};
|
|
50
73
|
var style = `
|
|
51
74
|
body {
|
|
@@ -74,10 +97,11 @@ function buildSandBoxDocument({
|
|
|
74
97
|
title,
|
|
75
98
|
type,
|
|
76
99
|
styles,
|
|
77
|
-
scripts
|
|
100
|
+
scripts,
|
|
101
|
+
lang
|
|
78
102
|
}) {
|
|
79
103
|
const htmlDoc = /* @__PURE__ */ _jsxs("html", {
|
|
80
|
-
lang
|
|
104
|
+
lang,
|
|
81
105
|
className: type,
|
|
82
106
|
children: [/* @__PURE__ */ _jsxs("head", {
|
|
83
107
|
children: [/* @__PURE__ */ _jsx("title", {
|
|
@@ -90,7 +114,12 @@ function buildSandBoxDocument({
|
|
|
90
114
|
dangerouslySetInnerHTML: {
|
|
91
115
|
__html: rules
|
|
92
116
|
}
|
|
93
|
-
}, i))
|
|
117
|
+
}, i)), /* @__PURE__ */ _jsx("script", {
|
|
118
|
+
type: "text/javascript",
|
|
119
|
+
dangerouslySetInnerHTML: {
|
|
120
|
+
__html: `(${observeAndResizeJS.toString()})();`
|
|
121
|
+
}
|
|
122
|
+
})]
|
|
94
123
|
}), /* @__PURE__ */ _jsxs("body", {
|
|
95
124
|
"data-resizable-iframe-connected": "data-resizable-iframe-connected",
|
|
96
125
|
className: type,
|
|
@@ -98,11 +127,6 @@ function buildSandBoxDocument({
|
|
|
98
127
|
dangerouslySetInnerHTML: {
|
|
99
128
|
__html: html
|
|
100
129
|
}
|
|
101
|
-
}), /* @__PURE__ */ _jsx("script", {
|
|
102
|
-
type: "text/javascript",
|
|
103
|
-
dangerouslySetInnerHTML: {
|
|
104
|
-
__html: `(${observeAndResizeJS.toString()})();`
|
|
105
|
-
}
|
|
106
130
|
}), scripts.map((src) => /* @__PURE__ */ _jsx("script", {
|
|
107
131
|
src
|
|
108
132
|
}, src))]
|
|
@@ -117,17 +141,25 @@ function IsolatedSandBox({
|
|
|
117
141
|
styles = [],
|
|
118
142
|
scripts = [],
|
|
119
143
|
onFocus,
|
|
120
|
-
tabIndex
|
|
144
|
+
tabIndex,
|
|
145
|
+
allowPopups = false
|
|
121
146
|
}) {
|
|
122
147
|
const ref = useRef(null);
|
|
123
148
|
const [width, setWidth] = useState(0);
|
|
124
149
|
const [height, setHeight] = useState(0);
|
|
150
|
+
const sandbox = clsx("allow-scripts", "allow-presentation", {
|
|
151
|
+
"allow-popups": allowPopups
|
|
152
|
+
});
|
|
125
153
|
const srcDoc = useMemo(() => buildSandBoxDocument({
|
|
126
154
|
html,
|
|
127
155
|
title,
|
|
128
156
|
type,
|
|
129
157
|
styles,
|
|
130
|
-
scripts
|
|
158
|
+
scripts,
|
|
159
|
+
// Read inside the memo: the `no-dom-globals-in-react-fc` lint
|
|
160
|
+
// rule forbids DOM globals in the render body. `lang` rarely
|
|
161
|
+
// changes after load, so leaving it out of the deps is fine.
|
|
162
|
+
lang: document.documentElement.lang
|
|
131
163
|
}), [html, title, type, styles, scripts]);
|
|
132
164
|
useEffect(() => {
|
|
133
165
|
const iframe = ref.current;
|
|
@@ -173,7 +205,7 @@ function IsolatedSandBox({
|
|
|
173
205
|
title,
|
|
174
206
|
tabIndex,
|
|
175
207
|
className: "components-sandbox",
|
|
176
|
-
sandbox
|
|
208
|
+
sandbox,
|
|
177
209
|
srcDoc,
|
|
178
210
|
onFocus,
|
|
179
211
|
width: Math.ceil(width),
|
|
@@ -187,11 +219,15 @@ function SameOriginSandBox({
|
|
|
187
219
|
styles = [],
|
|
188
220
|
scripts = [],
|
|
189
221
|
onFocus,
|
|
190
|
-
tabIndex
|
|
222
|
+
tabIndex,
|
|
223
|
+
allowPopups = false
|
|
191
224
|
}) {
|
|
192
225
|
const ref = useRef(null);
|
|
193
226
|
const [width, setWidth] = useState(0);
|
|
194
227
|
const [height, setHeight] = useState(0);
|
|
228
|
+
const sandbox = clsx("allow-scripts", "allow-same-origin", "allow-presentation", {
|
|
229
|
+
"allow-popups": allowPopups
|
|
230
|
+
});
|
|
195
231
|
function isFrameAccessible() {
|
|
196
232
|
try {
|
|
197
233
|
return !!ref.current?.contentDocument?.body;
|
|
@@ -210,40 +246,15 @@ function SameOriginSandBox({
|
|
|
210
246
|
if (!forceRerender && null !== contentDocument?.body.getAttribute("data-resizable-iframe-connected")) {
|
|
211
247
|
return;
|
|
212
248
|
}
|
|
213
|
-
const htmlDoc = /* @__PURE__ */ _jsxs("html", {
|
|
214
|
-
lang: ownerDocument.documentElement.lang,
|
|
215
|
-
className: type,
|
|
216
|
-
children: [/* @__PURE__ */ _jsxs("head", {
|
|
217
|
-
children: [/* @__PURE__ */ _jsx("title", {
|
|
218
|
-
children: title
|
|
219
|
-
}), /* @__PURE__ */ _jsx("style", {
|
|
220
|
-
dangerouslySetInnerHTML: {
|
|
221
|
-
__html: style
|
|
222
|
-
}
|
|
223
|
-
}), styles.map((rules, i) => /* @__PURE__ */ _jsx("style", {
|
|
224
|
-
dangerouslySetInnerHTML: {
|
|
225
|
-
__html: rules
|
|
226
|
-
}
|
|
227
|
-
}, i))]
|
|
228
|
-
}), /* @__PURE__ */ _jsxs("body", {
|
|
229
|
-
"data-resizable-iframe-connected": "data-resizable-iframe-connected",
|
|
230
|
-
className: type,
|
|
231
|
-
children: [/* @__PURE__ */ _jsx("div", {
|
|
232
|
-
dangerouslySetInnerHTML: {
|
|
233
|
-
__html: html
|
|
234
|
-
}
|
|
235
|
-
}), /* @__PURE__ */ _jsx("script", {
|
|
236
|
-
type: "text/javascript",
|
|
237
|
-
dangerouslySetInnerHTML: {
|
|
238
|
-
__html: `(${observeAndResizeJS.toString()})();`
|
|
239
|
-
}
|
|
240
|
-
}), scripts.map((src) => /* @__PURE__ */ _jsx("script", {
|
|
241
|
-
src
|
|
242
|
-
}, src))]
|
|
243
|
-
})]
|
|
244
|
-
});
|
|
245
249
|
contentDocument.open();
|
|
246
|
-
contentDocument.write(
|
|
250
|
+
contentDocument.write(buildSandBoxDocument({
|
|
251
|
+
html,
|
|
252
|
+
title,
|
|
253
|
+
type,
|
|
254
|
+
styles,
|
|
255
|
+
scripts,
|
|
256
|
+
lang: ownerDocument.documentElement.lang
|
|
257
|
+
}));
|
|
247
258
|
contentDocument.close();
|
|
248
259
|
}
|
|
249
260
|
useEffect(() => {
|
|
@@ -289,7 +300,7 @@ function SameOriginSandBox({
|
|
|
289
300
|
title,
|
|
290
301
|
tabIndex,
|
|
291
302
|
className: "components-sandbox",
|
|
292
|
-
sandbox
|
|
303
|
+
sandbox,
|
|
293
304
|
onFocus,
|
|
294
305
|
width: Math.ceil(width),
|
|
295
306
|
height: Math.ceil(height)
|
|
@@ -311,6 +322,7 @@ function SandBox({
|
|
|
311
322
|
var sandbox_default = SandBox;
|
|
312
323
|
export {
|
|
313
324
|
VIEWPORT_UNIT_VALUE_REGEX,
|
|
325
|
+
buildSandBoxDocument,
|
|
314
326
|
sandbox_default as default
|
|
315
327
|
};
|
|
316
328
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sandbox/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect, useMemo } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Matches CSS viewport-relative length values such as `100vh`, `50.5vw`,\n * and `.5dvh`. Used to strip viewport units from user-supplied HTML inside\n * the sandbox iframe, because those units are relative to the iframe's\n * own size and would create a measurement feedback loop with the\n * resize observer.\n *\n * Exported for tests. NOTE: an identical regex literal is duplicated\n * inside `observeAndResizeJS` below because that function is serialized\n * via `.toString()` and embedded into the iframe's `srcdoc` — it has no\n * access to this module's scope at runtime. If you change one, change\n * the other; the \"is embedded in the sandbox iframe srcdoc\" test\n * guards against drift.\n */\nexport const VIEWPORT_UNIT_VALUE_REGEX = /^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/;\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !document.body || !window.parent) {\n return;\n }\n function sendResize() {\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(document.body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n window.addEventListener('load', sendResize, true);\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n Array.prototype.forEach.call(stylesheet.cssRules || stylesheet.rules, removeViewportStyles);\n });\n document.body.style.position = 'absolute';\n document.body.style.width = '100%';\n document.body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * Builds the full HTML document string for the sandbox iframe content.\n */\nfunction buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts\n}) {\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: document.documentElement.lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i))]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n return '<!DOCTYPE html>' + renderToString(htmlDoc);\n}\n\n/**\n * Isolated sandbox that uses the `srcdoc` attribute to render content\n * without `allow-same-origin`. This is the default for user-controlled\n * content (e.g., the HTML block) where same-origin access would be a\n * security risk.\n *\n * Because `srcdoc` is a declarative attribute, the browser automatically\n * re-renders the content when the iframe is moved in the DOM (e.g.,\n * block reordering), so no `load` event listener is needed.\n * The `message` listener is re-synced on every `load` so\n * it follows the iframe if it's reparented into a different document.\n */\nfunction IsolatedSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const srcDoc = useMemo(() => buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts\n }), [html, title, type, styles, scripts]);\n useEffect(() => {\n const iframe = ref.current;\n if (!iframe) {\n return;\n }\n function checkMessageForResize(event) {\n // Verify that the mounted element is the source of the message.\n // iframe.contentWindow is accessible cross-origin as a\n // WindowProxy reference, so this check still works without\n // allow-same-origin.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n let currentView = null;\n function syncListener() {\n const view = iframe?.ownerDocument?.defaultView ?? null;\n if (view === currentView) {\n return;\n }\n currentView?.removeEventListener('message', checkMessageForResize);\n currentView = view;\n currentView?.addEventListener('message', checkMessageForResize);\n }\n syncListener();\n iframe.addEventListener('load', syncListener);\n return () => {\n iframe.removeEventListener('load', syncListener);\n currentView?.removeEventListener('message', checkMessageForResize);\n };\n }, []);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: \"allow-scripts allow-presentation\",\n srcDoc: srcDoc,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * Same-origin sandbox that writes to `contentDocument` directly. This\n * preserves the parent page's URL as the iframe's document URL, which\n * provides a valid Referer header for nested iframes (required by\n * providers like YouTube).\n *\n * Only used when `allowSameOrigin` is true — i.e., for server-fetched\n * oEmbed previews that are not directly user-controlled.\n *\n * This implementation is intentionally kept close to the original\n * pre-refactor code to preserve past bugfixes:\n * - load listener for iframe re-initialization after DOM moves (#21916)\n * - forceRerender guard to avoid unnecessary full rewrites (#20176)\n */\nfunction SameOriginSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch {\n return false;\n }\n }\n function trySandBox(forceRerender = false) {\n if (!isFrameAccessible()) {\n return;\n }\n const {\n contentDocument,\n ownerDocument\n } = ref.current;\n if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {\n return;\n }\n\n // Put the html snippet into a html document, and then write it to the iframe's document\n // we can use this in the future to inject custom styles or scripts.\n // Scripts go into the body rather than the head, to support embedded content such as Instagram\n // that expect the scripts to be part of the body.\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: ownerDocument.documentElement.lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i))]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n\n // Writing the document like this makes it act in the same way as if it was\n // loaded over the network, so DOM creation and mutation, script execution, etc.\n // all work as expected.\n contentDocument.open();\n contentDocument.write('<!DOCTYPE html>' + renderToString(htmlDoc));\n contentDocument.close();\n }\n useEffect(() => {\n trySandBox();\n function tryNoForceSandBox() {\n trySandBox(false);\n }\n function checkMessageForResize(event) {\n const iframe = ref.current;\n\n // Verify that the mounted element is the source of the message.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n const iframe = ref.current;\n const defaultView = iframe?.ownerDocument?.defaultView;\n\n // This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n // after reordering the containing block. See these two issues for more details:\n // https://github.com/WordPress/gutenberg/issues/6146\n // https://github.com/facebook/react/issues/18752\n iframe?.addEventListener('load', tryNoForceSandBox, false);\n defaultView?.addEventListener('message', checkMessageForResize);\n return () => {\n iframe?.removeEventListener('load', tryNoForceSandBox, false);\n defaultView?.removeEventListener('message', checkMessageForResize);\n };\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, []);\n useEffect(() => {\n trySandBox();\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [title, styles, scripts]);\n useEffect(() => {\n trySandBox(true);\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [html, type]);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: \"allow-scripts allow-same-origin allow-presentation\",\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n allowSameOrigin = false,\n ...contentProps\n}) {\n if (allowSameOrigin) {\n return /*#__PURE__*/_jsx(SameOriginSandBox, {\n ...contentProps\n });\n }\n return /*#__PURE__*/_jsx(IsolatedSandBox, {\n ...contentProps\n });\n}\nexport default SandBox;"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,gBAAgB,QAAQ,UAAU,WAAW,eAAe;AACrE,SAAS,oBAAoB,oBAAoB;AAKjD,SAAS,OAAO,MAAM,QAAQ,aAAa;AAepC,IAAM,4BAA4B;AACzC,IAAM,qBAAqB,WAAY;AACrC,QAAM;AAAA,IACJ;AAAA,EACF,IAAI;AACJ,MAAI,CAAC,oBAAoB,CAAC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString, useRef, useState, useEffect, useMemo } from '@wordpress/element';\nimport { useFocusableIframe, useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Matches CSS viewport-relative length values such as `100vh`, `50.5vw`,\n * and `.5dvh`. Used to strip viewport units from user-supplied HTML inside\n * the sandbox iframe, because those units are relative to the iframe's\n * own size and would create a measurement feedback loop with the\n * resize observer.\n *\n * Exported for tests. NOTE: an identical regex literal is duplicated\n * inside `observeAndResizeJS` below because that function is serialized\n * via `.toString()` and embedded into the iframe's `srcdoc` — it has no\n * access to this module's scope at runtime. If you change one, change\n * the other; the \"is embedded in the sandbox iframe srcdoc\" test\n * guards against drift.\n */\nexport const VIEWPORT_UNIT_VALUE_REGEX = /^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/;\nconst observeAndResizeJS = function () {\n const {\n MutationObserver\n } = window;\n if (!MutationObserver || !window.parent) {\n return;\n }\n function sendResize() {\n // This runs in the document <head>, and as a `load`/`resize` listener,\n // so the body may not exist yet. Bail rather than throw on a null body.\n if (!document.body) {\n return;\n }\n const clientBoundingRect = document.body.getBoundingClientRect();\n window.parent.postMessage({\n action: 'resize',\n width: clientBoundingRect.width,\n height: clientBoundingRect.height\n }, '*');\n }\n\n // Runs the body-dependent setup once the document body is available. Reads\n // `document.body` into a local so the null check narrows it for the rest of\n // the function: this runs in <head> and via DOMContentLoaded, so the body\n // isn't guaranteed to exist yet.\n function connect() {\n const {\n body\n } = document;\n if (!body) {\n return;\n }\n const observer = new MutationObserver(sendResize);\n observer.observe(body, {\n attributes: true,\n attributeOldValue: false,\n characterData: true,\n characterDataOldValue: false,\n childList: true,\n subtree: true\n });\n\n // Hack: Remove viewport unit styles, as these are relative\n // the iframe root and interfere with our mechanism for\n // determining the unconstrained page bounds.\n function removeViewportStyles(ruleOrNode) {\n if (ruleOrNode.style) {\n ['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {\n if (/^\\d*\\.?\\d+(?:vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {\n ruleOrNode.style[style] = '';\n }\n });\n }\n }\n Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);\n Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {\n let rules;\n try {\n rules = stylesheet.cssRules || stylesheet.rules;\n } catch {\n // Reading `cssRules` throws a SecurityError for a\n // cross-origin stylesheet (e.g. a remote <link> in the\n // user's HTML). Skip those rather than aborting the setup.\n return;\n }\n Array.prototype.forEach.call(rules, removeViewportStyles);\n });\n body.style.position = 'absolute';\n body.style.width = '100%';\n body.setAttribute('data-resizable-iframe-connected', '');\n sendResize();\n }\n window.addEventListener('load', sendResize, true);\n\n // Resize events can change the width of elements with 100% width, but we don't\n // get an DOM mutations for that, so do the resize when the window is resized, too.\n window.addEventListener('resize', sendResize, true);\n\n // This script is injected into the document <head> so it parses before the\n // (possibly malformed) user content in <body>: an unclosed attribute quote\n // in that content can't then swallow this <script> tag and dump its source\n // into the preview as visible text. Because <head> runs before <body>\n // exists, defer the body-dependent setup until the DOM is ready.\n if (document.body) {\n connect();\n } else {\n document.addEventListener('DOMContentLoaded', connect);\n }\n};\n\n// TODO: These styles shouldn't be coupled with WordPress.\nconst style = `\n\tbody {\n\t\tmargin: 0;\n\t}\n\thtml,\n\tbody,\n\tbody > div {\n\t\twidth: 100%;\n\t}\n\thtml.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio,\n\tbody.wp-has-aspect-ratio > div,\n\tbody.wp-has-aspect-ratio > div iframe {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */\n\t}\n\tbody > div > * {\n\t\tmargin-top: 0 !important; /* Has to have !important to override inline styles. */\n\t\tmargin-bottom: 0 !important;\n\t}\n`;\n\n/**\n * Builds the full HTML document string for the sandbox iframe content. Shared\n * by both the isolated (`srcdoc`) and same-origin (`contentDocument.write`)\n * sandboxes so the two paths always emit the same markup — notably keeping the\n * resize script in `<head>`, ahead of the user content, on both. A single\n * builder means the write path cannot drift back to putting the script in\n * `<body>` while the `srcdoc` path keeps it in `<head>`.\n *\n * `lang` is passed in rather than read here because the two callers source it\n * from different documents: the isolated sandbox uses the module's `document`,\n * while the same-origin sandbox uses the iframe's `ownerDocument`. They are\n * normally the same document, but keeping the argument preserves each path's\n * exact prior behavior.\n *\n * Exported for tests.\n *\n * @param props\n * @param props.html User-supplied HTML for the iframe body.\n * @param props.title Document title.\n * @param props.type Optional class name for the `<html>`/`<body>` elements.\n * @param props.styles CSS rule strings, injected as `<style>` tags in the head.\n * @param props.scripts External script URLs, injected as `<script src>` in the\n * body (embeds expect their scripts there).\n * @param props.lang Language for the `<html lang>` attribute.\n * @return The full `<!DOCTYPE html>…` document string.\n */\nexport function buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang\n}) {\n const htmlDoc = /*#__PURE__*/_jsxs(\"html\", {\n lang: lang,\n className: type,\n children: [/*#__PURE__*/_jsxs(\"head\", {\n children: [/*#__PURE__*/_jsx(\"title\", {\n children: title\n }), /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: style\n }\n }), styles.map((rules, i) => /*#__PURE__*/_jsx(\"style\", {\n dangerouslySetInnerHTML: {\n __html: rules\n }\n }, i)), /*#__PURE__*/_jsx(\"script\", {\n type: \"text/javascript\",\n dangerouslySetInnerHTML: {\n __html: `(${observeAndResizeJS.toString()})();`\n }\n })]\n }), /*#__PURE__*/_jsxs(\"body\", {\n \"data-resizable-iframe-connected\": \"data-resizable-iframe-connected\",\n className: type,\n children: [/*#__PURE__*/_jsx(\"div\", {\n dangerouslySetInnerHTML: {\n __html: html\n }\n }), scripts.map(src => /*#__PURE__*/_jsx(\"script\", {\n src: src\n }, src))]\n })]\n });\n return '<!DOCTYPE html>' + renderToString(htmlDoc);\n}\n\n/**\n * Isolated sandbox that uses the `srcdoc` attribute to render content\n * without `allow-same-origin`. This is the default for user-controlled\n * content (e.g., the HTML block) where same-origin access would be a\n * security risk.\n *\n * Because `srcdoc` is a declarative attribute, the browser automatically\n * re-renders the content when the iframe is moved in the DOM (e.g.,\n * block reordering), so no `load` event listener is needed.\n * The `message` listener is re-synced on every `load` so\n * it follows the iframe if it's reparented into a different document.\n */\nfunction IsolatedSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex,\n allowPopups = false\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const sandbox = clsx('allow-scripts', 'allow-presentation', {\n 'allow-popups': allowPopups\n });\n const srcDoc = useMemo(() => buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n // Read inside the memo: the `no-dom-globals-in-react-fc` lint\n // rule forbids DOM globals in the render body. `lang` rarely\n // changes after load, so leaving it out of the deps is fine.\n lang: document.documentElement.lang\n }), [html, title, type, styles, scripts]);\n useEffect(() => {\n const iframe = ref.current;\n if (!iframe) {\n return;\n }\n function checkMessageForResize(event) {\n // Verify that the mounted element is the source of the message.\n // iframe.contentWindow is accessible cross-origin as a\n // WindowProxy reference, so this check still works without\n // allow-same-origin.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n let currentView = null;\n function syncListener() {\n const view = iframe?.ownerDocument?.defaultView ?? null;\n if (view === currentView) {\n return;\n }\n currentView?.removeEventListener('message', checkMessageForResize);\n currentView = view;\n currentView?.addEventListener('message', checkMessageForResize);\n }\n syncListener();\n iframe.addEventListener('load', syncListener);\n return () => {\n iframe.removeEventListener('load', syncListener);\n currentView?.removeEventListener('message', checkMessageForResize);\n };\n }, []);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: sandbox,\n srcDoc: srcDoc,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * Same-origin sandbox that writes to `contentDocument` directly. This\n * preserves the parent page's URL as the iframe's document URL, which\n * provides a valid Referer header for nested iframes (required by\n * providers like YouTube).\n *\n * Only used when `allowSameOrigin` is true — i.e., for server-fetched\n * oEmbed previews that are not directly user-controlled.\n *\n * This implementation is intentionally kept close to the original\n * pre-refactor code to preserve past bugfixes:\n * - load listener for iframe re-initialization after DOM moves (#21916)\n * - forceRerender guard to avoid unnecessary full rewrites (#20176)\n */\nfunction SameOriginSandBox({\n html = '',\n title = '',\n type,\n styles = [],\n scripts = [],\n onFocus,\n tabIndex,\n allowPopups = false\n}) {\n const ref = useRef(null);\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const sandbox = clsx('allow-scripts', 'allow-same-origin', 'allow-presentation', {\n 'allow-popups': allowPopups\n });\n function isFrameAccessible() {\n try {\n return !!ref.current?.contentDocument?.body;\n } catch {\n return false;\n }\n }\n function trySandBox(forceRerender = false) {\n if (!isFrameAccessible()) {\n return;\n }\n const {\n contentDocument,\n ownerDocument\n } = ref.current;\n if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {\n return;\n }\n\n // Put the html snippet into a html document, and then write it to the\n // iframe's document. The external `scripts` still go into the body to\n // support embedded content such as Instagram that expects them there;\n // only the resize helper lives in the head.\n //\n // Writing the document like this makes it act in the same way as if it\n // was loaded over the network, so DOM creation and mutation, script\n // execution, etc. all work as expected.\n contentDocument.open();\n contentDocument.write(buildSandBoxDocument({\n html,\n title,\n type,\n styles,\n scripts,\n lang: ownerDocument.documentElement.lang\n }));\n contentDocument.close();\n }\n useEffect(() => {\n trySandBox();\n function tryNoForceSandBox() {\n trySandBox(false);\n }\n function checkMessageForResize(event) {\n const iframe = ref.current;\n\n // Verify that the mounted element is the source of the message.\n if (!iframe || iframe.contentWindow !== event.source) {\n return;\n }\n\n // Attempt to parse the message data as JSON if passed as string.\n let data = event.data || {};\n if ('string' === typeof data) {\n try {\n data = JSON.parse(data);\n } catch {}\n }\n\n // Update the state only if the message is formatted as we expect,\n // i.e. as an object with a 'resize' action.\n if ('resize' !== data.action) {\n return;\n }\n setWidth(data.width);\n setHeight(data.height);\n }\n const iframe = ref.current;\n const defaultView = iframe?.ownerDocument?.defaultView;\n\n // This used to be registered using <iframe onLoad={} />, but it made the iframe blank\n // after reordering the containing block. See these two issues for more details:\n // https://github.com/WordPress/gutenberg/issues/6146\n // https://github.com/facebook/react/issues/18752\n iframe?.addEventListener('load', tryNoForceSandBox, false);\n defaultView?.addEventListener('message', checkMessageForResize);\n return () => {\n iframe?.removeEventListener('load', tryNoForceSandBox, false);\n defaultView?.removeEventListener('message', checkMessageForResize);\n };\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, []);\n useEffect(() => {\n trySandBox();\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [title, styles, scripts]);\n useEffect(() => {\n trySandBox(true);\n // Passing `exhaustive-deps` will likely involve a more detailed refactor.\n // See https://github.com/WordPress/gutenberg/pull/44378\n }, [html, type]);\n return /*#__PURE__*/_jsx(\"iframe\", {\n ref: useMergeRefs([ref, useFocusableIframe()]),\n title: title,\n tabIndex: tabIndex,\n className: \"components-sandbox\",\n sandbox: sandbox,\n onFocus: onFocus,\n width: Math.ceil(width),\n height: Math.ceil(height)\n });\n}\n\n/**\n * This component provides an isolated environment for arbitrary HTML via iframes.\n *\n * ```jsx\n * import { SandBox } from '@wordpress/components';\n *\n * const MySandBox = () => (\n * \t<SandBox html=\"<p>Content</p>\" title=\"SandBox\" type=\"embed\" />\n * );\n * ```\n */\nfunction SandBox({\n allowSameOrigin = false,\n ...contentProps\n}) {\n if (allowSameOrigin) {\n return /*#__PURE__*/_jsx(SameOriginSandBox, {\n ...contentProps\n });\n }\n return /*#__PURE__*/_jsx(IsolatedSandBox, {\n ...contentProps\n });\n}\nexport default SandBox;"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,gBAAgB,QAAQ,UAAU,WAAW,eAAe;AACrE,SAAS,oBAAoB,oBAAoB;AAKjD,SAAS,OAAO,MAAM,QAAQ,aAAa;AAepC,IAAM,4BAA4B;AACzC,IAAM,qBAAqB,WAAY;AACrC,QAAM;AAAA,IACJ;AAAA,EACF,IAAI;AACJ,MAAI,CAAC,oBAAoB,CAAC,OAAO,QAAQ;AACvC;AAAA,EACF;AACA,WAAS,aAAa;AAGpB,QAAI,CAAC,SAAS,MAAM;AAClB;AAAA,IACF;AACA,UAAM,qBAAqB,SAAS,KAAK,sBAAsB;AAC/D,WAAO,OAAO,YAAY;AAAA,MACxB,QAAQ;AAAA,MACR,OAAO,mB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ACL,CAAC;AAAA,EACH;AACA,SAAoB,qBAAK,iBAAiB;AAAA,IACxC,GAAG;AAAA,EACL,CAAC;AACH;AACA,IAAO,kBAAQ;",
|
|
6
6
|
"names": ["style", "iframe"]
|
|
7
7
|
}
|
|
@@ -6,19 +6,101 @@ import { search, closeSmall } from "@wordpress/icons";
|
|
|
6
6
|
import { forwardRef, useRef } from "@wordpress/element";
|
|
7
7
|
import deprecated from "@wordpress/deprecated";
|
|
8
8
|
import Button from "../button/index.mjs";
|
|
9
|
+
import InputControl from "../input-control/index.mjs";
|
|
10
|
+
import Icon from "../icon/index.mjs";
|
|
9
11
|
import { InputControlPrefixWrapper } from "../input-control/input-prefix-wrapper.mjs";
|
|
10
12
|
import { InputControlSuffixWrapper } from "../input-control/input-suffix-wrapper.mjs";
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
// packages/style-runtime/src/index.ts
|
|
15
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
16
|
+
function getRuntime() {
|
|
17
|
+
const globalScope = globalThis;
|
|
18
|
+
if (globalScope.__wpStyleRuntime) {
|
|
19
|
+
return globalScope.__wpStyleRuntime;
|
|
20
|
+
}
|
|
21
|
+
globalScope.__wpStyleRuntime = {
|
|
22
|
+
documents: /* @__PURE__ */ new Map(),
|
|
23
|
+
styles: /* @__PURE__ */ new Map(),
|
|
24
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
25
|
+
};
|
|
26
|
+
if (typeof document !== "undefined") {
|
|
27
|
+
registerDocument(document);
|
|
28
|
+
}
|
|
29
|
+
return globalScope.__wpStyleRuntime;
|
|
30
|
+
}
|
|
31
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
32
|
+
if (!targetDocument.head) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
36
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function injectStyle(targetDocument, hash, css) {
|
|
43
|
+
if (!targetDocument.head) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const runtime = getRuntime();
|
|
47
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
48
|
+
if (!injectedStyles) {
|
|
49
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
50
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
51
|
+
}
|
|
52
|
+
if (injectedStyles.has(hash)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
56
|
+
injectedStyles.add(hash);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const style = targetDocument.createElement("style");
|
|
60
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
61
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
62
|
+
targetDocument.head.appendChild(style);
|
|
63
|
+
injectedStyles.add(hash);
|
|
64
|
+
}
|
|
65
|
+
function registerDocument(targetDocument) {
|
|
66
|
+
const runtime = getRuntime();
|
|
67
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
68
|
+
for (const [hash, css] of runtime.styles) {
|
|
69
|
+
injectStyle(targetDocument, hash, css);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
const count = runtime.documents.get(targetDocument);
|
|
73
|
+
if (count === void 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (count <= 1) {
|
|
77
|
+
runtime.documents.delete(targetDocument);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function registerStyle(hash, css) {
|
|
84
|
+
const runtime = getRuntime();
|
|
85
|
+
runtime.styles.set(hash, css);
|
|
86
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
87
|
+
injectStyle(targetDocument, hash, css);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// packages/components/src/search-control/style.module.scss
|
|
92
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
93
|
+
registerStyle("77f847972d", "._5e6152f7430df331__input input[type=search]::-webkit-search-cancel-button,._5e6152f7430df331__input input[type=search]::-webkit-search-decoration,._5e6152f7430df331__input input[type=search]::-webkit-search-results-button,._5e6152f7430df331__input input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}._9a856163f1b1aaae__icon:dir(ltr){transform:scaleX(-1)}");
|
|
94
|
+
}
|
|
95
|
+
var style_module_default = { "input": "_5e6152f7430df331__input", "icon": "_9a856163f1b1aaae__icon" };
|
|
96
|
+
|
|
97
|
+
// packages/components/src/search-control/index.tsx
|
|
12
98
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
99
|
function SuffixItem({
|
|
14
100
|
searchRef,
|
|
15
|
-
value,
|
|
16
101
|
onChange,
|
|
17
102
|
onClose
|
|
18
103
|
}) {
|
|
19
|
-
if (!onClose && !value) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
104
|
if (onClose) {
|
|
23
105
|
deprecated("`onClose` prop in wp.components.SearchControl", {
|
|
24
106
|
since: "6.8"
|
|
@@ -58,29 +140,29 @@ function UnforwardedSearchControl({
|
|
|
58
140
|
} = restProps;
|
|
59
141
|
const searchRef = useRef(null);
|
|
60
142
|
const instanceId = useInstanceId(SearchControl, "components-search-control");
|
|
61
|
-
|
|
62
|
-
|
|
143
|
+
const hasSuffix = !!onClose || !!value;
|
|
144
|
+
return /* @__PURE__ */ _jsx(InputControl, {
|
|
63
145
|
id: instanceId,
|
|
64
146
|
hideLabelFromVision,
|
|
65
147
|
label,
|
|
66
148
|
ref: useMergeRefs([searchRef, forwardedRef]),
|
|
67
149
|
type: "search",
|
|
68
150
|
size,
|
|
69
|
-
className: clsx("components-search-control", className),
|
|
151
|
+
className: clsx(style_module_default.input, "components-search-control", className),
|
|
70
152
|
onChange: (nextValue) => onChange(nextValue ?? ""),
|
|
71
153
|
autoComplete: "off",
|
|
72
154
|
placeholder,
|
|
73
155
|
value: value ?? "",
|
|
74
156
|
prefix: /* @__PURE__ */ _jsx(InputControlPrefixWrapper, {
|
|
75
157
|
variant: "icon",
|
|
76
|
-
children: /* @__PURE__ */ _jsx(
|
|
158
|
+
children: /* @__PURE__ */ _jsx(Icon, {
|
|
159
|
+
className: style_module_default.icon,
|
|
77
160
|
icon: search,
|
|
78
161
|
fill: "currentColor"
|
|
79
162
|
})
|
|
80
163
|
}),
|
|
81
|
-
suffix: /* @__PURE__ */ _jsx(SuffixItem, {
|
|
164
|
+
suffix: hasSuffix && /* @__PURE__ */ _jsx(SuffixItem, {
|
|
82
165
|
searchRef,
|
|
83
|
-
value,
|
|
84
166
|
onChange,
|
|
85
167
|
onClose
|
|
86
168
|
}),
|