@sqrzro/ui 4.0.0-alpha.8 → 4.0.0-alpha.81

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 (309) hide show
  1. package/dist/components/buttons/ActionButton/index.d.ts +8 -6
  2. package/dist/components/buttons/ActionButton/index.js +5 -29
  3. package/dist/components/buttons/Button/index.d.ts +7 -6
  4. package/dist/components/buttons/Button/index.js +9 -19
  5. package/dist/components/collections/Collection/index.d.ts +9 -5
  6. package/dist/components/collections/Collection/index.js +14 -12
  7. package/dist/components/collections/DataTable/index.d.ts +14 -0
  8. package/dist/components/collections/DataTable/index.js +14 -0
  9. package/dist/components/collections/DefinitionList/index.d.ts +13 -0
  10. package/dist/components/collections/DefinitionList/index.js +13 -0
  11. package/dist/components/collections/EmptyMessage/index.d.ts +2 -2
  12. package/dist/components/collections/EmptyMessage/index.js +6 -4
  13. package/dist/components/collections/EmptyMessageAction/index.d.ts +2 -2
  14. package/dist/components/collections/EmptyMessageAction/index.js +3 -3
  15. package/dist/components/collections/List/index.d.ts +6 -3
  16. package/dist/components/collections/List/index.js +2 -2
  17. package/dist/components/collections/ListClientComponent/index.d.ts +7 -4
  18. package/dist/components/collections/ListClientComponent/index.js +8 -5
  19. package/dist/components/collections/ListItem/index.d.ts +10 -3
  20. package/dist/components/collections/ListItem/index.js +15 -23
  21. package/dist/components/collections/ListItemMenu/index.d.ts +8 -0
  22. package/dist/components/collections/ListItemMenu/index.js +7 -0
  23. package/dist/components/collections/ListItemMeta/index.d.ts +6 -4
  24. package/dist/components/collections/ListItemMeta/index.js +13 -17
  25. package/dist/components/collections/ListItemSecondary/index.d.ts +5 -3
  26. package/dist/components/collections/ListItemSecondary/index.js +12 -8
  27. package/dist/components/collections/Pagination/index.d.ts +1 -1
  28. package/dist/components/collections/Pagination/index.js +7 -8
  29. package/dist/components/collections/PaginationLink/index.d.ts +9 -0
  30. package/dist/components/collections/PaginationLink/index.js +9 -0
  31. package/dist/components/collections/Table/index.d.ts +3 -4
  32. package/dist/components/collections/Table/index.js +2 -8
  33. package/dist/components/collections/TableClientComponent/index.d.ts +7 -6
  34. package/dist/components/collections/TableClientComponent/index.js +12 -27
  35. package/dist/components/collections/TableRow/index.d.ts +13 -0
  36. package/dist/components/collections/TableRow/index.js +15 -0
  37. package/dist/components/collections/interfaces.d.ts +41 -34
  38. package/dist/components/collections/lang.js +1 -1
  39. package/dist/components/collections/utility/is-paginated.d.ts +1 -1
  40. package/dist/components/collections/utility/is-right-aligned.d.ts +3 -0
  41. package/dist/components/collections/utility/is-right-aligned.js +11 -0
  42. package/dist/components/collections/utility/render-cell.d.ts +5 -0
  43. package/dist/components/collections/utility/render-cell.js +33 -0
  44. package/dist/components/elements/Badge/index.d.ts +12 -0
  45. package/dist/components/elements/Badge/index.js +9 -0
  46. package/dist/components/elements/ContentLink/index.d.ts +4 -0
  47. package/dist/components/elements/ContentLink/index.js +7 -0
  48. package/dist/components/elements/InfoPanel/index.d.ts +13 -0
  49. package/dist/components/elements/InfoPanel/index.js +20 -0
  50. package/dist/components/{utility → elements}/Link/index.d.ts +3 -2
  51. package/dist/components/{utility → elements}/Link/index.js +10 -9
  52. package/dist/components/elements/Menu/index.d.ts +19 -0
  53. package/dist/components/elements/Menu/index.js +20 -0
  54. package/dist/components/elements/MenuItem/index.d.ts +9 -0
  55. package/dist/components/elements/MenuItem/index.js +14 -0
  56. package/dist/components/elements/Page/index.d.ts +19 -0
  57. package/dist/components/elements/Page/index.js +18 -0
  58. package/dist/components/elements/Reference/index.d.ts +9 -0
  59. package/dist/components/elements/Reference/index.js +16 -0
  60. package/dist/components/elements/Summary/index.d.ts +13 -0
  61. package/dist/components/elements/Summary/index.js +22 -0
  62. package/dist/components/errors/AppError/index.d.ts +19 -0
  63. package/dist/components/errors/AppError/index.js +9 -0
  64. package/dist/components/errors/AppForbiddenError/index.d.ts +7 -0
  65. package/dist/components/errors/AppForbiddenError/index.js +6 -0
  66. package/dist/components/errors/AppNotFoundError/index.d.ts +7 -0
  67. package/dist/components/errors/AppNotFoundError/index.js +6 -0
  68. package/dist/components/errors/AppServerError/index.d.ts +8 -0
  69. package/dist/components/errors/AppServerError/index.js +17 -0
  70. package/dist/components/index.d.ts +35 -6
  71. package/dist/components/index.js +17 -3
  72. package/dist/components/modals/ConfirmModal/index.d.ts +6 -4
  73. package/dist/components/modals/ConfirmModal/index.js +4 -4
  74. package/dist/components/modals/Modal/index.d.ts +4 -4
  75. package/dist/components/modals/Modal/index.js +3 -3
  76. package/dist/components/modals/ModalActions/index.d.ts +3 -3
  77. package/dist/components/modals/ModalActions/index.js +5 -4
  78. package/dist/components/utility/Action/index.d.ts +11 -0
  79. package/dist/components/utility/Action/index.js +48 -0
  80. package/dist/components/utility/ActionList/index.d.ts +5 -5
  81. package/dist/components/utility/ActionList/index.js +6 -4
  82. package/dist/components/utility/AppBody/index.d.ts +5 -0
  83. package/dist/components/utility/AppBody/index.js +9 -0
  84. package/dist/components/utility/Calendar/index.d.ts +32 -0
  85. package/dist/components/utility/Calendar/index.js +66 -0
  86. package/dist/components/utility/CalendarDay/index.d.ts +11 -0
  87. package/dist/components/utility/CalendarDay/index.js +22 -0
  88. package/dist/components/utility/Confirmable/index.d.ts +9 -0
  89. package/dist/components/utility/Confirmable/index.js +14 -0
  90. package/dist/components/utility/Container/index.d.ts +1 -1
  91. package/dist/components/utility/Container/index.js +2 -2
  92. package/dist/components/utility/Loader/index.d.ts +1 -1
  93. package/dist/components/utility/Loader/index.js +5 -4
  94. package/dist/components/utility/Popover/index.d.ts +1 -1
  95. package/dist/components/utility/Popover/index.js +5 -5
  96. package/dist/components/utility/Toast/index.d.ts +3 -3
  97. package/dist/components/utility/Toast/index.js +6 -4
  98. package/dist/components/utility/Toaster/index.js +5 -5
  99. package/dist/filters/components/FilterBar/index.d.ts +6 -3
  100. package/dist/filters/components/FilterBarClientComponent/index.d.ts +3 -5
  101. package/dist/filters/components/FilterBarClientComponent/index.js +4 -44
  102. package/dist/filters/components/FilterClearButton/index.d.ts +7 -2
  103. package/dist/filters/components/FilterClearButton/index.js +8 -4
  104. package/dist/filters/components/FilterControl/index.d.ts +1 -1
  105. package/dist/filters/components/FilterControl/index.js +11 -4
  106. package/dist/filters/components/FilterItem/index.d.ts +3 -2
  107. package/dist/filters/components/FilterItem/index.js +4 -8
  108. package/dist/filters/components/FilterPanel/index.d.ts +2 -2
  109. package/dist/filters/{utility/filter.d.ts → filter.d.ts} +1 -1
  110. package/dist/filters/{utility/filter.js → filter.js} +8 -8
  111. package/dist/filters/filters/BooleanFilter/index.js +2 -2
  112. package/dist/filters/filters/CalendarFilter/index.js +3 -2
  113. package/dist/filters/filters/DateFilter/index.d.ts +1 -1
  114. package/dist/filters/filters/DateFilter/index.js +9 -4
  115. package/dist/filters/filters/DropdownFilter/index.js +2 -2
  116. package/dist/filters/filters/Filter/index.d.ts +6 -5
  117. package/dist/filters/filters/Filter/index.js +9 -9
  118. package/dist/filters/filters/SearchFilter/index.d.ts +8 -3
  119. package/dist/filters/filters/SearchFilter/index.js +10 -10
  120. package/dist/filters/filters/interfaces.d.ts +1 -3
  121. package/dist/filters/index.d.ts +2 -1
  122. package/dist/filters/index.js +2 -1
  123. package/dist/filters/interfaces.d.ts +3 -3
  124. package/dist/filters/utility/get-quick-dates.d.ts +1 -1
  125. package/dist/filters/utility/render-value.js +5 -5
  126. package/dist/forms/components/Autocomplete/index.d.ts +2 -2
  127. package/dist/forms/components/Autocomplete/index.js +5 -5
  128. package/dist/forms/components/AutocompleteList/index.d.ts +7 -0
  129. package/dist/forms/components/AutocompleteList/index.js +15 -0
  130. package/dist/forms/components/BaseCalendarInput/index.d.ts +11 -0
  131. package/dist/forms/components/BaseCalendarInput/index.js +22 -0
  132. package/dist/forms/components/CSVInput/index.d.ts +11 -0
  133. package/dist/forms/components/CSVInput/index.js +32 -0
  134. package/dist/forms/components/CalendarInput/index.d.ts +6 -0
  135. package/dist/forms/components/CalendarInput/index.js +14 -0
  136. package/dist/forms/components/CheckboxInput/index.d.ts +12 -0
  137. package/dist/forms/components/CheckboxInput/index.js +15 -0
  138. package/dist/forms/components/ChkRad/index.d.ts +19 -0
  139. package/dist/forms/components/ChkRad/index.js +25 -0
  140. package/dist/forms/components/ColorInput/index.d.ts +16 -0
  141. package/dist/forms/components/ColorInput/index.js +14 -0
  142. package/dist/forms/components/Dropdown/index.d.ts +1 -1
  143. package/dist/forms/components/Dropdown/index.js +11 -10
  144. package/dist/forms/components/DropdownItem/index.d.ts +9 -0
  145. package/dist/forms/components/DropdownItem/index.js +9 -0
  146. package/dist/forms/components/DropdownList/index.d.ts +2 -2
  147. package/dist/forms/components/DropdownList/index.js +7 -11
  148. package/dist/forms/components/EditableForm/index.d.ts +7 -5
  149. package/dist/forms/components/EditableForm/index.js +19 -15
  150. package/dist/forms/components/EditableFormField/index.d.ts +1 -1
  151. package/dist/forms/components/EditableFormField/index.js +3 -3
  152. package/dist/forms/components/EditableFormFields/index.d.ts +23 -0
  153. package/dist/forms/components/EditableFormFields/index.js +78 -1
  154. package/dist/forms/components/Form/index.d.ts +5 -2
  155. package/dist/forms/components/Form/index.js +7 -6
  156. package/dist/forms/components/FormError/index.d.ts +2 -2
  157. package/dist/forms/components/FormError/index.js +7 -5
  158. package/dist/forms/components/FormField/index.d.ts +8 -6
  159. package/dist/forms/components/FormField/index.js +16 -8
  160. package/dist/forms/components/FormFields/index.d.ts +27 -2
  161. package/dist/forms/components/FormFields/index.js +55 -2
  162. package/dist/forms/components/FormLabel/index.d.ts +1 -1
  163. package/dist/forms/components/FormLabel/index.js +4 -3
  164. package/dist/forms/components/FormSubmit/index.d.ts +1 -1
  165. package/dist/forms/components/FormSubmit/index.js +1 -1
  166. package/dist/forms/components/ImageInput/index.d.ts +20 -0
  167. package/dist/forms/components/ImageInput/index.js +51 -0
  168. package/dist/forms/components/ImageInputPanel/index.d.ts +10 -0
  169. package/dist/forms/components/ImageInputPanel/index.js +34 -0
  170. package/dist/forms/components/ModalForm/index.d.ts +4 -3
  171. package/dist/forms/components/ModalForm/index.js +8 -7
  172. package/dist/forms/components/NumberInput/index.d.ts +1 -1
  173. package/dist/forms/components/PasswordComplexity/index.d.ts +16 -0
  174. package/dist/forms/components/PasswordComplexity/index.js +14 -0
  175. package/dist/forms/components/PasswordComplexityItem/index.d.ts +8 -0
  176. package/dist/forms/components/PasswordComplexityItem/index.js +10 -0
  177. package/dist/forms/components/PasswordInput/index.d.ts +2 -2
  178. package/dist/forms/components/PasswordInput/index.js +6 -6
  179. package/dist/forms/components/PointsInput/index.d.ts +5 -0
  180. package/dist/forms/components/{MoneyInput → PointsInput}/index.js +3 -3
  181. package/dist/forms/components/RangeCalendarInput/index.d.ts +6 -0
  182. package/dist/forms/components/RangeCalendarInput/index.js +14 -0
  183. package/dist/forms/components/StaticTextInput/index.d.ts +3 -3
  184. package/dist/forms/components/StaticTextInput/index.js +7 -8
  185. package/dist/forms/components/Switch/index.d.ts +10 -4
  186. package/dist/forms/components/Switch/index.js +7 -5
  187. package/dist/forms/components/TextArea/index.d.ts +14 -0
  188. package/dist/forms/components/TextArea/index.js +15 -0
  189. package/dist/forms/components/TextInput/index.d.ts +2 -2
  190. package/dist/forms/components/TextInput/index.js +5 -4
  191. package/dist/forms/hooks/useAutocomplete.d.ts +7 -6
  192. package/dist/forms/hooks/useAutocomplete.js +4 -4
  193. package/dist/forms/hooks/useDropdown.d.ts +5 -7
  194. package/dist/forms/hooks/useDropdown.js +5 -5
  195. package/dist/forms/hooks/useEditableDropdown.d.ts +4 -0
  196. package/dist/forms/hooks/useEditableDropdown.js +6 -0
  197. package/dist/forms/hooks/useEditableForm.d.ts +2 -1
  198. package/dist/forms/hooks/useEditableForm.js +21 -9
  199. package/dist/forms/hooks/useForm.d.ts +7 -14
  200. package/dist/forms/hooks/useForm.js +27 -28
  201. package/dist/forms/hooks/useModalForm.d.ts +2 -2
  202. package/dist/forms/hooks/useModalForm.js +10 -3
  203. package/dist/forms/index.d.ts +18 -7
  204. package/dist/forms/index.js +9 -3
  205. package/dist/forms/interfaces.d.ts +9 -1
  206. package/dist/forms/utility/extract-input-props.js +1 -0
  207. package/dist/forms/utility/format-date-value.d.ts +2 -0
  208. package/dist/forms/utility/format-date-value.js +13 -0
  209. package/dist/forms/utility/format-file-size.d.ts +2 -0
  210. package/dist/forms/utility/format-file-size.js +11 -0
  211. package/dist/forms/utility/preprocess-image.d.ts +9 -0
  212. package/dist/forms/utility/preprocess-image.js +61 -0
  213. package/dist/hooks/index.d.ts +3 -0
  214. package/dist/hooks/index.js +3 -0
  215. package/dist/hooks/useConfirmable.d.ts +21 -0
  216. package/dist/hooks/useConfirmable.js +58 -0
  217. package/dist/hooks/useDownload.d.ts +2 -0
  218. package/dist/hooks/useDownload.js +18 -0
  219. package/dist/hooks/usePopover.d.ts +12 -0
  220. package/dist/hooks/usePopover.js +24 -0
  221. package/dist/hooks/useSelected.d.ts +12 -0
  222. package/dist/hooks/useSelected.js +35 -0
  223. package/dist/hooks/useServerAction.d.ts +14 -0
  224. package/dist/hooks/useServerAction.js +30 -0
  225. package/dist/hooks/useSuccess.d.ts +10 -0
  226. package/dist/hooks/useSuccess.js +24 -0
  227. package/dist/mail/Mail/index.d.ts +8 -0
  228. package/dist/mail/Mail/index.js +108 -0
  229. package/dist/mail/MailBlock/index.d.ts +5 -0
  230. package/dist/mail/MailBlock/index.js +5 -0
  231. package/dist/mail/MailButton/index.d.ts +8 -0
  232. package/dist/mail/MailButton/index.js +28 -0
  233. package/dist/mail/MailTable/index.d.ts +9 -0
  234. package/dist/mail/MailTable/index.js +7 -0
  235. package/dist/mail/index.d.ts +8 -0
  236. package/dist/mail/index.js +4 -0
  237. package/dist/mail/utility/convert-to-datauri.d.ts +2 -0
  238. package/dist/mail/utility/convert-to-datauri.js +37 -0
  239. package/dist/mail/utility/interfaces.d.ts +23 -0
  240. package/dist/mail/utility/mail-config.d.ts +4 -0
  241. package/dist/mail/utility/mail-config.js +42 -0
  242. package/dist/navigation/components/AppNavigation/index.d.ts +3 -1
  243. package/dist/navigation/components/AppNavigation/index.js +4 -4
  244. package/dist/navigation/components/AppNavigationItem/index.d.ts +6 -4
  245. package/dist/navigation/components/AppNavigationItem/index.js +16 -7
  246. package/dist/navigation/components/Tabs/index.js +1 -4
  247. package/dist/navigation/hooks/useNavigation.d.ts +3 -3
  248. package/dist/navigation/hooks/useNavigation.js +5 -5
  249. package/dist/styles/classnames/config.d.ts +97 -0
  250. package/dist/styles/classnames/config.js +1 -0
  251. package/dist/styles/classnames/interfaces.d.ts +56 -0
  252. package/dist/styles/classnames/interfaces.js +1 -0
  253. package/dist/styles/classnames/utility/apply-sizes.d.ts +3 -0
  254. package/dist/styles/classnames/utility/apply-sizes.js +21 -0
  255. package/dist/styles/classnames/utility/apply-variants.d.ts +3 -0
  256. package/dist/styles/classnames/utility/apply-variants.js +26 -0
  257. package/dist/styles/classnames/utility/is-classname-object.d.ts +3 -0
  258. package/dist/styles/classnames/utility/is-classname-object.js +7 -0
  259. package/dist/styles/classnames/utility/parse-classnames.d.ts +6 -0
  260. package/dist/styles/classnames/utility/parse-classnames.js +33 -0
  261. package/dist/styles/context.d.ts +28 -0
  262. package/dist/styles/context.js +19 -0
  263. package/dist/styles/icons/config.d.ts +29 -0
  264. package/dist/styles/icons/config.js +1 -0
  265. package/dist/styles/icons/interfaces.d.ts +4 -0
  266. package/dist/styles/icons/interfaces.js +1 -0
  267. package/dist/styles/index.d.ts +6 -2
  268. package/dist/styles/index.js +2 -1
  269. package/dist/styles/styles.css +60 -0
  270. package/dist/utility/compare-dates.d.ts +2 -0
  271. package/dist/utility/compare-dates.js +13 -0
  272. package/dist/utility/get-date-state.d.ts +8 -0
  273. package/dist/utility/get-date-state.js +63 -0
  274. package/dist/utility/get-days.d.ts +2 -0
  275. package/dist/utility/get-days.js +5 -0
  276. package/dist/utility/get-weeks.d.ts +2 -0
  277. package/dist/utility/get-weeks.js +31 -0
  278. package/dist/utility/index.d.ts +1 -1
  279. package/dist/utility/interfaces.d.ts +33 -17
  280. package/dist/utility/is-data-object-array.d.ts +3 -0
  281. package/dist/utility/is-data-object-array.js +5 -0
  282. package/dist/utility/is-data-object.d.ts +3 -0
  283. package/dist/utility/is-data-object.js +4 -0
  284. package/dist/utility/normalize-href.d.ts +2 -0
  285. package/dist/utility/normalize-href.js +8 -0
  286. package/package.json +37 -25
  287. package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
  288. package/dist/components/buttons/ConfirmableButton/index.js +0 -13
  289. package/dist/components/collections/utility/filter-columns.d.ts +0 -3
  290. package/dist/components/collections/utility/filter-columns.js +0 -8
  291. package/dist/components/collections/utility/get-selected-from-search-params.d.ts +0 -2
  292. package/dist/components/collections/utility/get-selected-from-search-params.js +0 -5
  293. package/dist/components/collections/utility/set-selected-to-search-params.d.ts +0 -2
  294. package/dist/components/collections/utility/set-selected-to-search-params.js +0 -4
  295. package/dist/components/utility/ClassNames/index.d.ts +0 -6
  296. package/dist/components/utility/ClassNames/index.js +0 -7
  297. package/dist/components/utility/Page/index.d.ts +0 -18
  298. package/dist/components/utility/Page/index.js +0 -34
  299. package/dist/components/utility/RootLayout/index.d.ts +0 -15
  300. package/dist/components/utility/RootLayout/index.js +0 -14
  301. package/dist/forms/components/MoneyInput/index.d.ts +0 -5
  302. package/dist/styles/config.d.ts +0 -64
  303. package/dist/styles/config.js +0 -43
  304. package/dist/styles/icons.d.ts +0 -15
  305. package/dist/styles/icons.js +0 -7
  306. package/dist/styles/interfaces.d.ts +0 -41
  307. /package/dist/{styles → mail/utility}/interfaces.js +0 -0
  308. /package/dist/styles/{tw.d.ts → classnames/utility/tw.d.ts} +0 -0
  309. /package/dist/styles/{tw.js → classnames/utility/tw.js} +0 -0
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { isValidElement, useEffect, useRef } from 'react';
4
4
  import FormField from '../FormField';
