@dbcdk/react-components 0.0.5 → 0.0.7

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 (276) hide show
  1. package/dist/assets/logo.js +2 -85
  2. package/dist/components/__stories__/_data/table.d.ts +15 -0
  3. package/dist/components/__stories__/_data/table.js +49 -0
  4. package/dist/components/__stories__/story-components/Colors.d.ts +2 -1
  5. package/dist/components/__stories__/story-components/Colors.js +87 -142
  6. package/dist/components/__stories__/story-components/Spacing.d.ts +1 -0
  7. package/dist/components/__stories__/story-components/Spacing.js +58 -166
  8. package/dist/components/app-header/AppHeader.d.ts +4 -3
  9. package/dist/components/app-header/AppHeader.js +3 -6
  10. package/dist/components/attribute-chip/AttributeChip.d.ts +1 -0
  11. package/dist/components/attribute-chip/AttributeChip.js +3 -14
  12. package/dist/components/avatar/Avatar.d.ts +2 -2
  13. package/dist/components/avatar/Avatar.js +37 -71
  14. package/dist/components/breadcrumbs/Breadcrumbs.d.ts +4 -4
  15. package/dist/components/breadcrumbs/Breadcrumbs.js +4 -13
  16. package/dist/components/button/Button.d.ts +3 -2
  17. package/dist/components/button/Button.js +54 -56
  18. package/dist/components/button/Button.module.css +1 -1
  19. package/dist/components/card/Card.d.ts +8 -7
  20. package/dist/components/card/Card.js +19 -60
  21. package/dist/components/card-container/CardContainer.d.ts +3 -3
  22. package/dist/components/card-container/CardContainer.js +4 -16
  23. package/dist/components/chip/Chip.d.ts +6 -5
  24. package/dist/components/chip/Chip.js +14 -38
  25. package/dist/components/chip/Chip.module.css +9 -1
  26. package/dist/components/circle/Circle.d.ts +3 -2
  27. package/dist/components/circle/Circle.js +3 -10
  28. package/dist/components/clear-button/ClearButton.d.ts +2 -1
  29. package/dist/components/clear-button/ClearButton.js +6 -17
  30. package/dist/components/code-block/CodeBlock.d.ts +1 -0
  31. package/dist/components/code-block/CodeBlock.js +4 -10
  32. package/dist/components/copy-button/CopyButton.d.ts +4 -3
  33. package/dist/components/copy-button/CopyButton.js +19 -26
  34. package/dist/components/datetime-picker/DateTimePicker.d.ts +8 -5
  35. package/dist/components/datetime-picker/DateTimePicker.js +262 -475
  36. package/dist/components/datetime-picker/dateTimeHelpers.d.ts +13 -0
  37. package/dist/components/datetime-picker/dateTimeHelpers.js +119 -0
  38. package/dist/components/filter-field/FilterField.d.ts +5 -2
  39. package/dist/components/filter-field/FilterField.js +130 -173
  40. package/dist/components/filter-field/FilterField.module.css +21 -5
  41. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.d.ts +36 -0
  42. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +53 -0
  43. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +60 -0
  44. package/dist/components/forms/checkbox/Checkbox.d.ts +31 -0
  45. package/dist/components/forms/checkbox/Checkbox.js +27 -0
  46. package/dist/components/{checkbox → forms/checkbox}/Checkbox.module.css +0 -1
  47. package/dist/components/forms/checkbox-group/CheckboxGroup.d.ts +47 -0
  48. package/dist/components/forms/checkbox-group/CheckboxGroup.js +75 -0
  49. package/dist/components/forms/checkbox-group/CheckboxGroup.module.css +115 -0
  50. package/dist/components/{input → forms/input}/Input.d.ts +9 -5
  51. package/dist/components/forms/input/Input.js +70 -0
  52. package/dist/components/{input → forms/input}/Input.module.css +1 -0
  53. package/dist/components/forms/input-container/InputContainer.d.ts +15 -0
  54. package/dist/components/forms/input-container/InputContainer.js +15 -0
  55. package/dist/components/forms/input-container/InputContainer.module.css +34 -0
  56. package/dist/components/forms/multi-select/MultiSelect.d.ts +20 -0
  57. package/dist/components/forms/multi-select/MultiSelect.js +19 -0
  58. package/dist/components/forms/select/Select.d.ts +21 -0
  59. package/dist/components/forms/select/Select.js +94 -0
  60. package/dist/components/forms/text-area/Textarea.d.ts +17 -0
  61. package/dist/components/forms/text-area/Textarea.js +33 -0
  62. package/dist/components/forms/text-area/Textarea.module.css +26 -0
  63. package/dist/components/headline/Headline.js +18 -43
  64. package/dist/components/{link/Link.d.ts → hyperlink/Hyperlink.d.ts} +2 -2
  65. package/dist/components/hyperlink/Hyperlink.js +11 -0
  66. package/dist/components/{link/Link.module.css → hyperlink/Hyperlink.module.css} +5 -14
  67. package/dist/components/icon/Icon.d.ts +4 -3
  68. package/dist/components/icon/Icon.js +11 -17
  69. package/dist/components/interval-select/IntervalSelect.d.ts +30 -0
  70. package/dist/components/interval-select/IntervalSelect.js +82 -0
  71. package/dist/components/menu/Menu.js +25 -67
  72. package/dist/components/meta-bar/MetaBar.d.ts +4 -4
  73. package/dist/components/meta-bar/MetaBar.js +7 -20
  74. package/dist/components/nav-bar/NavBar.d.ts +5 -5
  75. package/dist/components/nav-bar/NavBar.js +15 -45
  76. package/dist/components/{modal → overlay/modal}/Modal.d.ts +4 -2
  77. package/dist/components/overlay/modal/Modal.js +92 -0
  78. package/dist/components/{modal → overlay/modal}/provider/ModalProvider.d.ts +0 -1
  79. package/dist/components/overlay/modal/provider/ModalProvider.js +70 -0
  80. package/dist/components/overlay/side-panel/SidePanel.d.ts +16 -0
  81. package/dist/components/overlay/side-panel/SidePanel.js +10 -0
  82. package/dist/components/overlay/side-panel/SidePanel.module.css +56 -0
  83. package/dist/components/overlay/side-panel/useSidePanel.d.ts +5 -0
  84. package/dist/components/overlay/side-panel/useSidePanel.js +11 -0
  85. package/dist/components/overlay/tooltip/Tooltip.d.ts +13 -0
  86. package/dist/components/overlay/tooltip/Tooltip.js +17 -0
  87. package/dist/components/overlay/tooltip/Tooltip.module.css +106 -0
  88. package/dist/components/overlay/tooltip/TooltipProvider.d.ts +20 -0
  89. package/dist/components/overlay/tooltip/TooltipProvider.js +244 -0
  90. package/dist/components/overlay/tooltip/useTooltipTrigger.d.ts +24 -0
  91. package/dist/components/overlay/tooltip/useTooltipTrigger.js +108 -0
  92. package/dist/components/page/Page.d.ts +7 -6
  93. package/dist/components/page/Page.js +4 -21
  94. package/dist/components/page-layout/PageLayout.d.ts +11 -12
  95. package/dist/components/page-layout/PageLayout.js +35 -71
  96. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +4 -22
  97. package/dist/components/pagination/Pagination.d.ts +2 -1
  98. package/dist/components/pagination/Pagination.js +38 -121
  99. package/dist/components/panel/Panel.d.ts +4 -3
  100. package/dist/components/panel/Panel.js +5 -10
  101. package/dist/components/popover/Popover.d.ts +1 -0
  102. package/dist/components/popover/Popover.js +116 -141
  103. package/dist/components/search-box/SearchBox.d.ts +2 -2
  104. package/dist/components/search-box/SearchBox.js +112 -162
  105. package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +1 -1
  106. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +47 -94
  107. package/dist/components/sidebar/Sidebar.d.ts +1 -0
  108. package/dist/components/sidebar/Sidebar.js +5 -7
  109. package/dist/components/sidebar/components/SidebarItem.js +6 -14
  110. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +1 -1
  111. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +48 -88
  112. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +3 -2
  113. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +11 -41
  114. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +1 -0
  115. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +4 -25
  116. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +9 -23
  117. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +19 -40
  118. package/dist/components/sidebar/providers/SidebarProvider.d.ts +2 -1
  119. package/dist/components/sidebar/providers/SidebarProvider.js +182 -165
  120. package/dist/components/skeleton-loader/SkeletonLoader.js +68 -266
  121. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +11 -34
  122. package/dist/components/split-button/SplitButton.d.ts +7 -5
  123. package/dist/components/split-button/SplitButton.js +4 -27
  124. package/dist/components/split-pane/SplitPane.js +69 -105
  125. package/dist/components/split-pane/provider/SplitPaneContext.js +77 -71
  126. package/dist/components/table/Table.d.ts +9 -7
  127. package/dist/components/table/Table.js +115 -238
  128. package/dist/components/table/Table.module.css +5 -1
  129. package/dist/components/table/components/column-resizer/ColumnResizer.js +4 -15
  130. package/dist/components/table/components/empty-state/EmptyState.d.ts +6 -5
  131. package/dist/components/table/components/empty-state/EmptyState.js +22 -41
  132. package/dist/components/table/components/table-settings/TableSettings.d.ts +2 -1
  133. package/dist/components/table/components/table-settings/TableSettings.js +9 -27
  134. package/dist/components/table/tanstack.d.ts +1 -1
  135. package/dist/components/table/tanstack.js +154 -160
  136. package/dist/components/tabs/Tabs.d.ts +1 -0
  137. package/dist/components/tabs/Tabs.js +32 -81
  138. package/dist/components/toast/Toast.d.ts +1 -1
  139. package/dist/components/toast/Toast.js +4 -37
  140. package/dist/components/toast/Toast.module.css +1 -0
  141. package/dist/components/toast/provider/ToastProvider.d.ts +1 -1
  142. package/dist/components/toast/provider/ToastProvider.js +60 -87
  143. package/dist/components/user-display/UserDisplay.d.ts +2 -1
  144. package/dist/components/user-display/UserDisplay.js +4 -20
  145. package/dist/constants/severity.d.ts +1 -1
  146. package/dist/constants/severity.js +14 -16
  147. package/dist/constants/severity.types.d.ts +1 -1
  148. package/dist/constants/severity.types.js +1 -1
  149. package/dist/constants/sizes.js +6 -8
  150. package/dist/hooks/usePagination.d.ts +1 -1
  151. package/dist/hooks/usePagination.js +75 -82
  152. package/dist/hooks/useSorting.js +112 -110
  153. package/dist/hooks/useTableData.d.ts +1 -1
  154. package/dist/hooks/useTableData.js +42 -47
  155. package/dist/hooks/useTableSelection.js +121 -121
  156. package/dist/hooks/useTableSettings.js +23 -25
  157. package/dist/hooks/useTheme.d.ts +3 -7
  158. package/dist/hooks/useTheme.js +52 -47
  159. package/dist/hooks/useTimeDuration.d.ts +2 -2
  160. package/dist/hooks/useTimeDuration.js +33 -34
  161. package/dist/hooks/useViewportFill.d.ts +3 -2
  162. package/dist/hooks/useViewportFill.js +55 -48
  163. package/dist/index.d.ts +17 -8
  164. package/dist/index.js +18 -8
  165. package/dist/src/styles/styles.css +3 -3
  166. package/dist/styles/css-helper-classes/flex.css +4 -0
  167. package/dist/styles/styles.css +3 -3
  168. package/dist/styles/themes/dbc/dark.css +1 -1
  169. package/dist/styles/themes/dbc/light.css +2 -1
  170. package/dist/styles/themes/forfatterweb/light.css +1 -1
  171. package/dist/styles/themes/types.js +1 -1
  172. package/dist/types/a11y-props.types.d.ts +5 -5
  173. package/dist/types/a11y-props.types.js +1 -1
  174. package/dist/types/sizes.types.js +1 -1
  175. package/dist/utils/arrays/nested-filtering.js +43 -33
  176. package/dist/utils/date/formatDate.js +25 -16
  177. package/package.json +18 -9
  178. package/dist/assets/logo.cjs +0 -87
  179. package/dist/components/__stories__/story-components/Colors.cjs +0 -159
  180. package/dist/components/__stories__/story-components/Spacing.cjs +0 -190
  181. package/dist/components/app-header/AppHeader.cjs +0 -14
  182. package/dist/components/attribute-chip/AttributeChip.cjs +0 -22
  183. package/dist/components/avatar/Avatar.cjs +0 -101
  184. package/dist/components/breadcrumbs/Breadcrumbs.cjs +0 -22
  185. package/dist/components/button/Button.cjs +0 -87
  186. package/dist/components/card/Card.cjs +0 -69
  187. package/dist/components/card-container/CardContainer.cjs +0 -24
  188. package/dist/components/checkbox/Checkbox.cjs +0 -42
  189. package/dist/components/checkbox/Checkbox.d.ts +0 -12
  190. package/dist/components/checkbox/Checkbox.js +0 -36
  191. package/dist/components/chip/Chip.cjs +0 -50
  192. package/dist/components/circle/Circle.cjs +0 -18
  193. package/dist/components/clear-button/ClearButton.cjs +0 -26
  194. package/dist/components/code-block/CodeBlock.cjs +0 -18
  195. package/dist/components/copy-button/CopyButton.cjs +0 -35
  196. package/dist/components/datetime-picker/DateTimePicker.cjs +0 -504
  197. package/dist/components/filter-field/FilterField.cjs +0 -189
  198. package/dist/components/headline/Headline.cjs +0 -53
  199. package/dist/components/icon/Icon.cjs +0 -27
  200. package/dist/components/input/Input.cjs +0 -89
  201. package/dist/components/input/Input.js +0 -83
  202. package/dist/components/link/Link.cjs +0 -46
  203. package/dist/components/link/Link.js +0 -21
  204. package/dist/components/menu/Menu.cjs +0 -96
  205. package/dist/components/meta-bar/MetaBar.cjs +0 -29
  206. package/dist/components/modal/Modal.cjs +0 -134
  207. package/dist/components/modal/Modal.js +0 -128
  208. package/dist/components/modal/provider/ModalProvider.cjs +0 -80
  209. package/dist/components/modal/provider/ModalProvider.js +0 -77
  210. package/dist/components/multi-select/MultiSelect.cjs +0 -59
  211. package/dist/components/multi-select/MultiSelect.d.ts +0 -18
  212. package/dist/components/multi-select/MultiSelect.js +0 -57
  213. package/dist/components/nav-bar/NavBar.cjs +0 -55
  214. package/dist/components/page/Page.cjs +0 -30
  215. package/dist/components/page-layout/PageLayout.cjs +0 -84
  216. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.cjs +0 -32
  217. package/dist/components/pagination/Pagination.cjs +0 -133
  218. package/dist/components/panel/Panel.cjs +0 -18
  219. package/dist/components/popover/Popover.cjs +0 -149
  220. package/dist/components/search-box/SearchBox.cjs +0 -175
  221. package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +0 -103
  222. package/dist/components/select/Select.cjs +0 -121
  223. package/dist/components/select/Select.d.ts +0 -12
  224. package/dist/components/select/Select.js +0 -119
  225. package/dist/components/sidebar/Sidebar.cjs +0 -11
  226. package/dist/components/sidebar/components/SidebarItem.cjs +0 -18
  227. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +0 -100
  228. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +0 -50
  229. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +0 -34
  230. package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +0 -29
  231. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +0 -52
  232. package/dist/components/sidebar/providers/SidebarProvider.cjs +0 -179
  233. package/dist/components/skeleton-loader/SkeletonLoader.cjs +0 -270
  234. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +0 -42
  235. package/dist/components/split-button/SplitButton.cjs +0 -37
  236. package/dist/components/split-pane/SplitPane.cjs +0 -123
  237. package/dist/components/split-pane/provider/SplitPaneContext.cjs +0 -87
  238. package/dist/components/table/Table.cjs +0 -249
  239. package/dist/components/table/components/column-resizer/ColumnResizer.cjs +0 -22
  240. package/dist/components/table/components/empty-state/EmptyState.cjs +0 -52
  241. package/dist/components/table/components/table-settings/TableSettings.cjs +0 -32
  242. package/dist/components/table/tanstack.cjs +0 -193
  243. package/dist/components/tabs/Tabs.cjs +0 -90
  244. package/dist/components/text-area/Textarea.cjs +0 -62
  245. package/dist/components/text-area/Textarea.d.ts +0 -14
  246. package/dist/components/text-area/Textarea.js +0 -56
  247. package/dist/components/text-area/Textarea.module.css +0 -3
  248. package/dist/components/toast/Toast.cjs +0 -47
  249. package/dist/components/toast/provider/ToastProvider.cjs +0 -98
  250. package/dist/components/tooltip/Tooltip.cjs +0 -183
  251. package/dist/components/tooltip/Tooltip.d.ts +0 -11
  252. package/dist/components/tooltip/Tooltip.js +0 -177
  253. package/dist/components/tooltip/Tooltip.module.css +0 -66
  254. package/dist/components/user-display/UserDisplay.cjs +0 -28
  255. package/dist/constants/severity.cjs +0 -21
  256. package/dist/constants/severity.types.cjs +0 -2
  257. package/dist/constants/sizes.cjs +0 -11
  258. package/dist/hooks/usePagination.cjs +0 -88
  259. package/dist/hooks/useSorting.cjs +0 -118
  260. package/dist/hooks/useTableData.cjs +0 -52
  261. package/dist/hooks/useTableSelection.cjs +0 -130
  262. package/dist/hooks/useTableSettings.cjs +0 -28
  263. package/dist/hooks/useTheme.cjs +0 -58
  264. package/dist/hooks/useTimeDuration.cjs +0 -39
  265. package/dist/hooks/useViewportFill.cjs +0 -52
  266. package/dist/index.cjs +0 -383
  267. package/dist/styles/themes/types.cjs +0 -2
  268. package/dist/types/a11y-props.types.cjs +0 -2
  269. package/dist/types/assets.d.cjs +0 -2
  270. package/dist/types/assets.d.js +0 -1
  271. package/dist/types/css.d.cjs +0 -2
  272. package/dist/types/css.d.js +0 -1
  273. package/dist/types/sizes.types.cjs +0 -2
  274. package/dist/utils/arrays/nested-filtering.cjs +0 -40
  275. package/dist/utils/date/formatDate.cjs +0 -19
  276. /package/dist/components/{modal → overlay/modal}/Modal.module.css +0 -0
