@nubisco/cms-vue 1.1.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.
- package/dist/cms-vue.css +1 -1
- package/dist/index.d.ts +18 -0
- package/dist/index.js +162 -41
- package/package.json +2 -1
package/dist/cms-vue.css
CHANGED
|
@@ -1,2 +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)}
|
|
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
2
|
/*$vite$:1*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
1
2
|
import { ComponentOptionsMixin } from 'vue';
|
|
2
3
|
import { ComponentProvideOptions } from 'vue';
|
|
3
4
|
import { DefineComponent } from 'vue';
|
|
@@ -9,6 +10,17 @@ declare type __VLS_Props = {
|
|
|
9
10
|
field: string;
|
|
10
11
|
};
|
|
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
|
+
|
|
12
24
|
export declare type BlockCategory = 'content' | 'media' | 'form' | 'layout';
|
|
13
25
|
|
|
14
26
|
/**
|
|
@@ -88,6 +100,12 @@ export declare const CmsText: DefineComponent<__VLS_Props, {}, {}, {}, {}, Compo
|
|
|
88
100
|
el: HTMLSpanElement;
|
|
89
101
|
}, any>;
|
|
90
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
|
+
|
|
91
109
|
export declare type Condition = {
|
|
92
110
|
kind: 'always';
|
|
93
111
|
} | {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, inject as s, normalizeClass as c, openBlock as l, provide as u, ref as d, renderList as f, renderSlot as p, resolveDynamicComponent as m, toDisplayString as h, unref as g, withCtx as _, withKeys as v, withModifiers as y } from "vue";
|
|
2
2
|
//#region src/contract/logic.ts
|
|
3
|
-
var
|
|
3
|
+
var b = [
|
|
4
4
|
{
|
|
5
5
|
id: "featureFlag",
|
|
6
6
|
label: "Feature flag",
|
|
@@ -67,7 +67,7 @@ var u = [
|
|
|
67
67
|
],
|
|
68
68
|
resolveAt: "request"
|
|
69
69
|
}
|
|
70
|
-
],
|
|
70
|
+
], x = {
|
|
71
71
|
featureFlag: {
|
|
72
72
|
label: "Feature flag",
|
|
73
73
|
color: "#6e6bd6",
|
|
@@ -180,9 +180,9 @@ var u = [
|
|
|
180
180
|
}]
|
|
181
181
|
}
|
|
182
182
|
};
|
|
183
|
-
function
|
|
183
|
+
function S(e) {
|
|
184
184
|
return e.nodes.map((e) => {
|
|
185
|
-
let t =
|
|
185
|
+
let t = x[e.kind], n = e.param ? `${t.label}: ${e.param}` : t.label;
|
|
186
186
|
return {
|
|
187
187
|
id: e.id,
|
|
188
188
|
x: e.x,
|
|
@@ -198,7 +198,7 @@ function f(e) {
|
|
|
198
198
|
};
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function C(e, t) {
|
|
202
202
|
let n = {}, r = (t, n) => e.connections.find((e) => e.toNode === t && e.toPort === n)?.fromNode, i = (e, t) => {
|
|
203
203
|
let n = r(e, t);
|
|
204
204
|
return n ? a(n) : !1;
|
|
@@ -244,89 +244,210 @@ function p(e, t) {
|
|
|
244
244
|
}
|
|
245
245
|
//#endregion
|
|
246
246
|
//#region src/evaluate.ts
|
|
247
|
-
function
|
|
247
|
+
function w(e, t, n) {
|
|
248
248
|
if (!e || e.kind === "always") return !0;
|
|
249
249
|
switch (e.kind) {
|
|
250
250
|
case "simple": {
|
|
251
251
|
let n = t[e.input];
|
|
252
252
|
return n ? n(e.params, e.op, e.value) : !1;
|
|
253
253
|
}
|
|
254
|
-
case "all": return e.of.every((e) =>
|
|
255
|
-
case "any": return e.of.some((e) =>
|
|
256
|
-
case "not": return !
|
|
254
|
+
case "all": return e.of.every((e) => w(e, t, n));
|
|
255
|
+
case "any": return e.of.some((e) => w(e, t, n));
|
|
256
|
+
case "not": return !w(e.of, t, n);
|
|
257
257
|
case "graph": {
|
|
258
258
|
let r = n?.[e.graphId];
|
|
259
|
-
return !r ||
|
|
259
|
+
return !r || C(r, t).visible;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/resolve.ts
|
|
265
|
-
function
|
|
265
|
+
function T(e) {
|
|
266
266
|
return typeof e == "object" && !!e && "$t" in e;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function E(e) {
|
|
269
269
|
return typeof e == "object" && !!e && "src" in e;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function D(e) {
|
|
272
272
|
return typeof e == "object" && !!e && "href" in e;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) :
|
|
274
|
+
function O(e, t) {
|
|
275
|
+
return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : T(e) ? t[e.$t] ?? e.$t : "";
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/context.ts
|
|
279
|
-
var
|
|
279
|
+
var k = Symbol("cms-context");
|
|
280
280
|
//#endregion
|
|
281
281
|
//#region src/useField.ts
|
|
282
|
-
function
|
|
283
|
-
let e =
|
|
282
|
+
function A() {
|
|
283
|
+
let e = s(k, {
|
|
284
284
|
messages: {},
|
|
285
285
|
editing: !1,
|
|
286
286
|
setText: () => {}
|
|
287
287
|
});
|
|
288
|
-
return { t: (t) =>
|
|
288
|
+
return { t: (t) => O(t, e.messages) };
|
|
289
289
|
}
|
|
290
290
|
//#endregion
|
|
291
291
|
//#region src/CmsText.vue?vue&type=script&setup=true&lang.ts
|
|
292
|
-
var
|
|
292
|
+
var j = [
|
|
293
293
|
"data-cms-block",
|
|
294
294
|
"data-cms-field",
|
|
295
295
|
"onKeydown"
|
|
296
|
-
],
|
|
297
|
-
let n = e.__vccOpts || e;
|
|
298
|
-
for (let [e, r] of t) n[e] = r;
|
|
299
|
-
return n;
|
|
300
|
-
})(/* @__PURE__ */ n({
|
|
296
|
+
], M = { key: 1 }, N = /*@__PURE__*/ o({
|
|
301
297
|
__name: "CmsText",
|
|
302
298
|
props: {
|
|
303
299
|
block: {},
|
|
304
300
|
field: {}
|
|
305
301
|
},
|
|
306
|
-
setup(
|
|
307
|
-
let
|
|
302
|
+
setup(e) {
|
|
303
|
+
let n = e, r = s(k, {
|
|
308
304
|
messages: {},
|
|
309
305
|
editing: !1,
|
|
310
306
|
setText: () => {}
|
|
311
|
-
}),
|
|
312
|
-
function
|
|
313
|
-
let e =
|
|
314
|
-
e !==
|
|
307
|
+
}), a = t(() => n.block.fields[n.field]), o = t(() => O(a.value, r.messages)), c = d(null);
|
|
308
|
+
function u() {
|
|
309
|
+
let e = c.value?.innerText.trim() ?? "";
|
|
310
|
+
e !== o.value && r.setText(n.block, n.field, a.value, e), c.value?.blur();
|
|
315
311
|
}
|
|
316
|
-
return (
|
|
312
|
+
return (t, n) => g(r).editing ? (l(), i("span", {
|
|
317
313
|
key: 0,
|
|
318
314
|
ref_key: "el",
|
|
319
|
-
ref:
|
|
315
|
+
ref: c,
|
|
320
316
|
class: "cms-text cms-text--editing",
|
|
321
|
-
"data-cms-block":
|
|
322
|
-
"data-cms-field":
|
|
317
|
+
"data-cms-block": e.block.id,
|
|
318
|
+
"data-cms-field": e.field,
|
|
323
319
|
contenteditable: "plaintext-only",
|
|
324
320
|
role: "textbox",
|
|
325
321
|
tabindex: "0",
|
|
326
|
-
onBlur:
|
|
327
|
-
onKeydown:
|
|
328
|
-
}, o
|
|
322
|
+
onBlur: u,
|
|
323
|
+
onKeydown: v(y(u, ["prevent"]), ["enter"])
|
|
324
|
+
}, h(o.value), 41, j)) : (l(), i("span", M, h(o.value), 1));
|
|
325
|
+
}
|
|
326
|
+
}), P = (e, t) => {
|
|
327
|
+
let n = e.__vccOpts || e;
|
|
328
|
+
for (let [e, r] of t) n[e] = r;
|
|
329
|
+
return n;
|
|
330
|
+
}, F = /*#__PURE__*/ P(N, [["__scopeId", "data-v-57962fd1"]]), I = { class: "bf__type" }, L = {
|
|
331
|
+
key: 0,
|
|
332
|
+
class: "bf__badge"
|
|
333
|
+
}, R = ["disabled"], z = ["disabled"], B = { class: "bf__body" }, V = /*#__PURE__*/ P(/* @__PURE__ */ o({
|
|
334
|
+
__name: "BlockFrame",
|
|
335
|
+
props: {
|
|
336
|
+
label: {},
|
|
337
|
+
hidden: { type: Boolean },
|
|
338
|
+
isFirst: { type: Boolean },
|
|
339
|
+
isLast: { type: Boolean },
|
|
340
|
+
selected: { type: Boolean }
|
|
341
|
+
},
|
|
342
|
+
emits: [
|
|
343
|
+
"up",
|
|
344
|
+
"down",
|
|
345
|
+
"select"
|
|
346
|
+
],
|
|
347
|
+
setup(e) {
|
|
348
|
+
return (t, n) => (l(), i("div", { class: c(["bf", {
|
|
349
|
+
"bf--dim": e.hidden,
|
|
350
|
+
"bf--selected": e.selected
|
|
351
|
+
}]) }, [a("div", {
|
|
352
|
+
class: "bf__bar",
|
|
353
|
+
onClick: n[2] ||= (e) => t.$emit("select")
|
|
354
|
+
}, [
|
|
355
|
+
n[3] ||= a("span", {
|
|
356
|
+
class: "bf__grip",
|
|
357
|
+
"aria-hidden": "true"
|
|
358
|
+
}, "⠿", -1),
|
|
359
|
+
a("span", I, h(e.label), 1),
|
|
360
|
+
e.hidden ? (l(), i("span", L, "hidden by condition")) : r("", !0),
|
|
361
|
+
n[4] ||= a("span", { class: "bf__spacer" }, null, -1),
|
|
362
|
+
a("button", {
|
|
363
|
+
class: "bf__btn",
|
|
364
|
+
type: "button",
|
|
365
|
+
disabled: e.isFirst,
|
|
366
|
+
title: "Move up",
|
|
367
|
+
onClick: n[0] ||= y((e) => t.$emit("up"), ["stop"])
|
|
368
|
+
}, " ↑ ", 8, R),
|
|
369
|
+
a("button", {
|
|
370
|
+
class: "bf__btn",
|
|
371
|
+
type: "button",
|
|
372
|
+
disabled: e.isLast,
|
|
373
|
+
title: "Move down",
|
|
374
|
+
onClick: n[1] ||= y((e) => t.$emit("down"), ["stop"])
|
|
375
|
+
}, " ↓ ", 8, z)
|
|
376
|
+
]), a("div", B, [p(t.$slots, "default", {}, void 0, !0)])], 2));
|
|
377
|
+
}
|
|
378
|
+
}), [["__scopeId", "data-v-22d52899"]]), H = { class: "cms-zone" }, U = {
|
|
379
|
+
key: 1,
|
|
380
|
+
class: "cms-zone__missing"
|
|
381
|
+
}, W = {
|
|
382
|
+
key: 1,
|
|
383
|
+
class: "cms-zone__missing"
|
|
384
|
+
}, G = /*#__PURE__*/ P(/* @__PURE__ */ o({
|
|
385
|
+
__name: "CmsZone",
|
|
386
|
+
props: {
|
|
387
|
+
zone: {},
|
|
388
|
+
registry: {},
|
|
389
|
+
messages: {},
|
|
390
|
+
env: {},
|
|
391
|
+
editing: { type: Boolean },
|
|
392
|
+
selectedId: {},
|
|
393
|
+
graphs: {},
|
|
394
|
+
setText: { type: Function }
|
|
395
|
+
},
|
|
396
|
+
emits: ["select"],
|
|
397
|
+
setup(r, { emit: a }) {
|
|
398
|
+
let o = r, s = a;
|
|
399
|
+
u(k, {
|
|
400
|
+
get messages() {
|
|
401
|
+
return o.messages;
|
|
402
|
+
},
|
|
403
|
+
get editing() {
|
|
404
|
+
return o.editing ?? !1;
|
|
405
|
+
},
|
|
406
|
+
setText: (e, t, n, r) => o.setText?.(e, t, n, r)
|
|
407
|
+
});
|
|
408
|
+
function c(e) {
|
|
409
|
+
return w(e.when, o.env, o.graphs);
|
|
410
|
+
}
|
|
411
|
+
let d = t(() => o.zone.blocks.filter(c));
|
|
412
|
+
function p(e) {
|
|
413
|
+
return e.type + (e.variation ? ` · ${e.variation}` : "");
|
|
414
|
+
}
|
|
415
|
+
function g(e, t) {
|
|
416
|
+
let n = o.zone.blocks;
|
|
417
|
+
if (t < 0 || t >= n.length) return;
|
|
418
|
+
let [r] = n.splice(e, 1);
|
|
419
|
+
n.splice(t, 0, r);
|
|
420
|
+
}
|
|
421
|
+
return (t, a) => (l(), i("div", H, [r.editing ? (l(!0), i(e, { key: 0 }, f(r.zone.blocks, (e, t) => (l(), n(V, {
|
|
422
|
+
key: e.id,
|
|
423
|
+
label: p(e),
|
|
424
|
+
hidden: !c(e),
|
|
425
|
+
"is-first": t === 0,
|
|
426
|
+
"is-last": t === r.zone.blocks.length - 1,
|
|
427
|
+
selected: e.id === r.selectedId,
|
|
428
|
+
onUp: (e) => g(t, t - 1),
|
|
429
|
+
onDown: (e) => g(t, t + 1),
|
|
430
|
+
onSelect: (t) => s("select", e.id)
|
|
431
|
+
}, {
|
|
432
|
+
default: _(() => [r.registry[e.type] ? (l(), n(m(r.registry[e.type]), {
|
|
433
|
+
key: 0,
|
|
434
|
+
block: e
|
|
435
|
+
}, null, 8, ["block"])) : (l(), i("div", U, "Unknown block type: " + h(e.type), 1))]),
|
|
436
|
+
_: 2
|
|
437
|
+
}, 1032, [
|
|
438
|
+
"label",
|
|
439
|
+
"hidden",
|
|
440
|
+
"is-first",
|
|
441
|
+
"is-last",
|
|
442
|
+
"selected",
|
|
443
|
+
"onUp",
|
|
444
|
+
"onDown",
|
|
445
|
+
"onSelect"
|
|
446
|
+
]))), 128)) : (l(!0), i(e, { key: 1 }, f(d.value, (t) => (l(), i(e, { key: t.id }, [r.registry[t.type] ? (l(), n(m(r.registry[t.type]), {
|
|
447
|
+
key: 0,
|
|
448
|
+
block: t
|
|
449
|
+
}, null, 8, ["block"])) : (l(), i("div", W, "Unknown block type: " + h(t.type), 1))], 64))), 128))]));
|
|
329
450
|
}
|
|
330
|
-
}), [["__scopeId", "data-v-
|
|
451
|
+
}), [["__scopeId", "data-v-b1bd4d10"]]);
|
|
331
452
|
//#endregion
|
|
332
|
-
export {
|
|
453
|
+
export { k as CMS_CONTEXT, b as CORE_LOGIC_INPUTS, F as CmsText, G as CmsZone, x as NODE_SPECS, w as evaluate, C as evaluateGraph, E as isImage, D as isLink, T as isTRef, O as text, S as toCards, A as useField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nubisco/cms-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Nubisco CMS content contract, evaluator, and Vue render kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@semantic-release/changelog": "^6.0.3",
|
|
34
34
|
"@semantic-release/git": "^10.0.1",
|
|
35
35
|
"@vitejs/plugin-vue": "^6.0.5",
|
|
36
|
+
"sass-embedded": "^1.102.0",
|
|
36
37
|
"semantic-release": "^25.0.3",
|
|
37
38
|
"typescript": "^5.9.3",
|
|
38
39
|
"vite": "^8.0.2",
|