@wordpress/components 32.1.0 → 32.2.1-next.v.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 +19 -0
- package/build/private-apis.cjs +2 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/range-control/styles/range-control-styles.cjs +30 -40
- package/build/range-control/styles/range-control-styles.cjs.map +2 -2
- package/build/text/styles.cjs +7 -7
- package/build/text/styles.cjs.map +2 -2
- package/build/toggle-control/index.cjs +4 -2
- package/build/toggle-control/index.cjs.map +2 -2
- package/build/toggle-group-control/toggle-group-control/styles.cjs +7 -7
- package/build/toggle-group-control/toggle-group-control/styles.cjs.map +2 -2
- package/build/validated-form-controls/components/toggle-control.cjs +1 -5
- package/build/validated-form-controls/components/toggle-control.cjs.map +2 -2
- package/build-module/private-apis.mjs +2 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/range-control/styles/range-control-styles.mjs +30 -40
- package/build-module/range-control/styles/range-control-styles.mjs.map +2 -2
- package/build-module/text/styles.mjs +7 -7
- package/build-module/text/styles.mjs.map +2 -2
- package/build-module/toggle-control/index.mjs +4 -2
- package/build-module/toggle-control/index.mjs.map +2 -2
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs +7 -7
- package/build-module/toggle-group-control/toggle-group-control/styles.mjs.map +2 -2
- package/build-module/validated-form-controls/components/toggle-control.mjs +2 -6
- package/build-module/validated-form-controls/components/toggle-control.mjs.map +2 -2
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts.map +1 -1
- package/build-types/text/styles.d.ts.map +1 -1
- package/build-types/toggle-control/index.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/heading/test/__snapshots__/index.tsx.snap +0 -1
- package/src/private-apis.ts +6 -0
- package/src/range-control/styles/range-control-styles.ts +33 -24
- package/src/text/styles.ts +0 -1
- package/src/text/test/__snapshots__/index.tsx.snap +0 -2
- package/src/toggle-control/index.tsx +2 -0
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +4 -4
- package/src/toggle-group-control/toggle-group-control/styles.ts +1 -1
- package/src/validated-form-controls/components/toggle-control.tsx +6 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAkCA,eAAO,MAAM,WAAW,IAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range-control-styles.d.ts","sourceRoot":"","sources":["../../../src/range-control/styles/range-control-styles.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACX,cAAc,EAEd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,MAAM,UAAU,CAAC;AAalB,KAAK,SAAS,GAAG,IAAI,CAAE,iBAAiB,EAAE,uBAAuB,CAAE,CAAC;AACpE,eAAO,MAAM,IAAI;;;qHAYhB,CAAC;AAKF,eAAO,MAAM,OAAO;;;wHAWnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;2GAK7B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;2GAK5B,CAAC;
|
|
1
|
+
{"version":3,"file":"range-control-styles.d.ts","sourceRoot":"","sources":["../../../src/range-control/styles/range-control-styles.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACX,cAAc,EAEd,UAAU,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,MAAM,UAAU,CAAC;AAalB,KAAK,SAAS,GAAG,IAAI,CAAE,iBAAiB,EAAE,uBAAuB,CAAE,CAAC;AACpE,eAAO,MAAM,IAAI;;;qHAYhB,CAAC;AAKF,eAAO,MAAM,OAAO;;;wHAWnB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;2GAK7B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;2GAK5B,CAAC;AAcF,eAAO,MAAM,IAAI;;;;;;;aA9CZ,CAAC;;;;;2GA0DL,CAAC;AAcF,eAAO,MAAM,KAAK;;;wHAgBjB,CAAC;AAEF,eAAO,MAAM,YAAY;;;2GAOxB,CAAC;AAEF,eAAO,MAAM,IAAI;;;2GAShB,CAAC;AAQF,eAAO,MAAM,SAAS;;;4HAcrB,CAAC;AAcF,eAAO,MAAM,YAAY;;;wHA2BxB,CAAC;AAwBF,eAAO,MAAM,KAAK;;;wHAYjB,CAAC;AAEF,eAAO,MAAM,UAAU;;;kHAatB,CAAC;AAiCF,eAAO,MAAM,OAAO;;;0HAoBnB,CAAC;AAIF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;UAUvB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;2GAW9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/text/styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/text/styles.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,IAAI,2CAKhB,CAAC;AAEF,eAAO,MAAM,KAAK,2CAEjB,CAAC;AAEF,eAAO,MAAM,QAAQ,2CAEpB,CAAC;AAEF,eAAO,MAAM,WAAW,2CAEvB,CAAC;AAEF,eAAO,MAAM,KAAK,2CAEjB,CAAC;AAEF,eAAO,MAAM,eAAe,2CAQ3B,CAAC;AAEF,eAAO,MAAM,SAAS,2CAErB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toggle-control/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toggle-control/index.tsx"],"names":[],"mappings":"AA6FA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa;;;;0SAAyC,CAAC;AAGpE,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"toggle-control.d.ts","sourceRoot":"","sources":["../../../src/validated-form-controls/components/toggle-control.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAiCrD,eAAO,MAAM,sBAAsB;;;;4XAElC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/components",
|
|
3
|
-
"version": "32.1.0",
|
|
3
|
+
"version": "32.2.1-next.v.0+642962a6d",
|
|
4
4
|
"description": "UI components for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -64,24 +64,24 @@
|
|
|
64
64
|
"@types/highlight-words-core": "1.2.1",
|
|
65
65
|
"@types/react": "^18.3.27",
|
|
66
66
|
"@use-gesture/react": "^10.3.1",
|
|
67
|
-
"@wordpress/a11y": "^4.39.0",
|
|
68
|
-
"@wordpress/base-styles": "^6.15.0",
|
|
69
|
-
"@wordpress/compose": "^7.39.0",
|
|
70
|
-
"@wordpress/date": "^5.39.0",
|
|
71
|
-
"@wordpress/deprecated": "^4.39.0",
|
|
72
|
-
"@wordpress/dom": "^4.39.0",
|
|
73
|
-
"@wordpress/element": "^6.39.0",
|
|
74
|
-
"@wordpress/escape-html": "^3.39.0",
|
|
75
|
-
"@wordpress/hooks": "^4.39.0",
|
|
76
|
-
"@wordpress/html-entities": "^4.39.0",
|
|
77
|
-
"@wordpress/i18n": "^6.12.0",
|
|
78
|
-
"@wordpress/icons": "^11.6.0",
|
|
79
|
-
"@wordpress/is-shallow-equal": "^5.39.0",
|
|
80
|
-
"@wordpress/keycodes": "^4.39.0",
|
|
81
|
-
"@wordpress/primitives": "^4.39.0",
|
|
82
|
-
"@wordpress/private-apis": "^1.39.0",
|
|
83
|
-
"@wordpress/rich-text": "^7.39.0",
|
|
84
|
-
"@wordpress/warning": "^3.39.0",
|
|
67
|
+
"@wordpress/a11y": "^4.39.1-next.v.0+642962a6d",
|
|
68
|
+
"@wordpress/base-styles": "^6.15.1-next.v.0+642962a6d",
|
|
69
|
+
"@wordpress/compose": "^7.39.1-next.v.0+642962a6d",
|
|
70
|
+
"@wordpress/date": "^5.39.1-next.v.0+642962a6d",
|
|
71
|
+
"@wordpress/deprecated": "^4.39.1-next.v.0+642962a6d",
|
|
72
|
+
"@wordpress/dom": "^4.39.1-next.v.0+642962a6d",
|
|
73
|
+
"@wordpress/element": "^6.39.1-next.v.0+642962a6d",
|
|
74
|
+
"@wordpress/escape-html": "^3.39.1-next.v.0+642962a6d",
|
|
75
|
+
"@wordpress/hooks": "^4.39.1-next.v.0+642962a6d",
|
|
76
|
+
"@wordpress/html-entities": "^4.39.1-next.v.0+642962a6d",
|
|
77
|
+
"@wordpress/i18n": "^6.12.1-next.v.0+642962a6d",
|
|
78
|
+
"@wordpress/icons": "^11.6.1-next.v.0+642962a6d",
|
|
79
|
+
"@wordpress/is-shallow-equal": "^5.39.1-next.v.0+642962a6d",
|
|
80
|
+
"@wordpress/keycodes": "^4.39.1-next.v.0+642962a6d",
|
|
81
|
+
"@wordpress/primitives": "^4.39.1-next.v.0+642962a6d",
|
|
82
|
+
"@wordpress/private-apis": "^1.39.1-next.v.0+642962a6d",
|
|
83
|
+
"@wordpress/rich-text": "^7.39.1-next.v.0+642962a6d",
|
|
84
|
+
"@wordpress/warning": "^3.39.1-next.v.0+642962a6d",
|
|
85
85
|
"change-case": "^4.1.2",
|
|
86
86
|
"clsx": "^2.1.1",
|
|
87
87
|
"colord": "^2.7.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@storybook/react-vite": "^10.1.11",
|
|
108
108
|
"@testing-library/jest-dom": "^6.6.3",
|
|
109
109
|
"@types/jest": "^29.5.14",
|
|
110
|
-
"@wordpress/jest-console": "^8.39.0",
|
|
110
|
+
"@wordpress/jest-console": "^8.39.1-next.v.0+642962a6d",
|
|
111
111
|
"snapshot-diff": "^0.10.0",
|
|
112
112
|
"storybook": "^10.1.11",
|
|
113
113
|
"timezone-mock": "^1.3.6"
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"publishConfig": {
|
|
120
120
|
"access": "public"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "2de56f23b200b6dc4b1feda4408613ad088d160a"
|
|
123
123
|
}
|
|
@@ -5,7 +5,6 @@ exports[`props should render correctly 1`] = `
|
|
|
5
5
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
6
6
|
line-height: 1.4;
|
|
7
7
|
margin: 0;
|
|
8
|
-
text-wrap: balance;
|
|
9
8
|
text-wrap: pretty;
|
|
10
9
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
11
10
|
font-size: calc(1.95 * 13px);
|
package/src/private-apis.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDrag } from '@use-gesture/react';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -42,6 +47,7 @@ lock( privateApis, {
|
|
|
42
47
|
DateRangeCalendar,
|
|
43
48
|
TZDate,
|
|
44
49
|
Picker,
|
|
50
|
+
useDrag,
|
|
45
51
|
ValidatedInputControl,
|
|
46
52
|
ValidatedCheckboxControl,
|
|
47
53
|
ValidatedComboboxControl,
|
|
@@ -78,17 +78,18 @@ export const AfterIconWrapper = styled.span`
|
|
|
78
78
|
`;
|
|
79
79
|
|
|
80
80
|
const railBackgroundColor = ( { disabled, railColor }: RailProps ) => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
81
|
+
return css`
|
|
82
|
+
background: ${ disabled
|
|
83
|
+
? COLORS.ui.backgroundDisabled
|
|
84
|
+
: railColor || COLORS.theme.gray[ 300 ] };
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
@media ( forced-colors: active ) {
|
|
87
|
+
background: GrayText;
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
export const Rail = styled.span`
|
|
91
|
-
background-color: ${ COLORS.gray[ 300 ] };
|
|
92
93
|
left: 0;
|
|
93
94
|
pointer-events: none;
|
|
94
95
|
right: 0;
|
|
@@ -103,17 +104,18 @@ export const Rail = styled.span`
|
|
|
103
104
|
`;
|
|
104
105
|
|
|
105
106
|
const trackBackgroundColor = ( { disabled, trackColor }: TrackProps ) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
107
|
+
return css`
|
|
108
|
+
background: ${ disabled
|
|
109
|
+
? COLORS.theme.gray[ 400 ]
|
|
110
|
+
: trackColor || 'currentColor' };
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
@media ( forced-colors: active ) {
|
|
113
|
+
background: ${ disabled ? 'GrayText' : 'CanvasText' };
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
export const Track = styled.span`
|
|
116
|
-
background-color: currentColor;
|
|
117
119
|
border-radius: ${ CONFIG.radiusFull };
|
|
118
120
|
height: ${ railHeight }px;
|
|
119
121
|
pointer-events: none;
|
|
@@ -153,12 +155,12 @@ export const Mark = styled.span`
|
|
|
153
155
|
|
|
154
156
|
const markLabelFill = ( { isFilled }: RangeMarkProps ) => {
|
|
155
157
|
return css( {
|
|
156
|
-
color: isFilled ? COLORS.gray[ 700 ] : COLORS.gray[ 300 ],
|
|
158
|
+
color: isFilled ? COLORS.theme.gray[ 700 ] : COLORS.theme.gray[ 300 ],
|
|
157
159
|
} );
|
|
158
160
|
};
|
|
159
161
|
|
|
160
162
|
export const MarkLabel = styled.span`
|
|
161
|
-
color: ${ COLORS.gray[ 300 ] };
|
|
163
|
+
color: ${ COLORS.theme.gray[ 300 ] };
|
|
162
164
|
font-size: 11px;
|
|
163
165
|
position: absolute;
|
|
164
166
|
top: 8px;
|
|
@@ -173,14 +175,17 @@ export const MarkLabel = styled.span`
|
|
|
173
175
|
${ markLabelFill };
|
|
174
176
|
`;
|
|
175
177
|
|
|
176
|
-
const thumbColor = ( { disabled }: ThumbProps ) =>
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
const thumbColor = ( { disabled }: ThumbProps ) => {
|
|
179
|
+
return css`
|
|
180
|
+
background: ${ disabled
|
|
181
|
+
? COLORS.theme.gray[ 400 ]
|
|
182
|
+
: COLORS.theme.accent };
|
|
183
|
+
|
|
184
|
+
@media ( forced-colors: active ) {
|
|
185
|
+
background: ${ disabled ? 'GrayText' : 'CanvasText' };
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
};
|
|
184
189
|
|
|
185
190
|
export const ThumbWrapper = styled.span`
|
|
186
191
|
align-items: center;
|
|
@@ -224,6 +229,10 @@ const thumbFocus = ( { isFocused }: ThumbProps ) => {
|
|
|
224
229
|
width: ${ thumbSize + 8 }px;
|
|
225
230
|
top: -4px;
|
|
226
231
|
left: -4px;
|
|
232
|
+
|
|
233
|
+
@media ( forced-colors: active ) {
|
|
234
|
+
background: GrayText;
|
|
235
|
+
}
|
|
227
236
|
}
|
|
228
237
|
`
|
|
229
238
|
: '';
|
package/src/text/styles.ts
CHANGED
|
@@ -22,7 +22,6 @@ exports[`Text should render highlighted words with highlightCaseSensitive 1`] =
|
|
|
22
22
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
23
23
|
line-height: 1.4;
|
|
24
24
|
margin: 0;
|
|
25
|
-
text-wrap: balance;
|
|
26
25
|
text-wrap: pretty;
|
|
27
26
|
font-size: calc((13 / 13) * 13px);
|
|
28
27
|
font-weight: normal;
|
|
@@ -55,7 +54,6 @@ exports[`Text snapshot tests should render correctly 1`] = `
|
|
|
55
54
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
56
55
|
line-height: 1.4;
|
|
57
56
|
margin: 0;
|
|
58
|
-
text-wrap: balance;
|
|
59
57
|
text-wrap: pretty;
|
|
60
58
|
font-size: calc((13 / 13) * 13px);
|
|
61
59
|
font-weight: normal;
|
|
@@ -28,6 +28,7 @@ function UnforwardedToggleControl(
|
|
|
28
28
|
className,
|
|
29
29
|
onChange,
|
|
30
30
|
disabled,
|
|
31
|
+
...additionalProps
|
|
31
32
|
}: WordPressComponentProps< ToggleControlProps, 'input', false >,
|
|
32
33
|
ref: ForwardedRef< HTMLInputElement >
|
|
33
34
|
) {
|
|
@@ -74,6 +75,7 @@ function UnforwardedToggleControl(
|
|
|
74
75
|
aria-describedby={ describedBy }
|
|
75
76
|
disabled={ disabled }
|
|
76
77
|
ref={ ref }
|
|
78
|
+
{ ...additionalProps }
|
|
77
79
|
/>
|
|
78
80
|
<FlexBlock
|
|
79
81
|
as="label"
|
|
@@ -69,7 +69,7 @@ exports[`ToggleGroupControl controlled should render correctly with icons 1`] =
|
|
|
69
69
|
content: '';
|
|
70
70
|
position: absolute;
|
|
71
71
|
pointer-events: none;
|
|
72
|
-
background: var(--wp-components-color-
|
|
72
|
+
background: var(--wp-components-color-gray-100, #f0f0f0);
|
|
73
73
|
border: 1px solid var(--wp-components-color-gray-700, #757575);
|
|
74
74
|
outline: 2px solid transparent;
|
|
75
75
|
outline-offset: -3px;
|
|
@@ -410,7 +410,7 @@ exports[`ToggleGroupControl controlled should render correctly with text options
|
|
|
410
410
|
content: '';
|
|
411
411
|
position: absolute;
|
|
412
412
|
pointer-events: none;
|
|
413
|
-
background: var(--wp-components-color-
|
|
413
|
+
background: var(--wp-components-color-gray-100, #f0f0f0);
|
|
414
414
|
border: 1px solid var(--wp-components-color-gray-700, #757575);
|
|
415
415
|
outline: 2px solid transparent;
|
|
416
416
|
outline-offset: -3px;
|
|
@@ -658,7 +658,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with icons 1`]
|
|
|
658
658
|
content: '';
|
|
659
659
|
position: absolute;
|
|
660
660
|
pointer-events: none;
|
|
661
|
-
background: var(--wp-components-color-
|
|
661
|
+
background: var(--wp-components-color-gray-100, #f0f0f0);
|
|
662
662
|
border: 1px solid var(--wp-components-color-gray-700, #757575);
|
|
663
663
|
outline: 2px solid transparent;
|
|
664
664
|
outline-offset: -3px;
|
|
@@ -993,7 +993,7 @@ exports[`ToggleGroupControl uncontrolled should render correctly with text optio
|
|
|
993
993
|
content: '';
|
|
994
994
|
position: absolute;
|
|
995
995
|
pointer-events: none;
|
|
996
|
-
background: var(--wp-components-color-
|
|
996
|
+
background: var(--wp-components-color-gray-100, #f0f0f0);
|
|
997
997
|
border: 1px solid var(--wp-components-color-gray-700, #757575);
|
|
998
998
|
outline: 2px solid transparent;
|
|
999
999
|
outline-offset: -3px;
|
|
@@ -39,7 +39,7 @@ export const toggleGroupControl = ( {
|
|
|
39
39
|
content: '';
|
|
40
40
|
position: absolute;
|
|
41
41
|
pointer-events: none;
|
|
42
|
-
background: ${ COLORS.theme.
|
|
42
|
+
background: ${ COLORS.theme.gray[ 100 ] };
|
|
43
43
|
border: 1px solid ${ COLORS.theme.gray[ 700 ] };
|
|
44
44
|
|
|
45
45
|
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { forwardRef, useRef
|
|
4
|
+
import { forwardRef, useRef } from '@wordpress/element';
|
|
5
5
|
import { useMergeRefs } from '@wordpress/compose';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -25,14 +25,6 @@ const UnforwardedValidatedToggleControl = (
|
|
|
25
25
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
26
26
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
27
27
|
|
|
28
|
-
// TODO: Upstream limitation - The `required` attribute is not passed down to the input,
|
|
29
|
-
// so we need to set it manually.
|
|
30
|
-
useEffect( () => {
|
|
31
|
-
if ( validityTargetRef.current ) {
|
|
32
|
-
validityTargetRef.current.required = required ?? false;
|
|
33
|
-
}
|
|
34
|
-
}, [ required ] );
|
|
35
|
-
|
|
36
28
|
return (
|
|
37
29
|
<ControlWithError
|
|
38
30
|
required={ required }
|
|
@@ -40,7 +32,11 @@ const UnforwardedValidatedToggleControl = (
|
|
|
40
32
|
customValidity={ customValidity }
|
|
41
33
|
getValidityTarget={ () => validityTargetRef.current }
|
|
42
34
|
>
|
|
43
|
-
<ToggleControl
|
|
35
|
+
<ToggleControl
|
|
36
|
+
ref={ mergedRefs }
|
|
37
|
+
required={ required }
|
|
38
|
+
{ ...restProps }
|
|
39
|
+
/>
|
|
44
40
|
</ControlWithError>
|
|
45
41
|
);
|
|
46
42
|
};
|