@powerhousedao/powerhouse-vetra-packages 6.2.3-dev.1 → 6.2.3-dev.11
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/assets/{entry-5_Eh4a2Z.js → entry-4ObkElbc.js} +2 -2
- package/dist/browser/assets/{projection-entry-5PVbP10h.js → projection-entry-DRGRQCSu.js} +8 -8
- package/dist/browser/{button-CuO8Gh3v.js → button-sZQCXeCo.js} +131 -24
- package/dist/browser/button-sZQCXeCo.js.map +1 -0
- package/dist/browser/chunk-CRPLlQ3x.js +28 -0
- package/dist/browser/{dist-BAJ5nRDl.js → dist-D3_ER0Dn.js} +2 -399
- package/dist/browser/dist-D3_ER0Dn.js.map +1 -0
- package/dist/browser/document-models/index.js +2 -1
- package/dist/browser/{documents-J_l59mSV.js → documents-C-lAnv6o.js} +604 -735
- package/dist/browser/documents-C-lAnv6o.js.map +1 -0
- package/dist/browser/editor-BO_s5gTQ.js +3679 -0
- package/dist/browser/editor-BO_s5gTQ.js.map +1 -0
- package/dist/browser/{editor-DZP1WlYy.js → editor-DNV-46lY.js} +5 -5
- package/dist/browser/{editor-DZP1WlYy.js.map → editor-DNV-46lY.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -5
- 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/folder-view-CzItU0hn.js +957 -0
- package/dist/browser/folder-view-CzItU0hn.js.map +1 -0
- package/dist/browser/{graphql-editor-Cbkb5KRZ.js → graphql-editor-BMhHl2XP.js} +7 -9
- package/dist/browser/{graphql-editor-Cbkb5KRZ.js.map → graphql-editor-BMhHl2XP.js.map} +1 -1
- package/dist/{node/hooks-D0DcS3MV.mjs → browser/hooks-Bh1JCohS.js} +2 -2
- package/dist/browser/{hooks-KKcNp2X0.js.map → hooks-Bh1JCohS.js.map} +1 -1
- package/dist/browser/index.js +120 -20
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{json-editor-CN6kPtl1.js → json-editor-DBhkG5TF.js} +3 -4
- package/dist/browser/{json-editor-CN6kPtl1.js.map → json-editor-DBhkG5TF.js.map} +1 -1
- package/dist/browser/{parser-CkF6Qt8V.js → parser-BBzK7bLd.js} +1 -1
- package/dist/browser/{parser-CkF6Qt8V.js.map → parser-BBzK7bLd.js.map} +1 -1
- package/dist/browser/{schema-context-ZyeclQwy.js → schema-context-p2bhyog_.js} +3 -3
- package/dist/browser/{schema-context-ZyeclQwy.js.map → schema-context-p2bhyog_.js.map} +1 -1
- package/dist/browser/src-CVV6HzQZ-D-OQvEkh.js +5151 -0
- package/dist/browser/src-CVV6HzQZ-D-OQvEkh.js.map +1 -0
- package/dist/browser/state-schemas-DuA5rB1e.js +694 -0
- package/dist/browser/state-schemas-DuA5rB1e.js.map +1 -0
- package/dist/browser/tslib.es6-CeIASJ2O.js +32 -0
- package/dist/browser/tslib.es6-CeIASJ2O.js.map +1 -0
- package/dist/node/{button-Da7CxMn7.mjs → button-5bnYEAVq.mjs} +130 -23
- package/dist/node/button-5bnYEAVq.mjs.map +1 -0
- package/dist/node/chunk-17FXJ3dL.mjs +31 -0
- package/dist/node/{dist-CzYOpeXN.mjs → dist-Bf_PIbO7.mjs} +2 -399
- package/dist/node/dist-Bf_PIbO7.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +2 -1
- package/dist/node/documents-XAQfHX5Q.mjs +17 -0
- package/dist/node/documents-XAQfHX5Q.mjs.map +1 -0
- package/dist/node/editor-BiiLqEe9.mjs +3679 -0
- package/dist/node/editor-BiiLqEe9.mjs.map +1 -0
- package/dist/node/{editor-Dg2OZEJu.mjs → editor-Cp2TC5MJ.mjs} +5 -5
- package/dist/node/{editor-Dg2OZEJu.mjs.map → editor-Cp2TC5MJ.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +4 -5
- 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/folder-view-m_rH84Nz.mjs +962 -0
- package/dist/node/folder-view-m_rH84Nz.mjs.map +1 -0
- package/dist/node/{graphql-BfAoPeWM.mjs → graphql-BvV3tC1U.mjs} +2 -2
- package/dist/node/{graphql-BfAoPeWM.mjs.map → graphql-BvV3tC1U.mjs.map} +1 -1
- package/dist/node/{graphql-editor-DNxebuTn.mjs → graphql-editor-BhF6KN6y.mjs} +6 -7
- package/dist/node/{graphql-editor-DNxebuTn.mjs.map → graphql-editor-BhF6KN6y.mjs.map} +1 -1
- package/dist/{browser/hooks-KKcNp2X0.js → node/hooks-Di3FASx-.mjs} +2 -2
- package/dist/node/{hooks-D0DcS3MV.mjs.map → hooks-Di3FASx-.mjs.map} +1 -1
- package/dist/node/index.mjs +142 -21
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{json-editor-BpnEn9AS.mjs → json-editor-Cqc0zuz0.mjs} +3 -4
- package/dist/node/{json-editor-BpnEn9AS.mjs.map → json-editor-Cqc0zuz0.mjs.map} +1 -1
- package/dist/node/{schema-context-DL8jhi_d.mjs → schema-context-mHmP3Cl6.mjs} +3 -3
- package/dist/node/{schema-context-DL8jhi_d.mjs.map → schema-context-mHmP3Cl6.mjs.map} +1 -1
- package/dist/node/{connect-CeLh6yfj.mjs → src-CVV6HzQZ-CvqjXbXk.mjs} +1829 -11016
- package/dist/node/src-CVV6HzQZ-CvqjXbXk.mjs.map +1 -0
- package/dist/node/state-schemas-DXG02fMh.mjs +695 -0
- package/dist/node/state-schemas-DXG02fMh.mjs.map +1 -0
- package/dist/node/{main-B1tRsYOp.mjs → tslib.es6-DdiHgz9e.mjs} +3 -203
- package/dist/node/tslib.es6-DdiHgz9e.mjs.map +1 -0
- package/package.json +7 -7
- package/dist/browser/button-CuO8Gh3v.js.map +0 -1
- package/dist/browser/connect-BqgnsniX.js +0 -14322
- package/dist/browser/connect-BqgnsniX.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/dist-C-xkNfyD.js +0 -4641
- package/dist/browser/dist-C-xkNfyD.js.map +0 -1
- package/dist/browser/document-drive-ZQzPQfEL.js +0 -8237
- package/dist/browser/document-drive-ZQzPQfEL.js.map +0 -1
- package/dist/browser/documents-J_l59mSV.js.map +0 -1
- package/dist/browser/editor-BNgF9-uX.js +0 -1809
- package/dist/browser/editor-BNgF9-uX.js.map +0 -1
- package/dist/browser/folder-view-tx0A96ZI.js +0 -232
- package/dist/browser/folder-view-tx0A96ZI.js.map +0 -1
- package/dist/browser/lib-ewnRj2dJ.js +0 -209
- package/dist/browser/lib-ewnRj2dJ.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-CKh98ehP.js +0 -298
- package/dist/browser/state-schemas-CKh98ehP.js.map +0 -1
- package/dist/node/button-Da7CxMn7.mjs.map +0 -1
- package/dist/node/connect-CeLh6yfj.mjs.map +0 -1
- package/dist/node/dist-CUFTZwfc.mjs +0 -4649
- package/dist/node/dist-CUFTZwfc.mjs.map +0 -1
- 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-D1NMjQQc.mjs +0 -8254
- package/dist/node/document-drive-D1NMjQQc.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-CXQOsbup.mjs +0 -1809
- package/dist/node/editor-CXQOsbup.mjs.map +0 -1
- package/dist/node/folder-view-DZ0o2-Ef.mjs +0 -232
- package/dist/node/folder-view-DZ0o2-Ef.mjs.map +0 -1
- package/dist/node/main-B1tRsYOp.mjs.map +0 -1
- package/dist/node/state-schemas-CuSHxrn6.mjs +0 -299
- package/dist/node/state-schemas-CuSHxrn6.mjs.map +0 -1
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
import { c as Kind } from "./parser-BBzK7bLd.js";
|
|
2
|
+
import { r as typeDefsDoc } from "./documents-C-lAnv6o.js";
|
|
3
|
+
import { d as makeMinimalObjectForStateType, h as validateStateObject, i as StateValidationError, p as makeStateSchemaNameForScope, r as ensureValidStateSchemaName, t as Button, u as makeInitialSchemaDoc } from "./button-sZQCXeCo.js";
|
|
4
|
+
import { f as useComposedRefs, h as twMerge, i as Primitive, n as useId$1, o as createSlot, p as composeEventHandlers, r as useCallbackRef, s as useControllableState, t as Presence, u as createContextScope } from "./dist-D3_ER0Dn.js";
|
|
5
|
+
import { n as safeParseSdl, r as useSchemaContext } from "./schema-context-p2bhyog_.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
import React, { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#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
|
|
10
|
+
function createCollection(name) {
|
|
11
|
+
const PROVIDER_NAME = name + "CollectionProvider";
|
|
12
|
+
const [createCollectionContext, createCollectionScope] = createContextScope(PROVIDER_NAME);
|
|
13
|
+
const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(PROVIDER_NAME, {
|
|
14
|
+
collectionRef: { current: null },
|
|
15
|
+
itemMap: /* @__PURE__ */ new Map()
|
|
16
|
+
});
|
|
17
|
+
const CollectionProvider = (props) => {
|
|
18
|
+
const { scope, children } = props;
|
|
19
|
+
const ref = React.useRef(null);
|
|
20
|
+
const itemMap = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
21
|
+
return /* @__PURE__ */ jsx(CollectionProviderImpl, {
|
|
22
|
+
scope,
|
|
23
|
+
itemMap,
|
|
24
|
+
collectionRef: ref,
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
CollectionProvider.displayName = PROVIDER_NAME;
|
|
29
|
+
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
30
|
+
const CollectionSlotImpl = createSlot(COLLECTION_SLOT_NAME);
|
|
31
|
+
const CollectionSlot = React.forwardRef((props, forwardedRef) => {
|
|
32
|
+
const { scope, children } = props;
|
|
33
|
+
return /* @__PURE__ */ jsx(CollectionSlotImpl, {
|
|
34
|
+
ref: useComposedRefs(forwardedRef, useCollectionContext(COLLECTION_SLOT_NAME, scope).collectionRef),
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
39
|
+
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
40
|
+
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
41
|
+
const CollectionItemSlotImpl = createSlot(ITEM_SLOT_NAME);
|
|
42
|
+
const CollectionItemSlot = React.forwardRef((props, forwardedRef) => {
|
|
43
|
+
const { scope, children, ...itemData } = props;
|
|
44
|
+
const ref = React.useRef(null);
|
|
45
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
46
|
+
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
context.itemMap.set(ref, {
|
|
49
|
+
ref,
|
|
50
|
+
...itemData
|
|
51
|
+
});
|
|
52
|
+
return () => void context.itemMap.delete(ref);
|
|
53
|
+
});
|
|
54
|
+
return /* @__PURE__ */ jsx(CollectionItemSlotImpl, {
|
|
55
|
+
[ITEM_DATA_ATTR]: "",
|
|
56
|
+
ref: composedRefs,
|
|
57
|
+
children
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
61
|
+
function useCollection(scope) {
|
|
62
|
+
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
63
|
+
return React.useCallback(() => {
|
|
64
|
+
const collectionNode = context.collectionRef.current;
|
|
65
|
+
if (!collectionNode) return [];
|
|
66
|
+
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
67
|
+
return Array.from(context.itemMap.values()).sort((a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current));
|
|
68
|
+
}, [context.collectionRef, context.itemMap]);
|
|
69
|
+
}
|
|
70
|
+
return [
|
|
71
|
+
{
|
|
72
|
+
Provider: CollectionProvider,
|
|
73
|
+
Slot: CollectionSlot,
|
|
74
|
+
ItemSlot: CollectionItemSlot
|
|
75
|
+
},
|
|
76
|
+
useCollection,
|
|
77
|
+
createCollectionScope
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#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
|
|
82
|
+
var DirectionContext = React$1.createContext(void 0);
|
|
83
|
+
function useDirection(localDir) {
|
|
84
|
+
const globalDir = React$1.useContext(DirectionContext);
|
|
85
|
+
return localDir || globalDir || "ltr";
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#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
|
|
89
|
+
var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
|
|
90
|
+
var EVENT_OPTIONS = {
|
|
91
|
+
bubbles: false,
|
|
92
|
+
cancelable: true
|
|
93
|
+
};
|
|
94
|
+
var GROUP_NAME = "RovingFocusGroup";
|
|
95
|
+
var [Collection, useCollection, createCollectionScope] = createCollection(GROUP_NAME);
|
|
96
|
+
var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(GROUP_NAME, [createCollectionScope]);
|
|
97
|
+
var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
|
|
98
|
+
var RovingFocusGroup = React$1.forwardRef((props, forwardedRef) => {
|
|
99
|
+
return /* @__PURE__ */ jsx(Collection.Provider, {
|
|
100
|
+
scope: props.__scopeRovingFocusGroup,
|
|
101
|
+
children: /* @__PURE__ */ jsx(Collection.Slot, {
|
|
102
|
+
scope: props.__scopeRovingFocusGroup,
|
|
103
|
+
children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, {
|
|
104
|
+
...props,
|
|
105
|
+
ref: forwardedRef
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
RovingFocusGroup.displayName = GROUP_NAME;
|
|
111
|
+
var RovingFocusGroupImpl = React$1.forwardRef((props, forwardedRef) => {
|
|
112
|
+
const { __scopeRovingFocusGroup, orientation, loop = false, dir, currentTabStopId: currentTabStopIdProp, defaultCurrentTabStopId, onCurrentTabStopIdChange, onEntryFocus, preventScrollOnEntryFocus = false, ...groupProps } = props;
|
|
113
|
+
const ref = React$1.useRef(null);
|
|
114
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
115
|
+
const direction = useDirection(dir);
|
|
116
|
+
const [currentTabStopId, setCurrentTabStopId] = useControllableState({
|
|
117
|
+
prop: currentTabStopIdProp,
|
|
118
|
+
defaultProp: defaultCurrentTabStopId ?? null,
|
|
119
|
+
onChange: onCurrentTabStopIdChange,
|
|
120
|
+
caller: GROUP_NAME
|
|
121
|
+
});
|
|
122
|
+
const [isTabbingBackOut, setIsTabbingBackOut] = React$1.useState(false);
|
|
123
|
+
const handleEntryFocus = useCallbackRef(onEntryFocus);
|
|
124
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
125
|
+
const isClickFocusRef = React$1.useRef(false);
|
|
126
|
+
const [focusableItemsCount, setFocusableItemsCount] = React$1.useState(0);
|
|
127
|
+
React$1.useEffect(() => {
|
|
128
|
+
const node = ref.current;
|
|
129
|
+
if (node) {
|
|
130
|
+
node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
131
|
+
return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
|
|
132
|
+
}
|
|
133
|
+
}, [handleEntryFocus]);
|
|
134
|
+
return /* @__PURE__ */ jsx(RovingFocusProvider, {
|
|
135
|
+
scope: __scopeRovingFocusGroup,
|
|
136
|
+
orientation,
|
|
137
|
+
dir: direction,
|
|
138
|
+
loop,
|
|
139
|
+
currentTabStopId,
|
|
140
|
+
onItemFocus: React$1.useCallback((tabStopId) => setCurrentTabStopId(tabStopId), [setCurrentTabStopId]),
|
|
141
|
+
onItemShiftTab: React$1.useCallback(() => setIsTabbingBackOut(true), []),
|
|
142
|
+
onFocusableItemAdd: React$1.useCallback(() => setFocusableItemsCount((prevCount) => prevCount + 1), []),
|
|
143
|
+
onFocusableItemRemove: React$1.useCallback(() => setFocusableItemsCount((prevCount) => prevCount - 1), []),
|
|
144
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
145
|
+
tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
|
|
146
|
+
"data-orientation": orientation,
|
|
147
|
+
...groupProps,
|
|
148
|
+
ref: composedRefs,
|
|
149
|
+
style: {
|
|
150
|
+
outline: "none",
|
|
151
|
+
...props.style
|
|
152
|
+
},
|
|
153
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, () => {
|
|
154
|
+
isClickFocusRef.current = true;
|
|
155
|
+
}),
|
|
156
|
+
onFocus: composeEventHandlers(props.onFocus, (event) => {
|
|
157
|
+
const isKeyboardFocus = !isClickFocusRef.current;
|
|
158
|
+
if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
|
|
159
|
+
const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
|
|
160
|
+
event.currentTarget.dispatchEvent(entryFocusEvent);
|
|
161
|
+
if (!entryFocusEvent.defaultPrevented) {
|
|
162
|
+
const items = getItems().filter((item) => item.focusable);
|
|
163
|
+
focusFirst([
|
|
164
|
+
items.find((item) => item.active),
|
|
165
|
+
items.find((item) => item.id === currentTabStopId),
|
|
166
|
+
...items
|
|
167
|
+
].filter(Boolean).map((item) => item.ref.current), preventScrollOnEntryFocus);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
isClickFocusRef.current = false;
|
|
171
|
+
}),
|
|
172
|
+
onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
|
|
173
|
+
})
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
var ITEM_NAME = "RovingFocusGroupItem";
|
|
177
|
+
var RovingFocusGroupItem = React$1.forwardRef((props, forwardedRef) => {
|
|
178
|
+
const { __scopeRovingFocusGroup, focusable = true, active = false, tabStopId, children, ...itemProps } = props;
|
|
179
|
+
const autoId = useId$1();
|
|
180
|
+
const id = tabStopId || autoId;
|
|
181
|
+
const context = useRovingFocusContext(ITEM_NAME, __scopeRovingFocusGroup);
|
|
182
|
+
const isCurrentTabStop = context.currentTabStopId === id;
|
|
183
|
+
const getItems = useCollection(__scopeRovingFocusGroup);
|
|
184
|
+
const { onFocusableItemAdd, onFocusableItemRemove, currentTabStopId } = context;
|
|
185
|
+
React$1.useEffect(() => {
|
|
186
|
+
if (focusable) {
|
|
187
|
+
onFocusableItemAdd();
|
|
188
|
+
return () => onFocusableItemRemove();
|
|
189
|
+
}
|
|
190
|
+
}, [
|
|
191
|
+
focusable,
|
|
192
|
+
onFocusableItemAdd,
|
|
193
|
+
onFocusableItemRemove
|
|
194
|
+
]);
|
|
195
|
+
return /* @__PURE__ */ jsx(Collection.ItemSlot, {
|
|
196
|
+
scope: __scopeRovingFocusGroup,
|
|
197
|
+
id,
|
|
198
|
+
focusable,
|
|
199
|
+
active,
|
|
200
|
+
children: /* @__PURE__ */ jsx(Primitive.span, {
|
|
201
|
+
tabIndex: isCurrentTabStop ? 0 : -1,
|
|
202
|
+
"data-orientation": context.orientation,
|
|
203
|
+
...itemProps,
|
|
204
|
+
ref: forwardedRef,
|
|
205
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
206
|
+
if (!focusable) event.preventDefault();
|
|
207
|
+
else context.onItemFocus(id);
|
|
208
|
+
}),
|
|
209
|
+
onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
|
|
210
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
211
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
212
|
+
context.onItemShiftTab();
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (event.target !== event.currentTarget) return;
|
|
216
|
+
const focusIntent = getFocusIntent(event, context.orientation, context.dir);
|
|
217
|
+
if (focusIntent !== void 0) {
|
|
218
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
let candidateNodes = getItems().filter((item) => item.focusable).map((item) => item.ref.current);
|
|
221
|
+
if (focusIntent === "last") candidateNodes.reverse();
|
|
222
|
+
else if (focusIntent === "prev" || focusIntent === "next") {
|
|
223
|
+
if (focusIntent === "prev") candidateNodes.reverse();
|
|
224
|
+
const currentIndex = candidateNodes.indexOf(event.currentTarget);
|
|
225
|
+
candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
|
|
226
|
+
}
|
|
227
|
+
setTimeout(() => focusFirst(candidateNodes));
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
230
|
+
children: typeof children === "function" ? children({
|
|
231
|
+
isCurrentTabStop,
|
|
232
|
+
hasTabStop: currentTabStopId != null
|
|
233
|
+
}) : children
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
RovingFocusGroupItem.displayName = ITEM_NAME;
|
|
238
|
+
var MAP_KEY_TO_FOCUS_INTENT = {
|
|
239
|
+
ArrowLeft: "prev",
|
|
240
|
+
ArrowUp: "prev",
|
|
241
|
+
ArrowRight: "next",
|
|
242
|
+
ArrowDown: "next",
|
|
243
|
+
PageUp: "first",
|
|
244
|
+
Home: "first",
|
|
245
|
+
PageDown: "last",
|
|
246
|
+
End: "last"
|
|
247
|
+
};
|
|
248
|
+
function getDirectionAwareKey(key, dir) {
|
|
249
|
+
if (dir !== "rtl") return key;
|
|
250
|
+
return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
|
|
251
|
+
}
|
|
252
|
+
function getFocusIntent(event, orientation, dir) {
|
|
253
|
+
const key = getDirectionAwareKey(event.key, dir);
|
|
254
|
+
if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
|
|
255
|
+
if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
|
|
256
|
+
return MAP_KEY_TO_FOCUS_INTENT[key];
|
|
257
|
+
}
|
|
258
|
+
function focusFirst(candidates, preventScroll = false) {
|
|
259
|
+
const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
|
|
260
|
+
for (const candidate of candidates) {
|
|
261
|
+
if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
262
|
+
candidate.focus({ preventScroll });
|
|
263
|
+
if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function wrapArray(array, startIndex) {
|
|
267
|
+
return array.map((_, index) => array[(startIndex + index) % array.length]);
|
|
268
|
+
}
|
|
269
|
+
var Root = RovingFocusGroup;
|
|
270
|
+
var Item = RovingFocusGroupItem;
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region editors/document-model-editor/components/state-error.tsx
|
|
273
|
+
function StateValidationErrorMessage({ error }) {
|
|
274
|
+
const { payload } = error;
|
|
275
|
+
switch (payload.kind) {
|
|
276
|
+
case "MISSING": return /* @__PURE__ */ jsxs("span", { children: [
|
|
277
|
+
"Field ",
|
|
278
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
279
|
+
" is missing."
|
|
280
|
+
] });
|
|
281
|
+
case "MISSING_OPTIONAL": return /* @__PURE__ */ jsxs("span", { children: [
|
|
282
|
+
"Optional field ",
|
|
283
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
284
|
+
" is not defined."
|
|
285
|
+
] });
|
|
286
|
+
case "UNKNOWN_FIELD": return /* @__PURE__ */ jsxs("span", { children: [
|
|
287
|
+
"Field ",
|
|
288
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
289
|
+
" is not a known field."
|
|
290
|
+
] });
|
|
291
|
+
case "NON_NULL": return /* @__PURE__ */ jsxs("span", { children: [
|
|
292
|
+
"Field ",
|
|
293
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
294
|
+
" cannot be null."
|
|
295
|
+
] });
|
|
296
|
+
case "TYPE": return /* @__PURE__ */ jsxs("span", { children: [
|
|
297
|
+
"Field ",
|
|
298
|
+
/* @__PURE__ */ jsx("strong", { children: payload.field }),
|
|
299
|
+
payload.expectedType ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
300
|
+
" ",
|
|
301
|
+
"must be a",
|
|
302
|
+
" ",
|
|
303
|
+
/* @__PURE__ */ jsx("strong", { children: payload.expectedType.replace(/!/g, "") }),
|
|
304
|
+
"."
|
|
305
|
+
] }) : /* @__PURE__ */ jsx(Fragment, { children: " has an invalid value." })
|
|
306
|
+
] });
|
|
307
|
+
case "RECURSIVE_TYPE": return /* @__PURE__ */ jsxs("span", { children: [
|
|
308
|
+
"Field ",
|
|
309
|
+
/* @__PURE__ */ jsx("strong", { children: payload.typeName }),
|
|
310
|
+
" has a recursive type. It must be optional."
|
|
311
|
+
] });
|
|
312
|
+
default: return /* @__PURE__ */ jsx("span", { children: "Invalid value." });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#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
|
|
317
|
+
var TABS_NAME = "Tabs";
|
|
318
|
+
var [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [createRovingFocusGroupScope]);
|
|
319
|
+
var useRovingFocusGroupScope = createRovingFocusGroupScope();
|
|
320
|
+
var [TabsProvider, useTabsContext] = createTabsContext(TABS_NAME);
|
|
321
|
+
var Tabs$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
322
|
+
const { __scopeTabs, value: valueProp, onValueChange, defaultValue, orientation = "horizontal", dir, activationMode = "automatic", ...tabsProps } = props;
|
|
323
|
+
const direction = useDirection(dir);
|
|
324
|
+
const [value, setValue] = useControllableState({
|
|
325
|
+
prop: valueProp,
|
|
326
|
+
onChange: onValueChange,
|
|
327
|
+
defaultProp: defaultValue ?? "",
|
|
328
|
+
caller: TABS_NAME
|
|
329
|
+
});
|
|
330
|
+
return /* @__PURE__ */ jsx(TabsProvider, {
|
|
331
|
+
scope: __scopeTabs,
|
|
332
|
+
baseId: useId$1(),
|
|
333
|
+
value,
|
|
334
|
+
onValueChange: setValue,
|
|
335
|
+
orientation,
|
|
336
|
+
dir: direction,
|
|
337
|
+
activationMode,
|
|
338
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
339
|
+
dir: direction,
|
|
340
|
+
"data-orientation": orientation,
|
|
341
|
+
...tabsProps,
|
|
342
|
+
ref: forwardedRef
|
|
343
|
+
})
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
Tabs$1.displayName = TABS_NAME;
|
|
347
|
+
var TAB_LIST_NAME = "TabsList";
|
|
348
|
+
var TabsList$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
349
|
+
const { __scopeTabs, loop = true, ...listProps } = props;
|
|
350
|
+
const context = useTabsContext(TAB_LIST_NAME, __scopeTabs);
|
|
351
|
+
return /* @__PURE__ */ jsx(Root, {
|
|
352
|
+
asChild: true,
|
|
353
|
+
...useRovingFocusGroupScope(__scopeTabs),
|
|
354
|
+
orientation: context.orientation,
|
|
355
|
+
dir: context.dir,
|
|
356
|
+
loop,
|
|
357
|
+
children: /* @__PURE__ */ jsx(Primitive.div, {
|
|
358
|
+
role: "tablist",
|
|
359
|
+
"aria-orientation": context.orientation,
|
|
360
|
+
...listProps,
|
|
361
|
+
ref: forwardedRef
|
|
362
|
+
})
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
TabsList$1.displayName = TAB_LIST_NAME;
|
|
366
|
+
var TRIGGER_NAME = "TabsTrigger";
|
|
367
|
+
var TabsTrigger$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
368
|
+
const { __scopeTabs, value, disabled = false, ...triggerProps } = props;
|
|
369
|
+
const context = useTabsContext(TRIGGER_NAME, __scopeTabs);
|
|
370
|
+
const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeTabs);
|
|
371
|
+
const triggerId = makeTriggerId(context.baseId, value);
|
|
372
|
+
const contentId = makeContentId(context.baseId, value);
|
|
373
|
+
const isSelected = value === context.value;
|
|
374
|
+
return /* @__PURE__ */ jsx(Item, {
|
|
375
|
+
asChild: true,
|
|
376
|
+
...rovingFocusGroupScope,
|
|
377
|
+
focusable: !disabled,
|
|
378
|
+
active: isSelected,
|
|
379
|
+
children: /* @__PURE__ */ jsx(Primitive.button, {
|
|
380
|
+
type: "button",
|
|
381
|
+
role: "tab",
|
|
382
|
+
"aria-selected": isSelected,
|
|
383
|
+
"aria-controls": contentId,
|
|
384
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
385
|
+
"data-disabled": disabled ? "" : void 0,
|
|
386
|
+
disabled,
|
|
387
|
+
id: triggerId,
|
|
388
|
+
...triggerProps,
|
|
389
|
+
ref: forwardedRef,
|
|
390
|
+
onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
|
|
391
|
+
if (!disabled && event.button === 0 && event.ctrlKey === false) context.onValueChange(value);
|
|
392
|
+
else event.preventDefault();
|
|
393
|
+
}),
|
|
394
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
395
|
+
if ([" ", "Enter"].includes(event.key)) context.onValueChange(value);
|
|
396
|
+
}),
|
|
397
|
+
onFocus: composeEventHandlers(props.onFocus, () => {
|
|
398
|
+
const isAutomaticActivation = context.activationMode !== "manual";
|
|
399
|
+
if (!isSelected && !disabled && isAutomaticActivation) context.onValueChange(value);
|
|
400
|
+
})
|
|
401
|
+
})
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
TabsTrigger$1.displayName = TRIGGER_NAME;
|
|
405
|
+
var CONTENT_NAME = "TabsContent";
|
|
406
|
+
var TabsContent$1 = React$1.forwardRef((props, forwardedRef) => {
|
|
407
|
+
const { __scopeTabs, value, forceMount, children, ...contentProps } = props;
|
|
408
|
+
const context = useTabsContext(CONTENT_NAME, __scopeTabs);
|
|
409
|
+
const triggerId = makeTriggerId(context.baseId, value);
|
|
410
|
+
const contentId = makeContentId(context.baseId, value);
|
|
411
|
+
const isSelected = value === context.value;
|
|
412
|
+
const isMountAnimationPreventedRef = React$1.useRef(isSelected);
|
|
413
|
+
React$1.useEffect(() => {
|
|
414
|
+
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
415
|
+
return () => cancelAnimationFrame(rAF);
|
|
416
|
+
}, []);
|
|
417
|
+
return /* @__PURE__ */ jsx(Presence, {
|
|
418
|
+
present: forceMount || isSelected,
|
|
419
|
+
children: ({ present }) => /* @__PURE__ */ jsx(Primitive.div, {
|
|
420
|
+
"data-state": isSelected ? "active" : "inactive",
|
|
421
|
+
"data-orientation": context.orientation,
|
|
422
|
+
role: "tabpanel",
|
|
423
|
+
"aria-labelledby": triggerId,
|
|
424
|
+
hidden: !present,
|
|
425
|
+
id: contentId,
|
|
426
|
+
tabIndex: 0,
|
|
427
|
+
...contentProps,
|
|
428
|
+
ref: forwardedRef,
|
|
429
|
+
style: {
|
|
430
|
+
...props.style,
|
|
431
|
+
animationDuration: isMountAnimationPreventedRef.current ? "0s" : void 0
|
|
432
|
+
},
|
|
433
|
+
children: present && children
|
|
434
|
+
})
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
TabsContent$1.displayName = CONTENT_NAME;
|
|
438
|
+
function makeTriggerId(baseId, value) {
|
|
439
|
+
return `${baseId}-trigger-${value}`;
|
|
440
|
+
}
|
|
441
|
+
function makeContentId(baseId, value) {
|
|
442
|
+
return `${baseId}-content-${value}`;
|
|
443
|
+
}
|
|
444
|
+
var Root2 = Tabs$1;
|
|
445
|
+
var List = TabsList$1;
|
|
446
|
+
var Trigger = TabsTrigger$1;
|
|
447
|
+
var Content = TabsContent$1;
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region editors/document-model-editor/components/tabs.tsx
|
|
450
|
+
const Tabs = Root2;
|
|
451
|
+
const TabsList = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(List, {
|
|
452
|
+
ref,
|
|
453
|
+
className: twMerge("flex items-center justify-center rounded-xl bg-background p-1 shadow-inner", className),
|
|
454
|
+
...props
|
|
455
|
+
}));
|
|
456
|
+
TabsList.displayName = List.displayName;
|
|
457
|
+
const TabsTrigger = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Trigger, {
|
|
458
|
+
ref,
|
|
459
|
+
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),
|
|
460
|
+
...props
|
|
461
|
+
}));
|
|
462
|
+
TabsTrigger.displayName = Trigger.displayName;
|
|
463
|
+
const TabsContent = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(Content, {
|
|
464
|
+
ref,
|
|
465
|
+
className,
|
|
466
|
+
...props
|
|
467
|
+
}));
|
|
468
|
+
TabsContent.displayName = Content.displayName;
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region editors/document-model-editor/components/state-schemas.tsx
|
|
471
|
+
const GraphqlEditor = lazy(() => import("./graphql-editor-BMhHl2XP.js"));
|
|
472
|
+
const JSONEditor = lazy(() => import("./json-editor-DBhkG5TF.js"));
|
|
473
|
+
function StateEditor({ modelName, stateSchema, initialValue, setStateSchema, setInitialState, scope }) {
|
|
474
|
+
const { sharedSchema: sharedSchemaSdl, error: sharedSchemaError } = useSchemaContext();
|
|
475
|
+
const [showStandardLib, setShowStandardLib] = useState(false);
|
|
476
|
+
const [syncWithSchema, setSyncWithSchema] = useState(true);
|
|
477
|
+
const customLinter = useCallback((doc) => ensureValidStateSchemaName(doc, modelName, scope), [modelName, scope]);
|
|
478
|
+
const schemaErrors = useMemo(() => {
|
|
479
|
+
const errors = ensureValidStateSchemaName(stateSchema, modelName, scope);
|
|
480
|
+
if (sharedSchemaError) return [...errors, sharedSchemaError];
|
|
481
|
+
return errors;
|
|
482
|
+
}, [
|
|
483
|
+
stateSchema,
|
|
484
|
+
modelName,
|
|
485
|
+
scope,
|
|
486
|
+
sharedSchemaError
|
|
487
|
+
]);
|
|
488
|
+
const handleToggleStandardLib = useCallback(() => {
|
|
489
|
+
setShowStandardLib((prev) => !prev);
|
|
490
|
+
}, []);
|
|
491
|
+
const handleSchemaUpdate = useCallback((newDoc) => setStateSchema(newDoc, scope), [setStateSchema, scope]);
|
|
492
|
+
const handleInitialStateUpdate = useCallback((newDoc) => setInitialState(newDoc, scope), [setInitialState, scope]);
|
|
493
|
+
const hasSyncedRef = useRef(false);
|
|
494
|
+
const { initialValueErrors, fixedState } = useMemo(() => {
|
|
495
|
+
const existingValue = initialValue || "{}";
|
|
496
|
+
const sharedSchemaDocumentNode = safeParseSdl(sharedSchemaSdl);
|
|
497
|
+
if (!sharedSchemaDocumentNode) return {
|
|
498
|
+
initialValueErrors: [],
|
|
499
|
+
fixedState: null
|
|
500
|
+
};
|
|
501
|
+
const stateTypeName = makeStateSchemaNameForScope(modelName, scope);
|
|
502
|
+
if (!stateTypeName) return {
|
|
503
|
+
initialValueErrors: [],
|
|
504
|
+
fixedState: null
|
|
505
|
+
};
|
|
506
|
+
const stateTypeDefinitionNode = sharedSchemaDocumentNode.definitions.find((def) => def.kind === Kind.OBJECT_TYPE_DEFINITION && def.name.value === stateTypeName);
|
|
507
|
+
if (!stateTypeDefinitionNode || stateTypeDefinitionNode.kind !== Kind.OBJECT_TYPE_DEFINITION) return {
|
|
508
|
+
initialValueErrors: [],
|
|
509
|
+
fixedState: null
|
|
510
|
+
};
|
|
511
|
+
const errors = validateStateObject(sharedSchemaDocumentNode, stateTypeDefinitionNode, existingValue);
|
|
512
|
+
if (errors.length && syncWithSchema) {
|
|
513
|
+
const computedFixedState = makeMinimalObjectForStateType({
|
|
514
|
+
sharedSchemaDocumentNode,
|
|
515
|
+
stateTypeDefinitionNode,
|
|
516
|
+
existingValue
|
|
517
|
+
});
|
|
518
|
+
if (initialValue !== computedFixedState) return {
|
|
519
|
+
initialValueErrors: [],
|
|
520
|
+
fixedState: computedFixedState
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
initialValueErrors: errors,
|
|
525
|
+
fixedState: null
|
|
526
|
+
};
|
|
527
|
+
}, [
|
|
528
|
+
sharedSchemaSdl,
|
|
529
|
+
initialValue,
|
|
530
|
+
syncWithSchema,
|
|
531
|
+
scope,
|
|
532
|
+
modelName
|
|
533
|
+
]);
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
if (fixedState && !hasSyncedRef.current) {
|
|
536
|
+
hasSyncedRef.current = true;
|
|
537
|
+
setInitialState(fixedState, scope);
|
|
538
|
+
} else if (!fixedState) hasSyncedRef.current = false;
|
|
539
|
+
}, [
|
|
540
|
+
fixedState,
|
|
541
|
+
setInitialState,
|
|
542
|
+
scope
|
|
543
|
+
]);
|
|
544
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
545
|
+
className: "grid grid-cols-2 gap-4",
|
|
546
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [
|
|
547
|
+
/* @__PURE__ */ jsxs("h3", {
|
|
548
|
+
className: "mb-2 text-lg text-foreground capitalize",
|
|
549
|
+
children: [scope, " state schema *"]
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ jsxs(Button, {
|
|
552
|
+
onClick: handleToggleStandardLib,
|
|
553
|
+
className: "mb-2 flex w-fit items-center gap-2",
|
|
554
|
+
children: [
|
|
555
|
+
showStandardLib ? "Hide" : "Show",
|
|
556
|
+
" standard library",
|
|
557
|
+
/* @__PURE__ */ jsx("svg", {
|
|
558
|
+
className: twMerge("inline-block transition-transform", showStandardLib ? "rotate-180" : "rotate-0"),
|
|
559
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
560
|
+
width: "24",
|
|
561
|
+
height: "24",
|
|
562
|
+
viewBox: "0 0 24 24",
|
|
563
|
+
fill: "currentColor",
|
|
564
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
565
|
+
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",
|
|
566
|
+
fill: "currentColor"
|
|
567
|
+
})
|
|
568
|
+
})
|
|
569
|
+
]
|
|
570
|
+
}),
|
|
571
|
+
/* @__PURE__ */ jsxs(Suspense, { children: [
|
|
572
|
+
showStandardLib && /* @__PURE__ */ jsx(GraphqlEditor, {
|
|
573
|
+
doc: typeDefsDoc,
|
|
574
|
+
readonly: true
|
|
575
|
+
}),
|
|
576
|
+
/* @__PURE__ */ jsx(GraphqlEditor, {
|
|
577
|
+
doc: stateSchema,
|
|
578
|
+
updateDocumentInModel: handleSchemaUpdate,
|
|
579
|
+
customLinter
|
|
580
|
+
}),
|
|
581
|
+
schemaErrors.length > 0 && /* @__PURE__ */ jsx("p", {
|
|
582
|
+
className: "mt-2 text-sm text-destructive",
|
|
583
|
+
children: schemaErrors[0].message
|
|
584
|
+
})
|
|
585
|
+
] })
|
|
586
|
+
] }), /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
587
|
+
className: "flex flex-col items-end",
|
|
588
|
+
children: [/* @__PURE__ */ jsxs("h3", {
|
|
589
|
+
className: "mb-2 text-right text-lg text-foreground capitalize",
|
|
590
|
+
children: [scope, " state initial value *"]
|
|
591
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
592
|
+
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",
|
|
593
|
+
children: [
|
|
594
|
+
/* @__PURE__ */ jsx("input", {
|
|
595
|
+
type: "checkbox",
|
|
596
|
+
className: "",
|
|
597
|
+
value: syncWithSchema.toString(),
|
|
598
|
+
onChange: (e) => {
|
|
599
|
+
setSyncWithSchema(e.currentTarget.value === "true" ? true : false);
|
|
600
|
+
}
|
|
601
|
+
}),
|
|
602
|
+
"Sync with schema",
|
|
603
|
+
" ",
|
|
604
|
+
/* @__PURE__ */ jsx("svg", {
|
|
605
|
+
className: "inline-block",
|
|
606
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
607
|
+
width: "16",
|
|
608
|
+
height: "16",
|
|
609
|
+
viewBox: "0 0 16 16",
|
|
610
|
+
fill: "none",
|
|
611
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
612
|
+
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",
|
|
613
|
+
fill: "currentColor"
|
|
614
|
+
})
|
|
615
|
+
})
|
|
616
|
+
]
|
|
617
|
+
})]
|
|
618
|
+
}), /* @__PURE__ */ jsxs(Suspense, { children: [/* @__PURE__ */ jsx(JSONEditor, {
|
|
619
|
+
doc: initialValue,
|
|
620
|
+
updateDocumentInModel: handleInitialStateUpdate
|
|
621
|
+
}), initialValueErrors.map((error, index) => /* @__PURE__ */ jsx("p", {
|
|
622
|
+
className: "mt-2 text-sm text-destructive",
|
|
623
|
+
children: error instanceof StateValidationError ? /* @__PURE__ */ jsx(StateValidationErrorMessage, { error }) : error.message
|
|
624
|
+
}, index))] })] })]
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
function StateSchemas({ modelName, globalStateSchema, localStateSchema, globalStateInitialValue, localStateInitialValue, setStateSchema, setInitialState, currentScope, onScopeChange }) {
|
|
628
|
+
const handleAddLocalState = useCallback(() => {
|
|
629
|
+
setStateSchema(makeInitialSchemaDoc(modelName, "local"), "local");
|
|
630
|
+
setInitialState("", "local");
|
|
631
|
+
}, [
|
|
632
|
+
modelName,
|
|
633
|
+
setStateSchema,
|
|
634
|
+
setInitialState
|
|
635
|
+
]);
|
|
636
|
+
return /* @__PURE__ */ jsxs(Tabs, {
|
|
637
|
+
className: "pb-8",
|
|
638
|
+
activationMode: "manual",
|
|
639
|
+
value: currentScope,
|
|
640
|
+
onValueChange: (value) => onScopeChange(value),
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ jsx("div", {
|
|
643
|
+
className: "my-6",
|
|
644
|
+
children: /* @__PURE__ */ jsxs(TabsList, {
|
|
645
|
+
className: "mx-auto flex max-w-sm",
|
|
646
|
+
children: [/* @__PURE__ */ jsx(TabsTrigger, {
|
|
647
|
+
value: "global",
|
|
648
|
+
children: "Global"
|
|
649
|
+
}), /* @__PURE__ */ jsx(TabsTrigger, {
|
|
650
|
+
value: "local",
|
|
651
|
+
children: "Local"
|
|
652
|
+
})]
|
|
653
|
+
})
|
|
654
|
+
}),
|
|
655
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
656
|
+
value: "global",
|
|
657
|
+
tabIndex: -1,
|
|
658
|
+
children: /* @__PURE__ */ jsx(StateEditor, {
|
|
659
|
+
modelName,
|
|
660
|
+
stateSchema: globalStateSchema,
|
|
661
|
+
initialValue: globalStateInitialValue,
|
|
662
|
+
setStateSchema,
|
|
663
|
+
setInitialState,
|
|
664
|
+
scope: "global"
|
|
665
|
+
})
|
|
666
|
+
}),
|
|
667
|
+
/* @__PURE__ */ jsx(TabsContent, {
|
|
668
|
+
value: "local",
|
|
669
|
+
tabIndex: -1,
|
|
670
|
+
children: !localStateSchema ? /* @__PURE__ */ jsxs("div", {
|
|
671
|
+
className: "",
|
|
672
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
673
|
+
className: "mb-2 text-lg text-foreground capitalize",
|
|
674
|
+
children: "local state schema *"
|
|
675
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
676
|
+
onClick: handleAddLocalState,
|
|
677
|
+
children: "Add local state"
|
|
678
|
+
})]
|
|
679
|
+
}) : /* @__PURE__ */ jsx(StateEditor, {
|
|
680
|
+
modelName,
|
|
681
|
+
stateSchema: localStateSchema,
|
|
682
|
+
initialValue: localStateInitialValue,
|
|
683
|
+
setStateSchema,
|
|
684
|
+
setInitialState,
|
|
685
|
+
scope: "local"
|
|
686
|
+
})
|
|
687
|
+
})
|
|
688
|
+
]
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
//#endregion
|
|
692
|
+
export { StateSchemas as default };
|
|
693
|
+
|
|
694
|
+
//# sourceMappingURL=state-schemas-DuA5rB1e.js.map
|