@canonical/react-ds-global-form 0.47.0 → 0.48.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 (435) hide show
  1. package/README.md +5 -6
  2. package/dist/esm/density.css +23 -28
  3. package/dist/esm/index.css +28 -13
  4. package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/ColorField.js +2 -2
  5. package/dist/esm/lib/_work_in_progress/component/ColorField/ColorField.js.map +1 -0
  6. package/dist/esm/lib/_work_in_progress/component/ColorField/index.js.map +1 -0
  7. package/dist/esm/lib/_work_in_progress/component/ColorField/types.js.map +1 -0
  8. package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/ComboboxField.js +2 -2
  9. package/dist/esm/lib/_work_in_progress/component/ComboboxField/ComboboxField.js.map +1 -0
  10. package/dist/esm/lib/_work_in_progress/component/ComboboxField/index.js.map +1 -0
  11. package/dist/esm/lib/_work_in_progress/component/ComboboxField/types.js.map +1 -0
  12. package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/RatingField.js +2 -2
  13. package/dist/esm/lib/_work_in_progress/component/RatingField/RatingField.js.map +1 -0
  14. package/dist/esm/lib/_work_in_progress/component/RatingField/index.js.map +1 -0
  15. package/dist/esm/lib/_work_in_progress/component/RatingField/types.js.map +1 -0
  16. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.js.map +1 -0
  17. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/index.js.map +1 -0
  18. package/dist/esm/lib/_work_in_progress/subcomponent/ColorInput/types.js.map +1 -0
  19. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.js.map +1 -0
  20. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js +198 -0
  21. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.js.map +1 -0
  22. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js +120 -0
  23. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.js.map +1 -0
  24. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.js +16 -4
  25. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.js.map +1 -0
  26. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.js.map +1 -0
  27. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.js.map +1 -0
  28. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.js +2 -2
  29. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +1 -0
  30. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.js.map +1 -0
  31. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/styles.css +3 -0
  32. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.js.map +1 -0
  33. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.js.map +1 -0
  34. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/constants.js.map +1 -0
  35. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/index.js.map +1 -0
  36. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.js +1 -0
  37. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/messages.js.map +1 -0
  38. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/types.js.map +1 -0
  39. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.js.map +1 -0
  40. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +1 -0
  41. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.js.map +1 -0
  42. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js +7 -0
  43. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.js.map +1 -0
  44. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js +6 -0
  45. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.js.map +1 -0
  46. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js +10 -0
  47. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.js.map +1 -0
  48. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js +25 -0
  49. package/dist/esm/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.js.map +1 -0
  50. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.js.map +1 -0
  51. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/index.js.map +1 -0
  52. package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/styles.css +7 -7
  53. package/dist/esm/lib/_work_in_progress/subcomponent/RatingInput/types.js.map +1 -0
  54. package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js +3 -1
  55. package/dist/esm/lib/common/Wrapper/InvisibleWrapper.js.map +1 -1
  56. package/dist/esm/lib/common/Wrapper/ToggleWrapper.css +0 -6
  57. package/dist/esm/lib/common/Wrapper/ToggleWrapper.js +2 -1
  58. package/dist/esm/lib/common/Wrapper/ToggleWrapper.js.map +1 -1
  59. package/dist/esm/lib/common/Wrapper/Wrapper.js +10 -6
  60. package/dist/esm/lib/common/Wrapper/Wrapper.js.map +1 -1
  61. package/dist/esm/lib/common/Wrapper/createMiddleware.js +70 -0
  62. package/dist/esm/lib/common/Wrapper/createMiddleware.js.map +1 -0
  63. package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js +2 -2
  64. package/dist/esm/lib/common/Wrapper/hooks/useFieldWrapper.js.map +1 -1
  65. package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js +17 -12
  66. package/dist/esm/lib/common/Wrapper/withConditionalDisplay.js.map +1 -1
  67. package/dist/esm/lib/common/Wrapper/withWrapper.js +16 -10
  68. package/dist/esm/lib/common/Wrapper/withWrapper.js.map +1 -1
  69. package/dist/esm/lib/component/ChoicesField/Choices.js +2 -2
  70. package/dist/esm/lib/component/ChoicesField/Choices.js.map +1 -1
  71. package/dist/esm/lib/component/ChoicesField/ChoicesField.js +3 -2
  72. package/dist/esm/lib/component/ChoicesField/ChoicesField.js.map +1 -1
  73. package/dist/esm/lib/component/ChoicesField/styles.css +3 -65
  74. package/dist/esm/lib/component/DateTimeField/DateTimeField.js +2 -1
  75. package/dist/esm/lib/component/DateTimeField/DateTimeField.js.map +1 -1
  76. package/dist/esm/lib/component/FileUploadField/FileUploadField.js +45 -41
  77. package/dist/esm/lib/component/FileUploadField/FileUploadField.js.map +1 -1
  78. package/dist/esm/lib/component/FileUploadField/fileUploadRules.js +39 -0
  79. package/dist/esm/lib/component/FileUploadField/fileUploadRules.js.map +1 -0
  80. package/dist/esm/lib/component/FileUploadField/styles.css +30 -0
  81. package/dist/esm/lib/component/RichChoicesField/RichChoices.js +2 -2
  82. package/dist/esm/lib/component/RichChoicesField/RichChoices.js.map +1 -1
  83. package/dist/esm/lib/component/RichChoicesField/RichChoicesField.js +2 -2
  84. package/dist/esm/lib/component/index.js +5 -4
  85. package/dist/esm/lib/component/index.js.map +1 -1
  86. package/dist/esm/lib/index.js.map +1 -1
  87. package/dist/esm/lib/pattern/Field/Field.js +3 -3
  88. package/dist/esm/lib/pattern/Field/Field.js.map +1 -1
  89. package/dist/esm/lib/subcomponent/DateInput/styles.css +16 -0
  90. package/dist/esm/lib/subcomponent/DateTimeInput/styles.css +24 -7
  91. package/dist/esm/lib/subcomponent/Field/Description/Description.js +1 -3
  92. package/dist/esm/lib/subcomponent/Field/Description/Description.js.map +1 -1
  93. package/dist/esm/lib/subcomponent/Field/Description/styles.css +4 -0
  94. package/dist/esm/lib/subcomponent/Field/Error/Error.js +4 -4
  95. package/dist/esm/lib/subcomponent/Field/Error/Error.js.map +1 -1
  96. package/dist/esm/lib/subcomponent/Field/Error/styles.css +8 -0
  97. package/dist/esm/lib/subcomponent/Field/Label/styles.css +1 -0
  98. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js +119 -64
  99. package/dist/esm/lib/subcomponent/FileUploadInput/FileUploadInput.js.map +1 -1
  100. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js +52 -0
  101. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.js.map +1 -0
  102. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js +2 -0
  103. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/index.js.map +1 -0
  104. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js +2 -0
  105. package/dist/esm/lib/subcomponent/FileUploadInput/common/FileItem/types.js.map +1 -0
  106. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js +40 -0
  107. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.js.map +1 -0
  108. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js +2 -0
  109. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/index.js.map +1 -0
  110. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js +2 -0
  111. package/dist/esm/lib/subcomponent/FileUploadInput/common/Thumbnail/types.js.map +1 -0
  112. package/dist/esm/lib/subcomponent/FileUploadInput/constants.js +3 -0
  113. package/dist/esm/lib/subcomponent/FileUploadInput/constants.js.map +1 -0
  114. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js +3 -0
  115. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/index.js.map +1 -0
  116. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js +148 -0
  117. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useFileUploads.js.map +1 -0
  118. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js +22 -0
  119. package/dist/esm/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.js.map +1 -0
  120. package/dist/esm/lib/subcomponent/FileUploadInput/messages.js +25 -0
  121. package/dist/esm/lib/subcomponent/FileUploadInput/messages.js.map +1 -0
  122. package/dist/esm/lib/subcomponent/FileUploadInput/styles.css +255 -94
  123. package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js +21 -0
  124. package/dist/esm/lib/subcomponent/FileUploadInput/utils/formatFileSize.js.map +1 -0
  125. package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js +20 -0
  126. package/dist/esm/lib/subcomponent/FileUploadInput/utils/getFileMessage.js.map +1 -0
  127. package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js +4 -0
  128. package/dist/esm/lib/subcomponent/FileUploadInput/utils/index.js.map +1 -0
  129. package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js +26 -0
  130. package/dist/esm/lib/subcomponent/FileUploadInput/utils/matchesAccept.js.map +1 -0
  131. package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js +1 -1
  132. package/dist/esm/lib/subcomponent/NumberInput/NumberInput.js.map +1 -1
  133. package/dist/esm/lib/subcomponent/NumberInput/styles.css +17 -0
  134. package/dist/esm/lib/subcomponent/PasswordInput/styles.css +7 -1
  135. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js +8 -2
  136. package/dist/esm/lib/subcomponent/PhoneInput/PhoneInput.js.map +1 -1
  137. package/dist/esm/lib/subcomponent/RadioInput/styles.css +15 -13
  138. package/dist/esm/lib/subcomponent/TextInput/TextInput.js +3 -1
  139. package/dist/esm/lib/subcomponent/TextInput/TextInput.js.map +1 -1
  140. package/dist/esm/lib/subcomponent/index.js +5 -5
  141. package/dist/esm/lib/subcomponent/index.js.map +1 -1
  142. package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js +6 -4
  143. package/dist/esm/lib/utils/hooks/useFieldAriaProperties.js.map +1 -1
  144. package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js +3 -3
  145. package/dist/esm/lib/utils/hooks/useOptionAriaProperties.js.map +1 -1
  146. package/dist/esm/lib/utils/middleware/addRESTOptions.js +99 -39
  147. package/dist/esm/lib/utils/middleware/addRESTOptions.js.map +1 -1
  148. package/dist/esm/lib/utils/middleware/addRESTValidation.js +246 -32
  149. package/dist/esm/lib/utils/middleware/addRESTValidation.js.map +1 -1
  150. package/dist/esm/lib/utils/middleware/index.js +1 -0
  151. package/dist/esm/lib/utils/middleware/index.js.map +1 -1
  152. package/dist/esm/testing/expectNoAxeViolations.js +30 -0
  153. package/dist/esm/testing/expectNoAxeViolations.js.map +1 -0
  154. package/dist/types/lib/{component → _work_in_progress/component}/ColorField/ColorField.d.ts +7 -12
  155. package/dist/types/lib/_work_in_progress/component/ColorField/ColorField.d.ts.map +1 -0
  156. package/dist/types/lib/_work_in_progress/component/ColorField/index.d.ts.map +1 -0
  157. package/dist/types/lib/{component → _work_in_progress/component}/ColorField/types.d.ts +1 -1
  158. package/dist/types/lib/_work_in_progress/component/ColorField/types.d.ts.map +1 -0
  159. package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts +53 -0
  160. package/dist/types/lib/_work_in_progress/component/ComboboxField/ComboboxField.d.ts.map +1 -0
  161. package/dist/types/lib/_work_in_progress/component/ComboboxField/index.d.ts.map +1 -0
  162. package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/types.d.ts +1 -1
  163. package/dist/types/lib/_work_in_progress/component/ComboboxField/types.d.ts.map +1 -0
  164. package/dist/types/lib/{component → _work_in_progress/component}/RatingField/RatingField.d.ts +7 -12
  165. package/dist/types/lib/_work_in_progress/component/RatingField/RatingField.d.ts.map +1 -0
  166. package/dist/types/lib/_work_in_progress/component/RatingField/index.d.ts.map +1 -0
  167. package/dist/types/lib/{component → _work_in_progress/component}/RatingField/types.d.ts +1 -1
  168. package/dist/types/lib/_work_in_progress/component/RatingField/types.d.ts.map +1 -0
  169. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.d.ts.map +1 -0
  170. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/index.d.ts.map +1 -0
  171. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.d.ts +1 -1
  172. package/dist/types/lib/_work_in_progress/subcomponent/ColorInput/types.d.ts.map +1 -0
  173. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.d.ts +13 -5
  174. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +1 -0
  175. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts +24 -0
  176. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +1 -0
  177. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/SingleCombobox.d.ts +19 -4
  178. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +1 -0
  179. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/List.d.ts +1 -1
  180. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/List.d.ts.map +1 -0
  181. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/index.d.ts.map +1 -0
  182. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.d.ts +2 -1
  183. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/List/types.d.ts.map +1 -0
  184. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/ResetButton.d.ts +1 -1
  185. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +1 -0
  186. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +1 -0
  187. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.d.ts +1 -0
  188. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +1 -0
  189. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/common/index.d.ts.map +1 -0
  190. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/constants.d.ts.map +1 -0
  191. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/index.d.ts.map +1 -0
  192. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/messages.d.ts +1 -0
  193. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/messages.d.ts.map +1 -0
  194. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts +52 -0
  195. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/types.d.ts.map +1 -0
  196. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +4 -0
  197. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +1 -0
  198. package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.d.ts +1 -1
  199. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +1 -0
  200. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts +4 -0
  201. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +1 -0
  202. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts +7 -0
  203. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/index.d.ts.map +1 -0
  204. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts +4 -0
  205. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/isPromise.d.ts.map +1 -0
  206. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts +8 -0
  207. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/settleLookup.d.ts.map +1 -0
  208. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts +13 -0
  209. package/dist/types/lib/_work_in_progress/subcomponent/ComboboxInput/utils/stopPageMovesAtEnds.d.ts.map +1 -0
  210. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/RatingInput.d.ts.map +1 -0
  211. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/index.d.ts.map +1 -0
  212. package/dist/types/lib/_work_in_progress/subcomponent/RatingInput/types.d.ts.map +1 -0
  213. package/dist/types/lib/common/Wrapper/InvisibleWrapper.d.ts.map +1 -1
  214. package/dist/types/lib/common/Wrapper/ToggleWrapper.d.ts.map +1 -1
  215. package/dist/types/lib/common/Wrapper/Wrapper.d.ts +1 -1
  216. package/dist/types/lib/common/Wrapper/Wrapper.d.ts.map +1 -1
  217. package/dist/types/lib/common/Wrapper/createMiddleware.d.ts +43 -0
  218. package/dist/types/lib/common/Wrapper/createMiddleware.d.ts.map +1 -0
  219. package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts +2 -0
  220. package/dist/types/lib/common/Wrapper/hooks/useFieldWrapper.d.ts.map +1 -1
  221. package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts +9 -3
  222. package/dist/types/lib/common/Wrapper/withConditionalDisplay.d.ts.map +1 -1
  223. package/dist/types/lib/common/Wrapper/withWrapper.d.ts +3 -5
  224. package/dist/types/lib/common/Wrapper/withWrapper.d.ts.map +1 -1
  225. package/dist/types/lib/common/types.d.ts +19 -7
  226. package/dist/types/lib/common/types.d.ts.map +1 -1
  227. package/dist/types/lib/component/ChoicesField/Choices.d.ts +1 -1
  228. package/dist/types/lib/component/ChoicesField/Choices.d.ts.map +1 -1
  229. package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts +9 -13
  230. package/dist/types/lib/component/ChoicesField/ChoicesField.d.ts.map +1 -1
  231. package/dist/types/lib/component/ChoicesField/types.d.ts +2 -2
  232. package/dist/types/lib/component/ChoicesField/types.d.ts.map +1 -1
  233. package/dist/types/lib/component/DateField/DateField.d.ts +6 -11
  234. package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts +7 -11
  235. package/dist/types/lib/component/DateTimeField/DateTimeField.d.ts.map +1 -1
  236. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts +299 -19
  237. package/dist/types/lib/component/FileUploadField/FileUploadField.d.ts.map +1 -1
  238. package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts +24 -0
  239. package/dist/types/lib/component/FileUploadField/fileUploadRules.d.ts.map +1 -0
  240. package/dist/types/lib/component/HiddenField/HiddenField.d.ts +6 -11
  241. package/dist/types/lib/component/NumberField/NumberField.d.ts +6 -11
  242. package/dist/types/lib/component/PasswordField/PasswordField.d.ts +6 -11
  243. package/dist/types/lib/component/PhoneField/PhoneField.d.ts +7 -11
  244. package/dist/types/lib/component/RangeField/RangeField.d.ts +6 -11
  245. package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts +1 -1
  246. package/dist/types/lib/component/RichChoicesField/RichChoices.d.ts.map +1 -1
  247. package/dist/types/lib/component/RichChoicesField/RichChoicesField.d.ts +8 -13
  248. package/dist/types/lib/component/RichChoicesField/types.d.ts +2 -2
  249. package/dist/types/lib/component/RichChoicesField/types.d.ts.map +1 -1
  250. package/dist/types/lib/component/SelectField/SelectField.d.ts +6 -11
  251. package/dist/types/lib/component/TextField/TextField.d.ts +6 -11
  252. package/dist/types/lib/component/TextareaField/TextareaField.d.ts +6 -11
  253. package/dist/types/lib/component/TimeField/TimeField.d.ts +6 -11
  254. package/dist/types/lib/component/index.d.ts +3 -3
  255. package/dist/types/lib/component/index.d.ts.map +1 -1
  256. package/dist/types/lib/index.d.ts +1 -1
  257. package/dist/types/lib/index.d.ts.map +1 -1
  258. package/dist/types/lib/pattern/Field/types.d.ts +4 -4
  259. package/dist/types/lib/pattern/Field/types.d.ts.map +1 -1
  260. package/dist/types/lib/subcomponent/Field/Description/Description.d.ts.map +1 -1
  261. package/dist/types/lib/subcomponent/Field/Error/Error.d.ts.map +1 -1
  262. package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts +25 -4
  263. package/dist/types/lib/subcomponent/FileUploadInput/FileUploadInput.d.ts.map +1 -1
  264. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts +15 -0
  265. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/FileItem.d.ts.map +1 -0
  266. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts +3 -0
  267. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/index.d.ts.map +1 -0
  268. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts +28 -0
  269. package/dist/types/lib/subcomponent/FileUploadInput/common/FileItem/types.d.ts.map +1 -0
  270. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts +14 -0
  271. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/Thumbnail.d.ts.map +1 -0
  272. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts +3 -0
  273. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/index.d.ts.map +1 -0
  274. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts +9 -0
  275. package/dist/types/lib/subcomponent/FileUploadInput/common/Thumbnail/types.d.ts.map +1 -0
  276. package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts +3 -0
  277. package/dist/types/lib/subcomponent/FileUploadInput/constants.d.ts.map +1 -0
  278. package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts +3 -0
  279. package/dist/types/lib/subcomponent/FileUploadInput/hooks/index.d.ts.map +1 -0
  280. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts +33 -0
  281. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useFileUploads.d.ts.map +1 -0
  282. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts +8 -0
  283. package/dist/types/lib/subcomponent/FileUploadInput/hooks/useObjectUrl.d.ts.map +1 -0
  284. package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts +1 -1
  285. package/dist/types/lib/subcomponent/FileUploadInput/index.d.ts.map +1 -1
  286. package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts +4 -0
  287. package/dist/types/lib/subcomponent/FileUploadInput/messages.d.ts.map +1 -0
  288. package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts +165 -8
  289. package/dist/types/lib/subcomponent/FileUploadInput/types.d.ts.map +1 -1
  290. package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts +7 -0
  291. package/dist/types/lib/subcomponent/FileUploadInput/utils/formatFileSize.d.ts.map +1 -0
  292. package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts +14 -0
  293. package/dist/types/lib/subcomponent/FileUploadInput/utils/getFileMessage.d.ts.map +1 -0
  294. package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts +5 -0
  295. package/dist/types/lib/subcomponent/FileUploadInput/utils/index.d.ts.map +1 -0
  296. package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts +10 -0
  297. package/dist/types/lib/subcomponent/FileUploadInput/utils/matchesAccept.d.ts.map +1 -0
  298. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts +12 -0
  299. package/dist/types/lib/subcomponent/PhoneInput/PhoneInput.d.ts.map +1 -1
  300. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts +11 -2
  301. package/dist/types/lib/subcomponent/PhoneInput/types.d.ts.map +1 -1
  302. package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts +2 -0
  303. package/dist/types/lib/subcomponent/TextInput/TextInput.d.ts.map +1 -1
  304. package/dist/types/lib/subcomponent/index.d.ts +7 -7
  305. package/dist/types/lib/subcomponent/index.d.ts.map +1 -1
  306. package/dist/types/lib/subcomponent/types.d.ts +6 -0
  307. package/dist/types/lib/subcomponent/types.d.ts.map +1 -1
  308. package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts +2 -1
  309. package/dist/types/lib/utils/hooks/useFieldAriaProperties.d.ts.map +1 -1
  310. package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts +3 -2
  311. package/dist/types/lib/utils/hooks/useOptionAriaProperties.d.ts.map +1 -1
  312. package/dist/types/lib/utils/middleware/addRESTOptions.d.ts +37 -4
  313. package/dist/types/lib/utils/middleware/addRESTOptions.d.ts.map +1 -1
  314. package/dist/types/lib/utils/middleware/addRESTValidation.d.ts +38 -3
  315. package/dist/types/lib/utils/middleware/addRESTValidation.d.ts.map +1 -1
  316. package/dist/types/lib/utils/middleware/index.d.ts +2 -0
  317. package/dist/types/lib/utils/middleware/index.d.ts.map +1 -1
  318. package/dist/types/testing/expectNoAxeViolations.d.ts +10 -0
  319. package/dist/types/testing/expectNoAxeViolations.d.ts.map +1 -0
  320. package/package.json +18 -17
  321. package/dist/esm/lib/component/ColorField/ColorField.js.map +0 -1
  322. package/dist/esm/lib/component/ColorField/index.js.map +0 -1
  323. package/dist/esm/lib/component/ColorField/types.js.map +0 -1
  324. package/dist/esm/lib/component/ComboboxField/ComboboxField.js.map +0 -1
  325. package/dist/esm/lib/component/ComboboxField/index.js.map +0 -1
  326. package/dist/esm/lib/component/ComboboxField/types.js.map +0 -1
  327. package/dist/esm/lib/component/RatingField/RatingField.js.map +0 -1
  328. package/dist/esm/lib/component/RatingField/index.js.map +0 -1
  329. package/dist/esm/lib/component/RatingField/types.js.map +0 -1
  330. package/dist/esm/lib/subcomponent/ColorInput/ColorInput.js.map +0 -1
  331. package/dist/esm/lib/subcomponent/ColorInput/index.js.map +0 -1
  332. package/dist/esm/lib/subcomponent/ColorInput/types.js.map +0 -1
  333. package/dist/esm/lib/subcomponent/ComboboxInput/ComboboxInput.js.map +0 -1
  334. package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js +0 -84
  335. package/dist/esm/lib/subcomponent/ComboboxInput/MultipleCombobox.js.map +0 -1
  336. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js +0 -67
  337. package/dist/esm/lib/subcomponent/ComboboxInput/SingleCombobox.js.map +0 -1
  338. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/List.js.map +0 -1
  339. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/index.js.map +0 -1
  340. package/dist/esm/lib/subcomponent/ComboboxInput/common/List/types.js.map +0 -1
  341. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.js.map +0 -1
  342. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/index.js.map +0 -1
  343. package/dist/esm/lib/subcomponent/ComboboxInput/common/ResetButton/types.js.map +0 -1
  344. package/dist/esm/lib/subcomponent/ComboboxInput/common/index.js.map +0 -1
  345. package/dist/esm/lib/subcomponent/ComboboxInput/constants.js.map +0 -1
  346. package/dist/esm/lib/subcomponent/ComboboxInput/index.js.map +0 -1
  347. package/dist/esm/lib/subcomponent/ComboboxInput/messages.js.map +0 -1
  348. package/dist/esm/lib/subcomponent/ComboboxInput/types.js.map +0 -1
  349. package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertItemToString.js.map +0 -1
  350. package/dist/esm/lib/subcomponent/ComboboxInput/utils/convertValueToItem.js.map +0 -1
  351. package/dist/esm/lib/subcomponent/ComboboxInput/utils/filterItems.js.map +0 -1
  352. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js +0 -4
  353. package/dist/esm/lib/subcomponent/ComboboxInput/utils/index.js.map +0 -1
  354. package/dist/esm/lib/subcomponent/RatingInput/RatingInput.js.map +0 -1
  355. package/dist/esm/lib/subcomponent/RatingInput/index.js.map +0 -1
  356. package/dist/esm/lib/subcomponent/RatingInput/types.js.map +0 -1
  357. package/dist/types/lib/component/ColorField/ColorField.d.ts.map +0 -1
  358. package/dist/types/lib/component/ColorField/index.d.ts.map +0 -1
  359. package/dist/types/lib/component/ColorField/types.d.ts.map +0 -1
  360. package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts +0 -56
  361. package/dist/types/lib/component/ComboboxField/ComboboxField.d.ts.map +0 -1
  362. package/dist/types/lib/component/ComboboxField/index.d.ts.map +0 -1
  363. package/dist/types/lib/component/ComboboxField/types.d.ts.map +0 -1
  364. package/dist/types/lib/component/RatingField/RatingField.d.ts.map +0 -1
  365. package/dist/types/lib/component/RatingField/index.d.ts.map +0 -1
  366. package/dist/types/lib/component/RatingField/types.d.ts.map +0 -1
  367. package/dist/types/lib/subcomponent/ColorInput/ColorInput.d.ts.map +0 -1
  368. package/dist/types/lib/subcomponent/ColorInput/index.d.ts.map +0 -1
  369. package/dist/types/lib/subcomponent/ColorInput/types.d.ts.map +0 -1
  370. package/dist/types/lib/subcomponent/ComboboxInput/ComboboxInput.d.ts.map +0 -1
  371. package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts +0 -16
  372. package/dist/types/lib/subcomponent/ComboboxInput/MultipleCombobox.d.ts.map +0 -1
  373. package/dist/types/lib/subcomponent/ComboboxInput/SingleCombobox.d.ts.map +0 -1
  374. package/dist/types/lib/subcomponent/ComboboxInput/common/List/List.d.ts.map +0 -1
  375. package/dist/types/lib/subcomponent/ComboboxInput/common/List/index.d.ts.map +0 -1
  376. package/dist/types/lib/subcomponent/ComboboxInput/common/List/types.d.ts.map +0 -1
  377. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/ResetButton.d.ts.map +0 -1
  378. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/index.d.ts.map +0 -1
  379. package/dist/types/lib/subcomponent/ComboboxInput/common/ResetButton/types.d.ts.map +0 -1
  380. package/dist/types/lib/subcomponent/ComboboxInput/common/index.d.ts.map +0 -1
  381. package/dist/types/lib/subcomponent/ComboboxInput/constants.d.ts.map +0 -1
  382. package/dist/types/lib/subcomponent/ComboboxInput/index.d.ts.map +0 -1
  383. package/dist/types/lib/subcomponent/ComboboxInput/messages.d.ts.map +0 -1
  384. package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts +0 -27
  385. package/dist/types/lib/subcomponent/ComboboxInput/types.d.ts.map +0 -1
  386. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts +0 -4
  387. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertItemToString.d.ts.map +0 -1
  388. package/dist/types/lib/subcomponent/ComboboxInput/utils/convertValueToItem.d.ts.map +0 -1
  389. package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts +0 -4
  390. package/dist/types/lib/subcomponent/ComboboxInput/utils/filterItems.d.ts.map +0 -1
  391. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts +0 -4
  392. package/dist/types/lib/subcomponent/ComboboxInput/utils/index.d.ts.map +0 -1
  393. package/dist/types/lib/subcomponent/RatingInput/RatingInput.d.ts.map +0 -1
  394. package/dist/types/lib/subcomponent/RatingInput/index.d.ts.map +0 -1
  395. package/dist/types/lib/subcomponent/RatingInput/types.d.ts.map +0 -1
  396. /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/index.js +0 -0
  397. /package/dist/esm/lib/{component → _work_in_progress/component}/ColorField/types.js +0 -0
  398. /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/index.js +0 -0
  399. /package/dist/esm/lib/{component → _work_in_progress/component}/ComboboxField/types.js +0 -0
  400. /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/index.js +0 -0
  401. /package/dist/esm/lib/{component → _work_in_progress/component}/RatingField/types.js +0 -0
  402. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.js +0 -0
  403. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.js +0 -0
  404. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/styles.css +0 -0
  405. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/types.js +0 -0
  406. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/ComboboxInput.js +0 -0
  407. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.js +0 -0
  408. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/styles.css +0 -0
  409. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/types.js +0 -0
  410. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.js +0 -0
  411. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/types.js +0 -0
  412. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.js +0 -0
  413. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.js +0 -0
  414. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.js +0 -0
  415. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/styles.css +0 -0
  416. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/types.js +0 -0
  417. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertItemToString.js +0 -0
  418. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/convertValueToItem.js +0 -0
  419. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/utils/filterItems.js +0 -0
  420. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.js +0 -0
  421. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.js +0 -0
  422. /package/dist/esm/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.js +0 -0
  423. /package/dist/types/lib/{component → _work_in_progress/component}/ColorField/index.d.ts +0 -0
  424. /package/dist/types/lib/{component → _work_in_progress/component}/ComboboxField/index.d.ts +0 -0
  425. /package/dist/types/lib/{component → _work_in_progress/component}/RatingField/index.d.ts +0 -0
  426. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/ColorInput.d.ts +0 -0
  427. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ColorInput/index.d.ts +0 -0
  428. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/List/index.d.ts +0 -0
  429. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/ResetButton/index.d.ts +0 -0
  430. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/common/index.d.ts +0 -0
  431. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/constants.d.ts +0 -0
  432. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/ComboboxInput/index.d.ts +0 -0
  433. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/RatingInput.d.ts +0 -0
  434. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/index.d.ts +0 -0
  435. /package/dist/types/lib/{subcomponent → _work_in_progress/subcomponent}/RatingInput/types.d.ts +0 -0
