@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.
- package/dist/components/alert/alert.const.d.ts +0 -3
- package/dist/components/alert/alert.const.js +16 -31
- package/dist/components/alert/alert.js +32 -44
- package/dist/components/assets/icons/check.d.ts +8 -0
- package/dist/components/assets/icons/check.js +17 -0
- package/dist/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/components/assets/icons/x-mark.js +17 -0
- package/dist/components/button/button.d.ts +3 -3
- package/dist/components/button/button.js +58 -58
- package/dist/components/collapsible-side-nav-bar/side-nav-bar-header.js +17 -17
- package/dist/components/nav-header/nav-item/nav-item.d.ts +4 -2
- package/dist/components/nav-header/nav-item/nav-item.js +29 -28
- package/dist/components/select/z2-select.js +131 -78
- package/dist/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/components/table/components/cell/avatar-cell.js +74 -0
- package/dist/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/components/table/components/cell/boolean-cell.js +5 -5
- package/dist/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/components/table/components/cell/description-cell.js +16 -0
- package/dist/components/table/components/cell/index.d.ts +10 -1
- package/dist/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/components/table/components/cell/label-cell.js +47 -0
- package/dist/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/components/table/components/cell/link-cell.js +35 -0
- package/dist/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/components/table/components/cell/number-cell.js +40 -3
- package/dist/components/table/components/index.d.ts +1 -1
- package/dist/components/table/components/table-cell.d.ts +1 -1
- package/dist/components/table/components/table-cell.js +41 -32
- package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.d.ts +10 -0
- package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.js +33 -0
- package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.d.ts +13 -0
- package/dist/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.js +20 -0
- package/dist/components/table/components/table-filter/filters/boolean.js +52 -44
- package/dist/components/table/components/table-filter/selected-filters-display/selected-filters-display.utils.js +16 -16
- package/dist/components/table/components/table-filter/table-filter-button.js +88 -57
- package/dist/components/table/components/table-filter/table-filter-column-button.js +81 -51
- package/dist/components/table/components/table-filter/table-filter.context.d.ts +1 -0
- package/dist/components/table/components/table-filter/table-filter.hook.d.ts +1 -0
- package/dist/components/table/components/table-filter/table-filter.hook.js +17 -14
- package/dist/components/table/components/table-footer.js +6 -6
- package/dist/components/table/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/components/table/components/table-header/table-header.js +27 -33
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/table-provider.js +37 -8
- package/dist/components/table/table.const.d.ts +15 -9
- package/dist/components/table/table.const.js +15 -9
- package/dist/components/table/table.js +39 -34
- package/dist/components/table/table.type.d.ts +36 -5
- package/dist/components/table/table.utils.d.ts +1 -1
- package/dist/components/table/table.utils.js +5 -3
- package/dist/components/table-card/table-card.js +116 -89
- package/dist/components/tooltip/tooltip.js +24 -22
- package/dist/css/config/colors/backgrounds.css +8 -8
- package/dist/css/config/colors/components/avatar.css +12 -12
- package/dist/css/config/colors/components/badge.css +42 -42
- package/dist/css/config/colors/components/checkbox.css +2 -2
- package/dist/css/config/colors/components/featured-icon.css +18 -18
- package/dist/css/config/colors/components/progress-bar.css +2 -2
- package/dist/css/config/colors/components/radio-button.css +2 -2
- package/dist/css/config/colors/components/scroll-overlay.css +4 -4
- package/dist/css/config/colors/components/tab.css +7 -7
- package/dist/css/config/colors/components/toggle-switch.css +1 -1
- package/dist/css/config/colors/components/toggle.css +6 -6
- package/dist/css/config/colors/icons.css +20 -20
- package/dist/css/config/colors/overlay.css +1 -1
- package/dist/css/config/colors/semantic/alert.css +44 -0
- package/dist/css/config/colors/semantic/background.css +51 -0
- package/dist/css/config/colors/semantic/base.css +395 -0
- package/dist/css/config/colors/semantic/button.css +131 -0
- package/dist/css/config/colors/semantic/drop-shadow.css +30 -0
- package/dist/css/config/colors/semantic/dropdown.css +12 -0
- package/dist/css/config/colors/semantic/index.css +16 -0
- package/dist/css/config/colors/semantic/input.css +56 -0
- package/dist/css/config/colors/semantic/overlay.css +13 -0
- package/dist/css/config/colors/semantic/stroke.css +90 -0
- package/dist/css/config/colors/semantic/surface.css +135 -0
- package/dist/css/config/colors/semantic/text.css +113 -0
- package/dist/css/config/colors/semantic/tooltip.css +12 -0
- package/dist/css/config/colors/shape.css +40 -40
- package/dist/css/config/colors/stroke.css +19 -19
- package/dist/css/config/colors/surfaces.css +47 -47
- package/dist/css/config/colors/text.css +37 -37
- package/dist/css/config/components/index.css +0 -2
- package/dist/css/config/config-deprecated.css +3 -5
- package/dist/css/config/config.css +5 -3
- package/dist/css/config/other-variables.css +9 -0
- package/dist/css/config/shadows.css +15 -0
- package/dist/css/config/typography/2xl.css +7 -14
- package/dist/css/config/typography/3xl.css +7 -14
- package/dist/css/config/typography/4xl.css +7 -14
- package/dist/css/config/typography/base.css +7 -14
- package/dist/css/config/typography/lg.css +7 -14
- package/dist/css/config/typography/sm.css +7 -14
- package/dist/css/config/typography/xl.css +7 -14
- package/dist/css/config/typography/xs.css +7 -14
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.js +62 -64
- package/dist/types/components/alert/alert.const.d.ts +0 -3
- package/dist/types/components/assets/icons/check.d.ts +8 -0
- package/dist/types/components/assets/icons/x-mark.d.ts +8 -0
- package/dist/types/components/button/button.d.ts +3 -3
- package/dist/types/components/nav-header/nav-item/nav-item.d.ts +4 -2
- package/dist/types/components/table/components/cell/avatar-cell.d.ts +15 -0
- package/dist/types/components/table/components/cell/boolean-cell.d.ts +1 -2
- package/dist/types/components/table/components/cell/description-cell.d.ts +7 -0
- package/dist/types/components/table/components/cell/index.d.ts +10 -1
- package/dist/types/components/table/components/cell/label-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/link-cell.d.ts +10 -0
- package/dist/types/components/table/components/cell/number-cell.d.ts +5 -3
- package/dist/types/components/table/components/index.d.ts +1 -1
- package/dist/types/components/table/components/table-cell.d.ts +1 -1
- package/dist/types/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.d.ts +10 -0
- package/dist/types/components/table/components/table-filter/close-filter-confirm/filter-confirmation-dialog.utils.d.ts +13 -0
- package/dist/types/components/table/components/table-filter/table-filter.context.d.ts +1 -0
- package/dist/types/components/table/components/table-filter/table-filter.hook.d.ts +1 -0
- package/dist/types/components/table/components/table-header/stories/basic-header.d.ts +1 -1
- package/dist/types/components/table/index.d.ts +1 -1
- package/dist/types/components/table/table.const.d.ts +15 -9
- package/dist/types/components/table/table.type.d.ts +36 -5
- package/dist/types/components/table/table.utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/components/table/components/cell/text-cell.d.ts +0 -7
- package/dist/components/table/components/cell/text-cell.js +0 -5
- package/dist/css/config/colors/components/alert.css +0 -84
- package/dist/css/config/colors/components/button.css +0 -93
- package/dist/css/config/colors/components/select.css +0 -128
- package/dist/css/config/colors/components/text-button.css +0 -67
- package/dist/css/config/colors/defaults.css +0 -393
- package/dist/css/config/colors/semantic-colors.css +0 -353
- package/dist/css/config/components/button.css +0 -160
- package/dist/css/config/components/input.css +0 -56
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +0 -26
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +0 -26
- package/dist/types/components/table/components/cell/text-cell.d.ts +0 -7
- /package/dist/css/config/typography/{typography.css → index.css} +0 -0
|
@@ -1,46 +1,55 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { TABLE_CSS_CLASSES as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
|
8
|
-
const
|
|
9
|
-
value:
|
|
10
|
-
cellType:
|
|
11
|
-
cellRenderer:
|
|
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:
|
|
16
|
+
index: a,
|
|
14
17
|
customCells: e,
|
|
15
|
-
cell:
|
|
18
|
+
cell: b
|
|
16
19
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
text:
|
|
19
|
-
number:
|
|
20
|
-
boolean:
|
|
21
|
-
checkbox:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
30
|
-
o
|
|
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__ */
|
|
42
|
+
return /* @__PURE__ */ t(
|
|
33
43
|
"td",
|
|
34
44
|
{
|
|
35
|
-
className:
|
|
36
|
-
|
|
37
|
-
|
|
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:
|
|
49
|
+
children: r
|
|
41
50
|
}
|
|
42
51
|
);
|
|
43
52
|
};
|
|
44
53
|
export {
|
|
45
|
-
|
|
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
|
|
2
|
-
import { useEffect as
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
8
|
-
|
|
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__ */
|
|
20
|
-
/* @__PURE__ */
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
/* @__PURE__ */
|
|
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:
|
|
27
|
-
onChange: (
|
|
28
|
-
className: "rounded border-stroke-solid-medium text-
|
|
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__ */
|
|
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__ */
|
|
34
|
-
/* @__PURE__ */
|
|
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:
|
|
39
|
-
onChange: (
|
|
40
|
-
className: "rounded border-stroke-solid-medium text-
|
|
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__ */
|
|
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
|
-
|
|
70
|
+
u as default
|
|
63
71
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (!
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}, l = (
|
|
13
|
-
const t =
|
|
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:
|
|
19
|
+
count: r
|
|
20
20
|
};
|
|
21
|
-
}), c = (
|
|
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
|
-
|
|
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
|
|
3
|
-
import { Button as
|
|
4
|
-
import { useTableFilterContext as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { SelectedFiltersDisplay as
|
|
11
|
-
import { useClickOutside as
|
|
12
|
-
|
|
13
|
-
|
|
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:
|
|
16
|
-
getFilterForColumn:
|
|
17
|
-
hasFilterForColumn:
|
|
18
|
-
updateColumnFilter:
|
|
19
|
-
clearAllFilters:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
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 =
|
|
34
|
-
boolean:
|
|
35
|
-
text:
|
|
36
|
-
number:
|
|
37
|
-
checkbox:
|
|
38
|
-
},
|
|
39
|
-
if (!
|
|
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 =
|
|
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
|
-
|
|
60
|
+
g,
|
|
49
61
|
{
|
|
50
|
-
value:
|
|
51
|
-
onChange: ({ condition:
|
|
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:
|
|
68
|
+
return /* @__PURE__ */ l("div", { className: "relative", ref: x, children: [
|
|
57
69
|
/* @__PURE__ */ l(
|
|
58
|
-
|
|
70
|
+
u,
|
|
59
71
|
{
|
|
60
72
|
onClick: (e) => {
|
|
61
|
-
e.stopPropagation(), o(!
|
|
73
|
+
e.stopPropagation(), o(!i);
|
|
62
74
|
},
|
|
63
|
-
variant:
|
|
64
|
-
shade:
|
|
75
|
+
variant: c ? "filled" : "stroke",
|
|
76
|
+
shade: c ? "brand" : "neutral",
|
|
65
77
|
size: "small",
|
|
66
78
|
children: [
|
|
67
79
|
"Filter ",
|
|
68
|
-
|
|
80
|
+
c && `(${d.value.length})`
|
|
69
81
|
]
|
|
70
82
|
}
|
|
71
83
|
),
|
|
72
|
-
|
|
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
|
-
|
|
88
|
+
j.map((e) => /* @__PURE__ */ l(
|
|
77
89
|
"button",
|
|
78
90
|
{
|
|
79
|
-
onClick: () =>
|
|
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
|
-
|
|
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 ?
|
|
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(
|
|
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(
|
|
95
|
-
/* @__PURE__ */ t(
|
|
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
|
-
|
|
133
|
+
ie as TableFilterButton
|
|
103
134
|
};
|