@ztwoint/z-ui 0.1.46 → 0.1.49

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 (136) hide show
  1. package/dist/components/alert/alert.const.d.ts +0 -3
  2. package/dist/components/alert/alert.const.js +16 -31
  3. package/dist/components/alert/alert.js +32 -44
  4. package/dist/components/assets/icons/check.d.ts +8 -0
  5. package/dist/components/assets/icons/check.js +17 -0
  6. package/dist/components/assets/icons/x-mark.d.ts +8 -0
  7. package/dist/components/assets/icons/x-mark.js +17 -0
  8. package/dist/components/button/button.d.ts +3 -3
  9. package/dist/components/button/button.js +58 -58
  10. package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.js +17 -17
  11. package/dist/components/nav-header/nav-item/nav-item.d.ts +4 -2
  12. package/dist/components/nav-header/nav-item/nav-item.js +29 -28
  13. package/dist/components/select/z2-select.js +131 -78
  14. package/dist/components/table/components/cell/avatar-cell.d.ts +15 -0
  15. package/dist/components/table/components/cell/avatar-cell.js +74 -0
  16. package/dist/components/table/components/cell/boolean-cell.d.ts +1 -2
  17. package/dist/components/table/components/cell/boolean-cell.js +5 -5
  18. package/dist/components/table/components/cell/description-cell.d.ts +7 -0
  19. package/dist/components/table/components/cell/description-cell.js +16 -0
  20. package/dist/components/table/components/cell/index.d.ts +10 -1
  21. package/dist/components/table/components/cell/label-cell.d.ts +10 -0
  22. package/dist/components/table/components/cell/label-cell.js +47 -0
  23. package/dist/components/table/components/cell/link-cell.d.ts +10 -0
  24. package/dist/components/table/components/cell/link-cell.js +35 -0
  25. package/dist/components/table/components/cell/number-cell.d.ts +5 -3
  26. package/dist/components/table/components/cell/number-cell.js +40 -3
  27. package/dist/components/table/components/index.d.ts +1 -1
  28. package/dist/components/table/components/table-cell.d.ts +1 -1
  29. package/dist/components/table/components/table-cell.js +41 -32
  30. package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.d.ts +10 -0
  31. package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.js +33 -0
  32. package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.d.ts +13 -0
  33. package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.js +20 -0
  34. package/dist/components/table/components/table-filter/filters/boolean.js +52 -44
  35. package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.js +16 -16
  36. package/dist/components/table/components/table-filter/table-filter-button.js +88 -57
  37. package/dist/components/table/components/table-filter/table-filter-column-button.js +81 -51
  38. package/dist/components/table/components/table-filter/table-filter.context.d.ts +1 -0
  39. package/dist/components/table/components/table-filter/table-filter.hook.d.ts +1 -0
  40. package/dist/components/table/components/table-filter/table-filter.hook.js +17 -14
  41. package/dist/components/table/components/table-footer.js +6 -6
  42. package/dist/components/table/components/table-header/stories/basic-header.d.ts +1 -1
  43. package/dist/components/table/components/table-header/table-header.js +27 -33
  44. package/dist/components/table/index.d.ts +1 -1
  45. package/dist/components/table/table-provider.js +37 -8
  46. package/dist/components/table/table.const.d.ts +15 -9
  47. package/dist/components/table/table.const.js +15 -9
  48. package/dist/components/table/table.js +39 -34
  49. package/dist/components/table/table.type.d.ts +36 -5
  50. package/dist/components/table/table.utils.d.ts +1 -1
  51. package/dist/components/table/table.utils.js +5 -3
  52. package/dist/components/table-card/table-card.js +116 -89
  53. package/dist/components/tooltip/tooltip.js +24 -22
  54. package/dist/css/config/colors/backgrounds.css +8 -8
  55. package/dist/css/config/colors/components/avatar.css +12 -12
  56. package/dist/css/config/colors/components/badge.css +42 -42
  57. package/dist/css/config/colors/components/checkbox.css +2 -2
  58. package/dist/css/config/colors/components/featured-icon.css +18 -18
  59. package/dist/css/config/colors/components/progress-bar.css +2 -2
  60. package/dist/css/config/colors/components/radio-button.css +2 -2
  61. package/dist/css/config/colors/components/scroll-overlay.css +4 -4
  62. package/dist/css/config/colors/components/tab.css +7 -7
  63. package/dist/css/config/colors/components/toggle-switch.css +1 -1
  64. package/dist/css/config/colors/components/toggle.css +6 -6
  65. package/dist/css/config/colors/icons.css +20 -20
  66. package/dist/css/config/colors/overlay.css +1 -1
  67. package/dist/css/config/colors/semantic/alert.css +44 -0
  68. package/dist/css/config/colors/semantic/background.css +51 -0
  69. package/dist/css/config/colors/semantic/base.css +395 -0
  70. package/dist/css/config/colors/semantic/button.css +131 -0
  71. package/dist/css/config/colors/semantic/drop-shadow.css +30 -0
  72. package/dist/css/config/colors/semantic/dropdown.css +12 -0
  73. package/dist/css/config/colors/semantic/index.css +16 -0
  74. package/dist/css/config/colors/semantic/input.css +56 -0
  75. package/dist/css/config/colors/semantic/overlay.css +13 -0
  76. package/dist/css/config/colors/semantic/stroke.css +90 -0
  77. package/dist/css/config/colors/semantic/surface.css +135 -0
  78. package/dist/css/config/colors/semantic/text.css +113 -0
  79. package/dist/css/config/colors/semantic/tooltip.css +12 -0
  80. package/dist/css/config/colors/shape.css +40 -40
  81. package/dist/css/config/colors/stroke.css +19 -19
  82. package/dist/css/config/colors/surfaces.css +47 -47
  83. package/dist/css/config/colors/text.css +37 -37
  84. package/dist/css/config/components/index.css +0 -2
  85. package/dist/css/config/config-deprecated.css +3 -5
  86. package/dist/css/config/config.css +5 -3
  87. package/dist/css/config/other-variables.css +9 -0
  88. package/dist/css/config/shadows.css +15 -0
  89. package/dist/css/config/typography/2xl.css +7 -14
  90. package/dist/css/config/typography/3xl.css +7 -14
  91. package/dist/css/config/typography/4xl.css +7 -14
  92. package/dist/css/config/typography/base.css +7 -14
  93. package/dist/css/config/typography/lg.css +7 -14
  94. package/dist/css/config/typography/sm.css +7 -14
  95. package/dist/css/config/typography/xl.css +7 -14
  96. package/dist/css/config/typography/xs.css +7 -14
  97. package/dist/css/styles/tailwind.css +1 -1
  98. package/dist/index.js +62 -64
  99. package/dist/types/components/alert/alert.const.d.ts +0 -3
  100. package/dist/types/components/assets/icons/check.d.ts +8 -0
  101. package/dist/types/components/assets/icons/x-mark.d.ts +8 -0
  102. package/dist/types/components/button/button.d.ts +3 -3
  103. package/dist/types/components/nav-header/nav-item/nav-item.d.ts +4 -2
  104. package/dist/types/components/table/components/cell/avatar-cell.d.ts +15 -0
  105. package/dist/types/components/table/components/cell/boolean-cell.d.ts +1 -2
  106. package/dist/types/components/table/components/cell/description-cell.d.ts +7 -0
  107. package/dist/types/components/table/components/cell/index.d.ts +10 -1
  108. package/dist/types/components/table/components/cell/label-cell.d.ts +10 -0
  109. package/dist/types/components/table/components/cell/link-cell.d.ts +10 -0
  110. package/dist/types/components/table/components/cell/number-cell.d.ts +5 -3
  111. package/dist/types/components/table/components/index.d.ts +1 -1
  112. package/dist/types/components/table/components/table-cell.d.ts +1 -1
  113. package/dist/types/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.d.ts +10 -0
  114. package/dist/types/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.d.ts +13 -0
  115. package/dist/types/components/table/components/table-filter/table-filter.context.d.ts +1 -0
  116. package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +1 -0
  117. package/dist/types/components/table/components/table-header/stories/basic-header.d.ts +1 -1
  118. package/dist/types/components/table/index.d.ts +1 -1
  119. package/dist/types/components/table/table.const.d.ts +15 -9
  120. package/dist/types/components/table/table.type.d.ts +36 -5
  121. package/dist/types/components/table/table.utils.d.ts +1 -1
  122. package/package.json +1 -1
  123. package/dist/components/table/components/cell/text-cell.d.ts +0 -7
  124. package/dist/components/table/components/cell/text-cell.js +0 -5
  125. package/dist/css/config/colors/components/alert.css +0 -84
  126. package/dist/css/config/colors/components/button.css +0 -93
  127. package/dist/css/config/colors/components/select.css +0 -128
  128. package/dist/css/config/colors/components/text-button.css +0 -67
  129. package/dist/css/config/colors/defaults.css +0 -393
  130. package/dist/css/config/colors/semantic-colors.css +0 -353
  131. package/dist/css/config/components/button.css +0 -160
  132. package/dist/css/config/components/input.css +0 -56
  133. package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +0 -26
  134. package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +0 -26
  135. package/dist/types/components/table/components/cell/text-cell.d.ts +0 -7
  136. /package/dist/css/config/typography/{typography.css → index.css} +0 -0
