tp-react-elements 1.3.0 → 1.3.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/_virtual/index.esm12.js +2 -2
- package/dist/_virtual/index.esm13.js +2 -2
- package/dist/_virtual/index.esm14.js +2 -2
- package/dist/_virtual/index.esm5.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/DatePicker/index.d.ts +0 -1
- package/dist/components/DatePicker/index.esm.js +0 -1
- package/dist/components/FormComponents/DatePicker/Monthpickerrender.esm.js +12 -2
- package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.esm.js +2 -2
- package/dist/components/FormComponents/PasswordField/PasswordField.esm.js +40 -40
- package/dist/components/FormComponents/index.d.ts +1 -1
- package/dist/components/FormComponents/index.esm.js +0 -1
- package/dist/components/PaginatedGrid/DynamicFilterBar.d.ts +59 -0
- package/dist/components/PaginatedGrid/DynamicFilterBar.esm.js +269 -0
- package/dist/components/PaginatedGrid/GenericPaginatedGrid.d.ts +40 -0
- package/dist/components/PaginatedGrid/GenericPaginatedGrid.esm.js +222 -0
- package/dist/components/PaginatedGrid/InvoiceGrid.d.ts +2 -0
- package/dist/components/PaginatedGrid/columns.d.ts +3 -0
- package/dist/components/PaginatedGrid/helpers.d.ts +3 -0
- package/dist/components/PaginatedGrid/index.d.ts +4 -0
- package/dist/components/PaginatedGrid/index.esm.js +2 -0
- package/dist/components/PaginatedGrid/invoiceApi.d.ts +2 -0
- package/dist/components/PaginatedGrid/types.d.ts +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/environmentManager.esm.js +22 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.esm.js +65 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.esm.js +83 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.esm.js +55 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/query.esm.js +16 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.esm.js +463 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/retryer.esm.js +8 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.esm.js +24 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/thenable.esm.js +34 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.esm.js +66 -0
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.esm.js +115 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.esm.js +7 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.esm.js +15 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.esm.js +21 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.esm.js +27 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.esm.js +22 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.esm.js +94 -0
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.esm.js +8 -0
- package/dist/node_modules/react-date-range/dist/components/Calendar/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateInput/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/InputRangeField/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/Month/index.esm.js +1 -1
- package/package.json +2 -1
- package/dist/components/FormComponents/DatePicker/MonthPicker.d.ts +0 -2
- package/dist/components/FormComponents/DatePicker/MonthPicker.esm.js +0 -59
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
3
|
+
function noop() {
|
|
4
|
+
}
|
|
5
|
+
function isValidTimeout(value) {
|
|
6
|
+
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
7
|
+
}
|
|
8
|
+
function timeUntilStale(updatedAt, staleTime) {
|
|
9
|
+
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
10
|
+
}
|
|
11
|
+
function resolveStaleTime(staleTime, query) {
|
|
12
|
+
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
13
|
+
}
|
|
14
|
+
function resolveQueryBoolean(option, query) {
|
|
15
|
+
return typeof option === "function" ? option(query) : option;
|
|
16
|
+
}
|
|
17
|
+
var hasOwn = Object.prototype.hasOwnProperty;
|
|
18
|
+
function replaceEqualDeep(a, b, depth = 0) {
|
|
19
|
+
if (a === b) {
|
|
20
|
+
return a;
|
|
21
|
+
}
|
|
22
|
+
if (depth > 500) return b;
|
|
23
|
+
const array = isPlainArray(a) && isPlainArray(b);
|
|
24
|
+
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
25
|
+
const aItems = array ? a : Object.keys(a);
|
|
26
|
+
const aSize = aItems.length;
|
|
27
|
+
const bItems = array ? b : Object.keys(b);
|
|
28
|
+
const bSize = bItems.length;
|
|
29
|
+
const copy = array ? new Array(bSize) : {};
|
|
30
|
+
let equalItems = 0;
|
|
31
|
+
for (let i = 0; i < bSize; i++) {
|
|
32
|
+
const key = array ? i : bItems[i];
|
|
33
|
+
const aItem = a[key];
|
|
34
|
+
const bItem = b[key];
|
|
35
|
+
if (aItem === bItem) {
|
|
36
|
+
copy[key] = aItem;
|
|
37
|
+
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
41
|
+
copy[key] = bItem;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
45
|
+
copy[key] = v;
|
|
46
|
+
if (v === aItem) equalItems++;
|
|
47
|
+
}
|
|
48
|
+
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
49
|
+
}
|
|
50
|
+
function shallowEqualObjects(a, b) {
|
|
51
|
+
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
for (const key in a) {
|
|
55
|
+
if (a[key] !== b[key]) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function isPlainArray(value) {
|
|
62
|
+
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
63
|
+
}
|
|
64
|
+
function isPlainObject(o) {
|
|
65
|
+
if (!hasObjectPrototype(o)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const ctor = o.constructor;
|
|
69
|
+
if (ctor === void 0) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
const prot = ctor.prototype;
|
|
73
|
+
if (!hasObjectPrototype(prot)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function hasObjectPrototype(o) {
|
|
85
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
86
|
+
}
|
|
87
|
+
function replaceData(prevData, data, options) {
|
|
88
|
+
if (typeof options.structuralSharing === "function") {
|
|
89
|
+
return options.structuralSharing(prevData, data);
|
|
90
|
+
} else if (options.structuralSharing !== false) {
|
|
91
|
+
if (process.env.NODE_ENV !== "production") {
|
|
92
|
+
try {
|
|
93
|
+
return replaceEqualDeep(prevData, data);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error(
|
|
96
|
+
`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
|
|
97
|
+
);
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return replaceEqualDeep(prevData, data);
|
|
102
|
+
}
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
function keepPreviousData(previousData) {
|
|
106
|
+
return previousData;
|
|
107
|
+
}
|
|
108
|
+
function shouldThrowError(throwOnError, params) {
|
|
109
|
+
if (typeof throwOnError === "function") {
|
|
110
|
+
return throwOnError(...params);
|
|
111
|
+
}
|
|
112
|
+
return !!throwOnError;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { isPlainArray, isPlainObject, isServer, isValidTimeout, keepPreviousData, noop, replaceData, replaceEqualDeep, resolveQueryBoolean, resolveStaleTime, shallowEqualObjects, shouldThrowError, timeUntilStale };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
var QueryClientContext = React.createContext(
|
|
5
|
+
void 0
|
|
6
|
+
);
|
|
7
|
+
var useQueryClient = (queryClient) => {
|
|
8
|
+
const client = React.useContext(QueryClientContext);
|
|
9
|
+
if (!client) {
|
|
10
|
+
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
11
|
+
}
|
|
12
|
+
return client;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { QueryClientContext, useQueryClient };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
function createValue() {
|
|
5
|
+
let isReset = false;
|
|
6
|
+
return {
|
|
7
|
+
clearReset: () => {
|
|
8
|
+
isReset = false;
|
|
9
|
+
},
|
|
10
|
+
reset: () => {
|
|
11
|
+
isReset = true;
|
|
12
|
+
},
|
|
13
|
+
isReset: () => {
|
|
14
|
+
return isReset;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var QueryErrorResetBoundaryContext = React.createContext(createValue());
|
|
19
|
+
var useQueryErrorResetBoundary = () => React.useContext(QueryErrorResetBoundaryContext);
|
|
20
|
+
|
|
21
|
+
export { useQueryErrorResetBoundary };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { shouldThrowError } from '../../../query-core/build/modern/utils.esm.js';
|
|
3
|
+
|
|
4
|
+
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
5
|
+
const throwOnError = query?.state.error && typeof options.throwOnError === "function" ? shouldThrowError(options.throwOnError, [query.state.error, query]) : options.throwOnError;
|
|
6
|
+
if (options.suspense || options.experimental_prefetchInRender || throwOnError) {
|
|
7
|
+
if (!errorResetBoundary.isReset()) {
|
|
8
|
+
options.retryOnMount = false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
errorResetBoundary.clearReset();
|
|
15
|
+
}, [errorResetBoundary]);
|
|
16
|
+
};
|
|
17
|
+
var getHasError = ({
|
|
18
|
+
result,
|
|
19
|
+
errorResetBoundary,
|
|
20
|
+
throwOnError,
|
|
21
|
+
query,
|
|
22
|
+
suspense
|
|
23
|
+
}) => {
|
|
24
|
+
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/suspense.ts
|
|
2
|
+
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
3
|
+
if (defaultedOptions.suspense) {
|
|
4
|
+
const MIN_SUSPENSE_TIME_MS = 1e3;
|
|
5
|
+
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
|
6
|
+
const originalStaleTime = defaultedOptions.staleTime;
|
|
7
|
+
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
|
8
|
+
if (typeof defaultedOptions.gcTime === "number") {
|
|
9
|
+
defaultedOptions.gcTime = Math.max(
|
|
10
|
+
defaultedOptions.gcTime,
|
|
11
|
+
MIN_SUSPENSE_TIME_MS
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
17
|
+
var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
|
|
18
|
+
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
|
19
|
+
errorResetBoundary.clearReset();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { ensureSuspenseTimers, fetchOptimistic, shouldSuspend, willFetch };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { environmentManager } from '../../../query-core/build/modern/environmentManager.esm.js';
|
|
3
|
+
import { notifyManager } from '../../../query-core/build/modern/notifyManager.esm.js';
|
|
4
|
+
import { noop } from '../../../query-core/build/modern/utils.esm.js';
|
|
5
|
+
import { useQueryClient } from './QueryClientProvider.esm.js';
|
|
6
|
+
import { useQueryErrorResetBoundary } from './QueryErrorResetBoundary.esm.js';
|
|
7
|
+
import { ensurePreventErrorBoundaryRetry, useClearResetErrorBoundary, getHasError } from './errorBoundaryUtils.esm.js';
|
|
8
|
+
import { useIsRestoring } from './IsRestoringProvider.esm.js';
|
|
9
|
+
import { ensureSuspenseTimers, shouldSuspend, fetchOptimistic, willFetch } from './suspense.esm.js';
|
|
10
|
+
|
|
11
|
+
function useBaseQuery(options, Observer, queryClient) {
|
|
12
|
+
if (process.env.NODE_ENV !== "production") {
|
|
13
|
+
if (typeof options !== "object" || Array.isArray(options)) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const isRestoring = useIsRestoring();
|
|
20
|
+
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
21
|
+
const client = useQueryClient();
|
|
22
|
+
const defaultedOptions = client.defaultQueryOptions(options);
|
|
23
|
+
client.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
24
|
+
defaultedOptions
|
|
25
|
+
);
|
|
26
|
+
const query = client.getQueryCache().get(defaultedOptions.queryHash);
|
|
27
|
+
if (process.env.NODE_ENV !== "production") {
|
|
28
|
+
if (!defaultedOptions.queryFn) {
|
|
29
|
+
console.error(
|
|
30
|
+
`[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const subscribed = options.subscribed !== false;
|
|
35
|
+
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : subscribed ? "optimistic" : void 0;
|
|
36
|
+
ensureSuspenseTimers(defaultedOptions);
|
|
37
|
+
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary, query);
|
|
38
|
+
useClearResetErrorBoundary(errorResetBoundary);
|
|
39
|
+
const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
|
|
40
|
+
const [observer] = React.useState(
|
|
41
|
+
() => new Observer(
|
|
42
|
+
client,
|
|
43
|
+
defaultedOptions
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
const result = observer.getOptimisticResult(defaultedOptions);
|
|
47
|
+
const shouldSubscribe = !isRestoring && subscribed;
|
|
48
|
+
React.useSyncExternalStore(
|
|
49
|
+
React.useCallback(
|
|
50
|
+
(onStoreChange) => {
|
|
51
|
+
const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
|
|
52
|
+
observer.updateResult();
|
|
53
|
+
return unsubscribe;
|
|
54
|
+
},
|
|
55
|
+
[observer, shouldSubscribe]
|
|
56
|
+
),
|
|
57
|
+
() => observer.getCurrentResult(),
|
|
58
|
+
() => observer.getCurrentResult()
|
|
59
|
+
);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
observer.setOptions(defaultedOptions);
|
|
62
|
+
}, [defaultedOptions, observer]);
|
|
63
|
+
if (shouldSuspend(defaultedOptions, result)) {
|
|
64
|
+
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
65
|
+
}
|
|
66
|
+
if (getHasError({
|
|
67
|
+
result,
|
|
68
|
+
errorResetBoundary,
|
|
69
|
+
throwOnError: defaultedOptions.throwOnError,
|
|
70
|
+
query,
|
|
71
|
+
suspense: defaultedOptions.suspense
|
|
72
|
+
})) {
|
|
73
|
+
throw result.error;
|
|
74
|
+
}
|
|
75
|
+
client.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
76
|
+
defaultedOptions,
|
|
77
|
+
result
|
|
78
|
+
);
|
|
79
|
+
if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) {
|
|
80
|
+
const promise = isNewCacheEntry ? (
|
|
81
|
+
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
82
|
+
fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
|
|
83
|
+
) : (
|
|
84
|
+
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
85
|
+
query?.promise
|
|
86
|
+
);
|
|
87
|
+
promise?.catch(noop).finally(() => {
|
|
88
|
+
observer.updateResult();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { useBaseQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as Calendar } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Calendar } from '../../../../../_virtual/index.esm5.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDayCell } from '../DayCell/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateInput } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateInput } from '../../../../../_virtual/index.esm13.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireClassnames } from '../../../../classnames/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DefinedRange } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DefinedRange } from '../../../../../_virtual/index.esm7.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireStyles } from '../../styles.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as InputRangeField } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as InputRangeField } from '../../../../../_virtual/index.esm14.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as Month } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Month } from '../../../../../_virtual/index.esm12.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDayCell } from '../DayCell/index.esm.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tp-react-elements",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "React form components library built with React Hook Form and Yup",
|
|
@@ -129,6 +129,7 @@
|
|
|
129
129
|
"@storybook/addon-docs": "^9.1.2",
|
|
130
130
|
"@storybook/addon-links": "^9.1.2",
|
|
131
131
|
"@storybook/react-vite": "^9.1.2",
|
|
132
|
+
"@tanstack/react-query": "^5.100.14",
|
|
132
133
|
"@testing-library/jest-dom": "^6.5.0",
|
|
133
134
|
"@testing-library/react": "^16.0.1",
|
|
134
135
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useRef, useState } from 'react';
|
|
3
|
-
import { Controller } from 'react-hook-form';
|
|
4
|
-
import { TextField, FormGroup, FormControlLabel, Checkbox } from '@mui/material';
|
|
5
|
-
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
6
|
-
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
7
|
-
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
8
|
-
|
|
9
|
-
const MonthPicker = ({ props }) => {
|
|
10
|
-
const inputTextRef = useRef(null);
|
|
11
|
-
const [open, setOpen] = useState(false);
|
|
12
|
-
const [selectedMonths, setSelectedMonths] = useState([]);
|
|
13
|
-
const handleToggle = () => {
|
|
14
|
-
if (!open) {
|
|
15
|
-
inputTextRef.current?.blur();
|
|
16
|
-
}
|
|
17
|
-
document.activeElement?.blur();
|
|
18
|
-
setOpen(!open);
|
|
19
|
-
};
|
|
20
|
-
const handleMonthChange = (date) => {
|
|
21
|
-
// Handle the selected months
|
|
22
|
-
setSelectedMonths((prevSelectedMonths) => {
|
|
23
|
-
const monthIndex = date.getMonth();
|
|
24
|
-
if (prevSelectedMonths.includes(monthIndex)) {
|
|
25
|
-
// If month is already selected, remove it
|
|
26
|
-
return prevSelectedMonths?.filter((month) => month !== monthIndex);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// If month is not selected, add it
|
|
30
|
-
return [...prevSelectedMonths, monthIndex];
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
return (jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: jsx(DatePicker, { value: field.value, onChange: handleMonthChange, open: open, onOpen: handleToggle, onClose: handleToggle, slots: {
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
textField: (textFieldProps) => (jsx(TextField, { ...textFieldProps, fullWidth: true, onClick: () => handleToggle(), inputRef: inputTextRef, disabled: props.item.disable || false, InputLabelProps: {
|
|
37
|
-
shrink: true,
|
|
38
|
-
}, error: props.errors, inputProps: {
|
|
39
|
-
min: props.item.minDate,
|
|
40
|
-
readOnly: true,
|
|
41
|
-
style: { cursor: 'pointer' },
|
|
42
|
-
} })),
|
|
43
|
-
}, slotProps: {
|
|
44
|
-
textField: {
|
|
45
|
-
sx: {
|
|
46
|
-
'& .MuiFormLabel-root': {
|
|
47
|
-
top: -10,
|
|
48
|
-
},
|
|
49
|
-
'& .MuiInputLabel-shrink': {
|
|
50
|
-
top: 0,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
} }) }), jsx(FormGroup, { children: Array.from({ length: 12 }).map((_, index) => (jsx(FormControlLabel, { control: jsx(Checkbox, { checked: selectedMonths.includes(index), onChange: () => handleMonthChange(new Date(2000, index, 1)), color: "primary" }), label: new Date(2000, index, 1).toLocaleDateString(undefined, {
|
|
55
|
-
month: 'short',
|
|
56
|
-
}) }, index))) })] })) }));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export { MonthPicker as default };
|