@dbcdk/react-components 0.0.3 → 0.0.5

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 (223) hide show
  1. package/dist/assets/logo.cjs +10 -10
  2. package/dist/assets/logo.js +10 -10
  3. package/dist/components/__stories__/story-components/Colors.cjs +159 -0
  4. package/dist/components/__stories__/story-components/Colors.d.ts +10 -0
  5. package/dist/components/__stories__/story-components/Colors.js +151 -0
  6. package/dist/components/__stories__/story-components/Colors.module.css +27 -0
  7. package/dist/components/__stories__/story-components/Spacing.cjs +190 -0
  8. package/dist/components/__stories__/story-components/Spacing.d.ts +1 -0
  9. package/dist/components/__stories__/story-components/Spacing.js +184 -0
  10. package/dist/components/__stories__/story-components/Spacing.module.css +154 -0
  11. package/dist/components/app-header/AppHeader.module.css +10 -15
  12. package/dist/components/attribute-chip/AttributeChip.cjs +22 -0
  13. package/dist/components/attribute-chip/AttributeChip.d.ts +8 -0
  14. package/dist/components/attribute-chip/AttributeChip.js +16 -0
  15. package/dist/components/attribute-chip/AttributeChip.module.css +65 -0
  16. package/dist/components/avatar/Avatar.cjs +38 -4
  17. package/dist/components/avatar/Avatar.d.ts +4 -2
  18. package/dist/components/avatar/Avatar.js +39 -5
  19. package/dist/components/avatar/Avatar.module.css +27 -0
  20. package/dist/components/breadcrumbs/Breadcrumbs.cjs +1 -2
  21. package/dist/components/breadcrumbs/Breadcrumbs.js +1 -2
  22. package/dist/components/breadcrumbs/Breadcrumbs.module.css +19 -22
  23. package/dist/components/button/Button.cjs +20 -12
  24. package/dist/components/button/Button.d.ts +4 -1
  25. package/dist/components/button/Button.js +20 -12
  26. package/dist/components/button/Button.module.css +118 -55
  27. package/dist/components/card/Card.cjs +53 -13
  28. package/dist/components/card/Card.d.ts +21 -6
  29. package/dist/components/card/Card.js +54 -14
  30. package/dist/components/card/Card.module.css +148 -44
  31. package/dist/components/card-container/CardContainer.cjs +6 -5
  32. package/dist/components/card-container/CardContainer.d.ts +5 -2
  33. package/dist/components/card-container/CardContainer.js +6 -5
  34. package/dist/components/card-container/CardContainer.module.css +40 -0
  35. package/dist/components/checkbox/Checkbox.cjs +3 -4
  36. package/dist/components/checkbox/Checkbox.d.ts +1 -1
  37. package/dist/components/checkbox/Checkbox.js +3 -4
  38. package/dist/components/checkbox/Checkbox.module.css +10 -10
  39. package/dist/components/chip/Chip.cjs +2 -1
  40. package/dist/components/chip/Chip.d.ts +2 -1
  41. package/dist/components/chip/Chip.js +2 -1
  42. package/dist/components/chip/Chip.module.css +42 -27
  43. package/dist/components/circle/Circle.module.css +11 -11
  44. package/dist/components/clear-button/ClearButton.cjs +3 -3
  45. package/dist/components/clear-button/ClearButton.js +3 -3
  46. package/dist/components/clear-button/ClearButton.module.css +8 -7
  47. package/dist/components/code-block/CodeBlock.cjs +18 -0
  48. package/dist/components/code-block/CodeBlock.d.ts +6 -0
  49. package/dist/components/code-block/CodeBlock.js +12 -0
  50. package/dist/components/code-block/CodeBlock.module.css +60 -0
  51. package/dist/components/copy-button/CopyButton.cjs +35 -0
  52. package/dist/components/copy-button/CopyButton.d.ts +9 -0
  53. package/dist/components/copy-button/CopyButton.js +29 -0
  54. package/dist/components/copy-button/CopyButton.module.css +6 -0
  55. package/dist/components/datetime-picker/DateTimePicker.cjs +504 -0
  56. package/dist/components/datetime-picker/DateTimePicker.d.ts +39 -0
  57. package/dist/components/datetime-picker/DateTimePicker.js +498 -0
  58. package/dist/components/datetime-picker/DateTimePicker.module.css +144 -0
  59. package/dist/components/filter-field/FilterField.cjs +34 -19
  60. package/dist/components/filter-field/FilterField.d.ts +2 -2
  61. package/dist/components/filter-field/FilterField.js +35 -20
  62. package/dist/components/filter-field/FilterField.module.css +14 -20
  63. package/dist/components/headline/Headline.cjs +10 -4
  64. package/dist/components/headline/Headline.d.ts +9 -1
  65. package/dist/components/headline/Headline.js +10 -4
  66. package/dist/components/headline/Headline.module.css +32 -7
  67. package/dist/components/icon/Icon.module.css +10 -9
  68. package/dist/components/input/Input.cjs +60 -19
  69. package/dist/components/input/Input.d.ts +7 -2
  70. package/dist/components/input/Input.js +60 -19
  71. package/dist/components/input/Input.module.css +90 -43
  72. package/dist/components/link/Link.cjs +46 -0
  73. package/dist/components/link/Link.d.ts +9 -0
  74. package/dist/components/link/Link.js +21 -0
  75. package/dist/components/link/Link.module.css +32 -0
  76. package/dist/components/menu/Menu.module.css +10 -32
  77. package/dist/components/meta-bar/MetaBar.cjs +29 -0
  78. package/dist/components/meta-bar/MetaBar.d.ts +11 -0
  79. package/dist/components/meta-bar/MetaBar.js +22 -0
  80. package/dist/components/meta-bar/MetaBar.module.css +12 -0
  81. package/dist/components/modal/Modal.cjs +134 -0
  82. package/dist/components/modal/Modal.d.ts +21 -0
  83. package/dist/components/modal/Modal.js +128 -0
  84. package/dist/components/modal/Modal.module.css +66 -0
  85. package/dist/components/modal/provider/ModalProvider.cjs +80 -0
  86. package/dist/components/modal/provider/ModalProvider.d.ts +21 -0
  87. package/dist/components/modal/provider/ModalProvider.js +77 -0
  88. package/dist/components/multi-select/MultiSelect.cjs +12 -1
  89. package/dist/components/multi-select/MultiSelect.js +12 -1
  90. package/dist/components/nav-bar/NavBar.module.css +11 -16
  91. package/dist/components/page/Page.module.css +2 -2
  92. package/dist/components/page-layout/PageLayout.cjs +5 -22
  93. package/dist/components/page-layout/PageLayout.d.ts +1 -8
  94. package/dist/components/page-layout/PageLayout.js +5 -22
  95. package/dist/components/page-layout/PageLayout.module.css +4 -80
  96. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.cjs +32 -0
  97. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.d.ts +11 -0
  98. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.js +25 -0
  99. package/dist/components/page-layout/components/page-layout-hero/PageLayoutHero.module.css +84 -0
  100. package/dist/components/pagination/Pagination.cjs +83 -67
  101. package/dist/components/pagination/Pagination.d.ts +3 -1
  102. package/dist/components/pagination/Pagination.js +84 -68
  103. package/dist/components/pagination/Pagination.module.css +11 -3
  104. package/dist/components/panel/Panel.module.css +5 -7
  105. package/dist/components/popover/Popover.cjs +25 -8
  106. package/dist/components/popover/Popover.d.ts +2 -1
  107. package/dist/components/popover/Popover.js +25 -8
  108. package/dist/components/popover/Popover.module.css +4 -6
  109. package/dist/components/search-box/SearchBox.cjs +50 -37
  110. package/dist/components/search-box/SearchBox.d.ts +10 -7
  111. package/dist/components/search-box/SearchBox.js +50 -37
  112. package/dist/components/search-box/SearchBox.module.css +0 -1
  113. package/dist/components/segmented-progress-bar/SegmentedProgressBar.cjs +12 -6
  114. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +12 -6
  115. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +5 -1
  116. package/dist/components/select/Select.cjs +82 -13
  117. package/dist/components/select/Select.d.ts +2 -1
  118. package/dist/components/select/Select.js +83 -14
  119. package/dist/components/sidebar/Sidebar.cjs +3 -30
  120. package/dist/components/sidebar/Sidebar.d.ts +2 -1
  121. package/dist/components/sidebar/Sidebar.js +4 -26
  122. package/dist/components/sidebar/components/SidebarItem.cjs +3 -1
  123. package/dist/components/sidebar/components/SidebarItem.js +3 -1
  124. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +40 -14
  125. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +3 -1
  126. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +40 -14
  127. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +9 -38
  128. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.cjs +50 -0
  129. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +8 -0
  130. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +43 -0
  131. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +155 -0
  132. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +16 -9
  133. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +2 -1
  134. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +16 -9
  135. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +25 -12
  136. package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +2 -1
  137. package/dist/components/sidebar/components/sidebar-items/SidebarItems.d.ts +1 -1
  138. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +2 -1
  139. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.cjs +29 -2
  140. package/dist/components/sidebar/components/sidenav-filteirng/SidenavFiltering.js +25 -2
  141. package/dist/components/sidebar/providers/SidebarProvider.cjs +108 -10
  142. package/dist/components/sidebar/providers/SidebarProvider.d.ts +7 -3
  143. package/dist/components/sidebar/providers/SidebarProvider.js +109 -11
  144. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.cjs +1 -1
  145. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.js +1 -1
  146. package/dist/components/skeleton-loader/skeleton-loader-item/SkeletonLoaderItem.module.css +0 -12
  147. package/dist/components/split-pane/SplitPane.cjs +123 -0
  148. package/dist/components/split-pane/SplitPane.d.ts +34 -0
  149. package/dist/components/split-pane/SplitPane.js +114 -0
  150. package/dist/components/split-pane/SplitPane.module.css +106 -0
  151. package/dist/components/split-pane/provider/SplitPaneContext.cjs +87 -0
  152. package/dist/components/split-pane/provider/SplitPaneContext.d.ts +23 -0
  153. package/dist/components/split-pane/provider/SplitPaneContext.js +79 -0
  154. package/dist/components/table/Table.cjs +180 -112
  155. package/dist/components/table/Table.d.ts +22 -6
  156. package/dist/components/table/Table.js +181 -113
  157. package/dist/components/table/Table.module.css +74 -47
  158. package/dist/components/table/components/empty-state/EmptyState.cjs +52 -0
  159. package/dist/components/table/components/empty-state/EmptyState.d.ts +40 -0
  160. package/dist/components/table/components/empty-state/EmptyState.js +46 -0
  161. package/dist/components/table/components/empty-state/EmptyState.module.css +16 -0
  162. package/dist/components/table/components/table-settings/TableSettings.cjs +32 -0
  163. package/dist/components/table/components/table-settings/TableSettings.d.ts +7 -0
  164. package/dist/components/table/components/table-settings/TableSettings.js +30 -0
  165. package/dist/{tanstack.cjs → components/table/tanstack.cjs} +61 -99
  166. package/dist/components/table/tanstack.d.ts +14 -0
  167. package/dist/{tanstack.js → components/table/tanstack.js} +61 -99
  168. package/dist/components/tabs/Tabs.cjs +33 -17
  169. package/dist/components/tabs/Tabs.d.ts +6 -3
  170. package/dist/components/tabs/Tabs.js +33 -17
  171. package/dist/components/tabs/Tabs.module.css +9 -9
  172. package/dist/components/toast/Toast.cjs +47 -0
  173. package/dist/components/toast/Toast.d.ts +14 -0
  174. package/dist/components/toast/Toast.js +41 -0
  175. package/dist/components/toast/Toast.module.css +101 -0
  176. package/dist/components/toast/provider/ToastProvider.cjs +98 -0
  177. package/dist/components/toast/provider/ToastProvider.d.ts +23 -0
  178. package/dist/components/toast/provider/ToastProvider.js +91 -0
  179. package/dist/components/tooltip/Tooltip.cjs +134 -29
  180. package/dist/components/tooltip/Tooltip.js +135 -30
  181. package/dist/components/tooltip/Tooltip.module.css +25 -43
  182. package/dist/components/user-display/UserDisplay.module.css +2 -2
  183. package/dist/constants/severity.cjs +12 -12
  184. package/dist/constants/severity.js +12 -12
  185. package/dist/constants/sizes.cjs +1 -0
  186. package/dist/constants/sizes.d.ts +1 -1
  187. package/dist/constants/sizes.js +1 -0
  188. package/dist/hooks/usePagination.cjs +88 -0
  189. package/dist/hooks/usePagination.d.ts +33 -0
  190. package/dist/hooks/usePagination.js +86 -0
  191. package/dist/hooks/useSorting.cjs +118 -0
  192. package/dist/hooks/useSorting.d.ts +49 -0
  193. package/dist/hooks/useSorting.js +116 -0
  194. package/dist/hooks/useTableData.cjs +52 -0
  195. package/dist/hooks/useTableData.d.ts +40 -0
  196. package/dist/hooks/useTableData.js +50 -0
  197. package/dist/hooks/useTableSelection.cjs +130 -0
  198. package/dist/hooks/useTableSelection.d.ts +25 -0
  199. package/dist/hooks/useTableSelection.js +128 -0
  200. package/dist/hooks/useTableSettings.cjs +28 -0
  201. package/dist/hooks/useTableSettings.d.ts +7 -0
  202. package/dist/hooks/useTableSettings.js +26 -0
  203. package/dist/hooks/useTimeDuration.cjs +39 -0
  204. package/dist/hooks/useTimeDuration.d.ts +22 -0
  205. package/dist/hooks/useTimeDuration.js +37 -0
  206. package/dist/hooks/useViewportFill.js +1 -1
  207. package/dist/index.cjs +119 -0
  208. package/dist/index.d.ts +17 -0
  209. package/dist/index.js +17 -0
  210. package/dist/src/styles/styles.css +101 -8
  211. package/dist/styles/css-helper-classes/flex.css +97 -0
  212. package/dist/styles/css-helper-classes/typography.css +7 -0
  213. package/dist/styles/styles.css +101 -8
  214. package/dist/styles/themes/dbc/dark.css +206 -99
  215. package/dist/styles/themes/dbc/light.css +183 -89
  216. package/dist/types/sizes.types.d.ts +2 -2
  217. package/package.json +17 -11
  218. package/dist/components/data-summary/DataSummary.cjs +0 -49
  219. package/dist/components/data-summary/DataSummary.d.ts +0 -19
  220. package/dist/components/data-summary/DataSummary.js +0 -43
  221. package/dist/components/data-summary/DataSummary.module.css +0 -51
  222. package/dist/components/sidebar/Sidebar.module.css +0 -66
  223. package/dist/tanstack.d.ts +0 -25
