@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.
Files changed (233) hide show
  1. package/CHANGELOG.md +26 -4
  2. package/build/alignment-matrix-control/cell.js +131 -3
  3. package/build/alignment-matrix-control/cell.js.map +4 -4
  4. package/build/alignment-matrix-control/index.js +134 -6
  5. package/build/alignment-matrix-control/index.js.map +3 -3
  6. package/build/angle-picker-control/angle-circle.js +119 -15
  7. package/build/angle-picker-control/angle-circle.js.map +4 -4
  8. package/build/angle-picker-control/index.js +12 -7
  9. package/build/angle-picker-control/index.js.map +3 -3
  10. package/build/dropdown-menu/index.js +1 -1
  11. package/build/dropdown-menu/index.js.map +2 -2
  12. package/build/form-token-field/index.js +1 -13
  13. package/build/form-token-field/index.js.map +3 -3
  14. package/build/menu/styles.js +17 -17
  15. package/build/menu/styles.js.map +2 -2
  16. package/build/menu-item/index.js +1 -1
  17. package/build/menu-item/index.js.map +2 -2
  18. package/build/notice/index.js +1 -1
  19. package/build/notice/index.js.map +2 -2
  20. package/build/query-controls/index.js +0 -1
  21. package/build/query-controls/index.js.map +2 -2
  22. package/build/snackbar/index.js +1 -1
  23. package/build/snackbar/index.js.map +1 -1
  24. package/build/validated-form-controls/components/checkbox-control.js +0 -10
  25. package/build/validated-form-controls/components/checkbox-control.js.map +2 -2
  26. package/build/validated-form-controls/components/combobox-control.js +1 -11
  27. package/build/validated-form-controls/components/combobox-control.js.map +2 -2
  28. package/build/validated-form-controls/components/custom-select-control.js +0 -10
  29. package/build/validated-form-controls/components/custom-select-control.js.map +2 -2
  30. package/build/validated-form-controls/components/form-token-field.js +2 -13
  31. package/build/validated-form-controls/components/form-token-field.js.map +2 -2
  32. package/build/validated-form-controls/components/input-control.js +0 -10
  33. package/build/validated-form-controls/components/input-control.js.map +2 -2
  34. package/build/validated-form-controls/components/number-control.js +0 -10
  35. package/build/validated-form-controls/components/number-control.js.map +2 -2
  36. package/build/validated-form-controls/components/radio-control.js +0 -10
  37. package/build/validated-form-controls/components/radio-control.js.map +2 -2
  38. package/build/validated-form-controls/components/range-control.js +0 -10
  39. package/build/validated-form-controls/components/range-control.js.map +2 -2
  40. package/build/validated-form-controls/components/select-control.js +0 -10
  41. package/build/validated-form-controls/components/select-control.js.map +2 -2
  42. package/build/validated-form-controls/components/text-control.js +0 -10
  43. package/build/validated-form-controls/components/text-control.js.map +2 -2
  44. package/build/validated-form-controls/components/textarea-control.js +0 -10
  45. package/build/validated-form-controls/components/textarea-control.js.map +2 -2
  46. package/build/validated-form-controls/components/toggle-control.js +0 -10
  47. package/build/validated-form-controls/components/toggle-control.js.map +2 -2
  48. package/build/validated-form-controls/components/toggle-group-control.js +0 -10
  49. package/build/validated-form-controls/components/toggle-group-control.js.map +2 -2
  50. package/build/validated-form-controls/control-with-error.js +53 -58
  51. package/build/validated-form-controls/control-with-error.js.map +2 -2
  52. package/build-module/alignment-matrix-control/cell.js +131 -3
  53. package/build-module/alignment-matrix-control/cell.js.map +3 -3
  54. package/build-module/alignment-matrix-control/index.js +134 -6
  55. package/build-module/alignment-matrix-control/index.js.map +3 -3
  56. package/build-module/angle-picker-control/angle-circle.js +109 -15
  57. package/build-module/angle-picker-control/angle-circle.js.map +3 -3
  58. package/build-module/angle-picker-control/index.js +12 -7
  59. package/build-module/angle-picker-control/index.js.map +2 -2
  60. package/build-module/dropdown-menu/index.js +1 -1
  61. package/build-module/dropdown-menu/index.js.map +2 -2
  62. package/build-module/form-token-field/index.js +1 -13
  63. package/build-module/form-token-field/index.js.map +2 -2
  64. package/build-module/menu/styles.js +17 -17
  65. package/build-module/menu/styles.js.map +2 -2
  66. package/build-module/menu-item/index.js +1 -1
  67. package/build-module/menu-item/index.js.map +2 -2
  68. package/build-module/notice/index.js +1 -1
  69. package/build-module/notice/index.js.map +2 -2
  70. package/build-module/query-controls/index.js +0 -1
  71. package/build-module/query-controls/index.js.map +2 -2
  72. package/build-module/snackbar/index.js +1 -1
  73. package/build-module/snackbar/index.js.map +1 -1
  74. package/build-module/validated-form-controls/components/checkbox-control.js +0 -10
  75. package/build-module/validated-form-controls/components/checkbox-control.js.map +2 -2
  76. package/build-module/validated-form-controls/components/combobox-control.js +1 -11
  77. package/build-module/validated-form-controls/components/combobox-control.js.map +2 -2
  78. package/build-module/validated-form-controls/components/custom-select-control.js +0 -10
  79. package/build-module/validated-form-controls/components/custom-select-control.js.map +2 -2
  80. package/build-module/validated-form-controls/components/form-token-field.js +2 -13
  81. package/build-module/validated-form-controls/components/form-token-field.js.map +2 -2
  82. package/build-module/validated-form-controls/components/input-control.js +0 -10
  83. package/build-module/validated-form-controls/components/input-control.js.map +2 -2
  84. package/build-module/validated-form-controls/components/number-control.js +0 -10
  85. package/build-module/validated-form-controls/components/number-control.js.map +2 -2
  86. package/build-module/validated-form-controls/components/radio-control.js +0 -10
  87. package/build-module/validated-form-controls/components/radio-control.js.map +2 -2
  88. package/build-module/validated-form-controls/components/range-control.js +0 -10
  89. package/build-module/validated-form-controls/components/range-control.js.map +2 -2
  90. package/build-module/validated-form-controls/components/select-control.js +0 -10
  91. package/build-module/validated-form-controls/components/select-control.js.map +2 -2
  92. package/build-module/validated-form-controls/components/text-control.js +0 -10
  93. package/build-module/validated-form-controls/components/text-control.js.map +2 -2
  94. package/build-module/validated-form-controls/components/textarea-control.js +0 -10
  95. package/build-module/validated-form-controls/components/textarea-control.js.map +2 -2
  96. package/build-module/validated-form-controls/components/toggle-control.js +0 -10
  97. package/build-module/validated-form-controls/components/toggle-control.js.map +2 -2
  98. package/build-module/validated-form-controls/components/toggle-group-control.js +0 -10
  99. package/build-module/validated-form-controls/components/toggle-group-control.js.map +2 -2
  100. package/build-module/validated-form-controls/control-with-error.js +53 -58
  101. package/build-module/validated-form-controls/control-with-error.js.map +2 -2
  102. package/build-style/style-rtl.css +21 -33
  103. package/build-style/style.css +21 -33
  104. package/build-types/alignment-matrix-control/cell.d.ts.map +1 -1
  105. package/build-types/alignment-matrix-control/index.d.ts.map +1 -1
  106. package/build-types/angle-picker-control/angle-circle.d.ts +1 -1
  107. package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
  108. package/build-types/angle-picker-control/index.d.ts.map +1 -1
  109. package/build-types/form-token-field/index.d.ts.map +1 -1
  110. package/build-types/form-token-field/stories/index.story.d.ts.map +1 -1
  111. package/build-types/form-token-field/types.d.ts +0 -6
  112. package/build-types/form-token-field/types.d.ts.map +1 -1
  113. package/build-types/notice/index.d.ts.map +1 -1
  114. package/build-types/notice/stories/index.story.d.ts.map +1 -1
  115. package/build-types/query-controls/index.d.ts.map +1 -1
  116. package/build-types/validated-form-controls/components/checkbox-control.d.ts +1 -1
  117. package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
  118. package/build-types/validated-form-controls/components/combobox-control.d.ts +2 -3
  119. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -1
  120. package/build-types/validated-form-controls/components/custom-select-control.d.ts +1 -2
  121. package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -1
  122. package/build-types/validated-form-controls/components/form-token-field.d.ts +1 -2
  123. package/build-types/validated-form-controls/components/form-token-field.d.ts.map +1 -1
  124. package/build-types/validated-form-controls/components/input-control.d.ts +1 -2
  125. package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -1
  126. package/build-types/validated-form-controls/components/number-control.d.ts +1 -1
  127. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -1
  128. package/build-types/validated-form-controls/components/radio-control.d.ts +1 -1
  129. package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
  130. package/build-types/validated-form-controls/components/range-control.d.ts +1 -1
  131. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -1
  132. package/build-types/validated-form-controls/components/select-control.d.ts +2 -3
  133. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -1
  134. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -1
  135. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -1
  136. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -1
  137. package/build-types/validated-form-controls/components/stories/form-token-field.story.d.ts.map +1 -1
  138. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -1
  139. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -1
  140. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +7 -0
  141. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -1
  142. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -1
  143. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -1
  144. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -1
  145. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -1
  146. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -1
  147. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -1
  148. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -1
  149. package/build-types/validated-form-controls/components/text-control.d.ts +1 -1
  150. package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -1
  151. package/build-types/validated-form-controls/components/textarea-control.d.ts +1 -1
  152. package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -1
  153. package/build-types/validated-form-controls/components/toggle-control.d.ts +1 -1
  154. package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -1
  155. package/build-types/validated-form-controls/components/toggle-group-control.d.ts +1 -1
  156. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -1
  157. package/build-types/validated-form-controls/components/types.d.ts +1 -9
  158. package/build-types/validated-form-controls/components/types.d.ts.map +1 -1
  159. package/build-types/validated-form-controls/control-with-error.d.ts +4 -5
  160. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
  161. package/package.json +20 -20
  162. package/src/alignment-matrix-control/cell.tsx +14 -3
  163. package/src/alignment-matrix-control/index.tsx +15 -6
  164. package/src/alignment-matrix-control/style.module.scss +84 -0
  165. package/src/angle-picker-control/angle-circle.tsx +27 -12
  166. package/src/angle-picker-control/index.tsx +8 -7
  167. package/src/angle-picker-control/style.module.scss +40 -0
  168. package/src/button/style.scss +1 -1
  169. package/src/dropdown-menu/index.tsx +1 -1
  170. package/src/dropdown-menu/style.scss +1 -1
  171. package/src/form-token-field/README.md +0 -2
  172. package/src/form-token-field/index.tsx +1 -13
  173. package/src/form-token-field/stories/index.story.tsx +0 -2
  174. package/src/form-token-field/test/index.tsx +0 -1
  175. package/src/form-token-field/types.ts +0 -6
  176. package/src/guide/style.scss +3 -3
  177. package/src/menu/styles.ts +2 -2
  178. package/src/menu-item/index.tsx +1 -1
  179. package/src/menu-item/test/__snapshots__/index.js.snap +4 -4
  180. package/src/modal/style.scss +5 -5
  181. package/src/notice/index.tsx +53 -46
  182. package/src/notice/stories/index.story.tsx +17 -1
  183. package/src/notice/style.scss +3 -20
  184. package/src/query-controls/index.tsx +0 -1
  185. package/src/snackbar/index.tsx +1 -1
  186. package/src/validated-form-controls/components/checkbox-control.tsx +1 -14
  187. package/src/validated-form-controls/components/combobox-control.tsx +1 -14
  188. package/src/validated-form-controls/components/custom-select-control.tsx +1 -19
  189. package/src/validated-form-controls/components/form-token-field.tsx +4 -21
  190. package/src/validated-form-controls/components/input-control.tsx +1 -14
  191. package/src/validated-form-controls/components/number-control.tsx +1 -16
  192. package/src/validated-form-controls/components/radio-control.tsx +2 -18
  193. package/src/validated-form-controls/components/range-control.tsx +1 -14
  194. package/src/validated-form-controls/components/select-control.tsx +1 -23
  195. package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +11 -20
  196. package/src/validated-form-controls/components/stories/combobox-control.story.tsx +8 -17
  197. package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +8 -17
  198. package/src/validated-form-controls/components/stories/form-token-field.story.tsx +14 -26
  199. package/src/validated-form-controls/components/stories/input-control.story.tsx +25 -50
  200. package/src/validated-form-controls/components/stories/number-control.story.tsx +10 -19
  201. package/src/validated-form-controls/components/stories/overview.mdx +3 -3
  202. package/src/validated-form-controls/components/stories/overview.story.tsx +94 -79
  203. package/src/validated-form-controls/components/stories/radio-control.story.tsx +11 -20
  204. package/src/validated-form-controls/components/stories/range-control.story.tsx +8 -17
  205. package/src/validated-form-controls/components/stories/select-control.story.tsx +9 -18
  206. package/src/validated-form-controls/components/stories/text-control.story.tsx +11 -17
  207. package/src/validated-form-controls/components/stories/textarea-control.story.tsx +12 -16
  208. package/src/validated-form-controls/components/stories/toggle-control.story.tsx +11 -20
  209. package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +8 -17
  210. package/src/validated-form-controls/components/text-control.tsx +1 -14
  211. package/src/validated-form-controls/components/textarea-control.tsx +1 -14
  212. package/src/validated-form-controls/components/toggle-control.tsx +1 -14
  213. package/src/validated-form-controls/components/toggle-group-control.tsx +1 -14
  214. package/src/validated-form-controls/components/types.ts +1 -9
  215. package/src/validated-form-controls/control-with-error.tsx +57 -84
  216. package/src/validated-form-controls/style.scss +7 -7
  217. package/src/validated-form-controls/test/control-with-error.tsx +66 -5
  218. package/tsconfig.json +1 -0
  219. package/tsconfig.tsbuildinfo +1 -1
  220. package/build/alignment-matrix-control/styles.js +0 -105
  221. package/build/alignment-matrix-control/styles.js.map +0 -7
  222. package/build/angle-picker-control/styles/angle-picker-control-styles.js +0 -88
  223. package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
  224. package/build-module/alignment-matrix-control/styles.js +0 -67
  225. package/build-module/alignment-matrix-control/styles.js.map +0 -7
  226. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +0 -50
  227. package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +0 -7
  228. package/build-types/alignment-matrix-control/styles.d.ts +0 -21
  229. package/build-types/alignment-matrix-control/styles.d.ts.map +0 -1
  230. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +0 -18
  231. package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +0 -1
  232. package/src/alignment-matrix-control/styles.ts +0 -113
  233. package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +0 -58
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/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 onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n const valueRef = useRef(restProps.value);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(RangeControl, {\n __next40pxDefaultSize: true,\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n });\n};\nexport const ValidatedRangeControl = forwardRef(UnforwardedValidatedRangeControl);"],
5
- "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,kBAAkB;AACzB,SAAS,OAAO,YAAY;AAC5B,IAAM,mCAAmC,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,QAAM,WAAW,OAAO,UAAU,KAAK;AACvC,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,aAAa,SAAS,OAAO;AAAA,IACtC;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,cAAc;AAAA,MACxC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,UAAU,WAAS;AACjB,iBAAS,UAAU;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,wBAAwB,WAAW,gCAAgC;",
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": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,kBAAkB;AACzB,SAAS,OAAO,YAAY;AAC5B,IAAM,mCAAmC,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,cAAc;AAAA,MACxC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,wBAAwB,WAAW,gCAAgC;",
6
6
  "names": []
