@sqrzro/ui 4.0.0-alpha.7 → 4.0.0-alpha.71

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 (301) hide show
  1. package/dist/components/buttons/ActionButton/index.d.ts +8 -6
  2. package/dist/components/buttons/ActionButton/index.js +3 -27
  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 +7 -3
  6. package/dist/components/collections/Collection/index.js +9 -7
  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 +1 -1
  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 +1 -1
  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 +6 -7
  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 +11 -26
  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/normalize-href.d.ts +2 -0
  43. package/dist/components/collections/utility/normalize-href.js +8 -0
  44. package/dist/components/collections/utility/render-cell.d.ts +5 -0
  45. package/dist/components/collections/utility/render-cell.js +33 -0
  46. package/dist/components/elements/Badge/index.d.ts +12 -0
  47. package/dist/components/elements/Badge/index.js +9 -0
  48. package/dist/components/elements/ContentLink/index.d.ts +4 -0
  49. package/dist/components/elements/ContentLink/index.js +7 -0
  50. package/dist/components/elements/InfoPanel/index.d.ts +13 -0
  51. package/dist/components/elements/InfoPanel/index.js +20 -0
  52. package/dist/components/{utility → elements}/Link/index.d.ts +3 -2
  53. package/dist/components/{utility → elements}/Link/index.js +10 -9
  54. package/dist/components/elements/Menu/index.d.ts +19 -0
  55. package/dist/components/elements/Menu/index.js +17 -0
  56. package/dist/components/elements/MenuItem/index.d.ts +9 -0
  57. package/dist/components/elements/MenuItem/index.js +14 -0
  58. package/dist/components/elements/Page/index.d.ts +19 -0
  59. package/dist/components/elements/Page/index.js +18 -0
  60. package/dist/components/elements/Reference/index.d.ts +9 -0
  61. package/dist/components/elements/Reference/index.js +16 -0
  62. package/dist/components/elements/Summary/index.d.ts +13 -0
  63. package/dist/components/elements/Summary/index.js +22 -0
  64. package/dist/components/errors/AppError/index.d.ts +19 -0
  65. package/dist/components/errors/AppError/index.js +9 -0
  66. package/dist/components/errors/AppForbiddenError/index.d.ts +7 -0
  67. package/dist/components/errors/AppForbiddenError/index.js +6 -0
  68. package/dist/components/errors/AppNotFoundError/index.d.ts +7 -0
  69. package/dist/components/errors/AppNotFoundError/index.js +6 -0
  70. package/dist/components/errors/AppServerError/index.d.ts +8 -0
  71. package/dist/components/errors/AppServerError/index.js +17 -0
  72. package/dist/components/index.d.ts +35 -6
  73. package/dist/components/index.js +17 -3
  74. package/dist/components/modals/ConfirmModal/index.d.ts +5 -3
  75. package/dist/components/modals/ConfirmModal/index.js +3 -3
  76. package/dist/components/modals/Modal/index.d.ts +4 -4
  77. package/dist/components/modals/Modal/index.js +3 -3
  78. package/dist/components/modals/ModalActions/index.d.ts +3 -3
  79. package/dist/components/modals/ModalActions/index.js +4 -3
  80. package/dist/components/utility/Action/index.d.ts +11 -0
  81. package/dist/components/utility/Action/index.js +48 -0
  82. package/dist/components/utility/ActionList/index.d.ts +5 -5
  83. package/dist/components/utility/ActionList/index.js +5 -3
  84. package/dist/components/utility/AppBody/index.d.ts +5 -0
  85. package/dist/components/utility/AppBody/index.js +9 -0
  86. package/dist/components/utility/Calendar/index.d.ts +32 -0
  87. package/dist/components/utility/Calendar/index.js +66 -0
  88. package/dist/components/utility/CalendarDay/index.d.ts +11 -0
  89. package/dist/components/utility/CalendarDay/index.js +22 -0
  90. package/dist/components/utility/Confirmable/index.d.ts +9 -0
  91. package/dist/components/utility/Confirmable/index.js +14 -0
  92. package/dist/components/utility/Container/index.d.ts +1 -1
  93. package/dist/components/utility/Container/index.js +2 -2
  94. package/dist/components/utility/Loader/index.d.ts +1 -1
  95. package/dist/components/utility/Loader/index.js +5 -4
  96. package/dist/components/utility/Popover/index.d.ts +1 -1
  97. package/dist/components/utility/Popover/index.js +5 -5
  98. package/dist/components/utility/Toast/index.d.ts +2 -2
  99. package/dist/components/utility/Toast/index.js +6 -4
  100. package/dist/components/utility/Toaster/index.js +5 -5
  101. package/dist/filters/components/FilterBar/index.d.ts +5 -2
  102. package/dist/filters/components/FilterBarClientComponent/index.d.ts +2 -4
  103. package/dist/filters/components/FilterBarClientComponent/index.js +3 -43
  104. package/dist/filters/components/FilterClearButton/index.d.ts +7 -2
  105. package/dist/filters/components/FilterClearButton/index.js +8 -4
  106. package/dist/filters/components/FilterControl/index.d.ts +1 -1
  107. package/dist/filters/components/FilterControl/index.js +11 -4
  108. package/dist/filters/components/FilterItem/index.d.ts +2 -1
  109. package/dist/filters/components/FilterItem/index.js +3 -7
  110. package/dist/filters/components/FilterPanel/index.d.ts +1 -1
  111. package/dist/filters/{utility/filter.d.ts → filter.d.ts} +1 -1
  112. package/dist/filters/{utility/filter.js → filter.js} +8 -8
  113. package/dist/filters/filters/BooleanFilter/index.js +1 -1
  114. package/dist/filters/filters/CalendarFilter/index.js +3 -2
  115. package/dist/filters/filters/DateFilter/index.d.ts +1 -1
  116. package/dist/filters/filters/DateFilter/index.js +9 -4
  117. package/dist/filters/filters/DropdownFilter/index.js +1 -1
  118. package/dist/filters/filters/Filter/index.d.ts +5 -4
  119. package/dist/filters/filters/Filter/index.js +7 -7
  120. package/dist/filters/filters/SearchFilter/index.d.ts +7 -2
  121. package/dist/filters/filters/SearchFilter/index.js +8 -8
  122. package/dist/filters/filters/interfaces.d.ts +0 -2
  123. package/dist/filters/index.d.ts +2 -1
  124. package/dist/filters/index.js +2 -1
  125. package/dist/filters/interfaces.d.ts +2 -2
  126. package/dist/filters/utility/render-value.js +5 -5
  127. package/dist/forms/components/Autocomplete/index.d.ts +2 -2
  128. package/dist/forms/components/Autocomplete/index.js +3 -3
  129. package/dist/forms/components/AutocompleteList/index.d.ts +7 -0
  130. package/dist/forms/components/AutocompleteList/index.js +15 -0
  131. package/dist/forms/components/BaseCalendarInput/index.d.ts +11 -0
  132. package/dist/forms/components/BaseCalendarInput/index.js +22 -0
  133. package/dist/forms/components/CSVInput/index.d.ts +11 -0
  134. package/dist/forms/components/CSVInput/index.js +32 -0
  135. package/dist/forms/components/CalendarInput/index.d.ts +6 -0
  136. package/dist/forms/components/CalendarInput/index.js +14 -0
  137. package/dist/forms/components/ColorInput/index.d.ts +16 -0
  138. package/dist/forms/components/ColorInput/index.js +14 -0
  139. package/dist/forms/components/Dropdown/index.d.ts +1 -1
  140. package/dist/forms/components/Dropdown/index.js +9 -8
  141. package/dist/forms/components/DropdownItem/index.d.ts +9 -0
  142. package/dist/forms/components/DropdownItem/index.js +9 -0
  143. package/dist/forms/components/DropdownList/index.d.ts +1 -1
  144. package/dist/forms/components/DropdownList/index.js +7 -11
  145. package/dist/forms/components/EditableForm/index.d.ts +3 -3
  146. package/dist/forms/components/EditableForm/index.js +9 -9
  147. package/dist/forms/components/EditableFormField/index.d.ts +1 -1
  148. package/dist/forms/components/EditableFormField/index.js +3 -3
  149. package/dist/forms/components/EditableFormFields/index.d.ts +12 -0
  150. package/dist/forms/components/EditableFormFields/index.js +44 -1
  151. package/dist/forms/components/Form/index.d.ts +4 -2
  152. package/dist/forms/components/Form/index.js +7 -6
  153. package/dist/forms/components/FormError/index.d.ts +2 -2
  154. package/dist/forms/components/FormError/index.js +7 -5
  155. package/dist/forms/components/FormField/index.d.ts +7 -5
  156. package/dist/forms/components/FormField/index.js +15 -7
  157. package/dist/forms/components/FormFields/index.d.ts +22 -2
  158. package/dist/forms/components/FormFields/index.js +44 -2
  159. package/dist/forms/components/FormLabel/index.d.ts +1 -1
  160. package/dist/forms/components/FormLabel/index.js +4 -3
  161. package/dist/forms/components/ImageInput/index.d.ts +17 -0
  162. package/dist/forms/components/ImageInput/index.js +46 -0
  163. package/dist/forms/components/ImageInputPanel/index.d.ts +10 -0
  164. package/dist/forms/components/ImageInputPanel/index.js +34 -0
  165. package/dist/forms/components/ModalForm/index.d.ts +3 -2
  166. package/dist/forms/components/ModalForm/index.js +5 -4
  167. package/dist/forms/components/NumberInput/index.d.ts +1 -1
  168. package/dist/forms/components/PasswordComplexity/index.d.ts +16 -0
  169. package/dist/forms/components/PasswordComplexity/index.js +14 -0
  170. package/dist/forms/components/PasswordComplexityItem/index.d.ts +8 -0
  171. package/dist/forms/components/PasswordComplexityItem/index.js +10 -0
  172. package/dist/forms/components/PasswordInput/index.d.ts +1 -1
  173. package/dist/forms/components/PasswordInput/index.js +6 -6
  174. package/dist/forms/components/PointsInput/index.d.ts +5 -0
  175. package/dist/forms/components/{MoneyInput → PointsInput}/index.js +3 -3
  176. package/dist/forms/components/RangeCalendarInput/index.d.ts +6 -0
  177. package/dist/forms/components/RangeCalendarInput/index.js +14 -0
  178. package/dist/forms/components/StaticTextInput/index.d.ts +2 -2
  179. package/dist/forms/components/StaticTextInput/index.js +6 -7
  180. package/dist/forms/components/Switch/index.d.ts +9 -3
  181. package/dist/forms/components/Switch/index.js +7 -5
  182. package/dist/forms/components/TextArea/index.d.ts +14 -0
  183. package/dist/forms/components/TextArea/index.js +15 -0
  184. package/dist/forms/components/TextInput/index.d.ts +1 -1
  185. package/dist/forms/components/TextInput/index.js +5 -4
  186. package/dist/forms/hooks/useAutocomplete.d.ts +8 -6
  187. package/dist/forms/hooks/useAutocomplete.js +4 -4
  188. package/dist/forms/hooks/useDropdown.d.ts +5 -7
  189. package/dist/forms/hooks/useDropdown.js +5 -5
  190. package/dist/forms/hooks/useEditableDropdown.d.ts +4 -0
  191. package/dist/forms/hooks/useEditableDropdown.js +6 -0
  192. package/dist/forms/hooks/useEditableForm.js +8 -1
  193. package/dist/forms/hooks/useForm.d.ts +7 -14
  194. package/dist/forms/hooks/useForm.js +25 -27
  195. package/dist/forms/hooks/useModalForm.d.ts +2 -2
  196. package/dist/forms/hooks/useModalForm.js +9 -2
  197. package/dist/forms/index.d.ts +22 -6
  198. package/dist/forms/index.js +9 -4
  199. package/dist/forms/interfaces.d.ts +8 -1
  200. package/dist/forms/utility/extract-input-props.js +1 -0
  201. package/dist/forms/utility/format-date-value.d.ts +2 -0
  202. package/dist/forms/utility/format-date-value.js +13 -0
  203. package/dist/forms/utility/format-file-size.d.ts +2 -0
  204. package/dist/forms/utility/format-file-size.js +11 -0
  205. package/dist/forms/utility/preprocess-image.d.ts +6 -0
  206. package/dist/forms/utility/preprocess-image.js +58 -0
  207. package/dist/hooks/index.d.ts +3 -0
  208. package/dist/hooks/index.js +3 -0
  209. package/dist/hooks/useConfirmable.d.ts +21 -0
  210. package/dist/hooks/useConfirmable.js +58 -0
  211. package/dist/hooks/useDownload.d.ts +2 -0
  212. package/dist/hooks/useDownload.js +18 -0
  213. package/dist/hooks/usePopover.d.ts +12 -0
  214. package/dist/hooks/usePopover.js +24 -0
  215. package/dist/hooks/useSelected.d.ts +12 -0
  216. package/dist/hooks/useSelected.js +35 -0
  217. package/dist/hooks/useServerAction.d.ts +10 -0
  218. package/dist/hooks/useServerAction.js +17 -0
  219. package/dist/hooks/useSuccess.d.ts +10 -0
  220. package/dist/hooks/useSuccess.js +22 -0
  221. package/dist/mail/Mail/index.d.ts +8 -0
  222. package/dist/mail/Mail/index.js +108 -0
  223. package/dist/mail/MailBlock/index.d.ts +5 -0
  224. package/dist/mail/MailBlock/index.js +5 -0
  225. package/dist/mail/MailButton/index.d.ts +8 -0
  226. package/dist/mail/MailButton/index.js +28 -0
  227. package/dist/mail/MailTable/index.d.ts +9 -0
  228. package/dist/mail/MailTable/index.js +7 -0
  229. package/dist/mail/index.d.ts +8 -0
  230. package/dist/mail/index.js +4 -0
  231. package/dist/mail/utility/convert-to-datauri.d.ts +2 -0
  232. package/dist/mail/utility/convert-to-datauri.js +37 -0
  233. package/dist/mail/utility/interfaces.d.ts +23 -0
  234. package/dist/mail/utility/mail-config.d.ts +4 -0
  235. package/dist/mail/utility/mail-config.js +42 -0
  236. package/dist/navigation/components/AppNavigation/index.d.ts +3 -1
  237. package/dist/navigation/components/AppNavigation/index.js +4 -4
  238. package/dist/navigation/components/AppNavigationItem/index.d.ts +5 -3
  239. package/dist/navigation/components/AppNavigationItem/index.js +16 -7
  240. package/dist/navigation/components/Tabs/index.js +1 -4
  241. package/dist/navigation/hooks/useNavigation.d.ts +3 -3
  242. package/dist/navigation/hooks/useNavigation.js +5 -5
  243. package/dist/styles/classnames/config.d.ts +93 -0
  244. package/dist/styles/classnames/config.js +1 -0
  245. package/dist/styles/classnames/interfaces.d.ts +56 -0
  246. package/dist/styles/classnames/interfaces.js +1 -0
  247. package/dist/styles/classnames/utility/apply-sizes.d.ts +3 -0
  248. package/dist/styles/classnames/utility/apply-sizes.js +21 -0
  249. package/dist/styles/classnames/utility/apply-variants.d.ts +3 -0
  250. package/dist/styles/classnames/utility/apply-variants.js +26 -0
  251. package/dist/styles/classnames/utility/is-classname-object.d.ts +3 -0
  252. package/dist/styles/classnames/utility/is-classname-object.js +7 -0
  253. package/dist/styles/classnames/utility/parse-classnames.d.ts +6 -0
  254. package/dist/styles/classnames/utility/parse-classnames.js +33 -0
  255. package/dist/styles/context.d.ts +28 -0
  256. package/dist/styles/context.js +19 -0
  257. package/dist/styles/icons/config.d.ts +28 -0
  258. package/dist/styles/icons/config.js +1 -0
  259. package/dist/styles/icons/interfaces.d.ts +4 -0
  260. package/dist/styles/icons/interfaces.js +1 -0
  261. package/dist/styles/index.d.ts +6 -2
  262. package/dist/styles/index.js +2 -1
  263. package/dist/styles/styles.css +60 -0
  264. package/dist/utility/compare-dates.d.ts +2 -0
  265. package/dist/utility/compare-dates.js +13 -0
  266. package/dist/utility/get-date-state.d.ts +8 -0
  267. package/dist/utility/get-date-state.js +63 -0
  268. package/dist/utility/get-days.d.ts +2 -0
  269. package/dist/utility/get-days.js +5 -0
  270. package/dist/utility/get-weeks.d.ts +2 -0
  271. package/dist/utility/get-weeks.js +31 -0
  272. package/dist/utility/index.d.ts +1 -1
  273. package/dist/utility/interfaces.d.ts +33 -17
  274. package/dist/utility/is-data-object-array.d.ts +3 -0
  275. package/dist/utility/is-data-object-array.js +5 -0
  276. package/dist/utility/is-data-object.d.ts +3 -0
  277. package/dist/utility/is-data-object.js +4 -0
  278. package/package.json +34 -22
  279. package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
  280. package/dist/components/buttons/ConfirmableButton/index.js +0 -13
  281. package/dist/components/collections/utility/filter-columns.d.ts +0 -3
  282. package/dist/components/collections/utility/filter-columns.js +0 -8
  283. package/dist/components/collections/utility/get-selected-from-search-params.d.ts +0 -2
  284. package/dist/components/collections/utility/get-selected-from-search-params.js +0 -5
  285. package/dist/components/collections/utility/set-selected-to-search-params.d.ts +0 -2
  286. package/dist/components/collections/utility/set-selected-to-search-params.js +0 -4
  287. package/dist/components/utility/ClassNames/index.d.ts +0 -6
  288. package/dist/components/utility/ClassNames/index.js +0 -7
  289. package/dist/components/utility/Page/index.d.ts +0 -18
  290. package/dist/components/utility/Page/index.js +0 -34
  291. package/dist/components/utility/RootLayout/index.d.ts +0 -15
  292. package/dist/components/utility/RootLayout/index.js +0 -14
  293. package/dist/forms/components/MoneyInput/index.d.ts +0 -5
  294. package/dist/styles/config.d.ts +0 -64
  295. package/dist/styles/config.js +0 -43
  296. package/dist/styles/icons.d.ts +0 -15
  297. package/dist/styles/icons.js +0 -7
  298. package/dist/styles/interfaces.d.ts +0 -41
  299. /package/dist/{styles → mail/utility}/interfaces.js +0 -0
  300. /package/dist/styles/{tw.d.ts → classnames/utility/tw.d.ts} +0 -0
  301. /package/dist/styles/{tw.js → classnames/utility/tw.js} +0 -0
