vlite3 1.5.50 → 1.5.52

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.
Files changed (31) hide show
  1. package/components/CategoryManager/CategoryManager2.vue.js +2 -2
  2. package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
  3. package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
  4. package/components/Form/Form.vue.d.ts +3 -0
  5. package/components/Form/Form.vue.js +1 -1
  6. package/components/Form/Form2.vue.js +292 -276
  7. package/components/Form/composables/useCustomFieldRows.d.ts +3 -0
  8. package/components/Form/composables/useCustomFieldRows.js +109 -58
  9. package/components/Form/composables/useForm.d.ts +4 -1
  10. package/components/Form/composables/useForm.js +249 -187
  11. package/components/Form/index.vue.d.ts +2 -0
  12. package/components/Form/index.vue.js +2 -2
  13. package/components/Form/index2.vue.js +12 -8
  14. package/components/Form/types.d.ts +2 -0
  15. package/components/NavbarCommandPalette.vue.js +1 -1
  16. package/components/RichTextEditor/RichTextEditor.vue.d.ts +58 -0
  17. package/components/RichTextEditor/RichTextEditor.vue.js +309 -180
  18. package/components/RichTextEditor/RichTextLinkPopover.vue.d.ts +3 -8
  19. package/components/RichTextEditor/RichTextLinkPopover3.vue.js +2 -2
  20. package/components/RichTextEditor/RichTextToolbar3.vue.js +2 -2
  21. package/components/RichTextEditor/index.d.ts +1 -1
  22. package/components/RichTextEditor/types.d.ts +22 -0
  23. package/components/Screen/ScreenFilter.vue.js +2 -2
  24. package/components/Screen/components/ScreenToolbar.vue.d.ts +2 -2
  25. package/directives/ScrollReveal/ScrollRevealPager.js +76 -76
  26. package/docs/components/rich-text-editor.md +33 -2
  27. package/docs-manifest.json +3 -3
  28. package/package.json +1 -1
  29. package/style.css +1 -1
  30. /package/components/RichTextEditor/{RichTextLinkPopover2.vue.js → RichTextLinkPopover.vue.js} +0 -0
  31. /package/components/RichTextEditor/{RichTextToolbar2.vue.js → RichTextToolbar.vue.js} +0 -0
@@ -25,6 +25,9 @@ export interface UseCustomFieldRowsGetters {
25
25
  readonly: () => boolean;
26
26
  minRows: () => number;
27
27
  maxRows: () => number;
28
+ /** Optional defaults for new rows, including a consumer-owned stable identity. */
29
+ rowDefaults?: () => Record<string, any>;
30
+ rowKey?: () => string | undefined;
28
31
  }
