@acronis-platform/ui-react 0.56.1 → 0.57.1

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 (44) hide show
  1. package/dist/components/ui/avatar/avatar.js +7 -7
  2. package/dist/components/ui/avatar/avatar.js.map +1 -1
  3. package/dist/components/ui/bar-chart/bar-chart.js +104 -0
  4. package/dist/components/ui/bar-chart/bar-chart.js.map +1 -0
  5. package/dist/components/ui/chart/chart.js +49 -49
  6. package/dist/components/ui/chart/chart.js.map +1 -1
  7. package/dist/components/ui/checkbox/checkbox.js +1 -1
  8. package/dist/components/ui/checkbox/checkbox.js.map +1 -1
  9. package/dist/components/ui/chip/chip.js +28 -28
  10. package/dist/components/ui/chip/chip.js.map +1 -1
  11. package/dist/components/ui/data-table/data-table.js +223 -155
  12. package/dist/components/ui/data-table/data-table.js.map +1 -1
  13. package/dist/components/ui/input-text/input-text.js +8 -8
  14. package/dist/components/ui/input-text/input-text.js.map +1 -1
  15. package/dist/components/ui/link/link.js +16 -16
  16. package/dist/components/ui/link/link.js.map +1 -1
  17. package/dist/components/ui/page-header/page-header.js +159 -49
  18. package/dist/components/ui/page-header/page-header.js.map +1 -1
  19. package/dist/components/ui/search/search.js +6 -6
  20. package/dist/components/ui/search/search.js.map +1 -1
  21. package/dist/components/ui/table/table.js +32 -32
  22. package/dist/components/ui/table/table.js.map +1 -1
  23. package/dist/components/ui/toolbar/toolbar.js +214 -0
  24. package/dist/components/ui/toolbar/toolbar.js.map +1 -0
  25. package/dist/hooks/use-intersection-observer.js +26 -0
  26. package/dist/hooks/use-intersection-observer.js.map +1 -0
  27. package/dist/index.js +356 -343
  28. package/dist/index.js.map +1 -1
  29. package/dist/react.js +356 -343
  30. package/dist/react.js.map +1 -1
  31. package/dist/src/components/ui/bar-chart/bar-chart.d.ts +28 -0
  32. package/dist/src/components/ui/bar-chart/index.d.ts +1 -0
  33. package/dist/src/components/ui/data-table/data-table.d.ts +107 -4
  34. package/dist/src/components/ui/data-table/data-table.docs.d.ts +88 -4
  35. package/dist/src/components/ui/data-table/index.d.ts +1 -1
  36. package/dist/src/components/ui/page-header/index.d.ts +1 -1
  37. package/dist/src/components/ui/page-header/page-header.d.ts +9 -3
  38. package/dist/src/components/ui/toolbar/index.d.ts +1 -0
  39. package/dist/src/components/ui/toolbar/toolbar.d.ts +23 -0
  40. package/dist/src/hooks/index.d.ts +1 -0
  41. package/dist/src/hooks/use-intersection-observer.d.ts +26 -0
  42. package/dist/src/index.d.ts +2 -0
  43. package/dist/ui-react.css +1 -1
  44. package/package.json +3 -3
