@eifi1/ui-kit 0.8.1 → 0.10.0

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 (204) hide show
  1. package/README.md +25 -11
  2. package/dist/components/alert-banner.d.ts +32 -5
  3. package/dist/components/alert-banner.js +57 -14
  4. package/dist/components/alert-banner.js.map +1 -1
  5. package/dist/components/amount-input.d.ts +6 -0
  6. package/dist/components/breadcrumbs.d.ts +60 -0
  7. package/dist/components/breadcrumbs.js +88 -0
  8. package/dist/components/breadcrumbs.js.map +1 -0
  9. package/dist/components/bulk-action-bar.d.ts +66 -0
  10. package/dist/components/bulk-action-bar.js +149 -0
  11. package/dist/components/bulk-action-bar.js.map +1 -0
  12. package/dist/components/calculator.d.ts +6 -0
  13. package/dist/components/chip.d.ts +58 -10
  14. package/dist/components/chip.js +91 -7
  15. package/dist/components/chip.js.map +1 -1
  16. package/dist/components/copy-button.d.ts +13 -4
  17. package/dist/components/copy-button.js +17 -4
  18. package/dist/components/copy-button.js.map +1 -1
  19. package/dist/components/data-table-filter-popover.d.ts +1 -1
  20. package/dist/components/data-table-filters.d.ts +1 -1
  21. package/dist/components/data-table.d.ts +1 -1
  22. package/dist/components/data-table.js +122 -91
  23. package/dist/components/data-table.js.map +1 -1
  24. package/dist/components/date-picker.d.ts +89 -3
  25. package/dist/components/date-picker.js +163 -68
  26. package/dist/components/date-picker.js.map +1 -1
  27. package/dist/components/description-list.d.ts +43 -6
  28. package/dist/components/description-list.js +91 -11
  29. package/dist/components/description-list.js.map +1 -1
  30. package/dist/components/dialog-frame.d.ts +7 -0
  31. package/dist/components/dialog-frame.js.map +1 -1
  32. package/dist/components/disclosure.d.ts +68 -4
  33. package/dist/components/disclosure.js +33 -15
  34. package/dist/components/disclosure.js.map +1 -1
  35. package/dist/components/file-dropzone.d.ts +3 -4
  36. package/dist/components/file-dropzone.js +2 -1
  37. package/dist/components/file-dropzone.js.map +1 -1
  38. package/dist/components/floating-panel.d.ts +29 -2
  39. package/dist/components/floating-panel.js +16 -2
  40. package/dist/components/floating-panel.js.map +1 -1
  41. package/dist/components/full-bleed-dialog.d.ts +23 -4
  42. package/dist/components/full-bleed-dialog.js +11 -2
  43. package/dist/components/full-bleed-dialog.js.map +1 -1
  44. package/dist/components/list.d.ts +174 -0
  45. package/dist/components/list.js +215 -0
  46. package/dist/components/list.js.map +1 -0
  47. package/dist/components/menu-item.d.ts +99 -0
  48. package/dist/components/menu-item.js +83 -0
  49. package/dist/components/menu-item.js.map +1 -0
  50. package/dist/components/modal.d.ts +23 -1
  51. package/dist/components/modal.js +36 -10
  52. package/dist/components/modal.js.map +1 -1
  53. package/dist/components/number-field.d.ts +6 -0
  54. package/dist/components/number-input.d.ts +6 -0
  55. package/dist/components/numpad-sheet.d.ts +6 -0
  56. package/dist/components/page-contents.js +1 -2
  57. package/dist/components/page-contents.js.map +1 -1
  58. package/dist/components/page-header.d.ts +37 -0
  59. package/dist/components/page-header.js +36 -0
  60. package/dist/components/page-header.js.map +1 -0
  61. package/dist/components/progress-bar.d.ts +16 -2
  62. package/dist/components/progress-bar.js +4 -2
  63. package/dist/components/progress-bar.js.map +1 -1
  64. package/dist/components/series-chart-labels.d.ts +3 -0
  65. package/dist/components/series-chart-labels.js +2 -1
  66. package/dist/components/series-chart-labels.js.map +1 -1
  67. package/dist/components/series-chart.d.ts +16 -0
  68. package/dist/components/series-chart.js +137 -3
  69. package/dist/components/series-chart.js.map +1 -1
  70. package/dist/components/status-dot.d.ts +49 -0
  71. package/dist/components/status-dot.js +52 -0
  72. package/dist/components/status-dot.js.map +1 -0
  73. package/dist/components/table.d.ts +39 -6
  74. package/dist/components/table.js +43 -4
  75. package/dist/components/table.js.map +1 -1
  76. package/dist/components/text.d.ts +63 -0
  77. package/dist/components/text.js +23 -0
  78. package/dist/components/text.js.map +1 -0
  79. package/dist/components/toast.d.ts +167 -0
  80. package/dist/components/toast.js +226 -0
  81. package/dist/components/toast.js.map +1 -0
  82. package/dist/components/toggle-group.d.ts +29 -1
  83. package/dist/components/toggle-group.js +52 -3
  84. package/dist/components/toggle-group.js.map +1 -1
  85. package/dist/components/tooltip.d.ts +38 -15
  86. package/dist/components/tooltip.js +85 -47
  87. package/dist/components/tooltip.js.map +1 -1
  88. package/dist/components/ui.d.ts +139 -16
  89. package/dist/components/ui.js +136 -26
  90. package/dist/components/ui.js.map +1 -1
  91. package/dist/components/use-table-state.d.ts +1 -1
  92. package/dist/{data-table-filters-CF1PXqjQ.d.ts → data-table-filters-Dh9uF_S-.d.ts} +33 -2
  93. package/dist/data-table.d.ts +1 -1
  94. package/dist/hooks/use-close-transition.d.ts +7 -1
  95. package/dist/hooks/use-close-transition.js +5 -2
  96. package/dist/hooks/use-close-transition.js.map +1 -1
  97. package/dist/hooks/use-copy-to-clipboard.js +1 -1
  98. package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
  99. package/dist/hooks/use-overlay-history.js +84 -4
  100. package/dist/hooks/use-overlay-history.js.map +1 -1
  101. package/dist/i18n/defaults.d.ts +6 -0
  102. package/dist/i18n/defaults.js +11 -1
  103. package/dist/i18n/defaults.js.map +1 -1
  104. package/dist/i18n/kit-labels.d.ts +11 -0
  105. package/dist/i18n/kit-labels.js.map +1 -1
  106. package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
  107. package/dist/i18n/locales/de-CH.d.ts +6 -0
  108. package/dist/i18n/locales/de-informal.d.ts +6 -0
  109. package/dist/i18n/locales/de.d.ts +6 -0
  110. package/dist/i18n/locales/de.js +31 -1
  111. package/dist/i18n/locales/de.js.map +1 -1
  112. package/dist/i18n/locales/es.d.ts +6 -0
  113. package/dist/i18n/locales/es.js +31 -1
  114. package/dist/i18n/locales/es.js.map +1 -1
  115. package/dist/i18n/locales/fr.d.ts +6 -0
  116. package/dist/i18n/locales/fr.js +31 -1
  117. package/dist/i18n/locales/fr.js.map +1 -1
  118. package/dist/i18n/locales/hu.d.ts +6 -0
  119. package/dist/i18n/locales/hu.js +31 -1
  120. package/dist/i18n/locales/hu.js.map +1 -1
  121. package/dist/i18n/locales/it.d.ts +6 -0
  122. package/dist/i18n/locales/it.js +31 -1
  123. package/dist/i18n/locales/it.js.map +1 -1
  124. package/dist/i18n/locales/zh.d.ts +6 -0
  125. package/dist/i18n/locales/zh.js +31 -1
  126. package/dist/i18n/locales/zh.js.map +1 -1
  127. package/dist/index.d.ts +18 -8
  128. package/dist/index.js +14 -0
  129. package/dist/index.js.map +1 -1
  130. package/dist/lib/clipping.d.ts +9 -0
  131. package/dist/lib/clipping.js +14 -0
  132. package/dist/lib/clipping.js.map +1 -0
  133. package/dist/search/command-palette.d.ts +67 -2
  134. package/dist/search/command-palette.js +147 -33
  135. package/dist/search/command-palette.js.map +1 -1
  136. package/dist/search/global-search.d.ts +166 -0
  137. package/dist/search/global-search.js +293 -0
  138. package/dist/search/global-search.js.map +1 -0
  139. package/dist/search/search-index.d.ts +105 -0
  140. package/dist/search/search-index.js +142 -0
  141. package/dist/search/search-index.js.map +1 -0
  142. package/dist/search.d.ts +3 -1
  143. package/dist/search.js +2 -0
  144. package/dist/search.js.map +1 -1
  145. package/dist/wizard/stepper-nav.d.ts +10 -1
  146. package/dist/wizard/stepper-nav.js +3 -2
  147. package/dist/wizard/stepper-nav.js.map +1 -1
  148. package/dist/wizard/types.d.ts +2 -2
  149. package/dist/wizard/types.js.map +1 -1
  150. package/dist/wizard/use-wizard.js +1 -1
  151. package/dist/wizard/use-wizard.js.map +1 -1
  152. package/dist/wizard/wizard-summary.js +3 -3
  153. package/dist/wizard/wizard-summary.js.map +1 -1
  154. package/package.json +25 -12
  155. package/src/components/alert-banner.tsx +117 -18
  156. package/src/components/breadcrumbs.tsx +168 -0
  157. package/src/components/bulk-action-bar.tsx +256 -0
  158. package/src/components/chip.tsx +164 -13
  159. package/src/components/copy-button.tsx +29 -7
  160. package/src/components/data-table.tsx +81 -5
  161. package/src/components/date-picker.tsx +377 -118
  162. package/src/components/description-list.tsx +168 -15
  163. package/src/components/dialog-frame.tsx +7 -0
  164. package/src/components/disclosure.tsx +116 -28
  165. package/src/components/file-dropzone.tsx +9 -10
  166. package/src/components/floating-panel.tsx +46 -2
  167. package/src/components/full-bleed-dialog.tsx +42 -5
  168. package/src/components/list.tsx +417 -0
  169. package/src/components/menu-item.tsx +214 -0
  170. package/src/components/modal.tsx +80 -17
  171. package/src/components/page-contents.tsx +4 -4
  172. package/src/components/page-header.tsx +68 -0
  173. package/src/components/progress-bar.tsx +27 -3
  174. package/src/components/series-chart-labels.ts +4 -0
  175. package/src/components/series-chart.tsx +253 -3
  176. package/src/components/status-dot.tsx +99 -0
  177. package/src/components/table.tsx +91 -6
  178. package/src/components/text.tsx +89 -0
  179. package/src/components/toast.tsx +441 -0
  180. package/src/components/toggle-group.tsx +82 -3
  181. package/src/components/tooltip.tsx +186 -100
  182. package/src/components/ui.tsx +321 -41
  183. package/src/hooks/use-close-transition.ts +14 -5
  184. package/src/hooks/use-copy-to-clipboard.ts +1 -1
  185. package/src/hooks/use-overlay-history.ts +181 -4
  186. package/src/i18n/defaults.ts +10 -0
  187. package/src/i18n/kit-labels.tsx +10 -0
  188. package/src/i18n/locales/de.ts +30 -0
  189. package/src/i18n/locales/es.ts +30 -0
  190. package/src/i18n/locales/fr.ts +30 -0
  191. package/src/i18n/locales/hu.ts +30 -0
  192. package/src/i18n/locales/it.ts +30 -0
  193. package/src/i18n/locales/zh.ts +30 -0
  194. package/src/index.ts +30 -0
  195. package/src/lib/clipping.ts +16 -0
  196. package/src/search/command-palette.tsx +241 -31
  197. package/src/search/global-search.tsx +525 -0
  198. package/src/search/search-index.ts +295 -0
  199. package/src/search.ts +2 -0
  200. package/src/wizard/stepper-nav.tsx +13 -2
  201. package/src/wizard/types.ts +2 -2
  202. package/src/wizard/use-wizard.ts +3 -3
  203. package/src/wizard/wizard-summary.tsx +14 -10
  204. package/tokens.css +97 -0