@@ -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';
5
+ import tw from '../../../styles/classnames/utility/tw';
6
6
  import FormError from '../FormError';
7
7
  import FormLabel from '../FormLabel';
8
8
  import ActionButton from '../../../components/buttons/ActionButton';
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,39 @@
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';
3
5
  import type { DropdownComponentProps } from '../Dropdown';
4
- import type { MoneyInputComponentProps } from '../MoneyInput';
6
+ import type { ImageInputComponentProps } from '../ImageInput';
7
+ import type { PointsInputComponentProps } from '../PointsInput';
5
8
  import type { NumberInputComponentProps } from '../NumberInput';
6
9
  import type { PasswordInputComponentProps } from '../PasswordInput';
10
+ import type { RangeCalendarInputComponentProps } from '../RangeCalendarInput';
11
+ import type { SwitchComponentProps } from '../Switch';
12
+ import type { TextAreaComponentProps } from '../TextArea';
7
13
  import type { TextInputComponentProps } from '../TextInput';
8
14
  export type AutocompleteFormFieldProps<T> = FormFieldComponentProps<T | null> & AutocompleteComponentProps<T>;
9
15
  export declare function AutocompleteFormField<T>(props: Readonly<AutocompleteFormFieldProps<T>>): React.ReactElement;
16
+ export type CalendarFormFieldProps = FormFieldComponentProps<Date | null> & CalendarInputComponentProps;
17
+ export declare function CalendarFormField(props: Readonly<CalendarFormFieldProps>): React.ReactElement;
18
+ export type ColorFormFieldProps = FormFieldComponentProps<string> & ColorInputComponentProps;
19
+ export declare function ColorFormField(props: Readonly<ColorFormFieldProps>): React.ReactElement;
20
+ export type CSVFormFieldProps = FormFieldComponentProps<string>;
21
+ export declare function CSVFormField(props: Readonly<CSVFormFieldProps>): React.ReactElement;
10
22
  export type DropdownFormFieldProps<T> = FormFieldComponentProps<T | null> & DropdownComponentProps<T>;
