@sepveneto/dnde 0.3.1 → 0.3.2

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.
@@ -27,7 +27,7 @@ declare const editor: import("pinia").Store<"editor", Pick<{
27
27
  list: import("./store").ConfigPanel[];
28
28
  readonly defaultPane: string;
29
29
  addPanel(panel: import("./store").ConfigPanel): void;
30
- validate(data: any): Promise<boolean | undefined>;
30
+ validate(data: any): Promise<false | undefined>;
31
31
  };
32
32
  };
33
33
  getData: () => Record<string, any>;
@@ -61,7 +61,7 @@ declare const editor: import("pinia").Store<"editor", Pick<{
61
61
  list: import("./store").ConfigPanel[];
62
62
  readonly defaultPane: string;
63
63
  addPanel(panel: import("./store").ConfigPanel): void;
64
- validate(data: any): Promise<boolean | undefined>;
64
+ validate(data: any): Promise<false | undefined>;
65
65
  };
66
66
  };
67
67
  getData: () => Record<string, any>;
@@ -95,7 +95,7 @@ declare const editor: import("pinia").Store<"editor", Pick<{
95
95
  list: import("./store").ConfigPanel[];
96
96
  readonly defaultPane: string;
97
97
  addPanel(panel: import("./store").ConfigPanel): void;
98
- validate(data: any): Promise<boolean | undefined>;
98
+ validate(data: any): Promise<false | undefined>;
99
99
  };
100
100
  };
101
101
  getData: () => Record<string, any>;
@@ -28,7 +28,7 @@ declare const _default: import("vue").DefineComponent<{}, {
28
28
  list: import("@/store").ConfigPanel[];
29
29
  readonly defaultPane: string;
30
30
  addPanel(panel: import("@/store").ConfigPanel): void;
31
- validate(data: any): Promise<boolean | undefined>;
31
+ validate(data: any): Promise<false | undefined>;
32
32
  };
33
33
  };
34
34
  getData: () => Record<string, any>;
@@ -62,7 +62,7 @@ declare const _default: import("vue").DefineComponent<{}, {
62
62
  list: import("@/store").ConfigPanel[];
63
63
  readonly defaultPane: string;
64
64
  addPanel(panel: import("@/store").ConfigPanel): void;
65
- validate(data: any): Promise<boolean | undefined>;
65
+ validate(data: any): Promise<false | undefined>;
66
66
  };
67
67
  };
68
68
  getData: () => Record<string, any>;
@@ -96,7 +96,7 @@ declare const _default: import("vue").DefineComponent<{}, {
96
96
  list: import("@/store").ConfigPanel[];
97
97
  readonly defaultPane: string;
98
98
  addPanel(panel: import("@/store").ConfigPanel): void;
99
- validate(data: any): Promise<boolean | undefined>;
99
+ validate(data: any): Promise<false | undefined>;
100
100
  };
101
101
  };
102
102
  getData: () => Record<string, any>;
package/dist/editor.js CHANGED
@@ -102610,35 +102610,6 @@ var Node$1 = class _Node {
102610
102610
  }
102611
102611
  };
102612
102612
 
102613
- const useApp = defineStore("app", () => {
102614
- const widgets = shallowRef();
102615
- const widgetMap = /* @__PURE__ */ new Map();
102616
- function setWidgets(data) {
102617
- widgets.value = [];
102618
- data.forEach((widget) => {
102619
- if (isGroup(widget)) {
102620
- widgets.value?.push({ name: widget.name, list: widget.list.map((item) => {
102621
- const inst = new Widget(item);
102622
- widgetMap.set(inst.view, inst);
102623
- return inst;
102624
- }) });
102625
- } else {
102626
- const inst = new Widget(widget);
102627
- widgetMap.set(inst.view, inst);
102628
- widgets.value?.push(inst);
102629
- }
102630
- });
102631
- }
102632
- function isGroup(data) {
102633
- return data.type === widgetType.GROUP;
102634
- }
102635
- return {
102636
- setWidgets,
102637
- widgets,
102638
- widgetMap
102639
- };
102640
- });
102641
-
102642
102613
  var browser = {exports: {}};
