@sqrzro/ui 4.0.0-alpha.6 → 4.0.0-alpha.60

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 (295) 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 +11 -0
  51. package/dist/components/elements/InfoPanel/index.js +9 -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 +12 -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 +13 -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 +6 -0
  150. package/dist/forms/components/EditableFormFields/index.js +22 -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 +19 -2
  158. package/dist/forms/components/FormFields/index.js +38 -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/ModalForm/index.d.ts +3 -2
  162. package/dist/forms/components/ModalForm/index.js +4 -3
  163. package/dist/forms/components/NumberInput/index.d.ts +1 -1
  164. package/dist/forms/components/PasswordComplexity/index.d.ts +16 -0
  165. package/dist/forms/components/PasswordComplexity/index.js +14 -0
  166. package/dist/forms/components/PasswordComplexityItem/index.d.ts +8 -0
  167. package/dist/forms/components/PasswordComplexityItem/index.js +10 -0
  168. package/dist/forms/components/PasswordInput/index.d.ts +1 -1
  169. package/dist/forms/components/PasswordInput/index.js +6 -6
  170. package/dist/forms/components/PointsInput/index.d.ts +5 -0
  171. package/dist/forms/components/{MoneyInput → PointsInput}/index.js +3 -3
  172. package/dist/forms/components/RangeCalendarInput/index.d.ts +6 -0
  173. package/dist/forms/components/RangeCalendarInput/index.js +14 -0
  174. package/dist/forms/components/StaticTextInput/index.d.ts +2 -2
  175. package/dist/forms/components/StaticTextInput/index.js +6 -7
  176. package/dist/forms/components/Switch/index.d.ts +9 -3
  177. package/dist/forms/components/Switch/index.js +7 -5
  178. package/dist/forms/components/TextArea/index.d.ts +14 -0
  179. package/dist/forms/components/TextArea/index.js +15 -0
  180. package/dist/forms/components/TextInput/index.d.ts +1 -1
  181. package/dist/forms/components/TextInput/index.js +5 -4
  182. package/dist/forms/hooks/useAutocomplete.d.ts +8 -6
  183. package/dist/forms/hooks/useAutocomplete.js +4 -4
  184. package/dist/forms/hooks/useDropdown.d.ts +5 -7
  185. package/dist/forms/hooks/useDropdown.js +5 -5
  186. package/dist/forms/hooks/useEditableDropdown.d.ts +4 -0
  187. package/dist/forms/hooks/useEditableDropdown.js +6 -0
  188. package/dist/forms/hooks/useEditableForm.js +8 -1
  189. package/dist/forms/hooks/useForm.d.ts +6 -7
  190. package/dist/forms/hooks/useForm.js +25 -27
  191. package/dist/forms/hooks/useModalForm.d.ts +2 -2
  192. package/dist/forms/hooks/useModalForm.js +8 -1
  193. package/dist/forms/index.d.ts +22 -6
  194. package/dist/forms/index.js +9 -4
  195. package/dist/forms/interfaces.d.ts +1 -1
  196. package/dist/forms/utility/extract-input-props.js +1 -0
  197. package/dist/forms/utility/format-date-value.d.ts +2 -0
  198. package/dist/forms/utility/format-date-value.js +13 -0
  199. package/dist/forms/utility/format-file-size.d.ts +2 -0
  200. package/dist/forms/utility/format-file-size.js +11 -0
  201. package/dist/hooks/index.d.ts +3 -0
  202. package/dist/hooks/index.js +3 -0
  203. package/dist/hooks/useConfirmable.d.ts +21 -0
  204. package/dist/hooks/useConfirmable.js +58 -0
  205. package/dist/hooks/useDownload.d.ts +2 -0
  206. package/dist/hooks/useDownload.js +18 -0
  207. package/dist/hooks/usePopover.d.ts +12 -0
  208. package/dist/hooks/usePopover.js +24 -0
  209. package/dist/hooks/useSelected.d.ts +12 -0
  210. package/dist/hooks/useSelected.js +35 -0
  211. package/dist/hooks/useServerAction.d.ts +10 -0
  212. package/dist/hooks/useServerAction.js +17 -0
  213. package/dist/hooks/useSuccess.d.ts +10 -0
  214. package/dist/hooks/useSuccess.js +22 -0
  215. package/dist/mail/Mail/index.d.ts +8 -0
  216. package/dist/mail/Mail/index.js +106 -0
  217. package/dist/mail/MailBlock/index.d.ts +5 -0
  218. package/dist/mail/MailBlock/index.js +5 -0
  219. package/dist/mail/MailButton/index.d.ts +8 -0
  220. package/dist/mail/MailButton/index.js +28 -0
  221. package/dist/mail/MailTable/index.d.ts +9 -0
  222. package/dist/mail/MailTable/index.js +7 -0
  223. package/dist/mail/index.d.ts +8 -0
  224. package/dist/mail/index.js +4 -0
  225. package/dist/mail/utility/convert-to-datauri.d.ts +2 -0
  226. package/dist/mail/utility/convert-to-datauri.js +16 -0
  227. package/dist/mail/utility/get-mail-config.d.ts +4 -0
  228. package/dist/mail/utility/get-mail-config.js +34 -0
  229. package/dist/mail/utility/interfaces.d.ts +23 -0
  230. package/dist/navigation/components/AppNavigation/index.d.ts +3 -1
  231. package/dist/navigation/components/AppNavigation/index.js +4 -4
  232. package/dist/navigation/components/AppNavigationItem/index.d.ts +5 -3
  233. package/dist/navigation/components/AppNavigationItem/index.js +16 -7
  234. package/dist/navigation/components/Tabs/index.js +1 -4
  235. package/dist/navigation/hooks/useNavigation.d.ts +3 -3
  236. package/dist/navigation/hooks/useNavigation.js +5 -5
  237. package/dist/styles/classnames/config.d.ts +91 -0
  238. package/dist/styles/classnames/config.js +1 -0
  239. package/dist/styles/classnames/interfaces.d.ts +56 -0
  240. package/dist/styles/classnames/interfaces.js +1 -0
  241. package/dist/styles/classnames/utility/apply-sizes.d.ts +3 -0
  242. package/dist/styles/classnames/utility/apply-sizes.js +21 -0
  243. package/dist/styles/classnames/utility/apply-variants.d.ts +3 -0
  244. package/dist/styles/classnames/utility/apply-variants.js +26 -0
  245. package/dist/styles/classnames/utility/is-classname-object.d.ts +3 -0
  246. package/dist/styles/classnames/utility/is-classname-object.js +7 -0
  247. package/dist/styles/classnames/utility/parse-classnames.d.ts +6 -0
  248. package/dist/styles/classnames/utility/parse-classnames.js +33 -0
  249. package/dist/styles/context.d.ts +28 -0
  250. package/dist/styles/context.js +19 -0
  251. package/dist/styles/icons/config.d.ts +21 -0
  252. package/dist/styles/icons/config.js +1 -0
  253. package/dist/styles/icons/interfaces.d.ts +4 -0
  254. package/dist/styles/icons/interfaces.js +1 -0
  255. package/dist/styles/index.d.ts +6 -2
  256. package/dist/styles/index.js +2 -1
  257. package/dist/styles/styles.css +60 -0
  258. package/dist/utility/compare-dates.d.ts +2 -0
  259. package/dist/utility/compare-dates.js +13 -0
  260. package/dist/utility/get-date-state.d.ts +8 -0
  261. package/dist/utility/get-date-state.js +63 -0
  262. package/dist/utility/get-days.d.ts +2 -0
  263. package/dist/utility/get-days.js +5 -0
  264. package/dist/utility/get-weeks.d.ts +2 -0
  265. package/dist/utility/get-weeks.js +31 -0
  266. package/dist/utility/index.d.ts +1 -1
  267. package/dist/utility/interfaces.d.ts +33 -17
  268. package/dist/utility/is-data-object-array.d.ts +3 -0
  269. package/dist/utility/is-data-object-array.js +5 -0
  270. package/dist/utility/is-data-object.d.ts +3 -0
  271. package/dist/utility/is-data-object.js +4 -0
  272. package/package.json +31 -19
  273. package/dist/components/buttons/ConfirmableButton/index.d.ts +0 -7
  274. package/dist/components/buttons/ConfirmableButton/index.js +0 -13
  275. package/dist/components/collections/utility/filter-columns.d.ts +0 -3
  276. package/dist/components/collections/utility/filter-columns.js +0 -8
  277. package/dist/components/collections/utility/get-selected-from-search-params.d.ts +0 -2
  278. package/dist/components/collections/utility/get-selected-from-search-params.js +0 -5
  279. package/dist/components/collections/utility/set-selected-to-search-params.d.ts +0 -2
  280. package/dist/components/collections/utility/set-selected-to-search-params.js +0 -4
  281. package/dist/components/utility/ClassNames/index.d.ts +0 -6
  282. package/dist/components/utility/ClassNames/index.js +0 -7
  283. package/dist/components/utility/Page/index.d.ts +0 -18
  284. package/dist/components/utility/Page/index.js +0 -34
  285. package/dist/components/utility/RootLayout/index.d.ts +0 -12
  286. package/dist/components/utility/RootLayout/index.js +0 -14
  287. package/dist/forms/components/MoneyInput/index.d.ts +0 -5
  288. package/dist/styles/config.d.ts +0 -64
  289. package/dist/styles/config.js +0 -43
  290. package/dist/styles/icons.d.ts +0 -15
  291. package/dist/styles/icons.js +0 -7
  292. package/dist/styles/interfaces.d.ts +0 -41
  293. /package/dist/{styles → mail/utility}/interfaces.js +0 -0
  294. /package/dist/styles/{tw.d.ts → classnames/utility/tw.d.ts} +0 -0
  295. /package/dist/styles/{tw.js → classnames/utility/tw.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { ClassNameProps } from '../../../styles/interfaces';
1
+ import { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  import type { DropdownObject, InputProps } from '../../interfaces';
3
3
  import { DropdownClassNames, DropdownComponentProps } from '../Dropdown';
4
4
  export interface AutocompleteComponentProps<T> extends DropdownComponentProps<T> {
@@ -7,5 +7,5 @@ export interface AutocompleteComponentProps<T> extends DropdownComponentProps<T>
7
7
  selected?: DropdownObject<T> | null;
8
8
  }
9
9
  export type AutocompleteProps<T> = ClassNameProps<DropdownClassNames> & InputProps<T | null> & AutocompleteComponentProps<T>;
10
- declare function Autocomplete<T>({ hasError, isDisabled, isLoading, isOptional, name, onChange, onSearch, options, selected, placeholder, value, }: Readonly<AutocompleteProps<T>>): React.ReactElement;
10
+ declare function Autocomplete<T>({ hasError, isDisabled, name, onChange, onSearch, options, selected, placeholder, value, }: Readonly<AutocompleteProps<T>>): React.ReactElement;
11
11
  export default Autocomplete;
@@ -3,10 +3,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Fragment, useRef, useState } from 'react';
4
4
  import Popover from '../../../components/utility/Popover';
5
5
  import useClickOutside from '../../../hooks/useClickOutside';
6
- import DropdownList from '../DropdownList';
7
6
  import StaticTextInput from '../StaticTextInput';
8
7
  import TextInput from '../TextInput';
9
- function Autocomplete({ hasError, isDisabled, isLoading, isOptional, name, onChange, onSearch, options, selected, placeholder, value, }) {
8
+ import AutocompleteList from '../AutocompleteList';
9
+ function Autocomplete({ hasError, isDisabled, name, onChange, onSearch, options, selected, placeholder, value, }) {
10
10
  const inputRef = useRef(null);
11
11
  const [search, setSearch] = useState('');
12
12
  const [isOpen, setIsOpen, ref] = useClickOutside();
@@ -32,6 +32,6 @@ function Autocomplete({ hasError, isDisabled, isLoading, isOptional, name, onCha
32
32
  inputRef.current?.focus();
33
33
  }, 10);
34
34
  }
35
- return (_jsx("div", { ref: ref, className: "relative", children: selected ? (_jsx(StaticTextInput, { details: selected.details, hasError: hasError, isDisabled: isDisabled, isOptional: isOptional, label: selected.label, name: name, onClick: handleReset, placeholder: placeholder || 'Select...', value: value ? String(value) : '' })) : (_jsxs(Fragment, { children: [_jsx(TextInput, { ref: inputRef, hasError: hasError, isDisabled: isDisabled, name: `${name}_search`, onChange: handleSearch, onFocus: () => setIsOpen(Boolean(options?.length)), placeholder: "Start typing...", value: search }), _jsx(Popover, { align: "center", isOpen: isOpen, isScrollable: true, children: options?.length ? (_jsx(DropdownList, { name: name, onChange: handleChange, options: options ?? [], value: value })) : isLoading ? (_jsx("div", { children: "Loading..." })) : (_jsx("div", { children: "No results" })) })] })) }));
35
+ return (_jsx("div", { ref: ref, className: "relative", children: selected ? (_jsx(StaticTextInput, { details: selected.details, hasError: hasError, isDisabled: isDisabled, isOptional: true, label: selected.label, name: name, onClear: handleReset, placeholder: placeholder || 'Select...', value: value ? String(value) : '' })) : (_jsxs(Fragment, { children: [_jsx(TextInput, { ref: inputRef, hasError: hasError, isDisabled: isDisabled, name: `${name}_search`, onChange: handleSearch, onFocus: () => setIsOpen(true), placeholder: "Start typing...", value: search }), _jsx(Popover, { align: "center", isOpen: isOpen && search.length >= 3, isScrollable: true, children: _jsx(AutocompleteList, { name: name, onChange: handleChange, options: options, search: search, value: value }) })] })) }));
36
36
  }
37
37
  export default Autocomplete;
@@ -0,0 +1,7 @@
1
+ import type { DropdownObject, InputProps } from '../../interfaces';
2
+ interface AutocompleteListProps<T> extends InputProps<T | null> {
3
+ options?: DropdownObject<T>[];
4
+ search: string;
5
+ }
6
+ declare function AutocompleteList<T>({ name, onChange, options, search, value, }: AutocompleteListProps<T>): React.ReactElement | null;
7
+ export default AutocompleteList;
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
3
+ import DropdownList from '../DropdownList';
4
+ function AutocompleteList({ name, onChange, options, search, value, }) {
5
+ if (!options?.length) {
6
+ return (_jsx(DropdownList, { name: name, options: [
7
+ {
8
+ label: (_jsxs(Fragment, { children: ["No results found for ", _jsx("strong", { children: search })] })),
9
+ value: null,
10
+ },
11
+ ] }));
12
+ }
13
+ return _jsx(DropdownList, { name: name, onChange: onChange, options: options, value: value });
14
+ }
15
+ export default AutocompleteList;
@@ -0,0 +1,11 @@
1
+ import { InputProps } from '../../interfaces';
2
+ export interface BaseCalendarInputComponentProps {
3
+ isOptional?: boolean;
4
+ isPanelOnly?: boolean;
5
+ }
6
+ interface BaseCalendarInputProps extends InputProps<Date | [Date, Date] | null>, BaseCalendarInputComponentProps {
7
+ children: React.ReactElement;
8
+ onClear?: () => void;
9
+ }
10
+ declare function BaseCalendarInput({ children, hasError, isDisabled, isOptional, isPanelOnly, name, onClear, value, }: BaseCalendarInputProps): React.ReactElement;
11
+ export default BaseCalendarInput;
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useState } from 'react';
4
+ import Popover from '../../../components/utility/Popover';
5
+ import usePopover from '../../../hooks/usePopover';
6
+ import formatDateValue from '../../utility/format-date-value';
7
+ import StaticTextInput from '../StaticTextInput';
8
+ function BaseCalendarInput({ children, hasError, isDisabled, isOptional, isPanelOnly, name, onClear, value, }) {
9
+ const [oldValue, setOldValue] = useState(value);
10
+ const { controlProps, ref, targetProps } = usePopover();
11
+ if (isPanelOnly) {
12
+ return children;
13
+ }
14
+ useEffect(() => {
15
+ if ((value && !oldValue) || (value && oldValue)) {
16
+ controlProps.onClick();
17
+ }
18
+ setOldValue(value);
19
+ }, [value]);
20
+ return (_jsxs("div", { ref: ref, className: "relative", children: [_jsx(StaticTextInput, { hasError: hasError, isDisabled: isDisabled, label: formatDateValue(value), name: name, isOptional: isOptional, onClear: onClear, onClick: controlProps.onClick, value: value?.toString() }), _jsx(Popover, { ...targetProps, align: "center", children: children })] }));
21
+ }
22
+ export default BaseCalendarInput;
@@ -0,0 +1,11 @@
1
+ import { InputProps } from '../../../forms/interfaces';
2
+ import type { ClassNameProps, HighlightableClassName } from '../../../styles/classnames/interfaces';
3
+ export interface CSVInputClassNames {
4
+ root: string;
5
+ icon: HighlightableClassName;
6
+ title: string;
7
+ description: string;
8
+ }
9
+ export type CSVInputProps = ClassNameProps<CSVInputClassNames> & InputProps<string>;
10
+ declare function CSVInput({ classNames, classNameProps, id, isDisabled, name, onChange, value, }: Readonly<CSVInputProps>): React.ReactElement;
11
+ export default CSVInput;
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { formatPlural } from '@sqrzro/utility';
5
+ import { useClassNames, useIcon } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
7
+ import formatFileSize from '../../utility/format-file-size';
8
+ function CSVInput({ classNames, classNameProps, id, isDisabled, name, onChange, value, }) {
9
+ const UploadIcon = useIcon('csvInput.upload');
10
+ const SuccessIcon = useIcon('csvInput.success');
11
+ const [fileData, setFileData] = useState(null);
12
+ const componentClassNames = useClassNames('csvInput', { props: classNameProps, states: { isHighlighted: Boolean(fileData) } }, classNames);
13
+ function handleChange(event) {
14
+ const { files } = event.target;
15
+ const reader = new FileReader();
16
+ reader.addEventListener('load', () => {
17
+ const text = reader.result?.toString() || '';
18
+ const lines = text.split('\n').filter((item) => item.trim() !== '').length;
19
+ setFileData({
20
+ lines,
21
+ name: files?.[0].name || '',
22
+ size: files?.[0].size || 0,
23
+ });
24
+ onChange?.({ target: { name, value: text } });
25
+ }, false);
26
+ if (files?.[0]) {
27
+ reader.readAsText(files[0]);
28
+ }
29
+ }
30
+ return (_jsxs("div", { className: tw('relative flex items-center justify-center', componentClassNames?.root), children: [_jsx("input", { name: name, type: "hidden", value: value || '' }), _jsx("input", { accept: "text/csv", className: "absolute left-0 top-0 h-full w-full cursor-pointer opacity-0", disabled: isDisabled, id: id || name, name: name, onChange: handleChange, type: "file" }), fileData ? (_jsxs("div", { className: tw('text-center', isDisabled ? 'pointer-events-none opacity-20' : null), children: [_jsx("i", { className: componentClassNames?.icon, children: SuccessIcon ? _jsx(SuccessIcon, {}) : null }), _jsx("p", { className: componentClassNames?.title, children: fileData.name }), _jsxs("p", { className: componentClassNames?.description, children: [formatFileSize(fileData.size), " \u2022", ' ', formatPlural('line', fileData.lines)] })] })) : (_jsxs("div", { className: "text-center", 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: "(or drag a CSV file over this box)" })] }))] }));
31
+ }
32
+ export default CSVInput;
@@ -0,0 +1,6 @@
1
+ import { InputProps } from '../../interfaces';
2
+ import { BaseCalendarInputComponentProps } from '../BaseCalendarInput';
3
+ export type CalendarInputComponentProps = BaseCalendarInputComponentProps;
4
+ export type CalendarInputProps = InputProps<Date | null> & CalendarInputComponentProps;
5
+ declare function CalendarInput({ name, onChange, value, ...baseProps }: CalendarInputProps): React.ReactElement;
6
+ export default CalendarInput;
@@ -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 CalendarInput({ 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, { onChange: handleChange, value: value }) }));
13
+ }
14
+ export default CalendarInput;
@@ -0,0 +1,16 @@
1
+ import { InputProps } from '../../../forms/interfaces';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
3
+ export interface ColorInputClassNames {
4
+ root: ErrorableClassName;
5
+ input: string;
6
+ icon: string;
7
+ label: string;
8
+ placeholder: string;
9
+ clear: string;
10
+ }
11
+ export interface ColorInputComponentProps {
12
+ placeholder?: string;
13
+ }
14
+ export type ColorInputProps = ClassNameProps<ColorInputClassNames> & InputProps<string | undefined, string> & ColorInputComponentProps;
15
+ declare function ColorInput({ classNames, classNameProps, hasError, name, onChange, placeholder, value, }: Readonly<ColorInputProps>): React.ReactElement;
16
+ export default ColorInput;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import Assistive from '../../../components/utility/Assistive';
4
+ import { useClassNames } from '../../../styles/context';
5
+ import tw from '../../../styles/classnames/utility/tw';
6
+ function ColorInput({ classNames, classNameProps, hasError, name, onChange, placeholder, value, }) {
7
+ const componentClassNames = useClassNames('colorInput', { props: classNameProps, states: { isError: hasError ?? false } }, classNames);
8
+ function handleClear() {
9
+ onChange?.({ target: { name, value: '' } });
10
+ }
11
+ return (_jsxs("div", { className: tw('relative', componentClassNames?.root), children: [_jsx("input", { className: tw('absolute inset-0 h-full w-full cursor-pointer opacity-0', componentClassNames?.input), name: name, onChange: onChange, type: "color", value: value || '' }), _jsx("i", { className: tw(componentClassNames?.icon), style: { backgroundColor: value || 'transparent' } }), value ? (_jsx("span", { className: tw(componentClassNames?.label), children: value.toUpperCase() })) : (_jsx("span", { className: tw(componentClassNames?.placeholder), children: placeholder || 'Select...' })), _jsx("span", { className: "absolute bottom-0 right-0 top-0 flex w-0 items-center justify-end", children: value ? (_jsx("button", { className: tw('flex-none', componentClassNames?.clear), onClick: handleClear, type: "button", children: _jsx(Assistive, { children: "Clear" }) })) : null })] }));
12
+ }
13
+ export default ColorInput;
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps, ErrorableClassName, FocusableClassName, SelectableClassName } from '../../../styles/interfaces';
1
+ import type { ClassNameProps, ErrorableClassName, FocusableClassName, SelectableClassName } from '../../../styles/classnames/interfaces';
2
2
  import type { DropdownObject, InputProps } from '../../interfaces';
