lizaui 9.0.13 → 9.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/button/index.es.js +1 -1
  2. package/dist/calendar/index.es.js +1 -1
  3. package/dist/checkbox/index.es.js +1 -1
  4. package/dist/chunks/{button-CA3Y2GZ1.js → button-B0fpJrMg.js} +2 -2
  5. package/dist/chunks/{button-CA3Y2GZ1.js.map → button-B0fpJrMg.js.map} +1 -1
  6. package/dist/chunks/{checkbox-qzZKMLRN.js → checkbox-C1Sssumg.js} +2 -2
  7. package/dist/chunks/{checkbox-qzZKMLRN.js.map → checkbox-C1Sssumg.js.map} +1 -1
  8. package/dist/chunks/{floating-ui.dom-N5ROFCJy.js → floating-ui.dom-B9hvXzxg.js} +11 -1
  9. package/dist/chunks/{floating-ui.dom-N5ROFCJy.js.map → floating-ui.dom-B9hvXzxg.js.map} +1 -1
  10. package/dist/chunks/{floating-ui.dom-NqZWWqNg.js → floating-ui.dom-DRSBqyFN.js} +14 -4
  11. package/dist/chunks/{floating-ui.dom-NqZWWqNg.js.map → floating-ui.dom-DRSBqyFN.js.map} +1 -1
  12. package/dist/chunks/floating-ui.react-dom-BUZLdP4-.js +294 -0
  13. package/dist/chunks/floating-ui.react-dom-BUZLdP4-.js.map +1 -0
  14. package/dist/chunks/floating-ui.react-dom-CI1b2uK3.js +310 -0
  15. package/dist/chunks/floating-ui.react-dom-CI1b2uK3.js.map +1 -0
  16. package/dist/chunks/{index-DiC9dI6_.js → index-B4RTH1-D.js} +4 -4
  17. package/dist/chunks/{index-DiC9dI6_.js.map → index-B4RTH1-D.js.map} +1 -1
  18. package/dist/chunks/{scroll-area-CgJodNZ_.js → scroll-area-B-5YmafW.js} +27 -27
  19. package/dist/chunks/{scroll-area-CgJodNZ_.js.map → scroll-area-B-5YmafW.js.map} +1 -1
  20. package/dist/chunks/{scroll-area-BcM0NCEM.js → scroll-area-WNAy-5-i.js} +3 -3
  21. package/dist/chunks/{scroll-area-BcM0NCEM.js.map → scroll-area-WNAy-5-i.js.map} +1 -1
  22. package/dist/chunks/{select-DyihZY-4.js → select-C9BYUpJm.js} +439 -83
  23. package/dist/chunks/select-C9BYUpJm.js.map +1 -0
  24. package/dist/chunks/{select-DaKy-WhC.js → select-CLIZOVIj.js} +366 -10
  25. package/dist/chunks/select-CLIZOVIj.js.map +1 -0
  26. package/dist/chunks/{textarea-By2Vv44z.js → textarea-D2_KC-J4.js} +587 -36
  27. package/dist/chunks/textarea-D2_KC-J4.js.map +1 -0
  28. package/dist/chunks/{textarea-ClJsk9Gp.js → textarea-_HQpXiCX.js} +586 -35
  29. package/dist/chunks/textarea-_HQpXiCX.js.map +1 -0
  30. package/dist/chunks/tooltip-CjmRm1rv.js +1937 -0
  31. package/dist/chunks/tooltip-CjmRm1rv.js.map +1 -0
  32. package/dist/chunks/tooltip-o938-GAz.js +1921 -0
  33. package/dist/chunks/tooltip-o938-GAz.js.map +1 -0
  34. package/dist/components/tooltip/tooltip.d.ts +1 -1
  35. package/dist/components/tooltip/tooltip.d.ts.map +1 -1
  36. package/dist/divider/index.es.js +1 -1
  37. package/dist/modal/index.es.js +1 -1
  38. package/dist/pagination/index.cjs.js +2 -2
  39. package/dist/pagination/index.es.js +3 -3
  40. package/dist/phone-input/index.cjs.js +2 -2
  41. package/dist/phone-input/index.es.js +3 -3
  42. package/dist/select-input/index.cjs.js +1 -1
  43. package/dist/select-input/index.es.js +2 -2
  44. package/dist/table/index.cjs.js +1 -1
  45. package/dist/table/index.es.js +2 -2
  46. package/dist/time-input/index.cjs.js +1 -1
  47. package/dist/time-input/index.es.js +2 -2
  48. package/dist/tooltip/index.cjs.js +1 -1
  49. package/dist/tooltip/index.es.js +1 -1
  50. package/dist/ui/index.cjs.js +290 -292
  51. package/dist/ui/index.cjs.js.map +1 -1
  52. package/dist/ui/index.es.js +180 -182
  53. package/dist/ui/index.es.js.map +1 -1
  54. package/package.json +2 -2
  55. package/dist/chunks/index-CuySPbdY.js +0 -559
  56. package/dist/chunks/index-CuySPbdY.js.map +0 -1
  57. package/dist/chunks/index-DBDBh58Q.js +0 -575
  58. package/dist/chunks/index-DBDBh58Q.js.map +0 -1
  59. package/dist/chunks/index-DNSql2gU.js +0 -662
  60. package/dist/chunks/index-DNSql2gU.js.map +0 -1
  61. package/dist/chunks/index-DlZi5TkN.js +0 -646
  62. package/dist/chunks/index-DlZi5TkN.js.map +0 -1
  63. package/dist/chunks/select-DaKy-WhC.js.map +0 -1
  64. package/dist/chunks/select-DyihZY-4.js.map +0 -1
  65. package/dist/chunks/textarea-By2Vv44z.js.map +0 -1
  66. package/dist/chunks/textarea-ClJsk9Gp.js.map +0 -1
  67. package/dist/chunks/tooltip-D4UvkD2G.js +0 -525
  68. package/dist/chunks/tooltip-D4UvkD2G.js.map +0 -1
  69. package/dist/chunks/tooltip-WGeoFpGx.js +0 -541
  70. package/dist/chunks/tooltip-WGeoFpGx.js.map +0 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lizaui",
