@dbcdk/react-components 0.0.4 → 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
@@ -1,20 +1,23 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
+ import { useMemo, useCallback, useRef } from 'react';
2
3
  import { ArrowUp, ArrowDown } from 'lucide-react';
3
4
  import { Checkbox } from '../checkbox/Checkbox';
4
- import { useMemo, useCallback, useRef } from 'react';
5
5
  import styles from './Table.module.css';
6
6
  import { useViewportFill } from '../../hooks/useViewportFill';
7
7
  import { Pagination } from '../pagination/Pagination';
8
8
  import { SkeletonLoaderItem } from '../skeleton-loader/skeleton-loader-item/SkeletonLoaderItem';
9
+ import { SeverityBgColor } from '../../constants/severity';
10
+ import { TableEmptyState } from './components/empty-state/EmptyState';
9
11
 
10
12
  function Table({
11
13
  data,
12
14
  columns,
13
15
  selectedRows,
14
16
  onRowSelect,
17
+ selectionMode = "single",
15
18
  onSortChange,
16
19
  onRowClick,
17
- sortBy,
20
+ sortById,
18
21
  sortDirection,
19
22
  dataKey,
20
23
  headerExtras,
@@ -27,11 +30,18 @@ function Table({
27
30
  viewportIncludeMarginTop = false,
28
31
  take,
29
32
  skip,
33
+ paginationPlacement = "bottom",
30
34
  totalItemsCount,
31
35
  onPageChange,
32
36
  loading,
33
- variant = "filled",
34
- size = "md"
37
+ variant = "primary",
38
+ size = "md",
39
+ getRowSeverity,
40
+ showFirstLast = false,
41
+ allRowsSelected,
42
+ onSelectAllRows,
43
+ viewMode,
44
+ emptyConfig
35
45
  }) {
36
46
  const filteredColumns = useMemo(() => columns.filter((c) => !c.hidden), [columns]);
37
47
  const handlePageChange = useCallback(
@@ -40,11 +50,13 @@ function Table({
40
50
  },
41
51
  [onPageChange]
42
52
  );
43
- const getColStyle = (accessor, alignment) => {
44
- const baseStyle = accessor ? columnStyles == null ? void 0 : columnStyles[String(accessor)] : void 0;
53
+ const getColStyle = (columnId, alignment, verticalAlignment) => {
54
+ const baseStyle = columnStyles == null ? void 0 : columnStyles[columnId];
45
55
  return {
46
- textAlign: alignment != null ? alignment : "left",
47
- ...baseStyle != null ? baseStyle : {}
56
+ ...baseStyle != null ? baseStyle : {},
57
+ ...alignment === "right" && { fontVariantNumeric: "tabular-nums" },
58
+ verticalAlign: verticalAlignment != null ? verticalAlignment : "top",
59
+ textAlign: alignment != null ? alignment : "left"
48
60
  };
49
61
  };
50
62
  const scrollRef = useRef(null);
@@ -53,123 +65,179 @@ function Table({
53
65
  min: viewportMin,
54
66
  includeMarginTop: viewportIncludeMarginTop
55
67
  });
56
- const tableEl = /* @__PURE__ */ jsxs("table", { className: `${styles.table} ${styles[variant]} ${styles[size]}`, children: [
57
- /* @__PURE__ */ jsxs("thead", { children: [
58
- /* @__PURE__ */ jsxs("tr", { children: [
59
- selectedRows && dataKey && /* @__PURE__ */ jsx("th", { className: "fitContent" }),
60
- filteredColumns.map((column, index) => {
61
- var _a;
62
- const accessorKey = String((_a = column.accessor) != null ? _a : "");
63
- const isActiveSort = sortBy === column.accessor;
64
- const ariaSort = column.sortable && isActiveSort ? sortDirection === "asc" ? "ascending" : "descending" : "none";
65
- const toggleSort = () => {
66
- if (!onSortChange || !column.sortable) return;
67
- const nextDir = !isActiveSort ? "asc" : sortDirection === "asc" ? "desc" : null;
68
- onSortChange(column, nextDir);
69
- };
70
- return /* @__PURE__ */ jsx(
71
- "th",
72
- {
73
- style: getColStyle(column.accessor, column.align),
74
- "aria-sort": ariaSort,
75
- className: `${styles.th} ${column.sortable ? styles.sortable : ""}`,
76
- onClick: (e) => {
77
- if (!column.sortable) return;
78
- if (e.target instanceof HTMLElement && e.target.closest(".resizer")) return;
79
- toggleSort();
80
- },
81
- role: column.sortable ? "button" : void 0,
82
- tabIndex: column.sortable ? 0 : void 0,
83
- onKeyDown: (e) => {
84
- if (!column.sortable) return;
85
- if (e.key === "Enter" || e.key === " ") {
86
- e.preventDefault();
87
- toggleSort();
88
- }
89
- },
90
- children: /* @__PURE__ */ jsx("div", { className: styles.thInner, children: /* @__PURE__ */ jsxs("span", { children: [
91
- /* @__PURE__ */ jsx("span", { className: styles.thLabel, children: column.header }),
92
- column.sortable && /* @__PURE__ */ jsxs("span", { className: styles.sortIndicator, "aria-hidden": "true", children: [
93
- isActiveSort && sortDirection === "asc" && /* @__PURE__ */ jsx(ArrowUp, {}),
94
- isActiveSort && sortDirection === "desc" && /* @__PURE__ */ jsx(ArrowDown, { className: styles.descending }),
95
- !isActiveSort && /* @__PURE__ */ jsx(ArrowDown, { className: styles.descending })
96
- ] }),
97
- headerExtras == null ? void 0 : headerExtras({ column, index })
98
- ] }) })
99
- },
100
- `${accessorKey}-${index}`
101
- );
102
- })
103
- ] }),
104
- headerBelowRow ? /* @__PURE__ */ jsx("tr", { className: styles.headerBelowRow, children: /* @__PURE__ */ jsx("th", { colSpan: filteredColumns.length, children: headerBelowRow }) }) : null
105
- ] }),
106
- loading && !data.length ? /* @__PURE__ */ jsx("tbody", { className: `${styles.tBody} ${striped ? styles.striped : ""}`, children: Array.from({ length: take != null ? take : 5 }).map((_, rowIndex) => /* @__PURE__ */ jsx("tr", { children: filteredColumns.map((column, colIndex) => /* @__PURE__ */ jsx(
107
- "td",
108
- {
109
- style: getColStyle(column.accessor, column.align),
110
- className: `${styles.tableCell}`,
111
- children: /* @__PURE__ */ jsx(SkeletonLoaderItem, { height: 20, width: "100%" })
112
- },
113
- `loading-cell-${colIndex}`
114
- )) }, `loading-row-${rowIndex}`)) }) : /* @__PURE__ */ jsx("tbody", { className: `${styles.tBody} ${striped ? styles.striped : ""}`, children: data == null ? void 0 : data.map((row, rowIndex) => /* @__PURE__ */ jsxs(
115
- "tr",
116
- {
117
- onClick: () => onRowClick == null ? void 0 : onRowClick(row),
118
- className: `${onRowClick ? styles.clickableRow : ""} ${(selectedRows == null ? void 0 : selectedRows.has(row[dataKey])) ? styles.selectedRow : ""}`,
119
- children: [
120
- selectedRows && dataKey && /* @__PURE__ */ jsx("td", { className: "fitContent", children: /* @__PURE__ */ jsx(
68
+ const tableEl = /* @__PURE__ */ jsxs(Fragment, { children: [
69
+ /* @__PURE__ */ jsxs("table", { className: `${styles.table} ${styles[variant]} ${styles[size]}`, children: [
70
+ /* @__PURE__ */ jsxs("thead", { children: [
71
+ /* @__PURE__ */ jsxs("tr", { children: [
72
+ selectedRows && dataKey && /* @__PURE__ */ jsx("th", { className: `${styles.fitContent} ${styles.th}`, children: selectionMode === "multiple" ? /* @__PURE__ */ jsx(
121
73
  Checkbox,
122
74
  {
123
- checked: selectedRows.has(row[dataKey]),
124
75
  size: "sm",
125
- onChange: () => onRowSelect == null ? void 0 : onRowSelect(row[dataKey], !selectedRows.has(row[dataKey]))
76
+ variant: "primary",
77
+ checked: allRowsSelected,
78
+ onChange: (checked) => onSelectAllRows == null ? void 0 : onSelectAllRows(checked)
126
79
  }
127
- ) }),
128
- filteredColumns.map((column) => {
129
- var _a;
130
- const accessorKey = String((_a = column.accessor) != null ? _a : "");
80
+ ) : null }),
81
+ filteredColumns.map((column, index) => {
82
+ const isActiveSort = sortById === column.id;
83
+ const ariaSort = column.sortable && isActiveSort ? sortDirection === "asc" ? "ascending" : "descending" : "none";
84
+ const toggleSort = () => {
85
+ if (!onSortChange || !column.sortable) return;
86
+ const nextDir = !isActiveSort ? "asc" : sortDirection === "asc" ? "desc" : null;
87
+ onSortChange(column, nextDir);
88
+ };
131
89
  return /* @__PURE__ */ jsx(
132
- "td",
90
+ "th",
133
91
  {
134
- style: getColStyle(column.accessor, column.align),
135
- className: `${styles.tableCell} `,
136
- children: column.render ? column.render(row) : row[accessorKey]
92
+ style: getColStyle(column.id, column.align, "middle"),
93
+ "aria-sort": ariaSort,
94
+ className: `${styles.th} ${column.sortable ? styles.sortable : ""} `,
95
+ onClick: (e) => {
96
+ if (!column.sortable) return;
97
+ if (e.target instanceof HTMLElement && e.target.closest(".resizer")) return;
98
+ toggleSort();
99
+ },
100
+ role: column.sortable ? "button" : void 0,
101
+ tabIndex: column.sortable ? 0 : void 0,
102
+ onKeyDown: (e) => {
103
+ if (!column.sortable) return;
104
+ if (e.key === "Enter" || e.key === " ") {
105
+ e.preventDefault();
106
+ toggleSort();
107
+ }
108
+ },
109
+ children: /* @__PURE__ */ jsx("div", { className: styles.thInner, children: /* @__PURE__ */ jsxs("span", { children: [
110
+ /* @__PURE__ */ jsx("span", { className: styles.thLabel, children: typeof column.header === "function" ? column.header() : column.header }),
111
+ column.sortable && /* @__PURE__ */ jsxs("span", { className: styles.sortIndicator, "aria-hidden": "true", children: [
112
+ isActiveSort && sortDirection === "asc" && /* @__PURE__ */ jsx(ArrowUp, {}),
113
+ isActiveSort && sortDirection === "desc" && /* @__PURE__ */ jsx(ArrowDown, { className: styles.descending }),
114
+ !isActiveSort && /* @__PURE__ */ jsx(ArrowDown, { className: `${styles.descending} ${styles.inActiveSort}` })
115
+ ] }),
116
+ headerExtras == null ? void 0 : headerExtras({ column, index })
117
+ ] }) })
137
118
  },
138
- accessorKey
119
+ column.id
139
120
  );
140
121
  })
141
- ]
142
- },
143
- `tableRow-${String(row[dataKey])}-${rowIndex} `
144
- )) })
122
+ ] }),
123
+ headerBelowRow ? /* @__PURE__ */ jsx("tr", { className: styles.headerBelowRow, children: /* @__PURE__ */ jsx("th", { colSpan: filteredColumns.length, children: headerBelowRow }) }) : null
124
+ ] }),
125
+ loading && !data.length ? /* @__PURE__ */ jsx("tbody", { className: `${styles.tBody} ${striped ? styles.striped : ""}`, children: Array.from({ length: take != null ? take : 5 }).map((_, rowIndex) => /* @__PURE__ */ jsx("tr", { children: filteredColumns.map((column, colIndex) => /* @__PURE__ */ jsx(
126
+ "td",
127
+ {
128
+ style: getColStyle(column.id, column.align),
129
+ className: `${styles.tableCell} ${column.fitContent ? "fitContent" : ""}`,
130
+ children: /* @__PURE__ */ jsx(SkeletonLoaderItem, { height: 20, width: "100%" })
131
+ },
132
+ `${column.id}-${colIndex}`
133
+ )) }, `loading-row-${rowIndex}`)) }) : /* @__PURE__ */ jsx("tbody", { className: `${styles.tBody} ${striped ? styles.striped : ""}`, children: data == null ? void 0 : data.map((row, rowIndex) => {
134
+ const rowSeverity = getRowSeverity == null ? void 0 : getRowSeverity(row);
135
+ return /* @__PURE__ */ jsxs(
136
+ "tr",
137
+ {
138
+ tabIndex: onRowClick ? 0 : -1,
139
+ onClick: (e) => {
140
+ const rowId = row[dataKey];
141
+ const isModifierClick = e.metaKey || e.ctrlKey;
142
+ const canSelect = Boolean(selectedRows && onRowSelect && dataKey);
143
+ if (isModifierClick && canSelect) {
144
+ e.preventDefault();
145
+ e.stopPropagation();
146
+ const isSelected = selectedRows.has(rowId);
147
+ if (selectionMode === "single") {
148
+ onRowSelect(rowId, !isSelected);
149
+ } else {
150
+ onRowSelect(rowId, !isSelected);
151
+ }
152
+ return;
153
+ }
154
+ onRowClick == null ? void 0 : onRowClick(row);
155
+ },
156
+ style: {
157
+ ["--row-severity-color"]: rowSeverity ? SeverityBgColor[rowSeverity] : void 0
158
+ },
159
+ className: `${onRowClick ? styles.clickableRow : ""} ${(selectedRows == null ? void 0 : selectedRows.has(row[dataKey])) ? styles.selectedRow : ""} ${rowSeverity ? styles.severity : ""}`,
160
+ children: [
161
+ selectedRows && dataKey && /* @__PURE__ */ jsx("td", { className: "fitContent", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
162
+ Checkbox,
163
+ {
164
+ variant: "primary",
165
+ checked: selectedRows.has(row[dataKey]),
166
+ size: "sm",
167
+ onChange: () => onRowSelect == null ? void 0 : onRowSelect(row[dataKey], !selectedRows.has(row[dataKey]))
168
+ }
169
+ ) }),
170
+ filteredColumns.map((column) => {
171
+ var _a, _b;
172
+ return /* @__PURE__ */ jsx(
173
+ "td",
174
+ {
175
+ style: getColStyle(column.id, column.align, column.verticalAlign),
176
+ className: `${styles.tableCell} ${column.fitContent ? "fitContent" : ""} ${column.allowWrap || (selectedRows == null ? void 0 : selectedRows.has(row[dataKey])) || viewMode === "comfortable" ? "" : styles.nowrap} `,
177
+ children: column.render ? column.render(row) || ((_a = column.emptyPlaceholder) != null ? _a : "") : column.accessor ? row[column.accessor] || ((_b = column.emptyPlaceholder) != null ? _b : "") : null
178
+ },
179
+ column.id
180
+ );
181
+ })
182
+ ]
183
+ },
184
+ `tableRow-${String(row[dataKey])}-${rowIndex}`
185
+ );
186
+ }) })
187
+ ] }),
188
+ !data.length && /* @__PURE__ */ jsx(TableEmptyState, { config: emptyConfig })
145
189
  ] });
146
190
  if (fillViewport) {
147
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "20px" }, children: [
148
- /* @__PURE__ */ jsx("div", { ref: scrollRef, style: viewportStyle, className: styles.tableScroll, children: tableEl }),
149
- onPageChange && /* @__PURE__ */ jsx(
150
- Pagination,
151
- {
152
- itemsCount: totalItemsCount,
153
- take,
154
- skip,
155
- onPageChange: handlePageChange
156
- }
157
- )
158
- ] });
159
- }
160
- return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: "20px" }, children: [
161
- tableEl,
162
- " ",
163
- onPageChange && /* @__PURE__ */ jsx(
164
- Pagination,
191
+ return /* @__PURE__ */ jsxs(
192
+ "div",
165
193
  {
166
- itemsCount: totalItemsCount,
167
- take,
168
- skip,
169
- onPageChange: handlePageChange
194
+ style: {
195
+ display: "flex",
196
+ flexDirection: "column",
197
+ gap: "20px",
198
+ flexFlow: paginationPlacement === "top" ? "column-reverse" : "column",
199
+ position: "relative"
200
+ },
201
+ children: [
202
+ /* @__PURE__ */ jsx("div", { ref: scrollRef, style: viewportStyle, className: styles.tableScroll, children: tableEl }),
203
+ onPageChange && /* @__PURE__ */ jsx(
204
+ Pagination,
205
+ {
206
+ itemsCount: totalItemsCount,
207
+ take,
208
+ skip,
209
+ onPageChange: handlePageChange,
210
+ showFirstLast
211
+ }
212
+ )
213
+ ]
170
214
  }
171
- )
172
- ] });
215
+ );
216
+ }
217
+ return /* @__PURE__ */ jsxs(
218
+ "div",
219
+ {
220
+ style: {
221
+ display: "flex",
222
+ flexDirection: "column",
223
+ gap: "20px",
224
+ flexFlow: paginationPlacement === "top" ? "column-reverse" : "column",
225
+ position: "relative"
226
+ },
227
+ children: [
228
+ tableEl,
229
+ onPageChange && /* @__PURE__ */ jsx(
230
+ Pagination,
231
+ {
232
+ itemsCount: totalItemsCount,
233
+ take,
234
+ skip,
235
+ onPageChange: handlePageChange
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ );
173
241
  }
174
242
 
175
243
  export { Table };
@@ -5,33 +5,37 @@
5
5
  border-collapse: collapse;
6
6
  font-family: var(--font-family);
7
7
  font-size: var(--font-size-sm);
8
- color: var(--color-text);
9
- background: var(--color-surface);
8
+ color: var(--color-fg-default);
9
+ background: var(--color-bg-surface);
10
10
  }
11
11
 
12
- .table.sm tr td,
13
- .table.sm th {
14
- padding-block: var(--spacing-xxs);
15
- padding-inline: var(--spacing-sm);
12
+ .table.sm tr td {
13
+ padding-block: var(--spacing-xs);
14
+ padding-inline: var(--spacing-md);
16
15
  font-size: var(--font-size-xs);
17
16
  }
18
17
 
18
+ .table.sm th {
19
+ padding-inline: var(--spacing-md);
20
+ }
21
+
19
22
  .table thead {
20
23
  position: sticky;
21
24
  inset-block-start: 0;
22
- background-color: var(--color-surface);
25
+ background-color: var(--color-bg-surface);
23
26
  z-index: 10;
24
27
  }
25
28
 
26
- .table.filled thead th {
27
- background-color: var(--color-surface-hover);
29
+ .table.primary thead {
30
+ box-shadow: var(--shadow-md);
28
31
  }
29
32
 
30
33
  .clickableRow {
31
34
  cursor: pointer;
32
35
  }
36
+
33
37
  .clickableRow:hover {
34
- background-color: var(--color-surface-hover);
38
+ background-color: var(--color-bg-contextual);
35
39
  }
36
40
 
37
41
  .selectedRow {
@@ -41,20 +45,29 @@
41
45
  background-color: var(--color-bg-selected-hover);
42
46
  }
43
47
 
44
- .th,
45
- th {
46
- color: var(--color-text-secondary);
48
+ .nowrap {
49
+ white-space: nowrap;
50
+ overflow: hidden;
51
+ text-overflow: ellipsis;
52
+ }
53
+
54
+ .table .th {
55
+ color: var(--color-fg-muted);
56
+ font-size: var(--font-size-xs);
47
57
  font-weight: var(--font-weight-medium);
48
58
  position: relative;
49
59
  padding-block: var(--spacing-xs);
50
- padding-inline: var(--spacing-sm);
60
+ padding-inline: var(--spacing-md);
51
61
  text-align: start;
52
62
  background: inherit;
53
- border-block-end: var(--border-width-thin) solid var(--color-border);
63
+ white-space: nowrap;
64
+ min-width: unset;
65
+ max-width: unset;
66
+ width: 1%;
67
+ vertical-align: middle;
54
68
  }
55
69
 
56
- .th.sortable,
57
- th.sortable {
70
+ .th.sortable {
58
71
  cursor: pointer;
59
72
  user-select: none;
60
73
  transition:
@@ -63,7 +76,7 @@ th.sortable {
63
76
  }
64
77
  .th.sortable:hover,
65
78
  th.sortable:hover {
66
- background-color: var(--color-surface-hover);
79
+ background-color: var(--color-bg-contextual);
67
80
  }
68
81
  .th.sortable:focus-visible,
69
82
  th.sortable:focus-visible {
@@ -71,9 +84,16 @@ th.sortable:focus-visible {
71
84
  box-shadow: var(--focus-ring);
72
85
  }
73
86
 
87
+ .inActiveSort {
88
+ color: var(--color-fg-subtle);
89
+ }
90
+
91
+ .sortIndicator {
92
+ display: flex;
93
+ }
74
94
  .sortIndicator svg {
75
- inline-size: var(--icon-size);
76
- block-size: var(--icon-size);
95
+ inline-size: var(--icon-size-sm);
96
+ block-size: var(--icon-size-sm);
77
97
  }
78
98
 
79
99
  .th > .thInner {
@@ -86,57 +106,64 @@ th.sortable:focus-visible {
86
106
  inline-size: 100%;
87
107
  }
88
108
 
109
+ .tBody::before {
110
+ content: '';
111
+ height: var(--spacing-xs);
112
+ display: block;
113
+ }
114
+
89
115
  .tBody tr td,
90
- tbody tr td {
116
+ .tbody tr td {
91
117
  position: relative;
92
118
  padding-block: var(--spacing-xs);
93
119
  padding-inline: var(--spacing-sm);
94
- border-block-end: var(--border-width-thin) solid var(--color-border);
120
+ border-block-end: var(--border-width-thin) solid var(--color-border-default);
95
121
  text-align: start;
96
122
  vertical-align: top;
123
+ overflow-wrap: break-word;
124
+ word-break: normal;
97
125
  }
98
126
 
99
- .striped tr:nth-child(even) {
100
- background-color: var(--color-surface-hover);
127
+ .tBody tr.severity {
128
+ background-repeat: no-repeat;
129
+ background-size: 100% 100%;
130
+ background-position: left top;
131
+ background-image: linear-gradient(to right, var(--row-severity-color) 0 3px, transparent 3px);
132
+ }
133
+
134
+ .striped tr:nth-child(even):not(.selectedRow):not(:hover) {
135
+ background-color: var(--color-bg-surface-subtle);
101
136
  }
102
137
 
103
138
  .td--numeric {
104
139
  text-align: end;
105
140
  }
106
141
  .td--muted {
107
- color: var(--color-text-muted);
142
+ color: var(--color-fg-muted);
143
+ }
144
+
145
+ .td .error {
146
+ color: var(--color-danger);
108
147
  }
109
148
  .tr--hover:hover {
110
- background-color: var(--color-surface-hover);
149
+ background-color: var(--color-bg-contextual);
111
150
  }
112
151
 
113
- /* focus ring across the entire row, above sticky header and row backgrounds */
114
- tr:focus-within {
152
+ .table .tbody tr:focus-within {
115
153
  outline: none;
116
154
  box-shadow: none;
117
155
  }
118
- tr:focus-within td::after {
119
- content: '';
120
- position: absolute;
121
- inset-block-start: -2px;
122
- inset-block-end: -2px;
123
- inset-inline-start: 0;
124
- inset-inline-end: 0;
125
- border-block-start: 2px solid var(--color-primary);
126
- border-block-end: 2px solid var(--color-primary);
127
- pointer-events: none;
128
- z-index: 11;
129
- }
130
- tr:focus-within td:first-child::after {
131
- inset-inline-start: -2px;
132
- border-inline-start: 2px solid var(--color-primary);
133
- }
134
- tr:focus-within td:last-child::after {
135
- inset-inline-end: -2px;
136
- border-inline-end: 2px solid var(--color-primary);
156
+ .table .tbody tr:focus-within {
157
+ outline: none;
158
+ box-shadow:
159
+ inset 2px 0 0 var(--color-brand),
160
+ inset -2px 0 0 var(--color-brand),
161
+ inset 0 2px 0 var(--color-brand),
162
+ inset 0 -2px 0 var(--color-brand);
137
163
  }
138
164
 
139
165
  .tableScroll {
166
+ position: relative;
140
167
  overflow: auto;
141
168
  max-inline-size: 100%;
142
169
  -webkit-overflow-scrolling: touch;
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var Button = require('../../../button/Button');
5
+ var Headline = require('../../../headline/Headline');
6
+ var lucideReact = require('lucide-react');
7
+ var styles = require('./EmptyState.module.css');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
12
+
13
+ const defaultEmptyConfig = {
14
+ enabled: true,
15
+ title: /* @__PURE__ */ jsxRuntime.jsx(Headline.Headline, { disableMargin: true, size: 3, children: "Hov, der er ingen data" }),
16
+ description: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Pr\xF8v at \xE6ndre dine filtre eller tilf\xF8je data." }),
17
+ showBack: true,
18
+ showRefresh: true,
19
+ backLabel: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
20
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, {}),
21
+ "Tilbage"
22
+ ] }),
23
+ refreshLabel: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
24
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, {}),
25
+ "Indl\xE6s igen"
26
+ ] }),
27
+ className: "dbc-flex dbc-flex-column dbc-justify-center dbc-items-center dbc-flex-grow "
28
+ };
29
+ function TableEmptyState({ config }) {
30
+ const merged = {
31
+ ...defaultEmptyConfig,
32
+ ...config != null ? config : {}
33
+ };
34
+ if (!merged.enabled) return null;
35
+ const showBack = merged.showBack && typeof merged.onBack === "function";
36
+ const showRefresh = merged.showRefresh && typeof merged.onRefresh === "function";
37
+ const hasAnyActions = Boolean(merged.actions) || showBack || showRefresh;
38
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${merged.className} ${styles__default.default.container}`, children: [
39
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "dbc-flex dbc-flex-column dbc-gap-sm dbc-items-center", children: [
40
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SearchX, { className: styles__default.default.icon }),
41
+ merged.title,
42
+ merged.description
43
+ ] }),
44
+ hasAnyActions && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dbc-flex dbc-gap-sm", children: [
45
+ merged.actions,
46
+ showBack && /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { onClick: merged.onBack, className: "dbc-mr-xxs", children: merged.backLabel }),
47
+ showRefresh && /* @__PURE__ */ jsxRuntime.jsx(Button.Button, { onClick: merged.onRefresh, children: merged.refreshLabel })
48
+ ] })
49
+ ] });
50
+ }
51
+
52
+ exports.TableEmptyState = TableEmptyState;
@@ -0,0 +1,40 @@
1
+ export type TableEmptyConfig = {
2
+ /**
3
+ * Whether to show the empty state at all.
4
+ * Default: true
5
+ */
6
+ enabled?: boolean;
7
+ /**
8
+ * Title + description text (defaults are your current Danish copy)
9
+ */
10
+ title?: React.ReactNode;
11
+ description?: React.ReactNode;
12
+ /**
13
+ * Optional custom actions area. If provided, it will be rendered first.
14
+ * Useful for passing your own buttons/links/etc.
15
+ */
16
+ actions?: React.ReactNode;
17
+ /**
18
+ * Convenience callbacks for built-in default buttons.
19
+ * If provided, the corresponding button is shown (unless hidden via showBack/showRefresh).
20
+ */
21
+ onBack?: () => void;
22
+ onRefresh?: () => void;
23
+ /**
24
+ * Control default buttons
25
+ */
26
+ showBack?: boolean;
27
+ showRefresh?: boolean;
28
+ /**
29
+ * Override default labels for default buttons
30
+ */
31
+ backLabel?: React.ReactNode;
32
+ refreshLabel?: React.ReactNode;
33
+ /**
34
+ * Wrapper className for layout styling
35
+ */
36
+ className?: string;
37
+ };
38
+ export declare function TableEmptyState({ config }: {
39
+ config?: TableEmptyConfig;
40
+ }): JSX.Element | null;