@datavac/ui-kit 1.8.0-data-table.1 → 1.8.0-data-table.2

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.
@@ -32,6 +32,11 @@ export interface DataTableColumn<T = Record<string, unknown>> {
32
32
  * В планшетных и мобильных карточках колонка скрывается.
33
33
  */
34
34
  desktopOnly?: boolean;
35
+ /**
36
+ * На мобайле (< 480px) колонка занимает половину ширины.
37
+ * Соседние `mobileHalf`-колонки группируются в одну строку.
38
+ */
39
+ mobileHalf?: boolean;
35
40
  }
36
41
  export interface DataTableProps<T = Record<string, unknown>> {
37
42
  columns: DataTableColumn<T>[];
package/dist/index.js CHANGED
@@ -8967,18 +8967,27 @@ function Gm(e, t) {
8967
8967
  return n;
8968
8968
  }
8969
8969
  function Km(e) {
8970
+ let t = [], n = 0;
8971
+ for (; n < e.length;) if (e[n].mobileHalf) {
8972
+ let r = [];
8973
+ for (; n < e.length && e[n].mobileHalf;) r.push(e[n]), n++;
8974
+ t.push(r);
8975
+ } else t.push([e[n]]), n++;
8976
+ return t;
8977
+ }
8978
+ function qm(e) {
8970
8979
  return {
8971
8980
  width: e.width == null ? void 0 : typeof e.width == "number" ? `${e.width}px` : e.width,
8972
8981
  flex: e.flex,
8973
8982
  minWidth: 0
8974
8983
  };
8975
8984
  }
8976
- function qm(e, t, n) {
8985
+ function Jm(e, t, n) {
8977
8986
  if (e.render) return e.render(t, n);
8978
8987
  let r = t[e.key];
8979
8988
  return r == null ? "" : typeof r == "string" ? r : JSON.stringify(r);
8980
8989
  }
8981
- function Jm({ row: e, index: t, columns: n, isDisabled: r = !1, hasAction: i = !1, mobileActionLabel: a = "Подробнее", mobileDisabledLabel: o = "Нет сведений", tabletColumns: s = 3, desktopBreakpoint: c = "md", onClick: l }) {
8990
+ function Ym({ row: e, index: t, columns: n, isDisabled: r = !1, hasAction: i = !1, mobileActionLabel: a = "Подробнее", mobileDisabledLabel: o = "Нет сведений", tabletColumns: s = 3, desktopBreakpoint: c = "md", onClick: l }) {
8982
8991
  let u = !!l && !r, d = u ? {
8983
8992
  role: "button",
8984
8993
  tabIndex: 0,
@@ -8988,33 +8997,33 @@ function Jm({ row: e, index: t, columns: n, isDisabled: r = !1, hasAction: i = !
8988
8997
  onKeyDown: (e) => {
8989
8998
  u && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), l());
8990
8999
  }
8991
- } : {}, h = K("bg-card rounded-xl transition-colors", r ? "text-fg-muted" : "text-fg", !r && u ? "cursor-pointer hover:brightness-[0.97]" : ""), g = r ? "py-[11px]" : "py-4", _ = n.filter((e) => !e.desktopOnly), v = Gm(_, s), { desktop: y, tablet: b } = Wm[c], x = i && /* @__PURE__ */ p("div", {
9000
+ } : {}, h = K("bg-card rounded-xl transition-colors", r ? "text-fg-muted" : "text-fg", !r && u ? "cursor-pointer hover:brightness-[0.97]" : ""), g = r ? "py-[11px]" : "py-4", _ = n.filter((e) => !e.desktopOnly), v = Gm(_, s), y = Km(_), { desktop: b, tablet: x } = Wm[c], S = i && /* @__PURE__ */ p("div", {
8992
9001
  className: "shrink-0 flex items-center justify-center size-5 rounded-full bg-subtle",
8993
9002
  children: r ? /* @__PURE__ */ p(Is, {
8994
9003
  width: 12,
8995
9004
  height: 12,
8996
9005
  className: "text-fg-muted"
8997
9006
  }) : /* @__PURE__ */ p(ws, { className: "text-fg" })
8998
- }), S = i && /* @__PURE__ */ p("span", {
9007
+ }), C = i && /* @__PURE__ */ p("span", {
8999
9008
  className: "shrink-0 px-2 py-0.5 bg-subtle rounded-full text-xs text-neutral whitespace-nowrap",
9000
9009
  children: r ? o : a
9001
9010
  });
9002
9011
  return /* @__PURE__ */ m(f, { children: [
9003
9012
  /* @__PURE__ */ m("div", {
9004
- className: K(y, "items-center px-3 gap-5", g, h),
9013
+ className: K(b, "items-center px-3 gap-5", g, h),
9005
9014
  "aria-disabled": r || void 0,
9006
9015
  ...d,
9007
9016
  children: [n.map((n) => /* @__PURE__ */ p("div", {
9008
9017
  className: "shrink-0 text-base overflow-hidden text-ellipsis",
9009
- style: Km(n),
9010
- children: qm(n, e, t)
9018
+ style: qm(n),
9019
+ children: Jm(n, e, t)
9011
9020
  }, n.key)), i && /* @__PURE__ */ p("div", {
9012
9021
  className: "ml-auto",
9013
- children: x
9022
+ children: S
9014
9023
  })]
9015
9024
  }),
9016
9025
  /* @__PURE__ */ m("div", {
9017
- className: K(b, "items-start gap-[10px] p-3", h),
9026
+ className: K(x, "items-start gap-[10px] p-3", h),
9018
9027
  "aria-disabled": r || void 0,
9019
9028
  ...d,
9020
9029
  children: [/* @__PURE__ */ p("div", {
@@ -9028,35 +9037,38 @@ function Jm({ row: e, index: t, columns: n, isDisabled: r = !1, hasAction: i = !
9028
9037
  children: n.label
9029
9038
  }), /* @__PURE__ */ p("div", {
9030
9039
  className: "text-sm",
9031
- children: qm(n, e, t)
9040
+ children: Jm(n, e, t)
9032
9041
  })]
9033
9042
  }, n.key))
9034
9043
  }, r))
9035
- }), x]
9044
+ }), S]
9036
9045
  }),