3
3
  export interface DropdownClassNames {
4
4
  root: ErrorableClassName & FocusableClassName;
@@ -2,22 +2,26 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import Popover from '../../../components/utility/Popover';
4
4
  import useClickOutside from '../../../hooks/useClickOutside';
5
- import tw from '../../../styles/tw';
6
- import { getClassNames } from '../../../styles/config';
5
+ import tw from '../../../styles/classnames/utility/tw';
6
+ import { useClassNames, useIcon } from '../../../styles/context';
7
7
  import DropdownList from '../DropdownList';
8
8
  import StaticTextInput from '../StaticTextInput';
9
9
  function findByValue(options, value) {
10
10
  return options.find((item) => item.value === value);
11
11
  }
12
12
  export function renderLabel(options, value) {
13
- return findByValue(options, value)?.label || '';
13
+ return String(findByValue(options, value)?.label || '');
14
14
  }
15
15
  export function renderDetails(options, value) {
16
16
  return findByValue(options, value)?.details || '';
17
17
  }
18
18
  function Dropdown({ classNames, classNameProps, hasError, isDisabled, isOptional, isPanelOnly, name, onChange, options = [], placeholder, value, }) {
19
- const componentClassNames = classNames || getClassNames('dropdown')?.(classNameProps);
20
19
  const [isOpen, setIsOpen, node] = useClickOutside({ shouldHandleEnterKey: true });
20
+ const componentClassNames = useClassNames('dropdown', {
21
+ props: classNameProps,
22
+ states: { isError: hasError ?? false, isFocused: isOpen && !isDisabled },
23
+ }, classNames);
24
+ const Icon = useIcon('dropdown.control');
21
25
  function toggleIsOpen() {
22
26
  setIsOpen(!isOpen);
23
27
  }
@@ -33,9 +37,6 @@ function Dropdown({ classNames, classNameProps, hasError, isDisabled, isOptional
33
37
  if (isPanelOnly) {
34
38
  return _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value });
35
39
  }
36
- return (_jsxs("div", { ref: node, className: tw('relative', componentClassNames?.root?.default, hasError ? componentClassNames?.root?.error : null, isOpen && !isDisabled ? componentClassNames?.root?.focused : null), children: [_jsx(StaticTextInput, { classNames: {
37
- clear: componentClassNames?.clear,
38
- icon: componentClassNames?.icon,
39
- }, details: renderDetails(options, value), hasError: hasError, isDisabled: isDisabled || !options?.length, isOptional: isOptional, label: renderLabel(options, value), name: name, onClear: handleClear, onClick: toggleIsOpen, placeholder: placeholder || 'Select...', value: value ? String(value) : '' }), _jsx(Popover, { align: "center", isOpen: isOpen ? !isDisabled : false, isScrollable: true, children: _jsx(DropdownList, { name: name, onChange: handleChange, options: options, value: value }) })] }));
40
+ return (_jsxs("div", { ref: node, className: tw('relative', componentClassNames?.root), children: [_jsx(StaticTextInput, { classNameProps: classNameProps, details: renderDetails(options, value), hasError: hasError, icon: Icon ? _jsx(Icon, {}) : null, isDisabled: isDisabled || !options?.length, isOptional: isOptional, label: renderLabel(options, value), name: name, onClear: handleClear, onClick: toggleIsOpen, placeholder: placeholder || 'Select...', value: value ? String(value) : '' }), _jsx(Popover, { align: "center", isOpen: isOpen ? !isDisabled : false, isScrollable: true, children: _jsx(DropdownList, { classNameProps: classNameProps, classNames: classNames, name: name, onChange: handleChange, options: options, value: value }) })] }));
40
41
  }
41
42
  export default Dropdown;
@@ -0,0 +1,9 @@
1
+ import type { DropdownObject } from '../../../forms/interfaces';
2
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
3
+ import type { DropdownClassNames } from '../Dropdown';
4
+ interface DropdownItemProps<T> extends ClassNameProps<DropdownClassNames>, DropdownObject<T> {
5
+ isSelected: boolean;
6
+ onChange: (item: Pick<DropdownObject<T>, '$data' | 'value'>) => () => void;
7
+ }
8
+ declare function DropdownItem<T>({ $data, classNameProps, classNames, details, isDisabled, isSelected, label, onChange, value, }: DropdownItemProps<T>): React.ReactElement;
9
+ export default DropdownItem;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import tw from '../../../styles/classnames/utility/tw';
5
+ function DropdownItem({ $data, classNameProps, classNames, details, isDisabled, isSelected, label, onChange, value, }) {
6
+ const componentClassNames = useClassNames('dropdown', { props: classNameProps, states: { isSelected } }, classNames);
7
+ return (_jsx("li", { "aria-selected": isSelected, role: "option", children: _jsxs("button", { className: tw('relative w-full text-left', componentClassNames?.item, isDisabled ? 'pointer-events-none opacity-30' : null), onClick: onChange({ $data, value }), tabIndex: -1, type: "button", children: [_jsx("span", { className: tw('whitespace-nowrap', componentClassNames?.title), children: label }), details ? (_jsx("small", { className: tw(componentClassNames?.details), children: details })) : null] }) }));
8
+ }
9
+ export default DropdownItem;
@@ -1,5 +1,5 @@
1
1
  import type { DropdownObject, InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps } from '../../../styles/interfaces';
2
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
3
3
  import type { DropdownClassNames } from '../Dropdown';
4
4
  export interface DropdownListProps<T> extends ClassNameProps<DropdownClassNames>, InputProps<T | null> {
5
5
  options: DropdownObject<T>[];
@@ -1,12 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { getClassNames } from '../../../styles/config';
3
- import tw from '../../../styles/tw';
4
- function isSelected(id, value) {
5
- return Boolean(value) && value === id;
6
- }
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import DropdownItem from '../DropdownItem';
7
5
  function DropdownList({ classNames, classNameProps, name, onChange, options, value, }) {
8
- const componentClassNames = classNames || getClassNames('dropdown')?.(classNameProps);
9
- // const checkboxClassNames = getClassNames('checkboxInput')?.(classNameProps);
6
+ const componentClassNames = useClassNames('dropdown', { props: classNameProps }, classNames);
7
+ // const checkboxClassNames = useClassNames('checkboxInput')?.(classNameProps);
10
8
  function handleChange(item) {
11
9
  return () => {
12
10
  onChange?.({
@@ -15,8 +13,6 @@ function DropdownList({ classNames, classNameProps, name, onChange, options, val
15
13
  });
16
14
  };
17
15
  }
18
- return (_jsx("ul", { className: componentClassNames?.list, role: "listbox", children: options.map((item, index) => (_jsx("li", { "aria-selected": isSelected(item.value, value), role: "option", children: _jsxs("button", { className: tw('relative w-full text-left', item.isDisabled ? 'pointer-events-none opacity-30' : null, componentClassNames?.item?.default, isSelected(item.value, value)
19
- ? componentClassNames?.item?.selected
20
- : null), onClick: handleChange(item), tabIndex: -1, type: "button", children: [_jsx("span", { className: tw('whitespace-nowrap' /*componentClassNames?.label*/), children: item.label }), item.details ? (_jsx("small", { className: tw(componentClassNames?.details), children: item.details })) : null] }) }, index))) }));
16
+ return (_jsx("ul", { className: componentClassNames?.list, role: "listbox", children: options.map((item, index) => (_jsx(DropdownItem, { ...item, classNameProps: classNameProps, classNames: classNames, isSelected: Boolean(value) && value === item.value, onChange: handleChange }, index))) }));
21
17
  }
22
18
  export default DropdownList;
@@ -1,5 +1,5 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
2
- import type { Action } from '../../../utility/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
+ import type { SimpleActionObject } from '../../../utility/interfaces';
3
3
  import type { EditingStatus } from '../../interfaces';
4
4
  import type { FormProps } from '../Form';
5
5
  export interface EditableFormClassNames {
@@ -11,7 +11,7 @@ export interface EditableFormClassNames {
11
11
  content: string;
12
12
  }
13
13
  export interface EditableFormProps extends ClassNameProps<EditableFormClassNames> {
14
- actions?: Action[] | false;
14
+ actions?: SimpleActionObject[] | false;
15
15
  children: React.ReactNode;
16
16
  formProps: Omit<FormProps, 'children'>;
17
17
  onCancel?: () => void;
@@ -1,10 +1,10 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import ActionList from '../../../components/utility/ActionList';
3
- import { getClassNames } from '../../../styles/config';
4
- import tw from '../../../styles/tw';
4
+ import { useClassNames } from '../../../styles/context';
5
5
  import Form from '../Form';
6
6
  function EditableForm({ classNameProps, classNames, children, formProps, onCancel, onEdit, setStatus, status, title, }) {
7
- const componentClassNames = classNames || getClassNames('editableForm')?.(classNameProps);
7
+ const componentClassNames = useClassNames('editableForm', { props: classNameProps }, classNames);
8
8
  function setCancelled() {
9
9
  onCancel?.();
10
10
  setStatus?.('CANCELLED');
@@ -13,11 +13,11 @@ function EditableForm({ classNameProps, classNames, children, formProps, onCance
13
13
  onEdit?.();
14
14
  setStatus?.('EDITING');
15
15
  }
16
- return (_jsx(Form, { ...formProps, children: _jsxs("fieldset", { className: componentClassNames?.root, children: [title ? _jsx("header", { className: tw(componentClassNames?.header), children: _jsx("legend", { className: componentClassNames?.title, children: title }) }) : null, _jsxs("div", { className: tw(componentClassNames?.content), children: [children, _jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: status === 'EDITING'
17
- ? [
18
- { label: 'Cancel', onClick: setCancelled },
19
- { isSubmittable: true, label: 'Save' },
20
- ]
21
- : [{ label: 'Edit', onClick: setEditing }] }) })] })] }) }));
16
+ return (_jsxs(Form, { ...formProps, classNames: { root: componentClassNames?.root }, children: [title ? (_jsx("header", { className: componentClassNames?.header, children: _jsx("legend", { className: componentClassNames?.title, children: title }) })) : null, _jsxs("div", { className: componentClassNames?.content, children: [children, _jsx("footer", { className: componentClassNames?.actions, children: _jsx(ActionList, { actions: status === 'EDITING'
17
+ ? [
18
+ { label: 'Cancel', onClick: setCancelled },
19
+ { isSubmittable: true, label: 'Save' },
20
+ ]
21
+ : [{ label: 'Edit', onClick: setEditing }] }) })] })] }));
22
22
  }
23
23
  export default EditableForm;
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  import { FormFieldProps } from '../FormField';
3
3
  import { EditingStatus } from '../../interfaces';
4
4
  export interface EditableFormFieldClassNames {
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { isValidElement, useEffect, useRef } from 'react';
4
4
  import FormField from '../FormField';
5
- import { getClassNames } from '../../../styles/config';
5
+ import { useClassNames } from '../../../styles/context';
6
6
  function getRenderedValue(value, renderValue) {
7
7
  if (renderValue) {
8
8
  if (typeof renderValue === 'function') {
@@ -19,7 +19,7 @@ function getRenderedValue(value, renderValue) {
19
19
  return value ? String(value) : '-';
20
20
  }
21
21
  function EditableFormField({ classNameProps, classNames, renderValue, status, ...props }) {
22
- const componentClassNames = classNames || getClassNames('editableFormField')(classNameProps);
22
+ const componentClassNames = useClassNames('editableFormField', { props: classNameProps }, classNames);
23
23
  const cachedValue = useRef(props.value);
24
24
  useEffect(() => {
25
25
  if (status === 'CANCELLED') {
@@ -30,7 +30,7 @@ function EditableFormField({ classNameProps, classNames, renderValue, status, ..
30
30
  }
31
31
  }, [status]);
32
32
  if (status === 'EDITING') {
33
- return _jsx(FormField, { ...props });
33
+ return _jsx(FormField, { classNameProps: { ...classNameProps, isEditable: true }, ...props });
34
34
  }
35
35
  return (_jsxs("div", { className: componentClassNames?.root, children: [_jsx("div", { className: componentClassNames?.label, children: props.label }), _jsx("div", { className: componentClassNames?.field, children: getRenderedValue(props.value, renderValue) })] }));
36
36
  }
@@ -1,7 +1,13 @@
1
1
  import type { EditableFormFieldComponentProps } from '../../interfaces';
2
+ import type { ColorInputComponentProps } from '../ColorInput';
2
3
  import type { DropdownComponentProps } from '../Dropdown';
4
+ import type { TextAreaComponentProps } from '../TextArea';
3
5
  import type { TextInputComponentProps } from '../TextInput';
6
+ export type EditableColorFormFieldProps = EditableFormFieldComponentProps<string | undefined> & ColorInputComponentProps;
7
+ export declare function EditableColorFormField(props: Readonly<EditableColorFormFieldProps>): React.ReactElement;
4
8
  export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<T | null> & DropdownComponentProps<T>;
5
9
  export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
10
+ export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
11
+ export declare function EditableTextAreaFormField(props: Readonly<EditableTextAreaFormFieldProps>): React.ReactElement;
6
12
  export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
7
13
  export declare function EditableTextFormField(props: Readonly<EditableTextFormFieldProps>): React.ReactElement;
@@ -1,9 +1,25 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
+ import { useClassNames } from '../../../styles/context';
4
+ import tw from '../../../styles/classnames/utility/tw';
3
5
  import extractEditableInputProps from '../../utility/extract-editable-input-props';
6
+ import ColorInput from '../ColorInput';
4
7
  import Dropdown from '../Dropdown';
5
8
  import EditableFormField from '../EditableFormField';
9
+ import TextArea from '../TextArea';
6
10
  import TextInput from '../TextInput';
11
+ export function EditableColorFormField(props) {
12
+ const classNames = useClassNames('colorInput');
13
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
14
+ const renderInput = useCallback((renderProps) => (_jsx(ColorInput, { ...renderProps, ...inputProps })), [inputProps]);
15
+ const renderValue = useCallback((value) => {
16
+ if (!value) {
17
+ return '-';
18
+ }
19
+ return (_jsxs("div", { className: "relative flex items-center gap-2", children: [_jsx("span", { className: tw(classNames?.icon), style: { backgroundColor: value || 'transparent' } }), _jsx("span", { className: tw(classNames?.label), children: value.toUpperCase() })] }));
20
+ }, [fieldProps.value]);
21
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
22
+ }
7
23
  export function EditableDropdownFormField(props) {
8
24
  const { fieldProps, inputProps } = extractEditableInputProps(props);
9
25
  const renderInput = useCallback((renderProps) => (_jsx(Dropdown, { ...renderProps, ...inputProps })), [inputProps]);
@@ -13,6 +29,11 @@ export function EditableDropdownFormField(props) {
13
29
  }, [inputProps]);
14
30
  return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
15
31
  }
32
+ export function EditableTextAreaFormField(props) {
33
+ const { fieldProps, inputProps } = extractEditableInputProps(props);
34
+ const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
35
+ return _jsx(EditableFormField, { ...fieldProps, render: renderInput });
36
+ }
16
37
  export function EditableTextFormField(props) {
17
38
  const { fieldProps, inputProps } = extractEditableInputProps(props);
18
39
  const renderInput = useCallback((renderProps) => (_jsx(TextInput, { ...renderProps, ...inputProps })), [inputProps]);
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  export interface FormClassNames {
3
3
  root: string;
4
4
  }
@@ -7,6 +7,8 @@ export interface FormProps extends ClassNameProps<FormClassNames> {
7
7
  children: React.ReactNode;
8
8
  id?: string;
9
9
  onSubmit?: React.FormEventHandler<HTMLFormElement>;
10
+ ref?: React.Ref<HTMLFormElement>;
11
+ uncaughtErrors: Record<string, string> | null;
10
12
  }
11
- declare function Form({ action, children, classNames, classNameProps, id, onSubmit, }: Readonly<FormProps>): React.ReactElement;
13
+ declare function Form({ action, children, classNames, classNameProps, id, onSubmit, uncaughtErrors, ref, }: Readonly<FormProps>): React.ReactElement;
12
14
  export default Form;
@@ -1,9 +1,10 @@
1
1
  'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { getClassNames } from '../../../styles/config';
4
- import tw from '../../../styles/tw';
5
- function Form({ action, children, classNames, classNameProps, id, onSubmit, }) {
6
- const componentClassNames = classNames || getClassNames('form')?.(classNameProps);
7
- return (_jsx("form", { action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: children }));
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import tw from '../../../styles/classnames/utility/tw';
5
+ import { InfoPanel } from '../../../components';
6
+ function Form({ action, children, classNames, classNameProps, id, onSubmit, uncaughtErrors, ref, }) {
7
+ const componentClassNames = useClassNames('form', { props: classNameProps }, classNames);
8
+ return (_jsxs("form", { ref: ref, action: action, className: tw(componentClassNames?.root), id: id, onSubmit: onSubmit, children: [uncaughtErrors && Object.keys(uncaughtErrors).length ? (_jsx(InfoPanel, { variant: "error", children: Object.values(uncaughtErrors).map((item, index) => (_jsx("p", { children: item }, index))) })) : null, children] }));
8
9
  }
9
10
  export default Form;
@@ -1,6 +1,6 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  import type { FormFieldClassNames } from '../FormField';
3
- interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
3
+ export interface FormErrorProps extends ClassNameProps<FormFieldClassNames> {
4
4
  children: React.ReactNode;
5
5
  id: string;
6
6
  isAssistive?: boolean;
@@ -1,8 +1,10 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getClassNames } from '../../../styles/config';
3
- import tw from '../../../styles/tw';
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames, useIcon } from '../../../styles/context';
4
+ import tw from '../../../styles/classnames/utility/tw';
4
5
  function FormError({ children, classNames, classNameProps, id, isAssistive, }) {
5
- const componentClassNames = classNames || getClassNames('formField')?.(classNameProps);
6
- return (_jsx("div", { className: tw(componentClassNames?.error, isAssistive ? 'sr-only' : null), id: `${id}_err`, children: children }));
6
+ const componentClassNames = useClassNames('formField', { props: classNameProps }, classNames);
7
+ const Icon = useIcon('formField.error');
8
+ return (_jsxs("div", { className: tw(componentClassNames?.error, isAssistive ? 'sr-only' : null), id: `${id}_err`, children: [Icon ? (_jsx("div", { className: "h-5 w-5", children: _jsx(Icon, {}) })) : null, children] }));
7
9
  }
8
10
  export default FormError;
@@ -1,6 +1,6 @@
1
1
  import type { InputEvent, InputProps } from '../../../forms/interfaces';
2
- import type { ClassNameProps, ErrorableClassName } from '../../../styles/interfaces';
3
- import { Action } from '../../../utility/interfaces';
2
+ import type { ClassNameProps, ErrorableClassName } from '../../../styles/classnames/interfaces';
3
+ import { SimpleActionObject } from '../../../utility/interfaces';
4
4
  export interface FormFieldClassNames {
5
5
  root: ErrorableClassName;
6
6
  label: string;
@@ -10,16 +10,18 @@ export interface FormFieldClassNames {
10
10
  error: string;
11
11
  }
12
12
  export interface FormFieldProps<T, V extends T> extends ClassNameProps<FormFieldClassNames>, InputProps<T, V> {
13
- action?: Action | null;
14
- details?: string | null;
13
+ action?: SimpleActionObject | null;
14
+ details?: React.ReactNode;
15
15
  error?: Record<string, string> | null;
16
16
  hasAssistiveError?: boolean;
17
+ hasAssistiveDetails?: boolean;
17
18
  hasAssistiveLabel?: boolean;
18
19
  isContentOnly?: boolean;
19
20
  isOptional?: boolean;
20
21
  label?: React.ReactNode;
21
22
  onChange?: (event: InputEvent<T>) => void;
23
+ onFieldChange?: (event: InputEvent<T>) => void;
22
24
  render: (props: InputProps<T>) => React.ReactElement | null;
23
25
  }
24
- declare function FormField<T, V extends T>({ action, classNameProps, details, error, hasAssistiveError, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
26
+ declare function FormField<T, V extends T>({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onFieldChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
25
27
  export default FormField;
@@ -1,30 +1,38 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState } from 'react';
4
- import { getClassNames } from '../../../styles/config';
5
- import tw from '../../../styles/tw';
4
+ import { useClassNames } from '../../../styles/context';
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;