@preply/ds-web-lib 10.0.0 → 11.0.0
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/{DropdownMenu.primitives-CqJE9k4D.js → DropdownMenu.primitives-B3WK71bR.js} +4 -4
- package/dist/assets/Accordion.css +2 -2
- package/dist/assets/AlertBannerProvider.css +2 -2
- package/dist/assets/AlertDialog.css +2 -2
- package/dist/assets/Avatar.css +3 -3
- package/dist/assets/AvatarWithStatus.css +2 -2
- package/dist/assets/Badge.css +1 -1
- package/dist/assets/Box.css +3 -3
- package/dist/assets/BubbleCounter.css +1 -1
- package/dist/assets/Button.css +4 -4
- package/dist/assets/ButtonBase.css +4 -4
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/Chips.css +2 -2
- package/dist/assets/ChipsPrimitive.css +2 -2
- package/dist/assets/CountryFlag.css +1 -1
- package/dist/assets/Dialog.css +3 -3
- package/dist/assets/Divider.css +1 -1
- package/dist/assets/DropdownMenu.css +2 -2
- package/dist/assets/FieldButton.css +3 -3
- package/dist/assets/FormControl.css +1 -1
- package/dist/assets/Heading.css +3 -3
- package/dist/assets/Icon.css +3 -3
- package/dist/assets/IconTile.css +9 -1
- package/dist/assets/InputContainer.css +2 -2
- package/dist/assets/LayoutFlex.css +1 -1
- package/dist/assets/LayoutFlexItem.css +1 -1
- package/dist/assets/Link.css +3 -3
- package/dist/assets/Loader.css +1 -1
- package/dist/assets/OnboardingTooltip.css +6 -4
- package/dist/assets/OnboardingTour.css +3 -2
- package/dist/assets/PreplyLogo.css +1 -1
- package/dist/assets/ProgressBar.css +1 -1
- package/dist/assets/ProgressSteps.css +1 -1
- package/dist/assets/Select.css +2 -2
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/Spinner.css +3 -3
- package/dist/assets/Stars.css +3 -3
- package/dist/assets/Steps.css +2 -2
- package/dist/assets/Switch.css +1 -1
- package/dist/assets/Text.css +3 -3
- package/dist/assets/TextHighlighted.css +3 -3
- package/dist/assets/TextInline.css +3 -3
- package/dist/assets/Toast.css +2 -2
- package/dist/assets/Tooltip.css +1 -1
- package/dist/assets/align-self.css +1 -1
- package/dist/assets/exp-color.css +2 -2
- package/dist/assets/index.css +1 -1
- package/dist/assets/layout-gap.css +3 -3
- package/dist/assets/layout-grid.css +3 -3
- package/dist/assets/layout-hide.css +1 -1
- package/dist/assets/layout-padding.css +3 -3
- package/dist/assets/layout-relative.css +1 -1
- package/dist/assets/text-accent.css +2 -2
- package/dist/assets/text-centered.css +1 -1
- package/dist/assets/text-weight.css +2 -2
- package/dist/components/AlertDialog/AlertDialog.d.ts +3 -3
- package/dist/components/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +354 -18
- package/dist/components/Dialog/primitives/DialogCloseButton.d.ts.map +1 -1
- package/dist/components/Dialog/primitives/DialogCloseButton.js +5 -31
- package/dist/components/Dialog/primitives/DialogDescription.js +1 -1
- package/dist/components/Dialog/primitives/DialogRoot.js +5 -1149
- package/dist/components/Dialog/primitives/DialogTitle.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/DropdownMenu/primitives/DropdownMenu.primitives.js +1 -1
- package/dist/components/DropdownMenu/primitives/DropdownMenuSelectItem.primitives.js +1 -1
- package/dist/components/OnboardingTooltip/OnboardingTooltip.js +1 -1
- package/dist/{floating-ui.utils.dom-BvMNldxo.js → floating-ui.utils.dom-3OgjGonN.js} +1 -1
- package/dist/store-BUKWfVf3.js +1155 -0
- package/dist/{useButton-fjQ0ak8m.js → useButton-CFPpP0o5.js} +2 -2
- package/dist/useDialogClose-C9x1leGd.js +34 -0
- package/dist/{useOpenInteractionType-DNYFqf-a.js → useOpenInteractionType-Cj41-8Yk.js} +48 -48
- package/dist/{useRenderElement-BSthtPOr.js → useRenderElement-DtYPTE_y.js} +2 -2
- package/package.json +12 -12
|
@@ -0,0 +1,1155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import React__default from "react";
|
|
7
|
+
import { u as useEventCallback, a as useIsoLayoutEffect } from "./floating-ui.utils.dom-3OgjGonN.js";
|
|
8
|
+
import { d as useTransitionStatus, e as useOpenInteractionType, u as useOpenChangeComplete, f as useFloatingRootContext, h as useRole, j as useClick, k as useDismiss, l as useScrollLock, m as useInteractions, n as getTarget } from "./useOpenInteractionType-Cj41-8Yk.js";
|
|
9
|
+
import { N as NOOP } from "./useRenderElement-DtYPTE_y.js";
|
|
10
|
+
function useDialogRoot(params) {
|
|
11
|
+
const {
|
|
12
|
+
store,
|
|
13
|
+
parentContext
|
|
14
|
+
} = params;
|
|
15
|
+
const open = store.useState("open");
|
|
16
|
+
const dismissible = store.useState("dismissible");
|
|
17
|
+
const modal = store.useState("modal");
|
|
18
|
+
const triggerElement = store.useState("triggerElement");
|
|
19
|
+
const popupElement = store.useState("popupElement");
|
|
20
|
+
const {
|
|
21
|
+
mounted,
|
|
22
|
+
setMounted,
|
|
23
|
+
transitionStatus
|
|
24
|
+
} = useTransitionStatus(open);
|
|
25
|
+
const {
|
|
26
|
+
openMethod,
|
|
27
|
+
triggerProps,
|
|
28
|
+
reset: resetOpenInteractionType
|
|
29
|
+
} = useOpenInteractionType(open);
|
|
30
|
+
const handleUnmount = useEventCallback(() => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
setMounted(false);
|
|
33
|
+
(_b = (_a = store.context).openChangeComplete) == null ? void 0 : _b.call(_a, false);
|
|
34
|
+
resetOpenInteractionType();
|
|
35
|
+
});
|
|
36
|
+
useOpenChangeComplete({
|
|
37
|
+
enabled: !params.actionsRef,
|
|
38
|
+
open,
|
|
39
|
+
ref: store.context.popupRef,
|
|
40
|
+
onComplete() {
|
|
41
|
+
if (!open) {
|
|
42
|
+
handleUnmount();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
React.useImperativeHandle(params.actionsRef, () => ({
|
|
47
|
+
unmount: handleUnmount
|
|
48
|
+
}), [handleUnmount]);
|
|
49
|
+
const context = useFloatingRootContext({
|
|
50
|
+
elements: {
|
|
51
|
+
reference: triggerElement,
|
|
52
|
+
floating: popupElement
|
|
53
|
+
},
|
|
54
|
+
open,
|
|
55
|
+
onOpenChange: store.setOpen,
|
|
56
|
+
noEmit: true
|
|
57
|
+
});
|
|
58
|
+
const [ownNestedOpenDialogs, setOwnNestedOpenDialogs] = React.useState(0);
|
|
59
|
+
const isTopmost = ownNestedOpenDialogs === 0;
|
|
60
|
+
const role = useRole(context);
|
|
61
|
+
const click = useClick(context);
|
|
62
|
+
const dismiss = useDismiss(context, {
|
|
63
|
+
outsidePressEvent() {
|
|
64
|
+
if (store.context.internalBackdropRef.current || store.context.backdropRef.current) {
|
|
65
|
+
return "intentional";
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
mouse: modal === "trap-focus" ? "sloppy" : "intentional",
|
|
69
|
+
touch: "sloppy"
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
outsidePress(event) {
|
|
73
|
+
if (event.button !== 0) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const target = getTarget(event);
|
|
77
|
+
if (isTopmost && dismissible) {
|
|
78
|
+
const eventTarget = target;
|
|
79
|
+
if (modal) {
|
|
80
|
+
return store.context.internalBackdropRef.current || store.context.backdropRef.current ? store.context.internalBackdropRef.current === eventTarget || store.context.backdropRef.current === eventTarget : true;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
},
|
|
86
|
+
escapeKey: isTopmost
|
|
87
|
+
});
|
|
88
|
+
useScrollLock({
|
|
89
|
+
enabled: open && modal === true,
|
|
90
|
+
mounted,
|
|
91
|
+
open,
|
|
92
|
+
referenceElement: popupElement
|
|
93
|
+
});
|
|
94
|
+
const {
|
|
95
|
+
getReferenceProps,
|
|
96
|
+
getFloatingProps
|
|
97
|
+
} = useInteractions([role, click, dismiss]);
|
|
98
|
+
store.useContextCallback("nestedDialogOpen", (ownChildrenCount) => {
|
|
99
|
+
setOwnNestedOpenDialogs(ownChildrenCount + 1);
|
|
100
|
+
});
|
|
101
|
+
store.useContextCallback("nestedDialogClose", () => {
|
|
102
|
+
setOwnNestedOpenDialogs(0);
|
|
103
|
+
});
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
if ((parentContext == null ? void 0 : parentContext.nestedDialogOpen) && open) {
|
|
106
|
+
parentContext.nestedDialogOpen(ownNestedOpenDialogs);
|
|
107
|
+
}
|
|
108
|
+
if ((parentContext == null ? void 0 : parentContext.nestedDialogClose) && !open) {
|
|
109
|
+
parentContext.nestedDialogClose();
|
|
110
|
+
}
|
|
111
|
+
return () => {
|
|
112
|
+
if ((parentContext == null ? void 0 : parentContext.nestedDialogClose) && open) {
|
|
113
|
+
parentContext.nestedDialogClose();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}, [open, parentContext, ownNestedOpenDialogs]);
|
|
117
|
+
const dialogTriggerProps = React.useMemo(() => getReferenceProps(triggerProps), [getReferenceProps, triggerProps]);
|
|
118
|
+
store.useSyncedValues({
|
|
119
|
+
openMethod,
|
|
120
|
+
mounted,
|
|
121
|
+
transitionStatus,
|
|
122
|
+
triggerProps: dialogTriggerProps,
|
|
123
|
+
popupProps: getFloatingProps(),
|
|
124
|
+
floatingRootContext: context,
|
|
125
|
+
nestedOpenDialogCount: ownNestedOpenDialogs
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
var runIdentityFunctionCheck = (resultFunc, inputSelectorsResults, outputSelectorResult) => {
|
|
129
|
+
if (inputSelectorsResults.length === 1 && inputSelectorsResults[0] === outputSelectorResult) {
|
|
130
|
+
let isInputSameAsOutput = false;
|
|
131
|
+
try {
|
|
132
|
+
const emptyObject = {};
|
|
133
|
+
if (resultFunc(emptyObject) === emptyObject)
|
|
134
|
+
isInputSameAsOutput = true;
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
if (isInputSameAsOutput) {
|
|
138
|
+
let stack = void 0;
|
|
139
|
+
try {
|
|
140
|
+
throw new Error();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
({ stack } = e);
|
|
143
|
+
}
|
|
144
|
+
console.warn(
|
|
145
|
+
"The result function returned its own inputs without modification. e.g\n`createSelector([state => state.todos], todos => todos)`\nThis could lead to inefficient memoization and unnecessary re-renders.\nEnsure transformation logic is in the result function, and extraction logic is in the input selectors.",
|
|
146
|
+
{ stack }
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var runInputStabilityCheck = (inputSelectorResultsObject, options, inputSelectorArgs) => {
|
|
152
|
+
const { memoize, memoizeOptions } = options;
|
|
153
|
+
const { inputSelectorResults, inputSelectorResultsCopy } = inputSelectorResultsObject;
|
|
154
|
+
const createAnEmptyObject = memoize(() => ({}), ...memoizeOptions);
|
|
155
|
+
const areInputSelectorResultsEqual = createAnEmptyObject.apply(null, inputSelectorResults) === createAnEmptyObject.apply(null, inputSelectorResultsCopy);
|
|
156
|
+
if (!areInputSelectorResultsEqual) {
|
|
157
|
+
let stack = void 0;
|
|
158
|
+
try {
|
|
159
|
+
throw new Error();
|
|
160
|
+
} catch (e) {
|
|
161
|
+
({ stack } = e);
|
|
162
|
+
}
|
|
163
|
+
console.warn(
|
|
164
|
+
"An input selector returned a different result when passed same arguments.\nThis means your output selector will likely run more frequently than intended.\nAvoid returning a new reference inside your input selector, e.g.\n`createSelector([state => state.todos.map(todo => todo.id)], todoIds => todoIds.length)`",
|
|
165
|
+
{
|
|
166
|
+
arguments: inputSelectorArgs,
|
|
167
|
+
firstInputs: inputSelectorResults,
|
|
168
|
+
secondInputs: inputSelectorResultsCopy,
|
|
169
|
+
stack
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var globalDevModeChecks = {
|
|
175
|
+
inputStabilityCheck: "once",
|
|
176
|
+
identityFunctionCheck: "once"
|
|
177
|
+
};
|
|
178
|
+
var NOT_FOUND = /* @__PURE__ */ Symbol("NOT_FOUND");
|
|
179
|
+
function assertIsFunction(func, errorMessage = `expected a function, instead received ${typeof func}`) {
|
|
180
|
+
if (typeof func !== "function") {
|
|
181
|
+
throw new TypeError(errorMessage);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function assertIsObject(object, errorMessage = `expected an object, instead received ${typeof object}`) {
|
|
185
|
+
if (typeof object !== "object") {
|
|
186
|
+
throw new TypeError(errorMessage);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
function assertIsArrayOfFunctions(array, errorMessage = `expected all items to be functions, instead received the following types: `) {
|
|
190
|
+
if (!array.every((item) => typeof item === "function")) {
|
|
191
|
+
const itemTypes = array.map(
|
|
192
|
+
(item) => typeof item === "function" ? `function ${item.name || "unnamed"}()` : typeof item
|
|
193
|
+
).join(", ");
|
|
194
|
+
throw new TypeError(`${errorMessage}[${itemTypes}]`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
var ensureIsArray = (item) => {
|
|
198
|
+
return Array.isArray(item) ? item : [item];
|
|
199
|
+
};
|
|
200
|
+
function getDependencies(createSelectorArgs) {
|
|
201
|
+
const dependencies = Array.isArray(createSelectorArgs[0]) ? createSelectorArgs[0] : createSelectorArgs;
|
|
202
|
+
assertIsArrayOfFunctions(
|
|
203
|
+
dependencies,
|
|
204
|
+
`createSelector expects all input-selectors to be functions, but received the following types: `
|
|
205
|
+
);
|
|
206
|
+
return dependencies;
|
|
207
|
+
}
|
|
208
|
+
function collectInputSelectorResults(dependencies, inputSelectorArgs) {
|
|
209
|
+
const inputSelectorResults = [];
|
|
210
|
+
const { length } = dependencies;
|
|
211
|
+
for (let i = 0; i < length; i++) {
|
|
212
|
+
inputSelectorResults.push(dependencies[i].apply(null, inputSelectorArgs));
|
|
213
|
+
}
|
|
214
|
+
return inputSelectorResults;
|
|
215
|
+
}
|
|
216
|
+
var getDevModeChecksExecutionInfo = (firstRun, devModeChecks) => {
|
|
217
|
+
const { identityFunctionCheck, inputStabilityCheck } = {
|
|
218
|
+
...globalDevModeChecks,
|
|
219
|
+
...devModeChecks
|
|
220
|
+
};
|
|
221
|
+
return {
|
|
222
|
+
identityFunctionCheck: {
|
|
223
|
+
shouldRun: identityFunctionCheck === "always" || identityFunctionCheck === "once" && firstRun,
|
|
224
|
+
run: runIdentityFunctionCheck
|
|
225
|
+
},
|
|
226
|
+
inputStabilityCheck: {
|
|
227
|
+
shouldRun: inputStabilityCheck === "always" || inputStabilityCheck === "once" && firstRun,
|
|
228
|
+
run: runInputStabilityCheck
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
function createSingletonCache(equals) {
|
|
233
|
+
let entry;
|
|
234
|
+
return {
|
|
235
|
+
get(key) {
|
|
236
|
+
if (entry && equals(entry.key, key)) {
|
|
237
|
+
return entry.value;
|
|
238
|
+
}
|
|
239
|
+
return NOT_FOUND;
|
|
240
|
+
},
|
|
241
|
+
put(key, value) {
|
|
242
|
+
entry = { key, value };
|
|
243
|
+
},
|
|
244
|
+
getEntries() {
|
|
245
|
+
return entry ? [entry] : [];
|
|
246
|
+
},
|
|
247
|
+
clear() {
|
|
248
|
+
entry = void 0;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function createLruCache(maxSize, equals) {
|
|
253
|
+
let entries = [];
|
|
254
|
+
function get(key) {
|
|
255
|
+
const cacheIndex = entries.findIndex((entry) => equals(key, entry.key));
|
|
256
|
+
if (cacheIndex > -1) {
|
|
257
|
+
const entry = entries[cacheIndex];
|
|
258
|
+
if (cacheIndex > 0) {
|
|
259
|
+
entries.splice(cacheIndex, 1);
|
|
260
|
+
entries.unshift(entry);
|
|
261
|
+
}
|
|
262
|
+
return entry.value;
|
|
263
|
+
}
|
|
264
|
+
return NOT_FOUND;
|
|
265
|
+
}
|
|
266
|
+
function put(key, value) {
|
|
267
|
+
if (get(key) === NOT_FOUND) {
|
|
268
|
+
entries.unshift({ key, value });
|
|
269
|
+
if (entries.length > maxSize) {
|
|
270
|
+
entries.pop();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function getEntries() {
|
|
275
|
+
return entries;
|
|
276
|
+
}
|
|
277
|
+
function clear() {
|
|
278
|
+
entries = [];
|
|
279
|
+
}
|
|
280
|
+
return { get, put, getEntries, clear };
|
|
281
|
+
}
|
|
282
|
+
var referenceEqualityCheck = (a, b) => a === b;
|
|
283
|
+
function createCacheKeyComparator(equalityCheck) {
|
|
284
|
+
return function areArgumentsShallowlyEqual(prev, next) {
|
|
285
|
+
if (prev === null || next === null || prev.length !== next.length) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
const { length } = prev;
|
|
289
|
+
for (let i = 0; i < length; i++) {
|
|
290
|
+
if (!equalityCheck(prev[i], next[i])) {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function lruMemoize(func, equalityCheckOrOptions) {
|
|
298
|
+
const providedOptions = typeof equalityCheckOrOptions === "object" ? equalityCheckOrOptions : { equalityCheck: equalityCheckOrOptions };
|
|
299
|
+
const {
|
|
300
|
+
equalityCheck = referenceEqualityCheck,
|
|
301
|
+
maxSize = 1,
|
|
302
|
+
resultEqualityCheck
|
|
303
|
+
} = providedOptions;
|
|
304
|
+
const comparator = createCacheKeyComparator(equalityCheck);
|
|
305
|
+
let resultsCount = 0;
|
|
306
|
+
const cache = maxSize <= 1 ? createSingletonCache(comparator) : createLruCache(maxSize, comparator);
|
|
307
|
+
function memoized() {
|
|
308
|
+
let value = cache.get(arguments);
|
|
309
|
+
if (value === NOT_FOUND) {
|
|
310
|
+
value = func.apply(null, arguments);
|
|
311
|
+
resultsCount++;
|
|
312
|
+
if (resultEqualityCheck) {
|
|
313
|
+
const entries = cache.getEntries();
|
|
314
|
+
const matchingEntry = entries.find(
|
|
315
|
+
(entry) => resultEqualityCheck(entry.value, value)
|
|
316
|
+
);
|
|
317
|
+
if (matchingEntry) {
|
|
318
|
+
value = matchingEntry.value;
|
|
319
|
+
resultsCount !== 0 && resultsCount--;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
cache.put(arguments, value);
|
|
323
|
+
}
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
326
|
+
memoized.clearCache = () => {
|
|
327
|
+
cache.clear();
|
|
328
|
+
memoized.resetResultsCount();
|
|
329
|
+
};
|
|
330
|
+
memoized.resultsCount = () => resultsCount;
|
|
331
|
+
memoized.resetResultsCount = () => {
|
|
332
|
+
resultsCount = 0;
|
|
333
|
+
};
|
|
334
|
+
return memoized;
|
|
335
|
+
}
|
|
336
|
+
var StrongRef = class {
|
|
337
|
+
constructor(value) {
|
|
338
|
+
this.value = value;
|
|
339
|
+
}
|
|
340
|
+
deref() {
|
|
341
|
+
return this.value;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
var Ref = typeof WeakRef !== "undefined" ? WeakRef : StrongRef;
|
|
345
|
+
var UNTERMINATED = 0;
|
|
346
|
+
var TERMINATED = 1;
|
|
347
|
+
function createCacheNode() {
|
|
348
|
+
return {
|
|
349
|
+
s: UNTERMINATED,
|
|
350
|
+
v: void 0,
|
|
351
|
+
o: null,
|
|
352
|
+
p: null
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function weakMapMemoize(func, options = {}) {
|
|
356
|
+
let fnNode = createCacheNode();
|
|
357
|
+
const { resultEqualityCheck } = options;
|
|
358
|
+
let lastResult;
|
|
359
|
+
let resultsCount = 0;
|
|
360
|
+
function memoized() {
|
|
361
|
+
var _a, _b;
|
|
362
|
+
let cacheNode = fnNode;
|
|
363
|
+
const { length } = arguments;
|
|
364
|
+
for (let i = 0, l = length; i < l; i++) {
|
|
365
|
+
const arg = arguments[i];
|
|
366
|
+
if (typeof arg === "function" || typeof arg === "object" && arg !== null) {
|
|
367
|
+
let objectCache = cacheNode.o;
|
|
368
|
+
if (objectCache === null) {
|
|
369
|
+
cacheNode.o = objectCache = /* @__PURE__ */ new WeakMap();
|
|
370
|
+
}
|
|
371
|
+
const objectNode = objectCache.get(arg);
|
|
372
|
+
if (objectNode === void 0) {
|
|
373
|
+
cacheNode = createCacheNode();
|
|
374
|
+
objectCache.set(arg, cacheNode);
|
|
375
|
+
} else {
|
|
376
|
+
cacheNode = objectNode;
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
let primitiveCache = cacheNode.p;
|
|
380
|
+
if (primitiveCache === null) {
|
|
381
|
+
cacheNode.p = primitiveCache = /* @__PURE__ */ new Map();
|
|
382
|
+
}
|
|
383
|
+
const primitiveNode = primitiveCache.get(arg);
|
|
384
|
+
if (primitiveNode === void 0) {
|
|
385
|
+
cacheNode = createCacheNode();
|
|
386
|
+
primitiveCache.set(arg, cacheNode);
|
|
387
|
+
} else {
|
|
388
|
+
cacheNode = primitiveNode;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
const terminatedNode = cacheNode;
|
|
393
|
+
let result;
|
|
394
|
+
if (cacheNode.s === TERMINATED) {
|
|
395
|
+
result = cacheNode.v;
|
|
396
|
+
} else {
|
|
397
|
+
result = func.apply(null, arguments);
|
|
398
|
+
resultsCount++;
|
|
399
|
+
if (resultEqualityCheck) {
|
|
400
|
+
const lastResultValue = (_b = (_a = lastResult == null ? void 0 : lastResult.deref) == null ? void 0 : _a.call(lastResult)) != null ? _b : lastResult;
|
|
401
|
+
if (lastResultValue != null && resultEqualityCheck(lastResultValue, result)) {
|
|
402
|
+
result = lastResultValue;
|
|
403
|
+
resultsCount !== 0 && resultsCount--;
|
|
404
|
+
}
|
|
405
|
+
const needsWeakRef = typeof result === "object" && result !== null || typeof result === "function";
|
|
406
|
+
lastResult = needsWeakRef ? new Ref(result) : result;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
terminatedNode.s = TERMINATED;
|
|
410
|
+
terminatedNode.v = result;
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
memoized.clearCache = () => {
|
|
414
|
+
fnNode = createCacheNode();
|
|
415
|
+
memoized.resetResultsCount();
|
|
416
|
+
};
|
|
417
|
+
memoized.resultsCount = () => resultsCount;
|
|
418
|
+
memoized.resetResultsCount = () => {
|
|
419
|
+
resultsCount = 0;
|
|
420
|
+
};
|
|
421
|
+
return memoized;
|
|
422
|
+
}
|
|
423
|
+
function createSelectorCreator(memoizeOrOptions, ...memoizeOptionsFromArgs) {
|
|
424
|
+
const createSelectorCreatorOptions = typeof memoizeOrOptions === "function" ? {
|
|
425
|
+
memoize: memoizeOrOptions,
|
|
426
|
+
memoizeOptions: memoizeOptionsFromArgs
|
|
427
|
+
} : memoizeOrOptions;
|
|
428
|
+
const createSelector2 = (...createSelectorArgs) => {
|
|
429
|
+
let recomputations = 0;
|
|
430
|
+
let dependencyRecomputations = 0;
|
|
431
|
+
let lastResult;
|
|
432
|
+
let directlyPassedOptions = {};
|
|
433
|
+
let resultFunc = createSelectorArgs.pop();
|
|
434
|
+
if (typeof resultFunc === "object") {
|
|
435
|
+
directlyPassedOptions = resultFunc;
|
|
436
|
+
resultFunc = createSelectorArgs.pop();
|
|
437
|
+
}
|
|
438
|
+
assertIsFunction(
|
|
439
|
+
resultFunc,
|
|
440
|
+
`createSelector expects an output function after the inputs, but received: [${typeof resultFunc}]`
|
|
441
|
+
);
|
|
442
|
+
const combinedOptions = {
|
|
443
|
+
...createSelectorCreatorOptions,
|
|
444
|
+
...directlyPassedOptions
|
|
445
|
+
};
|
|
446
|
+
const {
|
|
447
|
+
memoize,
|
|
448
|
+
memoizeOptions = [],
|
|
449
|
+
argsMemoize = weakMapMemoize,
|
|
450
|
+
argsMemoizeOptions = [],
|
|
451
|
+
devModeChecks = {}
|
|
452
|
+
} = combinedOptions;
|
|
453
|
+
const finalMemoizeOptions = ensureIsArray(memoizeOptions);
|
|
454
|
+
const finalArgsMemoizeOptions = ensureIsArray(argsMemoizeOptions);
|
|
455
|
+
const dependencies = getDependencies(createSelectorArgs);
|
|
456
|
+
const memoizedResultFunc = memoize(function recomputationWrapper() {
|
|
457
|
+
recomputations++;
|
|
458
|
+
return resultFunc.apply(
|
|
459
|
+
null,
|
|
460
|
+
arguments
|
|
461
|
+
);
|
|
462
|
+
}, ...finalMemoizeOptions);
|
|
463
|
+
let firstRun = true;
|
|
464
|
+
const selector = argsMemoize(function dependenciesChecker() {
|
|
465
|
+
dependencyRecomputations++;
|
|
466
|
+
const inputSelectorResults = collectInputSelectorResults(
|
|
467
|
+
dependencies,
|
|
468
|
+
arguments
|
|
469
|
+
);
|
|
470
|
+
lastResult = memoizedResultFunc.apply(null, inputSelectorResults);
|
|
471
|
+
if (process.env.NODE_ENV !== "production") {
|
|
472
|
+
const { identityFunctionCheck, inputStabilityCheck } = getDevModeChecksExecutionInfo(firstRun, devModeChecks);
|
|
473
|
+
if (identityFunctionCheck.shouldRun) {
|
|
474
|
+
identityFunctionCheck.run(
|
|
475
|
+
resultFunc,
|
|
476
|
+
inputSelectorResults,
|
|
477
|
+
lastResult
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (inputStabilityCheck.shouldRun) {
|
|
481
|
+
const inputSelectorResultsCopy = collectInputSelectorResults(
|
|
482
|
+
dependencies,
|
|
483
|
+
arguments
|
|
484
|
+
);
|
|
485
|
+
inputStabilityCheck.run(
|
|
486
|
+
{ inputSelectorResults, inputSelectorResultsCopy },
|
|
487
|
+
{ memoize, memoizeOptions: finalMemoizeOptions },
|
|
488
|
+
arguments
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
if (firstRun)
|
|
492
|
+
firstRun = false;
|
|
493
|
+
}
|
|
494
|
+
return lastResult;
|
|
495
|
+
}, ...finalArgsMemoizeOptions);
|
|
496
|
+
return Object.assign(selector, {
|
|
497
|
+
resultFunc,
|
|
498
|
+
memoizedResultFunc,
|
|
499
|
+
dependencies,
|
|
500
|
+
dependencyRecomputations: () => dependencyRecomputations,
|
|
501
|
+
resetDependencyRecomputations: () => {
|
|
502
|
+
dependencyRecomputations = 0;
|
|
503
|
+
},
|
|
504
|
+
lastResult: () => lastResult,
|
|
505
|
+
recomputations: () => recomputations,
|
|
506
|
+
resetRecomputations: () => {
|
|
507
|
+
recomputations = 0;
|
|
508
|
+
},
|
|
509
|
+
memoize,
|
|
510
|
+
argsMemoize
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
Object.assign(createSelector2, {
|
|
514
|
+
withTypes: () => createSelector2
|
|
515
|
+
});
|
|
516
|
+
return createSelector2;
|
|
517
|
+
}
|
|
518
|
+
var createSelector$1 = /* @__PURE__ */ createSelectorCreator(weakMapMemoize);
|
|
519
|
+
var createStructuredSelector = Object.assign(
|
|
520
|
+
(inputSelectorsObject, selectorCreator = createSelector$1) => {
|
|
521
|
+
assertIsObject(
|
|
522
|
+
inputSelectorsObject,
|
|
523
|
+
`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof inputSelectorsObject}`
|
|
524
|
+
);
|
|
525
|
+
const inputSelectorKeys = Object.keys(inputSelectorsObject);
|
|
526
|
+
const dependencies = inputSelectorKeys.map(
|
|
527
|
+
(key) => inputSelectorsObject[key]
|
|
528
|
+
);
|
|
529
|
+
const structuredSelector = selectorCreator(
|
|
530
|
+
dependencies,
|
|
531
|
+
(...inputSelectorResults) => {
|
|
532
|
+
return inputSelectorResults.reduce((composition, value, index) => {
|
|
533
|
+
composition[inputSelectorKeys[index]] = value;
|
|
534
|
+
return composition;
|
|
535
|
+
}, {});
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
return structuredSelector;
|
|
539
|
+
},
|
|
540
|
+
{ withTypes: () => createStructuredSelector }
|
|
541
|
+
);
|
|
542
|
+
createSelectorCreator({
|
|
543
|
+
memoize: lruMemoize,
|
|
544
|
+
memoizeOptions: {
|
|
545
|
+
maxSize: 1,
|
|
546
|
+
equalityCheck: Object.is
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
550
|
+
if (other.length > 0) {
|
|
551
|
+
throw new Error("Unsupported number of selectors");
|
|
552
|
+
}
|
|
553
|
+
let selector;
|
|
554
|
+
if (a) {
|
|
555
|
+
selector = a;
|
|
556
|
+
} else {
|
|
557
|
+
throw new Error("Missing arguments");
|
|
558
|
+
}
|
|
559
|
+
return selector;
|
|
560
|
+
};
|
|
561
|
+
var withSelector = { exports: {} };
|
|
562
|
+
var withSelector_production = {};
|
|
563
|
+
var shim = { exports: {} };
|
|
564
|
+
var useSyncExternalStoreShim_production = {};
|
|
565
|
+
/**
|
|
566
|
+
* @license React
|
|
567
|
+
* use-sync-external-store-shim.production.js
|
|
568
|
+
*
|
|
569
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
570
|
+
*
|
|
571
|
+
* This source code is licensed under the MIT license found in the
|
|
572
|
+
* LICENSE file in the root directory of this source tree.
|
|
573
|
+
*/
|
|
574
|
+
var hasRequiredUseSyncExternalStoreShim_production;
|
|
575
|
+
function requireUseSyncExternalStoreShim_production() {
|
|
576
|
+
if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
|
|
577
|
+
hasRequiredUseSyncExternalStoreShim_production = 1;
|
|
578
|
+
var React2 = React__default;
|
|
579
|
+
function is(x, y) {
|
|
580
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
581
|
+
}
|
|
582
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is, useState = React2.useState, useEffect = React2.useEffect, useLayoutEffect = React2.useLayoutEffect, useDebugValue = React2.useDebugValue;
|
|
583
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
584
|
+
var value = getSnapshot(), _useState = useState({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
585
|
+
useLayoutEffect(
|
|
586
|
+
function() {
|
|
587
|
+
inst.value = value;
|
|
588
|
+
inst.getSnapshot = getSnapshot;
|
|
589
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
590
|
+
},
|
|
591
|
+
[subscribe, value, getSnapshot]
|
|
592
|
+
);
|
|
593
|
+
useEffect(
|
|
594
|
+
function() {
|
|
595
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
596
|
+
return subscribe(function() {
|
|
597
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
598
|
+
});
|
|
599
|
+
},
|
|
600
|
+
[subscribe]
|
|
601
|
+
);
|
|
602
|
+
useDebugValue(value);
|
|
603
|
+
return value;
|
|
604
|
+
}
|
|
605
|
+
function checkIfSnapshotChanged(inst) {
|
|
606
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
607
|
+
inst = inst.value;
|
|
608
|
+
try {
|
|
609
|
+
var nextValue = latestGetSnapshot();
|
|
610
|
+
return !objectIs(inst, nextValue);
|
|
611
|
+
} catch (error) {
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
616
|
+
return getSnapshot();
|
|
617
|
+
}
|
|
618
|
+
var shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
619
|
+
useSyncExternalStoreShim_production.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim2;
|
|
620
|
+
return useSyncExternalStoreShim_production;
|
|
621
|
+
}
|
|
622
|
+
var useSyncExternalStoreShim_development = {};
|
|
623
|
+
/**
|
|
624
|
+
* @license React
|
|
625
|
+
* use-sync-external-store-shim.development.js
|
|
626
|
+
*
|
|
627
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
628
|
+
*
|
|
629
|
+
* This source code is licensed under the MIT license found in the
|
|
630
|
+
* LICENSE file in the root directory of this source tree.
|
|
631
|
+
*/
|
|
632
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
633
|
+
function requireUseSyncExternalStoreShim_development() {
|
|
634
|
+
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
635
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
636
|
+
"production" !== process.env.NODE_ENV && (function() {
|
|
637
|
+
function is(x, y) {
|
|
638
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
639
|
+
}
|
|
640
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
641
|
+
didWarnOld18Alpha || void 0 === React2.startTransition || (didWarnOld18Alpha = true, console.error(
|
|
642
|
+
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
643
|
+
));
|
|
644
|
+
var value = getSnapshot();
|
|
645
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
646
|
+
var cachedValue = getSnapshot();
|
|
647
|
+
objectIs(value, cachedValue) || (console.error(
|
|
648
|
+
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
649
|
+
), didWarnUncachedGetSnapshot = true);
|
|
650
|
+
}
|
|
651
|
+
cachedValue = useState({
|
|
652
|
+
inst: { value, getSnapshot }
|
|
653
|
+
});
|
|
654
|
+
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
655
|
+
useLayoutEffect(
|
|
656
|
+
function() {
|
|
657
|
+
inst.value = value;
|
|
658
|
+
inst.getSnapshot = getSnapshot;
|
|
659
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
660
|
+
},
|
|
661
|
+
[subscribe, value, getSnapshot]
|
|
662
|
+
);
|
|
663
|
+
useEffect(
|
|
664
|
+
function() {
|
|
665
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
666
|
+
return subscribe(function() {
|
|
667
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
668
|
+
});
|
|
669
|
+
},
|
|
670
|
+
[subscribe]
|
|
671
|
+
);
|
|
672
|
+
useDebugValue(value);
|
|
673
|
+
return value;
|
|
674
|
+
}
|
|
675
|
+
function checkIfSnapshotChanged(inst) {
|
|
676
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
677
|
+
inst = inst.value;
|
|
678
|
+
try {
|
|
679
|
+
var nextValue = latestGetSnapshot();
|
|
680
|
+
return !objectIs(inst, nextValue);
|
|
681
|
+
} catch (error) {
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
686
|
+
return getSnapshot();
|
|
687
|
+
}
|
|
688
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
689
|
+
var React2 = React__default, objectIs = "function" === typeof Object.is ? Object.is : is, useState = React2.useState, useEffect = React2.useEffect, useLayoutEffect = React2.useLayoutEffect, useDebugValue = React2.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
690
|
+
useSyncExternalStoreShim_development.useSyncExternalStore = void 0 !== React2.useSyncExternalStore ? React2.useSyncExternalStore : shim2;
|
|
691
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
692
|
+
})();
|
|
693
|
+
return useSyncExternalStoreShim_development;
|
|
694
|
+
}
|
|
695
|
+
var hasRequiredShim;
|
|
696
|
+
function requireShim() {
|
|
697
|
+
if (hasRequiredShim) return shim.exports;
|
|
698
|
+
hasRequiredShim = 1;
|
|
699
|
+
if (process.env.NODE_ENV === "production") {
|
|
700
|
+
shim.exports = requireUseSyncExternalStoreShim_production();
|
|
701
|
+
} else {
|
|
702
|
+
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
703
|
+
}
|
|
704
|
+
return shim.exports;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* @license React
|
|
708
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
709
|
+
*
|
|
710
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
711
|
+
*
|
|
712
|
+
* This source code is licensed under the MIT license found in the
|
|
713
|
+
* LICENSE file in the root directory of this source tree.
|
|
714
|
+
*/
|
|
715
|
+
var hasRequiredWithSelector_production;
|
|
716
|
+
function requireWithSelector_production() {
|
|
717
|
+
if (hasRequiredWithSelector_production) return withSelector_production;
|
|
718
|
+
hasRequiredWithSelector_production = 1;
|
|
719
|
+
var React2 = React__default, shim2 = requireShim();
|
|
720
|
+
function is(x, y) {
|
|
721
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
722
|
+
}
|
|
723
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim2.useSyncExternalStore, useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
724
|
+
withSelector_production.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
725
|
+
var instRef = useRef(null);
|
|
726
|
+
if (null === instRef.current) {
|
|
727
|
+
var inst = { hasValue: false, value: null };
|
|
728
|
+
instRef.current = inst;
|
|
729
|
+
} else inst = instRef.current;
|
|
730
|
+
instRef = useMemo(
|
|
731
|
+
function() {
|
|
732
|
+
function memoizedSelector(nextSnapshot) {
|
|
733
|
+
if (!hasMemo) {
|
|
734
|
+
hasMemo = true;
|
|
735
|
+
memoizedSnapshot = nextSnapshot;
|
|
736
|
+
nextSnapshot = selector(nextSnapshot);
|
|
737
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
738
|
+
var currentSelection = inst.value;
|
|
739
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
740
|
+
return memoizedSelection = currentSelection;
|
|
741
|
+
}
|
|
742
|
+
return memoizedSelection = nextSnapshot;
|
|
743
|
+
}
|
|
744
|
+
currentSelection = memoizedSelection;
|
|
745
|
+
if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;
|
|
746
|
+
var nextSelection = selector(nextSnapshot);
|
|
747
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
748
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
749
|
+
memoizedSnapshot = nextSnapshot;
|
|
750
|
+
return memoizedSelection = nextSelection;
|
|
751
|
+
}
|
|
752
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
753
|
+
return [
|
|
754
|
+
function() {
|
|
755
|
+
return memoizedSelector(getSnapshot());
|
|
756
|
+
},
|
|
757
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
758
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
759
|
+
}
|
|
760
|
+
];
|
|
761
|
+
},
|
|
762
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
763
|
+
);
|
|
764
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
765
|
+
useEffect(
|
|
766
|
+
function() {
|
|
767
|
+
inst.hasValue = true;
|
|
768
|
+
inst.value = value;
|
|
769
|
+
},
|
|
770
|
+
[value]
|
|
771
|
+
);
|
|
772
|
+
useDebugValue(value);
|
|
773
|
+
return value;
|
|
774
|
+
};
|
|
775
|
+
return withSelector_production;
|
|
776
|
+
}
|
|
777
|
+
var withSelector_development = {};
|
|
778
|
+
/**
|
|
779
|
+
* @license React
|
|
780
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
781
|
+
*
|
|
782
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
783
|
+
*
|
|
784
|
+
* This source code is licensed under the MIT license found in the
|
|
785
|
+
* LICENSE file in the root directory of this source tree.
|
|
786
|
+
*/
|
|
787
|
+
var hasRequiredWithSelector_development;
|
|
788
|
+
function requireWithSelector_development() {
|
|
789
|
+
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
790
|
+
hasRequiredWithSelector_development = 1;
|
|
791
|
+
"production" !== process.env.NODE_ENV && (function() {
|
|
792
|
+
function is(x, y) {
|
|
793
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
794
|
+
}
|
|
795
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
796
|
+
var React2 = React__default, shim2 = requireShim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim2.useSyncExternalStore, useRef = React2.useRef, useEffect = React2.useEffect, useMemo = React2.useMemo, useDebugValue = React2.useDebugValue;
|
|
797
|
+
withSelector_development.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
798
|
+
var instRef = useRef(null);
|
|
799
|
+
if (null === instRef.current) {
|
|
800
|
+
var inst = { hasValue: false, value: null };
|
|
801
|
+
instRef.current = inst;
|
|
802
|
+
} else inst = instRef.current;
|
|
803
|
+
instRef = useMemo(
|
|
804
|
+
function() {
|
|
805
|
+
function memoizedSelector(nextSnapshot) {
|
|
806
|
+
if (!hasMemo) {
|
|
807
|
+
hasMemo = true;
|
|
808
|
+
memoizedSnapshot = nextSnapshot;
|
|
809
|
+
nextSnapshot = selector(nextSnapshot);
|
|
810
|
+
if (void 0 !== isEqual && inst.hasValue) {
|
|
811
|
+
var currentSelection = inst.value;
|
|
812
|
+
if (isEqual(currentSelection, nextSnapshot))
|
|
813
|
+
return memoizedSelection = currentSelection;
|
|
814
|
+
}
|
|
815
|
+
return memoizedSelection = nextSnapshot;
|
|
816
|
+
}
|
|
817
|
+
currentSelection = memoizedSelection;
|
|
818
|
+
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
819
|
+
return currentSelection;
|
|
820
|
+
var nextSelection = selector(nextSnapshot);
|
|
821
|
+
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
822
|
+
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
823
|
+
memoizedSnapshot = nextSnapshot;
|
|
824
|
+
return memoizedSelection = nextSelection;
|
|
825
|
+
}
|
|
826
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
827
|
+
return [
|
|
828
|
+
function() {
|
|
829
|
+
return memoizedSelector(getSnapshot());
|
|
830
|
+
},
|
|
831
|
+
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
832
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
833
|
+
}
|
|
834
|
+
];
|
|
835
|
+
},
|
|
836
|
+
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
837
|
+
);
|
|
838
|
+
var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);
|
|
839
|
+
useEffect(
|
|
840
|
+
function() {
|
|
841
|
+
inst.hasValue = true;
|
|
842
|
+
inst.value = value;
|
|
843
|
+
},
|
|
844
|
+
[value]
|
|
845
|
+
);
|
|
846
|
+
useDebugValue(value);
|
|
847
|
+
return value;
|
|
848
|
+
};
|
|
849
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
850
|
+
})();
|
|
851
|
+
return withSelector_development;
|
|
852
|
+
}
|
|
853
|
+
var hasRequiredWithSelector;
|
|
854
|
+
function requireWithSelector() {
|
|
855
|
+
if (hasRequiredWithSelector) return withSelector.exports;
|
|
856
|
+
hasRequiredWithSelector = 1;
|
|
857
|
+
if (process.env.NODE_ENV === "production") {
|
|
858
|
+
withSelector.exports = requireWithSelector_production();
|
|
859
|
+
} else {
|
|
860
|
+
withSelector.exports = requireWithSelector_development();
|
|
861
|
+
}
|
|
862
|
+
return withSelector.exports;
|
|
863
|
+
}
|
|
864
|
+
var withSelectorExports = requireWithSelector();
|
|
865
|
+
function useStore(store, selector, a1, a2, a3) {
|
|
866
|
+
const selectorWithArgs = (state) => selector(state, a1, a2, a3);
|
|
867
|
+
return withSelectorExports.useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, selectorWithArgs);
|
|
868
|
+
}
|
|
869
|
+
class Store {
|
|
870
|
+
/**
|
|
871
|
+
* The current state of the store.
|
|
872
|
+
* This property is updated immediately when the state changes as a result of calling {@link update}, {@link apply}, or {@link set}.
|
|
873
|
+
* To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
|
|
874
|
+
* The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
|
|
875
|
+
*
|
|
876
|
+
* Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
|
|
877
|
+
*/
|
|
878
|
+
constructor(state) {
|
|
879
|
+
/**
|
|
880
|
+
* Registers a listener that will be called whenever the store's state changes.
|
|
881
|
+
*
|
|
882
|
+
* @param fn The listener function to be called on state changes.
|
|
883
|
+
* @returns A function to unsubscribe the listener.
|
|
884
|
+
*/
|
|
885
|
+
__publicField(this, "subscribe", (fn) => {
|
|
886
|
+
this.listeners.add(fn);
|
|
887
|
+
return () => {
|
|
888
|
+
this.listeners.delete(fn);
|
|
889
|
+
};
|
|
890
|
+
});
|
|
891
|
+
/**
|
|
892
|
+
* Returns the current state of the store.
|
|
893
|
+
*/
|
|
894
|
+
__publicField(this, "getSnapshot", () => {
|
|
895
|
+
return this.state;
|
|
896
|
+
});
|
|
897
|
+
this.state = state;
|
|
898
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* Updates the entire store's state and notifies all registered listeners.
|
|
902
|
+
*
|
|
903
|
+
* @param newState The new state to set for the store.
|
|
904
|
+
*/
|
|
905
|
+
update(newState) {
|
|
906
|
+
if (this.state !== newState) {
|
|
907
|
+
this.state = newState;
|
|
908
|
+
this.listeners.forEach((l) => l(newState));
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Merges the provided changes into the current state and notifies listeners if there are changes.
|
|
913
|
+
*
|
|
914
|
+
* @param changes An object containing the changes to apply to the current state.
|
|
915
|
+
*/
|
|
916
|
+
apply(changes) {
|
|
917
|
+
for (const key in changes) {
|
|
918
|
+
if (!Object.is(this.state[key], changes[key])) {
|
|
919
|
+
this.update({
|
|
920
|
+
...this.state,
|
|
921
|
+
...changes
|
|
922
|
+
});
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
|
|
929
|
+
*
|
|
930
|
+
* @param key The key in the store's state to update.
|
|
931
|
+
* @param value The new value to set for the specified key.
|
|
932
|
+
*/
|
|
933
|
+
set(key, value) {
|
|
934
|
+
if (!Object.is(this.state[key], value)) {
|
|
935
|
+
this.update({
|
|
936
|
+
...this.state,
|
|
937
|
+
[key]: value
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
class ReactStore extends Store {
|
|
943
|
+
constructor(state, context = {}, selectors2) {
|
|
944
|
+
super(state);
|
|
945
|
+
/**
|
|
946
|
+
* Non-reactive values such as refs, callbacks, etc.
|
|
947
|
+
* Unlike `state`, this property can be accessed directly.
|
|
948
|
+
*/
|
|
949
|
+
/**
|
|
950
|
+
* Keeps track of which properties are controlled.
|
|
951
|
+
*/
|
|
952
|
+
__publicField(this, "controlledValues", /* @__PURE__ */ (() => /* @__PURE__ */ new Map())());
|
|
953
|
+
this.context = context;
|
|
954
|
+
this.selectors = selectors2;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Synchronizes a single external value into the store during layout phase.
|
|
958
|
+
*/
|
|
959
|
+
useSyncedValue(key, value) {
|
|
960
|
+
useIsoLayoutEffect(() => {
|
|
961
|
+
if (this.state[key] !== value) {
|
|
962
|
+
this.set(key, value);
|
|
963
|
+
}
|
|
964
|
+
}, [key, value]);
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Synchronizes a single external value into the store during layout phase and
|
|
968
|
+
* cleans it up (sets to `undefined`) on unmount.
|
|
969
|
+
*/
|
|
970
|
+
useSyncedValueWithCleanup(key, value) {
|
|
971
|
+
useIsoLayoutEffect(() => {
|
|
972
|
+
if (this.state[key] !== value) {
|
|
973
|
+
this.set(key, value);
|
|
974
|
+
}
|
|
975
|
+
return () => {
|
|
976
|
+
this.set(key, void 0);
|
|
977
|
+
};
|
|
978
|
+
}, [key, value]);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Synchronizes multiple external values into the store during layout phase.
|
|
982
|
+
*/
|
|
983
|
+
useSyncedValues(props) {
|
|
984
|
+
useIsoLayoutEffect(() => {
|
|
985
|
+
this.apply(props);
|
|
986
|
+
}, [props]);
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key.
|
|
990
|
+
* - If `controlled` is non-undefined, the key is marked as controlled and the store's
|
|
991
|
+
* state at `key` is updated to match `controlled`. Local writes to that key are ignored.
|
|
992
|
+
* - If `controlled` is undefined, the key is marked as uncontrolled. The store's state
|
|
993
|
+
* is initialized to `defaultValue` on first render and can be updated with local writes.
|
|
994
|
+
*/
|
|
995
|
+
useControlledProp(key, controlled, defaultValue) {
|
|
996
|
+
const isControlled = controlled !== void 0;
|
|
997
|
+
if (process.env.NODE_ENV !== "production") {
|
|
998
|
+
const previouslyControlled = this.controlledValues.get(key);
|
|
999
|
+
if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
|
|
1000
|
+
console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (!this.controlledValues.has(key)) {
|
|
1004
|
+
this.controlledValues.set(key, isControlled);
|
|
1005
|
+
if (!isControlled && !Object.is(this.state[key], defaultValue)) {
|
|
1006
|
+
super.update({
|
|
1007
|
+
...this.state,
|
|
1008
|
+
[key]: defaultValue
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
useIsoLayoutEffect(() => {
|
|
1013
|
+
if (isControlled && !Object.is(this.state[key], controlled)) {
|
|
1014
|
+
super.update({
|
|
1015
|
+
...this.state,
|
|
1016
|
+
[key]: controlled
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}, [key, controlled, defaultValue, isControlled]);
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
|
|
1023
|
+
* If the key is controlled (registered via {@link useControlledProp} with a non-undefined value),
|
|
1024
|
+
* the update is ignored and no listeners are notified.
|
|
1025
|
+
*
|
|
1026
|
+
* @param key The state key to update.
|
|
1027
|
+
* @param value The new value to set for the specified key.
|
|
1028
|
+
*/
|
|
1029
|
+
set(key, value) {
|
|
1030
|
+
if (this.controlledValues.get(key) === true) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
super.set(key, value);
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Merges the provided changes into the current state and notifies listeners if there are changes.
|
|
1037
|
+
* Controlled keys are filtered out and not updated.
|
|
1038
|
+
*
|
|
1039
|
+
* @param values An object containing the changes to apply to the current state.
|
|
1040
|
+
*/
|
|
1041
|
+
apply(values) {
|
|
1042
|
+
const newValues = {
|
|
1043
|
+
...values
|
|
1044
|
+
};
|
|
1045
|
+
for (const key in newValues) {
|
|
1046
|
+
if (this.controlledValues.get(key) === true) {
|
|
1047
|
+
delete newValues[key];
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
super.apply(newValues);
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Updates the entire store's state and notifies all registered listeners.
|
|
1054
|
+
* Controlled keys are left unchanged; only uncontrolled keys from `newState` are applied.
|
|
1055
|
+
*
|
|
1056
|
+
* @param newState The new state to set for the store.
|
|
1057
|
+
*/
|
|
1058
|
+
update(newState) {
|
|
1059
|
+
const newValues = {
|
|
1060
|
+
...newState
|
|
1061
|
+
};
|
|
1062
|
+
for (const key in newValues) {
|
|
1063
|
+
if (this.controlledValues.get(key) === true) {
|
|
1064
|
+
delete newValues[key];
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
super.update({
|
|
1068
|
+
...this.state,
|
|
1069
|
+
...newValues
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Returns a value from the store's state using a selector function.
|
|
1074
|
+
* Used to subscribe to specific parts of the state.
|
|
1075
|
+
* This methods causes a rerender whenever the selected state changes.
|
|
1076
|
+
*
|
|
1077
|
+
* @param key Key of the selector to use.
|
|
1078
|
+
*/
|
|
1079
|
+
useState(key) {
|
|
1080
|
+
if (!this.selectors) {
|
|
1081
|
+
throw new Error("Base UI: selectors are required to call useState.");
|
|
1082
|
+
}
|
|
1083
|
+
return useStore(this, this.selectors[key]);
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Wraps a function with `useEventCallback` to ensure it has a stable reference
|
|
1087
|
+
* and assigns it to the context.
|
|
1088
|
+
*
|
|
1089
|
+
* @param key Key of the event callback. Must be a function in the context.
|
|
1090
|
+
* @param fn Function to assign.
|
|
1091
|
+
*/
|
|
1092
|
+
useContextCallback(key, fn) {
|
|
1093
|
+
const stableFunction = useEventCallback(fn != null ? fn : NOOP);
|
|
1094
|
+
this.context[key] = stableFunction;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Returns a stable setter function for a specific key in the store's state.
|
|
1098
|
+
* It's commonly used to pass as a ref callback to React elements.
|
|
1099
|
+
* @param key Key of the state to set.
|
|
1100
|
+
*/
|
|
1101
|
+
getElementSetter(key) {
|
|
1102
|
+
return React.useCallback((element) => {
|
|
1103
|
+
this.set(key, element);
|
|
1104
|
+
}, [key]);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
const selectors = {
|
|
1108
|
+
open: createSelector((state) => state.open),
|
|
1109
|
+
modal: createSelector((state) => state.modal),
|
|
1110
|
+
nested: createSelector((state) => state.nested),
|
|
1111
|
+
nestedOpenDialogCount: createSelector((state) => state.nestedOpenDialogCount),
|
|
1112
|
+
dismissible: createSelector((state) => state.dismissible),
|
|
1113
|
+
openMethod: createSelector((state) => state.openMethod),
|
|
1114
|
+
descriptionElementId: createSelector((state) => state.descriptionElementId),
|
|
1115
|
+
titleElementId: createSelector((state) => state.titleElementId),
|
|
1116
|
+
mounted: createSelector((state) => state.mounted),
|
|
1117
|
+
transitionStatus: createSelector((state) => state.transitionStatus),
|
|
1118
|
+
triggerProps: createSelector((state) => state.triggerProps),
|
|
1119
|
+
popupProps: createSelector((state) => state.popupProps),
|
|
1120
|
+
floatingRootContext: createSelector((state) => state.floatingRootContext),
|
|
1121
|
+
popupElement: createSelector((state) => state.popupElement),
|
|
1122
|
+
triggerElement: createSelector((state) => state.triggerElement)
|
|
1123
|
+
};
|
|
1124
|
+
class DialogStore extends ReactStore {
|
|
1125
|
+
constructor() {
|
|
1126
|
+
super(...arguments);
|
|
1127
|
+
__publicField(this, "setOpen", (nextOpen, eventDetails) => {
|
|
1128
|
+
var _a, _b, _c;
|
|
1129
|
+
(_b = (_a = this.context).openChange) == null ? void 0 : _b.call(_a, nextOpen, eventDetails);
|
|
1130
|
+
if (eventDetails.isCanceled) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
const details = {
|
|
1134
|
+
open: nextOpen,
|
|
1135
|
+
nativeEvent: eventDetails.event,
|
|
1136
|
+
reason: eventDetails.reason,
|
|
1137
|
+
nested: this.state.nested
|
|
1138
|
+
};
|
|
1139
|
+
(_c = this.state.floatingRootContext.events) == null ? void 0 : _c.emit("openchange", details);
|
|
1140
|
+
this.set("open", nextOpen);
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
static create(initialState) {
|
|
1144
|
+
const context = {
|
|
1145
|
+
popupRef: /* @__PURE__ */ React.createRef(),
|
|
1146
|
+
backdropRef: /* @__PURE__ */ React.createRef(),
|
|
1147
|
+
internalBackdropRef: /* @__PURE__ */ React.createRef()
|
|
1148
|
+
};
|
|
1149
|
+
return new DialogStore(initialState, context, selectors);
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
export {
|
|
1153
|
+
DialogStore as D,
|
|
1154
|
+
useDialogRoot as u
|
|
1155
|
+
};
|