3
3
  "private": false,
4
4
  "license": "ISC",
5
- "version": "9.0.13",
5
+ "version": "9.0.15",
6
6
  "type": "module",
7
7
  "main": "dist/index.cjs.js",
8
8
  "module": "dist/index.es.js",
@@ -111,6 +111,7 @@
111
111
  "yup": ">=1.7"
112
112
  },
113
113
  "dependencies": {
114
+ "@floating-ui/react": "^0.27.16",
114
115
  "@radix-ui/react-accordion": "^1.2.12",
115
116
  "@radix-ui/react-alert-dialog": "^1.1.15",
116
117
  "@radix-ui/react-aspect-ratio": "^1.1.7",
@@ -130,7 +131,6 @@
130
131
  "@radix-ui/react-slot": "^1.2.3",
131
132
  "@radix-ui/react-switch": "^1.2.6",
132
133
  "@radix-ui/react-tabs": "^1.1.13",
133
- "@radix-ui/react-tooltip": "^1.2.8",
134
134
  "@react-aria/interactions": "^3.25.5",
135
135
  "@tailwindcss/vite": "^4.1.13",
136
136
  "@wojtekmaj/react-daterange-picker": "^7.0.0",
@@ -1,559 +0,0 @@
1
- import * as React from "react";
2
- import { jsx } from "react/jsx-runtime";
3
- import { a as createSlot, u as useComposedRefs } from "./index-DiC9dI6_.js";
4
- import * as ReactDOM from "react-dom";
5
- import ReactDOM__default from "react-dom";
6
- var NODES = [
7
- "a",
8
- "button",
9
- "div",
10
- "form",
11
- "h2",
12
- "h3",
13
- "img",
14
- "input",
15
- "label",
16
- "li",
17
- "nav",
18
- "ol",
19
- "p",
20
- "select",
21
- "span",
22
- "svg",
23
- "ul"
24
- ];
25
- var Primitive = NODES.reduce((primitive, node) => {
26
- const Slot = createSlot(`Primitive.${node}`);
27
- const Node = React.forwardRef((props, forwardedRef) => {
28
- const { asChild, ...primitiveProps } = props;
29
- const Comp = asChild ? Slot : node;
30
- if (typeof window !== "undefined") {
31
- window[Symbol.for("radix-ui")] = true;
32
- }
33
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
34
- });
35
- Node.displayName = `Primitive.${node}`;
36
- return { ...primitive, [node]: Node };
37
- }, {});
38
- function dispatchDiscreteCustomEvent(target, event) {
39
- if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
40
- }
41
- function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
42
- return function handleEvent(event) {
43
- originalEventHandler?.(event);
44
- if (checkForDefaultPrevented === false || !event.defaultPrevented) {
45
- return ourEventHandler?.(event);
46
- }
47
- };
48
- }
49
- function createContext2(rootComponentName, defaultContext) {
50
- const Context = React.createContext(defaultContext);
51
- const Provider = (props) => {
52
- const { children, ...context } = props;
53
- const value = React.useMemo(() => context, Object.values(context));
54
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
55
- };
56
- Provider.displayName = rootComponentName + "Provider";
57
- function useContext2(consumerName) {
58
- const context = React.useContext(Context);
59
- if (context) return context;
60
- if (defaultContext !== void 0) return defaultContext;
61
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
62
- }
63
- return [Provider, useContext2];
64
- }
65
- function createContextScope(scopeName, createContextScopeDeps = []) {
66
- let defaultContexts = [];
67
- function createContext3(rootComponentName, defaultContext) {
68
- const BaseContext = React.createContext(defaultContext);
69
- const index = defaultContexts.length;
70
- defaultContexts = [...defaultContexts, defaultContext];
71
- const Provider = (props) => {
72
- const { scope, children, ...context } = props;
73
- const Context = scope?.[scopeName]?.[index] || BaseContext;
74
- const value = React.useMemo(() => context, Object.values(context));
75
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
76
- };
77
- Provider.displayName = rootComponentName + "Provider";
78
- function useContext2(consumerName, scope) {
79
- const Context = scope?.[scopeName]?.[index] || BaseContext;
80
- const context = React.useContext(Context);
81
- if (context) return context;
82
- if (defaultContext !== void 0) return defaultContext;
83
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
84
- }
85
- return [Provider, useContext2];
86
- }
87
- const createScope = () => {
88
- const scopeContexts = defaultContexts.map((defaultContext) => {
89
- return React.createContext(defaultContext);
90
- });
91
- return function useScope(scope) {
92
- const contexts = scope?.[scopeName] || scopeContexts;
93
- return React.useMemo(
94
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
95
- [scope, contexts]
96
- );
97
- };
98
- };
99
- createScope.scopeName = scopeName;
100
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
101
- }
102
- function composeContextScopes(...scopes) {
103
- const baseScope = scopes[0];
104
- if (scopes.length === 1) return baseScope;
105
- const createScope = () => {
106
- const scopeHooks = scopes.map((createScope2) => ({
107
- useScope: createScope2(),
108
- scopeName: createScope2.scopeName
109
- }));
110
- return function useComposedScopes(overrideScopes) {
111
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
112
- const scopeProps = useScope(overrideScopes);
113
- const currentScope = scopeProps[`__scope${scopeName}`];
114
- return { ...nextScopes2, ...currentScope };
115
- }, {});
116
- return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
117
- };
118
- };
119
- createScope.scopeName = baseScope.scopeName;
120
- return createScope;
121
- }
122
- var useLayoutEffect2 = globalThis?.document ? React.useLayoutEffect : () => {
123
- };
124
- var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
125
- function useControllableState({
126
- prop,
127
- defaultProp,
128
- onChange = () => {
129
- },
130
- caller
131
- }) {
132
- const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
133
- defaultProp,
134
- onChange
135
- });
136
- const isControlled = prop !== void 0;
137
- const value = isControlled ? prop : uncontrolledProp;
138
- {
139
- const isControlledRef = React.useRef(prop !== void 0);
140
- React.useEffect(() => {
141
- const wasControlled = isControlledRef.current;
142
- if (wasControlled !== isControlled) {
143
- const from = wasControlled ? "controlled" : "uncontrolled";
144
- const to = isControlled ? "controlled" : "uncontrolled";
145
- }
146
- isControlledRef.current = isControlled;
147
- }, [isControlled, caller]);
148
- }
149
- const setValue = React.useCallback(
150
- (nextValue) => {
151
- if (isControlled) {
152
- const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
153
- if (value2 !== prop) {
154
- onChangeRef.current?.(value2);
155
- }
156
- } else {
157
- setUncontrolledProp(nextValue);
158
- }
159
- },
160
- [isControlled, prop, setUncontrolledProp, onChangeRef]
161
- );
162
- return [value, setValue];
163
- }
164
- function useUncontrolledState({
165
- defaultProp,
166
- onChange
167
- }) {
168
- const [value, setValue] = React.useState(defaultProp);
169
- const prevValueRef = React.useRef(value);
170
- const onChangeRef = React.useRef(onChange);
171
- useInsertionEffect(() => {
172
- onChangeRef.current = onChange;
173
- }, [onChange]);
174
- React.useEffect(() => {
175
- if (prevValueRef.current !== value) {
176
- onChangeRef.current?.(value);
177
- prevValueRef.current = value;
178
- }
179
- }, [value, prevValueRef]);
180
- return [value, setValue, onChangeRef];
181
- }
182
- function isFunction(value) {
183
- return typeof value === "function";
184
- }
185
- function useCallbackRef(callback) {
186
- const callbackRef = React.useRef(callback);
187
- React.useEffect(() => {
188
- callbackRef.current = callback;
189
- });
190
- return React.useMemo(() => (...args) => callbackRef.current?.(...args), []);
191
- }
192
- function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
193
- const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
194
- React.useEffect(() => {
195
- const handleKeyDown = (event) => {
196
- if (event.key === "Escape") {
197
- onEscapeKeyDown(event);
198
- }
199
- };
200
- ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
201
- return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
202
- }, [onEscapeKeyDown, ownerDocument]);
203
- }
204
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
205
- var CONTEXT_UPDATE = "dismissableLayer.update";
206
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
207
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
208
- var originalBodyPointerEvents;
209
- var DismissableLayerContext = React.createContext({
210
- layers: /* @__PURE__ */ new Set(),
211
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
212
- branches: /* @__PURE__ */ new Set()
213
- });
214
- var DismissableLayer = React.forwardRef(
215
- (props, forwardedRef) => {
216
- const {
217
- disableOutsidePointerEvents = false,
218
- onEscapeKeyDown,
219
- onPointerDownOutside,
220
- onFocusOutside,
221
- onInteractOutside,
222
- onDismiss,
223
- ...layerProps
224
- } = props;
225
- const context = React.useContext(DismissableLayerContext);
226
- const [node, setNode] = React.useState(null);
227
- const ownerDocument = node?.ownerDocument ?? globalThis?.document;
228
- const [, force] = React.useState({});
229
- const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
230
- const layers = Array.from(context.layers);
231
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
232
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
233
- const index = node ? layers.indexOf(node) : -1;
234
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
235
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
236
- const pointerDownOutside = usePointerDownOutside((event) => {
237
- const target = event.target;
238
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
239
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
240
- onPointerDownOutside?.(event);
241
- onInteractOutside?.(event);
242
- if (!event.defaultPrevented) onDismiss?.();
243
- }, ownerDocument);
244
- const focusOutside = useFocusOutside((event) => {
245
- const target = event.target;
246
- const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
247
- if (isFocusInBranch) return;
248
- onFocusOutside?.(event);
249
- onInteractOutside?.(event);
250
- if (!event.defaultPrevented) onDismiss?.();
251
- }, ownerDocument);
252
- useEscapeKeydown((event) => {
253
- const isHighestLayer = index === context.layers.size - 1;
254
- if (!isHighestLayer) return;
255
- onEscapeKeyDown?.(event);
256
- if (!event.defaultPrevented && onDismiss) {
257
- event.preventDefault();
258
- onDismiss();
259
- }
260
- }, ownerDocument);
261
- React.useEffect(() => {
262
- if (!node) return;
263
- if (disableOutsidePointerEvents) {
264
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
265
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
266
- ownerDocument.body.style.pointerEvents = "none";
267
- }
268
- context.layersWithOutsidePointerEventsDisabled.add(node);
269
- }
270
- context.layers.add(node);
271
- dispatchUpdate();
272
- return () => {
273
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
274
- ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
275
- }
276
- };
277
- }, [node, ownerDocument, disableOutsidePointerEvents, context]);
278
- React.useEffect(() => {
279
- return () => {
280
- if (!node) return;
281
- context.layers.delete(node);
282
- context.layersWithOutsidePointerEventsDisabled.delete(node);
283
- dispatchUpdate();
284
- };
285
- }, [node, context]);
286
- React.useEffect(() => {
287
- const handleUpdate = () => force({});
288
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
289
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
290
- }, []);
291
- return /* @__PURE__ */ jsx(
292
- Primitive.div,
293
- {
294
- ...layerProps,
295
- ref: composedRefs,
296
- style: {
297
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
298
- ...props.style
299
- },
300
- onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
301
- onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
302
- onPointerDownCapture: composeEventHandlers(
303
- props.onPointerDownCapture,
304
- pointerDownOutside.onPointerDownCapture
305
- )
306
- }
307
- );
308
- }
309
- );
310
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
311
- var BRANCH_NAME = "DismissableLayerBranch";
312
- var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
313
- const context = React.useContext(DismissableLayerContext);
314
- const ref = React.useRef(null);
315
- const composedRefs = useComposedRefs(forwardedRef, ref);
316
- React.useEffect(() => {
317
- const node = ref.current;
318
- if (node) {
319
- context.branches.add(node);
320
- return () => {
321
- context.branches.delete(node);
322
- };
323
- }
324
- }, [context.branches]);
325
- return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
326
- });
327
- DismissableLayerBranch.displayName = BRANCH_NAME;
328
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
329
- const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
330
- const isPointerInsideReactTreeRef = React.useRef(false);
331
- const handleClickRef = React.useRef(() => {
332
- });
333
- React.useEffect(() => {
334
- const handlePointerDown = (event) => {
335
- if (event.target && !isPointerInsideReactTreeRef.current) {
336
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
337
- handleAndDispatchCustomEvent(
338
- POINTER_DOWN_OUTSIDE,
339
- handlePointerDownOutside,
340
- eventDetail,
341
- { discrete: true }
342
- );
343
- };
344
- const eventDetail = { originalEvent: event };
345
- if (event.pointerType === "touch") {
346
- ownerDocument.removeEventListener("click", handleClickRef.current);
347
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
348
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
349
- } else {
350
- handleAndDispatchPointerDownOutsideEvent2();
351
- }
352
- } else {
353
- ownerDocument.removeEventListener("click", handleClickRef.current);
354
- }
355
- isPointerInsideReactTreeRef.current = false;
356
- };
357
- const timerId = window.setTimeout(() => {
358
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
359
- }, 0);
360
- return () => {
361
- window.clearTimeout(timerId);
362
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
363
- ownerDocument.removeEventListener("click", handleClickRef.current);
364
- };
365
- }, [ownerDocument, handlePointerDownOutside]);
366
- return {
367
- // ensures we check React component tree (not just DOM tree)
368
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
369
- };
370
- }
371
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
372
- const handleFocusOutside = useCallbackRef(onFocusOutside);
373
- const isFocusInsideReactTreeRef = React.useRef(false);
374
- React.useEffect(() => {
375
- const handleFocus = (event) => {
376
- if (event.target && !isFocusInsideReactTreeRef.current) {
377
- const eventDetail = { originalEvent: event };
378
- handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
379
- discrete: false
380
- });
381
- }
382
- };
383
- ownerDocument.addEventListener("focusin", handleFocus);
384
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
385
- }, [ownerDocument, handleFocusOutside]);
386
- return {
387
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
388
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
389
- };
390
- }
391
- function dispatchUpdate() {
392
- const event = new CustomEvent(CONTEXT_UPDATE);
393
- document.dispatchEvent(event);
394
- }
395
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
396
- const target = detail.originalEvent.target;
397
- const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
398
- if (handler) target.addEventListener(name, handler, { once: true });
399
- if (discrete) {
400
- dispatchDiscreteCustomEvent(target, event);
401
- } else {
402
- target.dispatchEvent(event);
403
- }
404
- }
405
- var useReactId = React[" useId ".trim().toString()] || (() => void 0);
406
- var count = 0;
407
- function useId(deterministicId) {
408
- const [id, setId] = React.useState(useReactId());
409
- useLayoutEffect2(() => {
410
- setId((reactId) => reactId ?? String(count++));
411
- }, [deterministicId]);
412
- return id ? `radix-${id}` : "";
413
- }
414
- var PORTAL_NAME = "Portal";
415
- var Portal = React.forwardRef((props, forwardedRef) => {
416
- const { container: containerProp, ...portalProps } = props;
417
- const [mounted, setMounted] = React.useState(false);
418
- useLayoutEffect2(() => setMounted(true), []);
419
- const container = containerProp || mounted && globalThis?.document?.body;
420
- return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
421
- });
422
- Portal.displayName = PORTAL_NAME;
423
- function useStateMachine(initialState, machine) {
424
- return React.useReducer((state, event) => {
425
- const nextState = machine[state][event];
426
- return nextState ?? state;
427
- }, initialState);
428
- }
429
- var Presence = (props) => {
430
- const { present, children } = props;
431
- const presence = usePresence(present);
432
- const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
433
- const ref = useComposedRefs(presence.ref, getElementRef(child));
434
- const forceMount = typeof children === "function";
435
- return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
436
- };
437
- Presence.displayName = "Presence";
438
- function usePresence(present) {
439
- const [node, setNode] = React.useState();
440
- const stylesRef = React.useRef(null);
441
- const prevPresentRef = React.useRef(present);
442
- const prevAnimationNameRef = React.useRef("none");
443
- const initialState = present ? "mounted" : "unmounted";
444
- const [state, send] = useStateMachine(initialState, {
445
- mounted: {
446
- UNMOUNT: "unmounted",
447
- ANIMATION_OUT: "unmountSuspended"
448
- },
449
- unmountSuspended: {
450
- MOUNT: "mounted",
451
- ANIMATION_END: "unmounted"
452
- },
453
- unmounted: {
454
- MOUNT: "mounted"
455
- }
456
- });
457
- React.useEffect(() => {
458
- const currentAnimationName = getAnimationName(stylesRef.current);
459
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
460
- }, [state]);
461
- useLayoutEffect2(() => {
462
- const styles = stylesRef.current;
463
- const wasPresent = prevPresentRef.current;
464
- const hasPresentChanged = wasPresent !== present;
465
- if (hasPresentChanged) {
466
- const prevAnimationName = prevAnimationNameRef.current;
467
- const currentAnimationName = getAnimationName(styles);
468
- if (present) {
469
- send("MOUNT");
470
- } else if (currentAnimationName === "none" || styles?.display === "none") {
471
- send("UNMOUNT");
472
- } else {
473
- const isAnimating = prevAnimationName !== currentAnimationName;
474
- if (wasPresent && isAnimating) {
475
- send("ANIMATION_OUT");
476
- } else {
477
- send("UNMOUNT");
478
- }
479
- }
480
- prevPresentRef.current = present;
481
- }
482
- }, [present, send]);
483
- useLayoutEffect2(() => {
484
- if (node) {
485
- let timeoutId;
486
- const ownerWindow = node.ownerDocument.defaultView ?? window;
487
- const handleAnimationEnd = (event) => {
488
- const currentAnimationName = getAnimationName(stylesRef.current);
489
- const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
490
- if (event.target === node && isCurrentAnimation) {
491
- send("ANIMATION_END");
492
- if (!prevPresentRef.current) {
493
- const currentFillMode = node.style.animationFillMode;
494
- node.style.animationFillMode = "forwards";
495
- timeoutId = ownerWindow.setTimeout(() => {
496
- if (node.style.animationFillMode === "forwards") {
497
- node.style.animationFillMode = currentFillMode;
498
- }
499
- });
500
- }
501
- }
502
- };
503
- const handleAnimationStart = (event) => {
504
- if (event.target === node) {
505
- prevAnimationNameRef.current = getAnimationName(stylesRef.current);
506
- }
507
- };
508
- node.addEventListener("animationstart", handleAnimationStart);
509
- node.addEventListener("animationcancel", handleAnimationEnd);
510
- node.addEventListener("animationend", handleAnimationEnd);
511
- return () => {
512
- ownerWindow.clearTimeout(timeoutId);
513
- node.removeEventListener("animationstart", handleAnimationStart);
514
- node.removeEventListener("animationcancel", handleAnimationEnd);
515
- node.removeEventListener("animationend", handleAnimationEnd);
516
- };
517
- } else {
518
- send("ANIMATION_END");
519
- }
520
- }, [node, send]);
521
- return {
522
- isPresent: ["mounted", "unmountSuspended"].includes(state),
523
- ref: React.useCallback((node2) => {
524
- stylesRef.current = node2 ? getComputedStyle(node2) : null;
525
- setNode(node2);
526
- }, [])
527
- };
528
- }
529
- function getAnimationName(styles) {
530
- return styles?.animationName || "none";
531
- }
532
- function getElementRef(element) {
533
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
534
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
535
- if (mayWarn) {
536
- return element.ref;
537
- }
538
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
539
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
540
- if (mayWarn) {
541
- return element.props.ref;
542
- }
543
- return element.props.ref || element.ref;
544
- }
545
- export {
546
- DismissableLayer as D,
547
- Primitive as P,
548
- useControllableState as a,
549
- composeEventHandlers as b,
550
- createContextScope as c,
551
- Presence as d,
552
- Portal as e,
553
- useCallbackRef as f,
554
- useLayoutEffect2 as g,
555
- createContext2 as h,
556
- dispatchDiscreteCustomEvent as i,
557
- useId as u
558
- };
559
- //# sourceMappingURL=index-CuySPbdY.js.map