@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
@@ -1,16 +1,17 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import Modal from '../../../components/modals/Modal';
4
- import ModalActions from '../../../components/modals/ModalActions';
5
- import useSearchParamsHref from '../../../hooks/useSearchParamsHref';
3
+ import Modal from '../../../components/modals/Modal/index.js';
4
+ import ModalActions from '../../../components/modals/ModalActions/index.js';
5
+ import useSearchParamsHref from '../../../hooks/useSearchParamsHref.js';
6
6
  import Form from '../Form';
7
- function ModalForm({ children, formProps, hasServerError, hasSubmit = true, isDisabled, modalProps, submitLabel, }) {
7
+ import { InfoPanel } from '../../../components/index.js';
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.js';
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/index.js';
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/index.js';
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/index.js';
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/index.js';
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
- import { InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, SelectableClassName } from '../../../styles/interfaces';
1
+ import { InputProps } from '../../interfaces.js';
2
+ import type { ClassNameProps, SelectableClassName } from '../../../styles/classnames/interfaces.js';
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.js';
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/index.js';
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
- import type { InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
1
+ import type { InputProps } from '../../interfaces.js';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
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
- import Assistive from '../../../components/utility/Assistive';
4
- import { getClassNames } from '../../../styles/config';
5
- import tw from '../../../styles/tw';
4
+ import Assistive from '../../../components/utility/Assistive/index.js';
5
+ import { useClassNames, useIcon } from '../../../styles/context.js';
6
+ import tw from '../../../styles/classnames/utility/tw.js';
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
- import type { InputProps } from '../../../forms/interfaces';
2
- import { CheckableClassName, ClassNameProps } from '../../../styles/interfaces';
1
+ import type { InputProps } from '../../interfaces.js';
2
+ import { CheckableClassName, ClassNameProps } from '../../../styles/classnames/interfaces.js';
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/index.js';
5
+ import { useClassNames } from '../../../styles/context.js';
6
+ import tw from '../../../styles/classnames/utility/tw.js';
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 '../../interfaces.js';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
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;
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context.js';
4
+ import tw from '../../../styles/classnames/utility/tw.js';
5
+ function TextArea({ classNames, classNameProps, hasError, id, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, rows = 4, value, }) {
6
+ const componentClassNames = useClassNames('textArea', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
7
+ function handleChange(event) {
8
+ if (onChange) {
9
+ const target = { name, value: event.target.value };
10
+ onChange({ target });
11
+ }
12
+ }
13
+ return (_jsx("textarea", { "aria-invalid": hasError, "aria-labelledby": hasError ? `${id || name}_err` : undefined /* eslint-disable-line no-undefined */, className: tw('w-full focus-visible:outline-0', isDisabled ? 'pointer-events-none opacity-30' : null, componentClassNames?.root), disabled: isDisabled, id: id || name, name: name, onBlur: onBlur, onChange: handleChange, onFocus: onFocus, onKeyDown: onKeyDown, placeholder: placeholder, rows: rows, value: value || '' }));
14
+ }
15
+ export default TextArea;
@@ -1,5 +1,5 @@
1
- import type { InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
1
+ import type { InputProps } from '../../interfaces.js';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces.js';
3
3
  export interface TextInputClassNames {
4
4
  loading: string;
5
5
  prefix: ErrorableClassName;
@@ -1,6 +1,7 @@
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
  /**
5
6
  *
6
7
  * ## ClassNames
@@ -14,7 +15,7 @@ import tw from '../../../styles/tw';
14
15
  * button itself is handled by the `renderClear` prop. | `string` |
15
16
  */
16
17
  function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, isDisabled, name, onBlur, onChange, onFocus, onKeyDown, placeholder, prefix, ref, suffix, type, value, }) {
17
- const componentClassNames = classNames || getClassNames('textInput')?.(classNameProps);
18
+ const componentClassNames = useClassNames('textInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
18
19
  function handleChange(event) {
19
20
  if (onChange) {
20
21
  const target = { name, value: event.target.value };
@@ -25,6 +26,6 @@ function TextInput({ classNames, classNameProps, hasError, id, isAutocomplete, i
25
26
  ? `${id || name}_err`
26
27
  : undefined /* eslint-disable-line no-undefined */, autoComplete: isAutocomplete === false
27
28
  ? 'one-time-code'
28
- : undefined /* eslint-disable-line no-undefined */, className: tw('peer w-full focus-visible:outline-0', prefix ? 'border-l-0' : null, (!prefix && suffix) || value ? 'border-r-0' : null, componentClassNames?.root?.default, hasError ? componentClassNames?.root?.error : null), disabled: isDisabled, formNoValidate: true, id: id || name, name: name, onBlur: onBlur, onChange: handleChange, onFocus: onFocus, onKeyDown: onKeyDown, placeholder: placeholder, type: type, value: value || '' }), suffix ? _jsx("div", { children: suffix }) : null] }));
29
+ : undefined /* eslint-disable-line no-undefined */, className: tw('peer w-full focus-visible:outline-0', prefix ? 'border-l-0' : null, (!prefix && suffix) || value ? 'border-r-0' : null, componentClassNames?.root), disabled: isDisabled, formNoValidate: true, id: id || name, name: name, onBlur: onBlur, onChange: handleChange, onFocus: onFocus, onKeyDown: onKeyDown, placeholder: placeholder, type: type, value: value || '' }), suffix ? _jsx("div", { children: suffix }) : null] }));
29
30
  }
