@ultrst-armada/floks 1.5.2 → 1.5.4

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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/floks",
4
- "version": "1.5.2",
5
- "sourceCommit": "12db7b76eea89ca4dd948ead3277e53bb7fffa14",
4
+ "version": "1.5.4",
5
+ "sourceCommit": "0ff200b15f4eb2c91b2ed2e034ed5aa7bf89a411",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "40317793760"
7
+ "workflowRunId": "40318988564"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/floks",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -61,7 +61,7 @@
61
61
  "@dinilmusick/gutts": "^0.1.3"
62
62
  },
63
63
  "peerDependencies": {
64
- "@ultrst-armada/kloks": "^1.0.2 || ^1.4.0",
64
+ "@ultrst-armada/kloks": "^1.9.0",
65
65
  "lucide-react": ">=0.300.0",
66
66
  "react": "^18.0.0 || ^19.0.0",
67
67
  "react-dom": "^18.0.0 || ^19.0.0"
@@ -17,6 +17,9 @@ interface UIAuthoringNode {
17
17
  assetRef?: AuthoringAssetRef;
18
18
  parentId?: string;
19
19
  props: Record<string, string | number | boolean>;
20
+ slots?: Record<string, string[]>;
21
+ states?: Record<string, Record<string, string | number | boolean>>;
22
+ events?: Record<string, string>;
20
23
  }
21
24
  interface UIAuthoringSession {
22
25
  sessionId: string;
@@ -36,6 +39,14 @@ interface UIAuthoringSession {
36
39
  operationId: string;
37
40
  name: string;
38
41
  description?: string;
42
+ inputFields?: Array<{
43
+ name: string;
44
+ type: string;
45
+ }>;
46
+ outputFields?: Array<{
47
+ name: string;
48
+ type: string;
49
+ }>;
39
50
  }>;
40
51
  metadata: Record<string, string>;
41
52
  }
@@ -61,4 +72,9 @@ declare function UiAuthoringWorkspace(props: {
61
72
  onValidate?: () => void;
62
73
  }): React__default.JSX.Element;
63
74
 
64
- export { type AuthoringAssetRef, type UIAuthoringContext, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringSession, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth };
75
+ declare function UiAuthoringBindingEditor(props: {
76
+ session: UIAuthoringSession;
77
+ onChange: (session: UIAuthoringSession) => void;
78
+ }): React__default.JSX.Element;
79
+
80
+ export { type AuthoringAssetRef, type UIAuthoringContext, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringSession, UiAuthoringBindingEditor, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth };
@@ -1,11 +1,13 @@
1
1
  import {
2
+ UiAuthoringBindingEditor,
2
3
  UiAuthoringInspector,
3
4
  UiAuthoringTree,
4
5
  UiAuthoringWorkspace,
5
6
  getAuthoringChildren,
6
7
  getAuthoringDepth
7
- } from "../chunk-MFZKZ76J.js";
8
+ } from "../chunk-GJ472MWX.js";
8
9
  export {
10
+ UiAuthoringBindingEditor,
9
11
  UiAuthoringInspector,
10
12
  UiAuthoringTree,
11
13
  UiAuthoringWorkspace,
@@ -50,6 +50,7 @@ function useMonaco() {
50
50
 
51
51
  // src/editor/MonacoEditor.tsx
52
52
  import { useEffect as useEffect2, useRef } from "react";
53
+ import { MonacoIdeServiceFacade } from "@ultrst-armada/kloks/services";
53
54
  import { jsx } from "react/jsx-runtime";
54
55
  function MonacoEditor({
55
56
  value,
@@ -69,7 +70,7 @@ function MonacoEditor({
69
70
  const editorRef = useRef(null);
70
71
  const sessionRef = useRef(sessionId);
71
72
  const monaco = useMonaco();
72
- const service = ideService || { execute: async () => void 0 };
73
+ const service = ideService || MonacoIdeServiceFacade;
73
74
  useEffect2(() => {
74
75
  if (!sessionRef.current) sessionRef.current = sessionId || `editor-${Date.now().toString(36)}`;
75
76
  void service.execute("createSession", {
@@ -0,0 +1,282 @@
1
+ // src/authoring/authoringModel.ts
2
+ function getAuthoringDepth(node, nodes) {
3
+ let depth = 0;
4
+ let parentId = node.parentId;
5
+ while (parentId) {
6
+ const parent = nodes.find((item) => item.id === parentId);
7
+ if (!parent) break;
8
+ depth += 1;
9
+ parentId = parent.parentId;
10
+ }
11
+ return depth;
12
+ }
13
+ function getAuthoringChildren(nodeId, nodes) {
14
+ return nodes.filter((node) => node.parentId === nodeId);
15
+ }
16
+
17
+ // src/authoring/UiAuthoringTree.tsx
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ function UiAuthoringTree(props) {
20
+ return /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [
21
+ props.nodes.map((node) => /* @__PURE__ */ jsxs(
22
+ "button",
23
+ {
24
+ type: "button",
25
+ onClick: () => props.onSelect(node.id),
26
+ className: `flex w-full items-center gap-2 border-b border-black/10 px-2 py-1.5 text-left text-xs ${props.selectedNodeId === node.id ? "bg-black/10" : ""}`,
27
+ style: { paddingLeft: 8 + getAuthoringDepth(node, props.nodes) * 14 },
28
+ children: [
29
+ /* @__PURE__ */ jsx("span", { className: "font-semibold", children: node.name }),
30
+ /* @__PURE__ */ jsx("span", { className: "ml-auto opacity-50", children: node.kind })
31
+ ]
32
+ },
33
+ node.id
34
+ )),
35
+ !props.nodes.length && /* @__PURE__ */ jsx("div", { className: "p-4 text-xs opacity-60", children: "No authored nodes." })
36
+ ] });
37
+ }
38
+
39
+ // src/authoring/UiAuthoringInspector.tsx
40
+ import React from "react";
41
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
42
+ function readJsonObject(raw) {
43
+ try {
44
+ const value = JSON.parse(raw);
45
+ if (value && typeof value === "object" && !Array.isArray(value)) return value;
46
+ } catch {
47
+ return void 0;
48
+ }
49
+ return void 0;
50
+ }
51
+ function JsonEditor(props) {
52
+ const [invalid, setInvalid] = React.useState(false);
53
+ return /* @__PURE__ */ jsxs2("label", { className: "mt-3 block text-xs", children: [
54
+ props.label,
55
+ " (JSON)",
56
+ /* @__PURE__ */ jsx2(
57
+ "textarea",
58
+ {
59
+ className: `mt-1 min-h-20 w-full rounded border px-2 py-1.5 font-mono text-[10px] ${invalid ? "border-red-500" : ""}`,
60
+ defaultValue: JSON.stringify(props.value || {}, null, 2),
61
+ spellCheck: false,
62
+ onBlur: (event) => {
63
+ const parsed = readJsonObject(event.currentTarget.value);
64
+ setInvalid(!parsed);
65
+ if (parsed) props.onCommit(parsed);
66
+ }
67
+ },
68
+ props.nodeId + props.label
69
+ ),
70
+ invalid && /* @__PURE__ */ jsx2("span", { className: "text-[10px] text-red-600", children: "Enter a valid JSON object, then blur to apply." })
71
+ ] });
72
+ }
73
+ function UiAuthoringInspector(props) {
74
+ if (!props.node) return /* @__PURE__ */ jsx2("aside", { className: "w-72 border-l border-black/10 p-3 text-xs opacity-60", children: "Select a node." });
75
+ const node = props.node;
76
+ const description = String(node.props.description || "");
77
+ return /* @__PURE__ */ jsxs2("aside", { className: "w-72 overflow-auto border-l border-black/10 p-3", children: [
78
+ /* @__PURE__ */ jsx2("div", { className: "mb-3 text-xs font-bold uppercase tracking-wide", children: node.kind }),
79
+ /* @__PURE__ */ jsxs2("label", { className: "block text-xs", children: [
80
+ "Name",
81
+ /* @__PURE__ */ jsx2("input", { className: "mt-1 w-full rounded border px-2 py-1.5", value: node.name, onChange: (e) => props.onChange({ name: e.target.value }) })
82
+ ] }),
83
+ /* @__PURE__ */ jsxs2("label", { className: "mt-3 block text-xs", children: [
84
+ "Description",
85
+ /* @__PURE__ */ jsx2("textarea", { className: "mt-1 min-h-20 w-full rounded border px-2 py-1.5", value: description, onChange: (e) => props.onChange({ props: { ...node.props, description: e.target.value } }) })
86
+ ] }),
87
+ /* @__PURE__ */ jsx2(
88
+ JsonEditor,
89
+ {
90
+ label: "Properties",
91
+ value: node.props,
92
+ nodeId: node.id,
93
+ onCommit: (value) => props.onChange({ props: value })
94
+ }
95
+ ),
96
+ node.kind === "component" && /* @__PURE__ */ jsxs2(Fragment, { children: [
97
+ /* @__PURE__ */ jsx2(
98
+ JsonEditor,
99
+ {
100
+ label: "Slots",
101
+ value: node.slots,
102
+ nodeId: node.id,
103
+ onCommit: (slots) => props.onChange({ slots })
104
+ }
105
+ ),
106
+ /* @__PURE__ */ jsx2(
107
+ JsonEditor,
108
+ {
109
+ label: "Visual states",
110
+ value: node.states,
111
+ nodeId: node.id,
112
+ onCommit: (states) => props.onChange({ states })
113
+ }
114
+ ),
115
+ /* @__PURE__ */ jsx2(
116
+ JsonEditor,
117
+ {
118
+ label: "Event \u2192 operation bindings",
119
+ value: node.events,
120
+ nodeId: node.id,
121
+ onCommit: (events) => props.onChange({ events })
122
+ }
123
+ )
124
+ ] })
125
+ ] });
126
+ }
127
+
128
+ // src/authoring/UiAuthoringWorkspace.tsx
129
+ import React3 from "react";
130
+
131
+ // src/authoring/UiAuthoringBindingEditor.tsx
132
+ import React2 from "react";
133
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
134
+ function UiAuthoringBindingEditor(props) {
135
+ const components = props.session.nodes.filter((node) => node.kind === "component");
136
+ const [componentId, setComponentId] = React2.useState("");
137
+ const [property, setProperty] = React2.useState("value");
138
+ const [operationId, setOperationId] = React2.useState("");
139
+ const [targetKind, setTargetKind] = React2.useState("api-input");
140
+ const [fieldName, setFieldName] = React2.useState("");
141
+ const operation = props.session.operations.find((item) => item.operationId === operationId);
142
+ const fields = targetKind === "api-input" ? operation?.inputFields || [] : operation?.outputFields || [];
143
+ const addBinding = () => {
144
+ if (!componentId || !property.trim() || !operationId || !fields.length) return;
145
+ const field = fields.find((item) => item.name === fieldName) || fields[0];
146
+ const binding = { componentId, property: property.trim(), target: {
147
+ kind: targetKind,
148
+ apiId: operationId,
149
+ field: field.name,
150
+ fieldType: field.type
151
+ } };
152
+ props.onChange({
153
+ ...props.session,
154
+ bindings: [...props.session.bindings.filter((item) => item.componentId !== componentId || item.property !== property.trim()), binding]
155
+ });
156
+ };
157
+ const removeBinding = (component, prop) => props.onChange({
158
+ ...props.session,
159
+ bindings: props.session.bindings.filter((item) => item.componentId !== component || item.property !== prop)
160
+ });
161
+ return /* @__PURE__ */ jsxs3("section", { className: "shrink-0 border-t border-black/10 p-3 text-xs", children: [
162
+ /* @__PURE__ */ jsx3("div", { className: "mb-2 font-bold uppercase tracking-wide", children: "Data bindings" }),
163
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-2", children: [
164
+ /* @__PURE__ */ jsxs3("select", { className: "max-w-48 rounded border px-2 py-1.5", value: componentId, onChange: (event) => setComponentId(event.target.value), children: [
165
+ /* @__PURE__ */ jsx3("option", { value: "", children: "Component\u2026" }),
166
+ components.map((node) => /* @__PURE__ */ jsx3("option", { value: node.id, children: node.name }, node.id))
167
+ ] }),
168
+ /* @__PURE__ */ jsx3("input", { className: "w-28 rounded border px-2 py-1.5", "aria-label": "Bound property", value: property, onChange: (event) => setProperty(event.target.value) }),
169
+ /* @__PURE__ */ jsxs3("select", { className: "rounded border px-2 py-1.5", value: operationId, onChange: (event) => setOperationId(event.target.value), children: [
170
+ /* @__PURE__ */ jsx3("option", { value: "", children: "Operation\u2026" }),
171
+ props.session.operations.map((item) => /* @__PURE__ */ jsx3("option", { value: item.operationId, children: item.name }, item.operationId))
172
+ ] }),
173
+ /* @__PURE__ */ jsxs3("select", { className: "rounded border px-2 py-1.5", value: targetKind, onChange: (event) => setTargetKind(event.target.value), children: [
174
+ /* @__PURE__ */ jsx3("option", { value: "api-input", children: "Operation input" }),
175
+ /* @__PURE__ */ jsx3("option", { value: "api-output", children: "Operation output" })
176
+ ] }),
177
+ /* @__PURE__ */ jsx3("select", { className: "max-w-40 rounded border px-2 py-1.5", "aria-label": "Bound field", value: fields.some((field) => field.name === fieldName) ? fieldName : fields[0]?.name || "", disabled: !fields.length, onChange: (event) => setFieldName(event.target.value), children: fields.length ? fields.map((field) => /* @__PURE__ */ jsxs3("option", { value: field.name, children: [
178
+ field.name,
179
+ " \xB7 ",
180
+ field.type
181
+ ] }, field.name)) : /* @__PURE__ */ jsx3("option", { value: "", children: "No fields" }) }),
182
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "rounded border px-2 py-1.5 disabled:opacity-40", disabled: !componentId || !operationId || !fields.length, onClick: addBinding, children: "Add / replace" })
183
+ ] }),
184
+ /* @__PURE__ */ jsxs3("ul", { className: "mt-2 flex flex-wrap gap-2", children: [
185
+ props.session.bindings.map((binding) => /* @__PURE__ */ jsxs3("li", { className: "flex items-center gap-2 rounded bg-black/5 px-2 py-1", children: [
186
+ /* @__PURE__ */ jsxs3("span", { children: [
187
+ components.find((node) => node.id === binding.componentId)?.name || binding.componentId,
188
+ ".",
189
+ binding.property,
190
+ " \u2190 ",
191
+ binding.target.apiId,
192
+ ".",
193
+ binding.target.field
194
+ ] }),
195
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-label": `Remove binding ${binding.property}`, onClick: () => removeBinding(binding.componentId, binding.property), children: "\xD7" })
196
+ ] }, binding.componentId + ":" + binding.property)),
197
+ !props.session.bindings.length && /* @__PURE__ */ jsx3("li", { className: "opacity-60", children: "No bindings configured." })
198
+ ] })
199
+ ] });
200
+ }
201
+
202
+ // src/authoring/UiAuthoringWorkspace.tsx
203
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
204
+ function UiAuthoringWorkspace(props) {
205
+ const [selectedNodeId, setSelectedNodeId] = React3.useState();
206
+ const selectedNode = props.session.nodes.find((node) => node.id === selectedNodeId);
207
+ const addNode = (kind, assetRef) => {
208
+ const parent = kind === "section" ? props.session.nodes.find((node2) => node2.kind === "page") : kind === "component" ? props.session.nodes.find((node2) => node2.kind === "section") : void 0;
209
+ const node = {
210
+ id: `authoring-${kind}-${Date.now().toString(36)}`,
211
+ kind,
212
+ name: kind === "component" ? assetRef?.assetId || "Component" : kind[0].toUpperCase() + kind.slice(1),
213
+ componentId: kind === "component" ? assetRef?.assetId : void 0,
214
+ assetRef,
215
+ parentId: parent?.id,
216
+ props: {}
217
+ };
218
+ props.onChange({ ...props.session, nodes: [...props.session.nodes, node] });
219
+ setSelectedNodeId(node.id);
220
+ };
221
+ const updateSelected = (patch) => {
222
+ if (!selectedNode) return;
223
+ props.onChange({
224
+ ...props.session,
225
+ nodes: props.session.nodes.map((node) => node.id === selectedNode.id ? { ...node, ...patch } : node)
226
+ });
227
+ };
228
+ const removeSelected = () => {
229
+ if (!selectedNode) return;
230
+ props.onChange({
231
+ ...props.session,
232
+ nodes: props.session.nodes.filter((node) => node.id !== selectedNode.id && node.parentId !== selectedNode.id)
233
+ });
234
+ setSelectedNodeId(void 0);
235
+ };
236
+ const contextLabel = {
237
+ service: "Service UI",
238
+ "general-component": "General Component",
239
+ application: "Application UI"
240
+ };
241
+ return /* @__PURE__ */ jsxs4("section", { className: "flex h-full min-h-0 flex-col overflow-hidden border border-black/10 bg-white", children: [
242
+ /* @__PURE__ */ jsxs4("header", { className: "flex shrink-0 items-center gap-2 border-b border-black/10 px-3 py-2", children: [
243
+ /* @__PURE__ */ jsxs4("strong", { className: "text-xs", children: [
244
+ contextLabel[props.session.context],
245
+ " Authoring"
246
+ ] }),
247
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => addNode("page"), className: "rounded border px-2 py-1 text-xs", children: "Page" }),
248
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: () => addNode("section"), className: "rounded border px-2 py-1 text-xs", children: "Section" }),
249
+ /* @__PURE__ */ jsxs4(
250
+ "select",
251
+ {
252
+ className: "rounded border px-2 py-1 text-xs",
253
+ value: "",
254
+ onChange: (e) => {
255
+ const asset = props.availableAssets.find((item) => item.assetId === e.target.value);
256
+ if (asset) addNode("component", asset);
257
+ },
258
+ children: [
259
+ /* @__PURE__ */ jsx4("option", { value: "", children: "Add component\u2026" }),
260
+ props.availableAssets.map((asset) => /* @__PURE__ */ jsx4("option", { value: asset.assetId, children: asset.assetId }, asset.assetId))
261
+ ]
262
+ }
263
+ ),
264
+ /* @__PURE__ */ jsx4("button", { type: "button", disabled: !selectedNode, onClick: removeSelected, className: "ml-auto rounded border px-2 py-1 text-xs disabled:opacity-40", children: "Remove" }),
265
+ /* @__PURE__ */ jsx4("button", { type: "button", onClick: props.onValidate, className: "rounded border px-2 py-1 text-xs", children: "Validate" })
266
+ ] }),
267
+ /* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 flex-1", children: [
268
+ /* @__PURE__ */ jsx4(UiAuthoringTree, { nodes: props.session.nodes, selectedNodeId, onSelect: setSelectedNodeId }),
269
+ /* @__PURE__ */ jsx4(UiAuthoringInspector, { node: selectedNode, onChange: updateSelected })
270
+ ] }),
271
+ /* @__PURE__ */ jsx4(UiAuthoringBindingEditor, { session: props.session, onChange: props.onChange })
272
+ ] });
273
+ }
274
+
275
+ export {
276
+ getAuthoringDepth,
277
+ getAuthoringChildren,
278
+ UiAuthoringTree,
279
+ UiAuthoringInspector,
280
+ UiAuthoringBindingEditor,
281
+ UiAuthoringWorkspace
282
+ };
@@ -2,7 +2,7 @@ import {
2
2
  MonacoEditor,
3
3
  skipoDarkTheme,
4
4
  useMonaco
5
- } from "../chunk-WUNEXPZP.js";
5
+ } from "../chunk-5I3TTHDX.js";
6
6
  export {
7
7
  MonacoEditor,
8
8
  skipoDarkTheme,
@@ -10,7 +10,7 @@ export { FrnlEditableNodeGraph, FrnlEditableNodeGraphProps, frnlEditableNodeGrap
10
10
  export { B as BIOME_CONFIGS, C as COORD_SCALE, a as CameraState, b as Canvas2DViewerProps, c as ConnectingWireState } from './types-D3RRfQUo.js';
11
11
  export { CanvasBackground2D, CanvasErrorBoundary, ContainerNode2D, EffectNode2D, MagneticTraces2D, ModuleNode2D, NODE_CARD_WIDTH, Node2DBase, Node2DBaseProps, NodeRenderer2D, NodeRenderer2DProps, RecorderWaveformDisplay, RecorderWaveformDisplayProps, RotaryKnob, RotaryKnobProps, SOCKET_ROW_HEIGHT, Socket2D, Socket2DProps, SocketScreenPosition, TriggerNode2D, Wire2D, Wire2DProps, getSocketLocalOffset, getSocketScreenPosition, renderSpriteIcon, useCanvas2DCoordinates, useCanvas2DMagnetic } from './graph-2d/index.js';
12
12
  export { PredictiveGhostNodeCard, PredictiveGhostNodeCardProps, PredictiveHudToolbar, PredictiveLayer2D, PredictiveLayer2DProps, UsePredictiveGraph2DProps, UseViewer2DPredictiveProps, usePredictiveGraph2D } from './predictive/index.js';
13
- export { AuthoringAssetRef, UIAuthoringContext, UIAuthoringNode, UIAuthoringNodeKind, UIAuthoringSession, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth } from './authoring/index.js';
13
+ export { AuthoringAssetRef, UIAuthoringContext, UIAuthoringNode, UIAuthoringNodeKind, UIAuthoringSession, UiAuthoringBindingEditor, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth } from './authoring/index.js';
14
14
 
15
15
  interface MidpointWidgetsProps {
16
16
  x: number;
@@ -5,12 +5,13 @@ import {
5
5
  useTileMenu
6
6
  } from "./chunk-SA3JADUG.js";
7
7
  import {
8
+ UiAuthoringBindingEditor,
8
9
  UiAuthoringInspector,
9
10
  UiAuthoringTree,
10
11
  UiAuthoringWorkspace,
11
12
  getAuthoringChildren,
12
13
  getAuthoringDepth
13
- } from "./chunk-MFZKZ76J.js";
14
+ } from "./chunk-GJ472MWX.js";
14
15
  import {
15
16
  CanvasViewport,
16
17
  InfiniteCanvas,
@@ -26,7 +27,7 @@ import {
26
27
  MonacoEditor,
27
28
  skipoDarkTheme,
28
29
  useMonaco
29
- } from "./chunk-WUNEXPZP.js";
30
+ } from "./chunk-5I3TTHDX.js";
30
31
  import {
31
32
  CanvasContextMenu,
32
33
  CompatibleNodePicker,
@@ -737,6 +738,7 @@ export {
737
738
  TileCreateButton,
738
739
  TileGrid,
739
740
  TriggerNode2D,
741
+ UiAuthoringBindingEditor,
740
742
  UiAuthoringInspector,
741
743
  UiAuthoringTree,
742
744
  UiAuthoringWorkspace,
@@ -73,7 +73,7 @@
73
73
  "@dnd-kit/utilities": "^3.0.0",
74
74
  "monaco-editor": "^0.50.0",
75
75
  "react": "^18.0.0 || ^19.0.0",
76
- "@ultrst-armada/kloks": "^1.0.2 || ^1.4.0"
76
+ "@ultrst-armada/kloks": "^1.9.0"
77
77
  },
78
78
  "peerDependenciesMeta": {
79
79
  "@dnd-kit/core": {
@@ -1,3 +1,13 @@
1
+ import {
2
+ ConfirmDialog,
3
+ CopyableErrorAlert,
4
+ EmptyState,
5
+ LoadingOverlay,
6
+ SearchInput,
7
+ SearchableList,
8
+ StatusIndicator,
9
+ useSearchKeyboardNavigation
10
+ } from "./chunk-VEWPTZGO.js";
1
11
  import {
2
12
  DEFAULT_PANEL_GEOMETRY,
3
13
  DrawerContainer,
@@ -12,16 +22,6 @@ import {
12
22
  usePanelGeometry,
13
23
  usePanelInteraction
14
24
  } from "./chunk-TXKLROFC.js";
15
- import {
16
- ConfirmDialog,
17
- CopyableErrorAlert,
18
- EmptyState,
19
- LoadingOverlay,
20
- SearchInput,
21
- SearchableList,
22
- StatusIndicator,
23
- useSearchKeyboardNavigation
24
- } from "./chunk-VEWPTZGO.js";
25
25
  import {
26
26
  IconOnlyButton,
27
27
  ModalContainer
@@ -1,136 +0,0 @@
1
- // src/authoring/authoringModel.ts
2
- function getAuthoringDepth(node, nodes) {
3
- let depth = 0;
4
- let parentId = node.parentId;
5
- while (parentId) {
6
- const parent = nodes.find((item) => item.id === parentId);
7
- if (!parent) break;
8
- depth += 1;
9
- parentId = parent.parentId;
10
- }
11
- return depth;
12
- }
13
- function getAuthoringChildren(nodeId, nodes) {
14
- return nodes.filter((node) => node.parentId === nodeId);
15
- }
16
-
17
- // src/authoring/UiAuthoringTree.tsx
18
- import { jsx, jsxs } from "react/jsx-runtime";
19
- function UiAuthoringTree(props) {
20
- return /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [
21
- props.nodes.map((node) => /* @__PURE__ */ jsxs(
22
- "button",
23
- {
24
- type: "button",
25
- onClick: () => props.onSelect(node.id),
26
- className: `flex w-full items-center gap-2 border-b border-black/10 px-2 py-1.5 text-left text-xs ${props.selectedNodeId === node.id ? "bg-black/10" : ""}`,
27
- style: { paddingLeft: 8 + getAuthoringDepth(node, props.nodes) * 14 },
28
- children: [
29
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: node.name }),
30
- /* @__PURE__ */ jsx("span", { className: "ml-auto opacity-50", children: node.kind })
31
- ]
32
- },
33
- node.id
34
- )),
35
- !props.nodes.length && /* @__PURE__ */ jsx("div", { className: "p-4 text-xs opacity-60", children: "No authored nodes." })
36
- ] });
37
- }
38
-
39
- // src/authoring/UiAuthoringInspector.tsx
40
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
41
- function UiAuthoringInspector(props) {
42
- if (!props.node) return /* @__PURE__ */ jsx2("aside", { className: "w-72 border-l border-black/10 p-3 text-xs opacity-60", children: "Select a node." });
43
- const description = String(props.node.props.description || "");
44
- return /* @__PURE__ */ jsxs2("aside", { className: "w-72 border-l border-black/10 p-3", children: [
45
- /* @__PURE__ */ jsx2("div", { className: "mb-3 text-xs font-bold uppercase tracking-wide", children: props.node.kind }),
46
- /* @__PURE__ */ jsxs2("label", { className: "block text-xs", children: [
47
- "Name",
48
- /* @__PURE__ */ jsx2("input", { className: "mt-1 w-full rounded border px-2 py-1.5", value: props.node.name, onChange: (e) => props.onChange({ name: e.target.value }) })
49
- ] }),
50
- /* @__PURE__ */ jsxs2("label", { className: "mt-3 block text-xs", children: [
51
- "Description",
52
- /* @__PURE__ */ jsx2("textarea", { className: "mt-1 min-h-20 w-full rounded border px-2 py-1.5", value: description, onChange: (e) => props.onChange({ props: { ...props.node?.props, description: e.target.value } }) })
53
- ] })
54
- ] });
55
- }
56
-
57
- // src/authoring/UiAuthoringWorkspace.tsx
58
- import React from "react";
59
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
60
- function UiAuthoringWorkspace(props) {
61
- const [selectedNodeId, setSelectedNodeId] = React.useState();
62
- const selectedNode = props.session.nodes.find((node) => node.id === selectedNodeId);
63
- const addNode = (kind, assetRef) => {
64
- const parent = kind === "section" ? props.session.nodes.find((node2) => node2.kind === "page") : kind === "component" ? props.session.nodes.find((node2) => node2.kind === "section") : void 0;
65
- const node = {
66
- id: `authoring-${kind}-${Date.now().toString(36)}`,
67
- kind,
68
- name: kind === "component" ? assetRef?.assetId || "Component" : kind[0].toUpperCase() + kind.slice(1),
69
- componentId: kind === "component" ? assetRef?.assetId : void 0,
70
- assetRef,
71
- parentId: parent?.id,
72
- props: {}
73
- };
74
- props.onChange({ ...props.session, nodes: [...props.session.nodes, node] });
75
- setSelectedNodeId(node.id);
76
- };
77
- const updateSelected = (patch) => {
78
- if (!selectedNode) return;
79
- props.onChange({
80
- ...props.session,
81
- nodes: props.session.nodes.map((node) => node.id === selectedNode.id ? { ...node, ...patch } : node)
82
- });
83
- };
84
- const removeSelected = () => {
85
- if (!selectedNode) return;
86
- props.onChange({
87
- ...props.session,
88
- nodes: props.session.nodes.filter((node) => node.id !== selectedNode.id && node.parentId !== selectedNode.id)
89
- });
90
- setSelectedNodeId(void 0);
91
- };
92
- const contextLabel = {
93
- service: "Service UI",
94
- "general-component": "General Component",
95
- application: "Application UI"
96
- };
97
- return /* @__PURE__ */ jsxs3("section", { className: "flex h-full min-h-0 flex-col overflow-hidden border border-black/10 bg-white", children: [
98
- /* @__PURE__ */ jsxs3("header", { className: "flex shrink-0 items-center gap-2 border-b border-black/10 px-3 py-2", children: [
99
- /* @__PURE__ */ jsxs3("strong", { className: "text-xs", children: [
100
- contextLabel[props.session.context],
101
- " Authoring"
102
- ] }),
103
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => addNode("page"), className: "rounded border px-2 py-1 text-xs", children: "Page" }),
104
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => addNode("section"), className: "rounded border px-2 py-1 text-xs", children: "Section" }),
105
- /* @__PURE__ */ jsxs3(
106
- "select",
107
- {
108
- className: "rounded border px-2 py-1 text-xs",
109
- value: "",
110
- onChange: (e) => {
111
- const asset = props.availableAssets.find((item) => item.assetId === e.target.value);
112
- if (asset) addNode("component", asset);
113
- },
114
- children: [
115
- /* @__PURE__ */ jsx3("option", { value: "", children: "Add component\u2026" }),
116
- props.availableAssets.map((asset) => /* @__PURE__ */ jsx3("option", { value: asset.assetId, children: asset.assetId }, asset.assetId))
117
- ]
118
- }
119
- ),
120
- /* @__PURE__ */ jsx3("button", { type: "button", disabled: !selectedNode, onClick: removeSelected, className: "ml-auto rounded border px-2 py-1 text-xs disabled:opacity-40", children: "Remove" }),
121
- /* @__PURE__ */ jsx3("button", { type: "button", onClick: props.onValidate, className: "rounded border px-2 py-1 text-xs", children: "Validate" })
122
- ] }),
123
- /* @__PURE__ */ jsxs3("div", { className: "flex min-h-0 flex-1", children: [
124
- /* @__PURE__ */ jsx3(UiAuthoringTree, { nodes: props.session.nodes, selectedNodeId, onSelect: setSelectedNodeId }),
125
- /* @__PURE__ */ jsx3(UiAuthoringInspector, { node: selectedNode, onChange: updateSelected })
126
- ] })
127
- ] });
128
- }
129
-
130
- export {
131
- getAuthoringDepth,
132
- getAuthoringChildren,
133
- UiAuthoringTree,
134
- UiAuthoringInspector,
135
- UiAuthoringWorkspace
136
- };