ingeniuscliq-core 0.4.15 → 0.4.17

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 (78) hide show
  1. package/dist/components/common/logo/Logo.tsx +1 -1
  2. package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +3 -3
  3. package/dist/node_modules/@radix-ui/{react-select/node_modules/@radix-ui/react-popper/node_modules/@radix-ui/react-arrow → react-arrow}/dist/index.js +1 -1
  4. package/dist/node_modules/@radix-ui/react-avatar/dist/index.js +1 -1
  5. package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +2 -2
  6. package/dist/node_modules/@radix-ui/{react-accordion/node_modules/@radix-ui/react-collapsible → react-collapsible}/dist/index.js +7 -7
  7. package/dist/node_modules/@radix-ui/{react-select/node_modules/@radix-ui/react-collection → react-collection}/dist/index.js +3 -3
  8. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +5 -5
  9. package/dist/node_modules/@radix-ui/{react-select/node_modules/@radix-ui/react-dismissable-layer → react-dismissable-layer}/dist/index.js +4 -4
  10. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +2 -2
  11. package/dist/node_modules/@radix-ui/{react-dialog/node_modules/@radix-ui/react-focus-scope → react-focus-scope}/dist/index.js +2 -2
  12. package/dist/node_modules/@radix-ui/react-label/dist/index.js +1 -1
  13. package/dist/node_modules/@radix-ui/{react-dropdown-menu/node_modules/@radix-ui/react-menu → react-menu}/dist/index.js +17 -17
  14. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +6 -6
  15. package/dist/node_modules/@radix-ui/{react-popover/node_modules/@radix-ui/react-popper → react-popper}/dist/index.js +8 -8
  16. package/dist/node_modules/@radix-ui/{react-popover/node_modules/@radix-ui/react-portal → react-portal}/dist/index.js +1 -1
  17. package/dist/node_modules/@radix-ui/{react-popover/node_modules/@radix-ui/react-presence → react-presence}/dist/index.js +2 -2
  18. package/dist/node_modules/@radix-ui/{react-dropdown-menu/node_modules/@radix-ui/react-primitive → react-primitive}/dist/index.js +1 -1
  19. package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +3 -3
  20. package/dist/node_modules/@radix-ui/{react-radio-group/node_modules/@radix-ui/react-roving-focus → react-roving-focus}/dist/index.js +8 -8
  21. package/dist/node_modules/@radix-ui/react-select/dist/index.js +7 -7
  22. package/dist/node_modules/@radix-ui/react-separator/dist/index.js +1 -1
  23. package/dist/node_modules/@radix-ui/react-slider/dist/index.js +2 -2
  24. package/dist/node_modules/@radix-ui/react-switch/dist/index.js +1 -1
  25. package/dist/node_modules/@radix-ui/react-tabs/dist/index.js +3 -3
  26. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +5 -5
  27. package/dist/node_modules/react-i18next/dist/es/defaults.js +2 -1
  28. package/package.json +10 -10
  29. package/src/core/commands/create-core-module.js +288 -0
  30. package/src/core/commands/create-module.js +288 -0
  31. package/src/core/commands/create-template.js +169 -0
  32. package/src/core/commands/rollback-core-module.js +195 -0
  33. package/src/core/commands/rollback-module.js +208 -0
  34. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-collapsible/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  35. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  36. package/dist/node_modules/@radix-ui/react-accordion/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  37. package/dist/node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  38. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  39. package/dist/node_modules/@radix-ui/react-checkbox/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  40. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  41. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
  42. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  43. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  44. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  45. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  46. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
  47. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
  48. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-popper/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
  49. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
  50. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  51. package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -223
  52. package/dist/node_modules/@radix-ui/react-label/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  53. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  54. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
  55. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-popper/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
  56. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  57. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  58. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  59. package/dist/node_modules/@radix-ui/react-radio-group/node_modules/@radix-ui/react-roving-focus/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  60. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
  61. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
  62. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
  63. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  64. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-visually-hidden/dist/index.js +0 -34
  65. package/dist/node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  66. package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  67. package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  68. package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  69. package/dist/node_modules/@radix-ui/react-tabs/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  70. package/dist/node_modules/@radix-ui/react-tabs/node_modules/@radix-ui/react-primitive/dist/index.js +0 -40
  71. package/dist/node_modules/@radix-ui/react-tabs/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -223
  72. package/dist/node_modules/@radix-ui/react-tabs/node_modules/@radix-ui/react-roving-focus/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  73. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  74. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
  75. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-popper/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
  76. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  77. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  78. /package/dist/node_modules/@radix-ui/{react-tooltip/node_modules/@radix-ui/react-visually-hidden → react-visually-hidden}/dist/index.js +0 -0