30
31
  export default TextInput;
@@ -1,9 +1,10 @@
1
- import { DropdownObject } from '../interfaces';
2
- import { AutocompleteFormFieldProps } from '../components/FormFields';
3
- export interface UseAutocompleteArgs<T extends string> {
4
- searchFn: (search: string) => Promise<DropdownObject<T>[]>;
5
- selectFn: (id: T) => Promise<DropdownObject<T> | null>;
1
+ import type { AutocompleteFormFieldProps } from '../components/FormFields';
2
+ import type { DropdownObject } from '../interfaces';
3
+ export interface UseAutocompleteArgs<T extends string, U extends unknown[] = unknown[]> {
4
+ deps?: [...U];
5
+ searchFn: (search: string, ...deps: U) => Promise<DropdownObject<T>[]>;
6
+ selectFn: (id: T, ...deps: U) => Promise<DropdownObject<T> | null>;
6
7
  }
7
8
  export type UseAutocompleteReturn<T extends string> = AutocompleteFormFieldProps<T>;
8
- declare function useAutocomplete<T extends string>(props: AutocompleteFormFieldProps<T>, { searchFn, selectFn }: UseAutocompleteArgs<T>): UseAutocompleteReturn<T>;
9
+ declare function useAutocomplete<T extends string, U extends unknown[] = unknown[]>(props: AutocompleteFormFieldProps<T>, { searchFn, selectFn, deps }: UseAutocompleteArgs<T, U>): UseAutocompleteReturn<T>;
9
10
  export default useAutocomplete;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useEffect, useState } from 'react';
3
- function useAutocomplete(props, { searchFn, selectFn }) {
3
+ function useAutocomplete(props, { searchFn, selectFn, deps }) {
4
4
  const [isLoading, setIsLoading] = useState(false);
5
5
  const [options, setOptions] = useState([]);
6
6
  const [selected, setSelected] = useState(null);
@@ -9,7 +9,7 @@ function useAutocomplete(props, { searchFn, selectFn }) {
9
9
  setSelected(null);
10
10
  return;
11
11
  }
12
- const response = await selectFn(value);
12
+ const response = await selectFn(value, ...(deps ?? []));
13
13
  setOptions([]);
14
14
  setSelected(response);
15
15
  }
@@ -19,13 +19,13 @@ function useAutocomplete(props, { searchFn, selectFn }) {
19
19
  return;
20
20
  }
21
21
  setIsLoading(true);
22
- const response = await searchFn(search);
22
+ const response = await searchFn(search, ...(deps ?? []));
23
23
  setOptions(response);
24
24
  setIsLoading(false);
25
25
  }
26
26
  useEffect(() => {
27
27
  void handleSelect(props.value);
28
- }, [props.value]);
28
+ }, [props.value, ...(deps ?? [])]);
29
29
  return { ...props, isLoading, onSearch: handleSearch, options, selected };
30
30
  }