@@ -1,5 +1,5 @@
1
1
  import { Fragment, useEffect, useMemo, useRef, useState } from "react";
2
- import type { ReactNode } from "react";
2
+ import type { CSSProperties, ReactNode, TdHTMLAttributes, ThHTMLAttributes } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import {
5
5
  ArrowDown,
@@ -76,6 +76,65 @@ export interface DataTableColumn<T> {
76
76
  * Default `"asc"`.
77
77
  */
78
78
  firstSort?: SortDir;
79
+ /**
80
+ * Extra attributes for this column's `<td>` in a given row — a `data-*` hook, a
81
+ * `title`, an `aria-describedby`, a class. keksdose's accounts page
82
+ * (accounts-page.tsx, the name and IBAN columns) is why it exists: its demo mode
83
+ * blurs everything marked `data-private`, and with nowhere to put the marker on the
84
+ * cell it wrapped every value in an inner `<span data-private>` — which blurs the
85
+ * text but not the cell, and has to be remembered in every `cell` renderer.
86
+ *
87
+ * MERGED under the kit's own, which win: `className` is joined before the column's
88
+ * `className` (so the column's alignment is still the alignment), `style` is laid
89
+ * under a resized column's pinned width, and `data-col` and a `role` stay the
90
+ * table's — `data-col` is how a resize finds the column's cells, and a `<td>` that
91
+ * claims another role leaves its row's cell count wrong for a screen reader.
92
+ *
93
+ * On a phone the card field (`<dd>`, or the primary line) gets the `data-*`
94
+ * attributes only: the rest — padding classes, `colSpan`, a width — describe a
95
+ * table cell and would mean something else, or nothing, on a card.
96
+ */
97
+ cellProps?: (row: T) => DataTableCellProps | undefined;
98
+ /** The same for the column's `<th>`, once. `scope`, `aria-sort`, `data-col` and the
99
+ * width a resize pins stay the table's, and the class list goes before
100
+ * `headClassName` for the same reason as in {@link cellProps}. */
101
+ headProps?: DataTableHeadProps;
102
+ }
103
+
104
+ /** A `data-*` attribute, typed so `{ "data-private": "" }` needs no cast. */
105
+ type DataAttributes = { [key: `data-${string}`]: string | number | boolean | undefined };
106
+
107
+ /** What {@link DataTableColumn.cellProps} may return. */
108
+ export type DataTableCellProps = TdHTMLAttributes<HTMLTableCellElement> & DataAttributes;
109
+
110
+ /** What {@link DataTableColumn.headProps} takes. */
111
+ export type DataTableHeadProps = ThHTMLAttributes<HTMLTableCellElement> & DataAttributes;
112
+
113
+ /**
114
+ * Split a caller's cell attributes into what may reach the element and what the kit
115
+ * owns. `role` and `data-col` are dropped outright (see `cellProps`); `className` and
116
+ * `style` come back separately so the kit can merge rather than replace them.
117
+ */
118
+ function splitCellProps(
119
+ props: DataTableCellProps | DataTableHeadProps | undefined,
120
+ ): { attrs: Record<string, unknown>; className?: string; style?: CSSProperties } {
121
+ if (!props) return { attrs: {} };
122
+ const {
123
+ className,
124
+ style,
125
+ role: _role,
126
+ "data-col": _col,
127
+ ...attrs
128
+ } = props as DataTableCellProps & { "data-col"?: unknown };
129
+ return { attrs, className, style };
130
+ }
131
+
132
+ /** Only the `data-*` attributes of a cell's props — what a phone card field takes. */
133
+ function dataAttrsOf(props: DataTableCellProps | undefined): Record<string, unknown> | undefined {
134
+ if (!props) return undefined;
135
+ const out: Record<string, unknown> = {};
136
+ for (const [k, v] of Object.entries(props)) if (k.startsWith("data-") && k !== "data-col") out[k] = v;
137
+ return out;
79
138
  }
80
139
 
81
140
  /** A column resize in flight. Held in a ref rather than in state: the live width is
@@ -1226,7 +1285,12 @@ export function DataTable<T>({
1226
1285
  mobileCard(row)
1227
1286
  ) : (
1228
1287
  <>
1229
- {mobilePrimaryCol && <div className="font-medium">{mobilePrimaryCol.cell(row)}</div>}
1288
+ {/* Only the `data-*` half of `cellProps` — see its note. */}
1289
+ {mobilePrimaryCol && (
1290
+ <div {...dataAttrsOf(mobilePrimaryCol.cellProps?.(row))} className="font-medium">
1291
+ {mobilePrimaryCol.cell(row)}
1292
+ </div>
1293
+ )}
1230
1294
  {mobileSecondaryColumns.length > 0 && (
1231
1295
  <dl
1232
1296
  className={cn(
@@ -1239,7 +1303,10 @@ export function DataTable<T>({
1239
1303
  <dt className="text-xs uppercase tracking-wide text-[var(--text-muted)] self-center">
1240
1304
  {col.header}
1241
1305
  </dt>
1242
- <dd className="min-w-0 text-[var(--text-secondary)] self-center">
1306
+ <dd
1307
+ {...dataAttrsOf(col.cellProps?.(row))}
1308
+ className="min-w-0 text-[var(--text-secondary)] self-center"
1309
+ >
1243
1310
  {col.cell(row)}
1244
1311
  </dd>
1245
1312
  </Fragment>
@@ -1526,8 +1593,11 @@ export function DataTable<T>({
1526
1593
  const headClass = logicalAlign(col.headClassName);
1527
1594
  const isEndAligned = !!headClass && END_ALIGN.test(headClass);
1528
1595
  const width = widths[col.key];
1596
+ const ownHead = splitCellProps(col.headProps);
1597
+ const pinnedHead = width ? { width, minWidth: width, maxWidth: width } : undefined;
1529
1598
  return (
1530
1599
  <th
1600
+ {...ownHead.attrs}
1531
1601
  key={col.key}
1532
1602
  ref={(el) => {
1533
1603
  if (el) headRefs.set(col.key, el);
@@ -1554,7 +1624,7 @@ export function DataTable<T>({
1554
1624
  : "none"
1555
1625
  : undefined
1556
1626
  }
1557
- style={width ? { width, minWidth: width, maxWidth: width } : undefined}
1627
+ style={ownHead.style || pinnedHead ? { ...ownHead.style, ...pinnedHead } : undefined}
1558
1628
  className={cn(
1559
1629
  "relative font-medium align-middle whitespace-nowrap",
1560
1630
  compact ? "px-2 py-1" : "px-3 py-2",
@@ -1562,6 +1632,7 @@ export function DataTable<T>({
1562
1632
  // Each <th> carries its own bg so the row doesn't render
1563
1633
  // transparent over the data rows underneath.
1564
1634
  "sticky top-0 z-10 bg-[var(--bg-surface-2)] backdrop-blur-sm",
1635
+ logicalAlign(ownHead.className),
1565
1636
  headClass,
1566
1637
  )}
1567
1638
  >
@@ -1795,15 +1866,20 @@ export function DataTable<T>({
1795
1866
  )}
1796
1867
  {visibleColumns.map((col) => {
1797
1868
  const width = widths[col.key];
1869
+ // The caller's first, the table's over it — see `cellProps`.
1870
+ const own = splitCellProps(col.cellProps?.(row));
1871
+ const pinned = width ? { width, minWidth: width, maxWidth: width } : undefined;
1798
1872
  return (
1799
1873
  <td
1874
+ {...own.attrs}
1800
1875
  key={col.key}
1801
1876
  data-col={col.key}
1802
- style={width ? { width, minWidth: width, maxWidth: width } : undefined}
1877
+ style={own.style || pinned ? { ...own.style, ...pinned } : undefined}
1803
1878
  className={cn(
1804
1879
  "align-top",
1805
1880
  compact ? "px-2 py-1" : "px-3 py-2",
1806
1881
  width && "overflow-hidden text-ellipsis",
1882
+ logicalAlign(own.className),
1807
1883
  logicalAlign(col.className),
1808
1884
  )}
1809
1885
  >