@wordpress/block-editor 14.10.1 → 14.12.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 +5 -1
- package/build/components/background-image-control/index.js +0 -1
- package/build/components/background-image-control/index.js.map +1 -1
- package/build/components/block-actions/index.js +0 -3
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -11
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build/components/block-rename/modal.js +36 -11
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-rename/rename-control.js +2 -43
- package/build/components/block-rename/rename-control.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/preview.native.js +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +7 -7
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +2 -2
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
- package/build/components/block-switcher/index.js +1 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +2 -2
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -2
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -2
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +3 -3
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/grid/grid-visualizer.js +11 -19
- package/build/components/grid/grid-visualizer.js.map +1 -1
- package/build/components/grid/utils.js +6 -4
- package/build/components/grid/utils.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +1 -1
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/index.js +2 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/menu.js +13 -2
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +49 -21
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.native.js +1 -1
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +1 -1
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +1 -0
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/observe-typing/index.js +1 -1
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/provider/index.js +0 -2
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +2 -2
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/event-listeners/input-rules.js +3 -3
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build/components/rich-text/native/use-format-types.js +1 -1
- package/build/components/rich-text/native/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +1 -1
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +44 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/linked-button.js +6 -9
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +0 -108
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +39 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +3 -3
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-commands/index.js +1 -1
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +1 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/hooks/contrast-checker.js +41 -22
- package/build/hooks/contrast-checker.js.map +1 -1
- package/build/hooks/custom-class-name.js +2 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +18 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/index.js +1 -1
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-notify-copy.js +19 -11
- package/build/utils/use-notify-copy.js.map +1 -1
- package/build-module/components/background-image-control/index.js +0 -1
- package/build-module/components/background-image-control/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +0 -3
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -11
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build-module/components/block-rename/modal.js +36 -11
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-rename/rename-control.js +2 -43
- package/build-module/components/block-rename/rename-control.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +7 -7
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +2 -2
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
- package/build-module/components/block-switcher/index.js +1 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +2 -2
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +2 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +3 -3
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/grid/grid-visualizer.js +11 -19
- package/build-module/components/grid/grid-visualizer.js.map +1 -1
- package/build-module/components/grid/utils.js +6 -4
- package/build-module/components/grid/utils.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/index.js +3 -2
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/menu.js +13 -2
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +51 -23
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +1 -1
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +1 -1
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +6 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +1 -0
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +1 -1
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/provider/index.js +0 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +2 -2
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js +3 -3
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/native/use-format-types.js +1 -1
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +1 -1
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +45 -1
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/linked-button.js +7 -10
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +0 -104
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +39 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +1 -1
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +1 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/hooks/contrast-checker.js +42 -23
- package/build-module/hooks/contrast-checker.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +2 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +18 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +1 -1
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-notify-copy.js +19 -11
- package/build-module/utils/use-notify-copy.js.map +1 -1
- package/build-style/content-rtl.css +0 -9
- package/build-style/content.css +0 -9
- package/build-style/style-rtl.css +19 -21
- package/build-style/style.css +19 -21
- package/package.json +34 -33
- package/src/components/background-image-control/index.js +0 -1
- package/src/components/block-actions/index.js +0 -3
- package/src/components/block-icon/content.scss +1 -1
- package/src/components/{block-card → block-icon}/stories/index.story.js +16 -26
- package/src/components/block-icon/style.scss +1 -1
- package/src/components/block-inspector/index.js +7 -10
- package/src/components/block-list/use-block-props/use-focus-handler.js +1 -1
- package/src/components/block-preview/style.scss +1 -1
- package/src/components/block-rename/modal.js +40 -12
- package/src/components/block-rename/rename-control.js +1 -53
- package/src/components/block-settings-menu/block-settings-dropdown.js +16 -2
- package/src/components/block-styles/preview.native.js +1 -1
- package/src/components/block-switcher/block-transformations-menu.js +9 -9
- package/src/components/block-switcher/block-variation-transformations.js +2 -2
- package/src/components/block-switcher/index.js +1 -1
- package/src/components/block-switcher/use-transformed-patterns.js +1 -1
- package/src/components/block-toolbar/index.native.js +2 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/style.scss +1 -0
- package/src/components/colors-gradients/test/control.js +2 -2
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/duotone-control/style.scss +2 -2
- package/src/components/global-styles/filters-panel.js +4 -2
- package/src/components/global-styles/image-settings-panel.js +2 -2
- package/src/components/global-styles/test/typography-utils.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +3 -3
- package/src/components/grid/grid-visualizer.js +10 -21
- package/src/components/grid/style.scss +1 -0
- package/src/components/grid/utils.js +6 -4
- package/src/components/iframe/get-compatibility-styles.js +1 -1
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/index.js +6 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
- package/src/components/inserter/menu.js +11 -9
- package/src/components/inserter/reusable-blocks-tab.native.js +1 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +62 -27
- package/src/components/line-height-control/index.native.js +1 -1
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/test/index.js +3 -3
- package/src/components/link-control/use-search-handler.js +1 -1
- package/src/components/list-view/README.md +1 -1
- package/src/components/list-view/block-select-button.js +5 -5
- package/src/components/list-view/style.scss +3 -7
- package/src/components/media-placeholder/content.scss +0 -8
- package/src/components/media-placeholder/index.js +1 -0
- package/src/components/media-placeholder/style.scss +7 -0
- package/src/components/observe-typing/index.js +1 -1
- package/src/components/provider/index.js +0 -1
- package/src/components/provider/use-block-sync.js +2 -2
- package/src/components/resolution-tool/stories/index.story.js +52 -2
- package/src/components/rich-text/README.md +1 -1
- package/src/components/rich-text/event-listeners/input-rules.js +3 -3
- package/src/components/rich-text/native/use-format-types.js +1 -1
- package/src/components/rich-text/use-format-types.js +1 -1
- package/src/components/spacing-sizes-control/README.md +93 -0
- package/src/components/spacing-sizes-control/index.js +44 -1
- package/src/components/spacing-sizes-control/linked-button.js +8 -10
- package/src/components/spacing-sizes-control/test/utils.js +0 -151
- package/src/components/spacing-sizes-control/utils.js +0 -106
- package/src/components/tabbed-sidebar/README.md +24 -13
- package/src/components/tabbed-sidebar/index.js +38 -0
- package/src/components/tabbed-sidebar/stories/index.story.js +104 -0
- package/src/components/typewriter/index.js +1 -1
- package/src/components/unit-control/README.md +1 -1
- package/src/components/unit-control/stories/index.story.js +124 -0
- package/src/components/url-popover/image-url-input-ui.js +3 -3
- package/src/components/use-block-commands/index.js +1 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-settings/README.md +1 -1
- package/src/components/warning/content.scss +1 -1
- package/src/components/writing-flow/test/index.js +1 -1
- package/src/hooks/color.scss +0 -7
- package/src/hooks/contrast-checker.js +64 -30
- package/src/hooks/custom-class-name.js +2 -1
- package/src/store/actions.js +1 -1
- package/src/store/selectors.js +20 -12
- package/src/store/test/private-selectors.js +1 -1
- package/src/store/test/selectors.js +3 -3
- package/src/style.scss +1 -0
- package/src/utils/test/sorting.js +1 -1
- package/src/utils/transform-styles/index.js +1 -1
- package/src/utils/use-notify-copy.js +51 -43
- package/tsconfig.json +1 -0
|
@@ -8,11 +8,11 @@ exports.default = SpacingSizesControl;
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
10
|
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
var _useSpacingSizes = _interopRequireDefault(require("./hooks/use-spacing-sizes"));
|
|
11
12
|
var _axial = _interopRequireDefault(require("./input-controls/axial"));
|
|
12
13
|
var _separated = _interopRequireDefault(require("./input-controls/separated"));
|
|
13
14
|
var _single = _interopRequireDefault(require("./input-controls/single"));
|
|
14
15
|
var _linkedButton = _interopRequireDefault(require("./linked-button"));
|
|
15
|
-
var _useSpacingSizes = _interopRequireDefault(require("./hooks/use-spacing-sizes"));
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
/**
|
|
@@ -23,7 +23,49 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/**
|
|
27
|
+
* A flexible control for managing spacing values in the block editor. Supports single, axial,
|
|
28
|
+
* and separated input controls for different spacing configurations with automatic view selection
|
|
29
|
+
* based on current values and available sides.
|
|
30
|
+
*
|
|
31
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/spacing-sizes-control/README.md
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```jsx
|
|
35
|
+
* import { __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor';
|
|
36
|
+
* import { useState } from '@wordpress/element';
|
|
37
|
+
*
|
|
38
|
+
* function Example() {
|
|
39
|
+
* const [ sides, setSides ] = useState( {
|
|
40
|
+
* top: '0px',
|
|
41
|
+
* right: '0px',
|
|
42
|
+
* bottom: '0px',
|
|
43
|
+
* left: '0px',
|
|
44
|
+
* } );
|
|
45
|
+
*
|
|
46
|
+
* return (
|
|
47
|
+
* <SpacingSizesControl
|
|
48
|
+
* values={ sides }
|
|
49
|
+
* onChange={ setSides }
|
|
50
|
+
* label="Sides"
|
|
51
|
+
* />
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param {Object} props Component props.
|
|
57
|
+
* @param {Object} props.inputProps Additional props for input controls.
|
|
58
|
+
* @param {string} props.label Label for the control.
|
|
59
|
+
* @param {number} props.minimumCustomValue Minimum value for custom input.
|
|
60
|
+
* @param {Function} props.onChange Called when spacing values change.
|
|
61
|
+
* @param {Function} props.onMouseOut Called when mouse leaves the control.
|
|
62
|
+
* @param {Function} props.onMouseOver Called when mouse enters the control.
|
|
63
|
+
* @param {boolean} props.showSideInLabel Show side in control label.
|
|
64
|
+
* @param {Array} props.sides Available sides for control.
|
|
65
|
+
* @param {boolean} props.useSelect Use select control for predefined values.
|
|
66
|
+
* @param {Object} props.values Current spacing values.
|
|
67
|
+
* @return {Element} Spacing sizes control component.
|
|
68
|
+
*/function SpacingSizesControl({
|
|
27
69
|
inputProps,
|
|
28
70
|
label: labelProp,
|
|
29
71
|
minimumCustomValue = 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_useSpacingSizes","_interopRequireDefault","_axial","_separated","_single","_linkedButton","_utils","_jsxRuntime","SpacingSizesControl","inputProps","label","labelProp","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","sides","ALL_SIDES","useSelect","values","spacingSizes","useSpacingSizes","inputValues","DEFAULT_VALUES","hasOneSide","length","hasOnlyAxialSides","includes","view","setView","useState","getInitialView","toggleLinked","VIEWS","axial","custom","handleOnChange","nextValue","newValues","inputControlProps","type","renderControls","jsx","default","side","sideLabel","LABELS","sprintf","_x","trim","jsxs","className","children","__experimentalHStack","BaseControl","VisualLabel","as","onClick","isLinked","__experimentalVStack","spacing"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { _x, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSpacingSizes from './hooks/use-spacing-sizes';\nimport AxialInputControls from './input-controls/axial';\nimport SeparatedInputControls from './input-controls/separated';\nimport SingleInputControl from './input-controls/single';\nimport LinkedButton from './linked-button';\nimport {\n\tALL_SIDES,\n\tDEFAULT_VALUES,\n\tLABELS,\n\tVIEWS,\n\tgetInitialView,\n} from './utils';\n\n/**\n * A flexible control for managing spacing values in the block editor. Supports single, axial,\n * and separated input controls for different spacing configurations with automatic view selection\n * based on current values and available sides.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/spacing-sizes-control/README.md\n *\n * @example\n * ```jsx\n * import { __experimentalSpacingSizesControl as SpacingSizesControl } from '@wordpress/block-editor';\n * import { useState } from '@wordpress/element';\n *\n * function Example() {\n * const [ sides, setSides ] = useState( {\n * top: '0px',\n * right: '0px',\n * bottom: '0px',\n * left: '0px',\n * } );\n *\n * return (\n * <SpacingSizesControl\n * values={ sides }\n * onChange={ setSides }\n * label=\"Sides\"\n * />\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {Object} props.inputProps Additional props for input controls.\n * @param {string} props.label Label for the control.\n * @param {number} props.minimumCustomValue Minimum value for custom input.\n * @param {Function} props.onChange Called when spacing values change.\n * @param {Function} props.onMouseOut Called when mouse leaves the control.\n * @param {Function} props.onMouseOver Called when mouse enters the control.\n * @param {boolean} props.showSideInLabel Show side in control label.\n * @param {Array} props.sides Available sides for control.\n * @param {boolean} props.useSelect Use select control for predefined values.\n * @param {Object} props.values Current spacing values.\n * @return {Element} Spacing sizes control component.\n */\nexport default function SpacingSizesControl( {\n\tinputProps,\n\tlabel: labelProp,\n\tminimumCustomValue = 0,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel = true,\n\tsides = ALL_SIDES,\n\tuseSelect,\n\tvalues,\n} ) {\n\tconst spacingSizes = useSpacingSizes();\n\tconst inputValues = values || DEFAULT_VALUES;\n\tconst hasOneSide = sides?.length === 1;\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tconst [ view, setView ] = useState( getInitialView( inputValues, sides ) );\n\n\tconst toggleLinked = () => {\n\t\tsetView( view === VIEWS.axial ? VIEWS.custom : VIEWS.axial );\n\t};\n\n\tconst handleOnChange = ( nextValue ) => {\n\t\tconst newValues = { ...values, ...nextValue };\n\t\tonChange( newValues );\n\t};\n\n\tconst inputControlProps = {\n\t\t...inputProps,\n\t\tminimumCustomValue,\n\t\tonChange: handleOnChange,\n\t\tonMouseOut,\n\t\tonMouseOver,\n\t\tsides,\n\t\tspacingSizes,\n\t\ttype: labelProp,\n\t\tuseSelect,\n\t\tvalues: inputValues,\n\t};\n\n\tconst renderControls = () => {\n\t\tif ( view === VIEWS.axial ) {\n\t\t\treturn <AxialInputControls { ...inputControlProps } />;\n\t\t}\n\t\tif ( view === VIEWS.custom ) {\n\t\t\treturn <SeparatedInputControls { ...inputControlProps } />;\n\t\t}\n\t\treturn (\n\t\t\t<SingleInputControl\n\t\t\t\tside={ view }\n\t\t\t\t{ ...inputControlProps }\n\t\t\t\tshowSideInLabel={ showSideInLabel }\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst sideLabel =\n\t\tALL_SIDES.includes( view ) && showSideInLabel ? LABELS[ view ] : '';\n\n\tconst label = sprintf(\n\t\t// translators: 1: The side of the block being modified (top, bottom, left etc.). 2. Type of spacing being modified (padding, margin, etc).\n\t\t_x( '%1$s %2$s', 'spacing' ),\n\t\tlabelProp,\n\t\tsideLabel\n\t).trim();\n\n\treturn (\n\t\t<fieldset className=\"spacing-sizes-control\">\n\t\t\t<HStack className=\"spacing-sizes-control__header\">\n\t\t\t\t<BaseControl.VisualLabel\n\t\t\t\t\tas=\"legend\"\n\t\t\t\t\tclassName=\"spacing-sizes-control__label\"\n\t\t\t\t>\n\t\t\t\t\t{ label }\n\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t{ ! hasOneSide && ! hasOnlyAxialSides && (\n\t\t\t\t\t<LinkedButton\n\t\t\t\t\t\tlabel={ labelProp }\n\t\t\t\t\t\tonClick={ toggleLinked }\n\t\t\t\t\t\tisLinked={ view === VIEWS.axial }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</HStack>\n\t\t\t<VStack spacing={ 0.5 }>{ renderControls() }</VStack>\n\t\t</fieldset>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,G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QAAE,EAAE,WAAW,EAAE,SAAU,CAAC,EAC5BtC,SAAS,EACTmC,SACD,CAAC,CAACI,IAAI,CAAC,CAAC;EAER,oBACC,IAAA3C,WAAA,CAAA4C,IAAA;IAAUC,SAAS,EAAC,uBAAuB;IAAAC,QAAA,gBAC1C,IAAA9C,WAAA,CAAA4C,IAAA,EAACvD,WAAA,CAAA0D,oBAAM;MAACF,SAAS,EAAC,+BAA+B;MAAAC,QAAA,gBAChD,IAAA9C,WAAA,CAAAoC,GAAA,EAAC/C,WAAA,CAAA2D,WAAW,CAACC,WAAW;QACvBC,EAAE,EAAC,QAAQ;QACXL,SAAS,EAAC,8BAA8B;QAAAC,QAAA,EAEtC3C;MAAK,CACiB,CAAC,EACxB,CAAEe,UAAU,IAAI,CAAEE,iBAAiB,iBACpC,IAAApB,WAAA,CAAAoC,GAAA,EAACtC,aAAA,CAAAuC,OAAY;QACZlC,KAAK,EAAGC,SAAW;QACnB+C,OAAO,EAAGzB,YAAc;QACxB0B,QAAQ,EAAG9B,IAAI,KAAKK,YAAK,CAACC;MAAO,CACjC,CACD;IAAA,CACM,CAAC,eACT,IAAA5B,WAAA,CAAAoC,GAAA,EAAC/C,WAAA,CAAAgE,oBAAM;MAACC,OAAO,EAAG,GAAK;MAAAR,QAAA,EAAGX,cAAc,CAAC;IAAC,CAAU,CAAC;EAAA,CAC5C,CAAC;AAEb","ignoreList":[]}
|
|
@@ -17,15 +17,12 @@ function LinkedButton({
|
|
|
17
17
|
...props
|
|
18
18
|
}) {
|
|
19
19
|
const label = isLinked ? (0, _i18n.__)('Unlink sides') : (0, _i18n.__)('Link sides');
|
|
20
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
iconSize: 24,
|
|
27
|
-
"aria-label": label
|
|
28
|
-
})
|
|
20
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
21
|
+
...props,
|
|
22
|
+
size: "small",
|
|
23
|
+
icon: isLinked ? _icons.link : _icons.linkOff,
|
|
24
|
+
iconSize: 24,
|
|
25
|
+
label: label
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
28
|
//# sourceMappingURL=linked-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_icons","_i18n","_jsxRuntime","LinkedButton","isLinked","props","label","__","jsx","
|
|
1
|
+
{"version":3,"names":["_components","require","_icons","_i18n","_jsxRuntime","LinkedButton","isLinked","props","label","__","jsx","Button","size","icon","link","linkOff","iconSize"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/linked-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { link, linkOff } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\nexport default function LinkedButton( { isLinked, ...props } ) {\n\tconst label = isLinked ? __( 'Unlink sides' ) : __( 'Link sides' );\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tsize=\"small\"\n\t\t\ticon={ isLinked ? link : linkOff }\n\t\t\ticonSize={ 24 }\n\t\t\tlabel={ label }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAqC,IAAAG,WAAA,GAAAH,OAAA;AALrC;AACA;AACA;;AAKe,SAASI,YAAYA,CAAE;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAG;EAC9D,MAAMC,KAAK,GAAGF,QAAQ,GAAG,IAAAG,QAAE,EAAE,cAAe,CAAC,GAAG,IAAAA,QAAE,EAAE,YAAa,CAAC;EAElE,oBACC,IAAAL,WAAA,CAAAM,GAAA,EAACV,WAAA,CAAAW,MAAM;IAAA,GACDJ,KAAK;IACVK,IAAI,EAAC,OAAO;IACZC,IAAI,EAAGP,QAAQ,GAAGQ,WAAI,GAAGC,cAAS;IAClCC,QAAQ,EAAG,EAAI;IACfR,KAAK,EAAGA;EAAO,CACf,CAAC;AAEJ","ignoreList":[]}
|
|
@@ -5,19 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.VIEWS = exports.RANGE_CONTROL_MAX_SIZE = exports.LABELS = exports.ICONS = exports.DEFAULT_VALUES = exports.ALL_SIDES = void 0;
|
|
8
|
-
exports.getAllRawValue = getAllRawValue;
|
|
9
8
|
exports.getCustomValueFromPreset = getCustomValueFromPreset;
|
|
10
9
|
exports.getInitialView = getInitialView;
|
|
11
10
|
exports.getPresetValueFromCustomValue = getPresetValueFromCustomValue;
|
|
12
11
|
exports.getSliderValueFromPreset = getSliderValueFromPreset;
|
|
13
12
|
exports.getSpacingPresetCssVar = getSpacingPresetCssVar;
|
|
14
13
|
exports.getSpacingPresetSlug = getSpacingPresetSlug;
|
|
15
|
-
exports.getSupportedMenuItems = getSupportedMenuItems;
|
|
16
14
|
exports.hasAxisSupport = hasAxisSupport;
|
|
17
15
|
exports.hasBalancedSidesSupport = hasBalancedSidesSupport;
|
|
18
16
|
exports.isValueSpacingPreset = isValueSpacingPreset;
|
|
19
|
-
exports.isValuesDefined = isValuesDefined;
|
|
20
|
-
exports.isValuesMixed = isValuesMixed;
|
|
21
17
|
var _i18n = require("@wordpress/i18n");
|
|
22
18
|
var _icons = require("@wordpress/icons");
|
|
23
19
|
/**
|
|
@@ -173,54 +169,6 @@ function getSliderValueFromPreset(presetValue, spacingSizes) {
|
|
|
173
169
|
return sliderValue !== -1 ? sliderValue : NaN;
|
|
174
170
|
}
|
|
175
171
|
|
|
176
|
-
/**
|
|
177
|
-
* Gets an items with the most occurrence within an array
|
|
178
|
-
* https://stackoverflow.com/a/20762713
|
|
179
|
-
*
|
|
180
|
-
* @param {Array<any>} arr Array of items to check.
|
|
181
|
-
* @return {any} The item with the most occurrences.
|
|
182
|
-
*/
|
|
183
|
-
function mode(arr) {
|
|
184
|
-
return arr.sort((a, b) => arr.filter(v => v === a).length - arr.filter(v => v === b).length).pop();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Gets the 'all' input value from values data.
|
|
189
|
-
*
|
|
190
|
-
* @param {Object} values Box spacing values
|
|
191
|
-
*
|
|
192
|
-
* @return {string} The most common value from all sides of box.
|
|
193
|
-
*/
|
|
194
|
-
function getAllRawValue(values = {}) {
|
|
195
|
-
return mode(Object.values(values));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Checks to determine if values are mixed.
|
|
200
|
-
*
|
|
201
|
-
* @param {Object} values Box values.
|
|
202
|
-
* @param {Array} sides Sides that values relate to.
|
|
203
|
-
*
|
|
204
|
-
* @return {boolean} Whether values are mixed.
|
|
205
|
-
*/
|
|
206
|
-
function isValuesMixed(values = {}, sides = ALL_SIDES) {
|
|
207
|
-
return Object.values(values).length >= 1 && Object.values(values).length < sides.length || new Set(Object.values(values)).size > 1;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Checks to determine if values are defined.
|
|
212
|
-
*
|
|
213
|
-
* @param {Object} values Box values.
|
|
214
|
-
*
|
|
215
|
-
* @return {boolean} Whether values are defined.
|
|
216
|
-
*/
|
|
217
|
-
function isValuesDefined(values) {
|
|
218
|
-
if (values === undefined || values === null) {
|
|
219
|
-
return false;
|
|
220
|
-
}
|
|
221
|
-
return Object.values(values).filter(value => !!value).length > 0;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
172
|
/**
|
|
225
173
|
* Determines whether a particular axis has support. If no axis is
|
|
226
174
|
* specified, this function checks if either axis is supported.
|
|
@@ -245,62 +193,6 @@ function hasAxisSupport(sides, axis) {
|
|
|
245
193
|
return hasHorizontalSupport || hasVerticalSupport;
|
|
246
194
|
}
|
|
247
195
|
|
|
248
|
-
/**
|
|
249
|
-
* Determines which menu options should be included in the SidePicker.
|
|
250
|
-
*
|
|
251
|
-
* @param {Array} sides Supported sides.
|
|
252
|
-
*
|
|
253
|
-
* @return {Object} Menu options with each option containing label & icon.
|
|
254
|
-
*/
|
|
255
|
-
function getSupportedMenuItems(sides) {
|
|
256
|
-
if (!sides || !sides.length) {
|
|
257
|
-
return {};
|
|
258
|
-
}
|
|
259
|
-
const menuItems = {};
|
|
260
|
-
|
|
261
|
-
// Determine the primary "side" menu options.
|
|
262
|
-
const hasHorizontalSupport = hasAxisSupport(sides, 'horizontal');
|
|
263
|
-
const hasVerticalSupport = hasAxisSupport(sides, 'vertical');
|
|
264
|
-
if (hasHorizontalSupport && hasVerticalSupport) {
|
|
265
|
-
menuItems.axial = {
|
|
266
|
-
label: LABELS.axial,
|
|
267
|
-
icon: ICONS.axial
|
|
268
|
-
};
|
|
269
|
-
} else if (hasHorizontalSupport) {
|
|
270
|
-
menuItems.axial = {
|
|
271
|
-
label: LABELS.horizontal,
|
|
272
|
-
icon: ICONS.horizontal
|
|
273
|
-
};
|
|
274
|
-
} else if (hasVerticalSupport) {
|
|
275
|
-
menuItems.axial = {
|
|
276
|
-
label: LABELS.vertical,
|
|
277
|
-
icon: ICONS.vertical
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Track whether we have any individual sides so we can omit the custom
|
|
282
|
-
// option if required.
|
|
283
|
-
let numberOfIndividualSides = 0;
|
|
284
|
-
ALL_SIDES.forEach(side => {
|
|
285
|
-
if (sides.includes(side)) {
|
|
286
|
-
numberOfIndividualSides += 1;
|
|
287
|
-
menuItems[side] = {
|
|
288
|
-
label: LABELS[side],
|
|
289
|
-
icon: ICONS[side]
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
// Add custom item if there are enough sides to warrant a separated view.
|
|
295
|
-
if (numberOfIndividualSides > 1) {
|
|
296
|
-
menuItems.custom = {
|
|
297
|
-
label: LABELS.custom,
|
|
298
|
-
icon: ICONS.custom
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
return menuItems;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
196
|
/**
|
|
305
197
|
* Checks if the supported sides are balanced for each axis.
|
|
306
198
|
* - Horizontal - both left and right sides are supported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","RANGE_CONTROL_MAX_SIZE","exports","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","sidesAll","axial","horizontal","sidesHorizontal","vertical","sidesVertical","sidesTop","sidesRight","sidesBottom","sidesLeft","LABELS","default","__","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","hasOnlyAxialSides","entries","some","key"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAYO,MAAME,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAAC;AAEhC,MAAME,SAAS,GAAAD,O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CAAE;EAClB;;EAEA;EACA,OAAOnC,KAAK,CAACf,MAAM;AACpB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","RANGE_CONTROL_MAX_SIZE","exports","ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","sidesAll","axial","horizontal","sidesHorizontal","vertical","sidesVertical","sidesTop","sidesRight","sidesBottom","sidesLeft","LABELS","default","__","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","hasAxisSupport","sides","axis","length","hasHorizontalSupport","hasVerticalSupport","hasBalancedSidesSupport","counts","forEach","side","getInitialView","values","sideValues","filter","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","hasOnlyAxialSides","Object","entries","some","key"],"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const RANGE_CONTROL_MAX_SIZE = 8;\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAll,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is undefined or is already a preset, or '0';\n\tif ( ! value || isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\tconst hasOnlyAxialSides =\n\t\tsides?.includes( 'horizontal' ) &&\n\t\tsides?.includes( 'vertical' ) &&\n\t\tsides?.length === 2;\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Only axial sides are supported and single value defined.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( hasOnlyAxialSides && sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAYO,MAAME,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,CAAC;AAEhC,MAAME,SAAS,GAAAD,OAAA,CAAAC,SAAA,GAAG,CAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAE;AAEtD,MAAMC,cAAc,GAAAF,OAAA,CAAAE,cAAA,GAAG;EAC7BC,GAAG,EAAEC,SAAS;EACdC,KAAK,EAAED,SAAS;EAChBE,MAAM,EAAEF,SAAS;EACjBG,IAAI,EAAEH;AACP,CAAC;AAEM,MAAMI,KAAK,GAAAR,OAAA,CAAAQ,KAAA,GAAG;EACpBC,MAAM,EAAEC,eAAQ;EAChBC,KAAK,EAAED,eAAQ;EACfE,UAAU,EAAEC,sBAAe;EAC3BC,QAAQ,EAAEC,oBAAa;EACvBZ,GAAG,EAAEa,eAAQ;EACbX,KAAK,EAAEY,iBAAU;EACjBX,MAAM,EAAEY,kBAAW;EACnBX,IAAI,EAAEY;AACP,CAAC;AAEM,MAAMC,MAAM,GAAApB,OAAA,CAAAoB,MAAA,GAAG;EACrBC,OAAO,EAAE,IAAAC,QAAE,EAAE,iBAAkB,CAAC;EAChCnB,GAAG,EAAE,IAAAmB,QAAE,EAAE,KAAM,CAAC;EAChBhB,MAAM,EAAE,IAAAgB,QAAE,EAAE,Q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M,KAAK,CAAC,EAAG;IACnD,IAAIM,IAAI;IAERS,MAAM,CAACC,OAAO,CAAER,MAAO,CAAC,CAACS,IAAI,CAAE,CAAE,CAAEC,GAAG,EAAEzC,KAAK,CAAE,KAAM;MACpD6B,IAAI,GAAGY,GAAG;MACV,OAAOzC,KAAK,KAAKtB,SAAS;IAC3B,CAAE,CAAC;IAEH,OAAOmD,IAAI;EACZ;;EAEA;EACA,IAAKR,KAAK,EAAEE,MAAM,KAAK,CAAC,IAAI,CAAES,UAAU,CAACT,MAAM,EAAG;IACjD,OAAOF,KAAK,CAAE,CAAC,CAAE;EAClB;;EAEA;EACA,OAAOvB,KAAK,CAACf,MAAM;AACpB","ignoreList":[]}
|
|
@@ -21,6 +21,45 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
21
|
const {
|
|
22
22
|
Tabs
|
|
23
23
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A component that creates a tabbed sidebar with a close button.
|
|
27
|
+
*
|
|
28
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/tabbed-sidebar/README.md
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```jsx
|
|
32
|
+
* function MyTabbedSidebar() {
|
|
33
|
+
* return (
|
|
34
|
+
* <TabbedSidebar
|
|
35
|
+
* tabs={ [
|
|
36
|
+
* {
|
|
37
|
+
* name: 'tab1',
|
|
38
|
+
* title: 'Settings',
|
|
39
|
+
* panel: <PanelContents />,
|
|
40
|
+
* }
|
|
41
|
+
* ] }
|
|
42
|
+
* onClose={ () => {} }
|
|
43
|
+
* onSelect={ () => {} }
|
|
44
|
+
* defaultTabId="tab1"
|
|
45
|
+
* selectedTab="tab1"
|
|
46
|
+
* closeButtonLabel="Close sidebar"
|
|
47
|
+
* />
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @param {Object} props Component props.
|
|
53
|
+
* @param {string} [props.defaultTabId] The ID of the tab to be selected by default when the component renders.
|
|
54
|
+
* @param {Function} props.onClose Function called when the close button is clicked.
|
|
55
|
+
* @param {Function} props.onSelect Function called when a tab is selected. Receives the selected tab's ID as an argument.
|
|
56
|
+
* @param {string} props.selectedTab The ID of the currently selected tab.
|
|
57
|
+
* @param {Array} props.tabs Array of tab objects. Each tab should have: name (string), title (string),
|
|
58
|
+
* panel (React.Node), and optionally panelRef (React.Ref).
|
|
59
|
+
* @param {string} props.closeButtonLabel Accessibility label for the close button.
|
|
60
|
+
* @param {Object} ref Forward ref to the tabs list element.
|
|
61
|
+
* @return {Element} The tabbed sidebar component.
|
|
62
|
+
*/
|
|
24
63
|
function TabbedSidebar({
|
|
25
64
|
defaultTabId,
|
|
26
65
|
onClose,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_icons","_lockUnlock","_jsxRuntime","Tabs","unlock","componentsPrivateApis","TabbedSidebar","defaultTabId","onClose","onSelect","selectedTab","tabs","closeButtonLabel","ref","jsx","className","children","jsxs","selectOnMove","selectedTabId","Button","icon","closeSmall","label","onClick","size","TabList","map","tab","Tab","tabId","name","title","TabPanel","focusable","panelRef","panel","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/tabbed-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction TabbedSidebar(\n\t{ defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },\n\tref\n) {\n\treturn (\n\t\t<div className=\"block-editor-tabbed-sidebar\">\n\t\t\t<Tabs\n\t\t\t\tselectOnMove={ false }\n\t\t\t\tdefaultTabId={ defaultTabId }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tselectedTabId={ selectedTab }\n\t\t\t>\n\t\t\t\t<div className=\"block-editor-tabbed-sidebar__tablist-and-close-button\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__close-button\"\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tlabel={ closeButtonLabel }\n\t\t\t\t\t\tonClick={ () => onClose() }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Tabs.TabList\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tablist\"\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tab\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t</div>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tabpanel\"\n\t\t\t\t\t\tref={ tab.panelRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tab.panel }\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( TabbedSidebar );\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAb3C;AACA;AACA;;AAQA;AACA;AACA;;AAGA,MAAM;EAAEK;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_icons","_lockUnlock","_jsxRuntime","Tabs","unlock","componentsPrivateApis","TabbedSidebar","defaultTabId","onClose","onSelect","selectedTab","tabs","closeButtonLabel","ref","jsx","className","children","jsxs","selectOnMove","selectedTabId","Button","icon","closeSmall","label","onClick","size","TabList","map","tab","Tab","tabId","name","title","TabPanel","focusable","panelRef","panel","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/tabbed-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { closeSmall } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\n/**\n * A component that creates a tabbed sidebar with a close button.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/tabbed-sidebar/README.md\n *\n * @example\n * ```jsx\n * function MyTabbedSidebar() {\n * return (\n * <TabbedSidebar\n * tabs={ [\n * {\n * name: 'tab1',\n * title: 'Settings',\n * panel: <PanelContents />,\n * }\n * ] }\n * onClose={ () => {} }\n * onSelect={ () => {} }\n * defaultTabId=\"tab1\"\n * selectedTab=\"tab1\"\n * closeButtonLabel=\"Close sidebar\"\n * />\n * );\n * }\n * ```\n *\n * @param {Object} props Component props.\n * @param {string} [props.defaultTabId] The ID of the tab to be selected by default when the component renders.\n * @param {Function} props.onClose Function called when the close button is clicked.\n * @param {Function} props.onSelect Function called when a tab is selected. Receives the selected tab's ID as an argument.\n * @param {string} props.selectedTab The ID of the currently selected tab.\n * @param {Array} props.tabs Array of tab objects. Each tab should have: name (string), title (string),\n * panel (React.Node), and optionally panelRef (React.Ref).\n * @param {string} props.closeButtonLabel Accessibility label for the close button.\n * @param {Object} ref Forward ref to the tabs list element.\n * @return {Element} The tabbed sidebar component.\n */\nfunction TabbedSidebar(\n\t{ defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },\n\tref\n) {\n\treturn (\n\t\t<div className=\"block-editor-tabbed-sidebar\">\n\t\t\t<Tabs\n\t\t\t\tselectOnMove={ false }\n\t\t\t\tdefaultTabId={ defaultTabId }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tselectedTabId={ selectedTab }\n\t\t\t>\n\t\t\t\t<div className=\"block-editor-tabbed-sidebar__tablist-and-close-button\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__close-button\"\n\t\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\t\tlabel={ closeButtonLabel }\n\t\t\t\t\t\tonClick={ () => onClose() }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Tabs.TabList\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tablist\"\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tab\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t</div>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\tkey={ tab.name }\n\t\t\t\t\t\ttabId={ tab.name }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t\tclassName=\"block-editor-tabbed-sidebar__tabpanel\"\n\t\t\t\t\t\tref={ tab.panelRef }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tab.panel }\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs>\n\t\t</div>\n\t);\n}\n\nexport default forwardRef( TabbedSidebar );\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAA2C,IAAAI,WAAA,GAAAJ,OAAA;AAb3C;AACA;AACA;;AAQA;AACA;AACA;;AAGA,MAAM;EAAEK;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;;AAEhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CACrB;EAAEC,YAAY;EAAEC,OAAO;EAAEC,QAAQ;EAAEC,WAAW;EAAEC,IAAI;EAAEC;AAAiB,CAAC,EACxEC,GAAG,EACF;EACD,oBACC,IAAAX,WAAA,CAAAY,GAAA;IAAKC,SAAS,EAAC,6BAA6B;IAAAC,QAAA,eAC3C,IAAAd,WAAA,CAAAe,IAAA,EAACd,IAAI;MACJe,YAAY,EAAG,KAAO;MACtBX,YAAY,EAAGA,YAAc;MAC7BE,QAAQ,EAAGA,QAAU;MACrBU,aAAa,EAAGT,WAAa;MAAAM,QAAA,gBAE7B,IAAAd,WAAA,CAAAe,IAAA;QAAKF,SAAS,EAAC,uDAAuD;QAAAC,QAAA,gBACrE,IAAAd,WAAA,CAAAY,GAAA,EAACjB,WAAA,CAAAuB,MAAM;UACNL,SAAS,EAAC,2CAA2C;UACrDM,IAAI,EAAGC,iBAAY;UACnBC,KAAK,EAAGX,gBAAkB;UAC1BY,OAAO,EAAGA,CAAA,KAAMhB,OAAO,CAAC,CAAG;UAC3BiB,IAAI,EAAC;QAAS,CACd,CAAC,eAEF,IAAAvB,WAAA,CAAAY,GAAA,EAACX,IAAI,CAACuB,OAAO;UACZX,SAAS,EAAC,sCAAsC;UAChDF,GAAG,EAAGA,GAAK;UAAAG,QAAA,EAETL,IAAI,CAACgB,GAAG,CAAIC,GAAG,iBAChB,IAAA1B,WAAA,CAAAY,GAAA,EAACX,IAAI,CAAC0B,GAAG;YAERC,KAAK,EAAGF,GAAG,CAACG,IAAM;YAClBhB,SAAS,EAAC,kCAAkC;YAAAC,QAAA,EAE1CY,GAAG,CAACI;UAAK,GAJLJ,GAAG,CAACG,IAKD,CACT;QAAC,CACU,CAAC;MAAA,CACX,CAAC,EACJpB,IAAI,CAACgB,GAAG,CAAIC,GAAG,iBAChB,IAAA1B,WAAA,CAAAY,GAAA,EAACX,IAAI,CAAC8B,QAAQ;QAEbH,KAAK,EAAGF,GAAG,CAACG,IAAM;QAClBG,SAAS,EAAG,KAAO;QACnBnB,SAAS,EAAC,uCAAuC;QACjDF,GAAG,EAAGe,GAAG,CAACO,QAAU;QAAAnB,QAAA,EAElBY,GAAG,CAACQ;MAAK,GANLR,GAAG,CAACG,IAOI,CACd,CAAC;IAAA,CACE;EAAC,CACH,CAAC;AAER;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAElC,aAAc,CAAC","ignoreList":[]}
|
|
@@ -164,7 +164,7 @@ function useTypewriter() {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
* Checks if the current situation is
|
|
167
|
+
* Checks if the current situation is eligible for scroll:
|
|
168
168
|
* - There should be one and only one block selected.
|
|
169
169
|
* - The component must contain the selection.
|
|
170
170
|
* - The active element must be contenteditable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_dom","_data","_keycodes","_store","_jsxRuntime","isIE","window","navigator","userAgent","indexOf","arrowKeyCodes","Set","UP","DOWN","LEFT","RIGHT","initialTriggerPercentage","useTypewriter","hasSelectedBlock","useSelect","select","blockEditorStore","useRefEffect","node","ownerDocument","defaultView","scrollResizeRafId","onKeyDownRafId","caretRect","onScrollResize","requestAnimationFrame","computeCaretRectangle","onKeyDown","event","cancelAnimationFrame","maintainCaretPosition","keyCode","isSelectionEligibleForScroll","currentCaretRect","computeCaretRect","has","diff","top","scrollContainer","getScrollContainer","windowScroll","body","documentElement","scrollY","scrollTop","scrollContainerY","getBoundingClientRect","relativeScrollPosition","innerHeight","isLastEditableNode","scrollContainerHeight","clientHeight","height","scrollBy","addSelectionChangeListener","addEventListener","computeCaretRectOnSelectionChange","removeEventListener","contains","activeElement","isContentEditable","editableNodes","querySelectorAll","lastEditableNode","length","Typewriter","children","jsx","ref","className","TypewriterOrIEBypass","props","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/typewriter/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\tconst hasSelectedBlock = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasSelectedBlock(),\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! hasSelectedBlock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet scrollResizeRafId;\n\t\t\tlet onKeyDownRafId;\n\n\t\t\tlet caretRect;\n\n\t\t\tfunction onScrollResize() {\n\t\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tcomputeCaretRectangle();\n\t\t\t\t\tscrollResizeRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t\t}\n\n\t\t\t\t// Use an animation frame for a smooth result.\n\t\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\t\tonKeyDownRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Maintains the scroll position after a selection change caused by a\n\t\t\t * keyboard event.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t\t */\n\t\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t\t// this be the position to be scrolled to in the future.\n\t\t\t\tif ( ! caretRect ) {\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t\t// now, let's disable it.\n\t\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\t\tif ( diff === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t\t// The page must be scrollable.\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\t\tconst scrollY = windowScroll\n\t\t\t\t\t? defaultView.scrollY\n\t\t\t\t\t: scrollContainer.scrollTop;\n\t\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t\t? 0\n\t\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t\t// intentionally down.\n\t\t\t\tif (\n\t\t\t\t\tscrollY === 0 &&\n\t\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\t\tisLastEditableNode()\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t\t? defaultView.innerHeight\n\t\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t\t// view.\n\t\t\t\tif (\n\t\t\t\t\t// The caret is under the lower fold.\n\t\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t\t// The caret is above the upper fold.\n\t\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( windowScroll ) {\n\t\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t\t} else {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t\t * maintained.\n\t\t\t */\n\t\t\tfunction addSelectionChangeListener() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t\t */\n\t\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained.\n\t\t\t */\n\t\t\tfunction computeCaretRectangle() {\n\t\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Checks if the current situation is elegible for scroll:\n\t\t\t * - There should be one and only one block selected.\n\t\t\t * - The component must contain the selection.\n\t\t\t * - The active element must be contenteditable.\n\t\t\t */\n\t\t\tfunction isSelectionEligibleForScroll() {\n\t\t\t\treturn (\n\t\t\t\t\tnode.contains( ownerDocument.activeElement ) &&\n\t\t\t\t\townerDocument.activeElement.isContentEditable\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction isLastEditableNode() {\n\t\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t\t);\n\t\t\t\tconst lastEditableNode =\n\t\t\t\t\teditableNodes[ editableNodes.length - 1 ];\n\t\t\t\treturn lastEditableNode === ownerDocument.activeElement;\n\t\t\t}\n\n\t\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t\t// reset.\n\t\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\t\treturn () => {\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'scroll',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'resize',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'touchstart',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\n\t\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t};\n\t\t},\n\t\t[ hasSelectedBlock ]\n\t);\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAAwD,IAAAK,WAAA,GAAAL,OAAA;AAXxD;AACA;AACA;;AAMA;AACA;AACA;;AAGA,MAAMM,IAAI,GAAGC,MAAM,CAACC,SAAS,CAACC,SAAS,CAACC,OAAO,CAAE,SAAU,CAAC,KAAK,CAAC,CAAC;AACnE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAE,CAAEC,YAAE,EAAEC,cAAI,EAAEC,cAAI,EAAEC,eAAK,CAAG,CAAC;AAC1D,MAAMC,wBAAwB,GAAG,IAAI;AAE9B,SAASC,aAAaA,CAAA,EAAG;EAC/B,MAAMC,gBAAgB,GAAG,IAAAC,eAAS,EAC/BC,MAAM,IAAMA,MAA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om","_data","_keycodes","_store","_jsxRuntime","isIE","window","navigator","userAgent","indexOf","arrowKeyCodes","Set","UP","DOWN","LEFT","RIGHT","initialTriggerPercentage","useTypewriter","hasSelectedBlock","useSelect","select","blockEditorStore","useRefEffect","node","ownerDocument","defaultView","scrollResizeRafId","onKeyDownRafId","caretRect","onScrollResize","requestAnimationFrame","computeCaretRectangle","onKeyDown","event","cancelAnimationFrame","maintainCaretPosition","keyCode","isSelectionEligibleForScroll","currentCaretRect","computeCaretRect","has","diff","top","scrollContainer","getScrollContainer","windowScroll","body","documentElement","scrollY","scrollTop","scrollContainerY","getBoundingClientRect","relativeScrollPosition","innerHeight","isLastEditableNode","scrollContainerHeight","clientHeight","height","scrollBy","addSelectionChangeListener","addEventListener","computeCaretRectOnSelectionChange","removeEventListener","contains","activeElement","isContentEditable","editableNodes","querySelectorAll","lastEditableNode","length","Typewriter","children","jsx","ref","className","TypewriterOrIEBypass","props","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/typewriter/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { computeCaretRect, getScrollContainer } from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nconst isIE = window.navigator.userAgent.indexOf( 'Trident' ) !== -1;\nconst arrowKeyCodes = new Set( [ UP, DOWN, LEFT, RIGHT ] );\nconst initialTriggerPercentage = 0.75;\n\nexport function useTypewriter() {\n\tconst hasSelectedBlock = useSelect(\n\t\t( select ) => select( blockEditorStore ).hasSelectedBlock(),\n\t\t[]\n\t);\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( ! hasSelectedBlock ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tlet scrollResizeRafId;\n\t\t\tlet onKeyDownRafId;\n\n\t\t\tlet caretRect;\n\n\t\t\tfunction onScrollResize() {\n\t\t\t\tif ( scrollResizeRafId ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscrollResizeRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tcomputeCaretRectangle();\n\t\t\t\t\tscrollResizeRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\t// Ensure the any remaining request is cancelled.\n\t\t\t\tif ( onKeyDownRafId ) {\n\t\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t\t}\n\n\t\t\t\t// Use an animation frame for a smooth result.\n\t\t\t\tonKeyDownRafId = defaultView.requestAnimationFrame( () => {\n\t\t\t\t\tmaintainCaretPosition( event );\n\t\t\t\t\tonKeyDownRafId = null;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Maintains the scroll position after a selection change caused by a\n\t\t\t * keyboard event.\n\t\t\t *\n\t\t\t * @param {KeyboardEvent} event Keyboard event.\n\t\t\t */\n\t\t\tfunction maintainCaretPosition( { keyCode } ) {\n\t\t\t\tif ( ! isSelectionEligibleForScroll() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst currentCaretRect = computeCaretRect( defaultView );\n\n\t\t\t\tif ( ! currentCaretRect ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If for some reason there is no position set to be scrolled to, let\n\t\t\t\t// this be the position to be scrolled to in the future.\n\t\t\t\tif ( ! caretRect ) {\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Even though enabling the typewriter effect for arrow keys results in\n\t\t\t\t// a pleasant experience, it may not be the case for everyone, so, for\n\t\t\t\t// now, let's disable it.\n\t\t\t\tif ( arrowKeyCodes.has( keyCode ) ) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst diff = currentCaretRect.top - caretRect.top;\n\n\t\t\t\tif ( diff === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainer = getScrollContainer( node );\n\n\t\t\t\t// The page must be scrollable.\n\t\t\t\tif ( ! scrollContainer ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\t\t\t\tconst scrollY = windowScroll\n\t\t\t\t\t? defaultView.scrollY\n\t\t\t\t\t: scrollContainer.scrollTop;\n\t\t\t\tconst scrollContainerY = windowScroll\n\t\t\t\t\t? 0\n\t\t\t\t\t: scrollContainer.getBoundingClientRect().top;\n\t\t\t\tconst relativeScrollPosition = windowScroll\n\t\t\t\t\t? caretRect.top / defaultView.innerHeight\n\t\t\t\t\t: ( caretRect.top - scrollContainerY ) /\n\t\t\t\t\t ( defaultView.innerHeight - scrollContainerY );\n\n\t\t\t\t// If the scroll position is at the start, the active editable element\n\t\t\t\t// is the last one, and the caret is positioned within the initial\n\t\t\t\t// trigger percentage of the page, do not scroll the page.\n\t\t\t\t// The typewriter effect should not kick in until an empty page has been\n\t\t\t\t// filled with the initial trigger percentage or the user scrolls\n\t\t\t\t// intentionally down.\n\t\t\t\tif (\n\t\t\t\t\tscrollY === 0 &&\n\t\t\t\t\trelativeScrollPosition < initialTriggerPercentage &&\n\t\t\t\t\tisLastEditableNode()\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst scrollContainerHeight = windowScroll\n\t\t\t\t\t? defaultView.innerHeight\n\t\t\t\t\t: scrollContainer.clientHeight;\n\n\t\t\t\t// Abort if the target scroll position would scroll the caret out of\n\t\t\t\t// view.\n\t\t\t\tif (\n\t\t\t\t\t// The caret is under the lower fold.\n\t\t\t\t\tcaretRect.top + caretRect.height >\n\t\t\t\t\t\tscrollContainerY + scrollContainerHeight ||\n\t\t\t\t\t// The caret is above the upper fold.\n\t\t\t\t\tcaretRect.top < scrollContainerY\n\t\t\t\t) {\n\t\t\t\t\t// Reset the caret position to maintain.\n\t\t\t\t\tcaretRect = currentCaretRect;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( windowScroll ) {\n\t\t\t\t\tdefaultView.scrollBy( 0, diff );\n\t\t\t\t} else {\n\t\t\t\t\tscrollContainer.scrollTop += diff;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Adds a `selectionchange` listener to reset the scroll position to be\n\t\t\t * maintained.\n\t\t\t */\n\t\t\tfunction addSelectionChangeListener() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained during a `selectionchange`\n\t\t\t * event. Also removes the listener, so it acts as a one-time listener.\n\t\t\t */\n\t\t\tfunction computeCaretRectOnSelectionChange() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\t\t\t\tcomputeCaretRectangle();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Resets the scroll position to be maintained.\n\t\t\t */\n\t\t\tfunction computeCaretRectangle() {\n\t\t\t\tif ( isSelectionEligibleForScroll() ) {\n\t\t\t\t\tcaretRect = computeCaretRect( defaultView );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Checks if the current situation is eligible for scroll:\n\t\t\t * - There should be one and only one block selected.\n\t\t\t * - The component must contain the selection.\n\t\t\t * - The active element must be contenteditable.\n\t\t\t */\n\t\t\tfunction isSelectionEligibleForScroll() {\n\t\t\t\treturn (\n\t\t\t\t\tnode.contains( ownerDocument.activeElement ) &&\n\t\t\t\t\townerDocument.activeElement.isContentEditable\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction isLastEditableNode() {\n\t\t\t\tconst editableNodes = node.querySelectorAll(\n\t\t\t\t\t'[contenteditable=\"true\"]'\n\t\t\t\t);\n\t\t\t\tconst lastEditableNode =\n\t\t\t\t\teditableNodes[ editableNodes.length - 1 ];\n\t\t\t\treturn lastEditableNode === ownerDocument.activeElement;\n\t\t\t}\n\n\t\t\t// When the user scrolls or resizes, the scroll position should be\n\t\t\t// reset.\n\t\t\tdefaultView.addEventListener( 'scroll', onScrollResize, true );\n\t\t\tdefaultView.addEventListener( 'resize', onScrollResize, true );\n\n\t\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\t\tnode.addEventListener( 'keyup', maintainCaretPosition );\n\t\t\tnode.addEventListener( 'mousedown', addSelectionChangeListener );\n\t\t\tnode.addEventListener( 'touchstart', addSelectionChangeListener );\n\n\t\t\treturn () => {\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'scroll',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener(\n\t\t\t\t\t'resize',\n\t\t\t\t\tonScrollResize,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\t\tnode.removeEventListener( 'keyup', maintainCaretPosition );\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\t\t\t\tnode.removeEventListener(\n\t\t\t\t\t'touchstart',\n\t\t\t\t\taddSelectionChangeListener\n\t\t\t\t);\n\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tcomputeCaretRectOnSelectionChange\n\t\t\t\t);\n\n\t\t\t\tdefaultView.cancelAnimationFrame( scrollResizeRafId );\n\t\t\t\tdefaultView.cancelAnimationFrame( onKeyDownRafId );\n\t\t\t};\n\t\t},\n\t\t[ hasSelectedBlock ]\n\t);\n}\n\nfunction Typewriter( { children } ) {\n\treturn (\n\t\t<div ref={ useTypewriter() } className=\"block-editor__typewriter\">\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\n/**\n * The exported component. The implementation of Typewriter faced technical\n * challenges in Internet Explorer, and is simply skipped, rendering the given\n * props children instead.\n *\n * @type {Component}\n */\nconst TypewriterOrIEBypass = isIE ? ( props ) => props.children : Typewriter;\n\n/**\n * Ensures that the text selection keeps the same vertical distance from the\n * viewport during keyboard events within this component. The vertical distance\n * can vary. It is the last clicked or scrolled to position.\n */\nexport default TypewriterOrIEBypass;\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAKA,IAAAI,MAAA,GAAAJ,OAAA;AAAwD,IAAAK,WAAA,GAAAL,OAAA;AAXxD;AACA;AACA;;AAMA;AACA;AACA;;AAGA,MAAMM,IAAI,GAAGC,MAAM,CAACC,SAAS,CAACC,SAAS,CAACC,OAAO,CAAE,SAAU,CAAC,KAAK,CAAC,CAAC;AACnE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAE,CAAEC,YAAE,EAAEC,cAAI,EAAEC,cAAI,EAAEC,eAAK,CAAG,CAAC;AAC1D,MAAMC,wBAAwB,GAAG,IAAI;AAE9B,SAASC,aAAaA,CAAA,EAAG;EAC/B,MAAMC,gBAAgB,GAAG,IAAAC,eAAS,EAC/BC,MAAM,IAAMA,MAAM,CAAEC,YAAiB,CAAC,CAACH,gBAAgB,CAAC,CAAC,EAC3D,EACD,CAAC;EAED,OAAO,IAAAI,qBAAY,EAChBC,IAAI,IAAM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,YAAY,EAAED,0BAA2B,CAAC;IAEjE,OAAO,MAAM;MACZlC,WAAW,CAACqC,mBAAmB,CAC9B,QAAQ,EACRjC,cAAc,EACd,IACD,CAAC;MACDJ,WAAW,CAACqC,mBAAmB,CAC9B,QAAQ,EACRjC,cAAc,EACd,IACD,CAAC;MAEDN,IAAI,CAACuC,mBAAmB,CAAE,SAAS,EAAE9B,SAAU,CAAC;MAChDT,IAAI,CAACuC,mBAAmB,CAAE,OAAO,EAAE3B,qBAAsB,CAAC;MAC1DZ,IAAI,CAACuC,mBAAmB,CACvB,WAAW,EACXH,0BACD,CAAC;MACDpC,IAAI,CAACuC,mBAAmB,CACvB,YAAY,EACZH,0BACD,CAAC;MAEDnC,aAAa,CAACsC,mBAAmB,CAChC,iBAAiB,EACjBD,iCACD,CAAC;MAEDpC,WAAW,CAACS,oBAAoB,CAAER,iBAAkB,CAAC;MACrDD,WAAW,CAACS,oBAAoB,CAAEP,cAAe,CAAC;IACnD,CAAC;EACF,CAAC,EACD,CAAET,gBAAgB,CACnB,CAAC;AACF;AAEA,SAASoD,UAAUA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnC,oBACC,IAAAnE,WAAA,CAAAoE,GAAA;IAAKC,GAAG,EAAGxD,aAAa,CAAC,CAAG;IAACyD,SAAS,EAAC,0BAA0B;IAAAH,QAAA,EAC9DA;EAAQ,CACN,CAAC;AAER;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,oBAAoB,GAAGtE,IAAI,GAAKuE,KAAK,IAAMA,KAAK,CAACL,QAAQ,GAAGD,UAAU;;AAE5E;AACA;AACA;AACA;AACA;AAJA,IAAAO,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKeJ,oBAAoB","ignoreList":[]}
|
|
@@ -215,14 +215,14 @@ const ImageURLInputUI = ({
|
|
|
215
215
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
216
216
|
className: "text",
|
|
217
217
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
218
|
-
children: (0, _i18n.__)('
|
|
218
|
+
children: (0, _i18n.__)('Enlarge on click')
|
|
219
219
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
220
220
|
className: "description",
|
|
221
221
|
children: (0, _i18n.__)('Scales the image with a lightbox effect')
|
|
222
222
|
})]
|
|
223
223
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
224
224
|
icon: _icons.linkOff,
|
|
225
|
-
label: (0, _i18n.__)('Disable
|
|
225
|
+
label: (0, _i18n.__)('Disable enlarge on click'),
|
|
226
226
|
onClick: () => {
|
|
227
227
|
onSetLightbox?.(false);
|
|
228
228
|
},
|
|
@@ -295,7 +295,7 @@ const ImageURLInputUI = ({
|
|
|
295
295
|
onSetLightbox?.(true);
|
|
296
296
|
stopEditLink();
|
|
297
297
|
},
|
|
298
|
-
children: (0, _i18n.__)('
|
|
298
|
+
children: (0, _i18n.__)('Enlarge on click')
|
|
299
299
|
}, "expand-on-click")]
|
|
300
300
|
}),
|
|
301
301
|
offset: 13,
|