@wordpress/components 30.9.0 → 31.0.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 +26 -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/form-token-field/index.js +1 -13
- package/build/form-token-field/index.js.map +3 -3
- 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/query-controls/index.js +0 -1
- package/build/query-controls/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 -13
- 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/form-token-field/index.js +1 -13
- package/build-module/form-token-field/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/query-controls/index.js +0 -1
- package/build-module/query-controls/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 -13
- 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/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +0 -6
- package/build-types/form-token-field/types.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/query-controls/index.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/form-token-field/README.md +0 -2
- package/src/form-token-field/index.tsx +1 -13
- package/src/form-token-field/stories/index.story.tsx +0 -2
- package/src/form-token-field/test/index.tsx +0 -1
- package/src/form-token-field/types.ts +0 -6
- 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/query-controls/index.tsx +0 -1
- 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 +4 -21
- 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
|
@@ -40,31 +40,21 @@ var import_range_control = __toESM(require("../../range-control"));
|
|
|
40
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
41
|
var UnforwardedValidatedRangeControl = ({
|
|
42
42
|
required,
|
|
43
|
-
onValidate,
|
|
44
43
|
customValidity,
|
|
45
|
-
onChange,
|
|
46
44
|
markWhenOptional,
|
|
47
45
|
...restProps
|
|
48
46
|
}, forwardedRef) => {
|
|
49
47
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
50
48
|
const mergedRefs = (0, import_compose.useMergeRefs)([forwardedRef, validityTargetRef]);
|
|
51
|
-
const valueRef = (0, import_element.useRef)(restProps.value);
|
|
52
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
53
50
|
required,
|
|
54
51
|
markWhenOptional,
|
|
55
|
-
onValidate: () => {
|
|
56
|
-
return onValidate?.(valueRef.current);
|
|
57
|
-
},
|
|
58
52
|
customValidity,
|
|
59
53
|
getValidityTarget: () => validityTargetRef.current,
|
|
60
54
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_range_control.default, {
|
|
61
55
|
__next40pxDefaultSize: true,
|
|
62
56
|
__nextHasNoMarginBottom: true,
|
|
63
57
|
ref: mergedRefs,
|
|
64
|
-
onChange: (value) => {
|
|
65
|
-
valueRef.current = value;
|
|
66
|
-
onChange?.(value);
|
|
67
|
-
},
|
|
68
58
|
...restProps
|
|
69
59
|
})
|
|
70
60
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/validated-form-controls/components/range-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 RangeControl from '../../range-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedRangeControl = ({\n required,\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,qBAAmC;AAKnC,gCAAiC;AACjC,2BAAyB;AACzB,yBAA4B;AAC5B,IAAM,mCAAmC,CAAC;AAAA,EACxC;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 RangeControl from '../../range-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedRangeControl = ({\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(RangeControl, {\n __next40pxDefaultSize: true,\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedRangeControl = forwardRef(UnforwardedValidatedRangeControl);"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,qBAAmC;AAKnC,gCAAiC;AACjC,2BAAyB;AACzB,yBAA4B;AAC5B,IAAM,mCAAmC,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,iBAAa,6BAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,uCAAAA,KAAK,4CAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,uCAAAA,KAAK,qBAAAC,SAAc;AAAA,MACxC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,4BAAwB,2BAAW,gCAAgC;",
|
|
6
6
|
"names": ["_jsx", "RangeControl"]
|
|
7
7
|
}
|
|
@@ -40,31 +40,21 @@ var import_select_control = __toESM(require("../../select-control"));
|
|
|
40
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
41
|
var UnforwardedValidatedSelectControl = ({
|
|
42
42
|
required,
|
|
43
|
-
onValidate,
|
|
44
43
|
customValidity,
|
|
45
|
-
onChange,
|
|
46
44
|
markWhenOptional,
|
|
47
45
|
...restProps
|
|
48
46
|
}, forwardedRef) => {
|
|
49
47
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
50
48
|
const mergedRefs = (0, import_compose.useMergeRefs)([forwardedRef, validityTargetRef]);
|
|
51
|
-
const valueRef = (0, import_element.useRef)(restProps.value);
|
|
52
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
53
50
|
required,
|
|
54
51
|
markWhenOptional,
|
|
55
|
-
onValidate: () => {
|
|
56
|
-
return onValidate?.(valueRef.current);
|
|
57
|
-
},
|
|
58
52
|
customValidity,
|
|
59
53
|
getValidityTarget: () => validityTargetRef.current,
|
|
60
54
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_select_control.default, {
|
|
61
55
|
__nextHasNoMarginBottom: true,
|
|
62
56
|
__next40pxDefaultSize: true,
|
|
63
57
|
ref: mergedRefs,
|
|
64
|
-
onChange: (value) => {
|
|
65
|
-
valueRef.current = value;
|
|
66
|
-
onChange?.(value);
|
|
67
|
-
},
|
|
68
58
|
...restProps
|
|
69
59
|
})
|
|
70
60
|
});
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAA6B;AAK7B,gCAAiC;AACjC,4BAA0B;
|
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAA6B;AAK7B,gCAAiC;AACjC,4BAA0B;AAC1B,yBAA4B;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,iBAAa,6BAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,uCAAAA,KAAK,4CAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,uCAAAA,KAAK,sBAAAC,SAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,uBAAuB;AAAA,MACvB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,6BAAyB,2BAAW,iCAAiC;",
|
|
6
6
|
"names": ["_jsx", "SelectControl"]
|
|
7
7
|
}
|
|
@@ -40,31 +40,21 @@ var import_text_control = __toESM(require("../../text-control"));
|
|
|
40
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
41
|
var UnforwardedValidatedTextControl = ({
|
|
42
42
|
required,
|
|
43
|
-
onValidate,
|
|
44
43
|
customValidity,
|
|
45
|
-
onChange,
|
|
46
44
|
markWhenOptional,
|
|
47
45
|
...restProps
|
|
48
46
|
}, forwardedRef) => {
|
|
49
47
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
50
48
|
const mergedRefs = (0, import_compose.useMergeRefs)([forwardedRef, validityTargetRef]);
|
|
51
|
-
const valueRef = (0, import_element.useRef)(restProps.value);
|
|
52
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
53
50
|
required,
|
|
54
51
|
markWhenOptional,
|
|
55
|
-
onValidate: () => {
|
|
56
|
-
return onValidate?.(valueRef.current);
|
|
57
|
-
},
|
|
58
52
|
customValidity,
|
|
59
53
|
getValidityTarget: () => validityTargetRef.current,
|
|
60
54
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text_control.default, {
|
|
61
55
|
__next40pxDefaultSize: true,
|
|
62
56
|
__nextHasNoMarginBottom: true,
|
|
63
57
|
ref: mergedRefs,
|
|
64
|
-
onChange: (value) => {
|
|
65
|
-
valueRef.current = value;
|
|
66
|
-
onChange?.(value);
|
|
67
|
-
},
|
|
68
58
|
...restProps
|
|
69
59
|
})
|
|
70
60
|
});
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,qBAAmC;AAKnC,gCAAiC;AACjC,0BAAwB;AACxB,yBAA4B;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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA6B;AAC7B,qBAAmC;AAKnC,gCAAiC;AACjC,0BAAwB;AACxB,yBAA4B;AAC5B,IAAM,kCAAkC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,iBAAa,6BAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,uCAAAA,KAAK,4CAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,uCAAAA,KAAK,oBAAAC,SAAa;AAAA,MACvC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,2BAAuB,2BAAW,+BAA+B;",
|
|
6
6
|
"names": ["_jsx", "TextControl"]
|
|
7
7
|
}
|
|
@@ -40,30 +40,20 @@ var import_textarea_control = __toESM(require("../../textarea-control"));
|
|
|
40
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
41
|
var UnforwardedValidatedTextareaControl = ({
|
|
42
42
|
required,
|
|
43
|
-
onValidate,
|
|
44
43
|
customValidity,
|
|
45
|
-
onChange,
|
|
46
44
|
markWhenOptional,
|
|
47
45
|
...restProps
|
|
48
46
|
}, forwardedRef) => {
|
|
49
47
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
50
48
|
const mergedRefs = (0, import_compose.useMergeRefs)([forwardedRef, validityTargetRef]);
|
|
51
|
-
const valueRef = (0, import_element.useRef)(restProps.value);
|
|
52
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
53
50
|
required,
|
|
54
51
|
markWhenOptional,
|
|
55
|
-
onValidate: () => {
|
|
56
|
-
return onValidate?.(valueRef.current);
|
|
57
|
-
},
|
|
58
52
|
customValidity,
|
|
59
53
|
getValidityTarget: () => validityTargetRef.current,
|
|
60
54
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_textarea_control.default, {
|
|
61
55
|
__nextHasNoMarginBottom: true,
|
|
62
56
|
ref: mergedRefs,
|
|
63
|
-
onChange: (value) => {
|
|
64
|
-
valueRef.current = value;
|
|
65
|
-
onChange?.(value);
|
|
66
|
-
},
|
|
67
57
|
...restProps
|
|
68
58
|
})
|
|
69
59
|
});
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAA6B;AAK7B,gCAAiC;AACjC,8BAA4B;AAC5B,yBAA4B;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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmC;AACnC,qBAA6B;AAK7B,gCAAiC;AACjC,8BAA4B;AAC5B,yBAA4B;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,iBAAa,6BAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,uCAAAA,KAAK,4CAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,uCAAAA,KAAK,wBAAAC,SAAiB;AAAA,MAC3C,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,+BAA2B,2BAAW,mCAAmC;",
|
|
6
6
|
"names": ["_jsx", "TextareaControl"]
|
|
7
7
|
}
|
|
@@ -40,15 +40,12 @@ var import_toggle_control = __toESM(require("../../toggle-control"));
|
|
|
40
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
41
41
|
var UnforwardedValidatedToggleControl = ({
|
|
42
42
|
required,
|
|
43
|
-
onValidate,
|
|
44
43
|
customValidity,
|
|
45
|
-
onChange,
|
|
46
44
|
markWhenOptional,
|
|
47
45
|
...restProps
|
|
48
46
|
}, forwardedRef) => {
|
|
49
47
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
50
48
|
const mergedRefs = (0, import_compose.useMergeRefs)([forwardedRef, validityTargetRef]);
|
|
51
|
-
const valueRef = (0, import_element.useRef)(restProps.checked);
|
|
52
49
|
(0, import_element.useEffect)(() => {
|
|
53
50
|
if (validityTargetRef.current) {
|
|
54
51
|
validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;
|
|
@@ -57,18 +54,11 @@ var UnforwardedValidatedToggleControl = ({
|
|
|
57
54
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
58
55
|
required,
|
|
59
56
|
markWhenOptional,
|
|
60
|
-
onValidate: () => {
|
|
61
|
-
return onValidate?.(valueRef.current);
|
|
62
|
-
},
|
|
63
57
|
customValidity,
|
|
64
58
|
getValidityTarget: () => validityTargetRef.current,
|
|
65
59
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_toggle_control.default, {
|
|
66
60
|
__nextHasNoMarginBottom: true,
|
|
67
61
|
ref: mergedRefs,
|
|
68
|
-
onChange: (value) => {
|
|
69
|
-
valueRef.current = value;
|
|
70
|
-
onChange?.(value);
|
|
71
|
-
},
|
|
72
62
|
...restProps
|
|
73
63
|
})
|
|
74
64
|
});
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8C;AAC9C,qBAA6B;AAK7B,gCAAiC;AACjC,4BAA0B;
|
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8C;AAC9C,qBAA6B;AAK7B,gCAAiC;AACjC,4BAA0B;AAG1B,yBAA4B;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,iBAAa,6BAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,gCAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,aAAa,QAAQ,aAAa,SAAS,WAAW;AAAA,IAC7F;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb,SAAoB,uCAAAA,KAAK,4CAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,uCAAAA,KAAK,sBAAAC,SAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,6BAAyB,2BAAW,iCAAiC;",
|
|
6
6
|
"names": ["_jsx", "ToggleControl"]
|
|
7
7
|
}
|
|
@@ -29,33 +29,23 @@ var import_toggle_group_control = require("../../toggle-group-control");
|
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var UnforwardedValidatedToggleGroupControl = ({
|
|
31
31
|
required,
|
|
32
|
-
onValidate,
|
|
33
32
|
customValidity,
|
|
34
|
-
onChange,
|
|
35
33
|
markWhenOptional,
|
|
36
34
|
...restProps
|
|
37
35
|
}, forwardedRef) => {
|
|
38
36
|
const validityTargetRef = (0, import_element.useRef)(null);
|
|
39
|
-
const valueRef = (0, import_element.useRef)(restProps.value);
|
|
40
37
|
const nameAttr = (0, import_element.useId)();
|
|
41
38
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
42
39
|
className: "components-validated-control__wrapper-with-error-delegate",
|
|
43
40
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_control_with_error.ControlWithError, {
|
|
44
41
|
required,
|
|
45
42
|
markWhenOptional,
|
|
46
|
-
onValidate: () => {
|
|
47
|
-
return onValidate?.(valueRef.current);
|
|
48
|
-
},
|
|
49
43
|
customValidity,
|
|
50
44
|
getValidityTarget: () => validityTargetRef.current,
|
|
51
45
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_toggle_group_control.ToggleGroupControl, {
|
|
52
46
|
__nextHasNoMarginBottom: true,
|
|
53
47
|
__next40pxDefaultSize: true,
|
|
54
48
|
ref: forwardedRef,
|
|
55
|
-
onChange: (value) => {
|
|
56
|
-
valueRef.current = value;
|
|
57
|
-
onChange?.(value);
|
|
58
|
-
},
|
|
59
49
|
...restProps
|
|
60
50
|
})
|
|
61
51
|
}), /* @__PURE__ */ (0, import_jsx_runtime.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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0C;AAK1C,gCAAiC;AACjC,kCAAmC;AACnC,yBAA2C;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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA0C;AAK1C,gCAAiC;AACjC,kCAAmC;AACnC,yBAA2C;AAC3C,IAAM,yCAAyC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,wBAAoB,uBAAO,IAAI;AACrC,QAAM,eAAW,sBAAM;AACvB,SAAoB,uCAAAA,MAAM,OAAO;AAAA,IAC/B,WAAW;AAAA,IACX,UAAU,CAAc,uCAAAC,KAAK,4CAAkB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,MAAM,kBAAkB;AAAA,MAC3C,UAAuB,uCAAAA,KAAK,gDAAoB;AAAA,QAC9C,yBAAyB;AAAA,QACzB,uBAAuB;AAAA,QACvB,KAAK;AAAA,QACL,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC,GAAgB,uCAAAA,KAAK,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,kCAA8B,2BAAW,sCAAsC;",
|
|
6
6
|
"names": ["_jsxs", "_jsx"]
|
|
7
7
|
}
|
|
@@ -23,10 +23,8 @@ __export(control_with_error_exports, {
|
|
|
23
23
|
ControlWithError: () => ControlWithError
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(control_with_error_exports);
|
|
26
|
-
var import_compose = require("@wordpress/compose");
|
|
27
26
|
var import_i18n = require("@wordpress/i18n");
|
|
28
27
|
var import_element = require("@wordpress/element");
|
|
29
|
-
var import_with_ignore_ime_events = require("../utils/with-ignore-ime-events");
|
|
30
28
|
var import_validity_indicator = require("./validity-indicator");
|
|
31
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
30
|
function appendRequiredIndicator(label, required, markWhenOptional) {
|
|
@@ -42,30 +40,28 @@ function appendRequiredIndicator(label, required, markWhenOptional) {
|
|
|
42
40
|
}
|
|
43
41
|
return label;
|
|
44
42
|
}
|
|
43
|
+
var VALIDITY_VISIBLE_ATTRIBUTE = "data-validity-visible";
|
|
45
44
|
function UnforwardedControlWithError({
|
|
46
45
|
required,
|
|
47
46
|
markWhenOptional,
|
|
48
|
-
onValidate,
|
|
49
47
|
customValidity,
|
|
50
48
|
getValidityTarget,
|
|
51
49
|
children
|
|
52
50
|
}, forwardedRef) {
|
|
53
51
|
const [errorMessage, setErrorMessage] = (0, import_element.useState)();
|
|
54
52
|
const [statusMessage, setStatusMessage] = (0, import_element.useState)();
|
|
53
|
+
const [showMessage, setShowMessage] = (0, import_element.useState)(false);
|
|
55
54
|
const [isTouched, setIsTouched] = (0, import_element.useState)(false);
|
|
56
|
-
const previousCustomValidityType = (0, import_compose.usePrevious)(customValidity?.type);
|
|
57
55
|
(0, import_element.useEffect)(() => {
|
|
58
56
|
const validityTarget = getValidityTarget();
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
validityTarget?.removeEventListener("invalid", showValidationMessage);
|
|
57
|
+
const handler = () => {
|
|
58
|
+
setShowMessage(true);
|
|
59
|
+
validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
|
|
63
60
|
};
|
|
64
|
-
|
|
61
|
+
validityTarget?.addEventListener("invalid", handler);
|
|
62
|
+
return () => validityTarget?.removeEventListener("invalid", handler);
|
|
63
|
+
}, [getValidityTarget]);
|
|
65
64
|
(0, import_element.useEffect)(() => {
|
|
66
|
-
if (!isTouched) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
65
|
const validityTarget = getValidityTarget();
|
|
70
66
|
if (!customValidity?.type) {
|
|
71
67
|
validityTarget?.setCustomValidity("");
|
|
@@ -75,20 +71,15 @@ function UnforwardedControlWithError({
|
|
|
75
71
|
}
|
|
76
72
|
switch (customValidity.type) {
|
|
77
73
|
case "validating": {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, 1e3);
|
|
86
|
-
return () => clearTimeout(timer);
|
|
74
|
+
validityTarget?.setCustomValidity("");
|
|
75
|
+
setErrorMessage(void 0);
|
|
76
|
+
setStatusMessage({
|
|
77
|
+
type: "validating",
|
|
78
|
+
message: customValidity.message
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
87
81
|
}
|
|
88
82
|
case "valid": {
|
|
89
|
-
if (previousCustomValidityType === "valid") {
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
83
|
validityTarget?.setCustomValidity("");
|
|
93
84
|
setErrorMessage(validityTarget?.validationMessage);
|
|
94
85
|
setStatusMessage({
|
|
@@ -105,51 +96,55 @@ function UnforwardedControlWithError({
|
|
|
105
96
|
break;
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
|
-
}, [
|
|
99
|
+
}, [customValidity, getValidityTarget]);
|
|
100
|
+
(0, import_element.useEffect)(() => {
|
|
101
|
+
if (!isTouched || showMessage) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (customValidity?.type === "validating") {
|
|
105
|
+
const timer = setTimeout(() => {
|
|
106
|
+
setShowMessage(true);
|
|
107
|
+
}, 1e3);
|
|
108
|
+
return () => clearTimeout(timer);
|
|
109
|
+
}
|
|
110
|
+
setShowMessage(true);
|
|
111
|
+
}, [isTouched, customValidity?.type, showMessage]);
|
|
109
112
|
const onBlur = (event) => {
|
|
110
113
|
if (isTouched) {
|
|
111
114
|
return;
|
|
112
115
|
}
|
|
113
116
|
if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
|
|
114
117
|
setIsTouched(true);
|
|
115
|
-
|
|
118
|
+
getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
|
|
116
119
|
}
|
|
117
120
|
};
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
const message = () => {
|
|
122
|
+
if (errorMessage) {
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_validity_indicator.ValidityIndicator, {
|
|
124
|
+
type: "invalid",
|
|
125
|
+
message: errorMessage
|
|
126
|
+
});
|
|
122
127
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
if (statusMessage?.type) {
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_validity_indicator.ValidityIndicator, {
|
|
130
|
+
type: statusMessage.type,
|
|
131
|
+
message: statusMessage.message
|
|
132
|
+
});
|
|
127
133
|
}
|
|
134
|
+
return null;
|
|
128
135
|
};
|
|
129
|
-
return (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
142
|
-
"aria-live": "polite",
|
|
143
|
-
children: [errorMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_validity_indicator.ValidityIndicator, {
|
|
144
|
-
type: "invalid",
|
|
145
|
-
message: errorMessage
|
|
146
|
-
}), !errorMessage && statusMessage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_validity_indicator.ValidityIndicator, {
|
|
147
|
-
type: statusMessage.type,
|
|
148
|
-
message: statusMessage.message
|
|
149
|
-
})]
|
|
150
|
-
})]
|
|
151
|
-
})
|
|
152
|
-
);
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
137
|
+
className: "components-validated-control",
|
|
138
|
+
ref: forwardedRef,
|
|
139
|
+
onBlur,
|
|
140
|
+
children: [(0, import_element.cloneElement)(children, {
|
|
141
|
+
label: appendRequiredIndicator(children.props.label, required, markWhenOptional),
|
|
142
|
+
required
|
|
143
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
144
|
+
"aria-live": "polite",
|
|
145
|
+
children: showMessage && message()
|
|
146
|
+
})]
|
|
147
|
+
});
|
|
153
148
|
}
|
|
154
149
|
var ControlWithError = (0, import_element.forwardRef)(UnforwardedControlWithError);
|
|
155
150
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
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": ["_jsxs", "_Fragment", "_jsx"]
|
|
7
7
|
}
|