5
- import { getClassNames } from '../../../styles/config';
5
+ import { useClassNames } from '../../../styles/context.js';
6
6
  function getRenderedValue(value, renderValue) {
7
7
  if (renderValue) {
8
8
  if (typeof renderValue === 'function') {
@@ -19,7 +19,7 @@ function getRenderedValue(value, renderValue) {
19
19
  return value ? String(value) : '-';
20
20
  }
21
21
  function EditableFormField({ classNameProps, classNames, renderValue, status, ...props }) {
22
- const componentClassNames = classNames || getClassNames('editableFormField')(classNameProps);
22
+ const componentClassNames = useClassNames('editableFormField', { props: classNameProps }, classNames);
23
23
  const cachedValue = useRef(props.value);
24
24
  useEffect(() => {
25
25
  if (status === 'CANCELLED') {
@@ -30,7 +30,7 @@ function EditableFormField({ classNameProps, classNames, renderValue, status, ..
30
30
  }
31
31
  }, [status]);
32
32
  if (status === 'EDITING') {
33
- return _jsx(FormField, { ...props });
33
+ return _jsx(FormField, { classNameProps: { ...classNameProps, isEditable: true }, ...props });
34
34
  }
35
35
  return (_jsxs("div", { className: componentClassNames?.root, children: [_jsx("div", { className: componentClassNames?.label, children: props.label }), _jsx("div", { className: componentClassNames?.field, children: getRenderedValue(props.value, renderValue) })] }));
36
36
  }
@@ -1,7 +1,30 @@
1
1
  import type { EditableFormFieldComponentProps } from '../../interfaces';
2
+ import type { CheckboxInputComponentProps } from '../CheckboxInput';
3
+ import type { ColorInputComponentProps } from '../ColorInput';
2
4
  import type { DropdownComponentProps } from '../Dropdown';
5
+ import type { ImageInputComponentProps } from '../ImageInput';
6
+ import type { NumberInputComponentProps } from '../NumberInput';
7
+ import type { PointsInputComponentProps } from '../PointsInput';
8
+ import type { SwitchComponentProps } from '../Switch';
9
+ import type { TextAreaComponentProps } from '../TextArea';
3
10
  import type { TextInputComponentProps } from '../TextInput';
11
+ export type EditableCheckboxFormFieldProps<T> = EditableFormFieldComponentProps<T[]> & CheckboxInputComponentProps<T>;
12
+ export declare function EditableCheckboxFormField<T>(props: Readonly<EditableCheckboxFormFieldProps<T>>): React.ReactElement;
13
+ export type EditableColorFormFieldProps = EditableFormFieldComponentProps<string | undefined> & ColorInputComponentProps;
14
+ export declare function EditableColorFormField(props: Readonly<EditableColorFormFieldProps>): React.ReactElement;
4
15
  export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<T | null> & DropdownComponentProps<T>;
5
16
  export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
17
+ export type EditableImageFormFieldProps = EditableFormFieldComponentProps<string | null> & ImageInputComponentProps;
18
+ export declare function EditableImageFormField(props: Readonly<EditableImageFormFieldProps>): React.ReactElement;
19
+ export type EditableMoneyFormFieldProps = EditableFormFieldComponentProps<number> & PointsInputComponentProps;
20
+ export declare function EditableMoneyFormField(props: Readonly<EditableMoneyFormFieldProps>): React.ReactElement;
21
+ export type EditableNumberFormFieldProps = EditableFormFieldComponentProps<number> & NumberInputComponentProps;
22
+ export declare function EditableNumberFormField(props: Readonly<EditableNumberFormFieldProps>): React.ReactElement;
23
+ export type EditablePointsFormFieldProps = EditableFormFieldComponentProps<number> & PointsInputComponentProps;
24
+ export declare function EditablePointsFormField(props: Readonly<EditablePointsFormFieldProps>): React.ReactElement;
25
+ export type EditableSwitchFormFieldProps = EditableFormFieldComponentProps<boolean> & SwitchComponentProps;
26
+ export declare function EditableSwitchFormField(props: Readonly<EditableSwitchFormFieldProps>): React.ReactElement;
27
+ export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
28
+ export declare function EditableTextAreaFormField(props: Readonly<EditableTextAreaFormFieldProps>): React.ReactElement;
6
29
  export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
7
30
  export declare function EditableTextFormField(props: Readonly<EditableTextFormFieldProps>): React.ReactElement;
@@ -1,9 +1,46 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
+ import { formatMoney, formatPoints } from '@sqrzro/utility';
4
+ import { useClassNames } from '../../../styles/context.js';
5
+ import tw from '../../../styles/classnames/utility/tw.js';
3
6
  import extractEditableInputProps from '../../utility/extract-editable-input-props';
7
+ import CheckboxInput from '../CheckboxInput';
8
+ import ColorInput from '../ColorInput';
4
9
  import Dropdown from '../Dropdown';
5
10
  import EditableFormField from '../EditableFormField';
11
+ import ImageInput from '../ImageInput';
12
+ import NumberInput from '../NumberInput';
13
+ import PointsInput from '../PointsInput';
14
+ import Switch from '../Switch';
15
+ import TextArea from '../TextArea';
6
16
  import TextInput from '../TextInput';
17
+ import ChkRad from '../ChkRad';
18
+ export function EditableCheckboxFormField(props) {
19
+ const classNames = useClassNames('checkboxInput');
20
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
21
+ const renderInput = useCallback((renderProps) => (_jsx(CheckboxInput, { ...renderProps, ...inputProps })), [inputProps]);
22
+ const renderValue = useCallback((value) => {
23
+ if (!value) {
24
+ return '-';
25
+ }
26
+ return (_jsx("ul", { className: classNames?.root, role: "listbox", children: props.options
27
+ ?.filter((option) => value.includes(option.value))
28
+ .map((option) => (_jsx("li", { className: classNames?.item, children: _jsx(ChkRad, { isReadOnly: true, label: option.label, name: props.name, value: true }) }, String(option.value)))) }));
29
+ }, [fieldProps.value]);
30
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
31
+ }
32
+ export function EditableColorFormField(props) {
33
+ const classNames = useClassNames('colorInput');
34
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
35
+ const renderInput = useCallback((renderProps) => (_jsx(ColorInput, { ...renderProps, ...inputProps })), [inputProps]);
36
+ const renderValue = useCallback((value) => {
37
+ if (!value) {
38
+ return '-';
39
+ }
40
+ return (_jsxs("div", { className: "relative flex items-center gap-2", children: [_jsx("span", { className: tw(classNames?.icon), style: { backgroundColor: value || 'transparent' } }), _jsx("span", { className: tw(classNames?.label), children: value.toUpperCase() })] }));
41
+ }, [fieldProps.value]);
42
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
43
+ }
7
44
  export function EditableDropdownFormField(props) {
8
45
  const { fieldProps, inputProps } = extractEditableInputProps(props);
9
46
  const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
@@ -13,6 +50,46 @@ export function EditableDropdownFormField(props) {
13
50
  }, [inputProps]);
14
51
  return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
15
52
  }
53
+ export function EditableImageFormField(props) {
54
+ const classNames = useClassNames('imageInput');
55
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
56
+ const renderInput = useCallback((renderProps) => (_jsx(ImageInput, { ...renderProps, ...inputProps })), [inputProps]);
57
+ const renderValue = useCallback((value) => {
58
+ if (!value) {
59
+ return '-';
60
+ }
61
+ return (_jsx("div", { className: tw('relative flex items-center justify-center overflow-hidden text-center', classNames?.root), children: _jsx("img", { src: value, className: classNames?.image }) }));
62
+ }, [fieldProps.value]);
63
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
64
+ }
65
+ export function EditableMoneyFormField(props) {
66
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
67
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps, prefix: "\u00A3" })), [inputProps]);
68
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: formatMoney });
69
+ }
70
+ export function EditableNumberFormField(props) {
71
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
72
+ const renderInput = useCallback((renderProps) => (_jsx(NumberInput, { ...renderProps, ...inputProps })), [inputProps]);
73
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
74
+ }
75
+ export function EditablePointsFormField(props) {
76
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
77
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
78
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: formatPoints });
79
+ }
80
+ export function EditableSwitchFormField(props) {
81
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
82
+ const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps, label: null })), [inputProps]);
83
+ const renderValue = useCallback((value) => {
84
+ return _jsx("div", { children: value ? 'Yes' : 'No' });
85
+ }, [inputProps]);
86
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
87
+ }
88
+ export function EditableTextAreaFormField(props) {
89
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
90
+ const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
91
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
92
+ }
16
93
  export function EditableTextFormField(props) {
17
94
  const { fieldProps, inputProps } = extractEditableInputProps(props);
18
95
  const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
@@ -1,12 +1,15 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
2
2
  export interface FormClassNames {
3
3
  root: string;
4
+ errors: string;
4
5
  }
5
6
  export interface FormProps extends ClassNameProps<FormClassNames> {
6
7
  action?: (formData: FormData) => void;
7
8
  children: React.ReactNode;
8
9
  id?: string;
9
10
  onSubmit?: React.FormEventHandler<HTMLFormElement>;
11
+ ref?: React.Ref<HTMLFormElement>;
12
+ uncaughtErrors: Record<string, string> | null;
10
13
  }
11
- declare function Form({ action, children, classNames, classNameProps, id, onSubmit, }: Readonly<FormProps>): React.ReactElement;
14
+ declare function Form({ action, children, classNames, classNameProps, id, onSubmit, uncaughtErrors, ref, }: Readonly<FormProps>): React.ReactElement;
12
15
  export default Form;
@@ -1,9 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { getClassNames } from '../../../styles/config';
4
- import tw from '../../../styles/tw';
5
- function Form({ action, children, classNames, classNameProps, id, onSubmit, }) {
6
- const componentClassNames = classNames || getClassNames('form')?.(classNameProps);
7
- return (_jsx("form", { action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: children }));
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context.js';
4
+ import tw from '../../../styles/classnames/utility/tw.js';
5
+ import { InfoPanel } from '../../../components/index.js';
6
+ function Form({ action, children, classNames, classNameProps, id, onSubmit, uncaughtErrors, ref, }) {
7
+ const componentClassNames = useClassNames('form', { props: classNameProps }, classNames);
8
+ return (_jsxs("form", { ref: ref, action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: [uncaughtErrors && Object.keys(uncaughtErrors).length ? (_jsx("div", { className: tw(componentClassNames?.errors), children: _jsx(InfoPanel, { variant: "error", children: Object.values(uncaughtErrors).map((item, index) => (_jsx("p", { children: item }, index))) }) })) : null, children] }));
8
9
  }
9
10
  export default Form;
@@ -1,6 +1,6 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
2
2
  import type { FormFieldClassNames } from '../FormField';
3
- interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
3
+ export interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
4
4
  children: React.ReactNode;
5
5
  id: string;
6
6
  isAssistive?: boolean;
@@ -1,8 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getClassNames } from '../../../styles/config';
3
- import tw from '../../../styles/tw';
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames, useIcon } from '../../../styles/context.js';
4
+ import tw from '../../../styles/classnames/utility/tw.js';
4
5
  function FormError({ children, classNames, classNameProps, id, isAssistive, }) {
5
- const componentClassNames = classNames || getClassNames('formField')?.(classNameProps);
6
- return (_jsx("div", { className: tw(componentClassNames?.error, isAssistive ? 'sr-only' : null), id: `${id}_err`, children: children }));
6
+ const componentClassNames = useClassNames('formField', { props: classNameProps }, classNames);
7
+ const Icon = useIcon('formField.error');
8
+ return (_jsxs("div", { className: tw(componentClassNames?.error, isAssistive ? 'sr-only' : null), id: `${id}_err`, children: [Icon ? (_jsx("div", { className: "h-5 w-5", children: _jsx(Icon, {}) })) : null, children] }));
7
9
  }
