fastapi-rtk 0.1.23 → 0.1.25
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/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/errorBoundaryUtils.cjs +1 -1
- package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/useBaseQuery.cjs +2 -2
- package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/useQuery.cjs +1 -1
- package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/errorBoundaryUtils.mjs +1 -1
- package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/useBaseQuery.mjs +2 -2
- package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/useQuery.mjs +1 -1
- package/dist/core/cjs/ActionIcons/utils/convertToFormInputs.cjs +2 -2
- package/dist/core/cjs/Tables/NextGenDataGrid/NextGenDataGrid.cjs +0 -2
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilter.cjs +9 -9
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/ColumnHeaderFilterInput.cjs +93 -66
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/HeaderInputs/HeaderSelectInput.cjs +12 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/HeaderInputs/HeaderTextInput.cjs +11 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useColumns/useColumns.cjs +10 -10
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.cjs +1 -2
- package/dist/core/cjs/Wrappers/ApiProvider/hooks/useProvideApi.cjs +4 -3
- package/dist/core/cjs/Wrappers/ApiProvider/hooks/useProvideForm.cjs +1 -1
- package/dist/core/cjs/Wrappers/Provider/Provider.cjs +2 -2
- package/dist/core/cjs/Wrappers/Provider/hooks/useProvideAuth.cjs +2 -2
- package/dist/core/cjs/Wrappers/Provider/hooks/useProvideInfo.cjs +1 -1
- package/dist/core/cjs/fab-react-toolkit-patch/api/hooks/useProvideApi.cjs +4 -3
- package/dist/core/cjs/fab-react-toolkit-patch/auth/hooks/useProvideAuth.cjs +2 -2
- package/dist/core/cjs/fab-react-toolkit-patch/auth/hooks/useProvideInfo.cjs +1 -1
- package/dist/core/esm/ActionIcons/utils/convertToFormInputs.mjs +2 -2
- package/dist/core/esm/Tables/NextGenDataGrid/NextGenDataGrid.mjs +0 -2
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilter.mjs +9 -9
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/ColumnHeaderFilterInput.mjs +95 -68
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/HeaderInputs/HeaderSelectInput.mjs +12 -1
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/HeaderInputs/HeaderTextInput.mjs +11 -1
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useColumns/useColumns.mjs +10 -10
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.mjs +1 -2
- package/dist/core/esm/Wrappers/ApiProvider/hooks/useProvideApi.mjs +4 -3
- package/dist/core/esm/Wrappers/ApiProvider/hooks/useProvideForm.mjs +1 -1
- package/dist/core/esm/Wrappers/Provider/Provider.mjs +2 -2
- package/dist/core/esm/Wrappers/Provider/hooks/useProvideAuth.mjs +2 -2
- package/dist/core/esm/Wrappers/Provider/hooks/useProvideInfo.mjs +1 -1
- package/dist/core/esm/fab-react-toolkit-patch/api/hooks/useProvideApi.mjs +4 -3
- package/dist/core/esm/fab-react-toolkit-patch/auth/hooks/useProvideAuth.mjs +2 -2
- package/dist/core/esm/fab-react-toolkit-patch/auth/hooks/useProvideInfo.mjs +1 -1
- package/dist/core/lib/Tables/NextGenDataGrid/NextGenDataGrid.d.ts +24 -16
- package/dist/core/lib/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilter.d.ts +7 -7
- package/dist/core/lib/Tables/NextGenDataGrid/hooks/useColumns/ColumnHeaderFilterInput/ColumnHeaderFilterInput.d.ts +4 -4
- package/dist/core/lib/Tables/NextGenDataGrid/hooks/useToolbar/basicToolbars.d.ts +0 -1
- package/dist/hooks/cjs/index.cjs +2 -0
- package/dist/hooks/cjs/useSyncValues/useSyncValues.cjs +30 -0
- package/dist/hooks/esm/index.mjs +2 -0
- package/dist/hooks/esm/useSyncValues/useSyncValues.mjs +30 -0
- package/dist/hooks/lib/index.d.ts +1 -0
- package/dist/hooks/lib/useSyncValues/index.d.ts +1 -0
- package/dist/hooks/lib/useSyncValues/useSyncValues.d.ts +7 -0
- package/dist/zustand/cjs/useProxy/useProxy.cjs +1 -1
- package/dist/zustand/esm/useProxy/useProxy.mjs +1 -1
- package/package.json +2 -1
- package/dist/core/cjs/Tables/NextGenDataGrid/hooks/useQueryParams.cjs +0 -43
- package/dist/core/esm/Tables/NextGenDataGrid/hooks/useQueryParams.mjs +0 -43
- package/dist/core/lib/Tables/NextGenDataGrid/hooks/useQueryParams.d.ts +0 -1
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/focusManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/infiniteQueryBehavior.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/mutation.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/mutationCache.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/notifyManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/onlineManager.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/query.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryCache.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryClient.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryObserver.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/removable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/retryer.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/subscribable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/thenable.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/utils.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/IsRestoringProvider.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/QueryClientProvider.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/QueryErrorResetBoundary.cjs +0 -0
- /package/dist/.external/cjs/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/suspense.cjs +0 -0
- /package/dist/.external/cjs/{zustand@5.0.5_@types_react@18.3.22_react@18.3.1 → zustand@5.0.5_@types_react@18.3.23_react@18.3.1}/zustand/esm/react.cjs +0 -0
- /package/dist/.external/cjs/{zustand@5.0.5_@types_react@18.3.22_react@18.3.1 → zustand@5.0.5_@types_react@18.3.23_react@18.3.1}/zustand/esm/vanilla.cjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/focusManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/infiniteQueryBehavior.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/mutation.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/mutationCache.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/notifyManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/onlineManager.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/query.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryCache.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryClient.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/queryObserver.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/removable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/retryer.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/subscribable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/thenable.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_query-core@5.76.2 → @tanstack_query-core@5.77.2}/@tanstack/query-core/build/modern/utils.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/IsRestoringProvider.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/QueryClientProvider.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/QueryErrorResetBoundary.mjs +0 -0
- /package/dist/.external/esm/{@tanstack_react-query@5.76.2_react@18.3.1 → @tanstack_react-query@5.77.2_react@18.3.1}/@tanstack/react-query/build/modern/suspense.mjs +0 -0
- /package/dist/.external/esm/{zustand@5.0.5_@types_react@18.3.22_react@18.3.1 → zustand@5.0.5_@types_react@18.3.23_react@18.3.1}/zustand/esm/react.mjs +0 -0
- /package/dist/.external/esm/{zustand@5.0.5_@types_react@18.3.22_react@18.3.1 → zustand@5.0.5_@types_react@18.3.23_react@18.3.1}/zustand/esm/vanilla.mjs +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import classes from "./headerinput.module.css.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { useSyncValues } from "fastapi-rtk/hooks";
|
|
4
4
|
import { getValueOrDefault, parseFromValuesOrFunc } from "fastapi-rtk/utils";
|
|
5
5
|
import { Tooltip, Indicator, CloseButton } from "@mantine/core";
|
|
6
6
|
import { useField } from "@mantine/form";
|
|
7
|
-
import { useElementSize, useMergedRef,
|
|
7
|
+
import { useElementSize, useMergedRef, useDidUpdate } from "@mantine/hooks";
|
|
8
8
|
import { clsx } from "../../../../../../../.external/esm/clsx@2.1.1/clsx/dist/clsx.mjs";
|
|
9
|
-
import { forwardRef, cloneElement, useMemo, useRef
|
|
9
|
+
import { forwardRef, cloneElement, useMemo, useRef } from "react";
|
|
10
10
|
import { useApi } from "../../../../../hooks/api/useApi.mjs";
|
|
11
|
-
import { useAuth } from "../../../../../hooks/auth/useAuth.mjs";
|
|
12
11
|
import { getProps } from "../../../utils.mjs";
|
|
13
12
|
import { getBasicInput } from "../utils.mjs";
|
|
14
13
|
import { HeaderInput } from "./HeaderInput.mjs";
|
|
@@ -34,83 +33,111 @@ function ColumnHeaderFilterInput({
|
|
|
34
33
|
children,
|
|
35
34
|
opr,
|
|
36
35
|
enableFilterModes,
|
|
36
|
+
filters,
|
|
37
37
|
filterProps,
|
|
38
38
|
filterState,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
filters,
|
|
39
|
+
filterSync,
|
|
40
|
+
updateQueryParams,
|
|
42
41
|
actionIconProps,
|
|
43
42
|
functionProps,
|
|
44
43
|
mrtProps
|
|
45
44
|
}) {
|
|
45
|
+
var _a, _b;
|
|
46
46
|
const { column } = mrtProps;
|
|
47
|
-
const { info, queryParams } = useApi();
|
|
48
|
-
const api = useApi();
|
|
49
|
-
const auth = useAuth();
|
|
47
|
+
const { info, queryParams, setQueryParams } = useApi();
|
|
50
48
|
const schema = useMemo(() => {
|
|
51
|
-
var
|
|
52
|
-
return (
|
|
49
|
+
var _a2, _b2;
|
|
50
|
+
return (_b2 = (_a2 = info == null ? void 0 : info.filters) == null ? void 0 : _a2[column.id]) == null ? void 0 : _b2.schema;
|
|
53
51
|
}, [column.id, info == null ? void 0 : info.filters]);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
52
|
+
const field = useField({ mode: "controlled" });
|
|
53
|
+
useSyncValues(
|
|
54
|
+
[
|
|
55
|
+
{
|
|
56
|
+
value: field.getValue(),
|
|
57
|
+
onChange: field.getInputProps().onChange,
|
|
58
|
+
log: (value) => console.log(`Field value changed to: ${value}`)
|
|
59
|
+
},
|
|
60
|
+
...filterState ? [
|
|
61
|
+
{
|
|
62
|
+
...filterState,
|
|
63
|
+
log: (value) => console.log(`filterState value changed to: ${value}`)
|
|
64
|
+
}
|
|
65
|
+
] : [],
|
|
66
|
+
{
|
|
67
|
+
value: column.getFilterValue(),
|
|
68
|
+
onChange: column.setFilterValue,
|
|
69
|
+
log: (value) => console.log(`Column filter value changed to: ${value}`)
|
|
70
|
+
},
|
|
71
|
+
...updateQueryParams ? [
|
|
72
|
+
{
|
|
73
|
+
value: (_b = (_a = queryParams == null ? void 0 : queryParams.filters) == null ? void 0 : _a.find((qpFilter) => qpFilter.id === column.id)) == null ? void 0 : _b.value,
|
|
74
|
+
onChange: (value) => {
|
|
75
|
+
setQueryParams((prev) => {
|
|
76
|
+
const newFilters = (prev == null ? void 0 : prev.filters) || [];
|
|
77
|
+
const newFilter = {
|
|
78
|
+
id: column.id,
|
|
79
|
+
col: column.id,
|
|
80
|
+
opr,
|
|
81
|
+
value
|
|
82
|
+
};
|
|
83
|
+
if (value === void 0) {
|
|
84
|
+
return { ...prev, filters: newFilters.filter((qpFilter) => qpFilter.id !== newFilter.id) };
|
|
85
|
+
}
|
|
86
|
+
const existingFilterIndex = newFilters.findIndex((qpFilter) => qpFilter.id === newFilter.id);
|
|
87
|
+
if (existingFilterIndex > -1) {
|
|
88
|
+
newFilters[existingFilterIndex] = newFilter;
|
|
89
|
+
} else {
|
|
90
|
+
newFilters.push(newFilter);
|
|
91
|
+
}
|
|
92
|
+
return { ...prev, filters: newFilters };
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
log: (value) => console.log(`Query Params filter value changed to: ${value}`)
|
|
96
|
+
}
|
|
97
|
+
] : []
|
|
98
|
+
],
|
|
99
|
+
filterSync
|
|
95
100
|
);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const lastOpr = useRef(opr);
|
|
102
|
+
useDidUpdate(() => {
|
|
103
|
+
var _a2;
|
|
104
|
+
if (opr !== lastOpr.current) {
|
|
105
|
+
lastOpr.current = opr;
|
|
106
|
+
if (filterState) {
|
|
107
|
+
(_a2 = filterState.onOprChange) == null ? void 0 : _a2.call(filterState, { value: filterState.value, opr });
|
|
108
|
+
if (updateQueryParams) {
|
|
109
|
+
setQueryParams((prev) => {
|
|
110
|
+
var _a3;
|
|
111
|
+
return {
|
|
112
|
+
...prev,
|
|
113
|
+
filters: (_a3 = prev == null ? void 0 : prev.filters) == null ? void 0 : _a3.map((qpFilter) => {
|
|
114
|
+
if (qpFilter.id === column.id) {
|
|
115
|
+
return {
|
|
116
|
+
...qpFilter,
|
|
117
|
+
opr,
|
|
118
|
+
// Update the operator
|
|
119
|
+
value: field.getValue()
|
|
120
|
+
// Ensure the value is updated from the field
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return qpFilter;
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
field.reset();
|
|
130
|
+
}
|
|
102
131
|
}
|
|
103
|
-
}, [
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
onFilterMount == null ? void 0 : onFilterMount({ api: api.getState(), auth: auth.getState(), mrtProps });
|
|
106
|
-
}, [onFilterMount]);
|
|
132
|
+
}, [opr]);
|
|
107
133
|
const component = useMemo(
|
|
108
134
|
() => getValueOrDefault(enableFilterModes ? children == null ? void 0 : children[opr] : children, getBasicInput(opr, schema)),
|
|
109
135
|
[children, enableFilterModes, opr, schema]
|
|
110
136
|
);
|
|
111
137
|
const clearIconProps = useMemo(
|
|
112
|
-
() => ({ ...actionIconProps, variant: "transparent", c: void 0, size: "sm", onClick:
|
|
113
|
-
|
|
138
|
+
() => ({ ...actionIconProps, variant: "transparent", c: void 0, size: "sm", onClick: field.reset }),
|
|
139
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
|
+
[actionIconProps]
|
|
114
141
|
);
|
|
115
142
|
const configuration = parseFromValuesOrFunc(
|
|
116
143
|
enableFilterModes ? getProps(filterProps, opr) : filterProps,
|
|
@@ -118,17 +145,17 @@ function ColumnHeaderFilterInput({
|
|
|
118
145
|
);
|
|
119
146
|
const headerInputProps = useMemo(
|
|
120
147
|
() => {
|
|
121
|
-
var
|
|
148
|
+
var _a2, _b2;
|
|
122
149
|
return {
|
|
123
150
|
w: "100%",
|
|
124
151
|
variant: "unstyled",
|
|
125
152
|
disabled: !(filters == null ? void 0 : filters.length),
|
|
126
153
|
title: !filters.length ? "No filters" : void 0,
|
|
127
|
-
placeholder: (
|
|
154
|
+
placeholder: (_a2 = mrtProps.table.options.localization.filterByColumn) == null ? void 0 : _a2.replace(
|
|
128
155
|
"{column}",
|
|
129
156
|
String(mrtProps.column.columnDef.header)
|
|
130
157
|
),
|
|
131
|
-
"aria-label": (
|
|
158
|
+
"aria-label": (_b2 = mrtProps.table.options.localization.filterByColumn) == null ? void 0 : _b2.replace(
|
|
132
159
|
"{column}",
|
|
133
160
|
String(mrtProps.column.columnDef.header)
|
|
134
161
|
),
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Select } from "@mantine/core";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
const HeaderSelectInput = forwardRef(({ data, clearIcon, mrtprops: { selectprops }, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4
|
+
const HeaderSelectInput = forwardRef(({ data, clearIcon, mrtprops: { selectprops }, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
5
|
+
Select,
|
|
6
|
+
{
|
|
7
|
+
ref,
|
|
8
|
+
data,
|
|
9
|
+
searchable: true,
|
|
10
|
+
...selectprops,
|
|
11
|
+
...props,
|
|
12
|
+
value: props.value ?? null,
|
|
13
|
+
onChange: (value) => props.onChange(value ?? void 0)
|
|
14
|
+
}
|
|
15
|
+
));
|
|
5
16
|
HeaderSelectInput.displayName = "HeaderSelectInput";
|
|
6
17
|
export {
|
|
7
18
|
HeaderSelectInput
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TextInput } from "@mantine/core";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
const HeaderTextInput = forwardRef(({ clearIcon, mrtprops: { textinputprops }, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
4
|
+
const HeaderTextInput = forwardRef(({ clearIcon, mrtprops: { textinputprops }, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
5
|
+
TextInput,
|
|
6
|
+
{
|
|
7
|
+
ref,
|
|
8
|
+
rightSection: clearIcon,
|
|
9
|
+
...textinputprops,
|
|
10
|
+
...props,
|
|
11
|
+
value: props.value || "",
|
|
12
|
+
onChange: (e) => props.onChange(e.target.value || void 0)
|
|
13
|
+
}
|
|
14
|
+
));
|
|
5
15
|
HeaderTextInput.displayName = "HeaderTextInput";
|
|
6
16
|
export {
|
|
7
17
|
HeaderTextInput
|
|
@@ -28,11 +28,11 @@ function useColumns(columnProps, header, body, textFilterSeparator) {
|
|
|
28
28
|
enableAdvancedFilters,
|
|
29
29
|
filterComponent,
|
|
30
30
|
filterProps,
|
|
31
|
-
filterModeDescription,
|
|
32
|
-
filterMenu,
|
|
33
31
|
filterState,
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
filterSync,
|
|
33
|
+
filterMenu,
|
|
34
|
+
filterModeDescription,
|
|
35
|
+
updateQueryParams = true,
|
|
36
36
|
defaultOpr = ((_d = (_c = (_b = (_a = info == null ? void 0 : info.filters) == null ? void 0 : _a[col]) == null ? void 0 : _b.filters) == null ? void 0 : _c[0]) == null ? void 0 : _d.operator) || ""
|
|
37
37
|
} = getProps(header, specialKey.all, col);
|
|
38
38
|
const filterFn = fromFilterToFilterFn(col, defaultOpr);
|
|
@@ -51,14 +51,14 @@ function useColumns(columnProps, header, body, textFilterSeparator) {
|
|
|
51
51
|
{
|
|
52
52
|
enableFilterModes,
|
|
53
53
|
enableAdvancedFilters,
|
|
54
|
-
filterProps,
|
|
55
|
-
filterModeDescription,
|
|
56
|
-
filterMenu,
|
|
57
|
-
filterState,
|
|
58
|
-
onFilterClear,
|
|
59
|
-
onFilterMount,
|
|
60
54
|
filters,
|
|
61
55
|
filterFn,
|
|
56
|
+
filterProps,
|
|
57
|
+
filterState,
|
|
58
|
+
filterSync,
|
|
59
|
+
filterMenu,
|
|
60
|
+
filterModeDescription,
|
|
61
|
+
updateQueryParams,
|
|
62
62
|
mrtProps: props,
|
|
63
63
|
children: filterComponent
|
|
64
64
|
}
|
|
@@ -3,7 +3,6 @@ import { MRT_ToggleFullScreenButton, MRT_ToggleDensePaddingButton, MRT_ShowHideC
|
|
|
3
3
|
import { Add } from "../../../../ActionIcons/Add/Add.mjs";
|
|
4
4
|
import { Download } from "../../../../ActionIcons/Download/Download.mjs";
|
|
5
5
|
import { Refresh } from "../../../../ActionIcons/Refresh/Refresh.mjs";
|
|
6
|
-
import { Upload } from "../../../../ActionIcons/Upload/Upload.mjs";
|
|
7
6
|
function getBasicToolbars(table, rules) {
|
|
8
7
|
return {
|
|
9
8
|
toggleGlobalFilter: /* @__PURE__ */ jsx(MRT_ToggleGlobalFilterButton, { table, disabled: false }, "basic-toggleGlobalFilter"),
|
|
@@ -11,7 +10,7 @@ function getBasicToolbars(table, rules) {
|
|
|
11
10
|
refresh: /* @__PURE__ */ jsx(Refresh, { tooltipProps: { label: table.options.localization.refresh } }, "basic-refresh"),
|
|
12
11
|
add: (rules == null ? void 0 : rules.add) && /* @__PURE__ */ jsx(Add, { tooltipProps: { label: table.options.localization.add } }, "basic-add"),
|
|
13
12
|
download: (rules == null ? void 0 : rules.download) && /* @__PURE__ */ jsx(Download, { tooltipProps: { label: table.options.localization.download } }, "basic-download"),
|
|
14
|
-
upload:
|
|
13
|
+
// upload: rules?.upload && <Upload key="basic-upload" tooltipProps={{ label: table.options.localization.upload }} />, //! Disabled until further notice
|
|
15
14
|
showHideColumns: /* @__PURE__ */ jsx(MRT_ShowHideColumnsButton, { table }, "basic-showHideColumns"),
|
|
16
15
|
toggleDensePadding: /* @__PURE__ */ jsx(MRT_ToggleDensePaddingButton, { table }, "basic-toggleDensePadding"),
|
|
17
16
|
toggleFullScreen: /* @__PURE__ */ jsx(MRT_ToggleFullScreenButton, { table }, "basic-toggleFullScreen")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
|
2
2
|
import { getItemId, urlJoin } from "fastapi-rtk/utils";
|
|
3
3
|
import { useDidUpdate, useSetState } from "@mantine/hooks";
|
|
4
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
4
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
5
5
|
import { createItem } from "../utils/api/createItem.mjs";
|
|
6
6
|
import { deleteItem } from "../utils/api/deleteItem.mjs";
|
|
7
7
|
import { downloadItems } from "../utils/api/downloadItems.mjs";
|
|
@@ -13,7 +13,7 @@ import { uploadItems } from "../utils/api/uploadItems.mjs";
|
|
|
13
13
|
import { convertId } from "../utils/convertId.mjs";
|
|
14
14
|
import { convertInfo } from "../utils/convertInfo.mjs";
|
|
15
15
|
import { createQueryParams } from "../utils/createQueryParams.mjs";
|
|
16
|
-
import { keepPreviousData } from "../../../../../.external/esm/@tanstack_query-core@5.
|
|
16
|
+
import { keepPreviousData } from "../../../../../.external/esm/@tanstack_query-core@5.77.2/@tanstack/query-core/build/modern/utils.mjs";
|
|
17
17
|
function useProvideApi({
|
|
18
18
|
path,
|
|
19
19
|
initialQueryParams,
|
|
@@ -266,11 +266,12 @@ function useProvideApi({
|
|
|
266
266
|
});
|
|
267
267
|
}, [data, setQueryParamsCallback, setStreaming, streamingMode]);
|
|
268
268
|
const specialKey = useMemo(() => {
|
|
269
|
+
var _a;
|
|
269
270
|
const specialKey2 = {
|
|
270
271
|
all: "all",
|
|
271
272
|
actions: "actions"
|
|
272
273
|
};
|
|
273
|
-
data == null ? void 0 : data.list_columns.forEach((key) => {
|
|
274
|
+
(_a = data == null ? void 0 : data.list_columns) == null ? void 0 : _a.forEach((key) => {
|
|
274
275
|
if (specialKey2[key]) {
|
|
275
276
|
specialKey2[key] = `_${key}`;
|
|
276
277
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { initialState, VIEW_MODE } from "fastapi-rtk/constants";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { create } from "../../../../../.external/esm/zustand@5.0.5_@types_react@18.3.
|
|
3
|
+
import { create } from "../../../../../.external/esm/zustand@5.0.5_@types_react@18.3.23_react@18.3.1/zustand/esm/react.mjs";
|
|
4
4
|
const useProvideForm = () => {
|
|
5
5
|
const [storeAdd] = useState(
|
|
6
6
|
() => create((set, get) => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useProxy } from "fastapi-rtk/zustand";
|
|
3
|
-
import { QueryClient } from "../../../../.external/esm/@tanstack_query-core@5.
|
|
4
|
-
import { QueryClientProvider } from "../../../../.external/esm/@tanstack_react-query@5.
|
|
3
|
+
import { QueryClient } from "../../../../.external/esm/@tanstack_query-core@5.77.2/@tanstack/query-core/build/modern/queryClient.mjs";
|
|
4
|
+
import { QueryClientProvider } from "../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/QueryClientProvider.mjs";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { useFabProvideAuth } from "../../fab-react-toolkit-patch/auth/hooks/useProvideAuth.mjs";
|
|
7
7
|
import { useFabProvideInfo } from "../../fab-react-toolkit-patch/auth/hooks/useProvideInfo.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
2
|
-
import { useQueryClient } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
1
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
2
|
+
import { useQueryClient } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/QueryClientProvider.mjs";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
4
|
import { authSignin, authSignout, authResetPassword, authOAuthSignin } from "../utils/authFetch.mjs";
|
|
5
5
|
import { getUser, updateUser } from "../utils/userCRUD.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
1
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { authInfo } from "../utils/authFetch.mjs";
|
|
4
4
|
function useProvideInfo(baseUrl, auth) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
|
2
2
|
import { getItemId, urlJoin } from "fastapi-rtk/utils";
|
|
3
3
|
import { useDidUpdate, useSetState } from "@mantine/hooks";
|
|
4
|
-
import { keepPreviousData } from "../../../../../.external/esm/@tanstack_query-core@5.
|
|
5
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
4
|
+
import { keepPreviousData } from "../../../../../.external/esm/@tanstack_query-core@5.77.2/@tanstack/query-core/build/modern/utils.mjs";
|
|
5
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
6
6
|
import { createItem } from "../utils/api/createItem.mjs";
|
|
7
7
|
import { deleteItem } from "../utils/api/deleteItem.mjs";
|
|
8
8
|
import { downloadItems } from "../utils/api/downloadItems.mjs";
|
|
@@ -266,11 +266,12 @@ function useFabProvideApi({
|
|
|
266
266
|
});
|
|
267
267
|
}, [data, setQueryParamsCallback, setStreaming, streamingMode]);
|
|
268
268
|
const specialKey = useMemo(() => {
|
|
269
|
+
var _a;
|
|
269
270
|
const specialKey2 = {
|
|
270
271
|
all: "all",
|
|
271
272
|
actions: "actions"
|
|
272
273
|
};
|
|
273
|
-
data == null ? void 0 : data.list_columns.forEach((key) => {
|
|
274
|
+
(_a = data == null ? void 0 : data.list_columns) == null ? void 0 : _a.forEach((key) => {
|
|
274
275
|
if (specialKey2[key]) {
|
|
275
276
|
specialKey2[key] = `_${key}`;
|
|
276
277
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
2
|
-
import { useQueryClient } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
1
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
2
|
+
import { useQueryClient } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/QueryClientProvider.mjs";
|
|
3
3
|
import { useState, useCallback } from "react";
|
|
4
4
|
import { authSignin, authSignout, authResetPassword, authOAuthSignin } from "../utils/authFetch.mjs";
|
|
5
5
|
import { getUser, updateUser } from "../utils/userCRUD.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.
|
|
1
|
+
import { useQuery } from "../../../../../.external/esm/@tanstack_react-query@5.77.2_react@18.3.1/@tanstack/react-query/build/modern/useQuery.mjs";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { authInfo } from "../utils/authFetch.mjs";
|
|
4
4
|
function useFabProvideInfo(baseUrl, auth) {
|
|
@@ -14,11 +14,21 @@ export type NextGenDataGridFilterStateProps = {
|
|
|
14
14
|
*/
|
|
15
15
|
value: any;
|
|
16
16
|
/**
|
|
17
|
-
* -
|
|
17
|
+
* - Callback when the filter value changes
|
|
18
18
|
*/
|
|
19
19
|
onChange: (value: any) => void;
|
|
20
20
|
/**
|
|
21
|
-
* -
|
|
21
|
+
* - Callback when the operator changes.
|
|
22
|
+
*/
|
|
23
|
+
onOprChange?: ({ value: any, opr: string }: any) => void;
|
|
24
|
+
};
|
|
25
|
+
export type NextGenDataGridFilterSyncProps = {
|
|
26
|
+
/**
|
|
27
|
+
* - Function to compare values for synchronization. Defaults to strict equality (`===`).
|
|
28
|
+
*/
|
|
29
|
+
equals?: (a: any, b: any) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* - Debounce delay in milliseconds for synchronization. Defaults to `DEBOUNCE_DELAY`.
|
|
22
32
|
*/
|
|
23
33
|
delay?: number;
|
|
24
34
|
};
|
|
@@ -43,34 +53,32 @@ export type NextGenDataGridHeaderProps = {
|
|
|
43
53
|
* - Props for the filter component. When `enableFilterModes` is enabled, this will be a key-value pair object where the key is the filter operator and the value is the filter component props
|
|
44
54
|
*/
|
|
45
55
|
filterProps?: Record<string, any> | (({ api, auth, mrtProps }: any) => Record<string, any> | Record<string, Record<string, any> | (({ api, auth, mrtProps }: any) => Record<string, any>)>);
|
|
46
|
-
/**
|
|
47
|
-
* - Customize the description below the filter when `enableFilterModes` is enabled. Defaults to `Filter Mode: {Filter name}`
|
|
48
|
-
*/
|
|
49
|
-
filterModeDescription?: JSX.Element | (({ api, auth, mrtProps, componentProps: { value: string } }: any) => JSX.Element);
|
|
50
|
-
/**
|
|
51
|
-
* - Customize the filter menu action icon beside the filter. Defaults to `Filter Menu` with icon `IconFilterCog`
|
|
52
|
-
*/
|
|
53
|
-
filterMenu?: JSX.Element | (({ api, auth, mrtProps, componentProps: { label: string, disabled: boolean, indicator: number, actionIconProps: Object, onClick: Function } }: any) => JSX.Element);
|
|
54
56
|
/**
|
|
55
57
|
* - Manage filter state externally
|
|
56
58
|
*/
|
|
57
59
|
filterState?: NextGenDataGridFilterStateProps;
|
|
58
60
|
/**
|
|
59
|
-
* -
|
|
61
|
+
* - Options for synchronizing filter state with other components. Defaults to:
|
|
62
|
+
* - `equals`: A function to compare values, defaults to strict equality (`===`).
|
|
63
|
+
* - `delay`: A debounce delay in milliseconds, defaults to `DEBOUNCE_DELAY`. It is recommended to use the default value for `delay` to avoid performance issues.
|
|
60
64
|
*/
|
|
61
|
-
|
|
65
|
+
filterSync?: NextGenDataGridFilterSyncProps;
|
|
62
66
|
/**
|
|
63
|
-
* -
|
|
67
|
+
* - Customize the filter menu action icon beside the filter. Defaults to `Filter Menu` with icon `IconFilterCog`
|
|
64
68
|
*/
|
|
65
|
-
|
|
69
|
+
filterMenu?: JSX.Element | (({ api, auth, mrtProps, componentProps: { label: string, disabled: boolean, indicator: number, actionIconProps: Object, onClick: Function } }: any) => JSX.Element);
|
|
66
70
|
/**
|
|
67
|
-
* -
|
|
71
|
+
* - Customize the description below the filter when `enableFilterModes` is enabled. Defaults to `Filter Mode: {Filter name}`
|
|
68
72
|
*/
|
|
69
|
-
|
|
73
|
+
filterModeDescription?: JSX.Element | (({ api, auth, mrtProps, componentProps: { value: string } }: any) => JSX.Element);
|
|
70
74
|
/**
|
|
71
75
|
* - Whether to update the query params when the filter is applied. Default is true
|
|
72
76
|
*/
|
|
73
77
|
updateQueryParams?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* - Sets the default operator for the filter. The filter componenet may change based on the operator
|
|
80
|
+
*/
|
|
81
|
+
defaultOpr?: string;
|
|
74
82
|
};
|
|
75
83
|
export type NextGenDataGridBodyProps = {
|
|
76
84
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function ColumnHeaderFilter({ children, enableFilterModes, enableAdvancedFilters,
|
|
1
|
+
export function ColumnHeaderFilter({ children, enableFilterModes, enableAdvancedFilters, filters, filterFn, filterProps, filterState, filterSync, filterMenu, filterModeDescription, updateQueryParams, mrtProps, }: {
|
|
2
2
|
children: any;
|
|
3
3
|
enableFilterModes: any;
|
|
4
4
|
enableAdvancedFilters: any;
|
|
5
|
-
filterProps: any;
|
|
6
|
-
filterModeDescription: any;
|
|
7
|
-
filterMenu: any;
|
|
8
|
-
filterState: any;
|
|
9
|
-
onFilterClear: any;
|
|
10
|
-
onFilterMount: any;
|
|
11
5
|
filters: any;
|
|
12
6
|
filterFn: any;
|
|
7
|
+
filterProps: any;
|
|
8
|
+
filterState: any;
|
|
9
|
+
filterSync: any;
|
|
10
|
+
filterMenu: any;
|
|
11
|
+
filterModeDescription: any;
|
|
12
|
+
updateQueryParams: any;
|
|
13
13
|
mrtProps: any;
|
|
14
14
|
}): import("react").JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export function ColumnHeaderFilterInput({ children, opr, enableFilterModes, filterProps, filterState,
|
|
1
|
+
export function ColumnHeaderFilterInput({ children, opr, enableFilterModes, filters, filterProps, filterState, filterSync, updateQueryParams, actionIconProps, functionProps, mrtProps, }: {
|
|
2
2
|
children: any;
|
|
3
3
|
opr: any;
|
|
4
4
|
enableFilterModes: any;
|
|
5
|
+
filters: any;
|
|
5
6
|
filterProps: any;
|
|
6
7
|
filterState: any;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
filters: any;
|
|
8
|
+
filterSync: any;
|
|
9
|
+
updateQueryParams: any;
|
|
10
10
|
actionIconProps: any;
|
|
11
11
|
functionProps: any;
|
|
12
12
|
mrtProps: any;
|
|
@@ -10,7 +10,6 @@ export function getBasicToolbars(table: any, rules?: Record<string, boolean>): {
|
|
|
10
10
|
refresh: import("react").JSX.Element;
|
|
11
11
|
add: import("react").JSX.Element;
|
|
12
12
|
download: import("react").JSX.Element;
|
|
13
|
-
upload: import("react").JSX.Element;
|
|
14
13
|
showHideColumns: import("react").JSX.Element;
|
|
15
14
|
toggleDensePadding: import("react").JSX.Element;
|
|
16
15
|
toggleFullScreen: import("react").JSX.Element;
|
package/dist/hooks/cjs/index.cjs
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const useActionIcon = require("./useActionIcon/useActionIcon.cjs");
|
|
4
4
|
const useCustomFetch = require("./useCustomFetch/useCustomFetch.cjs");
|
|
5
|
+
const useSyncValues = require("./useSyncValues/useSyncValues.cjs");
|
|
5
6
|
const useTrueOnce = require("./useTrueOnce/useTrueOnce.cjs");
|
|
6
7
|
exports.useActionIcon = useActionIcon.useActionIcon;
|
|
7
8
|
exports.useCustomFetch = useCustomFetch.useCustomFetch;
|
|
9
|
+
exports.useSyncValues = useSyncValues.useSyncValues;
|
|
8
10
|
exports.useTrueOnce = useTrueOnce.useTrueOnce;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const constants = require("fastapi-rtk/constants");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const useSyncValues = (states, { equals = (a, b) => a === b, delay = constants.DEBOUNCE_DELAY } = {}) => {
|
|
6
|
+
const lastValueRef = react.useRef(states[0].value);
|
|
7
|
+
const timeoutRef = react.useRef(null);
|
|
8
|
+
react.useEffect(
|
|
9
|
+
() => {
|
|
10
|
+
const changed = states.find((state) => !equals(state.value, lastValueRef.current));
|
|
11
|
+
if (!changed) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
clearTimeout(timeoutRef.current);
|
|
15
|
+
timeoutRef.current = setTimeout(() => {
|
|
16
|
+
lastValueRef.current = changed.value;
|
|
17
|
+
states.forEach((state) => {
|
|
18
|
+
if (!equals(state.value, lastValueRef.current)) {
|
|
19
|
+
state.onChange(lastValueRef.current);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}, delay);
|
|
23
|
+
return () => clearTimeout(timeoutRef.current);
|
|
24
|
+
},
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
states.map((state) => state.value)
|
|
27
|
+
);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
exports.useSyncValues = useSyncValues;
|
package/dist/hooks/esm/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useActionIcon } from "./useActionIcon/useActionIcon.mjs";
|
|
2
2
|
import { useCustomFetch } from "./useCustomFetch/useCustomFetch.mjs";
|
|
3
|
+
import { useSyncValues } from "./useSyncValues/useSyncValues.mjs";
|
|
3
4
|
import { useTrueOnce } from "./useTrueOnce/useTrueOnce.mjs";
|
|
4
5
|
export {
|
|
5
6
|
useActionIcon,
|
|
6
7
|
useCustomFetch,
|
|
8
|
+
useSyncValues,
|
|
7
9
|
useTrueOnce
|
|
8
10
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DEBOUNCE_DELAY } from "fastapi-rtk/constants";
|
|
2
|
+
import { useRef, useEffect } from "react";
|
|
3
|
+
const useSyncValues = (states, { equals = (a, b) => a === b, delay = DEBOUNCE_DELAY } = {}) => {
|
|
4
|
+
const lastValueRef = useRef(states[0].value);
|
|
5
|
+
const timeoutRef = useRef(null);
|
|
6
|
+
useEffect(
|
|
7
|
+
() => {
|
|
8
|
+
const changed = states.find((state) => !equals(state.value, lastValueRef.current));
|
|
9
|
+
if (!changed) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
clearTimeout(timeoutRef.current);
|
|
13
|
+
timeoutRef.current = setTimeout(() => {
|
|
14
|
+
lastValueRef.current = changed.value;
|
|
15
|
+
states.forEach((state) => {
|
|
16
|
+
if (!equals(state.value, lastValueRef.current)) {
|
|
17
|
+
state.onChange(lastValueRef.current);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}, delay);
|
|
21
|
+
return () => clearTimeout(timeoutRef.current);
|
|
22
|
+
},
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
states.map((state) => state.value)
|
|
25
|
+
);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
useSyncValues
|
|
30
|
+
};
|