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

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 +14 -0
  139. package/dist/forms/components/Dropdown/index.d.ts +1 -1
  140. package/dist/forms/components/Dropdown/index.js +9 -8
  141. package/dist/forms/components/DropdownItem/index.d.ts +9 -0
  142. package/dist/forms/components/DropdownItem/index.js +9 -0
  143. package/dist/forms/components/DropdownList/index.d.ts +1 -1
  144. package/dist/forms/components/DropdownList/index.js +7 -11
  145. package/dist/forms/components/EditableForm/index.d.ts +3 -3
  146. package/dist/forms/components/EditableForm/index.js +9 -9
  147. package/dist/forms/components/EditableFormField/index.d.ts +1 -1
  148. package/dist/forms/components/EditableFormField/index.js +3 -3
  149. package/dist/forms/components/EditableFormFields/index.d.ts +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 +22 -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,17 +1,16 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import usePagination from '../../../hooks/usePagination';
4
- import { getClassNames } from '../../../styles/config';
5
- import tw from '../../../styles/tw';
6
- import Link from '../../../components/utility/Link';
4
+ import { useClassNames } from '../../../styles/context';
5
+ import tw from '../../../styles/classnames/utility/tw';
6
+ import Link from '../../elements/Link';
7
+ import PaginationLink from '../PaginationLink';
7
8
  function Pagination({ classNames, classNameProps, gapLabel = '•••', limit, nextLabel, page, previousLabel, total, }) {
8
- const componentClassNames = classNames || getClassNames('pagination')?.(classNameProps);
9
+ const componentClassNames = useClassNames('pagination', { props: classNameProps }, classNames);
9
10
  const { links, nextLink, pageCount, previousLink } = usePagination({ limit, page, total });
10
11
  if (pageCount <= 1) {
11
12
  return null;
12
13
  }
13
- return (_jsxs("nav", { className: tw(componentClassNames?.root), children: [previousLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page <= 1 ? 'pointer-events-none opacity-30' : null), href: previousLink, children: previousLabel })) : null, _jsx("ul", { className: tw(componentClassNames?.list), children: links.map((link, index) => (_jsx("li", { className: componentClassNames?.item, children: link ? (_jsx(Link, { className: tw(componentClassNames?.link?.default, link.label === page.toString()
14
- ? componentClassNames?.link?.highlighted
15
- : null), href: link.href, children: link.label })) : (_jsx("span", { className: tw(componentClassNames?.gap), children: gapLabel })) }, index))) }), nextLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page >= pageCount ? 'pointer-events-none opacity-30' : null), href: nextLink, children: nextLabel })) : null] }));
14
+ return (_jsxs("nav", { className: componentClassNames?.root, children: [previousLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page <= 1 ? 'pointer-events-none opacity-30' : null), href: previousLink, children: previousLabel })) : null, _jsx("ul", { className: componentClassNames?.list, children: links.map((link, index) => (_jsx("li", { className: componentClassNames?.item, children: link ? (_jsx(PaginationLink, { ...link, isCurrent: link.label === page.toString() })) : (_jsx("span", { className: componentClassNames?.gap, children: gapLabel })) }, index))) }), nextLabel ? (_jsx(Link, { className: tw(componentClassNames?.navigation, page >= pageCount ? 'pointer-events-none opacity-30' : null), href: nextLink, children: nextLabel })) : null] }));
16
15
  }
17
16
  export default Pagination;
@@ -0,0 +1,9 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
+ import type { PaginationClassNames } from '../Pagination';
3
+ interface PaginationLinkProps extends ClassNameProps<PaginationClassNames> {
4
+ href: string;
5
+ isCurrent: boolean;
6
+ label: string;
7
+ }
8
+ declare function PaginationLink({ classNameProps, classNames, href, isCurrent, label, }: PaginationLinkProps): React.ReactElement;
9
+ export default PaginationLink;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import Link from '../../elements/Link';
5
+ function PaginationLink({ classNameProps, classNames, href, isCurrent, label, }) {
6
+ const componentClassNames = useClassNames('pagination', { props: classNameProps, states: { isHighlighted: isCurrent } }, classNames);
7
+ return (_jsx(Link, { className: componentClassNames?.link, href: href, children: label }));
8
+ }
9
+ export default PaginationLink;
@@ -1,9 +1,8 @@
1
1
  import { CollectionComponentProps } from '../Collection';
