@wordpress/components 19.2.1-next.33ec3857e2.0 → 19.2.1
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 +6 -29
- package/build/angle-picker-control/index.js +0 -2
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/button/index.native.js +3 -13
- package/build/button/index.native.js.map +1 -1
- package/build/checkbox-control/index.js +1 -1
- package/build/checkbox-control/index.js.map +1 -1
- package/build/clipboard-button/index.js +2 -1
- package/build/clipboard-button/index.js.map +1 -1
- package/build/color-palette/index.js +1 -13
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-display.js +2 -4
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/hex-input.js +1 -3
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js +1 -3
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/custom-gradient-picker/index.js +0 -1
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/date-time/date.js +86 -63
- package/build/date-time/date.js.map +1 -1
- package/build/divider/component.js +7 -8
- package/build/divider/component.js.map +1 -1
- package/build/divider/styles.js +13 -38
- package/build/divider/styles.js.map +1 -1
- package/build/drop-zone/index.js +6 -14
- package/build/drop-zone/index.js.map +1 -1
- package/build/drop-zone/provider.js +0 -1
- package/build/drop-zone/provider.js.map +1 -1
- package/build/flyout/styles.js +2 -2
- package/build/flyout/styles.js.map +1 -1
- package/build/focusable-iframe/index.js +0 -1
- package/build/focusable-iframe/index.js.map +1 -1
- package/build/higher-order/with-focus-outside/index.js +0 -2
- package/build/higher-order/with-focus-outside/index.js.map +1 -1
- package/build/index.js +0 -8
- package/build/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +32 -44
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +3 -10
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +2 -4
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +6 -7
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +1 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/gridicons/index.native.js +1 -3
- package/build/mobile/gridicons/index.native.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +4 -45
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +0 -10
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/modal/aria-helper.js +0 -2
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +8 -17
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +31 -27
- package/build/palette-edit/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +9 -33
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/style-provider/index.js +0 -2
- package/build/style-provider/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +2 -7
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +14 -25
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build/tools-panel/styles.js +10 -12
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +8 -6
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +8 -6
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +41 -23
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/z-stack/component.js.map +1 -1
- package/build/z-stack/styles.js +8 -10
- package/build/z-stack/styles.js.map +1 -1
- package/build-module/angle-picker-control/index.js +0 -2
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/button/index.native.js +3 -13
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/checkbox-control/index.js +1 -1
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/clipboard-button/index.js +2 -1
- package/build-module/clipboard-button/index.js.map +1 -1
- package/build-module/color-palette/index.js +2 -14
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-display.js +2 -3
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/hex-input.js +1 -2
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +1 -2
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +0 -1
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/date-time/date.js +87 -63
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/divider/component.js +7 -8
- package/build-module/divider/component.js.map +1 -1
- package/build-module/divider/styles.js +13 -37
- package/build-module/divider/styles.js.map +1 -1
- package/build-module/drop-zone/index.js +6 -14
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/drop-zone/provider.js +0 -1
- package/build-module/drop-zone/provider.js.map +1 -1
- package/build-module/flyout/styles.js +2 -2
- package/build-module/flyout/styles.js.map +1 -1
- package/build-module/focusable-iframe/index.js +0 -1
- package/build-module/focusable-iframe/index.js.map +1 -1
- package/build-module/higher-order/with-focus-outside/index.js +0 -1
- package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
- package/build-module/index.js +0 -1
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +32 -44
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +4 -10
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +2 -4
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +6 -7
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/gridicons/index.native.js +0 -1
- package/build-module/mobile/gridicons/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +8 -50
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +0 -10
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/modal/aria-helper.js +0 -2
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +8 -15
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +30 -27
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +9 -33
- package/build-module/select-control/styles/select-control-styles.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/toggle-group-control/toggle-group-control/component.js +3 -8
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +14 -25
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build-module/tools-panel/styles.js +11 -12
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +8 -5
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +8 -6
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +41 -23
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/z-stack/component.js.map +1 -1
- package/build-module/z-stack/styles.js +8 -13
- package/build-module/z-stack/styles.js.map +1 -1
- package/build-style/style-rtl.css +11 -23
- package/build-style/style.css +11 -23
- package/build-types/base-field/hook.d.ts +16 -16
- package/build-types/card/card/hook.d.ts +16 -16
- package/build-types/card/card-body/hook.d.ts +16 -16
- package/build-types/card/card-divider/hook.d.ts +18 -18
- package/build-types/card/card-footer/hook.d.ts +17 -17
- package/build-types/card/card-header/hook.d.ts +16 -16
- package/build-types/card/card-media/hook.d.ts +16 -16
- package/build-types/divider/component.d.ts +7 -8
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +2 -2
- package/build-types/divider/styles.d.ts.map +1 -1
- package/build-types/divider/types.d.ts +5 -5
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +15 -15
- package/build-types/flex/flex/hook.d.ts +16 -16
- package/build-types/flex/flex-block/hook.d.ts +16 -16
- package/build-types/flex/flex-item/hook.d.ts +16 -16
- package/build-types/flyout/flyout/hook.d.ts +17 -17
- package/build-types/flyout/styles.d.ts +9 -7
- package/build-types/flyout/styles.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +16 -16
- package/build-types/h-stack/hook.d.ts +16 -16
- package/build-types/heading/hook.d.ts +16 -16
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +2 -1
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +1 -2
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +16 -16
- package/build-types/item-group/item-group/hook.d.ts +16 -16
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/scrollable/hook.d.ts +16 -16
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +16 -16
- package/build-types/surface/hook.d.ts +16 -16
- package/build-types/text/hook.d.ts +16 -16
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +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 +16 -16
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +16 -16
- package/build-types/ui/control-group/hook.d.ts +18 -18
- package/build-types/ui/control-label/hook.d.ts +16 -16
- package/build-types/ui/form-group/form-group.d.ts +4 -4
- package/build-types/ui/form-group/use-form-group.d.ts +55 -55
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +0 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +2 -2
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +16 -16
- package/build-types/z-stack/component.d.ts +1 -1
- package/build-types/z-stack/styles.d.ts.map +1 -1
- package/package.json +23 -21
- package/src/alignment-matrix-control/stories/index.js +1 -1
- package/src/angle-picker-control/index.js +0 -2
- package/src/base-control/stories/index.js +1 -1
- package/src/button/index.native.js +1 -15
- package/src/button/stories/index.js +1 -1
- package/src/button/style.scss +0 -14
- package/src/card/card/README.md +3 -3
- package/src/card/stories/index.js +1 -1
- package/src/card/test/__snapshots__/index.js.snap +6 -6
- package/src/checkbox-control/index.js +1 -1
- package/src/checkbox-control/stories/index.js +1 -1
- package/src/clipboard-button/index.js +2 -1
- package/src/color-indicator/stories/index.js +1 -1
- package/src/color-indicator/style.scss +8 -5
- package/src/color-palette/index.js +5 -13
- package/src/color-palette/stories/index.js +1 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +0 -1
- package/src/color-picker/color-display.tsx +2 -3
- package/src/color-picker/hex-input.tsx +1 -2
- package/src/color-picker/input-with-slider.tsx +1 -2
- package/src/color-picker/stories/index.js +1 -1
- package/src/combobox-control/README.md +2 -2
- package/src/custom-gradient-picker/index.js +0 -1
- package/src/custom-gradient-picker/style.scss +4 -0
- package/src/date-time/README.md +0 -7
- package/src/date-time/date.js +84 -67
- package/src/date-time/stories/index.js +1 -1
- package/src/date-time/stories/time.js +1 -1
- package/src/date-time/test/date.js +29 -3
- package/src/dimension-control/README.md +1 -1
- package/src/divider/README.md +5 -33
- package/src/divider/component.tsx +7 -8
- package/src/divider/stories/index.js +17 -43
- package/src/divider/styles.ts +16 -53
- package/src/divider/test/__snapshots__/index.js.snap +11 -11
- package/src/divider/test/index.js +4 -4
- package/src/divider/types.ts +5 -5
- package/src/drop-zone/index.js +6 -14
- package/src/drop-zone/provider.js +0 -1
- package/src/dropdown-menu/stories/index.js +1 -1
- package/src/duotone-picker/README.md +1 -1
- package/src/elevation/stories/index.js +1 -1
- package/src/external-link/stories/index.js +1 -1
- package/src/flyout/styles.ts +2 -4
- package/src/focusable-iframe/index.js +0 -1
- package/src/font-size-picker/stories/index.js +1 -1
- package/src/form-token-field/stories/index.js +1 -1
- package/src/gradient-picker/stories/index.js +1 -1
- package/src/grid/stories/index.js +1 -1
- package/src/guide/stories/index.js +1 -1
- package/src/higher-order/with-focus-outside/index.js +0 -2
- package/src/icon/stories/index.js +1 -1
- package/src/index.js +0 -1
- package/src/input-control/stories/index.js +1 -2
- package/src/input-control/styles/input-control-styles.tsx +6 -16
- package/src/input-control/types.ts +1 -3
- package/src/item-group/stories/index.js +2 -84
- package/src/menu-item/README.md +2 -2
- package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +2 -6
- package/src/mobile/color-settings/index.native.js +0 -2
- package/src/mobile/color-settings/palette.screen.native.js +5 -8
- package/src/mobile/color-settings/style.native.scss +1 -1
- package/src/mobile/global-styles-context/utils.native.js +1 -1
- package/src/mobile/gridicons/index.native.js +3 -3
- package/src/mobile/inserter-button/style.native.scss +0 -1
- package/src/mobile/link-picker/index.native.js +7 -41
- package/src/mobile/link-settings/index.native.js +0 -11
- package/src/modal/README.md +0 -10
- package/src/modal/aria-helper.js +0 -2
- package/src/modal/index.js +55 -72
- package/src/modal/stories/index.js +1 -6
- package/src/modal/style.scss +0 -9
- package/src/modal/test/index.js +0 -11
- package/src/navigation/README.md +9 -0
- package/src/notice/stories/index.js +1 -1
- package/src/number-control/stories/index.js +1 -1
- package/src/palette-edit/index.js +106 -73
- package/src/panel/stories/index.js +1 -1
- package/src/placeholder/stories/index.js +1 -1
- package/src/popover/stories/index.js +1 -1
- package/src/query-controls/README.md +6 -138
- package/src/radio-group/README.md +1 -4
- package/src/range-control/stories/index.js +1 -1
- package/src/resizable-box/stories/index.js +1 -1
- package/src/scrollable/stories/index.js +1 -1
- package/src/search-control/stories/index.js +1 -1
- package/src/select-control/stories/index.js +1 -2
- package/src/select-control/styles/select-control-styles.ts +2 -25
- package/src/select-control/types.ts +1 -1
- package/src/slot-fill/stories/index.js +1 -1
- package/src/snackbar/stories/index.js +1 -1
- package/src/spacer/stories/index.js +1 -1
- package/src/style-provider/index.js +0 -2
- package/src/surface/stories/index.js +1 -1
- package/src/tab-panel/stories/index.js +1 -1
- package/src/text-control/stories/index.js +1 -1
- package/src/text-highlight/stories/index.js +1 -1
- package/src/textarea-control/stories/index.js +1 -1
- package/src/tip/stories/index.js +1 -1
- package/src/toggle-control/stories/index.js +1 -1
- package/src/toggle-group-control/stories/index.js +1 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +2 -7
- package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +9 -24
- package/src/toolbar-button/stories/index.js +1 -1
- package/src/tools-panel/stories/index.js +0 -54
- package/src/tools-panel/styles.ts +1 -41
- package/src/tools-panel/test/index.js +137 -19
- package/src/tools-panel/tools-panel/README.md +3 -11
- package/src/tools-panel/tools-panel/component.tsx +5 -2
- package/src/tools-panel/tools-panel-item/hook.ts +14 -6
- package/src/tooltip/stories/index.js +1 -1
- package/src/tree-select/stories/index.js +1 -1
- package/src/truncate/stories/index.js +1 -1
- package/src/unit-control/stories/index.js +1 -19
- package/src/unit-control/styles/unit-control-styles.ts +46 -33
- package/src/unit-control/types.ts +2 -5
- package/src/z-stack/README.md +1 -1
- package/src/z-stack/component.tsx +1 -1
- package/src/z-stack/stories/index.js +1 -1
- package/src/z-stack/styles.ts +2 -7
- package/tsconfig.json +2 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/build/confirm-dialog/component.js +0 -103
- package/build/confirm-dialog/component.js.map +0 -1
- package/build/confirm-dialog/index.js +0 -16
- package/build/confirm-dialog/index.js.map +0 -1
- package/build/confirm-dialog/types.js +0 -6
- package/build/confirm-dialog/types.js.map +0 -1
- package/build/date-time/utils.js +0 -32
- package/build/date-time/utils.js.map +0 -1
- package/build-module/confirm-dialog/component.js +0 -84
- package/build-module/confirm-dialog/component.js.map +0 -1
- package/build-module/confirm-dialog/index.js +0 -6
- package/build-module/confirm-dialog/index.js.map +0 -1
- package/build-module/confirm-dialog/types.js +0 -2
- package/build-module/confirm-dialog/types.js.map +0 -1
- package/build-module/date-time/utils.js +0 -20
- package/build-module/date-time/utils.js.map +0 -1
- package/src/confirm-dialog/README.md +0 -128
- package/src/confirm-dialog/component.tsx +0 -114
- package/src/confirm-dialog/index.tsx +0 -6
- package/src/confirm-dialog/stories/index.js +0 -120
- package/src/confirm-dialog/test/index.js +0 -302
- package/src/confirm-dialog/types.ts +0 -26
- package/src/date-time/test/utils.js +0 -32
- package/src/date-time/utils.js +0 -18
- package/src/mobile/link-settings/test/edit.native.js +0 -432
package/src/tip/stories/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import useResizeAware from 'react-resize-aware';
|
|
|
12
12
|
*/
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
14
|
import { useRef, useMemo } from '@wordpress/element';
|
|
15
|
-
import { useMergeRefs, useInstanceId
|
|
15
|
+
import { useMergeRefs, useInstanceId } from '@wordpress/compose';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Internal dependencies
|
|
@@ -59,15 +59,10 @@ function ToggleGroupControl(
|
|
|
59
59
|
baseId,
|
|
60
60
|
state: value,
|
|
61
61
|
} );
|
|
62
|
-
const previousValue = usePrevious( value );
|
|
63
62
|
|
|
64
63
|
// Propagate radio.state change
|
|
65
64
|
useUpdateEffect( () => {
|
|
66
|
-
|
|
67
|
-
// from incoming value.
|
|
68
|
-
if ( previousValue !== radio.state ) {
|
|
69
|
-
onChange( radio.state );
|
|
70
|
-
}
|
|
65
|
+
onChange( radio.state );
|
|
71
66
|
}, [ radio.state ] );
|
|
72
67
|
|
|
73
68
|
// Sync incoming value with radio.state
|
|
@@ -35,36 +35,21 @@ function ToggleGroupControlBackdrop( {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} = targetNode.getBoundingClientRect();
|
|
38
|
+
const { x: parentX } = containerNode.getBoundingClientRect();
|
|
39
|
+
const { width: offsetWidth, x } = targetNode.getBoundingClientRect();
|
|
40
|
+
const borderWidth = 1;
|
|
41
|
+
const offsetLeft = x - parentX - borderWidth;
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
setLeft( offsetLeft );
|
|
44
|
+
setWidth( offsetWidth );
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
const offsetLeft = x - parentX - borderWidth;
|
|
48
|
-
|
|
49
|
-
setLeft( offsetLeft );
|
|
50
|
-
setWidth( offsetWidth );
|
|
51
|
-
};
|
|
52
|
-
// Fix to make the component appear as expected inside popovers.
|
|
53
|
-
// If the targetNode width is 0 it means the element was not yet rendered we should allow
|
|
54
|
-
// some time for the render to happen.
|
|
55
|
-
// requestAnimationFrame instead of setTimeout with a small time does not seems to work.
|
|
56
|
-
const dimensionsRequestId = window.setTimeout( computeDimensions, 100 );
|
|
57
|
-
|
|
58
|
-
let animationRequestId: number;
|
|
46
|
+
let requestId: number;
|
|
59
47
|
if ( ! canAnimate ) {
|
|
60
|
-
|
|
48
|
+
requestId = window.requestAnimationFrame( () => {
|
|
61
49
|
setCanAnimate( true );
|
|
62
50
|
} );
|
|
63
51
|
}
|
|
64
|
-
return () =>
|
|
65
|
-
window.clearTimeout( dimensionsRequestId );
|
|
66
|
-
window.cancelAnimationFrame( animationRequestId );
|
|
67
|
-
};
|
|
52
|
+
return () => window.cancelAnimationFrame( requestId );
|
|
68
53
|
}, [ canAnimate, containerRef, containerWidth, state, isAdaptiveWidth ] );
|
|
69
54
|
|
|
70
55
|
if ( ! renderBackdrop ) {
|
|
@@ -85,56 +85,6 @@ export const _default = () => {
|
|
|
85
85
|
);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
export const WithNonToolsPanelItems = () => {
|
|
89
|
-
const [ height, setHeight ] = useState();
|
|
90
|
-
const [ width, setWidth ] = useState();
|
|
91
|
-
|
|
92
|
-
const resetAll = () => {
|
|
93
|
-
setHeight( undefined );
|
|
94
|
-
setWidth( undefined );
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<PanelWrapperView>
|
|
99
|
-
<Panel>
|
|
100
|
-
<ToolsPanel
|
|
101
|
-
label="ToolsPanel (with non-menu items)"
|
|
102
|
-
resetAll={ resetAll }
|
|
103
|
-
>
|
|
104
|
-
<IntroText>
|
|
105
|
-
This text illustrates not all items must be wrapped in a
|
|
106
|
-
ToolsPanelItem and represented in the panel menu.
|
|
107
|
-
</IntroText>
|
|
108
|
-
<SingleColumnItem
|
|
109
|
-
hasValue={ () => !! width }
|
|
110
|
-
label="Width"
|
|
111
|
-
onDeselect={ () => setWidth( undefined ) }
|
|
112
|
-
isShownByDefault={ true }
|
|
113
|
-
>
|
|
114
|
-
<UnitControl
|
|
115
|
-
label="Width"
|
|
116
|
-
value={ width }
|
|
117
|
-
onChange={ ( next ) => setWidth( next ) }
|
|
118
|
-
/>
|
|
119
|
-
</SingleColumnItem>
|
|
120
|
-
<SingleColumnItem
|
|
121
|
-
hasValue={ () => !! height }
|
|
122
|
-
label="Height"
|
|
123
|
-
onDeselect={ () => setHeight( undefined ) }
|
|
124
|
-
isShownByDefault={ true }
|
|
125
|
-
>
|
|
126
|
-
<UnitControl
|
|
127
|
-
label="Height"
|
|
128
|
-
value={ height }
|
|
129
|
-
onChange={ ( next ) => setHeight( next ) }
|
|
130
|
-
/>
|
|
131
|
-
</SingleColumnItem>
|
|
132
|
-
</ToolsPanel>
|
|
133
|
-
</Panel>
|
|
134
|
-
</PanelWrapperView>
|
|
135
|
-
);
|
|
136
|
-
};
|
|
137
|
-
|
|
138
88
|
export const WithOptionalItemsPlusIcon = () => {
|
|
139
89
|
const [ height, setHeight ] = useState();
|
|
140
90
|
const [ width, setWidth ] = useState();
|
|
@@ -462,7 +412,3 @@ const PanelWrapperView = styled.div`
|
|
|
462
412
|
const SingleColumnItem = styled( ToolsPanelItem )`
|
|
463
413
|
grid-column: span 1;
|
|
464
414
|
`;
|
|
465
|
-
|
|
466
|
-
const IntroText = styled.div`
|
|
467
|
-
grid-column: span 2;
|
|
468
|
-
`;
|
|
@@ -8,11 +8,8 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
10
|
StyledField as BaseControlField,
|
|
11
|
-
StyledHelp as BaseControlHelp,
|
|
12
|
-
StyledLabel as BaseControlLabel,
|
|
13
11
|
Wrapper as BaseControlWrapper,
|
|
14
12
|
} from '../base-control/styles/base-control-styles';
|
|
15
|
-
import { LabelWrapper } from '../input-control/styles/input-control-styles';
|
|
16
13
|
import { COLORS, CONFIG } from '../utils';
|
|
17
14
|
import { space } from '../ui/utils/space';
|
|
18
15
|
|
|
@@ -72,7 +69,6 @@ export const ToolsPanelHeader = css`
|
|
|
72
69
|
*/
|
|
73
70
|
.components-dropdown-menu {
|
|
74
71
|
margin: ${ space( -1 ) } 0;
|
|
75
|
-
line-height: 0;
|
|
76
72
|
}
|
|
77
73
|
&&&& .components-dropdown-menu__toggle {
|
|
78
74
|
padding: 0;
|
|
@@ -107,46 +103,10 @@ export const ToolsPanelItem = css`
|
|
|
107
103
|
&& ${ BaseControlWrapper } {
|
|
108
104
|
margin-bottom: 0;
|
|
109
105
|
|
|
110
|
-
|
|
111
|
-
* To maintain proper spacing within a base control, the field's bottom
|
|
112
|
-
* margin should only be removed when there is no help text included and
|
|
113
|
-
* it is therefore the last-child.
|
|
114
|
-
*/
|
|
115
|
-
${ BaseControlField }:last-child {
|
|
106
|
+
${ BaseControlField } {
|
|
116
107
|
margin-bottom: 0;
|
|
117
108
|
}
|
|
118
109
|
}
|
|
119
|
-
|
|
120
|
-
${ BaseControlHelp } {
|
|
121
|
-
margin-bottom: 0;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Standardize InputControl and BaseControl labels with other labels when
|
|
126
|
-
* inside ToolsPanel.
|
|
127
|
-
*
|
|
128
|
-
* This is a temporary fix until the different control components have their
|
|
129
|
-
* labels normalized.
|
|
130
|
-
*/
|
|
131
|
-
&& ${ LabelWrapper } {
|
|
132
|
-
label {
|
|
133
|
-
margin-bottom: ${ space( 2 ) };
|
|
134
|
-
padding-bottom: 0;
|
|
135
|
-
line-height: 1.4em;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* The targeting of .components-custom-select-control__label here is a
|
|
141
|
-
* temporary measure only.
|
|
142
|
-
*
|
|
143
|
-
* It should be replaced once CustomSelectControl component has been
|
|
144
|
-
* refactored and can be targeted via component interpolation.
|
|
145
|
-
*/
|
|
146
|
-
.components-custom-select-control__label,
|
|
147
|
-
${ BaseControlLabel } {
|
|
148
|
-
line-height: 1.4em;
|
|
149
|
-
}
|
|
150
110
|
`;
|
|
151
111
|
|
|
152
112
|
export const ToolsPanelItemPlaceholder = css`
|
|
@@ -11,6 +11,7 @@ import { createSlotFill, Provider as SlotFillProvider } from '../../slot-fill';
|
|
|
11
11
|
|
|
12
12
|
const { Fill: ToolsPanelItems, Slot } = createSlotFill( 'ToolsPanelSlot' );
|
|
13
13
|
const resetAll = jest.fn();
|
|
14
|
+
const noop = () => undefined;
|
|
14
15
|
|
|
15
16
|
// Default props for the tools panel.
|
|
16
17
|
const defaultProps = {
|
|
@@ -86,6 +87,23 @@ const GroupedItems = ( {
|
|
|
86
87
|
);
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
// This context object is used to help simulate different scenarios in which
|
|
91
|
+
// `ToolsPanelItem` registration or deregistration requires testing.
|
|
92
|
+
const panelContext = {
|
|
93
|
+
panelId: '1234',
|
|
94
|
+
menuItems: {
|
|
95
|
+
default: {},
|
|
96
|
+
optional: { [ altControlProps.label ]: true },
|
|
97
|
+
},
|
|
98
|
+
hasMenuItems: false,
|
|
99
|
+
isResetting: false,
|
|
100
|
+
shouldRenderPlaceholderItems: false,
|
|
101
|
+
registerPanelItem: jest.fn(),
|
|
102
|
+
deregisterPanelItem: jest.fn(),
|
|
103
|
+
flagItemCustomization: noop,
|
|
104
|
+
areAllOptionalControlsHidden: true,
|
|
105
|
+
};
|
|
106
|
+
|
|
89
107
|
// Renders a tools panel including panel items that have been grouped within
|
|
90
108
|
// a custom component.
|
|
91
109
|
const renderGroupedItemsInPanel = () => {
|
|
@@ -499,6 +517,10 @@ describe( 'ToolsPanel', () => {
|
|
|
499
517
|
} );
|
|
500
518
|
|
|
501
519
|
describe( 'registration of panel items', () => {
|
|
520
|
+
beforeEach( () => {
|
|
521
|
+
jest.clearAllMocks();
|
|
522
|
+
} );
|
|
523
|
+
|
|
502
524
|
it( 'should register and deregister items when panelId changes', () => {
|
|
503
525
|
// This test simulates switching block selection, which causes the
|
|
504
526
|
// `ToolsPanel` to rerender with a new panelId, necessitating the
|
|
@@ -509,23 +531,7 @@ describe( 'ToolsPanel', () => {
|
|
|
509
531
|
// themselves, while those for the old panelId deregister.
|
|
510
532
|
//
|
|
511
533
|
// See: https://github.com/WordPress/gutenberg/pull/36588
|
|
512
|
-
|
|
513
|
-
const noop = () => undefined;
|
|
514
|
-
const context = {
|
|
515
|
-
panelId: '1234',
|
|
516
|
-
menuItems: {
|
|
517
|
-
default: {},
|
|
518
|
-
optional: { [ altControlProps.label ]: true },
|
|
519
|
-
},
|
|
520
|
-
hasMenuItems: false,
|
|
521
|
-
isResetting: false,
|
|
522
|
-
shouldRenderPlaceholderItems: false,
|
|
523
|
-
registerPanelItem: jest.fn(),
|
|
524
|
-
deregisterPanelItem: jest.fn(),
|
|
525
|
-
flagItemCustomization: noop,
|
|
526
|
-
areAllOptionalControlsHidden: true,
|
|
527
|
-
};
|
|
528
|
-
|
|
534
|
+
const context = { ...panelContext };
|
|
529
535
|
const TestPanel = () => (
|
|
530
536
|
<ToolsPanelContext.Provider value={ context }>
|
|
531
537
|
<ToolsPanelItem { ...altControlProps } panelId="1234">
|
|
@@ -581,6 +587,67 @@ describe( 'ToolsPanel', () => {
|
|
|
581
587
|
// deregisterPanelItem has still only been called once.
|
|
582
588
|
expect( context.deregisterPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
583
589
|
} );
|
|
590
|
+
|
|
591
|
+
it( 'should register items when ToolsPanel panelId is null', () => {
|
|
592
|
+
// This test simulates when a panel spans multiple block selections.
|
|
593
|
+
// Multi-selection means a panel can't have a single id to match
|
|
594
|
+
// against the item's. Instead the panel gets an id of `null` and
|
|
595
|
+
// individual items should still render themselves in this case.
|
|
596
|
+
//
|
|
597
|
+
// See: https://github.com/WordPress/gutenberg/pull/37216
|
|
598
|
+
const context = { ...panelContext, panelId: null };
|
|
599
|
+
const TestPanel = () => (
|
|
600
|
+
<ToolsPanelContext.Provider value={ context }>
|
|
601
|
+
<ToolsPanelItem { ...altControlProps } panelId="1234">
|
|
602
|
+
<div>Item</div>
|
|
603
|
+
</ToolsPanelItem>
|
|
604
|
+
</ToolsPanelContext.Provider>
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// On the initial render of the panel, the ToolsPanelItem should
|
|
608
|
+
// be registered.
|
|
609
|
+
const { rerender, unmount } = render( <TestPanel /> );
|
|
610
|
+
|
|
611
|
+
expect( context.registerPanelItem ).toHaveBeenCalledWith(
|
|
612
|
+
expect.objectContaining( {
|
|
613
|
+
label: altControlProps.label,
|
|
614
|
+
panelId: '1234',
|
|
615
|
+
} )
|
|
616
|
+
);
|
|
617
|
+
expect( context.deregisterPanelItem ).not.toHaveBeenCalled();
|
|
618
|
+
|
|
619
|
+
// Simulate a further block selection being added to the
|
|
620
|
+
// multi-selection. The panelId will remain `null` in this case.
|
|
621
|
+
rerender( <TestPanel /> );
|
|
622
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
623
|
+
expect( context.deregisterPanelItem ).not.toHaveBeenCalled();
|
|
624
|
+
|
|
625
|
+
// Simulate a change in panel back to single block selection for
|
|
626
|
+
// which the item matches panelId.
|
|
627
|
+
context.panelId = '1234';
|
|
628
|
+
rerender( <TestPanel /> );
|
|
629
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
630
|
+
expect( context.deregisterPanelItem ).not.toHaveBeenCalled();
|
|
631
|
+
|
|
632
|
+
// Simulate another multi-selection where the panelId is `null`.
|
|
633
|
+
// Item should re-register itself after it deregistered as the
|
|
634
|
+
// multi-selection occurred.
|
|
635
|
+
context.panelId = null;
|
|
636
|
+
rerender( <TestPanel /> );
|
|
637
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 2 );
|
|
638
|
+
expect( context.deregisterPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
639
|
+
|
|
640
|
+
// Simulate a change in panel e.g. back to a single block selection
|
|
641
|
+
// Where the item's panelId is not a match.
|
|
642
|
+
context.panelId = '4321';
|
|
643
|
+
rerender( <TestPanel /> );
|
|
644
|
+
|
|
645
|
+
// As the item no longer matches the panelId it should not have
|
|
646
|
+
// registered again but instead deregistered.
|
|
647
|
+
unmount();
|
|
648
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 2 );
|
|
649
|
+
expect( context.deregisterPanelItem ).toHaveBeenCalledTimes( 2 );
|
|
650
|
+
} );
|
|
584
651
|
} );
|
|
585
652
|
|
|
586
653
|
describe( 'callbacks on menu item selection', () => {
|
|
@@ -775,8 +842,6 @@ describe( 'ToolsPanel', () => {
|
|
|
775
842
|
// This test simulates this issue by rendering an item within a
|
|
776
843
|
// contrived `ToolsPanelContext` to reflect the changes the panel
|
|
777
844
|
// item needs to protect against.
|
|
778
|
-
|
|
779
|
-
const noop = () => undefined;
|
|
780
845
|
const context = {
|
|
781
846
|
panelId: '1234',
|
|
782
847
|
menuItems: {
|
|
@@ -821,6 +886,59 @@ describe( 'ToolsPanel', () => {
|
|
|
821
886
|
|
|
822
887
|
expect( altControlProps.onDeselect ).not.toHaveBeenCalled();
|
|
823
888
|
} );
|
|
889
|
+
|
|
890
|
+
it( 'should not contain orphaned menu items when panelId changes', async () => {
|
|
891
|
+
// As fills and the panel can update independently this aims to
|
|
892
|
+
// test that no orphaned items appear registered in the panel menu.
|
|
893
|
+
//
|
|
894
|
+
// See: https://github.com/WordPress/gutenberg/pull/34085
|
|
895
|
+
const TestSlotFillPanel = ( { panelId } ) => (
|
|
896
|
+
<SlotFillProvider>
|
|
897
|
+
<ToolsPanelItems>
|
|
898
|
+
<ToolsPanelItem { ...altControlProps } panelId="1234">
|
|
899
|
+
<div>Item 1</div>
|
|
900
|
+
</ToolsPanelItem>
|
|
901
|
+
</ToolsPanelItems>
|
|
902
|
+
<ToolsPanelItems>
|
|
903
|
+
<ToolsPanelItem { ...controlProps } panelId="9999">
|
|
904
|
+
<div>Item 2</div>
|
|
905
|
+
</ToolsPanelItem>
|
|
906
|
+
</ToolsPanelItems>
|
|
907
|
+
<ToolsPanel { ...defaultProps } panelId={ panelId }>
|
|
908
|
+
<Slot />
|
|
909
|
+
</ToolsPanel>
|
|
910
|
+
</SlotFillProvider>
|
|
911
|
+
);
|
|
912
|
+
|
|
913
|
+
const { rerender } = render( <TestSlotFillPanel panelId="1234" /> );
|
|
914
|
+
await openDropdownMenu();
|
|
915
|
+
|
|
916
|
+
// Only the item matching the panelId should have been registered
|
|
917
|
+
// and appear in the panel menu.
|
|
918
|
+
let altMenuItem = screen.getByRole( 'menuitemcheckbox', {
|
|
919
|
+
name: 'Show Alt',
|
|
920
|
+
} );
|
|
921
|
+
let exampleMenuItem = screen.queryByRole( 'menuitemcheckbox', {
|
|
922
|
+
name: 'Hide and reset Example',
|
|
923
|
+
} );
|
|
924
|
+
|
|
925
|
+
expect( altMenuItem ).toBeInTheDocument();
|
|
926
|
+
expect( exampleMenuItem ).not.toBeInTheDocument();
|
|
927
|
+
|
|
928
|
+
// Re-render the panel with different panelID simulating a block
|
|
929
|
+
// selection change.
|
|
930
|
+
rerender( <TestSlotFillPanel panelId="9999" /> );
|
|
931
|
+
|
|
932
|
+
altMenuItem = screen.queryByRole( 'menuitemcheckbox', {
|
|
933
|
+
name: 'Show Alt',
|
|
934
|
+
} );
|
|
935
|
+
exampleMenuItem = screen.getByRole( 'menuitemcheckbox', {
|
|
936
|
+
name: 'Hide and reset Example',
|
|
937
|
+
} );
|
|
938
|
+
|
|
939
|
+
expect( altMenuItem ).not.toBeInTheDocument();
|
|
940
|
+
expect( exampleMenuItem ).toBeInTheDocument();
|
|
941
|
+
} );
|
|
824
942
|
} );
|
|
825
943
|
|
|
826
944
|
describe( 'panel header icon toggle', () => {
|
|
@@ -25,11 +25,6 @@ displaying by default through the `isShownByDefault` prop. Determining whether a
|
|
|
25
25
|
child has a value is done via the `hasValue` function provided through the
|
|
26
26
|
child's props.
|
|
27
27
|
|
|
28
|
-
Components that are not wrapped within a `ToolsPanelItem` are still rendered
|
|
29
|
-
however they will not be represented within, or controlled by, the `ToolsPanel`
|
|
30
|
-
menu. An example scenario that benefits from this could be displaying
|
|
31
|
-
introduction or help text within a panel.
|
|
32
|
-
|
|
33
28
|
## Usage
|
|
34
29
|
|
|
35
30
|
```jsx
|
|
@@ -56,10 +51,6 @@ export function DimensionPanel( props ) {
|
|
|
56
51
|
|
|
57
52
|
return (
|
|
58
53
|
<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
|
|
59
|
-
<p>
|
|
60
|
-
Select dimensions or spacing related settings from the menu for
|
|
61
|
-
additional controls.
|
|
62
|
-
</p>
|
|
63
54
|
{ ! isPaddingDisabled && (
|
|
64
55
|
<ToolsPanelItem
|
|
65
56
|
hasValue={ () => hasPaddingValue( props ) }
|
|
@@ -93,8 +84,9 @@ panel's dropdown menu.
|
|
|
93
84
|
### `panelId`: `string`
|
|
94
85
|
|
|
95
86
|
If a `panelId` is set, it is passed through the `ToolsPanelContext` and used
|
|
96
|
-
to restrict panel items.
|
|
97
|
-
|
|
87
|
+
to restrict panel items. When a `panelId` is set, items can only register
|
|
88
|
+
themselves if the `panelId` is explicitly `null` or the item's `panelId` matches
|
|
89
|
+
exactly.
|
|
98
90
|
|
|
99
91
|
- Required: No
|
|
100
92
|
|
|
@@ -24,11 +24,14 @@ const ToolsPanel = (
|
|
|
24
24
|
panelContext,
|
|
25
25
|
resetAllItems,
|
|
26
26
|
toggleItem,
|
|
27
|
-
|
|
27
|
+
className,
|
|
28
28
|
} = useToolsPanel( props );
|
|
29
29
|
|
|
30
|
+
// Props are not directly passed through to avoid exposing Grid props
|
|
31
|
+
// until agreement has been reached on how ToolsPanel layout should be
|
|
32
|
+
// handled.
|
|
30
33
|
return (
|
|
31
|
-
<Grid {
|
|
34
|
+
<Grid columns={ 2 } className={ className } ref={ forwardedRef }>
|
|
32
35
|
<ToolsPanelContext.Provider value={ panelContext }>
|
|
33
36
|
<ToolsPanelHeader
|
|
34
37
|
label={ label }
|
|
@@ -40,11 +40,15 @@ export function useToolsPanelItem(
|
|
|
40
40
|
|
|
41
41
|
const hasValueCallback = useCallback( hasValue, [ panelId ] );
|
|
42
42
|
const resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );
|
|
43
|
+
const previousPanelId = usePrevious( currentPanelId );
|
|
44
|
+
|
|
45
|
+
const hasMatchingPanel =
|
|
46
|
+
currentPanelId === panelId || currentPanelId === null;
|
|
43
47
|
|
|
44
48
|
// Registering the panel item allows the panel to include it in its
|
|
45
49
|
// automatically generated menu and determine its initial checked status.
|
|
46
50
|
useEffect( () => {
|
|
47
|
-
if (
|
|
51
|
+
if ( hasMatchingPanel && previousPanelId !== null ) {
|
|
48
52
|
registerPanelItem( {
|
|
49
53
|
hasValue: hasValueCallback,
|
|
50
54
|
isShownByDefault,
|
|
@@ -55,16 +59,21 @@ export function useToolsPanelItem(
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
return () => {
|
|
58
|
-
if (
|
|
62
|
+
if (
|
|
63
|
+
( previousPanelId === null && !! currentPanelId ) ||
|
|
64
|
+
currentPanelId === panelId
|
|
65
|
+
) {
|
|
59
66
|
deregisterPanelItem( label );
|
|
60
67
|
}
|
|
61
68
|
};
|
|
62
69
|
}, [
|
|
63
70
|
currentPanelId,
|
|
64
|
-
|
|
71
|
+
hasMatchingPanel,
|
|
65
72
|
isShownByDefault,
|
|
66
73
|
label,
|
|
67
74
|
hasValueCallback,
|
|
75
|
+
panelId,
|
|
76
|
+
previousPanelId,
|
|
68
77
|
resetAllFilterCallback,
|
|
69
78
|
] );
|
|
70
79
|
|
|
@@ -88,7 +97,7 @@ export function useToolsPanelItem(
|
|
|
88
97
|
// Determine if the panel item's corresponding menu is being toggled and
|
|
89
98
|
// trigger appropriate callback if it is.
|
|
90
99
|
useEffect( () => {
|
|
91
|
-
if ( isResetting ||
|
|
100
|
+
if ( isResetting || ! hasMatchingPanel ) {
|
|
92
101
|
return;
|
|
93
102
|
}
|
|
94
103
|
|
|
@@ -100,11 +109,10 @@ export function useToolsPanelItem(
|
|
|
100
109
|
onDeselect?.();
|
|
101
110
|
}
|
|
102
111
|
}, [
|
|
103
|
-
|
|
112
|
+
hasMatchingPanel,
|
|
104
113
|
isMenuItemChecked,
|
|
105
114
|
isResetting,
|
|
106
115
|
isValueSet,
|
|
107
|
-
panelId,
|
|
108
116
|
wasMenuItemChecked,
|
|
109
117
|
] );
|
|
110
118
|
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
title: 'Components/UnitControl',
|
|
20
20
|
component: UnitControl,
|
|
21
21
|
parameters: {
|
|
22
|
-
knobs: {
|
|
22
|
+
knobs: { disabled: false },
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
@@ -45,7 +45,6 @@ function Example() {
|
|
|
45
45
|
{
|
|
46
46
|
default: 'default',
|
|
47
47
|
small: 'small',
|
|
48
|
-
'__unstable-large': '__unstable-large',
|
|
49
48
|
},
|
|
50
49
|
'default'
|
|
51
50
|
),
|
|
@@ -68,23 +67,6 @@ export const _default = () => {
|
|
|
68
67
|
return <Example />;
|
|
69
68
|
};
|
|
70
69
|
|
|
71
|
-
export const WithSingleUnit = ( props ) => {
|
|
72
|
-
const [ value, setValue ] = useState( '10px' );
|
|
73
|
-
return (
|
|
74
|
-
<ControlWrapperView>
|
|
75
|
-
<UnitControl
|
|
76
|
-
{ ...props }
|
|
77
|
-
value={ value }
|
|
78
|
-
onChange={ ( v ) => setValue( v ) }
|
|
79
|
-
/>
|
|
80
|
-
</ControlWrapperView>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
WithSingleUnit.args = {
|
|
84
|
-
label: 'Value',
|
|
85
|
-
units: CSS_UNITS.slice( 0, 1 ),
|
|
86
|
-
};
|
|
87
|
-
|
|
88
70
|
export function WithCustomUnits() {
|
|
89
71
|
const [ value, setValue ] = useState( '10km' );
|
|
90
72
|
|