@wordpress/components 29.13.1-next.719a03cbe.0 → 30.1.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 (280) hide show
  1. package/CHANGELOG.md +34 -3
  2. package/build/autocomplete/index.js +4 -0
  3. package/build/autocomplete/index.js.map +1 -1
  4. package/build/calendar/date-calendar/index.js +13 -4
  5. package/build/calendar/date-calendar/index.js.map +1 -1
  6. package/build/calendar/date-range-calendar/index.js +8 -4
  7. package/build/calendar/date-range-calendar/index.js.map +1 -1
  8. package/build/calendar/types.js.map +1 -1
  9. package/build/color-picker/styles.js +7 -7
  10. package/build/color-picker/styles.js.map +1 -1
  11. package/build/icon/index.js +2 -0
  12. package/build/icon/index.js.map +1 -1
  13. package/build/index.js +0 -19
  14. package/build/index.js.map +1 -1
  15. package/build/palette-edit/index.js +1 -1
  16. package/build/palette-edit/index.js.map +1 -1
  17. package/build/private-apis.js +9 -1
  18. package/build/private-apis.js.map +1 -1
  19. package/build/range-control/index.js +1 -1
  20. package/build/range-control/index.js.map +1 -1
  21. package/build/range-control/styles/range-control-styles.js +35 -35
  22. package/build/range-control/styles/range-control-styles.js.map +1 -1
  23. package/build/range-control/tooltip.js +15 -15
  24. package/build/range-control/tooltip.js.map +1 -1
  25. package/build/range-control/types.js.map +1 -1
  26. package/build/select-control/index.js +1 -1
  27. package/build/select-control/index.js.map +1 -1
  28. package/build/textarea-control/index.js +7 -1
  29. package/build/textarea-control/index.js.map +1 -1
  30. package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  31. package/build/utils/hooks/use-controlled-value.js +8 -4
  32. package/build/utils/hooks/use-controlled-value.js.map +1 -1
  33. package/build/validated-form-controls/components/checkbox-control.js +52 -0
  34. package/build/validated-form-controls/components/checkbox-control.js.map +1 -0
  35. package/build/validated-form-controls/components/combobox-control.js +64 -0
  36. package/build/validated-form-controls/components/combobox-control.js.map +1 -0
  37. package/build/validated-form-controls/components/custom-select-control.js +71 -0
  38. package/build/validated-form-controls/components/custom-select-control.js.map +1 -0
  39. package/build/validated-form-controls/components/index.js +138 -0
  40. package/build/validated-form-controls/components/index.js.map +1 -0
  41. package/build/validated-form-controls/components/input-control.js +50 -0
  42. package/build/validated-form-controls/components/input-control.js.map +1 -0
  43. package/build/validated-form-controls/components/number-control.js +53 -0
  44. package/build/validated-form-controls/components/number-control.js.map +1 -0
  45. package/build/validated-form-controls/components/radio-control.js +51 -0
  46. package/build/validated-form-controls/components/radio-control.js.map +1 -0
  47. package/build/validated-form-controls/components/range-control.js +51 -0
  48. package/build/validated-form-controls/components/range-control.js.map +1 -0
  49. package/build/validated-form-controls/components/select-control.js +53 -0
  50. package/build/validated-form-controls/components/select-control.js.map +1 -0
  51. package/build/validated-form-controls/components/text-control.js +51 -0
  52. package/build/validated-form-controls/components/text-control.js.map +1 -0
  53. package/build/validated-form-controls/components/textarea-control.js +50 -0
  54. package/build/validated-form-controls/components/textarea-control.js.map +1 -0
  55. package/build/validated-form-controls/components/toggle-control.js +60 -0
  56. package/build/validated-form-controls/components/toggle-control.js.map +1 -0
  57. package/build/validated-form-controls/components/toggle-group-control.js +69 -0
  58. package/build/validated-form-controls/components/toggle-group-control.js.map +1 -0
  59. package/build/validated-form-controls/components/types.js +6 -0
  60. package/build/validated-form-controls/components/types.js.map +1 -0
  61. package/build/validated-form-controls/control-with-error.js +137 -0
  62. package/build/validated-form-controls/control-with-error.js.map +1 -0
  63. package/build/validated-form-controls/index.js +28 -0
  64. package/build/validated-form-controls/index.js.map +1 -0
  65. package/build-module/autocomplete/index.js +4 -0
  66. package/build-module/autocomplete/index.js.map +1 -1
  67. package/build-module/calendar/date-calendar/index.js +11 -3
  68. package/build-module/calendar/date-calendar/index.js.map +1 -1
  69. package/build-module/calendar/date-range-calendar/index.js +8 -4
  70. package/build-module/calendar/date-range-calendar/index.js.map +1 -1
  71. package/build-module/calendar/types.js.map +1 -1
  72. package/build-module/color-picker/styles.js +7 -7
  73. package/build-module/color-picker/styles.js.map +1 -1
  74. package/build-module/icon/index.js +2 -0
  75. package/build-module/icon/index.js.map +1 -1
  76. package/build-module/index.js +0 -1
  77. package/build-module/index.js.map +1 -1
  78. package/build-module/palette-edit/index.js +2 -2
  79. package/build-module/palette-edit/index.js.map +1 -1
  80. package/build-module/private-apis.js +9 -1
  81. package/build-module/private-apis.js.map +1 -1
  82. package/build-module/range-control/index.js +1 -1
  83. package/build-module/range-control/index.js.map +1 -1
  84. package/build-module/range-control/styles/range-control-styles.js +35 -35
  85. package/build-module/range-control/styles/range-control-styles.js.map +1 -1
  86. package/build-module/range-control/tooltip.js +15 -15
  87. package/build-module/range-control/tooltip.js.map +1 -1
  88. package/build-module/range-control/types.js.map +1 -1
  89. package/build-module/select-control/index.js +1 -1
  90. package/build-module/select-control/index.js.map +1 -1
  91. package/build-module/textarea-control/index.js +7 -1
  92. package/build-module/textarea-control/index.js.map +1 -1
  93. package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
  94. package/build-module/utils/hooks/use-controlled-value.js +9 -5
  95. package/build-module/utils/hooks/use-controlled-value.js.map +1 -1
  96. package/build-module/validated-form-controls/components/checkbox-control.js +44 -0
  97. package/build-module/validated-form-controls/components/checkbox-control.js.map +1 -0
  98. package/build-module/validated-form-controls/components/combobox-control.js +56 -0
  99. package/build-module/validated-form-controls/components/combobox-control.js.map +1 -0
  100. package/build-module/validated-form-controls/components/custom-select-control.js +63 -0
  101. package/build-module/validated-form-controls/components/custom-select-control.js.map +1 -0
  102. package/build-module/validated-form-controls/components/index.js +13 -0
  103. package/build-module/validated-form-controls/components/index.js.map +1 -0
  104. package/build-module/validated-form-controls/components/input-control.js +42 -0
  105. package/build-module/validated-form-controls/components/input-control.js.map +1 -0
  106. package/build-module/validated-form-controls/components/number-control.js +45 -0
  107. package/build-module/validated-form-controls/components/number-control.js.map +1 -0
  108. package/build-module/validated-form-controls/components/radio-control.js +43 -0
  109. package/build-module/validated-form-controls/components/radio-control.js.map +1 -0
  110. package/build-module/validated-form-controls/components/range-control.js +43 -0
  111. package/build-module/validated-form-controls/components/range-control.js.map +1 -0
  112. package/build-module/validated-form-controls/components/select-control.js +45 -0
  113. package/build-module/validated-form-controls/components/select-control.js.map +1 -0
  114. package/build-module/validated-form-controls/components/text-control.js +43 -0
  115. package/build-module/validated-form-controls/components/text-control.js.map +1 -0
  116. package/build-module/validated-form-controls/components/textarea-control.js +42 -0
  117. package/build-module/validated-form-controls/components/textarea-control.js.map +1 -0
  118. package/build-module/validated-form-controls/components/toggle-control.js +52 -0
  119. package/build-module/validated-form-controls/components/toggle-control.js.map +1 -0
  120. package/build-module/validated-form-controls/components/toggle-group-control.js +62 -0
  121. package/build-module/validated-form-controls/components/toggle-group-control.js.map +1 -0
  122. package/build-module/validated-form-controls/components/types.js +2 -0
  123. package/build-module/validated-form-controls/components/types.js.map +1 -0
  124. package/build-module/validated-form-controls/control-with-error.js +129 -0
  125. package/build-module/validated-form-controls/control-with-error.js.map +1 -0
  126. package/build-module/validated-form-controls/index.js +3 -0
  127. package/build-module/validated-form-controls/index.js.map +1 -0
  128. package/build-style/style-rtl.css +81 -71
  129. package/build-style/style.css +81 -71
  130. package/build-types/autocomplete/index.d.ts.map +1 -1
  131. package/build-types/box-control/utils.d.ts +7 -7
  132. package/build-types/calendar/date-calendar/index.d.ts.map +1 -1
  133. package/build-types/calendar/date-range-calendar/index.d.ts.map +1 -1
  134. package/build-types/calendar/types.d.ts +2 -2
  135. package/build-types/calendar/types.d.ts.map +1 -1
  136. package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
  137. package/build-types/color-picker/styles.d.ts.map +1 -1
  138. package/build-types/custom-gradient-picker/constants.d.ts +2 -2
  139. package/build-types/dimension-control/sizes.d.ts +5 -5
  140. package/build-types/font-size-picker/constants.d.ts +2 -2
  141. package/build-types/font-size-picker/constants.d.ts.map +1 -1
  142. package/build-types/icon/index.d.ts.map +1 -1
  143. package/build-types/index.d.ts +0 -1
  144. package/build-types/index.d.ts.map +1 -1
  145. package/build-types/private-apis.d.ts.map +1 -1
  146. package/build-types/range-control/types.d.ts +2 -2
  147. package/build-types/range-control/types.d.ts.map +1 -1
  148. package/build-types/select-control/stories/index.story.d.ts.map +1 -1
  149. package/build-types/text-control/stories/index.story.d.ts.map +1 -1
  150. package/build-types/textarea-control/index.d.ts.map +1 -1
  151. package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
  152. package/build-types/utils/hooks/use-controlled-value.d.ts +2 -2
  153. package/build-types/utils/hooks/use-controlled-value.d.ts.map +1 -1
  154. package/build-types/validated-form-controls/components/checkbox-control.d.ts +9 -0
  155. package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -0
  156. package/build-types/validated-form-controls/components/combobox-control.d.ts +21 -0
  157. package/build-types/validated-form-controls/components/combobox-control.d.ts.map +1 -0
  158. package/build-types/validated-form-controls/components/custom-select-control.d.ts +4 -0
  159. package/build-types/validated-form-controls/components/custom-select-control.d.ts.map +1 -0
  160. package/build-types/validated-form-controls/components/index.d.ts +13 -0
  161. package/build-types/validated-form-controls/components/index.d.ts.map +1 -0
  162. package/build-types/validated-form-controls/components/input-control.d.ts +4 -0
  163. package/build-types/validated-form-controls/components/input-control.d.ts.map +1 -0
  164. package/build-types/validated-form-controls/components/number-control.d.ts +17 -0
  165. package/build-types/validated-form-controls/components/number-control.d.ts.map +1 -0
  166. package/build-types/validated-form-controls/components/radio-control.d.ts +11 -0
  167. package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -0
  168. package/build-types/validated-form-controls/components/range-control.d.ts +36 -0
  169. package/build-types/validated-form-controls/components/range-control.d.ts.map +1 -0
  170. package/build-types/validated-form-controls/components/select-control.d.ts +9 -0
  171. package/build-types/validated-form-controls/components/select-control.d.ts.map +1 -0
  172. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts +12 -0
  173. package/build-types/validated-form-controls/components/stories/checkbox-control.story.d.ts.map +1 -0
  174. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts +12 -0
  175. package/build-types/validated-form-controls/components/stories/combobox-control.story.d.ts.map +1 -0
  176. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts +12 -0
  177. package/build-types/validated-form-controls/components/stories/custom-select-control.story.d.ts.map +1 -0
  178. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts +18 -0
  179. package/build-types/validated-form-controls/components/stories/input-control.story.d.ts.map +1 -0
  180. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts +12 -0
  181. package/build-types/validated-form-controls/components/stories/number-control.story.d.ts.map +1 -0
  182. package/build-types/validated-form-controls/components/stories/overview.story.d.ts +19 -0
  183. package/build-types/validated-form-controls/components/stories/overview.story.d.ts.map +1 -0
  184. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts +12 -0
  185. package/build-types/validated-form-controls/components/stories/radio-control.story.d.ts.map +1 -0
  186. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts +9 -0
  187. package/build-types/validated-form-controls/components/stories/range-control.story.d.ts.map +1 -0
  188. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts +12 -0
  189. package/build-types/validated-form-controls/components/stories/select-control.story.d.ts.map +1 -0
  190. package/build-types/validated-form-controls/components/stories/story-utils.d.ts +9 -0
  191. package/build-types/validated-form-controls/components/stories/story-utils.d.ts.map +1 -0
  192. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts +9 -0
  193. package/build-types/validated-form-controls/components/stories/text-control.story.d.ts.map +1 -0
  194. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts +9 -0
  195. package/build-types/validated-form-controls/components/stories/textarea-control.story.d.ts.map +1 -0
  196. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts +9 -0
  197. package/build-types/validated-form-controls/components/stories/toggle-control.story.d.ts.map +1 -0
  198. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts +9 -0
  199. package/build-types/validated-form-controls/components/stories/toggle-group-control.story.d.ts.map +1 -0
  200. package/build-types/validated-form-controls/components/text-control.d.ts +8 -0
  201. package/build-types/validated-form-controls/components/text-control.d.ts.map +1 -0
  202. package/build-types/validated-form-controls/components/textarea-control.d.ts +7 -0
  203. package/build-types/validated-form-controls/components/textarea-control.d.ts.map +1 -0
  204. package/build-types/validated-form-controls/components/toggle-control.d.ts +7 -0
  205. package/build-types/validated-form-controls/components/toggle-control.d.ts.map +1 -0
  206. package/build-types/validated-form-controls/components/toggle-group-control.d.ts +15 -0
  207. package/build-types/validated-form-controls/components/toggle-group-control.d.ts.map +1 -0
  208. package/build-types/validated-form-controls/components/types.d.ts +27 -0
  209. package/build-types/validated-form-controls/components/types.d.ts.map +1 -0
  210. package/build-types/validated-form-controls/control-with-error.d.ts +36 -0
  211. package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -0
  212. package/build-types/validated-form-controls/index.d.ts +3 -0
  213. package/build-types/validated-form-controls/index.d.ts.map +1 -0
  214. package/package.json +19 -19
  215. package/src/autocomplete/index.tsx +4 -0
  216. package/src/calendar/date-calendar/README.md +57 -46
  217. package/src/calendar/date-calendar/index.tsx +22 -8
  218. package/src/calendar/date-range-calendar/README.md +63 -52
  219. package/src/calendar/date-range-calendar/index.tsx +23 -11
  220. package/src/calendar/types.ts +2 -2
  221. package/src/color-picker/styles.ts +10 -0
  222. package/src/dimension-control/test/__snapshots__/index.test.js.snap +8 -8
  223. package/src/icon/index.tsx +2 -0
  224. package/src/index.ts +0 -1
  225. package/src/modal/style.scss +2 -2
  226. package/src/palette-edit/index.tsx +3 -3
  227. package/src/private-apis.ts +13 -0
  228. package/src/range-control/index.tsx +1 -1
  229. package/src/range-control/styles/range-control-styles.ts +3 -3
  230. package/src/range-control/tooltip.tsx +13 -13
  231. package/src/range-control/types.ts +2 -2
  232. package/src/select-control/index.tsx +1 -1
  233. package/src/style.scss +2 -2
  234. package/src/text-control/stories/index.story.tsx +1 -0
  235. package/src/text-control/style.scss +6 -1
  236. package/src/textarea-control/index.tsx +8 -1
  237. package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +3 -1
  238. package/src/utils/hooks/use-controlled-value.ts +16 -8
  239. package/src/utils/theme-variables.scss +3 -0
  240. package/src/validated-form-controls/components/checkbox-control.tsx +64 -0
  241. package/src/validated-form-controls/components/combobox-control.tsx +77 -0
  242. package/src/validated-form-controls/components/custom-select-control.tsx +86 -0
  243. package/src/validated-form-controls/components/index.ts +12 -0
  244. package/src/validated-form-controls/components/input-control.tsx +59 -0
  245. package/src/validated-form-controls/components/number-control.tsx +61 -0
  246. package/src/validated-form-controls/components/radio-control.tsx +60 -0
  247. package/src/validated-form-controls/components/range-control.tsx +60 -0
  248. package/src/validated-form-controls/components/select-control.tsx +75 -0
  249. package/src/validated-form-controls/components/stories/checkbox-control.story.tsx +57 -0
  250. package/src/validated-form-controls/components/stories/combobox-control.story.tsx +64 -0
  251. package/src/validated-form-controls/components/stories/custom-select-control.story.tsx +64 -0
  252. package/src/validated-form-controls/components/stories/input-control.story.tsx +132 -0
  253. package/src/validated-form-controls/components/stories/number-control.story.tsx +62 -0
  254. package/src/validated-form-controls/components/stories/overview.mdx +52 -0
  255. package/src/validated-form-controls/components/stories/overview.story.tsx +100 -0
  256. package/src/validated-form-controls/components/stories/radio-control.story.tsx +64 -0
  257. package/src/validated-form-controls/components/stories/range-control.story.tsx +60 -0
  258. package/src/validated-form-controls/components/stories/select-control.story.tsx +60 -0
  259. package/src/validated-form-controls/components/stories/story-utils.tsx +46 -0
  260. package/src/validated-form-controls/components/stories/text-control.story.tsx +55 -0
  261. package/src/validated-form-controls/components/stories/textarea-control.story.tsx +52 -0
  262. package/src/validated-form-controls/components/stories/toggle-control.story.tsx +55 -0
  263. package/src/validated-form-controls/components/stories/toggle-group-control.story.tsx +66 -0
  264. package/src/validated-form-controls/components/text-control.tsx +60 -0
  265. package/src/validated-form-controls/components/textarea-control.tsx +59 -0
  266. package/src/validated-form-controls/components/toggle-control.tsx +69 -0
  267. package/src/validated-form-controls/components/toggle-group-control.tsx +82 -0
  268. package/src/validated-form-controls/components/types.ts +28 -0
  269. package/src/validated-form-controls/control-with-error.tsx +198 -0
  270. package/src/validated-form-controls/index.ts +2 -0
  271. package/src/validated-form-controls/style.scss +75 -0
  272. package/tsconfig.tsbuildinfo +1 -1
  273. package/build/calendar/utils/use-controlled-value.js +0 -58
  274. package/build/calendar/utils/use-controlled-value.js.map +0 -1
  275. package/build-module/calendar/utils/use-controlled-value.js +0 -51
  276. package/build-module/calendar/utils/use-controlled-value.js.map +0 -1
  277. package/build-types/calendar/utils/use-controlled-value.d.ts +0 -27
  278. package/build-types/calendar/utils/use-controlled-value.d.ts.map +0 -1
  279. package/src/calendar/utils/use-controlled-value.ts +0 -61
  280. package/src/dimension-control/style.scss +0 -22
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","ControlWithError","CustomSelectControl","jsx","_jsx","jsxs","_jsxs","UnforwardedValidatedCustomSelectControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","valueRef","value","className","ref","children","current","getValidityTarget","__next40pxDefaultSize","selectedItem","tabIndex","key","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedCustomSelectControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,mBAAmB,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAU9D,MAAMC,uCAAuC,GAAGA,CAC/C;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAkD,KAC9C;EACJ,MAAMC,iBAAiB,GAAGd,MAAM,CAAuB,IAAK,CAAC;EAC7D,MAAMe,QAAQ,GAAGf,MAAM,CAAWY,SAAS,CAACI,KAAM,CAAC;EAEnD,oBACCV,KAAA;IACCW,SAAS,EAAC,2DAA2D;IACrEC,GAAG,EAAGL,YAAc;IAAAM,QAAA,gBAEpBf,IAAA,CAACH,gBAAgB;MAChBO,QAAQ,EAAGA,QAAU;MACrBG,gBAAgB,EAAGA,gBAAkB;MACrCF,eAAe,EAAGA,CAAA,KAAM;QACvB,OAAOA,eAAe,GAAIM,QAAQ,CAACK,OAAQ,CAAC;MAC7C,CAAG;MACHC,iBAAiB,EAAGA,CAAA,KAAMP,iBAAiB,CAACM,OAAS;MAAAD,QAAA,eAErDf,IAAA,CAACF;MACA;MACA;MAAA;QACAoB,qBAAqB;QACrBZ,QAAQ,EAAKM,KAAK,IAAM;UACvBD,QAAQ,CAACK,OAAO,GAAGJ,KAAK,CAACO,YAAY;UACrCb,QAAQ,GAAIM,KAAM,CAAC;QACpB,CAAG;QAAA,GACEJ;MAAS,CACd;IAAC,CACe,CAAC,eACnBN,KAAA;MACCW,SAAS,EAAC,8CAA8C;MACxDC,GAAG,EAAGJ,iBAAmB;MACzBN,QAAQ,EAAGA,QAAU;MACrBgB,QAAQ,EAAG,CAAC,CAAG;MACfR,KAAK,EAAGJ,SAAS,CAACI,KAAK,EAAES,GAAG,GAAG,UAAU,GAAG,EAAI;MAChDf,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrBgB,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,MAAM,CAACC,sBAAsB,EAC5BC,aAAa,CACd,mBACD,CAAC,EACCC,KAAK,CAAC,CAAC;MACX,CAAG;MAAAZ,QAAA,gBAEHf,IAAA;QAAQY,KAAK,EAAC,EAAE;QAAAG,QAAA,EAAC;MAAY,CAAQ,CAAC,eACtCf,IAAA;QAAQY,KAAK,EAAC,UAAU;QAAAG,QAAA,EAAC;MAAa,CAAQ,CAAC;IAAA,CACxC,CAAC;EAAA,CACL,CAAC;AAER,CAAC;AAED,OAAO,MAAMa,4BAA4B,GAAGjC,UAAU,CACrDQ,uCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ export * from './checkbox-control';
2
+ export * from './combobox-control';
3
+ export * from './custom-select-control';
4
+ export * from './input-control';
5
+ export * from './number-control';
6
+ export * from './radio-control';
7
+ export * from './range-control';
8
+ export * from './select-control';
9
+ export * from './text-control';
10
+ export * from './textarea-control';
11
+ export * from './toggle-control';
12
+ export * from './toggle-group-control';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/validated-form-controls/components/index.ts"],"sourcesContent":["export * from './checkbox-control';\nexport * from './combobox-control';\nexport * from './custom-select-control';\nexport * from './input-control';\nexport * from './number-control';\nexport * from './radio-control';\nexport * from './range-control';\nexport * from './select-control';\nexport * from './text-control';\nexport * from './textarea-control';\nexport * from './toggle-control';\nexport * from './toggle-group-control';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AACvC,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,kBAAkB;AAChC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,wBAAwB","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useRef } from '@wordpress/element';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import InputControl from '../../input-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedInputControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.value);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional,
26
+ customValidator: () => {
27
+ return customValidator?.(valueRef.current);
28
+ },
29
+ getValidityTarget: () => validityTargetRef.current,
30
+ children: /*#__PURE__*/_jsx(InputControl, {
31
+ __next40pxDefaultSize: true,
32
+ ref: mergedRefs,
33
+ onChange: (value, ...args) => {
34
+ valueRef.current = value;
35
+ onChange?.(value, ...args);
36
+ },
37
+ ...restProps
38
+ })
39
+ });
40
+ };
41
+ export const ValidatedInputControl = forwardRef(UnforwardedValidatedInputControl);
42
+ //# sourceMappingURL=input-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","useMergeRefs","ControlWithError","InputControl","jsx","_jsx","UnforwardedValidatedInputControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__next40pxDefaultSize","ref","args","ValidatedInputControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,YAAY,MAAM,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAK/C,MAAMC,gCAAgC,GAAGA,CACxC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAKiD,CAAC,EACtDC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGb,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMc,UAAU,GAAGb,YAAY,CAAE,CAAEW,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGf,MAAM,CAAWW,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,YAAY;MACZiB,qBAAqB;MACrBC,GAAG,EAAGP,UAAY;MAClBL,QAAQ,EAAGA,CAAEO,KAAK,EAAE,GAAGM,IAAI,KAAM;QAChCP,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAK,EAAE,GAAGM,IAAK,CAAC;MAC7B,CAAG;MAAA,GACEX;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,qBAAqB,GAAGxB,UAAU,CAC9CO,gCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useRef } from '@wordpress/element';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import NumberControl from '../../number-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedNumberControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.value);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional,
26
+ customValidator: () => {
27
+ return customValidator?.(valueRef.current);
28
+ },
29
+ getValidityTarget: () => validityTargetRef.current,
30
+ children: /*#__PURE__*/_jsx(NumberControl, {
31
+ __next40pxDefaultSize: true,
32
+ ref: mergedRefs
33
+ // TODO: Upstream limitation - When form is submitted when value is undefined, it will
34
+ // automatically set a clamped value (as defined by `min` attribute, so 0 by default).
35
+ ,
36
+ onChange: (value, ...args) => {
37
+ valueRef.current = value;
38
+ onChange?.(value, ...args);
39
+ },
40
+ ...restProps
41
+ })
42
+ });
43
+ };
44
+ export const ValidatedNumberControl = forwardRef(UnforwardedValidatedNumberControl);
45
+ //# sourceMappingURL=number-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","useMergeRefs","ControlWithError","NumberControl","jsx","_jsx","UnforwardedValidatedNumberControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__next40pxDefaultSize","ref","args","ValidatedNumberControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,OAAOC,aAAa,MAAM,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAMjD,MAAMC,iCAAiC,GAAGA,CACzC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGb,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMc,UAAU,GAAGb,YAAY,CAAE,CAAEW,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGf,MAAM,CAAWW,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,aAAa;MACbiB,qBAAqB;MACrBC,GAAG,EAAGP;MACN;MACA;MAAA;MACAL,QAAQ,EAAGA,CAAEO,KAAK,EAAE,GAAGM,IAAI,KAAM;QAChCP,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAK,EAAE,GAAGM,IAAK,CAAC;MAC7B,CAAG;MAAA,GACEX;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,sBAAsB,GAAGxB,UAAU,CAC/CO,iCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMergeRefs } from '@wordpress/compose';
5
+ import { forwardRef, useRef } from '@wordpress/element';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import RadioControl from '../../radio-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedRadioControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.selected);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional
26
+ // TODO: Upstream limitation - RadioControl does not accept a ref.
27
+ ,
28
+ ref: mergedRefs,
29
+ customValidator: () => {
30
+ return customValidator?.(valueRef.current);
31
+ },
32
+ getValidityTarget: () => validityTargetRef.current?.querySelector('input[type="radio"]'),
33
+ children: /*#__PURE__*/_jsx(RadioControl, {
34
+ onChange: value => {
35
+ valueRef.current = value;
36
+ onChange?.(value);
37
+ },
38
+ ...restProps
39
+ })
40
+ });
41
+ };
42
+ export const ValidatedRadioControl = forwardRef(UnforwardedValidatedRadioControl);
43
+ //# sourceMappingURL=radio-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMergeRefs","forwardRef","useRef","ControlWithError","RadioControl","jsx","_jsx","UnforwardedValidatedRadioControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","selected","ref","current","getValidityTarget","querySelector","children","value","ValidatedRadioControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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);\n};\n\nexport const ValidatedRadioControl = forwardRef(\n\tUnforwardedValidatedRadioControl\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,YAAY,MAAM,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAK/C,MAAMC,gCAAgC,GAAGA,CACxC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAE0B,CAAC,EAC/BC,YAAkD,KAC9C;EACJ,MAAMC,iBAAiB,GAAGZ,MAAM,CAAoB,IAAK,CAAC;EAC1D,MAAMa,UAAU,GAAGf,YAAY,CAAE,CAAEa,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGd,MAAM,CAAWU,SAAS,CAACK,QAAS,CAAC;EAEtD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA;IACnB;IAAA;IACAO,GAAG,EAAGH,UAAY;IAClBN,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACG,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KACnBN,iBAAiB,CAACK,OAAO,EAAEE,aAAa,CACvC,qBACD,CACA;IAAAC,QAAA,eAEDhB,IAAA,CAACF,YAAY;MACZM,QAAQ,EAAKa,KAAK,IAAM;QACvBP,QAAQ,CAACG,OAAO,GAAGI,KAAK;QACxBb,QAAQ,GAAIa,KAAM,CAAC;MACpB,CAAG;MAAA,GACEX;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,qBAAqB,GAAGvB,UAAU,CAC9CM,gCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMergeRefs } from '@wordpress/compose';
5
+ import { forwardRef, useRef } from '@wordpress/element';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import RangeControl from '../../range-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedRangeControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.value);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional,
26
+ customValidator: () => {
27
+ return customValidator?.(valueRef.current);
28
+ },
29
+ getValidityTarget: () => validityTargetRef.current,
30
+ children: /*#__PURE__*/_jsx(RangeControl, {
31
+ __next40pxDefaultSize: true,
32
+ __nextHasNoMarginBottom: true,
33
+ ref: mergedRefs,
34
+ onChange: value => {
35
+ valueRef.current = value;
36
+ onChange?.(value);
37
+ },
38
+ ...restProps
39
+ })
40
+ });
41
+ };
42
+ export const ValidatedRangeControl = forwardRef(UnforwardedValidatedRangeControl);
43
+ //# sourceMappingURL=range-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMergeRefs","forwardRef","useRef","ControlWithError","RangeControl","jsx","_jsx","UnforwardedValidatedRangeControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__next40pxDefaultSize","__nextHasNoMarginBottom","ref","ValidatedRangeControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,YAAY,MAAM,qBAAqB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAK/C,MAAMC,gCAAgC,GAAGA,CACxC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGZ,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMa,UAAU,GAAGf,YAAY,CAAE,CAAEa,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGd,MAAM,CAAWU,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,YAAY;MACZiB,qBAAqB;MACrBC,uBAAuB;MACvBC,GAAG,EAAGR,UAAY;MAClBL,QAAQ,EAAKO,KAAK,IAAM;QACvBD,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAM,CAAC;MACpB,CAAG;MAAA,GACEL;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,qBAAqB,GAAGvB,UAAU,CAC9CM,gCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useRef } from '@wordpress/element';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import SelectControl from '../../select-control';
12
+
13
+ // Only support single value selection
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ const UnforwardedValidatedSelectControl = ({
16
+ required,
17
+ customValidator,
18
+ onChange,
19
+ markWhenOptional,
20
+ ...restProps
21
+ }, forwardedRef) => {
22
+ const validityTargetRef = useRef(null);
23
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
24
+ const valueRef = useRef(restProps.value);
25
+ return /*#__PURE__*/_jsx(ControlWithError, {
26
+ required: required,
27
+ markWhenOptional: markWhenOptional,
28
+ customValidator: () => {
29
+ return customValidator?.(valueRef.current);
30
+ },
31
+ getValidityTarget: () => validityTargetRef.current,
32
+ children: /*#__PURE__*/_jsx(SelectControl, {
33
+ __nextHasNoMarginBottom: true,
34
+ __next40pxDefaultSize: true,
35
+ ref: mergedRefs,
36
+ onChange: value => {
37
+ valueRef.current = value;
38
+ onChange?.(value);
39
+ },
40
+ ...restProps
41
+ })
42
+ });
43
+ };
44
+ export const ValidatedSelectControl = forwardRef(UnforwardedValidatedSelectControl);
45
+ //# sourceMappingURL=select-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","useMergeRefs","ControlWithError","SelectControl","jsx","_jsx","UnforwardedValidatedSelectControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__nextHasNoMarginBottom","__next40pxDefaultSize","ref","ValidatedSelectControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,OAAOC,aAAa,MAAM,sBAAsB;;AAIhD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAWA,MAAMC,iCAAiC,GAAGA,CACzC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAW6B,CAAC,EAClCC,YAAqD,KACjD;EACJ,MAAMC,iBAAiB,GAAGb,MAAM,CAAuB,IAAK,CAAC;EAC7D,MAAMc,UAAU,GAAGb,YAAY,CAAE,CAAEW,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGf,MAAM,CAAWW,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,aAAa;MACbiB,uBAAuB;MACvBC,qBAAqB;MACrBC,GAAG,EAAGR,UAAY;MAClBL,QAAQ,EAAKO,KAAK,IAAM;QACvBD,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAM,CAAC;MACpB,CAAG;MAAA,GACEL;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,sBAAsB,GAAGxB,UAAU,CAC/CO,iCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useMergeRefs } from '@wordpress/compose';
5
+ import { forwardRef, useRef } from '@wordpress/element';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import TextControl from '../../text-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedTextControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.value);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional,
26
+ customValidator: () => {
27
+ return customValidator?.(valueRef.current);
28
+ },
29
+ getValidityTarget: () => validityTargetRef.current,
30
+ children: /*#__PURE__*/_jsx(TextControl, {
31
+ __next40pxDefaultSize: true,
32
+ __nextHasNoMarginBottom: true,
33
+ ref: mergedRefs,
34
+ onChange: value => {
35
+ valueRef.current = value;
36
+ onChange?.(value);
37
+ },
38
+ ...restProps
39
+ })
40
+ });
41
+ };
42
+ export const ValidatedTextControl = forwardRef(UnforwardedValidatedTextControl);
43
+ //# sourceMappingURL=text-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMergeRefs","forwardRef","useRef","ControlWithError","TextControl","jsx","_jsx","UnforwardedValidatedTextControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__next40pxDefaultSize","__nextHasNoMarginBottom","ref","ValidatedTextControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,WAAW,MAAM,oBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAK7C,MAAMC,+BAA+B,GAAGA,CACvC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGZ,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMa,UAAU,GAAGf,YAAY,CAAE,CAAEa,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGd,MAAM,CAAWU,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,WAAW;MACXiB,qBAAqB;MACrBC,uBAAuB;MACvBC,GAAG,EAAGR,UAAY;MAClBL,QAAQ,EAAKO,KAAK,IAAM;QACvBD,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAM,CAAC;MACpB,CAAG;MAAA,GACEL;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,oBAAoB,GAAGvB,UAAU,CAC7CM,+BACD,CAAC","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useRef } from '@wordpress/element';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import TextareaControl from '../../textarea-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ const UnforwardedValidatedTextareaControl = ({
14
+ required,
15
+ customValidator,
16
+ onChange,
17
+ markWhenOptional,
18
+ ...restProps
19
+ }, forwardedRef) => {
20
+ const validityTargetRef = useRef(null);
21
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
22
+ const valueRef = useRef(restProps.value);
23
+ return /*#__PURE__*/_jsx(ControlWithError, {
24
+ required: required,
25
+ markWhenOptional: markWhenOptional,
26
+ customValidator: () => {
27
+ return customValidator?.(valueRef.current);
28
+ },
29
+ getValidityTarget: () => validityTargetRef.current,
30
+ children: /*#__PURE__*/_jsx(TextareaControl, {
31
+ __nextHasNoMarginBottom: true,
32
+ ref: mergedRefs,
33
+ onChange: value => {
34
+ valueRef.current = value;
35
+ onChange?.(value);
36
+ },
37
+ ...restProps
38
+ })
39
+ });
40
+ };
41
+ export const ValidatedTextareaControl = forwardRef(UnforwardedValidatedTextareaControl);
42
+ //# sourceMappingURL=textarea-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","useMergeRefs","ControlWithError","TextareaControl","jsx","_jsx","UnforwardedValidatedTextareaControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","value","current","getValidityTarget","children","__nextHasNoMarginBottom","ref","ValidatedTextareaControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,QAAQ,oBAAoB;AACvD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,eAAe,MAAM,wBAAwB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAKrD,MAAMC,mCAAmC,GAAGA,CAC3C;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAuD,KACnD;EACJ,MAAMC,iBAAiB,GAAGb,MAAM,CAAyB,IAAK,CAAC;EAC/D,MAAMc,UAAU,GAAGb,YAAY,CAAE,CAAEW,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGf,MAAM,CAAWW,SAAS,CAACK,KAAM,CAAC;EAEnD,oBACCX,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,eAAe;MACfiB,uBAAuB;MACvBC,GAAG,EAAGP,UAAY;MAClBL,QAAQ,EAAKO,KAAK,IAAM;QACvBD,QAAQ,CAACE,OAAO,GAAGD,KAAK;QACxBP,QAAQ,GAAIO,KAAM,CAAC;MACpB,CAAG;MAAA,GACEL;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMW,wBAAwB,GAAGvB,UAAU,CACjDO,mCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useRef, useEffect } from '@wordpress/element';
5
+ import { useMergeRefs } from '@wordpress/compose';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { ControlWithError } from '../control-with-error';
11
+ import ToggleControl from '../../toggle-control';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ // TODO: Should we customize the default `missingValue` message? It says to "check this box".
14
+
15
+ const UnforwardedValidatedToggleControl = ({
16
+ required,
17
+ customValidator,
18
+ onChange,
19
+ markWhenOptional,
20
+ ...restProps
21
+ }, forwardedRef) => {
22
+ const validityTargetRef = useRef(null);
23
+ const mergedRefs = useMergeRefs([forwardedRef, validityTargetRef]);
24
+ const valueRef = useRef(restProps.checked);
25
+
26
+ // TODO: Upstream limitation - The `required` attribute is not passed down to the input,
27
+ // so we need to set it manually.
28
+ useEffect(() => {
29
+ if (validityTargetRef.current) {
30
+ validityTargetRef.current.required = required !== null && required !== void 0 ? required : false;
31
+ }
32
+ }, [required]);
33
+ return /*#__PURE__*/_jsx(ControlWithError, {
34
+ required: required,
35
+ markWhenOptional: markWhenOptional,
36
+ customValidator: () => {
37
+ return customValidator?.(valueRef.current);
38
+ },
39
+ getValidityTarget: () => validityTargetRef.current,
40
+ children: /*#__PURE__*/_jsx(ToggleControl, {
41
+ __nextHasNoMarginBottom: true,
42
+ ref: mergedRefs,
43
+ onChange: value => {
44
+ valueRef.current = value;
45
+ onChange?.(value);
46
+ },
47
+ ...restProps
48
+ })
49
+ });
50
+ };
51
+ export const ValidatedToggleControl = forwardRef(UnforwardedValidatedToggleControl);
52
+ //# sourceMappingURL=toggle-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useRef","useEffect","useMergeRefs","ControlWithError","ToggleControl","jsx","_jsx","UnforwardedValidatedToggleControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","mergedRefs","valueRef","checked","current","getValidityTarget","children","__nextHasNoMarginBottom","ref","value","ValidatedToggleControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAClE,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAOC,aAAa,MAAM,sBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAKjD;;AAEA,MAAMC,iCAAiC,GAAGA,CACzC;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGd,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMe,UAAU,GAAGb,YAAY,CAAE,CAAEW,YAAY,EAAEC,iBAAiB,CAAG,CAAC;EACtE,MAAME,QAAQ,GAAGhB,MAAM,CAAWY,SAAS,CAACK,OAAQ,CAAC;;EAErD;EACA;EACAhB,SAAS,CAAE,MAAM;IAChB,IAAKa,iBAAiB,CAACI,OAAO,EAAG;MAChCJ,iBAAiB,CAACI,OAAO,CAACV,QAAQ,GAAGA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,KAAK;IACvD;EACD,CAAC,EAAE,CAAEA,QAAQ,CAAG,CAAC;EAEjB,oBACCF,IAAA,CAACH,gBAAgB;IAChBK,QAAQ,EAAGA,QAAU;IACrBG,gBAAgB,EAAGA,gBAAkB;IACrCF,eAAe,EAAGA,CAAA,KAAM;MACvB,OAAOA,eAAe,GAAIO,QAAQ,CAACE,OAAQ,CAAC;IAC7C,CAAG;IACHC,iBAAiB,EAAGA,CAAA,KAAML,iBAAiB,CAACI,OAAS;IAAAE,QAAA,eAErDd,IAAA,CAACF,aAAa;MACbiB,uBAAuB;MACvBC,GAAG,EAAGP,UAAY;MAClBL,QAAQ,EAAKa,KAAK,IAAM;QACvBP,QAAQ,CAACE,OAAO,GAAGK,KAAK;QACxBb,QAAQ,GAAIa,KAAM,CAAC;MACpB,CAAG;MAAA,GACEX;IAAS,CACd;EAAC,CACe,CAAC;AAErB,CAAC;AAED,OAAO,MAAMY,sBAAsB,GAAGzB,UAAU,CAC/CQ,iCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { forwardRef, useId, useRef } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import { ControlWithError } from '../control-with-error';
10
+ import { ToggleGroupControl } from '../../toggle-group-control';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const UnforwardedValidatedToggleGroupControl = ({
13
+ required,
14
+ customValidator,
15
+ onChange,
16
+ markWhenOptional,
17
+ ...restProps
18
+ }, forwardedRef) => {
19
+ const validityTargetRef = useRef(null);
20
+ const valueRef = useRef(restProps.value);
21
+ const nameAttr = useId();
22
+ return /*#__PURE__*/_jsxs("div", {
23
+ className: "components-validated-control__wrapper-with-error-delegate",
24
+ children: [/*#__PURE__*/_jsx(ControlWithError, {
25
+ required: required,
26
+ markWhenOptional: markWhenOptional,
27
+ customValidator: () => {
28
+ return customValidator?.(valueRef.current);
29
+ },
30
+ getValidityTarget: () => validityTargetRef.current,
31
+ children: /*#__PURE__*/_jsx(ToggleGroupControl, {
32
+ __nextHasNoMarginBottom: true,
33
+ __next40pxDefaultSize: true,
34
+ ref: forwardedRef
35
+ // TODO: Upstream limitation - In uncontrolled mode, starting from an undefined value then
36
+ // setting a value has a visual bug.
37
+ ,
38
+ onChange: value => {
39
+ valueRef.current = value;
40
+ onChange?.(value);
41
+ },
42
+ ...restProps
43
+ })
44
+ }), /*#__PURE__*/_jsx("input", {
45
+ className: "components-validated-control__error-delegate",
46
+ type: "radio",
47
+ ref: validityTargetRef,
48
+ required: required,
49
+ checked: restProps.value !== null,
50
+ tabIndex: -1
51
+ // A name attribute is needed for the `required` behavior to work.
52
+ ,
53
+ name: nameAttr,
54
+ onChange: () => {},
55
+ onFocus: e => {
56
+ e.target.previousElementSibling?.querySelector('[data-active-item="true"]')?.focus();
57
+ }
58
+ })]
59
+ });
60
+ };
61
+ export const ValidatedToggleGroupControl = forwardRef(UnforwardedValidatedToggleGroupControl);
62
+ //# sourceMappingURL=toggle-group-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useId","useRef","ControlWithError","ToggleGroupControl","jsx","_jsx","jsxs","_jsxs","UnforwardedValidatedToggleGroupControl","required","customValidator","onChange","markWhenOptional","restProps","forwardedRef","validityTargetRef","valueRef","value","nameAttr","className","children","current","getValidityTarget","__nextHasNoMarginBottom","__next40pxDefaultSize","ref","type","checked","tabIndex","name","onFocus","e","target","previousElementSibling","querySelector","focus","ValidatedToggleGroupControl"],"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\tcustomValidator,\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\tcustomValidator={ () => {\n\t\t\t\t\treturn customValidator?.( valueRef.current );\n\t\t\t\t} }\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":"AAAA;AACA;AACA;AACA,SAASA,UAAU,EAAEC,KAAK,EAAEC,MAAM,QAAQ,oBAAoB;;AAE9D;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,SAASC,kBAAkB,QAAQ,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKhE,MAAMC,sCAAsC,GAAGA,CAC9C;EACCC,QAAQ;EACRC,eAAe;EACfC,QAAQ;EACRC,gBAAgB;EAChB,GAAGC;AAK0B,CAAC,EAC/BC,YAAoD,KAChD;EACJ,MAAMC,iBAAiB,GAAGd,MAAM,CAAsB,IAAK,CAAC;EAC5D,MAAMe,QAAQ,GAAGf,MAAM,CAAWY,SAAS,CAACI,KAAM,CAAC;EAEnD,MAAMC,QAAQ,GAAGlB,KAAK,CAAC,CAAC;EAExB,oBACCO,KAAA;IAAKY,SAAS,EAAC,2DAA2D;IAAAC,QAAA,gBACzEf,IAAA,CAACH,gBAAgB;MAChBO,QAAQ,EAAGA,QAAU;MACrBG,gBAAgB,EAAGA,gBAAkB;MACrCF,eAAe,EAAGA,CAAA,KAAM;QACvB,OAAOA,eAAe,GAAIM,QAAQ,CAACK,OAAQ,CAAC;MAC7C,CAAG;MACHC,iBAAiB,EAAGA,CAAA,KAAMP,iBAAiB,CAACM,OAAS;MAAAD,QAAA,eAErDf,IAAA,CAACF,kBAAkB;QAClBoB,uBAAuB;QACvBC,qBAAqB;QACrBC,GAAG,EAAGX;QACN;QACA;QAAA;QACAH,QAAQ,EAAKM,KAAK,IAAM;UACvBD,QAAQ,CAACK,OAAO,GAAGJ,KAAK;UACxBN,QAAQ,GAAIM,KAAM,CAAC;QACpB,CAAG;QAAA,GACEJ;MAAS,CACd;IAAC,CACe,CAAC,eACnBR,IAAA;MACCc,SAAS,EAAC,8CAA8C;MACxDO,IAAI,EAAC,OAAO;MACZD,GAAG,EAAGV,iBAAmB;MACzBN,QAAQ,EAAGA,QAAU;MACrBkB,OAAO,EAAGd,SAAS,CAACI,KAAK,KAAK,IAAM;MACpCW,QAAQ,EAAG,CAAC;MACZ;MAAA;MACAC,IAAI,EAAGX,QAAU;MACjBP,QAAQ,EAAGA,CAAA,KAAM,CAAC,CAAG;MACrBmB,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;AAED,OAAO,MAAMC,2BAA2B,GAAGrC,UAAU,CACpDS,sCACD,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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 * A function that returns a custom validity message when applicable. This error message will be applied to the\n\t * underlying element using the native [`setCustomValidity()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity).\n\t * This means the custom validator will be run _in addition_ to any other HTML attribute-based validation, and\n\t * will be prioritized over any existing validity messages dictated by the HTML attributes.\n\t * An empty string or `undefined` return value will clear any existing custom validity message.\n\t *\n\t * Make sure you don't programatically pass a value (such as an initial value) to the control component\n\t * that fails this validator, because the validator will only run for user-initiated changes.\n\t *\n\t * Always prefer using standard HTML attributes like `required` and `min`/`max` over custom validators\n\t * when possible, as they are simpler and have localized error messages built in.\n\t */\n\t// TODO: Technically, we could add an optional `customValidity` string prop so the consumer can set\n\t// an error message at any point in time. We should wait until we have a use case though.\n\tcustomValidator?: ( currentValue: V ) => string | void;\n};\n"],"mappings":"","ignoreList":[]}