@@ -1,41 +1,8 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Button } from '../button/Button';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { X } from 'lucide-react';
4
3
  import styles from './Toast.module.css';
4
+ import { Button } from '../button/Button';
5
5
  import { Headline } from '../headline/Headline';
6
-
7
- function Toast({
8
- title,
9
- message,
10
- severity = "info",
11
- action,
12
- onClose
13
- }) {
14
- return /* @__PURE__ */ jsxs("div", { className: `${styles.toast} ${styles[severity]}`, role: "status", children: [
15
- /* @__PURE__ */ jsxs("div", { className: styles.content, children: [
16
- /* @__PURE__ */ jsx(
17
- Headline,
18
- {
19
- size: 4,
20
- severity: title ? severity : void 0,
21
- disableMargin: true,
22
- addition: onClose && /* @__PURE__ */ jsx("div", { style: { marginLeft: "auto" }, children: /* @__PURE__ */ jsx(
23
- Button,
24
- {
25
- type: "button",
26
- variant: "inline",
27
- "aria-label": "Dismiss notification",
28
- onClick: onClose,
29
- children: /* @__PURE__ */ jsx(X, { className: styles.closeIcon, "aria-hidden": "true" })
30
- }
31
- ) }),
32
- children: title
33
- }
34
- ),
35
- message && /* @__PURE__ */ jsx("div", { className: styles.message, children: message })
36
- ] }),
37
- /* @__PURE__ */ jsx("div", { className: styles.actions, children: action && /* @__PURE__ */ jsx(Button, { type: "button", variant: "primary", onClick: action.onClick, children: action.label }) })
38
- ] });
6
+ export function Toast({ title, message, severity = 'info', action, onClose, }) {
7
+ return (_jsxs("div", { className: `${styles.toast} ${styles[severity]}`, role: "status", children: [_jsxs("div", { className: styles.content, children: [_jsx(Headline, { size: 4, severity: title ? severity : undefined, disableMargin: true, addition: onClose && (_jsx("div", { style: { marginLeft: 'auto' }, children: _jsx(Button, { type: "button", variant: "inline", "aria-label": "Dismiss notification", onClick: onClose, children: _jsx(X, { className: styles.closeIcon, "aria-hidden": "true" }) }) })), children: title }), message && _jsx("div", { className: styles.message, children: message })] }), _jsx("div", { className: styles.actions, children: action && (_jsx(Button, { type: "button", variant: "primary", onClick: action.onClick, children: action.label })) })] }));
39
8
  }
40
-
41
- export { Toast };
@@ -7,6 +7,7 @@
7
7
  gap: var(--spacing-xs);
8
8
  z-index: var(--z-toast);
9
9
  min-width: 280px;
10
+ word-break: break-word;
10
11
  }
