@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.
Files changed (101) hide show
  1. package/README.md +4 -0
  2. package/dist/components/amount-input.d.ts +2 -0
  3. package/dist/components/calculator.d.ts +2 -0
  4. package/dist/components/chip.d.ts +27 -5
  5. package/dist/components/chip.js +6 -2
  6. package/dist/components/chip.js.map +1 -1
  7. package/dist/components/data-table-filter-popover.d.ts +1 -1
  8. package/dist/components/data-table-filters.d.ts +1 -1
  9. package/dist/components/data-table.d.ts +1 -1
  10. package/dist/components/data-table.js +122 -91
  11. package/dist/components/data-table.js.map +1 -1
  12. package/dist/components/date-picker.d.ts +69 -3
  13. package/dist/components/date-picker.js +152 -65
  14. package/dist/components/date-picker.js.map +1 -1
  15. package/dist/components/disclosure.d.ts +11 -2
  16. package/dist/components/disclosure.js +10 -4
  17. package/dist/components/disclosure.js.map +1 -1
  18. package/dist/components/floating-panel.d.ts +29 -2
  19. package/dist/components/floating-panel.js +16 -2
  20. package/dist/components/floating-panel.js.map +1 -1
  21. package/dist/components/number-field.d.ts +2 -0
  22. package/dist/components/number-input.d.ts +2 -0
  23. package/dist/components/numpad-sheet.d.ts +2 -0
  24. package/dist/components/progress-bar.d.ts +16 -2
  25. package/dist/components/progress-bar.js +4 -2
  26. package/dist/components/progress-bar.js.map +1 -1
  27. package/dist/components/ui.d.ts +37 -14
  28. package/dist/components/ui.js +28 -22
  29. package/dist/components/ui.js.map +1 -1
  30. package/dist/components/use-table-state.d.ts +1 -1
  31. package/dist/{data-table-filters-CF1PXqjQ.d.ts → data-table-filters-Dh9uF_S-.d.ts} +33 -2
  32. package/dist/data-table.d.ts +1 -1
  33. package/dist/hooks/use-overlay-history.js +84 -4
  34. package/dist/hooks/use-overlay-history.js.map +1 -1
  35. package/dist/i18n/defaults.d.ts +2 -0
  36. package/dist/i18n/defaults.js +2 -0
  37. package/dist/i18n/defaults.js.map +1 -1
  38. package/dist/i18n/kit-labels.d.ts +3 -0
  39. package/dist/i18n/kit-labels.js.map +1 -1
  40. package/dist/i18n/locales/de-CH-informal.d.ts +2 -0
  41. package/dist/i18n/locales/de-CH.d.ts +2 -0
  42. package/dist/i18n/locales/de-informal.d.ts +2 -0
  43. package/dist/i18n/locales/de.d.ts +2 -0
  44. package/dist/i18n/locales/de.js +10 -0
  45. package/dist/i18n/locales/de.js.map +1 -1
  46. package/dist/i18n/locales/es.d.ts +2 -0
  47. package/dist/i18n/locales/es.js +10 -0
  48. package/dist/i18n/locales/es.js.map +1 -1
  49. package/dist/i18n/locales/fr.d.ts +2 -0
  50. package/dist/i18n/locales/fr.js +10 -0
  51. package/dist/i18n/locales/fr.js.map +1 -1
  52. package/dist/i18n/locales/hu.d.ts +2 -0
  53. package/dist/i18n/locales/hu.js +10 -0
  54. package/dist/i18n/locales/hu.js.map +1 -1
  55. package/dist/i18n/locales/it.d.ts +2 -0
  56. package/dist/i18n/locales/it.js +10 -0
  57. package/dist/i18n/locales/it.js.map +1 -1
  58. package/dist/i18n/locales/zh.d.ts +2 -0
  59. package/dist/i18n/locales/zh.js +10 -0
  60. package/dist/i18n/locales/zh.js.map +1 -1
  61. package/dist/index.d.ts +5 -3
  62. package/dist/index.js +2 -0
  63. package/dist/index.js.map +1 -1
  64. package/dist/search/command-palette.d.ts +49 -1
  65. package/dist/search/command-palette.js +132 -29
  66. package/dist/search/command-palette.js.map +1 -1
  67. package/dist/search/global-search.d.ts +141 -0
  68. package/dist/search/global-search.js +277 -0
  69. package/dist/search/global-search.js.map +1 -0
  70. package/dist/search/search-index.d.ts +105 -0
  71. package/dist/search/search-index.js +142 -0
  72. package/dist/search/search-index.js.map +1 -0
  73. package/dist/search.d.ts +2 -0
  74. package/dist/search.js +2 -0
  75. package/dist/search.js.map +1 -1
  76. package/dist/wizard/stepper-nav.d.ts +10 -1
  77. package/dist/wizard/stepper-nav.js +2 -1
  78. package/dist/wizard/stepper-nav.js.map +1 -1
  79. package/package.json +12 -3
  80. package/src/components/chip.tsx +36 -6
  81. package/src/components/data-table.tsx +81 -5
  82. package/src/components/date-picker.tsx +328 -117
  83. package/src/components/disclosure.tsx +24 -8
  84. package/src/components/floating-panel.tsx +46 -2
  85. package/src/components/progress-bar.tsx +27 -3
  86. package/src/components/ui.tsx +88 -37
  87. package/src/hooks/use-overlay-history.ts +181 -4
  88. package/src/i18n/defaults.ts +2 -0
  89. package/src/i18n/kit-labels.tsx +2 -0
  90. package/src/i18n/locales/de.ts +10 -0
  91. package/src/i18n/locales/es.ts +10 -0
  92. package/src/i18n/locales/fr.ts +10 -0
  93. package/src/i18n/locales/hu.ts +10 -0
  94. package/src/i18n/locales/it.ts +10 -0
  95. package/src/i18n/locales/zh.ts +10 -0
  96. package/src/index.ts +4 -0
  97. package/src/search/command-palette.tsx +200 -27
  98. package/src/search/global-search.tsx +484 -0
  99. package/src/search/search-index.ts +295 -0
  100. package/src/search.ts +2 -0
  101. 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("dd", { className: "min-w-0 text-[var(--text-secondary)] self-center", children: col.cell(row) })
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
- return /* @__PURE__ */ jsxs(
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: width ? { width, minWidth: width, maxWidth: width } : void 0,
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
- children: [
752
- /* @__PURE__ */ jsxs(
753
- "div",
754
- {
755
- className: cn(
756
- "flex items-center gap-1",
757
- isEndAligned && "flex-row-reverse"
758
- ),
759
- children: [
760
- /* @__PURE__ */ jsx(Tooltip, { label: sortable && multiSort ? labels.sortHint : void 0, portal: true, children: /* @__PURE__ */ jsxs(
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
- onClick: (e) => sortable && toggleSort(col.key, e.shiftKey),
765
- disabled: !sortable,
816
+ ref,
817
+ onClick: toggle,
818
+ "aria-label": labels.filter,
766
819
  className: cn(
767
- "flex items-center gap-1 text-start",
768
- sortable && "hover:text-[var(--text-primary)]"
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
- filter && /* @__PURE__ */ jsx(
778
- Popover,
825
+ ),
826
+ children: () => /* @__PURE__ */ jsx(
827
+ FilterPopover,
779
828
  {
780
- width: filter.type === "date" ? 420 : void 0,
781
- labels: { panel: labels.filter },
782
- trigger: ({ toggle, ref }) => /* @__PURE__ */ jsx(
783
- "button",
784
- {
785
- type: "button",
786
- ref,
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
- resizable && /* @__PURE__ */ jsx(
814
- "span",
815
- {
816
- role: "separator",
817
- "aria-orientation": "vertical",
818
- onPointerDown: (e) => startResize(e, col.key),
819
- onPointerMove: moveResize,
820
- onPointerUp: (e) => finishResize(e, true),
821
- onPointerCancel: (e) => finishResize(e, false),
822
- onDoubleClick: (e) => {
823
- e.preventDefault();
824
- setWidths((w) => {
825
- const next = { ...w };
826
- delete next[col.key];
827
- return next;
828
- });
829
- },
830
- 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)]"
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
- return /* @__PURE__ */ jsx(
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: width ? { width, minWidth: width, maxWidth: width } : void 0,
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.key
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
  ]