2
2
  import type { TableColumnObject, TableItemObject } from '../interfaces';
3
3
  export type { TableClassNames } from '../TableClientComponent';
4
- export interface TableProps<Item, Filters = null> extends CollectionComponentProps<Item, TableItemObject, Filters> {
5
- readonly columns: TableColumnObject[];
6
- readonly isSelectable?: boolean;
4
+ export interface TableProps<Item, Filters, Columns extends readonly TableColumnObject[], Data, Response> extends CollectionComponentProps<Item, TableItemObject<Columns, Data, Response>, Filters> {
5
+ readonly columns: Columns;
7
6
  }
8
- declare function Table<Item extends object, Filters>({ columns, isSelectable, ...props }: TableProps<Item, Filters>): React.ReactElement;
7
+ declare function Table<Item, Filters, Columns extends readonly TableColumnObject[], Data, Response>({ columns, ...props }: TableProps<Item, Filters, Columns, Data, Response>): React.ReactElement;
9
8
  export default Table;
@@ -1,13 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Collection from '../Collection';
3
3
  import TableClientComponent from '../TableClientComponent';
4
- function defaultTransformer(item) {
5
- return {
6
- id: 'id' in item ? String(item.id) : JSON.stringify(item),
7
- ...item,
8
- };
9
- }
10
- function Table({ columns, isSelectable, ...props }) {
11
- return (_jsx(Collection, { ...props, render: (data) => (_jsx(TableClientComponent, { columns: columns, data: data, isSelectable: isSelectable })), transformer: props.transformer ?? defaultTransformer }));
4
+ function Table({ columns, ...props }) {
5
+ return (_jsx(Collection, { ...props, render: (data) => _jsx(TableClientComponent, { columns: columns, data: data }), transformer: props.transformer }));
12
6
  }
13
7
  export default Table;
@@ -1,14 +1,15 @@
1
- import { ClassNameProps, SelectableClassName } from '../../../styles/interfaces';
1
+ import { ClassNameProps, SelectableClassName } from '../../../styles/classnames/interfaces';
2
2
  import type { TableColumnObject, TableItemObject } from '../interfaces';
3
3
  export interface TableClassNames {
4
4
  root: string;
5
5
  row: SelectableClassName;
6
+ head: string;
6
7
  cell: string;
8
+ actions: string;
7
9
  }
8
- interface TableClientComponentProps extends ClassNameProps<TableClassNames> {
9
- readonly columns: TableColumnObject[];
10
- readonly data: TableItemObject[];
11
- readonly isSelectable?: boolean;
10
+ interface TableClientComponentProps<Columns extends readonly TableColumnObject[], Data, Response> extends ClassNameProps<TableClassNames> {
11
+ readonly columns: Columns;
12
+ readonly data: TableItemObject<Columns, Data, Response>[];
12
13
  }
13
- declare function TableClientComponent({ classNameProps, classNames, columns, data, isSelectable, }: Readonly<TableClientComponentProps>): React.ReactElement;
14
+ declare function TableClientComponent<Columns extends readonly TableColumnObject[], Data, Response>({ classNameProps, classNames, columns, data, }: Readonly<TableClientComponentProps<Columns, Data, Response>>): React.ReactElement;
14
15
  export default TableClientComponent;
@@ -1,30 +1,15 @@
1
1
  'use client';
2
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
3
- import { toggleArrayItem } from '@sqrzro/utility';
4
- import { useSearchParams } from 'next/navigation';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import useSelected from '../../../hooks/useSelected';
4
+ import { useClassNames } from '../../../styles/context';
5
+ import tw from '../../../styles/classnames/utility/tw';
6
+ import isRightAligned from '../utility/is-right-aligned';
7
+ import TableRow from '../TableRow';
5
8
  import Switch from '../../../forms/components/Switch';
6
- import useSearchParamsHref from '../../../hooks/useSearchParamsHref';
7
- import { getClassNames } from '../../../styles/config';
8
- import tw from '../../../styles/tw';
9
- import filterColumns from '../utility/filter-columns';
10
- import getSelectedFromSearchParams from '../utility/get-selected-from-search-params';
11
- import setSelectedToSearchParams from '../utility/set-selected-to-search-params';
12
- function TableClientComponent({ classNameProps, classNames, columns, data, isSelectable, }) {
13
- const componentClassNames = classNames || getClassNames('table')?.(classNameProps);
14
- const { setSearchParamsHref } = useSearchParamsHref();
15
- const searchParams = useSearchParams();
16
- const filteredColumns = filterColumns(columns, isSelectable);
17
- const selected = getSelectedFromSearchParams(searchParams);
18
- function handleSelect(event) {
19
- const value = toggleArrayItem(selected, event.target.name);
20
- setSearchParamsHref({ selected: setSelectedToSearchParams(value) });
21
- }
22
- function handleSelectAll() {
23
- const value = selected.length === data.length ? [] : data.map((item) => item.id);
24
- setSearchParamsHref({ selected: setSelectedToSearchParams(value) });
25
- }
26
- return (_jsx("div", { className: componentClassNames?.root, children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsx("tr", { children: filteredColumns.map((column) => (_jsx("th", { children: column.type === 'selectable' ? (_jsxs("button", { name: column.id, onClick: handleSelectAll, children: ["Select All ", selected.includes(column.id) ? '✓' : ''] })) : (column.title) }, column.id))) }) }), _jsx("tbody", { children: data.map((item) => (_jsx("tr", { className: tw(componentClassNames?.row?.default, selected.includes(item.id)
27
- ? componentClassNames?.row?.selected
28
- : null), children: filteredColumns.map((column) => (_jsx("td", { className: tw(componentClassNames?.cell, column.type === 'selectable' ? 'w-1' : null), children: column.type === 'selectable' ? (_jsx(Switch, { name: item.id, onChange: handleSelect, value: selected.includes(item.id) })) : (item[column.id]) }, column.id))) }, item.id))) })] }) }));
9
+ function TableClientComponent({ classNameProps, classNames, columns, data, }) {
10
+ const componentClassNames = useClassNames('table', { props: classNameProps }, classNames);
11
+ const { checkSelected, isAllSelected, onSelect, onSelectAll } = useSelected(data);
12
+ const hasActions = data.some((item) => item.actions?.length);
13
+ return (_jsx("div", { className: componentClassNames?.root, children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsxs("tr", { children: [data[0].isSelectable ? (_jsx("th", { className: componentClassNames?.head, children: _jsx(Switch, { name: "all", onChange: onSelectAll, value: isAllSelected }) })) : null, columns.map((column) => (_jsx("th", { className: tw(componentClassNames?.head, isRightAligned(column.type) ? 'text-right' : null), children: column.title }, column.id)))] }) }), _jsx("tbody", { children: data.map((item) => (_jsx(TableRow, { columns: columns, data: item, hasActions: hasActions, isSelected: checkSelected(item.id), onSelect: onSelect }, item.id))) })] }) }));
29
14
  }
