@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.
- package/README.md +25 -11
- package/dist/components/alert-banner.d.ts +32 -5
- package/dist/components/alert-banner.js +57 -14
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/breadcrumbs.d.ts +60 -0
- package/dist/components/breadcrumbs.js +88 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bulk-action-bar.d.ts +66 -0
- package/dist/components/bulk-action-bar.js +149 -0
- package/dist/components/bulk-action-bar.js.map +1 -0
- package/dist/components/calculator.d.ts +6 -0
- package/dist/components/chip.d.ts +58 -10
- package/dist/components/chip.js +91 -7
- package/dist/components/chip.js.map +1 -1
- package/dist/components/copy-button.d.ts +13 -4
- package/dist/components/copy-button.js +17 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +122 -91
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +89 -3
- package/dist/components/date-picker.js +163 -68
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +43 -6
- package/dist/components/description-list.js +91 -11
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +7 -0
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +68 -4
- package/dist/components/disclosure.js +33 -15
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +3 -4
- package/dist/components/file-dropzone.js +2 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.d.ts +29 -2
- package/dist/components/floating-panel.js +16 -2
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +23 -4
- package/dist/components/full-bleed-dialog.js +11 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/list.d.ts +174 -0
- package/dist/components/list.js +215 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu-item.d.ts +99 -0
- package/dist/components/menu-item.js +83 -0
- package/dist/components/menu-item.js.map +1 -0
- package/dist/components/modal.d.ts +23 -1
- package/dist/components/modal.js +36 -10
- package/dist/components/modal.js.map +1 -1
- package/dist/components/number-field.d.ts +6 -0
- package/dist/components/number-input.d.ts +6 -0
- package/dist/components/numpad-sheet.d.ts +6 -0
- package/dist/components/page-contents.js +1 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.d.ts +37 -0
- package/dist/components/page-header.js +36 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/progress-bar.d.ts +16 -2
- package/dist/components/progress-bar.js +4 -2
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +3 -0
- package/dist/components/series-chart-labels.js +2 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +16 -0
- package/dist/components/series-chart.js +137 -3
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/status-dot.d.ts +49 -0
- package/dist/components/status-dot.js +52 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/table.d.ts +39 -6
- package/dist/components/table.js +43 -4
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +63 -0
- package/dist/components/text.js +23 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/toast.d.ts +167 -0
- package/dist/components/toast.js +226 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +29 -1
- package/dist/components/toggle-group.js +52 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +38 -15
- package/dist/components/tooltip.js +85 -47
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +139 -16
- package/dist/components/ui.js +136 -26
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/{data-table-filters-CF1PXqjQ.d.ts → data-table-filters-Dh9uF_S-.d.ts} +33 -2
- package/dist/data-table.d.ts +1 -1
- package/dist/hooks/use-close-transition.d.ts +7 -1
- package/dist/hooks/use-close-transition.js +5 -2
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +84 -4
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.d.ts +6 -0
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +11 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
- package/dist/i18n/locales/de-CH.d.ts +6 -0
- package/dist/i18n/locales/de-informal.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.js +31 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.js +31 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.js +31 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.js +31 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.js +31 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +6 -0
- package/dist/i18n/locales/zh.js +31 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +9 -0
- package/dist/lib/clipping.js +14 -0
- package/dist/lib/clipping.js.map +1 -0
- package/dist/search/command-palette.d.ts +67 -2
- package/dist/search/command-palette.js +147 -33
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +166 -0
- package/dist/search/global-search.js +293 -0
- package/dist/search/global-search.js.map +1 -0
- package/dist/search/search-index.d.ts +105 -0
- package/dist/search/search-index.js +142 -0
- package/dist/search/search-index.js.map +1 -0
- package/dist/search.d.ts +3 -1
- package/dist/search.js +2 -0
- package/dist/search.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +10 -1
- package/dist/wizard/stepper-nav.js +3 -2
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +2 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +1 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-summary.js +3 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +25 -12
- package/src/components/alert-banner.tsx +117 -18
- package/src/components/breadcrumbs.tsx +168 -0
- package/src/components/bulk-action-bar.tsx +256 -0
- package/src/components/chip.tsx +164 -13
- package/src/components/copy-button.tsx +29 -7
- package/src/components/data-table.tsx +81 -5
- package/src/components/date-picker.tsx +377 -118
- package/src/components/description-list.tsx +168 -15
- package/src/components/dialog-frame.tsx +7 -0
- package/src/components/disclosure.tsx +116 -28
- package/src/components/file-dropzone.tsx +9 -10
- package/src/components/floating-panel.tsx +46 -2
- package/src/components/full-bleed-dialog.tsx +42 -5
- package/src/components/list.tsx +417 -0
- package/src/components/menu-item.tsx +214 -0
- package/src/components/modal.tsx +80 -17
- package/src/components/page-contents.tsx +4 -4
- package/src/components/page-header.tsx +68 -0
- package/src/components/progress-bar.tsx +27 -3
- package/src/components/series-chart-labels.ts +4 -0
- package/src/components/series-chart.tsx +253 -3
- package/src/components/status-dot.tsx +99 -0
- package/src/components/table.tsx +91 -6
- package/src/components/text.tsx +89 -0
- package/src/components/toast.tsx +441 -0
- package/src/components/toggle-group.tsx +82 -3
- package/src/components/tooltip.tsx +186 -100
- package/src/components/ui.tsx +321 -41
- package/src/hooks/use-close-transition.ts +14 -5
- package/src/hooks/use-copy-to-clipboard.ts +1 -1
- package/src/hooks/use-overlay-history.ts +181 -4
- package/src/i18n/defaults.ts +10 -0
- package/src/i18n/kit-labels.tsx +10 -0
- package/src/i18n/locales/de.ts +30 -0
- package/src/i18n/locales/es.ts +30 -0
- package/src/i18n/locales/fr.ts +30 -0
- package/src/i18n/locales/hu.ts +30 -0
- package/src/i18n/locales/it.ts +30 -0
- package/src/i18n/locales/zh.ts +30 -0
- package/src/index.ts +30 -0
- package/src/lib/clipping.ts +16 -0
- package/src/search/command-palette.tsx +241 -31
- package/src/search/global-search.tsx +525 -0
- package/src/search/search-index.ts +295 -0
- package/src/search.ts +2 -0
- package/src/wizard/stepper-nav.tsx +13 -2
- package/src/wizard/types.ts +2 -2
- package/src/wizard/use-wizard.ts +3 -3
- package/src/wizard/wizard-summary.tsx +14 -10
- 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
|
-
{
|
|
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
|
|
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={
|
|
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={
|
|
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
|
>
|