@me1a/ui 1.2.13 → 2.0.1

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.
Files changed (56) hide show
  1. package/dist/index.css +2 -0
  2. package/dist/index.css.map +1 -0
  3. package/dist/index.d.mts +437 -0
  4. package/dist/index.d.ts +437 -2
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +2 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +84 -96
  10. package/dist/components/iconify/iconify.d.ts +0 -7
  11. package/dist/components/iconify/index.d.ts +0 -2
  12. package/dist/components/iconify/types.d.ts +0 -2
  13. package/dist/components/index.cjs.js +0 -7961
  14. package/dist/components/index.cjs.js.map +0 -1
  15. package/dist/components/index.d.ts +0 -1
  16. package/dist/components/index.es.js +0 -7941
  17. package/dist/components/index.es.js.map +0 -1
  18. package/dist/hook-forms/form-provider.d.ts +0 -8
  19. package/dist/hook-forms/index.cjs.js +0 -27806
  20. package/dist/hook-forms/index.cjs.js.map +0 -1
  21. package/dist/hook-forms/index.d.ts +0 -11
  22. package/dist/hook-forms/index.es.js +0 -27765
  23. package/dist/hook-forms/index.es.js.map +0 -1
  24. package/dist/hook-forms/rhf-autocomplete.d.ts +0 -11
  25. package/dist/hook-forms/rhf-checkbox.d.ts +0 -19
  26. package/dist/hook-forms/rhf-radio-group.d.ts +0 -13
  27. package/dist/hook-forms/rhf-select.d.ts +0 -11
  28. package/dist/hook-forms/rhf-slider.d.ts +0 -7
  29. package/dist/hook-forms/rhf-switch.d.ts +0 -7
  30. package/dist/hook-forms/rhf-text-field.d.ts +0 -6
  31. package/dist/hooks/index.cjs.js +0 -27
  32. package/dist/hooks/index.cjs.js.map +0 -1
  33. package/dist/hooks/index.d.ts +0 -1
  34. package/dist/hooks/index.es.js +0 -25
  35. package/dist/hooks/index.es.js.map +0 -1
  36. package/dist/hooks/use-boolean.d.ts +0 -9
  37. package/dist/index.cjs.js +0 -27828
  38. package/dist/index.cjs.js.map +0 -1
  39. package/dist/index.es.js +0 -27786
  40. package/dist/index.es.js.map +0 -1
  41. package/dist/redux/index.cjs.js +0 -1347
  42. package/dist/redux/index.cjs.js.map +0 -1
  43. package/dist/redux/index.d.ts +0 -1
  44. package/dist/redux/index.es.js +0 -1317
  45. package/dist/redux/index.es.js.map +0 -1
  46. package/dist/redux-toolkit/index.cjs.js +0 -7668
  47. package/dist/redux-toolkit/index.cjs.js.map +0 -1
  48. package/dist/redux-toolkit/index.d.ts +0 -2
  49. package/dist/redux-toolkit/index.es.js +0 -7589
  50. package/dist/redux-toolkit/index.es.js.map +0 -1
  51. package/dist/snackbar/index.cjs.js +0 -10873
  52. package/dist/snackbar/index.cjs.js.map +0 -1
  53. package/dist/snackbar/index.d.ts +0 -2
  54. package/dist/snackbar/index.es.js +0 -10849
  55. package/dist/snackbar/index.es.js.map +0 -1
  56. package/dist/snackbar/snackbar-provider.d.ts +0 -7