9037
9046
  /* @__PURE__ */ p("div", {
9038
9047
  className: K("min-[480px]:hidden flex flex-col gap-[10px] px-3 py-4", h),
9039
9048
  "aria-disabled": r || void 0,
9040
9049
  ...d,
9041
- children: _.map((n, r) => /* @__PURE__ */ m("div", {
9042
- className: "flex flex-col gap-1",
9043
- children: [/* @__PURE__ */ m("div", {
9044
- className: "flex items-center justify-between gap-2",
9045
- children: [/* @__PURE__ */ p("span", {
9046
- className: "text-xs text-fg-secondary",
9047
- children: n.label
9048
- }), r === 0 && S]
9049
- }), /* @__PURE__ */ p("div", {
9050
- className: "text-sm",
9051
- children: qm(n, e, t)
9052
- })]
9053
- }, n.key))
9050
+ children: y.map((n, r) => /* @__PURE__ */ p("div", {
9051
+ className: "flex gap-3 w-full",
9052
+ children: n.map((n, i) => /* @__PURE__ */ m("div", {
9053
+ className: "flex-1 flex flex-col gap-1 min-w-0",
9054
+ children: [/* @__PURE__ */ m("div", {
9055
+ className: "flex items-center justify-between gap-2",
9056
+ children: [/* @__PURE__ */ p("span", {
9057
+ className: "text-xs text-fg-secondary",
9058
+ children: n.label
9059
+ }), r === 0 && i === 0 && C]
9060
+ }), /* @__PURE__ */ p("div", {
9061
+ className: "text-sm",
9062
+ children: Jm(n, e, t)
9063
+ })]
9064
+ }, n.key))
9065
+ }, n[0].key))
9054
9066
  })
9055
9067
  ] });
9056
9068
  }
9057
9069
  //#endregion
9058
9070
  //#region src/components/DataTable/DataTable.tsx
