@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.7 → 6.2.3-dev.71
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/browser/document-models/index.js +2 -1
- package/dist/browser/documents-BLZ-QW5b.js +16 -0
- package/dist/browser/documents-BLZ-QW5b.js.map +1 -0
- package/dist/browser/{editor-DHysndk4.js → editor-Dmpkd8pQ.js} +4 -5
- package/dist/browser/{editor-DHysndk4.js.map → editor-Dmpkd8pQ.js.map} +1 -1
- package/dist/browser/{editor-6T4WF2og.js → editor-x1UIfSot.js} +740 -272
- package/dist/browser/editor-x1UIfSot.js.map +1 -0
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/document-model-editor/module.js.map +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -324
- package/dist/browser/editors/generic-drive-explorer/index.js.map +1 -1
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/module.js.map +1 -1
- package/dist/browser/{folder-view-DTewe8q8.js → folder-view-CwIU4XEe.js} +17 -12
- package/dist/browser/folder-view-CwIU4XEe.js.map +1 -0
- package/dist/browser/graphql-editor-CpcGaYmP.js +103 -0
- package/dist/browser/graphql-editor-CpcGaYmP.js.map +1 -0
- package/dist/browser/hooks-BmHa-lY2.js +126 -0
- package/dist/browser/hooks-BmHa-lY2.js.map +1 -0
- package/dist/browser/index.js +6 -703
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/json-editor-CB1XmZgN.js +55 -0
- package/dist/browser/json-editor-CB1XmZgN.js.map +1 -0
- package/dist/browser/{schema-context-ZyeclQwy.js → schema-context-5evhtuMb.js} +6 -5
- package/dist/browser/{schema-context-ZyeclQwy.js.map → schema-context-5evhtuMb.js.map} +1 -1
- package/dist/browser/{state-schemas-CpcWN_Qo.js → state-schemas-DHLAg1w0.js} +20 -18
- package/dist/browser/state-schemas-DHLAg1w0.js.map +1 -0
- package/dist/{browser/dist-BAJ5nRDl.js → node/bundle-mjs-Cuu3DEfT.mjs} +1251 -822
- package/dist/node/bundle-mjs-Cuu3DEfT.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +2 -1
- package/dist/node/{graphql-BfAoPeWM.mjs → documents-CFiuC6XV.mjs} +64 -50
- package/dist/node/documents-CFiuC6XV.mjs.map +1 -0
- package/dist/node/editor-7g9ujMII.mjs +4747 -0
- package/dist/node/editor-7g9ujMII.mjs.map +1 -0
- package/dist/node/{editor-DPv5LEug.mjs → editor-NwTlNx8z.mjs} +4 -5
- package/dist/node/{editor-DPv5LEug.mjs.map → editor-NwTlNx8z.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/document-model-editor/module.mjs.map +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +26 -21
- package/dist/node/editors/generic-drive-explorer/index.mjs.map +1 -1
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/module.mjs.map +1 -1
- package/dist/node/folder-view-CkCNU8A_.mjs +966 -0
- package/dist/node/folder-view-CkCNU8A_.mjs.map +1 -0
- package/dist/node/{graphql-editor-D0CHQeCL.mjs → graphql-editor-v1OXETjM.mjs} +5130 -63
- package/dist/node/graphql-editor-v1OXETjM.mjs.map +1 -0
- package/dist/node/{hooks-D0DcS3MV.mjs → hooks-gEAaW5rF.mjs} +824 -444
- package/dist/node/{hooks-D0DcS3MV.mjs.map → hooks-gEAaW5rF.mjs.map} +1 -1
- package/dist/node/index.mjs +38 -90
- package/dist/node/index.mjs.map +1 -1
- package/dist/{browser/json-editor-xI_oaxyT.js → node/json-editor-8dfjgcaX.mjs} +8 -9
- package/dist/node/{json-editor-Ckaem6ky.mjs.map → json-editor-8dfjgcaX.mjs.map} +1 -1
- package/dist/node/rolldown-runtime-Bl3dcgcQ.mjs +16 -0
- package/dist/node/{schema-context-DL8jhi_d.mjs → schema-context-DgUu7l_Q.mjs} +5 -5
- package/dist/node/schema-context-DgUu7l_Q.mjs.map +1 -0
- package/dist/node/state-schemas-DXWpf1zO.mjs +1064 -0
- package/dist/node/state-schemas-DXWpf1zO.mjs.map +1 -0
- package/package.json +25 -23
- package/style.css +2 -0
- package/dist/browser/assets/entry-DSBtQnit.js +0 -314
- package/dist/browser/assets/projection-entry-Bem3exmO.js +0 -404
- package/dist/browser/button-CuO8Gh3v.js +0 -696
- package/dist/browser/button-CuO8Gh3v.js.map +0 -1
- package/dist/browser/connect-5NZDVmbb.js +0 -14328
- package/dist/browser/connect-5NZDVmbb.js.map +0 -1
- package/dist/browser/dist-1yB-AuT-.js +0 -4641
- package/dist/browser/dist-1yB-AuT-.js.map +0 -1
- package/dist/browser/dist-B4FWbuEM.js +0 -4148
- package/dist/browser/dist-B4FWbuEM.js.map +0 -1
- package/dist/browser/dist-BAJ5nRDl.js.map +0 -1
- package/dist/browser/document-drive-CrvzV1D4.js +0 -8319
- package/dist/browser/document-drive-CrvzV1D4.js.map +0 -1
- package/dist/browser/documents-J_l59mSV.js +0 -6188
- package/dist/browser/documents-J_l59mSV.js.map +0 -1
- package/dist/browser/editor-6T4WF2og.js.map +0 -1
- package/dist/browser/folder-view-DTewe8q8.js.map +0 -1
- package/dist/browser/graphql-editor-C2EtXqb9.js +0 -11698
- package/dist/browser/graphql-editor-C2EtXqb9.js.map +0 -1
- package/dist/browser/hooks-KKcNp2X0.js +0 -24213
- package/dist/browser/hooks-KKcNp2X0.js.map +0 -1
- package/dist/browser/json-editor-xI_oaxyT.js.map +0 -1
- package/dist/browser/lib-CPkPeg_u.js +0 -209
- package/dist/browser/lib-CPkPeg_u.js.map +0 -1
- package/dist/browser/parser-CkF6Qt8V.js +0 -2553
- package/dist/browser/parser-CkF6Qt8V.js.map +0 -1
- package/dist/browser/printer-CEYr4JOg.js +0 -604
- package/dist/browser/printer-CEYr4JOg.js.map +0 -1
- package/dist/browser/state-schemas-CpcWN_Qo.js.map +0 -1
- package/dist/node/button-Da7CxMn7.mjs +0 -678
- package/dist/node/button-Da7CxMn7.mjs.map +0 -1
- package/dist/node/connect-cjzsd2cR.mjs +0 -15022
- package/dist/node/connect-cjzsd2cR.mjs.map +0 -1
- package/dist/node/dist-C30J_pcg.mjs +0 -4649
- package/dist/node/dist-C30J_pcg.mjs.map +0 -1
- package/dist/node/dist-CzYOpeXN.mjs +0 -2711
- package/dist/node/dist-CzYOpeXN.mjs.map +0 -1
- package/dist/node/dist-DT7jI9ol.mjs +0 -4148
- package/dist/node/dist-DT7jI9ol.mjs.map +0 -1
- package/dist/node/document-drive-BByBwg-I.mjs +0 -8336
- package/dist/node/document-drive-BByBwg-I.mjs.map +0 -1
- package/dist/node/documents-DCf53bzO.mjs +0 -747
- package/dist/node/documents-DCf53bzO.mjs.map +0 -1
- package/dist/node/editor-B4vhYrmV.mjs +0 -1809
- package/dist/node/editor-B4vhYrmV.mjs.map +0 -1
- package/dist/node/folder-view-BhackcXO.mjs +0 -232
- package/dist/node/folder-view-BhackcXO.mjs.map +0 -1
- package/dist/node/graphql-BfAoPeWM.mjs.map +0 -1
- package/dist/node/graphql-editor-D0CHQeCL.mjs.map +0 -1
- package/dist/node/json-editor-Ckaem6ky.mjs +0 -154
- package/dist/node/main-BhH_ajBM.mjs +0 -745
- package/dist/node/main-BhH_ajBM.mjs.map +0 -1
- package/dist/node/schema-context-DL8jhi_d.mjs.map +0 -1
- package/dist/node/state-schemas-B1SNl8Ob.mjs +0 -299
- package/dist/node/state-schemas-B1SNl8Ob.mjs.map +0 -1
|
@@ -0,0 +1,1064 @@
|
|
|
1
|
+
import { t as twMerge } from "./bundle-mjs-Cuu3DEfT.mjs";
|
|
2
|
+
import { a as require_graphql, r as typeDefsDoc } from "./documents-CFiuC6XV.mjs";
|
|
3
|
+
import { n as safeParseSdl, r as useSchemaContext } from "./schema-context-DgUu7l_Q.mjs";
|
|
4
|
+
import { a as ensureValidStateSchemaName, c as makeMinimalObjectForStateType, i as Button, l as makeStateSchemaNameForScope, n as composeRefs, o as StateValidationError, r as useComposedRefs, s as makeInitialSchemaDoc, u as validateStateObject } from "./editor-7g9ujMII.mjs";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import React, { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
+
import "@powerhousedao/design-system/connect";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import "react-dom";
|
|
10
|
+
//#region editors/document-model-editor/components/state-error.tsx
|
|
11
|
+
var import_graphql = require_graphql();
|
|
12
|
+
function StateValidationErrorMessage({ error }) {
|
|
13
|
+
const { payload } = error;
|
|
14
|
+
switch (payload.kind) {
|
|
15
|
+
case "MISSING": return /* @__PURE__ */ jsxs("span", { children: [
|
|
16
|
+
"Field ",
|
|
17
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
18
|
+
" is missing."
|
|
19
|
+
] });
|
|
20
|
+
case "MISSING_OPTIONAL": return /* @__PURE__ */ jsxs("span", { children: [
|
|
21
|
+
"Optional field ",
|
|
22
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
23
|
+
" is not defined."
|
|
24
|
+
] });
|
|
25
|
+
case "UNKNOWN_FIELD": return /* @__PURE__ */ jsxs("span", { children: [
|
|
26
|
+
"Field ",
|
|
27
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
28
|
+
" is not a known field."
|
|
29
|
+
] });
|
|
30
|
+
case "NON_NULL": return /* @__PURE__ */ jsxs("span", { children: [
|
|
31
|
+
"Field ",
|
|
32
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
33
|
+
" cannot be null."
|
|
34
|
+
] });
|
|
35
|
+
case "TYPE": return /* @__PURE__ */ jsxs("span", { children: [
|
|
36
|
+
"Field ",
|
|
37
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
38
|
+
payload.expectedType ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
" ",
|
|
40
|
+
"must be a",
|
|
41
|
+
" ",
|
|
42
|
+
/* @__PURE__ */ jsx("strong", { children: payload.expectedType.replace(/!/g, "") }),
|
|
43
|
+
"."
|
|
44
|
+
] }) : /* @__PURE__ */ jsx(Fragment, { children: " has an invalid value." })
|
|
45
|
+
] });
|
|
46
|
+
case "RECURSIVE_TYPE": return /* @__PURE__ */ jsxs("span", { children: [
|
|
47
|
+
"Field ",
|
|
48
|
+
/* @__PURE__ */ jsx("strong", { children: payload.typeName }),
|
|
49
|
+
" has a recursive type. It must be optional."
|
|
50
|
+
] });
|
|
51
|
+
default: return /* @__PURE__ */ jsx("span", { children: "Invalid value." });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
typeof window !== "undefined" && window.document && window.document.createElement;
|
|
55
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
56
|
+
return function handleEvent(event) {
|
|
57
|
+
originalEventHandler?.(event);
|
|
58
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) return ourEventHandler?.(event);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-context@1.1.2_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-context/dist/index.mjs
|
|
63
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
64
|
+
let defaultContexts = [];
|
|
65
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
66
|
+
const BaseContext = React$1.createContext(defaultContext);
|
|
67
|
+
const index = defaultContexts.length;
|
|
68
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
69
|
+
const Provider = (props) => {
|
|
70
|
+
const { scope, children, ...context } = props;
|
|
71
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
72
|
+
const value = React$1.useMemo(() => context, Object.values(context));
|
|
73
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
74
|
+
value,
|
|
75
|
+
children
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
79
|
+
function useContext2(consumerName, scope) {
|
|
80
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
81
|
+
const context = React$1.useContext(Context);
|
|
82
|
+
if (context) return context;
|
|
83
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
84
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
85
|
+
}
|
|
86
|
+
return [Provider, useContext2];
|
|
87
|
+
}
|
|
88
|
+
const createScope = () => {
|
|
89
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
90
|
+
return React$1.createContext(defaultContext);
|
|
91
|
+
});
|
|
92
|
+
return function useScope(scope) {
|
|
93
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
94
|
+
return React$1.useMemo(() => ({ [`__scope${scopeName}`]: {
|
|
95
|
+
...scope,
|
|
96
|
+
[scopeName]: contexts
|
|
97
|
+
} }), [scope, contexts]);
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
createScope.scopeName = scopeName;
|
|
101
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
102
|
+
}
|
|
103
|
+
function composeContextScopes(...scopes) {
|
|
104
|
+
const baseScope = scopes[0];
|
|
105
|
+
if (scopes.length === 1) return baseScope;
|
|
106
|
+
const createScope = () => {
|
|
107
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
108
|
+
useScope: createScope2(),
|
|
109
|
+
scopeName: createScope2.scopeName
|
|
110
|
+
}));
|
|
111
|
+
return function useComposedScopes(overrideScopes) {
|
|
112
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
113
|
+
const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
|
|
114
|
+
return {
|
|
115
|
+
...nextScopes2,
|
|
116
|
+
...currentScope
|
|
117
|
+
};
|
|
118
|
+
}, {});
|
|
119
|
+
return React$1.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
createScope.scopeName = baseScope.scopeName;
|
|
123
|
+
return createScope;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-slot@1.2.3_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
127
|
+
// @__NO_SIDE_EFFECTS__
|
|
128
|
+
function createSlot(ownerName) {
|
|
129
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
130
|
+
const Slot2 = React$1.forwardRef((props, forwardedRef) => {
|
|
131
|
+
const { children, ...slotProps } = props;
|
|
132
|
+
const childrenArray = React$1.Children.toArray(children);
|
|
133
|
+
const slottable = childrenArray.find(isSlottable);
|
|
134
|
+
if (slottable) {
|
|
135
|
+
const newElement = slottable.props.children;
|
|
136
|
+
const newChildren = childrenArray.map((child) => {
|
|
137
|
+
if (child === slottable) {
|
|
138
|
+
if (React$1.Children.count(newElement) > 1) return React$1.Children.only(null);
|
|
139
|
+
return React$1.isValidElement(newElement) ? newElement.props.children : null;
|
|
140
|
+
} else return child;
|
|
141
|
+
});
|
|
142
|
+
return /* @__PURE__ */ jsx(SlotClone, {
|
|
143
|
+
...slotProps,
|
|
144
|
+
ref: forwardedRef,
|
|
145
|
+
children: React$1.isValidElement(newElement) ? React$1.cloneElement(newElement, void 0, newChildren) : null
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return /* @__PURE__ */ jsx(SlotClone, {
|
|
149
|
+
...slotProps,
|
|
150
|
+
ref: forwardedRef,
|
|
151
|
+
children
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
155
|
+
return Slot2;
|
|
156
|
+
}
|
|
157
|
+
// @__NO_SIDE_EFFECTS__
|
|
158
|
+
function createSlotClone(ownerName) {
|
|
159
|
+
const SlotClone = React$1.forwardRef((props, forwardedRef) => {
|
|
160
|
+
const { children, ...slotProps } = props;
|
|
161
|
+
if (React$1.isValidElement(children)) {
|
|
162
|
+
const childrenRef = getElementRef$1(children);
|
|
163
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
164
|
+
if (children.type !== React$1.Fragment) props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
165
|
+
return React$1.cloneElement(children, props2);
|
|
166
|
+
}
|
|
167
|
+
return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
|
|
168
|
+
});
|
|
169
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
170
|
+
return SlotClone;
|
|
171
|
+
}
|
|
172
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
173
|
+
function isSlottable(child) {
|
|
174
|
+
return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
175
|
+
}
|
|
176
|
+
function mergeProps(slotProps, childProps) {
|
|
177
|
+
const overrideProps = { ...childProps };
|
|
178
|
+
for (const propName in childProps) {
|
|
179
|
+
const slotPropValue = slotProps[propName];
|
|
180
|
+
const childPropValue = childProps[propName];
|
|
181
|
+
if (/^on[A-Z]/.test(propName)) {
|
|
182
|
+
if (slotPropValue && childPropValue) overrideProps[propName] = (...args) => {
|
|
183
|
+
const result = childPropValue(...args);
|
|
184
|
+
slotPropValue(...args);
|
|
185
|
+
return result;
|
|
186
|
+
};
|
|
187
|
+
else if (slotPropValue) overrideProps[propName] = slotPropValue;
|
|
188
|
+
} else if (propName === "style") overrideProps[propName] = {
|
|
189
|
+
...slotPropValue,
|
|
190
|
+
...childPropValue
|
|
191
|
+
};
|
|
192
|
+
else if (propName === "className") overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
...slotProps,
|
|
196
|
+
...overrideProps
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function getElementRef$1(element) {
|
|
200
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
201
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
202
|
+
if (mayWarn) return element.ref;
|
|
203
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
204
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
205
|
+
if (mayWarn) return element.props.ref;
|
|
206
|
+
return element.props.ref || element.ref;
|
|
207
|
+
}
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-collection@1.1.7_@types+react-dom@19.2.3_@types+react@19.2.14__@types+r_b94f5365b88697a700662930c56ccffc/node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
210
|
+
function createCollection(name) {
|
|
211
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
212
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
213
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
214
|
+
collectionRef: { current: null },
|
|
215
|
+
itemMap: /* @__PURE__ */ new Map()
|
|
216
|
+
});
|
|
217
|
+
const CollectionProvider = (props) => {
|
|
218
|
+
const { scope, children } = props;
|
|
219
|
+
const ref = React.useRef(null);
|
|
220
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
221
|
+
return /* @__PURE__ */ jsx(CollectionProviderImpl, {
|
|
222
|
+
scope,
|
|
223
|
+
itemMap,
|
|
224
|
+
collectionRef: ref,
|
|
225
|
+
children
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
229
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
230
|
+
const CollectionSlotImpl = /* @__PURE__ */ createSlot(COLLECTION_SLOT_NAME);
|
|
231
|
+
const CollectionSlot = React.forwardRef((props, forwardedRef) => {
|
|
232
|
+
const { scope, children } = props;
|
|
233
|
+
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
234
|
+
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
235
|
+
return /* @__PURE__ */ jsx(CollectionSlotImpl, {
|
|
236
|
+
ref: composedRefs,
|
|
237
|
+
children
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
241
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
242
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
243
|
+
const CollectionItemSlotImpl = /* @__PURE__ */ createSlot(ITEM_SLOT_NAME);
|
|
244
|
+
const CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
|
|
245
|
+
const { scope, children, ...itemData } = props;
|
|
246
|
+
const ref = React.useRef(null);
|
|
247
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
248
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
249
|
+
React.useEffect(() => {
|
|
250
|
+
context.itemMap.set(ref, {
|
|
251
|
+
ref,
|
|
252
|
+
...itemData
|
|
253
|
+
});
|
|
254
|
+
return () => void context.itemMap.delete(ref);
|
|
255
|
+
});
|
|
256
|
+
return /* @__PURE__ */ jsx(CollectionItemSlotImpl, {
|
|
257
|
+
[ITEM_DATA_ATTR]: "",
|
|
258
|
+
ref: composedRefs,
|
|
259
|
+
children
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
263
|
+
function useCollection(scope) {
|
|
264
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
265
|
+
return React.useCallback(() => {
|
|
266
|
+
const collectionNode = context.collectionRef.current;
|
|
267
|
+
if (!collectionNode) return [];
|
|
268
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
269
|
+
return Array.from(context.itemMap.values()).sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
|
|
270
|
+
}, [context.collectionRef, context.itemMap]);
|
|
271
|
+
}
|
|
272
|
+
return [
|
|
273
|
+
{
|
|
274
|
+
Provider: CollectionProvider,
|
|
275
|
+
Slot: CollectionSlot,
|
|
276
|
+
ItemSlot: CollectionItemSlot
|
|
277
|
+
},
|
|
278
|
+
useCollection,
|
|
279
|
+
createCollectionScope
|
|
280
|
+
];
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-use-layout-effect@1.1.1_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
284
|
+
var useLayoutEffect2 = globalThis?.document ? React$1.useLayoutEffect : () => {};
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-id@1.1.1_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-id/dist/index.mjs
|
|
287
|
+
var useReactId = React$1[" useId ".trim().toString()] || (() => void 0);
|
|
288
|
+
var count = 0;
|
|
289
|
+
function useId$1(deterministicId) {
|
|
290
|
+
const [id, setId] = React$1.useState(useReactId());
|
|
291
|
+
useLayoutEffect2(() => {
|
|
292
|
+
if (!deterministicId) setId((reactId) => reactId ?? String(count++));
|
|
293
|
+
}, [deterministicId]);
|
|
294
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
297
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.3_@types+react-dom@19.2.3_@types+react@19.2.14__@types+re_0935c7b95cefcdb4f10a34e92035e5e3/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
298
|
+
var Primitive = [
|
|
299
|
+
"a",
|
|
300
|
+
"button",
|
|
301
|
+
"div",
|
|
302
|
+
"form",
|
|
303
|
+
"h2",
|
|
304
|
+
"h3",
|
|
305
|
+
"img",
|
|
306
|
+
"input",
|
|
307
|
+
"label",
|
|
308
|
+
"li",
|
|
309
|
+
"nav",
|
|
310
|
+
"ol",
|
|
311
|
+
"p",
|
|
312
|
+
"select",
|
|
313
|
+
"span",
|
|
314
|
+
"svg",
|
|
315
|
+
"ul"
|
|
316
|
+
].reduce((primitive, node) => {
|
|
317
|
+
const Slot = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
318
|
+
const Node = React$1.forwardRef((props, forwardedRef) => {
|
|
319
|
+
const { asChild, ...primitiveProps } = props;
|
|
320
|
+
const Comp = asChild ? Slot : node;
|
|
321
|
+
if (typeof window !== "undefined") window[Symbol.for("radix-ui")] = true;
|
|
322
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
323
|
+
...primitiveProps,
|
|
324
|
+
ref: forwardedRef
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
Node.displayName = `Primitive.${node}`;
|
|
328
|
+
return {
|
|
329
|
+
...primitive,
|
|
330
|
+
[node]: Node
|
|
331
|
+
};
|
|
332
|
+
}, {});
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-use-callback-ref@1.1.1_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs
|
|
335
|
+
function useCallbackRef(callback) {
|
|
336
|
+
const callbackRef = React$1.useRef(callback);
|
|
337
|
+
React$1.useEffect(() => {
|
|
338
|
+
callbackRef.current = callback;
|
|
339
|
+
});
|
|
340
|
+
return React$1.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
341
|
+
}
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-use-controllable-state@1.2.2_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
344
|
+
var useInsertionEffect = React$1[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
345
|
+
function useControllableState({ prop, defaultProp, onChange = () => {}, caller }) {
|
|
346
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
347
|
+
defaultProp,
|
|
348
|
+
onChange
|
|
349
|
+
});
|
|
350
|
+
const isControlled = prop !== void 0;
|
|
351
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
352
|
+
{
|
|
353
|
+
const isControlledRef = React$1.useRef(prop !== void 0);
|
|
354
|
+
React$1.useEffect(() => {
|
|
355
|
+
const wasControlled = isControlledRef.current;
|
|
356
|
+
if (wasControlled !== isControlled) console.warn(`${caller} is changing from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}. 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.`);
|
|
357
|
+
isControlledRef.current = isControlled;
|
|
358
|
+
}, [isControlled, caller]);
|
|
359
|
+
}
|
|
360
|
+
return [value, React$1.useCallback((nextValue) => {
|
|
361
|
+
if (isControlled) {
|
|
362
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
363
|
+
if (value2 !== prop) onChangeRef.current?.(value2);
|
|
364
|
+
} else setUncontrolledProp(nextValue);
|
|
365
|
+
}, [
|
|
366
|
+
isControlled,
|
|
367
|
+
prop,
|
|
368
|
+
setUncontrolledProp,
|
|
369
|
+
onChangeRef
|
|
370
|
+
])];
|
|
371
|
+
}
|
|
372
|
+
function useUncontrolledState({ defaultProp, onChange }) {
|
|
373
|
+
const [value, setValue] = React$1.useState(defaultProp);
|
|
374
|
+
const prevValueRef = React$1.useRef(value);
|
|
375
|
+
const onChangeRef = React$1.useRef(onChange);
|
|
376
|
+
useInsertionEffect(() => {
|
|
377
|
+
onChangeRef.current = onChange;
|
|
378
|
+
}, [onChange]);
|
|
379
|
+
React$1.useEffect(() => {
|
|
380
|
+
if (prevValueRef.current !== value) {
|
|
381
|
+
onChangeRef.current?.(value);
|
|
382
|
+
prevValueRef.current = value;
|
|
383
|
+
}
|
|
384
|
+
}, [value, prevValueRef]);
|
|
385
|
+
return [
|
|
386
|
+
value,
|
|
387
|
+
setValue,
|
|
388
|
+
onChangeRef
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
function isFunction(value) {
|
|
392
|
+
return typeof value === "function";
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-direction@1.1.1_@types+react@19.2.14_react@19.2.6/node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
396
|
+
var DirectionContext = React$1.createContext(void 0);
|
|
397
|
+
function useDirection(localDir) {
|
|
398
|
+
const globalDir = React$1.useContext(DirectionContext);
|
|
399
|
+
return localDir || globalDir || "ltr";
|
|
400
|
+
}
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-roving-focus@1.1.11_@types+react-dom@19.2.3_@types+react@19.2.14__@type_b849ea542e77d5b397b1fe12d9f00b2e/node_modules/@radix-ui/react-roving-focus/dist/index.mjs
|
|
403
|
+
var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
|
|
404
|
+
var EVENT_OPTIONS = {
|
|
405
|
+
bubbles: false,
|
|
406
|
+
cancelable: true
|
|
407
|
+
};
|
|
408
|
+
var GROUP_NAME = "RovingFocusGroup";
|
|
409
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(GROUP_NAME);
|
|
410
|
+
var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(GROUP_NAME, [createCollectionScope]);
|
|
411
|
+
var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
|
|
412
|
+
var RovingFocusGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
413
|
+
return /* @__PURE__ */ jsx(Collection.Provider, {
|
|
414
|
+
scope: props.__scopeRovingFocusGroup,
|
|
415
|
+
children: /* @__PURE__ */ jsx(Collection.Slot, {
|
|
416
|
+
scope: props.__scopeRovingFocusGroup,
|
|
417
|
+
children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, {
|
|
418
|
+
...props,
|
|
419
|
+
ref: forwardedRef
|
|
420
|
+
})
|
|
421
|
+
})
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
RovingFocusGroup.displayName = GROUP_NAME;
|
|
425
|
+
var RovingFocusGroupImpl = React$1.forwardRef((props, forwardedRef) => {
|
|
426
|
+
const { __scopeRovingFocusGroup, orientation, loop = false, dir, currentTabStopId: currentTabStopIdProp, defaultCurrentTabStopId, onCurrentTabStopIdChange, onEntryFocus, preventScrollOnEntryFocus = false, ...groupProps } = props;
|
|
427
|
+
const ref = React$1.useRef(null);
|
|
428
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
429
|
+
const direction = useDirection(dir);
|
|
430
|
+
const [currentTabStopId, setCurrentTabStopId] = useControllableState({
|
|
431
|
+
prop: currentTabStopIdProp,
|
|
432
|
+
defaultProp: defaultCurrentTabStopId ?? null,
|
|
433
|
+
onChange: onCurrentTabStopIdChange,
|
|
434
|
+
caller: GROUP_NAME
|
|
435
|
+
});
|
|
436
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React$1.useState(false);
|
|
437
|
+
const handleEntryFocus = useCallbackRef(onEntryFocus);
|
|
438
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
439
|
+
const isClickFocusRef = React$1.useRef(false);
|
|
440
|
+
const [focusableItemsCount, setFocusableItemsCount] = React$1.useState(0);
|
|
441
|
+
React$1.useEffect(() => {
|
|
442
|
+
const node = ref.current;
|
|
443
|
+
if (node) {
|
|
444
|
+
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
445
|
+
return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
446
|
+
}
|
|
447
|
+
}, [handleEntryFocus]);
|
|
448
|
+
return /* @__PURE__ */ jsx(RovingFocusProvider, {
|
|
449
|
+
scope: __scopeRovingFocusGroup,
|
|
450
|
+
orientation,
|
|
451
|
+
dir: direction,
|
|
452
|
+
loop,
|
|
453
|
+
currentTabStopId,
|
|
454
|
+
onItemFocus: React$1.useCallback((tabStopId) => setCurrentTabStopId(tabStopId), [setCurrentTabStopId]),
|
|
455
|
+
onItemShiftTab: React$1.useCallback(() => setIsTabbingBackOut(true), []),
|
|
456
|
+
onFocusableItemAdd: React$1.useCallback(() => setFocusableItemsCount((prevCount) => prevCount + 1), []),
|
|
457
|
+
onFocusableItemRemove: React$1.useCallback(() => setFocusableItemsCount((prevCount) => prevCount - 1), []),
|
|
458
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
459
|
+
tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
|
|
460
|
+
"data-orientation": orientation,
|
|
461
|
+
...groupProps,
|
|
462
|
+
ref: composedRefs,
|
|
463
|
+
style: {
|
|
464
|
+
outline: "none",
|
|
465
|
+
...props.style
|
|
466
|
+
},
|
|
467
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, () => {
|
|
468
|
+
isClickFocusRef.current = true;
|
|
469
|
+
}),
|
|
470
|
+
onFocus: composeEventHandlers(props.onFocus, (event) => {
|
|
471
|
+
const isKeyboardFocus = !isClickFocusRef.current;
|
|
472
|
+
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
473
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
474
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
475
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
476
|
+
const items = getItems().filter((item) => item.focusable);
|
|
477
|
+
focusFirst([
|
|
478
|
+
items.find((item) => item.active),
|
|
479
|
+
items.find((item) => item.id === currentTabStopId),
|
|
480
|
+
...items
|
|
481
|
+
].filter(Boolean).map((item) => item.ref.current), preventScrollOnEntryFocus);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
isClickFocusRef.current = false;
|
|
485
|
+
}),
|
|
486
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
|
|
487
|
+
})
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
var ITEM_NAME = "RovingFocusGroupItem";
|
|
491
|
+
var RovingFocusGroupItem = React$1.forwardRef((props, forwardedRef) => {
|
|
492
|
+
const { __scopeRovingFocusGroup, focusable = true, active = false, tabStopId, children, ...itemProps } = props;
|
|
493
|
+
const autoId = useId$1();
|
|
494
|
+
const id = tabStopId || autoId;
|
|
495
|
+
const context = useRovingFocusContext(ITEM_NAME, __scopeRovingFocusGroup);
|
|
496
|
+
const isCurrentTabStop = context.currentTabStopId === id;
|
|
497
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
498
|
+
const { onFocusableItemAdd, onFocusableItemRemove, currentTabStopId } = context;
|
|
499
|
+
React$1.useEffect(() => {
|
|
500
|
+
if (focusable) {
|
|
501
|
+
onFocusableItemAdd();
|
|
502
|
+
return () => onFocusableItemRemove();
|
|
503
|
+
}
|
|
504
|
+
}, [
|
|
505
|
+
focusable,
|
|
506
|
+
onFocusableItemAdd,
|
|
507
|
+
onFocusableItemRemove
|
|
508
|
+
]);
|
|
509
|
+
return /* @__PURE__ */ jsx(Collection.ItemSlot, {
|
|
510
|
+
scope: __scopeRovingFocusGroup,
|
|
511
|
+
id,
|
|
512
|
+
focusable,
|
|
513
|
+
active,
|
|
514
|
+
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
515
|
+
tabIndex: isCurrentTabStop ? 0 : -1,
|
|
516
|
+
"data-orientation": context.orientation,
|
|
517
|
+
...itemProps,
|
|
518
|
+
ref: forwardedRef,
|
|
519
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
520
|
+
if (!focusable) event.preventDefault();
|
|
521
|
+
else context.onItemFocus(id);
|
|
522
|
+
}),
|
|
523
|
+
onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
|
|
524
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
525
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
526
|
+
context.onItemShiftTab();
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (event.target !== event.currentTarget) return;
|
|
530
|
+
const focusIntent = getFocusIntent(event, context.orientation, context.dir);
|
|
531
|
+
if (focusIntent !== void 0) {
|
|
532
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
|
|
533
|
+
event.preventDefault();
|
|
534
|
+
let candidateNodes = getItems().filter((item) => item.focusable).map((item) => item.ref.current);
|
|
535
|
+
if (focusIntent === "last") candidateNodes.reverse();
|
|
536
|
+
else if (focusIntent === "prev" || focusIntent === "next") {
|
|
537
|
+
if (focusIntent === "prev") candidateNodes.reverse();
|
|
538
|
+
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
539
|
+
candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
|
|
540
|
+
}
|
|
541
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
542
|
+
}
|
|
543
|
+
}),
|
|
544
|
+
children: typeof children === "function" ? children({
|
|
545
|
+
isCurrentTabStop,
|
|
546
|
+
hasTabStop: currentTabStopId != null
|
|
547
|
+
}) : children
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
RovingFocusGroupItem.displayName = ITEM_NAME;
|
|
552
|
+
var MAP_KEY_TO_FOCUS_INTENT = {
|
|
553
|
+
ArrowLeft: "prev",
|
|
554
|
+
ArrowUp: "prev",
|
|
555
|
+
ArrowRight: "next",
|
|
556
|
+
ArrowDown: "next",
|
|
557
|
+
PageUp: "first",
|
|
558
|
+
Home: "first",
|
|
559
|
+
PageDown: "last",
|
|
560
|
+
End: "last"
|
|
561
|
+
};
|
|
562
|
+
function getDirectionAwareKey(key, dir) {
|
|
563
|
+
if (dir !== "rtl") return key;
|
|
564
|
+
return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
565
|
+
}
|
|
566
|
+
function getFocusIntent(event, orientation, dir) {
|
|
567
|
+
const key = getDirectionAwareKey(event.key, dir);
|
|
568
|
+
if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
|
|
569
|
+
if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
|
|
570
|
+
return MAP_KEY_TO_FOCUS_INTENT[key];
|
|
571
|
+
}
|
|
572
|
+
function focusFirst(candidates, preventScroll = false) {
|
|
573
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
574
|
+
for (const candidate of candidates) {
|
|
575
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
576
|
+
candidate.focus({ preventScroll });
|
|
577
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function wrapArray(array, startIndex) {
|
|
581
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
582
|
+
}
|
|
583
|
+
var Root = RovingFocusGroup;
|
|
584
|
+
var Item = RovingFocusGroupItem;
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-presence@1.1.5_@types+react-dom@19.2.3_@types+react@19.2.14__@types+rea_abbc8bcf75333b39bfe32b13ef7abc0e/node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
587
|
+
function useStateMachine(initialState, machine) {
|
|
588
|
+
return React$1.useReducer((state, event) => {
|
|
589
|
+
return machine[state][event] ?? state;
|
|
590
|
+
}, initialState);
|
|
591
|
+
}
|
|
592
|
+
var Presence = (props) => {
|
|
593
|
+
const { present, children } = props;
|
|
594
|
+
const presence = usePresence(present);
|
|
595
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React$1.Children.only(children);
|
|
596
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
597
|
+
return typeof children === "function" || presence.isPresent ? React$1.cloneElement(child, { ref }) : null;
|
|
598
|
+
};
|
|
599
|
+
Presence.displayName = "Presence";
|
|
600
|
+
function usePresence(present) {
|
|
601
|
+
const [node, setNode] = React$1.useState();
|
|
602
|
+
const stylesRef = React$1.useRef(null);
|
|
603
|
+
const prevPresentRef = React$1.useRef(present);
|
|
604
|
+
const prevAnimationNameRef = React$1.useRef("none");
|
|
605
|
+
const [state, send] = useStateMachine(present ? "mounted" : "unmounted", {
|
|
606
|
+
mounted: {
|
|
607
|
+
UNMOUNT: "unmounted",
|
|
608
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
609
|
+
},
|
|
610
|
+
unmountSuspended: {
|
|
611
|
+
MOUNT: "mounted",
|
|
612
|
+
ANIMATION_END: "unmounted"
|
|
613
|
+
},
|
|
614
|
+
unmounted: { MOUNT: "mounted" }
|
|
615
|
+
});
|
|
616
|
+
React$1.useEffect(() => {
|
|
617
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
618
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
619
|
+
}, [state]);
|
|
620
|
+
useLayoutEffect2(() => {
|
|
621
|
+
const styles = stylesRef.current;
|
|
622
|
+
const wasPresent = prevPresentRef.current;
|
|
623
|
+
if (wasPresent !== present) {
|
|
624
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
625
|
+
const currentAnimationName = getAnimationName(styles);
|
|
626
|
+
if (present) send("MOUNT");
|
|
627
|
+
else if (currentAnimationName === "none" || styles?.display === "none") send("UNMOUNT");
|
|
628
|
+
else if (wasPresent && prevAnimationName !== currentAnimationName) send("ANIMATION_OUT");
|
|
629
|
+
else send("UNMOUNT");
|
|
630
|
+
prevPresentRef.current = present;
|
|
631
|
+
}
|
|
632
|
+
}, [present, send]);
|
|
633
|
+
useLayoutEffect2(() => {
|
|
634
|
+
if (node) {
|
|
635
|
+
let timeoutId;
|
|
636
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
637
|
+
const handleAnimationEnd = (event) => {
|
|
638
|
+
const isCurrentAnimation = getAnimationName(stylesRef.current).includes(CSS.escape(event.animationName));
|
|
639
|
+
if (event.target === node && isCurrentAnimation) {
|
|
640
|
+
send("ANIMATION_END");
|
|
641
|
+
if (!prevPresentRef.current) {
|
|
642
|
+
const currentFillMode = node.style.animationFillMode;
|
|
643
|
+
node.style.animationFillMode = "forwards";
|
|
644
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
645
|
+
if (node.style.animationFillMode === "forwards") node.style.animationFillMode = currentFillMode;
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
const handleAnimationStart = (event) => {
|
|
651
|
+
if (event.target === node) prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
652
|
+
};
|
|
653
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
654
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
655
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
656
|
+
return () => {
|
|
657
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
658
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
659
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
660
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
661
|
+
};
|
|
662
|
+
} else send("ANIMATION_END");
|
|
663
|
+
}, [node, send]);
|
|
664
|
+
return {
|
|
665
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
666
|
+
ref: React$1.useCallback((node2) => {
|
|
667
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
668
|
+
setNode(node2);
|
|
669
|
+
}, [])
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function getAnimationName(styles) {
|
|
673
|
+
return styles?.animationName || "none";
|
|
674
|
+
}
|
|
675
|
+
function getElementRef(element) {
|
|
676
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
677
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
678
|
+
if (mayWarn) return element.ref;
|
|
679
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
680
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
681
|
+
if (mayWarn) return element.props.ref;
|
|
682
|
+
return element.props.ref || element.ref;
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region ../../node_modules/.pnpm/@radix-ui+react-tabs@1.1.13_@types+react-dom@19.2.3_@types+react@19.2.14__@types+react@_08684373bbac196273bdefb5472f93a8/node_modules/@radix-ui/react-tabs/dist/index.mjs
|
|
686
|
+
var TABS_NAME = "Tabs";
|
|
687
|
+
var [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [createRovingFocusGroupScope]);
|
|
688
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
689
|
+
var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
|
|
690
|
+
var Tabs$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
691
|
+
const { __scopeTabs, value: valueProp, onValueChange, defaultValue, orientation = "horizontal", dir, activationMode = "automatic", ...tabsProps } = props;
|
|
692
|
+
const direction = useDirection(dir);
|
|
693
|
+
const [value, setValue] = useControllableState({
|
|
694
|
+
prop: valueProp,
|
|
695
|
+
onChange: onValueChange,
|
|
696
|
+
defaultProp: defaultValue ?? "",
|
|
697
|
+
caller: TABS_NAME
|
|
698
|
+
});
|
|
699
|
+
return /* @__PURE__ */ jsx(TabsProvider, {
|
|
700
|
+
scope: __scopeTabs,
|
|
701
|
+
baseId: useId$1(),
|
|
702
|
+
value,
|
|
703
|
+
onValueChange: setValue,
|
|
704
|
+
orientation,
|
|
705
|
+
dir: direction,
|
|
706
|
+
activationMode,
|
|
707
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
708
|
+
dir: direction,
|
|
709
|
+
"data-orientation": orientation,
|
|
710
|
+
...tabsProps,
|
|
711
|
+
ref: forwardedRef
|
|
712
|
+
})
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
Tabs$1.displayName = TABS_NAME;
|
|
716
|
+
var TAB_LIST_NAME = "TabsList";
|
|
717
|
+
var TabsList$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
718
|
+
const { __scopeTabs, loop = true, ...listProps } = props;
|
|
719
|
+
const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
|
|
720
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
|
|
721
|
+
return /* @__PURE__ */ jsx(Root, {
|
|
722
|
+
asChild: true,
|
|
723
|
+
...rovingFocusGroupScope,
|
|
724
|
+
orientation: context.orientation,
|
|
725
|
+
dir: context.dir,
|
|
726
|
+
loop,
|
|
727
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
728
|
+
role: "tablist",
|
|
729
|
+
"aria-orientation": context.orientation,
|
|
730
|
+
...listProps,
|
|
731
|
+
ref: forwardedRef
|
|
732
|
+
})
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
TabsList$1.displayName = TAB_LIST_NAME;
|
|
736
|
+
var TRIGGER_NAME = "TabsTrigger";
|
|
737
|
+
var TabsTrigger$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
738
|
+
const { __scopeTabs, value, disabled = false, ...triggerProps } = props;
|
|
739
|
+
const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
|
|
740
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
|
|
741
|
+
const triggerId = makeTriggerId(context.baseId, value);
|
|
742
|
+
const contentId = makeContentId(context.baseId, value);
|
|
743
|
+
const isSelected = value === context.value;
|
|
744
|
+
return /* @__PURE__ */ jsx(Item, {
|
|
745
|
+
asChild: true,
|
|
746
|
+
...rovingFocusGroupScope,
|
|
747
|
+
focusable: !disabled,
|
|
748
|
+
active: isSelected,
|
|
749
|
+
children: /* @__PURE__ */ jsx(Primitive.button, {
|
|
750
|
+
type: "button",
|
|
751
|
+
role: "tab",
|
|
752
|
+
"aria-selected": isSelected,
|
|
753
|
+
"aria-controls": contentId,
|
|
754
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
755
|
+
"data-disabled": disabled ? "" : void 0,
|
|
756
|
+
disabled,
|
|
757
|
+
id: triggerId,
|
|
758
|
+
...triggerProps,
|
|
759
|
+
ref: forwardedRef,
|
|
760
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
761
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
|
|
762
|
+
else event.preventDefault();
|
|
763
|
+
}),
|
|
764
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
765
|
+
if ([" ", "Enter"].includes(event.key)) context.onValueChange(value);
|
|
766
|
+
}),
|
|
767
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
768
|
+
const isAutomaticActivation = context.activationMode !== "manual";
|
|
769
|
+
if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
|
|
770
|
+
})
|
|
771
|
+
})
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
TabsTrigger$1.displayName = TRIGGER_NAME;
|
|
775
|
+
var CONTENT_NAME = "TabsContent";
|
|
776
|
+
var TabsContent$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
777
|
+
const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
|
|
778
|
+
const context = useTabsContext(CONTENT_NAME, __scopeTabs);
|
|
779
|
+
const triggerId = makeTriggerId(context.baseId, value);
|
|
780
|
+
const contentId = makeContentId(context.baseId, value);
|
|
781
|
+
const isSelected = value === context.value;
|
|
782
|
+
const isMountAnimationPreventedRef = React$1.useRef(isSelected);
|
|
783
|
+
React$1.useEffect(() => {
|
|
784
|
+
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
785
|
+
return () => cancelAnimationFrame(rAF);
|
|
786
|
+
}, []);
|
|
787
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
788
|
+
present: forceMount || isSelected,
|
|
789
|
+
children: ({ present }) => /* @__PURE__ */ jsx(Primitive.div, {
|
|
790
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
791
|
+
"data-orientation": context.orientation,
|
|
792
|
+
role: "tabpanel",
|
|
793
|
+
"aria-labelledby": triggerId,
|
|
794
|
+
hidden: !present,
|
|
795
|
+
id: contentId,
|
|
796
|
+
tabIndex: 0,
|
|
797
|
+
...contentProps,
|
|
798
|
+
ref: forwardedRef,
|
|
799
|
+
style: {
|
|
800
|
+
...props.style,
|
|
801
|
+
animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0
|
|
802
|
+
},
|
|
803
|
+
children: present && children
|
|
804
|
+
})
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
TabsContent$1.displayName = CONTENT_NAME;
|
|
808
|
+
function makeTriggerId(baseId, value) {
|
|
809
|
+
return `${baseId}-trigger-${value}`;
|
|
810
|
+
}
|
|
811
|
+
function makeContentId(baseId, value) {
|
|
812
|
+
return `${baseId}-content-${value}`;
|
|
813
|
+
}
|
|
814
|
+
var Root2 = Tabs$1;
|
|
815
|
+
var List = TabsList$1;
|
|
816
|
+
var Trigger = TabsTrigger$1;
|
|
817
|
+
var Content = TabsContent$1;
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region editors/document-model-editor/components/tabs.tsx
|
|
820
|
+
const Tabs = Root2;
|
|
821
|
+
const TabsList = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(List, {
|
|
822
|
+
ref,
|
|
823
|
+
className: twMerge("flex items-center justify-center rounded-xl bg-background p-1 shadow-inner", className),
|
|
824
|
+
...props
|
|
825
|
+
}));
|
|
826
|
+
TabsList.displayName = List.displayName;
|
|
827
|
+
const TabsTrigger = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Trigger, {
|
|
828
|
+
ref,
|
|
829
|
+
className: twMerge("flex w-full items-center justify-center rounded-lg p-1 text-sm whitespace-nowrap text-muted-foreground transition-all disabled:disabled-effect data-[state=active]:bg-accent data-[state=active]:text-foreground data-[state=active]:shadow-tab", className),
|
|
830
|
+
...props
|
|
831
|
+
}));
|
|
832
|
+
TabsTrigger.displayName = Trigger.displayName;
|
|
833
|
+
const TabsContent = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Content, {
|
|
834
|
+
ref,
|
|
835
|
+
className,
|
|
836
|
+
...props
|
|
837
|
+
}));
|
|
838
|
+
TabsContent.displayName = Content.displayName;
|
|
839
|
+
//#endregion
|
|
840
|
+
//#region editors/document-model-editor/components/state-schemas.tsx
|
|
841
|
+
const GraphqlEditor = lazy(() => import("./graphql-editor-v1OXETjM.mjs"));
|
|
842
|
+
const JSONEditor = lazy(() => import("./json-editor-8dfjgcaX.mjs"));
|
|
843
|
+
function StateEditor({ modelName, stateSchema, initialValue, setStateSchema, setInitialState, scope }) {
|
|
844
|
+
const { sharedSchema: sharedSchemaSdl, error: sharedSchemaError } = useSchemaContext();
|
|
845
|
+
const [showStandardLib, setShowStandardLib] = useState(false);
|
|
846
|
+
const [syncWithSchema, setSyncWithSchema] = useState(true);
|
|
847
|
+
const customLinter = useCallback((doc) => ensureValidStateSchemaName(doc, modelName, scope), [modelName, scope]);
|
|
848
|
+
const schemaErrors = useMemo(() => {
|
|
849
|
+
const errors = ensureValidStateSchemaName(stateSchema, modelName, scope);
|
|
850
|
+
if (sharedSchemaError) return [...errors, sharedSchemaError];
|
|
851
|
+
return errors;
|
|
852
|
+
}, [
|
|
853
|
+
stateSchema,
|
|
854
|
+
modelName,
|
|
855
|
+
scope,
|
|
856
|
+
sharedSchemaError
|
|
857
|
+
]);
|
|
858
|
+
const handleToggleStandardLib = useCallback(() => {
|
|
859
|
+
setShowStandardLib((prev) => !prev);
|
|
860
|
+
}, []);
|
|
861
|
+
const handleSchemaUpdate = useCallback((newDoc) => setStateSchema(newDoc, scope), [setStateSchema, scope]);
|
|
862
|
+
const handleInitialStateUpdate = useCallback((newDoc) => setInitialState(newDoc, scope), [setInitialState, scope]);
|
|
863
|
+
const hasSyncedRef = useRef(false);
|
|
864
|
+
const { initialValueErrors, fixedState } = useMemo(() => {
|
|
865
|
+
const existingValue = initialValue || "{}";
|
|
866
|
+
const sharedSchemaDocumentNode = safeParseSdl(sharedSchemaSdl);
|
|
867
|
+
if (!sharedSchemaDocumentNode) return {
|
|
868
|
+
initialValueErrors: [],
|
|
869
|
+
fixedState: null
|
|
870
|
+
};
|
|
871
|
+
const stateTypeName = makeStateSchemaNameForScope(modelName, scope);
|
|
872
|
+
if (!stateTypeName) return {
|
|
873
|
+
initialValueErrors: [],
|
|
874
|
+
fixedState: null
|
|
875
|
+
};
|
|
876
|
+
const stateTypeDefinitionNode = sharedSchemaDocumentNode.definitions.find((def) => def.kind === import_graphql.Kind.OBJECT_TYPE_DEFINITION && def.name.value === stateTypeName);
|
|
877
|
+
if (!stateTypeDefinitionNode || stateTypeDefinitionNode.kind !== import_graphql.Kind.OBJECT_TYPE_DEFINITION) return {
|
|
878
|
+
initialValueErrors: [],
|
|
879
|
+
fixedState: null
|
|
880
|
+
};
|
|
881
|
+
const errors = validateStateObject(sharedSchemaDocumentNode, stateTypeDefinitionNode, existingValue);
|
|
882
|
+
if (errors.length && syncWithSchema) {
|
|
883
|
+
const computedFixedState = makeMinimalObjectForStateType({
|
|
884
|
+
sharedSchemaDocumentNode,
|
|
885
|
+
stateTypeDefinitionNode,
|
|
886
|
+
existingValue
|
|
887
|
+
});
|
|
888
|
+
if (initialValue !== computedFixedState) return {
|
|
889
|
+
initialValueErrors: [],
|
|
890
|
+
fixedState: computedFixedState
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
return {
|
|
894
|
+
initialValueErrors: errors,
|
|
895
|
+
fixedState: null
|
|
896
|
+
};
|
|
897
|
+
}, [
|
|
898
|
+
sharedSchemaSdl,
|
|
899
|
+
initialValue,
|
|
900
|
+
syncWithSchema,
|
|
901
|
+
scope,
|
|
902
|
+
modelName
|
|
903
|
+
]);
|
|
904
|
+
useEffect(() => {
|
|
905
|
+
if (fixedState && !hasSyncedRef.current) {
|
|
906
|
+
hasSyncedRef.current = true;
|
|
907
|
+
setInitialState(fixedState, scope);
|
|
908
|
+
} else if (!fixedState) hasSyncedRef.current = false;
|
|
909
|
+
}, [
|
|
910
|
+
fixedState,
|
|
911
|
+
setInitialState,
|
|
912
|
+
scope
|
|
913
|
+
]);
|
|
914
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
915
|
+
className: "grid grid-cols-2 gap-4",
|
|
916
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [
|
|
917
|
+
/* @__PURE__ */ jsxs("h3", {
|
|
918
|
+
className: "mb-2 text-lg text-foreground capitalize",
|
|
919
|
+
children: [scope, " state schema *"]
|
|
920
|
+
}),
|
|
921
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
922
|
+
onClick: handleToggleStandardLib,
|
|
923
|
+
className: "mb-2 flex w-fit items-center gap-2",
|
|
924
|
+
children: [
|
|
925
|
+
showStandardLib ? "Hide" : "Show",
|
|
926
|
+
" standard library",
|
|
927
|
+
/* @__PURE__ */ jsx("svg", {
|
|
928
|
+
className: twMerge("inline-block transition-transform", showStandardLib ? "rotate-180" : "rotate-0"),
|
|
929
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
930
|
+
width: "24",
|
|
931
|
+
height: "24",
|
|
932
|
+
viewBox: "0 0 24 24",
|
|
933
|
+
fill: "currentColor",
|
|
934
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
935
|
+
d: "M11.9883 6.01172C11.4363 6.01172 10.9883 6.45972 10.9883 7.01172V13.0117H6.98828L11.9883 18.0117L16.9883 13.0117H12.9883V7.01172C12.9883 6.45972 12.5403 6.01172 11.9883 6.01172Z",
|
|
936
|
+
fill: "currentColor"
|
|
937
|
+
})
|
|
938
|
+
})
|
|
939
|
+
]
|
|
940
|
+
}),
|
|
941
|
+
/* @__PURE__ */ jsxs(Suspense, { children: [
|
|
942
|
+
showStandardLib && /* @__PURE__ */ jsx(GraphqlEditor, {
|
|
943
|
+
doc: typeDefsDoc,
|
|
944
|
+
readonly: true
|
|
945
|
+
}),
|
|
946
|
+
/* @__PURE__ */ jsx(GraphqlEditor, {
|
|
947
|
+
doc: stateSchema,
|
|
948
|
+
updateDocumentInModel: handleSchemaUpdate,
|
|
949
|
+
customLinter
|
|
950
|
+
}),
|
|
951
|
+
schemaErrors.length > 0 && /* @__PURE__ */ jsx("p", {
|
|
952
|
+
className: "mt-2 text-sm text-destructive",
|
|
953
|
+
children: schemaErrors[0].message
|
|
954
|
+
})
|
|
955
|
+
] })
|
|
956
|
+
] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
957
|
+
className: "flex flex-col items-end",
|
|
958
|
+
children: [/* @__PURE__ */ jsxs("h3", {
|
|
959
|
+
className: "mb-2 text-right text-lg text-foreground capitalize",
|
|
960
|
+
children: [scope, " state initial value *"]
|
|
961
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
962
|
+
className: "mb-2 flex w-fit items-center gap-2 rounded-md border border-border bg-background p-2 text-sm font-medium whitespace-nowrap text-foreground transition-colors hover:hover-effect focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
|
|
963
|
+
children: [
|
|
964
|
+
/* @__PURE__ */ jsx("input", {
|
|
965
|
+
type: "checkbox",
|
|
966
|
+
className: "",
|
|
967
|
+
value: syncWithSchema.toString(),
|
|
968
|
+
onChange: (e) => {
|
|
969
|
+
setSyncWithSchema(e.currentTarget.value === "true" ? true : false);
|
|
970
|
+
}
|
|
971
|
+
}),
|
|
972
|
+
"Sync with schema",
|
|
973
|
+
" ",
|
|
974
|
+
/* @__PURE__ */ jsx("svg", {
|
|
975
|
+
className: "inline-block",
|
|
976
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
977
|
+
width: "16",
|
|
978
|
+
height: "16",
|
|
979
|
+
viewBox: "0 0 16 16",
|
|
980
|
+
fill: "none",
|
|
981
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
982
|
+
d: "M8.00521 1.99219C6.63588 1.99219 5.32788 2.45152 4.27588 3.28419C3.98721 3.51219 3.94321 3.93285 4.17188 4.22151C4.40054 4.51018 4.82055 4.55418 5.10921 4.32552C5.92721 3.67819 6.93921 3.32552 8.00521 3.32552C10.5825 3.32552 12.6719 5.41485 12.6719 7.99218H11.3385L13.3385 10.6588L15.3385 7.99218H14.0052C14.0052 4.67818 11.3192 1.99219 8.00521 1.99219ZM2.67188 5.32552L0.671875 7.99218H2.00521C2.00521 11.3062 4.69121 13.9922 8.00521 13.9922C9.37521 13.9922 10.6825 13.5335 11.7345 12.7002C12.0232 12.4722 12.0672 12.0515 11.8385 11.7628C11.6099 11.4742 11.1899 11.4302 10.9012 11.6588C10.0825 12.3068 9.07188 12.6588 8.00521 12.6588C5.42788 12.6588 3.33854 10.5695 3.33854 7.99218H4.67188L2.67188 5.32552Z",
|
|
983
|
+
fill: "currentColor"
|
|
984
|
+
})
|
|
985
|
+
})
|
|
986
|
+
]
|
|
987
|
+
})]
|
|
988
|
+
}), /* @__PURE__ */ jsxs(Suspense, { children: [/* @__PURE__ */ jsx(JSONEditor, {
|
|
989
|
+
doc: initialValue,
|
|
990
|
+
updateDocumentInModel: handleInitialStateUpdate
|
|
991
|
+
}), initialValueErrors.map((error, index) => /* @__PURE__ */ jsx("p", {
|
|
992
|
+
className: "mt-2 text-sm text-destructive",
|
|
993
|
+
children: error instanceof StateValidationError ? /* @__PURE__ */ jsx(StateValidationErrorMessage, { error }) : error.message
|
|
994
|
+
}, index))] })] })]
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
function StateSchemas({ modelName, globalStateSchema, localStateSchema, globalStateInitialValue, localStateInitialValue, setStateSchema, setInitialState, currentScope, onScopeChange }) {
|
|
998
|
+
const handleAddLocalState = useCallback(() => {
|
|
999
|
+
setStateSchema(makeInitialSchemaDoc(modelName, "local"), "local");
|
|
1000
|
+
setInitialState("", "local");
|
|
1001
|
+
}, [
|
|
1002
|
+
modelName,
|
|
1003
|
+
setStateSchema,
|
|
1004
|
+
setInitialState
|
|
1005
|
+
]);
|
|
1006
|
+
return /* @__PURE__ */ jsxs(Tabs, {
|
|
1007
|
+
className: "pb-8",
|
|
1008
|
+
activationMode: "manual",
|
|
1009
|
+
value: currentScope,
|
|
1010
|
+
onValueChange: (value) => onScopeChange(value),
|
|
1011
|
+
children: [
|
|
1012
|
+
/* @__PURE__ */ jsx("div", {
|
|
1013
|
+
className: "my-6",
|
|
1014
|
+
children: /* @__PURE__ */ jsxs(TabsList, {
|
|
1015
|
+
className: "mx-auto flex max-w-sm",
|
|
1016
|
+
children: [/* @__PURE__ */ jsx(TabsTrigger, {
|
|
1017
|
+
value: "global",
|
|
1018
|
+
children: "Global"
|
|
1019
|
+
}), /* @__PURE__ */ jsx(TabsTrigger, {
|
|
1020
|
+
value: "local",
|
|
1021
|
+
children: "Local"
|
|
1022
|
+
})]
|
|
1023
|
+
})
|
|
1024
|
+
}),
|
|
1025
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
1026
|
+
value: "global",
|
|
1027
|
+
tabIndex: -1,
|
|
1028
|
+
children: /* @__PURE__ */ jsx(StateEditor, {
|
|
1029
|
+
modelName,
|
|
1030
|
+
stateSchema: globalStateSchema,
|
|
1031
|
+
initialValue: globalStateInitialValue,
|
|
1032
|
+
setStateSchema,
|
|
1033
|
+
setInitialState,
|
|
1034
|
+
scope: "global"
|
|
1035
|
+
})
|
|
1036
|
+
}),
|
|
1037
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
1038
|
+
value: "local",
|
|
1039
|
+
tabIndex: -1,
|
|
1040
|
+
children: !localStateSchema ? /* @__PURE__ */ jsxs("div", {
|
|
1041
|
+
className: "",
|
|
1042
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
1043
|
+
className: "mb-2 text-lg text-foreground capitalize",
|
|
1044
|
+
children: "local state schema *"
|
|
1045
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1046
|
+
onClick: handleAddLocalState,
|
|
1047
|
+
children: "Add local state"
|
|
1048
|
+
})]
|
|
1049
|
+
}) : /* @__PURE__ */ jsx(StateEditor, {
|
|
1050
|
+
modelName,
|
|
1051
|
+
stateSchema: localStateSchema,
|
|
1052
|
+
initialValue: localStateInitialValue,
|
|
1053
|
+
setStateSchema,
|
|
1054
|
+
setInitialState,
|
|
1055
|
+
scope: "local"
|
|
1056
|
+
})
|
|
1057
|
+
})
|
|
1058
|
+
]
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
//#endregion
|
|
1062
|
+
export { StateSchemas as default };
|
|
1063
|
+
|
|
1064
|
+
//# sourceMappingURL=state-schemas-DXWpf1zO.mjs.map
|