@wordpress/components 35.1.1-next.v.202606191442.0 → 36.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/CONTRIBUTING.md +33 -26
- package/build/box-control/{input-control.cjs → box-input-control.cjs} +9 -9
- package/build/box-control/box-input-control.cjs.map +7 -0
- package/build/box-control/index.cjs +9 -25
- package/build/box-control/index.cjs.map +3 -3
- package/build/disabled/index.cjs.map +2 -2
- package/build/divider/component.cjs +108 -3
- package/build/divider/component.cjs.map +4 -4
- package/build/higher-order/with-fallback-styles/index.cjs +18 -44
- package/build/higher-order/with-fallback-styles/index.cjs.map +2 -2
- package/build/text-control/index.cjs +3 -12
- package/build/text-control/index.cjs.map +3 -3
- package/build/validated-form-controls/components/text-control.cjs +0 -1
- package/build/validated-form-controls/components/text-control.cjs.map +2 -2
- package/build-module/box-control/{input-control.mjs → box-input-control.mjs} +6 -6
- package/build-module/box-control/box-input-control.mjs.map +7 -0
- package/build-module/box-control/index.mjs +9 -25
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/disabled/index.mjs.map +2 -2
- package/build-module/divider/component.mjs +108 -3
- package/build-module/divider/component.mjs.map +3 -3
- package/build-module/higher-order/with-fallback-styles/index.mjs +20 -46
- package/build-module/higher-order/with-fallback-styles/index.mjs.map +2 -2
- package/build-module/text-control/index.mjs +3 -12
- package/build-module/text-control/index.mjs.map +2 -2
- package/build-module/validated-form-controls/components/text-control.mjs +0 -1
- package/build-module/validated-form-controls/components/text-control.mjs.map +2 -2
- package/build-style/style-rtl.css +3 -19
- package/build-style/style.css +3 -19
- package/build-types/box-control/box-input-control.d.ts +3 -0
- package/build-types/box-control/box-input-control.d.ts.map +1 -0
- package/build-types/box-control/index.d.ts +2 -6
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/stories/index.story.d.ts.map +1 -1
- package/build-types/box-control/types.d.ts +7 -6
- package/build-types/box-control/types.d.ts.map +1 -1
- package/build-types/disabled/index.d.ts +0 -1
- package/build-types/disabled/index.d.ts.map +1 -1
- package/build-types/disabled/stories/index.story.d.ts.map +1 -1
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/index.d.ts +1 -35
- package/build-types/higher-order/with-fallback-styles/index.d.ts.map +1 -1
- package/build-types/higher-order/with-fallback-styles/test/index.d.ts +2 -0
- package/build-types/higher-order/with-fallback-styles/test/index.d.ts.map +1 -0
- package/build-types/icon/stories/index.story.d.ts +0 -1
- package/build-types/icon/stories/index.story.d.ts.map +1 -1
- package/build-types/placeholder/stories/index.story.d.ts.map +1 -1
- package/build-types/resizable-box/index.d.ts +0 -2
- package/build-types/resizable-box/index.d.ts.map +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +0 -2
- package/build-types/resizable-box/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +0 -1
- package/build-types/text-control/index.d.ts.map +1 -1
- package/build-types/text-control/stories/index.story.d.ts.map +1 -1
- package/build-types/text-control/types.d.ts +2 -1
- package/build-types/text-control/types.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/text-control.d.ts +2 -2
- package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
- package/package.json +23 -23
- package/src/box-control/README.md +1 -13
- package/src/box-control/{input-control.tsx → box-input-control.tsx} +4 -4
- package/src/box-control/index.tsx +5 -23
- package/src/box-control/stories/index.story.tsx +1 -3
- package/src/box-control/test/index.tsx +15 -2
- package/src/box-control/types.ts +7 -6
- package/src/card/test/__snapshots__/index.tsx.snap +4 -6
- package/src/checkbox-control/test/__snapshots__/index.tsx.snap +4 -3
- package/src/custom-select-control/test/index.tsx +1 -1
- package/src/disabled/README.md +0 -1
- package/src/disabled/index.tsx +0 -1
- package/src/disabled/stories/index.story.tsx +0 -1
- package/src/divider/component.tsx +27 -3
- package/src/divider/style.module.scss +21 -0
- package/src/divider/test/index.tsx +21 -11
- package/src/higher-order/with-constrained-tabbing/README.md +0 -2
- package/src/higher-order/with-fallback-styles/index.tsx +31 -61
- package/src/higher-order/with-fallback-styles/test/index.tsx +47 -0
- package/src/higher-order/with-focus-return/README.md +0 -2
- package/src/icon/stories/index.story.tsx +0 -15
- package/src/menu/test/index.tsx +0 -16
- package/src/menu-item/test/__snapshots__/index.js.snap +2 -0
- package/src/modal/test/index.tsx +0 -24
- package/src/navigable-container/test/navigable-menu.tsx +0 -16
- package/src/navigable-container/test/tababble-container.tsx +0 -16
- package/src/navigator/test/index.tsx +0 -24
- package/src/notice/test/__snapshots__/index.tsx.snap +1 -0
- package/src/placeholder/stories/index.story.tsx +0 -1
- package/src/resizable-box/index.tsx +1 -2
- package/src/tab-panel/test/index.tsx +0 -17
- package/src/tabs/test/index.tsx +0 -17
- package/src/text-control/README.md +0 -9
- package/src/text-control/index.tsx +3 -14
- package/src/text-control/stories/index.story.tsx +0 -2
- package/src/text-control/style.scss +7 -11
- package/src/text-control/test/text-control.tsx +1 -5
- package/src/text-control/types.ts +2 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -0
- package/src/tools-panel/tools-panel/README.md +0 -2
- package/src/tree-grid/test/index.tsx +0 -23
- package/src/validated-form-controls/components/text-control.tsx +2 -10
- package/build/box-control/input-control.cjs.map +0 -7
- package/build/divider/styles.cjs +0 -98
- package/build/divider/styles.cjs.map +0 -7
- package/build-module/box-control/input-control.mjs.map +0 -7
- package/build-module/divider/styles.mjs +0 -63
- package/build-module/divider/styles.mjs.map +0 -7
- package/build-types/box-control/input-control.d.ts +0 -3
- package/build-types/box-control/input-control.d.ts.map +0 -1
- package/build-types/divider/styles.d.ts +0 -10
- package/build-types/divider/styles.d.ts.map +0 -1
- package/src/divider/styles.ts +0 -81
- package/src/divider/test/__snapshots__/index.tsx.snap +0 -71
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 36.0.0 (2026-06-24)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- The `__next40pxDefaultSize` prop is now true by default. The prop can be safely removed ([#79386](https://github.com/WordPress/gutenberg/pull/79386), [#79419](https://github.com/WordPress/gutenberg/pull/79419)):
|
|
10
|
+
- `BoxControl`
|
|
11
|
+
- `TextControl`
|
|
6
12
|
|
|
7
13
|
### Enhancements
|
|
8
14
|
|
|
@@ -12,11 +18,16 @@
|
|
|
12
18
|
### Bug Fixes
|
|
13
19
|
|
|
14
20
|
- `SandBox`: Fix the viewport-unit (`vh`, `vw`, etc.) stripping so user-supplied HTML using these units in `width`/`height` no longer triggers a runaway resize loop in the preview ([#78677](https://github.com/WordPress/gutenberg/pull/78677)).
|
|
21
|
+
- `BoxControl`: Respect a consumer-supplied `placeholder` passed via `inputProps`, falling back to it when there is no mixed-value placeholder ([#79466](https://github.com/WordPress/gutenberg/pull/79466)).
|
|
15
22
|
|
|
16
23
|
### Internal
|
|
17
24
|
|
|
25
|
+
- `ResizableBox`: Make the `children` prop optional ([#79370](https://github.com/WordPress/gutenberg/pull/79370)).
|
|
26
|
+
- Add documentation and lint guardrails for the ongoing Emotion migration ([#79442](https://github.com/WordPress/gutenberg/pull/79442)).
|
|
27
|
+
- `Divider`: Migrate styles from Emotion to SCSS Modules ([#79444](https://github.com/WordPress/gutenberg/pull/79444)).
|
|
18
28
|
- Adopt `--wpds-dimension-size-*` design tokens [#79093](https://github.com/WordPress/gutenberg/pull/79093).
|
|
19
29
|
- Point the legacy `--wp-components-*` color fallbacks at the design system tokens (`--wpds-*` / `--wp-admin-theme-color*`), so component styles get sensible defaults from the prebuilt token stylesheet without a runtime `<ThemeProvider>` ([#78664](https://github.com/WordPress/gutenberg/pull/78664)).
|
|
30
|
+
- `withFallbackStyles`: Refactor from a class component to a function component with hooks ([#78837](https://github.com/WordPress/gutenberg/pull/78837)).
|
|
20
31
|
|
|
21
32
|
### Documentation
|
|
22
33
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -191,10 +191,10 @@ function useExampleComponent(
|
|
|
191
191
|
);
|
|
192
192
|
|
|
193
193
|
// Any other reusable rendering logic (e.g. computing className, state, event listeners...)
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
const classes = clsx(
|
|
195
|
+
styles.example,
|
|
196
|
+
isVisible && styles.visible,
|
|
197
|
+
className
|
|
198
198
|
);
|
|
199
199
|
|
|
200
200
|
return {
|
|
@@ -416,9 +416,11 @@ On the component's main named export, add a JSDoc comment that includes the main
|
|
|
416
416
|
|
|
417
417
|
## Styling
|
|
418
418
|
|
|
419
|
-
All new
|
|
419
|
+
All new components should be styled using SCSS Modules.
|
|
420
420
|
|
|
421
|
-
|
|
421
|
+
Place component-local styles in a `style.module.scss` file next to the component, import the module from JavaScript or TypeScript, and compose class names with `clsx`. Preserve existing public `components-*` class names where consumers may rely on them. For dynamic values, prefer inline CSS custom properties consumed by the SCSS module. For variants and state, prefer conditional module classes composed with `clsx`.
|
|
422
|
+
|
|
423
|
+
Legacy components may still use Emotion while they are being migrated, but new Emotion usage should not be added.
|
|
422
424
|
|
|
423
425
|
### Deprecating styles
|
|
424
426
|
|
|
@@ -426,10 +428,11 @@ Changing the styles of a non-experimental component must be done with care. To p
|
|
|
426
428
|
|
|
427
429
|
```jsx
|
|
428
430
|
// component.tsx
|
|
431
|
+
import clsx from 'clsx';
|
|
429
432
|
import deprecated from '@wordpress/deprecated';
|
|
430
|
-
import
|
|
433
|
+
import styles from './style.module.scss';
|
|
431
434
|
|
|
432
|
-
function MyComponent( { __nextHasNoOuterMargins = false } ) {
|
|
435
|
+
function MyComponent( { __nextHasNoOuterMargins = false, className } ) {
|
|
433
436
|
if ( ! __nextHasNoOuterMargins ) {
|
|
434
437
|
deprecated( 'Outer margin styles for wp.components.MyComponent', {
|
|
435
438
|
since: '6.0',
|
|
@@ -437,27 +440,31 @@ function MyComponent( { __nextHasNoOuterMargins = false } ) {
|
|
|
437
440
|
hint: 'Set the `__nextHasNoOuterMargins` prop to true to start opting into the new styles, which will become the default in a future version.',
|
|
438
441
|
} );
|
|
439
442
|
}
|
|
440
|
-
return
|
|
443
|
+
return (
|
|
444
|
+
<div
|
|
445
|
+
className={ clsx(
|
|
446
|
+
'components-my-component',
|
|
447
|
+
styles.root,
|
|
448
|
+
! __nextHasNoOuterMargins &&
|
|
449
|
+
styles.deprecatedOuterMargins,
|
|
450
|
+
className
|
|
451
|
+
) }
|
|
452
|
+
/>
|
|
453
|
+
);
|
|
441
454
|
}
|
|
442
455
|
```
|
|
443
456
|
|
|
444
457
|
Styles should be structured so the deprecated styles are cleanly encapsulated, and can be easily removed when the deprecation version arrives.
|
|
445
458
|
|
|
446
|
-
```
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
if ( ! __nextHasNoOuterMargins ) {
|
|
450
|
-
return css`
|
|
451
|
-
margin: 8px;
|
|
452
|
-
`;
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
export const Wrapper = styled.div`
|
|
459
|
+
```scss
|
|
460
|
+
// style.module.scss
|
|
461
|
+
.root {
|
|
457
462
|
margin: 0;
|
|
463
|
+
}
|
|
458
464
|
|
|
459
|
-
|
|
460
|
-
|
|
465
|
+
.deprecatedOuterMargins {
|
|
466
|
+
margin: 8px;
|
|
467
|
+
}
|
|
461
468
|
```
|
|
462
469
|
|
|
463
470
|
Once deprecated, code examples in docs/stories should include the opt-in prop set to `true` so that new consumers are encouraged to adopt it from the start.
|
|
@@ -683,7 +690,7 @@ component-name/
|
|
|
683
690
|
├── hook.ts
|
|
684
691
|
├── index.ts
|
|
685
692
|
├── README.md
|
|
686
|
-
├──
|
|
693
|
+
├── style.module.scss
|
|
687
694
|
└── types.ts
|
|
688
695
|
```
|
|
689
696
|
|
|
@@ -696,13 +703,13 @@ component-family-name/
|
|
|
696
703
|
│ ├── component.tsx
|
|
697
704
|
│ ├── hook.ts
|
|
698
705
|
│ ├── README.md
|
|
699
|
-
│ └──
|
|
706
|
+
│ └── style.module.scss
|
|
700
707
|
├── sub-component-name/
|
|
701
708
|
│ ├── index.ts
|
|
702
709
|
│ ├── component.tsx
|
|
703
710
|
│ ├── hook.ts
|
|
704
711
|
│ ├── README.md
|
|
705
|
-
│ └──
|
|
712
|
+
│ └── style.module.scss
|
|
706
713
|
├── stories
|
|
707
714
|
│ └── index.js
|
|
708
715
|
├── test
|
|
@@ -742,7 +749,7 @@ This second approach involves creating a new, separate version (ie. export) of t
|
|
|
742
749
|
|
|
743
750
|
If possible, the legacy version of the component should be rewritten so that it uses the same underlying implementation of the new version, with an extra API "translation" layer to adapt the legacy API surface to the new API surface, e.g:
|
|
744
751
|
|
|
745
|
-
```
|
|
752
|
+
```tsx
|
|
746
753
|
// legacy-component/index.tsx
|
|
747
754
|
|
|
748
755
|
function LegacyComponent( props ) {
|
|
@@ -27,12 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/components/src/box-control/input-control.tsx
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
30
|
+
// packages/components/src/box-control/box-input-control.tsx
|
|
31
|
+
var box_input_control_exports = {};
|
|
32
|
+
__export(box_input_control_exports, {
|
|
33
33
|
default: () => BoxInputControl
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(box_input_control_exports);
|
|
36
36
|
var import_compose = require("@wordpress/compose");
|
|
37
37
|
var import_i18n = require("@wordpress/i18n");
|
|
38
38
|
var import_element = require("@wordpress/element");
|
|
@@ -80,7 +80,6 @@ function getSidesToModify(side, sides, isAlt) {
|
|
|
80
80
|
return modifiedSides.filter((s) => allowedSides.has(s));
|
|
81
81
|
}
|
|
82
82
|
function BoxInputControl({
|
|
83
|
-
__next40pxDefaultSize,
|
|
84
83
|
onChange = noop,
|
|
85
84
|
onFocus = noop,
|
|
86
85
|
values,
|
|
@@ -91,6 +90,7 @@ function BoxInputControl({
|
|
|
91
90
|
min = 0,
|
|
92
91
|
presets,
|
|
93
92
|
presetKey,
|
|
93
|
+
placeholder: placeholderProp,
|
|
94
94
|
...props
|
|
95
95
|
}) {
|
|
96
96
|
const defaultValuesToModify = getSidesToModify(side, sides);
|
|
@@ -179,7 +179,7 @@ function BoxInputControl({
|
|
|
179
179
|
...props,
|
|
180
180
|
min,
|
|
181
181
|
__shouldNotWarnDeprecated36pxSize: true,
|
|
182
|
-
__next40pxDefaultSize,
|
|
182
|
+
__next40pxDefaultSize: true,
|
|
183
183
|
className: "component-box-control__unit-control",
|
|
184
184
|
id: inputId,
|
|
185
185
|
isPressEnterToChange: true,
|
|
@@ -189,11 +189,11 @@ function BoxInputControl({
|
|
|
189
189
|
onUnitChange: handleOnUnitChange,
|
|
190
190
|
onFocus: handleOnFocus,
|
|
191
191
|
label: import_utils2.LABELS[side],
|
|
192
|
-
placeholder: mixedPlaceholder,
|
|
192
|
+
placeholder: mixedPlaceholder ?? placeholderProp,
|
|
193
193
|
hideLabelFromVision: true
|
|
194
194
|
})
|
|
195
195
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_control_styles.FlexedRangeControl, {
|
|
196
|
-
__next40pxDefaultSize,
|
|
196
|
+
__next40pxDefaultSize: true,
|
|
197
197
|
__shouldNotWarnDeprecated36pxSize: true,
|
|
198
198
|
"aria-controls": inputId,
|
|
199
199
|
label: import_utils2.LABELS[side],
|
|
@@ -236,4 +236,4 @@ function BoxInputControl({
|
|
|
236
236
|
})]
|
|
237
237
|
}, `box-control-${side}`);
|
|
238
238
|
}
|
|
239
|
-
//# sourceMappingURL=input-control.cjs.map
|
|
239
|
+
//# sourceMappingURL=box-input-control.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/box-control/box-input-control.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { settings } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport { CUSTOM_VALUE_SETTINGS, getMergedValue, getAllowedSides, getPresetIndexFromValue, getPresetValueFromIndex, isValuePreset, isValuesDefined, isValueMixed, LABELS } from './utils';\nimport { FlexedBoxControlIcon, FlexedRangeControl, InputWrapper, StyledUnitControl } from './styles/box-control-styles';\nimport Button from '../button';\nimport { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\nfunction getSidesToModify(side, sides, isAlt) {\n const allowedSides = getAllowedSides(sides);\n let modifiedSides = [];\n switch (side) {\n case 'all':\n modifiedSides = ['top', 'bottom', 'left', 'right'];\n break;\n case 'horizontal':\n modifiedSides = ['left', 'right'];\n break;\n case 'vertical':\n modifiedSides = ['top', 'bottom'];\n break;\n default:\n modifiedSides = [side];\n }\n if (isAlt) {\n switch (side) {\n case 'top':\n modifiedSides.push('bottom');\n break;\n case 'bottom':\n modifiedSides.push('top');\n break;\n case 'left':\n modifiedSides.push('left');\n break;\n case 'right':\n modifiedSides.push('right');\n break;\n }\n }\n return modifiedSides.filter(s => allowedSides.has(s));\n}\nexport default function BoxInputControl({\n onChange = noop,\n onFocus = noop,\n values,\n selectedUnits,\n setSelectedUnits,\n sides,\n side,\n min = 0,\n presets,\n presetKey,\n placeholder: placeholderProp,\n ...props\n}) {\n const defaultValuesToModify = getSidesToModify(side, sides);\n const handleOnFocus = event => {\n onFocus(event, {\n side\n });\n };\n const handleOnChange = nextValues => {\n onChange(nextValues);\n };\n const handleRawOnValueChange = next => {\n const nextValues = {\n ...values\n };\n defaultValuesToModify.forEach(modifiedSide => {\n nextValues[modifiedSide] = next;\n });\n handleOnChange(nextValues);\n };\n const handleOnValueChange = (next, extra) => {\n const nextValues = {\n ...values\n };\n const isNumeric = next !== undefined && !isNaN(parseFloat(next));\n const nextValue = isNumeric ? next : undefined;\n const modifiedSides = getSidesToModify(side, sides,\n /**\n * Supports changing pair sides. For example, holding the ALT key\n * when changing the TOP will also update BOTTOM.\n */\n // @ts-expect-error - TODO: event.altKey is only present when the change event was\n // triggered by a keyboard event. Should this feature be implemented differently so\n // it also works with drag events?\n !!extra?.event.altKey);\n modifiedSides.forEach(modifiedSide => {\n nextValues[modifiedSide] = nextValue;\n });\n handleOnChange(nextValues);\n };\n const handleOnUnitChange = next => {\n const newUnits = {\n ...selectedUnits\n };\n defaultValuesToModify.forEach(modifiedSide => {\n newUnits[modifiedSide] = next;\n });\n setSelectedUnits(newUnits);\n };\n const mergedValue = getMergedValue(values, defaultValuesToModify);\n const hasValues = isValuesDefined(values);\n const isMixed = hasValues && defaultValuesToModify.length > 1 && isValueMixed(values, defaultValuesToModify);\n const [parsedQuantity, parsedUnit] = parseQuantityAndUnitFromRawValue(mergedValue);\n const computedUnit = hasValues ? parsedUnit : selectedUnits[defaultValuesToModify[0]];\n const generatedId = useInstanceId(BoxInputControl, 'box-control-input');\n const inputId = [generatedId, side].join('-');\n const isMixedUnit = defaultValuesToModify.length > 1 && mergedValue === undefined && defaultValuesToModify.some(s => selectedUnits[s] !== computedUnit);\n const usedValue = mergedValue === undefined && computedUnit ? computedUnit : mergedValue;\n const mixedPlaceholder = isMixed || isMixedUnit ? __('Mixed') : undefined;\n const hasPresets = presets && presets.length > 0 && presetKey;\n const hasPresetValue = hasPresets && mergedValue !== undefined && !isMixed && isValuePreset(mergedValue, presetKey);\n const [showCustomValueControl, setShowCustomValueControl] = useState(!hasPresets || !hasPresetValue && !isMixed && mergedValue !== undefined);\n const presetIndex = hasPresetValue ? getPresetIndexFromValue(mergedValue, presetKey, presets) : undefined;\n const marks = hasPresets ? [{\n value: 0,\n label: '',\n tooltip: __('None')\n }, ...presets.map((preset, index) => ({\n value: index + 1,\n label: '',\n tooltip: preset.name ?? preset.slug\n }))] : [];\n return /*#__PURE__*/_jsxs(InputWrapper, {\n expanded: true,\n children: [/*#__PURE__*/_jsx(FlexedBoxControlIcon, {\n side: side,\n sides: sides\n }), showCustomValueControl && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(Tooltip, {\n placement: \"top-end\",\n text: LABELS[side],\n children: /*#__PURE__*/_jsx(StyledUnitControl, {\n ...props,\n min: min,\n __shouldNotWarnDeprecated36pxSize: true,\n __next40pxDefaultSize: true,\n className: \"component-box-control__unit-control\",\n id: inputId,\n isPressEnterToChange: true,\n disableUnits: isMixed || isMixedUnit,\n value: usedValue,\n onChange: handleOnValueChange,\n onUnitChange: handleOnUnitChange,\n onFocus: handleOnFocus,\n label: LABELS[side],\n placeholder: mixedPlaceholder ?? placeholderProp,\n hideLabelFromVision: true\n })\n }), /*#__PURE__*/_jsx(FlexedRangeControl, {\n __next40pxDefaultSize: true,\n __shouldNotWarnDeprecated36pxSize: true,\n \"aria-controls\": inputId,\n label: LABELS[side],\n hideLabelFromVision: true,\n onChange: newValue => {\n handleOnValueChange(newValue !== undefined ? [newValue, computedUnit].join('') : undefined);\n },\n min: isFinite(min) ? min : 0,\n max: CUSTOM_VALUE_SETTINGS[computedUnit ?? 'px']?.max ?? 10,\n step: CUSTOM_VALUE_SETTINGS[computedUnit ?? 'px']?.step ?? 0.1,\n value: parsedQuantity ?? 0,\n withInputField: false\n })]\n }), hasPresets && !showCustomValueControl && /*#__PURE__*/_jsx(FlexedRangeControl, {\n __next40pxDefaultSize: true,\n className: \"spacing-sizes-control__range-control\",\n value: presetIndex !== undefined ? presetIndex + 1 : 0,\n onChange: newIndex => {\n const newValue = newIndex === 0 || newIndex === undefined ? undefined : getPresetValueFromIndex(newIndex - 1, presetKey, presets);\n handleRawOnValueChange(newValue);\n },\n withInputField: false,\n \"aria-valuenow\": presetIndex !== undefined ? presetIndex + 1 : 0,\n \"aria-valuetext\": marks[presetIndex !== undefined ? presetIndex + 1 : 0].tooltip,\n renderTooltipContent: index => marks[!index ? 0 : index].tooltip,\n min: 0,\n max: marks.length - 1,\n marks: marks,\n label: LABELS[side],\n hideLabelFromVision: true\n }), hasPresets && /*#__PURE__*/_jsx(Button, {\n label: showCustomValueControl ? __('Use size preset') : __('Set custom size'),\n icon: settings,\n onClick: () => {\n setShowCustomValueControl(!showCustomValueControl);\n },\n isPressed: showCustomValueControl,\n size: \"small\",\n iconSize: 24\n })]\n }, `box-control-${side}`);\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,kBAAmB;AACnB,qBAAyB;AACzB,mBAAyB;AAKzB,qBAAoB;AACpB,mBAAiD;AACjD,IAAAA,gBAA+K;AAC/K,gCAA0F;AAC1F,oBAAmB;AACnB,yBAAkE;AAClE,IAAM,OAAO,MAAM;AAAC;AACpB,SAAS,iBAAiB,MAAM,OAAO,OAAO;AAC5C,QAAM,mBAAe,+BAAgB,KAAK;AAC1C,MAAI,gBAAgB,CAAC;AACrB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,sBAAgB,CAAC,OAAO,UAAU,QAAQ,OAAO;AACjD;AAAA,IACF,KAAK;AACH,sBAAgB,CAAC,QAAQ,OAAO;AAChC;AAAA,IACF,KAAK;AACH,sBAAgB,CAAC,OAAO,QAAQ;AAChC;AAAA,IACF;AACE,sBAAgB,CAAC,IAAI;AAAA,EACzB;AACA,MAAI,OAAO;AACT,YAAQ,MAAM;AAAA,MACZ,KAAK;AACH,sBAAc,KAAK,QAAQ;AAC3B;AAAA,MACF,KAAK;AACH,sBAAc,KAAK,KAAK;AACxB;AAAA,MACF,KAAK;AACH,sBAAc,KAAK,MAAM;AACzB;AAAA,MACF,KAAK;AACH,sBAAc,KAAK,OA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,WAAW,GAAG,WAAW,OAAO;AAChI,+BAAuB,QAAQ;AAAA,MACjC;AAAA,MACA,gBAAgB;AAAA,MAChB,iBAAiB,gBAAgB,SAAY,cAAc,IAAI;AAAA,MAC/D,kBAAkB,MAAM,gBAAgB,SAAY,cAAc,IAAI,CAAC,EAAE;AAAA,MACzE,sBAAsB,WAAS,MAAM,CAAC,QAAQ,IAAI,KAAK,EAAE;AAAA,MACzD,KAAK;AAAA,MACL,KAAK,MAAM,SAAS;AAAA,MACpB;AAAA,MACA,OAAO,qBAAO,IAAI;AAAA,MAClB,qBAAqB;AAAA,IACvB,CAAC,GAAG,cAA2B,uCAAAA,KAAK,cAAAG,SAAQ;AAAA,MAC1C,OAAO,6BAAyB,gBAAG,iBAAiB,QAAI,gBAAG,iBAAiB;AAAA,MAC5E,MAAM;AAAA,MACN,SAAS,MAAM;AACb,kCAA0B,CAAC,sBAAsB;AAAA,MACnD;AAAA,MACA,WAAW;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACZ,CAAC,CAAC;AAAA,EACJ,GAAG,eAAe,IAAI,EAAE;AAC1B;",
|
|
6
|
+
"names": ["import_utils", "_jsxs", "_jsx", "_Fragment", "Tooltip", "Button"]
|
|
7
|
+
}
|
|
@@ -38,14 +38,13 @@ var import_element = require("@wordpress/element");
|
|
|
38
38
|
var import_i18n = require("@wordpress/i18n");
|
|
39
39
|
var import_warning = __toESM(require("@wordpress/warning"));
|
|
40
40
|
var import_base_control = require("../base-control/index.cjs");
|
|
41
|
-
var
|
|
41
|
+
var import_box_input_control = __toESM(require("./box-input-control.cjs"));
|
|
42
42
|
var import_linked_button = __toESM(require("./linked-button.cjs"));
|
|
43
43
|
var import_grid = require("../grid/index.cjs");
|
|
44
44
|
var import_box_control_styles = require("./styles/box-control-styles.cjs");
|
|
45
45
|
var import_utils = require("../unit-control/utils.cjs");
|
|
46
46
|
var import_utils2 = require("./utils.cjs");
|
|
47
47
|
var import_hooks = require("../utils/hooks/index.cjs");
|
|
48
|
-
var import_deprecated_36px_size = require("../utils/deprecated-36px-size.cjs");
|
|
49
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
49
|
var defaultInputProps = {
|
|
51
50
|
min: 0
|
|
@@ -57,7 +56,6 @@ function useUniqueId(idProp) {
|
|
|
57
56
|
return idProp || instanceId;
|
|
58
57
|
}
|
|
59
58
|
function BoxControl({
|
|
60
|
-
__next40pxDefaultSize = false,
|
|
61
59
|
id: idProp,
|
|
62
60
|
inputProps = defaultInputProps,
|
|
63
61
|
onChange = noop,
|
|
@@ -114,15 +112,9 @@ function BoxControl({
|
|
|
114
112
|
setSelectedUnits,
|
|
115
113
|
sides,
|
|
116
114
|
values: inputValues,
|
|
117
|
-
__next40pxDefaultSize,
|
|
118
115
|
presets,
|
|
119
116
|
presetKey
|
|
120
117
|
};
|
|
121
|
-
(0, import_deprecated_36px_size.maybeWarnDeprecated36pxSize)({
|
|
122
|
-
componentName: "BoxControl",
|
|
123
|
-
__next40pxDefaultSize,
|
|
124
|
-
size: void 0
|
|
125
|
-
});
|
|
126
118
|
const sidesToRender = (0, import_utils2.getAllowedSides)(sides);
|
|
127
119
|
if (presets && !presetKey || !presets && presetKey) {
|
|
128
120
|
const definedProp = presets ? "presets" : "presetKey";
|
|
@@ -139,7 +131,7 @@ function BoxControl({
|
|
|
139
131
|
id: headingId,
|
|
140
132
|
children: label
|
|
141
133
|
}), isLinked && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_control_styles.InputWrapper, {
|
|
142
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
134
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_input_control.default, {
|
|
143
135
|
side: "all",
|
|
144
136
|
...inputControlProps
|
|
145
137
|
})
|
|
@@ -148,21 +140,13 @@ function BoxControl({
|
|
|
148
140
|
onClick: toggleLinked,
|
|
149
141
|
isLinked
|
|
150
142
|
})
|
|
151
|
-
}), !isLinked && splitOnAxis && ["vertical", "horizontal"].map((axis) => (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
)), !isLinked && !splitOnAxis && Array.from(sidesToRender).map((axis) => (
|
|
159
|
-
// Disable reason: the parent component is handling the __next40pxDefaultSize prop
|
|
160
|
-
// eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop
|
|
161
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_input_control.default, {
|
|
162
|
-
side: axis,
|
|
163
|
-
...inputControlProps
|
|
164
|
-
}, axis)
|
|
165
|
-
)), allowReset && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_control_styles.ResetButton, {
|
|
143
|
+
}), !isLinked && splitOnAxis && ["vertical", "horizontal"].map((axis) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_input_control.default, {
|
|
144
|
+
side: axis,
|
|
145
|
+
...inputControlProps
|
|
146
|
+
}, axis)), !isLinked && !splitOnAxis && Array.from(sidesToRender).map((axis) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_input_control.default, {
|
|
147
|
+
side: axis,
|
|
148
|
+
...inputControlProps
|
|
149
|
+
}, axis)), allowReset && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_box_control_styles.ResetButton, {
|
|
166
150
|
className: "component-box-control__reset-button",
|
|
167
151
|
variant: "secondary",
|
|
168
152
|
size: "small",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/box-control/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,qBAAyB;AACzB,kBAAmB;AACnB,qBAAoB;AAKpB,0BAA4B;AAC5B
|
|
6
|
-
"names": ["import_utils", "warning", "_jsxs", "_jsx", "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { BaseControl } from '../base-control';\nimport BoxInputControl from './box-input-control';\nimport LinkedButton from './linked-button';\nimport { Grid } from '../grid';\nimport { InputWrapper, ResetButton, LinkedButtonWrapper } from './styles/box-control-styles';\nimport { parseQuantityAndUnitFromRawValue } from '../unit-control/utils';\nimport { DEFAULT_VALUES, isValueMixed, isValuesDefined, getAllowedSides } from './utils';\nimport { useControlledState } from '../utils/hooks';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst defaultInputProps = {\n min: 0\n};\nconst noop = () => {};\nfunction useUniqueId(idProp) {\n const instanceId = useInstanceId(BoxControl, 'inspector-box-control');\n return idProp || instanceId;\n}\n\n/**\n * A control that lets users set values for top, right, bottom, and left. Can be\n * used as an input control for values like `padding` or `margin`.\n *\n * ```jsx\n * import { useState } from 'react';\n * import { BoxControl } from '@wordpress/components';\n *\n * function Example() {\n * const [ values, setValues ] = useState( {\n * top: '50px',\n * left: '10%',\n * right: '10%',\n * bottom: '50px',\n * } );\n *\n * return (\n * <BoxControl values={ values } onChange={ setValues } />\n * );\n * };\n * ```\n */\nfunction BoxControl({\n id: idProp,\n inputProps = defaultInputProps,\n onChange = noop,\n label = __('Box Control'),\n values: valuesProp,\n units,\n sides,\n splitOnAxis = false,\n allowReset = true,\n resetValues = DEFAULT_VALUES,\n presets,\n presetKey,\n onMouseOver,\n onMouseOut\n}) {\n const [values, setValues] = useControlledState(valuesProp, {\n fallback: DEFAULT_VALUES\n });\n const inputValues = values || DEFAULT_VALUES;\n const hasInitialValue = isValuesDefined(valuesProp);\n const hasOneSide = sides?.length === 1;\n const [isDirty, setIsDirty] = useState(hasInitialValue);\n const [isLinked, setIsLinked] = useState(!hasInitialValue || !isValueMixed(inputValues) || hasOneSide);\n\n // Tracking selected units via internal state allows filtering of CSS unit\n // only values from being saved while maintaining preexisting unit selection\n // behaviour. Filtering CSS only values prevents invalid style values.\n const [selectedUnits, setSelectedUnits] = useState({\n top: parseQuantityAndUnitFromRawValue(valuesProp?.top)[1],\n right: parseQuantityAndUnitFromRawValue(valuesProp?.right)[1],\n bottom: parseQuantityAndUnitFromRawValue(valuesProp?.bottom)[1],\n left: parseQuantityAndUnitFromRawValue(valuesProp?.left)[1]\n });\n const id = useUniqueId(idProp);\n const headingId = `${id}-heading`;\n const toggleLinked = () => {\n setIsLinked(!isLinked);\n };\n const handleOnChange = nextValues => {\n onChange(nextValues);\n setValues(nextValues);\n setIsDirty(true);\n };\n const handleOnReset = () => {\n onChange(resetValues);\n setValues(resetValues);\n setSelectedUnits(resetValues);\n setIsDirty(false);\n };\n const inputControlProps = {\n onMouseOver,\n onMouseOut,\n ...inputProps,\n onChange: handleOnChange,\n isLinked,\n units,\n selectedUnits,\n setSelectedUnits,\n sides,\n values: inputValues,\n presets,\n presetKey\n };\n const sidesToRender = getAllowedSides(sides);\n if (presets && !presetKey || !presets && presetKey) {\n const definedProp = presets ? 'presets' : 'presetKey';\n const missingProp = presets ? 'presetKey' : 'presets';\n globalThis.SCRIPT_DEBUG === true ? warning(`wp.components.BoxControl: the '${missingProp}' prop is required when the '${definedProp}' prop is defined.`) : void 0;\n }\n return /*#__PURE__*/_jsxs(Grid, {\n id: id,\n columns: 3,\n templateColumns: \"1fr min-content min-content\",\n role: \"group\",\n \"aria-labelledby\": headingId,\n children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {\n id: headingId,\n children: label\n }), isLinked && /*#__PURE__*/_jsx(InputWrapper, {\n children: /*#__PURE__*/_jsx(BoxInputControl, {\n side: \"all\",\n ...inputControlProps\n })\n }), !hasOneSide && /*#__PURE__*/_jsx(LinkedButtonWrapper, {\n children: /*#__PURE__*/_jsx(LinkedButton, {\n onClick: toggleLinked,\n isLinked: isLinked\n })\n }), !isLinked && splitOnAxis && ['vertical', 'horizontal'].map(axis => /*#__PURE__*/_jsx(BoxInputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), !isLinked && !splitOnAxis && Array.from(sidesToRender).map(axis => /*#__PURE__*/_jsx(BoxInputControl, {\n side: axis,\n ...inputControlProps\n }, axis)), allowReset && /*#__PURE__*/_jsx(ResetButton, {\n className: \"component-box-control__reset-button\",\n variant: \"secondary\",\n size: \"small\",\n onClick: handleOnReset,\n disabled: !isDirty,\n children: __('Reset')\n })]\n });\n}\nexport default BoxControl;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,qBAAyB;AACzB,kBAAmB;AACnB,qBAAoB;AAKpB,0BAA4B;AAC5B,+BAA4B;AAC5B,2BAAyB;AACzB,kBAAqB;AACrB,gCAA+D;AAC/D,mBAAiD;AACjD,IAAAA,gBAA+E;AAC/E,mBAAmC;AACnC,yBAA2C;AAC3C,IAAM,oBAAoB;AAAA,EACxB,KAAK;AACP;AACA,IAAM,OAAO,MAAM;AAAC;AACpB,SAAS,YAAY,QAAQ;AAC3B,QAAM,iBAAa,8BAAc,YAAY,uBAAuB;AACpE,SAAO,UAAU;AACnB;AAwBA,SAAS,WAAW;AAAA,EAClB,IAAI;AAAA,EACJ,aAAa;AAAA,EACb,WAAW;AAAA,EACX,YAAQ,gBAAG,aAAa;AAAA,EACxB,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG;AACD,QAAM,CAAC,QAAQ,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7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/disabled/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { disabledStyles } from './styles/disabled-styles';\nimport { useCx } from '../utils';\nimport Context from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst {\n Consumer,\n Provider\n} = Context;\n\n/**\n * `Disabled` is a component which disables descendant tabbable elements and\n * prevents pointer interaction.\n *\n * _Note: this component may not behave as expected in browsers that don't\n * support the `inert` HTML attribute. We recommend adding the official WICG\n * polyfill when using this component in your project._\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n *\n * ```jsx\n * import { Button, Disabled, TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDisabled = () => {\n * \tconst [ isDisabled, setIsDisabled ] = useState( true );\n *\n *\tlet input = (\n *\t\t<TextControl\n *\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;AAC/B,mBAAsB;AACtB,qBAAoB;AACpB,yBAA4B;AAC5B,IAAM;AAAA,EACJ;AAAA,EACA;AACF,IAAI,eAAAA;
|
|
4
|
+
"sourcesContent": ["import { disabledStyles } from './styles/disabled-styles';\nimport { useCx } from '../utils';\nimport Context from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst {\n Consumer,\n Provider\n} = Context;\n\n/**\n * `Disabled` is a component which disables descendant tabbable elements and\n * prevents pointer interaction.\n *\n * _Note: this component may not behave as expected in browsers that don't\n * support the `inert` HTML attribute. We recommend adding the official WICG\n * polyfill when using this component in your project._\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n *\n * ```jsx\n * import { Button, Disabled, TextControl } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDisabled = () => {\n * \tconst [ isDisabled, setIsDisabled ] = useState( true );\n *\n *\tlet input = (\n *\t\t<TextControl\n *\t\t\tlabel=\"Input\"\n *\t\t\tonChange={ () => {} }\n *\t\t/>\n *\t);\n * \tif ( isDisabled ) {\n * \t\tinput = <Disabled>{ input }</Disabled>;\n * \t}\n *\n * \tconst toggleDisabled = () => {\n * \t\tsetIsDisabled( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ input }\n * \t\t\t<Button variant=\"primary\" onClick={ toggleDisabled }>\n * \t\t\t\tToggle Disabled\n * \t\t\t</Button>\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nfunction Disabled({\n className,\n children,\n isDisabled = true,\n ...props\n}) {\n const cx = useCx();\n return /*#__PURE__*/_jsx(Provider, {\n value: isDisabled,\n children: /*#__PURE__*/_jsx(\"div\", {\n // @ts-ignore Reason: inert is a recent HTML attribute\n inert: isDisabled ? 'true' : undefined,\n className: isDisabled ? cx(disabledStyles, className, 'components-disabled') : undefined,\n ...props,\n children: children\n })\n });\n}\nDisabled.Context = Context;\nDisabled.Consumer = Consumer;\nexport default Disabled;"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;AAC/B,mBAAsB;AACtB,qBAAoB;AACpB,yBAA4B;AAC5B,IAAM;AAAA,EACJ;AAAA,EACA;AACF,IAAI,eAAAA;AA4CJ,SAAS,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,GAAG;AACL,GAAG;AACD,QAAM,SAAK,oBAAM;AACjB,SAAoB,uCAAAC,KAAK,UAAU;AAAA,IACjC,OAAO;AAAA,IACP,UAAuB,uCAAAA,KAAK,OAAO;AAAA;AAAA,MAEjC,OAAO,aAAa,SAAS;AAAA,MAC7B,WAAW,aAAa,GAAG,uCAAgB,WAAW,qBAAqB,IAAI;AAAA,MAC/E,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AACA,SAAS,UAAU,eAAAD;AACnB,SAAS,WAAW;AACpB,IAAO,mBAAQ;",
|
|
6
6
|
"names": ["Context", "_jsx"]
|
|
7
7
|
}
|
|
@@ -35,13 +35,118 @@ __export(component_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(component_exports);
|
|
37
37
|
var Ariakit = __toESM(require("@ariakit/react"));
|
|
38
|
+
var import_clsx = __toESM(require("clsx"));
|
|
38
39
|
var import_context = require("../context/index.cjs");
|
|
39
|
-
var
|
|
40
|
+
var import_space = require("../utils/space.cjs");
|
|
41
|
+
|
|
42
|
+
// packages/style-runtime/src/index.ts
|
|
43
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
44
|
+
function getRuntime() {
|
|
45
|
+
const globalScope = globalThis;
|
|
46
|
+
if (globalScope.__wpStyleRuntime) {
|
|
47
|
+
return globalScope.__wpStyleRuntime;
|
|
48
|
+
}
|
|
49
|
+
globalScope.__wpStyleRuntime = {
|
|
50
|
+
documents: /* @__PURE__ */ new Map(),
|
|
51
|
+
styles: /* @__PURE__ */ new Map(),
|
|
52
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
53
|
+
};
|
|
54
|
+
if (typeof document !== "undefined") {
|
|
55
|
+
registerDocument(document);
|
|
56
|
+
}
|
|
57
|
+
return globalScope.__wpStyleRuntime;
|
|
58
|
+
}
|
|
59
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
60
|
+
if (!targetDocument.head) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {
|
|
64
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
function injectStyle(targetDocument, hash, css) {
|
|
71
|
+
if (!targetDocument.head) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const runtime = getRuntime();
|
|
75
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
76
|
+
if (!injectedStyles) {
|
|
77
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
78
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
79
|
+
}
|
|
80
|
+
if (injectedStyles.has(hash)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
84
|
+
injectedStyles.add(hash);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const style = targetDocument.createElement("style");
|
|
88
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
89
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
90
|
+
targetDocument.head.appendChild(style);
|
|
91
|
+
injectedStyles.add(hash);
|
|
92
|
+
}
|
|
93
|
+
function registerDocument(targetDocument) {
|
|
94
|
+
const runtime = getRuntime();
|
|
95
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
96
|
+
for (const [hash, css] of runtime.styles) {
|
|
97
|
+
injectStyle(targetDocument, hash, css);
|
|
98
|
+
}
|
|
99
|
+
return () => {
|
|
100
|
+
const count = runtime.documents.get(targetDocument);
|
|
101
|
+
if (count === void 0) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (count <= 1) {
|
|
105
|
+
runtime.documents.delete(targetDocument);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function registerStyle(hash, css) {
|
|
112
|
+
const runtime = getRuntime();
|
|
113
|
+
runtime.styles.set(hash, css);
|
|
114
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
115
|
+
injectStyle(targetDocument, hash, css);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// packages/components/src/divider/style.module.scss
|
|
120
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
121
|
+
registerStyle("f2c8d759d8", ".e10c29fc10c181dc__divider{border:0;margin:0}.e10c29fc10c181dc__divider[aria-orientation=horizontal]{block-size:0;border-block-end:1px solid currentColor;inline-size:auto;margin-block-end:var(--wp-components-divider-margin-end,0);margin-block-start:var(--wp-components-divider-margin-start,0)}.e10c29fc10c181dc__divider[aria-orientation=vertical]{block-size:auto;border-inline-end:1px solid currentColor;display:inline;inline-size:0;margin-inline-end:var(--wp-components-divider-margin-end,0);margin-inline-start:var(--wp-components-divider-margin-start,0)}");
|
|
122
|
+
}
|
|
123
|
+
var style_module_default = { "divider": "e10c29fc10c181dc__divider" };
|
|
124
|
+
|
|
125
|
+
// packages/components/src/divider/component.tsx
|
|
40
126
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
127
|
function UnconnectedDivider(props, forwardedRef) {
|
|
42
|
-
const
|
|
128
|
+
const {
|
|
129
|
+
className,
|
|
130
|
+
margin,
|
|
131
|
+
marginEnd,
|
|
132
|
+
marginStart,
|
|
133
|
+
style,
|
|
134
|
+
...contextProps
|
|
135
|
+
} = (0, import_context.useContextSystem)(props, "Divider");
|
|
136
|
+
const dividerStyle = {
|
|
137
|
+
...style
|
|
138
|
+
};
|
|
139
|
+
const resolvedMarginStart = (0, import_space.space)(marginStart ?? margin);
|
|
140
|
+
const resolvedMarginEnd = (0, import_space.space)(marginEnd ?? margin);
|
|
141
|
+
if (resolvedMarginStart) {
|
|
142
|
+
dividerStyle["--wp-components-divider-margin-start"] = resolvedMarginStart;
|
|
143
|
+
}
|
|
144
|
+
if (resolvedMarginEnd) {
|
|
145
|
+
dividerStyle["--wp-components-divider-margin-end"] = resolvedMarginEnd;
|
|
146
|
+
}
|
|
43
147
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Ariakit.Separator, {
|
|
44
|
-
|
|
148
|
+
className: (0, import_clsx.default)(style_module_default.divider, className),
|
|
149
|
+
style: dividerStyle,
|
|
45
150
|
...contextProps,
|
|
46
151
|
ref: forwardedRef
|
|
47
152
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/divider/component.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\n\n/**\n * Internal dependencies\n */\n\nimport { contextConnect, useContextSystem } from '../context';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,cAAyB;
|
|
6
|
-
"names": ["_jsx"]
|
|
3
|
+
"sources": ["../../src/divider/component.tsx", "../../../style-runtime/src/index.ts", "../../src/divider/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as Ariakit from '@ariakit/react';\nimport clsx from 'clsx';\n\n/**\n * Internal dependencies\n */\n\nimport { contextConnect, useContextSystem } from '../context';\nimport { space } from '../utils/space';\nimport styles from './style.module.scss';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction UnconnectedDivider(props, forwardedRef) {\n const {\n className,\n margin,\n marginEnd,\n marginStart,\n style,\n ...contextProps\n } = useContextSystem(props, 'Divider');\n const dividerStyle = {\n ...style\n };\n const resolvedMarginStart = space(marginStart ?? margin);\n const resolvedMarginEnd = space(marginEnd ?? margin);\n if (resolvedMarginStart) {\n dividerStyle['--wp-components-divider-margin-start'] = resolvedMarginStart;\n }\n if (resolvedMarginEnd) {\n dividerStyle['--wp-components-divider-margin-end'] = resolvedMarginEnd;\n }\n return /*#__PURE__*/_jsx(Ariakit.Separator, {\n className: clsx(styles.divider, className),\n style: dividerStyle,\n ...contextProps,\n ref: forwardedRef\n });\n}\n\n/**\n * `Divider` is a layout component that separates groups of related content.\n *\n * ```js\n * import {\n * \t\t__experimentalDivider as Divider,\n * \t\t__experimentalText as Text,\n * \t\t__experimentalVStack as VStack,\n * } from `@wordpress/components`;\n *\n * function Example() {\n * \treturn (\n * \t\t<VStack spacing={4}>\n * \t\t\t<Text>Some text here</Text>\n * \t\t\t<Divider />\n * \t\t\t<Text>Some more text here</Text>\n * \t\t</VStack>\n * \t);\n * }\n * ```\n */\nexport const Divider = contextConnect(UnconnectedDivider, 'Divider');\nexport default Divider;", "const STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n const globalScope = globalThis;\n if (globalScope.__wpStyleRuntime) {\n return globalScope.__wpStyleRuntime;\n }\n globalScope.__wpStyleRuntime = {\n documents: new Map(),\n styles: new Map(),\n injectedStyles: new WeakMap()\n };\n if (typeof document !== 'undefined') {\n registerDocument(document);\n }\n return globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(targetDocument, hash) {\n if (!targetDocument.head) {\n return false;\n }\n for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) {\n if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle(targetDocument, hash, css) {\n if (!targetDocument.head) {\n return;\n }\n const runtime = getRuntime();\n let injectedStyles = runtime.injectedStyles.get(targetDocument);\n if (!injectedStyles) {\n injectedStyles = new Set();\n runtime.injectedStyles.set(targetDocument, injectedStyles);\n }\n if (injectedStyles.has(hash)) {\n return;\n }\n\n // Older generated CSS module output can still inject matching style tags\n // after this document's cache is created, so keep the DOM as the fallback\n // source of truth on cache misses.\n if (documentContainsStyleHash(targetDocument, hash)) {\n injectedStyles.add(hash);\n return;\n }\n const style = targetDocument.createElement('style');\n style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);\n style.appendChild(targetDocument.createTextNode(css));\n targetDocument.head.appendChild(style);\n injectedStyles.add(hash);\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument(targetDocument) {\n const runtime = getRuntime();\n runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);\n for (const [hash, css] of runtime.styles) {\n injectStyle(targetDocument, hash, css);\n }\n return () => {\n const count = runtime.documents.get(targetDocument);\n if (count === undefined) {\n return;\n }\n if (count <= 1) {\n runtime.documents.delete(targetDocument);\n return;\n }\n runtime.documents.set(targetDocument, count - 1);\n };\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle(hash, css) {\n const runtime = getRuntime();\n runtime.styles.set(hash, css);\n for (const targetDocument of runtime.documents.keys()) {\n injectStyle(targetDocument, hash, css);\n }\n}", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"f2c8d759d8\", \".e10c29fc10c181dc__divider{border:0;margin:0}.e10c29fc10c181dc__divider[aria-orientation=horizontal]{block-size:0;border-block-end:1px solid currentColor;inline-size:auto;margin-block-end:var(--wp-components-divider-margin-end,0);margin-block-start:var(--wp-components-divider-margin-start,0)}.e10c29fc10c181dc__divider[aria-orientation=vertical]{block-size:auto;border-inline-end:1px solid currentColor;display:inline;inline-size:0;margin-inline-end:var(--wp-components-divider-margin-end,0);margin-inline-start:var(--wp-components-divider-margin-start,0)}\");\n}\nexport default {\"divider\":\"e10c29fc10c181dc__divider\"};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,cAAyB;AACzB,kBAAiB;AAMjB,qBAAiD;AACjD,mBAAsB;;;ACXtB,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACpB,QAAM,cAAc;AACpB,MAAI,YAAY,kBAAkB;AAChC,WAAO,YAAY;AAAA,EACrB;AACA,cAAY,mBAAmB;AAAA,IAC7B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC9B;AACA,MAAI,OAAO,aAAa,aAAa;AACnC,qBAAiB,QAAQ;AAAA,EAC3B;AACA,SAAO,YAAY;AACrB;AAUA,SAAS,0BAA0B,gBAAgB,MAAM;AACvD,MAAI,CAAC,eAAe,MAAM;AACxB,WAAO;AAAA,EACT;AACA,aAAW,SAAS,eAAe,KAAK,iBAAiB,SAAS,oBAAoB,GAAG,GAAG;AAC1F,QAAI,MAAM,aAAa,oBAAoB,MAAM,MAAM;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAUA,SAAS,YAAY,gBAAgB,MAAM,KAAK;AAC9C,MAAI,CAAC,eAAe,MAAM;AACxB;AAAA,EACF;AACA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAI,cAAc;AAC9D,MAAI,CAAC,gBAAgB;AACnB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAI,gBAAgB,c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,IACA;AAAA,IACA,GAAG;AAAA,EACL,QAAI,iCAAiB,OAAO,SAAS;AACrC,QAAM,eAAe;AAAA,IACnB,GAAG;AAAA,EACL;AACA,QAAM,0BAAsB,oBAAM,eAAe,MAAM;AACvD,QAAM,wBAAoB,oBAAM,aAAa,MAAM;AACnD,MAAI,qBAAqB;AACvB,iBAAa,sCAAsC,IAAI;AAAA,EACzD;AACA,MAAI,mBAAmB;AACrB,iBAAa,oCAAoC,IAAI;AAAA,EACvD;AACA,SAAoB,uCAAAA,KAAa,mBAAW;AAAA,IAC1C,eAAW,YAAAC,SAAK,qBAAO,SAAS,SAAS;AAAA,IACzC,OAAO;AAAA,IACP,GAAG;AAAA,IACH,KAAK;AAAA,EACP,CAAC;AACH;AAuBO,IAAM,cAAU,+BAAe,oBAAoB,SAAS;AACnE,IAAO,oBAAQ;",
|
|
6
|
+
"names": ["_jsx", "clsx"]
|
|
7
7
|
}
|
|
@@ -38,53 +38,27 @@ var import_element = require("@wordpress/element");
|
|
|
38
38
|
var import_compose = require("@wordpress/compose");
|
|
39
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
40
|
var with_fallback_styles_default = (mapNodeToProps) => (0, import_compose.createHigherOrderComponent)((WrappedComponent) => {
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.bindRef = this.bindRef.bind(this);
|
|
50
|
-
}
|
|
51
|
-
bindRef(node) {
|
|
52
|
-
if (!node) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
this.nodeRef = node;
|
|
56
|
-
}
|
|
57
|
-
componentDidMount() {
|
|
58
|
-
this.grabFallbackStyles();
|
|
59
|
-
}
|
|
60
|
-
componentDidUpdate() {
|
|
61
|
-
this.grabFallbackStyles();
|
|
62
|
-
}
|
|
63
|
-
grabFallbackStyles() {
|
|
64
|
-
const {
|
|
65
|
-
grabStylesCompleted,
|
|
66
|
-
fallbackStyles
|
|
67
|
-
} = this.state;
|
|
68
|
-
if (this.nodeRef && !grabStylesCompleted) {
|
|
69
|
-
const newFallbackStyles = mapNodeToProps(this.nodeRef, this.props);
|
|
41
|
+
return function WithFallbackStyles(props) {
|
|
42
|
+
const [fallbackStyles, setFallbackStyles] = (0, import_element.useState)(void 0);
|
|
43
|
+
const nodeRef = (0, import_element.useRef)(null);
|
|
44
|
+
(0, import_compose.useIsomorphicLayoutEffect)(() => {
|
|
45
|
+
const node = props.node ?? nodeRef.current;
|
|
46
|
+
const grabStylesCompleted = !!fallbackStyles && Object.values(fallbackStyles).every(Boolean);
|
|
47
|
+
if (node && !grabStylesCompleted) {
|
|
48
|
+
const newFallbackStyles = mapNodeToProps(node, props);
|
|
70
49
|
if (!(0, import_es6.default)(newFallbackStyles, fallbackStyles)) {
|
|
71
|
-
|
|
72
|
-
fallbackStyles: newFallbackStyles,
|
|
73
|
-
grabStylesCompleted: Object.values(newFallbackStyles).every(Boolean)
|
|
74
|
-
});
|
|
50
|
+
setFallbackStyles(newFallbackStyles);
|
|
75
51
|
}
|
|
76
52
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
}
|
|
53
|
+
});
|
|
54
|
+
const wrappedComponent = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, {
|
|
55
|
+
...props,
|
|
56
|
+
...fallbackStyles
|
|
57
|
+
});
|
|
58
|
+
return props.node ? wrappedComponent : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
59
|
+
ref: nodeRef,
|
|
60
|
+
children: [" ", wrappedComponent, " "]
|
|
61
|
+
});
|
|
88
62
|
};
|
|
89
63
|
}, "withFallbackStyles");
|
|
90
64
|
//# sourceMappingURL=index.cjs.map
|