@@ -1,1317 +0,0 @@
1
- import * as ReactOriginal from 'react';
2
- import ReactOriginal__default from 'react';
3
-
4
- var withSelector = {exports: {}};
5
-
6
- var useSyncExternalStoreWithSelector_production_min = {};
7
-
8
- /**
9
- * @license React
10
- * use-sync-external-store-with-selector.production.min.js
11
- *
12
- * Copyright (c) Facebook, Inc. and its affiliates.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- */
17
-
18
- var hasRequiredUseSyncExternalStoreWithSelector_production_min;
19
-
20
- function requireUseSyncExternalStoreWithSelector_production_min () {
21
- if (hasRequiredUseSyncExternalStoreWithSelector_production_min) return useSyncExternalStoreWithSelector_production_min;
22
- hasRequiredUseSyncExternalStoreWithSelector_production_min = 1;
23
- var g=ReactOriginal__default;function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p="function"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;
24
- useSyncExternalStoreWithSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,h]);var d=q(a,c[0],c[1]);
25
- t(function(){f.hasValue=!0;f.value=d;},[d]);v(d);return d};
26
- return useSyncExternalStoreWithSelector_production_min;
27
- }
28
-
29
- var useSyncExternalStoreWithSelector_development = {};
30
-
31
- /**
32
- * @license React
33
- * use-sync-external-store-with-selector.development.js
34
- *
35
- * Copyright (c) Facebook, Inc. and its affiliates.
36
- *
37
- * This source code is licensed under the MIT license found in the
38
- * LICENSE file in the root directory of this source tree.
39
- */
40
-
41
- var hasRequiredUseSyncExternalStoreWithSelector_development;
42
-
43
- function requireUseSyncExternalStoreWithSelector_development () {
44
- if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
45
- hasRequiredUseSyncExternalStoreWithSelector_development = 1;
46
-
47
- if (process.env.NODE_ENV !== "production") {
48
- (function() {
49
-
50
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
51
- if (
52
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
53
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
54
- 'function'
55
- ) {
56
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
57
- }
58
- var React = ReactOriginal__default;
59
-
60
- /**
61
- * inlined Object.is polyfill to avoid requiring consumers ship their own
62
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
63
- */
64
- function is(x, y) {
65
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
66
- ;
67
- }
68
-
69
- var objectIs = typeof Object.is === 'function' ? Object.is : is;
70
-
71
- var useSyncExternalStore = React.useSyncExternalStore;
72
-
73
- // for CommonJS interop.
74
-
75
- var useRef = React.useRef,
76
- useEffect = React.useEffect,
77
- useMemo = React.useMemo,
78
- useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
79
-
80
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
81
- // Use this to track the rendered snapshot.
82
- var instRef = useRef(null);
83
- var inst;
84
-
85
- if (instRef.current === null) {
86
- inst = {
87
- hasValue: false,
88
- value: null
89
- };
90
- instRef.current = inst;
91
- } else {
92
- inst = instRef.current;
93
- }
94
-
95
- var _useMemo = useMemo(function () {
96
- // Track the memoized state using closure variables that are local to this
97
- // memoized instance of a getSnapshot function. Intentionally not using a
98
- // useRef hook, because that state would be shared across all concurrent
99
- // copies of the hook/component.
100
- var hasMemo = false;
101
- var memoizedSnapshot;
102
- var memoizedSelection;
103
-
104
- var memoizedSelector = function (nextSnapshot) {
105
- if (!hasMemo) {
106
- // The first time the hook is called, there is no memoized result.
107
- hasMemo = true;
108
- memoizedSnapshot = nextSnapshot;
109
-
110
- var _nextSelection = selector(nextSnapshot);
111
-
112
- if (isEqual !== undefined) {
113
- // Even if the selector has changed, the currently rendered selection
114
- // may be equal to the new selection. We should attempt to reuse the
115
- // current value if possible, to preserve downstream memoizations.
116
- if (inst.hasValue) {
117
- var currentSelection = inst.value;
118
-
119
- if (isEqual(currentSelection, _nextSelection)) {
120
- memoizedSelection = currentSelection;
121
- return currentSelection;
122
- }
123
- }
124
- }
125
-
126
- memoizedSelection = _nextSelection;
127
- return _nextSelection;
128
- } // We may be able to reuse the previous invocation's result.
129
-
130
-
131
- // We may be able to reuse the previous invocation's result.
132
- var prevSnapshot = memoizedSnapshot;
133
- var prevSelection = memoizedSelection;
134
-
135
- if (objectIs(prevSnapshot, nextSnapshot)) {
136
- // The snapshot is the same as last time. Reuse the previous selection.
137
- return prevSelection;
138
- } // The snapshot has changed, so we need to compute a new selection.
139
-
140
-
141
- // The snapshot has changed, so we need to compute a new selection.
142
- var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
143
- // has changed. If it hasn't, return the previous selection. That signals
144
- // to React that the selections are conceptually equal, and we can bail
145
- // out of rendering.
146
-
147
- // If a custom isEqual function is provided, use that to check if the data
148
- // has changed. If it hasn't, return the previous selection. That signals
149
- // to React that the selections are conceptually equal, and we can bail
150
- // out of rendering.
151
- if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
152
- return prevSelection;
153
- }
154
-
155
- memoizedSnapshot = nextSnapshot;
156
- memoizedSelection = nextSelection;
157
- return nextSelection;
158
- }; // Assigning this to a constant so that Flow knows it can't change.
159
-
160
-
161
- // Assigning this to a constant so that Flow knows it can't change.
162
- var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
163
-
164
- var getSnapshotWithSelector = function () {
165
- return memoizedSelector(getSnapshot());
166
- };
167
-
168
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
169
- return memoizedSelector(maybeGetServerSnapshot());
170
- };
171
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
172
- }, [getSnapshot, getServerSnapshot, selector, isEqual]),
173
- getSelection = _useMemo[0],
174
- getServerSelection = _useMemo[1];
175
-
176
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
177
- useEffect(function () {
178
- inst.hasValue = true;
179
- inst.value = value;
180
- }, [value]);
181
- useDebugValue(value);
182
- return value;
183
- }
184
-
185
- useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
186
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
187
- if (
188
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
189
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
190
- 'function'
191
- ) {
192
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
193
- }
194
-
195
- })();
196
- }
197
- return useSyncExternalStoreWithSelector_development;
198
- }
199
-
200
- var hasRequiredWithSelector;
201
-
202
- function requireWithSelector () {
203
- if (hasRequiredWithSelector) return withSelector.exports;
204
- hasRequiredWithSelector = 1;
205
-
206
- if (process.env.NODE_ENV === 'production') {
207
- withSelector.exports = requireUseSyncExternalStoreWithSelector_production_min();
208
- } else {
209
- withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
210
- }
211
- return withSelector.exports;
212
- }
213
-
214
- var withSelectorExports = requireWithSelector();
215
-
216
- // src/index.ts
217
- var React = (
218
- // prettier-ignore
219
- // @ts-ignore
220
- "default" in ReactOriginal ? ReactOriginal["default"] : ReactOriginal
221
- );
222
-
223
- // src/components/Context.ts
224
- var ContextKey = Symbol.for(`react-redux-context`);
225
- var gT = typeof globalThis !== "undefined" ? globalThis : (
226
- /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
227
- {}
228
- );
229
- function getContext() {
230
- if (!React.createContext)
231
- return {};
232
- const contextMap = gT[ContextKey] ?? (gT[ContextKey] = /* @__PURE__ */ new Map());
233
- let realContext = contextMap.get(React.createContext);
234
- if (!realContext) {
235
- realContext = React.createContext(
236
- null
237
- );
238
- if (process.env.NODE_ENV !== "production") {
239
- realContext.displayName = "ReactRedux";
240
- }
241
- contextMap.set(React.createContext, realContext);
242
- }
243
- return realContext;
244
- }
245
- var ReactReduxContext = /* @__PURE__ */ getContext();
246
-
247
- // src/utils/useSyncExternalStore.ts
248
- var notInitialized = () => {
249
- throw new Error("uSES not initialized!");
250
- };
251
-
252
- // src/hooks/useReduxContext.ts
253
- function createReduxContextHook(context = ReactReduxContext) {
254
- return function useReduxContext2() {
255
- const contextValue = React.useContext(context);
256
- if (process.env.NODE_ENV !== "production" && !contextValue) {
257
- throw new Error(
258
- "could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
259
- );
260
- }
261
- return contextValue;
262
- };
263
- }
264
- var useReduxContext = /* @__PURE__ */ createReduxContextHook();
265
-
266
- // src/hooks/useSelector.ts
267
- var useSyncExternalStoreWithSelector = notInitialized;
268
- var initializeUseSelector = (fn) => {
269
- useSyncExternalStoreWithSelector = fn;
270
- };
271
- var refEquality = (a, b) => a === b;
272
- function createSelectorHook(context = ReactReduxContext) {
273
- const useReduxContext2 = context === ReactReduxContext ? useReduxContext : createReduxContextHook(context);
274
- const useSelector2 = (selector, equalityFnOrOptions = {}) => {
275
- const { equalityFn = refEquality, devModeChecks = {} } = typeof equalityFnOrOptions === "function" ? { equalityFn: equalityFnOrOptions } : equalityFnOrOptions;
276
- if (process.env.NODE_ENV !== "production") {
277
- if (!selector) {
278
- throw new Error(`You must pass a selector to useSelector`);
279
- }
280
- if (typeof selector !== "function") {
281
- throw new Error(`You must pass a function as a selector to useSelector`);
282
- }
283
- if (typeof equalityFn !== "function") {
284
- throw new Error(
285
- `You must pass a function as an equality function to useSelector`
286
- );
287
- }
288
- }
289
- const {
290
- store,
291
- subscription,
292
- getServerState,
293
- stabilityCheck,
294
- identityFunctionCheck
295
- } = useReduxContext2();
296
- const firstRun = React.useRef(true);
297
- const wrappedSelector = React.useCallback(
298
- {
299
- [selector.name](state) {
300
- const selected = selector(state);
301
- if (process.env.NODE_ENV !== "production") {
302
- const {
303
- identityFunctionCheck: finalIdentityFunctionCheck,
304
- stabilityCheck: finalStabilityCheck
305
- } = {
306
- stabilityCheck,
307
- identityFunctionCheck,
308
- ...devModeChecks
309
- };
310
- if (finalStabilityCheck === "always" || finalStabilityCheck === "once" && firstRun.current) {
311
- const toCompare = selector(state);
312
- if (!equalityFn(selected, toCompare)) {
313
- let stack = void 0;
314
- try {
315
- throw new Error();
316
- } catch (e) {
317
- ({ stack } = e);
318
- }
319
- console.warn(
320
- "Selector " + (selector.name || "unknown") + " returned a different result when called with the same parameters. This can lead to unnecessary rerenders.\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization",
321
- {
322
- state,
323
- selected,
324
- selected2: toCompare,
325
- stack
326
- }
327
- );
328
- }
329
- }
330
- if (finalIdentityFunctionCheck === "always" || finalIdentityFunctionCheck === "once" && firstRun.current) {
331
- if (selected === state) {
332
- let stack = void 0;
333
- try {
334
- throw new Error();
335
- } catch (e) {
336
- ({ stack } = e);
337
- }
338
- console.warn(
339
- "Selector " + (selector.name || "unknown") + " returned the root state when called. This can lead to unnecessary rerenders.\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.",
340
- { stack }
341
- );
342
- }
343
- }
344
- if (firstRun.current)
345
- firstRun.current = false;
346
- }
347
- return selected;
348
- }
349
- }[selector.name],
350
- [selector, stabilityCheck, devModeChecks.stabilityCheck]
351
- );
352
- const selectedState = useSyncExternalStoreWithSelector(
353
- subscription.addNestedSub,
354
- store.getState,
355
- getServerState || store.getState,
356
- wrappedSelector,
357
- equalityFn
358
- );
359
- React.useDebugValue(selectedState);
360
- return selectedState;
361
- };
362
- Object.assign(useSelector2, {
363
- withTypes: () => useSelector2
364
- });
365
- return useSelector2;
366
- }
367
- var useSelector = /* @__PURE__ */ createSelectorHook();
368
-
369
- // src/utils/react-is.ts
370
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
371
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
372
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
373
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
374
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
375
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
376
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
377
- var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
378
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
379
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
380
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
381
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
382
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
383
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
384
- var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
385
- var ForwardRef = REACT_FORWARD_REF_TYPE;
386
- var Memo = REACT_MEMO_TYPE;
387
- function isValidElementType(type) {
388
- if (typeof type === "string" || typeof type === "function") {
389
- return true;
390
- }
391
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_OFFSCREEN_TYPE) {
392
- return true;
393
- }
394
- if (typeof type === "object" && type !== null) {
395
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
396
- // types supported by any Flight configuration anywhere since
397
- // we don't know which Flight build this will end up being used
398
- // with.
399
- type.$$typeof === REACT_CLIENT_REFERENCE || type.getModuleId !== void 0) {
400
- return true;
401
- }
402
- }
403
- return false;
404
- }
405
- function typeOf(object) {
406
- if (typeof object === "object" && object !== null) {
407
- const $$typeof = object.$$typeof;
408
- switch ($$typeof) {
409
- case REACT_ELEMENT_TYPE: {
410
- const type = object.type;
411
- switch (type) {
412
- case REACT_FRAGMENT_TYPE:
413
- case REACT_PROFILER_TYPE:
414
- case REACT_STRICT_MODE_TYPE:
415
- case REACT_SUSPENSE_TYPE:
416
- case REACT_SUSPENSE_LIST_TYPE:
417
- return type;
418
- default: {
419
- const $$typeofType = type && type.$$typeof;
420
- switch ($$typeofType) {
421
- case REACT_SERVER_CONTEXT_TYPE:
422
- case REACT_CONTEXT_TYPE:
423
- case REACT_FORWARD_REF_TYPE:
424
- case REACT_LAZY_TYPE:
425
- case REACT_MEMO_TYPE:
426
- case REACT_PROVIDER_TYPE:
427
- return $$typeofType;
428
- default:
429
- return $$typeof;
430
- }
431
- }
432
- }
433
- }
434
- case REACT_PORTAL_TYPE: {
435
- return $$typeof;
436
- }
437
- }
438
- }
439
- return void 0;
440
- }
441
- function isContextConsumer(object) {
442
- return typeOf(object) === REACT_CONTEXT_TYPE;
443
- }
444
- function isMemo(object) {
445
- return typeOf(object) === REACT_MEMO_TYPE;
446
- }
447
-
448
- // src/utils/warning.ts
449
- function warning(message) {
450
- if (typeof console !== "undefined" && typeof console.error === "function") {
451
- console.error(message);
452
- }
453
- try {
454
- throw new Error(message);
455
- } catch (e) {
456
- }
457
- }
458
-
459
- // src/connect/verifySubselectors.ts
460
- function verify(selector, methodName) {
461
- if (!selector) {
462
- throw new Error(`Unexpected value for ${methodName} in connect.`);
463
- } else if (methodName === "mapStateToProps" || methodName === "mapDispatchToProps") {
464
- if (!Object.prototype.hasOwnProperty.call(selector, "dependsOnOwnProps")) {
465
- warning(
466
- `The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`
467
- );
468
- }
469
- }
470
- }
471
- function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps) {
472
- verify(mapStateToProps, "mapStateToProps");
473
- verify(mapDispatchToProps, "mapDispatchToProps");
474
- verify(mergeProps, "mergeProps");
475
- }
476
-
477
- // src/connect/selectorFactory.ts
478
- function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, {
479
- areStatesEqual,
480
- areOwnPropsEqual,
481
- areStatePropsEqual
482
- }) {
483
- let hasRunAtLeastOnce = false;
484
- let state;
485
- let ownProps;
486
- let stateProps;
487
- let dispatchProps;
488
- let mergedProps;
489
- function handleFirstCall(firstState, firstOwnProps) {
490
- state = firstState;
491
- ownProps = firstOwnProps;
492
- stateProps = mapStateToProps(state, ownProps);
493
- dispatchProps = mapDispatchToProps(dispatch, ownProps);
494
- mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
495
- hasRunAtLeastOnce = true;
496
- return mergedProps;
497
- }
498
- function handleNewPropsAndNewState() {
499
- stateProps = mapStateToProps(state, ownProps);
500
- if (mapDispatchToProps.dependsOnOwnProps)
501
- dispatchProps = mapDispatchToProps(dispatch, ownProps);
502
- mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
503
- return mergedProps;
504
- }
505
- function handleNewProps() {
506
- if (mapStateToProps.dependsOnOwnProps)
507
- stateProps = mapStateToProps(state, ownProps);
508
- if (mapDispatchToProps.dependsOnOwnProps)
509
- dispatchProps = mapDispatchToProps(dispatch, ownProps);
510
- mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
511
- return mergedProps;
512
- }
513
- function handleNewState() {
514
- const nextStateProps = mapStateToProps(state, ownProps);
515
- const statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
516
- stateProps = nextStateProps;
517
- if (statePropsChanged)
518
- mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
519
- return mergedProps;
520
- }
521
- function handleSubsequentCalls(nextState, nextOwnProps) {
522
- const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
523
- const stateChanged = !areStatesEqual(
524
- nextState,
525
- state,
526
- nextOwnProps,
527
- ownProps
528
- );
529
- state = nextState;
530
- ownProps = nextOwnProps;
531
- if (propsChanged && stateChanged)
532
- return handleNewPropsAndNewState();
533
- if (propsChanged)
534
- return handleNewProps();
535
- if (stateChanged)
536
- return handleNewState();
537
- return mergedProps;
538
- }
539
- return function pureFinalPropsSelector(nextState, nextOwnProps) {
540
- return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
541
- };
542
- }
543
- function finalPropsSelectorFactory(dispatch, {
544
- initMapStateToProps,
545
- initMapDispatchToProps,
546
- initMergeProps,
547
- ...options
548
- }) {
549
- const mapStateToProps = initMapStateToProps(dispatch, options);
550
- const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
551
- const mergeProps = initMergeProps(dispatch, options);
552
- if (process.env.NODE_ENV !== "production") {
553
- verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps);
554
- }
555
- return pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
556
- }
557
-
558
- // src/utils/bindActionCreators.ts
559
- function bindActionCreators(actionCreators, dispatch) {
560
- const boundActionCreators = {};
561
- for (const key in actionCreators) {
562
- const actionCreator = actionCreators[key];
563
- if (typeof actionCreator === "function") {
564
- boundActionCreators[key] = (...args) => dispatch(actionCreator(...args));
565
- }
566
- }
567
- return boundActionCreators;
568
- }
569
-
570
- // src/utils/isPlainObject.ts
571
- function isPlainObject(obj) {
572
- if (typeof obj !== "object" || obj === null)
573
- return false;
574
- const proto = Object.getPrototypeOf(obj);
575
- if (proto === null)
576
- return true;
577
- let baseProto = proto;
578
- while (Object.getPrototypeOf(baseProto) !== null) {
579
- baseProto = Object.getPrototypeOf(baseProto);
580
- }
581
- return proto === baseProto;
582
- }
583
-
584
- // src/utils/verifyPlainObject.ts
585
- function verifyPlainObject(value, displayName, methodName) {
586
- if (!isPlainObject(value)) {
587
- warning(
588
- `${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`
589
- );
590
- }
591
- }
592
-
593
- // src/connect/wrapMapToProps.ts
594
- function wrapMapToPropsConstant(getConstant) {
595
- return function initConstantSelector(dispatch) {
596
- const constant = getConstant(dispatch);
597
- function constantSelector() {
598
- return constant;
599
- }
600
- constantSelector.dependsOnOwnProps = false;
601
- return constantSelector;
602
- };
603
- }
604
- function getDependsOnOwnProps(mapToProps) {
605
- return mapToProps.dependsOnOwnProps ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
606
- }
607
- function wrapMapToPropsFunc(mapToProps, methodName) {
608
- return function initProxySelector(dispatch, { displayName }) {
609
- const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
610
- return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch, void 0);
611
- };
612
- proxy.dependsOnOwnProps = true;
613
- proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
614
- proxy.mapToProps = mapToProps;
615
- proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
616
- let props = proxy(stateOrDispatch, ownProps);
617
- if (typeof props === "function") {
618
- proxy.mapToProps = props;
619
- proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
620
- props = proxy(stateOrDispatch, ownProps);
621
- }
622
- if (process.env.NODE_ENV !== "production")
623
- verifyPlainObject(props, displayName, methodName);
624
- return props;
625
- };
626
- return proxy;
627
- };
628
- }
629
-
630
- // src/connect/invalidArgFactory.ts
631
- function createInvalidArgFactory(arg, name) {
632
- return (dispatch, options) => {
633
- throw new Error(
634
- `Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`
635
- );
636
- };
637
- }
638
-
639
- // src/connect/mapDispatchToProps.ts
640
- function mapDispatchToPropsFactory(mapDispatchToProps) {
641
- return mapDispatchToProps && typeof mapDispatchToProps === "object" ? wrapMapToPropsConstant(
642
- (dispatch) => (
643
- // @ts-ignore
644
- bindActionCreators(mapDispatchToProps, dispatch)
645
- )
646
- ) : !mapDispatchToProps ? wrapMapToPropsConstant((dispatch) => ({
647
- dispatch
648
- })) : typeof mapDispatchToProps === "function" ? (
649
- // @ts-ignore
650
- wrapMapToPropsFunc(mapDispatchToProps, "mapDispatchToProps")
651
- ) : createInvalidArgFactory(mapDispatchToProps, "mapDispatchToProps");
652
- }
653
-
654
- // src/connect/mapStateToProps.ts
655
- function mapStateToPropsFactory(mapStateToProps) {
656
- return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : typeof mapStateToProps === "function" ? (
657
- // @ts-ignore
658
- wrapMapToPropsFunc(mapStateToProps, "mapStateToProps")
659
- ) : createInvalidArgFactory(mapStateToProps, "mapStateToProps");
660
- }
661
-
662
- // src/connect/mergeProps.ts
663
- function defaultMergeProps(stateProps, dispatchProps, ownProps) {
664
- return { ...ownProps, ...stateProps, ...dispatchProps };
665
- }
666
- function wrapMergePropsFunc(mergeProps) {
667
- return function initMergePropsProxy(dispatch, { displayName, areMergedPropsEqual }) {
668
- let hasRunOnce = false;
669
- let mergedProps;
670
- return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
671
- const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
672
- if (hasRunOnce) {
673
- if (!areMergedPropsEqual(nextMergedProps, mergedProps))
674
- mergedProps = nextMergedProps;
675
- } else {
676
- hasRunOnce = true;
677
- mergedProps = nextMergedProps;
678
- if (process.env.NODE_ENV !== "production")
679
- verifyPlainObject(mergedProps, displayName, "mergeProps");
680
- }
681
- return mergedProps;
682
- };
683
- };
684
- }
685
- function mergePropsFactory(mergeProps) {
686
- return !mergeProps ? () => defaultMergeProps : typeof mergeProps === "function" ? wrapMergePropsFunc(mergeProps) : createInvalidArgFactory(mergeProps, "mergeProps");
687
- }
688
-
689
- // src/utils/batch.ts
690
- function defaultNoopBatch(callback) {
691
- callback();
692
- }
693
-
694
- // src/utils/Subscription.ts
695
- function createListenerCollection() {
696
- let first = null;
697
- let last = null;
698
- return {
699
- clear() {
700
- first = null;
701
- last = null;
702
- },
703
- notify() {
704
- defaultNoopBatch(() => {
705
- let listener = first;
706
- while (listener) {
707
- listener.callback();
708
- listener = listener.next;
709
- }
710
- });
711
- },
712
- get() {
713
- const listeners = [];
714
- let listener = first;
715
- while (listener) {
716
- listeners.push(listener);
717
- listener = listener.next;
718
- }
719
- return listeners;
720
- },
721
- subscribe(callback) {
722
- let isSubscribed = true;
723
- const listener = last = {
724
- callback,
725
- next: null,
726
- prev: last
727
- };
728
- if (listener.prev) {
729
- listener.prev.next = listener;
730
- } else {
731
- first = listener;
732
- }
733
- return function unsubscribe() {
734
- if (!isSubscribed || first === null)
735
- return;
736
- isSubscribed = false;
737
- if (listener.next) {
738
- listener.next.prev = listener.prev;
739
- } else {
740
- last = listener.prev;
741
- }
742
- if (listener.prev) {
743
- listener.prev.next = listener.next;
744
- } else {
745
- first = listener.next;
746
- }
747
- };
748
- }
749
- };
750
- }
751
- var nullListeners = {
752
- notify() {
753
- },
754
- get: () => []
755
- };
756
- function createSubscription(store, parentSub) {
757
- let unsubscribe;
758
- let listeners = nullListeners;
759
- let subscriptionsAmount = 0;
760
- let selfSubscribed = false;
761
- function addNestedSub(listener) {
762
- trySubscribe();
763
- const cleanupListener = listeners.subscribe(listener);
764
- let removed = false;
765
- return () => {
766
- if (!removed) {
767
- removed = true;
768
- cleanupListener();
769
- tryUnsubscribe();
770
- }
771
- };
772
- }
773
- function notifyNestedSubs() {
774
- listeners.notify();
775
- }
776
- function handleChangeWrapper() {
777
- if (subscription.onStateChange) {
778
- subscription.onStateChange();
779
- }
780
- }
781
- function isSubscribed() {
782
- return selfSubscribed;
783
- }
784
- function trySubscribe() {
785
- subscriptionsAmount++;
786
- if (!unsubscribe) {
787
- unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
788
- listeners = createListenerCollection();
789
- }
790
- }
791
- function tryUnsubscribe() {
792
- subscriptionsAmount--;
793
- if (unsubscribe && subscriptionsAmount === 0) {
794
- unsubscribe();
795
- unsubscribe = void 0;
796
- listeners.clear();
797
- listeners = nullListeners;
798
- }
799
- }
800
- function trySubscribeSelf() {
801
- if (!selfSubscribed) {
802
- selfSubscribed = true;
803
- trySubscribe();
804
- }
805
- }
806
- function tryUnsubscribeSelf() {
807
- if (selfSubscribed) {
808
- selfSubscribed = false;
809
- tryUnsubscribe();
810
- }
811
- }
812
- const subscription = {
813
- addNestedSub,
814
- notifyNestedSubs,
815
- handleChangeWrapper,
816
- isSubscribed,
817
- trySubscribe: trySubscribeSelf,
818
- tryUnsubscribe: tryUnsubscribeSelf,
819
- getListeners: () => listeners
820
- };
821
- return subscription;
822
- }
823
-
824
- // src/utils/useIsomorphicLayoutEffect.ts
825
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
826
- var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
827
- var useIsomorphicLayoutEffect = canUseDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
828
-
829
- // src/utils/shallowEqual.ts
830
- function is(x, y) {
831
- if (x === y) {
832
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
833
- } else {
834
- return x !== x && y !== y;
835
- }
836
- }
837
- function shallowEqual(objA, objB) {
838
- if (is(objA, objB))
839
- return true;
840
- if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
841
- return false;
842
- }
843
- const keysA = Object.keys(objA);
844
- const keysB = Object.keys(objB);
845
- if (keysA.length !== keysB.length)
846
- return false;
847
- for (let i = 0; i < keysA.length; i++) {
848
- if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
849
- return false;
850
- }
851
- }
852
- return true;
853
- }
854
-
855
- // src/utils/hoistStatics.ts
856
- var REACT_STATICS = {
857
- childContextTypes: true,
858
- contextType: true,
859
- contextTypes: true,
860
- defaultProps: true,
861
- displayName: true,
862
- getDefaultProps: true,
863
- getDerivedStateFromError: true,
864
- getDerivedStateFromProps: true,
865
- mixins: true,
866
- propTypes: true,
867
- type: true
868
- };
869
- var KNOWN_STATICS = {
870
- name: true,
871
- length: true,
872
- prototype: true,
873
- caller: true,
874
- callee: true,
875
- arguments: true,
876
- arity: true
877
- };
878
- var FORWARD_REF_STATICS = {
879
- $$typeof: true,
880
- render: true,
881
- defaultProps: true,
882
- displayName: true,
883
- propTypes: true
884
- };
885
- var MEMO_STATICS = {
886
- $$typeof: true,
887
- compare: true,
888
- defaultProps: true,
889
- displayName: true,
890
- propTypes: true,
891
- type: true
892
- };
893
- var TYPE_STATICS = {
894
- [ForwardRef]: FORWARD_REF_STATICS,
895
- [Memo]: MEMO_STATICS
896
- };
897
- function getStatics(component) {
898
- if (isMemo(component)) {
899
- return MEMO_STATICS;
900
- }
901
- return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
902
- }
903
- var defineProperty = Object.defineProperty;
904
- var getOwnPropertyNames = Object.getOwnPropertyNames;
905
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
906
- var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
907
- var getPrototypeOf = Object.getPrototypeOf;
908
- var objectPrototype = Object.prototype;
909
- function hoistNonReactStatics(targetComponent, sourceComponent) {
910
- if (typeof sourceComponent !== "string") {
911
- if (objectPrototype) {
912
- const inheritedComponent = getPrototypeOf(sourceComponent);
913
- if (inheritedComponent && inheritedComponent !== objectPrototype) {
914
- hoistNonReactStatics(targetComponent, inheritedComponent);
915
- }
916
- }
917
- let keys = getOwnPropertyNames(sourceComponent);
918
- if (getOwnPropertySymbols) {
919
- keys = keys.concat(getOwnPropertySymbols(sourceComponent));
920
- }
921
- const targetStatics = getStatics(targetComponent);
922
- const sourceStatics = getStatics(sourceComponent);
923
- for (let i = 0; i < keys.length; ++i) {
924
- const key = keys[i];
925
- if (!KNOWN_STATICS[key] && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
926
- const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
927
- try {
928
- defineProperty(targetComponent, key, descriptor);
929
- } catch (e) {
930
- }
931
- }
932
- }
933
- }
934
- return targetComponent;
935
- }
936
-
937
- // src/components/connect.tsx
938
- var useSyncExternalStore = notInitialized;
939
- var initializeConnect = (fn) => {
940
- useSyncExternalStore = fn;
941
- };
942
- var NO_SUBSCRIPTION_ARRAY = [null, null];
943
- var stringifyComponent = (Comp) => {
944
- try {
945
- return JSON.stringify(Comp);
946
- } catch (err) {
947
- return String(Comp);
948
- }
949
- };
950
- function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
951
- useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies);
952
- }
953
- function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, childPropsFromStoreUpdate, notifyNestedSubs) {
954
- lastWrapperProps.current = wrapperProps;
955
- renderIsScheduled.current = false;
956
- if (childPropsFromStoreUpdate.current) {
957
- childPropsFromStoreUpdate.current = null;
958
- notifyNestedSubs();
959
- }
960
- }
961
- function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, additionalSubscribeListener) {
962
- if (!shouldHandleStateChanges)
963
- return () => {
964
- };
965
- let didUnsubscribe = false;
966
- let lastThrownError = null;
967
- const checkForUpdates = () => {
968
- if (didUnsubscribe || !isMounted.current) {
969
- return;
970
- }
971
- const latestStoreState = store.getState();
972
- let newChildProps, error;
973
- try {
974
- newChildProps = childPropsSelector(
975
- latestStoreState,
976
- lastWrapperProps.current
977
- );
978
- } catch (e) {
979
- error = e;
980
- lastThrownError = e;
981
- }
982
- if (!error) {
983
- lastThrownError = null;
984
- }
985
- if (newChildProps === lastChildProps.current) {
986
- if (!renderIsScheduled.current) {
987
- notifyNestedSubs();
988
- }
989
- } else {
990
- lastChildProps.current = newChildProps;
991
- childPropsFromStoreUpdate.current = newChildProps;
992
- renderIsScheduled.current = true;
993
- additionalSubscribeListener();
994
- }
995
- };
996
- subscription.onStateChange = checkForUpdates;
997
- subscription.trySubscribe();
998
- checkForUpdates();
999
- const unsubscribeWrapper = () => {
1000
- didUnsubscribe = true;
1001
- subscription.tryUnsubscribe();
1002
- subscription.onStateChange = null;
1003
- if (lastThrownError) {
1004
- throw lastThrownError;
1005
- }
1006
- };
1007
- return unsubscribeWrapper;
1008
- }
1009
- function strictEqual(a, b) {
1010
- return a === b;
1011
- }
1012
- var hasWarnedAboutDeprecatedPureOption = false;
1013
- function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
1014
- // The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
1015
- // @ts-ignore
1016
- pure,
1017
- areStatesEqual = strictEqual,
1018
- areOwnPropsEqual = shallowEqual,
1019
- areStatePropsEqual = shallowEqual,
1020
- areMergedPropsEqual = shallowEqual,
1021
- // use React's forwardRef to expose a ref of the wrapped component
1022
- forwardRef = false,
1023
- // the context consumer to use
1024
- context = ReactReduxContext
1025
- } = {}) {
1026
- if (process.env.NODE_ENV !== "production") {
1027
- if (pure !== void 0 && !hasWarnedAboutDeprecatedPureOption) {
1028
- hasWarnedAboutDeprecatedPureOption = true;
1029
- warning(
1030
- 'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
1031
- );
1032
- }
1033
- }
1034
- const Context = context;
1035
- const initMapStateToProps = mapStateToPropsFactory(mapStateToProps);
1036
- const initMapDispatchToProps = mapDispatchToPropsFactory(mapDispatchToProps);
1037
- const initMergeProps = mergePropsFactory(mergeProps);
1038
- const shouldHandleStateChanges = Boolean(mapStateToProps);
1039
- const wrapWithConnect = (WrappedComponent) => {
1040
- if (process.env.NODE_ENV !== "production") {
1041
- const isValid = /* @__PURE__ */ isValidElementType(WrappedComponent);
1042
- if (!isValid)
1043
- throw new Error(
1044
- `You must pass a component to the function returned by connect. Instead received ${stringifyComponent(
1045
- WrappedComponent
1046
- )}`
1047
- );
1048
- }
1049
- const wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
1050
- const displayName = `Connect(${wrappedComponentName})`;
1051
- const selectorFactoryOptions = {
1052
- shouldHandleStateChanges,
1053
- displayName,
1054
- wrappedComponentName,
1055
- WrappedComponent,
1056
- // @ts-ignore
1057
- initMapStateToProps,
1058
- // @ts-ignore
1059
- initMapDispatchToProps,
1060
- initMergeProps,
1061
- areStatesEqual,
1062
- areStatePropsEqual,
1063
- areOwnPropsEqual,
1064
- areMergedPropsEqual
1065
- };
1066
- function ConnectFunction(props) {
1067
- const [propsContext, reactReduxForwardedRef, wrapperProps] = React.useMemo(() => {
1068
- const { reactReduxForwardedRef: reactReduxForwardedRef2, ...wrapperProps2 } = props;
1069
- return [props.context, reactReduxForwardedRef2, wrapperProps2];
1070
- }, [props]);
1071
- const ContextToUse = React.useMemo(() => {
1072
- let ResultContext = Context;
1073
- if (propsContext?.Consumer) {
1074
- if (process.env.NODE_ENV !== "production") {
1075
- const isValid = /* @__PURE__ */ isContextConsumer(
1076
- // @ts-ignore
1077
- /* @__PURE__ */ React.createElement(propsContext.Consumer, null)
1078
- );
1079
- if (!isValid) {
1080
- throw new Error(
1081
- "You must pass a valid React context consumer as `props.context`"
1082
- );
1083
- }
1084
- ResultContext = propsContext;
1085
- }
1086
- }
1087
- return ResultContext;
1088
- }, [propsContext, Context]);
1089
- const contextValue = React.useContext(ContextToUse);
1090
- const didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
1091
- const didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
1092
- if (process.env.NODE_ENV !== "production" && !didStoreComeFromProps && !didStoreComeFromContext) {
1093
- throw new Error(
1094
- `Could not find "store" in the context of "${displayName}". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to ${displayName} in connect options.`
1095
- );
1096
- }
1097
- const store = didStoreComeFromProps ? props.store : contextValue.store;
1098
- const getServerState = didStoreComeFromContext ? contextValue.getServerState : store.getState;
1099
- const childPropsSelector = React.useMemo(() => {
1100
- return finalPropsSelectorFactory(store.dispatch, selectorFactoryOptions);
1101
- }, [store]);
1102
- const [subscription, notifyNestedSubs] = React.useMemo(() => {
1103
- if (!shouldHandleStateChanges)
1104
- return NO_SUBSCRIPTION_ARRAY;
1105
- const subscription2 = createSubscription(
1106
- store,
1107
- didStoreComeFromProps ? void 0 : contextValue.subscription
1108
- );
1109
- const notifyNestedSubs2 = subscription2.notifyNestedSubs.bind(subscription2);
1110
- return [subscription2, notifyNestedSubs2];
1111
- }, [store, didStoreComeFromProps, contextValue]);
1112
- const overriddenContextValue = React.useMemo(() => {
1113
- if (didStoreComeFromProps) {
1114
- return contextValue;
1115
- }
1116
- return {
1117
- ...contextValue,
1118
- subscription
1119
- };
1120
- }, [didStoreComeFromProps, contextValue, subscription]);
1121
- const lastChildProps = React.useRef(void 0);
1122
- const lastWrapperProps = React.useRef(wrapperProps);
1123
- const childPropsFromStoreUpdate = React.useRef(void 0);
1124
- const renderIsScheduled = React.useRef(false);
1125
- const isMounted = React.useRef(false);
1126
- const latestSubscriptionCallbackError = React.useRef(
1127
- void 0
1128
- );
1129
- useIsomorphicLayoutEffect(() => {
1130
- isMounted.current = true;
1131
- return () => {
1132
- isMounted.current = false;
1133
- };
1134
- }, []);
1135
- const actualChildPropsSelector = React.useMemo(() => {
1136
- const selector = () => {
1137
- if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
1138
- return childPropsFromStoreUpdate.current;
1139
- }
1140
- return childPropsSelector(store.getState(), wrapperProps);
1141
- };
1142
- return selector;
1143
- }, [store, wrapperProps]);
1144
- const subscribeForReact = React.useMemo(() => {
1145
- const subscribe = (reactListener) => {
1146
- if (!subscription) {
1147
- return () => {
1148
- };
1149
- }
1150
- return subscribeUpdates(
1151
- shouldHandleStateChanges,
1152
- store,
1153
- subscription,
1154
- // @ts-ignore
1155
- childPropsSelector,
1156
- lastWrapperProps,
1157
- lastChildProps,
1158
- renderIsScheduled,
1159
- isMounted,
1160
- childPropsFromStoreUpdate,
1161
- notifyNestedSubs,
1162
- reactListener
1163
- );
1164
- };
1165
- return subscribe;
1166
- }, [subscription]);
1167
- useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
1168
- lastWrapperProps,
1169
- lastChildProps,
1170
- renderIsScheduled,
1171
- wrapperProps,
1172
- childPropsFromStoreUpdate,
1173
- notifyNestedSubs
1174
- ]);
1175
- let actualChildProps;
1176
- try {
1177
- actualChildProps = useSyncExternalStore(
1178
- // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
1179
- subscribeForReact,
1180
- // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
1181
- // TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
1182
- actualChildPropsSelector,
1183
- getServerState ? () => childPropsSelector(getServerState(), wrapperProps) : actualChildPropsSelector
1184
- );
1185
- } catch (err) {
1186
- if (latestSubscriptionCallbackError.current) {
1187
- err.message += `
1188
- The error may be correlated with this previous error:
1189
- ${latestSubscriptionCallbackError.current.stack}
1190
-
1191
- `;
1192
- }
1193
- throw err;
1194
- }
1195
- useIsomorphicLayoutEffect(() => {
1196
- latestSubscriptionCallbackError.current = void 0;
1197
- childPropsFromStoreUpdate.current = void 0;
1198
- lastChildProps.current = actualChildProps;
1199
- });
1200
- const renderedWrappedComponent = React.useMemo(() => {
1201
- return (
1202
- // @ts-ignore
1203
- /* @__PURE__ */ React.createElement(
1204
- WrappedComponent,
1205
- {
1206
- ...actualChildProps,
1207
- ref: reactReduxForwardedRef
1208
- }
1209
- )
1210
- );
1211
- }, [reactReduxForwardedRef, WrappedComponent, actualChildProps]);
1212
- const renderedChild = React.useMemo(() => {
1213
- if (shouldHandleStateChanges) {
1214
- return /* @__PURE__ */ React.createElement(ContextToUse.Provider, { value: overriddenContextValue }, renderedWrappedComponent);
1215
- }
1216
- return renderedWrappedComponent;
1217
- }, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
1218
- return renderedChild;
1219
- }
1220
- const _Connect = React.memo(ConnectFunction);
1221
- const Connect = _Connect;
1222
- Connect.WrappedComponent = WrappedComponent;
1223
- Connect.displayName = ConnectFunction.displayName = displayName;
1224
- if (forwardRef) {
1225
- const _forwarded = React.forwardRef(
1226
- function forwardConnectRef(props, ref) {
1227
- return /* @__PURE__ */ React.createElement(Connect, { ...props, reactReduxForwardedRef: ref });
1228
- }
1229
- );
1230
- const forwarded = _forwarded;
1231
- forwarded.displayName = displayName;
1232
- forwarded.WrappedComponent = WrappedComponent;
1233
- return /* @__PURE__ */ hoistNonReactStatics(forwarded, WrappedComponent);
1234
- }
1235
- return /* @__PURE__ */ hoistNonReactStatics(Connect, WrappedComponent);
1236
- };
1237
- return wrapWithConnect;
1238
- }
1239
- var connect_default = connect;
1240
-
1241
- // src/components/Provider.tsx
1242
- function Provider({
1243
- store,
1244
- context,
1245
- children,
1246
- serverState,
1247
- stabilityCheck = "once",
1248
- identityFunctionCheck = "once"
1249
- }) {
1250
- const contextValue = React.useMemo(() => {
1251
- const subscription = createSubscription(store);
1252
- return {
1253
- store,
1254
- subscription,
1255
- getServerState: serverState ? () => serverState : void 0,
1256
- stabilityCheck,
1257
- identityFunctionCheck
1258
- };
1259
- }, [store, serverState, stabilityCheck, identityFunctionCheck]);
1260
- const previousState = React.useMemo(() => store.getState(), [store]);
1261
- useIsomorphicLayoutEffect(() => {
1262
- const { subscription } = contextValue;
1263
- subscription.onStateChange = subscription.notifyNestedSubs;
1264
- subscription.trySubscribe();
1265
- if (previousState !== store.getState()) {
1266
- subscription.notifyNestedSubs();
1267
- }
1268
- return () => {
1269
- subscription.tryUnsubscribe();
1270
- subscription.onStateChange = void 0;
1271
- };
1272
- }, [contextValue, previousState]);
1273
- const Context = context || ReactReduxContext;
1274
- return /* @__PURE__ */ React.createElement(Context.Provider, { value: contextValue }, children);
1275
- }
1276
- var Provider_default = Provider;
1277
-
1278
- // src/hooks/useStore.ts
1279
- function createStoreHook(context = ReactReduxContext) {
1280
- const useReduxContext2 = context === ReactReduxContext ? useReduxContext : (
1281
- // @ts-ignore
1282
- createReduxContextHook(context)
1283
- );
1284
- const useStore2 = () => {
1285
- const { store } = useReduxContext2();
1286
- return store;
1287
- };
1288
- Object.assign(useStore2, {
1289
- withTypes: () => useStore2
1290
- });
1291
- return useStore2;
1292
- }
1293
- var useStore = /* @__PURE__ */ createStoreHook();
1294
-
1295
- // src/hooks/useDispatch.ts
1296
- function createDispatchHook(context = ReactReduxContext) {
1297
- const useStore2 = context === ReactReduxContext ? useStore : createStoreHook(context);
1298
- const useDispatch2 = () => {
1299
- const store = useStore2();
1300
- return store.dispatch;
1301
- };
1302
- Object.assign(useDispatch2, {
1303
- withTypes: () => useDispatch2
1304
- });
1305
- return useDispatch2;
1306
- }
1307
- var useDispatch = /* @__PURE__ */ createDispatchHook();
1308
-
1309
- // src/exports.ts
1310
- var batch = defaultNoopBatch;
1311
-
1312
- // src/index.ts
1313
- initializeUseSelector(withSelectorExports.useSyncExternalStoreWithSelector);
1314
- initializeConnect(ReactOriginal.useSyncExternalStore);
1315
-
1316
- export { Provider_default as Provider, ReactReduxContext, batch, connect_default as connect, createDispatchHook, createSelectorHook, createStoreHook, shallowEqual, useDispatch, useSelector, useStore };
1317
- //# sourceMappingURL=index.es.js.map