11
12
 
12
13
  @media (max-width: var(--bp-sm)) {
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
+ import { Severity } from '../../../constants/severity.types';
2
3
  import { ToastActionConfig } from '../Toast';
3
- import { Severity } from '@/constants/severity.types';
4
4
  export type ToastConfig = {
5
5
  id?: string;
6
6
  title?: ReactNode;
@@ -1,91 +1,64 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { createContext, useState, useRef, useCallback, useEffect, useContext } from 'react';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useState, useRef, useEffect, } from 'react';
3
3
  import { Toast } from '../Toast';
4
4
  import styles from '../Toast.module.css';
5
-
6
- const ToastContext = createContext(void 0);
7
- function ToastProvider({
8
- children,
9
- defaultDuration = 1e4
10
- }) {
11
- const [toasts, setToasts] = useState([]);
12
- const timeouts = useRef(/* @__PURE__ */ new Map());
13
- const clearTimeoutForId = (id) => {
14
- const timeoutId = timeouts.current.get(id);
15
- if (timeoutId) {
16
- window.clearTimeout(timeoutId);
17
- timeouts.current.delete(id);
18
- }
19
- };
20
- const hideToast = useCallback((id) => {
21
- clearTimeoutForId(id);
22
- setToasts((prev) => prev.filter((t) => t.id !== id));
23
- }, []);
24
- const scheduleAutoDismiss = useCallback(
25
- (toast) => {
26
- var _a;
27
- const duration = (_a = toast.duration) != null ? _a : defaultDuration;
28
- if (!duration || duration <= 0) return;
29
- clearTimeoutForId(toast.id);
30
- const timeoutId = window.setTimeout(() => {
31
- hideToast(toast.id);
32
- }, duration);
33
- timeouts.current.set(toast.id, timeoutId);
34
- },
35
- [defaultDuration, hideToast]
36
- );
37
- const showToast = useCallback(
38
- (config) => {
39
- var _a, _b, _c;
40
- const id = (_c = (_b = config.id) != null ? _b : (_a = crypto.randomUUID) == null ? void 0 : _a.call(crypto)) != null ? _c : `${Date.now()}-${Math.random()}`;
41
- const toast = { ...config, id };
42
- setToasts((prev) => [...prev, toast]);
43
- scheduleAutoDismiss(toast);
44
- return id;
45
- },
46
- [scheduleAutoDismiss]
47
- );
48
- const clearToasts = useCallback(() => {
49
- toasts.forEach((t) => clearTimeoutForId(t.id));
50
- setToasts([]);
51
- }, [toasts]);
52
- useEffect(
53
- () => () => {
54
- toasts.forEach((t) => clearTimeoutForId(t.id));
55
- },
56
- [toasts]
57
- );
58
- return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { showToast, hideToast, clearToasts }, children: [
59
- children,
60
- toasts.length > 0 && /* @__PURE__ */ jsx("div", { className: styles.container, "aria-live": "polite", "aria-atomic": "false", children: toasts.map((toast) => {
61
- var _a;
62
- return /* @__PURE__ */ jsx(
63
- Toast,
64
- {
65
- title: toast.title,
66
- message: toast.message,
67
- severity: (_a = toast.severity) != null ? _a : "info",
68
- action: toast.action && {
69
- label: toast.action.label,
70
- onClick: () => {
71
- var _a2, _b;
72
- (_b = (_a2 = toast.action) == null ? void 0 : _a2.onClick) == null ? void 0 : _b.call(_a2);
73
- hideToast(toast.id);
74
- }
75
- },
76
- onClose: () => hideToast(toast.id)
77
- },
78
- toast.id
79
- );
80
- }) })
81
- ] });
5
+ const ToastContext = createContext(undefined);
6
+ export function ToastProvider({ children, defaultDuration = 4000, }) {
7
+ const [toasts, setToasts] = useState([]);
8
+ const timeouts = useRef(new Map());
9
+ const clearTimeoutForId = (id) => {
10
+ const timeoutId = timeouts.current.get(id);
11
+ if (timeoutId) {
12
+ window.clearTimeout(timeoutId);
13
+ timeouts.current.delete(id);
14
+ }
15
+ };
16
+ const hideToast = useCallback((id) => {
17
+ clearTimeoutForId(id);
18
+ setToasts(prev => prev.filter(t => t.id !== id));
19
+ }, []);
20
+ const scheduleAutoDismiss = useCallback((toast) => {
21
+ var _a;
22
+ const duration = (_a = toast.duration) !== null && _a !== void 0 ? _a : defaultDuration;
23
+ if (!duration || duration <= 0)
24
+ return;
25
+ clearTimeoutForId(toast.id);
26
+ const timeoutId = window.setTimeout(() => {
27
+ hideToast(toast.id);
28
+ }, duration);
29
+ timeouts.current.set(toast.id, timeoutId);
30
+ }, [defaultDuration, hideToast]);
31
+ const showToast = useCallback((config) => {
32
+ var _a, _b, _c;
33
+ const id = (_c = (_a = config.id) !== null && _a !== void 0 ? _a : (_b = crypto.randomUUID) === null || _b === void 0 ? void 0 : _b.call(crypto)) !== null && _c !== void 0 ? _c : `${Date.now()}-${Math.random()}`;
34
+ const toast = { ...config, id };
35
+ setToasts(prev => [...prev, toast]);
36
+ scheduleAutoDismiss(toast);
37
+ return id;
38
+ }, [scheduleAutoDismiss]);
39
+ const clearToasts = useCallback(() => {
40
+ toasts.forEach(t => clearTimeoutForId(t.id));
41
+ setToasts([]);
42
+ }, [toasts]);
43
+ useEffect(() => () => {
44
+ toasts.forEach(t => clearTimeoutForId(t.id));
45
+ }, [toasts]);
46
+ return (_jsxs(ToastContext.Provider, { value: { showToast, hideToast, clearToasts }, children: [children, toasts.length > 0 && (_jsx("div", { className: styles.container, "aria-live": "polite", "aria-atomic": "false", children: toasts.map(toast => {
47
+ var _a;
48
+ return (_jsx(Toast, { title: toast.title, message: toast.message, severity: (_a = toast.severity) !== null && _a !== void 0 ? _a : 'info', action: toast.action && {
49
+ label: toast.action.label,
50
+ onClick: () => {
51
+ var _a, _b;
52
+ (_b = (_a = toast.action) === null || _a === void 0 ? void 0 : _a.onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
53
+ hideToast(toast.id);
54
+ },
55
+ }, onClose: () => hideToast(toast.id) }, toast.id));
56
+ }) }))] }));
82
57
  }
83
- function useToast() {
84
- const ctx = useContext(ToastContext);
85
- if (!ctx) {
86
- throw new Error("useToast must be used within a ToastProvider");
87
- }
88
- return ctx;
58
+ export function useToast() {
59
+ const ctx = useContext(ToastContext);
60
+ if (!ctx) {
61
+ throw new Error('useToast must be used within a ToastProvider');
62
+ }
63
+ return ctx;
89
64
  }
90
-
91
- export { ToastProvider, useToast };
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from 'react';
1
2
  interface UserDisplayProps {
2
3
  id?: string;
3
4
  name?: string;
@@ -5,5 +6,5 @@ interface UserDisplayProps {
5
6
  role?: string;
6
7
  avatarUrl?: string;
7
8
  }
8
- export declare function UserDisplay({ id, name, email, role, avatarUrl, }: UserDisplayProps): React.ReactNode;
9
+ export declare function UserDisplay({ name, email, role, avatarUrl }: UserDisplayProps): ReactNode;
9
10
  export {};
@@ -1,22 +1,6 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { Avatar } from '../avatar/Avatar';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import styles from './UserDisplay.module.css';
4
-
5
- function UserDisplay({
6
- id,
7
- name,
8
- email,
9
- role,
10
- avatarUrl
11
- }) {
12
- return /* @__PURE__ */ jsxs("div", { className: styles.container, children: [
13
- /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Avatar, { imgSrc: avatarUrl, imgAlt: name, fullName: name, size: "xl" }) }),
14
- /* @__PURE__ */ jsxs("div", { className: styles.userInfo, children: [
15
- /* @__PURE__ */ jsx("h4", { children: name }),
16
- /* @__PURE__ */ jsx("p", { children: email }),
17
- /* @__PURE__ */ jsx("p", { children: role })
18
- ] })
19
- ] });
3
+ import { Avatar } from '../avatar/Avatar';
4
+ export function UserDisplay({ name, email, role, avatarUrl }) {
5
+ return (_jsxs("div", { className: styles.container, children: [_jsx("div", { children: _jsx(Avatar, { imgSrc: avatarUrl, imgAlt: name, fullName: name, size: "xl" }) }), _jsxs("div", { className: styles.userInfo, children: [_jsx("h4", { children: name }), _jsx("p", { children: email }), _jsx("p", { children: role })] })] }));
20
6
  }
21
-
22
- export { UserDisplay };
@@ -1,3 +1,3 @@
1
- import type { Severity } from '@/constants/severity.types';
1
+ import type { Severity } from '../constants/severity.types';
2
2
  export declare const SeverityBgColor: Record<Severity, string>;
3
3
  export declare const SeverityTextColor: Record<Severity, string>;
@@ -1,18 +1,16 @@
1
- const SeverityBgColor = {
2
- neutral: "var(--color-neutral-strong)",
3
- brand: "var(--color-brand)",
4
- success: "var(--color-status-success)",
5
- error: "var(--color-status-error)",
6
- info: "var(--color-status-info)",
7
- warning: "var(--color-status-warning)"
1
+ export const SeverityBgColor = {
2
+ neutral: 'var(--color-neutral-strong)',
3
+ brand: 'var(--color-brand)',
4
+ success: 'var(--color-status-success)',
5
+ error: 'var(--color-status-error)',
6
+ info: 'var(--color-status-info)',
7
+ warning: 'var(--color-status-warning)',
8
8
  };
9
- const SeverityTextColor = {
10
- neutral: "var(--color-neutral-strong-fg)",
11
- brand: "var(--color-fg-on-brand)",
12
- success: "var(--color-status-success-fg)",
13
- error: "var(--color-status-error-fg)",
14
- info: "var(--color-status-info-fg)",
15
- warning: "var(--color-status-warning-fg)"
9
+ export const SeverityTextColor = {
10
+ neutral: 'var(--color-neutral-strong-fg)',
11
+ brand: 'var(--color-fg-on-brand)',
12
+ success: 'var(--color-status-success-fg)',
13
+ error: 'var(--color-status-error-fg)',
14
+ info: 'var(--color-status-info-fg)',
15
+ warning: 'var(--color-status-warning-fg)',
16
16
  };
17
-
18
- export { SeverityBgColor, SeverityTextColor };
@@ -1 +1 @@
1
- export type Severity = "neutral" | "brand" | "success" | "error" | "info" | "warning";
1
+ export type Severity = 'neutral' | 'brand' | 'success' | 'error' | 'info' | 'warning';
@@ -1 +1 @@
1
-
1
+ export {};
@@ -1,9 +1,7 @@
1
- const sizes = {
2
- xs: "var(--component-size-xs)",
3
- sm: "var(--component-size-sm)",
4
- md: "var(--component-size-md)",
5
- lg: "var(--component-size-lg)",
6
- xl: "var(--component-size-xl)"
1
+ export const sizes = {
2
+ xs: 'var(--component-size-xs)',
3
+ sm: 'var(--component-size-sm)',
4
+ md: 'var(--component-size-md)',
5
+ lg: 'var(--component-size-lg)',
6
+ xl: 'var(--component-size-xl)',
7
7
  };
8
-
9
- export { sizes };
@@ -1,4 +1,4 @@
1
- import type { PageChangeEvent } from '@/components/pagination/Pagination';
1
+ import type { PageChangeEvent } from '../components/pagination/Pagination';
2
2
  export type PaginationState = {
3
3
  skip: number;
4
4
  take: number;
@@ -1,86 +1,79 @@
1
- import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
2
-
1
+ 'use client';
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  function clamp(n, min, max) {
4
- return Math.max(min, Math.min(max, n));
4
+ return Math.max(min, Math.min(max, n));
5
5
  }
6
- function usePagination({
7
- data = [],
8
- skip = 0,
9
- take = 10,
10
- state,
11
- onStateChange,
12
- resetOnDataChange = false
13
- }) {
14
- const isControlled = state != null;
15
- const [uncontrolled, setUncontrolled] = useState(() => ({
16
- skip: Math.max(0, skip),
17
- take: Math.max(1, take)
18
- }));
19
- const didInitRef = useRef(false);
20
- useEffect(() => {
21
- if (isControlled) return;
22
- if (!didInitRef.current) {
23
- didInitRef.current = true;
24
- return;
25
- }
26
- setUncontrolled((prev) => ({
27
- skip: prev.skip,
28
- take: Math.max(1, take)
6
+ export function usePagination({ data = [], skip = 0, take = 10, state, onStateChange, resetOnDataChange = false, }) {
7
+ const isControlled = state != null;
8
+ const [uncontrolled, setUncontrolled] = useState(() => ({
9
+ skip: Math.max(0, skip),
10
+ take: Math.max(1, take),
29
11
  }));
30
- }, [isControlled, take]);
31
- const paginationState = isControlled ? state : uncontrolled;
32
- const totalCount = data.length;
33
- const safeTake = Math.max(1, paginationState.take);
34
- const maxSkip = Math.max(
35
- 0,
36
- totalCount === 0 ? 0 : Math.floor((totalCount - 1) / safeTake) * safeTake
37
- );
38
- const safeSkip = clamp(Math.max(0, paginationState.skip), 0, maxSkip);
39
- const setPagination = useCallback(
40
- (next) => {
41
- const normalized = {
42
- take: Math.max(1, next.take),
43
- skip: Math.max(0, next.skip)
44
- };
45
- if (isControlled) onStateChange == null ? void 0 : onStateChange(normalized);
46
- else setUncontrolled(normalized);
47
- },
48
- [isControlled, onStateChange]
49
- );
50
- const onPageChange = useCallback(
51
- (pageEvent) => {
52
- const nextTake = Math.max(1, pageEvent.take);
53
- const nextSkip = Math.max(0, (pageEvent.page - 1) * nextTake);
54
- setPagination({ skip: nextSkip, take: nextTake });
55
- },
56
- [setPagination]
57
- );
58
- const resetPage = useCallback(() => {
59
- setPagination({ skip: 0, take: safeTake });
60
- }, [setPagination, safeTake]);
61
- useEffect(() => {
62
- if (!resetOnDataChange) return;
63
- resetPage();
64
- }, [resetOnDataChange, data]);
65
- const paginatedData = useMemo(() => {
66
- return data.slice(safeSkip, safeSkip + safeTake);
67
- }, [data, safeSkip, safeTake]);
68
- const page = useMemo(() => Math.floor(safeSkip / safeTake) + 1, [safeSkip, safeTake]);
69
- useEffect(() => {
70
- if (isControlled) return;
71
- if (safeSkip !== paginationState.skip) {
72
- setUncontrolled((prev) => ({ ...prev, skip: safeSkip }));
73
- }
74
- }, [isControlled, safeSkip, paginationState.skip]);
75
- return {
76
- paginatedData,
77
- paginationState: { skip: safeSkip, take: safeTake },
78
- onPageChange,
79
- setPagination,
80
- resetPage,
81
- page,
82
- totalCount
83
- };
12
+ // Keep initial props in sync ONLY for uncontrolled if props change.
13
+ // (For controlled, parent owns state.)
14
+ const didInitRef = useRef(false);
15
+ useEffect(() => {
16
+ if (isControlled)
17
+ return;
18
+ if (!didInitRef.current) {
19
+ didInitRef.current = true;
20
+ return;
21
+ }
22
+ setUncontrolled(prev => ({
23
+ skip: prev.skip,
24
+ take: Math.max(1, take),
25
+ }));
26
+ }, [isControlled, take]);
27
+ const paginationState = (isControlled ? state : uncontrolled);
28
+ const totalCount = data.length;
29
+ const safeTake = Math.max(1, paginationState.take);
30
+ const maxSkip = Math.max(0, totalCount === 0 ? 0 : Math.floor((totalCount - 1) / safeTake) * safeTake);
31
+ const safeSkip = clamp(Math.max(0, paginationState.skip), 0, maxSkip);
32
+ const setPagination = useCallback((next) => {
33
+ const normalized = {
34
+ take: Math.max(1, next.take),
35
+ skip: Math.max(0, next.skip),
36
+ };
37
+ if (isControlled)
38
+ onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(normalized);
39
+ else
40
+ setUncontrolled(normalized);
41
+ }, [isControlled, onStateChange]);
42
+ const onPageChange = useCallback((pageEvent) => {
43
+ const nextTake = Math.max(1, pageEvent.take);
44
+ const nextSkip = Math.max(0, (pageEvent.page - 1) * nextTake);
45
+ setPagination({ skip: nextSkip, take: nextTake });
46
+ }, [setPagination]);
47
+ const resetPage = useCallback(() => {
48
+ setPagination({ skip: 0, take: safeTake });
49
+ }, [setPagination, safeTake]);
50
+ // Optional: reset page when data reference changes (after sort/filter).
51
+ useEffect(() => {
52
+ if (!resetOnDataChange)
53
+ return;
54
+ resetPage();
55
+ // eslint-disable-next-line react-hooks/exhaustive-deps
56
+ }, [resetOnDataChange, data]);
57
+ const paginatedData = useMemo(() => {
58
+ // Use safeSkip to avoid slicing past end if data shrinks.
59
+ return data.slice(safeSkip, safeSkip + safeTake);
60
+ }, [data, safeSkip, safeTake]);
61
+ const page = useMemo(() => Math.floor(safeSkip / safeTake) + 1, [safeSkip, safeTake]);
62
+ // If uncontrolled and data shrinks such that skip becomes invalid, clamp it once.
63
+ useEffect(() => {
64
+ if (isControlled)
65
+ return;
66
+ if (safeSkip !== paginationState.skip) {
67
+ setUncontrolled(prev => ({ ...prev, skip: safeSkip }));
68
+ }
69
+ }, [isControlled, safeSkip, paginationState.skip]);
70
+ return {
71
+ paginatedData,
72
+ paginationState: { skip: safeSkip, take: safeTake },
73
+ onPageChange,
74
+ setPagination,
75
+ resetPage,
76
+ page,
77
+ totalCount,
78
+ };
84
79
  }
85
-
86
- export { usePagination };