@wordpress/components 28.13.0 → 28.14.1-next.cd6172eb0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -1
- package/build/angle-picker-control/index.js +1 -1
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/autocomplete/index.js +0 -1
- package/build/autocomplete/index.js.map +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js +1 -1
- package/build/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build/border-control/border-control/component.js +2 -0
- package/build/border-control/border-control/component.js.map +1 -1
- package/build/box-control/all-input-control.js +1 -0
- package/build/box-control/all-input-control.js.map +1 -1
- package/build/box-control/axial-input-controls.js +1 -0
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/box-control/index.js +9 -2
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/input-controls.js +1 -0
- package/build/box-control/input-controls.js.map +1 -1
- package/build/box-control/types.js.map +1 -1
- package/build/clipboard-button/index.js +5 -3
- package/build/clipboard-button/index.js.map +1 -1
- package/build/color-palette/index.native.js +0 -1
- package/build/color-palette/index.native.js.map +1 -1
- package/build/color-picker/input-with-slider.js +2 -2
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/composite/item.js +0 -9
- package/build/composite/item.js.map +1 -1
- package/build/context/context-connect.js +0 -1
- package/build/context/context-connect.js.map +1 -1
- package/build/custom-gradient-picker/index.js +2 -0
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/types.js.map +1 -1
- package/build/custom-select-control/index.js +8 -0
- package/build/custom-select-control/index.js.map +1 -1
- package/build/custom-select-control/types.js.map +1 -1
- package/build/drop-zone/index.js +19 -13
- package/build/drop-zone/index.js.map +1 -1
- package/build/drop-zone/types.js.map +1 -1
- package/build/dropdown-menu/index.js +1 -0
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/duotone-picker/color-list-picker/index.js +9 -14
- package/build/duotone-picker/color-list-picker/index.js.map +1 -1
- package/build/external-link/index.js +0 -1
- package/build/external-link/index.js.map +1 -1
- package/build/font-size-picker/font-size-picker-select.js +1 -0
- package/build/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build/font-size-picker/index.js +1 -0
- package/build/font-size-picker/index.js.map +1 -1
- package/build/form-file-upload/index.js +11 -1
- package/build/form-file-upload/index.js.map +1 -1
- package/build/form-file-upload/types.js.map +1 -1
- package/build/form-token-field/index.js +6 -1
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +2 -0
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js.map +1 -1
- package/build/menu/checkbox-item.js +5 -9
- package/build/menu/checkbox-item.js.map +1 -1
- package/build/menu/group-label.js +4 -1
- package/build/menu/group-label.js.map +1 -1
- package/build/menu/group.js +4 -1
- package/build/menu/group.js.map +1 -1
- package/build/menu/item-help-text.js +5 -0
- package/build/menu/item-help-text.js.map +1 -1
- package/build/menu/item-label.js +5 -0
- package/build/menu/item-label.js.map +1 -1
- package/build/menu/item.js +4 -8
- package/build/menu/item.js.map +1 -1
- package/build/menu/radio-item.js +5 -9
- package/build/menu/radio-item.js.map +1 -1
- package/build/menu/separator.js +5 -2
- package/build/menu/separator.js.map +1 -1
- package/build/modal/aria-helper.js +0 -1
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +0 -1
- package/build/modal/index.js.map +1 -1
- package/build/number-control/index.js +8 -0
- package/build/number-control/index.js.map +1 -1
- package/build/number-control/types.js.map +1 -1
- package/build/range-control/index.js +2 -1
- package/build/range-control/index.js.map +1 -1
- package/build/resizable-box/index.js +9 -1
- package/build/resizable-box/index.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/fill.js +8 -12
- package/build/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +6 -10
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot.js +4 -10
- package/build/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/style-provider/index.js +0 -1
- package/build/style-provider/index.js.map +1 -1
- package/build/tabs/tab.js +0 -17
- package/build/tabs/tab.js.map +1 -1
- package/build/toolbar/toolbar-button/index.js +2 -0
- package/build/toolbar/toolbar-button/index.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +2 -0
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/unit-control/index.js +10 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/types.js.map +1 -1
- package/build-module/angle-picker-control/index.js +1 -1
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/autocomplete/index.js +0 -1
- package/build-module/autocomplete/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js +1 -1
- package/build-module/border-box-control/border-box-control-split-controls/component.js.map +1 -1
- package/build-module/border-control/border-control/component.js +2 -0
- package/build-module/border-control/border-control/component.js.map +1 -1
- package/build-module/box-control/all-input-control.js +1 -0
- package/build-module/box-control/all-input-control.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js +1 -0
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/box-control/index.js +9 -2
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/input-controls.js +1 -0
- package/build-module/box-control/input-controls.js.map +1 -1
- package/build-module/box-control/types.js.map +1 -1
- package/build-module/clipboard-button/index.js +5 -3
- package/build-module/clipboard-button/index.js.map +1 -1
- package/build-module/color-palette/index.native.js +0 -1
- package/build-module/color-palette/index.native.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +2 -2
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/composite/item.js +0 -9
- package/build-module/composite/item.js.map +1 -1
- package/build-module/context/context-connect.js +0 -1
- package/build-module/context/context-connect.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +2 -0
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/types.js.map +1 -1
- package/build-module/custom-select-control/index.js +8 -0
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/custom-select-control/types.js.map +1 -1
- package/build-module/drop-zone/index.js +19 -13
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/drop-zone/types.js.map +1 -1
- package/build-module/dropdown-menu/index.js +1 -0
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/duotone-picker/color-list-picker/index.js +10 -15
- package/build-module/duotone-picker/color-list-picker/index.js.map +1 -1
- package/build-module/external-link/index.js +0 -1
- package/build-module/external-link/index.js.map +1 -1
- package/build-module/font-size-picker/font-size-picker-select.js +1 -0
- package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
- package/build-module/font-size-picker/index.js +1 -0
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/form-file-upload/index.js +13 -2
- package/build-module/form-file-upload/index.js.map +1 -1
- package/build-module/form-file-upload/types.js.map +1 -1
- package/build-module/form-token-field/index.js +6 -1
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +2 -0
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js.map +1 -1
- package/build-module/menu/checkbox-item.js +5 -9
- package/build-module/menu/checkbox-item.js.map +1 -1
- package/build-module/menu/group-label.js +4 -1
- package/build-module/menu/group-label.js.map +1 -1
- package/build-module/menu/group.js +4 -1
- package/build-module/menu/group.js.map +1 -1
- package/build-module/menu/item-help-text.js +6 -1
- package/build-module/menu/item-help-text.js.map +1 -1
- package/build-module/menu/item-label.js +6 -1
- package/build-module/menu/item-label.js.map +1 -1
- package/build-module/menu/item.js +4 -8
- package/build-module/menu/item.js.map +1 -1
- package/build-module/menu/radio-item.js +5 -9
- package/build-module/menu/radio-item.js.map +1 -1
- package/build-module/menu/separator.js +5 -2
- package/build-module/menu/separator.js.map +1 -1
- package/build-module/modal/aria-helper.js +0 -1
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +0 -1
- package/build-module/modal/index.js.map +1 -1
- package/build-module/number-control/index.js +8 -0
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/number-control/types.js.map +1 -1
- package/build-module/range-control/index.js +2 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/resizable-box/index.js +9 -1
- package/build-module/resizable-box/index.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/fill.js +9 -13
- package/build-module/slot-fill/bubbles-virtually/fill.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +6 -10
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot.js +4 -10
- package/build-module/slot-fill/bubbles-virtually/slot.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/style-provider/index.js +0 -1
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/tabs/tab.js +0 -15
- package/build-module/tabs/tab.js.map +1 -1
- package/build-module/toolbar/toolbar-button/index.js +2 -0
- package/build-module/toolbar/toolbar-button/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +2 -0
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/unit-control/index.js +10 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/types.js.map +1 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/build-types/border-control/border-control/component.d.ts.map +1 -1
- package/build-types/box-control/all-input-control.d.ts.map +1 -1
- package/build-types/box-control/axial-input-controls.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts +1 -0
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/input-controls.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts +42 -6
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/styles/box-control-styles.d.ts +3 -2
- package/build-types/box-control/styles/box-control-styles.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +14 -2
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/clipboard-button/index.d.ts.map +1 -1
- package/build-types/color-picker/styles.d.ts +3 -2
- package/build-types/color-picker/styles.d.ts.map +1 -1
- package/build-types/composite/item.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/types.d.ts +6 -0
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts.map +1 -1
- package/build-types/custom-select-control/stories/index.story.d.ts.map +1 -1
- package/build-types/custom-select-control/types.d.ts +7 -0
- package/build-types/custom-select-control/types.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +8 -4
- package/build-types/date-time/time/styles.d.ts.map +1 -1
- package/build-types/drop-zone/index.d.ts +1 -1
- package/build-types/drop-zone/index.d.ts.map +1 -1
- package/build-types/drop-zone/types.d.ts +5 -0
- package/build-types/drop-zone/types.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +2 -1
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts.map +1 -1
- package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/form-file-upload/index.d.ts +2 -1
- package/build-types/form-file-upload/index.d.ts.map +1 -1
- package/build-types/form-file-upload/stories/index.story.d.ts.map +1 -1
- package/build-types/form-file-upload/types.d.ts +10 -8
- package/build-types/form-file-upload/types.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +1 -1
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/types.d.ts +6 -0
- package/build-types/gradient-picker/types.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -2
- package/build-types/menu/checkbox-item.d.ts.map +1 -1
- package/build-types/menu/group-label.d.ts.map +1 -1
- package/build-types/menu/group.d.ts.map +1 -1
- package/build-types/menu/index.d.ts.map +1 -1
- package/build-types/menu/item-help-text.d.ts.map +1 -1
- package/build-types/menu/item-label.d.ts.map +1 -1
- package/build-types/menu/item.d.ts.map +1 -1
- package/build-types/menu/radio-item.d.ts.map +1 -1
- package/build-types/menu/separator.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +2 -1
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/stories/index.story.d.ts +2 -1
- package/build-types/number-control/stories/index.story.d.ts.map +1 -1
- package/build-types/number-control/types.d.ts +7 -0
- package/build-types/number-control/types.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/index.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +2 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/fill.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +1 -1
- package/build-types/slot-fill/types.d.ts +4 -3
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/tabs/tab.d.ts +3 -0
- package/build-types/tabs/tab.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/tools-panel/stories/index.story.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts +2 -0
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/unit-control/index.d.ts +3 -2
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/stories/index.story.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +2 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +7 -0
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/angle-picker-control/index.tsx +1 -1
- package/src/border-box-control/border-box-control-split-controls/component.tsx +1 -1
- package/src/border-control/border-control/component.tsx +2 -0
- package/src/box-control/README.md +1 -0
- package/src/box-control/all-input-control.tsx +1 -0
- package/src/box-control/axial-input-controls.tsx +1 -0
- package/src/box-control/index.tsx +10 -2
- package/src/box-control/input-controls.tsx +1 -0
- package/src/box-control/stories/index.story.tsx +1 -0
- package/src/box-control/test/index.tsx +33 -26
- package/src/box-control/types.ts +71 -56
- package/src/clipboard-button/index.tsx +5 -3
- package/src/color-picker/input-with-slider.tsx +1 -1
- package/src/composite/item.tsx +1 -19
- package/src/custom-gradient-picker/index.tsx +2 -0
- package/src/custom-gradient-picker/types.ts +6 -0
- package/src/custom-select-control/README.md +2 -0
- package/src/custom-select-control/index.tsx +9 -0
- package/src/custom-select-control/stories/index.story.tsx +1 -0
- package/src/custom-select-control/test/index.tsx +13 -9
- package/src/custom-select-control/types.ts +7 -0
- package/src/drop-zone/index.tsx +21 -24
- package/src/drop-zone/types.ts +5 -0
- package/src/dropdown-menu/index.tsx +1 -0
- package/src/dropdown-menu/style.scss +1 -1
- package/src/duotone-picker/color-list-picker/index.tsx +8 -8
- package/src/duotone-picker/color-list-picker/style.scss +0 -6
- package/src/font-size-picker/font-size-picker-select.tsx +1 -0
- package/src/font-size-picker/index.tsx +1 -0
- package/src/form-file-upload/README.md +58 -48
- package/src/form-file-upload/docs-manifest.json +5 -0
- package/src/form-file-upload/index.tsx +12 -1
- package/src/form-file-upload/stories/index.story.tsx +1 -0
- package/src/form-file-upload/test/index.tsx +5 -1
- package/src/form-file-upload/types.ts +10 -8
- package/src/form-token-field/README.md +1 -0
- package/src/form-token-field/index.tsx +7 -0
- package/src/form-token-field/stories/index.story.tsx +2 -0
- package/src/form-token-field/test/index.tsx +5 -1
- package/src/gradient-picker/README.md +8 -0
- package/src/gradient-picker/index.tsx +2 -0
- package/src/gradient-picker/types.ts +6 -0
- package/src/menu/checkbox-item.tsx +9 -7
- package/src/menu/group-label.tsx +8 -1
- package/src/menu/group.tsx +8 -1
- package/src/menu/item-help-text.tsx +10 -1
- package/src/menu/item-label.tsx +10 -1
- package/src/menu/item.tsx +8 -6
- package/src/menu/radio-item.tsx +9 -7
- package/src/menu/separator.tsx +9 -2
- package/src/menu-items-choice/style.scss +1 -0
- package/src/number-control/README.md +2 -1
- package/src/number-control/index.tsx +9 -0
- package/src/number-control/stories/index.story.tsx +1 -0
- package/src/number-control/test/index.tsx +5 -1
- package/src/number-control/types.ts +7 -0
- package/src/range-control/index.tsx +1 -0
- package/src/resizable-box/index.tsx +10 -0
- package/src/resizable-box/style.scss +8 -0
- package/src/slot-fill/bubbles-virtually/fill.tsx +7 -11
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +2 -13
- package/src/slot-fill/bubbles-virtually/slot.tsx +4 -7
- package/src/slot-fill/types.ts +4 -3
- package/src/tabs/tab.tsx +0 -18
- package/src/tabs/test/index.tsx +1492 -947
- package/src/toolbar/toolbar-button/index.tsx +2 -0
- package/src/tools-panel/stories/index.story.tsx +12 -0
- package/src/tools-panel/tools-panel/README.md +4 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -0
- package/src/unit-control/README.md +3 -3
- package/src/unit-control/index.tsx +11 -1
- package/src/unit-control/stories/index.story.tsx +1 -0
- package/src/unit-control/test/index.tsx +5 -1
- package/src/unit-control/types.ts +7 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/menu/use-temporary-focus-visible-fix.js +0 -27
- package/build/menu/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-module/menu/use-temporary-focus-visible-fix.js +0 -20
- package/build-module/menu/use-temporary-focus-visible-fix.js.map +0 -1
- package/build-types/menu/use-temporary-focus-visible-fix.d.ts +0 -8
- package/build-types/menu/use-temporary-focus-visible-fix.d.ts.map +0 -1
- package/src/menu/use-temporary-focus-visible-fix.ts +0 -22
package/src/drop-zone/index.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import { __experimentalUseDropZone as useDropZone } from '@wordpress/compose';
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
|
-
import type {
|
|
18
|
+
import type { DropZoneProps } from './types';
|
|
19
19
|
import type { WordPressComponentProps } from '../context';
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -47,19 +47,22 @@ export function DropZoneComponent( {
|
|
|
47
47
|
onFilesDrop,
|
|
48
48
|
onHTMLDrop,
|
|
49
49
|
onDrop,
|
|
50
|
+
isEligible = () => true,
|
|
50
51
|
...restProps
|
|
51
52
|
}: WordPressComponentProps< DropZoneProps, 'div', false > ) {
|
|
52
53
|
const [ isDraggingOverDocument, setIsDraggingOverDocument ] =
|
|
53
54
|
useState< boolean >();
|
|
54
55
|
const [ isDraggingOverElement, setIsDraggingOverElement ] =
|
|
55
56
|
useState< boolean >();
|
|
56
|
-
const [
|
|
57
|
+
const [ isActive, setIsActive ] = useState< boolean >();
|
|
57
58
|
const ref = useDropZone( {
|
|
58
59
|
onDrop( event ) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
if ( ! event.dataTransfer ) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const files = getFilesFromDataTransfer( event.dataTransfer );
|
|
65
|
+
const html = event.dataTransfer.getData( 'text/html' );
|
|
63
66
|
|
|
64
67
|
/**
|
|
65
68
|
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
|
|
@@ -76,32 +79,31 @@ export function DropZoneComponent( {
|
|
|
76
79
|
onDragStart( event ) {
|
|
77
80
|
setIsDraggingOverDocument( true );
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
if ( ! event.dataTransfer ) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
|
|
83
88
|
* The order of the checks is important to recognize the HTML drop.
|
|
84
89
|
*/
|
|
85
|
-
if ( event.dataTransfer
|
|
86
|
-
|
|
90
|
+
if ( event.dataTransfer.types.includes( 'text/html' ) ) {
|
|
91
|
+
setIsActive( !! onHTMLDrop );
|
|
87
92
|
} else if (
|
|
88
93
|
// Check for the types because sometimes the files themselves
|
|
89
94
|
// are only available on drop.
|
|
90
|
-
event.dataTransfer
|
|
91
|
-
( event.dataTransfer
|
|
92
|
-
? getFilesFromDataTransfer( event.dataTransfer )
|
|
93
|
-
: []
|
|
94
|
-
).length > 0
|
|
95
|
+
event.dataTransfer.types.includes( 'Files' ) ||
|
|
96
|
+
getFilesFromDataTransfer( event.dataTransfer ).length > 0
|
|
95
97
|
) {
|
|
96
|
-
|
|
98
|
+
setIsActive( !! onFilesDrop );
|
|
99
|
+
} else {
|
|
100
|
+
setIsActive( !! onDrop && isEligible( event.dataTransfer ) );
|
|
97
101
|
}
|
|
98
|
-
|
|
99
|
-
setType( _type );
|
|
100
102
|
},
|
|
101
103
|
onDragEnd() {
|
|
102
104
|
setIsDraggingOverElement( false );
|
|
103
105
|
setIsDraggingOverDocument( false );
|
|
104
|
-
|
|
106
|
+
setIsActive( undefined );
|
|
105
107
|
},
|
|
106
108
|
onDragEnter() {
|
|
107
109
|
setIsDraggingOverElement( true );
|
|
@@ -112,14 +114,9 @@ export function DropZoneComponent( {
|
|
|
112
114
|
} );
|
|
113
115
|
|
|
114
116
|
const classes = clsx( 'components-drop-zone', className, {
|
|
115
|
-
'is-active':
|
|
116
|
-
( isDraggingOverDocument || isDraggingOverElement ) &&
|
|
117
|
-
( ( type === 'file' && onFilesDrop ) ||
|
|
118
|
-
( type === 'html' && onHTMLDrop ) ||
|
|
119
|
-
( type === 'default' && onDrop ) ),
|
|
117
|
+
'is-active': isActive,
|
|
120
118
|
'is-dragging-over-document': isDraggingOverDocument,
|
|
121
119
|
'is-dragging-over-element': isDraggingOverElement,
|
|
122
|
-
[ `is-dragging-${ type }` ]: !! type,
|
|
123
120
|
} );
|
|
124
121
|
|
|
125
122
|
return (
|
package/src/drop-zone/types.ts
CHANGED
|
@@ -26,4 +26,9 @@ export type DropZoneProps = {
|
|
|
26
26
|
* It receives the HTML being dropped as an argument.
|
|
27
27
|
*/
|
|
28
28
|
onHTMLDrop?: ( html: string ) => void;
|
|
29
|
+
/**
|
|
30
|
+
* A function to determine if the drop zone is eligible to handle the drop
|
|
31
|
+
* data transfer items.
|
|
32
|
+
*/
|
|
33
|
+
isEligible?: ( dataTransfer: DataTransfer ) => boolean;
|
|
29
34
|
};
|
|
@@ -164,6 +164,7 @@ function UnconnectedDropdownMenu( dropdownMenuProps: DropdownMenuProps ) {
|
|
|
164
164
|
{ controlSets?.flatMap( ( controlSet, indexOfSet ) =>
|
|
165
165
|
controlSet.map( ( control, indexOfControl ) => (
|
|
166
166
|
<Button
|
|
167
|
+
__next40pxDefaultSize
|
|
167
168
|
key={ [
|
|
168
169
|
indexOfSet,
|
|
169
170
|
indexOfControl,
|
|
@@ -12,7 +12,6 @@ import Button from '../../button';
|
|
|
12
12
|
import ColorPalette from '../../color-palette';
|
|
13
13
|
import ColorIndicator from '../../color-indicator';
|
|
14
14
|
import Icon from '../../icon';
|
|
15
|
-
import { HStack } from '../../h-stack';
|
|
16
15
|
import type { ColorListPickerProps, ColorOptionProps } from './types';
|
|
17
16
|
import { useInstanceId } from '@wordpress/compose';
|
|
18
17
|
|
|
@@ -32,23 +31,24 @@ function ColorOption( {
|
|
|
32
31
|
return (
|
|
33
32
|
<>
|
|
34
33
|
<Button
|
|
34
|
+
__next40pxDefaultSize
|
|
35
35
|
className="components-color-list-picker__swatch-button"
|
|
36
|
+
id={ labelId }
|
|
36
37
|
onClick={ () => setIsOpen( ( prev ) => ! prev ) }
|
|
37
38
|
aria-expanded={ isOpen }
|
|
38
39
|
aria-controls={ contentId }
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{ value ? (
|
|
40
|
+
icon={
|
|
41
|
+
value ? (
|
|
42
42
|
<ColorIndicator
|
|
43
43
|
colorValue={ value }
|
|
44
44
|
className="components-color-list-picker__swatch-color"
|
|
45
45
|
/>
|
|
46
46
|
) : (
|
|
47
47
|
<Icon icon={ swatch } />
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
text={ label }
|
|
51
|
+
/>
|
|
52
52
|
<div
|
|
53
53
|
role="group"
|
|
54
54
|
id={ contentId }
|
|
@@ -7,12 +7,6 @@
|
|
|
7
7
|
margin: $grid-unit-10 0;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.components-color-list-picker__swatch-button {
|
|
11
|
-
// Used to simulate styles as a .button.has-icon (which this component can't
|
|
12
|
-
// opt into, because it has to show more than a simple SVG as the "icon")
|
|
13
|
-
padding: 6px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
.components-color-list-picker__swatch-color {
|
|
17
11
|
// Match the 24px size of the `swatch` icon (used when no color is set)
|
|
18
12
|
margin: 2px;
|
|
@@ -69,6 +69,7 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
|
|
|
69
69
|
return (
|
|
70
70
|
<CustomSelectControl
|
|
71
71
|
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
72
|
+
__shouldNotWarnDeprecated36pxSize
|
|
72
73
|
className="components-font-size-picker__select"
|
|
73
74
|
label={ __( 'Font size' ) }
|
|
74
75
|
hideLabelFromVision
|
|
@@ -1,95 +1,105 @@
|
|
|
1
1
|
# FormFileUpload
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-formfileupload--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>
|
|
6
|
+
|
|
7
|
+
FormFileUpload allows users to select files from their local device.
|
|
6
8
|
|
|
7
9
|
```jsx
|
|
8
10
|
import { FormFileUpload } from '@wordpress/components';
|
|
9
11
|
|
|
10
12
|
const MyFormFileUpload = () => (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
<FormFileUpload
|
|
14
|
+
__next40pxDefaultSize
|
|
15
|
+
accept="image/*"
|
|
16
|
+
onChange={ ( event ) => console.log( event.currentTarget.files ) }
|
|
17
|
+
>
|
|
18
|
+
Upload
|
|
19
|
+
</FormFileUpload>
|
|
17
20
|
);
|
|
18
21
|
```
|
|
19
|
-
|
|
20
22
|
## Props
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
### `__next40pxDefaultSize`
|
|
25
|
+
|
|
26
|
+
Start opting into the larger default height that will become the default size in a future version.
|
|
27
|
+
|
|
28
|
+
- Type: `boolean`
|
|
29
|
+
- Required: No
|
|
30
|
+
- Default: `false`
|
|
23
31
|
|
|
24
|
-
### accept
|
|
32
|
+
### `accept`
|
|
25
33
|
|
|
26
|
-
A string passed to `input` element that tells the browser which
|
|
27
|
-
|
|
34
|
+
A string passed to the `input` element that tells the browser which
|
|
35
|
+
[file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers)
|
|
36
|
+
can be uploaded by the user. e.g: `image/*,video/*`.
|
|
28
37
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
38
|
+
- Type: `string`
|
|
39
|
+
- Required: No
|
|
31
40
|
|
|
32
|
-
### children
|
|
41
|
+
### `children`
|
|
33
42
|
|
|
34
43
|
Children are passed as children of `Button`.
|
|
35
44
|
|
|
36
|
-
-
|
|
37
|
-
-
|
|
45
|
+
- Type: `ReactNode`
|
|
46
|
+
- Required: No
|
|
38
47
|
|
|
39
|
-
### icon
|
|
48
|
+
### `icon`
|
|
40
49
|
|
|
41
|
-
The icon to render
|
|
50
|
+
The icon to render in the default button.
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
- Required: No
|
|
45
|
-
- Default: `null`
|
|
52
|
+
See the `Icon` component docs for more information.
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
- Type: `IconType`
|
|
55
|
+
- Required: No
|
|
56
|
+
|
|
57
|
+
### `multiple`
|
|
48
58
|
|
|
49
59
|
Whether to allow multiple selection of files or not.
|
|
50
60
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
61
|
+
- Type: `boolean`
|
|
62
|
+
- Required: No
|
|
63
|
+
- Default: `false`
|
|
54
64
|
|
|
55
|
-
### onChange
|
|
65
|
+
### `onChange`
|
|
56
66
|
|
|
57
67
|
Callback function passed directly to the `input` file element.
|
|
58
68
|
|
|
59
69
|
Select files will be available in `event.currentTarget.files`.
|
|
60
70
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
71
|
+
- Type: `ChangeEventHandler<HTMLInputElement>`
|
|
72
|
+
- Required: Yes
|
|
63
73
|
|
|
64
|
-
### onClick
|
|
74
|
+
### `onClick`
|
|
65
75
|
|
|
66
76
|
Callback function passed directly to the `input` file element.
|
|
67
77
|
|
|
68
|
-
This can be useful when you want to force a `change` event to fire when
|
|
78
|
+
This can be useful when you want to force a `change` event to fire when
|
|
79
|
+
the user chooses the same file again. To do this, set the target value to
|
|
80
|
+
an empty string in the `onClick` function.
|
|
69
81
|
|
|
70
82
|
```jsx
|
|
71
83
|
<FormFileUpload
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
__next40pxDefaultSize
|
|
85
|
+
onClick={ ( event ) => ( event.target.value = '' ) }
|
|
86
|
+
onChange={ onChange }
|
|
74
87
|
>
|
|
75
|
-
|
|
88
|
+
Upload
|
|
76
89
|
</FormFileUpload>
|
|
77
90
|
```
|
|
78
91
|
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
### render
|
|
92
|
+
- Type: `MouseEventHandler<HTMLInputElement>`
|
|
93
|
+
- Required: No
|
|
83
94
|
|
|
84
|
-
|
|
95
|
+
### `render`
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
- Required: No
|
|
97
|
+
Optional callback function used to render the UI.
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
If passed, the component does not render the default UI (a button) and
|
|
100
|
+
calls this function to render it. The function receives an object with
|
|
101
|
+
property `openFileDialog`, a function that, when called, opens the browser
|
|
102
|
+
native file upload modal window.
|
|
92
103
|
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
- Default: `false`
|
|
104
|
+
- Type: `(arg: { openFileDialog: () => void; }) => ReactNode`
|
|
105
|
+
- Required: No
|
|
@@ -9,15 +9,17 @@ import { useRef } from '@wordpress/element';
|
|
|
9
9
|
import Button from '../button';
|
|
10
10
|
import type { WordPressComponentProps } from '../context';
|
|
11
11
|
import type { FormFileUploadProps } from './types';
|
|
12
|
+
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* FormFileUpload
|
|
15
|
+
* FormFileUpload allows users to select files from their local device.
|
|
15
16
|
*
|
|
16
17
|
* ```jsx
|
|
17
18
|
* import { FormFileUpload } from '@wordpress/components';
|
|
18
19
|
*
|
|
19
20
|
* const MyFormFileUpload = () => (
|
|
20
21
|
* <FormFileUpload
|
|
22
|
+
* __next40pxDefaultSize
|
|
21
23
|
* accept="image/*"
|
|
22
24
|
* onChange={ ( event ) => console.log( event.currentTarget.files ) }
|
|
23
25
|
* >
|
|
@@ -40,6 +42,15 @@ export function FormFileUpload( {
|
|
|
40
42
|
ref.current?.click();
|
|
41
43
|
};
|
|
42
44
|
|
|
45
|
+
if ( ! render ) {
|
|
46
|
+
maybeWarnDeprecated36pxSize( {
|
|
47
|
+
componentName: 'FormFileUpload',
|
|
48
|
+
__next40pxDefaultSize: props.__next40pxDefaultSize,
|
|
49
|
+
// @ts-expect-error - We don't "officially" support all Button props but this likely happens.
|
|
50
|
+
size: props.size,
|
|
51
|
+
} );
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
const ui = render ? (
|
|
44
55
|
render( { openFileDialog } )
|
|
45
56
|
) : (
|
|
@@ -7,13 +7,17 @@ import userEvent from '@testing-library/user-event';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import _FormFileUpload from '..';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Browser dependencies
|
|
14
14
|
*/
|
|
15
15
|
const { File } = window;
|
|
16
16
|
|
|
17
|
+
const FormFileUpload = (
|
|
18
|
+
props: React.ComponentProps< typeof _FormFileUpload >
|
|
19
|
+
) => <_FormFileUpload __next40pxDefaultSize { ...props } />;
|
|
20
|
+
|
|
17
21
|
// @testing-library/user-event considers changing <input type="file"> to a string as a change, but it do not occur on real browsers, so the comparisons will be against this result
|
|
18
22
|
const fakePath = expect.objectContaining( {
|
|
19
23
|
target: expect.objectContaining( {
|
|
@@ -17,10 +17,9 @@ export type FormFileUploadProps = {
|
|
|
17
17
|
*/
|
|
18
18
|
__next40pxDefaultSize?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* A string passed to `input` element that tells the browser which
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers.
|
|
20
|
+
* A string passed to the `input` element that tells the browser which
|
|
21
|
+
* [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers)
|
|
22
|
+
* can be uploaded by the user. e.g: `image/*,video/*`.
|
|
24
23
|
*/
|
|
25
24
|
accept?: InputHTMLAttributes< HTMLInputElement >[ 'accept' ];
|
|
26
25
|
/**
|
|
@@ -28,7 +27,9 @@ export type FormFileUploadProps = {
|
|
|
28
27
|
*/
|
|
29
28
|
children?: ReactNode;
|
|
30
29
|
/**
|
|
31
|
-
* The icon to render in the
|
|
30
|
+
* The icon to render in the default button.
|
|
31
|
+
*
|
|
32
|
+
* See the `Icon` component docs for more information.
|
|
32
33
|
*/
|
|
33
34
|
icon?: ComponentProps< typeof Icon >[ 'icon' ];
|
|
34
35
|
/**
|
|
@@ -50,10 +51,11 @@ export type FormFileUploadProps = {
|
|
|
50
51
|
*
|
|
51
52
|
* ```jsx
|
|
52
53
|
* <FormFileUpload
|
|
53
|
-
*
|
|
54
|
-
*
|
|
54
|
+
* __next40pxDefaultSize
|
|
55
|
+
* onClick={ ( event ) => ( event.target.value = '' ) }
|
|
56
|
+
* onChange={ onChange }
|
|
55
57
|
* >
|
|
56
|
-
*
|
|
58
|
+
* Upload
|
|
57
59
|
* </FormFileUpload>
|
|
58
60
|
* ```
|
|
59
61
|
*/
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import { Spacer } from '../spacer';
|
|
31
31
|
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
|
|
32
32
|
import { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';
|
|
33
|
+
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
|
|
33
34
|
|
|
34
35
|
const identity = ( value: string ) => value;
|
|
35
36
|
|
|
@@ -86,6 +87,12 @@ export function FormTokenField( props: FormTokenFieldProps ) {
|
|
|
86
87
|
} );
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
maybeWarnDeprecated36pxSize( {
|
|
91
|
+
componentName: 'FormTokenField',
|
|
92
|
+
size: undefined,
|
|
93
|
+
__next40pxDefaultSize,
|
|
94
|
+
} );
|
|
95
|
+
|
|
89
96
|
const instanceId = useInstanceId( FormTokenField );
|
|
90
97
|
|
|
91
98
|
// We reset to these initial values again in the onBlur
|
|
@@ -64,6 +64,7 @@ Default.args = {
|
|
|
64
64
|
label: 'Type a continent',
|
|
65
65
|
suggestions: continents,
|
|
66
66
|
__nextHasNoMarginBottom: true,
|
|
67
|
+
__next40pxDefaultSize: true,
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
export const Async: StoryFn< typeof FormTokenField > = ( {
|
|
@@ -102,6 +103,7 @@ Async.args = {
|
|
|
102
103
|
label: 'Type a continent',
|
|
103
104
|
suggestions: continents,
|
|
104
105
|
__nextHasNoMarginBottom: true,
|
|
106
|
+
__next40pxDefaultSize: true,
|
|
105
107
|
};
|
|
106
108
|
|
|
107
109
|
export const DropdownSelector: StoryFn< typeof FormTokenField > =
|
|
@@ -21,7 +21,11 @@ import { useState } from '@wordpress/element';
|
|
|
21
21
|
/**
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
|
-
import
|
|
24
|
+
import _FormTokenField from '../';
|
|
25
|
+
|
|
26
|
+
const FormTokenField = ( props: ComponentProps< typeof _FormTokenField > ) => (
|
|
27
|
+
<_FormTokenField __next40pxDefaultSize { ...props } />
|
|
28
|
+
);
|
|
25
29
|
|
|
26
30
|
const FormTokenFieldWithState = ( {
|
|
27
31
|
onChange,
|
|
@@ -100,6 +100,14 @@ gradients from `gradients` will be shown.
|
|
|
100
100
|
- Required: No
|
|
101
101
|
- Default: `false`
|
|
102
102
|
|
|
103
|
+
### `enableAlpha`
|
|
104
|
+
|
|
105
|
+
Whether to enable alpha transparency options in the picker.
|
|
106
|
+
|
|
107
|
+
- Type: `boolean`
|
|
108
|
+
- Required: No
|
|
109
|
+
- Default: `true`
|
|
110
|
+
|
|
103
111
|
### `gradients`
|
|
104
112
|
|
|
105
113
|
An array of objects as predefined gradients displayed above the gradient
|
|
@@ -213,6 +213,7 @@ export function GradientPicker( {
|
|
|
213
213
|
onChange,
|
|
214
214
|
value,
|
|
215
215
|
clearable = true,
|
|
216
|
+
enableAlpha = true,
|
|
216
217
|
disableCustomGradients = false,
|
|
217
218
|
__experimentalIsRenderedInSidebar,
|
|
218
219
|
headingLevel = 2,
|
|
@@ -230,6 +231,7 @@ export function GradientPicker( {
|
|
|
230
231
|
__experimentalIsRenderedInSidebar={
|
|
231
232
|
__experimentalIsRenderedInSidebar
|
|
232
233
|
}
|
|
234
|
+
enableAlpha={ enableAlpha }
|
|
233
235
|
value={ value }
|
|
234
236
|
onChange={ onChange }
|
|
235
237
|
/>
|
|
@@ -56,6 +56,12 @@ type GradientPickerBaseProps = {
|
|
|
56
56
|
* @default true
|
|
57
57
|
*/
|
|
58
58
|
loop?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to enable alpha transparency options in the picker.
|
|
61
|
+
*
|
|
62
|
+
* @default true
|
|
63
|
+
*/
|
|
64
|
+
enableAlpha?: boolean;
|
|
59
65
|
} & (
|
|
60
66
|
| {
|
|
61
67
|
// TODO: [#54055] Either this or `aria-labelledby` should be required
|
|
@@ -16,30 +16,32 @@ import type { WordPressComponentProps } from '../context';
|
|
|
16
16
|
import { MenuContext } from './context';
|
|
17
17
|
import type { MenuCheckboxItemProps } from './types';
|
|
18
18
|
import * as Styled from './styles';
|
|
19
|
-
import { useTemporaryFocusVisibleFix } from './use-temporary-focus-visible-fix';
|
|
20
19
|
|
|
21
20
|
export const MenuCheckboxItem = forwardRef<
|
|
22
21
|
HTMLDivElement,
|
|
23
22
|
WordPressComponentProps< MenuCheckboxItemProps, 'div', false >
|
|
24
23
|
>( function MenuCheckboxItem(
|
|
25
|
-
{ suffix, children,
|
|
24
|
+
{ suffix, children, hideOnClick = false, ...props },
|
|
26
25
|
ref
|
|
27
26
|
) {
|
|
28
|
-
// TODO: Remove when https://github.com/ariakit/ariakit/issues/4083 is fixed
|
|
29
|
-
const focusVisibleFixProps = useTemporaryFocusVisibleFix( { onBlur } );
|
|
30
27
|
const menuContext = useContext( MenuContext );
|
|
31
28
|
|
|
29
|
+
if ( ! menuContext?.store ) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
'Menu.CheckboxItem can only be rendered inside a Menu component'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
32
35
|
return (
|
|
33
36
|
<Styled.MenuCheckboxItem
|
|
34
37
|
ref={ ref }
|
|
35
38
|
{ ...props }
|
|
36
|
-
{ ...focusVisibleFixProps }
|
|
37
39
|
accessibleWhenDisabled
|
|
38
40
|
hideOnClick={ hideOnClick }
|
|
39
|
-
store={ menuContext
|
|
41
|
+
store={ menuContext.store }
|
|
40
42
|
>
|
|
41
43
|
<Ariakit.MenuItemCheck
|
|
42
|
-
store={ menuContext
|
|
44
|
+
store={ menuContext.store }
|
|
43
45
|
render={ <Styled.ItemPrefixWrapper /> }
|
|
44
46
|
// Override some ariakit inline styles
|
|
45
47
|
style={ { width: 'auto', height: 'auto' } }
|
package/src/menu/group-label.tsx
CHANGED
|
@@ -17,6 +17,13 @@ export const MenuGroupLabel = forwardRef<
|
|
|
17
17
|
WordPressComponentProps< MenuGroupLabelProps, 'div', false >
|
|
18
18
|
>( function MenuGroup( props, ref ) {
|
|
19
19
|
const menuContext = useContext( MenuContext );
|
|
20
|
+
|
|
21
|
+
if ( ! menuContext?.store ) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'Menu.GroupLabel can only be rendered inside a Menu component'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
return (
|
|
21
28
|
<Styled.MenuGroupLabel
|
|
22
29
|
ref={ ref }
|
|
@@ -31,7 +38,7 @@ export const MenuGroupLabel = forwardRef<
|
|
|
31
38
|
/>
|
|
32
39
|
}
|
|
33
40
|
{ ...props }
|
|
34
|
-
store={ menuContext
|
|
41
|
+
store={ menuContext.store }
|
|
35
42
|
/>
|
|
36
43
|
);
|
|
37
44
|
} );
|
package/src/menu/group.tsx
CHANGED
|
@@ -16,11 +16,18 @@ export const MenuGroup = forwardRef<
|
|
|
16
16
|
WordPressComponentProps< MenuGroupProps, 'div', false >
|
|
17
17
|
>( function MenuGroup( props, ref ) {
|
|
18
18
|
const menuContext = useContext( MenuContext );
|
|
19
|
+
|
|
20
|
+
if ( ! menuContext?.store ) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'Menu.Group can only be rendered inside a Menu component'
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
return (
|
|
20
27
|
<Styled.MenuGroup
|
|
21
28
|
ref={ ref }
|
|
22
29
|
{ ...props }
|
|
23
|
-
store={ menuContext
|
|
30
|
+
store={ menuContext.store }
|
|
24
31
|
/>
|
|
25
32
|
);
|
|
26
33
|
} );
|