@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/select-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport SelectControl from '../../select-control';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport SelectControl from '../../select-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedSelectControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedSelectControl = forwardRef(UnforwardedValidatedSelectControl);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAC1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,uBAAuB;AAAA,MACvB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,31 +6,21 @@ import TextControl from "../../text-control";
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
var UnforwardedValidatedTextControl = ({
|
|
8
8
|
required,
|
|
9
|
-
onValidate,
|
|
10
9
|
customValidity,
|
|
11
|
-
onChange,
|
|
12
10
|
markWhenOptional,
|
|
13
11
|
...restProps
|
|
14
12
|
}, forwardedRef) => {
|
|
15
13
|
const validityTargetRef = useRef(null);
|
|
16
14
|
const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
|
|
17
|
-
const valueRef = useRef(restProps.value);
|
|
18
15
|
return /* @__PURE__ */ _jsx(ControlWithError, {
|
|
19
16
|
required,
|
|
20
17
|
markWhenOptional,
|
|
21
|
-
onValidate: () => {
|
|
22
|
-
return onValidate?.(valueRef.current);
|
|
23
|
-
},
|
|
24
18
|
customValidity,
|
|
25
19
|
getValidityTarget: () => validityTargetRef.current,
|
|
26
20
|
children: /* @__PURE__ */ _jsx(TextControl, {
|
|
27
21
|
__next40pxDefaultSize: true,
|
|
28
22
|
__nextHasNoMarginBottom: true,
|
|
29
23
|
ref: mergedRefs,
|
|
30
|
-
onChange: (value) => {
|
|
31
|
-
valueRef.current = value;
|
|
32
|
-
onChange?.(value);
|
|
33
|
-
},
|
|
34
24
|
...restProps
|
|
35
25
|
})
|
|
36
26
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/text-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextControl from '../../text-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextControl = ({\n required,\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,iBAAiB;AACxB,SAAS,OAAO,YAAY;AAC5B,IAAM,kCAAkC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextControl from '../../text-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextControl, {\n __next40pxDefaultSize: true,\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedTextControl = forwardRef(UnforwardedValidatedTextControl);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,iBAAiB;AACxB,SAAS,OAAO,YAAY;AAC5B,IAAM,kCAAkC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,aAAa;AAAA,MACvC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,uBAAuB,WAAW,+BAA+B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,30 +6,20 @@ import TextareaControl from "../../textarea-control";
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
var UnforwardedValidatedTextareaControl = ({
|
|
8
8
|
required,
|
|
9
|
-
onValidate,
|
|
10
9
|
customValidity,
|
|
11
|
-
onChange,
|
|
12
10
|
markWhenOptional,
|
|
13
11
|
...restProps
|
|
14
12
|
}, forwardedRef) => {
|
|
15
13
|
const validityTargetRef = useRef(null);
|
|
16
14
|
const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
|
|
17
|
-
const valueRef = useRef(restProps.value);
|
|
18
15
|
return /* @__PURE__ */ _jsx(ControlWithError, {
|
|
19
16
|
required,
|
|
20
17
|
markWhenOptional,
|
|
21
|
-
onValidate: () => {
|
|
22
|
-
return onValidate?.(valueRef.current);
|
|
23
|
-
},
|
|
24
18
|
customValidity,
|
|
25
19
|
getValidityTarget: () => validityTargetRef.current,
|
|
26
20
|
children: /* @__PURE__ */ _jsx(TextareaControl, {
|
|
27
21
|
__nextHasNoMarginBottom: true,
|
|
28
22
|
ref: mergedRefs,
|
|
29
|
-
onChange: (value) => {
|
|
30
|
-
valueRef.current = value;
|
|
31
|
-
onChange?.(value);
|
|
32
|
-
},
|
|
33
23
|
...restProps
|
|
34
24
|
})
|
|
35
25
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/textarea-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextareaControl from '../../textarea-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextareaControl = ({\n required,\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextareaControl from '../../textarea-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextareaControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextareaControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedTextareaControl = forwardRef(UnforwardedValidatedTextareaControl);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,iBAAiB;AAAA,MAC3C,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,2BAA2B,WAAW,mCAAmC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,15 +6,12 @@ import ToggleControl from "../../toggle-control";
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
var UnforwardedValidatedToggleControl = ({
|
|
8
8
|
required,
|
|
9
|
-
onValidate,
|
|
10
9
|
customValidity,
|
|
11
|
-
onChange,
|
|
12
10
|
markWhenOptional,
|
|
13
11
|
...restProps
|
|
14
12
|
}, forwardedRef) => {
|
|
15
13
|
const validityTargetRef = useRef(null);
|
|
16
14
|
const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
|
|
17
|
-
const valueRef = useRef(restProps.checked);
|
|
18
15
|
useEffect(() => {
|
|
19
16
|
if (validityTargetRef.current) {
|
|
20
17
|
validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;
|
|
@@ -23,18 +20,11 @@ var UnforwardedValidatedToggleControl = ({
|
|
|
23
20
|
return /* @__PURE__ */ _jsx(ControlWithError, {
|
|
24
21
|
required,
|
|
25
22
|
markWhenOptional,
|
|
26
|
-
onValidate: () => {
|
|
27
|
-
return onValidate?.(valueRef.current);
|
|
28
|
-
},
|
|
29
23
|
customValidity,
|
|
30
24
|
getValidityTarget: () => validityTargetRef.current,
|
|
31
25
|
children: /* @__PURE__ */ _jsx(ToggleControl, {
|
|
32
26
|
__nextHasNoMarginBottom: true,
|
|
33
27
|
ref: mergedRefs,
|
|
34
|
-
onChange: (value) => {
|
|
35
|
-
valueRef.current = value;
|
|
36
|
-
onChange?.(value);
|
|
37
|
-
},
|
|
38
28
|
...restProps
|
|
39
29
|
})
|
|
40
30
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/toggle-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\n\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n if (validityTargetRef.current) {\n validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;\n }\n }, [required]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedToggleControl = forwardRef(UnforwardedValidatedToggleControl);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAG1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,aAAa,QAAQ,aAAa,SAAS,WAAW;AAAA,IAC7F;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,33 +5,23 @@ import { ToggleGroupControl } from "../../toggle-group-control";
|
|
|
5
5
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
6
|
var UnforwardedValidatedToggleGroupControl = ({
|
|
7
7
|
required,
|
|
8
|
-
onValidate,
|
|
9
8
|
customValidity,
|
|
10
|
-
onChange,
|
|
11
9
|
markWhenOptional,
|
|
12
10
|
...restProps
|
|
13
11
|
}, forwardedRef) => {
|
|
14
12
|
const validityTargetRef = useRef(null);
|
|
15
|
-
const valueRef = useRef(restProps.value);
|
|
16
13
|
const nameAttr = useId();
|
|
17
14
|
return /* @__PURE__ */ _jsxs("div", {
|
|
18
15
|
className: "components-validated-control__wrapper-with-error-delegate",
|
|
19
16
|
children: [/* @__PURE__ */ _jsx(ControlWithError, {
|
|
20
17
|
required,
|
|
21
18
|
markWhenOptional,
|
|
22
|
-
onValidate: () => {
|
|
23
|
-
return onValidate?.(valueRef.current);
|
|
24
|
-
},
|
|
25
19
|
customValidity,
|
|
26
20
|
getValidityTarget: () => validityTargetRef.current,
|
|
27
21
|
children: /* @__PURE__ */ _jsx(ToggleGroupControl, {
|
|
28
22
|
__nextHasNoMarginBottom: true,
|
|
29
23
|
__next40pxDefaultSize: true,
|
|
30
24
|
ref: forwardedRef,
|
|
31
|
-
onChange: (value) => {
|
|
32
|
-
valueRef.current = value;
|
|
33
|
-
onChange?.(value);
|
|
34
|
-
},
|
|
35
25
|
...restProps
|
|
36
26
|
})
|
|
37
27
|
}), /* @__PURE__ */ _jsx("input", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/toggle-group-control.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useId, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport { ToggleGroupControl } from '../../toggle-group-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleGroupControl = ({\n required,\n
|
|
5
|
-
"mappings": ";AAGA,SAAS,YAAY,OAAO,cAAc;AAK1C,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,yCAAyC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useId, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport { ToggleGroupControl } from '../../toggle-group-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleGroupControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const nameAttr = useId();\n return /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-validated-control__wrapper-with-error-delegate\",\n children: [/*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleGroupControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: forwardedRef,\n ...restProps\n })\n }), /*#__PURE__*/_jsx(\"input\", {\n className: \"components-validated-control__error-delegate\",\n type: \"radio\",\n ref: validityTargetRef,\n required: required,\n checked: restProps.value !== undefined,\n tabIndex: -1\n // A name attribute is needed for the `required` behavior to work.\n ,\n name: nameAttr,\n onChange: () => {},\n onFocus: e => {\n e.target.previousElementSibling?.querySelector('[data-active-item=\"true\"]')?.focus();\n }\n })]\n });\n};\nexport const ValidatedToggleGroupControl = forwardRef(UnforwardedValidatedToggleGroupControl);"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,YAAY,OAAO,cAAc;AAK1C,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,yCAAyC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,WAAW,MAAM;AACvB,SAAoB,sBAAM,OAAO;AAAA,IAC/B,WAAW;AAAA,IACX,UAAU,CAAc,qBAAK,kBAAkB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,MAAM,kBAAkB;AAAA,MAC3C,UAAuB,qBAAK,oBAAoB;AAAA,QAC9C,yBAAyB;AAAA,QACzB,uBAAuB;AAAA,QACvB,KAAK;AAAA,QACL,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC,GAAgB,qBAAK,SAAS;AAAA,MAC7B,WAAW;AAAA,MACX,MAAM;AAAA,MACN,KAAK;AAAA,MACL;AAAA,MACA,SAAS,UAAU,UAAU;AAAA,MAC7B,UAAU;AAAA,MAGV,MAAM;AAAA,MACN,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,SAAS,OAAK;AACZ,UAAE,OAAO,wBAAwB,cAAc,2BAA2B,GAAG,MAAM;AAAA,MACrF;AAAA,IACF,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,8BAA8B,WAAW,sCAAsC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// packages/components/src/validated-form-controls/control-with-error.tsx
|
|
2
|
-
import { usePrevious } from "@wordpress/compose";
|
|
3
2
|
import { __ } from "@wordpress/i18n";
|
|
4
3
|
import { cloneElement, forwardRef, useEffect, useState } from "@wordpress/element";
|
|
5
|
-
import { withIgnoreIMEEvents } from "../utils/with-ignore-ime-events";
|
|
6
4
|
import { ValidityIndicator } from "./validity-indicator";
|
|
7
5
|
import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
8
6
|
function appendRequiredIndicator(label, required, markWhenOptional) {
|
|
@@ -18,30 +16,28 @@ function appendRequiredIndicator(label, required, markWhenOptional) {
|
|
|
18
16
|
}
|
|
19
17
|
return label;
|
|
20
18
|
}
|
|
19
|
+
var VALIDITY_VISIBLE_ATTRIBUTE = "data-validity-visible";
|
|
21
20
|
function UnforwardedControlWithError({
|
|
22
21
|
required,
|
|
23
22
|
markWhenOptional,
|
|
24
|
-
onValidate,
|
|
25
23
|
customValidity,
|
|
26
24
|
getValidityTarget,
|
|
27
25
|
children
|
|
28
26
|
}, forwardedRef) {
|
|
29
27
|
const [errorMessage, setErrorMessage] = useState();
|
|
30
28
|
const [statusMessage, setStatusMessage] = useState();
|
|
29
|
+
const [showMessage, setShowMessage] = useState(false);
|
|
31
30
|
const [isTouched, setIsTouched] = useState(false);
|
|
32
|
-
const previousCustomValidityType = usePrevious(customValidity?.type);
|
|
33
31
|
useEffect(() => {
|
|
34
32
|
const validityTarget = getValidityTarget();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
validityTarget?.removeEventListener("invalid", showValidationMessage);
|
|
33
|
+
const handler = () => {
|
|
34
|
+
setShowMessage(true);
|
|
35
|
+
validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
|
|
39
36
|
};
|
|
40
|
-
|
|
37
|
+
validityTarget?.addEventListener("invalid", handler);
|
|
38
|
+
return () => validityTarget?.removeEventListener("invalid", handler);
|
|
39
|
+
}, [getValidityTarget]);
|
|
41
40
|
useEffect(() => {
|
|
42
|
-
if (!isTouched) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
41
|
const validityTarget = getValidityTarget();
|
|
46
42
|
if (!customValidity?.type) {
|
|
47
43
|
validityTarget?.setCustomValidity("");
|
|
@@ -51,20 +47,15 @@ function UnforwardedControlWithError({
|
|
|
51
47
|
}
|
|
52
48
|
switch (customValidity.type) {
|
|
53
49
|
case "validating": {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, 1e3);
|
|
62
|
-
return () => clearTimeout(timer);
|
|
50
|
+
validityTarget?.setCustomValidity("");
|
|
51
|
+
setErrorMessage(void 0);
|
|
52
|
+
setStatusMessage({
|
|
53
|
+
type: "validating",
|
|
54
|
+
message: customValidity.message
|
|
55
|
+
});
|
|
56
|
+
break;
|
|
63
57
|
}
|
|
64
58
|
case "valid": {
|
|
65
|
-
if (previousCustomValidityType === "valid") {
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
59
|
validityTarget?.setCustomValidity("");
|
|
69
60
|
setErrorMessage(validityTarget?.validationMessage);
|
|
70
61
|
setStatusMessage({
|
|
@@ -81,51 +72,55 @@ function UnforwardedControlWithError({
|
|
|
81
72
|
break;
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
|
-
}, [
|
|
75
|
+
}, [customValidity, getValidityTarget]);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!isTouched || showMessage) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (customValidity?.type === "validating") {
|
|
81
|
+
const timer = setTimeout(() => {
|
|
82
|
+
setShowMessage(true);
|
|
83
|
+
}, 1e3);
|
|
84
|
+
return () => clearTimeout(timer);
|
|
85
|
+
}
|
|
86
|
+
setShowMessage(true);
|
|
87
|
+
}, [isTouched, customValidity?.type, showMessage]);
|
|
85
88
|
const onBlur = (event) => {
|
|
86
89
|
if (isTouched) {
|
|
87
90
|
return;
|
|
88
91
|
}
|
|
89
92
|
if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
|
|
90
93
|
setIsTouched(true);
|
|
91
|
-
|
|
94
|
+
getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const message = () => {
|
|
98
|
+
if (errorMessage) {
|
|
99
|
+
return /* @__PURE__ */ _jsx(ValidityIndicator, {
|
|
100
|
+
type: "invalid",
|
|
101
|
+
message: errorMessage
|
|
102
|
+
});
|
|
98
103
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
if (statusMessage?.type) {
|
|
105
|
+
return /* @__PURE__ */ _jsx(ValidityIndicator, {
|
|
106
|
+
type: statusMessage.type,
|
|
107
|
+
message: statusMessage.message
|
|
108
|
+
});
|
|
103
109
|
}
|
|
110
|
+
return null;
|
|
104
111
|
};
|
|
105
|
-
return (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}), /* @__PURE__ */ _jsxs("div", {
|
|
118
|
-
"aria-live": "polite",
|
|
119
|
-
children: [errorMessage && /* @__PURE__ */ _jsx(ValidityIndicator, {
|
|
120
|
-
type: "invalid",
|
|
121
|
-
message: errorMessage
|
|
122
|
-
}), !errorMessage && statusMessage && /* @__PURE__ */ _jsx(ValidityIndicator, {
|
|
123
|
-
type: statusMessage.type,
|
|
124
|
-
message: statusMessage.message
|
|
125
|
-
})]
|
|
126
|
-
})]
|
|
127
|
-
})
|
|
128
|
-
);
|
|
112
|
+
return /* @__PURE__ */ _jsxs("div", {
|
|
113
|
+
className: "components-validated-control",
|
|
114
|
+
ref: forwardedRef,
|
|
115
|
+
onBlur,
|
|
116
|
+
children: [cloneElement(children, {
|
|
117
|
+
label: appendRequiredIndicator(children.props.label, required, markWhenOptional),
|
|
118
|
+
required
|
|
119
|
+
}), /* @__PURE__ */ _jsx("div", {
|
|
120
|
+
"aria-live": "polite",
|
|
121
|
+
children: showMessage && message()
|
|
122
|
+
})]
|
|
123
|
+
});
|
|
129
124
|
}
|
|
130
125
|
var ControlWithError = forwardRef(UnforwardedControlWithError);
|
|
131
126
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/validated-form-controls/control-with-error.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cloneElement, forwardRef, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\n\nimport { ValidityIndicator } from './validity-indicator';\nimport { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from \"react/jsx-runtime\";\nfunction appendRequiredIndicator(label, required, markWhenOptional) {\n if (required && !markWhenOptional) {\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [label, \" \", `(${__('Required')})`]\n });\n }\n if (!required && markWhenOptional) {\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [label, \" \", `(${__('Optional')})`]\n });\n }\n return label;\n}\nconst VALIDITY_VISIBLE_ATTRIBUTE = 'data-validity-visible';\n\n/**\n * HTML elements that support the Constraint Validation API.\n *\n * Here, we exclude HTMLButtonElement because although it does technically support the API,\n * normal buttons are actually exempted from any validation.\n * @see https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/willValidate\n */\n\nfunction UnforwardedControlWithError({\n required,\n markWhenOptional,\n customValidity,\n getValidityTarget,\n children\n}, forwardedRef) {\n const [errorMessage, setErrorMessage] = useState();\n const [statusMessage, setStatusMessage] = useState();\n const [showMessage, setShowMessage] = useState(false);\n const [isTouched, setIsTouched] = useState(false);\n\n // Ensure that error messages are visible when an `invalid` event is triggered,\n // e.g. when a form is submitted or reportValidity() is called.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n const handler = () => {\n setShowMessage(true);\n validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, '');\n };\n validityTarget?.addEventListener('invalid', handler);\n return () => validityTarget?.removeEventListener('invalid', handler);\n }, [getValidityTarget]);\n\n // Handle validity messages.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n if (!customValidity?.type) {\n validityTarget?.setCustomValidity('');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage(undefined);\n return;\n }\n switch (customValidity.type) {\n case 'validating':\n {\n validityTarget?.setCustomValidity('');\n setErrorMessage(undefined);\n setStatusMessage({\n type: 'validating',\n message: customValidity.message\n });\n break;\n }\n case 'valid':\n {\n validityTarget?.setCustomValidity('');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage({\n type: 'valid',\n message: customValidity.message\n });\n break;\n }\n case 'invalid':\n {\n var _customValidity$messa;\n validityTarget?.setCustomValidity((_customValidity$messa = customValidity.message) !== null && _customValidity$messa !== void 0 ? _customValidity$messa : '');\n setErrorMessage(validityTarget?.validationMessage);\n setStatusMessage(undefined);\n break;\n }\n }\n }, [customValidity, getValidityTarget]);\n\n // Show messages if field has been touched (i.e. has blurred at least once),\n // or validation has been triggered by the consumer/user.\n useEffect(() => {\n if (!isTouched || showMessage) {\n return;\n }\n if (customValidity?.type === 'validating') {\n // Don't show validating indicators for quick calls that take less than 1 sec.\n const timer = setTimeout(() => {\n setShowMessage(true);\n }, 1000);\n return () => clearTimeout(timer);\n }\n setShowMessage(true);\n }, [isTouched, customValidity?.type, showMessage]);\n\n // Mark blurred fields as touched.\n const onBlur = event => {\n if (isTouched) {\n return;\n }\n\n // Only consider \"blurred from the component\" if focus has fully left the wrapping div.\n // This prevents unnecessary blurs from components with multiple focusable elements.\n if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {\n setIsTouched(true);\n getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, '');\n }\n };\n const message = () => {\n if (errorMessage) {\n return /*#__PURE__*/_jsx(ValidityIndicator, {\n type: \"invalid\",\n message: errorMessage\n });\n }\n if (statusMessage?.type) {\n return /*#__PURE__*/_jsx(ValidityIndicator, {\n type: statusMessage.type,\n message: statusMessage.message\n });\n }\n return null;\n };\n return /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-validated-control\",\n ref: forwardedRef,\n onBlur: onBlur,\n children: [cloneElement(children, {\n label: appendRequiredIndicator(children.props.label, required, markWhenOptional),\n required\n }), /*#__PURE__*/_jsx(\"div\", {\n \"aria-live\": \"polite\",\n children: showMessage && message()\n })]\n });\n}\nexport const ControlWithError = forwardRef(UnforwardedControlWithError);"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
height: 36px;
|
|
275
275
|
align-items: center;
|
|
276
276
|
box-sizing: border-box;
|
|
277
|
-
padding:
|
|
277
|
+
padding: 4px 12px;
|
|
278
278
|
border-radius: 2px;
|
|
279
279
|
color: var(--wp-components-color-foreground, #1e1e1e);
|
|
280
280
|
}
|
|
@@ -1630,7 +1630,7 @@ body.is-dragging-components-draggable {
|
|
|
1630
1630
|
}
|
|
1631
1631
|
.components-dropdown-menu__menu .components-menu-item__button,
|
|
1632
1632
|
.components-dropdown-menu__menu .components-menu-item__button.components-button {
|
|
1633
|
-
min-height:
|
|
1633
|
+
min-height: 32px;
|
|
1634
1634
|
height: auto;
|
|
1635
1635
|
text-align: right;
|
|
1636
1636
|
padding-right: 8px;
|
|
@@ -2033,7 +2033,7 @@ body.is-dragging-components-draggable {
|
|
|
2033
2033
|
height: 36px;
|
|
2034
2034
|
justify-content: center;
|
|
2035
2035
|
margin: 0 0 24px 0;
|
|
2036
|
-
padding: 0
|
|
2036
|
+
padding: 0 24px;
|
|
2037
2037
|
position: relative;
|
|
2038
2038
|
width: 100%;
|
|
2039
2039
|
}
|
|
@@ -2069,10 +2069,10 @@ body.is-dragging-components-draggable {
|
|
|
2069
2069
|
position: absolute;
|
|
2070
2070
|
}
|
|
2071
2071
|
.components-button.components-guide__back-button {
|
|
2072
|
-
right:
|
|
2072
|
+
right: 24px;
|
|
2073
2073
|
}
|
|
2074
2074
|
.components-button.components-guide__forward-button, .components-button.components-guide__finish-button {
|
|
2075
|
-
left:
|
|
2075
|
+
left: 24px;
|
|
2076
2076
|
}
|
|
2077
2077
|
|
|
2078
2078
|
[role=region] {
|
|
@@ -2355,12 +2355,12 @@ body.is-dragging-components-draggable {
|
|
|
2355
2355
|
max-height: 70%;
|
|
2356
2356
|
}
|
|
2357
2357
|
}
|
|
2358
|
-
.components-modal__frame.is-full-screen .components-modal__content {
|
|
2358
|
+
.components-modal__frame.is-full-screen :where(.components-modal__content) {
|
|
2359
2359
|
display: flex;
|
|
2360
|
-
margin-bottom:
|
|
2360
|
+
margin-bottom: 24px;
|
|
2361
2361
|
padding-bottom: 0;
|
|
2362
2362
|
}
|
|
2363
|
-
.components-modal__frame.is-full-screen .components-modal__content > :last-child {
|
|
2363
|
+
.components-modal__frame.is-full-screen :where(.components-modal__content) > :last-child {
|
|
2364
2364
|
flex: 1;
|
|
2365
2365
|
}
|
|
2366
2366
|
|
|
@@ -2387,7 +2387,7 @@ body.is-dragging-components-draggable {
|
|
|
2387
2387
|
.components-modal__header {
|
|
2388
2388
|
box-sizing: border-box;
|
|
2389
2389
|
border-bottom: 1px solid transparent;
|
|
2390
|
-
padding: 24px
|
|
2390
|
+
padding: 24px;
|
|
2391
2391
|
display: flex;
|
|
2392
2392
|
flex-direction: row;
|
|
2393
2393
|
justify-content: space-between;
|
|
@@ -2434,12 +2434,12 @@ body.is-dragging-components-draggable {
|
|
|
2434
2434
|
.components-modal__content {
|
|
2435
2435
|
flex: 1;
|
|
2436
2436
|
margin-top: 72px;
|
|
2437
|
-
padding: 4px
|
|
2437
|
+
padding: 4px 24px 24px;
|
|
2438
2438
|
overflow: auto;
|
|
2439
2439
|
}
|
|
2440
2440
|
.components-modal__content.hide-header {
|
|
2441
2441
|
margin-top: 0;
|
|
2442
|
-
padding-top:
|
|
2442
|
+
padding-top: 24px;
|
|
2443
2443
|
}
|
|
2444
2444
|
.components-modal__content.is-scrollable:focus-visible {
|
|
2445
2445
|
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
|
|
@@ -2481,16 +2481,9 @@ body.is-dragging-components-draggable {
|
|
|
2481
2481
|
.components-notice__actions {
|
|
2482
2482
|
display: flex;
|
|
2483
2483
|
flex-wrap: wrap;
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
margin-right: 12px;
|
|
2488
|
-
}
|
|
2489
|
-
.components-notice__action.components-button.is-secondary {
|
|
2490
|
-
vertical-align: initial;
|
|
2491
|
-
}
|
|
2492
|
-
.components-notice__action.components-button {
|
|
2493
|
-
margin-left: 8px;
|
|
2484
|
+
align-items: center;
|
|
2485
|
+
gap: 12px;
|
|
2486
|
+
margin-top: 12px;
|
|
2494
2487
|
}
|
|
2495
2488
|
|
|
2496
2489
|
.components-notice__dismiss {
|
|
@@ -2515,11 +2508,6 @@ body.is-dragging-components-draggable {
|
|
|
2515
2508
|
margin-bottom: 12px;
|
|
2516
2509
|
line-height: 2;
|
|
2517
2510
|
}
|
|
2518
|
-
.components-notice-list .components-notice__action.components-button {
|
|
2519
|
-
display: block;
|
|
2520
|
-
margin-right: 0;
|
|
2521
|
-
margin-top: 8px;
|
|
2522
|
-
}
|
|
2523
2511
|
|
|
2524
2512
|
.components-panel {
|
|
2525
2513
|
background: #fff;
|
|
@@ -3891,30 +3879,30 @@ div.components-toolbar > div + div.has-left-divider::before {
|
|
|
3891
3879
|
margin-right: 8px;
|
|
3892
3880
|
}
|
|
3893
3881
|
|
|
3894
|
-
.components-validated-control:has(:is(input, select):
|
|
3882
|
+
.components-validated-control:has(:is(input, select):invalid[data-validity-visible]) .components-input-control__backdrop {
|
|
3895
3883
|
--wp-components-color-accent: #cc1818;
|
|
3896
3884
|
border-color: #cc1818;
|
|
3897
3885
|
}
|
|
3898
|
-
.components-validated-control :is(textarea, input[type=text]):
|
|
3886
|
+
.components-validated-control :is(textarea, input[type=text]):invalid[data-validity-visible] {
|
|
3899
3887
|
--wp-admin-theme-color: #cc1818;
|
|
3900
3888
|
--wp-components-color-accent: #cc1818;
|
|
3901
3889
|
border-color: #cc1818;
|
|
3902
3890
|
}
|
|
3903
|
-
.components-validated-control .components-combobox-control__suggestions-container:has(input:
|
|
3904
|
-
|
|
3891
|
+
.components-validated-control .components-combobox-control__suggestions-container:has(input:invalid[data-validity-visible]):not(:has([aria-expanded=true])) {
|
|
3892
|
+
--wp-components-color-accent: #cc1818;
|
|
3905
3893
|
}
|
|
3906
3894
|
|
|
3907
3895
|
.components-validated-control__wrapper-with-error-delegate {
|
|
3908
3896
|
position: relative;
|
|
3909
3897
|
}
|
|
3910
|
-
.components-validated-control__wrapper-with-error-delegate:has(select:
|
|
3898
|
+
.components-validated-control__wrapper-with-error-delegate:has(select:invalid[data-validity-visible]) .components-input-control__backdrop {
|
|
3911
3899
|
--wp-components-color-accent: #cc1818;
|
|
3912
3900
|
border-color: #cc1818;
|
|
3913
3901
|
}
|
|
3914
|
-
.components-validated-control__wrapper-with-error-delegate:has(input[type=radio]:invalid) {
|
|
3902
|
+
.components-validated-control__wrapper-with-error-delegate:has(input[type=radio]:invalid[data-validity-visible]) {
|
|
3915
3903
|
--wp-components-color-accent: #cc1818;
|
|
3916
3904
|
}
|
|
3917
|
-
.components-validated-control__wrapper-with-error-delegate:has(input:
|
|
3905
|
+
.components-validated-control__wrapper-with-error-delegate:has(input:invalid[data-validity-visible]) .components-form-token-field__input-container:not(:has([aria-expanded=true])) {
|
|
3918
3906
|
--wp-components-color-accent: #cc1818;
|
|
3919
3907
|
border-color: #cc1818;
|
|
3920
3908
|
}
|