nntc-ui 0.0.40 → 0.0.42
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/index.d.ts +11 -8
- package/index.js +22 -13
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -264,10 +264,16 @@ interface FilterBy {
|
|
|
264
264
|
values: (string | number)[];
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
type ColumnAlign = 'Left' | 'Right' | 'Center';
|
|
268
|
-
|
|
269
267
|
type SortType = 'alphanumeric' | 'locale';
|
|
270
268
|
|
|
269
|
+
interface SortBy {
|
|
270
|
+
columnName: string;
|
|
271
|
+
direction: 'asc' | 'desc';
|
|
272
|
+
sortType?: SortType;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
type ColumnAlign = 'Left' | 'Right' | 'Center';
|
|
276
|
+
|
|
271
277
|
type VerticalAlign = 'FlexStart' | 'Center' | 'FlexEnd';
|
|
272
278
|
|
|
273
279
|
interface TableColumn {
|
|
@@ -318,15 +324,12 @@ interface Props$7 {
|
|
|
318
324
|
borders?: Borders;
|
|
319
325
|
showUniqueValuesCount?: boolean;
|
|
320
326
|
globalFilters?: FilterBy[];
|
|
327
|
+
globalSorts?: SortBy[];
|
|
328
|
+
onFiltersChange?: (filters: FilterBy[]) => void;
|
|
329
|
+
onSortsChange?: (sorts: SortBy[]) => void;
|
|
321
330
|
}
|
|
322
331
|
declare function VirtualTable(props: UiProps<Props$7>): react_jsx_runtime.JSX.Element;
|
|
323
332
|
|
|
324
|
-
interface SortBy {
|
|
325
|
-
columnName: string;
|
|
326
|
-
direction: 'asc' | 'desc';
|
|
327
|
-
sortType?: SortType;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
333
|
interface Item {
|
|
331
334
|
id: string;
|
|
332
335
|
name: string;
|
package/index.js
CHANGED
|
@@ -2967,9 +2967,9 @@ function HeaderDropdown(props) {
|
|
|
2967
2967
|
return [...prev.filter((p) => !(p.columnName === headerResultName && p.type === "numberRange"))];
|
|
2968
2968
|
} else {
|
|
2969
2969
|
const newResult = [...prev];
|
|
2970
|
-
const
|
|
2971
|
-
if (
|
|
2972
|
-
|
|
2970
|
+
const existIndex = newResult.findIndex((p) => p.columnName === headerResultName && p.type === "numberRange");
|
|
2971
|
+
if (existIndex !== -1) {
|
|
2972
|
+
newResult[existIndex] = { ...newResult[existIndex], values };
|
|
2973
2973
|
} else {
|
|
2974
2974
|
newResult.push({
|
|
2975
2975
|
columnName: headerResultName,
|
|
@@ -2987,9 +2987,9 @@ function HeaderDropdown(props) {
|
|
|
2987
2987
|
return [...prev.filter((p) => !(p.columnName === headerResultName && p.type === "dateRange"))];
|
|
2988
2988
|
} else {
|
|
2989
2989
|
const newResult = [...prev];
|
|
2990
|
-
const
|
|
2991
|
-
if (
|
|
2992
|
-
|
|
2990
|
+
const existIndex = newResult.findIndex((p) => p.columnName === headerResultName && p.type === "dateRange");
|
|
2991
|
+
if (existIndex !== -1) {
|
|
2992
|
+
newResult[existIndex] = { ...newResult[existIndex], values };
|
|
2993
2993
|
} else {
|
|
2994
2994
|
newResult.push({
|
|
2995
2995
|
columnName: headerResultName,
|
|
@@ -3009,9 +3009,9 @@ function HeaderDropdown(props) {
|
|
|
3009
3009
|
});
|
|
3010
3010
|
setFilterBy((prev) => {
|
|
3011
3011
|
const newResult = [...prev];
|
|
3012
|
-
const
|
|
3013
|
-
if (
|
|
3014
|
-
|
|
3012
|
+
const existIndex = newResult.findIndex((p) => p.columnName === headerResultName && p.type === "value");
|
|
3013
|
+
if (existIndex !== -1) {
|
|
3014
|
+
newResult[existIndex] = { ...newResult[existIndex], values: Object.keys(selected5) };
|
|
3015
3015
|
} else {
|
|
3016
3016
|
newResult.push({ columnName: headerResultName, type: "value", values: Object.keys(selected5) });
|
|
3017
3017
|
}
|
|
@@ -3231,11 +3231,14 @@ function VirtualTable(props) {
|
|
|
3231
3231
|
useTableContainerAsRootForPopup,
|
|
3232
3232
|
size = "small",
|
|
3233
3233
|
borders = "horizontal",
|
|
3234
|
-
showUniqueValuesCount = false
|
|
3235
|
-
|
|
3234
|
+
showUniqueValuesCount = false,
|
|
3235
|
+
globalFilters,
|
|
3236
|
+
globalSorts,
|
|
3237
|
+
onFiltersChange,
|
|
3238
|
+
onSortsChange
|
|
3236
3239
|
} = props;
|
|
3237
|
-
const [filterBy, setFilterBy] = useState16([]);
|
|
3238
|
-
const [sortBy, setSortBy] = useState16([{ columnName: "isNew", direction: "desc" }]);
|
|
3240
|
+
const [filterBy, setFilterBy] = useState16(globalFilters ?? []);
|
|
3241
|
+
const [sortBy, setSortBy] = useState16([...globalSorts ?? [], { columnName: "isNew", direction: "desc" }]);
|
|
3239
3242
|
const tableContainerRef = useRef11(null);
|
|
3240
3243
|
const memoizedColumns = useMemo6(() => getColumns(columns), [columns]);
|
|
3241
3244
|
const memoizedData = useMemo6(() => {
|
|
@@ -3372,6 +3375,12 @@ function VirtualTable(props) {
|
|
|
3372
3375
|
fixedColumnsCount && virtualColumns[fixedColumnsCount].index !== fixedColumnsCount ? virtualColumns[fixedColumnsCount].start - fixedColumnsWidth : virtualColumns[0].start,
|
|
3373
3376
|
columnsTotalSize - virtualColumns[virtualColumns.length - 1].end
|
|
3374
3377
|
] : [0, 0];
|
|
3378
|
+
useEffect8(() => {
|
|
3379
|
+
onFiltersChange?.(filterBy);
|
|
3380
|
+
}, [filterBy]);
|
|
3381
|
+
useEffect8(() => {
|
|
3382
|
+
onSortsChange?.(sortBy.filter((sb) => sb.columnName !== "isNew"));
|
|
3383
|
+
}, [sortBy]);
|
|
3375
3384
|
return /* @__PURE__ */ jsx34(
|
|
3376
3385
|
"div",
|
|
3377
3386
|
{
|