102643
102614
 
102644
102615
  /**
@@ -103542,7 +103513,10 @@ class ConfigPlugin {
103542
103513
  const valid = await new Schema(_rules).validate(data[pane.name]).catch(() => {
103543
103514
  return false;
103544
103515
  });
103545
- return !!valid;
103516
+ if (valid) {
103517
+ continue;
103518
+ }
103519
+ return false;
103546
103520
  }
103547
103521
  }
103548
103522
  }
@@ -103580,6 +103554,11 @@ const useEditor = defineStore("editor", () => {
103580
103554
  const nodeMap = /* @__PURE__ */ new Map();
103581
103555
  nodeMap.set(rootNode.value.wid, rootNode.value);
103582
103556
  const selected = ref(rootNode.value.wid);
103557
+ watchEffect(() => {
103558
+ nodeMap.delete(rootNode.value.wid);
103559
+ selected.value = rootNode.value.wid;
103560
+ nodeMap.set(rootNode.value.wid, rootNode.value);
103561
+ });
103583
103562
  const plugins = {
103584
103563
  helper: new HelperPlugin({ addNode, delNode }),
103585
103564
  widget: new WidgetPlugin({ addPanel }),
@@ -103690,6 +103669,39 @@ const useEditor = defineStore("editor", () => {
103690
103669
  };
103691
103670
  });
103692
103671
 