@@ -1,46 +1,55 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { TABLE_CSS_CLASSES as r } from "../table.const.js";
3
- import { TextCell as m } from "./cell/text-cell.js";
4
- import { NumberCell as h } from "./cell/number-cell.js";
5
- import { BooleanCell as b } from "./cell/boolean-cell.js";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { TABLE_CSS_CLASSES as s } from "../table.const.js";
3
+ import { NumberCell as S } from "./cell/number-cell.js";
4
+ import { BooleanCell as C } from "./cell/boolean-cell.js";
5
+ import { LinkCell as d } from "./cell/link-cell.js";
6
+ import { DescriptionCell as h } from "./cell/description-cell.js";
7
+ import { AvatarCell as u } from "./cell/avatar-cell.js";
8
+ import { LabelCell as c } from "./cell/label-cell.js";
6
9
  import "react";
7
- import { cn as S } from "../../../lib/utils.js";
8
- const E = ({
9
- value: t,
10
- cellType: n,
11
- cellRenderer: f,
10
+ import { cn as B } from "../../../lib/utils.js";
11
+ const T = ({
12
+ value: o,
13
+ cellType: m,
14
+ cellRenderer: n,
12
15
  record: i,
13
- index: C,
16
+ index: a,
14
17
  customCells: e,
15
- cell: s
18
+ cell: b
16
19
  }) => {
17
- const p = {
18
- text: m,
19
- number: h,
20
- boolean: b,
21
- checkbox: m
22
- }, a = e == null ? void 0 : e[n];
23
- let o;
24
- if (f)
25
- o = f({ value: t, record: i, index: C });
26
- else if (a)
27
- o = /* @__PURE__ */ l(a, { value: t, record: i, index: C });
20
+ const A = {
21
+ text: c,
22
+ number: S,
23
+ boolean: C,
24
+ checkbox: C,
25
+ link: d,
26
+ avatar: u,
27
+ label: c
28
+ }, f = e == null ? void 0 : e[m];
29
+ let r;
30
+ if (n)
31
+ r = n({ value: o, record: i, index: a });
32
+ else if (f)
33
+ r = /* @__PURE__ */ t(f, { value: o, record: i, index: a });
28
34
  else {
29
- const c = p[n] ?? m;
30
- o = /* @__PURE__ */ l(c, { value: t });
35
+ const l = A[m] ?? h;
36
+ if (typeof o == "object" && o !== null && !Array.isArray(o)) {
37
+ const p = o, L = { value: p.value ?? "", ...p };
38
+ r = /* @__PURE__ */ t(l, { ...L });
39
+ } else
40
+ r = /* @__PURE__ */ t(l, { value: o ?? "" });
31
41
  }
32
- return /* @__PURE__ */ l(
42
+ return /* @__PURE__ */ t(
33
43
  "td",
34
44
  {
35
- className: S(
36
- r.cell.default,
37
- r.cell.cellHeight[s.cellHeight],
38
- r.cell.hasBorder[s.hasBorder ? "true" : "false"]
45
+ className: B(
46
+ s.cell.default,
47
+ s.cell.hasBorder[b.hasBorder ? "true" : "false"]
39
48
  ),
40
- children: o
49
+ children: r
41
50
  }
42
51
  );
43
52
  };
44
53
  export {
45
- E as TableCell
54
+ T as TableCell
46
55
  };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ interface FilterConfirmationDialogProps {
3
+ onClose: () => void;
4
+ onKeepChanges: () => void;
5
+ onRevertChanges: () => void;
6
+ onApplyChanges: () => void;
7
+ hasUnsavedChanges: boolean;
8
+ }
9
+ export declare const FilterConfirmationDialog: React.FC<FilterConfirmationDialogProps>;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { Button as l } from "../../../../button/button.js";
3
+ import { Z2Dialog as s, Z2DialogContent as d, Z2DialogHeader as h, Z2DialogTitle as c, Z2DialogDescription as g, Z2DialogFooter as m } from "../../../../dialog/dialog.js";
4
+ const v = ({
5
+ onClose: r,
6
+ onKeepChanges: i,
7
+ onRevertChanges: o,
8
+ onApplyChanges: a,
9
+ hasUnsavedChanges: t
10
+ }) => t ? /* @__PURE__ */ e(s, { open: !0, onOpenChange: r, children: /* @__PURE__ */ n(d, { className: "max-w-md p-4 rounded-2xl", children: [
11
+ /* @__PURE__ */ n(h, { children: [
12
+ /* @__PURE__ */ n("div", { className: "flex justify-between", children: [
13
+ /* @__PURE__ */ e(c, { children: "Unsaved Filter Changes" }),
14
+ /* @__PURE__ */ e(
15
+ l,
16
+ {
17
+ "aria-label": "Close",
18
+ className: "ml-4 p-2 text-xl leading-none font-bold bg-transparent border-none shadow-none hover:bg-gray-100 min-w-0 min-h-0",
19
+ onClick: i,
20
+ children: "×"
21
+ }
22
+ )
23
+ ] }),
24
+ /* @__PURE__ */ e(g, { children: "You have unsaved filter changes. Would you like to keep these changes or revert to the previous state?" })
25
+ ] }),
26
+ /* @__PURE__ */ n(m, { children: [
27
+ /* @__PURE__ */ e(l, { onClick: o, variant: "stroke", shade: "danger", size: "small", children: "Discard" }),
28
+ /* @__PURE__ */ e(l, { onClick: a, variant: "filled", shade: "brand", size: "small", children: "Apply Changes" })
29
+ ] })
30
+ ] }) }) : null;
31
+ export {
32
+ v as FilterConfirmationDialog
33
+ };
@@ -0,0 +1,13 @@
1
+ import { FilterRule } from '../../../table.type';
2
+ /**
3
+ * Compares two filter arrays to determine if they are different
4
+ */
5
+ export declare const areFiltersEqual: (filters1: FilterRule[], filters2: FilterRule[]) => boolean;
6
+ /**
7
+ * Checks if there are unsaved changes by comparing temporary filters with applied filters
8
+ */
9
+ export declare const hasUnsavedFilterChanges: (tempFilters: FilterRule[], appliedFilters: FilterRule[]) => boolean;
10
+ /**
11
+ * Checks if there are unsaved changes for a specific column filter
12
+ */
13
+ export declare const hasUnsavedFilterChangesForColumn: (columnName: string, tempFilters: FilterRule[], appliedFilters: FilterRule[]) => boolean;
@@ -0,0 +1,20 @@
1
+ const v = (l, n) => {
2
+ if (l.length !== n.length)
3
+ return !1;
4
+ const u = [...l].sort((e, t) => e.field.localeCompare(t.field)), r = [...n].sort((e, t) => e.field.localeCompare(t.field));
5
+ return u.every((e, t) => {
6
+ const a = r[t];
7
+ return e.field !== a.field || e.condition !== a.condition ? !1 : Array.isArray(e.value) && Array.isArray(a.value) ? e.value.length !== a.value.length ? !1 : e.value.every((i, s) => i === a.value[s]) : Array.isArray(e.value) || Array.isArray(a.value) ? !1 : e.value === a.value;
8
+ });
9
+ }, o = (l, n) => {
10
+ const u = l.filter((r) => Array.isArray(r.value) ? r.value.length > 0 : r.value !== "");
11
+ return !v(u, n);
12
+ }, f = (l, n, u) => {
13
+ const r = n.find((a) => a.field === l), e = u.find((a) => a.field === l);
14
+ return !r || !(Array.isArray(r.value) ? r.value.length > 0 : r.value !== "") ? !1 : !e || r.condition !== e.condition ? !0 : Array.isArray(r.value) && Array.isArray(e.value) ? r.value.length !== e.value.length ? !0 : !r.value.every((a, i) => a === e.value[i]) : Array.isArray(r.value) || Array.isArray(e.value) ? !0 : r.value !== e.value;
15
+ };
16
+ export {
17
+ v as areFiltersEqual,
18
+ o as hasUnsavedFilterChanges,
19
+ f as hasUnsavedFilterChangesForColumn
20
+ };
@@ -1,63 +1,71 @@
1
- import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import { useEffect as i } from "react";
3
- const c = ["equals", "notEqual"], m = ({ value: r, onChange: l }) => {
4
- i(() => {
5
- r.condition || l({ condition: c[0] });
1
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
+ import { useEffect as n } from "react";
3
+ const d = ["equals", "notEqual"], u = ({ value: t, onChange: s }) => {
4
+ n(() => {
5
+ t.condition || s({ condition: d[0] });
6
6
  }, []);
7
- const s = (e, u) => {
8
- l(u ? { value: e } : { value: "" });
9
- }, n = (e) => {
10
- switch (e) {
11
- case "equals":
12
- return "Equals";
13
- case "notEqual":
14
- return "Not equal to";
15
- default:
16
- return e;
17
- }
7
+ const i = (r, a) => {
8
+ s(a ? { value: r } : { value: "" });
18
9
  };
19
- return /* @__PURE__ */ t("div", { className: "flex flex-col", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-2 p-3", children: [
20
- /* @__PURE__ */ a("div", { className: "space-y-2", children: [
21
- /* @__PURE__ */ a("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
22
- /* @__PURE__ */ t(
10
+ return /* @__PURE__ */ e("div", { className: "w-full", children: /* @__PURE__ */ l("div", { className: "p-4 space-y-3", children: [
11
+ /* @__PURE__ */ l("label", { className: "flex items-center p-3 rounded-lg border border-stroke-solid-light hover:border-stroke-solid-medium hover:bg-gray-50 transition-all duration-200 cursor-pointer group", children: [
12
+ /* @__PURE__ */ l("div", { className: "relative", children: [
13
+ /* @__PURE__ */ e(
23
14
  "input",
24
15
  {
25
16
  type: "checkbox",
26
- checked: r.value === "true",
27
- onChange: (e) => s("true", e.target.checked),
28
- className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
17
+ checked: t.value === "true",
18
+ onChange: (r) => i("true", r.target.checked),
19
+ className: "w-5 h-5 rounded border-2 border-stroke-solid-medium text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200"
29
20
  }
30
21
  ),
31
- /* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: "True" })
22
+ t.value === "true" && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
23
+ "path",
24
+ {
25
+ fillRule: "evenodd",
26
+ d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
27
+ clipRule: "evenodd"
28
+ }
29
+ ) }) })
32
30
  ] }),
33
- /* @__PURE__ */ a("label", { className: "flex items-center space-x-2 cursor-pointer", children: [
34
- /* @__PURE__ */ t(
31
+ /* @__PURE__ */ l("div", { className: "ml-3 flex-1", children: [
32
+ /* @__PURE__ */ l("div", { className: "flex items-center", children: [
33
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-text-neutral-primary", children: "True" }),
34
+ t.value === "true" && /* @__PURE__ */ e("span", { className: "ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800", children: "Selected" })
35
+ ] }),
36
+ /* @__PURE__ */ e("p", { className: "text-xs text-text-neutral-secondary mt-0.5", children: "Include records with true values" })
37
+ ] })
38
+ ] }),
39
+ /* @__PURE__ */ l("label", { className: "flex items-center p-3 rounded-lg border border-stroke-solid-light hover:border-stroke-solid-medium hover:bg-gray-50 transition-all duration-200 cursor-pointer group", children: [
40
+ /* @__PURE__ */ l("div", { className: "relative", children: [
41
+ /* @__PURE__ */ e(
35
42
  "input",
36
43
  {
37
44
  type: "checkbox",
38
- checked: r.value === "false",
39
- onChange: (e) => s("false", e.target.checked),
40
- className: "rounded border-stroke-solid-medium text-text-neutral-primary focus:ring-2 focus:ring-blue-500"
45
+ checked: t.value === "false",
46
+ onChange: (r) => i("false", r.target.checked),
47
+ className: "w-5 h-5 rounded border-2 border-stroke-solid-medium text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors duration-200"
41
48
  }
42
49
  ),
43
- /* @__PURE__ */ t("span", { className: "text-text-neutral-primary text-sm", children: "False" })
50
+ t.value === "false" && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("svg", { className: "w-3 h-3 text-white", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
51
+ "path",
52
+ {
53
+ fillRule: "evenodd",
54
+ d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
55
+ clipRule: "evenodd"
56
+ }
57
+ ) }) })
58
+ ] }),
59
+ /* @__PURE__ */ l("div", { className: "ml-3 flex-1", children: [
60
+ /* @__PURE__ */ l("div", { className: "flex items-center", children: [
61
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-text-neutral-primary", children: "False" }),
62
+ t.value === "false" && /* @__PURE__ */ e("span", { className: "ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800", children: "Selected" })
63
+ ] }),
64
+ /* @__PURE__ */ e("p", { className: "text-xs text-text-neutral-secondary mt-0.5", children: "Include records with false values" })
44
65
  ] })
45
- ] }),
46
- /* @__PURE__ */ t(
47
- "select",
48
- {
49
- value: r.condition,
50
- onChange: (e) => l({ condition: e.target.value }),
51
- className: "border border-stroke-solid-medium bg-surface-neutral-default text-text-neutral-primary rounded px-2 py-1 text-sm mb-3",
52
- children: c.map((e) => /* @__PURE__ */ t("option", { value: e, children: n(e) }, e))
53
- }
54
- ),
55
- r.value && /* @__PURE__ */ a("div", { className: "mt-3 p-2 bg-surface-neutral-muted rounded text-sm", children: [
56
- /* @__PURE__ */ t("div", { className: "text-text-neutral-muted mb-1", children: "Selected:" }),
57
- /* @__PURE__ */ t("div", { className: "text-text-neutral-primary", children: r.value === "true" ? "True" : "False" })
58
66
  ] })
59
67
  ] }) });
60
68
  };
61
69
  export {
62
- m as default
70
+ u as default
63
71
  };
@@ -1,26 +1,26 @@
1
- const a = (r, n) => {
2
- if (!(!n || n.length === 0))
3
- if (Array.isArray(r.value)) {
4
- const t = n.filter(
5
- (u) => r.value.includes(u.value)
6
- ).reduce((u, o) => u + (o.total || 0), 0);
7
- return t > 0 ? t : void 0;
8
- } else {
9
- const e = n.find((t) => t.value === r.value);
10
- return e == null ? void 0 : e.total;
11
- }
12
- }, l = (r, n) => r.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "").map((e) => {
13
- const t = n.find((o) => o.key === e.field), u = a(e, t == null ? void 0 : t.filterOptions);
1
+ const o = (n, u) => {
2
+ if (!u || u.length === 0) return n.value !== "" ? 1 : 0;
3
+ if (Array.isArray(n.value)) {
4
+ const t = u.filter(
5
+ (r) => n.value.includes(r.value)
6
+ ).reduce((r, a) => r + (a.total || 0), 0);
7
+ return t > 0 ? t : void 0;
8
+ } else {
9
+ const e = u.find((t) => t.value === n.value);
10
+ return e == null ? void 0 : e.total;
11
+ }
12
+ }, l = (n, u) => n.filter((e) => Array.isArray(e.value) ? e.value.length > 0 : e.value !== "").map((e) => {
13
+ const t = u.find((a) => a.key === e.field), r = o(e, t == null ? void 0 : t.filterOptions);
14
14
  return {
15
15
  field: e.field,
16
16
  fieldTitle: (t == null ? void 0 : t.title) || e.field,
17
17
  value: e.value,
18
18
  condition: e.condition,
19
- count: u
19
+ count: r
20
20
  };
21
- }), c = (r) => r.reduce((n, e) => n + (e.count || 0), 0);
21
+ }), c = (n) => n.reduce((u, e) => u + (e.count || 1), 0);
22
22
  export {
23
23
  c as calculateTotalCount,
24
24
  l as createFilterDisplayItems,
25
- a as getFilterCount
25
+ o as getFilterCount
26
26
  };
@@ -1,103 +1,134 @@
1
1
  import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
- import * as f from "react";
3
- import { Button as c } from "../../../button/button.js";
4
- import { useTableFilterContext as O } from "./table-filter.context.js";
5
- import z from "./filters/text.js";
6
- import S from "./filters/boolean.js";
7
- import $ from "./filters/number/number.js";
8
- import B from "./filters/checkbox.js";
9
- import R from "../../../assets/icons/circle-check-filled.js";
10
- import { SelectedFiltersDisplay as P } from "./selected-filters-display/selected-filters-display.js";
11
- import { useClickOutside as D } from "../../../../hooks/useClickOutside.js";
12
- const Q = () => {
13
- const [d, o] = f.useState(!1), m = f.useRef(null), {
2
+ import * as h from "react";
3
+ import { Button as u } from "../../../button/button.js";
4
+ import { useTableFilterContext as P } from "./table-filter.context.js";
5
+ import U from "./filters/text.js";
6
+ import V from "./filters/boolean.js";
7
+ import q from "./filters/number/number.js";
8
+ import E from "./filters/checkbox.js";
9
+ import G from "../../../assets/icons/circle-check-filled.js";
10
+ import { SelectedFiltersDisplay as H } from "./selected-filters-display/selected-filters-display.js";
11
+ import { useClickOutside as J } from "../../../../hooks/useClickOutside.js";
12
+ import { createFilterDisplayItems as L, calculateTotalCount as M } from "./selected-filters-display/selected-filters-display.utils.js";
13
+ import { FilterConfirmationDialog as Q } from "./close-filter-confirm/filter-confirmation-dialog.js";
14
+ import { hasUnsavedFilterChanges as y } from "./close-filter-confirm/filter-confirmation-dialog.utils.js";
15
+ const ie = () => {
16
+ const [i, o] = h.useState(!1), [C, a] = h.useState(!1), x = h.useRef(null), {
14
17
  selectedColumn: r,
15
- setSelectedColumn: h,
16
- getFilterForColumn: x,
17
- hasFilterForColumn: b,
18
- updateColumnFilter: v,
19
- clearAllFilters: y,
20
- applyFilters: F,
21
- hasActiveFilters: i,
22
- filterableFields: k,
23
- tempFilters: N,
24
- schema: p,
25
- filter: g,
26
- filterComponents: n = {}
27
- } = O();
28
- D(m, () => o(!1));
29
- const w = () => {
30
- F(), o(!1);
31
- }, C = () => {
18
+ setSelectedColumn: F,
19
+ getFilterForColumn: k,
20
+ hasFilterForColumn: N,
21
+ updateColumnFilter: w,
22
+ clearAllFilters: T,
23
+ resetToAppliedFilters: A,
24
+ applyFilters: D,
25
+ hasActiveFilters: c,
26
+ filterableFields: j,
27
+ tempFilters: n,
28
+ schema: m,
29
+ filter: d,
30
+ filterComponents: p = {}
31
+ } = P();
32
+ J(x, () => {
33
+ y(n, d.value) && i ? a(!0) : o(!1);
34
+ });
35
+ const v = () => {
36
+ D(), o(!1);
37
+ }, S = () => {
38
+ a(!1), o(!1);
39
+ }, O = () => {
40
+ A(), a(!1), o(!1);
41
+ }, R = () => {
42
+ a(!1);
43
+ }, $ = L(n, m), b = M($), z = () => {
32
44
  if (!r) return null;
33
- const e = p.find((a) => a.key === r), T = {
34
- boolean: S,
35
- text: z,
36
- number: $,
37
- checkbox: B
38
- }, u = (n == null ? void 0 : n[(e == null ? void 0 : e.cellType) || ""]) || T[(e == null ? void 0 : e.cellType) || "text"];
39
- if (!u)
45
+ const e = m.find((f) => f.key === r), B = {
46
+ boolean: V,
47
+ text: U,
48
+ number: q,
49
+ checkbox: E
50
+ }, g = (e == null ? void 0 : e.cellType) && (p == null ? void 0 : p[e.cellType]) || B[(e == null ? void 0 : e.cellType) ?? "text"];
51
+ if (!g)
40
52
  return console.warn(
41
53
  `No filter component found for column "${e == null ? void 0 : e.key}" with cellType "${e == null ? void 0 : e.cellType}". Provide a custom filter component or use supported types: "text", "number", "boolean", "checkbox".`
42
54
  ), null;
43
- const s = x(r), j = {
55
+ const s = k(r), I = {
44
56
  condition: (s == null ? void 0 : s.condition) || "",
45
57
  value: (s == null ? void 0 : s.value) || ""
46
58
  };
47
59
  return /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t("div", { className: "mb-4", children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ t(
48
- u,
60
+ g,
49
61
  {
50
- value: j,
51
- onChange: ({ condition: a, value: A }) => v(r, a, A),
62
+ value: I,
63
+ onChange: ({ condition: f, value: K }) => w(r, f, K),
52
64
  filterOptions: e == null ? void 0 : e.filterOptions
53
65
  }
54
66
  ) }) }) });
55
67
  };
56
- return /* @__PURE__ */ l("div", { className: "relative", ref: m, children: [
68
+ return /* @__PURE__ */ l("div", { className: "relative", ref: x, children: [
57
69
  /* @__PURE__ */ l(
58
- c,
70
+ u,
59
71
  {
60
72
  onClick: (e) => {
61
- e.stopPropagation(), o(!d);
73
+ e.stopPropagation(), o(!i);
62
74
  },
63
- variant: i ? "filled" : "stroke",
64
- shade: i ? "brand" : "neutral",
75
+ variant: c ? "filled" : "stroke",
76
+ shade: c ? "brand" : "neutral",
65
77
  size: "small",
66
78
  children: [
67
79
  "Filter ",
68
- i && `(${g.value.length})`
80
+ c && `(${d.value.length})`
69
81
  ]
70
82
  }
71
83
  ),
72
- d && /* @__PURE__ */ l("div", { className: "absolute top-full left-0 mt-2 w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
84
+ i && /* @__PURE__ */ l("div", { className: "absolute top-full left-0 mt-2 w-[512px] bg-surface-neutral-default border border-stroke-solid-light rounded-2xl z-10 overflow-hidden shadow-lg", children: [
73
85
  /* @__PURE__ */ l("div", { className: "flex min-h-[442px]", children: [
74
86
  /* @__PURE__ */ l("div", { className: "w-48 border-r border-stroke-solid-light p-2 flex flex-col gap-1.5", children: [
75
87
  /* @__PURE__ */ t("div", { className: "p-2 pb-1", children: /* @__PURE__ */ t("h3", { className: "leading-none-medium-sm text-text-neutral-secondary", children: "Filters" }) }),
76
- k.map((e) => /* @__PURE__ */ l(
88
+ j.map((e) => /* @__PURE__ */ l(
77
89
  "button",
78
90
  {
79
- onClick: () => h(e.key),
91
+ onClick: () => F(e.key),
80
92
  className: `w-full text-left p-2 text-sm flex items-center justify-between hover:bg-surface-neutral-hovered transition-colors rounded-lg ${r === e.key ? "bg-surface-neutral-focused text-text-brand-primary" : "text-text-neutral-primary"}`,
81
93
  children: [
82
94
  /* @__PURE__ */ t("span", { className: "truncate", children: e.title }),
83
- b(e.key) && /* @__PURE__ */ t(R, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
95
+ N(e.key) && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-text-brand-secondary flex-shrink-0 ml-2" })
84
96
  ]
85
97
  },
86
98
  e.key
87
99
  ))
88
100
  ] }),
89
- /* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? C() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
101
+ /* @__PURE__ */ t("div", { className: "flex-1 flex flex-col", children: r ? z() : /* @__PURE__ */ t("div", { className: "flex-1 flex items-center justify-center text-text-neutral-muted", children: "Select a column to configure its filter" }) })
90
102
  ] }),
91
- /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium", children: [
92
- /* @__PURE__ */ t(P, { selectedFilters: N, schema: p }),
103
+ !!b && /* @__PURE__ */ l("div", { className: "flex justify-between items-end p-4 border-t border-stroke-solid-medium min-h-[71px]", children: [
104
+ /* @__PURE__ */ t(H, { selectedFilters: n, schema: m }),
93
105
  /* @__PURE__ */ l("div", { className: "flex justify-end gap-2", children: [
94
- /* @__PURE__ */ t(c, { onClick: y, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
95
- /* @__PURE__ */ t(c, { onClick: w, variant: "filled", shade: "neutral", size: "small", children: "Apply" })
106
+ /* @__PURE__ */ t(u, { onClick: T, variant: "stroke", shade: "neutral", size: "small", children: "Clear All" }),
107
+ /* @__PURE__ */ t(
108
+ u,
109
+ {
110
+ onClick: v,
111
+ variant: "filled",
112
+ shade: "neutral",
113
+ size: "small",
114
+ children: `Apply ${b || ""}`
115
+ }
116
+ )
96
117
  ] })
97
118
  ] })
98
- ] })
119
+ ] }),
120
+ C && /* @__PURE__ */ t(
121
+ Q,
122
+ {
123
+ onClose: R,
124
+ onKeepChanges: S,
125
+ onRevertChanges: O,
126
+ onApplyChanges: v,
127
+ hasUnsavedChanges: y(n, d.value)
128
+ }
129
+ )
99
130
  ] });
100
131
  };
101
132
  export {
102
- Q as TableFilterButton
133
+ ie as TableFilterButton
103
134
  };