@@ -0,0 +1,46 @@
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { Button } from '../../../button/Button';
3
+ import { Headline } from '../../../headline/Headline';
4
+ import { SearchX, RefreshCw, ArrowLeft } from 'lucide-react';
5
+ import styles from './EmptyState.module.css';
6
+
7
+ const defaultEmptyConfig = {
8
+ enabled: true,
9
+ title: /* @__PURE__ */ jsx(Headline, { disableMargin: true, size: 3, children: "Hov, der er ingen data" }),
10
+ description: /* @__PURE__ */ jsx("span", { children: "Pr\xF8v at \xE6ndre dine filtre eller tilf\xF8je data." }),
11
+ showBack: true,
12
+ showRefresh: true,
13
+ backLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
14
+ /* @__PURE__ */ jsx(ArrowLeft, {}),
15
+ "Tilbage"
16
+ ] }),
17
+ refreshLabel: /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ /* @__PURE__ */ jsx(RefreshCw, {}),
19
+ "Indl\xE6s igen"
20
+ ] }),
21
+ className: "dbc-flex dbc-flex-column dbc-justify-center dbc-items-center dbc-flex-grow "
22
+ };
23
+ function TableEmptyState({ config }) {
24
+ const merged = {
25
+ ...defaultEmptyConfig,
26
+ ...config != null ? config : {}
27
+ };
28
+ if (!merged.enabled) return null;
29
+ const showBack = merged.showBack && typeof merged.onBack === "function";
30
+ const showRefresh = merged.showRefresh && typeof merged.onRefresh === "function";
31
+ const hasAnyActions = Boolean(merged.actions) || showBack || showRefresh;
32
+ return /* @__PURE__ */ jsxs("div", { className: `${merged.className} ${styles.container}`, children: [
33
+ /* @__PURE__ */ jsxs("span", { className: "dbc-flex dbc-flex-column dbc-gap-sm dbc-items-center", children: [
34
+ /* @__PURE__ */ jsx(SearchX, { className: styles.icon }),
35
+ merged.title,
36
+ merged.description
37
+ ] }),
38
+ hasAnyActions && /* @__PURE__ */ jsxs("div", { className: "dbc-flex dbc-gap-sm", children: [
39
+ merged.actions,
40
+ showBack && /* @__PURE__ */ jsx(Button, { onClick: merged.onBack, className: "dbc-mr-xxs", children: merged.backLabel }),
41
+ showRefresh && /* @__PURE__ */ jsx(Button, { onClick: merged.onRefresh, children: merged.refreshLabel })
42
+ ] })
43
+ ] });
44
+ }
45
+
46
+ export { TableEmptyState };
@@ -0,0 +1,16 @@
1
+ .container {
2
+ position: absolute;
3
+ inset: 0;
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ transform: translateY(clamp(-32px, -6vh, -12px));
8
+ padding-top: 56px;
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ .icon {
13
+ inline-size: var(--component-size-lg);
14
+ block-size: var(--component-size-lg);
15
+ color: var(--color-fg-muted);
16
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Button = require('../../../button/Button');
5
+ var Popover = require('../../../popover/Popover');
6
+ var Menu = require('../../../menu/Menu');
7
+ var lucideReact = require('lucide-react');
8
+
9
+ function TableSettings({
10
+ viewMode,
11
+ handleChangeViewMode
12
+ }) {
13
+ const handleViewModeChange = (mode, close) => {
14
+ handleChangeViewMode("compact" );
15
+ close == null ? void 0 : close();
16
+ };
17
+ return /* @__PURE__ */ jsxRuntime.jsx(
18
+ Popover.Popover,
19
+ {
20
+ trigger: (onClick, icon) => /* @__PURE__ */ jsxRuntime.jsxs(Button.Button, { onClick, children: [
21
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, {}),
22
+ icon
23
+ ] }),
24
+ children: (close) => /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu, { children: /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Item, { active: viewMode === "compact", children: /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick: () => handleViewModeChange("compact", close), children: [
25
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListChevronsDownUp, {}),
26
+ "Kompakt"
27
+ ] }) }) })
28
+ }
29
+ );
30
+ }
31
+
32
+ exports.TableSettings = TableSettings;
@@ -0,0 +1,7 @@
1
+ import { ViewMode } from '../../../../hooks/useTableSettings';
2
+ interface TableSettingsProps {
3
+ handleChangeViewMode: (mode: ViewMode) => void;
4
+ viewMode: ViewMode;
5
+ }
6
+ export declare function TableSettings({ viewMode, handleChangeViewMode, }: TableSettingsProps): React.ReactNode | JSX.Element;
7
+ export {};
@@ -0,0 +1,30 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { Button } from '../../../button/Button';
3
+ import { Popover } from '../../../popover/Popover';
4
+ import { Menu } from '../../../menu/Menu';
5
+ import { ListChevronsDownUp, Settings } from 'lucide-react';
6
+
7
+ function TableSettings({
8
+ viewMode,
9
+ handleChangeViewMode
10
+ }) {
11
+ const handleViewModeChange = (mode, close) => {
12
+ handleChangeViewMode("compact" );
13
+ close == null ? void 0 : close();
14
+ };
15
+ return /* @__PURE__ */ jsx(
16
+ Popover,
17
+ {
18
+ trigger: (onClick, icon) => /* @__PURE__ */ jsxs(Button, { onClick, children: [
19
+ /* @__PURE__ */ jsx(Settings, {}),
20
+ icon
21
+ ] }),
22
+ children: (close) => /* @__PURE__ */ jsx(Menu, { children: /* @__PURE__ */ jsx(Menu.Item, { active: viewMode === "compact", children: /* @__PURE__ */ jsxs("button", { onClick: () => handleViewModeChange("compact", close), children: [
23
+ /* @__PURE__ */ jsx(ListChevronsDownUp, {}),
24
+ "Kompakt"
25
+ ] }) }) })
26
+ }
27
+ );
28
+ }
29
+
30
+ export { TableSettings };
@@ -3,8 +3,8 @@
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var React = require('react');
5
5
  var reactTable = require('@tanstack/react-table');