11
23
  export declare function DropdownFormField<T>(props: Readonly<DropdownFormFieldProps<T>>): React.ReactElement;
12
- export type MoneyFormFieldProps = FormFieldComponentProps<number> & MoneyInputComponentProps;
24
+ export type ImageFormFieldProps = FormFieldComponentProps<string | null> & ImageInputComponentProps;
25
+ export declare function ImageFormField(props: Readonly<ImageFormFieldProps>): React.ReactElement;
26
+ export type MoneyFormFieldProps = FormFieldComponentProps<number> & PointsInputComponentProps;
13
27
  export declare function MoneyFormField(props: Readonly<MoneyFormFieldProps>): React.ReactElement;
14
28
  export type NumberFormFieldProps = FormFieldComponentProps<number> & NumberInputComponentProps;
15
29
  export declare function NumberFormField(props: Readonly<NumberFormFieldProps>): React.ReactElement;
16
30
  export type PasswordFormFieldProps = FormFieldComponentProps<string> & PasswordInputComponentProps;
17
31
  export declare function PasswordFormField(props: Readonly<PasswordFormFieldProps>): React.ReactElement;
32
+ export type RangeCalendarFormFieldProps = FormFieldComponentProps<[Date, Date] | null> & RangeCalendarInputComponentProps;
33
+ export declare function RangeCalendarFormField(props: Readonly<RangeCalendarFormFieldProps>): React.ReactElement;
34
+ export type SwitchFormFieldProps = FormFieldComponentProps<boolean> & SwitchComponentProps;
35
+ export declare function SwitchFormField(props: SwitchFormFieldProps): React.ReactElement;
18
36
  export type TextFormFieldProps = FormFieldComponentProps<string> & TextInputComponentProps;
