@niscorp/nova 0.1.0
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/ACTION_DOCS.md +552 -0
- package/ADAPTER.md +170 -0
- package/DESIGN.md +719 -0
- package/I18N_DOCS.md +224 -0
- package/LAYOUT_DOCS.md +505 -0
- package/LICENSE +202 -0
- package/REACT_DOCS.md +562 -0
- package/README.md +379 -0
- package/SHELL_DOCS.md +615 -0
- package/TERMINAL_DOCS.md +124 -0
- package/dist/adapters/dom/components/index.cjs +473 -0
- package/dist/adapters/dom/components/index.cjs.map +1 -0
- package/dist/adapters/dom/components/index.d.cts +48 -0
- package/dist/adapters/dom/components/index.d.ts +48 -0
- package/dist/adapters/dom/components/index.js +420 -0
- package/dist/adapters/dom/components/index.js.map +1 -0
- package/dist/adapters/dom/index.cjs +171 -0
- package/dist/adapters/dom/index.cjs.map +1 -0
- package/dist/adapters/dom/index.d.cts +29 -0
- package/dist/adapters/dom/index.d.ts +29 -0
- package/dist/adapters/dom/index.js +15 -0
- package/dist/adapters/dom/index.js.map +1 -0
- package/dist/adapters/dom/server.cjs +129 -0
- package/dist/adapters/dom/server.cjs.map +1 -0
- package/dist/adapters/dom/server.d.cts +15 -0
- package/dist/adapters/dom/server.d.ts +15 -0
- package/dist/adapters/dom/server.js +37 -0
- package/dist/adapters/dom/server.js.map +1 -0
- package/dist/adapters/ink/index.d.ts +75 -0
- package/dist/adapters/ink/index.js +472 -0
- package/dist/adapters/ink/index.js.map +1 -0
- package/dist/adapters/react/components/index.cjs +552 -0
- package/dist/adapters/react/components/index.cjs.map +1 -0
- package/dist/adapters/react/components/index.d.cts +30 -0
- package/dist/adapters/react/components/index.d.ts +30 -0
- package/dist/adapters/react/components/index.js +12 -0
- package/dist/adapters/react/components/index.js.map +1 -0
- package/dist/adapters/react/index.cjs +1526 -0
- package/dist/adapters/react/index.cjs.map +1 -0
- package/dist/adapters/react/index.d.cts +149 -0
- package/dist/adapters/react/index.d.ts +149 -0
- package/dist/adapters/react/index.js +12 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/tty/components/index.cjs +255 -0
- package/dist/adapters/tty/components/index.cjs.map +1 -0
- package/dist/adapters/tty/components/index.d.cts +40 -0
- package/dist/adapters/tty/components/index.d.ts +40 -0
- package/dist/adapters/tty/components/index.js +187 -0
- package/dist/adapters/tty/components/index.js.map +1 -0
- package/dist/adapters/tty/index.cjs +76 -0
- package/dist/adapters/tty/index.cjs.map +1 -0
- package/dist/adapters/tty/index.d.cts +47 -0
- package/dist/adapters/tty/index.d.ts +47 -0
- package/dist/adapters/tty/index.js +76 -0
- package/dist/adapters/tty/index.js.map +1 -0
- package/dist/adapters/vue/components/index.cjs +619 -0
- package/dist/adapters/vue/components/index.cjs.map +1 -0
- package/dist/adapters/vue/components/index.d.cts +224 -0
- package/dist/adapters/vue/components/index.d.ts +224 -0
- package/dist/adapters/vue/components/index.js +12 -0
- package/dist/adapters/vue/components/index.js.map +1 -0
- package/dist/adapters/vue/index.cjs +747 -0
- package/dist/adapters/vue/index.cjs.map +1 -0
- package/dist/adapters/vue/index.d.cts +98 -0
- package/dist/adapters/vue/index.d.ts +98 -0
- package/dist/adapters/vue/index.js +127 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/agent/index.cjs +178 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +28 -0
- package/dist/agent/index.d.ts +28 -0
- package/dist/agent/index.js +30 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/chunk-2MNLEL45.js +47 -0
- package/dist/chunk-2MNLEL45.js.map +1 -0
- package/dist/chunk-3HGE3VWK.js +753 -0
- package/dist/chunk-3HGE3VWK.js.map +1 -0
- package/dist/chunk-4ZID7UX5.js +549 -0
- package/dist/chunk-4ZID7UX5.js.map +1 -0
- package/dist/chunk-7B3RDENH.js +1982 -0
- package/dist/chunk-7B3RDENH.js.map +1 -0
- package/dist/chunk-7S5BNPUS.js +54 -0
- package/dist/chunk-7S5BNPUS.js.map +1 -0
- package/dist/chunk-7TS3YVQR.js +114 -0
- package/dist/chunk-7TS3YVQR.js.map +1 -0
- package/dist/chunk-EG2RUXJN.js +266 -0
- package/dist/chunk-EG2RUXJN.js.map +1 -0
- package/dist/chunk-GVBBL36G.js +429 -0
- package/dist/chunk-GVBBL36G.js.map +1 -0
- package/dist/chunk-I5D2R5UA.js +753 -0
- package/dist/chunk-I5D2R5UA.js.map +1 -0
- package/dist/chunk-IGLCWXQ3.js +304 -0
- package/dist/chunk-IGLCWXQ3.js.map +1 -0
- package/dist/chunk-JI7ZRESP.js +64 -0
- package/dist/chunk-JI7ZRESP.js.map +1 -0
- package/dist/chunk-L5223LLX.js +31 -0
- package/dist/chunk-L5223LLX.js.map +1 -0
- package/dist/chunk-LA3BSEMX.js +1905 -0
- package/dist/chunk-LA3BSEMX.js.map +1 -0
- package/dist/chunk-OAMC6R6E.js +121 -0
- package/dist/chunk-OAMC6R6E.js.map +1 -0
- package/dist/chunk-OGD5CCMZ.js +62 -0
- package/dist/chunk-OGD5CCMZ.js.map +1 -0
- package/dist/chunk-PF4OJTYU.js +199 -0
- package/dist/chunk-PF4OJTYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-RBU5PHN4.js +8 -0
- package/dist/chunk-RBU5PHN4.js.map +1 -0
- package/dist/chunk-RQB4PRPV.js +285 -0
- package/dist/chunk-RQB4PRPV.js.map +1 -0
- package/dist/chunk-V32EVEVM.js +464 -0
- package/dist/chunk-V32EVEVM.js.map +1 -0
- package/dist/chunk-ZITHBBF3.js +85 -0
- package/dist/chunk-ZITHBBF3.js.map +1 -0
- package/dist/devtools/index.cjs +1088 -0
- package/dist/devtools/index.cjs.map +1 -0
- package/dist/devtools/index.d.cts +33 -0
- package/dist/devtools/index.d.ts +33 -0
- package/dist/devtools/index.js +399 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/effects-CndX9K7D.d.cts +123 -0
- package/dist/effects-CndX9K7D.d.ts +123 -0
- package/dist/endpoints-CD-6Jl-H.d.ts +36 -0
- package/dist/endpoints-Dem-EdRx.d.cts +36 -0
- package/dist/i18n/index.cjs +299 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +28 -0
- package/dist/i18n/index.d.ts +28 -0
- package/dist/i18n/index.js +180 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index-CNfzSBe2.d.ts +93 -0
- package/dist/index-caZoXSwr.d.cts +93 -0
- package/dist/index.cjs +3723 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +144 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.cjs +635 -0
- package/dist/migrations/index.cjs.map +1 -0
- package/dist/migrations/index.d.cts +97 -0
- package/dist/migrations/index.d.ts +97 -0
- package/dist/migrations/index.js +50 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/palette-CP0wd3bE.d.ts +15 -0
- package/dist/palette-lm0bU9i5.d.cts +15 -0
- package/dist/primitive-props-BH_EJWIe.d.cts +100 -0
- package/dist/primitive-props-BH_EJWIe.d.ts +100 -0
- package/dist/primitive-props-CGoJvmcH.d.cts +100 -0
- package/dist/primitive-props-CGoJvmcH.d.ts +100 -0
- package/dist/reflect/index.cjs +998 -0
- package/dist/reflect/index.cjs.map +1 -0
- package/dist/reflect/index.d.cts +125 -0
- package/dist/reflect/index.d.ts +125 -0
- package/dist/reflect/index.js +13 -0
- package/dist/reflect/index.js.map +1 -0
- package/dist/schemas-DPdeFlCT.d.cts +38 -0
- package/dist/schemas-DPdeFlCT.d.ts +38 -0
- package/dist/schemas-pMyyuXV7.d.cts +47 -0
- package/dist/schemas-pMyyuXV7.d.ts +47 -0
- package/dist/types-Boh9ckdG.d.ts +194 -0
- package/dist/types-Brc7v_pS.d.ts +198 -0
- package/dist/types-ByNSwtUV.d.cts +20 -0
- package/dist/types-DdltMfw7.d.ts +20 -0
- package/dist/types-De0KpxfI.d.cts +198 -0
- package/dist/types-DhHL0twe.d.ts +20 -0
- package/dist/types-Dv6JLmgo.d.cts +194 -0
- package/dist/types-Q80YtOQt.d.cts +20 -0
- package/package.json +237 -0
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
import { StackPropsSchema, BoxPropsSchema, TextPropsSchema, ButtonPropsSchema, InputPropsSchema, PanelPropsSchema, JsonTreePropsSchema, CanvasSlotPropsSchema, ActionSlotPropsSchema } from './chunk-7S5BNPUS.js';
|
|
2
|
+
import { scopeDispatch } from './chunk-ZITHBBF3.js';
|
|
3
|
+
import { renderNodeKey, NOVA_MODEL_PROP, NOVA_REF_PROP } from './chunk-V32EVEVM.js';
|
|
4
|
+
import { defineComponent, h, shallowRef, onBeforeUnmount, inject, provide, createTextVNode, watch, toValue } from 'vue';
|
|
5
|
+
|
|
6
|
+
var px = (value) => `${value ?? 0}px`;
|
|
7
|
+
var ALIGN_MAP = {
|
|
8
|
+
start: "flex-start",
|
|
9
|
+
center: "center",
|
|
10
|
+
end: "flex-end",
|
|
11
|
+
stretch: "stretch"
|
|
12
|
+
};
|
|
13
|
+
var JUSTIFY_MAP = {
|
|
14
|
+
start: "flex-start",
|
|
15
|
+
center: "center",
|
|
16
|
+
end: "flex-end",
|
|
17
|
+
between: "space-between",
|
|
18
|
+
around: "space-around"
|
|
19
|
+
};
|
|
20
|
+
var Stack = Object.assign(
|
|
21
|
+
defineComponent(
|
|
22
|
+
(props, { slots }) => () => h(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
style: {
|
|
26
|
+
display: "flex",
|
|
27
|
+
flexDirection: props.direction ?? "column",
|
|
28
|
+
gap: px(props.gap),
|
|
29
|
+
alignItems: ALIGN_MAP[props.align ?? "stretch"],
|
|
30
|
+
justifyContent: JUSTIFY_MAP[props.justify ?? "start"],
|
|
31
|
+
padding: px(props.padding),
|
|
32
|
+
flexWrap: props.wrap === true ? "wrap" : "nowrap"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
slots.default?.()
|
|
36
|
+
),
|
|
37
|
+
{ name: "NovaStack", props: ["direction", "gap", "align", "justify", "padding", "wrap"], inheritAttrs: false }
|
|
38
|
+
),
|
|
39
|
+
{ meta: { description: "Flex container that arranges children in a row or column.", propsSchema: StackPropsSchema } }
|
|
40
|
+
);
|
|
41
|
+
var Box = Object.assign(
|
|
42
|
+
defineComponent(
|
|
43
|
+
(props, { slots }) => () => h(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
style: {
|
|
47
|
+
padding: px(props.padding),
|
|
48
|
+
background: props.background ?? "transparent",
|
|
49
|
+
border: props.border === true ? "1px solid #e5e7eb" : "none",
|
|
50
|
+
borderRadius: px(props.radius)
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
slots.default?.()
|
|
54
|
+
),
|
|
55
|
+
{ name: "NovaBox", props: ["padding", "background", "border", "radius"], inheritAttrs: false }
|
|
56
|
+
),
|
|
57
|
+
{
|
|
58
|
+
meta: {
|
|
59
|
+
description: "Generic container with basic styling props. Use Stack for layout, Box for visual wrapping.",
|
|
60
|
+
propsSchema: BoxPropsSchema
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
var SIZE_MAP = {
|
|
65
|
+
sm: "12px",
|
|
66
|
+
md: "14px",
|
|
67
|
+
lg: "16px",
|
|
68
|
+
xl: "20px",
|
|
69
|
+
"2xl": "24px"
|
|
70
|
+
};
|
|
71
|
+
var WEIGHT_MAP = {
|
|
72
|
+
normal: 400,
|
|
73
|
+
medium: 500,
|
|
74
|
+
bold: 700
|
|
75
|
+
};
|
|
76
|
+
var Text = Object.assign(
|
|
77
|
+
defineComponent(
|
|
78
|
+
(props, { slots }) => () => h(
|
|
79
|
+
props.as ?? "span",
|
|
80
|
+
{
|
|
81
|
+
style: {
|
|
82
|
+
fontSize: SIZE_MAP[props.size ?? "md"],
|
|
83
|
+
fontWeight: WEIGHT_MAP[props.weight ?? "normal"],
|
|
84
|
+
color: props.color ?? "inherit"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
slots.default?.()
|
|
88
|
+
),
|
|
89
|
+
{ name: "NovaText", props: ["as", "size", "weight", "color"], inheritAttrs: false }
|
|
90
|
+
),
|
|
91
|
+
{ meta: { description: "Text element with semantic typography props.", propsSchema: TextPropsSchema } }
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// src/adapters/vue/context.ts
|
|
95
|
+
var NovaRenderKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:render");
|
|
96
|
+
var NovaShellKey = /* @__PURE__ */ Symbol.for("@niscorp/nova/adapters/vue:shell");
|
|
97
|
+
|
|
98
|
+
// src/adapters/vue/composables/context.ts
|
|
99
|
+
var renderContext = (caller) => {
|
|
100
|
+
const ctx = inject(NovaRenderKey, void 0);
|
|
101
|
+
if (ctx === void 0) throw new Error(`${caller} must be used inside <NovaRenderProvider>`);
|
|
102
|
+
return ctx;
|
|
103
|
+
};
|
|
104
|
+
var useNovaDispatch = () => {
|
|
105
|
+
const ctx = renderContext("useNovaDispatch");
|
|
106
|
+
return (event) => ctx.dispatch(event);
|
|
107
|
+
};
|
|
108
|
+
var useNovaPublish = () => {
|
|
109
|
+
const ctx = renderContext("useNovaPublish");
|
|
110
|
+
return (channel, payload) => ctx.publish(channel, payload);
|
|
111
|
+
};
|
|
112
|
+
var useNovaRegistry = () => renderContext("useNovaRegistry").registry;
|
|
113
|
+
var useSlotWrapper = () => inject(NovaRenderKey, void 0)?.slotWrapper;
|
|
114
|
+
var useShellSource = () => {
|
|
115
|
+
const source = inject(NovaShellKey, void 0);
|
|
116
|
+
if (source === void 0) throw new Error("useShell must be used inside <NovaShellProvider>");
|
|
117
|
+
return source;
|
|
118
|
+
};
|
|
119
|
+
var useShell = () => useShellSource().shell;
|
|
120
|
+
|
|
121
|
+
// src/adapters/vue/components/controls.ts
|
|
122
|
+
var BASE_STYLE = {
|
|
123
|
+
borderRadius: "6px",
|
|
124
|
+
fontSize: "14px",
|
|
125
|
+
fontWeight: 500,
|
|
126
|
+
transition: "background-color 100ms"
|
|
127
|
+
};
|
|
128
|
+
var buttonStyle = (variant, isDisabled, isHovered, isActive) => {
|
|
129
|
+
const cursor = isDisabled ? "not-allowed" : "pointer";
|
|
130
|
+
if (variant === "primary") {
|
|
131
|
+
return {
|
|
132
|
+
...BASE_STYLE,
|
|
133
|
+
padding: "8px 16px",
|
|
134
|
+
border: "none",
|
|
135
|
+
color: "#ffffff",
|
|
136
|
+
cursor,
|
|
137
|
+
background: isDisabled ? "#93c5fd" : isActive ? "#1e40af" : isHovered ? "#1d4ed8" : "#2563eb"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (variant === "secondary") {
|
|
141
|
+
return {
|
|
142
|
+
...BASE_STYLE,
|
|
143
|
+
padding: "8px 16px",
|
|
144
|
+
border: `1px solid ${isDisabled ? "#e5e7eb" : isHovered ? "#9ca3af" : "#d1d5db"}`,
|
|
145
|
+
color: isDisabled ? "#9ca3af" : "#1f2937",
|
|
146
|
+
cursor,
|
|
147
|
+
background: isDisabled ? "#ffffff" : isActive ? "#e5e7eb" : isHovered ? "#f3f4f6" : "#ffffff"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
...BASE_STYLE,
|
|
152
|
+
padding: "8px 12px",
|
|
153
|
+
border: "none",
|
|
154
|
+
color: isDisabled ? "#93c5fd" : "#2563eb",
|
|
155
|
+
cursor,
|
|
156
|
+
background: isDisabled ? "transparent" : isActive ? "#dbeafe" : isHovered ? "#eff6ff" : "transparent"
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
var Button = Object.assign(
|
|
160
|
+
defineComponent(
|
|
161
|
+
(props, { slots }) => {
|
|
162
|
+
const dispatch = useNovaDispatch();
|
|
163
|
+
const isHovered = shallowRef(false);
|
|
164
|
+
const isActive = shallowRef(false);
|
|
165
|
+
const onClick = () => {
|
|
166
|
+
if (props.disabled === true) return;
|
|
167
|
+
if (props.novaRef === void 0) return;
|
|
168
|
+
dispatch({ type: "ui:click", ref: props.novaRef });
|
|
169
|
+
};
|
|
170
|
+
return () => {
|
|
171
|
+
const isDisabled = props.disabled ?? false;
|
|
172
|
+
return h(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
type: "button",
|
|
176
|
+
disabled: isDisabled,
|
|
177
|
+
style: buttonStyle(props.variant ?? "primary", isDisabled, isHovered.value, isActive.value),
|
|
178
|
+
onClick,
|
|
179
|
+
onMouseenter: () => isHovered.value = true,
|
|
180
|
+
onMouseleave: () => {
|
|
181
|
+
isHovered.value = false;
|
|
182
|
+
isActive.value = false;
|
|
183
|
+
},
|
|
184
|
+
onMousedown: () => isActive.value = true,
|
|
185
|
+
onMouseup: () => isActive.value = false
|
|
186
|
+
},
|
|
187
|
+
props.label ?? slots.default?.()
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
{ name: "NovaButton", props: ["label", "variant", "disabled", "novaRef"], inheritAttrs: false }
|
|
192
|
+
),
|
|
193
|
+
{ meta: { description: "Clickable button. Click events fire as `ui:click` with the layout node's ref.", propsSchema: ButtonPropsSchema } }
|
|
194
|
+
);
|
|
195
|
+
var inputStyle = (isDisabled, isFocused, isHovered) => ({
|
|
196
|
+
padding: "8px 12px",
|
|
197
|
+
border: `1px solid ${isDisabled ? "#d1d5db" : isFocused ? "#2563eb" : isHovered ? "#9ca3af" : "#d1d5db"}`,
|
|
198
|
+
borderRadius: "6px",
|
|
199
|
+
fontSize: "14px",
|
|
200
|
+
background: isDisabled ? "#f9fafb" : "#ffffff",
|
|
201
|
+
color: isDisabled ? "#9ca3af" : "inherit",
|
|
202
|
+
cursor: isDisabled ? "not-allowed" : "text",
|
|
203
|
+
minWidth: "240px",
|
|
204
|
+
outline: "none",
|
|
205
|
+
boxShadow: isFocused ? "0 0 0 3px rgba(37, 99, 235, 0.15)" : "none",
|
|
206
|
+
transition: "border-color 150ms, box-shadow 150ms"
|
|
207
|
+
});
|
|
208
|
+
var Input = Object.assign(
|
|
209
|
+
defineComponent(
|
|
210
|
+
(props) => {
|
|
211
|
+
const dispatch = useNovaDispatch();
|
|
212
|
+
const isHovered = shallowRef(false);
|
|
213
|
+
const draft = shallowRef(null);
|
|
214
|
+
let timer;
|
|
215
|
+
const clearPending = () => {
|
|
216
|
+
if (timer !== void 0) {
|
|
217
|
+
clearTimeout(timer);
|
|
218
|
+
timer = void 0;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
onBeforeUnmount(clearPending);
|
|
222
|
+
const fire = (next) => {
|
|
223
|
+
if (props.novaModel === void 0) return;
|
|
224
|
+
dispatch({ type: "ui:model", ref: props.novaModel.ref, payload: next });
|
|
225
|
+
};
|
|
226
|
+
const onInput = (event) => {
|
|
227
|
+
const target = event.target;
|
|
228
|
+
if (!(target instanceof HTMLInputElement)) return;
|
|
229
|
+
const next = target.value;
|
|
230
|
+
draft.value = next;
|
|
231
|
+
const debounceMs = props.debounce ?? 0;
|
|
232
|
+
if (debounceMs > 0) {
|
|
233
|
+
clearPending();
|
|
234
|
+
timer = setTimeout(() => {
|
|
235
|
+
timer = void 0;
|
|
236
|
+
fire(next);
|
|
237
|
+
}, debounceMs);
|
|
238
|
+
} else {
|
|
239
|
+
fire(next);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const onFocus = () => {
|
|
243
|
+
draft.value = props.value ?? "";
|
|
244
|
+
};
|
|
245
|
+
const onBlur = () => {
|
|
246
|
+
const pending = draft.value;
|
|
247
|
+
if (timer !== void 0 && pending !== null) {
|
|
248
|
+
clearPending();
|
|
249
|
+
fire(pending);
|
|
250
|
+
}
|
|
251
|
+
draft.value = null;
|
|
252
|
+
};
|
|
253
|
+
return () => {
|
|
254
|
+
const isDisabled = props.disabled ?? false;
|
|
255
|
+
return h("input", {
|
|
256
|
+
type: props.type ?? "text",
|
|
257
|
+
placeholder: props.placeholder,
|
|
258
|
+
disabled: isDisabled,
|
|
259
|
+
value: draft.value ?? props.value ?? "",
|
|
260
|
+
onInput,
|
|
261
|
+
onFocus,
|
|
262
|
+
onBlur,
|
|
263
|
+
onMouseenter: () => isHovered.value = true,
|
|
264
|
+
onMouseleave: () => isHovered.value = false,
|
|
265
|
+
style: inputStyle(isDisabled, draft.value !== null, isHovered.value)
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: "NovaInput",
|
|
271
|
+
props: ["type", "placeholder", "disabled", "value", "debounce", "novaModel"],
|
|
272
|
+
inheritAttrs: false
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
{ meta: { description: "Text input bound to data via the `model` field on the layout node.", propsSchema: InputPropsSchema } }
|
|
276
|
+
);
|
|
277
|
+
var HEADER_BUTTON_STYLE = {
|
|
278
|
+
border: "none",
|
|
279
|
+
background: "none",
|
|
280
|
+
color: "#6b7280",
|
|
281
|
+
cursor: "pointer",
|
|
282
|
+
fontSize: "13px",
|
|
283
|
+
lineHeight: 1,
|
|
284
|
+
padding: "2px"
|
|
285
|
+
};
|
|
286
|
+
var Panel = Object.assign(
|
|
287
|
+
defineComponent(
|
|
288
|
+
(props, { slots }) => {
|
|
289
|
+
const dispatch = useNovaDispatch();
|
|
290
|
+
const headerButton = (ref, glyph) => h("button", { type: "button", style: HEADER_BUTTON_STYLE, onClick: () => dispatch({ type: "ui:click", ref }) }, glyph);
|
|
291
|
+
return () => h(
|
|
292
|
+
"div",
|
|
293
|
+
{
|
|
294
|
+
style: {
|
|
295
|
+
border: "1px solid #d8dae0",
|
|
296
|
+
borderRadius: "10px",
|
|
297
|
+
background: "#fff",
|
|
298
|
+
boxShadow: "0 1px 3px rgba(0,0,0,.06)",
|
|
299
|
+
padding: "12px"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
[
|
|
303
|
+
props.title === void 0 ? null : h("div", { style: { display: "flex", alignItems: "center", gap: "6px", fontWeight: 600, fontSize: "13px", marginBottom: "8px" } }, [
|
|
304
|
+
props.backRef === void 0 ? null : headerButton(props.backRef, "\u2190"),
|
|
305
|
+
h("span", { style: { flex: 1 } }, props.title),
|
|
306
|
+
props.closeRef === void 0 ? null : headerButton(props.closeRef, "\u2715")
|
|
307
|
+
]),
|
|
308
|
+
slots.default?.()
|
|
309
|
+
]
|
|
310
|
+
);
|
|
311
|
+
},
|
|
312
|
+
{ name: "NovaPanel", props: ["title", "backRef", "closeRef"], inheritAttrs: false }
|
|
313
|
+
),
|
|
314
|
+
{
|
|
315
|
+
meta: {
|
|
316
|
+
description: "A framed, elevated surface with an optional title; `closeRef` adds a header \u2715.",
|
|
317
|
+
propsSchema: PanelPropsSchema
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
);
|
|
321
|
+
var entriesOf = (value) => Array.isArray(value) ? value.map((item, index) => [String(index), item]) : Object.entries(value);
|
|
322
|
+
var jsonNode = (value, name, key) => {
|
|
323
|
+
if (value !== null && typeof value === "object") {
|
|
324
|
+
const entries = entriesOf(value);
|
|
325
|
+
const shape = Array.isArray(value) ? `[${entries.length}]` : `{${entries.length}}`;
|
|
326
|
+
return h("details", { key }, [
|
|
327
|
+
h("summary", { style: { cursor: "pointer", color: "#6b7280" } }, name === void 0 ? shape : `${name} ${shape}`),
|
|
328
|
+
h(
|
|
329
|
+
"div",
|
|
330
|
+
{ style: { paddingLeft: "13px", borderLeft: "1px solid #d8dae0", marginLeft: "3px" } },
|
|
331
|
+
entries.map(([childKey, child]) => jsonNode(child, childKey, childKey))
|
|
332
|
+
)
|
|
333
|
+
]);
|
|
334
|
+
}
|
|
335
|
+
const text = name === void 0 ? JSON.stringify(value) : `${name}: ${JSON.stringify(value)}`;
|
|
336
|
+
return h("div", { key, style: { whiteSpace: "pre-wrap", wordBreak: "break-word" } }, text);
|
|
337
|
+
};
|
|
338
|
+
var JsonTree = Object.assign(
|
|
339
|
+
defineComponent(
|
|
340
|
+
(props) => () => h(
|
|
341
|
+
"div",
|
|
342
|
+
{ style: { fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace", fontSize: "12px", lineHeight: 1.5 } },
|
|
343
|
+
[jsonNode(props.value, props.label)]
|
|
344
|
+
),
|
|
345
|
+
{ name: "NovaJsonTree", props: ["value", "label"], inheritAttrs: false }
|
|
346
|
+
),
|
|
347
|
+
{ meta: { description: "A collapsible view of any JSON value.", propsSchema: JsonTreePropsSchema } }
|
|
348
|
+
);
|
|
349
|
+
var bindShell = (binding) => {
|
|
350
|
+
const source = useShellSource();
|
|
351
|
+
const value = shallowRef(binding.read(source.shell, binding.key()));
|
|
352
|
+
watch(
|
|
353
|
+
() => [source.shell, binding.key()],
|
|
354
|
+
([shell, key], _previous, onCleanup) => {
|
|
355
|
+
const refresh = () => {
|
|
356
|
+
value.value = binding.read(shell, key);
|
|
357
|
+
};
|
|
358
|
+
refresh();
|
|
359
|
+
onCleanup(binding.subscribe(shell, key, refresh));
|
|
360
|
+
},
|
|
361
|
+
{ immediate: true }
|
|
362
|
+
);
|
|
363
|
+
return value;
|
|
364
|
+
};
|
|
365
|
+
var EMPTY = [];
|
|
366
|
+
var subscribeState = (shell, _key, notify) => shell.onStateChange(() => notify());
|
|
367
|
+
var useCanvasRenderTree = (canvasId) => bindShell({
|
|
368
|
+
key: () => toValue(canvasId),
|
|
369
|
+
read: (shell, id) => id === void 0 || id === "" ? EMPTY : shell.getCanvasRenderTree(id),
|
|
370
|
+
subscribe: subscribeState
|
|
371
|
+
});
|
|
372
|
+
var useShellRenderTree = () => bindShell({ key: () => void 0, read: (shell) => shell.getShellRenderTree(), subscribe: subscribeState });
|
|
373
|
+
var useShellState = () => bindShell({ key: () => void 0, read: (shell) => shell.getState(), subscribe: subscribeState });
|
|
374
|
+
var useCanvas = (canvasId) => bindShell({
|
|
375
|
+
key: () => toValue(canvasId),
|
|
376
|
+
read: (shell, id) => shell.getCanvasState(id),
|
|
377
|
+
subscribe: (shell, id, notify) => shell.onCanvasChange(id, () => notify())
|
|
378
|
+
});
|
|
379
|
+
var subscribeRuntime = (listen) => (shell, instanceId, notify) => {
|
|
380
|
+
let current = shell.getRuntime(instanceId);
|
|
381
|
+
let offRuntime = current === void 0 ? void 0 : listen(current, notify);
|
|
382
|
+
const offState = shell.onStateChange(() => {
|
|
383
|
+
const next = shell.getRuntime(instanceId);
|
|
384
|
+
if (next !== current) {
|
|
385
|
+
offRuntime?.();
|
|
386
|
+
current = next;
|
|
387
|
+
offRuntime = current === void 0 ? void 0 : listen(current, notify);
|
|
388
|
+
}
|
|
389
|
+
notify();
|
|
390
|
+
});
|
|
391
|
+
return () => {
|
|
392
|
+
offRuntime?.();
|
|
393
|
+
offState();
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
var onData = subscribeRuntime((runtime, notify) => runtime.onDataChange(() => notify()));
|
|
397
|
+
var onStatus = subscribeRuntime((runtime, notify) => runtime.onStatusChange(() => notify()));
|
|
398
|
+
var useActionData = (instanceId) => bindShell({ key: () => toValue(instanceId), read: (shell, id) => shell.getRuntime(id)?.getData(), subscribe: onData });
|
|
399
|
+
var useActionStatus = (instanceId) => bindShell({ key: () => toValue(instanceId), read: (shell, id) => shell.getRuntime(id)?.instance.status, subscribe: onStatus });
|
|
400
|
+
var useRenderTree = (instanceId) => {
|
|
401
|
+
let cache;
|
|
402
|
+
return bindShell({
|
|
403
|
+
key: () => toValue(instanceId),
|
|
404
|
+
read: (shell, id) => {
|
|
405
|
+
const runtime = shell.getRuntime(id);
|
|
406
|
+
if (runtime === void 0) {
|
|
407
|
+
cache = void 0;
|
|
408
|
+
return EMPTY;
|
|
409
|
+
}
|
|
410
|
+
const data = runtime.getData();
|
|
411
|
+
const phrases = shell.getPhrases();
|
|
412
|
+
if (cache !== void 0 && cache.data === data && cache.phrases === phrases) return cache.tree;
|
|
413
|
+
const tree = runtime.render();
|
|
414
|
+
cache = { data, phrases, tree };
|
|
415
|
+
return tree;
|
|
416
|
+
},
|
|
417
|
+
subscribe: onData
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
var ErrorMarker = defineComponent(
|
|
421
|
+
(props) => () => h("span", { "data-nova-error": props.code, role: "alert" }, `[${props.code}] ${props.message}`),
|
|
422
|
+
{ name: "NovaErrorMarker", props: ["code", "message"] }
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
// src/adapters/vue/types.ts
|
|
426
|
+
var isNovaComponent = (value) => typeof value === "function" || typeof value === "object" && value !== null;
|
|
427
|
+
|
|
428
|
+
// src/adapters/vue/render-node.ts
|
|
429
|
+
var childViews = (children) => children.map((child, i) => h(RenderNodeView, { node: child, key: renderNodeKey(child, i) }));
|
|
430
|
+
var renderNode = (ctx, node) => {
|
|
431
|
+
if (node.type === "text") return createTextVNode(node.value);
|
|
432
|
+
if (node.type === "fragment") return h(RenderTree, { nodes: node.children });
|
|
433
|
+
if (node.type === "error") return h(ErrorMarker, { code: node.code, message: node.message });
|
|
434
|
+
const registered = ctx.registry.get(node.name)?.component;
|
|
435
|
+
const component = isNovaComponent(registered) ? registered : ctx.fallback;
|
|
436
|
+
if (component === void 0) return h(ErrorMarker, { code: "COMPONENT_NOT_FOUND", message: node.name });
|
|
437
|
+
const props = { ...node.props };
|
|
438
|
+
if (node.model !== void 0) props[NOVA_MODEL_PROP] = { ref: node.model.ref, path: node.model.path };
|
|
439
|
+
if (node.ref !== void 0) props[NOVA_REF_PROP] = node.ref;
|
|
440
|
+
const { children } = node;
|
|
441
|
+
if (children.length === 0) return h(component, props);
|
|
442
|
+
return h(component, props, { default: () => childViews(children) });
|
|
443
|
+
};
|
|
444
|
+
var RenderNodeView = defineComponent(
|
|
445
|
+
(props) => {
|
|
446
|
+
const ctx = inject(NovaRenderKey, void 0);
|
|
447
|
+
if (ctx === void 0) throw new Error("RenderNodeView must be used inside <NovaRenderProvider>");
|
|
448
|
+
return () => renderNode(ctx, props.node);
|
|
449
|
+
},
|
|
450
|
+
{ name: "NovaRenderNode", props: ["node"] }
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
// src/adapters/vue/render-tree.ts
|
|
454
|
+
var RenderTree = defineComponent(
|
|
455
|
+
(props) => () => props.nodes.map((node, i) => h(RenderNodeView, { node, key: renderNodeKey(node, i) })),
|
|
456
|
+
{ name: "NovaRenderTree", props: ["nodes"] }
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
// src/adapters/vue/components/slots.ts
|
|
460
|
+
var CanvasSlot = Object.assign(
|
|
461
|
+
defineComponent(
|
|
462
|
+
(props) => {
|
|
463
|
+
const tree = useCanvasRenderTree(() => props.canvasId);
|
|
464
|
+
return () => props.canvasId === void 0 || props.canvasId === "" ? null : h(RenderTree, { nodes: tree.value });
|
|
465
|
+
},
|
|
466
|
+
{ name: "NovaCanvasSlot", props: ["canvasId"], inheritAttrs: false }
|
|
467
|
+
),
|
|
468
|
+
{
|
|
469
|
+
meta: {
|
|
470
|
+
description: "Renders a canvas by id, recursing into its actionLayout.",
|
|
471
|
+
propsSchema: CanvasSlotPropsSchema
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
var InstanceScope = defineComponent(
|
|
476
|
+
(props, { slots }) => {
|
|
477
|
+
const parent = inject(NovaRenderKey, void 0);
|
|
478
|
+
if (parent !== void 0) {
|
|
479
|
+
const scoped = {
|
|
480
|
+
get registry() {
|
|
481
|
+
return parent.registry;
|
|
482
|
+
},
|
|
483
|
+
get dispatch() {
|
|
484
|
+
return scopeDispatch(parent.dispatch, props.instanceId);
|
|
485
|
+
},
|
|
486
|
+
get publish() {
|
|
487
|
+
return parent.publish;
|
|
488
|
+
},
|
|
489
|
+
get slotWrapper() {
|
|
490
|
+
return parent.slotWrapper;
|
|
491
|
+
},
|
|
492
|
+
get fallback() {
|
|
493
|
+
return parent.fallback;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
provide(NovaRenderKey, scoped);
|
|
497
|
+
}
|
|
498
|
+
return () => slots.default?.();
|
|
499
|
+
},
|
|
500
|
+
{ name: "NovaInstanceScope", props: ["instanceId"] }
|
|
501
|
+
);
|
|
502
|
+
var ActionSlot = Object.assign(
|
|
503
|
+
defineComponent(
|
|
504
|
+
(props) => {
|
|
505
|
+
const source = useShellSource();
|
|
506
|
+
const ctx = inject(NovaRenderKey, void 0);
|
|
507
|
+
const tree = useRenderTree(() => props.instanceId ?? "");
|
|
508
|
+
return () => {
|
|
509
|
+
const instanceId = props.instanceId;
|
|
510
|
+
const hasInstance = instanceId !== void 0 && instanceId !== "";
|
|
511
|
+
const content = hasInstance && tree.value.length > 0 ? h(InstanceScope, { instanceId }, { default: () => h(RenderTree, { nodes: tree.value }) }) : null;
|
|
512
|
+
const Wrapper = ctx?.slotWrapper;
|
|
513
|
+
if (Wrapper === void 0) return content;
|
|
514
|
+
const runtime = hasInstance ? source.shell.getRuntime(instanceId) : void 0;
|
|
515
|
+
return h(
|
|
516
|
+
Wrapper,
|
|
517
|
+
{ canvasId: runtime?.instance.canvasId, instanceId: hasInstance ? instanceId : void 0, action: runtime?.definition },
|
|
518
|
+
{ default: () => content }
|
|
519
|
+
);
|
|
520
|
+
};
|
|
521
|
+
},
|
|
522
|
+
{ name: "NovaActionSlot", props: ["instanceId"], inheritAttrs: false }
|
|
523
|
+
),
|
|
524
|
+
{
|
|
525
|
+
meta: {
|
|
526
|
+
description: "Renders an action instance by id. Used inside a canvas actionLayout.",
|
|
527
|
+
propsSchema: ActionSlotPropsSchema
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
// src/adapters/vue/components/index.ts
|
|
533
|
+
var registerNovaVueComponents = (registry) => {
|
|
534
|
+
registry.registerAll({
|
|
535
|
+
Stack,
|
|
536
|
+
Text,
|
|
537
|
+
Input,
|
|
538
|
+
Button,
|
|
539
|
+
Box,
|
|
540
|
+
Panel,
|
|
541
|
+
JsonTree,
|
|
542
|
+
CanvasSlot,
|
|
543
|
+
ActionSlot
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export { ActionSlot, Box, Button, CanvasSlot, ErrorMarker, Input, JsonTree, NovaRenderKey, NovaShellKey, Panel, RenderNodeView, RenderTree, Stack, Text, isNovaComponent, registerNovaVueComponents, useActionData, useActionStatus, useCanvas, useCanvasRenderTree, useNovaDispatch, useNovaPublish, useNovaRegistry, useRenderTree, useShell, useShellRenderTree, useShellState, useSlotWrapper };
|
|
548
|
+
//# sourceMappingURL=chunk-4ZID7UX5.js.map
|
|
549
|
+
//# sourceMappingURL=chunk-4ZID7UX5.js.map
|