@@ -1,60 +1,60 @@
1
- import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
- import * as h from "react";
3
- import { TimesIcon as b } from "@acronis-platform/icons-react/stroke-mono";
4
- import { cva as m } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
5
- import { cn as f } from "../../../lib/utils.js";
6
- const g = m(
7
- "inline-flex h-[var(--ui-chips-container-height)] min-w-[var(--ui-chips-container-width-min)] items-center justify-center gap-[var(--ui-chips-container-gap)] rounded-[var(--ui-chips-border-radius)] border-[length:var(--ui-chips-border-width)] border-solid border-[var(--ui-chips-border-color-idle)] bg-[var(--ui-chips-container-color-idle)] px-[var(--ui-chips-container-padding-x)] text-sm leading-6 text-[var(--ui-chips-label-color)] hover:border-[var(--ui-chips-border-color-hover)] hover:bg-[var(--ui-chips-container-color-hover)] [&_svg]:size-[var(--ui-chips-icon-size)] [&_svg]:shrink-0 [&_svg]:text-[var(--ui-chips-icon-color)]",
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import * as d from "react";
3
+ import { TimesIcon as h } from "@acronis-platform/icons-react/stroke-mono";
4
+ import { cva as g } from "../../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js";
5
+ import { cn as m } from "../../../lib/utils.js";
6
+ const f = g(
7
+ "inline-flex h-[var(--ui-chip-global-box-height)] min-w-[var(--ui-chip-global-box-width-min)] items-center justify-center gap-[var(--ui-chip-global-box-gap)] rounded-[var(--ui-chip-global-border-radius)] border-[length:var(--ui-chip-global-border-width)] border-solid border-[var(--ui-chip-global-border-color-idle)] bg-[var(--ui-chip-global-box-color-idle)] px-[var(--ui-chip-global-box-padding-x)] text-sm leading-6 hover:border-[var(--ui-chip-global-border-color-hover)] hover:bg-[var(--ui-chip-global-box-color-hover)] [&_svg]:size-[var(--ui-chip-global-icon-size)] [&_svg]:shrink-0 [&_svg]:text-[var(--ui-chip-global-icon-color)]",
8
8
  {
9
9
  variants: {
10
10
  variant: {
11
- removable: "focus-within:outline-none focus-within:ring-[3px] focus-within:ring-[var(--ui-focus-primary)] active:border-[var(--ui-chips-border-color-active)] active:bg-[var(--ui-chips-container-color-active)]",
12
- selectable: "cursor-pointer focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ui-focus-primary)] data-[selected=true]:border-[var(--ui-chips-border-color-active)] data-[selected=true]:bg-[var(--ui-chips-container-color-active)]"
11
+ removable: "text-[var(--ui-chip-removable-label-color)] focus-within:outline-none focus-within:ring-[3px] focus-within:ring-[var(--ui-focus-primary)] active:border-[var(--ui-chip-global-border-color-active)] active:bg-[var(--ui-chip-global-box-color-active)]",
12
+ selectable: "cursor-pointer text-[var(--ui-chip-selectable-label-color)] focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ui-focus-primary)] data-[selected=true]:border-[var(--ui-chip-global-border-color-active)] data-[selected=true]:bg-[var(--ui-chip-global-box-color-active)]"
13
13
  }
14
14
  },
15
15
  defaultVariants: {
16
16
  variant: "removable"
17
17
  }
18
18
  }
19
- ), x = h.forwardRef(
19
+ ), x = d.forwardRef(
20
20
  ({
21
- className: t,
21
+ className: c,
22
22
  variant: i = "removable",
23
- icon: s,
23
+ icon: t,
24
24
  selected: a,
25
- onRemove: n,
26
- removeLabel: l = "Remove",
25
+ onRemove: b,
26
+ removeLabel: s = "Remove",
27
27
  children: u,
28
28
  onKeyDown: e,
29
- ...v
30
- }, p) => {
31
- const c = i === "selectable";
32
- return /* @__PURE__ */ d(
29
+ ...n
30
+ }, v) => {
31
+ const l = i === "selectable";
32
+ return /* @__PURE__ */ p(
33
33
  "div",
34
34
  {
35
- ref: p,
36
- className: f(g({ variant: i }), t),
35
+ ref: v,
36
+ className: m(f({ variant: i }), c),
37
37
  onKeyDown: (r) => {
38
- c && (r.key === "Enter" || r.key === " ") && (r.preventDefault(), r.currentTarget.click()), e == null || e(r);
38
+ l && (r.key === "Enter" || r.key === " ") && (r.preventDefault(), r.currentTarget.click()), e == null || e(r);
39
39
  },
40
- ...c ? {
40
+ ...l ? {
41
41
  role: "button",
42
42
  tabIndex: 0,
43
43
  "aria-pressed": !!a,
44
44
  "data-selected": a ? "true" : void 0
45
45
  } : {},
46
- ...v,
46
+ ...n,
47
47
  children: [
48
- s,
48
+ t,
49
49
  /* @__PURE__ */ o("span", { className: "min-w-0 truncate", children: u }),
50
50
  i === "removable" && /* @__PURE__ */ o(
51
51
  "button",
52
52
  {
53
53
  type: "button",
54
- "aria-label": l,
55
- onClick: n,
54
+ "aria-label": s,
55
+ onClick: b,
56
56
  className: "-me-1 flex shrink-0 items-center justify-center rounded-full outline-none focus-visible:outline-none",
57
- children: /* @__PURE__ */ o(b, {})
57
+ children: /* @__PURE__ */ o(h, {})
58
58
  }
59
59
  )
60
60
  ]
@@ -65,6 +65,6 @@ const g = m(
65
65
  x.displayName = "Chip";
66
66
  export {
67
67
  x as Chip,
68
- g as chipVariants
68
+ f as chipVariants
69
69
  };
70
70
  //# sourceMappingURL=chip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chip.js","sources":["../../../../src/components/ui/chip/chip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { TimesIcon } from '@acronis-platform/icons-react/stroke-mono';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\n\n// A compact, interactive label. `variant` mirrors the Figma \"Chip\" `type`:\n// `removable` carries a trailing × (remove) button; `selectable` toggles a\n// selected state. The container fill/border/label/icon all wire to the dedicated\n// `--ui-chips-*` tier from @acronis-platform/tokens-pd; geometry (height, gap,\n// padding, min-width, radius, border width, icon size) is tokenized too.\n// The Figma `state` enum (idle / hover / active / focused) maps to interaction\n// states, not props: `hover:` → the hover tokens, `:focus`/`focus-visible` → the\n// 3px `--ui-focus-primary` ring, and the `active` look is the pressed state for\n// `removable` (`active:`) and the selected state for `selectable`\n// (`data-[selected]`, driven by the `selected` prop).\nconst chipVariants = cva(\n \"inline-flex h-[var(--ui-chips-container-height)] min-w-[var(--ui-chips-container-width-min)] items-center justify-center gap-[var(--ui-chips-container-gap)] rounded-[var(--ui-chips-border-radius)] border-[length:var(--ui-chips-border-width)] border-solid border-[var(--ui-chips-border-color-idle)] bg-[var(--ui-chips-container-color-idle)] px-[var(--ui-chips-container-padding-x)] text-sm leading-6 text-[var(--ui-chips-label-color)] hover:border-[var(--ui-chips-border-color-hover)] hover:bg-[var(--ui-chips-container-color-hover)] [&_svg]:size-[var(--ui-chips-icon-size)] [&_svg]:shrink-0 [&_svg]:text-[var(--ui-chips-icon-color)]\",\n {\n variants: {\n variant: {\n removable:\n 'focus-within:outline-none focus-within:ring-[3px] focus-within:ring-[var(--ui-focus-primary)] active:border-[var(--ui-chips-border-color-active)] active:bg-[var(--ui-chips-container-color-active)]',\n selectable:\n 'cursor-pointer focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ui-focus-primary)] data-[selected=true]:border-[var(--ui-chips-border-color-active)] data-[selected=true]:bg-[var(--ui-chips-container-color-active)]',\n },\n },\n defaultVariants: {\n variant: 'removable',\n },\n }\n);\n\nexport interface ChipProps\n extends\n React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof chipVariants> {\n /** Optional leading icon, rendered at 16px before the label. */\n icon?: React.ReactNode;\n /**\n * `selectable` only — applies the selected (active) styling and exposes the\n * chip as a pressed toggle (`role=\"button\"` + `aria-pressed`).\n */\n selected?: boolean;\n /** `removable` only — called when the trailing remove (×) button is pressed. */\n onRemove?: () => void;\n /** Accessible label for the remove button (`removable`). */\n removeLabel?: string;\n}\n\nconst Chip = React.forwardRef<HTMLDivElement, ChipProps>(\n (\n {\n className,\n variant = 'removable',\n icon,\n selected,\n onRemove,\n removeLabel = 'Remove',\n children,\n onKeyDown,\n ...props\n },\n ref\n ) => {\n const selectable = variant === 'selectable';\n return (\n <div\n ref={ref}\n className={cn(chipVariants({ variant }), className)}\n onKeyDown={(event) => {\n // The selectable chip is a div with button semantics; mirror native\n // button activation so Enter/Space fire its click handler.\n if (selectable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n event.currentTarget.click();\n }\n onKeyDown?.(event);\n }}\n {...(selectable\n ? {\n role: 'button',\n tabIndex: 0,\n 'aria-pressed': Boolean(selected),\n 'data-selected': selected ? 'true' : undefined,\n }\n : {})}\n {...props}\n >\n {icon}\n <span className=\"min-w-0 truncate\">{children}</span>\n {variant === 'removable' && (\n <button\n type=\"button\"\n aria-label={removeLabel}\n onClick={onRemove}\n className=\"-me-1 flex shrink-0 items-center justify-center rounded-full outline-none focus-visible:outline-none\"\n >\n <TimesIcon />\n </button>\n )}\n </div>\n );\n }\n);\nChip.displayName = 'Chip';\n\nexport { Chip, chipVariants };\n"],"names":["chipVariants","cva","Chip","React","className","variant","icon","selected","onRemove","removeLabel","children","onKeyDown","props","ref","selectable","jsxs","cn","event","jsx","TimesIcon"],"mappings":";;;;;AAgBA,MAAMA,IAAeC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,WACE;AAAA,QACF,YACE;AAAA,MAAA;AAAA,IACJ;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ,GAmBMC,IAAOC,EAAM;AAAA,EACjB,CACE;AAAA,IACE,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAMC,IAAaT,MAAY;AAC/B,WACE,gBAAAU;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAF;AAAA,QACA,WAAWG,EAAGhB,EAAa,EAAE,SAAAK,EAAA,CAAS,GAAGD,CAAS;AAAA,QAClD,WAAW,CAACa,MAAU;AAGpB,UAAIH,MAAeG,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SACxDA,EAAM,eAAA,GACNA,EAAM,cAAc,MAAA,IAEtBN,KAAA,QAAAA,EAAYM;AAAA,QACd;AAAA,QACC,GAAIH,IACD;AAAA,UACE,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB,EAAQP;AAAA,UACxB,iBAAiBA,IAAW,SAAS;AAAA,QAAA,IAEvC,CAAA;AAAA,QACH,GAAGK;AAAA,QAEH,UAAA;AAAA,UAAAN;AAAA,UACD,gBAAAY,EAAC,QAAA,EAAK,WAAU,oBAAoB,UAAAR,EAAA,CAAS;AAAA,UAC5CL,MAAY,eACX,gBAAAa;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,cAAYT;AAAA,cACZ,SAASD;AAAA,cACT,WAAU;AAAA,cAEV,4BAACW,GAAA,CAAA,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACb;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACAjB,EAAK,cAAc;"}
1
+ {"version":3,"file":"chip.js","sources":["../../../../src/components/ui/chip/chip.tsx"],"sourcesContent":["import * as React from 'react';\nimport { TimesIcon } from '@acronis-platform/icons-react/stroke-mono';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\n\n// A compact, interactive label. `variant` mirrors the Figma \"Chip\" `type`:\n// `removable` carries a trailing × (remove) button; `selectable` toggles a\n// selected state. The container fill/border/label/icon all wire to the dedicated\n// `--ui-chip-*` tier from @acronis-platform/tokens-pd; geometry (height, gap,\n// padding, min-width, radius, border width, icon size) is tokenized too.\n// The Figma `state` enum (idle / hover / active / focused) maps to interaction\n// states, not props: `hover:` → the hover tokens, `:focus`/`focus-visible` → the\n// 3px `--ui-focus-primary` ring, and the `active` look is the pressed state for\n// `removable` (`active:`) and the selected state for `selectable`\n// (`data-[selected]`, driven by the `selected` prop).\nconst chipVariants = cva(\n \"inline-flex h-[var(--ui-chip-global-box-height)] min-w-[var(--ui-chip-global-box-width-min)] items-center justify-center gap-[var(--ui-chip-global-box-gap)] rounded-[var(--ui-chip-global-border-radius)] border-[length:var(--ui-chip-global-border-width)] border-solid border-[var(--ui-chip-global-border-color-idle)] bg-[var(--ui-chip-global-box-color-idle)] px-[var(--ui-chip-global-box-padding-x)] text-sm leading-6 hover:border-[var(--ui-chip-global-border-color-hover)] hover:bg-[var(--ui-chip-global-box-color-hover)] [&_svg]:size-[var(--ui-chip-global-icon-size)] [&_svg]:shrink-0 [&_svg]:text-[var(--ui-chip-global-icon-color)]\",\n {\n variants: {\n variant: {\n removable:\n 'text-[var(--ui-chip-removable-label-color)] focus-within:outline-none focus-within:ring-[3px] focus-within:ring-[var(--ui-focus-primary)] active:border-[var(--ui-chip-global-border-color-active)] active:bg-[var(--ui-chip-global-box-color-active)]',\n selectable:\n 'cursor-pointer text-[var(--ui-chip-selectable-label-color)] focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[var(--ui-focus-primary)] data-[selected=true]:border-[var(--ui-chip-global-border-color-active)] data-[selected=true]:bg-[var(--ui-chip-global-box-color-active)]',\n },\n },\n defaultVariants: {\n variant: 'removable',\n },\n }\n);\n\nexport interface ChipProps\n extends\n React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof chipVariants> {\n /** Optional leading icon, rendered at 16px before the label. */\n icon?: React.ReactNode;\n /**\n * `selectable` only — applies the selected (active) styling and exposes the\n * chip as a pressed toggle (`role=\"button\"` + `aria-pressed`).\n */\n selected?: boolean;\n /** `removable` only — called when the trailing remove (×) button is pressed. */\n onRemove?: () => void;\n /** Accessible label for the remove button (`removable`). */\n removeLabel?: string;\n}\n\nconst Chip = React.forwardRef<HTMLDivElement, ChipProps>(\n (\n {\n className,\n variant = 'removable',\n icon,\n selected,\n onRemove,\n removeLabel = 'Remove',\n children,\n onKeyDown,\n ...props\n },\n ref\n ) => {\n const selectable = variant === 'selectable';\n return (\n <div\n ref={ref}\n className={cn(chipVariants({ variant }), className)}\n onKeyDown={(event) => {\n // The selectable chip is a div with button semantics; mirror native\n // button activation so Enter/Space fire its click handler.\n if (selectable && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n event.currentTarget.click();\n }\n onKeyDown?.(event);\n }}\n {...(selectable\n ? {\n role: 'button',\n tabIndex: 0,\n 'aria-pressed': Boolean(selected),\n 'data-selected': selected ? 'true' : undefined,\n }\n : {})}\n {...props}\n >\n {icon}\n <span className=\"min-w-0 truncate\">{children}</span>\n {variant === 'removable' && (\n <button\n type=\"button\"\n aria-label={removeLabel}\n onClick={onRemove}\n className=\"-me-1 flex shrink-0 items-center justify-center rounded-full outline-none focus-visible:outline-none\"\n >\n <TimesIcon />\n </button>\n )}\n </div>\n );\n }\n);\nChip.displayName = 'Chip';\n\nexport { Chip, chipVariants };\n"],"names":["chipVariants","cva","Chip","React","className","variant","icon","selected","onRemove","removeLabel","children","onKeyDown","props","ref","selectable","jsxs","cn","event","jsx","TimesIcon"],"mappings":";;;;;AAgBA,MAAMA,IAAeC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,WACE;AAAA,QACF,YACE;AAAA,MAAA;AAAA,IACJ;AAAA,IAEF,iBAAiB;AAAA,MACf,SAAS;AAAA,IAAA;AAAA,EACX;AAEJ,GAmBMC,IAAOC,EAAM;AAAA,EACjB,CACE;AAAA,IACE,WAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC,IAAc;AAAA,IACd,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,GAAGC;AAAA,EAAA,GAELC,MACG;AACH,UAAMC,IAAaT,MAAY;AAC/B,WACE,gBAAAU;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAF;AAAA,QACA,WAAWG,EAAGhB,EAAa,EAAE,SAAAK,EAAA,CAAS,GAAGD,CAAS;AAAA,QAClD,WAAW,CAACa,MAAU;AAGpB,UAAIH,MAAeG,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SACxDA,EAAM,eAAA,GACNA,EAAM,cAAc,MAAA,IAEtBN,KAAA,QAAAA,EAAYM;AAAA,QACd;AAAA,QACC,GAAIH,IACD;AAAA,UACE,MAAM;AAAA,UACN,UAAU;AAAA,UACV,gBAAgB,EAAQP;AAAA,UACxB,iBAAiBA,IAAW,SAAS;AAAA,QAAA,IAEvC,CAAA;AAAA,QACH,GAAGK;AAAA,QAEH,UAAA;AAAA,UAAAN;AAAA,UACD,gBAAAY,EAAC,QAAA,EAAK,WAAU,oBAAoB,UAAAR,EAAA,CAAS;AAAA,UAC5CL,MAAY,eACX,gBAAAa;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,cAAYT;AAAA,cACZ,SAASD;AAAA,cACT,WAAU;AAAA,cAEV,4BAACW,GAAA,CAAA,CAAU;AAAA,YAAA;AAAA,UAAA;AAAA,QACb;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AACAjB,EAAK,cAAc;"}
@@ -1,130 +1,151 @@
1
- import { jsx as n, jsxs as M } from "react/jsx-runtime";
2
- import { useState as u, useEffect as ee, Fragment as oe } from "react";
3
- import { useReactTable as te, flexRender as z } from "../../../node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@19.2.6_react@19.2.6__react@19.2.6/node_modules/@tanstack/react-table/build/lib/index.js";
4
- import { cn as b } from "../../../lib/utils.js";
5
- import { Table as le, TableHeader as ne, TableRow as f, TableHead as ie, TableBody as re, TableCell as S } from "../table/table.js";
6
- import { getFilteredRowModel as ae, getSortedRowModel as ce, getPaginationRowModel as se, getExpandedRowModel as de, getCoreRowModel as ue } from "../../../node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.js";
7
- function N(t) {
8
- const l = t.getIsPinned();
1
+ import { jsx as n, jsxs as y } from "react/jsx-runtime";
2
+ import { useState as m, useEffect as ve, Fragment as K } from "react";
3
+ import { useReactTable as Se, flexRender as k } from "../../../node_modules/.pnpm/@tanstack_react-table@8.21.3_react-dom@19.2.6_react@19.2.6__react@19.2.6/node_modules/@tanstack/react-table/build/lib/index.js";
4
+ import { cn as h } from "../../../lib/utils.js";
5
+ import { useIntersectionObserver as ye } from "../../../hooks/use-intersection-observer.js";
6
+ import { Table as we, TableHeader as Re, TableRow as u, TableHead as xe, TableBody as ze, TableCell as g } from "../table/table.js";
7
+ import { getFilteredRowModel as Ne, getSortedRowModel as Ce, getPaginationRowModel as De, getExpandedRowModel as Ie, getCoreRowModel as Me } from "../../../node_modules/.pnpm/@tanstack_table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.js";
8
+ function U(o) {
9
+ const l = o.getIsPinned();
9
10
  if (l)
10
11
  return {
11
12
  position: "sticky",
12
- left: l === "left" ? t.getStart("left") : void 0,
13
- right: l === "right" ? t.getAfter("right") : void 0,
13
+ left: l === "left" ? o.getStart("left") : void 0,
14
+ right: l === "right" ? o.getAfter("right") : void 0,
14
15
  zIndex: 1,
15
16
  // Derived from the same border token every other table divider uses (not a
16
17
  // hardcoded color), so the separator theme-adapts automatically.
17
- boxShadow: l === "left" ? "4px 0 4px -4px var(--ui-table-global-cell-border-color)" : "-4px 0 4px -4px var(--ui-table-global-cell-border-color)"
18
+ boxShadow: l === "left" ? "4px 0 4px -4px var(--ui-table-global-row-border-color)" : "-4px 0 4px -4px var(--ui-table-global-row-border-color)"
18
19
  };
19
20
  }
20
- function I(t, l) {
21
- if (l || t.columnDef.size !== void 0)
22
- return t.getSize();
21
+ function B(o, l) {
22
+ if (l || o.columnDef.size !== void 0)
23
+ return o.getSize();
23
24
  }
24
- function me(t, l) {
25
- const a = N(t.column), i = I(t.column, l);
26
- if (!(!a && i === void 0))
27
- return { ...a, width: i };
25
+ function Ee(o, l) {
26
+ const i = U(o.column), s = B(o.column, l);
27
+ if (!(!i && s === void 0))
28
+ return { ...i, width: s };
28
29
  }
29
- function ge(t, l) {
30
- const a = N(t.column), i = I(t.column, l);
31
- if (!(!a && i === void 0))
32
- return { ...a, width: i };
30
+ function _e(o, l) {
31
+ const i = U(o.column), s = B(o.column, l);
32
+ if (!(!i && s === void 0))
33
+ return { ...i, width: s };
33
34
  }
34
- const D = 20, C = Number.MAX_SAFE_INTEGER;
35
- function be(t, l, { shiftKey: a, min: i, max: m }) {
36
- const p = a ? 50 : 10;
37
- if (t === "ArrowLeft") return Math.min(m, Math.max(i, l - p));
38
- if (t === "ArrowRight") return Math.max(i, Math.min(m, l + p));
35
+ const L = 20, H = Number.MAX_SAFE_INTEGER;
36
+ function Fe(o, l, { shiftKey: i, min: s, max: b }) {
37
+ const p = i ? 50 : 10;
38
+ if (o === "ArrowLeft")
39
+ return Math.min(b, Math.max(s, l - p));
40
+ if (o === "ArrowRight")
41
+ return Math.max(s, Math.min(b, l + p));
39
42
  }
40
- function xe({
41
- columns: t,
42
- data: l,
43
- getRowCanExpand: a,
44
- renderExpandedRow: i,
45
- striped: m = !1,
46
- bordered: p = !1,
47
- highlightCurrentRow: y = !1,
48
- skeleton: E = !1,
49
- skeletonRows: T = 5,
50
- enableColumnResizing: g = !1,
43
+ function He({
44
+ columns: o = [],
45
+ data: l = [],
46
+ table: i,
47
+ getRowCanExpand: s,
48
+ renderExpandedRow: b,
49
+ striped: p = !1,
50
+ bordered: O = !1,
51
+ highlightCurrentRow: w = !1,
52
+ skeleton: R = !1,
53
+ skeletonRows: j = 5,
54
+ enableColumnResizing: I = !1,
51
55
  onColumnSizingChange: x,
52
- columnVisibility: _,
53
- onColumnVisibilityChange: w
56
+ columnVisibility: X,
57
+ onColumnVisibilityChange: z,
58
+ manualSorting: M = !1,
59
+ sorting: E,
60
+ onSortingChange: N,
61
+ renderRow: _,
62
+ renderEmptyState: F,
63
+ paginationMode: A = "page",
64
+ onLoadMore: C,
65
+ loadMoreRootMargin: Z,
66
+ hasNextPage: T = !1,
67
+ isLoadingMore: P = !1
54
68
  }) {
55
- const [A, P] = u([]), [F, k] = u([]), [K, L] = u({}), H = _ ?? K, [V, U] = u({}), [B, j] = u({}), [O, X] = u({}), [Z, G] = u(), W = (e) => {
56
- X(e), x == null || x(e);
57
- }, $ = (e) => {
58
- L(e), w == null || w(e);
59
- }, d = te({
69
+ const [G, W] = m([]), $ = E ?? G, [q, J] = m([]), [Q, Y] = m({}), ee = X ?? Q, [te, ne] = m({}), [oe, le] = m({}), [ie, re] = m({}), [ae, se] = m(), ce = (e) => {
70
+ re(e), x == null || x(e);
71
+ }, de = (e) => {
72
+ Y(e), z == null || z(e);
73
+ }, ue = (e) => {
74
+ E === void 0 && W(e), N == null || N(e);
75
+ }, me = Se({
60
76
  data: l,
61
- columns: t,
62
- enableColumnResizing: g,
77
+ columns: o,
78
+ enableColumnResizing: I,
63
79
  columnResizeMode: "onChange",
64
- getCoreRowModel: ue(),
65
- getExpandedRowModel: de(),
66
- getPaginationRowModel: se(),
67
- getRowCanExpand: a,
68
- onExpandedChange: j,
69
- onSortingChange: P,
70
- getSortedRowModel: ce(),
71
- onColumnFiltersChange: k,
72
- getFilteredRowModel: ae(),
73
- onColumnVisibilityChange: $,
74
- onRowSelectionChange: U,
75
- onColumnSizingChange: W,
80
+ getCoreRowModel: Me(),
81
+ getExpandedRowModel: Ie(),
82
+ ...A === "page" ? { getPaginationRowModel: De() } : {},
83
+ getRowCanExpand: s,
84
+ onExpandedChange: le,
85
+ manualSorting: M,
86
+ onSortingChange: ue,
87
+ ...M ? {} : { getSortedRowModel: Ce() },
88
+ onColumnFiltersChange: J,
89
+ getFilteredRowModel: Ne(),
90
+ onColumnVisibilityChange: de,
91
+ onRowSelectionChange: ne,
92
+ onColumnSizingChange: ce,
76
93
  state: {
77
- sorting: A,
78
- columnFilters: F,
79
- columnVisibility: H,
80
- rowSelection: V,
81
- expanded: B,
82
- columnSizing: O
94
+ sorting: $,
95
+ columnFilters: q,
96
+ columnVisibility: ee,
97
+ rowSelection: te,
98
+ expanded: oe,
99
+ columnSizing: ie
83
100
  }
84
- }), q = (e, o) => {
101
+ }), r = i ?? me, D = !i && A === "infinite", v = I && !i, ge = ye({
102
+ onIntersect: () => C == null ? void 0 : C(),
103
+ disabled: !D || !T || P,
104
+ rootMargin: Z
105
+ }), fe = (e, t) => {
85
106
  if (e.ctrlKey || e.altKey || e.metaKey) return;
86
- const r = be(e.key, o.column.getSize(), {
107
+ const a = Fe(e.key, t.column.getSize(), {
87
108
  shiftKey: e.shiftKey,
88
- min: o.column.columnDef.minSize ?? D,
89
- max: o.column.columnDef.maxSize ?? C
109
+ min: t.column.columnDef.minSize ?? L,
110
+ max: t.column.columnDef.maxSize ?? H
90
111
  });
91
- r !== void 0 && (e.preventDefault(), d.setColumnSizing((c) => ({ ...c, [o.column.id]: r })));
112
+ a !== void 0 && (e.preventDefault(), r.setColumnSizing((c) => ({ ...c, [t.column.id]: a })));
92
113
  };
93
- ee(() => {
94
- d.getAllLeafColumns().forEach((e) => {
95
- var o;
96
- e.pin(((o = e.columnDef.meta) == null ? void 0 : o.pin) ?? !1);
114
+ ve(() => {
115
+ i || r.getAllLeafColumns().forEach((e) => {
116
+ var t;
117
+ e.pin(((t = e.columnDef.meta) == null ? void 0 : t.pin) ?? !1);
97
118
  });
98
- }, [d, t]);
99
- const v = d.getRowModel().rows, J = p ? "[&_th:not(:last-child)]:border-e [&_td:not(:last-child)]:border-e [&_th]:border-[var(--ui-table-global-cell-border-color)] [&_td]:border-[var(--ui-table-global-cell-border-color)]" : void 0, Q = "bg-background";
119
+ }, [r, o, i]);
120
+ const f = r.getRowModel().rows, be = O ? "[&_th:not(:last-child)]:border-e [&_td:not(:last-child)]:border-e [&_th]:border-[var(--ui-table-global-row-border-color)] [&_td]:border-[var(--ui-table-global-row-border-color)]" : void 0, pe = "bg-background";
100
121
  return /* @__PURE__ */ n(
101
122
  "div",
102
123
  {
103
- className: b(
104
- "rounded-md border border-[var(--ui-table-global-cell-border-color)]",
105
- J
124
+ className: h(
125
+ "rounded-md border border-[var(--ui-table-global-row-border-color)]",
126
+ be
106
127
  ),
107
- children: /* @__PURE__ */ M(
108
- le,
128
+ children: /* @__PURE__ */ y(
129
+ we,
109
130
  {
110
- style: g ? { width: d.getCenterTotalSize() } : void 0,
131
+ style: v ? { width: r.getCenterTotalSize() } : void 0,
111
132
  children: [
112
- /* @__PURE__ */ n(ne, { children: d.getHeaderGroups().map((e) => /* @__PURE__ */ n(f, { children: e.headers.map((o) => {
113
- var h;
114
- const r = o.column.getIsPinned(), c = g && o.column.getCanResize();
115
- return /* @__PURE__ */ M(
116
- ie,
133
+ /* @__PURE__ */ n(Re, { children: r.getHeaderGroups().map((e) => /* @__PURE__ */ n(u, { children: e.headers.map((t) => {
134
+ var S;
135
+ const a = t.column.getIsPinned(), c = v && t.column.getCanResize();
136
+ return /* @__PURE__ */ y(
137
+ xe,
117
138
  {
118
- wrap: (h = o.column.columnDef.meta) == null ? void 0 : h.wrap,
119
- style: me(o, g),
120
- className: b(
139
+ wrap: (S = t.column.columnDef.meta) == null ? void 0 : S.wrap,
140
+ style: Ee(t, v),
141
+ className: h(
121
142
  c && "relative",
122
- r && Q
143
+ a && pe
123
144
  ),
124
145
  children: [
125
- o.isPlaceholder ? null : z(
126
- o.column.columnDef.header,
127
- o.getContext()
146
+ t.isPlaceholder ? null : k(
147
+ t.column.columnDef.header,
148
+ t.getContext()
128
149
  ),
129
150
  c && /* @__PURE__ */ n(
130
151
  "div",
@@ -132,73 +153,117 @@ function xe({
132
153
  role: "separator",
133
154
  "aria-orientation": "vertical",
134
155
  "aria-label": "Resize column",
135
- "aria-valuenow": o.column.getSize(),
136
- "aria-valuemin": o.column.columnDef.minSize ?? D,
137
- "aria-valuemax": o.column.columnDef.maxSize ?? C,
156
+ "aria-valuenow": t.column.getSize(),
157
+ "aria-valuemin": t.column.columnDef.minSize ?? L,
158
+ "aria-valuemax": t.column.columnDef.maxSize ?? H,
138
159
  tabIndex: 0,
139
- onMouseDown: o.getResizeHandler(),
140
- onTouchStart: o.getResizeHandler(),
141
- onKeyDown: (s) => q(s, o),
142
- className: b(
143
- "absolute end-0 top-0 h-full w-1 cursor-(--ui-resizable-cursor) touch-none select-none bg-[var(--ui-table-global-cell-border-color)] opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-(--ui-focus-primary)",
144
- o.column.getIsResizing() && "opacity-100"
160
+ onMouseDown: t.getResizeHandler(),
161
+ onTouchStart: t.getResizeHandler(),
162
+ onKeyDown: (d) => fe(d, t),
163
+ className: h(
164
+ "absolute end-0 top-0 h-full w-1 cursor-(--ui-resizable-cursor) touch-none select-none bg-[var(--ui-table-global-row-border-color)] opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-(--ui-focus-primary)",
165
+ t.column.getIsResizing() && "opacity-100"
145
166
  )
146
167
  }
147
168
  )
148
169
  ]
149
170
  },
150
- o.id
171
+ t.id
151
172
  );
152
173
  }) }, e.id)) }),
153
- /* @__PURE__ */ n(re, { children: E ? Array.from({ length: T }).map((e, o) => /* @__PURE__ */ n(f, { className: "hover:bg-transparent", children: d.getVisibleLeafColumns().map((r) => /* @__PURE__ */ n(S, { children: /* @__PURE__ */ n("div", { className: "h-4 w-full animate-pulse rounded bg-[var(--ui-background-surface-secondary)]" }) }, r.id)) }, `skeleton-${o}`)) : v != null && v.length ? v.map((e, o) => {
154
- const r = e.getIsSelected(), c = y && Z === e.id, h = r || c ? "bg-[var(--ui-table-global-row-color-active)]" : m && o % 2 === 1 ? "bg-[var(--ui-background-surface-secondary)]" : "bg-background";
155
- return /* @__PURE__ */ M(oe, { children: [
156
- /* @__PURE__ */ n(
157
- f,
158
- {
159
- selected: r,
160
- onClick: y ? () => G(e.id) : void 0,
161
- className: b(
162
- y && "cursor-pointer",
163
- m && o % 2 === 1 && !r && !c && "bg-[var(--ui-background-surface-secondary)]",
164
- c && !r && "bg-[var(--ui-table-global-row-color-active)]"
165
- ),
166
- children: e.getVisibleCells().map((s) => {
167
- var R;
168
- const Y = s.column.getIsPinned();
169
- return /* @__PURE__ */ n(
170
- S,
171
- {
172
- wrap: (R = s.column.columnDef.meta) == null ? void 0 : R.wrap,
173
- style: ge(s, g),
174
- className: b(Y && h),
175
- children: z(
176
- s.column.columnDef.cell,
177
- s.getContext()
178
- )
179
- },
180
- s.id
181
- );
182
- })
183
- }
184
- ),
185
- i && e.getIsExpanded() && /* @__PURE__ */ n(f, { className: "hover:bg-transparent", children: /* @__PURE__ */ n(
186
- S,
187
- {
188
- className: "h-auto py-3",
189
- colSpan: e.getVisibleCells().length,
190
- children: i(e)
191
- }
192
- ) })
193
- ] }, e.id);
194
- }) : /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
195
- S,
196
- {
197
- colSpan: t.length,
198
- className: "h-24 text-center text-[var(--ui-table-data-value-color-disabled)]",
199
- children: "No results."
200
- }
201
- ) }) })
174
+ /* @__PURE__ */ y(ze, { children: [
175
+ R ? Array.from({ length: j }).map((e, t) => /* @__PURE__ */ n(
176
+ u,
177
+ {
178
+ className: "hover:bg-transparent",
179
+ children: r.getVisibleLeafColumns().map((a) => /* @__PURE__ */ n(g, { children: /* @__PURE__ */ n("div", { className: "h-4 w-full animate-pulse rounded bg-[var(--ui-background-surface-secondary)]" }) }, a.id))
180
+ },
181
+ `skeleton-${t}`
182
+ )) : f != null && f.length ? f.map((e, t) => {
183
+ if (_)
184
+ return /* @__PURE__ */ n(K, { children: _(e, t) }, e.id);
185
+ const a = e.getIsSelected(), c = w && ae === e.id, S = a || c ? "bg-[var(--ui-table-data-row-color-active)]" : p && t % 2 === 1 ? "bg-[var(--ui-background-surface-secondary)]" : "bg-background";
186
+ return /* @__PURE__ */ y(K, { children: [
187
+ /* @__PURE__ */ n(
188
+ u,
189
+ {
190
+ selected: a,
191
+ onClick: w ? () => se(e.id) : void 0,
192
+ className: h(
193
+ w && "cursor-pointer",
194
+ p && t % 2 === 1 && !a && !c && "bg-[var(--ui-background-surface-secondary)]",
195
+ c && !a && "bg-[var(--ui-table-data-row-color-active)]"
196
+ ),
197
+ children: e.getVisibleCells().map((d) => {
198
+ var V;
199
+ const he = d.column.getIsPinned();
200
+ return /* @__PURE__ */ n(
201
+ g,
202
+ {
203
+ wrap: (V = d.column.columnDef.meta) == null ? void 0 : V.wrap,
204
+ style: _e(d, v),
205
+ className: h(he && S),
206
+ children: k(
207
+ d.column.columnDef.cell,
208
+ d.getContext()
209
+ )
210
+ },
211
+ d.id
212
+ );
213
+ })
214
+ }
215
+ ),
216
+ b && e.getIsExpanded() && /* @__PURE__ */ n(u, { className: "hover:bg-transparent", children: /* @__PURE__ */ n(
217
+ g,
218
+ {
219
+ className: "h-auto py-3",
220
+ colSpan: e.getVisibleCells().length,
221
+ children: b(e)
222
+ }
223
+ ) })
224
+ ] }, e.id);
225
+ }) : F ? /* @__PURE__ */ n(u, { children: /* @__PURE__ */ n(
226
+ g,
227
+ {
228
+ colSpan: r.getVisibleLeafColumns().length,
229
+ className: "h-24 text-center",
230
+ children: F({
231
+ hasFilters: r.getState().columnFilters.length > 0
232
+ })
233
+ }
234
+ ) }) : /* @__PURE__ */ n(u, { children: /* @__PURE__ */ n(
235
+ g,
236
+ {
237
+ colSpan: r.getVisibleLeafColumns().length,
238
+ className: "h-24 text-center text-[var(--ui-table-data-value-color-disabled)]",
239
+ children: "No results."
240
+ }
241
+ ) }),
242
+ D && !R && f.length > 0 && T && /* @__PURE__ */ n(
243
+ u,
244
+ {
245
+ ref: ge,
246
+ "aria-hidden": !0,
247
+ className: "hover:bg-transparent",
248
+ children: /* @__PURE__ */ n(
249
+ g,
250
+ {
251
+ colSpan: r.getVisibleLeafColumns().length,
252
+ className: "h-1 p-0"
253
+ }
254
+ )
255
+ }
256
+ ),
257
+ D && !R && f.length > 0 && P && /* @__PURE__ */ n(u, { className: "hover:bg-transparent", children: /* @__PURE__ */ n(g, { colSpan: r.getVisibleLeafColumns().length, children: /* @__PURE__ */ n(
258
+ "div",
259
+ {
260
+ role: "status",
261
+ "aria-live": "polite",
262
+ className: "h-4 w-full animate-pulse rounded bg-[var(--ui-background-surface-secondary)]",
263
+ children: /* @__PURE__ */ n("span", { className: "sr-only", children: "Loading more rows…" })
264
+ }
265
+ ) }) })
266
+ ] })
202
267
  ]
203
268
  }
204
269
  )
@@ -206,7 +271,10 @@ function xe({
206
271
  );
207
272
  }
208
273
  export {
209
- xe as DataTable,
210
- be as getResizeKeyboardStep
274
+ He as DataTable,
275
+ _e as getCellStyle,
276
+ B as getColumnWidth,
277
+ U as getPinnedStyle,
278
+ Fe as getResizeKeyboardStep
211
279
  };
212
280
  //# sourceMappingURL=data-table.js.map