8
10
  export default FormError;
@@ -1,6 +1,6 @@
1
- import type { InputEvent, InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
3
- import { Action } from '../../../utility/interfaces';
1
+ import type { InputEvent, InputProps } from '../../interfaces.js';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
3
+ import { SimpleActionObject } from '../../../utility/interfaces.js';
4
4
  export interface FormFieldClassNames {
5
5
  root: ErrorableClassName;
6
6
  label: string;
@@ -10,16 +10,18 @@ export interface FormFieldClassNames {
10
10
  error: string;
11
11
  }
12
12
  export interface FormFieldProps<T, V extends T> extends ClassNameProps<FormFieldClassNames>, InputProps<T, V> {
13
- action?: Action | null;
14
- details?: string | null;
13
+ action?: SimpleActionObject | null;
14
+ details?: React.ReactNode;
15
15
  error?: Record<string, string> | null;
16
16
  hasAssistiveError?: boolean;
17
+ hasAssistiveDetails?: boolean;
17
18
  hasAssistiveLabel?: boolean;
18
19
  isContentOnly?: boolean;
19
20
  isOptional?: boolean;
20
21
  label?: React.ReactNode;
21
22
  onChange?: (event: InputEvent<T>) => void;
23
+ onFieldChange?: (event: InputEvent<T>) => void;
22
24
  render: (props: InputProps<T>) => React.ReactElement | null;
23
25
  }
24
- declare function FormField<T, V extends T>({ action, classNameProps, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
26
+ declare function FormField<T, V extends T>({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onFieldChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
25
27
  export default FormField;
@@ -1,30 +1,38 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
- import { getClassNames } from '../../../styles/config';
5
- import tw from '../../../styles/tw';
4
+ import { useClassNames } from '../../../styles/context.js';
5
+ import tw from '../../../styles/classnames/utility/tw.js';
6
6
  import FormError from '../FormError';
7
7
  import FormLabel from '../FormLabel';
8
- import ActionButton from '../../../components/buttons/ActionButton';
8
+ import ActionButton from '../../../components/buttons/ActionButton/index.js';
9
9
  function checkHasError(error) {
10
- return Boolean(error && Object.keys(error).length > 0 && Object.values(error).some(Boolean));
10
+ return Boolean(error &&
11
+ Object.keys(error).length > 0 &&
12
+ Object.values(error).some((item) => typeof item === 'string'));
11
13
  }
12
- function FormField({ action, classNameProps, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }) {
13
- const classNames = getClassNames('formField')?.(classNameProps);
14
+ function FormField({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onFieldChange, onKeyDown, render, value, }) {
15
+ const componentClassNames = useClassNames('formField', { props: classNameProps, states: { isError: checkHasError(error) } }, classNames);
14
16
  const inputId = id || `ff_${name}`;
15
17
  const [inputError, setInputError] = useState(null);
18
+ function handleChange(event) {
19
+ onFieldChange?.(event);
20
+ onChange?.(event);
21
+ }
16
22
  function handleError(message) {
17
23
  setInputError(message);
18
24
  }
19
25
  const renderProps = {
20
26
  classNameProps,
27
+ details,
21
28
  error,
22
29
  hasError: checkHasError(error),
23
30
  id: inputId,
24
31
  isDisabled,
32
+ isOptional,
25
33
  label,
26
34
  name,
27
- onChange,
35
+ onChange: handleChange,
28
36
  onError: handleError,
29
37
  onKeyDown,
30
38
  value,
@@ -32,6 +40,6 @@ function FormField({ action, classNameProps, details, error, hasAssistiveError,
32
40
  if (isContentOnly) {
33
41
  return render(renderProps);
34
42
  }
35
- return (_jsxs("div", { className: tw(classNames?.root?.default, error ? classNames?.root?.error : null), children: [label ? (_jsx(FormLabel, { classNameProps: classNameProps, htmlFor: inputId, isAssistive: hasAssistiveLabel, isOptional: isOptional, children: label })) : null, details && label ? _jsx("div", { className: classNames?.details, children: details }) : null, _jsx("div", { className: classNames?.field, children: render(renderProps) }), action ? (_jsx("div", { children: _jsx(ActionButton, { ...action, isDisabled: Boolean(isDisabled || action.isDisabled) }) })) : null, inputError || error?.[name] ? (_jsx(FormError, { classNameProps: classNameProps, id: inputId, isAssistive: hasAssistiveError, children: inputError || error?.[name] })) : null] }));
43
+ return (_jsxs("div", { className: componentClassNames?.root, children: [label ? (_jsx(FormLabel, { classNameProps: classNameProps, htmlFor: inputId, isAssistive: hasAssistiveLabel, isOptional: isOptional, children: label })) : null, details && label ? (_jsx("div", { className: tw(componentClassNames?.details, hasAssistiveDetails ? 'sr-only' : null), children: details })) : null, _jsx("div", { className: componentClassNames?.field, children: render(renderProps) }), action ? (_jsx("div", { children: _jsx(ActionButton, { ...action, isDisabled: Boolean(isDisabled || action.isDisabled) }) })) : null, inputError || error?.[name] ? (_jsx(FormError, { classNameProps: classNameProps, id: inputId, isAssistive: hasAssistiveError, children: inputError || error?.[name] })) : null] }));
36
44
  }
37
45
  export default FormField;
@@ -1,19 +1,44 @@
1
1
  import type { FormFieldComponentProps } from '../../interfaces';
2
2
  import type { AutocompleteComponentProps } from '../Autocomplete';
3
+ import type { ColorInputComponentProps } from '../ColorInput';
4
+ import type { CalendarInputComponentProps } from '../CalendarInput';
5
+ import type { CheckboxInputComponentProps } from '../CheckboxInput';
3
6
  import type { DropdownComponentProps } from '../Dropdown';
4
- import type { MoneyInputComponentProps } from '../MoneyInput';
7
+ import type { ImageInputComponentProps } from '../ImageInput';
5
8
  import type { NumberInputComponentProps } from '../NumberInput';
6
9
  import type { PasswordInputComponentProps } from '../PasswordInput';
10
+ import type { PointsInputComponentProps } from '../PointsInput';
11
+ import type { RangeCalendarInputComponentProps } from '../RangeCalendarInput';
12
+ import type { SwitchComponentProps } from '../Switch';
13
+ import type { TextAreaComponentProps } from '../TextArea';
7
14
  import type { TextInputComponentProps } from '../TextInput';
8
15
  export type AutocompleteFormFieldProps<T> = FormFieldComponentProps<T | null> & AutocompleteComponentProps<T>;
9
16
  export declare function AutocompleteFormField<T>(props: Readonly<AutocompleteFormFieldProps<T>>): React.ReactElement;
17
+ export type CalendarFormFieldProps = FormFieldComponentProps<Date | null> & CalendarInputComponentProps;
18
+ export declare function CalendarFormField(props: Readonly<CalendarFormFieldProps>): React.ReactElement;
19
+ export type CheckboxFormFieldProps<T> = FormFieldComponentProps<T[]> & CheckboxInputComponentProps<T>;
20
+ export declare function CheckboxFormField<T>(props: Readonly<CheckboxFormFieldProps<T>>): React.ReactElement;
21
+ export type ColorFormFieldProps = FormFieldComponentProps<string> & ColorInputComponentProps;
22
+ export declare function ColorFormField(props: Readonly<ColorFormFieldProps>): React.ReactElement;
23
+ export type CSVFormFieldProps = FormFieldComponentProps<string>;
24
+ export declare function CSVFormField(props: Readonly<CSVFormFieldProps>): React.ReactElement;
10
25
  export type DropdownFormFieldProps<T> = FormFieldComponentProps<T | null> & DropdownComponentProps<T>;
11
26
  export declare function DropdownFormField<T>(props: Readonly<DropdownFormFieldProps<T>>): React.ReactElement;
12
- export type MoneyFormFieldProps = FormFieldComponentProps<number> & MoneyInputComponentProps;
27
+ export type ImageFormFieldProps = FormFieldComponentProps<string | null> & ImageInputComponentProps;
28
+ export declare function ImageFormField(props: Readonly<ImageFormFieldProps>): React.ReactElement;
29
+ export type MoneyFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
13
30
  export declare function MoneyFormField(props: Readonly<MoneyFormFieldProps>): React.ReactElement;
14
31
  export type NumberFormFieldProps = FormFieldComponentProps<number> & NumberInputComponentProps;
15
32
  export declare function NumberFormField(props: Readonly<NumberFormFieldProps>): React.ReactElement;
16
33
  export type PasswordFormFieldProps = FormFieldComponentProps<string> & PasswordInputComponentProps;
17
34
  export declare function PasswordFormField(props: Readonly<PasswordFormFieldProps>): React.ReactElement;
35
+ export type PointsFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
36
+ export declare function PointsFormField(props: Readonly<PointsFormFieldProps>): React.ReactElement;
37
+ export type RangeCalendarFormFieldProps = FormFieldComponentProps<[Date, Date] | null> & RangeCalendarInputComponentProps;
38
+ export declare function RangeCalendarFormField(props: Readonly<RangeCalendarFormFieldProps>): React.ReactElement;
39
+ export type SwitchFormFieldProps = FormFieldComponentProps<boolean> & SwitchComponentProps;
40
+ export declare function SwitchFormField(props: SwitchFormFieldProps): React.ReactElement;
18
41
  export type TextFormFieldProps = FormFieldComponentProps<string> & TextInputComponentProps;
19
42
  export declare function TextFormField(props: Readonly<TextFormFieldProps>): React.ReactElement;
43
+ export type TextAreaFormFieldProps = FormFieldComponentProps<string> & TextAreaComponentProps;
44
+ export declare function TextAreaFormField(props: Readonly<TextAreaFormFieldProps>): React.ReactElement;
@@ -2,25 +2,58 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
3
  import extractInputProps from '../../utility/extract-input-props';
4
4
  import Autocomplete from '../Autocomplete';
5
+ import ColorInput from '../ColorInput';
6
+ import CSVInput from '../CSVInput';
7
+ import CalendarInput from '../CalendarInput';
8
+ import CheckboxInput from '../CheckboxInput';
5
9
  import Dropdown from '../Dropdown';
6
10
  import FormField from '../FormField';
7
- import MoneyInput from '../MoneyInput';
11
+ import ImageInput from '../ImageInput';
8
12
  import NumberInput from '../NumberInput';
9
13
  import PasswordInput from '../PasswordInput';
14
+ import PointsInput from '../PointsInput';
15
+ import RangeCalendarInput from '../RangeCalendarInput';
16
+ import Switch from '../Switch';
17
+ import TextArea from '../TextArea';
10
18
  import TextInput from '../TextInput';
11
19
  export function AutocompleteFormField(props) {
12
20
  const { fieldProps, inputProps } = extractInputProps(props);
13
21
  const renderInput = useCallback((renderProps) => (_jsx(Autocomplete, { ...renderProps, ...inputProps })), [inputProps]);
14
22
  return _jsx(FormField, { ...fieldProps, render: renderInput });
15
23
  }
24
+ export function CalendarFormField(props) {
25
+ const { fieldProps, inputProps } = extractInputProps(props);
26
+ const renderInput = useCallback((renderProps) => (_jsx(CalendarInput, { ...renderProps, ...inputProps })), [inputProps]);
27
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
28
+ }
29
+ export function CheckboxFormField(props) {
30
+ const { fieldProps, inputProps } = extractInputProps(props);
31
+ const renderInput = useCallback((renderProps) => (_jsx(CheckboxInput, { ...renderProps, ...inputProps })), [inputProps]);
32
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
33
+ }
34
+ export function ColorFormField(props) {
35
+ const { fieldProps, inputProps } = extractInputProps(props);
36
+ const renderInput = useCallback((renderProps) => (_jsx(ColorInput, { ...renderProps, ...inputProps })), [inputProps]);
37
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
38
+ }
39
+ export function CSVFormField(props) {
40
+ const { fieldProps, inputProps } = extractInputProps(props);
41
+ const renderInput = useCallback((renderProps) => (_jsx(CSVInput, { ...renderProps, ...inputProps })), [inputProps]);
42
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
43
+ }
16
44
  export function DropdownFormField(props) {
17
45
  const { fieldProps, inputProps } = extractInputProps(props);
18
46
  const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
19
47
  return _jsx(FormField, { ...fieldProps, render: renderInput });
20
48
  }
49
+ export function ImageFormField(props) {
50
+ const { fieldProps, inputProps } = extractInputProps(props);
51
+ const renderInput = useCallback((renderProps) => (_jsx(ImageInput, { ...renderProps, ...inputProps })), [inputProps]);
52
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
53
+ }
21
54
  export function MoneyFormField(props) {
22
55
  const { fieldProps, inputProps } = extractInputProps(props);
23
- const renderInput = useCallback((renderProps) => (_jsx(MoneyInput, { ...renderProps, ...inputProps })), [inputProps]);
56
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps, prefix: "\u00A3" })), [inputProps]);
24
57
  return _jsx(FormField, { ...fieldProps, render: renderInput });
25
58
  }
26
59
  export function NumberFormField(props) {
@@ -33,8 +66,28 @@ export function PasswordFormField(props) {
33
66
  const renderInput = useCallback((renderProps) => (_jsx(PasswordInput, { ...renderProps, ...inputProps })), [inputProps]);
34
67
  return _jsx(FormField, { ...fieldProps, render: renderInput });
35
68
  }
69
+ export function PointsFormField(props) {
70
+ const { fieldProps, inputProps } = extractInputProps(props);
71
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
72
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
73
+ }
74
+ export function RangeCalendarFormField(props) {
75
+ const { fieldProps, inputProps } = extractInputProps(props);
76
+ const renderInput = useCallback((renderProps) => (_jsx(RangeCalendarInput, { ...renderProps, ...inputProps })), [inputProps]);
77
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
78
+ }
79
+ export function SwitchFormField(props) {
80
+ const { fieldProps, inputProps } = extractInputProps(props);
81
+ const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps })), [inputProps]);
82
+ return _jsx(FormField, { ...fieldProps, hasAssistiveLabel: true, hasAssistiveDetails: true, render: renderInput });
83
+ }
36
84
  export function TextFormField(props) {
37
85
  const { fieldProps, inputProps } = extractInputProps(props);
38
86
  const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
39
87
  return _jsx(FormField, { ...fieldProps, render: renderInput });
40
88
  }
89
+ export function TextAreaFormField(props) {
90
+ const { fieldProps, inputProps } = extractInputProps(props);
91
+ const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
92
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
93
+ }
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
2
2
  import type { FormFieldClassNames } from '../FormField';
3
3
  interface FormLabelProps extends ClassNameProps<FormFieldClassNames> {
4
4
  children: React.ReactNode;
@@ -1,8 +1,9 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getClassNames } from '../../../styles/config';
3
- import tw from '../../../styles/tw';
3
+ import { useClassNames } from '../../../styles/context.js';
4
+ import tw from '../../../styles/classnames/utility/tw.js';
4
5
  function FormLabel({ children, classNames, classNameProps, htmlFor, isAssistive, isOptional, }) {
5
- const componentClassNames = classNames || getClassNames('formField')?.(classNameProps);
6
+ const componentClassNames = useClassNames('formField', { props: classNameProps }, classNames);
6
7
  return (_jsxs("label", { className: tw(componentClassNames?.label, isAssistive ? 'sr-only' : null), htmlFor: htmlFor, children: [children, isOptional ? _jsx("small", { className: componentClassNames?.optional, children: "Optional" }) : null] }));
7
8
  }
8
9
  export default FormLabel;
@@ -1,4 +1,4 @@
1
- import type { ButtonProps } from '../../../components/buttons/Button';
1
+ import type { ButtonProps } from '../../../components/buttons/Button/index.js';
2
2
  export type FormSubmitProps = Omit<ButtonProps, 'href' | 'isNewWindow' | 'isText'>;
3
3
  declare function FormSubmit({ isLoading, ...props }: Readonly<FormSubmitProps>): React.ReactElement;
4
4
  export default FormSubmit;
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useFormStatus } from 'react-dom';
4
- import Button from '../../../components/buttons/Button';
4
+ import Button from '../../../components/buttons/Button/index.js';
5
5
  function FormSubmit({ isLoading, ...props }) {
6
6
  const { pending } = useFormStatus();
7
7
  return _jsx(Button, { ...props, isLoading: isLoading || pending, type: "submit", variant: "primary" });
@@ -0,0 +1,20 @@
1
+ import type { ImageTypeKey } from '../../utility/preprocess-image.js';
2
+ import type { FormResponse, InputProps } from '../../interfaces.js';
3
+ import type { ClassNameProps, HighlightableClassName } from '../../../styles/classnames/interfaces.js';
4
+ export interface ImageInputClassNames {
5
+ description: string;
6
+ icon: HighlightableClassName;
7
+ image: string;
8
+ root: string;
9
+ title: string;
10
+ }
11
+ export interface ImageInputComponentProps {
12
+ accept?: ImageTypeKey[];
13
+ format?: ImageTypeKey;
14
+ maxSize?: [number?, number?];
15
+ minSize?: [number?, number?];
16
+ onUpload?: (file: File) => FormResponse<string>;
17
+ }
18
+ export type ImageInputProps = ClassNameProps<ImageInputClassNames> & InputProps<string | null> & ImageInputComponentProps;
19
+ declare function ImageInput({ accept, classNames, classNameProps, format, id, isDisabled, maxSize, minSize, name, onChange, onUpload, value, }: Readonly<ImageInputProps>): React.ReactElement;
20
+ export default ImageInput;
@@ -0,0 +1,51 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import preprocessImage from '../../utility/preprocess-image.js';
5
+ import { useClassNames } from '../../../styles/context.js';
6
+ import tw from '../../../styles/classnames/utility/tw.js';
7
+ import ImageInputPanel from '../ImageInputPanel';
8
+ function ImageInput({ accept, classNames, classNameProps, format, id, isDisabled, maxSize, minSize, name, onChange, onUpload, value, }) {
9
+ const [error, setError] = useState(null);
10
+ const [isLoading, setIsLoading] = useState(false);
11
+ const componentClassNames = useClassNames('imageInput', {
12
+ props: classNameProps,
13
+ }, classNames);
14
+ async function handleChange(event) {
15
+ if (!onUpload) {
16
+ return;
17
+ }
18
+ setError(null);
19
+ setIsLoading(true);
20
+ const imageFiles = event.target.files;
21
+ if (!imageFiles?.length) {
22
+ setIsLoading(false);
23
+ return;
24
+ }
25
+ try {
26
+ const preprocessed = await preprocessImage(imageFiles[0], {
27
+ accept,
28
+ format,
29
+ maxSize,
30
+ minSize,
31
+ });
32
+ const fnReturn = await onUpload(preprocessed);
33
+ setIsLoading(false);
34
+ if (fnReturn.error) {
35
+ setError(fnReturn.error);
36
+ }
37
+ else if (fnReturn.validation) {
38
+ setError(Object.values(fnReturn.validation)[0]);
39
+ }
40
+ else if (fnReturn.data !== null) {
41
+ onChange?.({ target: { name, value: fnReturn.data } });
42
+ }
43
+ }
44
+ catch (err) {
45
+ setIsLoading(false);
46
+ setError(err instanceof Error ? err.message : 'An unexpected error occurred');
47
+ }
48
+ }
49
+ return (_jsxs("div", { className: tw('relative flex items-center justify-center overflow-hidden text-center', componentClassNames?.root, isDisabled || isLoading ? 'pointer-events-none opacity-20' : null), children: [_jsx("input", { name: name, type: "hidden", value: value || '' }), _jsx("input", { accept: accept?.map((type) => `.${type}`).join(',') || 'image/*', className: "absolute left-0 top-0 h-full w-full cursor-pointer opacity-0", disabled: isDisabled || isLoading, id: id || name, name: name, onChange: handleChange, type: "file" }), _jsx(ImageInputPanel, { classNames: classNames, classNameProps: { ...classNameProps, isError: Boolean(error) }, error: error, isLoading: isLoading, minSize: minSize, value: value })] }));
50
+ }
51
+ export default ImageInput;
@@ -0,0 +1,10 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces.js';
2
+ import type { ImageInputClassNames } from '../ImageInput';
3
+ interface ImageInputPanelProps extends ClassNameProps<ImageInputClassNames> {
4
+ error?: string | null;
5
+ isLoading?: boolean;
6
+ minSize?: [number?, number?];
7
+ value?: string | null;
8
+ }
9
+ declare function ImageInputPanel({ classNameProps, classNames, error, isLoading, minSize, value, }: ImageInputPanelProps): React.ReactElement;
10
+ export default ImageInputPanel;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useClassNames, useIcon } from '../../../styles/context.js';
3
+ function renderMinSize(minSize) {
4
+ if (!minSize) {
5
+ return null;
6
+ }
7
+ const [width, height] = minSize;
8
+ if (width && height) {
9
+ return `(Minimum size: ${width} x ${height}px)`;
10
+ }
11
+ if (width) {
12
+ return `(Minimum width: ${width}px)`;
13
+ }
14
+ if (height) {
15
+ return `(Minimum height: ${height}px)`;
16
+ }
17
+ return null;
18
+ }
19
+ function ImageInputPanel({ classNameProps, classNames, error, isLoading, minSize, value, }) {
20
+ const ErrorIcon = useIcon('imageInput.error');
21
+ const UploadIcon = useIcon('imageInput.upload');
22
+ const componentClassNames = useClassNames('imageInput', {
23
+ props: classNameProps,
24
+ }, classNames);
25
+ if (value) {
26
+ return _jsx("img", { src: value, className: componentClassNames?.image });
27
+ }
28
+ const minSizeDescription = renderMinSize(minSize);
29
+ if (error) {
30
+ return (_jsxs("div", { children: [_jsx("i", { className: componentClassNames?.icon, children: ErrorIcon ? _jsx(ErrorIcon, {}) : null }), _jsx("p", { className: componentClassNames?.title, children: error }), _jsx("p", { className: componentClassNames?.description, children: minSizeDescription ?? 'Please try again' })] }));
31
+ }
32
+ return (_jsxs("div", { children: [_jsx("i", { className: componentClassNames?.icon, children: UploadIcon ? _jsx(UploadIcon, {}) : null }), _jsx("p", { className: componentClassNames?.title, children: "Click to Upload" }), _jsx("p", { className: componentClassNames?.description, children: minSizeDescription ?? 'or drag an image over this box' })] }));
33
+ }
34
+ export default ImageInputPanel;
@@ -1,13 +1,14 @@
1
- import type { ModalProps } from '../../../components/modals/Modal';
1
+ import type { ModalProps } from '../../../components/modals/Modal/index.js';
2
2
  import type { FormProps } from '../Form';
3
3
  export interface ModalFormProps {
4
4
  children: React.ReactNode;
5
5
  formProps: Omit<FormProps, 'children'>;
6
- hasServerError?: boolean;
7
6
  hasSubmit?: boolean;
8
7
  isDisabled?: boolean;
9
8
  modalProps: Omit<ModalProps, 'children'>;
9
+ serverError?: string | null;
10
10
  submitLabel?: string;
11
+ validationErrors?: string[];
11
12
  }
12
- declare function ModalForm({ children, formProps, hasServerError, hasSubmit, isDisabled, modalProps, submitLabel, }: Readonly<ModalFormProps>): React.ReactElement;
13
+ declare function ModalForm({ children, formProps, hasSubmit, isDisabled, modalProps, serverError, submitLabel, validationErrors, }: Readonly<ModalFormProps>): React.ReactElement;
13
14
  export default ModalForm;