@eifi1/ui-kit 0.8.1 → 0.9.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 +4 -0
- package/dist/components/amount-input.d.ts +2 -0
- package/dist/components/calculator.d.ts +2 -0
- package/dist/components/chip.d.ts +27 -5
- package/dist/components/chip.js +6 -2
- package/dist/components/chip.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 +69 -3
- package/dist/components/date-picker.js +152 -65
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/disclosure.d.ts +11 -2
- package/dist/components/disclosure.js +10 -4
- package/dist/components/disclosure.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/number-field.d.ts +2 -0
- package/dist/components/number-input.d.ts +2 -0
- package/dist/components/numpad-sheet.d.ts +2 -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/ui.d.ts +37 -14
- package/dist/components/ui.js +28 -22
- 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-overlay-history.js +84 -4
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.d.ts +2 -0
- package/dist/i18n/defaults.js +2 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +3 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +2 -0
- package/dist/i18n/locales/de-CH.d.ts +2 -0
- package/dist/i18n/locales/de-informal.d.ts +2 -0
- package/dist/i18n/locales/de.d.ts +2 -0
- package/dist/i18n/locales/de.js +10 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +2 -0
- package/dist/i18n/locales/es.js +10 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +2 -0
- package/dist/i18n/locales/fr.js +10 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +2 -0
- package/dist/i18n/locales/hu.js +10 -0
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +2 -0
- package/dist/i18n/locales/it.js +10 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +2 -0
- package/dist/i18n/locales/zh.js +10 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/search/command-palette.d.ts +49 -1
- package/dist/search/command-palette.js +132 -29
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +141 -0
- package/dist/search/global-search.js +277 -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 +2 -0
- 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 +2 -1
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/package.json +12 -3
- package/src/components/chip.tsx +36 -6
- package/src/components/data-table.tsx +81 -5
- package/src/components/date-picker.tsx +328 -117
- package/src/components/disclosure.tsx +24 -8
- package/src/components/floating-panel.tsx +46 -2
- package/src/components/progress-bar.tsx +27 -3
- package/src/components/ui.tsx +88 -37
- package/src/hooks/use-overlay-history.ts +181 -4
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/kit-labels.tsx +2 -0
- package/src/i18n/locales/de.ts +10 -0
- package/src/i18n/locales/es.ts +10 -0
- package/src/i18n/locales/fr.ts +10 -0
- package/src/i18n/locales/hu.ts +10 -0
- package/src/i18n/locales/it.ts +10 -0
- package/src/i18n/locales/zh.ts +10 -0
- package/src/index.ts +4 -0
- package/src/search/command-palette.tsx +200 -27
- package/src/search/global-search.tsx +484 -0
- package/src/search/search-index.ts +295 -0
- package/src/search.ts +2 -0
- package/src/wizard/stepper-nav.tsx +11 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from "react";
|
|
3
4
|
import { Fragment as Fragment2, useEffect, useMemo, useRef, useState } from "react";
|
|
4
5
|
import { createPortal } from "react-dom";
|
|
5
6
|
import {
|
|
@@ -34,6 +35,23 @@ import { resolveDataTableLabels } from "./data-table-labels.js";
|
|
|
34
35
|
import { useKitLabelOverrides, useKitLocale } from "../i18n/kit-labels.js";
|
|
35
36
|
import { Tooltip } from "./tooltip.js";
|
|
36
37
|
import { dirOf, isRtl } from "../lib/direction.js";
|
|
38
|
+
function splitCellProps(props) {
|
|
39
|
+
if (!props) return { attrs: {} };
|
|
40
|
+
const {
|
|
41
|
+
className,
|
|
42
|
+
style,
|
|
43
|
+
role: _role,
|
|
44
|
+
"data-col": _col,
|
|
45
|
+
...attrs
|
|
46
|
+
} = props;
|
|
47
|
+
return { attrs, className, style };
|
|
48
|
+
}
|
|
49
|
+
function dataAttrsOf(props) {
|
|
50
|
+
if (!props) return void 0;
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const [k, v] of Object.entries(props)) if (k.startsWith("data-") && k !== "data-col") out[k] = v;
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
37
55
|
function physicalSwipe(actions, dir) {
|
|
38
56
|
const rtl = dir === "rtl";
|
|
39
57
|
return {
|
|
@@ -495,7 +513,7 @@ function DataTable({
|
|
|
495
513
|
);
|
|
496
514
|
const cardInner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
497
515
|
/* @__PURE__ */ jsx("div", { className: cn("flex min-w-0 flex-1 flex-col", compact ? "gap-1" : "gap-2"), children: mobileCard ? mobileCard(row) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
498
|
-
mobilePrimaryCol && /* @__PURE__ */ jsx("div", { className: "font-medium", children: mobilePrimaryCol.cell(row) }),
|
|
516
|
+
mobilePrimaryCol && /* @__PURE__ */ jsx("div", { ...dataAttrsOf(mobilePrimaryCol.cellProps?.(row)), className: "font-medium", children: mobilePrimaryCol.cell(row) }),
|
|
499
517
|
mobileSecondaryColumns.length > 0 && /* @__PURE__ */ jsx(
|
|
500
518
|
"dl",
|
|
501
519
|
{
|
|
@@ -505,7 +523,14 @@ function DataTable({
|
|
|
505
523
|
),
|
|
506
524
|
children: mobileSecondaryColumns.map((col) => /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
507
525
|
/* @__PURE__ */ jsx("dt", { className: "text-xs uppercase tracking-wide text-[var(--text-muted)] self-center", children: col.header }),
|
|
508
|
-
/* @__PURE__ */ jsx(
|
|
526
|
+
/* @__PURE__ */ jsx(
|
|
527
|
+
"dd",
|
|
528
|
+
{
|
|
529
|
+
...dataAttrsOf(col.cellProps?.(row)),
|
|
530
|
+
className: "min-w-0 text-[var(--text-secondary)] self-center",
|
|
531
|
+
children: col.cell(row)
|
|
532
|
+
}
|
|
533
|
+
)
|
|
509
534
|
] }, col.key))
|
|
510
535
|
}
|
|
511
536
|
)
|
|
@@ -729,16 +754,20 @@ function DataTable({
|
|
|
729
754
|
const headClass = logicalAlign(col.headClassName);
|
|
730
755
|
const isEndAligned = !!headClass && END_ALIGN.test(headClass);
|
|
731
756
|
const width = widths[col.key];
|
|
732
|
-
|
|
757
|
+
const ownHead = splitCellProps(col.headProps);
|
|
758
|
+
const pinnedHead = width ? { width, minWidth: width, maxWidth: width } : void 0;
|
|
759
|
+
return /* @__PURE__ */ createElement(
|
|
733
760
|
"th",
|
|
734
761
|
{
|
|
762
|
+
...ownHead.attrs,
|
|
763
|
+
key: col.key,
|
|
735
764
|
ref: (el) => {
|
|
736
765
|
if (el) headRefs.set(col.key, el);
|
|
737
766
|
else headRefs.delete(col.key);
|
|
738
767
|
},
|
|
739
768
|
scope: "col",
|
|
740
769
|
"aria-sort": sortable ? sortIdx === 0 ? sorts[0].dir === "asc" ? "ascending" : "descending" : "none" : void 0,
|
|
741
|
-
style:
|
|
770
|
+
style: ownHead.style || pinnedHead ? { ...ownHead.style, ...pinnedHead } : void 0,
|
|
742
771
|
className: cn(
|
|
743
772
|
"relative font-medium align-middle whitespace-nowrap",
|
|
744
773
|
compact ? "px-2 py-1" : "px-3 py-2",
|
|
@@ -746,93 +775,91 @@ function DataTable({
|
|
|
746
775
|
// Each <th> carries its own bg so the row doesn't render
|
|
747
776
|
// transparent over the data rows underneath.
|
|
748
777
|
"sticky top-0 z-10 bg-[var(--bg-surface-2)] backdrop-blur-sm",
|
|
778
|
+
logicalAlign(ownHead.className),
|
|
749
779
|
headClass
|
|
750
|
-
)
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
780
|
+
)
|
|
781
|
+
},
|
|
782
|
+
/* @__PURE__ */ jsxs(
|
|
783
|
+
"div",
|
|
784
|
+
{
|
|
785
|
+
className: cn(
|
|
786
|
+
"flex items-center gap-1",
|
|
787
|
+
isEndAligned && "flex-row-reverse"
|
|
788
|
+
),
|
|
789
|
+
children: [
|
|
790
|
+
/* @__PURE__ */ jsx(Tooltip, { label: sortable && multiSort ? labels.sortHint : void 0, portal: true, children: /* @__PURE__ */ jsxs(
|
|
791
|
+
"button",
|
|
792
|
+
{
|
|
793
|
+
type: "button",
|
|
794
|
+
onClick: (e) => sortable && toggleSort(col.key, e.shiftKey),
|
|
795
|
+
disabled: !sortable,
|
|
796
|
+
className: cn(
|
|
797
|
+
"flex items-center gap-1 text-start",
|
|
798
|
+
sortable && "hover:text-[var(--text-primary)]"
|
|
799
|
+
),
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ jsx("span", { children: col.header }),
|
|
802
|
+
sortable && /* @__PURE__ */ jsx(Icon, { className: cn("size-3", active ? "opacity-100" : "opacity-40") }),
|
|
803
|
+
active && sorts.length > 1 && /* @__PURE__ */ jsx("span", { className: "text-[9px] font-semibold leading-none text-brand", children: sortIdx + 1 })
|
|
804
|
+
]
|
|
805
|
+
}
|
|
806
|
+
) }),
|
|
807
|
+
filter && /* @__PURE__ */ jsx(
|
|
808
|
+
Popover,
|
|
809
|
+
{
|
|
810
|
+
width: filter.type === "date" ? 420 : void 0,
|
|
811
|
+
labels: { panel: labels.filter },
|
|
812
|
+
trigger: ({ toggle, ref }) => /* @__PURE__ */ jsx(
|
|
761
813
|
"button",
|
|
762
814
|
{
|
|
763
815
|
type: "button",
|
|
764
|
-
|
|
765
|
-
|
|
816
|
+
ref,
|
|
817
|
+
onClick: toggle,
|
|
818
|
+
"aria-label": labels.filter,
|
|
766
819
|
className: cn(
|
|
767
|
-
"
|
|
768
|
-
|
|
820
|
+
"rounded p-1 transition-colors",
|
|
821
|
+
filterActive ? "bg-[var(--brand-bg)] text-[var(--brand-muted)]" : "text-[var(--text-placeholder)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"
|
|
769
822
|
),
|
|
770
|
-
children:
|
|
771
|
-
/* @__PURE__ */ jsx("span", { children: col.header }),
|
|
772
|
-
sortable && /* @__PURE__ */ jsx(Icon, { className: cn("size-3", active ? "opacity-100" : "opacity-40") }),
|
|
773
|
-
active && sorts.length > 1 && /* @__PURE__ */ jsx("span", { className: "text-[9px] font-semibold leading-none text-brand", children: sortIdx + 1 })
|
|
774
|
-
]
|
|
823
|
+
children: /* @__PURE__ */ jsx(Filter, { className: "size-3" })
|
|
775
824
|
}
|
|
776
|
-
)
|
|
777
|
-
|
|
778
|
-
|
|
825
|
+
),
|
|
826
|
+
children: () => /* @__PURE__ */ jsx(
|
|
827
|
+
FilterPopover,
|
|
779
828
|
{
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
onClick: toggle,
|
|
788
|
-
"aria-label": labels.filter,
|
|
789
|
-
className: cn(
|
|
790
|
-
"rounded p-1 transition-colors",
|
|
791
|
-
filterActive ? "bg-[var(--brand-bg)] text-[var(--brand-muted)]" : "text-[var(--text-placeholder)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"
|
|
792
|
-
),
|
|
793
|
-
children: /* @__PURE__ */ jsx(Filter, { className: "size-3" })
|
|
794
|
-
}
|
|
795
|
-
),
|
|
796
|
-
children: () => /* @__PURE__ */ jsx(
|
|
797
|
-
FilterPopover,
|
|
798
|
-
{
|
|
799
|
-
column: col,
|
|
800
|
-
state: filterState ?? defaultFilterState(filter),
|
|
801
|
-
onChange: (next) => setFilterValue(col.key, next),
|
|
802
|
-
onClear: () => clearFilter(col.key),
|
|
803
|
-
selectOptions: selectOptionsByKey[col.key] ?? [],
|
|
804
|
-
labels,
|
|
805
|
-
locale
|
|
806
|
-
}
|
|
807
|
-
)
|
|
829
|
+
column: col,
|
|
830
|
+
state: filterState ?? defaultFilterState(filter),
|
|
831
|
+
onChange: (next) => setFilterValue(col.key, next),
|
|
832
|
+
onClear: () => clearFilter(col.key),
|
|
833
|
+
selectOptions: selectOptionsByKey[col.key] ?? [],
|
|
834
|
+
labels,
|
|
835
|
+
locale
|
|
808
836
|
}
|
|
809
837
|
)
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
)
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
col.key
|
|
838
|
+
}
|
|
839
|
+
)
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
),
|
|
843
|
+
resizable && /* @__PURE__ */ jsx(
|
|
844
|
+
"span",
|
|
845
|
+
{
|
|
846
|
+
role: "separator",
|
|
847
|
+
"aria-orientation": "vertical",
|
|
848
|
+
onPointerDown: (e) => startResize(e, col.key),
|
|
849
|
+
onPointerMove: moveResize,
|
|
850
|
+
onPointerUp: (e) => finishResize(e, true),
|
|
851
|
+
onPointerCancel: (e) => finishResize(e, false),
|
|
852
|
+
onDoubleClick: (e) => {
|
|
853
|
+
e.preventDefault();
|
|
854
|
+
setWidths((w) => {
|
|
855
|
+
const next = { ...w };
|
|
856
|
+
delete next[col.key];
|
|
857
|
+
return next;
|
|
858
|
+
});
|
|
859
|
+
},
|
|
860
|
+
className: "absolute end-0 top-0 z-10 h-full w-1.5 -translate-x-1/2 rtl:translate-x-1/2 cursor-col-resize select-none touch-none hover:bg-[var(--brand-bg-hover)]"
|
|
861
|
+
}
|
|
862
|
+
)
|
|
836
863
|
);
|
|
837
864
|
})
|
|
838
865
|
] }) }),
|
|
@@ -927,25 +954,29 @@ function DataTable({
|
|
|
927
954
|
),
|
|
928
955
|
visibleColumns.map((col) => {
|
|
929
956
|
const width = widths[col.key];
|
|
930
|
-
|
|
957
|
+
const own = splitCellProps(col.cellProps?.(row));
|
|
958
|
+
const pinned = width ? { width, minWidth: width, maxWidth: width } : void 0;
|
|
959
|
+
return /* @__PURE__ */ createElement(
|
|
931
960
|
"td",
|
|
932
961
|
{
|
|
962
|
+
...own.attrs,
|
|
963
|
+
key: col.key,
|
|
933
964
|
"data-col": col.key,
|
|
934
|
-
style:
|
|
965
|
+
style: own.style || pinned ? { ...own.style, ...pinned } : void 0,
|
|
935
966
|
className: cn(
|
|
936
967
|
"align-top",
|
|
937
968
|
compact ? "px-2 py-1" : "px-3 py-2",
|
|
938
969
|
width && "overflow-hidden text-ellipsis",
|
|
970
|
+
logicalAlign(own.className),
|
|
939
971
|
logicalAlign(col.className)
|
|
940
|
-
)
|
|
941
|
-
children: col === linkColumn && href ? (
|
|
942
|
-
// No `onActivate`: the click is left to bubble to the
|
|
943
|
-
// <tr> handler above, which already owns expand-vs-select.
|
|
944
|
-
// Calling it here as well would toggle the row twice.
|
|
945
|
-
/* @__PURE__ */ jsx(RowLink, { href, className: "block", "data-row-link": "", children: col.cell(row) })
|
|
946
|
-
) : col.cell(row)
|
|
972
|
+
)
|
|
947
973
|
},
|
|
948
|
-
col
|
|
974
|
+
col === linkColumn && href ? (
|
|
975
|
+
// No `onActivate`: the click is left to bubble to the
|
|
976
|
+
// <tr> handler above, which already owns expand-vs-select.
|
|
977
|
+
// Calling it here as well would toggle the row twice.
|
|
978
|
+
/* @__PURE__ */ jsx(RowLink, { href, className: "block", "data-row-link": "", children: col.cell(row) })
|
|
979
|
+
) : col.cell(row)
|
|
949
980
|
);
|
|
950
981
|
})
|
|
951
982
|
]
|