@nubisco/cms-vue 1.0.0 → 1.2.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.
@@ -0,0 +1,2 @@
1
+ .cms-text--editing[data-v-57962fd1]{outline:1px dashed color-mix(in srgb, var(--nb-c-primary,#5856a9) 55%, transparent);outline-offset:3px;cursor:text;border-radius:4px}.cms-text--editing[data-v-57962fd1]:hover{background:color-mix(in srgb, var(--nb-c-primary,#5856a9) 6%, transparent)}.cms-text--editing[data-v-57962fd1]:focus{outline:2px solid var(--nb-c-primary,#5856a9);background:color-mix(in srgb, var(--nb-c-primary,#5856a9) 9%, transparent)}.bf[data-v-22d52899]{border:1px solid var(--nb-c-border,#e7e7f1);background:var(--nb-c-surface,#fff);border-radius:10px;margin:10px;transition:box-shadow .15s,border-color .15s;position:relative}.bf[data-v-22d52899]:hover{box-shadow:0 4px 16px #1a1a2614}.bf--selected[data-v-22d52899]{border-color:var(--nb-c-primary,#5856a9);box-shadow:0 0 0 1px var(--nb-c-primary,#5856a9)}.bf--dim .bf__body[data-v-22d52899]{opacity:.42}.bf__bar[data-v-22d52899]{border-bottom:1px solid var(--nb-c-border,#e7e7f1);cursor:pointer;align-items:center;gap:10px;padding:7px 10px;font-size:12px;display:flex}.bf__grip[data-v-22d52899]{color:var(--nb-c-text-muted,#9797a6);cursor:grab}.bf__type[data-v-22d52899]{color:var(--nb-c-text-muted,#6a6a7b);font-family:ui-monospace,monospace;font-weight:600}.bf--selected .bf__type[data-v-22d52899]{color:var(--nb-c-primary,#5856a9)}.bf__badge[data-v-22d52899]{color:#b9781e;background:#b9781e29;border-radius:5px;padding:2px 7px;font-size:10px;font-weight:700}.bf__spacer[data-v-22d52899]{flex:1}.bf__btn[data-v-22d52899]{border:1px solid var(--nb-c-border,#d7d7e6);background:var(--nb-c-surface,#fff);width:26px;height:26px;color:var(--nb-c-text,#1a1a26);border-radius:6px;line-height:1}.bf__btn[data-v-22d52899]:hover:not(:disabled){background:var(--nb-c-surface-2,#f4f4fa)}.bf__btn[data-v-22d52899]:disabled{opacity:.35;cursor:not-allowed}.bf__body[data-v-22d52899]{border-radius:0 0 10px 10px;overflow:hidden}.cms-zone__missing[data-v-b1bd4d10]{border:1px dashed var(--nb-c-border,#d7d7e6);color:var(--nb-c-text-muted,#6a6a7b);border-radius:8px;padding:12px 16px;font-size:13px}
2
+ /*$vite$:1*/
package/dist/index.d.ts CHANGED
@@ -1,4 +1,363 @@
1
- export * from './contract';
2
- export * from './evaluate';
3
- export * from './graph';
4
- export * from './resolve';
1
+ import { Component } from 'vue';
2
+ import { ComponentOptionsMixin } from 'vue';
3
+ import { ComponentProvideOptions } from 'vue';
4
+ import { DefineComponent } from 'vue';
5
+ import { InjectionKey } from 'vue';
6
+ import { PublicProps } from 'vue';
7
+
8
+ declare type __VLS_Props = {
9
+ block: BlockInstance;
10
+ field: string;
11
+ };
12
+
13
+ declare type __VLS_Props_2 = {
14
+ zone: Zone;
15
+ registry: Record<string, Component>;
16
+ messages: Record<string, string>;
17
+ env: LogicEnv;
18
+ editing?: boolean;
19
+ selectedId?: string | null;
20
+ graphs?: Record<string, LogicGraph>;
21
+ setText?: (block: BlockInstance, field: string, current: FieldValue | undefined, next: string) => void;
22
+ };
23
+
24
+ export declare type BlockCategory = 'content' | 'media' | 'form' | 'layout';
25
+
26
+ /**
27
+ * A block type definition, registered once. The editor catalog, the inspector
28
+ * fields, validation, and serialization all derive from this, mirroring how the
29
+ * NubiscoUI Blueprint system derives everything from a NodeDefinition.
30
+ *
31
+ * Coded blocks map `type` to a real component through a per-framework registry
32
+ * that lives in the renderer package, not in this contract.
33
+ */
34
+ export declare interface BlockDefinition {
35
+ type: string;
36
+ label: string;
37
+ kind: BlockKind;
38
+ category?: BlockCategory;
39
+ icon?: string;
40
+ fields: Record<string, FieldSchema>;
41
+ variations?: BlockVariation[];
42
+ slots?: Record<string, SlotSchema>;
43
+ }
44
+
45
+ /** A block as it appears in a content document. */
46
+ export declare interface BlockInstance {
47
+ /** Stable id: survives reorder, used for deep links and in-place edit targeting. */
48
+ id: string;
49
+ type: string;
50
+ variation?: string;
51
+ fields: Record<string, FieldValue>;
52
+ /** Visibility logic. Absent means always visible. */
53
+ when?: Condition;
54
+ /** Nested blocks for composed blocks with slots. */
55
+ slots?: Record<string, BlockInstance[]>;
56
+ }
57
+
58
+ export declare type BlockKind =
59
+ /** Fields only, assembled in the CMS. No app code required. */
60
+ 'composed'
61
+ /** Backed by an app component (anything with behavior, e.g. a form). */
62
+ | 'coded';
63
+
64
+ export declare interface BlockVariation {
65
+ id: string;
66
+ label: string;
67
+ /** Field values this variation presets (a footer subscribe vs a hero one). */
68
+ presets?: Record<string, FieldValue>;
69
+ }
70
+
71
+ export declare interface BlueprintCard {
72
+ id: string;
73
+ x: number;
74
+ y: number;
75
+ width: number;
76
+ height: number;
77
+ paint: {
78
+ title: string;
79
+ color: string;
80
+ category: string;
81
+ ports: NodePort[];
82
+ };
83
+ }
84
+
85
+ export declare const CMS_CONTEXT: InjectionKey<CmsContext>;
86
+
87
+ /**
88
+ * Render context provided by CmsZone and injected by field primitives. It
89
+ * carries the string table (for { $t } refs), whether edit mode is on, and the
90
+ * write-back hook. In edit mode the primitives decorate the real DOM; off, they
91
+ * render plain text. This is where the in-context editor hangs off the render.
92
+ */
93
+ export declare interface CmsContext {
94
+ messages: Record<string, string>;
95
+ editing: boolean;
96
+ setText: (block: BlockInstance, field: string, current: FieldValue | undefined, next: string) => void;
97
+ }
98
+
99
+ export declare const CmsText: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {
100
+ el: HTMLSpanElement;
101
+ }, any>;
102
+
103
+ export declare const CmsZone: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
104
+ select: (id: string) => any;
105
+ }, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{
106
+ onSelect?: ((id: string) => any) | undefined;
107
+ }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
108
+
109
+ export declare type Condition = {
110
+ kind: 'always';
111
+ } | {
112
+ kind: 'simple';
113
+ /** A registered LogicInputDefinition id. */
114
+ input: string;
115
+ /** Input parameters, e.g. { flag: 'stagewright' } for featureFlag. */
116
+ params?: Record<string, unknown>;
117
+ /** Comparison for enum/number/date inputs. Boolean inputs need none. */
118
+ op?: Op;
119
+ value?: unknown;
120
+ } | {
121
+ kind: 'all';
122
+ of: Condition[];
123
+ } | {
124
+ kind: 'any';
125
+ of: Condition[];
126
+ } | {
127
+ kind: 'not';
128
+ of: Condition;
129
+ }
130
+ /** Reference to a serialized Blueprint graph stored alongside the content. */
131
+ | {
132
+ kind: 'graph';
133
+ graphId: string;
134
+ };
135
+
136
+ /**
137
+ * The initial catalog. Extend by appending a definition (and, for the visual
138
+ * editor, a matching Blueprint NodeDefinition). `campaignSource` is the worked
139
+ * example of a future input: append one entry with resolveAt: 'request'.
140
+ */
141
+ export declare const CORE_LOGIC_INPUTS: LogicInputDefinition[];
142
+
143
+ /**
144
+ * Evaluates a Condition tree to a visibility boolean. `graphs` supplies the
145
+ * logic graphs referenced by { kind: 'graph' } conditions (stored on the page
146
+ * document); a graph condition with no matching graph defaults to visible.
147
+ */
148
+ export declare function evaluate(condition: Condition | undefined, env: LogicEnv, graphs?: Record<string, LogicGraph>): boolean;
149
+
150
+ /** Evaluates the graph to the Visible sink's value, plus each node's output. */
151
+ export declare function evaluateGraph(graph: LogicGraph, env: LogicEnv): GraphResult;
152
+
153
+ /** A field's schema: what a Block declares it accepts. */
154
+ export declare interface FieldSchema {
155
+ type: FieldType;
156
+ /** Editor-facing label. */
157
+ label: string;
158
+ help?: string;
159
+ required?: boolean;
160
+ /**
161
+ * Whether the value is per-locale. Text/richtext default to true and are
162
+ * stored by reference (see TRef) so Verba owns the translations. Media,
163
+ * numbers, and booleans default to false.
164
+ */
165
+ localized?: boolean;
166
+ /** Allowed values for `select`. */
167
+ options?: string[];
168
+ default?: unknown;
169
+ /** Max length for text, or max value for number. */
170
+ max?: number;
171
+ }
172
+
173
+ /**
174
+ * Content contract: the framework-agnostic shape of Nubisco CMS content.
175
+ *
176
+ * This is the crown jewel of the system. The CMS edits documents of this shape,
177
+ * and any renderer (Vue first, others later) is just a function from these types
178
+ * to a rendered page. Nothing here mentions Vue on purpose.
179
+ *
180
+ * Vocabulary: Fields (primitives) compose into Blocks (placeable units), which
181
+ * are ordered inside Zones on a Page.
182
+ */
183
+ export declare type FieldType = 'text' | 'richtext' | 'number' | 'boolean' | 'image' | 'link' | 'color' | 'date' | 'select';
184
+
185
+ export declare type FieldValue = TRef | string | number | boolean | ImageValue | LinkValue;
186
+
187
+ export declare interface GraphConnection {
188
+ fromNode: string;
189
+ fromPort: string;
190
+ toNode: string;
191
+ toPort: string;
192
+ }
193
+
194
+ export declare interface GraphResult {
195
+ visible: boolean;
196
+ nodeOut: Record<string, boolean>;
197
+ }
198
+
199
+ export declare interface ImageValue {
200
+ src: string;
201
+ alt?: TRef;
202
+ /** Intrinsic size, when known, to avoid layout shift. */
203
+ w?: number;
204
+ h?: number;
205
+ }
206
+
207
+ /**
208
+ * Resolves one logic input to a boolean, given the author's params/op/value.
209
+ * The host provides one resolver per registered input id (featureFlag,
210
+ * environment, auth, region, ...). This is where build-time vs request-time
211
+ * resolution actually happens; the contract only declares which is which.
212
+ */
213
+ export declare type InputResolver = (params: Record<string, unknown> | undefined, op: Op | undefined, value: unknown) => boolean;
214
+
215
+ export declare function isImage(v: unknown): v is ImageValue;
216
+
217
+ export declare function isLink(v: unknown): v is LinkValue;
218
+
219
+ export declare function isTRef(v: unknown): v is TRef;
220
+
221
+ export declare interface LinkValue {
222
+ href: string;
223
+ label?: TRef;
224
+ external?: boolean;
225
+ }
226
+
227
+ export declare type LogicEnv = Record<string, InputResolver>;
228
+
229
+ export declare interface LogicGraph {
230
+ nodes: LogicNode[];
231
+ connections: GraphConnection[];
232
+ }
233
+
234
+ export declare interface LogicInputDefinition {
235
+ id: string;
236
+ label: string;
237
+ valueType: LogicValueType;
238
+ /** Parameters the author fills in, e.g. featureFlag needs a `flag`. */
239
+ params?: Record<string, FieldSchema>;
240
+ resolveAt: ResolveAt;
241
+ /** Allowed values for enum inputs (environment, region, locale). */
242
+ enumValues?: string[];
243
+ }
244
+
245
+ /**
246
+ * A logic input type, registered once. The value is resolved by a host-provided
247
+ * resolver keyed by `id`; this definition only declares the shape and where it
248
+ * can run, so the visual editor and the evaluator are fully data-driven.
249
+ */
250
+ export declare type LogicKind = 'featureFlag' | 'environment' | 'auth' | 'region' | 'and' | 'or' | 'not' | 'visible';
251
+
252
+ export declare interface LogicNode {
253
+ id: string;
254
+ kind: LogicKind;
255
+ x: number;
256
+ y: number;
257
+ /** Flag key / environment value / region code, for the input nodes. */
258
+ param?: string;
259
+ }
260
+
261
+ export declare type LogicValueType = 'boolean' | 'enum' | 'number' | 'date';
262
+
263
+ export declare const NODE_SPECS: Record<LogicKind, NodeSpec>;
264
+
265
+ /**
266
+ * App-side logic for the graph form of a Condition (the data shapes live in the
267
+ * contract). The node catalog, Blueprint card mapping, and evaluator are here.
268
+ * Inputs (feature flag, environment, ...) feed gates (AND/OR/NOT) that feed a
269
+ * single Visible sink; graphs are referenced from a condition as
270
+ * { kind: 'graph', graphId }.
271
+ */
272
+ declare interface NodePort {
273
+ id: string;
274
+ label: string;
275
+ type: 'input' | 'output';
276
+ }
277
+
278
+ declare interface NodeSpec {
279
+ label: string;
280
+ color: string;
281
+ category: string;
282
+ ports: NodePort[];
283
+ /** Which parameter this node carries, if any. */
284
+ param?: 'flag' | 'environment' | 'region';
285
+ }
286
+
287
+ /**
288
+ * Logic contract: visibility and variation conditions.
289
+ *
290
+ * A Condition gates whether a Block or Page renders. It is either a simple
291
+ * predicate, a boolean tree, or a reference to a NubiscoUI Blueprint graph for
292
+ * the genuinely compound cases. Most content uses a simple predicate; the graph
293
+ * is the escape hatch, not the default.
294
+ *
295
+ * Logic inputs are a registry. Adding a new input type (e.g. campaign source)
296
+ * later is one LogicInputDefinition plus one Blueprint NodeDefinition. Nothing
297
+ * in the engine or the content schema changes.
298
+ */
299
+ export declare type Op = 'is' | 'not' | 'in' | 'gte' | 'lte' | 'between';
300
+
301
+ export declare interface PageDocument {
302
+ route: string;
303
+ meta?: {
304
+ title?: TRef;
305
+ description?: TRef;
306
+ /** Page renders its own newsletter, so the footer one is suppressed. */
307
+ ownNewsletter?: boolean;
308
+ };
309
+ /** Named zones, usually just `main`. */
310
+ zones: Record<string, Zone>;
311
+ /** Whole-page gate, e.g. a product feature flag. */
312
+ when?: Condition;
313
+ /** Logic graphs referenced by block/page conditions via { kind: 'graph', graphId }. */
314
+ graphs?: Record<string, LogicGraph>;
315
+ }
316
+
317
+ /**
318
+ * Where a logic input can be evaluated. This is load-bearing for delivery:
319
+ * - `build` inputs (flag, environment, locale) let a gated block prerender.
320
+ * - `request` inputs (auth, region) force the block to be resolved at the edge
321
+ * (a Worker) or revealed client-side. It cannot be baked.
322
+ * A block whose condition mixes both is resolved at the most dynamic site.
323
+ */
324
+ export declare type ResolveAt = 'build' | 'request';
325
+
326
+ /** A named region inside a composed block that nests other blocks. */
327
+ export declare interface SlotSchema {
328
+ label: string;
329
+ /** Block types allowed in this slot. Omit to allow any. */
330
+ allow?: string[];
331
+ }
332
+
333
+ /**
334
+ * Resolves a field value to display text. String refs ({ $t }) resolve from the
335
+ * provided message table (Verba / locale JSON), falling back to the key so a
336
+ * missing translation is visible rather than blank.
337
+ */
338
+ export declare function text(value: FieldValue | undefined, messages: Record<string, string>): string;
339
+
340
+ /** Maps the logic graph to Blueprint card geometry + paint. */
341
+ export declare function toCards(graph: LogicGraph): BlueprintCard[];
342
+
343
+ /**
344
+ * A reference to an i18n key. Localized strings are never inlined into content;
345
+ * they resolve from Verba / the site's locale JSON at render time. This keeps
346
+ * Verba authoritative and the content documents small, and it matches how the
347
+ * existing sites already use vue-i18n keys.
348
+ */
349
+ export declare interface TRef {
350
+ $t: string;
351
+ }
352
+
353
+ /** Small helper for block components: resolve a field value to display text. */
354
+ export declare function useField(): {
355
+ t: (value: FieldValue | undefined) => string;
356
+ };
357
+
358
+ /** An ordered list of blocks. Array order is render order and reorder order. */
359
+ export declare interface Zone {
360
+ blocks: BlockInstance[];
361
+ }
362
+
363
+ export { }