19
37
  export declare function TextFormField(props: Readonly<TextFormFieldProps>): React.ReactElement;
38
+ export type TextAreaFormFieldProps = FormFieldComponentProps<string> & TextAreaComponentProps;
39
+ export declare function TextAreaFormField(props: Readonly<TextAreaFormFieldProps>): React.ReactElement;
@@ -2,25 +2,52 @@ 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';
5
8
  import Dropdown from '../Dropdown';
6
9
  import FormField from '../FormField';
7
- import MoneyInput from '../MoneyInput';
10
+ import ImageInput from '../ImageInput';
11
+ import PointsInput from '../PointsInput';
8
12
  import NumberInput from '../NumberInput';
9
13
  import PasswordInput from '../PasswordInput';
14
+ import RangeCalendarInput from '../RangeCalendarInput';
15
+ import Switch from '../Switch';
16
+ import TextArea from '../TextArea';
10
17
  import TextInput from '../TextInput';
11
18
  export function AutocompleteFormField(props) {
12
19
  const { fieldProps, inputProps } = extractInputProps(props);
13
20
  const renderInput = useCallback((renderProps) => (_jsx(Autocomplete, { ...renderProps, ...inputProps })), [inputProps]);
14
21
  return _jsx(FormField, { ...fieldProps, render: renderInput });
15
22
  }
