@povio/ui 3.2.4-rc.4 → 3.3.0-rc.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.
- package/dist/components/buttons/Button/button.cva.d.ts +1 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +0 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +127 -142
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +17 -2
- package/dist/components/inputs/DateTime/shared/DateField.js +87 -92
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +0 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +134 -144
- package/dist/components/inputs/FormField/FormField.js +47 -34
- package/dist/components/inputs/FormField/formField.cva.d.ts +11 -0
- package/dist/components/inputs/FormField/formField.cva.js +16 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +1 -2
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +1 -2
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +2 -54
- package/dist/components/inputs/Selection/Select/QuerySelect.js +46 -99
- package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +0 -1
- package/dist/components/inputs/Selection/shared/querySelect.utils.js +0 -1
- package/dist/components/inputs/Selection/shared/select.context.js +9 -19
- package/dist/components/inputs/shared/InputClear.js +40 -24
- package/dist/components/inputs/shared/input.cva.js +1 -1
- package/dist/components/shared/pagination/minWidth.cva.d.ts +1 -1
- package/dist/components/table/Table.d.ts +8 -2
- package/dist/components/table/Table.js +55 -33
- package/dist/components/table/TableColumnFilterInput.d.ts +9 -0
- package/dist/components/table/TableColumnFilterInput.js +108 -0
- package/dist/components/table/TableColumnFilterPlaceholder.d.ts +5 -0
- package/dist/components/table/TableColumnFilterPlaceholder.js +41 -0
- package/dist/components/table/TableColumnFilterRow.d.ts +16 -0
- package/dist/components/table/TableColumnFilterRow.js +68 -0
- package/dist/config/uiConfig.context.d.ts +0 -1
- package/dist/config/uiConfig.context.js +1 -2
- package/dist/config/uiOverrides.context.d.ts +1 -0
- package/dist/helpers/dynamicColumns.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/utils/date-time.utils.d.ts +1 -0
- package/dist/utils/date-time.utils.js +45 -21
- package/package.json +1 -1
- package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.d.ts +0 -2
- package/dist/components/inputs/DateTime/shared/useFirefoxDateSegmentSelectionGuard.js +0 -33
- package/dist/utils/intl.utils.d.ts +0 -7
- package/dist/utils/intl.utils.js +0 -38
- package/dist/utils/intl.utils.spec.d.ts +0 -1
|
@@ -8,10 +8,9 @@ import { useState } from "react";
|
|
|
8
8
|
import { mergeRefs } from "@react-aria/utils";
|
|
9
9
|
import { Controller } from "react-hook-form";
|
|
10
10
|
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
11
|
-
var
|
|
11
|
+
var QuerySelectContent = (t0) => {
|
|
12
12
|
const $ = c(31);
|
|
13
|
-
const { query, queryParams, queryOptions, queryMap, resolveSelectedItemsWithIds,
|
|
14
|
-
const isQueryEnabledInitially = t1 === void 0 ? false : t1;
|
|
13
|
+
const { query, queryParams, queryOptions, queryMap, resolveSelectedItemsWithIds, ...props } = t0;
|
|
15
14
|
const ui = UIConfig.useConfig();
|
|
16
15
|
const [search, setSearch] = useState("");
|
|
17
16
|
const isSearchable = props.isSearchable ?? ui.select.isSearchable;
|
|
@@ -22,44 +21,44 @@ var LoadedQuerySelectContent = (t0) => {
|
|
|
22
21
|
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
23
22
|
});
|
|
24
23
|
const shouldEnableInitialQuery = selectedIdsToResolve.count > 0;
|
|
25
|
-
let
|
|
24
|
+
let t1;
|
|
26
25
|
if ($[0] !== queryMap) {
|
|
27
|
-
|
|
26
|
+
t1 = (data) => getQueryItems(data, queryMap);
|
|
28
27
|
$[0] = queryMap;
|
|
29
|
-
$[1] =
|
|
30
|
-
} else
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
let
|
|
35
|
-
if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !==
|
|
36
|
-
|
|
28
|
+
$[1] = t1;
|
|
29
|
+
} else t1 = $[1];
|
|
30
|
+
const t2 = resolveSelectedItemsWithIds ?? ui.querySelect?.resolveSelectedItemsWithIds;
|
|
31
|
+
const t3 = isSearchable ? search : void 0;
|
|
32
|
+
const t4 = shouldEnableInitialQuery ? false : props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled;
|
|
33
|
+
let t5;
|
|
34
|
+
if ($[2] !== query || $[3] !== queryOptions || $[4] !== queryParams || $[5] !== selectedIdsToResolve.items || $[6] !== t1 || $[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
35
|
+
t5 = {
|
|
37
36
|
query,
|
|
38
37
|
queryParams,
|
|
39
38
|
queryOptions,
|
|
40
|
-
mapItems:
|
|
41
|
-
resolveSelectedItemsWithIds:
|
|
42
|
-
search:
|
|
43
|
-
initialQueryState:
|
|
39
|
+
mapItems: t1,
|
|
40
|
+
resolveSelectedItemsWithIds: t2,
|
|
41
|
+
search: t3,
|
|
42
|
+
initialQueryState: t4,
|
|
44
43
|
selectedIdsToResolve: selectedIdsToResolve.items
|
|
45
44
|
};
|
|
46
45
|
$[2] = query;
|
|
47
46
|
$[3] = queryOptions;
|
|
48
47
|
$[4] = queryParams;
|
|
49
48
|
$[5] = selectedIdsToResolve.items;
|
|
50
|
-
$[6] =
|
|
51
|
-
$[7] =
|
|
52
|
-
$[8] =
|
|
53
|
-
$[9] =
|
|
54
|
-
$[10] =
|
|
55
|
-
} else
|
|
56
|
-
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(
|
|
49
|
+
$[6] = t1;
|
|
50
|
+
$[7] = t2;
|
|
51
|
+
$[8] = t3;
|
|
52
|
+
$[9] = t4;
|
|
53
|
+
$[10] = t5;
|
|
54
|
+
} else t5 = $[10];
|
|
55
|
+
const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete(t5);
|
|
57
56
|
let onSearchChange;
|
|
58
57
|
let selectProps;
|
|
59
58
|
if ($[11] !== props) {
|
|
60
|
-
const { isInitialQueryDisabled: _, onSearchChange:
|
|
61
|
-
onSearchChange =
|
|
62
|
-
selectProps =
|
|
59
|
+
const { isInitialQueryDisabled: _, onSearchChange: t6, ...t7 } = props;
|
|
60
|
+
onSearchChange = t6;
|
|
61
|
+
selectProps = t7;
|
|
63
62
|
$[11] = props;
|
|
64
63
|
$[12] = onSearchChange;
|
|
65
64
|
$[13] = selectProps;
|
|
@@ -67,9 +66,9 @@ var LoadedQuerySelectContent = (t0) => {
|
|
|
67
66
|
onSearchChange = $[12];
|
|
68
67
|
selectProps = $[13];
|
|
69
68
|
}
|
|
70
|
-
let
|
|
69
|
+
let t6;
|
|
71
70
|
if ($[14] !== handleEnableQuery || $[15] !== onSearchChange || $[16] !== setSearch) {
|
|
72
|
-
|
|
71
|
+
t6 = (value_0) => {
|
|
73
72
|
setSearch(value_0);
|
|
74
73
|
handleEnableQuery();
|
|
75
74
|
onSearchChange?.(value_0);
|
|
@@ -77,33 +76,33 @@ var LoadedQuerySelectContent = (t0) => {
|
|
|
77
76
|
$[14] = handleEnableQuery;
|
|
78
77
|
$[15] = onSearchChange;
|
|
79
78
|
$[16] = setSearch;
|
|
80
|
-
$[17] =
|
|
81
|
-
} else
|
|
82
|
-
const handleSearchChange =
|
|
83
|
-
const
|
|
84
|
-
let
|
|
79
|
+
$[17] = t6;
|
|
80
|
+
} else t6 = $[17];
|
|
81
|
+
const handleSearchChange = t6;
|
|
82
|
+
const t7 = props.searchDebounceDelay ?? ui.querySelect?.searchDebounceDelay;
|
|
83
|
+
let t8;
|
|
85
84
|
if ($[18] !== handleSearchChange || $[19] !== isSearchable) {
|
|
86
|
-
|
|
85
|
+
t8 = isSearchable && {
|
|
87
86
|
isClientSearchDisabled: true,
|
|
88
87
|
onSearchChange: handleSearchChange
|
|
89
88
|
};
|
|
90
89
|
$[18] = handleSearchChange;
|
|
91
90
|
$[19] = isSearchable;
|
|
92
|
-
$[20] =
|
|
93
|
-
} else
|
|
94
|
-
let
|
|
95
|
-
if ($[21] !== fetchNextPage || $[22] !== handleEnableQuery || $[23] !== hasNextPage || $[24] !== isLoading || $[25] !== items || $[26] !== selectProps || $[27] !==
|
|
96
|
-
|
|
91
|
+
$[20] = t8;
|
|
92
|
+
} else t8 = $[20];
|
|
93
|
+
let t9;
|
|
94
|
+
if ($[21] !== fetchNextPage || $[22] !== handleEnableQuery || $[23] !== hasNextPage || $[24] !== isLoading || $[25] !== items || $[26] !== selectProps || $[27] !== t7 || $[28] !== t8 || $[29] !== totalItems) {
|
|
95
|
+
t9 = /* @__PURE__ */ jsx(Select, {
|
|
97
96
|
...selectProps,
|
|
98
97
|
items,
|
|
99
98
|
isLoading,
|
|
100
99
|
totalItems,
|
|
101
100
|
hasLoadMore: hasNextPage,
|
|
102
101
|
onLoadMore: fetchNextPage,
|
|
103
|
-
searchDebounceDelay:
|
|
102
|
+
searchDebounceDelay: t7,
|
|
104
103
|
onMouseEnter: handleEnableQuery,
|
|
105
104
|
onFocusCapture: handleEnableQuery,
|
|
106
|
-
...
|
|
105
|
+
...t8
|
|
107
106
|
});
|
|
108
107
|
$[21] = fetchNextPage;
|
|
109
108
|
$[22] = handleEnableQuery;
|
|
@@ -111,64 +110,12 @@ var LoadedQuerySelectContent = (t0) => {
|
|
|
111
110
|
$[24] = isLoading;
|
|
112
111
|
$[25] = items;
|
|
113
112
|
$[26] = selectProps;
|
|
114
|
-
$[27] =
|
|
115
|
-
$[28] =
|
|
113
|
+
$[27] = t7;
|
|
114
|
+
$[28] = t8;
|
|
116
115
|
$[29] = totalItems;
|
|
117
|
-
$[30] =
|
|
118
|
-
} else
|
|
119
|
-
return
|
|
120
|
-
};
|
|
121
|
-
var QuerySelectContent = (props) => {
|
|
122
|
-
const $ = c(9);
|
|
123
|
-
const [isQueryMounted, setIsQueryMounted] = useState(false);
|
|
124
|
-
const value = "value" in props ? props.value : void 0;
|
|
125
|
-
if (!getSelectionIdsToResolve({
|
|
126
|
-
initialSelection: props.initialSelection,
|
|
127
|
-
value,
|
|
128
|
-
mapInitialToSelectItem: props.mapInitialToSelectItem
|
|
129
|
-
}).isResolvedByInitialSelection || isQueryMounted) {
|
|
130
|
-
let t0;
|
|
131
|
-
if ($[0] !== isQueryMounted || $[1] !== props) {
|
|
132
|
-
t0 = /* @__PURE__ */ jsx(LoadedQuerySelectContent, {
|
|
133
|
-
...props,
|
|
134
|
-
isQueryEnabledInitially: isQueryMounted
|
|
135
|
-
});
|
|
136
|
-
$[0] = isQueryMounted;
|
|
137
|
-
$[1] = props;
|
|
138
|
-
$[2] = t0;
|
|
139
|
-
} else t0 = $[2];
|
|
140
|
-
return t0;
|
|
141
|
-
}
|
|
142
|
-
let selectProps;
|
|
143
|
-
if ($[3] !== props) {
|
|
144
|
-
const { query: _, queryParams: _queryParams, queryOptions: _queryOptions, queryMap: _queryMap, resolveSelectedItemsWithIds: _resolveSelectedItemsWithIds, isInitialQueryDisabled: _isInitialQueryDisabled, ...t0 } = props;
|
|
145
|
-
selectProps = t0;
|
|
146
|
-
$[3] = props;
|
|
147
|
-
$[4] = selectProps;
|
|
148
|
-
} else selectProps = $[4];
|
|
149
|
-
let t0;
|
|
150
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
151
|
-
t0 = () => setIsQueryMounted(true);
|
|
152
|
-
$[5] = t0;
|
|
153
|
-
} else t0 = $[5];
|
|
154
|
-
const mountQuery = t0;
|
|
155
|
-
let t1;
|
|
156
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
157
|
-
t1 = [];
|
|
158
|
-
$[6] = t1;
|
|
159
|
-
} else t1 = $[6];
|
|
160
|
-
let t2;
|
|
161
|
-
if ($[7] !== selectProps) {
|
|
162
|
-
t2 = /* @__PURE__ */ jsx(Select, {
|
|
163
|
-
...selectProps,
|
|
164
|
-
items: t1,
|
|
165
|
-
onMouseEnter: mountQuery,
|
|
166
|
-
onFocusCapture: mountQuery
|
|
167
|
-
});
|
|
168
|
-
$[7] = selectProps;
|
|
169
|
-
$[8] = t2;
|
|
170
|
-
} else t2 = $[8];
|
|
171
|
-
return t2;
|
|
116
|
+
$[30] = t9;
|
|
117
|
+
} else t9 = $[30];
|
|
118
|
+
return t9;
|
|
172
119
|
};
|
|
173
120
|
var QuerySelect = (props) => {
|
|
174
121
|
const $ = c(16);
|
|
@@ -9,7 +9,6 @@ export declare const getSelectionIdsToResolve: <TInitialSelectItem, TKey extends
|
|
|
9
9
|
mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
|
|
10
10
|
}) => {
|
|
11
11
|
count: number;
|
|
12
|
-
isResolvedByInitialSelection: boolean;
|
|
13
12
|
items: TKey[];
|
|
14
13
|
};
|
|
15
14
|
export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
|
|
@@ -26,7 +26,6 @@ var getSelectionIdsToResolve = ({ initialSelection, value, mapInitialToSelectIte
|
|
|
26
26
|
const items = Array.from(new Set([...missingLabelInitialSelectionIds, ...values.filter((id) => !labeledInitialSelectionIds.has(id))]));
|
|
27
27
|
return {
|
|
28
28
|
count: items.length,
|
|
29
|
-
isResolvedByInitialSelection: values.length > 0 && values.every((id) => labeledInitialSelectionIds.has(id)),
|
|
30
29
|
items
|
|
31
30
|
};
|
|
32
31
|
};
|
|
@@ -135,26 +135,16 @@ var SelectContext;
|
|
|
135
135
|
triggerBlurOnChange
|
|
136
136
|
]);
|
|
137
137
|
const onClear = useCallback(() => {
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
...
|
|
141
|
-
inputValue: ""
|
|
142
|
-
|
|
143
|
-
};
|
|
144
|
-
setFieldState(newFieldState_2);
|
|
145
|
-
emitStateChanges(newFieldState_2, true);
|
|
146
|
-
setShowAll(true);
|
|
138
|
+
if (!valueRef.current || Array.isArray(valueRef.current) && valueRef.current.length === 0) {
|
|
139
|
+
setFieldState((prev) => ({
|
|
140
|
+
...prev,
|
|
141
|
+
inputValue: ""
|
|
142
|
+
}));
|
|
147
143
|
return;
|
|
148
144
|
}
|
|
149
145
|
if (isMultiple) onChange([]);
|
|
150
146
|
else onChange(null);
|
|
151
|
-
}, [
|
|
152
|
-
emitStateChanges,
|
|
153
|
-
fieldState,
|
|
154
|
-
isMultiple,
|
|
155
|
-
onChange,
|
|
156
|
-
selectedIds.length
|
|
157
|
-
]);
|
|
147
|
+
}, [isMultiple, onChange]);
|
|
158
148
|
const onSelectAll = useCallback(() => {
|
|
159
149
|
onChange(selectableListItems.map(({ id: id_4 }) => id_4));
|
|
160
150
|
}, [selectableListItems, onChange]);
|
|
@@ -167,13 +157,13 @@ var SelectContext;
|
|
|
167
157
|
]);
|
|
168
158
|
const onBlur = useCallback(() => {
|
|
169
159
|
if (props.isSearchable && isMultiple && fieldState.searchValue !== "") {
|
|
170
|
-
const
|
|
160
|
+
const newFieldState_2 = {
|
|
171
161
|
...fieldState,
|
|
172
162
|
inputValue: "",
|
|
173
163
|
searchValue: ""
|
|
174
164
|
};
|
|
175
|
-
setFieldState(
|
|
176
|
-
emitStateChanges(
|
|
165
|
+
setFieldState(newFieldState_2);
|
|
166
|
+
emitStateChanges(newFieldState_2);
|
|
177
167
|
setShowAll(true);
|
|
178
168
|
}
|
|
179
169
|
fieldOnBlur?.({});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CloseIcon } from "../../../assets/icons/Close.js";
|
|
2
|
+
import { UIOverrides } from "../../../config/uiOverrides.context.js";
|
|
2
3
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
4
|
+
import { buttonIconSizeDefinition } from "../../buttons/Button/button.cva.js";
|
|
3
5
|
import { InlineIconButton } from "../../buttons/InlineIconButton/InlineIconButton.js";
|
|
4
6
|
import "../../../config/i18n.js";
|
|
5
7
|
import { c } from "react/compiler-runtime";
|
|
@@ -8,56 +10,70 @@ import { clsx } from "clsx";
|
|
|
8
10
|
import { useTranslation } from "react-i18next";
|
|
9
11
|
//#region src/components/inputs/shared/InputClear.tsx
|
|
10
12
|
var InputClear = (t0) => {
|
|
11
|
-
const $ = c(
|
|
13
|
+
const $ = c(16);
|
|
12
14
|
const { onClear, className, style, show, renderStatic } = t0;
|
|
13
|
-
const
|
|
15
|
+
const ui = UIConfig.useConfig();
|
|
16
|
+
const buttonIconSizeCva = UIOverrides.useCva("button.iconSize", buttonIconSizeDefinition);
|
|
17
|
+
const alwaysShowClear = ui.input.alwaysShowClear;
|
|
14
18
|
let clearClassName;
|
|
15
19
|
let t1;
|
|
16
|
-
if ($[0] !== alwaysShowClear || $[1] !==
|
|
20
|
+
if ($[0] !== alwaysShowClear || $[1] !== buttonIconSizeCva || $[2] !== className || $[3] !== renderStatic || $[4] !== show || $[5] !== style) {
|
|
17
21
|
t1 = Symbol.for("react.early_return_sentinel");
|
|
18
22
|
bb0: {
|
|
19
23
|
clearClassName = clsx("relative z-raised flex items-center", !alwaysShowClear && "md:invisible group-focus-within:visible group-hover/date-picker-content:visible group-hover/select-content:visible group-hover/text-area:visible group-hover:visible", "border-0!", !show && "invisible!", className);
|
|
20
24
|
if (renderStatic) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const t2 = clsx("group inline-flex items-center justify-center border border-solid border-support-transparent-outline", "rounded-button-rounding-s p-0 text-interactive-text-secondary-idle", clearClassName);
|
|
26
|
+
let t3;
|
|
27
|
+
if ($[8] !== buttonIconSizeCva) {
|
|
28
|
+
t3 = buttonIconSizeCva({
|
|
29
|
+
size: "none",
|
|
30
|
+
className: "shrink-0"
|
|
31
|
+
});
|
|
32
|
+
$[8] = buttonIconSizeCva;
|
|
33
|
+
$[9] = t3;
|
|
34
|
+
} else t3 = $[9];
|
|
35
|
+
let t4;
|
|
36
|
+
if ($[10] !== t3) {
|
|
37
|
+
t4 = /* @__PURE__ */ jsx(CloseIcon, { className: t3 });
|
|
38
|
+
$[10] = t3;
|
|
39
|
+
$[11] = t4;
|
|
40
|
+
} else t4 = $[11];
|
|
26
41
|
t1 = /* @__PURE__ */ jsx("button", {
|
|
27
42
|
type: "button",
|
|
28
43
|
"aria-hidden": "true",
|
|
29
44
|
tabIndex: -1,
|
|
30
|
-
className:
|
|
45
|
+
className: t2,
|
|
31
46
|
style,
|
|
32
|
-
children:
|
|
47
|
+
children: t4
|
|
33
48
|
});
|
|
34
49
|
break bb0;
|
|
35
50
|
}
|
|
36
51
|
}
|
|
37
52
|
$[0] = alwaysShowClear;
|
|
38
|
-
$[1] =
|
|
39
|
-
$[2] =
|
|
40
|
-
$[3] =
|
|
41
|
-
$[4] =
|
|
42
|
-
$[5] =
|
|
43
|
-
$[6] =
|
|
53
|
+
$[1] = buttonIconSizeCva;
|
|
54
|
+
$[2] = className;
|
|
55
|
+
$[3] = renderStatic;
|
|
56
|
+
$[4] = show;
|
|
57
|
+
$[5] = style;
|
|
58
|
+
$[6] = clearClassName;
|
|
59
|
+
$[7] = t1;
|
|
44
60
|
} else {
|
|
45
|
-
clearClassName = $[
|
|
46
|
-
t1 = $[
|
|
61
|
+
clearClassName = $[6];
|
|
62
|
+
t1 = $[7];
|
|
47
63
|
}
|
|
48
64
|
if (t1 !== Symbol.for("react.early_return_sentinel")) return t1;
|
|
49
65
|
let t2;
|
|
50
|
-
if ($[
|
|
66
|
+
if ($[12] !== clearClassName || $[13] !== onClear || $[14] !== style) {
|
|
51
67
|
t2 = /* @__PURE__ */ jsx(InputClearButton, {
|
|
52
68
|
onClear,
|
|
53
69
|
className: clearClassName,
|
|
54
70
|
style
|
|
55
71
|
});
|
|
56
|
-
$[
|
|
57
|
-
$[
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
} else t2 = $[
|
|
72
|
+
$[12] = clearClassName;
|
|
73
|
+
$[13] = onClear;
|
|
74
|
+
$[14] = style;
|
|
75
|
+
$[15] = t2;
|
|
76
|
+
} else t2 = $[15];
|
|
61
77
|
return t2;
|
|
62
78
|
};
|
|
63
79
|
var InputClearButton = (t0) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DragEndEvent, UniqueIdentifier } from '@dnd-kit/core';
|
|
2
2
|
import { ColumnDef, ColumnOrderState, OnChangeFn, Table as ReactTable, Row, RowSelectionState, SortingState, VisibilityState } from '@tanstack/react-table';
|
|
3
3
|
import { TFunction } from 'i18next';
|
|
4
|
-
import { ComponentType, Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { ComponentType, Dispatch, ReactNode, SetStateAction } from 'react';
|
|
5
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
6
|
+
import { InputDef } from '../inputs/Inputs/InputItem';
|
|
5
7
|
import { TableRowVariantProps } from './table.cva';
|
|
6
8
|
export type BulkSelectionActionsComponent<T> = ComponentType<{
|
|
7
9
|
table: ReactTable<T>;
|
|
@@ -30,8 +32,12 @@ export interface TableProps<T> extends TableRowVariantProps {
|
|
|
30
32
|
enableMultiRowSelection?: boolean | ((row: Row<T>) => boolean);
|
|
31
33
|
defaultSelectedRows?: RowSelectionState;
|
|
32
34
|
onRowSelectionChange?: OnChangeFn<RowSelectionState>;
|
|
35
|
+
filterForm?: UseFormReturn<Record<string, any>>;
|
|
36
|
+
filterDefs?: InputDef<any>[];
|
|
37
|
+
headerFilterCellClassName?: string;
|
|
38
|
+
emptyContent?: ReactNode;
|
|
33
39
|
}
|
|
34
40
|
export declare const RowDragHandleCell: ({ rowId }: {
|
|
35
41
|
rowId: string;
|
|
36
42
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
|
-
export declare const Table: <T>({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection, defaultSelectedRows, onRowSelectionChange, ...props }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare const Table: <T>({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection, defaultSelectedRows, onRowSelectionChange, filterForm, filterDefs, headerFilterCellClassName, emptyContent, ...props }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,6 +8,7 @@ import { tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, t
|
|
|
8
8
|
import { CellText } from "./CellText.js";
|
|
9
9
|
import { DragIndicatorIcon } from "../../assets/icons/DragIndicator.js";
|
|
10
10
|
import { HeaderText } from "./HeaderText.js";
|
|
11
|
+
import { TableColumnFilterRow } from "./TableColumnFilterRow.js";
|
|
11
12
|
import { useTableNav } from "../../hooks/useTableNav.js";
|
|
12
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { clsx } from "clsx";
|
|
@@ -74,7 +75,7 @@ var DraggableRow = ({ row, showCellBorder, onRowClick, onDoubleClick, tableRowCv
|
|
|
74
75
|
})
|
|
75
76
|
});
|
|
76
77
|
};
|
|
77
|
-
var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop = false, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection = false, defaultSelectedRows, onRowSelectionChange, ...props }) => {
|
|
78
|
+
var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, className, sorting, setSorting, columnOrder, setColumnOrder, columnVisibility, setColumnVisibility, bulkSelectionActions: ActionHeader, enableDragDrop = false, onDragEnd, onReorder, getRowId, enableRowSelection, enableMultiRowSelection = false, defaultSelectedRows, onRowSelectionChange, filterForm, filterDefs, headerFilterCellClassName, emptyContent, ...props }) => {
|
|
78
79
|
const tableRowCva = UIOverrides.useCva("table.rowCva", tableRowDefinition);
|
|
79
80
|
const theadCva = UIOverrides.useCva("table.theadCva", theadDefinition);
|
|
80
81
|
const tableHeadRowCva = UIOverrides.useCva("table.headRowCva", tableHeadRowDefinition);
|
|
@@ -172,50 +173,71 @@ var Table = ({ items, showCellBorder, columns, onRowClick, onDoubleClick, classN
|
|
|
172
173
|
const selectedRows = table.getSelectedRowModel().rows;
|
|
173
174
|
const columnCount = table.getHeaderGroups()[0].headers.length;
|
|
174
175
|
const isAnyRowSelected = selectedRows.length > 0 && !!ActionHeader;
|
|
176
|
+
const showFilterRow = !!filterForm && !!filterDefs?.length && !isAnyRowSelected;
|
|
175
177
|
const hasOnClick = !!onRowClick || !!onDoubleClick;
|
|
176
178
|
const tableElement = /* @__PURE__ */ jsxs("table", {
|
|
177
|
-
className: clsx("w-full", className),
|
|
179
|
+
className: clsx("w-full", showFilterRow && "table-fixed", className),
|
|
178
180
|
...listeners,
|
|
179
181
|
children: [/* @__PURE__ */ jsxs("thead", {
|
|
180
182
|
className: clsx(theadCva({})),
|
|
181
183
|
"data-is-sticky": isSticky || void 0,
|
|
182
|
-
children: [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return /* @__PURE__ */ jsx("
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("th", {
|
|
186
|
+
ref: stickyRef,
|
|
187
|
+
className: "-mt-px block"
|
|
188
|
+
}) }),
|
|
189
|
+
table.getHeaderGroups().map((headerGroup) => {
|
|
190
|
+
const visibleHeaders = headerGroup.headers.filter((header) => {
|
|
191
|
+
if (isAnyRowSelected && header.index > 0) return false;
|
|
192
|
+
return header.column.getIsVisible();
|
|
193
|
+
});
|
|
194
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
195
|
+
className: clsx(tableHeadRowCva({})),
|
|
196
|
+
children: visibleHeaders.map((header_0, index) => {
|
|
197
|
+
const columnMeta = header_0.column.columnDef.meta ?? {};
|
|
198
|
+
return /* @__PURE__ */ jsx("th", {
|
|
199
|
+
colSpan: isAnyRowSelected ? columnCount : header_0.colSpan,
|
|
200
|
+
tabIndex: -1,
|
|
201
|
+
className: clsx(tableHeadDataCva({ hasRightBorder: index > 0 && showCellBorder }), columnMeta.headerClass, columnMeta.width),
|
|
202
|
+
children: isAnyRowSelected ? /* @__PURE__ */ jsx(ActionHeader, { table }) : /* @__PURE__ */ jsxs("button", {
|
|
203
|
+
type: "button",
|
|
204
|
+
"aria-label": "Sort column",
|
|
205
|
+
className: clsx("flex select-none items-center gap-1 text-text-default-1", header_0.column.getCanSort() ? "h-6 cursor-pointer rounded-xs px-1 hover:bg-elevation-fill-default-2" : "cursor-default", columnMeta.sortClass),
|
|
206
|
+
onClick: header_0.column.getToggleSortingHandler(),
|
|
207
|
+
children: [typeof header_0.column.columnDef.header === "function" ? flexRender(header_0.column.columnDef.header, header_0.getContext()) : /* @__PURE__ */ jsx(HeaderText, { children: header_0.column.columnDef.header }), {
|
|
208
|
+
asc: /* @__PURE__ */ jsx(ChevronUpIcon, {
|
|
209
|
+
width: 18,
|
|
210
|
+
height: 18
|
|
211
|
+
}),
|
|
212
|
+
desc: /* @__PURE__ */ jsx(ChevronDownIcon, {
|
|
213
|
+
width: 18,
|
|
214
|
+
height: 18
|
|
215
|
+
})
|
|
216
|
+
}[header_0.column.getIsSorted()] ?? null]
|
|
209
217
|
})
|
|
210
|
-
}
|
|
218
|
+
}, header_0.id);
|
|
211
219
|
})
|
|
212
|
-
},
|
|
220
|
+
}, headerGroup.id);
|
|
221
|
+
}),
|
|
222
|
+
showFilterRow && table.getHeaderGroups().map((headerGroup_0) => {
|
|
223
|
+
return /* @__PURE__ */ jsx(TableColumnFilterRow, {
|
|
224
|
+
headers: headerGroup_0.headers.filter((header_1) => header_1.column.getIsVisible()),
|
|
225
|
+
filterForm,
|
|
226
|
+
filterDefs,
|
|
227
|
+
tableHeadDataCva,
|
|
228
|
+
rowClassName: clsx(tableHeadRowCva({})),
|
|
229
|
+
cellClassName: headerFilterCellClassName,
|
|
230
|
+
showCellBorder
|
|
231
|
+
}, `${headerGroup_0.id}-filters`);
|
|
213
232
|
})
|
|
214
|
-
|
|
233
|
+
]
|
|
215
234
|
}), /* @__PURE__ */ jsx("tbody", {
|
|
216
235
|
ref,
|
|
217
236
|
className: "relative",
|
|
218
|
-
children:
|
|
237
|
+
children: table.getRowModel().rows.length === 0 && emptyContent ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
238
|
+
colSpan: columnCount,
|
|
239
|
+
children: emptyContent
|
|
240
|
+
}) }) : enableDragDrop ? /* @__PURE__ */ jsx(SortableContext, {
|
|
219
241
|
items: dataIds,
|
|
220
242
|
strategy: verticalListSortingStrategy,
|
|
221
243
|
children: table.getRowModel().rows.map((row_0) => /* @__PURE__ */ jsx(DraggableRow, {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InputDef } from '../inputs/Inputs/InputItem';
|
|
2
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
3
|
+
interface TableColumnFilterInputProps<TFilterData extends Record<string, any>> {
|
|
4
|
+
form: UseFormReturn<TFilterData>;
|
|
5
|
+
inputDef: InputDef<TFilterData>;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const TableColumnFilterInput: <TFilterData extends Record<string, any>>({ form, inputDef, className, }: TableColumnFilterInputProps<TFilterData>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Inputs } from "../inputs/Inputs/Inputs.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { clsx } from "clsx";
|
|
5
|
+
//#region src/components/table/TableColumnFilterInput.tsx
|
|
6
|
+
var TableColumnFilterInput = (t0) => {
|
|
7
|
+
const $ = c(28);
|
|
8
|
+
const { form, inputDef, className } = t0;
|
|
9
|
+
const filterKey = String(inputDef.name);
|
|
10
|
+
const inputProps = inputDef.props;
|
|
11
|
+
const t1 = inputProps?.className;
|
|
12
|
+
let t2;
|
|
13
|
+
if ($[0] !== t1) {
|
|
14
|
+
t2 = clsx("w-full min-w-0 max-w-full", t1, "[&_label]:sr-only");
|
|
15
|
+
$[0] = t1;
|
|
16
|
+
$[1] = t2;
|
|
17
|
+
} else t2 = $[1];
|
|
18
|
+
const t3 = inputProps?.containerClassName;
|
|
19
|
+
let t4;
|
|
20
|
+
if ($[2] !== t3) {
|
|
21
|
+
t4 = clsx("w-full min-w-0 max-w-full", t3);
|
|
22
|
+
$[2] = t3;
|
|
23
|
+
$[3] = t4;
|
|
24
|
+
} else t4 = $[3];
|
|
25
|
+
const t5 = inputProps?.inputClassName;
|
|
26
|
+
let t6;
|
|
27
|
+
if ($[4] !== t5) {
|
|
28
|
+
t6 = clsx("min-w-0 max-w-full truncate", t5);
|
|
29
|
+
$[4] = t5;
|
|
30
|
+
$[5] = t6;
|
|
31
|
+
} else t6 = $[5];
|
|
32
|
+
let t7;
|
|
33
|
+
if ($[6] !== inputProps || $[7] !== t2 || $[8] !== t4 || $[9] !== t6) {
|
|
34
|
+
t7 = {
|
|
35
|
+
...inputProps,
|
|
36
|
+
as: "filter",
|
|
37
|
+
className: t2,
|
|
38
|
+
containerClassName: t4,
|
|
39
|
+
inputClassName: t6,
|
|
40
|
+
hideLabel: true,
|
|
41
|
+
isClearable: true,
|
|
42
|
+
placeholder: "",
|
|
43
|
+
size: "extra-small"
|
|
44
|
+
};
|
|
45
|
+
$[6] = inputProps;
|
|
46
|
+
$[7] = t2;
|
|
47
|
+
$[8] = t4;
|
|
48
|
+
$[9] = t6;
|
|
49
|
+
$[10] = t7;
|
|
50
|
+
} else t7 = $[10];
|
|
51
|
+
const props = t7;
|
|
52
|
+
let t8;
|
|
53
|
+
if ($[11] !== filterKey || $[12] !== inputDef.label) {
|
|
54
|
+
t8 = typeof inputDef.label === "string" && inputDef.label.trim() ? inputDef.label : filterKey;
|
|
55
|
+
$[11] = filterKey;
|
|
56
|
+
$[12] = inputDef.label;
|
|
57
|
+
$[13] = t8;
|
|
58
|
+
} else t8 = $[13];
|
|
59
|
+
let t9;
|
|
60
|
+
if ($[14] !== inputDef || $[15] !== props || $[16] !== t8) {
|
|
61
|
+
t9 = {
|
|
62
|
+
...inputDef,
|
|
63
|
+
label: t8,
|
|
64
|
+
placeholder: "",
|
|
65
|
+
props
|
|
66
|
+
};
|
|
67
|
+
$[14] = inputDef;
|
|
68
|
+
$[15] = props;
|
|
69
|
+
$[16] = t8;
|
|
70
|
+
$[17] = t9;
|
|
71
|
+
} else t9 = $[17];
|
|
72
|
+
const inlineInputDef = t9;
|
|
73
|
+
let t10;
|
|
74
|
+
if ($[18] !== className) {
|
|
75
|
+
t10 = clsx("w-full min-w-0 max-w-full [&>*]:w-full [&_*]:min-w-0", className);
|
|
76
|
+
$[18] = className;
|
|
77
|
+
$[19] = t10;
|
|
78
|
+
} else t10 = $[19];
|
|
79
|
+
let t11;
|
|
80
|
+
if ($[20] !== inlineInputDef) {
|
|
81
|
+
t11 = [inlineInputDef];
|
|
82
|
+
$[20] = inlineInputDef;
|
|
83
|
+
$[21] = t11;
|
|
84
|
+
} else t11 = $[21];
|
|
85
|
+
let t12;
|
|
86
|
+
if ($[22] !== form || $[23] !== t11) {
|
|
87
|
+
t12 = /* @__PURE__ */ jsx(Inputs, {
|
|
88
|
+
form,
|
|
89
|
+
inputDefs: t11
|
|
90
|
+
});
|
|
91
|
+
$[22] = form;
|
|
92
|
+
$[23] = t11;
|
|
93
|
+
$[24] = t12;
|
|
94
|
+
} else t12 = $[24];
|
|
95
|
+
let t13;
|
|
96
|
+
if ($[25] !== t10 || $[26] !== t12) {
|
|
97
|
+
t13 = /* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: t10,
|
|
99
|
+
children: t12
|
|
100
|
+
});
|
|
101
|
+
$[25] = t10;
|
|
102
|
+
$[26] = t12;
|
|
103
|
+
$[27] = t13;
|
|
104
|
+
} else t13 = $[27];
|
|
105
|
+
return t13;
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
export { TableColumnFilterInput };
|