103672
+ const useApp = defineStore("app", () => {
103673
+ const editor = useEditor();
103674
+ const widgets = shallowRef();
103675
+ const widgetMap = /* @__PURE__ */ new Map();
103676
+ function setWidgets(data) {
103677
+ widgets.value = [];
103678
+ data.forEach((widget) => {
103679
+ if (isGroup(widget)) {
103680
+ widgets.value?.push({ name: widget.name, list: widget.list.map((item) => {
103681
+ const inst = new Widget(item);
103682
+ widgetMap.set(inst.view, inst);
103683
+ return inst;
103684
+ }) });
103685
+ } else {
103686
+ const inst = new Widget(widget);
103687
+ widgetMap.set(inst.view, inst);
103688
+ widgets.value?.push(inst);
103689
+ }
103690
+ });
103691
+ if (widgetMap.has("page")) {
103692
+ editor.rootNode = new Node$1(widgetMap.get("page"));
103693
+ }
103694
+ }
103695
+ function isGroup(data) {
103696
+ return data.type === widgetType.GROUP;
103697
+ }
103698
+ return {
103699
+ setWidgets,
103700
+ widgets,
103701
+ widgetMap
103702
+ };
103703
+ });
103704
+
103693
103705
  const _sfc_main$f = /* @__PURE__ */ defineComponent({
103694
103706
  __name: "NodeContainer",
103695
103707
  props: {
@@ -104228,15 +104240,18 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
104228
104240
  const refProp = useTemplateRef("propRef");
104229
104241
  const refStyle = useTemplateRef("styleRef");
104230
104242
  const refPageConfig = shallowRef([]);
104231
- const pageActive = ref();
104232
104243
  const active = ref("props");
104233
104244
  watchOnce(() => editor.plugins.config.defaultPane, (name) => {
104234
- pageActive.value = name;
104245
+ active.value = propSchema.value.length > 0 ? "props" : name;
104235
104246
  });
104247
+ const isSelectRoot = computed(() => editor.selectedNode.wid === editor.rootNode.wid);
104236
104248
  watch(() => editor.selected, () => {
104237
104249
  refPageConfig.value = [];
104238
- pageActive.value = editor.plugins.config.defaultPane;
104239
- active.value = "props";
104250
+ if (isSelectRoot.value) {
104251
+ active.value = propSchema.value.length > 0 ? "props" : editor.plugins.config.defaultPane;
104252
+ } else {
104253
+ active.value = "props";
104254
+ }
104240
104255
  nextTick().then(() => {
104241
104256
  refPageConfig.value?.forEach((item) => {
104242
104257
  item?.ref?.clearValidate();
@@ -104247,18 +104262,21 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
104247
104262
  });
104248
104263
  __expose({
104249
104264
  async validate() {
104250
- if (refPageConfig.value) {
104251
- for (const pane of refPageConfig.value) {
104252
- await pane.ref.validate()?.catch(() => {
104253
- pageActive.value = pane.name;
104254
- });
104255
- }
104256
- }
104257
104265
  const propValid = await refProp.value?.validate()?.catch(() => {
104258
104266
  active.value = "props";
104259
104267
  });
104260
104268
  if (!propValid)
104261
104269
  return;
104270
+ if (refPageConfig.value) {
104271
+ for (const pane of refPageConfig.value) {
104272
+ const valid = await pane.ref.validate()?.catch(() => {
104273
+ active.value = pane.name;
104274
+ return false;
104275
+ });
104276
+ if (!valid)
104277
+ return;
104278
+ }
104279
+ }
104262
104280
  await refStyle.value?.validate()?.catch(() => {
104263
104281
  active.value = "style";
104264
104282
  });
@@ -104286,36 +104304,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
104286
104304
  ]),
104287
104305
  _: 1
104288
104306
  }, 8, ["separator-icon"]),
104289
- unref(editor).selected === unref(editor).rootNode.wid ? (openBlock(), createBlock(_component_ElTabs, {
104290
- key: 0,
104291
- modelValue: pageActive.value,
104292
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => pageActive.value = $event)
104293
- }, {
104294
- default: withCtx(() => [
104295
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(editor).plugins.config.list, (pane) => {
104296
- return openBlock(), createBlock(_component_ElTabPane, {
104297
- key: pane.name,
104298
- label: pane.label,
104299
- name: pane.name
104300
- }, {
104301
- default: withCtx(() => [
104302
- createVNode(_sfc_main$7, {
104303
- ref_for: true,
104304
- ref: (ref2) => refPageConfig.value.push({ ref: ref2, name: pane.name }),
104305
- modelValue: unref(editor).selectedNode.data[pane.name],
104306
- "onUpdate:modelValue": ($event) => unref(editor).selectedNode.data[pane.name] = $event,
104307
- list: pane.attributes
104308
- }, null, 8, ["modelValue", "onUpdate:modelValue", "list"])
104309
- ]),
104310
- _: 2
104311
- }, 1032, ["label", "name"]);
104312
- }), 128))
104313
- ]),
104314
- _: 1
104315
- }, 8, ["modelValue"])) : (openBlock(), createBlock(_component_ElTabs, {
104316
- key: 1,
104307
+ createVNode(_component_ElTabs, {
104317
104308
  modelValue: active.value,
104318
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => active.value = $event)
104309
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => active.value = $event)
104319
104310
  }, {
104320
104311
  default: withCtx(() => [
104321
104312
  createVNode(_component_ElTabPane, {
@@ -104326,7 +104317,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
104326
104317
  createVNode(_sfc_main$7, {
104327
104318
  ref: "propRef",
104328
104319
  modelValue: unref(editor).selectedNode.data,
104329
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(editor).selectedNode.data = $event),
104320
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(editor).selectedNode.data = $event),
104330
104321
  list: propSchema.value
104331
104322
  }, null, 8, ["modelValue", "list"])
104332
104323
  ]),
@@ -104341,15 +104332,33 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
104341
104332
  createVNode(_sfc_main$7, {
104342
104333
  ref: "styleRef",
104343
104334
  modelValue: unref(editor).selectedNode.style,
104344
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(editor).selectedNode.style = $event),
104335
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(editor).selectedNode.style = $event),
104345
104336
  list: styleSchema.value
104346
104337
  }, null, 8, ["modelValue", "list"])
104347
104338
  ]),
104348
104339
  _: 1
104349
- })) : createCommentVNode("", true)
104340
+ })) : createCommentVNode("", true),
104341
+ isSelectRoot.value ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(editor).plugins.config.list, (pane) => {
104342
+ return openBlock(), createBlock(_component_ElTabPane, {
104343
+ key: pane.name,
104344
+ label: pane.label,
104345
+ name: pane.name
104346
+ }, {
104347
+ default: withCtx(() => [
104348
+ createVNode(_sfc_main$7, {
104349
+ ref_for: true,
104350
+ ref: (ref2) => refPageConfig.value.push({ ref: ref2, name: pane.name }),
104351
+ modelValue: unref(editor).selectedNode.data[pane.name],
104352
+ "onUpdate:modelValue": ($event) => unref(editor).selectedNode.data[pane.name] = $event,
104353
+ list: pane.attributes
104354
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "list"])
104355
+ ]),
104356
+ _: 2
104357
+ }, 1032, ["label", "name"]);
104358
+ }), 128)) : createCommentVNode("", true)
104350
104359
  ]),