23
+ export function CalendarFormField(props) {
24
+ const { fieldProps, inputProps } = extractInputProps(props);
25
+ const renderInput = useCallback((renderProps) => (_jsx(CalendarInput, { ...renderProps, ...inputProps })), [inputProps]);
26
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
27
+ }
28
+ export function ColorFormField(props) {
29
+ const { fieldProps, inputProps } = extractInputProps(props);
30
+ const renderInput = useCallback((renderProps) => (_jsx(ColorInput, { ...renderProps, ...inputProps })), [inputProps]);
31
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
32
+ }
33
+ export function CSVFormField(props) {
34
+ const { fieldProps, inputProps } = extractInputProps(props);
35
+ const renderInput = useCallback((renderProps) => (_jsx(CSVInput, { ...renderProps, ...inputProps })), [inputProps]);
36
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
37
+ }
16
38
  export function DropdownFormField(props) {
17
39
  const { fieldProps, inputProps } = extractInputProps(props);
18
40
  const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
19
41
  return _jsx(FormField, { ...fieldProps, render: renderInput });
20
42
  }
43
+ export function ImageFormField(props) {
44
+ const { fieldProps, inputProps } = extractInputProps(props);
45
+ const renderInput = useCallback((renderProps) => (_jsx(ImageInput, { ...renderProps, ...inputProps })), [inputProps]);
46
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
47
+ }
21
48
  export function MoneyFormField(props) {
22
49
  const { fieldProps, inputProps } = extractInputProps(props);
23
- const renderInput = useCallback((renderProps) => (_jsx(MoneyInput, { ...renderProps, ...inputProps })), [inputProps]);
50
+ const renderInput = useCallback((renderProps) => (_jsx(PointsInput, { ...renderProps, ...inputProps })), [inputProps]);
24
51
  return _jsx(FormField, { ...fieldProps, render: renderInput });
25
52
  }
26
53
  export function NumberFormField(props) {
@@ -33,8 +60,23 @@ export function PasswordFormField(props) {
33
60
  const renderInput = useCallback((renderProps) => (_jsx(PasswordInput, { ...renderProps, ...inputProps })), [inputProps]);
34
61
  return _jsx(FormField, { ...fieldProps, render: renderInput });
35
62
  }
63
+ export function RangeCalendarFormField(props) {
64
+ const { fieldProps, inputProps } = extractInputProps(props);
65
+ const renderInput = useCallback((renderProps) => (_jsx(RangeCalendarInput, { ...renderProps, ...inputProps })), [inputProps]);
66
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
67
+ }
68
+ export function SwitchFormField(props) {
69
+ const { fieldProps, inputProps } = extractInputProps(props);
70
+ const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps })), [inputProps]);
71
+ return _jsx(FormField, { ...fieldProps, hasAssistiveLabel: true, hasAssistiveDetails: true, render: renderInput });
72
+ }
36
73
  export function TextFormField(props) {
37
74
  const { fieldProps, inputProps } = extractInputProps(props);
38
75
  const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
39
76
  return _jsx(FormField, { ...fieldProps, render: renderInput });
40
77
  }
78
+ export function TextAreaFormField(props) {
79
+ const { fieldProps, inputProps } = extractInputProps(props);
80
+ const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
81
+ return _jsx(FormField, { ...fieldProps, render: renderInput });
82
+ }
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
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';
4
+ import tw from '../../../styles/classnames/utility/tw';
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;
@@ -0,0 +1,17 @@
1
+ import type { FormResponse, InputProps } from '../../../forms/interfaces';
2
+ import type { ClassNameProps, HighlightableClassName } from '../../../styles/classnames/interfaces';
3
+ export interface ImageInputClassNames {
4
+ description: string;
5
+ icon: HighlightableClassName;
6
+ image: string;
7
+ root: string;
8
+ title: string;
9
+ }
10
+ export interface ImageInputComponentProps {
11
+ maxSize?: [number?, number?];
12
+ minSize?: [number?, number?];
13
+ onUpload?: (file: File) => FormResponse<string>;
14
+ }
15
+ export type ImageInputProps = ClassNameProps<ImageInputClassNames> & InputProps<string | null> & ImageInputComponentProps;
16
+ declare function ImageInput({ classNames, classNameProps, id, isDisabled, maxSize, minSize, name, onChange, onUpload, value, }: Readonly<ImageInputProps>): React.ReactElement;
17
+ export default ImageInput;
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import preprocessImage from '../../../forms/utility/preprocess-image';
5
+ import { useClassNames } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
7
+ import ImageInputPanel from '../ImageInputPanel';
8
+ function ImageInput({ classNames, classNameProps, 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], { maxSize, minSize });
27
+ const fnReturn = await onUpload(preprocessed);
28
+ setIsLoading(false);
29
+ if (fnReturn.error) {
30
+ setError(fnReturn.error);
31
+ }
32
+ else if (fnReturn.validation) {
33
+ setError(Object.values(fnReturn.validation)[0]);
34
+ }
35
+ else if (fnReturn.data !== null) {
36
+ onChange?.({ target: { name, value: fnReturn.data } });
37
+ }
38
+ }
39
+ catch (err) {
40
+ setIsLoading(false);
41
+ setError(err instanceof Error ? err.message : 'An unexpected error occurred');
42
+ }
43
+ }
44
+ 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: "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 })] }));
45
+ }
46
+ export default ImageInput;
@@ -0,0 +1,10 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
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';
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;
@@ -3,11 +3,12 @@ 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;
@@ -4,13 +4,14 @@ import Modal from '../../../components/modals/Modal';
4
4
  import ModalActions from '../../../components/modals/ModalActions';
5
5
  import useSearchParamsHref from '../../../hooks/useSearchParamsHref';
6
6
  import Form from '../Form';
