@konstructio/ui 0.1.2-alpha.70 → 0.1.2-alpha.71
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/Filter/Filter.d.ts +2 -2
- package/dist/components/Filter/Filter.js +15 -12
- package/dist/components/Filter/Filter.types.d.ts +2 -1
- package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.d.ts +3 -0
- package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.js +122 -0
- package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.types.d.ts +7 -0
- package/dist/components/Filter/components/index.d.ts +2 -0
- package/dist/components/Filter/components/index.js +7 -5
- package/dist/components/VirtualizedTable/VirtualizedTable.js +61 -59
- package/dist/components/VirtualizedTable/VirtualizedTable.types.d.ts +66 -5
- package/dist/components/VirtualizedTable/components/Filter/Filter.js +116 -64
- package/dist/components/VirtualizedTable/components/Filter/Filter.types.d.ts +3 -1
- package/dist/components/VirtualizedTable/contexts/table.context.d.ts +10 -0
- package/dist/components/VirtualizedTable/contexts/table.context.js +6 -0
- package/dist/components/VirtualizedTable/contexts/table.provider.js +179 -154
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +33 -31
- package/dist/index.js +62 -60
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,90 +1,142 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { d as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Button as
|
|
5
|
-
import { Filter as
|
|
6
|
-
import { Input as
|
|
7
|
-
import { cn as
|
|
8
|
-
import { useTableContext as
|
|
9
|
-
const
|
|
10
|
-
actions:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsxs as D, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { d as N } from "../../../../debounce-DJveWHr_.js";
|
|
3
|
+
import { useRef as P, useMemo as m, useCallback as S } from "react";
|
|
4
|
+
import { Button as I } from "../../../Button/Button.js";
|
|
5
|
+
import { Filter as r } from "../../../Filter/Filter.js";
|
|
6
|
+
import { Input as $ } from "../../../Input/Input.js";
|
|
7
|
+
import { cn as q } from "../../../../utils/index.js";
|
|
8
|
+
import { useTableContext as z } from "../../contexts/table.hook.js";
|
|
9
|
+
const U = ({
|
|
10
|
+
actions: b,
|
|
11
|
+
filters: u,
|
|
12
|
+
multiSelectFilter: p,
|
|
13
|
+
placeholder: x,
|
|
14
|
+
showFilterInput: w = !0,
|
|
15
|
+
showResetButton: M = !0,
|
|
16
|
+
resetButtonClassName: v
|
|
16
17
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
termOfSearch:
|
|
19
|
-
multiselectSelected:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const c = P(null), {
|
|
19
|
+
termOfSearch: d,
|
|
20
|
+
multiselectSelected: i,
|
|
21
|
+
dateFilters: h,
|
|
22
|
+
dateRangeFilters: y,
|
|
23
|
+
onChangeTermOfSearch: s,
|
|
24
|
+
onSelectMultiselect: F,
|
|
25
|
+
onSelectDateFilter: j,
|
|
26
|
+
onSelectDateRangeFilter: O
|
|
27
|
+
} = z(), T = m(
|
|
28
|
+
() => u ?? p?.map((e) => ({
|
|
29
|
+
...e,
|
|
30
|
+
type: "badgeMultiSelect"
|
|
31
|
+
})) ?? [],
|
|
32
|
+
[u, p]
|
|
33
|
+
), R = S(
|
|
34
|
+
(e, t) => F(
|
|
24
35
|
e,
|
|
25
|
-
t.map((
|
|
36
|
+
t.map((a) => a.id)
|
|
26
37
|
),
|
|
27
|
-
[
|
|
28
|
-
),
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
() =>
|
|
32
|
-
|
|
38
|
+
[F]
|
|
39
|
+
), g = S(() => {
|
|
40
|
+
s(""), c.current && (c.current.value = "");
|
|
41
|
+
}, [s]), B = m(
|
|
42
|
+
() => N((e) => {
|
|
43
|
+
s(e.target.value);
|
|
33
44
|
}, 500),
|
|
34
|
-
[
|
|
35
|
-
),
|
|
36
|
-
() => !!
|
|
37
|
-
[
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
[s]
|
|
46
|
+
), A = m(
|
|
47
|
+
() => !!d || Object.values(i ?? {}).flat().length > 0 || Object.values(h ?? {}).some(Boolean) || Object.values(y ?? {}).some(Boolean),
|
|
48
|
+
[d, i, h, y]
|
|
49
|
+
), k = (e) => {
|
|
50
|
+
const { key: t, label: a, position: l = "right" } = e;
|
|
51
|
+
return e.type === "textMultiSelect" ? /* @__PURE__ */ n(
|
|
52
|
+
r.TextMultiSelect,
|
|
42
53
|
{
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
label: a,
|
|
55
|
+
position: l,
|
|
56
|
+
options: e.options,
|
|
57
|
+
onApply: (o) => {
|
|
58
|
+
R(t, o);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
t
|
|
62
|
+
) : e.type === "date" ? /* @__PURE__ */ n(
|
|
63
|
+
r.DateFilterDropdown,
|
|
64
|
+
{
|
|
65
|
+
label: a,
|
|
66
|
+
position: l,
|
|
67
|
+
countryCode: e.countryCode,
|
|
68
|
+
onApply: (o) => {
|
|
69
|
+
j(t, o);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
t
|
|
73
|
+
) : e.type === "dateRange" ? /* @__PURE__ */ n(
|
|
74
|
+
r.DateRangeFilterDropdown,
|
|
75
|
+
{
|
|
76
|
+
label: a,
|
|
77
|
+
position: l,
|
|
78
|
+
showTime: e.showTime,
|
|
79
|
+
timeFormat: e.timeFormat,
|
|
80
|
+
showPresets: e.showPresets,
|
|
81
|
+
defaultRange: e.defaultRange,
|
|
82
|
+
minDate: e.minDate,
|
|
83
|
+
maxDate: e.maxDate,
|
|
84
|
+
countryCode: e.countryCode,
|
|
85
|
+
onApply: (o) => {
|
|
86
|
+
O(t, o);
|
|
87
|
+
},
|
|
88
|
+
onRangeChange: e.onRangeChange
|
|
89
|
+
},
|
|
90
|
+
t
|
|
91
|
+
) : /* @__PURE__ */ n(
|
|
92
|
+
r.BadgeMultiSelect,
|
|
93
|
+
{
|
|
94
|
+
label: a,
|
|
95
|
+
position: l,
|
|
96
|
+
options: e.options,
|
|
97
|
+
onApply: (o) => {
|
|
98
|
+
R(t, o);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
t
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ D("div", { className: "w-full flex items-center justify-end pb-6", children: [
|
|
105
|
+
w && /* @__PURE__ */ n(
|
|
106
|
+
$,
|
|
107
|
+
{
|
|
108
|
+
ref: c,
|
|
109
|
+
placeholder: x,
|
|
45
110
|
isSearch: !0,
|
|
46
111
|
autoComplete: "false",
|
|
47
112
|
className: "w-72",
|
|
48
113
|
inputMode: "search",
|
|
49
|
-
onChange:
|
|
114
|
+
onChange: B
|
|
50
115
|
}
|
|
51
116
|
),
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
label: t,
|
|
58
|
-
position: r,
|
|
59
|
-
options: j,
|
|
60
|
-
onApply: (O) => {
|
|
61
|
-
x(e, O);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
t
|
|
65
|
-
)
|
|
66
|
-
),
|
|
67
|
-
f?.map(({ label: e, onClick: t, variant: r = "secondary" }) => /* @__PURE__ */ a(
|
|
68
|
-
y,
|
|
117
|
+
/* @__PURE__ */ D(r, { children: [
|
|
118
|
+
T.map(k),
|
|
119
|
+
b?.map(({ label: e, onClick: t, variant: a = "secondary" }) => /* @__PURE__ */ n(
|
|
120
|
+
I,
|
|
69
121
|
{
|
|
70
|
-
variant:
|
|
122
|
+
variant: a,
|
|
71
123
|
appearance: "compact",
|
|
72
124
|
onClick: t,
|
|
73
125
|
children: e
|
|
74
126
|
},
|
|
75
127
|
e
|
|
76
128
|
)),
|
|
77
|
-
|
|
78
|
-
|
|
129
|
+
M && /* @__PURE__ */ n(
|
|
130
|
+
r.ResetButton,
|
|
79
131
|
{
|
|
80
|
-
className:
|
|
81
|
-
disabled: !
|
|
82
|
-
onClick:
|
|
132
|
+
className: q("select-none", v),
|
|
133
|
+
disabled: !A,
|
|
134
|
+
onClick: g
|
|
83
135
|
}
|
|
84
136
|
)
|
|
85
137
|
] })
|
|
86
138
|
] });
|
|
87
139
|
};
|
|
88
140
|
export {
|
|
89
|
-
|
|
141
|
+
U as Filter
|
|
90
142
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from '../../../Button/Button.types';
|
|
2
|
-
import { MultiSelectFilter } from '../../VirtualizedTable.types';
|
|
2
|
+
import { FilterConfig, MultiSelectFilter } from '../../VirtualizedTable.types';
|
|
3
3
|
export type { Option } from '../../../Filter/Filter.types';
|
|
4
4
|
export type FilterAction = {
|
|
5
5
|
label: string;
|
|
@@ -8,6 +8,8 @@ export type FilterAction = {
|
|
|
8
8
|
};
|
|
9
9
|
export type Props = {
|
|
10
10
|
actions?: FilterAction[];
|
|
11
|
+
filters?: FilterConfig[];
|
|
12
|
+
/** @deprecated Use `filters` instead */
|
|
11
13
|
multiSelectFilter?: MultiSelectFilter[];
|
|
12
14
|
placeholder: string;
|
|
13
15
|
showFilterInput?: boolean;
|
|
@@ -11,6 +11,11 @@ export type ContextType<TData extends RowData = RowData> = {
|
|
|
11
11
|
termOfSearch?: string;
|
|
12
12
|
page: number;
|
|
13
13
|
multiselectSelected?: Record<string, string[]>;
|
|
14
|
+
dateFilters?: Record<string, string | undefined>;
|
|
15
|
+
dateRangeFilters?: Record<string, {
|
|
16
|
+
from?: string;
|
|
17
|
+
to?: string;
|
|
18
|
+
} | undefined>;
|
|
14
19
|
totalPages: number;
|
|
15
20
|
isFirstLoad: boolean;
|
|
16
21
|
enableExpandedRow?: boolean;
|
|
@@ -28,5 +33,10 @@ export type ContextType<TData extends RowData = RowData> = {
|
|
|
28
33
|
onSorting: Dispatch<SetStateAction<SortingState>>;
|
|
29
34
|
onChangeTermOfSearch: (term: string) => void;
|
|
30
35
|
onSelectMultiselect: (key: string, selectedValues: string[]) => void;
|
|
36
|
+
onSelectDateFilter: (key: string, date?: Date) => void;
|
|
37
|
+
onSelectDateRangeFilter: (key: string, range?: {
|
|
38
|
+
from?: Date;
|
|
39
|
+
to?: Date;
|
|
40
|
+
}) => void;
|
|
31
41
|
};
|
|
32
42
|
export declare const TableContext: import('react').Context<ContextType<unknown>>;
|
|
@@ -20,6 +20,12 @@ const r = e({
|
|
|
20
20
|
onSelectMultiselect() {
|
|
21
21
|
throw new Error("onSelectMultiselect function is not implemented");
|
|
22
22
|
},
|
|
23
|
+
onSelectDateFilter() {
|
|
24
|
+
throw new Error("onSelectDateFilter function is not implemented");
|
|
25
|
+
},
|
|
26
|
+
onSelectDateRangeFilter() {
|
|
27
|
+
throw new Error("onSelectDateRangeFilter function is not implemented");
|
|
28
|
+
},
|
|
23
29
|
handlePage() {
|
|
24
30
|
throw new Error("handlePage function is not implemented");
|
|
25
31
|
},
|