9059
- var Ym = {
9071
+ var Xm = {
9060
9072
  md: {
9061
9073
  show: "hidden md:flex",
9062
9074
  hide: "md:hidden"
@@ -9066,7 +9078,7 @@ var Ym = {
9066
9078
  hide: "lg:hidden"
9067
9079
  }
9068
9080
  };
9069
- function Xm({ columns: e, rows: t, isRowDisabled: n, onRowClick: r, getRowKey: i, sortField: a, sortDirection: o = "asc", onSortChange: s, mobileActionLabel: c = "Подробнее", mobileDisabledLabel: l = "Нет сведений", tabletColumns: u = 3, desktopBreakpoint: d = "md", className: f }) {
9081
+ function Zm({ columns: e, rows: t, isRowDisabled: n, onRowClick: r, getRowKey: i, sortField: a, sortDirection: o = "asc", onSortChange: s, mobileActionLabel: c = "Подробнее", mobileDisabledLabel: l = "Нет сведений", tabletColumns: u = 3, desktopBreakpoint: d = "md", className: f }) {
9070
9082
  let h = e.filter((e) => e.sortable), g = h.length > 0 && !!s, _ = h.flatMap((e) => [{
9071
9083
  value: `${e.key}::asc`,
9072
9084
  label: `По ${e.label} А – Я`
@@ -9076,7 +9088,7 @@ function Xm({ columns: e, rows: t, isRowDisabled: n, onRowClick: r, getRowKey: i
9076
9088
  }]), v = a && o ? `${a}::${o}` : _[0]?.value ?? "", y = (e) => {
9077
9089
  let t = e.lastIndexOf("::");
9078
9090
  t === -1 || !s || s(e.slice(0, t), e.slice(t + 2));
9079
- }, b = !!r, { show: x, hide: S } = Ym[d];
9091
+ }, b = !!r, { show: x, hide: S } = Xm[d];
9080
9092
  return /* @__PURE__ */ m("div", {
9081
9093
  className: K("flex flex-col gap-3", f),
9082
9094
  children: [
@@ -9139,7 +9151,7 @@ function Xm({ columns: e, rows: t, isRowDisabled: n, onRowClick: r, getRowKey: i
9139
9151
  }),
9140
9152
  /* @__PURE__ */ p("div", {
9141
9153
  className: "flex flex-col gap-1",
9142
- children: t.map((t, a) => /* @__PURE__ */ p(Jm, {
9154
+ children: t.map((t, a) => /* @__PURE__ */ p(Ym, {
9143
9155
  row: t,
9144
9156
  index: a,
9145
9157
  columns: e,
@@ -9156,4 +9168,4 @@ function Xm({ columns: e, rows: t, isRowDisabled: n, onRowClick: r, getRowKey: i
9156
9168
  });
9157
9169
  }
9158
9170
  //#endregion
9159
- export { Gd as Accordion, Kd as AccordionItem, Jf as AdministrationIcon, bs as ArrowDownArrowUpIcon, xs as ArrowDownToBracketIcon, Cs as ArrowIcon, Ss as ArrowUpRightFromSquareIcon, ws as ArrowsIcon, bt as Badge, Ts as BottleIcon, yt as Button, nt as Caption, Jd as Card, Es as ChevronDownIcon, xt as Chip, Ds as CircleAttentionIcon, Os as CircleMinusIcon, ks as CirclePlusIcon, As as CircleXmarkIcon, js as CopyIcon, St as Counter, Xm as DataTable, Ms as DnaIcon, Bu as Drawer, Yd as EmptyState, Xd as ErrorState, Ns as FileArrowDownIcon, $e as Heading, Ps as InfoCircleIcon, Ct as Input, tt as Label, Fs as MenuIcon, Is as MinusIcon, Ls as MoonStarsIcon, Rs as PlusIcon, Xs as SearchBar, ys as SearchDropdown, zs as SearchIcon, Bs as SearchListIcon, Hm as Select, _s as Skeleton, Um as SortControl, gs as Spinner, Hs as SunIcon, Vs as SunMiniIcon, Xf as Switch, Rf as Tabs, dp as TagFilter, Us as TestTubeIcon, et as Text, sp as ThemeProvider, lp as ThemeToggle, Ws as ThermometerIcon, Uc as Tooltip, Gs as VirusIcon, qs as XmarkIcon, Ks as XmarkLargeIcon, K as cn, Qf as darkTheme, Zf as defaultTheme, ep as themes, np as tokensToCssVars, cp as useTheme };
9171
+ export { Gd as Accordion, Kd as AccordionItem, Jf as AdministrationIcon, bs as ArrowDownArrowUpIcon, xs as ArrowDownToBracketIcon, Cs as ArrowIcon, Ss as ArrowUpRightFromSquareIcon, ws as ArrowsIcon, bt as Badge, Ts as BottleIcon, yt as Button, nt as Caption, Jd as Card, Es as ChevronDownIcon, xt as Chip, Ds as CircleAttentionIcon, Os as CircleMinusIcon, ks as CirclePlusIcon, As as CircleXmarkIcon, js as CopyIcon, St as Counter, Zm as DataTable, Ms as DnaIcon, Bu as Drawer, Yd as EmptyState, Xd as ErrorState, Ns as FileArrowDownIcon, $e as Heading, Ps as InfoCircleIcon, Ct as Input, tt as Label, Fs as MenuIcon, Is as MinusIcon, Ls as MoonStarsIcon, Rs as PlusIcon, Xs as SearchBar, ys as SearchDropdown, zs as SearchIcon, Bs as SearchListIcon, Hm as Select, _s as Skeleton, Um as SortControl, gs as Spinner, Hs as SunIcon, Vs as SunMiniIcon, Xf as Switch, Rf as Tabs, dp as TagFilter, Us as TestTubeIcon, et as Text, sp as ThemeProvider, lp as ThemeToggle, Ws as ThermometerIcon, Uc as Tooltip, Gs as VirusIcon, qs as XmarkIcon, Ks as XmarkLargeIcon, K as cn, Qf as darkTheme, Zf as defaultTheme, ep as themes, np as tokensToCssVars, cp as useTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datavac/ui-kit",
3
- "version": "1.8.0-data-table.1",
3
+ "version": "1.8.0-data-table.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",