@@ -1,38 +1,252 @@
1
- import { debounce } from "@canonical/ds-utils";
2
- import { createElement, useCallback, useEffect } from "react";
3
- import { useFormContext } from "react-hook-form";
4
- function addRESTFieldValidation(url, options = {}) {
5
- const { method = "POST", headers = { "Content-Type": "application/json" }, bodyFormatter = (value) => ({ value }), errorExtractor = async () => "Validation failed", minLength = 3, debounceWait = 300, } = options;
6
- return (WrappedComponent) => {
7
- return function ExtendedComponent(props) {
8
- const { name } = props;
9
- const { setError, clearErrors, watch } = useFormContext();
10
- const value = watch(name);
11
- const debouncedFetch = useCallback(debounce(async (val) => {
12
- const response = await fetch(url, {
13
- method,
14
- headers,
15
- body: JSON.stringify(bodyFormatter(val)),
16
- });
17
- if (!response.ok) {
18
- const errorMessage = await errorExtractor(response);
19
- setError(name, { type: "manual", message: errorMessage });
20
- }
21
- else {
22
- clearErrors(name);
1
+ import { createElement, useEffect, useEffectEvent, useRef, } from "react";
2
+ import { useFormContext, useWatch, } from "react-hook-form";
3
+ import createMiddleware, {} from "../../common/Wrapper/createMiddleware.js";
4
+ /**
5
+ * The error type the middleware sets, and the name of the `validate` rule it
6
+ * registers, so it only ever clears its own error.
7
+ */
8
+ const REST_VALIDATION_ERROR_TYPE = "restValidation";
9
+ /** The message shown when the endpoint rejects a value without a readable one. */
10
+ const DEFAULT_ERROR_MESSAGE = "Validation failed";
11
+ const VALID = { kind: "valid" };
12
+ const NO_ANSWER = { kind: "none" };
13
+ /** Reads the message of an error set by a REST check, if it is one. */
14
+ const readRESTMessage = (error) => error?.type === REST_VALIDATION_ERROR_TYPE ? error.message : undefined;
15
+ /** Whether a value is long enough, and a string, to be sent. */
16
+ const isCheckable = (value, minLength) => typeof value === "string" && value.length >= minLength;
17
+ /**
18
+ * Reads the message of a rejected value, falling back to the default when
19
+ * `errorExtractor` cannot read the response, so the value still shows as
20
+ * rejected.
21
+ */
22
+ const readErrorMessage = async (response, errorExtractor) => {
23
+ try {
24
+ return await errorExtractor(response);
25
+ }
26
+ catch {
27
+ return DEFAULT_ERROR_MESSAGE;
28
+ }
29
+ };
30
+ /**
31
+ * Sends the value and reads the endpoint's answer. A request that fails to
32
+ * complete says nothing about the value. An aborted request's answer is never
33
+ * read: `startCheck` settles the check before it aborts the request.
34
+ * @note Impure: performs a network request.
35
+ */
36
+ const requestAnswer = async (url, value, { method, headers, bodyFormatter, errorExtractor }, signal) => {
37
+ try {
38
+ const response = await fetch(url, {
39
+ method,
40
+ headers,
41
+ body: JSON.stringify(bodyFormatter(value)),
42
+ signal,
43
+ });
44
+ if (response.ok)
45
+ return VALID;
46
+ const message = await readErrorMessage(response, errorExtractor);
47
+ return { kind: "invalid", message };
48
+ }
49
+ catch {
50
+ return NO_ANSWER;
51
+ }
52
+ };
53
+ /**
54
+ * Starts a check that sends the value once `debounceWait` has passed, and
55
+ * gives up on the request after `timeout`.
56
+ * @note Impure: schedules timers and a network request.
57
+ */
58
+ const startCheck = (url, value, settings) => {
59
+ const controller = new AbortController();
60
+ let settle;
61
+ const answer = new Promise((resolve) => {
62
+ settle = resolve;
63
+ });
64
+ let requestTimer;
65
+ const cancel = () => {
66
+ clearTimeout(debounceTimer);
67
+ clearTimeout(requestTimer);
68
+ settle(NO_ANSWER);
69
+ controller.abort();
70
+ };
71
+ const debounceTimer = setTimeout(() => {
72
+ requestTimer = setTimeout(cancel, settings.timeout);
73
+ requestAnswer(url, value, settings, controller.signal).then((result) => {
74
+ clearTimeout(requestTimer);
75
+ settle(result);
76
+ });
77
+ }, settings.debounceWait);
78
+ return { url, value, answer, cancel };
79
+ };
80
+ /** Whether a `validate` rule's result lets the value through. */
81
+ const isPassing = (result) => result === true || result === undefined || result === null;
82
+ /**
83
+ * Runs two `validate` rules together and returns the first failure, so a
84
+ * second REST check on the field keeps the first one under the same name.
85
+ */
86
+ const combineRules = (first, second) => async (value, formValues) => {
87
+ const [firstResult, secondResult] = await Promise.all([
88
+ first(value, formValues),
89
+ second(value, formValues),
90
+ ]);
91
+ return isPassing(firstResult) ? secondResult : firstResult;
92
+ };
93
+ /**
94
+ * Adds a rule to the field's `validate` rules, keeping the rules it has. A
95
+ * single `validate` function stays under the `validate` name, the error type
96
+ * react-hook-form gives it. A `restValidation` rule already there, from
97
+ * another REST check on the field, runs together with the new one.
98
+ */
99
+ const addValidateRule = (registerProps, rule) => {
100
+ const validate = registerProps?.validate;
101
+ const rules = typeof validate === "function" ? { validate } : validate;
102
+ const previous = rules?.[REST_VALIDATION_ERROR_TYPE];
103
+ return {
104
+ ...registerProps,
105
+ validate: {
106
+ ...rules,
107
+ [REST_VALIDATION_ERROR_TYPE]: previous
108
+ ? combineRules(previous, rule)
109
+ : rule,
110
+ },
111
+ };
112
+ };
113
+ /** Builds the component that checks the value and owns the REST error. */
114
+ const buildRESTValidation = (WrappedComponent, useSettings) => {
115
+ function WithRESTValidation(props) {
116
+ const { name } = props;
117
+ const settings = useSettings();
118
+ const { url } = settings;
119
+ const { setError, clearErrors, getFieldState } = useFormContext();
120
+ const value = useWatch({ name });
121
+ const pending = useRef(null);
122
+ // The message this instance last gave, so a second REST check on the
123
+ // field cannot clear or keep the other one's message. A REST message left
124
+ // from before the field mounted is adopted, so it can still be cleared.
125
+ const ownMessage = useRef(readRESTMessage(getFieldState(name).error));
126
+ /** Reads the field's error message when this instance set it. */
127
+ const readOwnMessage = () => {
128
+ const message = readRESTMessage(getFieldState(name).error);
129
+ return message === ownMessage.current ? message : undefined;
130
+ };
131
+ /** Clears the field's error when this instance set it. */
132
+ const clearOwnError = () => {
133
+ if (readOwnMessage() !== undefined)
134
+ clearErrors(name);
135
+ ownMessage.current = undefined;
136
+ };
137
+ /** Sets the endpoint's rejection as the field's error. */
138
+ const setOwnError = (message) => {
139
+ ownMessage.current = message;
140
+ setError(name, { type: REST_VALIDATION_ERROR_TYPE, message });
141
+ };
142
+ /** Stops the pending check, if any. */
143
+ const cancelPending = () => {
144
+ pending.current?.cancel();
145
+ pending.current = null;
146
+ };
147
+ /**
148
+ * Resolves to the answer for a value, sharing the pending check when it is
149
+ * for the same value and URL, so typing and submitting send one request.
150
+ * A newer value cancels the previous check, so only the answer for the
151
+ * latest value is ever used. A check that got no answer is dropped, so the
152
+ * next one asks again.
153
+ */
154
+ const check = (checkUrl, checkValue) => {
155
+ const current = pending.current;
156
+ if (current?.url === checkUrl && current.value === checkValue) {
157
+ return current.answer;
158
+ }
159
+ cancelPending();
160
+ const next = startCheck(checkUrl, checkValue, settings);
161
+ pending.current = next;
162
+ next.answer.then((answer) => {
163
+ if (answer.kind === "none" && pending.current === next) {
164
+ pending.current = null;
23
165
  }
24
- }, debounceWait), []);
25
- useEffect(() => {
26
- if (value && value.length >= minLength) {
27
- debouncedFetch(value);
166
+ });
167
+ return next.answer;
168
+ };
169
+ /**
170
+ * The `validate` rule react-hook-form runs, on submit among others, so a
171
+ * value the endpoint rejected cannot be submitted. Without an answer it
172
+ * keeps the message this middleware last set.
173
+ */
174
+ const validateRemotely = async (fieldValue) => {
175
+ if (!isCheckable(fieldValue, settings.minLength))
176
+ return true;
177
+ const answer = await check(url, fieldValue);
178
+ if (answer.kind === "valid") {
179
+ ownMessage.current = undefined;
180
+ return true;
181
+ }
182
+ if (answer.kind === "invalid") {
183
+ ownMessage.current = answer.message;
184
+ return answer.message;
185
+ }
186
+ return readOwnMessage() || true;
187
+ };
188
+ const followValue = useEffectEvent((nextValue, nextUrl) => {
189
+ if (!isCheckable(nextValue, settings.minLength)) {
190
+ cancelPending();
191
+ clearOwnError();
192
+ return;
193
+ }
194
+ check(nextUrl, nextValue).then((answer) => {
195
+ if (answer.kind === "valid") {
196
+ clearOwnError();
28
197
  }
29
- else {
30
- clearErrors(name);
198
+ else if (answer.kind === "invalid") {
199
+ setOwnError(answer.message);
31
200
  }
32
- }, [value, debouncedFetch, name, clearErrors]);
33
- return createElement(WrappedComponent, props);
34
- };
35
- };
201
+ // A check without an answer leaves the field's error as it is.
202
+ });
203
+ });
204
+ useEffect(() => followValue(value, url), [value, url]);
205
+ useEffect(() => () => {
206
+ pending.current?.cancel();
207
+ pending.current = null;
208
+ }, []);
209
+ return createElement(WrappedComponent, {
210
+ ...props,
211
+ registerProps: addValidateRule(props.registerProps, validateRemotely),
212
+ });
213
+ }
214
+ return WithRESTValidation;
215
+ };
216
+ const configureRESTValidation = createMiddleware(buildRESTValidation);
217
+ /**
218
+ * Validates a field's value against a REST endpoint once the user stops
219
+ * typing, and sets the field's error when the endpoint rejects it.
220
+ *
221
+ * The check is also registered as the field's `restValidation` rule, so
222
+ * submitting re-checks the value and a rejected value blocks the submit. Each
223
+ * change cancels the pending timer and aborts the request in flight, so only
224
+ * the answer for the latest value can set or clear the error; unmounting the
225
+ * field does the same. A request that fails to complete keeps the previous
226
+ * message, and a request still unanswered after `timeout` is given up. It
227
+ * only clears the error it set, so an error from the field's own rules or
228
+ * another middleware stays in place. Two instances on one field each keep
229
+ * their own message, and submit runs both checks. The middleware can be
230
+ * created inline: the field keeps one instance.
231
+ *
232
+ * @param url - The endpoint validating the value.
233
+ * @param options - Request, debounce and error options.
234
+ * @returns A middleware for any field.
235
+ *
236
+ * `import { addRESTValidation } from "@canonical/react-ds-global-form";`
237
+ */
238
+ function addRESTFieldValidation(url, options = {}) {
239
+ const { method = "POST", headers = { "Content-Type": "application/json" }, bodyFormatter = (value) => ({ value }), errorExtractor = () => DEFAULT_ERROR_MESSAGE, minLength = 3, debounceWait = 300, timeout = 10000, } = options;
240
+ return configureRESTValidation({
241
+ url,
242
+ method,
243
+ headers,
244
+ bodyFormatter,
245
+ errorExtractor,
246
+ minLength,
247
+ debounceWait,
248
+ timeout,
249
+ });
36
250
  }
37
251
  export default addRESTFieldValidation;
38
252
  //# sourceMappingURL=addRESTValidation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"addRESTValidation.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAajD,SAAS,sBAAsB,CAC7B,GAAW,EACX,OAAO,GAAsB,EAAE;IAG/B,MAAM,EACJ,MAAM,GAAG,MAAM,EACf,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAChD,a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I,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;YAE/C,OAAO,aAAa,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"addRESTValidation.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/addRESTValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAIL,cAAc,EACd,QAAQ,GAET,MAAM,iBAAiB,CAAC;AAEzB,OAAO,gBAAgB,EAAE,EAGxB,MAAM,0CAA0C,CAAC;AAyBlD;;;GAGG;AACH,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAEpD,kFAAkF;AAClF,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAWlD,MAAM,KAAK,GAAW,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AACxC,MAAM,SAAS,GAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAiB3C,uEAAuE;AACvE,MAAM,eAAe,GAAG,CAAC,KAA6B,EAAsB,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,0BAA0B,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAEzE,gEAAgE;AAChE,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,SAAiB,EAAmB,EAAE,CACzE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,CAAC;AAEzD;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,KAAK,EAC5B,QAAkB,EAClB,cAAoD,EACnC,EAAE;IACnB,IAAI,CAAC;QACH,OAAO,MAAM,cAAc,CAAC,QAAQ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GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QAEvD,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;YACT,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YAC1B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;QACzB,CAAC,EACD,EAAE,CACH,CAAC;QAEF,OAAO,aAAa,CAAC,gBAAgB,EAAE;YACrC,GAAG,KAAK;YACR,aAAa,EAAE,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,gBAAgB,CAAC;SACtE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAS,sBAAsB,CAC7B,GAAW,EACX,OAAO,GAAsB,EAAE;IAE/B,MAAM,EACJ,MAAM,GAAG,MAAM,EACf,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAChD,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAC9C,cAAc,GAAG,GAAG,EAAE,CAAC,qBAAqB,EAC5C,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,GAAG,EAClB,OAAO,GAAG,KAAK,GAChB,GAAG,OAAO,CAAC;IACZ,OAAO,uBAAuB,CAAC;QAC7B,GAAG;QACH,MAAM;QACN,OAAO;QACP,aAAa;QACb,cAAc;QACd,SAAS;QACT,YAAY;QACZ,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,eAAe,sBAAsB,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { default as createMiddleware } from "../../common/Wrapper/createMiddleware.js";
1
2
  export { default as addRESTOptions } from "./addRESTOptions.js";
2
3
  export { default as addRESTValidation } from "./addRESTValidation.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/utils/middleware/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import axe from "axe-core";
2
+ import { expect } from "vitest";
3
+ /**
4
+ * The WCAG 2.x A and AA rules, and nothing a page-level or layout rule adds:
5
+ * a component renders a fragment, not a page with landmarks, and jsdom lays
6
+ * nothing out, so a contrast result here would be a guess.
7
+ */
8
+ const RULES = {
9
+ runOnly: {
10
+ type: "tag",
11
+ values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"],
12
+ },
13
+ rules: { "color-contrast": { enabled: false } },
14
+ };
15
+ /**
16
+ * Asserts that axe finds no violation in a rendered element, naming every
17
+ * rule it breaks and where, so a failure reads as the finding itself.
18
+ *
19
+ * Necessary evidence, not a conformance claim: axe checks what markup can
20
+ * prove, and says nothing of keyboard journeys or what a screen reader
21
+ * announces.
22
+ */
23
+ export default async function expectNoAxeViolations(element) {
24
+ const results = await axe.run(element, RULES);
25
+ expect(results.violations.map((violation) => ({
26
+ rule: violation.id,
27
+ targets: violation.nodes.map((node) => node.target.join(" ")),
28
+ }))).toEqual([]);
29
+ }
30
+ //# sourceMappingURL=expectNoAxeViolations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expectNoAxeViolations.js","sourceRoot":"","sources":["../../../src/testing/expectNoAxeViolations.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,KAAK,GAAmB;IAC5B,OAAO,EAAE;QACP,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;KACjE;IACD,KAAK,EAAE,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;CAChD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CACjD,OAAgB;IAEhB,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,MAAM,CACJ,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,SAAS,CAAC,EAAE;QAClB,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC9D,CAAC,CAAC,CACJ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAChB,CAAC"}
@@ -6,7 +6,7 @@ import type { ColorFieldProps } from "./types.js";
6
6
  *
7
7
  * @implements ds:global.component.color_field
8
8
  */
9
- declare const _default: (props: {
9
+ declare const _default: import("react").ComponentType<{
10
10
  id?: string;
11
11
  className?: string;
12
12
  style?: React.CSSProperties;
@@ -21,17 +21,14 @@ declare const _default: (props: {
21
21
  controlLabel?: string;
22
22
  labelPosition?: "before" | "after";
23
23
  isOptional?: boolean;
24
- requiredIndicator?: import("../../subcomponent/index.js").RequiredIndicator;
24
+ requiredIndicator?: import("../../../subcomponent/index.js").RequiredIndicator;
25
+ descriptionPosition?: "leading" | "trailing";
25
26
  nestedRegisterProps?: import("react-hook-form").RegisterOptions;
26
27
  unregisterOnUnmount?: boolean;
27
28
  mockLabel?: boolean;
28
- middleware?: (import("../../index.js").Middleware<ColorFieldProps>[] & import("../../index.js").Middleware<Omit<import("../../index.js").WrappedComponentProps<ColorFieldProps>, "Component"> & {
29
- condition?: import("../../index.js").Condition;
30
- }>[]) | undefined;
31
- WrapperComponent?: (import("react").ComponentType<import("../../index.js").WrapperProps<ColorFieldProps>> & import("react").ComponentType<import("../../index.js").WrapperProps<Omit<import("../../index.js").WrappedComponentProps<ColorFieldProps>, "Component"> & {
32
- condition?: import("../../index.js").Condition;
33
- }>>) | undefined;
34
- condition?: import("../../index.js").Condition;
29
+ errorSlot?: "payload" | "input";
30
+ middleware?: import("../../../index.js").Middleware<ColorFieldProps>[] | undefined;
31
+ WrapperComponent?: import("react").ComponentType<import("../../../index.js").WrapperProps<ColorFieldProps>> | undefined;
35
32
  value?: string;
36
33
  onChange?: (value: string) => void;
37
34
  disabled?: boolean;
@@ -39,8 +36,6 @@ declare const _default: (props: {
39
36
  showHexInput?: boolean;
40
37
  showCurrentColor?: boolean;
41
38
  hexFormats?: import("../../subcomponent/ColorInput/types.js").HexFormat[];
42
- }) => import("react").ReactElement<Omit<import("../../index.js").WrappedComponentProps<ColorFieldProps>, "Component"> & {
43
- condition?: import("../../index.js").Condition;
44
- }, string | import("react").JSXElementConstructor<any>> | null;
39
+ } & import("../../../index.js").ConditionalDisplayProps>;
45
40
  export default _default;
46
41
  //# sourceMappingURL=ColorField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorField.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/ColorField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { InputProps } from "../../common/types.js";
1
+ import type { InputProps } from "../../../common/types.js";
2
2
  import type { ColorInputProps } from "../../subcomponent/ColorInput/index.js";
3
3
  /** Props for the react-hook-form-bound Color field. */
4
4
  export type ColorFieldProps = InputProps<ColorInputProps>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ColorField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE9E,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { ComboboxFieldProps } from "./types.js";
2
+ /**
3
+ * ComboboxInput bound to react-hook-form (controlled), wrapped with field chrome.
4
+ * The single composite value is owned by the field; the presentational
5
+ * ComboboxInput decomposes it across its input/list/chips internally.
6
+ *
7
+ * `import { ComboboxField } from "@canonical/react-ds-global-form";`
8
+ *
9
+ * @implements ds:global.component.combobox_field
10
+ */
11
+ declare const _default: import("react").ComponentType<{
12
+ "aria-label"?: string | undefined;
13
+ "aria-required"?: ("false" | "true" | boolean) | undefined;
14
+ id?: string;
15
+ className?: string;
16
+ style?: React.CSSProperties;
17
+ options: import("../../../index.js").Option[];
18
+ name: string;
19
+ registerProps?: import("react-hook-form").RegisterOptions;
20
+ "aria-labelledby"?: string;
21
+ "aria-describedby"?: string;
22
+ "aria-errormessage"?: string;
23
+ "aria-invalid"?: boolean;
24
+ description?: string;
25
+ label?: string;
26
+ controlLabel?: string;
27
+ labelPosition?: "before" | "after";
28
+ isOptional?: boolean;
29
+ requiredIndicator?: import("../../../subcomponent/index.js").RequiredIndicator;
30
+ descriptionPosition?: "leading" | "trailing";
31
+ nestedRegisterProps?: import("react-hook-form").RegisterOptions;
32
+ unregisterOnUnmount?: boolean;
33
+ mockLabel?: boolean;
34
+ errorSlot?: "payload" | "input";
35
+ middleware?: import("../../../index.js").Middleware<ComboboxFieldProps>[] | undefined;
36
+ WrapperComponent?: import("react").ComponentType<import("../../../index.js").WrapperProps<ComboboxFieldProps>> | undefined;
37
+ value?: string | string[];
38
+ onChange?: (value: string | string[] | undefined) => void;
39
+ onBlur?: () => void;
40
+ disabled?: boolean;
41
+ placeholder?: string;
42
+ valueKey?: keyof import("../../../index.js").Option;
43
+ openOnReset?: boolean;
44
+ isMultiple?: boolean;
45
+ filterItems?: (options: import("../../../index.js").Option[], inputValue: string) => import("../../../index.js").Option[];
46
+ convertItemToString?: typeof import("../../subcomponent/ComboboxInput/utils/convertItemToString.js").default;
47
+ convertValueToItem?: import("../../subcomponent/ComboboxInput/types.js").ConvertValueToItem;
48
+ onInputValueChangeFactory?: (setItems: React.Dispatch<React.SetStateAction<import("../../../index.js").Option[]>>) => ({ inputValue }: {
49
+ inputValue: string;
50
+ }) => void;
51
+ } & import("../../../index.js").ConditionalDisplayProps>;
52
+ export default _default;
53
+ //# sourceMappingURL=ComboboxField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxField.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ComboboxField/ComboboxField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;GAQG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ComboboxField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { InputProps } from "../../common/types.js";
1
+ import type { InputProps } from "../../../common/types.js";
2
2
  import type { ComboboxInputProps } from "../../subcomponent/ComboboxInput/index.js";
3
3
  /** Props for the react-hook-form-bound Combobox field. */
4
4
  export type ComboboxFieldProps = InputProps<ComboboxInputProps>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/ComboboxField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAEpF,0DAA0D;AAC1D,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC"}
@@ -8,7 +8,7 @@ import type { RatingFieldProps } from "./types.js";
8
8
  *
9
9
  * @implements ds:global.component.rating_field
10
10
  */
11
- declare const _default: (props: {
11
+ declare const _default: import("react").ComponentType<{
12
12
  id?: string;
13
13
  className?: string;
14
14
  style?: React.CSSProperties;
@@ -23,17 +23,14 @@ declare const _default: (props: {
23
23
  controlLabel?: string;
24
24
  labelPosition?: "before" | "after";
25
25
  isOptional?: boolean;
26
- requiredIndicator?: import("../../subcomponent/index.js").RequiredIndicator;
26
+ requiredIndicator?: import("../../../subcomponent/index.js").RequiredIndicator;
27
+ descriptionPosition?: "leading" | "trailing";
27
28
  nestedRegisterProps?: import("react-hook-form").RegisterOptions;
28
29
  unregisterOnUnmount?: boolean;
29
30
  mockLabel?: boolean;
30
- middleware?: (import("../../index.js").Middleware<RatingFieldProps>[] & import("../../index.js").Middleware<Omit<import("../../index.js").WrappedComponentProps<RatingFieldProps>, "Component"> & {
31
- condition?: import("../../index.js").Condition;
32
- }>[]) | undefined;
33
- WrapperComponent?: (import("react").ComponentType<import("../../index.js").WrapperProps<RatingFieldProps>> & import("react").ComponentType<import("../../index.js").WrapperProps<Omit<import("../../index.js").WrappedComponentProps<RatingFieldProps>, "Component"> & {
34
- condition?: import("../../index.js").Condition;
35
- }>>) | undefined;
36
- condition?: import("../../index.js").Condition;
31
+ errorSlot?: "payload" | "input";
32
+ middleware?: import("../../../index.js").Middleware<RatingFieldProps>[] | undefined;
33
+ WrapperComponent?: import("react").ComponentType<import("../../../index.js").WrapperProps<RatingFieldProps>> | undefined;
37
34
  count?: import("../../subcomponent/RatingInput/types.js").RatingScale;
38
35
  allowHalf?: boolean;
39
36
  value?: number;
@@ -42,8 +39,6 @@ declare const _default: (props: {
42
39
  disabled?: boolean;
43
40
  "aria-label"?: string;
44
41
  formatStarLabel?: (value: number, count: number) => string;
45
- }) => import("react").ReactElement<Omit<import("../../index.js").WrappedComponentProps<RatingFieldProps>, "Component"> & {
46
- condition?: import("../../index.js").Condition;
47
- }, string | import("react").JSXElementConstructor<any>> | null;
42
+ } & import("../../../index.js").ConditionalDisplayProps>;
48
43
  export default _default;
49
44
  //# sourceMappingURL=RatingField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RatingField.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/RatingField/RatingField.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;GAQG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/RatingField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { InputProps } from "../../common/types.js";
1
+ import type { InputProps } from "../../../common/types.js";
2
2
  import type { RatingInputProps } from "../../subcomponent/RatingInput/index.js";
3
3
  /**
4
4
  * Props for the react-hook-form-bound Rating field (presentational + binding).
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/component/RatingField/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorInput.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/subcomponent/ColorInput/ColorInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAC7D,OAAO,cAAc,CAAC;AAuCtB;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,6HAYpB,eAAe,KAAG,KAAK,CAAC,YAiK1B,CAAC;eAEa,UAAU"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/subcomponent/ColorInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { BaseProps } from "../types.js";
1
+ import type { BaseProps } from "../../../subcomponent/types.js";
2
2
  export type HexFormat = "hex6" | "hex3" | "hex8";
3
3
  /** Props for the presentational Color input (no react-hook-form). */
4
4
  export type ColorInputProps = BaseProps & {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/subcomponent/ColorInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,oDAAoD;IACpD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB,yCAAyC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,8CAA8C;IAC9C,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B,CAAC"}
@@ -8,22 +8,30 @@ import "./styles.css";
8
8
  *
9
9
  * @implements ds:global.subcomponent.combobox_input
10
10
  */
11
- export declare const ComboboxInput: import("react").ForwardRefExoticComponent<import("../types.js").BaseProps & import("../types.js").OptionsProps & {
11
+ export declare const ComboboxInput: import("react").ForwardRefExoticComponent<import("../../../index.js").BaseProps & import("../../../index.js").OptionsProps & {
12
+ name?: string;
12
13
  disabled?: boolean;
13
14
  placeholder?: string;
14
- valueKey?: keyof import("../types.js").Option;
15
+ valueKey?: keyof import("../../../index.js").Option;
15
16
  openOnReset?: boolean;
16
17
  isMultiple?: boolean;
17
- filterItems?: (options: import("../types.js").Option[], inputValue: string) => import("../types.js").Option[];
18
+ filterItems?: (options: import("../../../index.js").Option[], inputValue: string) => import("../../../index.js").Option[];
18
19
  convertItemToString?: typeof import("./utils/convertItemToString.js").default;
19
- convertValueToItem?: typeof import("./utils/convertValueToItem.js").default;
20
- onInputValueChangeFactory?: (setItems: React.Dispatch<React.SetStateAction<import("../types.js").Option[]>>) => ({ inputValue }: {
20
+ convertValueToItem?: import("./types.js").ConvertValueToItem;
21
+ onInputValueChangeFactory?: (setItems: React.Dispatch<React.SetStateAction<import("../../../index.js").Option[]>>) => ({ inputValue }: {
21
22
  inputValue: string;
22
23
  }) => void;
23
24
  } & {
24
25
  value?: string | string[];
25
26
  onChange?: (value: string | string[] | undefined) => void;
26
27
  onBlur?: () => void;
28
+ } & {
29
+ "aria-describedby"?: string | undefined;
30
+ "aria-errormessage"?: string | undefined;
31
+ "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
32
+ "aria-label"?: string | undefined;
33
+ "aria-labelledby"?: string | undefined;
34
+ "aria-required"?: ("false" | "true" | boolean) | undefined;
27
35
  } & import("react").RefAttributes<HTMLInputElement>>;
28
36
  export default ComboboxInput;
29
37
  //# sourceMappingURL=ComboboxInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxInput.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/_work_in_progress/subcomponent/ComboboxInput/ComboboxInput.tsx"],"names":[],"mappings":"AAKA,OAAO,cAAc,CAAC;AAItB;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;oDAezB,CAAC;eAEa,aAAa"}