@@ -1,70 +0,0 @@
1
- import React__default from 'react';
2
- import { createContextScope } from '../../../../../react-context/dist/index.js';
3
- import { useComposedRefs } from '../../../../../react-compose-refs/dist/index.js';
4
- import { createSlot } from '../../../../../react-slot/dist/index.js';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- function createCollection(name) {
8
- const PROVIDER_NAME = name + "CollectionProvider";
9
- const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
10
- const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
11
- PROVIDER_NAME,
12
- { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
13
- );
14
- const CollectionProvider = (props) => {
15
- const { scope, children } = props;
16
- const ref = React__default.useRef(null);
17
- const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
18
- return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
19
- };
20
- CollectionProvider.displayName = PROVIDER_NAME;
21
- const COLLECTION_SLOT_NAME = name + "CollectionSlot";
22
- const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
23
- const CollectionSlot = React__default.forwardRef(
24
- (props, forwardedRef) => {
25
- const { scope, children } = props;
26
- const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
27
- const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
28
- return /* @__PURE__ */ jsx(CollectionSlotImpl, { ref: composedRefs, children });
29
- }
30
- );
31
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
32
- const ITEM_SLOT_NAME = name + "CollectionItemSlot";
33
- const ITEM_DATA_ATTR = "data-radix-collection-item";
34
- const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
35
- const CollectionItemSlot = React__default.forwardRef(
36
- (props, forwardedRef) => {
37
- const { scope, children, ...itemData } = props;
38
- const ref = React__default.useRef(null);
39
- const composedRefs = useComposedRefs(forwardedRef, ref);
40
- const context = useCollectionContext(ITEM_SLOT_NAME, scope);
41
- React__default.useEffect(() => {
42
- context.itemMap.set(ref, { ref, ...itemData });
43
- return () => void context.itemMap.delete(ref);
44
- });
45
- return /* @__PURE__ */ jsx(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
46
- }
47
- );
48
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
49
- function useCollection(scope) {
50
- const context = useCollectionContext(name + "CollectionConsumer", scope);
51
- const getItems = React__default.useCallback(() => {
52
- const collectionNode = context.collectionRef.current;
53
- if (!collectionNode) return [];
54
- const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
55
- const items = Array.from(context.itemMap.values());
56
- const orderedItems = items.sort(
57
- (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
58
- );
59
- return orderedItems;
60
- }, [context.collectionRef, context.itemMap]);
61
- return getItems;
62
- }
63
- return [
64
- { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
65
- useCollection,
66
- createCollectionScope
67
- ];
68
- }
69
-
70
- export { createCollection };
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import 'react-dom';
3
- import { createSlot } from '../../../../../react-slot/dist/index.js';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- // src/primitive.tsx
7
- var NODES = [
8
- "a",
9
- "button",
10
- "div",
11
- "form",
12
- "h2",
13
- "h3",
14
- "img",
15
- "input",
16
- "label",
17
- "li",
18
- "nav",
19
- "ol",
20
- "p",
21
- "select",
22
- "span",
23
- "svg",
24
- "ul"
25
- ];
26
- var Primitive = NODES.reduce((primitive, node) => {
27
- const Slot = createSlot(`Primitive.${node}`);
28
- const Node = React.forwardRef((props, forwardedRef) => {
29
- const { asChild, ...primitiveProps } = props;
30
- const Comp = asChild ? Slot : node;
31
- if (typeof window !== "undefined") {
32
- window[Symbol.for("radix-ui")] = true;
33
- }
34
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
35
- });
36
- Node.displayName = `Primitive.${node}`;
37
- return { ...primitive, [node]: Node };
38
- }, {});
39
-
40
- export { Primitive };
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import 'react-dom';
3
- import { createSlot } from '../../../../../react-slot/dist/index.js';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- // src/primitive.tsx
7
- var NODES = [
8
- "a",
9
- "button",
10
- "div",
11
- "form",
12
- "h2",
13
- "h3",
14
- "img",
15
- "input",
16
- "label",
17
- "li",
18
- "nav",
19
- "ol",
20
- "p",
21
- "select",
22
- "span",
23
- "svg",
24
- "ul"
25
- ];
26
- var Primitive = NODES.reduce((primitive, node) => {
27
- const Slot = createSlot(`Primitive.${node}`);
28
- const Node = React.forwardRef((props, forwardedRef) => {
29
- const { asChild, ...primitiveProps } = props;
30
- const Comp = asChild ? Slot : node;
31
- if (typeof window !== "undefined") {
32
- window[Symbol.for("radix-ui")] = true;
33
- }
34
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
35
- });
36
- Node.displayName = `Primitive.${node}`;
37
- return { ...primitive, [node]: Node };
38
- }, {});
39
-
40
- export { Primitive };
@@ -1,130 +0,0 @@
1
- import * as React from 'react';
2
- import { useComposedRefs } from '../../../../../react-compose-refs/dist/index.js';
3
- import { useLayoutEffect as useLayoutEffect2 } from '../../../../../react-use-layout-effect/dist/index.js';
4
-
5
- function useStateMachine(initialState, machine) {
6
- return React.useReducer((state, event) => {
7
- const nextState = machine[state][event];
8
- return nextState ?? state;
9
- }, initialState);
10
- }
11
-
12
- // src/presence.tsx
13
- var Presence = (props) => {
14
- const { present, children } = props;
15
- const presence = usePresence(present);
16
- const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
17
- const ref = useComposedRefs(presence.ref, getElementRef(child));
18
- const forceMount = typeof children === "function";
19
- return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
20
- };
21
- Presence.displayName = "Presence";
22
- function usePresence(present) {
23
- const [node, setNode] = React.useState();
24
- const stylesRef = React.useRef(null);
25
- const prevPresentRef = React.useRef(present);
26
- const prevAnimationNameRef = React.useRef("none");
27
- const initialState = present ? "mounted" : "unmounted";
28
- const [state, send] = useStateMachine(initialState, {
29
- mounted: {
30
- UNMOUNT: "unmounted",
31
- ANIMATION_OUT: "unmountSuspended"
32
- },
33
- unmountSuspended: {
34
- MOUNT: "mounted",
35
- ANIMATION_END: "unmounted"
36
- },
37
- unmounted: {
38
- MOUNT: "mounted"
39
- }
40
- });
41
- React.useEffect(() => {
42
- const currentAnimationName = getAnimationName(stylesRef.current);
43
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
44
- }, [state]);
45
- useLayoutEffect2(() => {
46
- const styles = stylesRef.current;
47
- const wasPresent = prevPresentRef.current;
48
- const hasPresentChanged = wasPresent !== present;
49
- if (hasPresentChanged) {
50
- const prevAnimationName = prevAnimationNameRef.current;
51
- const currentAnimationName = getAnimationName(styles);
52
- if (present) {
53
- send("MOUNT");
54
- } else if (currentAnimationName === "none" || styles?.display === "none") {
55
- send("UNMOUNT");
56
- } else {
57
- const isAnimating = prevAnimationName !== currentAnimationName;
58
- if (wasPresent && isAnimating) {
59
- send("ANIMATION_OUT");
60
- } else {
61
- send("UNMOUNT");
62
- }
63
- }
64
- prevPresentRef.current = present;
65
- }
66
- }, [present, send]);
67
- useLayoutEffect2(() => {
68
- if (node) {
69
- let timeoutId;
70
- const ownerWindow = node.ownerDocument.defaultView ?? window;
71
- const handleAnimationEnd = (event) => {
72
- const currentAnimationName = getAnimationName(stylesRef.current);
73
- const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
74
- if (event.target === node && isCurrentAnimation) {
75
- send("ANIMATION_END");
76
- if (!prevPresentRef.current) {
77
- const currentFillMode = node.style.animationFillMode;
78
- node.style.animationFillMode = "forwards";
79
- timeoutId = ownerWindow.setTimeout(() => {
80
- if (node.style.animationFillMode === "forwards") {
81
- node.style.animationFillMode = currentFillMode;
82
- }
83
- });
84
- }
85
- }
86
- };
87
- const handleAnimationStart = (event) => {
88
- if (event.target === node) {
89
- prevAnimationNameRef.current = getAnimationName(stylesRef.current);
90
- }
91
- };
92
- node.addEventListener("animationstart", handleAnimationStart);
93
- node.addEventListener("animationcancel", handleAnimationEnd);
94
- node.addEventListener("animationend", handleAnimationEnd);
95
- return () => {
96
- ownerWindow.clearTimeout(timeoutId);
97
- node.removeEventListener("animationstart", handleAnimationStart);
98
- node.removeEventListener("animationcancel", handleAnimationEnd);
99
- node.removeEventListener("animationend", handleAnimationEnd);
100
- };
101
- } else {
102
- send("ANIMATION_END");
103
- }
104
- }, [node, send]);
105
- return {
106
- isPresent: ["mounted", "unmountSuspended"].includes(state),
107
- ref: React.useCallback((node2) => {
108
- stylesRef.current = node2 ? getComputedStyle(node2) : null;
109
- setNode(node2);
110
- }, [])
111
- };
112
- }
113
- function getAnimationName(styles) {
114
- return styles?.animationName || "none";
115
- }
116
- function getElementRef(element) {
117
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
118
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
119
- if (mayWarn) {
120
- return element.ref;
121
- }
122
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
123
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
124
- if (mayWarn) {
125
- return element.props.ref;
126
- }
127
- return element.props.ref || element.ref;
128
- }
129
-
130
- export { Presence };
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import 'react-dom';
3
- import { createSlot } from '../../../../../react-slot/dist/index.js';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- // src/primitive.tsx
7
- var NODES = [
8
- "a",
9
- "button",
10
- "div",
11
- "form",
12
- "h2",
13
- "h3",
14
- "img",
15
- "input",
16
- "label",
17
- "li",
18
- "nav",
19
- "ol",
20
- "p",
21
- "select",
22
- "span",
23
- "svg",
24
- "ul"
25
- ];
26
- var Primitive = NODES.reduce((primitive, node) => {
27
- const Slot = createSlot(`Primitive.${node}`);
28
- const Node = React.forwardRef((props, forwardedRef) => {
29
- const { asChild, ...primitiveProps } = props;
30
- const Comp = asChild ? Slot : node;
31
- if (typeof window !== "undefined") {
32
- window[Symbol.for("radix-ui")] = true;
33
- }
34
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
35
- });
36
- Node.displayName = `Primitive.${node}`;
37
- return { ...primitive, [node]: Node };
38
- }, {});
39
-
40
- export { Primitive };
@@ -1,211 +0,0 @@
1
- import * as React from 'react';
2
- import { composeEventHandlers } from '../../../../../primitive/dist/index.js';
3
- import { Primitive, dispatchDiscreteCustomEvent } from '../../react-primitive/dist/index.js';
4
- import { useComposedRefs } from '../../../../../react-compose-refs/dist/index.js';
5
- import { useCallbackRef } from '../../../../../react-use-callback-ref/dist/index.js';
6
- import { useEscapeKeydown } from '../../../../../react-use-escape-keydown/dist/index.js';
7
- import { jsx } from 'react/jsx-runtime';
8
-
9
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
10
- var CONTEXT_UPDATE = "dismissableLayer.update";
11
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
12
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
13
- var originalBodyPointerEvents;
14
- var DismissableLayerContext = React.createContext({
15
- layers: /* @__PURE__ */ new Set(),
16
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
17
- branches: /* @__PURE__ */ new Set()
18
- });
19
- var DismissableLayer = React.forwardRef(
20
- (props, forwardedRef) => {
21
- const {
22
- disableOutsidePointerEvents = false,
23
- onEscapeKeyDown,
24
- onPointerDownOutside,
25
- onFocusOutside,
26
- onInteractOutside,
27
- onDismiss,
28
- ...layerProps
29
- } = props;
30
- const context = React.useContext(DismissableLayerContext);
31
- const [node, setNode] = React.useState(null);
32
- const ownerDocument = node?.ownerDocument ?? globalThis?.document;
33
- const [, force] = React.useState({});
34
- const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
35
- const layers = Array.from(context.layers);
36
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
37
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
38
- const index = node ? layers.indexOf(node) : -1;
39
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
40
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
41
- const pointerDownOutside = usePointerDownOutside((event) => {
42
- const target = event.target;
43
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
44
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
45
- onPointerDownOutside?.(event);
46
- onInteractOutside?.(event);
47
- if (!event.defaultPrevented) onDismiss?.();
48
- }, ownerDocument);
49
- const focusOutside = useFocusOutside((event) => {
50
- const target = event.target;
51
- const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
52
- if (isFocusInBranch) return;
53
- onFocusOutside?.(event);
54
- onInteractOutside?.(event);
55
- if (!event.defaultPrevented) onDismiss?.();
56
- }, ownerDocument);
57
- useEscapeKeydown((event) => {
58
- const isHighestLayer = index === context.layers.size - 1;
59
- if (!isHighestLayer) return;
60
- onEscapeKeyDown?.(event);
61
- if (!event.defaultPrevented && onDismiss) {
62
- event.preventDefault();
63
- onDismiss();
64
- }
65
- }, ownerDocument);
66
- React.useEffect(() => {
67
- if (!node) return;
68
- if (disableOutsidePointerEvents) {
69
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
70
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
71
- ownerDocument.body.style.pointerEvents = "none";
72
- }
73
- context.layersWithOutsidePointerEventsDisabled.add(node);
74
- }
75
- context.layers.add(node);
76
- dispatchUpdate();
77
- return () => {
78
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
79
- ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
80
- }
81
- };
82
- }, [node, ownerDocument, disableOutsidePointerEvents, context]);
83
- React.useEffect(() => {
84
- return () => {
85
- if (!node) return;
86
- context.layers.delete(node);
87
- context.layersWithOutsidePointerEventsDisabled.delete(node);
88
- dispatchUpdate();
89
- };
90
- }, [node, context]);
91
- React.useEffect(() => {
92
- const handleUpdate = () => force({});
93
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
94
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
95
- }, []);
96
- return /* @__PURE__ */ jsx(
97
- Primitive.div,
98
- {
99
- ...layerProps,
100
- ref: composedRefs,
101
- style: {
102
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
103
- ...props.style
104
- },
105
- onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
106
- onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
107
- onPointerDownCapture: composeEventHandlers(
108
- props.onPointerDownCapture,
109
- pointerDownOutside.onPointerDownCapture
110
- )
111
- }
112
- );
113
- }
114
- );
115
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
116
- var BRANCH_NAME = "DismissableLayerBranch";
117
- var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
118
- const context = React.useContext(DismissableLayerContext);
119
- const ref = React.useRef(null);
120
- const composedRefs = useComposedRefs(forwardedRef, ref);
121
- React.useEffect(() => {
122
- const node = ref.current;
123
- if (node) {
124
- context.branches.add(node);
125
- return () => {
126
- context.branches.delete(node);
127
- };
128
- }
129
- }, [context.branches]);
130
- return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
131
- });
132
- DismissableLayerBranch.displayName = BRANCH_NAME;
133
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
134
- const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
135
- const isPointerInsideReactTreeRef = React.useRef(false);
136
- const handleClickRef = React.useRef(() => {
137
- });
138
- React.useEffect(() => {
139
- const handlePointerDown = (event) => {
140
- if (event.target && !isPointerInsideReactTreeRef.current) {
141
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
142
- handleAndDispatchCustomEvent(
143
- POINTER_DOWN_OUTSIDE,
144
- handlePointerDownOutside,
145
- eventDetail,
146
- { discrete: true }
147
- );
148
- };
149
- const eventDetail = { originalEvent: event };
150
- if (event.pointerType === "touch") {
151
- ownerDocument.removeEventListener("click", handleClickRef.current);
152
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
153
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
154
- } else {
155
- handleAndDispatchPointerDownOutsideEvent2();
156
- }
157
- } else {
158
- ownerDocument.removeEventListener("click", handleClickRef.current);
159
- }
160
- isPointerInsideReactTreeRef.current = false;
161
- };
162
- const timerId = window.setTimeout(() => {
163
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
164
- }, 0);
165
- return () => {
166
- window.clearTimeout(timerId);
167
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
168
- ownerDocument.removeEventListener("click", handleClickRef.current);
169
- };
170
- }, [ownerDocument, handlePointerDownOutside]);
171
- return {
172
- // ensures we check React component tree (not just DOM tree)
173
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
174
- };
175
- }
176
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
177
- const handleFocusOutside = useCallbackRef(onFocusOutside);
178
- const isFocusInsideReactTreeRef = React.useRef(false);
179
- React.useEffect(() => {
180
- const handleFocus = (event) => {
181
- if (event.target && !isFocusInsideReactTreeRef.current) {
182
- const eventDetail = { originalEvent: event };
183
- handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
184
- discrete: false
185
- });
186
- }
187
- };
188
- ownerDocument.addEventListener("focusin", handleFocus);
189
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
190
- }, [ownerDocument, handleFocusOutside]);
191
- return {
192
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
193
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
194
- };
195
- }
196
- function dispatchUpdate() {
197
- const event = new CustomEvent(CONTEXT_UPDATE);
198
- document.dispatchEvent(event);
199
- }
200
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
201
- const target = detail.originalEvent.target;
202
- const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
203
- if (handler) target.addEventListener(name, handler, { once: true });
204
- if (discrete) {
205
- dispatchDiscreteCustomEvent(target, event);
206
- } else {
207
- target.dispatchEvent(event);
208
- }
209
- }
210
-
211
- export { DismissableLayer, DismissableLayerBranch };
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import ReactDOM__default from 'react-dom';
3
- import { Primitive } from '../../react-primitive/dist/index.js';
4
- import { useLayoutEffect as useLayoutEffect2 } from '../../../../../react-use-layout-effect/dist/index.js';
5
- import { jsx } from 'react/jsx-runtime';
6
-
7
- var PORTAL_NAME = "Portal";
8
- var Portal = React.forwardRef((props, forwardedRef) => {
9
- const { container: containerProp, ...portalProps } = props;
10
- const [mounted, setMounted] = React.useState(false);
11
- useLayoutEffect2(() => setMounted(true), []);
12
- const container = containerProp || mounted && globalThis?.document?.body;
13
- return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
14
- });
15
- Portal.displayName = PORTAL_NAME;
16
-
17
- export { Portal };
@@ -1,130 +0,0 @@
1
- import * as React from 'react';
2
- import { useComposedRefs } from '../../../../../react-compose-refs/dist/index.js';
3
- import { useLayoutEffect as useLayoutEffect2 } from '../../../../../react-use-layout-effect/dist/index.js';
4
-
5
- function useStateMachine(initialState, machine) {
6
- return React.useReducer((state, event) => {
7
- const nextState = machine[state][event];
8
- return nextState ?? state;
9
- }, initialState);
10
- }
11
-
12
- // src/presence.tsx
13
- var Presence = (props) => {
14
- const { present, children } = props;
15
- const presence = usePresence(present);
16
- const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
17
- const ref = useComposedRefs(presence.ref, getElementRef(child));
18
- const forceMount = typeof children === "function";
19
- return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
20
- };
21
- Presence.displayName = "Presence";
22
- function usePresence(present) {
23
- const [node, setNode] = React.useState();
24
- const stylesRef = React.useRef(null);
25
- const prevPresentRef = React.useRef(present);
26
- const prevAnimationNameRef = React.useRef("none");
27
- const initialState = present ? "mounted" : "unmounted";
28
- const [state, send] = useStateMachine(initialState, {
29
- mounted: {
30
- UNMOUNT: "unmounted",
31
- ANIMATION_OUT: "unmountSuspended"
32
- },
33
- unmountSuspended: {
34
- MOUNT: "mounted",
35
- ANIMATION_END: "unmounted"
36
- },
37
- unmounted: {
38
- MOUNT: "mounted"
39
- }
40
- });
41
- React.useEffect(() => {
42
- const currentAnimationName = getAnimationName(stylesRef.current);
43
- prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
44
- }, [state]);
45
- useLayoutEffect2(() => {
46
- const styles = stylesRef.current;
47
- const wasPresent = prevPresentRef.current;
48
- const hasPresentChanged = wasPresent !== present;
49
- if (hasPresentChanged) {
50
- const prevAnimationName = prevAnimationNameRef.current;
51
- const currentAnimationName = getAnimationName(styles);
52
- if (present) {
53
- send("MOUNT");
54
- } else if (currentAnimationName === "none" || styles?.display === "none") {
55
- send("UNMOUNT");
56
- } else {
57
- const isAnimating = prevAnimationName !== currentAnimationName;
58
- if (wasPresent && isAnimating) {
59
- send("ANIMATION_OUT");
60
- } else {
61
- send("UNMOUNT");
62
- }
63
- }
64
- prevPresentRef.current = present;
65
- }
66
- }, [present, send]);
67
- useLayoutEffect2(() => {
68
- if (node) {
69
- let timeoutId;
70
- const ownerWindow = node.ownerDocument.defaultView ?? window;
71
- const handleAnimationEnd = (event) => {
72
- const currentAnimationName = getAnimationName(stylesRef.current);
73
- const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
74
- if (event.target === node && isCurrentAnimation) {
75
- send("ANIMATION_END");
76
- if (!prevPresentRef.current) {
77
- const currentFillMode = node.style.animationFillMode;
78
- node.style.animationFillMode = "forwards";
79
- timeoutId = ownerWindow.setTimeout(() => {
80
- if (node.style.animationFillMode === "forwards") {
81
- node.style.animationFillMode = currentFillMode;
82
- }
83
- });
84
- }
85
- }
86
- };
87
- const handleAnimationStart = (event) => {
88
- if (event.target === node) {
89
- prevAnimationNameRef.current = getAnimationName(stylesRef.current);
90
- }
91
- };
92
- node.addEventListener("animationstart", handleAnimationStart);
93
- node.addEventListener("animationcancel", handleAnimationEnd);
94
- node.addEventListener("animationend", handleAnimationEnd);
95
- return () => {
96
- ownerWindow.clearTimeout(timeoutId);
97
- node.removeEventListener("animationstart", handleAnimationStart);
98
- node.removeEventListener("animationcancel", handleAnimationEnd);
99
- node.removeEventListener("animationend", handleAnimationEnd);
100
- };
101
- } else {
102
- send("ANIMATION_END");
103
- }
104
- }, [node, send]);
105
- return {
106
- isPresent: ["mounted", "unmountSuspended"].includes(state),
107
- ref: React.useCallback((node2) => {
108
- stylesRef.current = node2 ? getComputedStyle(node2) : null;
109
- setNode(node2);
110
- }, [])
111
- };
112
- }
113
- function getAnimationName(styles) {
114
- return styles?.animationName || "none";
115
- }
116
- function getElementRef(element) {
117
- let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
118
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
119
- if (mayWarn) {
120
- return element.ref;
121
- }
122
- getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
123
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
124
- if (mayWarn) {
125
- return element.props.ref;
126
- }
127
- return element.props.ref || element.ref;
128
- }
129
-
130
- export { Presence };