@uninspired/cookie-banner 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/index.cjs +4089 -0
- package/dist/{component.d.ts → react/index.d.ts} +1 -1
- package/dist/react/index.js +4072 -0
- package/dist/react/style.css +387 -0
- package/dist/script/index.cjs +45 -0
- package/dist/script/index.js +3112 -0
- package/dist/script/theme.css +94 -0
- package/package.json +28 -6
- package/dist/component.js +0 -4
- package/dist/index-BfHatbv4.js +0 -3653
- package/dist/script.js +0 -16
- /package/dist/{theme.css → react/theme.css} +0 -0
- /package/dist/{script.d.ts → script/index.d.ts} +0 -0
- /package/dist/{style.css → script/style.css} +0 -0
|
@@ -0,0 +1,4089 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ReactDOM = require("react-dom");
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k2 in e) {
|
|
9
|
+
if (k2 !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k2);
|
|
11
|
+
Object.defineProperty(n, k2, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k2]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
22
|
+
const ReactDOM__namespace = /* @__PURE__ */ _interopNamespaceDefault(ReactDOM);
|
|
23
|
+
var l;
|
|
24
|
+
function k(n) {
|
|
25
|
+
return n.children;
|
|
26
|
+
}
|
|
27
|
+
l = { __e: function(n, l2, u2, t) {
|
|
28
|
+
for (var i, r, o; l2 = l2.__; ) if ((i = l2.__c) && !i.__) try {
|
|
29
|
+
if ((r = i.constructor) && null != r.getDerivedStateFromError && (i.setState(r.getDerivedStateFromError(n)), o = i.__d), null != i.componentDidCatch && (i.componentDidCatch(n, t || {}), o = i.__d), o) return i.__E = i;
|
|
30
|
+
} catch (l3) {
|
|
31
|
+
n = l3;
|
|
32
|
+
}
|
|
33
|
+
throw n;
|
|
34
|
+
} }, "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;
|
|
35
|
+
var f = 0;
|
|
36
|
+
function u(e, t, n, o, i, u2) {
|
|
37
|
+
t || (t = {});
|
|
38
|
+
var a, c, p = t;
|
|
39
|
+
if ("ref" in p) for (c in p = {}, t) "ref" == c ? a = t[c] : p[c] = t[c];
|
|
40
|
+
var l$1 = { type: e, props: p, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f, __i: -1, __u: 0, __source: i, __self: u2 };
|
|
41
|
+
if ("function" == typeof e && (a = e.defaultProps)) for (c in a) void 0 === p[c] && (p[c] = a[c]);
|
|
42
|
+
return l.vnode && l.vnode(l$1), l$1;
|
|
43
|
+
}
|
|
44
|
+
function cls(...classes2) {
|
|
45
|
+
return classes2.filter(Boolean).join(" ");
|
|
46
|
+
}
|
|
47
|
+
function clx(classes2) {
|
|
48
|
+
return Object.entries(classes2).filter(([, value]) => value).map(([key]) => key).join(" ");
|
|
49
|
+
}
|
|
50
|
+
const root$4 = "_root_hw69b_1";
|
|
51
|
+
const neutral = "_neutral_hw69b_17";
|
|
52
|
+
const brand = "_brand_hw69b_30";
|
|
53
|
+
const ghost = "_ghost_hw69b_43";
|
|
54
|
+
const classes$4 = {
|
|
55
|
+
root: root$4,
|
|
56
|
+
neutral,
|
|
57
|
+
brand,
|
|
58
|
+
ghost
|
|
59
|
+
};
|
|
60
|
+
const Button = ({ variant = "neutral", ...rest }) => {
|
|
61
|
+
return /* @__PURE__ */ u("button", { className: cls(classes$4.root, classes$4[variant]), ...rest });
|
|
62
|
+
};
|
|
63
|
+
const root$3 = "_root_14l5h_1";
|
|
64
|
+
const muted = "_muted_14l5h_4";
|
|
65
|
+
const body = "_body_14l5h_8";
|
|
66
|
+
const normal = "_normal_14l5h_14";
|
|
67
|
+
const bold = "_bold_14l5h_18";
|
|
68
|
+
const caption = "_caption_14l5h_23";
|
|
69
|
+
const classes$3 = {
|
|
70
|
+
root: root$3,
|
|
71
|
+
muted,
|
|
72
|
+
body,
|
|
73
|
+
normal,
|
|
74
|
+
bold,
|
|
75
|
+
caption
|
|
76
|
+
};
|
|
77
|
+
const Text = ({
|
|
78
|
+
as = "span",
|
|
79
|
+
size = "body",
|
|
80
|
+
weight = "normal",
|
|
81
|
+
color = "default",
|
|
82
|
+
...rest
|
|
83
|
+
}) => {
|
|
84
|
+
const Component = as ?? "span";
|
|
85
|
+
return (
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
/* @__PURE__ */ u(
|
|
88
|
+
Component,
|
|
89
|
+
{
|
|
90
|
+
className: cls(
|
|
91
|
+
classes$3.root,
|
|
92
|
+
classes$3[size],
|
|
93
|
+
classes$3[weight],
|
|
94
|
+
classes$3[color]
|
|
95
|
+
),
|
|
96
|
+
...rest
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
const root$2 = "_root_1wsw7_42";
|
|
102
|
+
const noTarget = "_noTarget_1wsw7_53";
|
|
103
|
+
const collapsible = "_collapsible_1wsw7_62";
|
|
104
|
+
const header$1 = "_header_1wsw7_65";
|
|
105
|
+
const heading = "_heading_1wsw7_72";
|
|
106
|
+
const chevron$1 = "_chevron_1wsw7_78";
|
|
107
|
+
const open$1 = "_open_1wsw7_83";
|
|
108
|
+
const settings = "_settings_1wsw7_89";
|
|
109
|
+
const footer = "_footer_1wsw7_103";
|
|
110
|
+
const legal = "_legal_1wsw7_110";
|
|
111
|
+
const actions$1 = "_actions_1wsw7_113";
|
|
112
|
+
const classes$2 = {
|
|
113
|
+
root: root$2,
|
|
114
|
+
noTarget,
|
|
115
|
+
collapsible,
|
|
116
|
+
header: header$1,
|
|
117
|
+
heading,
|
|
118
|
+
chevron: chevron$1,
|
|
119
|
+
open: open$1,
|
|
120
|
+
settings,
|
|
121
|
+
footer,
|
|
122
|
+
legal,
|
|
123
|
+
actions: actions$1
|
|
124
|
+
};
|
|
125
|
+
const root$1 = "_root_mqtha_19";
|
|
126
|
+
const header = "_header_mqtha_24";
|
|
127
|
+
const label = "_label_mqtha_33";
|
|
128
|
+
const actions = "_actions_mqtha_39";
|
|
129
|
+
const chevron = "_chevron_mqtha_45";
|
|
130
|
+
const open = "_open_mqtha_51";
|
|
131
|
+
const description = "_description_mqtha_58";
|
|
132
|
+
const classes$1 = {
|
|
133
|
+
root: root$1,
|
|
134
|
+
header,
|
|
135
|
+
label,
|
|
136
|
+
actions,
|
|
137
|
+
chevron,
|
|
138
|
+
open,
|
|
139
|
+
description
|
|
140
|
+
};
|
|
141
|
+
function $constructor(name, initializer2, params) {
|
|
142
|
+
function init(inst, def) {
|
|
143
|
+
if (!inst._zod) {
|
|
144
|
+
Object.defineProperty(inst, "_zod", {
|
|
145
|
+
value: {
|
|
146
|
+
def,
|
|
147
|
+
constr: _,
|
|
148
|
+
traits: /* @__PURE__ */ new Set()
|
|
149
|
+
},
|
|
150
|
+
enumerable: false
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (inst._zod.traits.has(name)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
inst._zod.traits.add(name);
|
|
157
|
+
initializer2(inst, def);
|
|
158
|
+
const proto = _.prototype;
|
|
159
|
+
const keys = Object.keys(proto);
|
|
160
|
+
for (let i = 0; i < keys.length; i++) {
|
|
161
|
+
const k2 = keys[i];
|
|
162
|
+
if (!(k2 in inst)) {
|
|
163
|
+
inst[k2] = proto[k2].bind(inst);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const Parent = params?.Parent ?? Object;
|
|
168
|
+
class Definition extends Parent {
|
|
169
|
+
}
|
|
170
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
171
|
+
function _(def) {
|
|
172
|
+
var _a;
|
|
173
|
+
const inst = params?.Parent ? new Definition() : this;
|
|
174
|
+
init(inst, def);
|
|
175
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
176
|
+
for (const fn of inst._zod.deferred) {
|
|
177
|
+
fn();
|
|
178
|
+
}
|
|
179
|
+
return inst;
|
|
180
|
+
}
|
|
181
|
+
Object.defineProperty(_, "init", { value: init });
|
|
182
|
+
Object.defineProperty(_, Symbol.hasInstance, {
|
|
183
|
+
value: (inst) => {
|
|
184
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
185
|
+
return true;
|
|
186
|
+
return inst?._zod?.traits?.has(name);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(_, "name", { value: name });
|
|
190
|
+
return _;
|
|
191
|
+
}
|
|
192
|
+
class $ZodAsyncError extends Error {
|
|
193
|
+
constructor() {
|
|
194
|
+
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const globalConfig = {};
|
|
198
|
+
function config(newConfig) {
|
|
199
|
+
return globalConfig;
|
|
200
|
+
}
|
|
201
|
+
function jsonStringifyReplacer(_, value) {
|
|
202
|
+
if (typeof value === "bigint")
|
|
203
|
+
return value.toString();
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
function cached(getter) {
|
|
207
|
+
return {
|
|
208
|
+
get value() {
|
|
209
|
+
{
|
|
210
|
+
const value = getter();
|
|
211
|
+
Object.defineProperty(this, "value", { value });
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function cleanRegex(source) {
|
|
218
|
+
const start = source.startsWith("^") ? 1 : 0;
|
|
219
|
+
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
220
|
+
return source.slice(start, end);
|
|
221
|
+
}
|
|
222
|
+
const EVALUATING = /* @__PURE__ */ Symbol("evaluating");
|
|
223
|
+
function defineLazy(object2, key, getter) {
|
|
224
|
+
let value = void 0;
|
|
225
|
+
Object.defineProperty(object2, key, {
|
|
226
|
+
get() {
|
|
227
|
+
if (value === EVALUATING) {
|
|
228
|
+
return void 0;
|
|
229
|
+
}
|
|
230
|
+
if (value === void 0) {
|
|
231
|
+
value = EVALUATING;
|
|
232
|
+
value = getter();
|
|
233
|
+
}
|
|
234
|
+
return value;
|
|
235
|
+
},
|
|
236
|
+
set(v) {
|
|
237
|
+
Object.defineProperty(object2, key, {
|
|
238
|
+
value: v
|
|
239
|
+
// configurable: true,
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
configurable: true
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
246
|
+
};
|
|
247
|
+
function isObject(data) {
|
|
248
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
249
|
+
}
|
|
250
|
+
function isPlainObject(o) {
|
|
251
|
+
if (isObject(o) === false)
|
|
252
|
+
return false;
|
|
253
|
+
const ctor = o.constructor;
|
|
254
|
+
if (ctor === void 0)
|
|
255
|
+
return true;
|
|
256
|
+
if (typeof ctor !== "function")
|
|
257
|
+
return true;
|
|
258
|
+
const prot = ctor.prototype;
|
|
259
|
+
if (isObject(prot) === false)
|
|
260
|
+
return false;
|
|
261
|
+
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
function escapeRegex(str) {
|
|
267
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
268
|
+
}
|
|
269
|
+
function clone(inst, def, params) {
|
|
270
|
+
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
271
|
+
if (!def || params?.parent)
|
|
272
|
+
cl._zod.parent = inst;
|
|
273
|
+
return cl;
|
|
274
|
+
}
|
|
275
|
+
function normalizeParams(_params) {
|
|
276
|
+
return {};
|
|
277
|
+
}
|
|
278
|
+
function optionalKeys(shape) {
|
|
279
|
+
return Object.keys(shape).filter((k2) => {
|
|
280
|
+
return shape[k2]._zod.optin === "optional" && shape[k2]._zod.optout === "optional";
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function aborted(x, startIndex = 0) {
|
|
284
|
+
if (x.aborted === true)
|
|
285
|
+
return true;
|
|
286
|
+
for (let i = startIndex; i < x.issues.length; i++) {
|
|
287
|
+
if (x.issues[i]?.continue !== true) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
function prefixIssues(path, issues) {
|
|
294
|
+
return issues.map((iss) => {
|
|
295
|
+
var _a;
|
|
296
|
+
(_a = iss).path ?? (_a.path = []);
|
|
297
|
+
iss.path.unshift(path);
|
|
298
|
+
return iss;
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function unwrapMessage(message) {
|
|
302
|
+
return typeof message === "string" ? message : message?.message;
|
|
303
|
+
}
|
|
304
|
+
function finalizeIssue(iss, ctx, config2) {
|
|
305
|
+
const full = { ...iss, path: iss.path ?? [] };
|
|
306
|
+
if (!iss.message) {
|
|
307
|
+
const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
|
|
308
|
+
full.message = message;
|
|
309
|
+
}
|
|
310
|
+
delete full.inst;
|
|
311
|
+
delete full.continue;
|
|
312
|
+
if (!ctx?.reportInput) {
|
|
313
|
+
delete full.input;
|
|
314
|
+
}
|
|
315
|
+
return full;
|
|
316
|
+
}
|
|
317
|
+
const initializer = (inst, def) => {
|
|
318
|
+
inst.name = "$ZodError";
|
|
319
|
+
Object.defineProperty(inst, "_zod", {
|
|
320
|
+
value: inst._zod,
|
|
321
|
+
enumerable: false
|
|
322
|
+
});
|
|
323
|
+
Object.defineProperty(inst, "issues", {
|
|
324
|
+
value: def,
|
|
325
|
+
enumerable: false
|
|
326
|
+
});
|
|
327
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
328
|
+
Object.defineProperty(inst, "toString", {
|
|
329
|
+
value: () => inst.message,
|
|
330
|
+
enumerable: false
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
const $ZodError = $constructor("$ZodError", initializer);
|
|
334
|
+
const $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
335
|
+
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
336
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
337
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
338
|
+
if (result instanceof Promise) {
|
|
339
|
+
throw new $ZodAsyncError();
|
|
340
|
+
}
|
|
341
|
+
if (result.issues.length) {
|
|
342
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
343
|
+
captureStackTrace(e, _params?.callee);
|
|
344
|
+
throw e;
|
|
345
|
+
}
|
|
346
|
+
return result.value;
|
|
347
|
+
};
|
|
348
|
+
const parse$1 = /* @__PURE__ */ _parse($ZodRealError);
|
|
349
|
+
const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
350
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
351
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
352
|
+
if (result instanceof Promise)
|
|
353
|
+
result = await result;
|
|
354
|
+
if (result.issues.length) {
|
|
355
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
|
|
356
|
+
captureStackTrace(e, params?.callee);
|
|
357
|
+
throw e;
|
|
358
|
+
}
|
|
359
|
+
return result.value;
|
|
360
|
+
};
|
|
361
|
+
const parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
362
|
+
const _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
363
|
+
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
364
|
+
const result = schema._zod.run({ value, issues: [] }, ctx);
|
|
365
|
+
if (result instanceof Promise) {
|
|
366
|
+
throw new $ZodAsyncError();
|
|
367
|
+
}
|
|
368
|
+
return result.issues.length ? {
|
|
369
|
+
success: false,
|
|
370
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
371
|
+
} : { success: true, data: result.value };
|
|
372
|
+
};
|
|
373
|
+
const safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
374
|
+
const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
375
|
+
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
376
|
+
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
377
|
+
if (result instanceof Promise)
|
|
378
|
+
result = await result;
|
|
379
|
+
return result.issues.length ? {
|
|
380
|
+
success: false,
|
|
381
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
382
|
+
} : { success: true, data: result.value };
|
|
383
|
+
};
|
|
384
|
+
const safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
385
|
+
const string$1 = (params) => {
|
|
386
|
+
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
387
|
+
return new RegExp(`^${regex}$`);
|
|
388
|
+
};
|
|
389
|
+
const number = /^-?\d+(?:\.\d+)?$/;
|
|
390
|
+
const boolean$1 = /^(?:true|false)$/i;
|
|
391
|
+
const version = {
|
|
392
|
+
major: 4,
|
|
393
|
+
minor: 3,
|
|
394
|
+
patch: 6
|
|
395
|
+
};
|
|
396
|
+
const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
397
|
+
var _a;
|
|
398
|
+
inst ?? (inst = {});
|
|
399
|
+
inst._zod.def = def;
|
|
400
|
+
inst._zod.bag = inst._zod.bag || {};
|
|
401
|
+
inst._zod.version = version;
|
|
402
|
+
const checks = [...inst._zod.def.checks ?? []];
|
|
403
|
+
if (inst._zod.traits.has("$ZodCheck")) {
|
|
404
|
+
checks.unshift(inst);
|
|
405
|
+
}
|
|
406
|
+
for (const ch of checks) {
|
|
407
|
+
for (const fn of ch._zod.onattach) {
|
|
408
|
+
fn(inst);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
if (checks.length === 0) {
|
|
412
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
413
|
+
inst._zod.deferred?.push(() => {
|
|
414
|
+
inst._zod.run = inst._zod.parse;
|
|
415
|
+
});
|
|
416
|
+
} else {
|
|
417
|
+
const runChecks = (payload, checks2, ctx) => {
|
|
418
|
+
let isAborted = aborted(payload);
|
|
419
|
+
let asyncResult;
|
|
420
|
+
for (const ch of checks2) {
|
|
421
|
+
if (ch._zod.def.when) {
|
|
422
|
+
const shouldRun = ch._zod.def.when(payload);
|
|
423
|
+
if (!shouldRun)
|
|
424
|
+
continue;
|
|
425
|
+
} else if (isAborted) {
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
const currLen = payload.issues.length;
|
|
429
|
+
const _ = ch._zod.check(payload);
|
|
430
|
+
if (_ instanceof Promise && ctx?.async === false) {
|
|
431
|
+
throw new $ZodAsyncError();
|
|
432
|
+
}
|
|
433
|
+
if (asyncResult || _ instanceof Promise) {
|
|
434
|
+
asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
|
|
435
|
+
await _;
|
|
436
|
+
const nextLen = payload.issues.length;
|
|
437
|
+
if (nextLen === currLen)
|
|
438
|
+
return;
|
|
439
|
+
if (!isAborted)
|
|
440
|
+
isAborted = aborted(payload, currLen);
|
|
441
|
+
});
|
|
442
|
+
} else {
|
|
443
|
+
const nextLen = payload.issues.length;
|
|
444
|
+
if (nextLen === currLen)
|
|
445
|
+
continue;
|
|
446
|
+
if (!isAborted)
|
|
447
|
+
isAborted = aborted(payload, currLen);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (asyncResult) {
|
|
451
|
+
return asyncResult.then(() => {
|
|
452
|
+
return payload;
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
return payload;
|
|
456
|
+
};
|
|
457
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
458
|
+
if (aborted(canary)) {
|
|
459
|
+
canary.aborted = true;
|
|
460
|
+
return canary;
|
|
461
|
+
}
|
|
462
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
463
|
+
if (checkResult instanceof Promise) {
|
|
464
|
+
if (ctx.async === false)
|
|
465
|
+
throw new $ZodAsyncError();
|
|
466
|
+
return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
|
|
467
|
+
}
|
|
468
|
+
return inst._zod.parse(checkResult, ctx);
|
|
469
|
+
};
|
|
470
|
+
inst._zod.run = (payload, ctx) => {
|
|
471
|
+
if (ctx.skipChecks) {
|
|
472
|
+
return inst._zod.parse(payload, ctx);
|
|
473
|
+
}
|
|
474
|
+
if (ctx.direction === "backward") {
|
|
475
|
+
const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
|
|
476
|
+
if (canary instanceof Promise) {
|
|
477
|
+
return canary.then((canary2) => {
|
|
478
|
+
return handleCanaryResult(canary2, payload, ctx);
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
482
|
+
}
|
|
483
|
+
const result = inst._zod.parse(payload, ctx);
|
|
484
|
+
if (result instanceof Promise) {
|
|
485
|
+
if (ctx.async === false)
|
|
486
|
+
throw new $ZodAsyncError();
|
|
487
|
+
return result.then((result2) => runChecks(result2, checks, ctx));
|
|
488
|
+
}
|
|
489
|
+
return runChecks(result, checks, ctx);
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
defineLazy(inst, "~standard", () => ({
|
|
493
|
+
validate: (value) => {
|
|
494
|
+
try {
|
|
495
|
+
const r = safeParse(inst, value);
|
|
496
|
+
return r.success ? { value: r.data } : { issues: r.error?.issues };
|
|
497
|
+
} catch (_) {
|
|
498
|
+
return safeParseAsync(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
vendor: "zod",
|
|
502
|
+
version: 1
|
|
503
|
+
}));
|
|
504
|
+
});
|
|
505
|
+
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
506
|
+
$ZodType.init(inst, def);
|
|
507
|
+
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
|
|
508
|
+
inst._zod.parse = (payload, _) => {
|
|
509
|
+
if (def.coerce)
|
|
510
|
+
try {
|
|
511
|
+
payload.value = String(payload.value);
|
|
512
|
+
} catch (_2) {
|
|
513
|
+
}
|
|
514
|
+
if (typeof payload.value === "string")
|
|
515
|
+
return payload;
|
|
516
|
+
payload.issues.push({
|
|
517
|
+
expected: "string",
|
|
518
|
+
code: "invalid_type",
|
|
519
|
+
input: payload.value,
|
|
520
|
+
inst
|
|
521
|
+
});
|
|
522
|
+
return payload;
|
|
523
|
+
};
|
|
524
|
+
});
|
|
525
|
+
const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
|
|
526
|
+
$ZodType.init(inst, def);
|
|
527
|
+
inst._zod.pattern = boolean$1;
|
|
528
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
529
|
+
if (def.coerce)
|
|
530
|
+
try {
|
|
531
|
+
payload.value = Boolean(payload.value);
|
|
532
|
+
} catch (_) {
|
|
533
|
+
}
|
|
534
|
+
const input = payload.value;
|
|
535
|
+
if (typeof input === "boolean")
|
|
536
|
+
return payload;
|
|
537
|
+
payload.issues.push({
|
|
538
|
+
expected: "boolean",
|
|
539
|
+
code: "invalid_type",
|
|
540
|
+
input,
|
|
541
|
+
inst
|
|
542
|
+
});
|
|
543
|
+
return payload;
|
|
544
|
+
};
|
|
545
|
+
});
|
|
546
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
547
|
+
if (result.issues.length) {
|
|
548
|
+
if (isOptionalOut && !(key in input)) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
552
|
+
}
|
|
553
|
+
if (result.value === void 0) {
|
|
554
|
+
if (key in input) {
|
|
555
|
+
final.value[key] = void 0;
|
|
556
|
+
}
|
|
557
|
+
} else {
|
|
558
|
+
final.value[key] = result.value;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function normalizeDef(def) {
|
|
562
|
+
const keys = Object.keys(def.shape);
|
|
563
|
+
for (const k2 of keys) {
|
|
564
|
+
if (!def.shape?.[k2]?._zod?.traits?.has("$ZodType")) {
|
|
565
|
+
throw new Error(`Invalid element at key "${k2}": expected a Zod schema`);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const okeys = optionalKeys(def.shape);
|
|
569
|
+
return {
|
|
570
|
+
...def,
|
|
571
|
+
keys,
|
|
572
|
+
keySet: new Set(keys),
|
|
573
|
+
numKeys: keys.length,
|
|
574
|
+
optionalKeys: new Set(okeys)
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
578
|
+
const unrecognized = [];
|
|
579
|
+
const keySet = def.keySet;
|
|
580
|
+
const _catchall = def.catchall._zod;
|
|
581
|
+
const t = _catchall.def.type;
|
|
582
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
583
|
+
for (const key in input) {
|
|
584
|
+
if (keySet.has(key))
|
|
585
|
+
continue;
|
|
586
|
+
if (t === "never") {
|
|
587
|
+
unrecognized.push(key);
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const r = _catchall.run({ value: input[key], issues: [] }, ctx);
|
|
591
|
+
if (r instanceof Promise) {
|
|
592
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
593
|
+
} else {
|
|
594
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (unrecognized.length) {
|
|
598
|
+
payload.issues.push({
|
|
599
|
+
code: "unrecognized_keys",
|
|
600
|
+
keys: unrecognized,
|
|
601
|
+
input,
|
|
602
|
+
inst
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
if (!proms.length)
|
|
606
|
+
return payload;
|
|
607
|
+
return Promise.all(proms).then(() => {
|
|
608
|
+
return payload;
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
612
|
+
$ZodType.init(inst, def);
|
|
613
|
+
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
614
|
+
if (!desc?.get) {
|
|
615
|
+
const sh = def.shape;
|
|
616
|
+
Object.defineProperty(def, "shape", {
|
|
617
|
+
get: () => {
|
|
618
|
+
const newSh = { ...sh };
|
|
619
|
+
Object.defineProperty(def, "shape", {
|
|
620
|
+
value: newSh
|
|
621
|
+
});
|
|
622
|
+
return newSh;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
627
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
628
|
+
const shape = def.shape;
|
|
629
|
+
const propValues = {};
|
|
630
|
+
for (const key in shape) {
|
|
631
|
+
const field = shape[key]._zod;
|
|
632
|
+
if (field.values) {
|
|
633
|
+
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
|
|
634
|
+
for (const v of field.values)
|
|
635
|
+
propValues[key].add(v);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return propValues;
|
|
639
|
+
});
|
|
640
|
+
const isObject$1 = isObject;
|
|
641
|
+
const catchall = def.catchall;
|
|
642
|
+
let value;
|
|
643
|
+
inst._zod.parse = (payload, ctx) => {
|
|
644
|
+
value ?? (value = _normalized.value);
|
|
645
|
+
const input = payload.value;
|
|
646
|
+
if (!isObject$1(input)) {
|
|
647
|
+
payload.issues.push({
|
|
648
|
+
expected: "object",
|
|
649
|
+
code: "invalid_type",
|
|
650
|
+
input,
|
|
651
|
+
inst
|
|
652
|
+
});
|
|
653
|
+
return payload;
|
|
654
|
+
}
|
|
655
|
+
payload.value = {};
|
|
656
|
+
const proms = [];
|
|
657
|
+
const shape = value.shape;
|
|
658
|
+
for (const key of value.keys) {
|
|
659
|
+
const el = shape[key];
|
|
660
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
661
|
+
const r = el._zod.run({ value: input[key], issues: [] }, ctx);
|
|
662
|
+
if (r instanceof Promise) {
|
|
663
|
+
proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
|
|
664
|
+
} else {
|
|
665
|
+
handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (!catchall) {
|
|
669
|
+
return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
670
|
+
}
|
|
671
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
672
|
+
};
|
|
673
|
+
});
|
|
674
|
+
function handleUnionResults(results, final, inst, ctx) {
|
|
675
|
+
for (const result of results) {
|
|
676
|
+
if (result.issues.length === 0) {
|
|
677
|
+
final.value = result.value;
|
|
678
|
+
return final;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
682
|
+
if (nonaborted.length === 1) {
|
|
683
|
+
final.value = nonaborted[0].value;
|
|
684
|
+
return nonaborted[0];
|
|
685
|
+
}
|
|
686
|
+
final.issues.push({
|
|
687
|
+
code: "invalid_union",
|
|
688
|
+
input: final.value,
|
|
689
|
+
inst,
|
|
690
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
|
|
691
|
+
});
|
|
692
|
+
return final;
|
|
693
|
+
}
|
|
694
|
+
const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
695
|
+
$ZodType.init(inst, def);
|
|
696
|
+
defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
|
|
697
|
+
defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
|
|
698
|
+
defineLazy(inst._zod, "values", () => {
|
|
699
|
+
if (def.options.every((o) => o._zod.values)) {
|
|
700
|
+
return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
|
|
701
|
+
}
|
|
702
|
+
return void 0;
|
|
703
|
+
});
|
|
704
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
705
|
+
if (def.options.every((o) => o._zod.pattern)) {
|
|
706
|
+
const patterns = def.options.map((o) => o._zod.pattern);
|
|
707
|
+
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
708
|
+
}
|
|
709
|
+
return void 0;
|
|
710
|
+
});
|
|
711
|
+
const single = def.options.length === 1;
|
|
712
|
+
const first = def.options[0]._zod.run;
|
|
713
|
+
inst._zod.parse = (payload, ctx) => {
|
|
714
|
+
if (single) {
|
|
715
|
+
return first(payload, ctx);
|
|
716
|
+
}
|
|
717
|
+
let async = false;
|
|
718
|
+
const results = [];
|
|
719
|
+
for (const option of def.options) {
|
|
720
|
+
const result = option._zod.run({
|
|
721
|
+
value: payload.value,
|
|
722
|
+
issues: []
|
|
723
|
+
}, ctx);
|
|
724
|
+
if (result instanceof Promise) {
|
|
725
|
+
results.push(result);
|
|
726
|
+
async = true;
|
|
727
|
+
} else {
|
|
728
|
+
if (result.issues.length === 0)
|
|
729
|
+
return result;
|
|
730
|
+
results.push(result);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
if (!async)
|
|
734
|
+
return handleUnionResults(results, payload, inst, ctx);
|
|
735
|
+
return Promise.all(results).then((results2) => {
|
|
736
|
+
return handleUnionResults(results2, payload, inst, ctx);
|
|
737
|
+
});
|
|
738
|
+
};
|
|
739
|
+
});
|
|
740
|
+
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
741
|
+
def.inclusive = false;
|
|
742
|
+
$ZodUnion.init(inst, def);
|
|
743
|
+
const _super = inst._zod.parse;
|
|
744
|
+
defineLazy(inst._zod, "propValues", () => {
|
|
745
|
+
const propValues = {};
|
|
746
|
+
for (const option of def.options) {
|
|
747
|
+
const pv = option._zod.propValues;
|
|
748
|
+
if (!pv || Object.keys(pv).length === 0)
|
|
749
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
750
|
+
for (const [k2, v] of Object.entries(pv)) {
|
|
751
|
+
if (!propValues[k2])
|
|
752
|
+
propValues[k2] = /* @__PURE__ */ new Set();
|
|
753
|
+
for (const val of v) {
|
|
754
|
+
propValues[k2].add(val);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
return propValues;
|
|
759
|
+
});
|
|
760
|
+
const disc = cached(() => {
|
|
761
|
+
const opts = def.options;
|
|
762
|
+
const map = /* @__PURE__ */ new Map();
|
|
763
|
+
for (const o of opts) {
|
|
764
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
765
|
+
if (!values || values.size === 0)
|
|
766
|
+
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
767
|
+
for (const v of values) {
|
|
768
|
+
if (map.has(v)) {
|
|
769
|
+
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
770
|
+
}
|
|
771
|
+
map.set(v, o);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return map;
|
|
775
|
+
});
|
|
776
|
+
inst._zod.parse = (payload, ctx) => {
|
|
777
|
+
const input = payload.value;
|
|
778
|
+
if (!isObject(input)) {
|
|
779
|
+
payload.issues.push({
|
|
780
|
+
code: "invalid_type",
|
|
781
|
+
expected: "object",
|
|
782
|
+
input,
|
|
783
|
+
inst
|
|
784
|
+
});
|
|
785
|
+
return payload;
|
|
786
|
+
}
|
|
787
|
+
const opt = disc.value.get(input?.[def.discriminator]);
|
|
788
|
+
if (opt) {
|
|
789
|
+
return opt._zod.run(payload, ctx);
|
|
790
|
+
}
|
|
791
|
+
if (def.unionFallback) {
|
|
792
|
+
return _super(payload, ctx);
|
|
793
|
+
}
|
|
794
|
+
payload.issues.push({
|
|
795
|
+
code: "invalid_union",
|
|
796
|
+
errors: [],
|
|
797
|
+
note: "No matching discriminator",
|
|
798
|
+
discriminator: def.discriminator,
|
|
799
|
+
input,
|
|
800
|
+
path: [def.discriminator],
|
|
801
|
+
inst
|
|
802
|
+
});
|
|
803
|
+
return payload;
|
|
804
|
+
};
|
|
805
|
+
});
|
|
806
|
+
const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
807
|
+
$ZodType.init(inst, def);
|
|
808
|
+
inst._zod.parse = (payload, ctx) => {
|
|
809
|
+
const input = payload.value;
|
|
810
|
+
if (!isPlainObject(input)) {
|
|
811
|
+
payload.issues.push({
|
|
812
|
+
expected: "record",
|
|
813
|
+
code: "invalid_type",
|
|
814
|
+
input,
|
|
815
|
+
inst
|
|
816
|
+
});
|
|
817
|
+
return payload;
|
|
818
|
+
}
|
|
819
|
+
const proms = [];
|
|
820
|
+
const values = def.keyType._zod.values;
|
|
821
|
+
if (values) {
|
|
822
|
+
payload.value = {};
|
|
823
|
+
const recordKeys = /* @__PURE__ */ new Set();
|
|
824
|
+
for (const key of values) {
|
|
825
|
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
826
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
827
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
828
|
+
if (result instanceof Promise) {
|
|
829
|
+
proms.push(result.then((result2) => {
|
|
830
|
+
if (result2.issues.length) {
|
|
831
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
832
|
+
}
|
|
833
|
+
payload.value[key] = result2.value;
|
|
834
|
+
}));
|
|
835
|
+
} else {
|
|
836
|
+
if (result.issues.length) {
|
|
837
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
838
|
+
}
|
|
839
|
+
payload.value[key] = result.value;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
let unrecognized;
|
|
844
|
+
for (const key in input) {
|
|
845
|
+
if (!recordKeys.has(key)) {
|
|
846
|
+
unrecognized = unrecognized ?? [];
|
|
847
|
+
unrecognized.push(key);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (unrecognized && unrecognized.length > 0) {
|
|
851
|
+
payload.issues.push({
|
|
852
|
+
code: "unrecognized_keys",
|
|
853
|
+
input,
|
|
854
|
+
inst,
|
|
855
|
+
keys: unrecognized
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
} else {
|
|
859
|
+
payload.value = {};
|
|
860
|
+
for (const key of Reflect.ownKeys(input)) {
|
|
861
|
+
if (key === "__proto__")
|
|
862
|
+
continue;
|
|
863
|
+
let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
|
|
864
|
+
if (keyResult instanceof Promise) {
|
|
865
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
866
|
+
}
|
|
867
|
+
const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
|
|
868
|
+
if (checkNumericKey) {
|
|
869
|
+
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
870
|
+
if (retryResult instanceof Promise) {
|
|
871
|
+
throw new Error("Async schemas not supported in object keys currently");
|
|
872
|
+
}
|
|
873
|
+
if (retryResult.issues.length === 0) {
|
|
874
|
+
keyResult = retryResult;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (keyResult.issues.length) {
|
|
878
|
+
if (def.mode === "loose") {
|
|
879
|
+
payload.value[key] = input[key];
|
|
880
|
+
} else {
|
|
881
|
+
payload.issues.push({
|
|
882
|
+
code: "invalid_key",
|
|
883
|
+
origin: "record",
|
|
884
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
885
|
+
input: key,
|
|
886
|
+
path: [key],
|
|
887
|
+
inst
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
|
|
893
|
+
if (result instanceof Promise) {
|
|
894
|
+
proms.push(result.then((result2) => {
|
|
895
|
+
if (result2.issues.length) {
|
|
896
|
+
payload.issues.push(...prefixIssues(key, result2.issues));
|
|
897
|
+
}
|
|
898
|
+
payload.value[keyResult.value] = result2.value;
|
|
899
|
+
}));
|
|
900
|
+
} else {
|
|
901
|
+
if (result.issues.length) {
|
|
902
|
+
payload.issues.push(...prefixIssues(key, result.issues));
|
|
903
|
+
}
|
|
904
|
+
payload.value[keyResult.value] = result.value;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (proms.length) {
|
|
909
|
+
return Promise.all(proms).then(() => payload);
|
|
910
|
+
}
|
|
911
|
+
return payload;
|
|
912
|
+
};
|
|
913
|
+
});
|
|
914
|
+
const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
915
|
+
$ZodType.init(inst, def);
|
|
916
|
+
if (def.values.length === 0) {
|
|
917
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
918
|
+
}
|
|
919
|
+
const values = new Set(def.values);
|
|
920
|
+
inst._zod.values = values;
|
|
921
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
922
|
+
inst._zod.parse = (payload, _ctx) => {
|
|
923
|
+
const input = payload.value;
|
|
924
|
+
if (values.has(input)) {
|
|
925
|
+
return payload;
|
|
926
|
+
}
|
|
927
|
+
payload.issues.push({
|
|
928
|
+
code: "invalid_value",
|
|
929
|
+
values: def.values,
|
|
930
|
+
input,
|
|
931
|
+
inst
|
|
932
|
+
});
|
|
933
|
+
return payload;
|
|
934
|
+
};
|
|
935
|
+
});
|
|
936
|
+
function handleOptionalResult(result, input) {
|
|
937
|
+
if (result.issues.length && input === void 0) {
|
|
938
|
+
return { issues: [], value: void 0 };
|
|
939
|
+
}
|
|
940
|
+
return result;
|
|
941
|
+
}
|
|
942
|
+
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
943
|
+
$ZodType.init(inst, def);
|
|
944
|
+
inst._zod.optin = "optional";
|
|
945
|
+
inst._zod.optout = "optional";
|
|
946
|
+
defineLazy(inst._zod, "values", () => {
|
|
947
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
948
|
+
});
|
|
949
|
+
defineLazy(inst._zod, "pattern", () => {
|
|
950
|
+
const pattern = def.innerType._zod.pattern;
|
|
951
|
+
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
952
|
+
});
|
|
953
|
+
inst._zod.parse = (payload, ctx) => {
|
|
954
|
+
if (def.innerType._zod.optin === "optional") {
|
|
955
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
956
|
+
if (result instanceof Promise)
|
|
957
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
958
|
+
return handleOptionalResult(result, payload.value);
|
|
959
|
+
}
|
|
960
|
+
if (payload.value === void 0) {
|
|
961
|
+
return payload;
|
|
962
|
+
}
|
|
963
|
+
return def.innerType._zod.run(payload, ctx);
|
|
964
|
+
};
|
|
965
|
+
});
|
|
966
|
+
// @__NO_SIDE_EFFECTS__
|
|
967
|
+
function _string(Class, params) {
|
|
968
|
+
return new Class({
|
|
969
|
+
type: "string",
|
|
970
|
+
...normalizeParams()
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
// @__NO_SIDE_EFFECTS__
|
|
974
|
+
function _boolean(Class, params) {
|
|
975
|
+
return new Class({
|
|
976
|
+
type: "boolean",
|
|
977
|
+
...normalizeParams()
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
981
|
+
if (!inst._zod)
|
|
982
|
+
throw new Error("Uninitialized schema in ZodMiniType.");
|
|
983
|
+
$ZodType.init(inst, def);
|
|
984
|
+
inst.def = def;
|
|
985
|
+
inst.type = def.type;
|
|
986
|
+
inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
|
|
987
|
+
inst.safeParse = (data, params) => safeParse(inst, data, params);
|
|
988
|
+
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
989
|
+
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
990
|
+
inst.check = (...checks) => {
|
|
991
|
+
return inst.clone({
|
|
992
|
+
...def,
|
|
993
|
+
checks: [
|
|
994
|
+
...def.checks ?? [],
|
|
995
|
+
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
|
|
996
|
+
]
|
|
997
|
+
}, { parent: true });
|
|
998
|
+
};
|
|
999
|
+
inst.with = inst.check;
|
|
1000
|
+
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
1001
|
+
inst.brand = () => inst;
|
|
1002
|
+
inst.register = ((reg, meta) => {
|
|
1003
|
+
reg.add(inst, meta);
|
|
1004
|
+
return inst;
|
|
1005
|
+
});
|
|
1006
|
+
inst.apply = (fn) => fn(inst);
|
|
1007
|
+
});
|
|
1008
|
+
const ZodMiniString = /* @__PURE__ */ $constructor("ZodMiniString", (inst, def) => {
|
|
1009
|
+
$ZodString.init(inst, def);
|
|
1010
|
+
ZodMiniType.init(inst, def);
|
|
1011
|
+
});
|
|
1012
|
+
// @__NO_SIDE_EFFECTS__
|
|
1013
|
+
function string(params) {
|
|
1014
|
+
return /* @__PURE__ */ _string(ZodMiniString);
|
|
1015
|
+
}
|
|
1016
|
+
const ZodMiniBoolean = /* @__PURE__ */ $constructor("ZodMiniBoolean", (inst, def) => {
|
|
1017
|
+
$ZodBoolean.init(inst, def);
|
|
1018
|
+
ZodMiniType.init(inst, def);
|
|
1019
|
+
});
|
|
1020
|
+
// @__NO_SIDE_EFFECTS__
|
|
1021
|
+
function boolean(params) {
|
|
1022
|
+
return /* @__PURE__ */ _boolean(ZodMiniBoolean);
|
|
1023
|
+
}
|
|
1024
|
+
const ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
1025
|
+
$ZodObject.init(inst, def);
|
|
1026
|
+
ZodMiniType.init(inst, def);
|
|
1027
|
+
defineLazy(inst, "shape", () => def.shape);
|
|
1028
|
+
});
|
|
1029
|
+
// @__NO_SIDE_EFFECTS__
|
|
1030
|
+
function object(shape, params) {
|
|
1031
|
+
const def = {
|
|
1032
|
+
type: "object",
|
|
1033
|
+
shape: shape ?? {},
|
|
1034
|
+
...normalizeParams()
|
|
1035
|
+
};
|
|
1036
|
+
return new ZodMiniObject(def);
|
|
1037
|
+
}
|
|
1038
|
+
const ZodMiniDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodMiniDiscriminatedUnion", (inst, def) => {
|
|
1039
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
1040
|
+
ZodMiniType.init(inst, def);
|
|
1041
|
+
});
|
|
1042
|
+
// @__NO_SIDE_EFFECTS__
|
|
1043
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
1044
|
+
return new ZodMiniDiscriminatedUnion({
|
|
1045
|
+
type: "union",
|
|
1046
|
+
options,
|
|
1047
|
+
discriminator,
|
|
1048
|
+
...normalizeParams()
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
const ZodMiniRecord = /* @__PURE__ */ $constructor("ZodMiniRecord", (inst, def) => {
|
|
1052
|
+
$ZodRecord.init(inst, def);
|
|
1053
|
+
ZodMiniType.init(inst, def);
|
|
1054
|
+
});
|
|
1055
|
+
// @__NO_SIDE_EFFECTS__
|
|
1056
|
+
function record(keyType, valueType, params) {
|
|
1057
|
+
return new ZodMiniRecord({
|
|
1058
|
+
type: "record",
|
|
1059
|
+
keyType,
|
|
1060
|
+
valueType,
|
|
1061
|
+
...normalizeParams()
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
const ZodMiniLiteral = /* @__PURE__ */ $constructor("ZodMiniLiteral", (inst, def) => {
|
|
1065
|
+
$ZodLiteral.init(inst, def);
|
|
1066
|
+
ZodMiniType.init(inst, def);
|
|
1067
|
+
});
|
|
1068
|
+
// @__NO_SIDE_EFFECTS__
|
|
1069
|
+
function literal(value, params) {
|
|
1070
|
+
return new ZodMiniLiteral({
|
|
1071
|
+
type: "literal",
|
|
1072
|
+
values: Array.isArray(value) ? value : [value],
|
|
1073
|
+
...normalizeParams()
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
const ZodMiniOptional = /* @__PURE__ */ $constructor("ZodMiniOptional", (inst, def) => {
|
|
1077
|
+
$ZodOptional.init(inst, def);
|
|
1078
|
+
ZodMiniType.init(inst, def);
|
|
1079
|
+
});
|
|
1080
|
+
// @__NO_SIDE_EFFECTS__
|
|
1081
|
+
function optional(innerType) {
|
|
1082
|
+
return new ZodMiniOptional({
|
|
1083
|
+
type: "optional",
|
|
1084
|
+
innerType
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
const remoteScriptDefinitionSchema = /* @__PURE__ */ object({
|
|
1088
|
+
variant: /* @__PURE__ */ literal("remote"),
|
|
1089
|
+
type: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
1090
|
+
src: /* @__PURE__ */ string(),
|
|
1091
|
+
async: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1092
|
+
defer: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1093
|
+
crossorigin: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
1094
|
+
integrity: /* @__PURE__ */ optional(/* @__PURE__ */ string())
|
|
1095
|
+
});
|
|
1096
|
+
const inlineScriptDefinitionSchema = /* @__PURE__ */ object({
|
|
1097
|
+
variant: /* @__PURE__ */ literal("inline"),
|
|
1098
|
+
type: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
1099
|
+
async: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1100
|
+
defer: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
|
|
1101
|
+
content: /* @__PURE__ */ string()
|
|
1102
|
+
});
|
|
1103
|
+
const scriptDefinitionSchema = /* @__PURE__ */ discriminatedUnion("variant", [
|
|
1104
|
+
remoteScriptDefinitionSchema,
|
|
1105
|
+
inlineScriptDefinitionSchema
|
|
1106
|
+
]);
|
|
1107
|
+
function createContext2(rootComponentName, defaultContext) {
|
|
1108
|
+
const Context = React__namespace.createContext(defaultContext);
|
|
1109
|
+
const Provider = (props) => {
|
|
1110
|
+
const { children, ...context } = props;
|
|
1111
|
+
const value = React__namespace.useMemo(() => context, Object.values(context));
|
|
1112
|
+
return /* @__PURE__ */ u(Context.Provider, { value, children });
|
|
1113
|
+
};
|
|
1114
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
1115
|
+
function useContext2(consumerName) {
|
|
1116
|
+
const context = React__namespace.useContext(Context);
|
|
1117
|
+
if (context) return context;
|
|
1118
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
1119
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
1120
|
+
}
|
|
1121
|
+
return [Provider, useContext2];
|
|
1122
|
+
}
|
|
1123
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
1124
|
+
let defaultContexts = [];
|
|
1125
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
1126
|
+
const BaseContext = React__namespace.createContext(defaultContext);
|
|
1127
|
+
const index = defaultContexts.length;
|
|
1128
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
1129
|
+
const Provider = (props) => {
|
|
1130
|
+
const { scope, children, ...context } = props;
|
|
1131
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
1132
|
+
const value = React__namespace.useMemo(() => context, Object.values(context));
|
|
1133
|
+
return /* @__PURE__ */ u(Context.Provider, { value, children });
|
|
1134
|
+
};
|
|
1135
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
1136
|
+
function useContext2(consumerName, scope) {
|
|
1137
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
1138
|
+
const context = React__namespace.useContext(Context);
|
|
1139
|
+
if (context) return context;
|
|
1140
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
1141
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
1142
|
+
}
|
|
1143
|
+
return [Provider, useContext2];
|
|
1144
|
+
}
|
|
1145
|
+
const createScope = () => {
|
|
1146
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
1147
|
+
return React__namespace.createContext(defaultContext);
|
|
1148
|
+
});
|
|
1149
|
+
return function useScope(scope) {
|
|
1150
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
1151
|
+
return React__namespace.useMemo(
|
|
1152
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
1153
|
+
[scope, contexts]
|
|
1154
|
+
);
|
|
1155
|
+
};
|
|
1156
|
+
};
|
|
1157
|
+
createScope.scopeName = scopeName;
|
|
1158
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
1159
|
+
}
|
|
1160
|
+
function composeContextScopes(...scopes) {
|
|
1161
|
+
const baseScope = scopes[0];
|
|
1162
|
+
if (scopes.length === 1) return baseScope;
|
|
1163
|
+
const createScope = () => {
|
|
1164
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
1165
|
+
useScope: createScope2(),
|
|
1166
|
+
scopeName: createScope2.scopeName
|
|
1167
|
+
}));
|
|
1168
|
+
return function useComposedScopes(overrideScopes) {
|
|
1169
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
1170
|
+
const scopeProps = useScope(overrideScopes);
|
|
1171
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
1172
|
+
return { ...nextScopes2, ...currentScope };
|
|
1173
|
+
}, {});
|
|
1174
|
+
return React__namespace.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
1175
|
+
};
|
|
1176
|
+
};
|
|
1177
|
+
createScope.scopeName = baseScope.scopeName;
|
|
1178
|
+
return createScope;
|
|
1179
|
+
}
|
|
1180
|
+
function setRef(ref, value) {
|
|
1181
|
+
if (typeof ref === "function") {
|
|
1182
|
+
return ref(value);
|
|
1183
|
+
} else if (ref !== null && ref !== void 0) {
|
|
1184
|
+
ref.current = value;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
function composeRefs(...refs) {
|
|
1188
|
+
return (node) => {
|
|
1189
|
+
let hasCleanup = false;
|
|
1190
|
+
const cleanups = refs.map((ref) => {
|
|
1191
|
+
const cleanup = setRef(ref, node);
|
|
1192
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
1193
|
+
hasCleanup = true;
|
|
1194
|
+
}
|
|
1195
|
+
return cleanup;
|
|
1196
|
+
});
|
|
1197
|
+
if (hasCleanup) {
|
|
1198
|
+
return () => {
|
|
1199
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
1200
|
+
const cleanup = cleanups[i];
|
|
1201
|
+
if (typeof cleanup == "function") {
|
|
1202
|
+
cleanup();
|
|
1203
|
+
} else {
|
|
1204
|
+
setRef(refs[i], null);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
};
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
function useComposedRefs(...refs) {
|
|
1212
|
+
return React__namespace.useCallback(composeRefs(...refs), refs);
|
|
1213
|
+
}
|
|
1214
|
+
// @__NO_SIDE_EFFECTS__
|
|
1215
|
+
function createSlot(ownerName) {
|
|
1216
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
1217
|
+
const Slot2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1218
|
+
const { children, ...slotProps } = props;
|
|
1219
|
+
const childrenArray = React__namespace.Children.toArray(children);
|
|
1220
|
+
const slottable = childrenArray.find(isSlottable);
|
|
1221
|
+
if (slottable) {
|
|
1222
|
+
const newElement = slottable.props.children;
|
|
1223
|
+
const newChildren = childrenArray.map((child) => {
|
|
1224
|
+
if (child === slottable) {
|
|
1225
|
+
if (React__namespace.Children.count(newElement) > 1) return React__namespace.Children.only(null);
|
|
1226
|
+
return React__namespace.isValidElement(newElement) ? newElement.props.children : null;
|
|
1227
|
+
} else {
|
|
1228
|
+
return child;
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
return /* @__PURE__ */ u(SlotClone, { ...slotProps, ref: forwardedRef, children: React__namespace.isValidElement(newElement) ? React__namespace.cloneElement(newElement, void 0, newChildren) : null });
|
|
1232
|
+
}
|
|
1233
|
+
return /* @__PURE__ */ u(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
1234
|
+
});
|
|
1235
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
1236
|
+
return Slot2;
|
|
1237
|
+
}
|
|
1238
|
+
// @__NO_SIDE_EFFECTS__
|
|
1239
|
+
function createSlotClone(ownerName) {
|
|
1240
|
+
const SlotClone = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1241
|
+
const { children, ...slotProps } = props;
|
|
1242
|
+
if (React__namespace.isValidElement(children)) {
|
|
1243
|
+
const childrenRef = getElementRef$1(children);
|
|
1244
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
1245
|
+
if (children.type !== React__namespace.Fragment) {
|
|
1246
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
1247
|
+
}
|
|
1248
|
+
return React__namespace.cloneElement(children, props2);
|
|
1249
|
+
}
|
|
1250
|
+
return React__namespace.Children.count(children) > 1 ? React__namespace.Children.only(null) : null;
|
|
1251
|
+
});
|
|
1252
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
1253
|
+
return SlotClone;
|
|
1254
|
+
}
|
|
1255
|
+
var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
|
|
1256
|
+
function isSlottable(child) {
|
|
1257
|
+
return React__namespace.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
1258
|
+
}
|
|
1259
|
+
function mergeProps(slotProps, childProps) {
|
|
1260
|
+
const overrideProps = { ...childProps };
|
|
1261
|
+
for (const propName in childProps) {
|
|
1262
|
+
const slotPropValue = slotProps[propName];
|
|
1263
|
+
const childPropValue = childProps[propName];
|
|
1264
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
1265
|
+
if (isHandler) {
|
|
1266
|
+
if (slotPropValue && childPropValue) {
|
|
1267
|
+
overrideProps[propName] = (...args) => {
|
|
1268
|
+
const result = childPropValue(...args);
|
|
1269
|
+
slotPropValue(...args);
|
|
1270
|
+
return result;
|
|
1271
|
+
};
|
|
1272
|
+
} else if (slotPropValue) {
|
|
1273
|
+
overrideProps[propName] = slotPropValue;
|
|
1274
|
+
}
|
|
1275
|
+
} else if (propName === "style") {
|
|
1276
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
1277
|
+
} else if (propName === "className") {
|
|
1278
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
return { ...slotProps, ...overrideProps };
|
|
1282
|
+
}
|
|
1283
|
+
function getElementRef$1(element) {
|
|
1284
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
1285
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1286
|
+
if (mayWarn) {
|
|
1287
|
+
return element.ref;
|
|
1288
|
+
}
|
|
1289
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
1290
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1291
|
+
if (mayWarn) {
|
|
1292
|
+
return element.props.ref;
|
|
1293
|
+
}
|
|
1294
|
+
return element.props.ref || element.ref;
|
|
1295
|
+
}
|
|
1296
|
+
function createCollection(name) {
|
|
1297
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
1298
|
+
const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
|
|
1299
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
|
|
1300
|
+
PROVIDER_NAME,
|
|
1301
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
1302
|
+
);
|
|
1303
|
+
const CollectionProvider = (props) => {
|
|
1304
|
+
const { scope, children } = props;
|
|
1305
|
+
const ref = React.useRef(null);
|
|
1306
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
1307
|
+
return /* @__PURE__ */ u(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
1308
|
+
};
|
|
1309
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
1310
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
1311
|
+
const CollectionSlotImpl = /* @__PURE__ */ createSlot(COLLECTION_SLOT_NAME);
|
|
1312
|
+
const CollectionSlot = React.forwardRef(
|
|
1313
|
+
(props, forwardedRef) => {
|
|
1314
|
+
const { scope, children } = props;
|
|
1315
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
1316
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
1317
|
+
return /* @__PURE__ */ u(CollectionSlotImpl, { ref: composedRefs, children });
|
|
1318
|
+
}
|
|
1319
|
+
);
|
|
1320
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
1321
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
1322
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
1323
|
+
const CollectionItemSlotImpl = /* @__PURE__ */ createSlot(ITEM_SLOT_NAME);
|
|
1324
|
+
const CollectionItemSlot = React.forwardRef(
|
|
1325
|
+
(props, forwardedRef) => {
|
|
1326
|
+
const { scope, children, ...itemData } = props;
|
|
1327
|
+
const ref = React.useRef(null);
|
|
1328
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1329
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
1330
|
+
React.useEffect(() => {
|
|
1331
|
+
context.itemMap.set(ref, { ref, ...itemData });
|
|
1332
|
+
return () => void context.itemMap.delete(ref);
|
|
1333
|
+
});
|
|
1334
|
+
return /* @__PURE__ */ u(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
1335
|
+
}
|
|
1336
|
+
);
|
|
1337
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
1338
|
+
function useCollection2(scope) {
|
|
1339
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
1340
|
+
const getItems = React.useCallback(() => {
|
|
1341
|
+
const collectionNode = context.collectionRef.current;
|
|
1342
|
+
if (!collectionNode) return [];
|
|
1343
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
1344
|
+
const items = Array.from(context.itemMap.values());
|
|
1345
|
+
const orderedItems = items.sort(
|
|
1346
|
+
(a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
|
|
1347
|
+
);
|
|
1348
|
+
return orderedItems;
|
|
1349
|
+
}, [context.collectionRef, context.itemMap]);
|
|
1350
|
+
return getItems;
|
|
1351
|
+
}
|
|
1352
|
+
return [
|
|
1353
|
+
{ Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
|
|
1354
|
+
useCollection2,
|
|
1355
|
+
createCollectionScope2
|
|
1356
|
+
];
|
|
1357
|
+
}
|
|
1358
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
1359
|
+
return function handleEvent(event) {
|
|
1360
|
+
originalEventHandler?.(event);
|
|
1361
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
1362
|
+
return ourEventHandler?.(event);
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
var useLayoutEffect2 = globalThis?.document ? React__namespace.useLayoutEffect : () => {
|
|
1367
|
+
};
|
|
1368
|
+
var useInsertionEffect = React__namespace[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
1369
|
+
function useControllableState({
|
|
1370
|
+
prop,
|
|
1371
|
+
defaultProp,
|
|
1372
|
+
onChange = () => {
|
|
1373
|
+
},
|
|
1374
|
+
caller
|
|
1375
|
+
}) {
|
|
1376
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
1377
|
+
defaultProp,
|
|
1378
|
+
onChange
|
|
1379
|
+
});
|
|
1380
|
+
const isControlled = prop !== void 0;
|
|
1381
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
1382
|
+
{
|
|
1383
|
+
const isControlledRef = React__namespace.useRef(prop !== void 0);
|
|
1384
|
+
React__namespace.useEffect(() => {
|
|
1385
|
+
const wasControlled = isControlledRef.current;
|
|
1386
|
+
if (wasControlled !== isControlled) {
|
|
1387
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
1388
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
1389
|
+
console.warn(
|
|
1390
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
isControlledRef.current = isControlled;
|
|
1394
|
+
}, [isControlled, caller]);
|
|
1395
|
+
}
|
|
1396
|
+
const setValue = React__namespace.useCallback(
|
|
1397
|
+
(nextValue) => {
|
|
1398
|
+
if (isControlled) {
|
|
1399
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
1400
|
+
if (value2 !== prop) {
|
|
1401
|
+
onChangeRef.current?.(value2);
|
|
1402
|
+
}
|
|
1403
|
+
} else {
|
|
1404
|
+
setUncontrolledProp(nextValue);
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
1408
|
+
);
|
|
1409
|
+
return [value, setValue];
|
|
1410
|
+
}
|
|
1411
|
+
function useUncontrolledState({
|
|
1412
|
+
defaultProp,
|
|
1413
|
+
onChange
|
|
1414
|
+
}) {
|
|
1415
|
+
const [value, setValue] = React__namespace.useState(defaultProp);
|
|
1416
|
+
const prevValueRef = React__namespace.useRef(value);
|
|
1417
|
+
const onChangeRef = React__namespace.useRef(onChange);
|
|
1418
|
+
useInsertionEffect(() => {
|
|
1419
|
+
onChangeRef.current = onChange;
|
|
1420
|
+
}, [onChange]);
|
|
1421
|
+
React__namespace.useEffect(() => {
|
|
1422
|
+
if (prevValueRef.current !== value) {
|
|
1423
|
+
onChangeRef.current?.(value);
|
|
1424
|
+
prevValueRef.current = value;
|
|
1425
|
+
}
|
|
1426
|
+
}, [value, prevValueRef]);
|
|
1427
|
+
return [value, setValue, onChangeRef];
|
|
1428
|
+
}
|
|
1429
|
+
function isFunction(value) {
|
|
1430
|
+
return typeof value === "function";
|
|
1431
|
+
}
|
|
1432
|
+
var NODES = [
|
|
1433
|
+
"a",
|
|
1434
|
+
"button",
|
|
1435
|
+
"div",
|
|
1436
|
+
"form",
|
|
1437
|
+
"h2",
|
|
1438
|
+
"h3",
|
|
1439
|
+
"img",
|
|
1440
|
+
"input",
|
|
1441
|
+
"label",
|
|
1442
|
+
"li",
|
|
1443
|
+
"nav",
|
|
1444
|
+
"ol",
|
|
1445
|
+
"p",
|
|
1446
|
+
"select",
|
|
1447
|
+
"span",
|
|
1448
|
+
"svg",
|
|
1449
|
+
"ul"
|
|
1450
|
+
];
|
|
1451
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
1452
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
1453
|
+
const Node2 = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1454
|
+
const { asChild, ...primitiveProps } = props;
|
|
1455
|
+
const Comp = asChild ? Slot2 : node;
|
|
1456
|
+
if (typeof window !== "undefined") {
|
|
1457
|
+
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
1458
|
+
}
|
|
1459
|
+
return /* @__PURE__ */ u(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
1460
|
+
});
|
|
1461
|
+
Node2.displayName = `Primitive.${node}`;
|
|
1462
|
+
return { ...primitive, [node]: Node2 };
|
|
1463
|
+
}, {});
|
|
1464
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
1465
|
+
if (target) ReactDOM__namespace.flushSync(() => target.dispatchEvent(event));
|
|
1466
|
+
}
|
|
1467
|
+
function useStateMachine(initialState, machine) {
|
|
1468
|
+
return React__namespace.useReducer((state, event) => {
|
|
1469
|
+
const nextState = machine[state][event];
|
|
1470
|
+
return nextState ?? state;
|
|
1471
|
+
}, initialState);
|
|
1472
|
+
}
|
|
1473
|
+
var Presence = (props) => {
|
|
1474
|
+
const { present, children } = props;
|
|
1475
|
+
const presence = usePresence(present);
|
|
1476
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React__namespace.Children.only(children);
|
|
1477
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
1478
|
+
const forceMount = typeof children === "function";
|
|
1479
|
+
return forceMount || presence.isPresent ? React__namespace.cloneElement(child, { ref }) : null;
|
|
1480
|
+
};
|
|
1481
|
+
Presence.displayName = "Presence";
|
|
1482
|
+
function usePresence(present) {
|
|
1483
|
+
const [node, setNode] = React__namespace.useState();
|
|
1484
|
+
const stylesRef = React__namespace.useRef(null);
|
|
1485
|
+
const prevPresentRef = React__namespace.useRef(present);
|
|
1486
|
+
const prevAnimationNameRef = React__namespace.useRef("none");
|
|
1487
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
1488
|
+
const [state, send] = useStateMachine(initialState, {
|
|
1489
|
+
mounted: {
|
|
1490
|
+
UNMOUNT: "unmounted",
|
|
1491
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
1492
|
+
},
|
|
1493
|
+
unmountSuspended: {
|
|
1494
|
+
MOUNT: "mounted",
|
|
1495
|
+
ANIMATION_END: "unmounted"
|
|
1496
|
+
},
|
|
1497
|
+
unmounted: {
|
|
1498
|
+
MOUNT: "mounted"
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
React__namespace.useEffect(() => {
|
|
1502
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
1503
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
1504
|
+
}, [state]);
|
|
1505
|
+
useLayoutEffect2(() => {
|
|
1506
|
+
const styles = stylesRef.current;
|
|
1507
|
+
const wasPresent = prevPresentRef.current;
|
|
1508
|
+
const hasPresentChanged = wasPresent !== present;
|
|
1509
|
+
if (hasPresentChanged) {
|
|
1510
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
1511
|
+
const currentAnimationName = getAnimationName(styles);
|
|
1512
|
+
if (present) {
|
|
1513
|
+
send("MOUNT");
|
|
1514
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
1515
|
+
send("UNMOUNT");
|
|
1516
|
+
} else {
|
|
1517
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
1518
|
+
if (wasPresent && isAnimating) {
|
|
1519
|
+
send("ANIMATION_OUT");
|
|
1520
|
+
} else {
|
|
1521
|
+
send("UNMOUNT");
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
prevPresentRef.current = present;
|
|
1525
|
+
}
|
|
1526
|
+
}, [present, send]);
|
|
1527
|
+
useLayoutEffect2(() => {
|
|
1528
|
+
if (node) {
|
|
1529
|
+
let timeoutId;
|
|
1530
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
1531
|
+
const handleAnimationEnd = (event) => {
|
|
1532
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
1533
|
+
const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
|
|
1534
|
+
if (event.target === node && isCurrentAnimation) {
|
|
1535
|
+
send("ANIMATION_END");
|
|
1536
|
+
if (!prevPresentRef.current) {
|
|
1537
|
+
const currentFillMode = node.style.animationFillMode;
|
|
1538
|
+
node.style.animationFillMode = "forwards";
|
|
1539
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
1540
|
+
if (node.style.animationFillMode === "forwards") {
|
|
1541
|
+
node.style.animationFillMode = currentFillMode;
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
const handleAnimationStart = (event) => {
|
|
1548
|
+
if (event.target === node) {
|
|
1549
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
1553
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
1554
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
1555
|
+
return () => {
|
|
1556
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
1557
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
1558
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
1559
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
1560
|
+
};
|
|
1561
|
+
} else {
|
|
1562
|
+
send("ANIMATION_END");
|
|
1563
|
+
}
|
|
1564
|
+
}, [node, send]);
|
|
1565
|
+
return {
|
|
1566
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
1567
|
+
ref: React__namespace.useCallback((node2) => {
|
|
1568
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
1569
|
+
setNode(node2);
|
|
1570
|
+
}, [])
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1573
|
+
function getAnimationName(styles) {
|
|
1574
|
+
return styles?.animationName || "none";
|
|
1575
|
+
}
|
|
1576
|
+
function getElementRef(element) {
|
|
1577
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
1578
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1579
|
+
if (mayWarn) {
|
|
1580
|
+
return element.ref;
|
|
1581
|
+
}
|
|
1582
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
1583
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1584
|
+
if (mayWarn) {
|
|
1585
|
+
return element.props.ref;
|
|
1586
|
+
}
|
|
1587
|
+
return element.props.ref || element.ref;
|
|
1588
|
+
}
|
|
1589
|
+
var useReactId = React__namespace[" useId ".trim().toString()] || (() => void 0);
|
|
1590
|
+
var count$1 = 0;
|
|
1591
|
+
function useId(deterministicId) {
|
|
1592
|
+
const [id, setId] = React__namespace.useState(useReactId());
|
|
1593
|
+
useLayoutEffect2(() => {
|
|
1594
|
+
setId((reactId) => reactId ?? String(count$1++));
|
|
1595
|
+
}, [deterministicId]);
|
|
1596
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
1597
|
+
}
|
|
1598
|
+
var COLLAPSIBLE_NAME = "Collapsible";
|
|
1599
|
+
var [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
|
|
1600
|
+
var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
|
|
1601
|
+
var Collapsible = React__namespace.forwardRef(
|
|
1602
|
+
(props, forwardedRef) => {
|
|
1603
|
+
const {
|
|
1604
|
+
__scopeCollapsible,
|
|
1605
|
+
open: openProp,
|
|
1606
|
+
defaultOpen,
|
|
1607
|
+
disabled,
|
|
1608
|
+
onOpenChange,
|
|
1609
|
+
...collapsibleProps
|
|
1610
|
+
} = props;
|
|
1611
|
+
const [open2, setOpen] = useControllableState({
|
|
1612
|
+
prop: openProp,
|
|
1613
|
+
defaultProp: defaultOpen ?? false,
|
|
1614
|
+
onChange: onOpenChange,
|
|
1615
|
+
caller: COLLAPSIBLE_NAME
|
|
1616
|
+
});
|
|
1617
|
+
return /* @__PURE__ */ u(
|
|
1618
|
+
CollapsibleProvider,
|
|
1619
|
+
{
|
|
1620
|
+
scope: __scopeCollapsible,
|
|
1621
|
+
disabled,
|
|
1622
|
+
contentId: useId(),
|
|
1623
|
+
open: open2,
|
|
1624
|
+
onOpenToggle: React__namespace.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
1625
|
+
children: /* @__PURE__ */ u(
|
|
1626
|
+
Primitive.div,
|
|
1627
|
+
{
|
|
1628
|
+
"data-state": getState$3(open2),
|
|
1629
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1630
|
+
...collapsibleProps,
|
|
1631
|
+
ref: forwardedRef
|
|
1632
|
+
}
|
|
1633
|
+
)
|
|
1634
|
+
}
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
);
|
|
1638
|
+
Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
1639
|
+
var TRIGGER_NAME$2 = "CollapsibleTrigger";
|
|
1640
|
+
var CollapsibleTrigger = React__namespace.forwardRef(
|
|
1641
|
+
(props, forwardedRef) => {
|
|
1642
|
+
const { __scopeCollapsible, ...triggerProps } = props;
|
|
1643
|
+
const context = useCollapsibleContext(TRIGGER_NAME$2, __scopeCollapsible);
|
|
1644
|
+
return /* @__PURE__ */ u(
|
|
1645
|
+
Primitive.button,
|
|
1646
|
+
{
|
|
1647
|
+
type: "button",
|
|
1648
|
+
"aria-controls": context.contentId,
|
|
1649
|
+
"aria-expanded": context.open || false,
|
|
1650
|
+
"data-state": getState$3(context.open),
|
|
1651
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
1652
|
+
disabled: context.disabled,
|
|
1653
|
+
...triggerProps,
|
|
1654
|
+
ref: forwardedRef,
|
|
1655
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
1656
|
+
}
|
|
1657
|
+
);
|
|
1658
|
+
}
|
|
1659
|
+
);
|
|
1660
|
+
CollapsibleTrigger.displayName = TRIGGER_NAME$2;
|
|
1661
|
+
var CONTENT_NAME$2 = "CollapsibleContent";
|
|
1662
|
+
var CollapsibleContent = React__namespace.forwardRef(
|
|
1663
|
+
(props, forwardedRef) => {
|
|
1664
|
+
const { forceMount, ...contentProps } = props;
|
|
1665
|
+
const context = useCollapsibleContext(CONTENT_NAME$2, props.__scopeCollapsible);
|
|
1666
|
+
return /* @__PURE__ */ u(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ u(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
|
|
1667
|
+
}
|
|
1668
|
+
);
|
|
1669
|
+
CollapsibleContent.displayName = CONTENT_NAME$2;
|
|
1670
|
+
var CollapsibleContentImpl = React__namespace.forwardRef((props, forwardedRef) => {
|
|
1671
|
+
const { __scopeCollapsible, present, children, ...contentProps } = props;
|
|
1672
|
+
const context = useCollapsibleContext(CONTENT_NAME$2, __scopeCollapsible);
|
|
1673
|
+
const [isPresent, setIsPresent] = React__namespace.useState(present);
|
|
1674
|
+
const ref = React__namespace.useRef(null);
|
|
1675
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
1676
|
+
const heightRef = React__namespace.useRef(0);
|
|
1677
|
+
const height = heightRef.current;
|
|
1678
|
+
const widthRef = React__namespace.useRef(0);
|
|
1679
|
+
const width = widthRef.current;
|
|
1680
|
+
const isOpen = context.open || isPresent;
|
|
1681
|
+
const isMountAnimationPreventedRef = React__namespace.useRef(isOpen);
|
|
1682
|
+
const originalStylesRef = React__namespace.useRef(void 0);
|
|
1683
|
+
React__namespace.useEffect(() => {
|
|
1684
|
+
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
1685
|
+
return () => cancelAnimationFrame(rAF);
|
|
1686
|
+
}, []);
|
|
1687
|
+
useLayoutEffect2(() => {
|
|
1688
|
+
const node = ref.current;
|
|
1689
|
+
if (node) {
|
|
1690
|
+
originalStylesRef.current = originalStylesRef.current || {
|
|
1691
|
+
transitionDuration: node.style.transitionDuration,
|
|
1692
|
+
animationName: node.style.animationName
|
|
1693
|
+
};
|
|
1694
|
+
node.style.transitionDuration = "0s";
|
|
1695
|
+
node.style.animationName = "none";
|
|
1696
|
+
const rect = node.getBoundingClientRect();
|
|
1697
|
+
heightRef.current = rect.height;
|
|
1698
|
+
widthRef.current = rect.width;
|
|
1699
|
+
if (!isMountAnimationPreventedRef.current) {
|
|
1700
|
+
node.style.transitionDuration = originalStylesRef.current.transitionDuration;
|
|
1701
|
+
node.style.animationName = originalStylesRef.current.animationName;
|
|
1702
|
+
}
|
|
1703
|
+
setIsPresent(present);
|
|
1704
|
+
}
|
|
1705
|
+
}, [context.open, present]);
|
|
1706
|
+
return /* @__PURE__ */ u(
|
|
1707
|
+
Primitive.div,
|
|
1708
|
+
{
|
|
1709
|
+
"data-state": getState$3(context.open),
|
|
1710
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
1711
|
+
id: context.contentId,
|
|
1712
|
+
hidden: !isOpen,
|
|
1713
|
+
...contentProps,
|
|
1714
|
+
ref: composedRefs,
|
|
1715
|
+
style: {
|
|
1716
|
+
[`--radix-collapsible-content-height`]: height ? `${height}px` : void 0,
|
|
1717
|
+
[`--radix-collapsible-content-width`]: width ? `${width}px` : void 0,
|
|
1718
|
+
...props.style
|
|
1719
|
+
},
|
|
1720
|
+
children: isOpen && children
|
|
1721
|
+
}
|
|
1722
|
+
);
|
|
1723
|
+
});
|
|
1724
|
+
function getState$3(open2) {
|
|
1725
|
+
return open2 ? "open" : "closed";
|
|
1726
|
+
}
|
|
1727
|
+
var Root$2 = Collapsible;
|
|
1728
|
+
var Trigger = CollapsibleTrigger;
|
|
1729
|
+
var Content$1 = CollapsibleContent;
|
|
1730
|
+
var DirectionContext = React__namespace.createContext(void 0);
|
|
1731
|
+
function useDirection(localDir) {
|
|
1732
|
+
const globalDir = React__namespace.useContext(DirectionContext);
|
|
1733
|
+
return localDir || globalDir || "ltr";
|
|
1734
|
+
}
|
|
1735
|
+
var ACCORDION_NAME = "Accordion";
|
|
1736
|
+
var ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"];
|
|
1737
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(ACCORDION_NAME);
|
|
1738
|
+
var [createAccordionContext] = createContextScope(ACCORDION_NAME, [
|
|
1739
|
+
createCollectionScope,
|
|
1740
|
+
createCollapsibleScope
|
|
1741
|
+
]);
|
|
1742
|
+
var useCollapsibleScope = createCollapsibleScope();
|
|
1743
|
+
var Accordion = React.forwardRef(
|
|
1744
|
+
(props, forwardedRef) => {
|
|
1745
|
+
const { type, ...accordionProps } = props;
|
|
1746
|
+
const singleProps = accordionProps;
|
|
1747
|
+
const multipleProps = accordionProps;
|
|
1748
|
+
return /* @__PURE__ */ u(Collection.Provider, { scope: props.__scopeAccordion, children: type === "multiple" ? /* @__PURE__ */ u(AccordionImplMultiple, { ...multipleProps, ref: forwardedRef }) : /* @__PURE__ */ u(AccordionImplSingle, { ...singleProps, ref: forwardedRef }) });
|
|
1749
|
+
}
|
|
1750
|
+
);
|
|
1751
|
+
Accordion.displayName = ACCORDION_NAME;
|
|
1752
|
+
var [AccordionValueProvider, useAccordionValueContext] = createAccordionContext(ACCORDION_NAME);
|
|
1753
|
+
var [AccordionCollapsibleProvider, useAccordionCollapsibleContext] = createAccordionContext(
|
|
1754
|
+
ACCORDION_NAME,
|
|
1755
|
+
{ collapsible: false }
|
|
1756
|
+
);
|
|
1757
|
+
var AccordionImplSingle = React.forwardRef(
|
|
1758
|
+
(props, forwardedRef) => {
|
|
1759
|
+
const {
|
|
1760
|
+
value: valueProp,
|
|
1761
|
+
defaultValue,
|
|
1762
|
+
onValueChange = () => {
|
|
1763
|
+
},
|
|
1764
|
+
collapsible: collapsible2 = false,
|
|
1765
|
+
...accordionSingleProps
|
|
1766
|
+
} = props;
|
|
1767
|
+
const [value, setValue] = useControllableState({
|
|
1768
|
+
prop: valueProp,
|
|
1769
|
+
defaultProp: defaultValue ?? "",
|
|
1770
|
+
onChange: onValueChange,
|
|
1771
|
+
caller: ACCORDION_NAME
|
|
1772
|
+
});
|
|
1773
|
+
return /* @__PURE__ */ u(
|
|
1774
|
+
AccordionValueProvider,
|
|
1775
|
+
{
|
|
1776
|
+
scope: props.__scopeAccordion,
|
|
1777
|
+
value: React.useMemo(() => value ? [value] : [], [value]),
|
|
1778
|
+
onItemOpen: setValue,
|
|
1779
|
+
onItemClose: React.useCallback(() => collapsible2 && setValue(""), [collapsible2, setValue]),
|
|
1780
|
+
children: /* @__PURE__ */ u(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible: collapsible2, children: /* @__PURE__ */ u(AccordionImpl, { ...accordionSingleProps, ref: forwardedRef }) })
|
|
1781
|
+
}
|
|
1782
|
+
);
|
|
1783
|
+
}
|
|
1784
|
+
);
|
|
1785
|
+
var AccordionImplMultiple = React.forwardRef((props, forwardedRef) => {
|
|
1786
|
+
const {
|
|
1787
|
+
value: valueProp,
|
|
1788
|
+
defaultValue,
|
|
1789
|
+
onValueChange = () => {
|
|
1790
|
+
},
|
|
1791
|
+
...accordionMultipleProps
|
|
1792
|
+
} = props;
|
|
1793
|
+
const [value, setValue] = useControllableState({
|
|
1794
|
+
prop: valueProp,
|
|
1795
|
+
defaultProp: defaultValue ?? [],
|
|
1796
|
+
onChange: onValueChange,
|
|
1797
|
+
caller: ACCORDION_NAME
|
|
1798
|
+
});
|
|
1799
|
+
const handleItemOpen = React.useCallback(
|
|
1800
|
+
(itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
|
|
1801
|
+
[setValue]
|
|
1802
|
+
);
|
|
1803
|
+
const handleItemClose = React.useCallback(
|
|
1804
|
+
(itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
|
|
1805
|
+
[setValue]
|
|
1806
|
+
);
|
|
1807
|
+
return /* @__PURE__ */ u(
|
|
1808
|
+
AccordionValueProvider,
|
|
1809
|
+
{
|
|
1810
|
+
scope: props.__scopeAccordion,
|
|
1811
|
+
value,
|
|
1812
|
+
onItemOpen: handleItemOpen,
|
|
1813
|
+
onItemClose: handleItemClose,
|
|
1814
|
+
children: /* @__PURE__ */ u(AccordionCollapsibleProvider, { scope: props.__scopeAccordion, collapsible: true, children: /* @__PURE__ */ u(AccordionImpl, { ...accordionMultipleProps, ref: forwardedRef }) })
|
|
1815
|
+
}
|
|
1816
|
+
);
|
|
1817
|
+
});
|
|
1818
|
+
var [AccordionImplProvider, useAccordionContext] = createAccordionContext(ACCORDION_NAME);
|
|
1819
|
+
var AccordionImpl = React.forwardRef(
|
|
1820
|
+
(props, forwardedRef) => {
|
|
1821
|
+
const { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props;
|
|
1822
|
+
const accordionRef = React.useRef(null);
|
|
1823
|
+
const composedRefs = useComposedRefs(accordionRef, forwardedRef);
|
|
1824
|
+
const getItems = useCollection(__scopeAccordion);
|
|
1825
|
+
const direction = useDirection(dir);
|
|
1826
|
+
const isDirectionLTR = direction === "ltr";
|
|
1827
|
+
const handleKeyDown = composeEventHandlers(props.onKeyDown, (event) => {
|
|
1828
|
+
if (!ACCORDION_KEYS.includes(event.key)) return;
|
|
1829
|
+
const target = event.target;
|
|
1830
|
+
const triggerCollection = getItems().filter((item) => !item.ref.current?.disabled);
|
|
1831
|
+
const triggerIndex = triggerCollection.findIndex((item) => item.ref.current === target);
|
|
1832
|
+
const triggerCount = triggerCollection.length;
|
|
1833
|
+
if (triggerIndex === -1) return;
|
|
1834
|
+
event.preventDefault();
|
|
1835
|
+
let nextIndex = triggerIndex;
|
|
1836
|
+
const homeIndex = 0;
|
|
1837
|
+
const endIndex = triggerCount - 1;
|
|
1838
|
+
const moveNext = () => {
|
|
1839
|
+
nextIndex = triggerIndex + 1;
|
|
1840
|
+
if (nextIndex > endIndex) {
|
|
1841
|
+
nextIndex = homeIndex;
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
const movePrev = () => {
|
|
1845
|
+
nextIndex = triggerIndex - 1;
|
|
1846
|
+
if (nextIndex < homeIndex) {
|
|
1847
|
+
nextIndex = endIndex;
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
switch (event.key) {
|
|
1851
|
+
case "Home":
|
|
1852
|
+
nextIndex = homeIndex;
|
|
1853
|
+
break;
|
|
1854
|
+
case "End":
|
|
1855
|
+
nextIndex = endIndex;
|
|
1856
|
+
break;
|
|
1857
|
+
case "ArrowRight":
|
|
1858
|
+
if (orientation === "horizontal") {
|
|
1859
|
+
if (isDirectionLTR) {
|
|
1860
|
+
moveNext();
|
|
1861
|
+
} else {
|
|
1862
|
+
movePrev();
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
break;
|
|
1866
|
+
case "ArrowDown":
|
|
1867
|
+
if (orientation === "vertical") {
|
|
1868
|
+
moveNext();
|
|
1869
|
+
}
|
|
1870
|
+
break;
|
|
1871
|
+
case "ArrowLeft":
|
|
1872
|
+
if (orientation === "horizontal") {
|
|
1873
|
+
if (isDirectionLTR) {
|
|
1874
|
+
movePrev();
|
|
1875
|
+
} else {
|
|
1876
|
+
moveNext();
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
break;
|
|
1880
|
+
case "ArrowUp":
|
|
1881
|
+
if (orientation === "vertical") {
|
|
1882
|
+
movePrev();
|
|
1883
|
+
}
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
const clampedIndex = nextIndex % triggerCount;
|
|
1887
|
+
triggerCollection[clampedIndex].ref.current?.focus();
|
|
1888
|
+
});
|
|
1889
|
+
return /* @__PURE__ */ u(
|
|
1890
|
+
AccordionImplProvider,
|
|
1891
|
+
{
|
|
1892
|
+
scope: __scopeAccordion,
|
|
1893
|
+
disabled,
|
|
1894
|
+
direction: dir,
|
|
1895
|
+
orientation,
|
|
1896
|
+
children: /* @__PURE__ */ u(Collection.Slot, { scope: __scopeAccordion, children: /* @__PURE__ */ u(
|
|
1897
|
+
Primitive.div,
|
|
1898
|
+
{
|
|
1899
|
+
...accordionProps,
|
|
1900
|
+
"data-orientation": orientation,
|
|
1901
|
+
ref: composedRefs,
|
|
1902
|
+
onKeyDown: disabled ? void 0 : handleKeyDown
|
|
1903
|
+
}
|
|
1904
|
+
) })
|
|
1905
|
+
}
|
|
1906
|
+
);
|
|
1907
|
+
}
|
|
1908
|
+
);
|
|
1909
|
+
var ITEM_NAME = "AccordionItem";
|
|
1910
|
+
var [AccordionItemProvider, useAccordionItemContext] = createAccordionContext(ITEM_NAME);
|
|
1911
|
+
var AccordionItem = React.forwardRef(
|
|
1912
|
+
(props, forwardedRef) => {
|
|
1913
|
+
const { __scopeAccordion, value, ...accordionItemProps } = props;
|
|
1914
|
+
const accordionContext = useAccordionContext(ITEM_NAME, __scopeAccordion);
|
|
1915
|
+
const valueContext = useAccordionValueContext(ITEM_NAME, __scopeAccordion);
|
|
1916
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
1917
|
+
const triggerId = useId();
|
|
1918
|
+
const open2 = value && valueContext.value.includes(value) || false;
|
|
1919
|
+
const disabled = accordionContext.disabled || props.disabled;
|
|
1920
|
+
return /* @__PURE__ */ u(
|
|
1921
|
+
AccordionItemProvider,
|
|
1922
|
+
{
|
|
1923
|
+
scope: __scopeAccordion,
|
|
1924
|
+
open: open2,
|
|
1925
|
+
disabled,
|
|
1926
|
+
triggerId,
|
|
1927
|
+
children: /* @__PURE__ */ u(
|
|
1928
|
+
Root$2,
|
|
1929
|
+
{
|
|
1930
|
+
"data-orientation": accordionContext.orientation,
|
|
1931
|
+
"data-state": getState$2(open2),
|
|
1932
|
+
...collapsibleScope,
|
|
1933
|
+
...accordionItemProps,
|
|
1934
|
+
ref: forwardedRef,
|
|
1935
|
+
disabled,
|
|
1936
|
+
open: open2,
|
|
1937
|
+
onOpenChange: (open22) => {
|
|
1938
|
+
if (open22) {
|
|
1939
|
+
valueContext.onItemOpen(value);
|
|
1940
|
+
} else {
|
|
1941
|
+
valueContext.onItemClose(value);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
)
|
|
1946
|
+
}
|
|
1947
|
+
);
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
AccordionItem.displayName = ITEM_NAME;
|
|
1951
|
+
var HEADER_NAME = "AccordionHeader";
|
|
1952
|
+
var AccordionHeader = React.forwardRef(
|
|
1953
|
+
(props, forwardedRef) => {
|
|
1954
|
+
const { __scopeAccordion, ...headerProps } = props;
|
|
1955
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
1956
|
+
const itemContext = useAccordionItemContext(HEADER_NAME, __scopeAccordion);
|
|
1957
|
+
return /* @__PURE__ */ u(
|
|
1958
|
+
Primitive.h3,
|
|
1959
|
+
{
|
|
1960
|
+
"data-orientation": accordionContext.orientation,
|
|
1961
|
+
"data-state": getState$2(itemContext.open),
|
|
1962
|
+
"data-disabled": itemContext.disabled ? "" : void 0,
|
|
1963
|
+
...headerProps,
|
|
1964
|
+
ref: forwardedRef
|
|
1965
|
+
}
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1968
|
+
);
|
|
1969
|
+
AccordionHeader.displayName = HEADER_NAME;
|
|
1970
|
+
var TRIGGER_NAME$1 = "AccordionTrigger";
|
|
1971
|
+
var AccordionTrigger = React.forwardRef(
|
|
1972
|
+
(props, forwardedRef) => {
|
|
1973
|
+
const { __scopeAccordion, ...triggerProps } = props;
|
|
1974
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
1975
|
+
const itemContext = useAccordionItemContext(TRIGGER_NAME$1, __scopeAccordion);
|
|
1976
|
+
const collapsibleContext = useAccordionCollapsibleContext(TRIGGER_NAME$1, __scopeAccordion);
|
|
1977
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
1978
|
+
return /* @__PURE__ */ u(Collection.ItemSlot, { scope: __scopeAccordion, children: /* @__PURE__ */ u(
|
|
1979
|
+
Trigger,
|
|
1980
|
+
{
|
|
1981
|
+
"aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
|
|
1982
|
+
"data-orientation": accordionContext.orientation,
|
|
1983
|
+
id: itemContext.triggerId,
|
|
1984
|
+
...collapsibleScope,
|
|
1985
|
+
...triggerProps,
|
|
1986
|
+
ref: forwardedRef
|
|
1987
|
+
}
|
|
1988
|
+
) });
|
|
1989
|
+
}
|
|
1990
|
+
);
|
|
1991
|
+
AccordionTrigger.displayName = TRIGGER_NAME$1;
|
|
1992
|
+
var CONTENT_NAME$1 = "AccordionContent";
|
|
1993
|
+
var AccordionContent = React.forwardRef(
|
|
1994
|
+
(props, forwardedRef) => {
|
|
1995
|
+
const { __scopeAccordion, ...contentProps } = props;
|
|
1996
|
+
const accordionContext = useAccordionContext(ACCORDION_NAME, __scopeAccordion);
|
|
1997
|
+
const itemContext = useAccordionItemContext(CONTENT_NAME$1, __scopeAccordion);
|
|
1998
|
+
const collapsibleScope = useCollapsibleScope(__scopeAccordion);
|
|
1999
|
+
return /* @__PURE__ */ u(
|
|
2000
|
+
Content$1,
|
|
2001
|
+
{
|
|
2002
|
+
role: "region",
|
|
2003
|
+
"aria-labelledby": itemContext.triggerId,
|
|
2004
|
+
"data-orientation": accordionContext.orientation,
|
|
2005
|
+
...collapsibleScope,
|
|
2006
|
+
...contentProps,
|
|
2007
|
+
ref: forwardedRef,
|
|
2008
|
+
style: {
|
|
2009
|
+
["--radix-accordion-content-height"]: "var(--radix-collapsible-content-height)",
|
|
2010
|
+
["--radix-accordion-content-width"]: "var(--radix-collapsible-content-width)",
|
|
2011
|
+
...props.style
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
);
|
|
2015
|
+
}
|
|
2016
|
+
);
|
|
2017
|
+
AccordionContent.displayName = CONTENT_NAME$1;
|
|
2018
|
+
function getState$2(open2) {
|
|
2019
|
+
return open2 ? "open" : "closed";
|
|
2020
|
+
}
|
|
2021
|
+
var Root2 = Accordion;
|
|
2022
|
+
var Item = AccordionItem;
|
|
2023
|
+
var Trigger2 = AccordionTrigger;
|
|
2024
|
+
var Content2 = AccordionContent;
|
|
2025
|
+
const mergeClasses = (...classes2) => classes2.filter((className, index, array) => {
|
|
2026
|
+
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
2027
|
+
}).join(" ").trim();
|
|
2028
|
+
const toKebabCase = (string2) => string2.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2029
|
+
const toCamelCase = (string2) => string2.replace(
|
|
2030
|
+
/^([A-Z])|[\s-_]+(\w)/g,
|
|
2031
|
+
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
2032
|
+
);
|
|
2033
|
+
const toPascalCase = (string2) => {
|
|
2034
|
+
const camelCase = toCamelCase(string2);
|
|
2035
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
2036
|
+
};
|
|
2037
|
+
var defaultAttributes = {
|
|
2038
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2039
|
+
width: 24,
|
|
2040
|
+
height: 24,
|
|
2041
|
+
viewBox: "0 0 24 24",
|
|
2042
|
+
fill: "none",
|
|
2043
|
+
stroke: "currentColor",
|
|
2044
|
+
strokeWidth: 2,
|
|
2045
|
+
strokeLinecap: "round",
|
|
2046
|
+
strokeLinejoin: "round"
|
|
2047
|
+
};
|
|
2048
|
+
const hasA11yProp = (props) => {
|
|
2049
|
+
for (const prop in props) {
|
|
2050
|
+
if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
|
|
2051
|
+
return true;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
return false;
|
|
2055
|
+
};
|
|
2056
|
+
const Icon = React.forwardRef(
|
|
2057
|
+
({
|
|
2058
|
+
color = "currentColor",
|
|
2059
|
+
size = 24,
|
|
2060
|
+
strokeWidth = 2,
|
|
2061
|
+
absoluteStrokeWidth,
|
|
2062
|
+
className = "",
|
|
2063
|
+
children,
|
|
2064
|
+
iconNode,
|
|
2065
|
+
...rest
|
|
2066
|
+
}, ref) => React.createElement(
|
|
2067
|
+
"svg",
|
|
2068
|
+
{
|
|
2069
|
+
ref,
|
|
2070
|
+
...defaultAttributes,
|
|
2071
|
+
width: size,
|
|
2072
|
+
height: size,
|
|
2073
|
+
stroke: color,
|
|
2074
|
+
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
2075
|
+
className: mergeClasses("lucide", className),
|
|
2076
|
+
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
2077
|
+
...rest
|
|
2078
|
+
},
|
|
2079
|
+
[
|
|
2080
|
+
...iconNode.map(([tag, attrs]) => React.createElement(tag, attrs)),
|
|
2081
|
+
...Array.isArray(children) ? children : [children]
|
|
2082
|
+
]
|
|
2083
|
+
)
|
|
2084
|
+
);
|
|
2085
|
+
const createLucideIcon = (iconName, iconNode) => {
|
|
2086
|
+
const Component = React.forwardRef(
|
|
2087
|
+
({ className, ...props }, ref) => React.createElement(Icon, {
|
|
2088
|
+
ref,
|
|
2089
|
+
iconNode,
|
|
2090
|
+
className: mergeClasses(
|
|
2091
|
+
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
2092
|
+
`lucide-${iconName}`,
|
|
2093
|
+
className
|
|
2094
|
+
),
|
|
2095
|
+
...props
|
|
2096
|
+
})
|
|
2097
|
+
);
|
|
2098
|
+
Component.displayName = toPascalCase(iconName);
|
|
2099
|
+
return Component;
|
|
2100
|
+
};
|
|
2101
|
+
const __iconNode$1 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
|
|
2102
|
+
const ChevronDown = createLucideIcon("chevron-down", __iconNode$1);
|
|
2103
|
+
const __iconNode = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
|
|
2104
|
+
const ChevronUp = createLucideIcon("chevron-up", __iconNode);
|
|
2105
|
+
function usePrevious(value) {
|
|
2106
|
+
const ref = React__namespace.useRef({ value, previous: value });
|
|
2107
|
+
return React__namespace.useMemo(() => {
|
|
2108
|
+
if (ref.current.value !== value) {
|
|
2109
|
+
ref.current.previous = ref.current.value;
|
|
2110
|
+
ref.current.value = value;
|
|
2111
|
+
}
|
|
2112
|
+
return ref.current.previous;
|
|
2113
|
+
}, [value]);
|
|
2114
|
+
}
|
|
2115
|
+
function useSize(element) {
|
|
2116
|
+
const [size, setSize] = React__namespace.useState(void 0);
|
|
2117
|
+
useLayoutEffect2(() => {
|
|
2118
|
+
if (element) {
|
|
2119
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
2120
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
2121
|
+
if (!Array.isArray(entries)) {
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2124
|
+
if (!entries.length) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2127
|
+
const entry = entries[0];
|
|
2128
|
+
let width;
|
|
2129
|
+
let height;
|
|
2130
|
+
if ("borderBoxSize" in entry) {
|
|
2131
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
2132
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
2133
|
+
width = borderSize["inlineSize"];
|
|
2134
|
+
height = borderSize["blockSize"];
|
|
2135
|
+
} else {
|
|
2136
|
+
width = element.offsetWidth;
|
|
2137
|
+
height = element.offsetHeight;
|
|
2138
|
+
}
|
|
2139
|
+
setSize({ width, height });
|
|
2140
|
+
});
|
|
2141
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
2142
|
+
return () => resizeObserver.unobserve(element);
|
|
2143
|
+
} else {
|
|
2144
|
+
setSize(void 0);
|
|
2145
|
+
}
|
|
2146
|
+
}, [element]);
|
|
2147
|
+
return size;
|
|
2148
|
+
}
|
|
2149
|
+
var SWITCH_NAME = "Switch";
|
|
2150
|
+
var [createSwitchContext] = createContextScope(SWITCH_NAME);
|
|
2151
|
+
var [SwitchProvider, useSwitchContext] = createSwitchContext(SWITCH_NAME);
|
|
2152
|
+
var Switch$1 = React__namespace.forwardRef(
|
|
2153
|
+
(props, forwardedRef) => {
|
|
2154
|
+
const {
|
|
2155
|
+
__scopeSwitch,
|
|
2156
|
+
name,
|
|
2157
|
+
checked: checkedProp,
|
|
2158
|
+
defaultChecked,
|
|
2159
|
+
required,
|
|
2160
|
+
disabled,
|
|
2161
|
+
value = "on",
|
|
2162
|
+
onCheckedChange,
|
|
2163
|
+
form,
|
|
2164
|
+
...switchProps
|
|
2165
|
+
} = props;
|
|
2166
|
+
const [button, setButton] = React__namespace.useState(null);
|
|
2167
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setButton(node));
|
|
2168
|
+
const hasConsumerStoppedPropagationRef = React__namespace.useRef(false);
|
|
2169
|
+
const isFormControl = button ? form || !!button.closest("form") : true;
|
|
2170
|
+
const [checked, setChecked] = useControllableState({
|
|
2171
|
+
prop: checkedProp,
|
|
2172
|
+
defaultProp: defaultChecked ?? false,
|
|
2173
|
+
onChange: onCheckedChange,
|
|
2174
|
+
caller: SWITCH_NAME
|
|
2175
|
+
});
|
|
2176
|
+
return /* @__PURE__ */ u(SwitchProvider, { scope: __scopeSwitch, checked, disabled, children: [
|
|
2177
|
+
/* @__PURE__ */ u(
|
|
2178
|
+
Primitive.button,
|
|
2179
|
+
{
|
|
2180
|
+
type: "button",
|
|
2181
|
+
role: "switch",
|
|
2182
|
+
"aria-checked": checked,
|
|
2183
|
+
"aria-required": required,
|
|
2184
|
+
"data-state": getState$1(checked),
|
|
2185
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2186
|
+
disabled,
|
|
2187
|
+
value,
|
|
2188
|
+
...switchProps,
|
|
2189
|
+
ref: composedRefs,
|
|
2190
|
+
onClick: composeEventHandlers(props.onClick, (event) => {
|
|
2191
|
+
setChecked((prevChecked) => !prevChecked);
|
|
2192
|
+
if (isFormControl) {
|
|
2193
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
2194
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
2195
|
+
}
|
|
2196
|
+
})
|
|
2197
|
+
}
|
|
2198
|
+
),
|
|
2199
|
+
isFormControl && /* @__PURE__ */ u(
|
|
2200
|
+
SwitchBubbleInput,
|
|
2201
|
+
{
|
|
2202
|
+
control: button,
|
|
2203
|
+
bubbles: !hasConsumerStoppedPropagationRef.current,
|
|
2204
|
+
name,
|
|
2205
|
+
value,
|
|
2206
|
+
checked,
|
|
2207
|
+
required,
|
|
2208
|
+
disabled,
|
|
2209
|
+
form,
|
|
2210
|
+
style: { transform: "translateX(-100%)" }
|
|
2211
|
+
}
|
|
2212
|
+
)
|
|
2213
|
+
] });
|
|
2214
|
+
}
|
|
2215
|
+
);
|
|
2216
|
+
Switch$1.displayName = SWITCH_NAME;
|
|
2217
|
+
var THUMB_NAME = "SwitchThumb";
|
|
2218
|
+
var SwitchThumb = React__namespace.forwardRef(
|
|
2219
|
+
(props, forwardedRef) => {
|
|
2220
|
+
const { __scopeSwitch, ...thumbProps } = props;
|
|
2221
|
+
const context = useSwitchContext(THUMB_NAME, __scopeSwitch);
|
|
2222
|
+
return /* @__PURE__ */ u(
|
|
2223
|
+
Primitive.span,
|
|
2224
|
+
{
|
|
2225
|
+
"data-state": getState$1(context.checked),
|
|
2226
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
2227
|
+
...thumbProps,
|
|
2228
|
+
ref: forwardedRef
|
|
2229
|
+
}
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
);
|
|
2233
|
+
SwitchThumb.displayName = THUMB_NAME;
|
|
2234
|
+
var BUBBLE_INPUT_NAME = "SwitchBubbleInput";
|
|
2235
|
+
var SwitchBubbleInput = React__namespace.forwardRef(
|
|
2236
|
+
({
|
|
2237
|
+
__scopeSwitch,
|
|
2238
|
+
control,
|
|
2239
|
+
checked,
|
|
2240
|
+
bubbles = true,
|
|
2241
|
+
...props
|
|
2242
|
+
}, forwardedRef) => {
|
|
2243
|
+
const ref = React__namespace.useRef(null);
|
|
2244
|
+
const composedRefs = useComposedRefs(ref, forwardedRef);
|
|
2245
|
+
const prevChecked = usePrevious(checked);
|
|
2246
|
+
const controlSize = useSize(control);
|
|
2247
|
+
React__namespace.useEffect(() => {
|
|
2248
|
+
const input = ref.current;
|
|
2249
|
+
if (!input) return;
|
|
2250
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
2251
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
2252
|
+
inputProto,
|
|
2253
|
+
"checked"
|
|
2254
|
+
);
|
|
2255
|
+
const setChecked = descriptor.set;
|
|
2256
|
+
if (prevChecked !== checked && setChecked) {
|
|
2257
|
+
const event = new Event("click", { bubbles });
|
|
2258
|
+
setChecked.call(input, checked);
|
|
2259
|
+
input.dispatchEvent(event);
|
|
2260
|
+
}
|
|
2261
|
+
}, [prevChecked, checked, bubbles]);
|
|
2262
|
+
return /* @__PURE__ */ u(
|
|
2263
|
+
"input",
|
|
2264
|
+
{
|
|
2265
|
+
type: "checkbox",
|
|
2266
|
+
"aria-hidden": true,
|
|
2267
|
+
defaultChecked: checked,
|
|
2268
|
+
...props,
|
|
2269
|
+
tabIndex: -1,
|
|
2270
|
+
ref: composedRefs,
|
|
2271
|
+
style: {
|
|
2272
|
+
...props.style,
|
|
2273
|
+
...controlSize,
|
|
2274
|
+
position: "absolute",
|
|
2275
|
+
pointerEvents: "none",
|
|
2276
|
+
opacity: 0,
|
|
2277
|
+
margin: 0
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
);
|
|
2283
|
+
SwitchBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
2284
|
+
function getState$1(checked) {
|
|
2285
|
+
return checked ? "checked" : "unchecked";
|
|
2286
|
+
}
|
|
2287
|
+
var Root$1 = Switch$1;
|
|
2288
|
+
var Thumb = SwitchThumb;
|
|
2289
|
+
const root = "_root_dibqz_1";
|
|
2290
|
+
const thumb = "_thumb_dibqz_38";
|
|
2291
|
+
const classes = {
|
|
2292
|
+
root,
|
|
2293
|
+
"switch": "_switch_dibqz_8",
|
|
2294
|
+
thumb
|
|
2295
|
+
};
|
|
2296
|
+
const Switch = ({ label: label2, id, ...rest }) => {
|
|
2297
|
+
return /* @__PURE__ */ u("div", { className: classes.root, children: [
|
|
2298
|
+
label2 && /* @__PURE__ */ u(Text, { className: classes.label, as: "label", htmlFor: id, children: label2 }),
|
|
2299
|
+
/* @__PURE__ */ u(Root$1, { className: classes.switch, ...rest, children: /* @__PURE__ */ u(Thumb, { className: classes.thumb }) })
|
|
2300
|
+
] });
|
|
2301
|
+
};
|
|
2302
|
+
const selectionSchema = /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ boolean());
|
|
2303
|
+
const SelectionContext = React.createContext(null);
|
|
2304
|
+
const SelectionProvider = ({
|
|
2305
|
+
children,
|
|
2306
|
+
items,
|
|
2307
|
+
localStorageKey
|
|
2308
|
+
}) => {
|
|
2309
|
+
function getLsSelection(localStorageKey2) {
|
|
2310
|
+
const storedSelection = localStorage.getItem(localStorageKey2);
|
|
2311
|
+
if (!storedSelection) return null;
|
|
2312
|
+
const { success, data } = selectionSchema.safeParse(
|
|
2313
|
+
JSON.parse(storedSelection)
|
|
2314
|
+
);
|
|
2315
|
+
if (!success) return null;
|
|
2316
|
+
return data;
|
|
2317
|
+
}
|
|
2318
|
+
const defaultSelection = React.useMemo(
|
|
2319
|
+
() => Object.fromEntries(
|
|
2320
|
+
items.map((item) => [item.value, item.defaultSelected ?? false])
|
|
2321
|
+
),
|
|
2322
|
+
[items]
|
|
2323
|
+
);
|
|
2324
|
+
const [selection, setSelection] = React.useState(
|
|
2325
|
+
getLsSelection(localStorageKey) ?? defaultSelection
|
|
2326
|
+
);
|
|
2327
|
+
const [savedSelection, setSavedSelection] = React.useState(
|
|
2328
|
+
getLsSelection(localStorageKey)
|
|
2329
|
+
);
|
|
2330
|
+
function toggleSelection(key, value) {
|
|
2331
|
+
const newSelection = selection ? { ...selection, [key]: value } : { [key]: value };
|
|
2332
|
+
setSelection(newSelection);
|
|
2333
|
+
}
|
|
2334
|
+
React.useEffect(() => {
|
|
2335
|
+
let selectedValues = [];
|
|
2336
|
+
if (savedSelection !== null) {
|
|
2337
|
+
selectedValues = Object.entries(savedSelection).filter(([_, value]) => value).map(([key]) => key);
|
|
2338
|
+
}
|
|
2339
|
+
const mountedItems = items.filter(
|
|
2340
|
+
(item) => selectedValues.includes(item.value)
|
|
2341
|
+
);
|
|
2342
|
+
for (const item of items) {
|
|
2343
|
+
const elem = document.head.querySelector(`#${item.value}`);
|
|
2344
|
+
if (!elem) continue;
|
|
2345
|
+
elem.remove();
|
|
2346
|
+
}
|
|
2347
|
+
for (const item of mountedItems) {
|
|
2348
|
+
const elem = document.createElement("script");
|
|
2349
|
+
elem.id = item.value;
|
|
2350
|
+
if (!item.script) {
|
|
2351
|
+
if (!item.required)
|
|
2352
|
+
console.warn("CookieBanner: Missing script for", item.value);
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
const { success, data: script } = scriptDefinitionSchema.safeParse(
|
|
2356
|
+
item.script
|
|
2357
|
+
);
|
|
2358
|
+
if (!success) {
|
|
2359
|
+
console.error(
|
|
2360
|
+
"CookieBanner: Invalid script definition for",
|
|
2361
|
+
item.value
|
|
2362
|
+
);
|
|
2363
|
+
continue;
|
|
2364
|
+
}
|
|
2365
|
+
elem.type = script.type ?? "text/javascript";
|
|
2366
|
+
elem.async = script.async ?? false;
|
|
2367
|
+
elem.defer = script.defer ?? false;
|
|
2368
|
+
switch (script.variant) {
|
|
2369
|
+
case "inline":
|
|
2370
|
+
elem.textContent = script.content;
|
|
2371
|
+
break;
|
|
2372
|
+
case "remote":
|
|
2373
|
+
elem.src = script.src;
|
|
2374
|
+
elem.crossOrigin = script.crossorigin ?? null;
|
|
2375
|
+
elem.integrity = script.integrity ?? "";
|
|
2376
|
+
break;
|
|
2377
|
+
}
|
|
2378
|
+
document.head.appendChild(elem);
|
|
2379
|
+
}
|
|
2380
|
+
}, [savedSelection, items]);
|
|
2381
|
+
function saveSelection(newSelection) {
|
|
2382
|
+
setSavedSelection(newSelection);
|
|
2383
|
+
localStorage.setItem(localStorageKey, JSON.stringify(newSelection));
|
|
2384
|
+
}
|
|
2385
|
+
const onDeclineAll = React.useCallback(() => {
|
|
2386
|
+
const newSelection = Object.fromEntries(
|
|
2387
|
+
items.map((item) => [item.value, false])
|
|
2388
|
+
);
|
|
2389
|
+
setSelection(newSelection);
|
|
2390
|
+
saveSelection(newSelection);
|
|
2391
|
+
}, [items]);
|
|
2392
|
+
const onSave = React.useCallback(() => {
|
|
2393
|
+
saveSelection(selection);
|
|
2394
|
+
}, [selection]);
|
|
2395
|
+
const selectionTaken = React.useMemo(() => {
|
|
2396
|
+
if (!savedSelection) return false;
|
|
2397
|
+
const selectedKeys = Object.keys(savedSelection);
|
|
2398
|
+
const itemKeys = items.map((item) => item.value);
|
|
2399
|
+
return itemKeys.every((key) => selectedKeys.includes(key));
|
|
2400
|
+
}, [savedSelection, items]);
|
|
2401
|
+
return /* @__PURE__ */ u(
|
|
2402
|
+
SelectionContext.Provider,
|
|
2403
|
+
{
|
|
2404
|
+
value: {
|
|
2405
|
+
selection,
|
|
2406
|
+
toggleSelection,
|
|
2407
|
+
onDeclineAll,
|
|
2408
|
+
onSave,
|
|
2409
|
+
selectionTaken
|
|
2410
|
+
},
|
|
2411
|
+
children
|
|
2412
|
+
}
|
|
2413
|
+
);
|
|
2414
|
+
};
|
|
2415
|
+
function useSelection() {
|
|
2416
|
+
const context = React.useContext(SelectionContext);
|
|
2417
|
+
if (!context) {
|
|
2418
|
+
throw new Error("useSelection must be used within a SelectionProvider");
|
|
2419
|
+
}
|
|
2420
|
+
return context;
|
|
2421
|
+
}
|
|
2422
|
+
const BannerItem = ({
|
|
2423
|
+
value,
|
|
2424
|
+
label: label2,
|
|
2425
|
+
sublabel,
|
|
2426
|
+
required = false,
|
|
2427
|
+
description: description2,
|
|
2428
|
+
openItem
|
|
2429
|
+
}) => {
|
|
2430
|
+
const { toggleSelection, selection } = useSelection();
|
|
2431
|
+
const selected = React.useMemo(
|
|
2432
|
+
() => selection?.[value] ?? false,
|
|
2433
|
+
[selection, value]
|
|
2434
|
+
);
|
|
2435
|
+
React.useEffect(() => {
|
|
2436
|
+
toggleSelection(value, selected);
|
|
2437
|
+
}, [value, selected]);
|
|
2438
|
+
const checked = React.useMemo(
|
|
2439
|
+
() => required ? true : selected,
|
|
2440
|
+
[required, selected]
|
|
2441
|
+
);
|
|
2442
|
+
const onCheckedChange = React.useMemo(
|
|
2443
|
+
() => (checked2) => required ? () => {
|
|
2444
|
+
} : toggleSelection(value, checked2),
|
|
2445
|
+
[required, toggleSelection, value]
|
|
2446
|
+
);
|
|
2447
|
+
const disabled = React.useMemo(() => required, [required]);
|
|
2448
|
+
return /* @__PURE__ */ u(Item, { value, className: classes$1.root, children: [
|
|
2449
|
+
/* @__PURE__ */ u("div", { className: classes$1.header, children: [
|
|
2450
|
+
/* @__PURE__ */ u(Trigger2, { asChild: true, children: /* @__PURE__ */ u("div", { className: classes$1.label, children: [
|
|
2451
|
+
/* @__PURE__ */ u(Text, { weight: "bold", children: label2 }),
|
|
2452
|
+
sublabel && /* @__PURE__ */ u(Text, { size: "caption", color: "muted", children: sublabel })
|
|
2453
|
+
] }) }),
|
|
2454
|
+
/* @__PURE__ */ u("div", { className: classes$1.actions, children: [
|
|
2455
|
+
/* @__PURE__ */ u(
|
|
2456
|
+
Switch,
|
|
2457
|
+
{
|
|
2458
|
+
checked,
|
|
2459
|
+
onCheckedChange,
|
|
2460
|
+
disabled
|
|
2461
|
+
}
|
|
2462
|
+
),
|
|
2463
|
+
/* @__PURE__ */ u(Trigger2, { asChild: true, children: /* @__PURE__ */ u(
|
|
2464
|
+
ChevronDown,
|
|
2465
|
+
{
|
|
2466
|
+
size: 16,
|
|
2467
|
+
className: clx({
|
|
2468
|
+
[classes$1.chevron]: true,
|
|
2469
|
+
[classes$1.open]: openItem === value
|
|
2470
|
+
})
|
|
2471
|
+
}
|
|
2472
|
+
) })
|
|
2473
|
+
] })
|
|
2474
|
+
] }),
|
|
2475
|
+
description2 && /* @__PURE__ */ u(Content2, { className: classes$1.description, children: /* @__PURE__ */ u(
|
|
2476
|
+
Text,
|
|
2477
|
+
{
|
|
2478
|
+
size: "caption",
|
|
2479
|
+
dangerouslySetInnerHTML: { __html: description2 }
|
|
2480
|
+
}
|
|
2481
|
+
) })
|
|
2482
|
+
] });
|
|
2483
|
+
};
|
|
2484
|
+
function useCallbackRef$1(callback) {
|
|
2485
|
+
const callbackRef = React__namespace.useRef(callback);
|
|
2486
|
+
React__namespace.useEffect(() => {
|
|
2487
|
+
callbackRef.current = callback;
|
|
2488
|
+
});
|
|
2489
|
+
return React__namespace.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
2490
|
+
}
|
|
2491
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
2492
|
+
const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
|
|
2493
|
+
React__namespace.useEffect(() => {
|
|
2494
|
+
const handleKeyDown = (event) => {
|
|
2495
|
+
if (event.key === "Escape") {
|
|
2496
|
+
onEscapeKeyDown(event);
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
2500
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
2501
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
2502
|
+
}
|
|
2503
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
2504
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
2505
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
2506
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
2507
|
+
var originalBodyPointerEvents;
|
|
2508
|
+
var DismissableLayerContext = React__namespace.createContext({
|
|
2509
|
+
layers: /* @__PURE__ */ new Set(),
|
|
2510
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
2511
|
+
branches: /* @__PURE__ */ new Set()
|
|
2512
|
+
});
|
|
2513
|
+
var DismissableLayer = React__namespace.forwardRef(
|
|
2514
|
+
(props, forwardedRef) => {
|
|
2515
|
+
const {
|
|
2516
|
+
disableOutsidePointerEvents = false,
|
|
2517
|
+
onEscapeKeyDown,
|
|
2518
|
+
onPointerDownOutside,
|
|
2519
|
+
onFocusOutside,
|
|
2520
|
+
onInteractOutside,
|
|
2521
|
+
onDismiss,
|
|
2522
|
+
...layerProps
|
|
2523
|
+
} = props;
|
|
2524
|
+
const context = React__namespace.useContext(DismissableLayerContext);
|
|
2525
|
+
const [node, setNode] = React__namespace.useState(null);
|
|
2526
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
2527
|
+
const [, force] = React__namespace.useState({});
|
|
2528
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
2529
|
+
const layers = Array.from(context.layers);
|
|
2530
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
2531
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
2532
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
2533
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
2534
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
2535
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
2536
|
+
const target = event.target;
|
|
2537
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
2538
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
2539
|
+
onPointerDownOutside?.(event);
|
|
2540
|
+
onInteractOutside?.(event);
|
|
2541
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
2542
|
+
}, ownerDocument);
|
|
2543
|
+
const focusOutside = useFocusOutside((event) => {
|
|
2544
|
+
const target = event.target;
|
|
2545
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
2546
|
+
if (isFocusInBranch) return;
|
|
2547
|
+
onFocusOutside?.(event);
|
|
2548
|
+
onInteractOutside?.(event);
|
|
2549
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
2550
|
+
}, ownerDocument);
|
|
2551
|
+
useEscapeKeydown((event) => {
|
|
2552
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
2553
|
+
if (!isHighestLayer) return;
|
|
2554
|
+
onEscapeKeyDown?.(event);
|
|
2555
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
2556
|
+
event.preventDefault();
|
|
2557
|
+
onDismiss();
|
|
2558
|
+
}
|
|
2559
|
+
}, ownerDocument);
|
|
2560
|
+
React__namespace.useEffect(() => {
|
|
2561
|
+
if (!node) return;
|
|
2562
|
+
if (disableOutsidePointerEvents) {
|
|
2563
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
2564
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
2565
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
2566
|
+
}
|
|
2567
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
2568
|
+
}
|
|
2569
|
+
context.layers.add(node);
|
|
2570
|
+
dispatchUpdate();
|
|
2571
|
+
return () => {
|
|
2572
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
2573
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
2577
|
+
React__namespace.useEffect(() => {
|
|
2578
|
+
return () => {
|
|
2579
|
+
if (!node) return;
|
|
2580
|
+
context.layers.delete(node);
|
|
2581
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
2582
|
+
dispatchUpdate();
|
|
2583
|
+
};
|
|
2584
|
+
}, [node, context]);
|
|
2585
|
+
React__namespace.useEffect(() => {
|
|
2586
|
+
const handleUpdate = () => force({});
|
|
2587
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
2588
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
2589
|
+
}, []);
|
|
2590
|
+
return /* @__PURE__ */ u(
|
|
2591
|
+
Primitive.div,
|
|
2592
|
+
{
|
|
2593
|
+
...layerProps,
|
|
2594
|
+
ref: composedRefs,
|
|
2595
|
+
style: {
|
|
2596
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
2597
|
+
...props.style
|
|
2598
|
+
},
|
|
2599
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
2600
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
2601
|
+
onPointerDownCapture: composeEventHandlers(
|
|
2602
|
+
props.onPointerDownCapture,
|
|
2603
|
+
pointerDownOutside.onPointerDownCapture
|
|
2604
|
+
)
|
|
2605
|
+
}
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
);
|
|
2609
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
2610
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
2611
|
+
var DismissableLayerBranch = React__namespace.forwardRef((props, forwardedRef) => {
|
|
2612
|
+
const context = React__namespace.useContext(DismissableLayerContext);
|
|
2613
|
+
const ref = React__namespace.useRef(null);
|
|
2614
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
2615
|
+
React__namespace.useEffect(() => {
|
|
2616
|
+
const node = ref.current;
|
|
2617
|
+
if (node) {
|
|
2618
|
+
context.branches.add(node);
|
|
2619
|
+
return () => {
|
|
2620
|
+
context.branches.delete(node);
|
|
2621
|
+
};
|
|
2622
|
+
}
|
|
2623
|
+
}, [context.branches]);
|
|
2624
|
+
return /* @__PURE__ */ u(Primitive.div, { ...props, ref: composedRefs });
|
|
2625
|
+
});
|
|
2626
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
2627
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
2628
|
+
const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
|
|
2629
|
+
const isPointerInsideReactTreeRef = React__namespace.useRef(false);
|
|
2630
|
+
const handleClickRef = React__namespace.useRef(() => {
|
|
2631
|
+
});
|
|
2632
|
+
React__namespace.useEffect(() => {
|
|
2633
|
+
const handlePointerDown = (event) => {
|
|
2634
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
2635
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
2636
|
+
handleAndDispatchCustomEvent(
|
|
2637
|
+
POINTER_DOWN_OUTSIDE,
|
|
2638
|
+
handlePointerDownOutside,
|
|
2639
|
+
eventDetail,
|
|
2640
|
+
{ discrete: true }
|
|
2641
|
+
);
|
|
2642
|
+
};
|
|
2643
|
+
const eventDetail = { originalEvent: event };
|
|
2644
|
+
if (event.pointerType === "touch") {
|
|
2645
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
2646
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
2647
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
2648
|
+
} else {
|
|
2649
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
2650
|
+
}
|
|
2651
|
+
} else {
|
|
2652
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
2653
|
+
}
|
|
2654
|
+
isPointerInsideReactTreeRef.current = false;
|
|
2655
|
+
};
|
|
2656
|
+
const timerId = window.setTimeout(() => {
|
|
2657
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
2658
|
+
}, 0);
|
|
2659
|
+
return () => {
|
|
2660
|
+
window.clearTimeout(timerId);
|
|
2661
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
2662
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
2663
|
+
};
|
|
2664
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
2665
|
+
return {
|
|
2666
|
+
// ensures we check React component tree (not just DOM tree)
|
|
2667
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
2671
|
+
const handleFocusOutside = useCallbackRef$1(onFocusOutside);
|
|
2672
|
+
const isFocusInsideReactTreeRef = React__namespace.useRef(false);
|
|
2673
|
+
React__namespace.useEffect(() => {
|
|
2674
|
+
const handleFocus = (event) => {
|
|
2675
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
2676
|
+
const eventDetail = { originalEvent: event };
|
|
2677
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
2678
|
+
discrete: false
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2682
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
2683
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
2684
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
2685
|
+
return {
|
|
2686
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
2687
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
2688
|
+
};
|
|
2689
|
+
}
|
|
2690
|
+
function dispatchUpdate() {
|
|
2691
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
2692
|
+
document.dispatchEvent(event);
|
|
2693
|
+
}
|
|
2694
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
2695
|
+
const target = detail.originalEvent.target;
|
|
2696
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
2697
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
2698
|
+
if (discrete) {
|
|
2699
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
2700
|
+
} else {
|
|
2701
|
+
target.dispatchEvent(event);
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
var AUTOFOCUS_ON_MOUNT = "focusScope.autoFocusOnMount";
|
|
2705
|
+
var AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
2706
|
+
var EVENT_OPTIONS = { bubbles: false, cancelable: true };
|
|
2707
|
+
var FOCUS_SCOPE_NAME = "FocusScope";
|
|
2708
|
+
var FocusScope = React__namespace.forwardRef((props, forwardedRef) => {
|
|
2709
|
+
const {
|
|
2710
|
+
loop = false,
|
|
2711
|
+
trapped = false,
|
|
2712
|
+
onMountAutoFocus: onMountAutoFocusProp,
|
|
2713
|
+
onUnmountAutoFocus: onUnmountAutoFocusProp,
|
|
2714
|
+
...scopeProps
|
|
2715
|
+
} = props;
|
|
2716
|
+
const [container, setContainer] = React__namespace.useState(null);
|
|
2717
|
+
const onMountAutoFocus = useCallbackRef$1(onMountAutoFocusProp);
|
|
2718
|
+
const onUnmountAutoFocus = useCallbackRef$1(onUnmountAutoFocusProp);
|
|
2719
|
+
const lastFocusedElementRef = React__namespace.useRef(null);
|
|
2720
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setContainer(node));
|
|
2721
|
+
const focusScope = React__namespace.useRef({
|
|
2722
|
+
paused: false,
|
|
2723
|
+
pause() {
|
|
2724
|
+
this.paused = true;
|
|
2725
|
+
},
|
|
2726
|
+
resume() {
|
|
2727
|
+
this.paused = false;
|
|
2728
|
+
}
|
|
2729
|
+
}).current;
|
|
2730
|
+
React__namespace.useEffect(() => {
|
|
2731
|
+
if (trapped) {
|
|
2732
|
+
let handleFocusIn2 = function(event) {
|
|
2733
|
+
if (focusScope.paused || !container) return;
|
|
2734
|
+
const target = event.target;
|
|
2735
|
+
if (container.contains(target)) {
|
|
2736
|
+
lastFocusedElementRef.current = target;
|
|
2737
|
+
} else {
|
|
2738
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
2739
|
+
}
|
|
2740
|
+
}, handleFocusOut2 = function(event) {
|
|
2741
|
+
if (focusScope.paused || !container) return;
|
|
2742
|
+
const relatedTarget = event.relatedTarget;
|
|
2743
|
+
if (relatedTarget === null) return;
|
|
2744
|
+
if (!container.contains(relatedTarget)) {
|
|
2745
|
+
focus(lastFocusedElementRef.current, { select: true });
|
|
2746
|
+
}
|
|
2747
|
+
}, handleMutations2 = function(mutations) {
|
|
2748
|
+
const focusedElement = document.activeElement;
|
|
2749
|
+
if (focusedElement !== document.body) return;
|
|
2750
|
+
for (const mutation of mutations) {
|
|
2751
|
+
if (mutation.removedNodes.length > 0) focus(container);
|
|
2752
|
+
}
|
|
2753
|
+
};
|
|
2754
|
+
document.addEventListener("focusin", handleFocusIn2);
|
|
2755
|
+
document.addEventListener("focusout", handleFocusOut2);
|
|
2756
|
+
const mutationObserver = new MutationObserver(handleMutations2);
|
|
2757
|
+
if (container) mutationObserver.observe(container, { childList: true, subtree: true });
|
|
2758
|
+
return () => {
|
|
2759
|
+
document.removeEventListener("focusin", handleFocusIn2);
|
|
2760
|
+
document.removeEventListener("focusout", handleFocusOut2);
|
|
2761
|
+
mutationObserver.disconnect();
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
}, [trapped, container, focusScope.paused]);
|
|
2765
|
+
React__namespace.useEffect(() => {
|
|
2766
|
+
if (container) {
|
|
2767
|
+
focusScopesStack.add(focusScope);
|
|
2768
|
+
const previouslyFocusedElement = document.activeElement;
|
|
2769
|
+
const hasFocusedCandidate = container.contains(previouslyFocusedElement);
|
|
2770
|
+
if (!hasFocusedCandidate) {
|
|
2771
|
+
const mountEvent = new CustomEvent(AUTOFOCUS_ON_MOUNT, EVENT_OPTIONS);
|
|
2772
|
+
container.addEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
2773
|
+
container.dispatchEvent(mountEvent);
|
|
2774
|
+
if (!mountEvent.defaultPrevented) {
|
|
2775
|
+
focusFirst(removeLinks(getTabbableCandidates(container)), { select: true });
|
|
2776
|
+
if (document.activeElement === previouslyFocusedElement) {
|
|
2777
|
+
focus(container);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
return () => {
|
|
2782
|
+
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onMountAutoFocus);
|
|
2783
|
+
setTimeout(() => {
|
|
2784
|
+
const unmountEvent = new CustomEvent(AUTOFOCUS_ON_UNMOUNT, EVENT_OPTIONS);
|
|
2785
|
+
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
2786
|
+
container.dispatchEvent(unmountEvent);
|
|
2787
|
+
if (!unmountEvent.defaultPrevented) {
|
|
2788
|
+
focus(previouslyFocusedElement ?? document.body, { select: true });
|
|
2789
|
+
}
|
|
2790
|
+
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, onUnmountAutoFocus);
|
|
2791
|
+
focusScopesStack.remove(focusScope);
|
|
2792
|
+
}, 0);
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
}, [container, onMountAutoFocus, onUnmountAutoFocus, focusScope]);
|
|
2796
|
+
const handleKeyDown = React__namespace.useCallback(
|
|
2797
|
+
(event) => {
|
|
2798
|
+
if (!loop && !trapped) return;
|
|
2799
|
+
if (focusScope.paused) return;
|
|
2800
|
+
const isTabKey = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
2801
|
+
const focusedElement = document.activeElement;
|
|
2802
|
+
if (isTabKey && focusedElement) {
|
|
2803
|
+
const container2 = event.currentTarget;
|
|
2804
|
+
const [first, last] = getTabbableEdges(container2);
|
|
2805
|
+
const hasTabbableElementsInside = first && last;
|
|
2806
|
+
if (!hasTabbableElementsInside) {
|
|
2807
|
+
if (focusedElement === container2) event.preventDefault();
|
|
2808
|
+
} else {
|
|
2809
|
+
if (!event.shiftKey && focusedElement === last) {
|
|
2810
|
+
event.preventDefault();
|
|
2811
|
+
if (loop) focus(first, { select: true });
|
|
2812
|
+
} else if (event.shiftKey && focusedElement === first) {
|
|
2813
|
+
event.preventDefault();
|
|
2814
|
+
if (loop) focus(last, { select: true });
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
},
|
|
2819
|
+
[loop, trapped, focusScope.paused]
|
|
2820
|
+
);
|
|
2821
|
+
return /* @__PURE__ */ u(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
|
|
2822
|
+
});
|
|
2823
|
+
FocusScope.displayName = FOCUS_SCOPE_NAME;
|
|
2824
|
+
function focusFirst(candidates, { select = false } = {}) {
|
|
2825
|
+
const previouslyFocusedElement = document.activeElement;
|
|
2826
|
+
for (const candidate of candidates) {
|
|
2827
|
+
focus(candidate, { select });
|
|
2828
|
+
if (document.activeElement !== previouslyFocusedElement) return;
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
function getTabbableEdges(container) {
|
|
2832
|
+
const candidates = getTabbableCandidates(container);
|
|
2833
|
+
const first = findVisible(candidates, container);
|
|
2834
|
+
const last = findVisible(candidates.reverse(), container);
|
|
2835
|
+
return [first, last];
|
|
2836
|
+
}
|
|
2837
|
+
function getTabbableCandidates(container) {
|
|
2838
|
+
const nodes = [];
|
|
2839
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
2840
|
+
acceptNode: (node) => {
|
|
2841
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
2842
|
+
if (node.disabled || node.hidden || isHiddenInput) return NodeFilter.FILTER_SKIP;
|
|
2843
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
2844
|
+
}
|
|
2845
|
+
});
|
|
2846
|
+
while (walker.nextNode()) nodes.push(walker.currentNode);
|
|
2847
|
+
return nodes;
|
|
2848
|
+
}
|
|
2849
|
+
function findVisible(elements, container) {
|
|
2850
|
+
for (const element of elements) {
|
|
2851
|
+
if (!isHidden(element, { upTo: container })) return element;
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
function isHidden(node, { upTo }) {
|
|
2855
|
+
if (getComputedStyle(node).visibility === "hidden") return true;
|
|
2856
|
+
while (node) {
|
|
2857
|
+
if (upTo !== void 0 && node === upTo) return false;
|
|
2858
|
+
if (getComputedStyle(node).display === "none") return true;
|
|
2859
|
+
node = node.parentElement;
|
|
2860
|
+
}
|
|
2861
|
+
return false;
|
|
2862
|
+
}
|
|
2863
|
+
function isSelectableInput(element) {
|
|
2864
|
+
return element instanceof HTMLInputElement && "select" in element;
|
|
2865
|
+
}
|
|
2866
|
+
function focus(element, { select = false } = {}) {
|
|
2867
|
+
if (element && element.focus) {
|
|
2868
|
+
const previouslyFocusedElement = document.activeElement;
|
|
2869
|
+
element.focus({ preventScroll: true });
|
|
2870
|
+
if (element !== previouslyFocusedElement && isSelectableInput(element) && select)
|
|
2871
|
+
element.select();
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
var focusScopesStack = createFocusScopesStack();
|
|
2875
|
+
function createFocusScopesStack() {
|
|
2876
|
+
let stack = [];
|
|
2877
|
+
return {
|
|
2878
|
+
add(focusScope) {
|
|
2879
|
+
const activeFocusScope = stack[0];
|
|
2880
|
+
if (focusScope !== activeFocusScope) {
|
|
2881
|
+
activeFocusScope?.pause();
|
|
2882
|
+
}
|
|
2883
|
+
stack = arrayRemove(stack, focusScope);
|
|
2884
|
+
stack.unshift(focusScope);
|
|
2885
|
+
},
|
|
2886
|
+
remove(focusScope) {
|
|
2887
|
+
stack = arrayRemove(stack, focusScope);
|
|
2888
|
+
stack[0]?.resume();
|
|
2889
|
+
}
|
|
2890
|
+
};
|
|
2891
|
+
}
|
|
2892
|
+
function arrayRemove(array, item) {
|
|
2893
|
+
const updatedArray = [...array];
|
|
2894
|
+
const index = updatedArray.indexOf(item);
|
|
2895
|
+
if (index !== -1) {
|
|
2896
|
+
updatedArray.splice(index, 1);
|
|
2897
|
+
}
|
|
2898
|
+
return updatedArray;
|
|
2899
|
+
}
|
|
2900
|
+
function removeLinks(items) {
|
|
2901
|
+
return items.filter((item) => item.tagName !== "A");
|
|
2902
|
+
}
|
|
2903
|
+
var count = 0;
|
|
2904
|
+
function useFocusGuards() {
|
|
2905
|
+
React__namespace.useEffect(() => {
|
|
2906
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
2907
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
2908
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
2909
|
+
count++;
|
|
2910
|
+
return () => {
|
|
2911
|
+
if (count === 1) {
|
|
2912
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
2913
|
+
}
|
|
2914
|
+
count--;
|
|
2915
|
+
};
|
|
2916
|
+
}, []);
|
|
2917
|
+
}
|
|
2918
|
+
function createFocusGuard() {
|
|
2919
|
+
const element = document.createElement("span");
|
|
2920
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
2921
|
+
element.tabIndex = 0;
|
|
2922
|
+
element.style.outline = "none";
|
|
2923
|
+
element.style.opacity = "0";
|
|
2924
|
+
element.style.position = "fixed";
|
|
2925
|
+
element.style.pointerEvents = "none";
|
|
2926
|
+
return element;
|
|
2927
|
+
}
|
|
2928
|
+
var __assign = function() {
|
|
2929
|
+
__assign = Object.assign || function __assign2(t) {
|
|
2930
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2931
|
+
s = arguments[i];
|
|
2932
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2933
|
+
}
|
|
2934
|
+
return t;
|
|
2935
|
+
};
|
|
2936
|
+
return __assign.apply(this, arguments);
|
|
2937
|
+
};
|
|
2938
|
+
function __rest(s, e) {
|
|
2939
|
+
var t = {};
|
|
2940
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2941
|
+
t[p] = s[p];
|
|
2942
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2943
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2944
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2945
|
+
t[p[i]] = s[p[i]];
|
|
2946
|
+
}
|
|
2947
|
+
return t;
|
|
2948
|
+
}
|
|
2949
|
+
function __spreadArray(to, from, pack) {
|
|
2950
|
+
if (pack || arguments.length === 2) for (var i = 0, l2 = from.length, ar; i < l2; i++) {
|
|
2951
|
+
if (ar || !(i in from)) {
|
|
2952
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
2953
|
+
ar[i] = from[i];
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2957
|
+
}
|
|
2958
|
+
var zeroRightClassName = "right-scroll-bar-position";
|
|
2959
|
+
var fullWidthClassName = "width-before-scroll-bar";
|
|
2960
|
+
var noScrollbarsClassName = "with-scroll-bars-hidden";
|
|
2961
|
+
var removedBarSizeVariable = "--removed-body-scroll-bar-size";
|
|
2962
|
+
function assignRef(ref, value) {
|
|
2963
|
+
if (typeof ref === "function") {
|
|
2964
|
+
ref(value);
|
|
2965
|
+
} else if (ref) {
|
|
2966
|
+
ref.current = value;
|
|
2967
|
+
}
|
|
2968
|
+
return ref;
|
|
2969
|
+
}
|
|
2970
|
+
function useCallbackRef(initialValue, callback) {
|
|
2971
|
+
var ref = React.useState(function() {
|
|
2972
|
+
return {
|
|
2973
|
+
// value
|
|
2974
|
+
value: initialValue,
|
|
2975
|
+
// last callback
|
|
2976
|
+
callback,
|
|
2977
|
+
// "memoized" public interface
|
|
2978
|
+
facade: {
|
|
2979
|
+
get current() {
|
|
2980
|
+
return ref.value;
|
|
2981
|
+
},
|
|
2982
|
+
set current(value) {
|
|
2983
|
+
var last = ref.value;
|
|
2984
|
+
if (last !== value) {
|
|
2985
|
+
ref.value = value;
|
|
2986
|
+
ref.callback(value, last);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2991
|
+
})[0];
|
|
2992
|
+
ref.callback = callback;
|
|
2993
|
+
return ref.facade;
|
|
2994
|
+
}
|
|
2995
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
2996
|
+
var currentValues = /* @__PURE__ */ new WeakMap();
|
|
2997
|
+
function useMergeRefs(refs, defaultValue) {
|
|
2998
|
+
var callbackRef = useCallbackRef(null, function(newValue) {
|
|
2999
|
+
return refs.forEach(function(ref) {
|
|
3000
|
+
return assignRef(ref, newValue);
|
|
3001
|
+
});
|
|
3002
|
+
});
|
|
3003
|
+
useIsomorphicLayoutEffect(function() {
|
|
3004
|
+
var oldValue = currentValues.get(callbackRef);
|
|
3005
|
+
if (oldValue) {
|
|
3006
|
+
var prevRefs_1 = new Set(oldValue);
|
|
3007
|
+
var nextRefs_1 = new Set(refs);
|
|
3008
|
+
var current_1 = callbackRef.current;
|
|
3009
|
+
prevRefs_1.forEach(function(ref) {
|
|
3010
|
+
if (!nextRefs_1.has(ref)) {
|
|
3011
|
+
assignRef(ref, null);
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3014
|
+
nextRefs_1.forEach(function(ref) {
|
|
3015
|
+
if (!prevRefs_1.has(ref)) {
|
|
3016
|
+
assignRef(ref, current_1);
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
}
|
|
3020
|
+
currentValues.set(callbackRef, refs);
|
|
3021
|
+
}, [refs]);
|
|
3022
|
+
return callbackRef;
|
|
3023
|
+
}
|
|
3024
|
+
function ItoI(a) {
|
|
3025
|
+
return a;
|
|
3026
|
+
}
|
|
3027
|
+
function innerCreateMedium(defaults, middleware) {
|
|
3028
|
+
if (middleware === void 0) {
|
|
3029
|
+
middleware = ItoI;
|
|
3030
|
+
}
|
|
3031
|
+
var buffer = [];
|
|
3032
|
+
var assigned = false;
|
|
3033
|
+
var medium = {
|
|
3034
|
+
read: function() {
|
|
3035
|
+
if (assigned) {
|
|
3036
|
+
throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");
|
|
3037
|
+
}
|
|
3038
|
+
if (buffer.length) {
|
|
3039
|
+
return buffer[buffer.length - 1];
|
|
3040
|
+
}
|
|
3041
|
+
return defaults;
|
|
3042
|
+
},
|
|
3043
|
+
useMedium: function(data) {
|
|
3044
|
+
var item = middleware(data, assigned);
|
|
3045
|
+
buffer.push(item);
|
|
3046
|
+
return function() {
|
|
3047
|
+
buffer = buffer.filter(function(x) {
|
|
3048
|
+
return x !== item;
|
|
3049
|
+
});
|
|
3050
|
+
};
|
|
3051
|
+
},
|
|
3052
|
+
assignSyncMedium: function(cb) {
|
|
3053
|
+
assigned = true;
|
|
3054
|
+
while (buffer.length) {
|
|
3055
|
+
var cbs = buffer;
|
|
3056
|
+
buffer = [];
|
|
3057
|
+
cbs.forEach(cb);
|
|
3058
|
+
}
|
|
3059
|
+
buffer = {
|
|
3060
|
+
push: function(x) {
|
|
3061
|
+
return cb(x);
|
|
3062
|
+
},
|
|
3063
|
+
filter: function() {
|
|
3064
|
+
return buffer;
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
},
|
|
3068
|
+
assignMedium: function(cb) {
|
|
3069
|
+
assigned = true;
|
|
3070
|
+
var pendingQueue = [];
|
|
3071
|
+
if (buffer.length) {
|
|
3072
|
+
var cbs = buffer;
|
|
3073
|
+
buffer = [];
|
|
3074
|
+
cbs.forEach(cb);
|
|
3075
|
+
pendingQueue = buffer;
|
|
3076
|
+
}
|
|
3077
|
+
var executeQueue = function() {
|
|
3078
|
+
var cbs2 = pendingQueue;
|
|
3079
|
+
pendingQueue = [];
|
|
3080
|
+
cbs2.forEach(cb);
|
|
3081
|
+
};
|
|
3082
|
+
var cycle = function() {
|
|
3083
|
+
return Promise.resolve().then(executeQueue);
|
|
3084
|
+
};
|
|
3085
|
+
cycle();
|
|
3086
|
+
buffer = {
|
|
3087
|
+
push: function(x) {
|
|
3088
|
+
pendingQueue.push(x);
|
|
3089
|
+
cycle();
|
|
3090
|
+
},
|
|
3091
|
+
filter: function(filter) {
|
|
3092
|
+
pendingQueue = pendingQueue.filter(filter);
|
|
3093
|
+
return buffer;
|
|
3094
|
+
}
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
};
|
|
3098
|
+
return medium;
|
|
3099
|
+
}
|
|
3100
|
+
function createSidecarMedium(options) {
|
|
3101
|
+
if (options === void 0) {
|
|
3102
|
+
options = {};
|
|
3103
|
+
}
|
|
3104
|
+
var medium = innerCreateMedium(null);
|
|
3105
|
+
medium.options = __assign({ async: true, ssr: false }, options);
|
|
3106
|
+
return medium;
|
|
3107
|
+
}
|
|
3108
|
+
var SideCar$1 = function(_a) {
|
|
3109
|
+
var sideCar = _a.sideCar, rest = __rest(_a, ["sideCar"]);
|
|
3110
|
+
if (!sideCar) {
|
|
3111
|
+
throw new Error("Sidecar: please provide `sideCar` property to import the right car");
|
|
3112
|
+
}
|
|
3113
|
+
var Target = sideCar.read();
|
|
3114
|
+
if (!Target) {
|
|
3115
|
+
throw new Error("Sidecar medium not found");
|
|
3116
|
+
}
|
|
3117
|
+
return React__namespace.createElement(Target, __assign({}, rest));
|
|
3118
|
+
};
|
|
3119
|
+
SideCar$1.isSideCarExport = true;
|
|
3120
|
+
function exportSidecar(medium, exported) {
|
|
3121
|
+
medium.useMedium(exported);
|
|
3122
|
+
return SideCar$1;
|
|
3123
|
+
}
|
|
3124
|
+
var effectCar = createSidecarMedium();
|
|
3125
|
+
var nothing = function() {
|
|
3126
|
+
return;
|
|
3127
|
+
};
|
|
3128
|
+
var RemoveScroll = React__namespace.forwardRef(function(props, parentRef) {
|
|
3129
|
+
var ref = React__namespace.useRef(null);
|
|
3130
|
+
var _a = React__namespace.useState({
|
|
3131
|
+
onScrollCapture: nothing,
|
|
3132
|
+
onWheelCapture: nothing,
|
|
3133
|
+
onTouchMoveCapture: nothing
|
|
3134
|
+
}), callbacks = _a[0], setCallbacks = _a[1];
|
|
3135
|
+
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noRelative = props.noRelative, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? "div" : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
|
3136
|
+
var SideCar2 = sideCar;
|
|
3137
|
+
var containerRef = useMergeRefs([ref, parentRef]);
|
|
3138
|
+
var containerProps = __assign(__assign({}, rest), callbacks);
|
|
3139
|
+
return React__namespace.createElement(
|
|
3140
|
+
React__namespace.Fragment,
|
|
3141
|
+
null,
|
|
3142
|
+
enabled && React__namespace.createElement(SideCar2, { sideCar: effectCar, removeScrollBar, shards, noRelative, noIsolation, inert, setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode }),
|
|
3143
|
+
forwardProps ? React__namespace.cloneElement(React__namespace.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef })) : React__namespace.createElement(Container, __assign({}, containerProps, { className, ref: containerRef }), children)
|
|
3144
|
+
);
|
|
3145
|
+
});
|
|
3146
|
+
RemoveScroll.defaultProps = {
|
|
3147
|
+
enabled: true,
|
|
3148
|
+
removeScrollBar: true,
|
|
3149
|
+
inert: false
|
|
3150
|
+
};
|
|
3151
|
+
RemoveScroll.classNames = {
|
|
3152
|
+
fullWidth: fullWidthClassName,
|
|
3153
|
+
zeroRight: zeroRightClassName
|
|
3154
|
+
};
|
|
3155
|
+
var getNonce = function() {
|
|
3156
|
+
if (typeof __webpack_nonce__ !== "undefined") {
|
|
3157
|
+
return __webpack_nonce__;
|
|
3158
|
+
}
|
|
3159
|
+
return void 0;
|
|
3160
|
+
};
|
|
3161
|
+
function makeStyleTag() {
|
|
3162
|
+
if (!document)
|
|
3163
|
+
return null;
|
|
3164
|
+
var tag = document.createElement("style");
|
|
3165
|
+
tag.type = "text/css";
|
|
3166
|
+
var nonce = getNonce();
|
|
3167
|
+
if (nonce) {
|
|
3168
|
+
tag.setAttribute("nonce", nonce);
|
|
3169
|
+
}
|
|
3170
|
+
return tag;
|
|
3171
|
+
}
|
|
3172
|
+
function injectStyles(tag, css) {
|
|
3173
|
+
if (tag.styleSheet) {
|
|
3174
|
+
tag.styleSheet.cssText = css;
|
|
3175
|
+
} else {
|
|
3176
|
+
tag.appendChild(document.createTextNode(css));
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
function insertStyleTag(tag) {
|
|
3180
|
+
var head = document.head || document.getElementsByTagName("head")[0];
|
|
3181
|
+
head.appendChild(tag);
|
|
3182
|
+
}
|
|
3183
|
+
var stylesheetSingleton = function() {
|
|
3184
|
+
var counter = 0;
|
|
3185
|
+
var stylesheet = null;
|
|
3186
|
+
return {
|
|
3187
|
+
add: function(style) {
|
|
3188
|
+
if (counter == 0) {
|
|
3189
|
+
if (stylesheet = makeStyleTag()) {
|
|
3190
|
+
injectStyles(stylesheet, style);
|
|
3191
|
+
insertStyleTag(stylesheet);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
counter++;
|
|
3195
|
+
},
|
|
3196
|
+
remove: function() {
|
|
3197
|
+
counter--;
|
|
3198
|
+
if (!counter && stylesheet) {
|
|
3199
|
+
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
|
|
3200
|
+
stylesheet = null;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
};
|
|
3204
|
+
};
|
|
3205
|
+
var styleHookSingleton = function() {
|
|
3206
|
+
var sheet = stylesheetSingleton();
|
|
3207
|
+
return function(styles, isDynamic) {
|
|
3208
|
+
React__namespace.useEffect(function() {
|
|
3209
|
+
sheet.add(styles);
|
|
3210
|
+
return function() {
|
|
3211
|
+
sheet.remove();
|
|
3212
|
+
};
|
|
3213
|
+
}, [styles && isDynamic]);
|
|
3214
|
+
};
|
|
3215
|
+
};
|
|
3216
|
+
var styleSingleton = function() {
|
|
3217
|
+
var useStyle = styleHookSingleton();
|
|
3218
|
+
var Sheet = function(_a) {
|
|
3219
|
+
var styles = _a.styles, dynamic = _a.dynamic;
|
|
3220
|
+
useStyle(styles, dynamic);
|
|
3221
|
+
return null;
|
|
3222
|
+
};
|
|
3223
|
+
return Sheet;
|
|
3224
|
+
};
|
|
3225
|
+
var zeroGap = {
|
|
3226
|
+
left: 0,
|
|
3227
|
+
top: 0,
|
|
3228
|
+
right: 0,
|
|
3229
|
+
gap: 0
|
|
3230
|
+
};
|
|
3231
|
+
var parse = function(x) {
|
|
3232
|
+
return parseInt(x || "", 10) || 0;
|
|
3233
|
+
};
|
|
3234
|
+
var getOffset = function(gapMode) {
|
|
3235
|
+
var cs = window.getComputedStyle(document.body);
|
|
3236
|
+
var left = cs[gapMode === "padding" ? "paddingLeft" : "marginLeft"];
|
|
3237
|
+
var top = cs[gapMode === "padding" ? "paddingTop" : "marginTop"];
|
|
3238
|
+
var right = cs[gapMode === "padding" ? "paddingRight" : "marginRight"];
|
|
3239
|
+
return [parse(left), parse(top), parse(right)];
|
|
3240
|
+
};
|
|
3241
|
+
var getGapWidth = function(gapMode) {
|
|
3242
|
+
if (gapMode === void 0) {
|
|
3243
|
+
gapMode = "margin";
|
|
3244
|
+
}
|
|
3245
|
+
if (typeof window === "undefined") {
|
|
3246
|
+
return zeroGap;
|
|
3247
|
+
}
|
|
3248
|
+
var offsets = getOffset(gapMode);
|
|
3249
|
+
var documentWidth = document.documentElement.clientWidth;
|
|
3250
|
+
var windowWidth = window.innerWidth;
|
|
3251
|
+
return {
|
|
3252
|
+
left: offsets[0],
|
|
3253
|
+
top: offsets[1],
|
|
3254
|
+
right: offsets[2],
|
|
3255
|
+
gap: Math.max(0, windowWidth - documentWidth + offsets[2] - offsets[0])
|
|
3256
|
+
};
|
|
3257
|
+
};
|
|
3258
|
+
var Style = styleSingleton();
|
|
3259
|
+
var lockAttribute = "data-scroll-locked";
|
|
3260
|
+
var getStyles = function(_a, allowRelative, gapMode, important) {
|
|
3261
|
+
var left = _a.left, top = _a.top, right = _a.right, gap = _a.gap;
|
|
3262
|
+
if (gapMode === void 0) {
|
|
3263
|
+
gapMode = "margin";
|
|
3264
|
+
}
|
|
3265
|
+
return "\n .".concat(noScrollbarsClassName, " {\n overflow: hidden ").concat(important, ";\n padding-right: ").concat(gap, "px ").concat(important, ";\n }\n body[").concat(lockAttribute, "] {\n overflow: hidden ").concat(important, ";\n overscroll-behavior: contain;\n ").concat([
|
|
3266
|
+
allowRelative && "position: relative ".concat(important, ";"),
|
|
3267
|
+
gapMode === "margin" && "\n padding-left: ".concat(left, "px;\n padding-top: ").concat(top, "px;\n padding-right: ").concat(right, "px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(gap, "px ").concat(important, ";\n "),
|
|
3268
|
+
gapMode === "padding" && "padding-right: ".concat(gap, "px ").concat(important, ";")
|
|
3269
|
+
].filter(Boolean).join(""), "\n }\n \n .").concat(zeroRightClassName, " {\n right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " {\n margin-right: ").concat(gap, "px ").concat(important, ";\n }\n \n .").concat(zeroRightClassName, " .").concat(zeroRightClassName, " {\n right: 0 ").concat(important, ";\n }\n \n .").concat(fullWidthClassName, " .").concat(fullWidthClassName, " {\n margin-right: 0 ").concat(important, ";\n }\n \n body[").concat(lockAttribute, "] {\n ").concat(removedBarSizeVariable, ": ").concat(gap, "px;\n }\n");
|
|
3270
|
+
};
|
|
3271
|
+
var getCurrentUseCounter = function() {
|
|
3272
|
+
var counter = parseInt(document.body.getAttribute(lockAttribute) || "0", 10);
|
|
3273
|
+
return isFinite(counter) ? counter : 0;
|
|
3274
|
+
};
|
|
3275
|
+
var useLockAttribute = function() {
|
|
3276
|
+
React__namespace.useEffect(function() {
|
|
3277
|
+
document.body.setAttribute(lockAttribute, (getCurrentUseCounter() + 1).toString());
|
|
3278
|
+
return function() {
|
|
3279
|
+
var newCounter = getCurrentUseCounter() - 1;
|
|
3280
|
+
if (newCounter <= 0) {
|
|
3281
|
+
document.body.removeAttribute(lockAttribute);
|
|
3282
|
+
} else {
|
|
3283
|
+
document.body.setAttribute(lockAttribute, newCounter.toString());
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
}, []);
|
|
3287
|
+
};
|
|
3288
|
+
var RemoveScrollBar = function(_a) {
|
|
3289
|
+
var noRelative = _a.noRelative, noImportant = _a.noImportant, _b = _a.gapMode, gapMode = _b === void 0 ? "margin" : _b;
|
|
3290
|
+
useLockAttribute();
|
|
3291
|
+
var gap = React__namespace.useMemo(function() {
|
|
3292
|
+
return getGapWidth(gapMode);
|
|
3293
|
+
}, [gapMode]);
|
|
3294
|
+
return React__namespace.createElement(Style, { styles: getStyles(gap, !noRelative, gapMode, !noImportant ? "!important" : "") });
|
|
3295
|
+
};
|
|
3296
|
+
var passiveSupported = false;
|
|
3297
|
+
if (typeof window !== "undefined") {
|
|
3298
|
+
try {
|
|
3299
|
+
var options = Object.defineProperty({}, "passive", {
|
|
3300
|
+
get: function() {
|
|
3301
|
+
passiveSupported = true;
|
|
3302
|
+
return true;
|
|
3303
|
+
}
|
|
3304
|
+
});
|
|
3305
|
+
window.addEventListener("test", options, options);
|
|
3306
|
+
window.removeEventListener("test", options, options);
|
|
3307
|
+
} catch (err) {
|
|
3308
|
+
passiveSupported = false;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
var nonPassive = passiveSupported ? { passive: false } : false;
|
|
3312
|
+
var alwaysContainsScroll = function(node) {
|
|
3313
|
+
return node.tagName === "TEXTAREA";
|
|
3314
|
+
};
|
|
3315
|
+
var elementCanBeScrolled = function(node, overflow) {
|
|
3316
|
+
if (!(node instanceof Element)) {
|
|
3317
|
+
return false;
|
|
3318
|
+
}
|
|
3319
|
+
var styles = window.getComputedStyle(node);
|
|
3320
|
+
return (
|
|
3321
|
+
// not-not-scrollable
|
|
3322
|
+
styles[overflow] !== "hidden" && // contains scroll inside self
|
|
3323
|
+
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === "visible")
|
|
3324
|
+
);
|
|
3325
|
+
};
|
|
3326
|
+
var elementCouldBeVScrolled = function(node) {
|
|
3327
|
+
return elementCanBeScrolled(node, "overflowY");
|
|
3328
|
+
};
|
|
3329
|
+
var elementCouldBeHScrolled = function(node) {
|
|
3330
|
+
return elementCanBeScrolled(node, "overflowX");
|
|
3331
|
+
};
|
|
3332
|
+
var locationCouldBeScrolled = function(axis, node) {
|
|
3333
|
+
var ownerDocument = node.ownerDocument;
|
|
3334
|
+
var current = node;
|
|
3335
|
+
do {
|
|
3336
|
+
if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
|
|
3337
|
+
current = current.host;
|
|
3338
|
+
}
|
|
3339
|
+
var isScrollable = elementCouldBeScrolled(axis, current);
|
|
3340
|
+
if (isScrollable) {
|
|
3341
|
+
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
|
3342
|
+
if (scrollHeight > clientHeight) {
|
|
3343
|
+
return true;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
current = current.parentNode;
|
|
3347
|
+
} while (current && current !== ownerDocument.body);
|
|
3348
|
+
return false;
|
|
3349
|
+
};
|
|
3350
|
+
var getVScrollVariables = function(_a) {
|
|
3351
|
+
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
3352
|
+
return [
|
|
3353
|
+
scrollTop,
|
|
3354
|
+
scrollHeight,
|
|
3355
|
+
clientHeight
|
|
3356
|
+
];
|
|
3357
|
+
};
|
|
3358
|
+
var getHScrollVariables = function(_a) {
|
|
3359
|
+
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
|
3360
|
+
return [
|
|
3361
|
+
scrollLeft,
|
|
3362
|
+
scrollWidth,
|
|
3363
|
+
clientWidth
|
|
3364
|
+
];
|
|
3365
|
+
};
|
|
3366
|
+
var elementCouldBeScrolled = function(axis, node) {
|
|
3367
|
+
return axis === "v" ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
|
3368
|
+
};
|
|
3369
|
+
var getScrollVariables = function(axis, node) {
|
|
3370
|
+
return axis === "v" ? getVScrollVariables(node) : getHScrollVariables(node);
|
|
3371
|
+
};
|
|
3372
|
+
var getDirectionFactor = function(axis, direction) {
|
|
3373
|
+
return axis === "h" && direction === "rtl" ? -1 : 1;
|
|
3374
|
+
};
|
|
3375
|
+
var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
|
|
3376
|
+
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
|
3377
|
+
var delta = directionFactor * sourceDelta;
|
|
3378
|
+
var target = event.target;
|
|
3379
|
+
var targetInLock = endTarget.contains(target);
|
|
3380
|
+
var shouldCancelScroll = false;
|
|
3381
|
+
var isDeltaPositive = delta > 0;
|
|
3382
|
+
var availableScroll = 0;
|
|
3383
|
+
var availableScrollTop = 0;
|
|
3384
|
+
do {
|
|
3385
|
+
if (!target) {
|
|
3386
|
+
break;
|
|
3387
|
+
}
|
|
3388
|
+
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
|
3389
|
+
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
|
3390
|
+
if (position || elementScroll) {
|
|
3391
|
+
if (elementCouldBeScrolled(axis, target)) {
|
|
3392
|
+
availableScroll += elementScroll;
|
|
3393
|
+
availableScrollTop += position;
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
var parent_1 = target.parentNode;
|
|
3397
|
+
target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
|
|
3398
|
+
} while (
|
|
3399
|
+
// portaled content
|
|
3400
|
+
!targetInLock && target !== document.body || // self content
|
|
3401
|
+
targetInLock && (endTarget.contains(target) || endTarget === target)
|
|
3402
|
+
);
|
|
3403
|
+
if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
|
|
3404
|
+
shouldCancelScroll = true;
|
|
3405
|
+
} else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
|
|
3406
|
+
shouldCancelScroll = true;
|
|
3407
|
+
}
|
|
3408
|
+
return shouldCancelScroll;
|
|
3409
|
+
};
|
|
3410
|
+
var getTouchXY = function(event) {
|
|
3411
|
+
return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
|
3412
|
+
};
|
|
3413
|
+
var getDeltaXY = function(event) {
|
|
3414
|
+
return [event.deltaX, event.deltaY];
|
|
3415
|
+
};
|
|
3416
|
+
var extractRef = function(ref) {
|
|
3417
|
+
return ref && "current" in ref ? ref.current : ref;
|
|
3418
|
+
};
|
|
3419
|
+
var deltaCompare = function(x, y) {
|
|
3420
|
+
return x[0] === y[0] && x[1] === y[1];
|
|
3421
|
+
};
|
|
3422
|
+
var generateStyle = function(id) {
|
|
3423
|
+
return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
|
|
3424
|
+
};
|
|
3425
|
+
var idCounter = 0;
|
|
3426
|
+
var lockStack = [];
|
|
3427
|
+
function RemoveScrollSideCar(props) {
|
|
3428
|
+
var shouldPreventQueue = React__namespace.useRef([]);
|
|
3429
|
+
var touchStartRef = React__namespace.useRef([0, 0]);
|
|
3430
|
+
var activeAxis = React__namespace.useRef();
|
|
3431
|
+
var id = React__namespace.useState(idCounter++)[0];
|
|
3432
|
+
var Style2 = React__namespace.useState(styleSingleton)[0];
|
|
3433
|
+
var lastProps = React__namespace.useRef(props);
|
|
3434
|
+
React__namespace.useEffect(function() {
|
|
3435
|
+
lastProps.current = props;
|
|
3436
|
+
}, [props]);
|
|
3437
|
+
React__namespace.useEffect(function() {
|
|
3438
|
+
if (props.inert) {
|
|
3439
|
+
document.body.classList.add("block-interactivity-".concat(id));
|
|
3440
|
+
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
|
3441
|
+
allow_1.forEach(function(el) {
|
|
3442
|
+
return el.classList.add("allow-interactivity-".concat(id));
|
|
3443
|
+
});
|
|
3444
|
+
return function() {
|
|
3445
|
+
document.body.classList.remove("block-interactivity-".concat(id));
|
|
3446
|
+
allow_1.forEach(function(el) {
|
|
3447
|
+
return el.classList.remove("allow-interactivity-".concat(id));
|
|
3448
|
+
});
|
|
3449
|
+
};
|
|
3450
|
+
}
|
|
3451
|
+
return;
|
|
3452
|
+
}, [props.inert, props.lockRef.current, props.shards]);
|
|
3453
|
+
var shouldCancelEvent = React__namespace.useCallback(function(event, parent) {
|
|
3454
|
+
if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
|
|
3455
|
+
return !lastProps.current.allowPinchZoom;
|
|
3456
|
+
}
|
|
3457
|
+
var touch = getTouchXY(event);
|
|
3458
|
+
var touchStart = touchStartRef.current;
|
|
3459
|
+
var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
|
|
3460
|
+
var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
|
|
3461
|
+
var currentAxis;
|
|
3462
|
+
var target = event.target;
|
|
3463
|
+
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
|
|
3464
|
+
if ("touches" in event && moveDirection === "h" && target.type === "range") {
|
|
3465
|
+
return false;
|
|
3466
|
+
}
|
|
3467
|
+
var selection = window.getSelection();
|
|
3468
|
+
var anchorNode = selection && selection.anchorNode;
|
|
3469
|
+
var isTouchingSelection = anchorNode ? anchorNode === target || anchorNode.contains(target) : false;
|
|
3470
|
+
if (isTouchingSelection) {
|
|
3471
|
+
return false;
|
|
3472
|
+
}
|
|
3473
|
+
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
3474
|
+
if (!canBeScrolledInMainDirection) {
|
|
3475
|
+
return true;
|
|
3476
|
+
}
|
|
3477
|
+
if (canBeScrolledInMainDirection) {
|
|
3478
|
+
currentAxis = moveDirection;
|
|
3479
|
+
} else {
|
|
3480
|
+
currentAxis = moveDirection === "v" ? "h" : "v";
|
|
3481
|
+
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
|
3482
|
+
}
|
|
3483
|
+
if (!canBeScrolledInMainDirection) {
|
|
3484
|
+
return false;
|
|
3485
|
+
}
|
|
3486
|
+
if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
|
|
3487
|
+
activeAxis.current = currentAxis;
|
|
3488
|
+
}
|
|
3489
|
+
if (!currentAxis) {
|
|
3490
|
+
return true;
|
|
3491
|
+
}
|
|
3492
|
+
var cancelingAxis = activeAxis.current || currentAxis;
|
|
3493
|
+
return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
|
|
3494
|
+
}, []);
|
|
3495
|
+
var shouldPrevent = React__namespace.useCallback(function(_event) {
|
|
3496
|
+
var event = _event;
|
|
3497
|
+
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style2) {
|
|
3498
|
+
return;
|
|
3499
|
+
}
|
|
3500
|
+
var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
|
|
3501
|
+
var sourceEvent = shouldPreventQueue.current.filter(function(e) {
|
|
3502
|
+
return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
|
|
3503
|
+
})[0];
|
|
3504
|
+
if (sourceEvent && sourceEvent.should) {
|
|
3505
|
+
if (event.cancelable) {
|
|
3506
|
+
event.preventDefault();
|
|
3507
|
+
}
|
|
3508
|
+
return;
|
|
3509
|
+
}
|
|
3510
|
+
if (!sourceEvent) {
|
|
3511
|
+
var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
|
|
3512
|
+
return node.contains(event.target);
|
|
3513
|
+
});
|
|
3514
|
+
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
|
3515
|
+
if (shouldStop) {
|
|
3516
|
+
if (event.cancelable) {
|
|
3517
|
+
event.preventDefault();
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
}, []);
|
|
3522
|
+
var shouldCancel = React__namespace.useCallback(function(name, delta, target, should) {
|
|
3523
|
+
var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
|
3524
|
+
shouldPreventQueue.current.push(event);
|
|
3525
|
+
setTimeout(function() {
|
|
3526
|
+
shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
|
|
3527
|
+
return e !== event;
|
|
3528
|
+
});
|
|
3529
|
+
}, 1);
|
|
3530
|
+
}, []);
|
|
3531
|
+
var scrollTouchStart = React__namespace.useCallback(function(event) {
|
|
3532
|
+
touchStartRef.current = getTouchXY(event);
|
|
3533
|
+
activeAxis.current = void 0;
|
|
3534
|
+
}, []);
|
|
3535
|
+
var scrollWheel = React__namespace.useCallback(function(event) {
|
|
3536
|
+
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
3537
|
+
}, []);
|
|
3538
|
+
var scrollTouchMove = React__namespace.useCallback(function(event) {
|
|
3539
|
+
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
|
3540
|
+
}, []);
|
|
3541
|
+
React__namespace.useEffect(function() {
|
|
3542
|
+
lockStack.push(Style2);
|
|
3543
|
+
props.setCallbacks({
|
|
3544
|
+
onScrollCapture: scrollWheel,
|
|
3545
|
+
onWheelCapture: scrollWheel,
|
|
3546
|
+
onTouchMoveCapture: scrollTouchMove
|
|
3547
|
+
});
|
|
3548
|
+
document.addEventListener("wheel", shouldPrevent, nonPassive);
|
|
3549
|
+
document.addEventListener("touchmove", shouldPrevent, nonPassive);
|
|
3550
|
+
document.addEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
3551
|
+
return function() {
|
|
3552
|
+
lockStack = lockStack.filter(function(inst) {
|
|
3553
|
+
return inst !== Style2;
|
|
3554
|
+
});
|
|
3555
|
+
document.removeEventListener("wheel", shouldPrevent, nonPassive);
|
|
3556
|
+
document.removeEventListener("touchmove", shouldPrevent, nonPassive);
|
|
3557
|
+
document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
|
|
3558
|
+
};
|
|
3559
|
+
}, []);
|
|
3560
|
+
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
|
3561
|
+
return React__namespace.createElement(
|
|
3562
|
+
React__namespace.Fragment,
|
|
3563
|
+
null,
|
|
3564
|
+
inert ? React__namespace.createElement(Style2, { styles: generateStyle(id) }) : null,
|
|
3565
|
+
removeScrollBar ? React__namespace.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
|
|
3566
|
+
);
|
|
3567
|
+
}
|
|
3568
|
+
function getOutermostShadowParent(node) {
|
|
3569
|
+
var shadowParent = null;
|
|
3570
|
+
while (node !== null) {
|
|
3571
|
+
if (node instanceof ShadowRoot) {
|
|
3572
|
+
shadowParent = node.host;
|
|
3573
|
+
node = node.host;
|
|
3574
|
+
}
|
|
3575
|
+
node = node.parentNode;
|
|
3576
|
+
}
|
|
3577
|
+
return shadowParent;
|
|
3578
|
+
}
|
|
3579
|
+
const SideCar = exportSidecar(effectCar, RemoveScrollSideCar);
|
|
3580
|
+
var ReactRemoveScroll = React__namespace.forwardRef(function(props, ref) {
|
|
3581
|
+
return React__namespace.createElement(RemoveScroll, __assign({}, props, { ref, sideCar: SideCar }));
|
|
3582
|
+
});
|
|
3583
|
+
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
|
3584
|
+
var getDefaultParent = function(originalTarget) {
|
|
3585
|
+
if (typeof document === "undefined") {
|
|
3586
|
+
return null;
|
|
3587
|
+
}
|
|
3588
|
+
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
3589
|
+
return sampleTarget.ownerDocument.body;
|
|
3590
|
+
};
|
|
3591
|
+
var counterMap = /* @__PURE__ */ new WeakMap();
|
|
3592
|
+
var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
3593
|
+
var markerMap = {};
|
|
3594
|
+
var lockCount = 0;
|
|
3595
|
+
var unwrapHost = function(node) {
|
|
3596
|
+
return node && (node.host || unwrapHost(node.parentNode));
|
|
3597
|
+
};
|
|
3598
|
+
var correctTargets = function(parent, targets) {
|
|
3599
|
+
return targets.map(function(target) {
|
|
3600
|
+
if (parent.contains(target)) {
|
|
3601
|
+
return target;
|
|
3602
|
+
}
|
|
3603
|
+
var correctedTarget = unwrapHost(target);
|
|
3604
|
+
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
3605
|
+
return correctedTarget;
|
|
3606
|
+
}
|
|
3607
|
+
console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
|
|
3608
|
+
return null;
|
|
3609
|
+
}).filter(function(x) {
|
|
3610
|
+
return Boolean(x);
|
|
3611
|
+
});
|
|
3612
|
+
};
|
|
3613
|
+
var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
|
|
3614
|
+
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
3615
|
+
if (!markerMap[markerName]) {
|
|
3616
|
+
markerMap[markerName] = /* @__PURE__ */ new WeakMap();
|
|
3617
|
+
}
|
|
3618
|
+
var markerCounter = markerMap[markerName];
|
|
3619
|
+
var hiddenNodes = [];
|
|
3620
|
+
var elementsToKeep = /* @__PURE__ */ new Set();
|
|
3621
|
+
var elementsToStop = new Set(targets);
|
|
3622
|
+
var keep = function(el) {
|
|
3623
|
+
if (!el || elementsToKeep.has(el)) {
|
|
3624
|
+
return;
|
|
3625
|
+
}
|
|
3626
|
+
elementsToKeep.add(el);
|
|
3627
|
+
keep(el.parentNode);
|
|
3628
|
+
};
|
|
3629
|
+
targets.forEach(keep);
|
|
3630
|
+
var deep = function(parent) {
|
|
3631
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
3632
|
+
return;
|
|
3633
|
+
}
|
|
3634
|
+
Array.prototype.forEach.call(parent.children, function(node) {
|
|
3635
|
+
if (elementsToKeep.has(node)) {
|
|
3636
|
+
deep(node);
|
|
3637
|
+
} else {
|
|
3638
|
+
try {
|
|
3639
|
+
var attr = node.getAttribute(controlAttribute);
|
|
3640
|
+
var alreadyHidden = attr !== null && attr !== "false";
|
|
3641
|
+
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
3642
|
+
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
3643
|
+
counterMap.set(node, counterValue);
|
|
3644
|
+
markerCounter.set(node, markerValue);
|
|
3645
|
+
hiddenNodes.push(node);
|
|
3646
|
+
if (counterValue === 1 && alreadyHidden) {
|
|
3647
|
+
uncontrolledNodes.set(node, true);
|
|
3648
|
+
}
|
|
3649
|
+
if (markerValue === 1) {
|
|
3650
|
+
node.setAttribute(markerName, "true");
|
|
3651
|
+
}
|
|
3652
|
+
if (!alreadyHidden) {
|
|
3653
|
+
node.setAttribute(controlAttribute, "true");
|
|
3654
|
+
}
|
|
3655
|
+
} catch (e) {
|
|
3656
|
+
console.error("aria-hidden: cannot operate on ", node, e);
|
|
3657
|
+
}
|
|
3658
|
+
}
|
|
3659
|
+
});
|
|
3660
|
+
};
|
|
3661
|
+
deep(parentNode);
|
|
3662
|
+
elementsToKeep.clear();
|
|
3663
|
+
lockCount++;
|
|
3664
|
+
return function() {
|
|
3665
|
+
hiddenNodes.forEach(function(node) {
|
|
3666
|
+
var counterValue = counterMap.get(node) - 1;
|
|
3667
|
+
var markerValue = markerCounter.get(node) - 1;
|
|
3668
|
+
counterMap.set(node, counterValue);
|
|
3669
|
+
markerCounter.set(node, markerValue);
|
|
3670
|
+
if (!counterValue) {
|
|
3671
|
+
if (!uncontrolledNodes.has(node)) {
|
|
3672
|
+
node.removeAttribute(controlAttribute);
|
|
3673
|
+
}
|
|
3674
|
+
uncontrolledNodes.delete(node);
|
|
3675
|
+
}
|
|
3676
|
+
if (!markerValue) {
|
|
3677
|
+
node.removeAttribute(markerName);
|
|
3678
|
+
}
|
|
3679
|
+
});
|
|
3680
|
+
lockCount--;
|
|
3681
|
+
if (!lockCount) {
|
|
3682
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
3683
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
3684
|
+
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
3685
|
+
markerMap = {};
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3688
|
+
};
|
|
3689
|
+
var hideOthers = function(originalTarget, parentNode, markerName) {
|
|
3690
|
+
if (markerName === void 0) {
|
|
3691
|
+
markerName = "data-aria-hidden";
|
|
3692
|
+
}
|
|
3693
|
+
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
3694
|
+
var activeParentNode = getDefaultParent(originalTarget);
|
|
3695
|
+
if (!activeParentNode) {
|
|
3696
|
+
return function() {
|
|
3697
|
+
return null;
|
|
3698
|
+
};
|
|
3699
|
+
}
|
|
3700
|
+
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
|
|
3701
|
+
return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
|
|
3702
|
+
};
|
|
3703
|
+
var DIALOG_NAME = "Dialog";
|
|
3704
|
+
var [createDialogContext] = createContextScope(DIALOG_NAME);
|
|
3705
|
+
var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
|
|
3706
|
+
var Dialog = (props) => {
|
|
3707
|
+
const {
|
|
3708
|
+
__scopeDialog,
|
|
3709
|
+
children,
|
|
3710
|
+
open: openProp,
|
|
3711
|
+
defaultOpen,
|
|
3712
|
+
onOpenChange,
|
|
3713
|
+
modal = true
|
|
3714
|
+
} = props;
|
|
3715
|
+
const triggerRef = React__namespace.useRef(null);
|
|
3716
|
+
const contentRef = React__namespace.useRef(null);
|
|
3717
|
+
const [open2, setOpen] = useControllableState({
|
|
3718
|
+
prop: openProp,
|
|
3719
|
+
defaultProp: defaultOpen ?? false,
|
|
3720
|
+
onChange: onOpenChange,
|
|
3721
|
+
caller: DIALOG_NAME
|
|
3722
|
+
});
|
|
3723
|
+
return /* @__PURE__ */ u(
|
|
3724
|
+
DialogProvider,
|
|
3725
|
+
{
|
|
3726
|
+
scope: __scopeDialog,
|
|
3727
|
+
triggerRef,
|
|
3728
|
+
contentRef,
|
|
3729
|
+
contentId: useId(),
|
|
3730
|
+
titleId: useId(),
|
|
3731
|
+
descriptionId: useId(),
|
|
3732
|
+
open: open2,
|
|
3733
|
+
onOpenChange: setOpen,
|
|
3734
|
+
onOpenToggle: React__namespace.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
3735
|
+
modal,
|
|
3736
|
+
children
|
|
3737
|
+
}
|
|
3738
|
+
);
|
|
3739
|
+
};
|
|
3740
|
+
Dialog.displayName = DIALOG_NAME;
|
|
3741
|
+
var TRIGGER_NAME = "DialogTrigger";
|
|
3742
|
+
var DialogTrigger = React__namespace.forwardRef(
|
|
3743
|
+
(props, forwardedRef) => {
|
|
3744
|
+
const { __scopeDialog, ...triggerProps } = props;
|
|
3745
|
+
const context = useDialogContext(TRIGGER_NAME, __scopeDialog);
|
|
3746
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
3747
|
+
return /* @__PURE__ */ u(
|
|
3748
|
+
Primitive.button,
|
|
3749
|
+
{
|
|
3750
|
+
type: "button",
|
|
3751
|
+
"aria-haspopup": "dialog",
|
|
3752
|
+
"aria-expanded": context.open,
|
|
3753
|
+
"aria-controls": context.contentId,
|
|
3754
|
+
"data-state": getState(context.open),
|
|
3755
|
+
...triggerProps,
|
|
3756
|
+
ref: composedTriggerRef,
|
|
3757
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
3758
|
+
}
|
|
3759
|
+
);
|
|
3760
|
+
}
|
|
3761
|
+
);
|
|
3762
|
+
DialogTrigger.displayName = TRIGGER_NAME;
|
|
3763
|
+
var PORTAL_NAME = "DialogPortal";
|
|
3764
|
+
var [PortalProvider, usePortalContext] = createDialogContext(PORTAL_NAME, {
|
|
3765
|
+
forceMount: void 0
|
|
3766
|
+
});
|
|
3767
|
+
var OVERLAY_NAME = "DialogOverlay";
|
|
3768
|
+
var DialogOverlay = React__namespace.forwardRef(
|
|
3769
|
+
(props, forwardedRef) => {
|
|
3770
|
+
const portalContext = usePortalContext(OVERLAY_NAME, props.__scopeDialog);
|
|
3771
|
+
const { forceMount = portalContext.forceMount, ...overlayProps } = props;
|
|
3772
|
+
const context = useDialogContext(OVERLAY_NAME, props.__scopeDialog);
|
|
3773
|
+
return context.modal ? /* @__PURE__ */ u(Presence, { present: forceMount || context.open, children: /* @__PURE__ */ u(DialogOverlayImpl, { ...overlayProps, ref: forwardedRef }) }) : null;
|
|
3774
|
+
}
|
|
3775
|
+
);
|
|
3776
|
+
DialogOverlay.displayName = OVERLAY_NAME;
|
|
3777
|
+
var Slot = /* @__PURE__ */ createSlot("DialogOverlay.RemoveScroll");
|
|
3778
|
+
var DialogOverlayImpl = React__namespace.forwardRef(
|
|
3779
|
+
(props, forwardedRef) => {
|
|
3780
|
+
const { __scopeDialog, ...overlayProps } = props;
|
|
3781
|
+
const context = useDialogContext(OVERLAY_NAME, __scopeDialog);
|
|
3782
|
+
return (
|
|
3783
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
3784
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
3785
|
+
/* @__PURE__ */ u(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ u(
|
|
3786
|
+
Primitive.div,
|
|
3787
|
+
{
|
|
3788
|
+
"data-state": getState(context.open),
|
|
3789
|
+
...overlayProps,
|
|
3790
|
+
ref: forwardedRef,
|
|
3791
|
+
style: { pointerEvents: "auto", ...overlayProps.style }
|
|
3792
|
+
}
|
|
3793
|
+
) })
|
|
3794
|
+
);
|
|
3795
|
+
}
|
|
3796
|
+
);
|
|
3797
|
+
var CONTENT_NAME = "DialogContent";
|
|
3798
|
+
var DialogContent = React__namespace.forwardRef(
|
|
3799
|
+
(props, forwardedRef) => {
|
|
3800
|
+
const portalContext = usePortalContext(CONTENT_NAME, props.__scopeDialog);
|
|
3801
|
+
const { forceMount = portalContext.forceMount, ...contentProps } = props;
|
|
3802
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
3803
|
+
return /* @__PURE__ */ u(Presence, { present: forceMount || context.open, children: context.modal ? /* @__PURE__ */ u(DialogContentModal, { ...contentProps, ref: forwardedRef }) : /* @__PURE__ */ u(DialogContentNonModal, { ...contentProps, ref: forwardedRef }) });
|
|
3804
|
+
}
|
|
3805
|
+
);
|
|
3806
|
+
DialogContent.displayName = CONTENT_NAME;
|
|
3807
|
+
var DialogContentModal = React__namespace.forwardRef(
|
|
3808
|
+
(props, forwardedRef) => {
|
|
3809
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
3810
|
+
const contentRef = React__namespace.useRef(null);
|
|
3811
|
+
const composedRefs = useComposedRefs(forwardedRef, context.contentRef, contentRef);
|
|
3812
|
+
React__namespace.useEffect(() => {
|
|
3813
|
+
const content = contentRef.current;
|
|
3814
|
+
if (content) return hideOthers(content);
|
|
3815
|
+
}, []);
|
|
3816
|
+
return /* @__PURE__ */ u(
|
|
3817
|
+
DialogContentImpl,
|
|
3818
|
+
{
|
|
3819
|
+
...props,
|
|
3820
|
+
ref: composedRefs,
|
|
3821
|
+
trapFocus: context.open,
|
|
3822
|
+
disableOutsidePointerEvents: true,
|
|
3823
|
+
onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
3824
|
+
event.preventDefault();
|
|
3825
|
+
context.triggerRef.current?.focus();
|
|
3826
|
+
}),
|
|
3827
|
+
onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
|
|
3828
|
+
const originalEvent = event.detail.originalEvent;
|
|
3829
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
3830
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
3831
|
+
if (isRightClick) event.preventDefault();
|
|
3832
|
+
}),
|
|
3833
|
+
onFocusOutside: composeEventHandlers(
|
|
3834
|
+
props.onFocusOutside,
|
|
3835
|
+
(event) => event.preventDefault()
|
|
3836
|
+
)
|
|
3837
|
+
}
|
|
3838
|
+
);
|
|
3839
|
+
}
|
|
3840
|
+
);
|
|
3841
|
+
var DialogContentNonModal = React__namespace.forwardRef(
|
|
3842
|
+
(props, forwardedRef) => {
|
|
3843
|
+
const context = useDialogContext(CONTENT_NAME, props.__scopeDialog);
|
|
3844
|
+
const hasInteractedOutsideRef = React__namespace.useRef(false);
|
|
3845
|
+
const hasPointerDownOutsideRef = React__namespace.useRef(false);
|
|
3846
|
+
return /* @__PURE__ */ u(
|
|
3847
|
+
DialogContentImpl,
|
|
3848
|
+
{
|
|
3849
|
+
...props,
|
|
3850
|
+
ref: forwardedRef,
|
|
3851
|
+
trapFocus: false,
|
|
3852
|
+
disableOutsidePointerEvents: false,
|
|
3853
|
+
onCloseAutoFocus: (event) => {
|
|
3854
|
+
props.onCloseAutoFocus?.(event);
|
|
3855
|
+
if (!event.defaultPrevented) {
|
|
3856
|
+
if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
|
|
3857
|
+
event.preventDefault();
|
|
3858
|
+
}
|
|
3859
|
+
hasInteractedOutsideRef.current = false;
|
|
3860
|
+
hasPointerDownOutsideRef.current = false;
|
|
3861
|
+
},
|
|
3862
|
+
onInteractOutside: (event) => {
|
|
3863
|
+
props.onInteractOutside?.(event);
|
|
3864
|
+
if (!event.defaultPrevented) {
|
|
3865
|
+
hasInteractedOutsideRef.current = true;
|
|
3866
|
+
if (event.detail.originalEvent.type === "pointerdown") {
|
|
3867
|
+
hasPointerDownOutsideRef.current = true;
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
const target = event.target;
|
|
3871
|
+
const targetIsTrigger = context.triggerRef.current?.contains(target);
|
|
3872
|
+
if (targetIsTrigger) event.preventDefault();
|
|
3873
|
+
if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
|
|
3874
|
+
event.preventDefault();
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
);
|
|
3879
|
+
}
|
|
3880
|
+
);
|
|
3881
|
+
var DialogContentImpl = React__namespace.forwardRef(
|
|
3882
|
+
(props, forwardedRef) => {
|
|
3883
|
+
const { __scopeDialog, trapFocus, onOpenAutoFocus, onCloseAutoFocus, ...contentProps } = props;
|
|
3884
|
+
const context = useDialogContext(CONTENT_NAME, __scopeDialog);
|
|
3885
|
+
const contentRef = React__namespace.useRef(null);
|
|
3886
|
+
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
3887
|
+
useFocusGuards();
|
|
3888
|
+
return /* @__PURE__ */ u(k, { children: [
|
|
3889
|
+
/* @__PURE__ */ u(
|
|
3890
|
+
FocusScope,
|
|
3891
|
+
{
|
|
3892
|
+
asChild: true,
|
|
3893
|
+
loop: true,
|
|
3894
|
+
trapped: trapFocus,
|
|
3895
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
3896
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
3897
|
+
children: /* @__PURE__ */ u(
|
|
3898
|
+
DismissableLayer,
|
|
3899
|
+
{
|
|
3900
|
+
role: "dialog",
|
|
3901
|
+
id: context.contentId,
|
|
3902
|
+
"aria-describedby": context.descriptionId,
|
|
3903
|
+
"aria-labelledby": context.titleId,
|
|
3904
|
+
"data-state": getState(context.open),
|
|
3905
|
+
...contentProps,
|
|
3906
|
+
ref: composedRefs,
|
|
3907
|
+
onDismiss: () => context.onOpenChange(false)
|
|
3908
|
+
}
|
|
3909
|
+
)
|
|
3910
|
+
}
|
|
3911
|
+
),
|
|
3912
|
+
/* @__PURE__ */ u(k, { children: [
|
|
3913
|
+
/* @__PURE__ */ u(TitleWarning, { titleId: context.titleId }),
|
|
3914
|
+
/* @__PURE__ */ u(DescriptionWarning, { contentRef, descriptionId: context.descriptionId })
|
|
3915
|
+
] })
|
|
3916
|
+
] });
|
|
3917
|
+
}
|
|
3918
|
+
);
|
|
3919
|
+
var TITLE_NAME = "DialogTitle";
|
|
3920
|
+
var DialogTitle = React__namespace.forwardRef(
|
|
3921
|
+
(props, forwardedRef) => {
|
|
3922
|
+
const { __scopeDialog, ...titleProps } = props;
|
|
3923
|
+
const context = useDialogContext(TITLE_NAME, __scopeDialog);
|
|
3924
|
+
return /* @__PURE__ */ u(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
|
|
3925
|
+
}
|
|
3926
|
+
);
|
|
3927
|
+
DialogTitle.displayName = TITLE_NAME;
|
|
3928
|
+
var DESCRIPTION_NAME = "DialogDescription";
|
|
3929
|
+
var DialogDescription = React__namespace.forwardRef(
|
|
3930
|
+
(props, forwardedRef) => {
|
|
3931
|
+
const { __scopeDialog, ...descriptionProps } = props;
|
|
3932
|
+
const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
|
|
3933
|
+
return /* @__PURE__ */ u(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
|
|
3934
|
+
}
|
|
3935
|
+
);
|
|
3936
|
+
DialogDescription.displayName = DESCRIPTION_NAME;
|
|
3937
|
+
var CLOSE_NAME = "DialogClose";
|
|
3938
|
+
var DialogClose = React__namespace.forwardRef(
|
|
3939
|
+
(props, forwardedRef) => {
|
|
3940
|
+
const { __scopeDialog, ...closeProps } = props;
|
|
3941
|
+
const context = useDialogContext(CLOSE_NAME, __scopeDialog);
|
|
3942
|
+
return /* @__PURE__ */ u(
|
|
3943
|
+
Primitive.button,
|
|
3944
|
+
{
|
|
3945
|
+
type: "button",
|
|
3946
|
+
...closeProps,
|
|
3947
|
+
ref: forwardedRef,
|
|
3948
|
+
onClick: composeEventHandlers(props.onClick, () => context.onOpenChange(false))
|
|
3949
|
+
}
|
|
3950
|
+
);
|
|
3951
|
+
}
|
|
3952
|
+
);
|
|
3953
|
+
DialogClose.displayName = CLOSE_NAME;
|
|
3954
|
+
function getState(open2) {
|
|
3955
|
+
return open2 ? "open" : "closed";
|
|
3956
|
+
}
|
|
3957
|
+
var TITLE_WARNING_NAME = "DialogTitleWarning";
|
|
3958
|
+
var [WarningProvider, useWarningContext] = createContext2(TITLE_WARNING_NAME, {
|
|
3959
|
+
contentName: CONTENT_NAME,
|
|
3960
|
+
titleName: TITLE_NAME,
|
|
3961
|
+
docsSlug: "dialog"
|
|
3962
|
+
});
|
|
3963
|
+
var TitleWarning = ({ titleId }) => {
|
|
3964
|
+
const titleWarningContext = useWarningContext(TITLE_WARNING_NAME);
|
|
3965
|
+
const MESSAGE = `\`${titleWarningContext.contentName}\` requires a \`${titleWarningContext.titleName}\` for the component to be accessible for screen reader users.
|
|
3966
|
+
|
|
3967
|
+
If you want to hide the \`${titleWarningContext.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
3968
|
+
|
|
3969
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${titleWarningContext.docsSlug}`;
|
|
3970
|
+
React__namespace.useEffect(() => {
|
|
3971
|
+
if (titleId) {
|
|
3972
|
+
const hasTitle = document.getElementById(titleId);
|
|
3973
|
+
if (!hasTitle) console.error(MESSAGE);
|
|
3974
|
+
}
|
|
3975
|
+
}, [MESSAGE, titleId]);
|
|
3976
|
+
return null;
|
|
3977
|
+
};
|
|
3978
|
+
var DESCRIPTION_WARNING_NAME = "DialogDescriptionWarning";
|
|
3979
|
+
var DescriptionWarning = ({ contentRef, descriptionId }) => {
|
|
3980
|
+
const descriptionWarningContext = useWarningContext(DESCRIPTION_WARNING_NAME);
|
|
3981
|
+
const MESSAGE = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${descriptionWarningContext.contentName}}.`;
|
|
3982
|
+
React__namespace.useEffect(() => {
|
|
3983
|
+
const describedById = contentRef.current?.getAttribute("aria-describedby");
|
|
3984
|
+
if (descriptionId && describedById) {
|
|
3985
|
+
const hasDescription = document.getElementById(descriptionId);
|
|
3986
|
+
if (!hasDescription) console.warn(MESSAGE);
|
|
3987
|
+
}
|
|
3988
|
+
}, [MESSAGE, contentRef, descriptionId]);
|
|
3989
|
+
return null;
|
|
3990
|
+
};
|
|
3991
|
+
var Root = Dialog;
|
|
3992
|
+
var Content = DialogContent;
|
|
3993
|
+
var Title = DialogTitle;
|
|
3994
|
+
var Description = DialogDescription;
|
|
3995
|
+
var Close = DialogClose;
|
|
3996
|
+
const BannerContent = ({
|
|
3997
|
+
noTarget: noTarget2 = true,
|
|
3998
|
+
heading: heading2 = "We use cookies.",
|
|
3999
|
+
subheading = "Please define your selection below.",
|
|
4000
|
+
selectLabel = "Select",
|
|
4001
|
+
hideLabel = "Hide",
|
|
4002
|
+
saveLabel = "Save selection",
|
|
4003
|
+
declineLabel = "Decline all",
|
|
4004
|
+
defaultSettingsOpen = true,
|
|
4005
|
+
privacyPolicy,
|
|
4006
|
+
items
|
|
4007
|
+
}) => {
|
|
4008
|
+
const { onSave, onDeclineAll, selectionTaken } = useSelection();
|
|
4009
|
+
const [openItem, setOpenItem] = React.useState(void 0);
|
|
4010
|
+
const [settingsOpen, setSettingsOpen] = React.useState(defaultSettingsOpen);
|
|
4011
|
+
return /* @__PURE__ */ u(Root, { open: !selectionTaken, children: /* @__PURE__ */ u(
|
|
4012
|
+
Content,
|
|
4013
|
+
{
|
|
4014
|
+
className: cls(classes$2.root, noTarget2 ? classes$2.noTarget : ""),
|
|
4015
|
+
children: /* @__PURE__ */ u(
|
|
4016
|
+
Root$2,
|
|
4017
|
+
{
|
|
4018
|
+
open: settingsOpen,
|
|
4019
|
+
onOpenChange: setSettingsOpen,
|
|
4020
|
+
className: classes$2.collapsible,
|
|
4021
|
+
children: [
|
|
4022
|
+
/* @__PURE__ */ u("div", { className: classes$2.header, children: [
|
|
4023
|
+
/* @__PURE__ */ u("div", { className: classes$2.heading, children: [
|
|
4024
|
+
/* @__PURE__ */ u(Title, { asChild: true, children: /* @__PURE__ */ u(Text, { weight: "bold", children: heading2 }) }),
|
|
4025
|
+
/* @__PURE__ */ u(Description, { asChild: true, children: /* @__PURE__ */ u(Text, { size: "caption", color: "muted", children: subheading }) })
|
|
4026
|
+
] }),
|
|
4027
|
+
/* @__PURE__ */ u(Trigger, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "ghost", children: [
|
|
4028
|
+
settingsOpen ? hideLabel : selectLabel,
|
|
4029
|
+
" ",
|
|
4030
|
+
/* @__PURE__ */ u(
|
|
4031
|
+
ChevronUp,
|
|
4032
|
+
{
|
|
4033
|
+
size: 12,
|
|
4034
|
+
className: clx({
|
|
4035
|
+
[classes$2.chevron]: true,
|
|
4036
|
+
[classes$2.open]: settingsOpen
|
|
4037
|
+
})
|
|
4038
|
+
}
|
|
4039
|
+
)
|
|
4040
|
+
] }) })
|
|
4041
|
+
] }),
|
|
4042
|
+
/* @__PURE__ */ u(
|
|
4043
|
+
Content$1,
|
|
4044
|
+
{
|
|
4045
|
+
className: clx({
|
|
4046
|
+
[classes$2.settings]: true
|
|
4047
|
+
}),
|
|
4048
|
+
children: /* @__PURE__ */ u(
|
|
4049
|
+
Root2,
|
|
4050
|
+
{
|
|
4051
|
+
type: "single",
|
|
4052
|
+
collapsible: true,
|
|
4053
|
+
value: openItem,
|
|
4054
|
+
onValueChange: setOpenItem,
|
|
4055
|
+
children: items.map((item) => /* @__PURE__ */ u(BannerItem, { ...item, openItem }, item.value))
|
|
4056
|
+
}
|
|
4057
|
+
)
|
|
4058
|
+
}
|
|
4059
|
+
),
|
|
4060
|
+
/* @__PURE__ */ u("div", { className: classes$2.footer, children: [
|
|
4061
|
+
/* @__PURE__ */ u("div", { className: classes$2.legal, children: privacyPolicy && /* @__PURE__ */ u(Text, { size: "caption", children: /* @__PURE__ */ u("a", { href: privacyPolicy.url, target: "_blank", children: privacyPolicy.label }) }) }),
|
|
4062
|
+
/* @__PURE__ */ u("div", { className: classes$2.actions, children: [
|
|
4063
|
+
/* @__PURE__ */ u(Close, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "neutral", onClick: () => onDeclineAll(), children: declineLabel }) }),
|
|
4064
|
+
/* @__PURE__ */ u(Close, { asChild: true, children: /* @__PURE__ */ u(Button, { variant: "brand", onClick: () => onSave(), children: saveLabel }) })
|
|
4065
|
+
] })
|
|
4066
|
+
] })
|
|
4067
|
+
]
|
|
4068
|
+
}
|
|
4069
|
+
)
|
|
4070
|
+
}
|
|
4071
|
+
) });
|
|
4072
|
+
};
|
|
4073
|
+
const Banner = ({
|
|
4074
|
+
localStorageKey = "cb-selection",
|
|
4075
|
+
items,
|
|
4076
|
+
...rest
|
|
4077
|
+
}) => {
|
|
4078
|
+
const selectionItems = React.useMemo(
|
|
4079
|
+
() => items.filter((item) => !item.required).map((item) => ({
|
|
4080
|
+
value: item.value,
|
|
4081
|
+
script: item.script,
|
|
4082
|
+
defaultSelected: item.defaultSelected,
|
|
4083
|
+
required: item.required
|
|
4084
|
+
})),
|
|
4085
|
+
[items]
|
|
4086
|
+
);
|
|
4087
|
+
return /* @__PURE__ */ u(SelectionProvider, { items: selectionItems, localStorageKey, children: /* @__PURE__ */ u(BannerContent, { items, ...rest }) });
|
|
4088
|
+
};
|
|
4089
|
+
exports.Banner = Banner;
|