tp-react-elements 1.3.2 → 1.3.3
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.esm4.js +2 -2
- package/dist/_virtual/index.esm5.js +2 -2
- package/dist/_virtual/index.esm6.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +0 -3
- package/dist/components/DateRangePicker/DateRangePicker.esm.js +4 -0
- package/dist/components/Form/FormRender.esm.js +4 -0
- package/dist/components/FormComponents/Select/SearchableSelect.d.ts +6 -0
- package/dist/components/FormComponents/Select/SearchableSelect.esm.js +78 -0
- package/dist/components/FormComponents/index.d.ts +1 -0
- package/dist/components/FormComponents/index.esm.js +1 -0
- package/dist/components/PaginatedGrid/DynamicFilterBar.d.ts +33 -7
- package/dist/components/PaginatedGrid/DynamicFilterBar.esm.js +95 -40
- package/dist/components/PaginatedGrid/GenericPaginatedGrid.esm.js +22 -4
- package/dist/components/PaginatedGrid/columns.d.ts +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1 -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/DateRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRangePicker/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/Month/index.esm.js +1 -1
- package/dist/utils/Interface/FormInterface.d.ts +1 -1
- package/dist/utils/rdrStyles.d.ts +12 -0
- package/dist/utils/rdrStyles.esm.js +180 -0
- package/package.json +5 -1
- package/dist/node_modules/@tanstack/query-core/build/modern/environmentManager.esm.js +0 -22
- package/dist/node_modules/@tanstack/query-core/build/modern/focusManager.esm.js +0 -65
- package/dist/node_modules/@tanstack/query-core/build/modern/notifyManager.esm.js +0 -83
- package/dist/node_modules/@tanstack/query-core/build/modern/onlineManager.esm.js +0 -55
- package/dist/node_modules/@tanstack/query-core/build/modern/query.esm.js +0 -16
- package/dist/node_modules/@tanstack/query-core/build/modern/queryObserver.esm.js +0 -463
- package/dist/node_modules/@tanstack/query-core/build/modern/retryer.esm.js +0 -8
- package/dist/node_modules/@tanstack/query-core/build/modern/subscribable.esm.js +0 -24
- package/dist/node_modules/@tanstack/query-core/build/modern/thenable.esm.js +0 -34
- package/dist/node_modules/@tanstack/query-core/build/modern/timeoutManager.esm.js +0 -66
- package/dist/node_modules/@tanstack/query-core/build/modern/utils.esm.js +0 -115
- package/dist/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.esm.js +0 -7
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.esm.js +0 -15
- package/dist/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.esm.js +0 -21
- package/dist/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.esm.js +0 -27
- package/dist/node_modules/@tanstack/react-query/build/modern/suspense.esm.js +0 -22
- package/dist/node_modules/@tanstack/react-query/build/modern/useBaseQuery.esm.js +0 -94
- package/dist/node_modules/@tanstack/react-query/build/modern/useQuery.esm.js +0 -8
|
@@ -1,463 +0,0 @@
|
|
|
1
|
-
import { focusManager } from './focusManager.esm.js';
|
|
2
|
-
import { environmentManager } from './environmentManager.esm.js';
|
|
3
|
-
import { notifyManager } from './notifyManager.esm.js';
|
|
4
|
-
import { fetchState } from './query.esm.js';
|
|
5
|
-
import { Subscribable } from './subscribable.esm.js';
|
|
6
|
-
import { pendingThenable } from './thenable.esm.js';
|
|
7
|
-
import { resolveQueryBoolean, shallowEqualObjects, resolveStaleTime, noop, isValidTimeout, timeUntilStale, replaceData } from './utils.esm.js';
|
|
8
|
-
import { timeoutManager } from './timeoutManager.esm.js';
|
|
9
|
-
|
|
10
|
-
// src/queryObserver.ts
|
|
11
|
-
var QueryObserver = class extends Subscribable {
|
|
12
|
-
constructor(client, options) {
|
|
13
|
-
super();
|
|
14
|
-
this.options = options;
|
|
15
|
-
this.#client = client;
|
|
16
|
-
this.#selectError = null;
|
|
17
|
-
this.#currentThenable = pendingThenable();
|
|
18
|
-
this.bindMethods();
|
|
19
|
-
this.setOptions(options);
|
|
20
|
-
}
|
|
21
|
-
#client;
|
|
22
|
-
#currentQuery = void 0;
|
|
23
|
-
#currentQueryInitialState = void 0;
|
|
24
|
-
#currentResult = void 0;
|
|
25
|
-
#currentResultState;
|
|
26
|
-
#currentResultOptions;
|
|
27
|
-
#currentThenable;
|
|
28
|
-
#selectError;
|
|
29
|
-
#selectFn;
|
|
30
|
-
#selectResult;
|
|
31
|
-
// This property keeps track of the last query with defined data.
|
|
32
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
33
|
-
#lastQueryWithDefinedData;
|
|
34
|
-
#staleTimeoutId;
|
|
35
|
-
#refetchIntervalId;
|
|
36
|
-
#currentRefetchInterval;
|
|
37
|
-
#trackedProps = /* @__PURE__ */ new Set();
|
|
38
|
-
bindMethods() {
|
|
39
|
-
this.refetch = this.refetch.bind(this);
|
|
40
|
-
}
|
|
41
|
-
onSubscribe() {
|
|
42
|
-
if (this.listeners.size === 1) {
|
|
43
|
-
this.#currentQuery.addObserver(this);
|
|
44
|
-
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
45
|
-
this.#executeFetch();
|
|
46
|
-
} else {
|
|
47
|
-
this.updateResult();
|
|
48
|
-
}
|
|
49
|
-
this.#updateTimers();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
onUnsubscribe() {
|
|
53
|
-
if (!this.hasListeners()) {
|
|
54
|
-
this.destroy();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
shouldFetchOnReconnect() {
|
|
58
|
-
return shouldFetchOn(
|
|
59
|
-
this.#currentQuery,
|
|
60
|
-
this.options,
|
|
61
|
-
this.options.refetchOnReconnect
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
shouldFetchOnWindowFocus() {
|
|
65
|
-
return shouldFetchOn(
|
|
66
|
-
this.#currentQuery,
|
|
67
|
-
this.options,
|
|
68
|
-
this.options.refetchOnWindowFocus
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
destroy() {
|
|
72
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
73
|
-
this.#clearStaleTimeout();
|
|
74
|
-
this.#clearRefetchInterval();
|
|
75
|
-
this.#currentQuery.removeObserver(this);
|
|
76
|
-
}
|
|
77
|
-
setOptions(options) {
|
|
78
|
-
const prevOptions = this.options;
|
|
79
|
-
const prevQuery = this.#currentQuery;
|
|
80
|
-
this.options = this.#client.defaultQueryOptions(options);
|
|
81
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") {
|
|
82
|
-
throw new Error(
|
|
83
|
-
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
this.#updateQuery();
|
|
87
|
-
this.#currentQuery.setOptions(this.options);
|
|
88
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
89
|
-
this.#client.getQueryCache().notify({
|
|
90
|
-
type: "observerOptionsUpdated",
|
|
91
|
-
query: this.#currentQuery,
|
|
92
|
-
observer: this
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
const mounted = this.hasListeners();
|
|
96
|
-
if (mounted && shouldFetchOptionally(
|
|
97
|
-
this.#currentQuery,
|
|
98
|
-
prevQuery,
|
|
99
|
-
this.options,
|
|
100
|
-
prevOptions
|
|
101
|
-
)) {
|
|
102
|
-
this.#executeFetch();
|
|
103
|
-
}
|
|
104
|
-
this.updateResult();
|
|
105
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
|
|
106
|
-
this.#updateStaleTimeout();
|
|
107
|
-
}
|
|
108
|
-
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
109
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
110
|
-
this.#updateRefetchInterval(nextRefetchInterval);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
getOptimisticResult(options) {
|
|
114
|
-
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
115
|
-
const result = this.createResult(query, options);
|
|
116
|
-
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
117
|
-
this.#currentResult = result;
|
|
118
|
-
this.#currentResultOptions = this.options;
|
|
119
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
getCurrentResult() {
|
|
124
|
-
return this.#currentResult;
|
|
125
|
-
}
|
|
126
|
-
trackResult(result, onPropTracked) {
|
|
127
|
-
return new Proxy(result, {
|
|
128
|
-
get: (target, key) => {
|
|
129
|
-
this.trackProp(key);
|
|
130
|
-
onPropTracked?.(key);
|
|
131
|
-
if (key === "promise") {
|
|
132
|
-
this.trackProp("data");
|
|
133
|
-
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") {
|
|
134
|
-
this.#currentThenable.reject(
|
|
135
|
-
new Error(
|
|
136
|
-
"experimental_prefetchInRender feature flag is not enabled"
|
|
137
|
-
)
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return Reflect.get(target, key);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
trackProp(key) {
|
|
146
|
-
this.#trackedProps.add(key);
|
|
147
|
-
}
|
|
148
|
-
getCurrentQuery() {
|
|
149
|
-
return this.#currentQuery;
|
|
150
|
-
}
|
|
151
|
-
refetch({ ...options } = {}) {
|
|
152
|
-
return this.fetch({
|
|
153
|
-
...options
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
fetchOptimistic(options) {
|
|
157
|
-
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
158
|
-
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
159
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
160
|
-
}
|
|
161
|
-
fetch(fetchOptions) {
|
|
162
|
-
return this.#executeFetch({
|
|
163
|
-
...fetchOptions,
|
|
164
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
165
|
-
}).then(() => {
|
|
166
|
-
this.updateResult();
|
|
167
|
-
return this.#currentResult;
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
#executeFetch(fetchOptions) {
|
|
171
|
-
this.#updateQuery();
|
|
172
|
-
let promise = this.#currentQuery.fetch(
|
|
173
|
-
this.options,
|
|
174
|
-
fetchOptions
|
|
175
|
-
);
|
|
176
|
-
if (!fetchOptions?.throwOnError) {
|
|
177
|
-
promise = promise.catch(noop);
|
|
178
|
-
}
|
|
179
|
-
return promise;
|
|
180
|
-
}
|
|
181
|
-
#updateStaleTimeout() {
|
|
182
|
-
this.#clearStaleTimeout();
|
|
183
|
-
const staleTime = resolveStaleTime(
|
|
184
|
-
this.options.staleTime,
|
|
185
|
-
this.#currentQuery
|
|
186
|
-
);
|
|
187
|
-
if (environmentManager.isServer() || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);
|
|
191
|
-
const timeout = time + 1;
|
|
192
|
-
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
193
|
-
if (!this.#currentResult.isStale) {
|
|
194
|
-
this.updateResult();
|
|
195
|
-
}
|
|
196
|
-
}, timeout);
|
|
197
|
-
}
|
|
198
|
-
#computeRefetchInterval() {
|
|
199
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
200
|
-
}
|
|
201
|
-
#updateRefetchInterval(nextInterval) {
|
|
202
|
-
this.#clearRefetchInterval();
|
|
203
|
-
this.#currentRefetchInterval = nextInterval;
|
|
204
|
-
if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
208
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
209
|
-
this.#executeFetch();
|
|
210
|
-
}
|
|
211
|
-
}, this.#currentRefetchInterval);
|
|
212
|
-
}
|
|
213
|
-
#updateTimers() {
|
|
214
|
-
this.#updateStaleTimeout();
|
|
215
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
216
|
-
}
|
|
217
|
-
#clearStaleTimeout() {
|
|
218
|
-
if (this.#staleTimeoutId !== void 0) {
|
|
219
|
-
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
220
|
-
this.#staleTimeoutId = void 0;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
#clearRefetchInterval() {
|
|
224
|
-
if (this.#refetchIntervalId !== void 0) {
|
|
225
|
-
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
226
|
-
this.#refetchIntervalId = void 0;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
createResult(query, options) {
|
|
230
|
-
const prevQuery = this.#currentQuery;
|
|
231
|
-
const prevOptions = this.options;
|
|
232
|
-
const prevResult = this.#currentResult;
|
|
233
|
-
const prevResultState = this.#currentResultState;
|
|
234
|
-
const prevResultOptions = this.#currentResultOptions;
|
|
235
|
-
const queryChange = query !== prevQuery;
|
|
236
|
-
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
237
|
-
const { state } = query;
|
|
238
|
-
let newState = { ...state };
|
|
239
|
-
let isPlaceholderData = false;
|
|
240
|
-
let data;
|
|
241
|
-
if (options._optimisticResults) {
|
|
242
|
-
const mounted = this.hasListeners();
|
|
243
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
244
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
245
|
-
if (fetchOnMount || fetchOptionally) {
|
|
246
|
-
newState = {
|
|
247
|
-
...newState,
|
|
248
|
-
...fetchState(state.data, query.options)
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
if (options._optimisticResults === "isRestoring") {
|
|
252
|
-
newState.fetchStatus = "idle";
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
let { error, errorUpdatedAt, status } = newState;
|
|
256
|
-
data = newState.data;
|
|
257
|
-
let skipSelect = false;
|
|
258
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
259
|
-
let placeholderData;
|
|
260
|
-
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
261
|
-
placeholderData = prevResult.data;
|
|
262
|
-
skipSelect = true;
|
|
263
|
-
} else {
|
|
264
|
-
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
|
|
265
|
-
this.#lastQueryWithDefinedData?.state.data,
|
|
266
|
-
this.#lastQueryWithDefinedData
|
|
267
|
-
) : options.placeholderData;
|
|
268
|
-
}
|
|
269
|
-
if (placeholderData !== void 0) {
|
|
270
|
-
status = "success";
|
|
271
|
-
data = replaceData(
|
|
272
|
-
prevResult?.data,
|
|
273
|
-
placeholderData,
|
|
274
|
-
options
|
|
275
|
-
);
|
|
276
|
-
isPlaceholderData = true;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
if (options.select && data !== void 0 && !skipSelect) {
|
|
280
|
-
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {
|
|
281
|
-
data = this.#selectResult;
|
|
282
|
-
} else {
|
|
283
|
-
try {
|
|
284
|
-
this.#selectFn = options.select;
|
|
285
|
-
data = options.select(data);
|
|
286
|
-
data = replaceData(prevResult?.data, data, options);
|
|
287
|
-
this.#selectResult = data;
|
|
288
|
-
this.#selectError = null;
|
|
289
|
-
} catch (selectError) {
|
|
290
|
-
this.#selectError = selectError;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
if (this.#selectError) {
|
|
295
|
-
error = this.#selectError;
|
|
296
|
-
data = this.#selectResult;
|
|
297
|
-
errorUpdatedAt = Date.now();
|
|
298
|
-
status = "error";
|
|
299
|
-
}
|
|
300
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
301
|
-
const isPending = status === "pending";
|
|
302
|
-
const isError = status === "error";
|
|
303
|
-
const isLoading = isPending && isFetching;
|
|
304
|
-
const hasData = data !== void 0;
|
|
305
|
-
const result = {
|
|
306
|
-
status,
|
|
307
|
-
fetchStatus: newState.fetchStatus,
|
|
308
|
-
isPending,
|
|
309
|
-
isSuccess: status === "success",
|
|
310
|
-
isError,
|
|
311
|
-
isInitialLoading: isLoading,
|
|
312
|
-
isLoading,
|
|
313
|
-
data,
|
|
314
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
315
|
-
error,
|
|
316
|
-
errorUpdatedAt,
|
|
317
|
-
failureCount: newState.fetchFailureCount,
|
|
318
|
-
failureReason: newState.fetchFailureReason,
|
|
319
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
320
|
-
isFetched: query.isFetched(),
|
|
321
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
322
|
-
isFetching,
|
|
323
|
-
isRefetching: isFetching && !isPending,
|
|
324
|
-
isLoadingError: isError && !hasData,
|
|
325
|
-
isPaused: newState.fetchStatus === "paused",
|
|
326
|
-
isPlaceholderData,
|
|
327
|
-
isRefetchError: isError && hasData,
|
|
328
|
-
isStale: isStale(query, options),
|
|
329
|
-
refetch: this.refetch,
|
|
330
|
-
promise: this.#currentThenable,
|
|
331
|
-
isEnabled: resolveQueryBoolean(options.enabled, query) !== false
|
|
332
|
-
};
|
|
333
|
-
const nextResult = result;
|
|
334
|
-
if (this.options.experimental_prefetchInRender) {
|
|
335
|
-
const hasResultData = nextResult.data !== void 0;
|
|
336
|
-
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
337
|
-
const finalizeThenableIfPossible = (thenable) => {
|
|
338
|
-
if (isErrorWithoutData) {
|
|
339
|
-
thenable.reject(nextResult.error);
|
|
340
|
-
} else if (hasResultData) {
|
|
341
|
-
thenable.resolve(nextResult.data);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
const recreateThenable = () => {
|
|
345
|
-
const pending = this.#currentThenable = nextResult.promise = pendingThenable();
|
|
346
|
-
finalizeThenableIfPossible(pending);
|
|
347
|
-
};
|
|
348
|
-
const prevThenable = this.#currentThenable;
|
|
349
|
-
switch (prevThenable.status) {
|
|
350
|
-
case "pending":
|
|
351
|
-
if (query.queryHash === prevQuery.queryHash) {
|
|
352
|
-
finalizeThenableIfPossible(prevThenable);
|
|
353
|
-
}
|
|
354
|
-
break;
|
|
355
|
-
case "fulfilled":
|
|
356
|
-
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
357
|
-
recreateThenable();
|
|
358
|
-
}
|
|
359
|
-
break;
|
|
360
|
-
case "rejected":
|
|
361
|
-
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
362
|
-
recreateThenable();
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return nextResult;
|
|
368
|
-
}
|
|
369
|
-
updateResult() {
|
|
370
|
-
const prevResult = this.#currentResult;
|
|
371
|
-
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
372
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
373
|
-
this.#currentResultOptions = this.options;
|
|
374
|
-
if (this.#currentResultState.data !== void 0) {
|
|
375
|
-
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
376
|
-
}
|
|
377
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
this.#currentResult = nextResult;
|
|
381
|
-
const shouldNotifyListeners = () => {
|
|
382
|
-
if (!prevResult) {
|
|
383
|
-
return true;
|
|
384
|
-
}
|
|
385
|
-
const { notifyOnChangeProps } = this.options;
|
|
386
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
387
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
388
|
-
return true;
|
|
389
|
-
}
|
|
390
|
-
const includedProps = new Set(
|
|
391
|
-
notifyOnChangePropsValue ?? this.#trackedProps
|
|
392
|
-
);
|
|
393
|
-
if (this.options.throwOnError) {
|
|
394
|
-
includedProps.add("error");
|
|
395
|
-
}
|
|
396
|
-
return Object.keys(this.#currentResult).some((key) => {
|
|
397
|
-
const typedKey = key;
|
|
398
|
-
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
399
|
-
return changed && includedProps.has(typedKey);
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
this.#notify({ listeners: shouldNotifyListeners() });
|
|
403
|
-
}
|
|
404
|
-
#updateQuery() {
|
|
405
|
-
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
406
|
-
if (query === this.#currentQuery) {
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
const prevQuery = this.#currentQuery;
|
|
410
|
-
this.#currentQuery = query;
|
|
411
|
-
this.#currentQueryInitialState = query.state;
|
|
412
|
-
if (this.hasListeners()) {
|
|
413
|
-
prevQuery?.removeObserver(this);
|
|
414
|
-
query.addObserver(this);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
onQueryUpdate() {
|
|
418
|
-
this.updateResult();
|
|
419
|
-
if (this.hasListeners()) {
|
|
420
|
-
this.#updateTimers();
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
#notify(notifyOptions) {
|
|
424
|
-
notifyManager.batch(() => {
|
|
425
|
-
if (notifyOptions.listeners) {
|
|
426
|
-
this.listeners.forEach((listener) => {
|
|
427
|
-
listener(this.#currentResult);
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
this.#client.getQueryCache().notify({
|
|
431
|
-
query: this.#currentQuery,
|
|
432
|
-
type: "observerResultsUpdated"
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
function shouldLoadOnMount(query, options) {
|
|
438
|
-
return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
|
|
439
|
-
}
|
|
440
|
-
function shouldFetchOnMount(query, options) {
|
|
441
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
442
|
-
}
|
|
443
|
-
function shouldFetchOn(query, options, field) {
|
|
444
|
-
if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
445
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
446
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
447
|
-
}
|
|
448
|
-
return false;
|
|
449
|
-
}
|
|
450
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
451
|
-
return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
452
|
-
}
|
|
453
|
-
function isStale(query, options) {
|
|
454
|
-
return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
455
|
-
}
|
|
456
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
457
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
458
|
-
return true;
|
|
459
|
-
}
|
|
460
|
-
return false;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
export { QueryObserver };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/subscribable.ts
|
|
2
|
-
var Subscribable = class {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
5
|
-
this.subscribe = this.subscribe.bind(this);
|
|
6
|
-
}
|
|
7
|
-
subscribe(listener) {
|
|
8
|
-
this.listeners.add(listener);
|
|
9
|
-
this.onSubscribe();
|
|
10
|
-
return () => {
|
|
11
|
-
this.listeners.delete(listener);
|
|
12
|
-
this.onUnsubscribe();
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
hasListeners() {
|
|
16
|
-
return this.listeners.size > 0;
|
|
17
|
-
}
|
|
18
|
-
onSubscribe() {
|
|
19
|
-
}
|
|
20
|
-
onUnsubscribe() {
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { Subscribable };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/thenable.ts
|
|
2
|
-
function pendingThenable() {
|
|
3
|
-
let resolve;
|
|
4
|
-
let reject;
|
|
5
|
-
const thenable = new Promise((_resolve, _reject) => {
|
|
6
|
-
resolve = _resolve;
|
|
7
|
-
reject = _reject;
|
|
8
|
-
});
|
|
9
|
-
thenable.status = "pending";
|
|
10
|
-
thenable.catch(() => {
|
|
11
|
-
});
|
|
12
|
-
function finalize(data) {
|
|
13
|
-
Object.assign(thenable, data);
|
|
14
|
-
delete thenable.resolve;
|
|
15
|
-
delete thenable.reject;
|
|
16
|
-
}
|
|
17
|
-
thenable.resolve = (value) => {
|
|
18
|
-
finalize({
|
|
19
|
-
status: "fulfilled",
|
|
20
|
-
value
|
|
21
|
-
});
|
|
22
|
-
resolve(value);
|
|
23
|
-
};
|
|
24
|
-
thenable.reject = (reason) => {
|
|
25
|
-
finalize({
|
|
26
|
-
status: "rejected",
|
|
27
|
-
reason
|
|
28
|
-
});
|
|
29
|
-
reject(reason);
|
|
30
|
-
};
|
|
31
|
-
return thenable;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { pendingThenable };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// src/timeoutManager.ts
|
|
2
|
-
var defaultTimeoutProvider = {
|
|
3
|
-
// We need the wrapper function syntax below instead of direct references to
|
|
4
|
-
// global setTimeout etc.
|
|
5
|
-
//
|
|
6
|
-
// BAD: `setTimeout: setTimeout`
|
|
7
|
-
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
8
|
-
//
|
|
9
|
-
// If we use direct references here, then anything that wants to spy on or
|
|
10
|
-
// replace the global setTimeout (like tests) won't work since we'll already
|
|
11
|
-
// have a hard reference to the original implementation at the time when this
|
|
12
|
-
// file was imported.
|
|
13
|
-
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
14
|
-
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
15
|
-
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
16
|
-
clearInterval: (intervalId) => clearInterval(intervalId)
|
|
17
|
-
};
|
|
18
|
-
var TimeoutManager = class {
|
|
19
|
-
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
20
|
-
// type at app boot; and if we leave that type, then any new timer provider
|
|
21
|
-
// would need to support the default provider's concrete timer ID, which is
|
|
22
|
-
// infeasible across environments.
|
|
23
|
-
//
|
|
24
|
-
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
25
|
-
// this class is unsafe internally to allow for extension.
|
|
26
|
-
#provider = defaultTimeoutProvider;
|
|
27
|
-
#providerCalled = false;
|
|
28
|
-
setTimeoutProvider(provider) {
|
|
29
|
-
if (process.env.NODE_ENV !== "production") {
|
|
30
|
-
if (this.#providerCalled && provider !== this.#provider) {
|
|
31
|
-
console.error(
|
|
32
|
-
`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
|
|
33
|
-
{ previous: this.#provider, provider }
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
this.#provider = provider;
|
|
38
|
-
if (process.env.NODE_ENV !== "production") {
|
|
39
|
-
this.#providerCalled = false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
setTimeout(callback, delay) {
|
|
43
|
-
if (process.env.NODE_ENV !== "production") {
|
|
44
|
-
this.#providerCalled = true;
|
|
45
|
-
}
|
|
46
|
-
return this.#provider.setTimeout(callback, delay);
|
|
47
|
-
}
|
|
48
|
-
clearTimeout(timeoutId) {
|
|
49
|
-
this.#provider.clearTimeout(timeoutId);
|
|
50
|
-
}
|
|
51
|
-
setInterval(callback, delay) {
|
|
52
|
-
if (process.env.NODE_ENV !== "production") {
|
|
53
|
-
this.#providerCalled = true;
|
|
54
|
-
}
|
|
55
|
-
return this.#provider.setInterval(callback, delay);
|
|
56
|
-
}
|
|
57
|
-
clearInterval(intervalId) {
|
|
58
|
-
this.#provider.clearInterval(intervalId);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var timeoutManager = new TimeoutManager();
|
|
62
|
-
function systemSetTimeoutZero(callback) {
|
|
63
|
-
setTimeout(callback, 0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { TimeoutManager, defaultTimeoutProvider, systemSetTimeoutZero, timeoutManager };
|