@wordpress/components 30.2.1-next.0f6f9d12c.0 → 30.2.2-next.e256d081a.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 +18 -1
- package/build/context/context-connect.js.map +1 -1
- package/build/menu-item/index.js +1 -0
- package/build/menu-item/index.js.map +1 -1
- package/build/tabs/styles.js +5 -5
- package/build/tabs/styles.js.map +1 -1
- package/build/utils/font-size.js.map +1 -1
- package/build/utils/get-valid-children.js.map +1 -1
- package/build/validated-form-controls/components/checkbox-control.js +5 -3
- package/build/validated-form-controls/components/checkbox-control.js.map +1 -1
- package/build/validated-form-controls/components/combobox-control.js +5 -3
- package/build/validated-form-controls/components/combobox-control.js.map +1 -1
- package/build/validated-form-controls/components/custom-select-control.js +5 -3
- package/build/validated-form-controls/components/custom-select-control.js.map +1 -1
- package/build/validated-form-controls/components/input-control.js +5 -3
- package/build/validated-form-controls/components/input-control.js.map +1 -1
- package/build/validated-form-controls/components/number-control.js +5 -3
- package/build/validated-form-controls/components/number-control.js.map +1 -1
- package/build/validated-form-controls/components/radio-control.js +5 -3
- package/build/validated-form-controls/components/radio-control.js.map +1 -1
- package/build/validated-form-controls/components/range-control.js +5 -3
- package/build/validated-form-controls/components/range-control.js.map +1 -1
- package/build/validated-form-controls/components/select-control.js +5 -3
- package/build/validated-form-controls/components/select-control.js.map +1 -1
- package/build/validated-form-controls/components/text-control.js +5 -3
- package/build/validated-form-controls/components/text-control.js.map +1 -1
- package/build/validated-form-controls/components/textarea-control.js +5 -3
- package/build/validated-form-controls/components/textarea-control.js.map +1 -1
- package/build/validated-form-controls/components/toggle-control.js +5 -3
- package/build/validated-form-controls/components/toggle-control.js.map +1 -1
- package/build/validated-form-controls/components/toggle-group-control.js +5 -3
- package/build/validated-form-controls/components/toggle-group-control.js.map +1 -1
- package/build/validated-form-controls/components/types.js.map +1 -1
- package/build/validated-form-controls/control-with-error.js +70 -35
- package/build/validated-form-controls/control-with-error.js.map +1 -1
- package/build/validated-form-controls/validity-indicator.js +45 -0
- package/build/validated-form-controls/validity-indicator.js.map +1 -0
- package/build-module/context/context-connect.js.map +1 -1
- package/build-module/menu-item/index.js +1 -0
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/tabs/styles.js +6 -6
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/utils/font-size.js.map +1 -1
- package/build-module/utils/get-valid-children.js.map +1 -1
- package/build-module/validated-form-controls/components/checkbox-control.js +5 -3
- package/build-module/validated-form-controls/components/checkbox-control.js.map +1 -1
- package/build-module/validated-form-controls/components/combobox-control.js +5 -3
- package/build-module/validated-form-controls/components/combobox-control.js.map +1 -1
- package/build-module/validated-form-controls/components/custom-select-control.js +5 -3
- package/build-module/validated-form-controls/components/custom-select-control.js.map +1 -1
- package/build-module/validated-form-controls/components/input-control.js +5 -3
- package/build-module/validated-form-controls/components/input-control.js.map +1 -1
- package/build-module/validated-form-controls/components/number-control.js +5 -3
- package/build-module/validated-form-controls/components/number-control.js.map +1 -1
- package/build-module/validated-form-controls/components/radio-control.js +5 -3
- package/build-module/validated-form-controls/components/radio-control.js.map +1 -1
- package/build-module/validated-form-controls/components/range-control.js +5 -3
- package/build-module/validated-form-controls/components/range-control.js.map +1 -1
- package/build-module/validated-form-controls/components/select-control.js +5 -3
- package/build-module/validated-form-controls/components/select-control.js.map +1 -1
- package/build-module/validated-form-controls/components/text-control.js +5 -3
- package/build-module/validated-form-controls/components/text-control.js.map +1 -1
- package/build-module/validated-form-controls/components/textarea-control.js +5 -3
- package/build-module/validated-form-controls/components/textarea-control.js.map +1 -1
- package/build-module/validated-form-controls/components/toggle-control.js +5 -3
- package/build-module/validated-form-controls/components/toggle-control.js.map +1 -1
- package/build-module/validated-form-controls/components/toggle-group-control.js +5 -3
- package/build-module/validated-form-controls/components/toggle-group-control.js.map +1 -1
- package/build-module/validated-form-controls/components/types.js.map +1 -1
- package/build-module/validated-form-controls/control-with-error.js +70 -34
- package/build-module/validated-form-controls/control-with-error.js.map +1 -1
- package/build-module/validated-form-controls/validity-indicator.js +37 -0
- package/build-module/validated-form-controls/validity-indicator.js.map +1 -0
- package/build-style/style-rtl.css +34 -22
- package/build-style/style.css +34 -22
- package/build-types/context/context-connect.d.ts +2 -2
- package/build-types/context/context-connect.d.ts.map +1 -1
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/utils/font-size.d.ts +2 -2
- package/build-types/utils/font-size.d.ts.map +1 -1
- package/build-types/utils/get-valid-children.d.ts +2 -2
- package/build-types/utils/get-valid-children.d.ts.map +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.map +1 -1
- package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
- 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.map +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.map +1 -1
- 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/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 +13 -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.map +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.map +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 +21 -10
- 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/build-types/validated-form-controls/test/control-with-error.d.ts +2 -0
- package/build-types/validated-form-controls/test/control-with-error.d.ts.map +1 -0
- package/build-types/validated-form-controls/validity-indicator.d.ts +5 -0
- package/build-types/validated-form-controls/validity-indicator.d.ts.map +1 -0
- package/package.json +19 -19
- package/src/calendar/style.scss +22 -22
- package/src/context/context-connect.ts +2 -2
- package/src/menu-item/index.tsx +1 -0
- package/src/tabs/styles.ts +2 -1
- package/src/tools-panel/stories/index.story.tsx +3 -3
- package/src/utils/font-size.ts +2 -2
- package/src/utils/get-valid-children.ts +4 -2
- package/src/utils/theme-variables.scss +1 -0
- package/src/validated-form-controls/components/checkbox-control.tsx +5 -3
- package/src/validated-form-controls/components/combobox-control.tsx +5 -3
- package/src/validated-form-controls/components/custom-select-control.tsx +5 -3
- package/src/validated-form-controls/components/input-control.tsx +5 -3
- package/src/validated-form-controls/components/number-control.tsx +5 -3
- package/src/validated-form-controls/components/radio-control.tsx +5 -3
- package/src/validated-form-controls/components/range-control.tsx +5 -3
- package/src/validated-form-controls/components/select-control.tsx +5 -3
- package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/combobox-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/input-control.story.tsx +51 -18
- package/src/validated-form-controls/components/stories/number-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/overview.mdx +1 -1
- package/src/validated-form-controls/components/stories/overview.story.tsx +207 -17
- package/src/validated-form-controls/components/stories/radio-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/range-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/select-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/text-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/textarea-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/toggle-control.story.tsx +17 -6
- package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +17 -6
- package/src/validated-form-controls/components/text-control.tsx +5 -3
- package/src/validated-form-controls/components/textarea-control.tsx +5 -3
- package/src/validated-form-controls/components/toggle-control.tsx +5 -3
- package/src/validated-form-controls/components/toggle-group-control.tsx +5 -3
- package/src/validated-form-controls/components/types.ts +21 -12
- package/src/validated-form-controls/control-with-error.tsx +93 -41
- package/src/validated-form-controls/style.scss +19 -5
- package/src/validated-form-controls/test/control-with-error.tsx +224 -0
- package/src/validated-form-controls/validity-indicator.tsx +48 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_controlWithError","_comboboxControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedComboboxControl","required","
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_controlWithError","_comboboxControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedComboboxControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","useEffect","input","current","querySelector","jsx","ControlWithError","ref","getValidityTarget","children","default","__nextHasNoMarginBottom","__next40pxDefaultSize","ValidatedComboboxControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/combobox-control.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport type { ValidatedControlProps } from './types';\nimport ComboboxControl from '../../combobox-control';\nimport type { ComboboxControlProps } from '../../combobox-control/types';\n\ntype Value = ComboboxControlProps[ 'value' ];\n\nconst UnforwardedValidatedComboboxControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof ComboboxControl >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\t// TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n\t// so we need to set it manually.\n\tuseEffect( () => {\n\t\tconst input =\n\t\t\tvalidityTargetRef.current?.querySelector< HTMLInputElement >(\n\t\t\t\t'input[role=\"combobox\"]'\n\t\t\t);\n\t\tif ( input ) {\n\t\t\tinput.required = required ?? false;\n\t\t}\n\t}, [ required ] );\n\n\treturn (\n\t\t// TODO: Bug - Missing value error is not cleared immediately on change, waits for blur.\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tref={ mergedRefs }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () =>\n\t\t\t\tvalidityTargetRef.current?.querySelector< HTMLInputElement >(\n\t\t\t\t\t'input[role=\"combobox\"]'\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<ComboboxControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t{ ...restProps }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedComboboxControl = forwardRef(\n\tUnforwardedValidatedComboboxControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqD,IAAAK,WAAA,GAAAL,OAAA;AAXrD;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMM,mCAAmC,GAAGA,CAC3C;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAsB,IAAK,CAAC;EAC5D,MAAMC,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEJ,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAMI,QAAQ,GAAG,IAAAH,eAAM,EAAWH,SAAS,CAACO,KAAM,CAAC;;EAEnD;EACA;EACA,IAAAC,kBAAS,EAAE,MAAM;IAChB,MAAMC,KAAK,GACVP,iBAAiB,CAACQ,OAAO,EAAEC,aAAa,CACvC,wBACD,CAAC;IACF,IAAKF,KAAK,EAAG;MACZA,KAAK,CAACd,QAAQ,GAAGA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,KAAK;IACnC;EACD,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjB;IAAA;IACC;IACA,IAAAF,WAAA,CAAAmB,GAAA,EAACtB,iBAAA,CAAAuB,gBAAgB;MAChBlB,QAAQ,EAAGA,QAAU;MACrBI,gBAAgB,EAAGA,gBAAkB;MACrCe,GAAG,EAAGV,UAAY;MAClBR,UAAU,EAAGA,CAAA,KAAM;QAClB,OAAOA,UAAU,GAAIU,QAAQ,CAACI,OAAQ,CAAC;MACxC,CAAG;MACHb,cAAc,EAAGA,cAAgB;MACjCkB,iBAAiB,EAAGA,CAAA,KACnBb,iBAAiB,CAACQ,OAAO,EAAEC,aAAa,CACvC,wBACD,CACA;MAAAK,QAAA,eAED,IAAAvB,WAAA,CAAAmB,GAAA,EAACrB,gBAAA,CAAA0B,OAAe;QACfC,uBAAuB;QACvBC,qBAAqB;QAAA,GAChBnB,SAAS;QACdF,QAAQ,EAAKS,KAAK,IAAM;UACvBD,QAAQ,CAACI,OAAO,GAAGH,KAAK;UACxBT,QAAQ,GAAIS,KAAM,CAAC;QACpB;MAAG,CACH;IAAC,CACe;EAAC;AAErB,CAAC;AAEM,MAAMa,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,IAAAE,mBAAU,EACjD5B,mCACD,CAAC","ignoreList":[]}
|
|
@@ -19,7 +19,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
19
19
|
|
|
20
20
|
const UnforwardedValidatedCustomSelectControl = ({
|
|
21
21
|
required,
|
|
22
|
-
|
|
22
|
+
onValidate,
|
|
23
|
+
customValidity,
|
|
23
24
|
onChange,
|
|
24
25
|
markWhenOptional,
|
|
25
26
|
...restProps
|
|
@@ -32,9 +33,10 @@ const UnforwardedValidatedCustomSelectControl = ({
|
|
|
32
33
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
33
34
|
required: required,
|
|
34
35
|
markWhenOptional: markWhenOptional,
|
|
35
|
-
|
|
36
|
-
return
|
|
36
|
+
onValidate: () => {
|
|
37
|
+
return onValidate?.(valueRef.current);
|
|
37
38
|
},
|
|
39
|
+
customValidity: customValidity,
|
|
38
40
|
getValidityTarget: () => validityTargetRef.current,
|
|
39
41
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_customSelectControl.default
|
|
40
42
|
// TODO: Upstream limitation - Required isn't passed down correctly,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_controlWithError","_customSelectControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedCustomSelectControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_controlWithError","_customSelectControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedCustomSelectControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","valueRef","value","jsxs","className","ref","children","jsx","ControlWithError","current","getValidityTarget","default","__next40pxDefaultSize","selectedItem","tabIndex","key","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedCustomSelectControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/custom-select-control.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport type { ValidatedControlProps } from './types';\nimport CustomSelectControl from '../../custom-select-control';\nimport type {\n\tCustomSelectOption,\n\tCustomSelectProps,\n} from '../../custom-select-control/types';\n\ntype CustomSelectControlProps = CustomSelectProps< CustomSelectOption >;\n\ntype Value = CustomSelectControlProps[ 'value' ];\n\nconst UnforwardedValidatedCustomSelectControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof CustomSelectControl >,\n\t\t'__next40pxDefaultSize'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLDivElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLSelectElement >( null );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"components-validated-control__wrapper-with-error-delegate\"\n\t\t\tref={ forwardedRef }\n\t\t>\n\t\t\t<ControlWithError\n\t\t\t\trequired={ required }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tonValidate={ () => {\n\t\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t\t} }\n\t\t\t\tcustomValidity={ customValidity }\n\t\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t\t>\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\t// TODO: Upstream limitation - Required isn't passed down correctly,\n\t\t\t\t\t// so it needs to be set on a delegate element.\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tvalueRef.current = value.selectedItem;\n\t\t\t\t\t\tonChange?.( value );\n\t\t\t\t\t} }\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t/>\n\t\t\t</ControlWithError>\n\t\t\t<select\n\t\t\t\tclassName=\"components-validated-control__error-delegate\"\n\t\t\t\tref={ validityTargetRef }\n\t\t\t\trequired={ required }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tvalue={ restProps.value?.key ? 'hasvalue' : '' }\n\t\t\t\tonChange={ () => {} }\n\t\t\t\tonFocus={ ( e ) => {\n\t\t\t\t\te.target.previousElementSibling\n\t\t\t\t\t\t?.querySelector< HTMLButtonElement >(\n\t\t\t\t\t\t\t'[role=\"combobox\"]'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t?.focus();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<option value=\"\">No selection</option>\n\t\t\t\t<option value=\"hasvalue\">Has selection</option>\n\t\t\t</select>\n\t\t</div>\n\t);\n};\n\nexport const ValidatedCustomSelectControl = forwardRef(\n\tUnforwardedValidatedCustomSelectControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;A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CAAC,CAAG;MACfZ,KAAK,EAAGL,SAAS,CAACK,KAAK,EAAEa,GAAG,GAAG,UAAU,GAAG,EAAI;MAChDpB,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrBqB,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,MAAM,CAACC,sBAAsB,EAC5BC,aAAa,CACd,mBACD,CAAC,EACCC,KAAK,CAAC,CAAC;MACX,CAAG;MAAAf,QAAA,gBAEH,IAAAhB,WAAA,CAAAiB,GAAA;QAAQL,KAAK,EAAC,EAAE;QAAAI,QAAA,EAAC;MAAY,CAAQ,CAAC,eACtC,IAAAhB,WAAA,CAAAiB,GAAA;QAAQL,KAAK,EAAC,UAAU;QAAAI,QAAA,EAAC;MAAa,CAAQ,CAAC;IAAA,CACxC,CAAC;EAAA,CACL,CAAC;AAER,CAAC;AAEM,MAAMgB,4BAA4B,GAAAC,OAAA,CAAAD,4BAAA,GAAG,IAAAE,mBAAU,EACrDjC,uCACD,CAAC","ignoreList":[]}
|
|
@@ -20,7 +20,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
|
|
21
21
|
const UnforwardedValidatedInputControl = ({
|
|
22
22
|
required,
|
|
23
|
-
|
|
23
|
+
onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedInputControl = ({
|
|
|
31
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_inputControl.default, {
|
|
39
41
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_controlWithError","_inputControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedInputControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_controlWithError","_inputControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedInputControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__next40pxDefaultSize","ref","args","ValidatedInputControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/input-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport InputControl from '../../input-control';\nimport type { InputControlProps } from '../../input-control/types';\n\ntype Value = InputControlProps[ 'value' ];\n\nconst UnforwardedValidatedInputControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof InputControl >,\n\t\t'__next40pxDefaultSize'\n\t> &\n\t\tValidatedControlProps< InputControlProps[ 'value' ] >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<InputControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value, ...args ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value, ...args );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedInputControl = forwardRef(\n\tUnforwardedValidatedInputControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA+C,IAAAK,WAAA,GAAAL,OAAA;AAX/C;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMM,gCAAgC,GAAGA,CACxC;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAKiD,CAAC,EACtDC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAsB,IAAK,CAAC;EAC5D,MAAMC,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEJ,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAMI,QAAQ,GAAG,IAAAH,eAAM,EAAWH,SAAS,CAACO,KAAM,CAAC;EAEnD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAAClB,iBAAA,CAAAmB,gBAAgB;IAChBd,QAAQ,EAAGA,QAAU;IACrBI,gBAAgB,EAAGA,gBAAkB;IACrCH,UAAU,EAAGA,CAAA,KAAM;MAClB,OAAOA,UAAU,GAAIU,QAAQ,CAACI,OAAQ,CAAC;IACxC,CAAG;IACHb,cAAc,EAAGA,cAAgB;IACjCc,iBAAiB,EAAGA,CAAA,KAAMT,iBAAiB,CAACQ,OAAS;IAAAE,QAAA,eAErD,IAAAnB,WAAA,CAAAe,GAAA,EAACjB,aAAA,CAAAsB,OAAY;MACZC,qBAAqB;MACrBC,GAAG,EAAGX,UAAY;MAClBN,QAAQ,EAAGA,CAAES,KAAK,EAAE,GAAGS,IAAI,KAAM;QAChCV,QAAQ,CAACI,OAAO,GAAGH,KAAK;QACxBT,QAAQ,GAAIS,KAAK,EAAE,GAAGS,IAAK,CAAC;MAC7B,CAAG;MAAA,GACEhB;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAEM,MAAMiB,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAAE,mBAAU,EAC9CzB,gCACD,CAAC","ignoreList":[]}
|
|
@@ -20,7 +20,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
|
|
21
21
|
const UnforwardedValidatedNumberControl = ({
|
|
22
22
|
required,
|
|
23
|
-
|
|
23
|
+
onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedNumberControl = ({
|
|
|
31
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_numberControl.default, {
|
|
39
41
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_controlWithError","_numberControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedNumberControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_controlWithError","_numberControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedNumberControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__next40pxDefaultSize","ref","args","ValidatedNumberControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/number-control.tsx"],"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 NumberControl from '../../number-control';\nimport type { ValidatedControlProps } from './types';\nimport type { NumberControlProps } from '../../number-control/types';\n\ntype Value = NumberControlProps[ 'value' ];\n\nconst UnforwardedValidatedNumberControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof NumberControl >,\n\t\t'__next40pxDefaultSize'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<NumberControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tref={ mergedRefs }\n\t\t\t\t// TODO: Upstream limitation - When form is submitted when value is undefined, it will\n\t\t\t\t// automatically set a clamped value (as defined by `min` attribute, so 0 by default).\n\t\t\t\tonChange={ ( value, ...args ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value, ...args );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedNumberControl = forwardRef(\n\tUnforwardedValidatedNumberControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAiD,IAAAK,WAAA,GAAAL,OAAA;AAVjD;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMM,iCAAiC,GAAGA,CACzC;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAsB,IAAK,CAAC;EAC5D,MAAMC,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEJ,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAMI,QAAQ,GAAG,IAAAH,eAAM,EAAWH,SAAS,CAACO,KAAM,CAAC;EAEnD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAAClB,iBAAA,CAAAmB,gBAAgB;IAChBd,QAAQ,EAAGA,QAAU;IACrBI,gBAAgB,EAAGA,gBAAkB;IACrCH,UAAU,EAAGA,CAAA,KAAM;MAClB,OAAOA,UAAU,GAAIU,QAAQ,CAACI,OAAQ,CAAC;IACxC,CAAG;IACHb,cAAc,EAAGA,cAAgB;IACjCc,iBAAiB,EAAGA,CAAA,KAAMT,iBAAiB,CAACQ,OAAS;IAAAE,QAAA,eAErD,IAAAnB,WAAA,CAAAe,GAAA,EAACjB,cAAA,CAAAsB,OAAa;MACbC,qBAAqB;MACrBC,GAAG,EAAGX;MACN;MACA;MAAA;MACAN,QAAQ,EAAGA,CAAES,KAAK,EAAE,GAAGS,IAAI,KAAM;QAChCV,QAAQ,CAACI,OAAO,GAAGH,KAAK;QACxBT,QAAQ,GAAIS,KAAK,EAAE,GAAGS,IAAK,CAAC;MAC7B,CAAG;MAAA,GACEhB;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAEM,MAAMiB,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,IAAAE,mBAAU,EAC/CzB,iCACD,CAAC","ignoreList":[]}
|
|
@@ -20,7 +20,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
|
|
21
21
|
const UnforwardedValidatedRadioControl = ({
|
|
22
22
|
required,
|
|
23
|
-
|
|
23
|
+
onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -34,9 +35,10 @@ const UnforwardedValidatedRadioControl = ({
|
|
|
34
35
|
// TODO: Upstream limitation - RadioControl does not accept a ref.
|
|
35
36
|
,
|
|
36
37
|
ref: mergedRefs,
|
|
37
|
-
|
|
38
|
-
return
|
|
38
|
+
onValidate: () => {
|
|
39
|
+
return onValidate?.(valueRef.current);
|
|
39
40
|
},
|
|
41
|
+
customValidity: customValidity,
|
|
40
42
|
getValidityTarget: () => validityTargetRef.current?.querySelector('input[type="radio"]'),
|
|
41
43
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_radioControl.default, {
|
|
42
44
|
onChange: value => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_controlWithError","_radioControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedRadioControl","required","
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_controlWithError","_radioControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedRadioControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","selected","jsx","ControlWithError","ref","current","getValidityTarget","querySelector","children","default","value","ValidatedRadioControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/radio-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport RadioControl from '../../radio-control';\nimport type { RadioControlProps } from '../../radio-control/types';\n\ntype Value = RadioControlProps[ 'selected' ];\n\nconst UnforwardedValidatedRadioControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: React.ComponentProps< typeof RadioControl > &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLDivElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLDivElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.selected );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t// TODO: Upstream limitation - RadioControl does not accept a ref.\n\t\t\tref={ mergedRefs }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () =>\n\t\t\t\tvalidityTargetRef.current?.querySelector< HTMLInputElement >(\n\t\t\t\t\t'input[type=\"radio\"]'\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t<RadioControl\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t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,GACEhB;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAEM,MAAMiB,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,IAAAE,mBAAU,EAC9CzB,gCACD,CAAC","ignoreList":[]}
|
|
@@ -20,7 +20,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
|
|
21
21
|
const UnforwardedValidatedRangeControl = ({
|
|
22
22
|
required,
|
|
23
|
-
|
|
23
|
+
onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedRangeControl = ({
|
|
|
31
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_rangeControl.default, {
|
|
39
41
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_controlWithError","_rangeControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedRangeControl","required","
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_controlWithError","_rangeControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedRangeControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__next40pxDefaultSize","__nextHasNoMarginBottom","ref","ValidatedRangeControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/range-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport RangeControl from '../../range-control';\nimport type { RangeControlProps } from '../../range-control/types';\n\ntype Value = RangeControlProps[ 'value' ];\n\nconst UnforwardedValidatedRangeControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof RangeControl >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<RangeControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedRangeControl = forwardRef(\n\tUnforwardedValidatedRangeControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,G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22,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
|
|
23
23
|
const UnforwardedValidatedSelectControl = ({
|
|
24
24
|
required,
|
|
25
|
-
|
|
25
|
+
onValidate,
|
|
26
|
+
customValidity,
|
|
26
27
|
onChange,
|
|
27
28
|
markWhenOptional,
|
|
28
29
|
...restProps
|
|
@@ -33,9 +34,10 @@ const UnforwardedValidatedSelectControl = ({
|
|
|
33
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
34
35
|
required: required,
|
|
35
36
|
markWhenOptional: markWhenOptional,
|
|
36
|
-
|
|
37
|
-
return
|
|
37
|
+
onValidate: () => {
|
|
38
|
+
return onValidate?.(valueRef.current);
|
|
38
39
|
},
|
|
40
|
+
customValidity: customValidity,
|
|
39
41
|
getValidityTarget: () => validityTargetRef.current,
|
|
40
42
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_selectControl.default, {
|
|
41
43
|
__nextHasNoMarginBottom: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_controlWithError","_selectControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedSelectControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_controlWithError","_selectControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedSelectControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__nextHasNoMarginBottom","__next40pxDefaultSize","ref","ValidatedSelectControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/select-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport type { SelectControlProps as _SelectControlProps } from '../../select-control/types';\n\n// Only support single value selection\ntype SelectControlProps = Omit<\n\t_SelectControlProps,\n\t'multiple' | 'onChange' | 'value'\n> & {\n\tonChange?: ( value: string ) => void;\n\tvalue?: string;\n};\n\ntype Value = SelectControlProps[ 'value' ];\n\nconst UnforwardedValidatedSelectControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof SelectControl >,\n\t\t| '__next40pxDefaultSize'\n\t\t| '__nextHasNoMarginBottom'\n\t\t| 'multiple'\n\t\t| 'onChange'\n\t\t| 'value'\n\t> & {\n\t\tvalue?: string;\n\t\tonChange: ( value: string ) => void;\n\t} & ValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLSelectElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLSelectElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<SelectControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedSelectControl = forwardRef(\n\tUnforwardedValidatedSelectControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,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IAAAE,mBAAU,EAC/CzB,iCACD,CAAC","ignoreList":[]}
|
|
@@ -20,7 +20,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
20
20
|
|
|
21
21
|
const UnforwardedValidatedTextControl = ({
|
|
22
22
|
required,
|
|
23
|
-
|
|
23
|
+
onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedTextControl = ({
|
|
|
31
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_textControl.default, {
|
|
39
41
|
__next40pxDefaultSize: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_element","_controlWithError","_textControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedTextControl","required","
|
|
1
|
+
{"version":3,"names":["_compose","require","_element","_controlWithError","_textControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedTextControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__next40pxDefaultSize","__nextHasNoMarginBottom","ref","ValidatedTextControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/text-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport TextControl from '../../text-control';\nimport type { TextControlProps } from '../../text-control/types';\n\ntype Value = TextControlProps[ 'value' ];\n\nconst UnforwardedValidatedTextControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof TextControl >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<TextControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedTextControl = forwardRef(\n\tUnforwardedValidatedTextControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA6C,IAAAK,WAAA,GAAAL,OAAA;AAX7C;AACA;AACA;;AAIA;AACA;AACA;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onValidate,
|
|
24
|
+
customValidity,
|
|
24
25
|
onChange,
|
|
25
26
|
markWhenOptional,
|
|
26
27
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedTextareaControl = ({
|
|
|
31
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_textareaControl.default, {
|
|
39
41
|
__nextHasNoMarginBottom: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_controlWithError","_textareaControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedTextareaControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_controlWithError","_textareaControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedTextareaControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","value","jsx","ControlWithError","current","getValidityTarget","children","default","__nextHasNoMarginBottom","ref","ValidatedTextareaControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/textarea-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport TextareaControl from '../../textarea-control';\nimport type { TextareaControlProps } from '../../textarea-control/types';\n\ntype Value = TextareaControlProps[ 'value' ];\n\nconst UnforwardedValidatedTextareaControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof TextareaControl >,\n\t\t'__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLTextAreaElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLTextAreaElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<TextareaControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedTextareaControl = forwardRef(\n\tUnforwardedValidatedTextareaControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAqD,IAAAK,WAAA,GAAAL,OAAA;AAXrD;AACA;AACA;;AAIA;AACA;AACA;;AAQA,MAAMM,mCAAmC,GAAGA,CAC3C;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAuD,KACnD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAyB,IAAK,CAAC;EAC/D,MAAMC,UAAU,GAAG,IAAAC,qBAAY,EAAE,CAAEJ,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAMI,QAAQ,GAAG,IAAAH,eAAM,EAAWH,SAAS,CAACO,KAAM,CAAC;EAEnD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAAClB,iBAAA,CAAAmB,gBAAgB;IAChBd,QAAQ,EAAGA,QAAU;IACrBI,gBAAgB,EAAGA,gBAAkB;IACrCH,UAAU,EAAGA,CAAA,KAAM;MAClB,OAAOA,UAAU,GAAIU,QAAQ,CAACI,OAAQ,CAAC;IACxC,CAAG;IACHb,cAAc,EAAGA,cAAgB;IACjCc,iBAAiB,EAAGA,CAAA,KAAMT,iBAAiB,CAACQ,OAAS;IAAAE,QAAA,eAErD,IAAAnB,WAAA,CAAAe,GAAA,EAACjB,gBAAA,CAAAsB,OAAe;MACfC,uBAAuB;MACvBC,GAAG,EAAGX,UAAY;MAClBN,QAAQ,EAAKS,KAAK,IAAM;QACvBD,QAAQ,CAACI,OAAO,GAAGH,KAAK;QACxBT,QAAQ,GAAIS,KAAM,CAAC;MACpB,CAAG;MAAA,GACEP;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAEM,MAAMgB,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,IAAAE,mBAAU,EACjDxB,mCACD,CAAC","ignoreList":[]}
|
|
@@ -22,7 +22,8 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
|
|
23
23
|
const UnforwardedValidatedToggleControl = ({
|
|
24
24
|
required,
|
|
25
|
-
|
|
25
|
+
onValidate,
|
|
26
|
+
customValidity,
|
|
26
27
|
onChange,
|
|
27
28
|
markWhenOptional,
|
|
28
29
|
...restProps
|
|
@@ -41,9 +42,10 @@ const UnforwardedValidatedToggleControl = ({
|
|
|
41
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
42
43
|
required: required,
|
|
43
44
|
markWhenOptional: markWhenOptional,
|
|
44
|
-
|
|
45
|
-
return
|
|
45
|
+
onValidate: () => {
|
|
46
|
+
return onValidate?.(valueRef.current);
|
|
46
47
|
},
|
|
48
|
+
customValidity: customValidity,
|
|
47
49
|
getValidityTarget: () => validityTargetRef.current,
|
|
48
50
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toggleControl.default, {
|
|
49
51
|
__nextHasNoMarginBottom: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_controlWithError","_toggleControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedToggleControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_controlWithError","_toggleControl","_interopRequireDefault","_jsxRuntime","UnforwardedValidatedToggleControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","mergedRefs","useMergeRefs","valueRef","checked","useEffect","current","jsx","ControlWithError","getValidityTarget","children","default","__nextHasNoMarginBottom","ref","value","ValidatedToggleControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/toggle-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport ToggleControl from '../../toggle-control';\nimport type { ToggleControlProps } from '../../toggle-control/types';\n\ntype Value = ToggleControlProps[ 'checked' ];\n\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\n\nconst UnforwardedValidatedToggleControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof ToggleControl >,\n\t\t'__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst mergedRefs = useMergeRefs( [ forwardedRef, validityTargetRef ] );\n\tconst valueRef = useRef< Value >( restProps.checked );\n\n\t// TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n\t// so we need to set it manually.\n\tuseEffect( () => {\n\t\tif ( validityTargetRef.current ) {\n\t\t\tvalidityTargetRef.current.required = required ?? false;\n\t\t}\n\t}, [ required ] );\n\n\treturn (\n\t\t<ControlWithError\n\t\t\trequired={ required }\n\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\tonValidate={ () => {\n\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tref={ mergedRefs }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\tonChange?.( value );\n\t\t\t\t} }\n\t\t\t\t{ ...restProps }\n\t\t\t/>\n\t\t</ControlWithError>\n\t);\n};\n\nexport const ValidatedToggleControl = forwardRef(\n\tUnforwardedValidatedToggleControl\n);\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAiD,IAAAK,WAAA,GAAAL,OAAA;AAXjD;AACA;AACA;;AAIA;AACA;AACA;;AAQA;;AAEA,MAAMM,iCAAiC,GAAGA,CACzC;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAA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required,
|
|
21
|
-
|
|
21
|
+
onValidate,
|
|
22
|
+
customValidity,
|
|
22
23
|
onChange,
|
|
23
24
|
markWhenOptional,
|
|
24
25
|
...restProps
|
|
@@ -31,9 +32,10 @@ const UnforwardedValidatedToggleGroupControl = ({
|
|
|
31
32
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_controlWithError.ControlWithError, {
|
|
32
33
|
required: required,
|
|
33
34
|
markWhenOptional: markWhenOptional,
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
onValidate: () => {
|
|
36
|
+
return onValidate?.(valueRef.current);
|
|
36
37
|
},
|
|
38
|
+
customValidity: customValidity,
|
|
37
39
|
getValidityTarget: () => validityTargetRef.current,
|
|
38
40
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_toggleGroupControl.ToggleGroupControl, {
|
|
39
41
|
__nextHasNoMarginBottom: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_controlWithError","_toggleGroupControl","_jsxRuntime","UnforwardedValidatedToggleGroupControl","required","
|
|
1
|
+
{"version":3,"names":["_element","require","_controlWithError","_toggleGroupControl","_jsxRuntime","UnforwardedValidatedToggleGroupControl","required","onValidate","customValidity","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","useRef","valueRef","value","nameAttr","useId","jsxs","className","children","jsx","ControlWithError","current","getValidityTarget","ToggleGroupControl","__nextHasNoMarginBottom","__next40pxDefaultSize","ref","type","checked","tabIndex","name","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedToggleGroupControl","exports","forwardRef"],"sources":["@wordpress/components/src/validated-form-controls/components/toggle-group-control.tsx"],"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 type { ValidatedControlProps } from './types';\nimport { ToggleGroupControl } from '../../toggle-group-control';\nimport type { ToggleGroupControlProps } from '../../toggle-group-control/types';\n\ntype Value = ToggleGroupControlProps[ 'value' ];\n\nconst UnforwardedValidatedToggleGroupControl = (\n\t{\n\t\trequired,\n\t\tonValidate,\n\t\tcustomValidity,\n\t\tonChange,\n\t\tmarkWhenOptional,\n\t\t...restProps\n\t}: Omit<\n\t\tReact.ComponentProps< typeof ToggleGroupControl >,\n\t\t'__next40pxDefaultSize' | '__nextHasNoMarginBottom'\n\t> &\n\t\tValidatedControlProps< Value >,\n\tforwardedRef: React.ForwardedRef< HTMLInputElement >\n) => {\n\tconst validityTargetRef = useRef< HTMLInputElement >( null );\n\tconst valueRef = useRef< Value >( restProps.value );\n\n\tconst nameAttr = useId();\n\n\treturn (\n\t\t<div className=\"components-validated-control__wrapper-with-error-delegate\">\n\t\t\t<ControlWithError\n\t\t\t\trequired={ required }\n\t\t\t\tmarkWhenOptional={ markWhenOptional }\n\t\t\t\tonValidate={ () => {\n\t\t\t\t\treturn onValidate?.( valueRef.current );\n\t\t\t\t} }\n\t\t\t\tcustomValidity={ customValidity }\n\t\t\t\tgetValidityTarget={ () => validityTargetRef.current }\n\t\t\t>\n\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ forwardedRef }\n\t\t\t\t\t// TODO: Upstream limitation - In uncontrolled mode, starting from an undefined value then\n\t\t\t\t\t// setting a value has a visual bug.\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tvalueRef.current = value;\n\t\t\t\t\t\tonChange?.( value );\n\t\t\t\t\t} }\n\t\t\t\t\t{ ...restProps }\n\t\t\t\t/>\n\t\t\t</ControlWithError>\n\t\t\t<input\n\t\t\t\tclassName=\"components-validated-control__error-delegate\"\n\t\t\t\ttype=\"radio\"\n\t\t\t\tref={ validityTargetRef }\n\t\t\t\trequired={ required }\n\t\t\t\tchecked={ restProps.value !== null }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\t// A name attribute is needed for the `required` behavior to work.\n\t\t\t\tname={ nameAttr }\n\t\t\t\tonChange={ () => {} }\n\t\t\t\tonFocus={ ( e ) => {\n\t\t\t\t\te.target.previousElementSibling\n\t\t\t\t\t\t?.querySelector< HTMLButtonElement | HTMLInputElement >(\n\t\t\t\t\t\t\t'[data-active-item=\"true\"]'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t?.focus();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n};\n\nexport const ValidatedToggleGroupControl = forwardRef(\n\tUnforwardedValidatedToggleGroupControl\n);\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAF,OAAA;AAAgE,IAAAG,WAAA,GAAAH,OAAA;AAVhE;AACA;AACA;;AAGA;AACA;AACA;;AAQA,MAAMI,sCAAsC,GAAGA,CAC9C;EACCC,QAAQ;EACRC,UAAU;EACVC,cAAc;EACdC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAG,IAAAC,eAAM,EAAsB,IAAK,CAAC;EAC5D,MAAMC,QAAQ,GAAG,IAAAD,eAAM,EAAWH,SAAS,CAACK,KAAM,CAAC;EAEnD,MAAMC,QAAQ,GAAG,IAAAC,cAAK,EAAC,CAAC;EAExB,oBACC,IAAAd,WAAA,CAAAe,IAAA;IAAKC,SAAS,EAAC,2DAA2D;IAAAC,QAAA,gBACzE,IAAAjB,WAAA,CAAAkB,GAAA,EAACpB,iBAAA,CAAAqB,gBAAgB;MAChBjB,QAAQ,EAAGA,QAAU;MACrBI,gBAAgB,EAAGA,gBAAkB;MACrCH,UAAU,EAAGA,CAAA,KAAM;QAClB,OAAOA,UAAU,GAAIQ,QAAQ,CAACS,OAAQ,CAAC;MACxC,CAAG;MACHhB,cAAc,EAAGA,cAAgB;MACjCiB,iBAAiB,EAAGA,CAAA,KAAMZ,iBAAiB,CAACW,OAAS;MAAAH,QAAA,eAErD,IAAAjB,WAAA,CAAAkB,GAAA,EAACnB,mBAAA,CAAAuB,kBAAkB;QAClBC,uBAAuB;QACvBC,qBAAqB;QACrBC,GAAG,EAAGjB;QACN;QACA;QAAA;QACAH,QAAQ,EAAKO,KAAK,IAAM;UACvBD,QAAQ,CAACS,OAAO,GAAGR,KAAK;UACxBP,QAAQ,GAAIO,KAAM,CAAC;QACpB,CAAG;QAAA,GACEL;MAAS,CACd;IAAC,CACe,CAAC,eACnB,IAAAP,WAAA,CAAAkB,GAAA;MACCF,SAAS,EAAC,8CAA8C;MACxDU,IAAI,EAAC,OAAO;MACZD,GAAG,EAAGhB,iBAAmB;MACzBP,QAAQ,EAAGA,QAAU;MACrByB,OAAO,EAAGpB,SAAS,CAACK,KAAK,KAAK,IAAM;MACpCgB,QAAQ,EAAG,CAAC;MACZ;MAAA;MACAC,IAAI,EAAGhB,QAAU;MACjBR,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrByB,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,MAAM,CAACC,sBAAsB,EAC5BC,aAAa,CACd,2BACD,CAAC,EACCC,KAAK,CAAC,CAAC;MACX;IAAG,CACH,CAAC;EAAA,CACE,CAAC;AAER,CAAC;AAEM,MAAMC,2BAA2B,GAAAC,OAAA,CAAAD,2BAAA,GAAG,IAAAE,mBAAU,EACpDrC,sCACD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/components/src/validated-form-controls/components/types.ts"],"sourcesContent":["export type ValidatedControlProps< V > = {\n\t/**\n\t * Whether the control is required.\n\t * @default false\n\t */\n\trequired?: boolean;\n\t/**\n\t * Label the control as \"optional\" when _not_ `required`, instead of the inverse.\n\t * @default false\n\t */\n\tmarkWhenOptional?: boolean;\n\t/**\n\t *
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/components/src/validated-form-controls/components/types.ts"],"sourcesContent":["export type ValidatedControlProps< V > = {\n\t/**\n\t * Whether the control is required.\n\t * @default false\n\t */\n\trequired?: boolean;\n\t/**\n\t * Label the control as \"optional\" when _not_ `required`, instead of the inverse.\n\t * @default false\n\t */\n\tmarkWhenOptional?: boolean;\n\t/**\n\t * Optional callback to run when the input should be validated. Use this to set\n\t * a `customValidity` as necessary.\n\t *\n\t * Always prefer using standard HTML attributes like `required` and `min`/`max` over\n\t * custom validators when possible, as they are simpler and have localized error messages built in.\n\t */\n\tonValidate?: ( currentValue: V ) => void;\n\t/**\n\t * Show a custom message based on the validation status.\n\t *\n\t * - When `type` is `invalid`, the message will be applied to the underlying element using the\n\t * native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).\n\t * This means the custom message will be prioritized over any existing validity messages\n\t * triggered by HTML attribute-based validation.\n\t * - When `type` is `validating` or `valid`, the custom validity message of the underlying element\n\t * will be cleared. If there are no remaining validity messages triggered by HTML attribute-based validation,\n\t * the message will be presented as a status indicator rather than an error. These indicators are intended\n\t * for asynchronous validation calls that may take more than 1 second to complete.\n\t * Otherwise, custom errors can simply be cleared by setting the `customValidity` prop to `undefined`.\n\t */\n\tcustomValidity?: {\n\t\ttype: 'validating' | 'valid' | 'invalid';\n\t\tmessage: string;\n\t};\n};\n"],"mappings":"","ignoreList":[]}
|