7
- function ModalForm({ children, formProps, hasServerError, hasSubmit = true, isDisabled, modalProps, submitLabel, }) {
7
+ import { InfoPanel } from '../../../components';
8
+ function ModalForm({ children, formProps, hasSubmit = true, isDisabled, modalProps, serverError, submitLabel, validationErrors, }) {
8
9
  const { setSearchParamsHref } = useSearchParamsHref();
9
10
  function handleCancel() {
10
- setSearchParamsHref('action', null);
11
+ setSearchParamsHref({ action: null, id: null });
11
12
  }
12
- return (_jsx(Modal, { ...modalProps, children: _jsxs(Form, { ...formProps, children: [children, hasServerError ? _jsx("div", { children: "SERVER ERROR" }) : null, _jsx(ModalActions, { actions: [
13
- { label: 'Cancel', onClick: handleCancel, variant: 'link' },
13
+ return (_jsx(Modal, { ...modalProps, children: _jsxs(Form, { ...formProps, children: [serverError ? _jsx(InfoPanel, { variant: "error", children: serverError }) : null, validationErrors?.length ? (_jsx(InfoPanel, { variant: "error", children: JSON.stringify(validationErrors) })) : null, children, _jsx(ModalActions, { actions: [
14
+ { label: 'Cancel', onClick: handleCancel },
14
15
  ...(modalProps.actions || []),
15
16
  hasSubmit
16
17
  ? {
@@ -1,4 +1,4 @@
1
- import { ClassNameProps } from '../../../styles/interfaces';
1
+ import { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  import type { InputProps } from '../../interfaces';
3
3
  import type { TextInputClassNames, TextInputComponentProps } from '../TextInput';
4
4
  export type NumberInputComponentProps = TextInputComponentProps;
@@ -0,0 +1,16 @@
1
+ import { ClassNameProps } from '../../../styles';
2
+ export interface PasswordComplexityClassNames {
3
+ root: string;
4
+ list: string;
5
+ item: string;
6
+ icon: string;
7
+ }
8
+ export interface PasswordComplexityProps extends ClassNameProps<PasswordComplexityClassNames> {
9
+ data: {
10
+ status: boolean;
11
+ value: string;
12
+ }[];
13
+ onComplexity?: (isValid: boolean) => void;
14
+ }
15
+ declare function PasswordComplexity({ classNameProps, classNames, data, onComplexity, }: PasswordComplexityProps): React.ReactElement;
16
+ export default PasswordComplexity;
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles';
4
+ import useDeepCompareEffect from 'use-deep-compare-effect';
5
+ import PasswordComplexityItem from '../PasswordComplexityItem';
6
+ function PasswordComplexity({ classNameProps, classNames, data, onComplexity, }) {
7
+ useDeepCompareEffect(() => {
8
+ onComplexity?.(data.every((item) => item.status));
9
+ }, [data]);
10
+ const isValid = data.every((item) => item.status);
11
+ const componentClassNames = useClassNames('passwordComplexity', { props: { ...classNameProps, isValid } }, classNames);
12
+ return (_jsx("aside", { className: componentClassNames?.root, children: _jsx("ul", { className: componentClassNames?.list, children: data.map((item) => (_jsx(PasswordComplexityItem, { classNameProps: classNameProps, classNames: classNames, isValid: item.status, value: item.value }, item.value))) }) }));
13
+ }
14
+ export default PasswordComplexity;
@@ -0,0 +1,8 @@
1
+ import { ClassNameProps } from '../../../styles';
2
+ import type { PasswordComplexityClassNames } from '../PasswordComplexity';
3
+ interface PasswordComplexityItemProps extends ClassNameProps<PasswordComplexityClassNames> {
4
+ isValid: boolean;
5
+ value: string;
6
+ }
7
+ declare function PasswordComplexityItem({ classNameProps, classNames, isValid, value, }: PasswordComplexityItemProps): React.ReactElement;
8
+ export default PasswordComplexityItem;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useClassNames, useIcon } from '../../../styles';
3
+ function PasswordComplexityItem({ classNameProps, classNames, isValid, value, }) {
4
+ const componentClassNames = useClassNames('passwordComplexity', { props: { ...classNameProps, isValid } }, classNames);
5
+ const InvalidIcon = useIcon('passwordComplexity.invalid');
6
+ const ValidIcon = useIcon('passwordComplexity.valid');
7
+ const Icon = isValid ? ValidIcon : InvalidIcon;
8
+ return (_jsxs("li", { className: componentClassNames?.item, children: [Icon ? (_jsx("div", { className: componentClassNames?.icon, children: _jsx(Icon, {}) })) : null, value] }));
9
+ }
10
+ export default PasswordComplexityItem;
@@ -1,5 +1,5 @@
1
1
  import { InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, SelectableClassName } from '../../../styles/interfaces';
2
+ import type { ClassNameProps, SelectableClassName } from '../../../styles/classnames/interfaces';
3
3
  import type { TextInputComponentProps } from '../TextInput';
4
4
  export interface PasswordInputClassNames {
5
5
  action: string;
@@ -1,17 +1,17 @@
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 { getIcon } from '../../../styles/icons';
6
- import tw from '../../../styles/tw';
4
+ import { useClassNames, useIcon } from '../../../styles/context';
7
5
  import TextInput from '../TextInput';
8
6
  function PasswordInput({ classNameProps, classNames, ...props }) {
9
- const componentClassNames = classNames || getClassNames('passwordInput')?.(classNameProps);
10
- const Icon = getIcon('password');
11
7
  const [isVisible, setIsVisible] = useState(false);
8
+ const componentClassNames = useClassNames('passwordInput', { props: classNameProps, states: { isSelected: isVisible } }, classNames);
9
+ const HiddenIcon = useIcon('passwordInput.hidden');
10
+ const VisibleIcon = useIcon('passwordInput.visible');
11
+ const Icon = isVisible ? VisibleIcon : HiddenIcon;
12
12
  function toggleVisible() {
13
13
  setIsVisible(!isVisible);
14
14
  }
15
- return (_jsxs("div", { className: "relative", children: [_jsx(TextInput, { type: isVisible ? 'text' : 'password', ...props }), _jsx("div", { className: componentClassNames?.action, children: _jsxs("button", { className: tw(componentClassNames?.icon?.default, isVisible ? componentClassNames?.icon?.selected : null), onClick: toggleVisible, type: "button", children: [Icon ? _jsx(Icon, {}) : null, isVisible ? 'Hide' : 'Show'] }) })] }));
15
+ return (_jsxs("div", { className: "relative", children: [_jsx(TextInput, { type: isVisible ? 'text' : 'password', ...props }), _jsx("div", { className: componentClassNames?.action, children: _jsxs("button", { className: componentClassNames?.icon, onClick: toggleVisible, type: "button", children: [Icon ? _jsx(Icon, {}) : null, isVisible ? 'Hide' : 'Show'] }) })] }));
16
16
  }
17
17
  export default PasswordInput;
@@ -0,0 +1,5 @@
1
+ import type { NumberInputComponentProps, NumberInputProps } from '../NumberInput';
2
+ export type PointsInputComponentProps = NumberInputComponentProps;
3
+ export type PointsInputProps = NumberInputProps;
4
+ declare function PointsInput({ name, onChange, value, ...props }: Readonly<PointsInputProps>): React.ReactElement;
5
+ export default PointsInput;
@@ -13,10 +13,10 @@ function getValue(value) {
13
13
  }
14
14
  return value / FACTOR;
15
15
  }
16
- function MoneyInput({ name, onChange, prefix = '£', value, ...props }) {
16
+ function PointsInput({ name, onChange, value, ...props }) {
17
17
  function handleChange(event) {
18
18
  onChange?.({ target: { name, value: setValue(event.target.value) } });
19
19
  }
20
- return (_jsx(NumberInput, { prefix: prefix, ...props, name: name, onChange: handleChange, value: getValue(value) }));
20
+ return _jsx(NumberInput, { ...props, name: name, onChange: handleChange, value: getValue(value) });
21
21
  }
22
- export default MoneyInput;
22
+ export default PointsInput;
@@ -0,0 +1,6 @@
1
+ import { InputProps } from '../../interfaces';
2
+ import { BaseCalendarInputComponentProps } from '../BaseCalendarInput';
3
+ export type RangeCalendarInputComponentProps = BaseCalendarInputComponentProps;
4
+ export type RangeCalendarInputProps = InputProps<[Date, Date] | null> & RangeCalendarInputComponentProps;
5
+ declare function RangeCalendarInput({ name, onChange, value, ...baseProps }: RangeCalendarInputProps): React.ReactElement;
6
+ export default RangeCalendarInput;
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import Calendar from '../../../components/utility/Calendar';
4
+ import BaseCalendarInput from '../BaseCalendarInput';
5
+ function RangeCalendarInput({ name, onChange, value, ...baseProps }) {
6
+ function handleChange(eventValue) {
7
+ onChange?.({ target: { name, value: eventValue } });
8
+ }
9
+ function handleClear() {
10
+ onChange?.({ target: { name, value: null } });
11
+ }
12
+ return (_jsx(BaseCalendarInput, { ...baseProps, name: name, onClear: handleClear, value: value, children: _jsx(Calendar, { isRange: true, onChange: handleChange, value: value }) }));
13
+ }
14
+ export default RangeCalendarInput;
@@ -1,5 +1,5 @@
1
1
  import type { InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
3
3
  export interface StaticTextInputClassNames {
4
4
  root: ErrorableClassName;
5
5
  placeholder: string;
@@ -10,7 +10,7 @@ export interface StaticTextInputClassNames {
10
10
  }
11
11
  export interface StaticTextInputProps extends ClassNameProps<StaticTextInputClassNames>, Omit<InputProps<string[] | string, string[] | string>, 'onChange'> {
12
12
  details?: string | null;
13
- label: string;
13
+ label: React.ReactNode;
14
14
  icon?: React.ReactNode;
15
15
  isOptional?: boolean;
16
16
  onClear?: () => void;
@@ -1,8 +1,9 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { Fragment } from 'react';
3
4
  import Assistive from '../../../components/utility/Assistive';
4
- import { getClassNames } from '../../../styles/config';
5
- import tw from '../../../styles/tw';
5
+ import { useClassNames, useIcon } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
6
7
  function hasValue(value) {
7
8
  if (Array.isArray(value)) {
8
9
  return Boolean(value.filter((item) => Boolean(item)).length);
@@ -10,13 +11,11 @@ function hasValue(value) {
10
11
  return Boolean(value);
11
12
  }
12
13
  function StaticTextInput({ classNames, classNameProps, details, hasError, icon, isDisabled, isOptional, label, name, onClear, onClick, onKeyDown, placeholder = 'Select...', value, }) {
13
- const componentClassNames = {
14
- ...getClassNames('staticTextInput')?.(classNameProps),
15
- ...classNames,
16
- };
14
+ const componentClassNames = useClassNames('staticTextInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
15
+ const ClearIcon = useIcon('staticTextInput.clear');
17
16
  function handleClear() {
18
17
  onClear?.();
19
18
  }
20
- return (_jsxs("div", { className: tw('relative', isDisabled ? 'pointer-events-none opacity-30' : null, componentClassNames.root?.default, hasError ? componentClassNames.root?.error : null), children: [_jsx("input", { name: name, type: "hidden", value: value ? value.toString() : '' }), label ? (_jsxs(Fragment, { children: [_jsx("span", { className: tw(componentClassNames.label), children: label }), details ? (_jsx("small", { className: tw(componentClassNames.details), children: details })) : null] })) : (_jsx("span", { className: tw(componentClassNames.placeholder), children: placeholder })), onClick ? (_jsx("button", { className: "absolute -bottom-px -left-px -right-px -top-px", disabled: isDisabled, onClick: onClick, onKeyDown: onKeyDown, tabIndex: 0, type: "button", children: _jsx(Assistive, { children: "Toggle" }) })) : null, _jsxs("div", { className: "absolute bottom-0 right-0 top-0 flex w-0 items-center justify-end", children: [isOptional && hasValue(value) ? (_jsx("button", { className: tw('flex-none', componentClassNames.clear), onClick: handleClear, type: "button", children: _jsx(Assistive, { children: "Clear" }) })) : null, icon && !isDisabled ? (_jsx("i", { className: tw('pointer-events-none flex-none', componentClassNames.icon) })) : null] })] }));
19
+ return (_jsxs("div", { className: tw('relative', componentClassNames?.root, isDisabled ? 'pointer-events-none opacity-30' : null), children: [_jsx("input", { name: name, type: "hidden", value: value ? value.toString() : '' }), label ? (_jsxs(Fragment, { children: [_jsx("span", { className: componentClassNames?.label, children: label }), details ? (_jsx("small", { className: componentClassNames?.details, children: details })) : null] })) : (_jsx("span", { className: componentClassNames?.placeholder, children: placeholder })), onClick ? (_jsx("button", { className: "absolute -bottom-px -left-px -right-px -top-px", disabled: isDisabled, onClick: onClick, onKeyDown: onKeyDown, tabIndex: 0, type: "button", children: _jsx(Assistive, { children: "Toggle" }) })) : null, _jsxs("div", { className: "absolute bottom-0 right-1 top-0 flex w-0 items-center justify-end", children: [isOptional && hasValue(value) ? (_jsxs("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: [ClearIcon ? _jsx(ClearIcon, {}) : null, _jsx(Assistive, { children: "Clear" })] })) : null, icon && !isDisabled ? (_jsx("div", { className: tw('pointer-events-none flex-none', componentClassNames?.icon), children: icon })) : null] })] }));
21
20
  }
22
21
  export default StaticTextInput;
@@ -1,11 +1,17 @@
1
1
  import type { InputProps } from '../../../forms/interfaces';
2
- import { CheckableClassName, ClassNameProps } from '../../../styles/interfaces';
2
+ import { CheckableClassName, ClassNameProps } from '../../../styles/classnames/interfaces';
3
3
  export interface SwitchClassNames {
4
4
  root: string;
5
5
  control: string;
6
6
  input: CheckableClassName;
7
7
  icon: CheckableClassName;
8
+ label: string;
9
+ details: string;
8
10
  }
9
- export type SwitchProps = ClassNameProps<SwitchClassNames> & InputProps<boolean>;
10
- declare function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, value, }: Readonly<SwitchProps>): React.ReactElement;
11
+ export type SwitchComponentProps = {
12
+ details?: React.ReactNode;
13
+ label?: React.ReactNode;
14
+ };
15
+ export type SwitchProps = ClassNameProps<SwitchClassNames> & InputProps<boolean> & SwitchComponentProps;
16
+ declare function Switch({ classNameProps, classNames, details, id, isDisabled, label, name, onChange, value, }: Readonly<SwitchProps>): React.ReactElement;
11
17
  export default Switch;
@@ -1,9 +1,11 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { Fragment } from 'react';
3
- import { getClassNames } from '../../../styles/config';
4
- import tw from '../../../styles/tw';
5
- function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, value, }) {
6
- const componentClassNames = classNames || getClassNames('switch')?.(classNameProps);
4
+ import Assistive from '../../../components/utility/Assistive';
5
+ import { useClassNames } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
7
+ function Switch({ classNameProps, classNames, details, id, isDisabled, label, name, onChange, value, }) {
8
+ const componentClassNames = useClassNames('switch', { props: classNameProps, states: { isChecked: Boolean(value) } }, classNames);
7
9
  function handleChange(event) {
8
10
  if (onChange) {
9
11
  const inputEvent = {
@@ -12,6 +14,6 @@ function Switch({ classNameProps, classNames, id, isDisabled, name, onChange, va
12
14
  onChange(inputEvent);
13
15
  }
14
16
  }
15
- return (_jsxs(Fragment, { children: [_jsx("input", { name: name, type: "hidden", value: "false" }), _jsx("div", { className: tw('block', componentClassNames?.root), children: _jsxs("div", { className: tw('relative', componentClassNames?.control), children: [_jsx("input", { "aria-checked": Boolean(value), checked: Boolean(value), className: tw('appearance-none', componentClassNames?.input?.default, value ? componentClassNames?.input?.checked : null), disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "checkbox", value: "true" }), _jsx("i", { className: tw(componentClassNames?.icon?.default, value ? componentClassNames?.icon?.checked : null) })] }) })] }));
17
+ return (_jsxs(Fragment, { children: [_jsx("input", { name: name, type: "hidden", value: "false" }), _jsxs("div", { className: tw('block', componentClassNames?.root), children: [_jsxs("div", { className: tw('relative', componentClassNames?.control, isDisabled ? 'pointer-events-none opacity-30' : ''), children: [_jsx("input", { "aria-checked": Boolean(value), checked: Boolean(value), className: tw('appearance-none', componentClassNames?.input), disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "checkbox", value: "true" }), _jsx("i", { className: componentClassNames?.icon })] }), label ? (_jsxs("label", { htmlFor: id || name, children: [_jsx("span", { className: tw('', componentClassNames?.label), children: label }), details ? (_jsx("small", { className: tw('', componentClassNames?.details), children: details })) : null] })) : (_jsx(Assistive, { children: "Yes?" }))] })] }));
16
18
  }
17
19
  export default Switch;
@@ -0,0 +1,14 @@
1
+ import type { InputProps } from '../../../forms/interfaces';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
3
+ export interface TextAreaClassNames {
4
+ root: ErrorableClassName;
5
+ }
6
+ export interface TextAreaComponentProps {
7
+ onBlur?: React.EventHandler<React.FocusEvent>;
8
+ onFocus?: React.EventHandler<React.FocusEvent>;
9
+ placeholder?: string;
10
+ rows?: number;
11
+ }
12
+ export type TextAreaProps = ClassNameProps<TextAreaClassNames> & InputProps<string> & TextAreaComponentProps;
13
+ declare function TextArea({ classNames, classNameProps, hasError, id, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, rows, value, }: Readonly<TextAreaProps>): React.ReactElement;
14
+ export default TextArea;