31
31
  export default useAutocomplete;
@@ -1,10 +1,8 @@
1
1
  import { DropdownObject } from '../interfaces';
2
- export interface UseDropdownArgs<T extends string> {
3
- deps?: unknown[];
4
- fn: (...args: unknown[]) => Promise<DropdownObject<T>[]>;
2
+ import { DropdownFormFieldProps } from '../components/FormFields';
3
+ export interface UseDropdownArgs<T extends string, U extends unknown[] = unknown[]> {
4
+ deps?: [...U];
5
+ fn: (...deps: U) => Promise<DropdownObject<T>[]>;
5
6
  }
6
- export interface UseDropdownReturn<T extends string> {
7
- data: DropdownObject<T>[];
8
- }
9
- declare function useDropdown<T extends string>({ deps, fn }: UseDropdownArgs<T>): UseDropdownReturn<T>;
7
+ declare function useDropdown<T extends string, U extends unknown[] = unknown[], TProps = DropdownFormFieldProps<T>>(props: TProps, { deps, fn }: UseDropdownArgs<T, U>): TProps;
10
8
  export default useDropdown;
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
  import { useEffect, useState } from 'react';
3
- function useDropdown({ deps, fn }) {
4
- const [data, setData] = useState([]);
3
+ function useDropdown(props, { deps, fn }) {
4
+ const [options, setOptions] = useState([]);
5
5
  async function getData() {
6
- const response = await (deps ? fn(...deps) : fn());
7
- setData(response);
6
+ const response = await fn(...(deps ?? []));
7
+ setOptions(response);
8
8
  }
9
9
  useEffect(() => {
10
10
  void getData();
11
11
  }, deps || []);
12
- return { data };
12
+ return { ...props, options };
13
13
  }
14
14
  export default useDropdown;
@@ -0,0 +1,4 @@
1
+ import { EditableDropdownFormFieldProps } from '../components/EditableFormFields';
2
+ import { UseDropdownArgs } from './useDropdown';
3
+ declare function useEditableDropdown<T extends string, U extends unknown[] = unknown[]>(props: EditableDropdownFormFieldProps<T>, args: UseDropdownArgs<T, U>): EditableDropdownFormFieldProps<T>;
4
+ export default useEditableDropdown;
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ import useDropdown from './useDropdown';
3
+ function useEditableDropdown(props, args) {
4
+ return useDropdown(props, args);
5
+ }
6
+ export default useEditableDropdown;
@@ -6,6 +6,7 @@ export interface EditableFieldPropsReturn<Request, K extends keyof Request = key
6
6
  }
7
7
  export type UseEditableFormArgs<Request, Response> = UseFormArgs<Request, Response> & {
8
8
  defaultStatus?: EditingStatus;
9
+ isEditable?: boolean;
9
10
  onCancel?: () => void;
10
11
  onEdit?: () => void;
11
12
  title?: string;
@@ -20,5 +21,5 @@ export interface UseEditableFormReturn<Request> extends Omit<UseFormReturn<Reque
20
21
  setStatus: React.Dispatch<React.SetStateAction<EditingStatus | null>>;
21
22
  status: EditingStatus | null;
22
23
  }
23
- declare function useEditableForm<Request extends object, Response = Request>({ defaultStatus, onCancel, onEdit, onSuccess, title, ...args }: UseEditableFormArgs<Request, Response>): UseEditableFormReturn<Request>;
24
+ declare function useEditableForm<Request extends object, Response = Request>({ defaultStatus, isEditable, onCancel, onEdit, onSuccess, title, ...args }: UseEditableFormArgs<Request, Response>): UseEditableFormReturn<Request>;
24
25
  export default useEditableForm;
@@ -1,8 +1,11 @@
1
- import { useEffect, useState } from 'react';
1
+ import { useState } from 'react';
2
2
  import useForm from './useForm';
3
- function useEditableForm({ defaultStatus, onCancel, onEdit, onSuccess, title, ...args }) {
4
- const [status, setStatus] = useState(defaultStatus ?? null);
3
+ function useEditableForm({ defaultStatus, isEditable = true, onCancel, onEdit, onSuccess, title, ...args }) {
4
+ const [status, setStatus] = useState(isEditable ? (defaultStatus ?? null) : null);
5
5
  async function onEditableSuccess(response) {
6
+ if (!isEditable) {
7
+ return;
8
+ }
6
9
  if (onSuccess) {
7
10
  await onSuccess(response);
8
11
  }
@@ -15,18 +18,27 @@ function useEditableForm({ defaultStatus, onCancel, onEdit, onSuccess, title, ..
15
18
  });
16
19
  function editableFieldProps(name, label) {
17
20
  const fieldProps = useFormReturn.fieldProps(name, label);
18
- return { ...fieldProps, status };
21
+ return { ...fieldProps, status: isEditable ? status : null };
19
22
  }
20
- useEffect(() => {
21
- if (status === 'CANCELLED') {
22
- useFormReturn.setErrors(null);
23
+ function handleCancel() {
24
+ if (onCancel) {
25
+ onCancel();
23
26
  }
24
- }, [status]);
27
+ useFormReturn.resetForm();
28
+ }
25
29
  return {
26
30
  ...useFormReturn,
27
31
  actionProps: { status, setStatus },
28
32
  fieldProps: editableFieldProps,
29
- formProps: { formProps: useFormReturn.formProps, onCancel, onEdit, status, setStatus, title },
33
+ formProps: {
34
+ formProps: useFormReturn.formProps,
35
+ isEditable,
36
+ onCancel: handleCancel,
37
+ onEdit,
38
+ status,
39
+ setStatus,
40
+ title,
41
+ },
30
42
  status,
31
43
  setStatus,
32
44
  };
@@ -1,17 +1,12 @@
1
- import type { Default, InputEvent } from '../../forms/interfaces';
1
+ import type { Default, FormResponse, InputEvent } from '../interfaces.js';
2
+ import type { UseSuccessArgs } from '../../hooks/useSuccess.js';
2
3
  import type { FormProps } from '../components/Form';
3
- interface AwaitedFormResponse<M> {
4
- data: M | null;
5
- error: string | null;
6
- validation: Record<string, string> | null;
7
- }
8
- export type FormResponse<M> = Promise<AwaitedFormResponse<M>>;
9
4
  export interface FieldPropsReturn<Request, K extends keyof Request = keyof Request> {
10
5
  error: Record<string, string> | null;
11
6
  isDisabled?: boolean;
12
7
  label?: string;
13
8
  name: string;
14
- onChange: (event: InputEvent<Request[K]>) => void;
9
+ onFieldChange: (event: InputEvent<Request[K]>) => void;
15
10
  value: Request[K];
16
11
  }
17
12
  export interface ToastsArgs {
@@ -19,14 +14,11 @@ export interface ToastsArgs {
19
14
  success?: string | false;
20
15
  validation?: string | false;
21
16
  }
22
- export interface UseFormArgs<Request, Response> {
17
+ export interface UseFormArgs<Request, Response> extends UseSuccessArgs<Response> {
23
18
  defaults?: Default<Request>;
24
19
  onError?: (message: string) => void;
25
20
  onSubmit?: (formData: Request) => FormResponse<Response>;
26
- onSuccess?: (response: Response) => Promise<void> | void;
27
- onValidation?: (errors: Record<string, string>) => void;
28
- redirectOnSuccess?: string | false | ((response: Response) => string | false);
29
- refreshOnSuccess?: boolean;
21
+ onValidation?: (errors: Record<string, string>, uncaughtErrors?: Record<string, string>) => void;
30
22
  toasts?: ToastsArgs | false;
31
23
  }
32
24
  export interface UseFormReturn<Request> {
@@ -37,9 +29,10 @@ export interface UseFormReturn<Request> {
37
29
  isLoading: boolean;
38
30
  resetForm: () => void;
39
31
  setErrors: (errors: Record<string, string> | null) => void;
40
- setFormData: (key: keyof Request, value: Request[keyof Request]) => void;
32
+ setFormData: <K extends keyof Request>(key: K, value: Request[K]) => void;
41
33
  submitForm: () => void;
42
34
  }
35
+ export declare const DEFAULT_TOAST_MESSAGES: Record<keyof ToastsArgs, string>;
43
36
  /**
44
37
  * ## Overview
45
38
  *