@wordpress/components 30.9.0 → 31.0.1-next.6deb34194.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 +25 -4
- package/build/alignment-matrix-control/cell.js +131 -3
- package/build/alignment-matrix-control/cell.js.map +4 -4
- package/build/alignment-matrix-control/index.js +134 -6
- package/build/alignment-matrix-control/index.js.map +3 -3
- package/build/angle-picker-control/angle-circle.js +119 -15
- package/build/angle-picker-control/angle-circle.js.map +4 -4
- package/build/angle-picker-control/index.js +12 -7
- package/build/angle-picker-control/index.js.map +3 -3
- package/build/dropdown-menu/index.js +1 -1
- package/build/dropdown-menu/index.js.map +2 -2
- package/build/menu/styles.js +17 -17
- package/build/menu/styles.js.map +2 -2
- package/build/menu-item/index.js +1 -1
- package/build/menu-item/index.js.map +2 -2
- package/build/notice/index.js +1 -1
- package/build/notice/index.js.map +2 -2
- package/build/snackbar/index.js +1 -1
- package/build/snackbar/index.js.map +1 -1
- package/build/validated-form-controls/components/checkbox-control.js +0 -10
- package/build/validated-form-controls/components/checkbox-control.js.map +2 -2
- package/build/validated-form-controls/components/combobox-control.js +1 -11
- package/build/validated-form-controls/components/combobox-control.js.map +2 -2
- package/build/validated-form-controls/components/custom-select-control.js +0 -10
- package/build/validated-form-controls/components/custom-select-control.js.map +2 -2
- package/build/validated-form-controls/components/form-token-field.js +2 -12
- package/build/validated-form-controls/components/form-token-field.js.map +2 -2
- package/build/validated-form-controls/components/input-control.js +0 -10
- package/build/validated-form-controls/components/input-control.js.map +2 -2
- package/build/validated-form-controls/components/number-control.js +0 -10
- package/build/validated-form-controls/components/number-control.js.map +2 -2
- package/build/validated-form-controls/components/radio-control.js +0 -10
- package/build/validated-form-controls/components/radio-control.js.map +2 -2
- package/build/validated-form-controls/components/range-control.js +0 -10
- package/build/validated-form-controls/components/range-control.js.map +2 -2
- package/build/validated-form-controls/components/select-control.js +0 -10
- package/build/validated-form-controls/components/select-control.js.map +2 -2
- package/build/validated-form-controls/components/text-control.js +0 -10
- package/build/validated-form-controls/components/text-control.js.map +2 -2
- package/build/validated-form-controls/components/textarea-control.js +0 -10
- package/build/validated-form-controls/components/textarea-control.js.map +2 -2
- package/build/validated-form-controls/components/toggle-control.js +0 -10
- package/build/validated-form-controls/components/toggle-control.js.map +2 -2
- package/build/validated-form-controls/components/toggle-group-control.js +0 -10
- package/build/validated-form-controls/components/toggle-group-control.js.map +2 -2
- package/build/validated-form-controls/control-with-error.js +53 -58
- package/build/validated-form-controls/control-with-error.js.map +2 -2
- package/build-module/alignment-matrix-control/cell.js +131 -3
- package/build-module/alignment-matrix-control/cell.js.map +3 -3
- package/build-module/alignment-matrix-control/index.js +134 -6
- package/build-module/alignment-matrix-control/index.js.map +3 -3
- package/build-module/angle-picker-control/angle-circle.js +109 -15
- package/build-module/angle-picker-control/angle-circle.js.map +3 -3
- package/build-module/angle-picker-control/index.js +12 -7
- package/build-module/angle-picker-control/index.js.map +2 -2
- package/build-module/dropdown-menu/index.js +1 -1
- package/build-module/dropdown-menu/index.js.map +2 -2
- package/build-module/menu/styles.js +17 -17
- package/build-module/menu/styles.js.map +2 -2
- package/build-module/menu-item/index.js +1 -1
- package/build-module/menu-item/index.js.map +2 -2
- package/build-module/notice/index.js +1 -1
- package/build-module/notice/index.js.map +2 -2
- package/build-module/snackbar/index.js +1 -1
- package/build-module/snackbar/index.js.map +1 -1
- package/build-module/validated-form-controls/components/checkbox-control.js +0 -10
- package/build-module/validated-form-controls/components/checkbox-control.js.map +2 -2
- package/build-module/validated-form-controls/components/combobox-control.js +1 -11
- package/build-module/validated-form-controls/components/combobox-control.js.map +2 -2
- package/build-module/validated-form-controls/components/custom-select-control.js +0 -10
- package/build-module/validated-form-controls/components/custom-select-control.js.map +2 -2
- package/build-module/validated-form-controls/components/form-token-field.js +2 -12
- package/build-module/validated-form-controls/components/form-token-field.js.map +2 -2
- package/build-module/validated-form-controls/components/input-control.js +0 -10
- package/build-module/validated-form-controls/components/input-control.js.map +2 -2
- package/build-module/validated-form-controls/components/number-control.js +0 -10
- package/build-module/validated-form-controls/components/number-control.js.map +2 -2
- package/build-module/validated-form-controls/components/radio-control.js +0 -10
- package/build-module/validated-form-controls/components/radio-control.js.map +2 -2
- package/build-module/validated-form-controls/components/range-control.js +0 -10
- package/build-module/validated-form-controls/components/range-control.js.map +2 -2
- package/build-module/validated-form-controls/components/select-control.js +0 -10
- package/build-module/validated-form-controls/components/select-control.js.map +2 -2
- package/build-module/validated-form-controls/components/text-control.js +0 -10
- package/build-module/validated-form-controls/components/text-control.js.map +2 -2
- package/build-module/validated-form-controls/components/textarea-control.js +0 -10
- package/build-module/validated-form-controls/components/textarea-control.js.map +2 -2
- package/build-module/validated-form-controls/components/toggle-control.js +0 -10
- package/build-module/validated-form-controls/components/toggle-control.js.map +2 -2
- package/build-module/validated-form-controls/components/toggle-group-control.js +0 -10
- package/build-module/validated-form-controls/components/toggle-group-control.js.map +2 -2
- package/build-module/validated-form-controls/control-with-error.js +53 -58
- package/build-module/validated-form-controls/control-with-error.js.map +2 -2
- package/build-style/style-rtl.css +21 -33
- package/build-style/style.css +21 -33
- package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
- package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
- package/build-types/angle-picker-control/angle-circle.d.ts +1 -1
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/notice/stories/index.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/combobox-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/custom-select-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/form-token-field.d.ts +1 -2
- package/build-types/validated-form-controls/components/form-token-field.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/input-control.d.ts +1 -2
- package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/select-control.d.ts +2 -3
- package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts +7 -0
- package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/text-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/textarea-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -1
- package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/types.d.ts +1 -9
- package/build-types/validated-form-controls/components/types.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts +4 -5
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/alignment-matrix-control/cell.tsx +14 -3
- package/src/alignment-matrix-control/index.tsx +15 -6
- package/src/alignment-matrix-control/style.module.scss +84 -0
- package/src/angle-picker-control/angle-circle.tsx +27 -12
- package/src/angle-picker-control/index.tsx +8 -7
- package/src/angle-picker-control/style.module.scss +40 -0
- package/src/button/style.scss +1 -1
- package/src/dropdown-menu/index.tsx +1 -1
- package/src/dropdown-menu/style.scss +1 -1
- package/src/guide/style.scss +3 -3
- package/src/menu/styles.ts +2 -2
- package/src/menu-item/index.tsx +1 -1
- package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
- package/src/modal/style.scss +5 -5
- package/src/notice/index.tsx +53 -46
- package/src/notice/stories/index.story.tsx +17 -1
- package/src/notice/style.scss +3 -20
- package/src/snackbar/index.tsx +1 -1
- package/src/validated-form-controls/components/checkbox-control.tsx +1 -14
- package/src/validated-form-controls/components/combobox-control.tsx +1 -14
- package/src/validated-form-controls/components/custom-select-control.tsx +1 -19
- package/src/validated-form-controls/components/form-token-field.tsx +2 -15
- package/src/validated-form-controls/components/input-control.tsx +1 -14
- package/src/validated-form-controls/components/number-control.tsx +1 -16
- package/src/validated-form-controls/components/radio-control.tsx +2 -18
- package/src/validated-form-controls/components/range-control.tsx +1 -14
- package/src/validated-form-controls/components/select-control.tsx +1 -23
- package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/combobox-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/form-token-field.story.tsx +14 -26
- package/src/validated-form-controls/components/stories/input-control.story.tsx +25 -50
- package/src/validated-form-controls/components/stories/number-control.story.tsx +10 -19
- package/src/validated-form-controls/components/stories/overview.mdx +3 -3
- package/src/validated-form-controls/components/stories/overview.story.tsx +94 -79
- package/src/validated-form-controls/components/stories/radio-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/range-control.story.tsx +8 -17
- package/src/validated-form-controls/components/stories/select-control.story.tsx +9 -18
- package/src/validated-form-controls/components/stories/text-control.story.tsx +11 -17
- package/src/validated-form-controls/components/stories/textarea-control.story.tsx +12 -16
- package/src/validated-form-controls/components/stories/toggle-control.story.tsx +11 -20
- package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +8 -17
- package/src/validated-form-controls/components/text-control.tsx +1 -14
- package/src/validated-form-controls/components/textarea-control.tsx +1 -14
- package/src/validated-form-controls/components/toggle-control.tsx +1 -14
- package/src/validated-form-controls/components/toggle-group-control.tsx +1 -14
- package/src/validated-form-controls/components/types.ts +1 -9
- package/src/validated-form-controls/control-with-error.tsx +57 -84
- package/src/validated-form-controls/style.scss +7 -7
- package/src/validated-form-controls/test/control-with-error.tsx +66 -5
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/alignment-matrix-control/styles.js +0 -105
- package/build/alignment-matrix-control/styles.js.map +0 -7
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +0 -88
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
- package/build-module/alignment-matrix-control/styles.js +0 -67
- package/build-module/alignment-matrix-control/styles.js.map +0 -7
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +0 -50
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
- package/build-types/alignment-matrix-control/styles.d.ts +0 -21
- package/build-types/alignment-matrix-control/styles.d.ts.map +0 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +0 -18
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +0 -1
- package/src/alignment-matrix-control/styles.ts +0 -113
- package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +0 -58
package/src/notice/index.tsx
CHANGED
|
@@ -111,53 +111,60 @@ function Notice( {
|
|
|
111
111
|
<VisuallyHidden>{ getStatusLabel( status ) }</VisuallyHidden>
|
|
112
112
|
<div className="components-notice__content">
|
|
113
113
|
{ children }
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
114
|
+
{ actions.length > 0 && (
|
|
115
|
+
<div className="components-notice__actions">
|
|
116
|
+
{ actions.map(
|
|
117
|
+
(
|
|
118
|
+
{
|
|
119
|
+
className: buttonCustomClasses,
|
|
120
|
+
label,
|
|
121
|
+
isPrimary,
|
|
122
|
+
variant,
|
|
123
|
+
noDefaultClasses = false,
|
|
124
|
+
onClick,
|
|
125
|
+
url,
|
|
126
|
+
}: NoticeAction &
|
|
127
|
+
// `isPrimary` is a legacy prop included for
|
|
128
|
+
// backcompat, but `variant` should be used
|
|
129
|
+
// instead.
|
|
130
|
+
Pick< DeprecatedButtonProps, 'isPrimary' >,
|
|
131
|
+
index
|
|
132
|
+
) => {
|
|
133
|
+
let computedVariant = variant;
|
|
134
|
+
if (
|
|
135
|
+
variant !== 'primary' &&
|
|
136
|
+
! noDefaultClasses
|
|
137
|
+
) {
|
|
138
|
+
computedVariant = ! url
|
|
139
|
+
? 'secondary'
|
|
140
|
+
: 'link';
|
|
141
|
+
}
|
|
142
|
+
if (
|
|
143
|
+
typeof computedVariant === 'undefined' &&
|
|
144
|
+
isPrimary
|
|
145
|
+
) {
|
|
146
|
+
computedVariant = 'primary';
|
|
147
|
+
}
|
|
142
148
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
return (
|
|
150
|
+
<Button
|
|
151
|
+
__next40pxDefaultSize
|
|
152
|
+
key={ index }
|
|
153
|
+
href={ url }
|
|
154
|
+
variant={ computedVariant }
|
|
155
|
+
onClick={ url ? undefined : onClick }
|
|
156
|
+
className={ clsx(
|
|
157
|
+
'components-notice__action',
|
|
158
|
+
buttonCustomClasses
|
|
159
|
+
) }
|
|
160
|
+
>
|
|
161
|
+
{ label }
|
|
162
|
+
</Button>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
) }
|
|
166
|
+
</div>
|
|
167
|
+
) }
|
|
161
168
|
</div>
|
|
162
169
|
{ isDismissible && (
|
|
163
170
|
<Button
|
|
@@ -89,7 +89,7 @@ WithActions.args = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
|
|
92
|
-
const exampleNotices = [
|
|
92
|
+
const exampleNotices: NoticeListProps[ 'notices' ] = [
|
|
93
93
|
{
|
|
94
94
|
id: 'second-notice',
|
|
95
95
|
content: 'second notice content',
|
|
@@ -97,6 +97,22 @@ export const NoticeListSubcomponent: StoryFn< typeof NoticeList > = () => {
|
|
|
97
97
|
{
|
|
98
98
|
id: 'first-notice',
|
|
99
99
|
content: 'first notice content',
|
|
100
|
+
actions: [
|
|
101
|
+
{
|
|
102
|
+
label: 'Click me!',
|
|
103
|
+
onClick: () => {},
|
|
104
|
+
variant: 'primary',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'Or click me instead!',
|
|
108
|
+
onClick: () => {},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
label: 'Or visit a link for more info',
|
|
112
|
+
url: 'https://wordpress.org',
|
|
113
|
+
variant: 'link',
|
|
114
|
+
},
|
|
115
|
+
],
|
|
100
116
|
},
|
|
101
117
|
];
|
|
102
118
|
const [ notices, setNotices ] = useState( exampleNotices );
|
package/src/notice/style.scss
CHANGED
|
@@ -41,20 +41,9 @@
|
|
|
41
41
|
.components-notice__actions {
|
|
42
42
|
display: flex;
|
|
43
43
|
flex-wrap: wrap;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
&,
|
|
48
|
-
&.is-link {
|
|
49
|
-
margin-left: $grid-unit-15;
|
|
50
|
-
}
|
|
51
|
-
&.is-secondary {
|
|
52
|
-
vertical-align: initial;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// When it has better support, this can be replaced
|
|
56
|
-
// with column-gap since these are flex items.
|
|
57
|
-
margin-right: $grid-unit-10;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: $grid-unit-15;
|
|
46
|
+
margin-top: $grid-unit-15;
|
|
58
47
|
}
|
|
59
48
|
|
|
60
49
|
.components-notice__dismiss {
|
|
@@ -86,10 +75,4 @@
|
|
|
86
75
|
margin-bottom: $grid-unit-15;
|
|
87
76
|
line-height: 2;
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
.components-notice__action.components-button {
|
|
91
|
-
display: block;
|
|
92
|
-
margin-left: 0;
|
|
93
|
-
margin-top: $grid-unit-10;
|
|
94
|
-
}
|
|
95
78
|
}
|
package/src/snackbar/index.tsx
CHANGED
|
@@ -27,7 +27,7 @@ import type { SnackbarProps } from './types';
|
|
|
27
27
|
import type { NoticeAction } from '../notice/types';
|
|
28
28
|
import type { WordPressComponentProps } from '../context';
|
|
29
29
|
|
|
30
|
-
const NOTICE_TIMEOUT =
|
|
30
|
+
const NOTICE_TIMEOUT = 6000;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Custom hook which announces the message with the given politeness, if a
|
|
@@ -10,37 +10,28 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import CheckboxControl from '../../checkbox-control';
|
|
13
|
-
import type { CheckboxControlProps } from '../../checkbox-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = CheckboxControlProps[ 'checked' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedCheckboxControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof CheckboxControl >,
|
|
27
22
|
'__nextHasNoMarginBottom'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLDivElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.checked );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
34
|
ref={ mergedRefs }
|
|
41
|
-
onValidate={ () => {
|
|
42
|
-
return onValidate?.( valueRef.current );
|
|
43
|
-
} }
|
|
44
35
|
customValidity={ customValidity }
|
|
45
36
|
getValidityTarget={ () =>
|
|
46
37
|
validityTargetRef.current?.querySelector< HTMLInputElement >(
|
|
@@ -50,10 +41,6 @@ const UnforwardedValidatedCheckboxControl = (
|
|
|
50
41
|
>
|
|
51
42
|
<CheckboxControl
|
|
52
43
|
__nextHasNoMarginBottom
|
|
53
|
-
onChange={ ( value ) => {
|
|
54
|
-
valueRef.current = value;
|
|
55
|
-
onChange?.( value );
|
|
56
|
-
} }
|
|
57
44
|
// TODO: Upstream limitation - CheckboxControl doesn't support uncontrolled mode, visually.
|
|
58
45
|
{ ...restProps }
|
|
59
46
|
/>
|
|
@@ -10,28 +10,22 @@ import { forwardRef, useEffect, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import ComboboxControl from '../../combobox-control';
|
|
13
|
-
import type { ComboboxControlProps } from '../../combobox-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = ComboboxControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedComboboxControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof ComboboxControl >,
|
|
27
22
|
'__next40pxDefaultSize' | '__nextHasNoMarginBottom'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
// TODO: Upstream limitation - The `required` attribute is not passed down to the input,
|
|
37
31
|
// so we need to set it manually.
|
|
@@ -51,9 +45,6 @@ const UnforwardedValidatedComboboxControl = (
|
|
|
51
45
|
required={ required }
|
|
52
46
|
markWhenOptional={ markWhenOptional }
|
|
53
47
|
ref={ mergedRefs }
|
|
54
|
-
onValidate={ () => {
|
|
55
|
-
return onValidate?.( valueRef.current );
|
|
56
|
-
} }
|
|
57
48
|
customValidity={ customValidity }
|
|
58
49
|
getValidityTarget={ () =>
|
|
59
50
|
validityTargetRef.current?.querySelector< HTMLInputElement >(
|
|
@@ -65,10 +56,6 @@ const UnforwardedValidatedComboboxControl = (
|
|
|
65
56
|
__nextHasNoMarginBottom
|
|
66
57
|
__next40pxDefaultSize
|
|
67
58
|
{ ...restProps }
|
|
68
|
-
onChange={ ( value ) => {
|
|
69
|
-
valueRef.current = value;
|
|
70
|
-
onChange?.( value );
|
|
71
|
-
} }
|
|
72
59
|
/>
|
|
73
60
|
</ControlWithError>
|
|
74
61
|
);
|
|
@@ -9,32 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
9
9
|
import { ControlWithError } from '../control-with-error';
|
|
10
10
|
import type { ValidatedControlProps } from './types';
|
|
11
11
|
import CustomSelectControl from '../../custom-select-control';
|
|
12
|
-
import type {
|
|
13
|
-
CustomSelectOption,
|
|
14
|
-
CustomSelectProps,
|
|
15
|
-
} from '../../custom-select-control/types';
|
|
16
|
-
|
|
17
|
-
type CustomSelectControlProps = CustomSelectProps< CustomSelectOption >;
|
|
18
|
-
|
|
19
|
-
type Value = CustomSelectControlProps[ 'value' ];
|
|
20
12
|
|
|
21
13
|
const UnforwardedValidatedCustomSelectControl = (
|
|
22
14
|
{
|
|
23
15
|
required,
|
|
24
|
-
onValidate,
|
|
25
16
|
customValidity,
|
|
26
|
-
onChange,
|
|
27
17
|
markWhenOptional,
|
|
28
18
|
...restProps
|
|
29
19
|
}: Omit<
|
|
30
20
|
React.ComponentProps< typeof CustomSelectControl >,
|
|
31
21
|
'__next40pxDefaultSize'
|
|
32
22
|
> &
|
|
33
|
-
ValidatedControlProps
|
|
23
|
+
ValidatedControlProps,
|
|
34
24
|
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
35
25
|
) => {
|
|
36
26
|
const validityTargetRef = useRef< HTMLSelectElement >( null );
|
|
37
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
38
27
|
|
|
39
28
|
return (
|
|
40
29
|
<div
|
|
@@ -44,9 +33,6 @@ const UnforwardedValidatedCustomSelectControl = (
|
|
|
44
33
|
<ControlWithError
|
|
45
34
|
required={ required }
|
|
46
35
|
markWhenOptional={ markWhenOptional }
|
|
47
|
-
onValidate={ () => {
|
|
48
|
-
return onValidate?.( valueRef.current );
|
|
49
|
-
} }
|
|
50
36
|
customValidity={ customValidity }
|
|
51
37
|
getValidityTarget={ () => validityTargetRef.current }
|
|
52
38
|
>
|
|
@@ -54,10 +40,6 @@ const UnforwardedValidatedCustomSelectControl = (
|
|
|
54
40
|
// TODO: Upstream limitation - Required isn't passed down correctly,
|
|
55
41
|
// so it needs to be set on a delegate element.
|
|
56
42
|
__next40pxDefaultSize
|
|
57
|
-
onChange={ ( value ) => {
|
|
58
|
-
valueRef.current = value.selectedItem;
|
|
59
|
-
onChange?.( value );
|
|
60
|
-
} }
|
|
61
43
|
{ ...restProps }
|
|
62
44
|
/>
|
|
63
45
|
</ControlWithError>
|
|
@@ -9,27 +9,21 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
9
9
|
import { ControlWithError } from '../control-with-error';
|
|
10
10
|
import type { ValidatedControlProps } from './types';
|
|
11
11
|
import { FormTokenField } from '../../form-token-field';
|
|
12
|
-
import type { FormTokenFieldProps } from '../../form-token-field/types';
|
|
13
|
-
|
|
14
|
-
type Value = FormTokenFieldProps[ 'value' ];
|
|
15
12
|
|
|
16
13
|
const UnforwardedValidatedFormTokenField = (
|
|
17
14
|
{
|
|
18
15
|
required,
|
|
19
|
-
onValidate,
|
|
20
16
|
customValidity,
|
|
21
|
-
onChange,
|
|
22
17
|
markWhenOptional,
|
|
23
18
|
...restProps
|
|
24
19
|
}: Omit<
|
|
25
20
|
React.ComponentProps< typeof FormTokenField >,
|
|
26
21
|
'__next40pxDefaultSize' | '__nextHasNoMarginBottom'
|
|
27
22
|
> &
|
|
28
|
-
ValidatedControlProps
|
|
23
|
+
ValidatedControlProps,
|
|
29
24
|
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
30
25
|
) => {
|
|
31
26
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
32
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
33
27
|
|
|
34
28
|
return (
|
|
35
29
|
<div
|
|
@@ -39,9 +33,6 @@ const UnforwardedValidatedFormTokenField = (
|
|
|
39
33
|
<ControlWithError
|
|
40
34
|
required={ required }
|
|
41
35
|
markWhenOptional={ markWhenOptional }
|
|
42
|
-
onValidate={ () => {
|
|
43
|
-
return onValidate?.( valueRef.current );
|
|
44
|
-
} }
|
|
45
36
|
customValidity={ customValidity }
|
|
46
37
|
getValidityTarget={ () => validityTargetRef.current }
|
|
47
38
|
>
|
|
@@ -49,10 +40,6 @@ const UnforwardedValidatedFormTokenField = (
|
|
|
49
40
|
__next40pxDefaultSize
|
|
50
41
|
__nextHasNoMarginBottom
|
|
51
42
|
{ ...restProps }
|
|
52
|
-
onChange={ ( value, ...args ) => {
|
|
53
|
-
valueRef.current = value;
|
|
54
|
-
onChange?.( value, ...args );
|
|
55
|
-
} }
|
|
56
43
|
/>
|
|
57
44
|
</ControlWithError>
|
|
58
45
|
<input
|
|
@@ -61,7 +48,7 @@ const UnforwardedValidatedFormTokenField = (
|
|
|
61
48
|
ref={ validityTargetRef }
|
|
62
49
|
required={ required }
|
|
63
50
|
value={
|
|
64
|
-
|
|
51
|
+
restProps.value && restProps.value.length > 0
|
|
65
52
|
? 'hasvalue'
|
|
66
53
|
: ''
|
|
67
54
|
}
|
|
@@ -10,46 +10,33 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import InputControl from '../../input-control';
|
|
13
|
-
import type { InputControlProps } from '../../input-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = InputControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedInputControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof InputControl >,
|
|
27
22
|
'__next40pxDefaultSize'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
|
-
onValidate={ () => {
|
|
41
|
-
return onValidate?.( valueRef.current );
|
|
42
|
-
} }
|
|
43
34
|
customValidity={ customValidity }
|
|
44
35
|
getValidityTarget={ () => validityTargetRef.current }
|
|
45
36
|
>
|
|
46
37
|
<InputControl
|
|
47
38
|
__next40pxDefaultSize
|
|
48
39
|
ref={ mergedRefs }
|
|
49
|
-
onChange={ ( value, ...args ) => {
|
|
50
|
-
valueRef.current = value;
|
|
51
|
-
onChange?.( value, ...args );
|
|
52
|
-
} }
|
|
53
40
|
{ ...restProps }
|
|
54
41
|
/>
|
|
55
42
|
</ControlWithError>
|
|
@@ -10,48 +10,33 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import NumberControl from '../../number-control';
|
|
12
12
|
import type { ValidatedControlProps } from './types';
|
|
13
|
-
import type { NumberControlProps } from '../../number-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = NumberControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedNumberControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof NumberControl >,
|
|
27
22
|
'__next40pxDefaultSize'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
|
-
onValidate={ () => {
|
|
41
|
-
return onValidate?.( valueRef.current );
|
|
42
|
-
} }
|
|
43
34
|
customValidity={ customValidity }
|
|
44
35
|
getValidityTarget={ () => validityTargetRef.current }
|
|
45
36
|
>
|
|
46
37
|
<NumberControl
|
|
47
38
|
__next40pxDefaultSize
|
|
48
39
|
ref={ mergedRefs }
|
|
49
|
-
// TODO: Upstream limitation - When form is submitted when value is undefined, it will
|
|
50
|
-
// automatically set a clamped value (as defined by `min` attribute, so 0 by default).
|
|
51
|
-
onChange={ ( value, ...args ) => {
|
|
52
|
-
valueRef.current = value;
|
|
53
|
-
onChange?.( value, ...args );
|
|
54
|
-
} }
|
|
55
40
|
{ ...restProps }
|
|
56
41
|
/>
|
|
57
42
|
</ControlWithError>
|
|
@@ -10,25 +10,18 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import RadioControl from '../../radio-control';
|
|
13
|
-
import type { RadioControlProps } from '../../radio-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = RadioControlProps[ 'selected' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedRadioControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
|
-
}: React.ComponentProps< typeof RadioControl > &
|
|
26
|
-
ValidatedControlProps< Value >,
|
|
20
|
+
}: React.ComponentProps< typeof RadioControl > & ValidatedControlProps,
|
|
27
21
|
forwardedRef: React.ForwardedRef< HTMLDivElement >
|
|
28
22
|
) => {
|
|
29
23
|
const validityTargetRef = useRef< HTMLDivElement >( null );
|
|
30
24
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
31
|
-
const valueRef = useRef< Value >( restProps.selected );
|
|
32
25
|
|
|
33
26
|
return (
|
|
34
27
|
<ControlWithError
|
|
@@ -36,9 +29,6 @@ const UnforwardedValidatedRadioControl = (
|
|
|
36
29
|
markWhenOptional={ markWhenOptional }
|
|
37
30
|
// TODO: Upstream limitation - RadioControl does not accept a ref.
|
|
38
31
|
ref={ mergedRefs }
|
|
39
|
-
onValidate={ () => {
|
|
40
|
-
return onValidate?.( valueRef.current );
|
|
41
|
-
} }
|
|
42
32
|
customValidity={ customValidity }
|
|
43
33
|
getValidityTarget={ () =>
|
|
44
34
|
validityTargetRef.current?.querySelector< HTMLInputElement >(
|
|
@@ -46,13 +36,7 @@ const UnforwardedValidatedRadioControl = (
|
|
|
46
36
|
)
|
|
47
37
|
}
|
|
48
38
|
>
|
|
49
|
-
<RadioControl
|
|
50
|
-
onChange={ ( value ) => {
|
|
51
|
-
valueRef.current = value;
|
|
52
|
-
onChange?.( value );
|
|
53
|
-
} }
|
|
54
|
-
{ ...restProps }
|
|
55
|
-
/>
|
|
39
|
+
<RadioControl { ...restProps } />
|
|
56
40
|
</ControlWithError>
|
|
57
41
|
);
|
|
58
42
|
};
|
|
@@ -10,36 +10,27 @@ import { forwardRef, useRef } from '@wordpress/element';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import type { ValidatedControlProps } from './types';
|
|
12
12
|
import RangeControl from '../../range-control';
|
|
13
|
-
import type { RangeControlProps } from '../../range-control/types';
|
|
14
|
-
|
|
15
|
-
type Value = RangeControlProps[ 'value' ];
|
|
16
13
|
|
|
17
14
|
const UnforwardedValidatedRangeControl = (
|
|
18
15
|
{
|
|
19
16
|
required,
|
|
20
|
-
onValidate,
|
|
21
17
|
customValidity,
|
|
22
|
-
onChange,
|
|
23
18
|
markWhenOptional,
|
|
24
19
|
...restProps
|
|
25
20
|
}: Omit<
|
|
26
21
|
React.ComponentProps< typeof RangeControl >,
|
|
27
22
|
'__next40pxDefaultSize' | '__nextHasNoMarginBottom'
|
|
28
23
|
> &
|
|
29
|
-
ValidatedControlProps
|
|
24
|
+
ValidatedControlProps,
|
|
30
25
|
forwardedRef: React.ForwardedRef< HTMLInputElement >
|
|
31
26
|
) => {
|
|
32
27
|
const validityTargetRef = useRef< HTMLInputElement >( null );
|
|
33
28
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
34
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
35
29
|
|
|
36
30
|
return (
|
|
37
31
|
<ControlWithError
|
|
38
32
|
required={ required }
|
|
39
33
|
markWhenOptional={ markWhenOptional }
|
|
40
|
-
onValidate={ () => {
|
|
41
|
-
return onValidate?.( valueRef.current );
|
|
42
|
-
} }
|
|
43
34
|
customValidity={ customValidity }
|
|
44
35
|
getValidityTarget={ () => validityTargetRef.current }
|
|
45
36
|
>
|
|
@@ -47,10 +38,6 @@ const UnforwardedValidatedRangeControl = (
|
|
|
47
38
|
__next40pxDefaultSize
|
|
48
39
|
__nextHasNoMarginBottom
|
|
49
40
|
ref={ mergedRefs }
|
|
50
|
-
onChange={ ( value ) => {
|
|
51
|
-
valueRef.current = value;
|
|
52
|
-
onChange?.( value );
|
|
53
|
-
} }
|
|
54
41
|
{ ...restProps }
|
|
55
42
|
/>
|
|
56
43
|
</ControlWithError>
|
|
@@ -10,25 +10,11 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
10
10
|
import { ControlWithError } from '../control-with-error';
|
|
11
11
|
import SelectControl from '../../select-control';
|
|
12
12
|
import type { ValidatedControlProps } from './types';
|
|
13
|
-
import type { SelectControlProps as _SelectControlProps } from '../../select-control/types';
|
|
14
|
-
|
|
15
|
-
// Only support single value selection
|
|
16
|
-
type SelectControlProps = Omit<
|
|
17
|
-
_SelectControlProps,
|
|
18
|
-
'multiple' | 'onChange' | 'value'
|
|
19
|
-
> & {
|
|
20
|
-
onChange?: ( value: string ) => void;
|
|
21
|
-
value?: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type Value = SelectControlProps[ 'value' ];
|
|
25
13
|
|
|
26
14
|
const UnforwardedValidatedSelectControl = (
|
|
27
15
|
{
|
|
28
16
|
required,
|
|
29
|
-
onValidate,
|
|
30
17
|
customValidity,
|
|
31
|
-
onChange,
|
|
32
18
|
markWhenOptional,
|
|
33
19
|
...restProps
|
|
34
20
|
}: Omit<
|
|
@@ -41,20 +27,16 @@ const UnforwardedValidatedSelectControl = (
|
|
|
41
27
|
> & {
|
|
42
28
|
value?: string;
|
|
43
29
|
onChange: ( value: string ) => void;
|
|
44
|
-
} & ValidatedControlProps
|
|
30
|
+
} & ValidatedControlProps,
|
|
45
31
|
forwardedRef: React.ForwardedRef< HTMLSelectElement >
|
|
46
32
|
) => {
|
|
47
33
|
const validityTargetRef = useRef< HTMLSelectElement >( null );
|
|
48
34
|
const mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );
|
|
49
|
-
const valueRef = useRef< Value >( restProps.value );
|
|
50
35
|
|
|
51
36
|
return (
|
|
52
37
|
<ControlWithError
|
|
53
38
|
required={ required }
|
|
54
39
|
markWhenOptional={ markWhenOptional }
|
|
55
|
-
onValidate={ () => {
|
|
56
|
-
return onValidate?.( valueRef.current );
|
|
57
|
-
} }
|
|
58
40
|
customValidity={ customValidity }
|
|
59
41
|
getValidityTarget={ () => validityTargetRef.current }
|
|
60
42
|
>
|
|
@@ -62,10 +44,6 @@ const UnforwardedValidatedSelectControl = (
|
|
|
62
44
|
__nextHasNoMarginBottom
|
|
63
45
|
__next40pxDefaultSize
|
|
64
46
|
ref={ mergedRefs }
|
|
65
|
-
onChange={ ( value ) => {
|
|
66
|
-
valueRef.current = value;
|
|
67
|
-
onChange?.( value );
|
|
68
|
-
} }
|
|
69
47
|
{ ...restProps }
|
|
70
48
|
/>
|
|
71
49
|
</ControlWithError>
|