30
15
  export default TableClientComponent;
@@ -0,0 +1,13 @@
1
+ import type { InputEvent } from '../../../forms/interfaces';
2
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
3
+ import type { TableClassNames } from '../TableClientComponent';
4
+ import type { TableColumnObject, TableItemObject } from '../interfaces';
5
+ interface TableRowProps<Columns extends readonly TableColumnObject[], Data, Response> extends ClassNameProps<TableClassNames> {
6
+ columns: Columns;
7
+ data: TableItemObject<Columns, Data, Response>;
8
+ hasActions: boolean;
9
+ isSelected: boolean;
10
+ onSelect: (event: InputEvent<boolean>) => void;
11
+ }
12
+ declare function TableRow<Columns extends readonly TableColumnObject[], Data, Response>({ classNameProps, classNames, columns, data, hasActions, isSelected, onSelect, }: TableRowProps<Columns, Data, Response>): React.ReactElement;
13
+ export default TableRow;
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { filterNull } from '@sqrzro/utility';
4
+ import Switch from '../../../forms/components/Switch';
5
+ import { useClassNames } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
7
+ import isRightAligned from '../utility/is-right-aligned';
8
+ import renderCell from '../utility/render-cell';
9
+ import ListItemMenu from '../ListItemMenu';
10
+ function TableRow({ classNameProps, classNames, columns, data, hasActions, isSelected, onSelect, }) {
11
+ const componentClassNames = useClassNames('table', { props: { ...classNameProps, isSelected } }, classNames);
12
+ const filteredActions = filterNull(data.actions || []);
13
+ return (_jsxs("tr", { className: componentClassNames?.row, children: [data.isSelectable ? (_jsx("td", { className: tw(componentClassNames?.cell, 'w-10'), children: _jsx(Switch, { name: data.id, onChange: onSelect, value: isSelected }) })) : null, columns.map((column) => (_jsx("td", { className: tw(componentClassNames?.cell, isRightAligned(column.type) ? 'text-right' : null), children: renderCell(column, data.row[column.id]) }, column.id))), hasActions ? (_jsx("td", { className: tw(componentClassNames?.cell, 'w-10'), children: _jsx("div", { className: componentClassNames?.actions, children: _jsx(ListItemMenu, { actions: filteredActions, data: data.$data, isDisabled: !filteredActions.length }) }) })) : null] }));
14
+ }
15
+ export default TableRow;
@@ -1,51 +1,58 @@
1
- import type { Action, StyleVariant } from '../../utility/interfaces';
2
- export interface CollectionFunctionConfig<Filters = null> {
3
- filters?: Partial<Filters> | null;
1
+ import type { ActionObject, DataObject, ReferenceObject, StyleVariant } from '../../utility/interfaces';
2
+ export type CollectionFunctionConfig<Filters = undefined> = {
4
3
  params?: Record<string, string> | null;
5
4
  page?: number | null;
6
- }
7
- export type ListFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
8
- export interface ListItemObject<Data extends object | null = null> {
5
+ filters?: Filters extends undefined ? never : Partial<Filters> | null;
6
+ };
7
+ export type ListFunctionConfig<Filters = undefined> = CollectionFunctionConfig<Filters>;
8
+ export interface ListItemObject<Data, Response> {
9
9
  $data?: Data;
10
- actions?: Action[];
11
- description?: React.ReactNode | null;
10
+ actions?: (ActionObject<Data, Response> | null)[];
11
+ description?: React.ReactNode;
12
12
  href?: string;
13
13
  id: string;
14
- isMinimal?: boolean;
15
- image?: string | null;
16
- imageHref?: string | null;
17
- isLoading?: boolean;
18
- meta?: {
19
- data?: React.ReactNode[] | Record<string, React.ReactNode>;
20
- id: string;
21
- };
22
- permission?: string;
23
- secondary?: {
24
- data?: React.ReactElement | {
25
- description?: string;
26
- meta?: {
27
- data?: React.ReactNode[] | Record<string, React.ReactNode>;
28
- id: string;
29
- };
30
- title?: string;
31
- } | null;
14
+ isSelectable?: boolean;
15
+ meta?: React.ReactNode[] | (DataObject | null)[];
16
+ secondary?: React.ReactElement | {
17
+ description?: React.ReactNode;
18
+ meta?: React.ReactNode[] | (DataObject | null)[];
19
+ title?: React.ReactNode;
32
20
  variant?: StyleVariant | null;
33
- };
21
+ } | null;
34
22
  tertiary?: React.ReactNode;
35
23
  title?: React.ReactNode;
36
24
  variant?: StyleVariant | null;
37
25
  }
38
- export type TableFunctionConfig<Filters = null> = CollectionFunctionConfig<Filters>;
39
- export interface TableItemObject {
40
- [key: string]: React.ReactNode;
41
- id: string;
42
- }
43
- export type TableColumnType = 'date' | 'decimal' | 'id' | 'link' | 'money' | 'number' | 'percentage' | 'reference' | 'selectable' | 'string';
26
+ export type TableFunctionConfig<Filters = undefined> = CollectionFunctionConfig<Filters>;
27
+ export type TableColumnTypeMap = {
28
+ date: Date;
29
+ datetime: Date;
30
+ decimal: number;
31
+ link: string;
32
+ money: number;
33
+ number: number;
34
+ percentage: number;
35
+ points: number;
36
+ raw: React.ReactNode;
37
+ reference: ReferenceObject;
38
+ string: string;
39
+ time: Date;
40
+ };
44
41
  export interface TableColumnObject {
45
42
  isSortable?: boolean;
46
43
  id: string;
47
44
  title?: string;
48
- type?: TableColumnType;
45
+ type: keyof TableColumnTypeMap;
46
+ }
47
+ export type TableRowFromColumns<T extends readonly TableColumnObject[]> = {
48
+ [K in T[number] as K['id']]: TableColumnTypeMap[K['type']];
49
+ };
50
+ export interface TableItemObject<Columns extends readonly TableColumnObject[], Data, Response> {
51
+ $data?: Data;
52
+ actions?: (ActionObject<Data, Response> | null)[];
53
+ id: string;
54
+ isSelectable?: boolean;
55
+ row: TableRowFromColumns<Columns>;
49
56
  }
50
57
  export interface Paginated<T> {
51
58
  data: T[];
@@ -1,4 +1,4 @@
1
1
  export const messages = {
2
- EMPTY_FILTER_DESCRIPTION: 'Try adjusting the filters above. If you think this is a mistake, please contact your site administrator.',
2
+ EMPTY_FILTER_DESCRIPTION: 'Try adjusting the filters above.',
3
3
  EMPTY_FILTER_TITLE: 'No results match the current filters',
4
4
  };
@@ -1,3 +1,3 @@
1
- import type { Paginated } from "../interfaces";
1
+ import type { Paginated } from '../interfaces';
2
2
  declare function isPaginated<Item>(response: Item[] | Paginated<Item>): response is Paginated<Item>;
3
3
  export default isPaginated;
@@ -0,0 +1,3 @@
1
+ import { TableColumnTypeMap } from '../interfaces';
2
+ declare function isRightAligned(type?: keyof TableColumnTypeMap): boolean;
3
+ export default isRightAligned;
@@ -0,0 +1,11 @@
1
+ const RIGHT_ALIGNED_TYPES = [
2
+ 'decimal',
3
+ 'money',
4
+ 'number',
5
+ 'percentage',
6
+ 'points',
7
+ ];
8
+ function isRightAligned(type) {
9
+ return Boolean(type && RIGHT_ALIGNED_TYPES.includes(type));
10
+ }
11
+ export default isRightAligned;
@@ -0,0 +1,2 @@
1
+ declare function normalizeHref(href: string, pathname: string): string;
2
+ export default normalizeHref;
@@ -0,0 +1,8 @@
1
+ import { joinURL } from '@sqrzro/utility';
2
+ function normalizeHref(href, pathname) {
3
+ if (href.startsWith('./')) {
4
+ return joinURL(pathname, href.slice(2));
5
+ }
6
+ return joinURL(href);
7
+ }
8
+ export default normalizeHref;
@@ -0,0 +1,5 @@
1
+ import type { TableColumnTypeMap } from '../interfaces';
2
+ declare function renderCell<K extends keyof TableColumnTypeMap>(column: {
3
+ type: K;
4
+ }, value: TableColumnTypeMap[K]): React.ReactNode;
5
+ export default renderCell;
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { formatDate, formatDatetime, formatMoney, formatPoints, formatTime } from '@sqrzro/utility';
4
+ import { usePathname } from 'next/navigation';
5
+ import Link from '../../../components/elements/Link';
6
+ import Reference from '../../../components/elements/Reference';
7
+ import normalizeHref from './normalize-href';
8
+ function renderDefault(value) {
9
+ return value;
10
+ }
11
+ function renderLink(value, pathname) {
12
+ const match = value.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
13
+ return match ? _jsx(Link, { href: normalizeHref(match[2], pathname), children: match[1] }) : value;
14
+ }
15
+ const renderers = {
16
+ date: (value) => formatDate(value),
17
+ datetime: (value) => formatDatetime(value),
18
+ decimal: (value) => value.toFixed(2),
19
+ link: (value, pathname) => renderLink(value, pathname),
20
+ money: (value) => formatMoney(value),
21
+ number: (value) => renderDefault(value),
22
+ percentage: (value) => `${value.toFixed(2)}%`,
23
+ points: (value) => formatPoints(value),
24
+ raw: (value) => renderDefault(value),
25
+ reference: (value) => _jsx(Reference, { ...value }),
26
+ string: (value) => renderDefault(value),
27
+ time: (value) => formatTime(value),
28
+ };
29
+ function renderCell(column, value) {
30
+ const pathname = usePathname();
31
+ return renderers[column.type](value, pathname);
32
+ }
33
+ export default renderCell;
@@ -0,0 +1,12 @@
1
+ import type { ClassNameProps, StylableClassName } from '../../../styles/classnames/interfaces';
2
+ import type { StyleVariant } from '../../../utility/interfaces';
3
+ export interface BadgeClassNames {
4
+ root: StylableClassName;
5
+ dot: StylableClassName;
6
+ }
7
+ export interface BadgeProps extends ClassNameProps<BadgeClassNames> {
8
+ children: React.ReactNode;
9
+ variant?: StyleVariant[] | StyleVariant | null;
10
+ }
11
+ declare function Badge({ classNameProps, classNames, children, variant }: BadgeProps): React.ReactElement;
12
+ export default Badge;
@@ -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 applyVariants from '../../../styles/classnames/utility/apply-variants';
5
+ function Badge({ classNameProps, classNames, children, variant }) {
6
+ const componentClassNames = useClassNames('badge', { props: { ...classNameProps, ...applyVariants(variant) } }, classNames);
7
+ return (_jsxs("strong", { className: componentClassNames?.root, children: [_jsx("svg", { "aria-hidden": "true", className: componentClassNames?.dot, viewBox: "0 0 6 6", children: _jsx("circle", { cx: "3", cy: "3", r: "3" }) }), children] }));
8
+ }
9
+ export default Badge;
@@ -0,0 +1,4 @@
1
+ import type { LinkProps } from '../Link';
2
+ export type ContentLinkProps = LinkProps;
3
+ declare function ContentLink({ className, ...props }: ContentLinkProps): React.ReactElement;
4
+ export default ContentLink;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import tw from '../../../styles/classnames/utility/tw';
3
+ import Link from '../Link';
4
+ function ContentLink({ className, ...props }) {
5
+ return _jsx(Link, { ...props, className: tw('text-link', className) });
6
+ }
7
+ export default ContentLink;
@@ -0,0 +1,11 @@
1
+ import type { ClassNameProps, StylableClassName } from '../../../styles/classnames/interfaces';
2
+ import type { StyleVariant } from '../../../utility/interfaces';
3
+ export interface InfoPanelClassNames {
4
+ root: StylableClassName;
5
+ }
6
+ export interface InfoPanelProps extends ClassNameProps<InfoPanelClassNames> {
7
+ children: React.ReactNode;
8
+ variant?: StyleVariant[] | StyleVariant | null;
9
+ }
10
+ declare function InfoPanel({ classNameProps, classNames, children, variant, }: InfoPanelProps): React.ReactElement;
11
+ export default InfoPanel;
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import applyVariants from '../../../styles/classnames/utility/apply-variants';
5
+ function InfoPanel({ classNameProps, classNames, children, variant, }) {
6
+ const componentClassNames = useClassNames('infoPanel', { props: { ...classNameProps, ...applyVariants(variant) } }, classNames);
7
+ return _jsx("aside", { className: componentClassNames?.root, children: children });
8
+ }
9
+ export default InfoPanel;
@@ -1,4 +1,4 @@
1
- import type { ClassNameProps } from '../../../styles/interfaces';
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
2
  interface DataProps {
3
3
  'data-test-id'?: string;
4
4
  }
@@ -10,10 +10,11 @@ export interface LinkProps extends ClassNameProps<LinkClassNames>, DataProps {
10
10
  children: React.ReactNode;
11
11
  href?: string | null;
12
12
  id?: string;
13
+ isDownload?: boolean;
13
14
  isNewWindow?: boolean;
14
15
  onClick?: React.MouseEventHandler<HTMLAnchorElement>;
15
16
  scroll?: boolean;
16
17
  style?: React.CSSProperties;
17
18
  }
18
- declare function Link({ children, className, classNames, classNameProps, isNewWindow, href, id, onClick, scroll, style, ...dataProps }: Readonly<LinkProps>): React.ReactElement;
19
+ declare function Link({ children, className, classNames, classNameProps, isDownload, isNewWindow, href, id, onClick, scroll, style, ...dataProps }: Readonly<LinkProps>): React.ReactElement;
19
20
  export default Link;
@@ -1,24 +1,25 @@
1
+ 'use client';
1
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { joinURL } from '@sqrzro/utility';
2
4
  import NextLink from 'next/link';
3
- import { getClassNames } from '../../../styles/config';
4
- import tw from '../../../styles/tw';
5
+ import { useClassNames } from '../../../styles/context';
6
+ import tw from '../../../styles/classnames/utility/tw';
5
7
  function normalizeHref(href) {
6
- if (!href) {
7
- return '';
8
- }
9
8
  if (href.startsWith('#')) {
10
9
  return href;
11
10
  }
12
- return /^\//u.exec(href) ? href : `/${href}`;
11
+ return joinURL(href);
13
12
  }
14
- function Link({ children, className, classNames, classNameProps, isNewWindow, href = '/', id, onClick, scroll, style, ...dataProps }) {
15
- const componentClassNames = classNames || getClassNames('link')?.(classNameProps);
13
+ function Link({ children, className, classNames, classNameProps, isDownload, isNewWindow, href = '/', id, onClick, scroll, style, ...dataProps }) {
14
+ const componentClassNames = useClassNames('link', { props: classNameProps }, classNames);
15
+ const downloadProps = isDownload ? { download: true } : {};
16
16
  const newWindowProps = isNewWindow
17
17
  ? { rel: 'noopener noreferrer', target: '_blank' }
18
18
  : {};
19
19
  const props = {
20
- ...newWindowProps,
21
20
  ...dataProps,
21
+ ...downloadProps,
22
+ ...newWindowProps,
22
23
  className: tw(componentClassNames?.root, className),
23
24
  id,
24
25
  onClick,
@@ -0,0 +1,19 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
+ import type { ActionObject } from '../../../utility/interfaces';
3
+ import { PopoverProps } from '../../utility/Popover';
4
+ export interface MenuClassNames {
5
+ root: string;
6
+ list: string;
7
+ item: string;
8
+ link: string;
9
+ }
10
+ export interface MenuProps<Data, Response> extends ClassNameProps<MenuClassNames> {
11
+ actions: (ActionObject<Data, Response> | null)[];
12
+ align?: PopoverProps['align'];
13
+ data?: Data;
14
+ isDisabled?: boolean;
15
+ label: React.ReactNode;
16
+ vAlign?: PopoverProps['vAlign'];
17
+ }
18
+ declare function Menu<Data, Response>({ actions, align, classNameProps, classNames, data, isDisabled, label, vAlign, }: MenuProps<Data, Response>): React.ReactElement;
19
+ export default Menu;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { filterNull } from '@sqrzro/utility';
4
+ import Button from '../../../components/buttons/Button';
5
+ import usePopover from '../../../hooks/usePopover';
6
+ import { useClassNames } from '../../../styles/context';
7
+ import tw from '../../../styles/classnames/utility/tw';
8
+ import Action from '../../utility/Action';
9
+ import Popover from '../../utility/Popover';
10
+ import MenuItem from '../MenuItem';
11
+ function Menu({ actions, align, classNameProps, classNames, data, isDisabled, label, vAlign, }) {
12
+ const componentClassNames = useClassNames('menu', { props: classNameProps }, classNames);
13
+ const { controlProps, ref, targetProps } = usePopover();
14
+ const filteredActions = filterNull(actions);
15
+ return (_jsxs("div", { className: tw('relative', componentClassNames?.root), ref: ref, children: [_jsx(Button, { ...controlProps, classNameProps: classNameProps, isDisabled: isDisabled, children: label }), _jsx(Popover, { ...targetProps, align: align, classNameProps: classNameProps, vAlign: vAlign, children: _jsx("ul", { className: componentClassNames?.list, children: filteredActions.map((item, index) => (_jsx("li", { className: componentClassNames?.item, children: _jsx(Action, { ...item, data: data, render: (props) => (_jsx(MenuItem, { ...props, classNameProps: classNameProps })) }) }, index))) }) })] }));
16
+ }
17
+ export default Menu;
@@ -0,0 +1,9 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
+ import type { ActionComponentProps } from '../../utility/Action';
3
+ import type { MenuClassNames } from '../Menu';
4
+ interface MenuItemProps<Data, Response> extends ClassNameProps<MenuClassNames>, ActionComponentProps<Data, Response> {
5
+ isDownload?: boolean;
6
+ isNewWindow?: boolean;
7
+ }
8
+ declare function MenuItem<Data, Response>({ children, classNameProps, classNames, href, isDownload, isLoading, isNewWindow, onClick, }: MenuItemProps<Data, Response>): React.ReactElement;
9
+ export default MenuItem;
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useClassNames } from '../../../styles/context';
4
+ import Link from '../Link';
5
+ function MenuItem({ children, classNameProps, classNames, href, isDownload, isLoading, isNewWindow, onClick, }) {
6
+ const componentClassNames = useClassNames('menu', { props: classNameProps }, classNames);
7
+ if (href) {
8
+ return (_jsx(Link, { className: componentClassNames?.link, href: href, isDownload: isDownload, isNewWindow: isNewWindow, onClick: onClick, children: children }));
9
+ }
10
+ return (_jsxs("button", { className: componentClassNames?.link, onClick: onClick, type: "button", children: [children, " ", isLoading && '...'] }));
11
+ }
12
+ export default MenuItem;
@@ -0,0 +1,19 @@
1
+ import type { NavigationObject } from '../../../navigation/interfaces';
2
+ import type { NextPageProps } from '../../../utility/interfaces';
3
+ type Fn = (params?: Promise<Record<string, string>> | null) => Promise<any>;
4
+ type FnReturn<T extends Fn> = T extends (...args: any[]) => Promise<infer R> ? R : never;
5
+ interface PageTemplateProps {
6
+ children: React.ReactNode;
7
+ tabs: NavigationObject[] | null;
8
+ title: React.ReactNode;
9
+ }
10
+ export type PageProps<T extends Fn | undefined = undefined> = {
11
+ readonly fn?: T;
12
+ readonly children: React.ReactNode | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => React.ReactNode);
13
+ readonly pageProps?: NextPageProps;
14
+ readonly tabs?: NavigationObject[] | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => NavigationObject[] | null);
15
+ readonly template?: (props: PageTemplateProps) => React.ReactElement;
16
+ readonly title?: React.ReactNode | ((data: T extends Fn ? FnReturn<T> : null, pageProps?: NextPageProps) => React.ReactNode);
17
+ };
18
+ declare function Page<T extends Fn | undefined = undefined>(props: PageProps<T>): import("react/jsx-runtime").JSX.Element;
19
+ export default Page;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Suspense } from 'react';
3
+ async function PageComponent(props) {
4
+ const data = props.fn ? await props.fn(props.pageProps?.params) : null;
5
+ const children = typeof props.children === 'function'
6
+ ? props.children(data, props.pageProps)
7
+ : props.children;
8
+ const tabs = typeof props.tabs === 'function' ? props.tabs(data, props.pageProps) : props.tabs;
9
+ const title = typeof props.title === 'function' ? props.title(data, props.pageProps) : props.title;
10
+ if (props.template) {
11
+ return props.template({ children, tabs: tabs ?? null, title });
12
+ }
13
+ return children;
14
+ }
15
+ function Page(props) {
16
+ return (_jsx(Suspense, { fallback: props.template?.({ children: null, tabs: null, title: '•••' }), children: _jsx(PageComponent, { ...props }) }));
17
+ }
18
+ export default Page;
@@ -0,0 +1,9 @@
1
+ import type { ClassNameProps } from '../../../styles/classnames/interfaces';
2
+ import type { ReferenceObject } from '../../../utility/interfaces';
3
+ export interface ReferenceClassNames {
4
+ root: string;
5
+ reference: string;
6
+ }
7
+ export type ReferenceProps = ClassNameProps<ReferenceClassNames> & ReferenceObject;
8
+ declare function Reference({ classNameProps, classNames, id, name, path, reference, }: Readonly<ReferenceProps>): React.ReactElement | string | null;
9
+ export default Reference;
@@ -0,0 +1,16 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { joinURL } from '@sqrzro/utility';
4
+ import { useClassNames } from '../../../styles/context';
5
+ import Link from '../Link';
6
+ function Reference({ classNameProps, classNames, id, name, path, reference, }) {
7
+ const componentClassNames = useClassNames('reference', { props: classNameProps }, classNames);
8
+ if (!reference) {
9
+ return name;
10
+ }
11
+ if (id && path) {
12
+ return (_jsxs(Link, { className: componentClassNames?.root, href: joinURL(path, id), children: [name, _jsx("small", { className: componentClassNames?.reference, children: reference })] }));
13
+ }
14
+ return (_jsxs("span", { className: componentClassNames?.root, children: [name, _jsx("small", { className: componentClassNames?.reference, children: reference })] }));
15
+ }
16
+ export default Reference;