104351
104360
  _: 1
104352
- }, 8, ["modelValue"]))
104361
+ }, 8, ["modelValue"])
104353
104362
  ]);
104354
104363
  };
104355
104364
  }
@@ -104933,7 +104942,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
104933
104942
  editor.selectNode();
104934
104943
  await nextTick();
104935
104944
  refApp.value?.validate();
104936
- return;
104937
104945
  }
104938
104946
  const invalidNode = await editor.rootNode.validate();
104939
104947
  if (invalidNode) {
@@ -3,15 +3,15 @@ import { Node, Widget } from '@sepveneto/dnde-core/class';
3
3
  declare const _default: import("vue").DefineComponent<{}, {
4
4
  app: import("pinia").Store<"app", Pick<{
5
5
  setWidgets: (data: import("@/store").LikeWidget[]) => void;
6
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
6
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
7
7
  widgetMap: Map<string, Widget>;
8
8
  }, "widgets" | "widgetMap">, Pick<{
9
9
  setWidgets: (data: import("@/store").LikeWidget[]) => void;
10
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
10
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
11
11
  widgetMap: Map<string, Widget>;
12
12
  }, never>, Pick<{
13
13
  setWidgets: (data: import("@/store").LikeWidget[]) => void;
14
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
14
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
15
15
  widgetMap: Map<string, Widget>;
16
16
  }, "setWidgets">>;
17
17
  hasGroup: (list?: (Widget | WidgetGroup)[]) => list is WidgetGroup[];
@@ -12,14 +12,14 @@ export type LikeWidget = IWidget | {
12
12
  };
13
13
  export declare const useApp: import("pinia").StoreDefinition<"app", Pick<{
14
14
  setWidgets: (data: LikeWidget[]) => void;
15
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
15
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
16
16
  widgetMap: Map<string, Widget>;
17
17
  }, "widgets" | "widgetMap">, Pick<{
18
18
  setWidgets: (data: LikeWidget[]) => void;
19
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
19
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
20
20
  widgetMap: Map<string, Widget>;
21
21
  }, never>, Pick<{
22
22
  setWidgets: (data: LikeWidget[]) => void;
23
- widgets: import("vue").ShallowRef<(WidgetGroup | Widget)[] | undefined, (WidgetGroup | Widget)[] | undefined>;
23
+ widgets: import("vue").ShallowRef<(Widget | WidgetGroup)[] | undefined, (Widget | WidgetGroup)[] | undefined>;
24
24
  widgetMap: Map<string, Widget>;
25
25
  }, "setWidgets">>;
@@ -27,7 +27,7 @@ declare class ConfigPlugin {
27
27
  constructor(_ctx?: any);
28
28
  get defaultPane(): string;
29
29
  addPanel(panel: ConfigPanel): void;
30
- validate(data: any): Promise<boolean | undefined>;
30
+ validate(data: any): Promise<false | undefined>;
31
31
  }
32
32
  export declare const useEditor: import("pinia").StoreDefinition<"editor", Pick<{
33
33
  rootNode: import("vue").Ref<Raw<Node>, Raw<Node>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sepveneto/dnde",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "GPL",
@@ -22,7 +22,8 @@
22
22
  ".": {
23
23
  "types": "./dist/main.d.ts",
24
24
  "imports": "./dist/editor.js",
25
- "require": "./dist/editor.js"
25
+ "require": "./dist/editor.js",
26
+ "default": "./dist/editor.js"
26
27
  }
27
28
  },
28
29
  "main": "./dist/editor.js",