hermium 0.1.3 → 0.1.4
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/bin/hermium.mjs +4 -1
- package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
- package/dist/web-server/_chunks/ssr-renderer.mjs +22 -0
- package/dist/web-server/_libs/babel__runtime.mjs +237 -0
- package/dist/web-server/_libs/bail.mjs +8 -0
- package/dist/web-server/_libs/base-ui__react.mjs +9554 -0
- package/dist/web-server/_libs/base-ui__utils.mjs +1101 -0
- package/dist/web-server/_libs/ccount.mjs +16 -0
- package/dist/web-server/_libs/character-entities-legacy.mjs +111 -0
- package/dist/web-server/_libs/character-entities.mjs +2130 -0
- package/dist/web-server/_libs/character-reference-invalid.mjs +33 -0
- package/dist/web-server/_libs/class-variance-authority.mjs +44 -0
- package/dist/web-server/_libs/clsx.mjs +16 -0
- package/dist/web-server/_libs/comma-separated-tokens.mjs +31 -0
- package/dist/web-server/_libs/cookie-es.mjs +44 -0
- package/dist/web-server/_libs/croner.mjs +1 -0
- package/dist/web-server/_libs/crossws.mjs +1 -0
- package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/dist/web-server/_libs/devlop.mjs +8 -0
- package/dist/web-server/_libs/escape-string-regexp.mjs +9 -0
- package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/dist/web-server/_libs/extend.mjs +97 -0
- package/dist/web-server/_libs/fault.mjs +1 -0
- package/dist/web-server/_libs/floating-ui__core.mjs +663 -0
- package/dist/web-server/_libs/floating-ui__dom.mjs +624 -0
- package/dist/web-server/_libs/floating-ui__react-dom.mjs +279 -0
- package/dist/web-server/_libs/floating-ui__utils.mjs +322 -0
- package/dist/web-server/_libs/format.mjs +1 -0
- package/dist/web-server/_libs/h3.mjs +408 -0
- package/dist/web-server/_libs/hast-util-parse-selector.mjs +39 -0
- package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/dist/web-server/_libs/hast-util-whitespace.mjs +10 -0
- package/dist/web-server/_libs/hastscript.mjs +200 -0
- package/dist/web-server/_libs/highlight.js.mjs +1 -0
- package/dist/web-server/_libs/hookable.mjs +1 -0
- package/dist/web-server/_libs/html-url-attributes.mjs +26 -0
- package/dist/web-server/_libs/inline-style-parser.mjs +142 -0
- package/dist/web-server/_libs/is-alphabetical.mjs +7 -0
- package/dist/web-server/_libs/is-alphanumerical.mjs +8 -0
- package/dist/web-server/_libs/is-decimal.mjs +7 -0
- package/dist/web-server/_libs/is-hexadecimal.mjs +7 -0
- package/dist/web-server/_libs/is-plain-obj.mjs +10 -0
- package/dist/web-server/_libs/isbot.mjs +21 -0
- package/dist/web-server/_libs/longest-streak.mjs +25 -0
- package/dist/web-server/_libs/lowlight.mjs +1 -0
- package/dist/web-server/_libs/markdown-table.mjs +142 -0
- package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +109 -0
- package/dist/web-server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
- package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +117 -0
- package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
- package/dist/web-server/_libs/mdast-util-gfm-table.mjs +157 -0
- package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
- package/dist/web-server/_libs/mdast-util-gfm.mjs +29 -0
- package/dist/web-server/_libs/mdast-util-phrasing.mjs +30 -0
- package/dist/web-server/_libs/mdast-util-to-hast.mjs +710 -0
- package/dist/web-server/_libs/mdast-util-to-markdown.mjs +798 -0
- package/dist/web-server/_libs/mdast-util-to-string.mjs +38 -0
- package/dist/web-server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
- package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
- package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
- package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +491 -0
- package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
- package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
- package/dist/web-server/_libs/micromark-extension-gfm.mjs +18 -0
- package/dist/web-server/_libs/micromark-factory-destination.mjs +94 -0
- package/dist/web-server/_libs/micromark-factory-label.mjs +63 -0
- package/dist/web-server/_libs/micromark-factory-space.mjs +24 -0
- package/dist/web-server/_libs/micromark-factory-title.mjs +65 -0
- package/dist/web-server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/dist/web-server/_libs/micromark-util-character.mjs +44 -0
- package/dist/web-server/_libs/micromark-util-chunked.mjs +36 -0
- package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/dist/web-server/_libs/micromark-util-decode-string.mjs +21 -0
- package/dist/web-server/_libs/micromark-util-encode.mjs +1 -0
- package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/dist/web-server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/dist/web-server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/dist/web-server/_libs/micromark.mjs +906 -0
- package/dist/web-server/_libs/ocache.mjs +1 -0
- package/dist/web-server/_libs/ohash.mjs +1 -0
- package/dist/web-server/_libs/parse-entities.mjs +245 -0
- package/dist/web-server/_libs/property-information.mjs +1210 -0
- package/dist/web-server/_libs/react-dom.mjs +10779 -0
- package/dist/web-server/_libs/react-markdown.mjs +147 -0
- package/dist/web-server/_libs/react-syntax-highlighter.mjs +941 -0
- package/dist/web-server/_libs/react.mjs +513 -0
- package/dist/web-server/_libs/refractor.mjs +2425 -0
- package/dist/web-server/_libs/remark-gfm.mjs +20 -0
- package/dist/web-server/_libs/remark-parse.mjs +19 -0
- package/dist/web-server/_libs/remark-rehype.mjs +21 -0
- package/dist/web-server/_libs/reselect.mjs +1 -0
- package/dist/web-server/_libs/rou3.mjs +8 -0
- package/dist/web-server/_libs/seroval-plugins.mjs +58 -0
- package/dist/web-server/_libs/seroval.mjs +1775 -0
- package/dist/web-server/_libs/space-separated-tokens.mjs +11 -0
- package/dist/web-server/_libs/srvx.mjs +781 -0
- package/dist/web-server/_libs/style-to-js.mjs +72 -0
- package/dist/web-server/_libs/style-to-object.mjs +38 -0
- package/dist/web-server/_libs/tabler__icons-react.mjs +224 -0
- package/dist/web-server/_libs/tanstack__history.mjs +204 -0
- package/dist/web-server/_libs/tanstack__query-core.mjs +2552 -0
- package/dist/web-server/_libs/tanstack__react-query.mjs +190 -0
- package/dist/web-server/_libs/tanstack__react-router.mjs +1120 -0
- package/dist/web-server/_libs/tanstack__react-store.mjs +2 -0
- package/dist/web-server/_libs/tanstack__router-core.mjs +4288 -0
- package/dist/web-server/_libs/tanstack__store.mjs +1 -0
- package/dist/web-server/_libs/trim-lines.mjs +41 -0
- package/dist/web-server/_libs/trough.mjs +85 -0
- package/dist/web-server/_libs/ufo.mjs +54 -0
- package/dist/web-server/_libs/unctx.mjs +1 -0
- package/dist/web-server/_libs/ungap__structured-clone.mjs +224 -0
- package/dist/web-server/_libs/unified.mjs +661 -0
- package/dist/web-server/_libs/unist-util-is.mjs +100 -0
- package/dist/web-server/_libs/unist-util-position.mjs +27 -0
- package/dist/web-server/_libs/unist-util-stringify-position.mjs +27 -0
- package/dist/web-server/_libs/unist-util-visit-parents.mjs +83 -0
- package/dist/web-server/_libs/unist-util-visit.mjs +24 -0
- package/dist/web-server/_libs/unstorage.mjs +1 -0
- package/dist/web-server/_libs/use-sync-external-store.mjs +139 -0
- package/dist/web-server/_libs/vfile-message.mjs +138 -0
- package/dist/web-server/_libs/vfile.mjs +467 -0
- package/dist/web-server/_libs/zod.mjs +3915 -0
- package/dist/web-server/_libs/zustand.mjs +343 -0
- package/dist/web-server/_libs/zwitch.mjs +1 -0
- package/dist/web-server/_ssr/index-BLK6uN4p.mjs +612 -0
- package/dist/web-server/_ssr/index-BkkxTg0a.mjs +1855 -0
- package/dist/web-server/_ssr/index-Bp9a_nTf.mjs +66 -0
- package/dist/web-server/_ssr/index-C8t8AZQG.mjs +513 -0
- package/dist/web-server/_ssr/index-DSIu0x-q.mjs +449 -0
- package/dist/web-server/_ssr/index-DqFrn6kj.mjs +278 -0
- package/dist/web-server/_ssr/index-EKE8NFy_.mjs +189 -0
- package/dist/web-server/_ssr/index-JzLhPyir.mjs +213 -0
- package/dist/web-server/_ssr/index-wTy_4MhH.mjs +369 -0
- package/dist/web-server/_ssr/index.mjs +1558 -0
- package/dist/web-server/_ssr/input-BQFduUUo.mjs +20 -0
- package/dist/web-server/_ssr/router-59cN5lqo.mjs +1998 -0
- package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +4 -0
- package/dist/web-server/_ssr/switch-Bim4kX8N.mjs +33 -0
- package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +62 -0
- package/dist/web-server/_ssr/textarea-CK0ROhfF.mjs +18 -0
- package/dist/web-server/_tanstack-start-manifest_v-DLw6M7p4.mjs +4 -0
- package/dist/web-server/index.mjs +120 -120
- package/package.json +1 -1
|
@@ -0,0 +1,1101 @@
|
|
|
1
|
+
import { r as reactExports, b as React } from "./react.mjs";
|
|
2
|
+
import { w as withSelectorExports, s as shimExports } from "./use-sync-external-store.mjs";
|
|
3
|
+
import "./react-dom.mjs";
|
|
4
|
+
import { g as getWindow, i as isOverflowElement } from "./floating-ui__utils.mjs";
|
|
5
|
+
const UNINITIALIZED = {};
|
|
6
|
+
function useRefWithInit(init, initArg) {
|
|
7
|
+
const ref = reactExports.useRef(UNINITIALIZED);
|
|
8
|
+
if (ref.current === UNINITIALIZED) {
|
|
9
|
+
ref.current = init(initArg);
|
|
10
|
+
}
|
|
11
|
+
return ref;
|
|
12
|
+
}
|
|
13
|
+
const hooks = [];
|
|
14
|
+
let currentInstance = void 0;
|
|
15
|
+
function getInstance() {
|
|
16
|
+
return currentInstance;
|
|
17
|
+
}
|
|
18
|
+
function register(hook) {
|
|
19
|
+
hooks.push(hook);
|
|
20
|
+
}
|
|
21
|
+
function fastComponent(fn) {
|
|
22
|
+
const FastComponent = (props, forwardedRef) => {
|
|
23
|
+
const instance = useRefWithInit(createInstance).current;
|
|
24
|
+
let result;
|
|
25
|
+
try {
|
|
26
|
+
currentInstance = instance;
|
|
27
|
+
for (const hook of hooks) {
|
|
28
|
+
hook.before(instance);
|
|
29
|
+
}
|
|
30
|
+
result = fn(props, forwardedRef);
|
|
31
|
+
for (const hook of hooks) {
|
|
32
|
+
hook.after(instance);
|
|
33
|
+
}
|
|
34
|
+
instance.didInitialize = true;
|
|
35
|
+
} finally {
|
|
36
|
+
currentInstance = void 0;
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
FastComponent.displayName = fn.displayName || fn.name;
|
|
41
|
+
return FastComponent;
|
|
42
|
+
}
|
|
43
|
+
function fastComponentRef(fn) {
|
|
44
|
+
return /* @__PURE__ */ reactExports.forwardRef(fastComponent(fn));
|
|
45
|
+
}
|
|
46
|
+
function createInstance() {
|
|
47
|
+
return {
|
|
48
|
+
didInitialize: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function useOnFirstRender(fn) {
|
|
52
|
+
const ref = reactExports.useRef(true);
|
|
53
|
+
if (ref.current) {
|
|
54
|
+
ref.current = false;
|
|
55
|
+
fn();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const noop = () => {
|
|
59
|
+
};
|
|
60
|
+
const useIsoLayoutEffect = typeof document !== "undefined" ? reactExports.useLayoutEffect : noop;
|
|
61
|
+
function createFormatErrorMessage(baseUrl, prefix) {
|
|
62
|
+
return function formatErrorMessage2(code, ...args) {
|
|
63
|
+
const url = new URL(baseUrl);
|
|
64
|
+
url.searchParams.set("code", code.toString());
|
|
65
|
+
args.forEach((arg) => url.searchParams.append("args[]", arg));
|
|
66
|
+
return `${prefix} error #${code}; visit ${url} for the full message.`;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
|
|
70
|
+
const EMPTY$2 = [];
|
|
71
|
+
function useOnMount(fn) {
|
|
72
|
+
reactExports.useEffect(fn, EMPTY$2);
|
|
73
|
+
}
|
|
74
|
+
const EMPTY$1 = 0;
|
|
75
|
+
class Timeout {
|
|
76
|
+
static create() {
|
|
77
|
+
return new Timeout();
|
|
78
|
+
}
|
|
79
|
+
currentId = EMPTY$1;
|
|
80
|
+
/**
|
|
81
|
+
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
82
|
+
*/
|
|
83
|
+
start(delay, fn) {
|
|
84
|
+
this.clear();
|
|
85
|
+
this.currentId = setTimeout(() => {
|
|
86
|
+
this.currentId = EMPTY$1;
|
|
87
|
+
fn();
|
|
88
|
+
}, delay);
|
|
89
|
+
}
|
|
90
|
+
isStarted() {
|
|
91
|
+
return this.currentId !== EMPTY$1;
|
|
92
|
+
}
|
|
93
|
+
clear = () => {
|
|
94
|
+
if (this.currentId !== EMPTY$1) {
|
|
95
|
+
clearTimeout(this.currentId);
|
|
96
|
+
this.currentId = EMPTY$1;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
disposeEffect = () => {
|
|
100
|
+
return this.clear;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function useTimeout() {
|
|
104
|
+
const timeout = useRefWithInit(Timeout.create).current;
|
|
105
|
+
useOnMount(timeout.disposeEffect);
|
|
106
|
+
return timeout;
|
|
107
|
+
}
|
|
108
|
+
const hasNavigator = typeof navigator !== "undefined";
|
|
109
|
+
const nav = getNavigatorData();
|
|
110
|
+
const platform = getPlatform();
|
|
111
|
+
const userAgent = getUserAgent();
|
|
112
|
+
const isWebKit = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
|
|
113
|
+
const isIOS = (
|
|
114
|
+
// iPads can claim to be MacIntel
|
|
115
|
+
nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform)
|
|
116
|
+
);
|
|
117
|
+
const isSafari = hasNavigator && /apple/i.test(navigator.vendor);
|
|
118
|
+
const isAndroid = hasNavigator && /android/i.test(platform) || /android/i.test(userAgent);
|
|
119
|
+
const isMac = hasNavigator && platform.toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
|
|
120
|
+
const isJSDOM = userAgent.includes("jsdom/");
|
|
121
|
+
function getNavigatorData() {
|
|
122
|
+
if (!hasNavigator) {
|
|
123
|
+
return {
|
|
124
|
+
platform: "",
|
|
125
|
+
maxTouchPoints: -1
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const uaData = navigator.userAgentData;
|
|
129
|
+
if (uaData?.platform) {
|
|
130
|
+
return {
|
|
131
|
+
platform: uaData.platform,
|
|
132
|
+
maxTouchPoints: navigator.maxTouchPoints
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
platform: navigator.platform ?? "",
|
|
137
|
+
maxTouchPoints: navigator.maxTouchPoints ?? -1
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function getUserAgent() {
|
|
141
|
+
if (!hasNavigator) {
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
const uaData = navigator.userAgentData;
|
|
145
|
+
if (uaData && Array.isArray(uaData.brands)) {
|
|
146
|
+
return uaData.brands.map(({
|
|
147
|
+
brand,
|
|
148
|
+
version
|
|
149
|
+
}) => `${brand}/${version}`).join(" ");
|
|
150
|
+
}
|
|
151
|
+
return navigator.userAgent;
|
|
152
|
+
}
|
|
153
|
+
function getPlatform() {
|
|
154
|
+
if (!hasNavigator) {
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
const uaData = navigator.userAgentData;
|
|
158
|
+
if (uaData?.platform) {
|
|
159
|
+
return uaData.platform;
|
|
160
|
+
}
|
|
161
|
+
return navigator.platform ?? "";
|
|
162
|
+
}
|
|
163
|
+
function NOOP() {
|
|
164
|
+
}
|
|
165
|
+
const EMPTY_ARRAY = Object.freeze([]);
|
|
166
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
167
|
+
function addEventListener(target, type, listener, options) {
|
|
168
|
+
target.addEventListener(type, listener, options);
|
|
169
|
+
return () => {
|
|
170
|
+
target.removeEventListener(type, listener, options);
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function mergeCleanups(...cleanups) {
|
|
174
|
+
return () => {
|
|
175
|
+
for (let i = 0; i < cleanups.length; i += 1) {
|
|
176
|
+
const cleanup = cleanups[i];
|
|
177
|
+
if (cleanup) {
|
|
178
|
+
cleanup();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function useMergedRefs(a, b, c, d) {
|
|
184
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
185
|
+
if (didChange(forkRef, a, b, c, d)) {
|
|
186
|
+
update(forkRef, [a, b, c, d]);
|
|
187
|
+
}
|
|
188
|
+
return forkRef.callback;
|
|
189
|
+
}
|
|
190
|
+
function useMergedRefsN(refs) {
|
|
191
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
192
|
+
if (didChangeN(forkRef, refs)) {
|
|
193
|
+
update(forkRef, refs);
|
|
194
|
+
}
|
|
195
|
+
return forkRef.callback;
|
|
196
|
+
}
|
|
197
|
+
function createForkRef() {
|
|
198
|
+
return {
|
|
199
|
+
callback: null,
|
|
200
|
+
cleanup: null,
|
|
201
|
+
refs: []
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function didChange(forkRef, a, b, c, d) {
|
|
205
|
+
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
206
|
+
}
|
|
207
|
+
function didChangeN(forkRef, newRefs) {
|
|
208
|
+
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
|
|
209
|
+
}
|
|
210
|
+
function update(forkRef, refs) {
|
|
211
|
+
forkRef.refs = refs;
|
|
212
|
+
if (refs.every((ref) => ref == null)) {
|
|
213
|
+
forkRef.callback = null;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
forkRef.callback = (instance) => {
|
|
217
|
+
if (forkRef.cleanup) {
|
|
218
|
+
forkRef.cleanup();
|
|
219
|
+
forkRef.cleanup = null;
|
|
220
|
+
}
|
|
221
|
+
if (instance != null) {
|
|
222
|
+
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
223
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
224
|
+
const ref = refs[i];
|
|
225
|
+
if (ref == null) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
switch (typeof ref) {
|
|
229
|
+
case "function": {
|
|
230
|
+
const refCleanup = ref(instance);
|
|
231
|
+
if (typeof refCleanup === "function") {
|
|
232
|
+
cleanupCallbacks[i] = refCleanup;
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case "object": {
|
|
237
|
+
ref.current = instance;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
forkRef.cleanup = () => {
|
|
243
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
244
|
+
const ref = refs[i];
|
|
245
|
+
if (ref == null) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
switch (typeof ref) {
|
|
249
|
+
case "function": {
|
|
250
|
+
const cleanupCallback = cleanupCallbacks[i];
|
|
251
|
+
if (typeof cleanupCallback === "function") {
|
|
252
|
+
cleanupCallback();
|
|
253
|
+
} else {
|
|
254
|
+
ref(null);
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
case "object": {
|
|
259
|
+
ref.current = null;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function useValueAsRef(value) {
|
|
269
|
+
const latest = useRefWithInit(createLatestRef, value).current;
|
|
270
|
+
latest.next = value;
|
|
271
|
+
useIsoLayoutEffect(latest.effect);
|
|
272
|
+
return latest;
|
|
273
|
+
}
|
|
274
|
+
function createLatestRef(value) {
|
|
275
|
+
const latest = {
|
|
276
|
+
current: value,
|
|
277
|
+
next: value,
|
|
278
|
+
effect: () => {
|
|
279
|
+
latest.current = latest.next;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
return latest;
|
|
283
|
+
}
|
|
284
|
+
const useInsertionEffect = React[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
|
|
285
|
+
const useSafeInsertionEffect = (
|
|
286
|
+
// React 17 doesn't have useInsertionEffect.
|
|
287
|
+
useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
|
|
288
|
+
useInsertionEffect !== reactExports.useLayoutEffect ? useInsertionEffect : (fn) => fn()
|
|
289
|
+
);
|
|
290
|
+
function useStableCallback(callback) {
|
|
291
|
+
const stable = useRefWithInit(createStableCallback).current;
|
|
292
|
+
stable.next = callback;
|
|
293
|
+
useSafeInsertionEffect(stable.effect);
|
|
294
|
+
return stable.trampoline;
|
|
295
|
+
}
|
|
296
|
+
function createStableCallback() {
|
|
297
|
+
const stable = {
|
|
298
|
+
next: void 0,
|
|
299
|
+
callback: assertNotCalled,
|
|
300
|
+
trampoline: (...args) => stable.callback?.(...args),
|
|
301
|
+
effect: () => {
|
|
302
|
+
stable.callback = stable.next;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
return stable;
|
|
306
|
+
}
|
|
307
|
+
function assertNotCalled() {
|
|
308
|
+
}
|
|
309
|
+
const EMPTY = null;
|
|
310
|
+
class Scheduler {
|
|
311
|
+
/* This implementation uses an array as a backing data-structure for frame callbacks.
|
|
312
|
+
* It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
|
|
313
|
+
* never calls the native `cancelAnimationFrame` if there are no frames left. This can
|
|
314
|
+
* be much more efficient if there is a call pattern that alterns as
|
|
315
|
+
* "request-cancel-request-cancel-…".
|
|
316
|
+
* But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
|
|
317
|
+
* frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
|
|
318
|
+
callbacks = [];
|
|
319
|
+
callbacksCount = 0;
|
|
320
|
+
nextId = 1;
|
|
321
|
+
startId = 1;
|
|
322
|
+
isScheduled = false;
|
|
323
|
+
tick = (timestamp) => {
|
|
324
|
+
this.isScheduled = false;
|
|
325
|
+
const currentCallbacks = this.callbacks;
|
|
326
|
+
const currentCallbacksCount = this.callbacksCount;
|
|
327
|
+
this.callbacks = [];
|
|
328
|
+
this.callbacksCount = 0;
|
|
329
|
+
this.startId = this.nextId;
|
|
330
|
+
if (currentCallbacksCount > 0) {
|
|
331
|
+
for (let i = 0; i < currentCallbacks.length; i += 1) {
|
|
332
|
+
currentCallbacks[i]?.(timestamp);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
request(fn) {
|
|
337
|
+
const id = this.nextId;
|
|
338
|
+
this.nextId += 1;
|
|
339
|
+
this.callbacks.push(fn);
|
|
340
|
+
this.callbacksCount += 1;
|
|
341
|
+
const didRAFChange = false;
|
|
342
|
+
if (!this.isScheduled || didRAFChange) {
|
|
343
|
+
requestAnimationFrame(this.tick);
|
|
344
|
+
this.isScheduled = true;
|
|
345
|
+
}
|
|
346
|
+
return id;
|
|
347
|
+
}
|
|
348
|
+
cancel(id) {
|
|
349
|
+
const index = id - this.startId;
|
|
350
|
+
if (index < 0 || index >= this.callbacks.length) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.callbacks[index] = null;
|
|
354
|
+
this.callbacksCount -= 1;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const scheduler = new Scheduler();
|
|
358
|
+
class AnimationFrame {
|
|
359
|
+
static create() {
|
|
360
|
+
return new AnimationFrame();
|
|
361
|
+
}
|
|
362
|
+
static request(fn) {
|
|
363
|
+
return scheduler.request(fn);
|
|
364
|
+
}
|
|
365
|
+
static cancel(id) {
|
|
366
|
+
return scheduler.cancel(id);
|
|
367
|
+
}
|
|
368
|
+
currentId = EMPTY;
|
|
369
|
+
/**
|
|
370
|
+
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
371
|
+
*/
|
|
372
|
+
request(fn) {
|
|
373
|
+
this.cancel();
|
|
374
|
+
this.currentId = scheduler.request(() => {
|
|
375
|
+
this.currentId = EMPTY;
|
|
376
|
+
fn();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
cancel = () => {
|
|
380
|
+
if (this.currentId !== EMPTY) {
|
|
381
|
+
scheduler.cancel(this.currentId);
|
|
382
|
+
this.currentId = EMPTY;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
disposeEffect = () => {
|
|
386
|
+
return this.cancel;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function useAnimationFrame() {
|
|
390
|
+
const timeout = useRefWithInit(AnimationFrame.create).current;
|
|
391
|
+
useOnMount(timeout.disposeEffect);
|
|
392
|
+
return timeout;
|
|
393
|
+
}
|
|
394
|
+
function ownerDocument(node) {
|
|
395
|
+
return node?.ownerDocument || document;
|
|
396
|
+
}
|
|
397
|
+
const visuallyHiddenBase = {
|
|
398
|
+
clipPath: "inset(50%)",
|
|
399
|
+
overflow: "hidden",
|
|
400
|
+
whiteSpace: "nowrap",
|
|
401
|
+
border: 0,
|
|
402
|
+
padding: 0,
|
|
403
|
+
width: 1,
|
|
404
|
+
height: 1,
|
|
405
|
+
margin: -1
|
|
406
|
+
};
|
|
407
|
+
const visuallyHidden = {
|
|
408
|
+
...visuallyHiddenBase,
|
|
409
|
+
position: "fixed",
|
|
410
|
+
top: 0,
|
|
411
|
+
left: 0
|
|
412
|
+
};
|
|
413
|
+
const SafeReact = {
|
|
414
|
+
...React
|
|
415
|
+
};
|
|
416
|
+
let globalId = 0;
|
|
417
|
+
function useGlobalId(idOverride, prefix = "mui") {
|
|
418
|
+
const [defaultId, setDefaultId] = reactExports.useState(idOverride);
|
|
419
|
+
const id = idOverride || defaultId;
|
|
420
|
+
reactExports.useEffect(() => {
|
|
421
|
+
if (defaultId == null) {
|
|
422
|
+
globalId += 1;
|
|
423
|
+
setDefaultId(`${prefix}-${globalId}`);
|
|
424
|
+
}
|
|
425
|
+
}, [defaultId, prefix]);
|
|
426
|
+
return id;
|
|
427
|
+
}
|
|
428
|
+
const maybeReactUseId = SafeReact.useId;
|
|
429
|
+
function useId(idOverride, prefix) {
|
|
430
|
+
if (maybeReactUseId !== void 0) {
|
|
431
|
+
const reactId = maybeReactUseId();
|
|
432
|
+
return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
|
|
433
|
+
}
|
|
434
|
+
return useGlobalId(idOverride, prefix);
|
|
435
|
+
}
|
|
436
|
+
const majorVersion = parseInt(reactExports.version, 10);
|
|
437
|
+
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
438
|
+
return majorVersion >= reactVersionToCheck;
|
|
439
|
+
}
|
|
440
|
+
function getReactElementRef(element) {
|
|
441
|
+
if (!/* @__PURE__ */ reactExports.isValidElement(element)) {
|
|
442
|
+
return null;
|
|
443
|
+
}
|
|
444
|
+
const reactElement = element;
|
|
445
|
+
const propsWithRef = reactElement.props;
|
|
446
|
+
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
447
|
+
}
|
|
448
|
+
function mergeObjects(a, b) {
|
|
449
|
+
if (a && !b) {
|
|
450
|
+
return a;
|
|
451
|
+
}
|
|
452
|
+
if (!a && b) {
|
|
453
|
+
return b;
|
|
454
|
+
}
|
|
455
|
+
if (a || b) {
|
|
456
|
+
return {
|
|
457
|
+
...a,
|
|
458
|
+
...b
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return void 0;
|
|
462
|
+
}
|
|
463
|
+
const createSelector = (a, b, c, d, e, f, ...other) => {
|
|
464
|
+
if (other.length > 0) {
|
|
465
|
+
throw new Error(formatErrorMessage(1));
|
|
466
|
+
}
|
|
467
|
+
let selector;
|
|
468
|
+
if (a) {
|
|
469
|
+
selector = a;
|
|
470
|
+
} else {
|
|
471
|
+
throw (
|
|
472
|
+
/* minify-error-disabled */
|
|
473
|
+
new Error("Missing arguments")
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
return selector;
|
|
477
|
+
};
|
|
478
|
+
const canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
|
|
479
|
+
const useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
|
|
480
|
+
function useStore(store, selector, a1, a2, a3) {
|
|
481
|
+
return useStoreImplementation(store, selector, a1, a2, a3);
|
|
482
|
+
}
|
|
483
|
+
function useStoreR19(store, selector, a1, a2, a3) {
|
|
484
|
+
const getSelection = reactExports.useCallback(() => selector(store.getSnapshot(), a1, a2, a3), [store, selector, a1, a2, a3]);
|
|
485
|
+
return shimExports.useSyncExternalStore(store.subscribe, getSelection, getSelection);
|
|
486
|
+
}
|
|
487
|
+
register({
|
|
488
|
+
before(instance) {
|
|
489
|
+
instance.syncIndex = 0;
|
|
490
|
+
if (!instance.didInitialize) {
|
|
491
|
+
instance.syncTick = 1;
|
|
492
|
+
instance.syncHooks = [];
|
|
493
|
+
instance.didChangeStore = true;
|
|
494
|
+
instance.getSnapshot = () => {
|
|
495
|
+
let didChange2 = false;
|
|
496
|
+
for (let i = 0; i < instance.syncHooks.length; i += 1) {
|
|
497
|
+
const hook = instance.syncHooks[i];
|
|
498
|
+
const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
|
|
499
|
+
if (hook.didChange || !Object.is(hook.value, value)) {
|
|
500
|
+
didChange2 = true;
|
|
501
|
+
hook.value = value;
|
|
502
|
+
hook.didChange = false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
if (didChange2) {
|
|
506
|
+
instance.syncTick += 1;
|
|
507
|
+
}
|
|
508
|
+
return instance.syncTick;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
after(instance) {
|
|
513
|
+
if (instance.syncHooks.length > 0) {
|
|
514
|
+
if (instance.didChangeStore) {
|
|
515
|
+
instance.didChangeStore = false;
|
|
516
|
+
instance.subscribe = (onStoreChange) => {
|
|
517
|
+
const stores = /* @__PURE__ */ new Set();
|
|
518
|
+
for (const hook of instance.syncHooks) {
|
|
519
|
+
stores.add(hook.store);
|
|
520
|
+
}
|
|
521
|
+
const unsubscribes = [];
|
|
522
|
+
for (const store of stores) {
|
|
523
|
+
unsubscribes.push(store.subscribe(onStoreChange));
|
|
524
|
+
}
|
|
525
|
+
return () => {
|
|
526
|
+
for (const unsubscribe of unsubscribes) {
|
|
527
|
+
unsubscribe();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
shimExports.useSyncExternalStore(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
function useStoreFast(store, selector, a1, a2, a3) {
|
|
537
|
+
const instance = getInstance();
|
|
538
|
+
if (!instance) {
|
|
539
|
+
return useStoreR19(store, selector, a1, a2, a3);
|
|
540
|
+
}
|
|
541
|
+
const index = instance.syncIndex;
|
|
542
|
+
instance.syncIndex += 1;
|
|
543
|
+
let hook;
|
|
544
|
+
if (!instance.didInitialize) {
|
|
545
|
+
hook = {
|
|
546
|
+
store,
|
|
547
|
+
selector,
|
|
548
|
+
a1,
|
|
549
|
+
a2,
|
|
550
|
+
a3,
|
|
551
|
+
value: selector(store.getSnapshot(), a1, a2, a3),
|
|
552
|
+
didChange: false
|
|
553
|
+
};
|
|
554
|
+
instance.syncHooks.push(hook);
|
|
555
|
+
} else {
|
|
556
|
+
hook = instance.syncHooks[index];
|
|
557
|
+
if (hook.store !== store || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
|
|
558
|
+
if (hook.store !== store) {
|
|
559
|
+
instance.didChangeStore = true;
|
|
560
|
+
}
|
|
561
|
+
hook.store = store;
|
|
562
|
+
hook.selector = selector;
|
|
563
|
+
hook.a1 = a1;
|
|
564
|
+
hook.a2 = a2;
|
|
565
|
+
hook.a3 = a3;
|
|
566
|
+
hook.didChange = true;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return hook.value;
|
|
570
|
+
}
|
|
571
|
+
function useStoreLegacy(store, selector, a1, a2, a3) {
|
|
572
|
+
return withSelectorExports.useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
|
|
573
|
+
}
|
|
574
|
+
class Store {
|
|
575
|
+
/**
|
|
576
|
+
* The current state of the store.
|
|
577
|
+
* This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
|
|
578
|
+
* 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).
|
|
579
|
+
* The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
|
|
580
|
+
*
|
|
581
|
+
* Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
|
|
582
|
+
*/
|
|
583
|
+
// Internal state to handle recursive `setState()` calls
|
|
584
|
+
constructor(state) {
|
|
585
|
+
this.state = state;
|
|
586
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
587
|
+
this.updateTick = 0;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Registers a listener that will be called whenever the store's state changes.
|
|
591
|
+
*
|
|
592
|
+
* @param fn The listener function to be called on state changes.
|
|
593
|
+
* @returns A function to unsubscribe the listener.
|
|
594
|
+
*/
|
|
595
|
+
subscribe = (fn) => {
|
|
596
|
+
this.listeners.add(fn);
|
|
597
|
+
return () => {
|
|
598
|
+
this.listeners.delete(fn);
|
|
599
|
+
};
|
|
600
|
+
};
|
|
601
|
+
/**
|
|
602
|
+
* Returns the current state of the store.
|
|
603
|
+
*/
|
|
604
|
+
getSnapshot = () => {
|
|
605
|
+
return this.state;
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* Updates the entire store's state and notifies all registered listeners.
|
|
609
|
+
*
|
|
610
|
+
* @param newState The new state to set for the store.
|
|
611
|
+
*/
|
|
612
|
+
setState(newState) {
|
|
613
|
+
if (this.state === newState) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
this.state = newState;
|
|
617
|
+
this.updateTick += 1;
|
|
618
|
+
const currentTick = this.updateTick;
|
|
619
|
+
for (const listener of this.listeners) {
|
|
620
|
+
if (currentTick !== this.updateTick) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
listener(newState);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Merges the provided changes into the current state and notifies listeners if there are changes.
|
|
628
|
+
*
|
|
629
|
+
* @param changes An object containing the changes to apply to the current state.
|
|
630
|
+
*/
|
|
631
|
+
update(changes) {
|
|
632
|
+
for (const key in changes) {
|
|
633
|
+
if (!Object.is(this.state[key], changes[key])) {
|
|
634
|
+
this.setState({
|
|
635
|
+
...this.state,
|
|
636
|
+
...changes
|
|
637
|
+
});
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
|
|
644
|
+
*
|
|
645
|
+
* @param key The key in the store's state to update.
|
|
646
|
+
* @param value The new value to set for the specified key.
|
|
647
|
+
*/
|
|
648
|
+
set(key, value) {
|
|
649
|
+
if (!Object.is(this.state[key], value)) {
|
|
650
|
+
this.setState({
|
|
651
|
+
...this.state,
|
|
652
|
+
[key]: value
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Gives the state a new reference and updates all registered listeners.
|
|
658
|
+
*/
|
|
659
|
+
notifyAll() {
|
|
660
|
+
const newState = {
|
|
661
|
+
...this.state
|
|
662
|
+
};
|
|
663
|
+
this.setState(newState);
|
|
664
|
+
}
|
|
665
|
+
use(selector, a1, a2, a3) {
|
|
666
|
+
return useStore(this, selector, a1, a2, a3);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
class ReactStore extends Store {
|
|
670
|
+
/**
|
|
671
|
+
* Creates a new ReactStore instance.
|
|
672
|
+
*
|
|
673
|
+
* @param state Initial state of the store.
|
|
674
|
+
* @param context Non-reactive context values.
|
|
675
|
+
* @param selectors Optional selectors for use with `useState`.
|
|
676
|
+
*/
|
|
677
|
+
constructor(state, context = {}, selectors) {
|
|
678
|
+
super(state);
|
|
679
|
+
this.context = context;
|
|
680
|
+
this.selectors = selectors;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Non-reactive values such as refs, callbacks, etc.
|
|
684
|
+
*/
|
|
685
|
+
/**
|
|
686
|
+
* Synchronizes a single external value into the store.
|
|
687
|
+
*
|
|
688
|
+
* Note that the while the value in `state` is updated immediately, the value returned
|
|
689
|
+
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
690
|
+
*/
|
|
691
|
+
useSyncedValue(key, value) {
|
|
692
|
+
reactExports.useDebugValue(key);
|
|
693
|
+
useIsoLayoutEffect(() => {
|
|
694
|
+
if (this.state[key] !== value) {
|
|
695
|
+
this.set(key, value);
|
|
696
|
+
}
|
|
697
|
+
}, [key, value]);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Synchronizes a single external value into the store and
|
|
701
|
+
* cleans it up (sets to `undefined`) on unmount.
|
|
702
|
+
*
|
|
703
|
+
* Note that the while the value in `state` is updated immediately, the value returned
|
|
704
|
+
* by `useState` is updated before the next render (similarly to React's `useState`).
|
|
705
|
+
*/
|
|
706
|
+
useSyncedValueWithCleanup(key, value) {
|
|
707
|
+
const store = this;
|
|
708
|
+
useIsoLayoutEffect(() => {
|
|
709
|
+
if (store.state[key] !== value) {
|
|
710
|
+
store.set(key, value);
|
|
711
|
+
}
|
|
712
|
+
return () => {
|
|
713
|
+
store.set(key, void 0);
|
|
714
|
+
};
|
|
715
|
+
}, [store, key, value]);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Synchronizes multiple external values into the store.
|
|
719
|
+
*
|
|
720
|
+
* Note that the while the values in `state` are updated immediately, the values returned
|
|
721
|
+
* by `useState` are updated before the next render (similarly to React's `useState`).
|
|
722
|
+
*/
|
|
723
|
+
useSyncedValues(statePart) {
|
|
724
|
+
const store = this;
|
|
725
|
+
const dependencies = Object.values(statePart);
|
|
726
|
+
useIsoLayoutEffect(() => {
|
|
727
|
+
store.update(statePart);
|
|
728
|
+
}, [store, ...dependencies]);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
|
|
732
|
+
* is non-undefined, the store's state at `key` is updated to match `controlled`.
|
|
733
|
+
*/
|
|
734
|
+
useControlledProp(key, controlled) {
|
|
735
|
+
reactExports.useDebugValue(key);
|
|
736
|
+
const isControlled = controlled !== void 0;
|
|
737
|
+
useIsoLayoutEffect(() => {
|
|
738
|
+
if (isControlled && !Object.is(this.state[key], controlled)) {
|
|
739
|
+
super.setState({
|
|
740
|
+
...this.state,
|
|
741
|
+
[key]: controlled
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
}, [key, controlled, isControlled]);
|
|
745
|
+
}
|
|
746
|
+
/** Gets the current value from the store using a selector with the provided key.
|
|
747
|
+
*
|
|
748
|
+
* @param key Key of the selector to use.
|
|
749
|
+
*/
|
|
750
|
+
select(key, a1, a2, a3) {
|
|
751
|
+
const selector = this.selectors[key];
|
|
752
|
+
return selector(this.state, a1, a2, a3);
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Returns a value from the store's state using a selector function.
|
|
756
|
+
* Used to subscribe to specific parts of the state.
|
|
757
|
+
* This methods causes a rerender whenever the selected state changes.
|
|
758
|
+
*
|
|
759
|
+
* @param key Key of the selector to use.
|
|
760
|
+
*/
|
|
761
|
+
useState(key, a1, a2, a3) {
|
|
762
|
+
reactExports.useDebugValue(key);
|
|
763
|
+
return useStore(this, this.selectors[key], a1, a2, a3);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Wraps a function with `useStableCallback` to ensure it has a stable reference
|
|
767
|
+
* and assigns it to the context.
|
|
768
|
+
*
|
|
769
|
+
* @param key Key of the event callback. Must be a function in the context.
|
|
770
|
+
* @param fn Function to assign.
|
|
771
|
+
*/
|
|
772
|
+
useContextCallback(key, fn) {
|
|
773
|
+
reactExports.useDebugValue(key);
|
|
774
|
+
const stableFunction = useStableCallback(fn ?? NOOP);
|
|
775
|
+
this.context[key] = stableFunction;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Returns a stable setter function for a specific key in the store's state.
|
|
779
|
+
* It's commonly used to pass as a ref callback to React elements.
|
|
780
|
+
*
|
|
781
|
+
* @param key Key of the state to set.
|
|
782
|
+
*/
|
|
783
|
+
useStateSetter(key) {
|
|
784
|
+
const ref = reactExports.useRef(void 0);
|
|
785
|
+
if (ref.current === void 0) {
|
|
786
|
+
ref.current = (value) => {
|
|
787
|
+
this.set(key, value);
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
return ref.current;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Observes changes derived from the store's selectors and calls the listener when the selected value changes.
|
|
794
|
+
*
|
|
795
|
+
* @param key Key of the selector to observe.
|
|
796
|
+
* @param listener Listener function called when the selector result changes.
|
|
797
|
+
*/
|
|
798
|
+
observe(selector, listener) {
|
|
799
|
+
let selectFn;
|
|
800
|
+
if (typeof selector === "function") {
|
|
801
|
+
selectFn = selector;
|
|
802
|
+
} else {
|
|
803
|
+
selectFn = this.selectors[selector];
|
|
804
|
+
}
|
|
805
|
+
let prevValue = selectFn(this.state);
|
|
806
|
+
listener(prevValue, prevValue, this);
|
|
807
|
+
return this.subscribe((nextState) => {
|
|
808
|
+
const nextValue = selectFn(nextState);
|
|
809
|
+
if (!Object.is(prevValue, nextValue)) {
|
|
810
|
+
const oldValue = prevValue;
|
|
811
|
+
prevValue = nextValue;
|
|
812
|
+
listener(nextValue, oldValue, this);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function inertValue(value) {
|
|
818
|
+
if (isReactVersionAtLeast(19)) {
|
|
819
|
+
return value;
|
|
820
|
+
}
|
|
821
|
+
return value ? "true" : void 0;
|
|
822
|
+
}
|
|
823
|
+
let originalHtmlStyles = {};
|
|
824
|
+
let originalBodyStyles = {};
|
|
825
|
+
let originalHtmlScrollBehavior = "";
|
|
826
|
+
function hasInsetScrollbars(referenceElement) {
|
|
827
|
+
if (typeof document === "undefined") {
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
const doc = ownerDocument(referenceElement);
|
|
831
|
+
const win = getWindow(doc);
|
|
832
|
+
return win.innerWidth - doc.documentElement.clientWidth > 0;
|
|
833
|
+
}
|
|
834
|
+
function supportsStableScrollbarGutter(referenceElement) {
|
|
835
|
+
const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
|
|
836
|
+
if (!supported || typeof document === "undefined") {
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
const doc = ownerDocument(referenceElement);
|
|
840
|
+
const html = doc.documentElement;
|
|
841
|
+
const body = doc.body;
|
|
842
|
+
const scrollContainer = isOverflowElement(html) ? html : body;
|
|
843
|
+
const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
|
|
844
|
+
const originalHtmlStyleGutter = html.style.scrollbarGutter;
|
|
845
|
+
html.style.scrollbarGutter = "stable";
|
|
846
|
+
scrollContainer.style.overflowY = "scroll";
|
|
847
|
+
const before = scrollContainer.offsetWidth;
|
|
848
|
+
scrollContainer.style.overflowY = "hidden";
|
|
849
|
+
const after = scrollContainer.offsetWidth;
|
|
850
|
+
scrollContainer.style.overflowY = originalScrollContainerOverflowY;
|
|
851
|
+
html.style.scrollbarGutter = originalHtmlStyleGutter;
|
|
852
|
+
return before === after;
|
|
853
|
+
}
|
|
854
|
+
function preventScrollOverlayScrollbars(referenceElement) {
|
|
855
|
+
const doc = ownerDocument(referenceElement);
|
|
856
|
+
const html = doc.documentElement;
|
|
857
|
+
const body = doc.body;
|
|
858
|
+
const elementToLock = isOverflowElement(html) ? html : body;
|
|
859
|
+
const originalElementToLockStyles = {
|
|
860
|
+
overflowY: elementToLock.style.overflowY,
|
|
861
|
+
overflowX: elementToLock.style.overflowX
|
|
862
|
+
};
|
|
863
|
+
Object.assign(elementToLock.style, {
|
|
864
|
+
overflowY: "hidden",
|
|
865
|
+
overflowX: "hidden"
|
|
866
|
+
});
|
|
867
|
+
return () => {
|
|
868
|
+
Object.assign(elementToLock.style, originalElementToLockStyles);
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function preventScrollInsetScrollbars(referenceElement) {
|
|
872
|
+
const doc = ownerDocument(referenceElement);
|
|
873
|
+
const html = doc.documentElement;
|
|
874
|
+
const body = doc.body;
|
|
875
|
+
const win = getWindow(html);
|
|
876
|
+
let scrollTop = 0;
|
|
877
|
+
let scrollLeft = 0;
|
|
878
|
+
let updateGutterOnly = false;
|
|
879
|
+
const resizeFrame = AnimationFrame.create();
|
|
880
|
+
if (isWebKit && (win.visualViewport?.scale ?? 1) !== 1) {
|
|
881
|
+
return () => {
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function lockScroll() {
|
|
885
|
+
const htmlStyles = win.getComputedStyle(html);
|
|
886
|
+
const bodyStyles = win.getComputedStyle(body);
|
|
887
|
+
const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
|
|
888
|
+
const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
|
|
889
|
+
const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
|
|
890
|
+
scrollTop = html.scrollTop;
|
|
891
|
+
scrollLeft = html.scrollLeft;
|
|
892
|
+
originalHtmlStyles = {
|
|
893
|
+
scrollbarGutter: html.style.scrollbarGutter,
|
|
894
|
+
overflowY: html.style.overflowY,
|
|
895
|
+
overflowX: html.style.overflowX
|
|
896
|
+
};
|
|
897
|
+
originalHtmlScrollBehavior = html.style.scrollBehavior;
|
|
898
|
+
originalBodyStyles = {
|
|
899
|
+
position: body.style.position,
|
|
900
|
+
height: body.style.height,
|
|
901
|
+
width: body.style.width,
|
|
902
|
+
boxSizing: body.style.boxSizing,
|
|
903
|
+
overflowY: body.style.overflowY,
|
|
904
|
+
overflowX: body.style.overflowX,
|
|
905
|
+
scrollBehavior: body.style.scrollBehavior
|
|
906
|
+
};
|
|
907
|
+
const isScrollableY = html.scrollHeight > html.clientHeight;
|
|
908
|
+
const isScrollableX = html.scrollWidth > html.clientWidth;
|
|
909
|
+
const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
|
|
910
|
+
const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
|
|
911
|
+
const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
|
|
912
|
+
const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
|
|
913
|
+
const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
|
|
914
|
+
const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
|
|
915
|
+
const elementToLock = isOverflowElement(html) ? html : body;
|
|
916
|
+
updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
|
|
917
|
+
if (updateGutterOnly) {
|
|
918
|
+
html.style.scrollbarGutter = scrollbarGutterValue;
|
|
919
|
+
elementToLock.style.overflowY = "hidden";
|
|
920
|
+
elementToLock.style.overflowX = "hidden";
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
Object.assign(html.style, {
|
|
924
|
+
scrollbarGutter: scrollbarGutterValue,
|
|
925
|
+
overflowY: "hidden",
|
|
926
|
+
overflowX: "hidden"
|
|
927
|
+
});
|
|
928
|
+
if (isScrollableY || hasConstantOverflowY) {
|
|
929
|
+
html.style.overflowY = "scroll";
|
|
930
|
+
}
|
|
931
|
+
if (isScrollableX || hasConstantOverflowX) {
|
|
932
|
+
html.style.overflowX = "scroll";
|
|
933
|
+
}
|
|
934
|
+
Object.assign(body.style, {
|
|
935
|
+
position: "relative",
|
|
936
|
+
height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
|
|
937
|
+
width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
|
|
938
|
+
boxSizing: "border-box",
|
|
939
|
+
overflow: "hidden",
|
|
940
|
+
scrollBehavior: "unset"
|
|
941
|
+
});
|
|
942
|
+
body.scrollTop = scrollTop;
|
|
943
|
+
body.scrollLeft = scrollLeft;
|
|
944
|
+
html.setAttribute("data-base-ui-scroll-locked", "");
|
|
945
|
+
html.style.scrollBehavior = "unset";
|
|
946
|
+
}
|
|
947
|
+
function cleanup() {
|
|
948
|
+
Object.assign(html.style, originalHtmlStyles);
|
|
949
|
+
Object.assign(body.style, originalBodyStyles);
|
|
950
|
+
if (!updateGutterOnly) {
|
|
951
|
+
html.scrollTop = scrollTop;
|
|
952
|
+
html.scrollLeft = scrollLeft;
|
|
953
|
+
html.removeAttribute("data-base-ui-scroll-locked");
|
|
954
|
+
html.style.scrollBehavior = originalHtmlScrollBehavior;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
function handleResize() {
|
|
958
|
+
cleanup();
|
|
959
|
+
resizeFrame.request(lockScroll);
|
|
960
|
+
}
|
|
961
|
+
lockScroll();
|
|
962
|
+
const unsubscribeResize = addEventListener(win, "resize", handleResize);
|
|
963
|
+
return () => {
|
|
964
|
+
resizeFrame.cancel();
|
|
965
|
+
cleanup();
|
|
966
|
+
if (typeof win.removeEventListener === "function") {
|
|
967
|
+
unsubscribeResize();
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
class ScrollLocker {
|
|
972
|
+
lockCount = 0;
|
|
973
|
+
restore = null;
|
|
974
|
+
timeoutLock = Timeout.create();
|
|
975
|
+
timeoutUnlock = Timeout.create();
|
|
976
|
+
acquire(referenceElement) {
|
|
977
|
+
this.lockCount += 1;
|
|
978
|
+
if (this.lockCount === 1 && this.restore === null) {
|
|
979
|
+
this.timeoutLock.start(0, () => this.lock(referenceElement));
|
|
980
|
+
}
|
|
981
|
+
return this.release;
|
|
982
|
+
}
|
|
983
|
+
release = () => {
|
|
984
|
+
this.lockCount -= 1;
|
|
985
|
+
if (this.lockCount === 0 && this.restore) {
|
|
986
|
+
this.timeoutUnlock.start(0, this.unlock);
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
unlock = () => {
|
|
990
|
+
if (this.lockCount === 0 && this.restore) {
|
|
991
|
+
this.restore?.();
|
|
992
|
+
this.restore = null;
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
lock(referenceElement) {
|
|
996
|
+
if (this.lockCount === 0 || this.restore !== null) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
const doc = ownerDocument(referenceElement);
|
|
1000
|
+
const html = doc.documentElement;
|
|
1001
|
+
const htmlOverflowY = getWindow(html).getComputedStyle(html).overflowY;
|
|
1002
|
+
if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
|
|
1003
|
+
this.restore = NOOP;
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
const hasOverlayScrollbars = isIOS || !hasInsetScrollbars(referenceElement);
|
|
1007
|
+
this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
const SCROLL_LOCKER = new ScrollLocker();
|
|
1011
|
+
function useScrollLock(enabled = true, referenceElement = null) {
|
|
1012
|
+
useIsoLayoutEffect(() => {
|
|
1013
|
+
if (!enabled) {
|
|
1014
|
+
return void 0;
|
|
1015
|
+
}
|
|
1016
|
+
return SCROLL_LOCKER.acquire(referenceElement);
|
|
1017
|
+
}, [enabled, referenceElement]);
|
|
1018
|
+
}
|
|
1019
|
+
function useEnhancedClickHandler(handler) {
|
|
1020
|
+
const lastClickInteractionTypeRef = reactExports.useRef("");
|
|
1021
|
+
const handlePointerDown = reactExports.useCallback((event) => {
|
|
1022
|
+
if (event.defaultPrevented) {
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
lastClickInteractionTypeRef.current = event.pointerType;
|
|
1026
|
+
handler(event, event.pointerType);
|
|
1027
|
+
}, [handler]);
|
|
1028
|
+
const handleClick = reactExports.useCallback((event) => {
|
|
1029
|
+
if (event.detail === 0) {
|
|
1030
|
+
handler(event, "keyboard");
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
if ("pointerType" in event) {
|
|
1034
|
+
handler(event, event.pointerType);
|
|
1035
|
+
} else {
|
|
1036
|
+
handler(event, lastClickInteractionTypeRef.current);
|
|
1037
|
+
}
|
|
1038
|
+
lastClickInteractionTypeRef.current = "";
|
|
1039
|
+
}, [handler]);
|
|
1040
|
+
return {
|
|
1041
|
+
onClick: handleClick,
|
|
1042
|
+
onPointerDown: handlePointerDown
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
function useControlled({
|
|
1046
|
+
controlled,
|
|
1047
|
+
default: defaultProp,
|
|
1048
|
+
name,
|
|
1049
|
+
state = "value"
|
|
1050
|
+
}) {
|
|
1051
|
+
const {
|
|
1052
|
+
current: isControlled
|
|
1053
|
+
} = reactExports.useRef(controlled !== void 0);
|
|
1054
|
+
const [valueState, setValue] = reactExports.useState(defaultProp);
|
|
1055
|
+
const value = isControlled ? controlled : valueState;
|
|
1056
|
+
const setValueIfUncontrolled = reactExports.useCallback((newValue) => {
|
|
1057
|
+
if (!isControlled) {
|
|
1058
|
+
setValue(newValue);
|
|
1059
|
+
}
|
|
1060
|
+
}, []);
|
|
1061
|
+
return [value, setValueIfUncontrolled];
|
|
1062
|
+
}
|
|
1063
|
+
export {
|
|
1064
|
+
AnimationFrame as A,
|
|
1065
|
+
inertValue as B,
|
|
1066
|
+
isIOS as C,
|
|
1067
|
+
useEnhancedClickHandler as D,
|
|
1068
|
+
EMPTY_OBJECT as E,
|
|
1069
|
+
useScrollLock as F,
|
|
1070
|
+
useControlled as G,
|
|
1071
|
+
EMPTY_ARRAY as H,
|
|
1072
|
+
NOOP as N,
|
|
1073
|
+
ReactStore as R,
|
|
1074
|
+
Timeout as T,
|
|
1075
|
+
isJSDOM as a,
|
|
1076
|
+
useIsoLayoutEffect as b,
|
|
1077
|
+
isSafari as c,
|
|
1078
|
+
useMergedRefs as d,
|
|
1079
|
+
useMergedRefsN as e,
|
|
1080
|
+
formatErrorMessage as f,
|
|
1081
|
+
getReactElementRef as g,
|
|
1082
|
+
mergeCleanups as h,
|
|
1083
|
+
isAndroid as i,
|
|
1084
|
+
addEventListener as j,
|
|
1085
|
+
useId as k,
|
|
1086
|
+
useStableCallback as l,
|
|
1087
|
+
mergeObjects as m,
|
|
1088
|
+
useRefWithInit as n,
|
|
1089
|
+
ownerDocument as o,
|
|
1090
|
+
useValueAsRef as p,
|
|
1091
|
+
useAnimationFrame as q,
|
|
1092
|
+
isWebKit as r,
|
|
1093
|
+
createSelector as s,
|
|
1094
|
+
isMac as t,
|
|
1095
|
+
useTimeout as u,
|
|
1096
|
+
visuallyHidden as v,
|
|
1097
|
+
useOnMount as w,
|
|
1098
|
+
fastComponent as x,
|
|
1099
|
+
useOnFirstRender as y,
|
|
1100
|
+
fastComponentRef as z
|
|
1101
|
+
};
|