7
7
  }
@@ -6,31 +6,21 @@ import SelectControl from "../../select-control";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var UnforwardedValidatedSelectControl = ({
8
8
  required,
9
- onValidate,
10
9
  customValidity,
11
- onChange,
12
10
  markWhenOptional,
13
11
  ...restProps
14
12
  }, forwardedRef) => {
15
13
  const validityTargetRef = useRef(null);
16
14
  const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
17
- const valueRef = useRef(restProps.value);
18
15
  return /* @__PURE__ */ _jsx(ControlWithError, {
19
16
  required,
20
17
  markWhenOptional,
21
- onValidate: () => {
22
- return onValidate?.(valueRef.current);
23
- },
24
18
  customValidity,
25
19
  getValidityTarget: () => validityTargetRef.current,
26
20
  children: /* @__PURE__ */ _jsx(SelectControl, {
27
21
  __nextHasNoMarginBottom: true,
28
22
  __next40pxDefaultSize: true,
29
23
  ref: mergedRefs,
30
- onChange: (value) => {
31
- valueRef.current = value;
32
- onChange?.(value);
33
- },
34
24
  ...restProps
35
25
  })
36
26
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/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';\n\n// Only support single value selection\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedSelectControl = ({\n required,\n onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n const valueRef = useRef(restProps.value);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: mergedRefs,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n });\n};\nexport const ValidatedSelectControl = forwardRef(UnforwardedValidatedSelectControl);"],
5
- "mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAG1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,QAAM,WAAW,OAAO,UAAU,KAAK;AACvC,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,aAAa,SAAS,OAAO;AAAA,IACtC;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,uBAAuB;AAAA,MACvB,KAAK;AAAA,MACL,UAAU,WAAS;AACjB,iBAAS,UAAU;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport SelectControl from '../../select-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedSelectControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(SelectControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedSelectControl = forwardRef(UnforwardedValidatedSelectControl);"],
5
+ "mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAC1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,uBAAuB;AAAA,MACvB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
6
6
  "names": []
7
7
  }
@@ -6,31 +6,21 @@ import TextControl from "../../text-control";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var UnforwardedValidatedTextControl = ({
8
8
  required,
9
- onValidate,
10
9
  customValidity,
11
- onChange,
12
10
  markWhenOptional,
13
11
  ...restProps
14
12
  }, forwardedRef) => {
15
13
  const validityTargetRef = useRef(null);
16
14
  const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
17
- const valueRef = useRef(restProps.value);
18
15
  return /* @__PURE__ */ _jsx(ControlWithError, {
19
16
  required,
20
17
  markWhenOptional,
21
- onValidate: () => {
22
- return onValidate?.(valueRef.current);
23
- },
24
18
  customValidity,
25
19
  getValidityTarget: () => validityTargetRef.current,
26
20
  children: /* @__PURE__ */ _jsx(TextControl, {
27
21
  __next40pxDefaultSize: true,
28
22
  __nextHasNoMarginBottom: true,
29
23
  ref: mergedRefs,
30
- onChange: (value) => {
31
- valueRef.current = value;
32
- onChange?.(value);
33
- },
34
24
  ...restProps
35
25
  })
36
26
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/text-control.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextControl from '../../text-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextControl = ({\n required,\n onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n const valueRef = useRef(restProps.value);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextControl, {\n __next40pxDefaultSize: true,\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n });\n};\nexport const ValidatedTextControl = forwardRef(UnforwardedValidatedTextControl);"],
5
- "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,iBAAiB;AACxB,SAAS,OAAO,YAAY;AAC5B,IAAM,kCAAkC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,QAAM,WAAW,OAAO,UAAU,KAAK;AACvC,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,aAAa,SAAS,OAAO;AAAA,IACtC;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,aAAa;AAAA,MACvC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,UAAU,WAAS;AACjB,iBAAS,UAAU;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,uBAAuB,WAAW,+BAA+B;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextControl from '../../text-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextControl, {\n __next40pxDefaultSize: true,\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedTextControl = forwardRef(UnforwardedValidatedTextControl);"],
5
+ "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc;AAKnC,SAAS,wBAAwB;AACjC,OAAO,iBAAiB;AACxB,SAAS,OAAO,YAAY;AAC5B,IAAM,kCAAkC,CAAC;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,aAAa;AAAA,MACvC,uBAAuB;AAAA,MACvB,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,uBAAuB,WAAW,+BAA+B;",
6
6
  "names": []
7
7
  }
@@ -6,30 +6,20 @@ import TextareaControl from "../../textarea-control";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var UnforwardedValidatedTextareaControl = ({
8
8
  required,
9
- onValidate,
10
9
  customValidity,
11
- onChange,
12
10
  markWhenOptional,
13
11
  ...restProps
14
12
  }, forwardedRef) => {
15
13
  const validityTargetRef = useRef(null);
16
14
  const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
17
- const valueRef = useRef(restProps.value);
18
15
  return /* @__PURE__ */ _jsx(ControlWithError, {
19
16
  required,
20
17
  markWhenOptional,
21
- onValidate: () => {
22
- return onValidate?.(valueRef.current);
23
- },
24
18
  customValidity,
25
19
  getValidityTarget: () => validityTargetRef.current,
26
20
  children: /* @__PURE__ */ _jsx(TextareaControl, {
27
21
  __nextHasNoMarginBottom: true,
28
22
  ref: mergedRefs,
29
- onChange: (value) => {
30
- valueRef.current = value;
31
- onChange?.(value);
32
- },
33
23
  ...restProps
34
24
  })
35
25
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/textarea-control.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextareaControl from '../../textarea-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextareaControl = ({\n required,\n onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n const valueRef = useRef(restProps.value);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextareaControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n });\n};\nexport const ValidatedTextareaControl = forwardRef(UnforwardedValidatedTextareaControl);"],
5
- "mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,QAAM,WAAW,OAAO,UAAU,KAAK;AACvC,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,aAAa,SAAS,OAAO;AAAA,IACtC;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,iBAAiB;AAAA,MAC3C,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,UAAU,WAAS;AACjB,iBAAS,UAAU;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,2BAA2B,WAAW,mCAAmC;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport TextareaControl from '../../textarea-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedTextareaControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(TextareaControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedTextareaControl = forwardRef(UnforwardedValidatedTextareaControl);"],
5
+ "mappings": ";AAGA,SAAS,YAAY,cAAc;AACnC,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,qBAAqB;AAC5B,SAAS,OAAO,YAAY;AAC5B,IAAM,sCAAsC,CAAC;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,iBAAiB;AAAA,MAC3C,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,2BAA2B,WAAW,mCAAmC;",
6
6
  "names": []
7
7
  }
@@ -6,15 +6,12 @@ import ToggleControl from "../../toggle-control";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  var UnforwardedValidatedToggleControl = ({
8
8
  required,
9
- onValidate,
10
9
  customValidity,
11
- onChange,
12
10
  markWhenOptional,
13
11
  ...restProps
14
12
  }, forwardedRef) => {
15
13
  const validityTargetRef = useRef(null);
16
14
  const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
17
- const valueRef = useRef(restProps.checked);
18
15
  useEffect(() => {
19
16
  if (validityTargetRef.current) {
20
17
  validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;
@@ -23,18 +20,11 @@ var UnforwardedValidatedToggleControl = ({
23
20
  return /* @__PURE__ */ _jsx(ControlWithError, {
24
21
  required,
25
22
  markWhenOptional,
26
- onValidate: () => {
27
- return onValidate?.(valueRef.current);
28
- },
29
23
  customValidity,
30
24
  getValidityTarget: () => validityTargetRef.current,
31
25
  children: /* @__PURE__ */ _jsx(ToggleControl, {
32
26
  __nextHasNoMarginBottom: true,
33
27
  ref: mergedRefs,
34
- onChange: (value) => {
35
- valueRef.current = value;
36
- onChange?.(value);
37
- },
38
28
  ...restProps
39
29
  })
40
30
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/toggle-control.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\n\nconst UnforwardedValidatedToggleControl = ({\n required,\n onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n const valueRef = useRef(restProps.checked);\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 onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n });\n};\nexport const ValidatedToggleControl = forwardRef(UnforwardedValidatedToggleControl);"],
5
- "mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAC1B,SAAS,OAAO,YAAY;AAG5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AACjE,QAAM,WAAW,OAAO,UAAU,OAAO;AAIzC,YAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,aAAa,QAAQ,aAAa,SAAS,WAAW;AAAA,IAC7F;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA,YAAY,MAAM;AAChB,aAAO,aAAa,SAAS,OAAO;AAAA,IACtC;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,UAAU,WAAS;AACjB,iBAAS,UAAU;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,MACA,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useRef, useEffect } from '@wordpress/element';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport ToggleControl from '../../toggle-control';\n\n// TODO: Should we customize the default `missingValue` message? It says to \"check this box\".\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);\n\n // TODO: Upstream limitation - The `required` attribute is not passed down to the input,\n // so we need to set it manually.\n useEffect(() => {\n if (validityTargetRef.current) {\n validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;\n }\n }, [required]);\n return /*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleControl, {\n __nextHasNoMarginBottom: true,\n ref: mergedRefs,\n ...restProps\n })\n });\n};\nexport const ValidatedToggleControl = forwardRef(UnforwardedValidatedToggleControl);"],
5
+ "mappings": ";AAGA,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,oBAAoB;AAK7B,SAAS,wBAAwB;AACjC,OAAO,mBAAmB;AAG1B,SAAS,OAAO,YAAY;AAC5B,IAAM,oCAAoC,CAAC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,aAAa,aAAa,CAAC,cAAc,iBAAiB,CAAC;AAIjE,YAAU,MAAM;AACd,QAAI,kBAAkB,SAAS;AAC7B,wBAAkB,QAAQ,WAAW,aAAa,QAAQ,aAAa,SAAS,WAAW;AAAA,IAC7F;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AACb,SAAoB,qBAAK,kBAAkB;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,MAAM,kBAAkB;AAAA,IAC3C,UAAuB,qBAAK,eAAe;AAAA,MACzC,yBAAyB;AAAA,MACzB,KAAK;AAAA,MACL,GAAG;AAAA,IACL,CAAC;AAAA,EACH,CAAC;AACH;AACO,IAAM,yBAAyB,WAAW,iCAAiC;",
6
6
  "names": []
7
7
  }
@@ -5,33 +5,23 @@ import { ToggleGroupControl } from "../../toggle-group-control";
5
5
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  var UnforwardedValidatedToggleGroupControl = ({
7
7
  required,
8
- onValidate,
9
8
  customValidity,
10
- onChange,
11
9
  markWhenOptional,
12
10
  ...restProps
13
11
  }, forwardedRef) => {
14
12
  const validityTargetRef = useRef(null);
15
- const valueRef = useRef(restProps.value);
16
13
  const nameAttr = useId();
17
14
  return /* @__PURE__ */ _jsxs("div", {
18
15
  className: "components-validated-control__wrapper-with-error-delegate",
19
16
  children: [/* @__PURE__ */ _jsx(ControlWithError, {
20
17
  required,
21
18
  markWhenOptional,
22
- onValidate: () => {
23
- return onValidate?.(valueRef.current);
24
- },
25
19
  customValidity,
26
20
  getValidityTarget: () => validityTargetRef.current,
27
21
  children: /* @__PURE__ */ _jsx(ToggleGroupControl, {
28
22
  __nextHasNoMarginBottom: true,
29
23
  __next40pxDefaultSize: true,
30
24
  ref: forwardedRef,
31
- onChange: (value) => {
32
- valueRef.current = value;
33
- onChange?.(value);
34
- },
35
25
  ...restProps
36
26
  })
37
27
  }), /* @__PURE__ */ _jsx("input", {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/validated-form-controls/components/toggle-group-control.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useId, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport { ToggleGroupControl } from '../../toggle-group-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleGroupControl = ({\n required,\n onValidate,\n customValidity,\n onChange,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const valueRef = useRef(restProps.value);\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 onValidate: () => {\n return onValidate?.(valueRef.current);\n },\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleGroupControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: forwardedRef,\n onChange: value => {\n valueRef.current = value;\n onChange?.(value);\n },\n ...restProps\n })\n }), /*#__PURE__*/_jsx(\"input\", {\n className: \"components-validated-control__error-delegate\",\n type: \"radio\",\n ref: validityTargetRef,\n required: required,\n checked: restProps.value !== undefined,\n tabIndex: -1\n // A name attribute is needed for the `required` behavior to work.\n ,\n name: nameAttr,\n onChange: () => {},\n onFocus: e => {\n e.target.previousElementSibling?.querySelector('[data-active-item=\"true\"]')?.focus();\n }\n })]\n });\n};\nexport const ValidatedToggleGroupControl = forwardRef(UnforwardedValidatedToggleGroupControl);"],
5
- "mappings": ";AAGA,SAAS,YAAY,OAAO,cAAc;AAK1C,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,yCAAyC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,WAAW,OAAO,UAAU,KAAK;AACvC,QAAM,WAAW,MAAM;AACvB,SAAoB,sBAAM,OAAO;AAAA,IAC/B,WAAW;AAAA,IACX,UAAU,CAAc,qBAAK,kBAAkB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA,YAAY,MAAM;AAChB,eAAO,aAAa,SAAS,OAAO;AAAA,MACtC;AAAA,MACA;AAAA,MACA,mBAAmB,MAAM,kBAAkB;AAAA,MAC3C,UAAuB,qBAAK,oBAAoB;AAAA,QAC9C,yBAAyB;AAAA,QACzB,uBAAuB;AAAA,QACvB,KAAK;AAAA,QACL,UAAU,WAAS;AACjB,mBAAS,UAAU;AACnB,qBAAW,KAAK;AAAA,QAClB;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC,GAAgB,qBAAK,SAAS;AAAA,MAC7B,WAAW;AAAA,MACX,MAAM;AAAA,MACN,KAAK;AAAA,MACL;AAAA,MACA,SAAS,UAAU,UAAU;AAAA,MAC7B,UAAU;AAAA,MAGV,MAAM;AAAA,MACN,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,SAAS,OAAK;AACZ,UAAE,OAAO,wBAAwB,cAAc,2BAA2B,GAAG,MAAM;AAAA,MACrF;AAAA,IACF,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,8BAA8B,WAAW,sCAAsC;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { forwardRef, useId, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ControlWithError } from '../control-with-error';\nimport { ToggleGroupControl } from '../../toggle-group-control';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst UnforwardedValidatedToggleGroupControl = ({\n required,\n customValidity,\n markWhenOptional,\n ...restProps\n}, forwardedRef) => {\n const validityTargetRef = useRef(null);\n const nameAttr = useId();\n return /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-validated-control__wrapper-with-error-delegate\",\n children: [/*#__PURE__*/_jsx(ControlWithError, {\n required: required,\n markWhenOptional: markWhenOptional,\n customValidity: customValidity,\n getValidityTarget: () => validityTargetRef.current,\n children: /*#__PURE__*/_jsx(ToggleGroupControl, {\n __nextHasNoMarginBottom: true,\n __next40pxDefaultSize: true,\n ref: forwardedRef,\n ...restProps\n })\n }), /*#__PURE__*/_jsx(\"input\", {\n className: \"components-validated-control__error-delegate\",\n type: \"radio\",\n ref: validityTargetRef,\n required: required,\n checked: restProps.value !== undefined,\n tabIndex: -1\n // A name attribute is needed for the `required` behavior to work.\n ,\n name: nameAttr,\n onChange: () => {},\n onFocus: e => {\n e.target.previousElementSibling?.querySelector('[data-active-item=\"true\"]')?.focus();\n }\n })]\n });\n};\nexport const ValidatedToggleGroupControl = forwardRef(UnforwardedValidatedToggleGroupControl);"],
5
+ "mappings": ";AAGA,SAAS,YAAY,OAAO,cAAc;AAK1C,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,OAAO,MAAM,QAAQ,aAAa;AAC3C,IAAM,yCAAyC,CAAC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG,iBAAiB;AAClB,QAAM,oBAAoB,OAAO,IAAI;AACrC,QAAM,WAAW,MAAM;AACvB,SAAoB,sBAAM,OAAO;AAAA,IAC/B,WAAW;AAAA,IACX,UAAU,CAAc,qBAAK,kBAAkB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA,mBAAmB,MAAM,kBAAkB;AAAA,MAC3C,UAAuB,qBAAK,oBAAoB;AAAA,QAC9C,yBAAyB;AAAA,QACzB,uBAAuB;AAAA,QACvB,KAAK;AAAA,QACL,GAAG;AAAA,MACL,CAAC;AAAA,IACH,CAAC,GAAgB,qBAAK,SAAS;AAAA,MAC7B,WAAW;AAAA,MACX,MAAM;AAAA,MACN,KAAK;AAAA,MACL;AAAA,MACA,SAAS,UAAU,UAAU;AAAA,MAC7B,UAAU;AAAA,MAGV,MAAM;AAAA,MACN,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,SAAS,OAAK;AACZ,UAAE,OAAO,wBAAwB,cAAc,2BAA2B,GAAG,MAAM;AAAA,MACrF;AAAA,IACF,CAAC,CAAC;AAAA,EACJ,CAAC;AACH;AACO,IAAM,8BAA8B,WAAW,sCAAsC;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,6 @@
1
1
  // packages/components/src/validated-form-controls/control-with-error.tsx
2
- import { usePrevious } from "@wordpress/compose";
3
2
  import { __ } from "@wordpress/i18n";
4
3
  import { cloneElement, forwardRef, useEffect, useState } from "@wordpress/element";
5
- import { withIgnoreIMEEvents } from "../utils/with-ignore-ime-events";
6
4
  import { ValidityIndicator } from "./validity-indicator";
7
5
  import { Fragment as _Fragment, jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
8
6
  function appendRequiredIndicator(label, required, markWhenOptional) {
@@ -18,30 +16,28 @@ function appendRequiredIndicator(label, required, markWhenOptional) {
18
16
  }
19
17
  return label;
20
18
  }
19
+ var VALIDITY_VISIBLE_ATTRIBUTE = "data-validity-visible";
21
20
  function UnforwardedControlWithError({
22
21
  required,
23
22
  markWhenOptional,
24
- onValidate,
25
23
  customValidity,
26
24
  getValidityTarget,
27
25
  children
28
26
  }, forwardedRef) {
29
27
  const [errorMessage, setErrorMessage] = useState();
30
28
  const [statusMessage, setStatusMessage] = useState();
29
+ const [showMessage, setShowMessage] = useState(false);
31
30
  const [isTouched, setIsTouched] = useState(false);
32
- const previousCustomValidityType = usePrevious(customValidity?.type);
33
31
  useEffect(() => {
34
32
  const validityTarget = getValidityTarget();
35
- const showValidationMessage = () => setErrorMessage(validityTarget?.validationMessage);
36
- validityTarget?.addEventListener("invalid", showValidationMessage);
37
- return () => {
38
- validityTarget?.removeEventListener("invalid", showValidationMessage);
33
+ const handler = () => {
34
+ setShowMessage(true);
35
+ validityTarget?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
39
36
  };
40
- });
37
+ validityTarget?.addEventListener("invalid", handler);
38
+ return () => validityTarget?.removeEventListener("invalid", handler);
39
+ }, [getValidityTarget]);
41
40
  useEffect(() => {
42
- if (!isTouched) {
43
- return;
44
- }
45
41
  const validityTarget = getValidityTarget();
46
42
  if (!customValidity?.type) {
47
43
  validityTarget?.setCustomValidity("");
@@ -51,20 +47,15 @@ function UnforwardedControlWithError({
51
47
  }
52
48
  switch (customValidity.type) {
53
49
  case "validating": {
54
- const timer = setTimeout(() => {
55
- validityTarget?.setCustomValidity("");
56
- setErrorMessage(void 0);
57
- setStatusMessage({
58
- type: "validating",
59
- message: customValidity.message
60
- });
61
- }, 1e3);
62
- return () => clearTimeout(timer);
50
+ validityTarget?.setCustomValidity("");
51
+ setErrorMessage(void 0);
52
+ setStatusMessage({
53
+ type: "validating",
54
+ message: customValidity.message
55
+ });
56
+ break;
63
57
  }
64
58
  case "valid": {
65
- if (previousCustomValidityType === "valid") {
66
- break;
67
- }
68
59
  validityTarget?.setCustomValidity("");
69
60
  setErrorMessage(validityTarget?.validationMessage);
70
61
  setStatusMessage({
@@ -81,51 +72,55 @@ function UnforwardedControlWithError({
81
72
  break;
82
73
  }
83
74
  }
84
- }, [isTouched, customValidity?.type, customValidity?.message, getValidityTarget, previousCustomValidityType]);
75
+ }, [customValidity, getValidityTarget]);
76
+ useEffect(() => {
77
+ if (!isTouched || showMessage) {
78
+ return;
79
+ }
80
+ if (customValidity?.type === "validating") {
81
+ const timer = setTimeout(() => {
82
+ setShowMessage(true);
83
+ }, 1e3);
84
+ return () => clearTimeout(timer);
85
+ }
86
+ setShowMessage(true);
87
+ }, [isTouched, customValidity?.type, showMessage]);
85
88
  const onBlur = (event) => {
86
89
  if (isTouched) {
87
90
  return;
88
91
  }
89
92
  if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
90
93
  setIsTouched(true);
91
- onValidate?.();
94
+ getValidityTarget()?.setAttribute(VALIDITY_VISIBLE_ATTRIBUTE, "");
92
95
  }
93
96
  };
94
- const onChange = (...args) => {
95
- children.props.onChange?.(...args);
96
- if (isTouched || errorMessage) {
97
- onValidate?.();
97
+ const message = () => {
98
+ if (errorMessage) {
99
+ return /* @__PURE__ */ _jsx(ValidityIndicator, {
100
+ type: "invalid",
101
+ message: errorMessage
102
+ });
98
103
  }
99
- };
100
- const onKeyDown = (event) => {
101
- if (event.key === "Enter") {
102
- onValidate?.();
104
+ if (statusMessage?.type) {
105
+ return /* @__PURE__ */ _jsx(ValidityIndicator, {
106
+ type: statusMessage.type,
107
+ message: statusMessage.message
108
+ });
103
109
  }
110
+ return null;
104
111
  };
105
- return (
106
- // Disable reason: Just listening to a bubbled event, not for interaction.
107
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
108
- /* @__PURE__ */ _jsxs("div", {
109
- className: "components-validated-control",
110
- ref: forwardedRef,
111
- onBlur,
112
- onKeyDown: withIgnoreIMEEvents(onKeyDown),
113
- children: [cloneElement(children, {
114
- label: appendRequiredIndicator(children.props.label, required, markWhenOptional),
115
- onChange,
116
- required
117
- }), /* @__PURE__ */ _jsxs("div", {
118
- "aria-live": "polite",
119
- children: [errorMessage && /* @__PURE__ */ _jsx(ValidityIndicator, {
120
- type: "invalid",
121
- message: errorMessage
122
- }), !errorMessage && statusMessage && /* @__PURE__ */ _jsx(ValidityIndicator, {
123
- type: statusMessage.type,
124
- message: statusMessage.message
125
- })]
126
- })]
127
- })
128
- );
112
+ return /* @__PURE__ */ _jsxs("div", {
113
+ className: "components-validated-control",
114
+ ref: forwardedRef,
115
+ onBlur,
116
+ children: [cloneElement(children, {
117
+ label: appendRequiredIndicator(children.props.label, required, markWhenOptional),
118
+ required
119
+ }), /* @__PURE__ */ _jsx("div", {
120
+ "aria-live": "polite",
121
+ children: showMessage && message()
122
+ })]
123
+ });
129
124
  }
130
125
  var ControlWithError = forwardRef(UnforwardedControlWithError);
131
126
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/validated-form-controls/control-with-error.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { cloneElement, forwardRef, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';\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}\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 onValidate,\n customValidity,\n getValidityTarget,\n children\n}, forwardedRef) {\n const [errorMessage, setErrorMessage] = useState();\n const [statusMessage, setStatusMessage] = useState();\n const [isTouched, setIsTouched] = useState(false);\n const previousCustomValidityType = usePrevious(customValidity?.type);\n\n // Ensure that error messages are visible after user attemps to submit a form\n // with multiple invalid fields.\n useEffect(() => {\n const validityTarget = getValidityTarget();\n const showValidationMessage = () => setErrorMessage(validityTarget?.validationMessage);\n validityTarget?.addEventListener('invalid', showValidationMessage);\n return () => {\n validityTarget?.removeEventListener('invalid', showValidationMessage);\n };\n });\n useEffect(() => {\n if (!isTouched) {\n return;\n }\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 // Wait before showing a validating state.\n const timer = setTimeout(() => {\n validityTarget?.setCustomValidity('');\n setErrorMessage(undefined);\n setStatusMessage({\n type: 'validating',\n message: customValidity.message\n });\n }, 1000);\n return () => clearTimeout(timer);\n }\n case 'valid':\n {\n // Ensures that we wait for any async responses before showing\n // a synchronously valid state.\n if (previousCustomValidityType === 'valid') {\n break;\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 }, [isTouched, customValidity?.type, customValidity?.message, getValidityTarget, previousCustomValidityType]);\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 onValidate?.();\n }\n };\n const onChange = (...args) => {\n children.props.onChange?.(...args);\n\n // Only validate incrementally if the field has blurred at least once,\n // or currently has an error message.\n if (isTouched || errorMessage) {\n onValidate?.();\n }\n };\n const onKeyDown = event => {\n // Ensures that custom validators are triggered when the user submits by pressing Enter,\n // without ever blurring the control.\n if (event.key === 'Enter') {\n onValidate?.();\n }\n };\n return (\n /*#__PURE__*/\n // Disable reason: Just listening to a bubbled event, not for interaction.\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsxs(\"div\", {\n className: \"components-validated-control\",\n ref: forwardedRef,\n onBlur: onBlur,\n onKeyDown: withIgnoreIMEEvents(onKeyDown),\n children: [cloneElement(children, {\n label: appendRequiredIndicator(children.props.label, required, markWhenOptional),\n onChange,\n required\n }), /*#__PURE__*/_jsxs(\"div\", {\n \"aria-live\": \"polite\",\n children: [errorMessage && /*#__PURE__*/_jsx(ValidityIndicator, {\n type: \"invalid\",\n message: errorMessage\n }), !errorMessage && statusMessage && /*#__PURE__*/_jsx(ValidityIndicator, {\n type: statusMessage.type,\n message: statusMessage.message\n })]\n })]\n })\n );\n}\nexport const ControlWithError = forwardRef(UnforwardedControlWithError);"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,WAAW,gBAAgB;AAK9D,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAClC,SAAS,YAAY,WAAW,QAAQ,OAAO,OAAO,YAAY;AAClE,SAAS,wBAAwB,OAAO,UAAU,kBAAkB;AACl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AAO;AAAA,QAC5B,aAAa;AAAA,QACb,UAAU,CAAC,gBAA6B,qBAAK,mBAAmB;AAAA,UAC9D,MAAM;AAAA,UACN,SAAS;AAAA,QACX,CAAC,GAAG,CAAC,gBAAgB,iBAA8B,qBAAK,mBAAmB;AAAA,UACzE,MAAM,cAAc;AAAA,UACpB,SAAS,cAAc;AAAA,QACzB,CAAC,CAAC;AAAA,MACJ,CAAC,CAAC;AAAA,IACJ,CAAC;AAAA;AAEL;AACO,IAAM,mBAAmB,WAAW,2BAA2B;",
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": ";AAGA,SAAS,UAAU;AACnB,SAAS,cAAc,YAAY,WAAW,gBAAgB;AAM9D,SAAS,yBAAyB;AAClC,SAAS,YAAY,WAAW,QAAQ,OAAO,OAAO,YAAY;AAClE,SAAS,wBAAwB,OAAO,UAAU,kBAAkB;AAClE,MAAI,YAAY,CAAC,kBAAkB;AACjC,WAAoB,sBAAM,WAAW;AAAA,MACnC,UAAU,CAAC,OAAO,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG;AAAA,IAC9C,CAAC;AAAA,EACH;AACA,MAAI,CAAC,YAAY,kBAAkB;AACjC,WAAoB,sBAAM,WAAW;AAAA,MACnC,UAAU,CAAC,OAAO,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG;AAAA,IAC9C,CAAC;AAAA,EACH;AACA,SAAO;AACT;AACA,IAAM,6BAA6B;AAWnC,SAAS,4BAA4B;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAG,cAAc;AACf,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS;AACjD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS;AACnD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,WAAW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