6
- var Table = require('./components/table/Table');
7
- var ColumnResizer = require('./components/table/components/column-resizer/ColumnResizer');
6
+ var Table = require('./Table');
7
+ var ColumnResizer = require('./components/column-resizer/ColumnResizer');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
@@ -29,57 +29,52 @@ function _interopNamespace(e) {
29
29
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
30
30
  var ColumnResizer__default = /*#__PURE__*/_interopDefault(ColumnResizer);
31
31
 
32
+ function getColumnId(def, index) {
33
+ const d = def;
34
+ if (d.id != null && String(d.id).length) return String(d.id);
35
+ if (d.accessorKey != null && String(d.accessorKey).length) return String(d.accessorKey);
36
+ return `col_${index}`;
37
+ }
32
38
  function mapDefsToColumnItems(defs) {
33
- if (!(defs == null ? void 0 : defs.length)) return [];
34
- return defs.map((def) => {
35
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
36
- const header = typeof def.header === "string" ? def.header : String((_b = (_a = def.accessorKey) != null ? _a : def.id) != null ? _b : "");
37
- const accessor = def.accessorKey;
39
+ return defs.map((def, index) => {
40
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
41
+ const id = getColumnId(def, index);
42
+ const accessorKey = def.accessorKey;
38
43
  const accessorFn = def.accessorFn;
39
44
  const cell = def.cell;
40
45
  let render;
41
46
  if (typeof cell === "function") {
42
47
  render = (row) => cell({
43
48
  row: { original: row },
44
- getValue: () => accessor != null ? row[accessor] : accessorFn ? accessorFn(row) : void 0
49
+ getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
45
50
  });
46
51
  } else if (accessorFn) {
47
52
  render = (row) => accessorFn(row);
48
- } else if (accessor != null) {
49
- render = (row) => row[accessor];
53
+ } else if (accessorKey != null) {
54
+ render = (row) => row[accessorKey];
55
+ } else {
56
+ render = () => null;
50
57
  }
51
58
  return {
52
- header,
53
- accessor,
54
- sortable: (_c = def.enableSorting) != null ? _c : !!accessor,
59
+ id,
60
+ header: def.header,
61
+ accessor: accessorKey,
62
+ sortable: (_a = def.enableSorting) != null ? _a : !!accessorKey,
55
63
  render,
56
- hidden: (_e = (_d = def.meta) == null ? void 0 : _d.hidden) != null ? _e : false,
57
- align: (_g = (_f = def.meta) == null ? void 0 : _f.align) != null ? _g : void 0,
64
+ hidden: (_c = (_b = def.meta) == null ? void 0 : _b.hidden) != null ? _c : false,
65
+ align: (_e = (_d = def.meta) == null ? void 0 : _d.align) != null ? _e : void 0,
66
+ verticalAlign: (_g = (_f = def.meta) == null ? void 0 : _f.verticalAlign) != null ? _g : void 0,
58
67
  fitContent: (_i = (_h = def.meta) == null ? void 0 : _h.fitContent) != null ? _i : false,
59
- fillWidth: (_k = (_j = def.meta) == null ? void 0 : _j.fillWidth) != null ? _k : false
68
+ emptyPlaceholder: (_k = (_j = def.meta) == null ? void 0 : _j.emptyPlaceholder) != null ? _k : "-",
69
+ allowWrap: (_m = (_l = def.meta) == null ? void 0 : _l.allowWrap) != null ? _m : false,
70
+ fillWidth: (_o = (_n = def.meta) == null ? void 0 : _n.fillWidth) != null ? _o : false,
71
+ severity: (_q = (_p = def.meta) == null ? void 0 : _p.severity) != null ? _q : void 0
60
72
  };
61
73
  });
62
74
  }
63
- function TanstackTable({
64
- data,
65
- dataKey,
66
- columns,
67
- filterable = [],
68
- loading,
69
- onRowClick,
70
- striped,
71
- fillViewport = false,
72
- viewportBottomOffset = 0,
73
- viewportMin = 120,
74
- viewportIncludeMarginTop = false,
75
- pageSize,
76
- skip,
77
- totalItemsCount,
78
- onPageChange,
79
- variant,
80
- size
81
- }) {
75
+ function TanstackTable(props) {
82
76
  var _a, _b;
77
+ const { data, dataKey, columns, filterable = [], onSortingChange, ...tableProps } = props;
83
78
  const [sorting, setSorting] = React__namespace.useState([]);
84
79
  const [columnFilters, setColumnFilters] = React__namespace.useState([]);
85
80
  const [columnSizing, setColumnSizing] = React__namespace.useState({});
@@ -108,42 +103,30 @@ function TanstackTable({
108
103
  [table, data]
109
104
  );
110
105
  const s = (_a = table.getState().sorting) == null ? void 0 : _a[0];
111
- const sortBy = (_b = s == null ? void 0 : s.id) != null ? _b : void 0;
106
+ const sortById = (_b = s == null ? void 0 : s.id) != null ? _b : void 0;
112
107
  const sortDirection = s ? s.desc ? "desc" : "asc" : null;
113
108
  const gridTemplateColumns = React__namespace.useMemo(() => {
114
109
  return columnItems.filter((ci) => !ci.hidden).map((ci) => {
115
- var _a2, _b2;
116
- const id = String((_a2 = ci.accessor) != null ? _a2 : "");
117
- const col = id ? table.getColumn(id) : void 0;
118
- const w = (_b2 = col == null ? void 0 : col.getSize) == null ? void 0 : _b2.call(col);
110
+ var _a2;
111
+ const col = table.getColumn(ci.id);
112
+ const w = (_a2 = col == null ? void 0 : col.getSize) == null ? void 0 : _a2.call(col);
119
113
  if (ci.fillWidth) return "1fr";
120
114
  if (ci.fitContent) return "1%";
121
115
  return `${w != null ? w : 180}px`;
122
116
  }).join(" ");
123
117
  }, [columnItems, table, table.getState().columnSizing]);
124
118
  const columnStyles = React__namespace.useMemo(() => {
125
- var _a2;
126
119
  const styles = {};
127
120
  for (const c of table.getAllLeafColumns()) {
128
121
  const id = c.id;
129
- const key = (_a2 = c.columnDef.accessorKey) != null ? _a2 : id;
130
- const ci = columnItems.find((x) => {
131
- var _a3;
132
- return String((_a3 = x.accessor) != null ? _a3 : "") === String(key);
133
- });
122
+ const ci = columnItems.find((x) => x.id === id);
134
123
  if (ci == null ? void 0 : ci.fillWidth) {
135
- styles[String(key)] = {
136
- width: "auto",
137
- minWidth: 0
138
- };
124
+ styles[id] = { width: "auto", minWidth: 0 };
139
125
  } else if (ci == null ? void 0 : ci.fitContent) {
140
- styles[String(key)] = {
141
- width: "1%",
142
- whiteSpace: "nowrap"
143
- };
126
+ styles[id] = { width: "1%", whiteSpace: "nowrap" };
144
127
  } else {
145
128
  const w = c.getSize();
146
- styles[String(key)] = { width: w, minWidth: w, maxWidth: w };
129
+ styles[id] = { width: w, minWidth: w, maxWidth: w };
147
130
  }
148
131
  }
149
132
  return styles;
@@ -164,66 +147,45 @@ function TanstackTable({
164
147
  );
165
148
  const headerBelowRow = React__namespace.useMemo(() => {
166
149
  if (!(filterable == null ? void 0 : filterable.length)) return null;
167
- return /* @__PURE__ */ jsxRuntime.jsx(
168
- "div",
169
- {
170
- style: {
171
- display: "grid",
172
- gridTemplateColumns,
173
- gap: 8
150
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gridTemplateColumns, gap: 8 }, children: columnItems.filter((ci) => !ci.hidden).map((ci) => {
151
+ var _a2;
152
+ const id = ci.id;
153
+ const isFilterable = filterable.includes(id);
154
+ if (!isFilterable) return /* @__PURE__ */ jsxRuntime.jsx("div", {}, id);
155
+ const col = table.getColumn(id);
156
+ const value = (_a2 = col == null ? void 0 : col.getFilterValue()) != null ? _a2 : "";
157
+ return /* @__PURE__ */ jsxRuntime.jsx(
158
+ "input",
159
+ {
160
+ value,
161
+ placeholder: `Filter ${String(ci.header)}`,
162
+ onChange: (e) => col == null ? void 0 : col.setFilterValue(e.target.value),
163
+ style: { width: "100%", padding: "4px 6px" }
174
164
  },
175
- children: columnItems.map((ci) => {
176
- var _a2, _b2;
177
- const id = String((_a2 = ci.accessor) != null ? _a2 : "");
178
- const isFilterable = id && filterable.includes(id);
179
- if (!isFilterable) return /* @__PURE__ */ jsxRuntime.jsx("div", {}, id);
180
- const col = table.getColumn(id);
181
- const value = (_b2 = col == null ? void 0 : col.getFilterValue()) != null ? _b2 : "";
182
- return /* @__PURE__ */ jsxRuntime.jsx(
183
- "input",
184
- {
185
- value,
186
- placeholder: `Filter ${ci.header}`,
187
- onChange: (e) => col == null ? void 0 : col.setFilterValue(e.target.value),
188
- style: { width: "100%", padding: "4px 6px" }
189
- },
190
- id
191
- );
192
- })
193
- }
194
- );
165
+ id
166
+ );
167
+ }) });
195
168
  }, [columnItems, filterable, table, table.getState().columnFilters, gridTemplateColumns]);
196
169
  return /* @__PURE__ */ jsxRuntime.jsx(
197
170
  Table.Table,
198
171
  {
172
+ ...tableProps,
199
173
  dataKey,
200
- variant,
201
174
  data: visibleData,
202
175
  columns: columnItems,
203
- sortBy,
176
+ sortById,
204
177
  sortDirection,
205
178
  onSortChange: (col, dir) => {
206
- var _a2;
207
- const id = String((_a2 = col.accessor) != null ? _a2 : "");
179
+ var _a2, _b2, _c;
180
+ const id = String(col.id);
208
181
  if (!id) return;
209
182
  if (!dir) table.setSorting([]);
210
183
  else table.setSorting([{ id, desc: dir === "desc" }]);
184
+ onSortingChange == null ? void 0 : onSortingChange((_c = (_b2 = (_a2 = table.getState().sorting) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.id) != null ? _c : null, dir);
211
185
  },
212
186
  headerExtras,
213
187
  columnStyles,
214
- headerBelowRow,
215
- loading,
216
- onRowClick,
217
- striped,
218
- fillViewport,
219
- viewportBottomOffset,
220
- viewportMin,
221
- viewportIncludeMarginTop,
222
- take: pageSize,
223
- skip,
224
- totalItemsCount,
225
- onPageChange,
226
- size
188
+ headerBelowRow
227
189
  }
228
190
  );
229
191
  }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { type ColumnDef } from '@tanstack/react-table';
3
+ import { type TableProps, type TableVariant } from './Table';
4
+ import { ViewMode } from '../../hooks/useTableSettings';
5
+ type Filterable<T> = Array<keyof T>;
6
+ export type TanstackTableProps<T extends Record<string, any>> = Omit<TableProps<T>, 'columns' | 'onSortChange' | 'sortById' | 'sortDirection' | 'headerBelowRow' | 'headerExtras' | 'columnStyles'> & {
7
+ columns: ReadonlyArray<ColumnDef<T, any>>;
8
+ filterable?: Filterable<T>;
9
+ onSortingChange?: (sortBy: string | number | symbol | null, direction: 'asc' | 'desc' | null) => void;
10
+ variant?: TableVariant;
11
+ viewMode?: ViewMode;
12
+ };
13
+ export declare function TanstackTable<T extends Record<string, any>>(props: TanstackTableProps<T>): React.ReactNode;
14
+ export {};
@@ -1,60 +1,55 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { useReactTable, getFilteredRowModel, getSortedRowModel, getCoreRowModel } from '@tanstack/react-table';
4
- import { Table } from './components/table/Table';
5
- import ColumnResizer from './components/table/components/column-resizer/ColumnResizer';
4
+ import { Table } from './Table';
5
+ import ColumnResizer from './components/column-resizer/ColumnResizer';
6
6
 
7
+ function getColumnId(def, index) {
8
+ const d = def;
9
+ if (d.id != null && String(d.id).length) return String(d.id);
10
+ if (d.accessorKey != null && String(d.accessorKey).length) return String(d.accessorKey);
11
+ return `col_${index}`;
12
+ }
7
13
  function mapDefsToColumnItems(defs) {
8
- if (!(defs == null ? void 0 : defs.length)) return [];
9
- return defs.map((def) => {
10
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
11
- const header = typeof def.header === "string" ? def.header : String((_b = (_a = def.accessorKey) != null ? _a : def.id) != null ? _b : "");
12
- const accessor = def.accessorKey;
14
+ return defs.map((def, index) => {
15
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
16
+ const id = getColumnId(def, index);
17
+ const accessorKey = def.accessorKey;
13
18
  const accessorFn = def.accessorFn;
14
19
  const cell = def.cell;
15
20
  let render;
16
21
  if (typeof cell === "function") {
17
22
  render = (row) => cell({
18
23
  row: { original: row },
19
- getValue: () => accessor != null ? row[accessor] : accessorFn ? accessorFn(row) : void 0
24
+ getValue: () => accessorKey != null ? row[accessorKey] : accessorFn ? accessorFn(row) : void 0
20
25
  });
21
26
  } else if (accessorFn) {
22
27
  render = (row) => accessorFn(row);
23
- } else if (accessor != null) {
24
- render = (row) => row[accessor];
28
+ } else if (accessorKey != null) {
29
+ render = (row) => row[accessorKey];
30
+ } else {
31
+ render = () => null;
25
32
  }
26
33
  return {
27
- header,
28
- accessor,
29
- sortable: (_c = def.enableSorting) != null ? _c : !!accessor,
34
+ id,
35
+ header: def.header,
36
+ accessor: accessorKey,
37
+ sortable: (_a = def.enableSorting) != null ? _a : !!accessorKey,
30
38
  render,
31
- hidden: (_e = (_d = def.meta) == null ? void 0 : _d.hidden) != null ? _e : false,
32
- align: (_g = (_f = def.meta) == null ? void 0 : _f.align) != null ? _g : void 0,
39
+ hidden: (_c = (_b = def.meta) == null ? void 0 : _b.hidden) != null ? _c : false,
40
+ align: (_e = (_d = def.meta) == null ? void 0 : _d.align) != null ? _e : void 0,
41
+ verticalAlign: (_g = (_f = def.meta) == null ? void 0 : _f.verticalAlign) != null ? _g : void 0,
33
42
  fitContent: (_i = (_h = def.meta) == null ? void 0 : _h.fitContent) != null ? _i : false,
34
- fillWidth: (_k = (_j = def.meta) == null ? void 0 : _j.fillWidth) != null ? _k : false
43
+ emptyPlaceholder: (_k = (_j = def.meta) == null ? void 0 : _j.emptyPlaceholder) != null ? _k : "-",
44
+ allowWrap: (_m = (_l = def.meta) == null ? void 0 : _l.allowWrap) != null ? _m : false,
45
+ fillWidth: (_o = (_n = def.meta) == null ? void 0 : _n.fillWidth) != null ? _o : false,
46
+ severity: (_q = (_p = def.meta) == null ? void 0 : _p.severity) != null ? _q : void 0
35
47
  };
36
48
  });
37
49
  }
38
- function TanstackTable({
39
- data,
40
- dataKey,
41
- columns,
42
- filterable = [],
43
- loading,
44
- onRowClick,
45
- striped,
46
- fillViewport = false,
47
- viewportBottomOffset = 0,
48
- viewportMin = 120,
49
- viewportIncludeMarginTop = false,
50
- pageSize,
51
- skip,
52
- totalItemsCount,
53
- onPageChange,
54
- variant,
55
- size
56
- }) {
50
+ function TanstackTable(props) {
57
51
  var _a, _b;
52
+ const { data, dataKey, columns, filterable = [], onSortingChange, ...tableProps } = props;
58
53
  const [sorting, setSorting] = React.useState([]);
59
54
  const [columnFilters, setColumnFilters] = React.useState([]);
60
55
  const [columnSizing, setColumnSizing] = React.useState({});
@@ -83,42 +78,30 @@ function TanstackTable({
83
78
  [table, data]
84
79
  );
85
80
  const s = (_a = table.getState().sorting) == null ? void 0 : _a[0];
86
- const sortBy = (_b = s == null ? void 0 : s.id) != null ? _b : void 0;
81
+ const sortById = (_b = s == null ? void 0 : s.id) != null ? _b : void 0;
87
82
  const sortDirection = s ? s.desc ? "desc" : "asc" : null;
88
83
  const gridTemplateColumns = React.useMemo(() => {
89
84
  return columnItems.filter((ci) => !ci.hidden).map((ci) => {
90
- var _a2, _b2;
91
- const id = String((_a2 = ci.accessor) != null ? _a2 : "");
92
- const col = id ? table.getColumn(id) : void 0;
93
- const w = (_b2 = col == null ? void 0 : col.getSize) == null ? void 0 : _b2.call(col);
85
+ var _a2;
86
+ const col = table.getColumn(ci.id);
87
+ const w = (_a2 = col == null ? void 0 : col.getSize) == null ? void 0 : _a2.call(col);
94
88
  if (ci.fillWidth) return "1fr";
95
89
  if (ci.fitContent) return "1%";
96
90
  return `${w != null ? w : 180}px`;
97
91
  }).join(" ");
98
92
  }, [columnItems, table, table.getState().columnSizing]);
99
93
  const columnStyles = React.useMemo(() => {
100
- var _a2;
101
94
  const styles = {};
102
95
  for (const c of table.getAllLeafColumns()) {
103
96
  const id = c.id;
104
- const key = (_a2 = c.columnDef.accessorKey) != null ? _a2 : id;
105
- const ci = columnItems.find((x) => {
106
- var _a3;
107
- return String((_a3 = x.accessor) != null ? _a3 : "") === String(key);
108
- });
97
+ const ci = columnItems.find((x) => x.id === id);
109
98
  if (ci == null ? void 0 : ci.fillWidth) {
110
- styles[String(key)] = {
111
- width: "auto",
112
- minWidth: 0
113
- };
99
+ styles[id] = { width: "auto", minWidth: 0 };
114
100
  } else if (ci == null ? void 0 : ci.fitContent) {
115
- styles[String(key)] = {
116
- width: "1%",
117
- whiteSpace: "nowrap"
118
- };
101
+ styles[id] = { width: "1%", whiteSpace: "nowrap" };
119
102
  } else {
120
103
  const w = c.getSize();
121
- styles[String(key)] = { width: w, minWidth: w, maxWidth: w };
104
+ styles[id] = { width: w, minWidth: w, maxWidth: w };
122
105
  }
123
106
  }
124
107
  return styles;
@@ -139,66 +122,45 @@ function TanstackTable({
139
122
  );
140
123
  const headerBelowRow = React.useMemo(() => {
141
124
  if (!(filterable == null ? void 0 : filterable.length)) return null;
142
- return /* @__PURE__ */ jsx(
143
- "div",
144
- {
145
- style: {
146
- display: "grid",
147
- gridTemplateColumns,
148
- gap: 8
125
+ return /* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns, gap: 8 }, children: columnItems.filter((ci) => !ci.hidden).map((ci) => {
126
+ var _a2;
127
+ const id = ci.id;
128
+ const isFilterable = filterable.includes(id);
129
+ if (!isFilterable) return /* @__PURE__ */ jsx("div", {}, id);
130
+ const col = table.getColumn(id);
131
+ const value = (_a2 = col == null ? void 0 : col.getFilterValue()) != null ? _a2 : "";
132
+ return /* @__PURE__ */ jsx(
133
+ "input",
134
+ {
135
+ value,
136
+ placeholder: `Filter ${String(ci.header)}`,
137
+ onChange: (e) => col == null ? void 0 : col.setFilterValue(e.target.value),
138
+ style: { width: "100%", padding: "4px 6px" }
149
139
  },
150
- children: columnItems.map((ci) => {
151
- var _a2, _b2;
152
- const id = String((_a2 = ci.accessor) != null ? _a2 : "");
153
- const isFilterable = id && filterable.includes(id);
154
- if (!isFilterable) return /* @__PURE__ */ jsx("div", {}, id);
155
- const col = table.getColumn(id);
156
- const value = (_b2 = col == null ? void 0 : col.getFilterValue()) != null ? _b2 : "";
157
- return /* @__PURE__ */ jsx(
158
- "input",
159
- {
160
- value,
161
- placeholder: `Filter ${ci.header}`,
162
- onChange: (e) => col == null ? void 0 : col.setFilterValue(e.target.value),
163
- style: { width: "100%", padding: "4px 6px" }
164
- },
165
- id
166
- );
167
- })
168
- }
169
- );
140
+ id
141
+ );
142
+ }) });
170
143
  }, [columnItems, filterable, table, table.getState().columnFilters, gridTemplateColumns]);
171
144
  return /* @__PURE__ */ jsx(
172
145
  Table,
173
146
  {
147
+ ...tableProps,
174
148
  dataKey,
175
- variant,
176
149
  data: visibleData,
177
150
  columns: columnItems,
178
- sortBy,
151
+ sortById,
179
152
  sortDirection,
180
153
  onSortChange: (col, dir) => {
181
- var _a2;
182
- const id = String((_a2 = col.accessor) != null ? _a2 : "");
154
+ var _a2, _b2, _c;
155
+ const id = String(col.id);
183
156
  if (!id) return;
184
157
  if (!dir) table.setSorting([]);
185
158
  else table.setSorting([{ id, desc: dir === "desc" }]);
159
+ onSortingChange == null ? void 0 : onSortingChange((_c = (_b2 = (_a2 = table.getState().sorting) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.id) != null ? _c : null, dir);
186
160
  },
187
161
  headerExtras,
188
162
  columnStyles,
189
- headerBelowRow,
190
- loading,
191
- onRowClick,
192
- striped,
193
- fillViewport,
194
- viewportBottomOffset,
195
- viewportMin,
196
- viewportIncludeMarginTop,
197
- take: pageSize,
198
- skip,
199
- totalItemsCount,
200
- onPageChange,
201
- size
163
+ headerBelowRow
202
164
  }
203
165
  );
204
166
  }