29
32
  export interface UseCustomFieldRowsReturn {
30
33
  /** Rows with internal `_id` for stable v-for keys */
@@ -1,77 +1,128 @@
1
- import { shallowRef as y, watch as b, computed as f } from "vue";
2
- import { setNestedValue as C } from "../utils/form.utils.js";
3
- const v = () => `row_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, E = (l, c) => {
4
- const o = y([]), p = () => {
5
- const e = {};
6
- for (const a of l.schema()) {
7
- const s = typeof a.value == "function" ? a.value() : a.value;
8
- let t = null;
9
- (a.props?.multiple || a.type === "multiSelect" || a.type === "tags") && (t = []), e[a.name] = s ?? t;
1
+ import { shallowRef as G, getCurrentScope as W, onScopeDispose as H, watch as J, computed as D, toRaw as E } from "vue";
2
+ import { setNestedValue as L } from "../utils/form.utils.js";
3
+ const U = () => `row_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, N = (s, S) => {
4
+ const a = G([]), C = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
5
+ let O = 0;
6
+ const R = (t) => {
7
+ d.delete(t), h.delete(t);
8
+ };
9
+ let V = !1;
10
+ W() && H(() => {
11
+ V = !0, d.clear(), h.clear();
12
+ });
13
+ const A = () => {
14
+ const t = {};
15
+ for (const e of s.schema()) {
16
+ const n = typeof e.value == "function" ? e.value() : e.value;
17
+ let o = null;
18
+ (e.props?.multiple || e.type === "multiSelect" || e.type === "tags") && (o = []), t[e.name] = n ?? o;
10
19
  }
11
- return { ...e, _id: v() };
12
- }, w = (e) => e.map(({ _id: a, ...s }) => s), u = (e) => {
13
- const a = w(e);
14
- c("update:modelValue", a), c("change", a);
20
+ return { ...t, ...s.rowDefaults?.(), _id: U() };
21
+ }, g = (t, e) => Object.keys(t).length === Object.keys(e).length + 1 && Object.keys(e).every((n) => n !== "_id" && Object.prototype.hasOwnProperty.call(t, n) && Object.is(E(t[n]), E(e[n]))), $ = (t) => t.map((e) => {
22
+ const n = C.get(e);
23
+ if (n && g(e, n)) return n;
24
+ const { _id: o, ...u } = e;
25
+ return C.set(e, u), u;
26
+ }), w = (t) => {
27
+ const e = $(t);
28
+ S("update:modelValue", e), S("change", e);
15
29
  };
16
- b(
17
- () => l.modelValue(),
18
- (e) => {
19
- Array.isArray(e) ? o.value = e.map((a, s) => {
20
- const t = o.value[s];
21
- return {
22
- ...a,
23
- _id: t?._id || v()
24
- };
25
- }) : o.value = [];
30
+ J(
31
+ () => s.modelValue(),
32
+ (t, e) => {
33
+ if (Array.isArray(t)) {
34
+ const n = a.value, o = s.rowKey?.(), u = new Map(o ? n.filter((l) => l[o] != null).map((l) => [l[o], l]) : []), r = /* @__PURE__ */ new Set(), p = t.map((l, i) => {
35
+ const b = o && l[o] != null ? u.get(l[o]) : n[i], f = b && !r.has(b._id) ? b : void 0, y = f?._id || U();
36
+ return r.add(y), f && t !== e && g(f, l) ? f : (f && !g(f, l) && R(y), { ...l, _id: y });
37
+ });
38
+ for (const l of n) r.has(l._id) || R(l._id);
39
+ (p.length !== n.length || p.some((l, i) => l !== n[i])) && (a.value = p);
40
+ } else
41
+ d.clear(), h.clear(), a.value = [];
26
42
  },
27
43
  { immediate: !0, deep: !0 }
28
44
  );
29
- const h = f(() => !(l.disabled() || l.readonly() || l.maxRows() && o.value.length >= l.maxRows())), R = f(() => l.disabled() || l.readonly() ? !1 : o.value.length > l.minRows());
45
+ const K = D(() => !(s.disabled() || s.readonly() || s.maxRows() && a.value.length >= s.maxRows())), P = D(() => s.disabled() || s.readonly() ? !1 : a.value.length > s.minRows());
30
46
  return {
31
- rows: o,
32
- canAddRow: h,
33
- canRemoveRow: R,
34
- getFieldValue: (e, a) => o.value[e]?.[a],
47
+ rows: a,
48
+ canAddRow: K,
49
+ canRemoveRow: P,
50
+ getFieldValue: (t, e) => a.value[t]?.[e],
35
51
  addRow: () => {
36
- if (l.disabled() || l.readonly() || l.maxRows() && o.value.length >= l.maxRows()) return;
37
- const e = [...o.value, p()];
38
- o.value = e, u(e);
52
+ if (s.disabled() || s.readonly() || s.maxRows() && a.value.length >= s.maxRows()) return;
53
+ const t = [...a.value, A()];
54
+ a.value = t, w(t);
39
55
  },
40
- removeRow: (e) => {
41
- if (l.disabled() || l.readonly() || o.value.length <= l.minRows()) return;
42
- const a = [...o.value];
43
- a.splice(e, 1), o.value = a, u(a);
56
+ removeRow: (t) => {
57
+ if (s.disabled() || s.readonly() || a.value.length <= s.minRows() || !a.value[t]) return;
58
+ R(a.value[t]._id);
59
+ const e = [...a.value];
60
+ e.splice(t, 1), a.value = e, w(e);
44
61
  },
45
- handleFieldChange: async (e, a, s) => {
46
- const t = [...o.value];
47
- t[e] = {
48
- ...t[e],
49
- [a]: s.value
62
+ handleFieldChange: async (t, e, n) => {
63
+ if (s.disabled() || s.readonly() || !a.value[t]) return;
64
+ const o = a.value[t]._id;
65
+ let u = h.get(o);
66
+ u || h.set(o, u = /* @__PURE__ */ new Map()), u.set(e, ++O), d.get(o)?.delete(e);
67
+ const r = [...a.value];
68
+ r[t] = {
69
+ ...r[t],
70
+ [e]: n.value
50
71
  };
51
- const r = l.schema().find((n) => n.name === a);
52
- if (r && r.updateValues)
72
+ const p = s.schema().find((l) => l.name === e);
73
+ if (p && p.updateValues) {
74
+ let l = !1, i = d.get(o);
75
+ i || d.set(o, i = /* @__PURE__ */ new Map());
76
+ const b = /* @__PURE__ */ Symbol();
77
+ i.set(e, b);
78
+ const f = new Map(u), y = () => !V && d.get(o)?.get(e) === b;
53
79
  try {
54
- const n = t[e], V = l.values() || {}, m = l.name();
55
- let d = { ...V };
56
- m && (d = C(d, m, t));
57
- const i = await r.updateValues({
58
- value: s.value,
59
- values: n,
60
- globalValues: d,
61
- data: s.data,
62
- isUpdate: l.isUpdate()
80
+ const m = r[t], z = s.values() || {}, F = s.name();
81
+ let k = { ...z };
82
+ F && (k = L(k, F, r));
83
+ const v = p.updateValues({
84
+ value: n.value,
85
+ values: m,
86
+ globalValues: k,
87
+ data: n.data,
88
+ isUpdate: s.isUpdate()
63
89
  });
64
- i && typeof i == "object" && (t[e] = { ...t[e], ...i });
65
- } catch (n) {
66
- console.error(`[CustomFields] Error in updateValues for ${a}:`, n);
90
+ if (v && typeof v.then == "function") {
91
+ a.value = r, l = !0, w(r);
92
+ const _ = await v;
93
+ if (!y() || s.disabled() || s.readonly() || !_) return;
94
+ const q = a.value.findIndex((c) => c._id === m._id), j = a.value[q];
95
+ if (!j || !Object.is(j[e], n.value)) return;
96
+ const M = Object.fromEntries(Object.entries(_).filter(
97
+ ([c]) => Object.is(j[c], m[c]) && h.get(o)?.get(c) === f.get(c)
98
+ ));
99
+ if (Object.keys(M).length) {
100
+ for (const B of Object.keys(M)) u.set(B, ++O);
101
+ const c = [...a.value];
102
+ c[q] = { ...j, ...M }, a.value = c, w(c);
103
+ }
104
+ return;
105
+ }
106
+ if (v && typeof v == "object") {
107
+ r[t] = { ...r[t], ...v };
108
+ for (const _ of Object.keys(v)) u.set(_, ++O);
109
+ }
110
+ } catch (m) {
111
+ if (console.error(`[CustomFields] Error in updateValues for ${e}:`, m), l || V) return;
112
+ } finally {
113
+ y() && (i.delete(e), i.size || d.delete(o));
67
114
  }
68
- o.value = t, u(t);
115
+ }
116
+ a.value = r, w(r);
69
117
  },
70
- handleDragUpdate: (e) => {
71
- o.value = e, u(e);
118
+ handleDragUpdate: (t) => {
119
+ if (s.disabled() || s.readonly()) return;
120
+ const e = new Set(t.map((n) => n._id));
121
+ for (const n of a.value) e.has(n._id) || R(n._id);
122
+ a.value = t, w(t);
72
123
  }
73
124
  };
74
125
  };
75
126
  export {
76
- E as useCustomFieldRows
127
+ N as useCustomFieldRows
77
128
  };
@@ -7,6 +7,7 @@ export interface UseFormOptions {
7
7
  folderId?: string;
8
8
  emitFields?: string[];
9
9
  onSubmit?: (payload: IFormSubmitPayload) => void | Promise<void>;
10
+ onAsyncChange?: (values: Record<string, any>) => void;
10
11
  }
11
12
  export interface UseFormReturn {
12
13
  /** Current form values */
@@ -46,7 +47,9 @@ export interface UseFormReturn {
46
47
  /** Flattened schema for iteration */
47
48
  flatSchema: ComputedRef<IForm[]>;
48
49
  /** Re-initialize form with new schema/values (useful for async data loading) */
49
- reinitialize: (newSchema?: IForm[] | IForm[][], newValues?: Record<string, any>) => Promise<void>;
50
+ reinitialize: (newSchema?: IForm[] | IForm[][], newValues?: Record<string, any>, mode?: 'refresh' | 'replace' | 'schema') => Promise<void>;
51
+ /** Apply already-initialized values atomically, without running user change callbacks. */
52
+ replaceValues: (values: Record<string, any>) => void;
50
53
  }
51
54
  /**
52
55
  * Main form composable for managing form state, validation, and submission