vlite3 1.2.12 → 1.2.13

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.
@@ -16,7 +16,7 @@ import "v-datepicker-lite";
16
16
  import "v-datepicker-lite/style.css";
17
17
  import "@jaames/iro";
18
18
  import "@vueuse/core";
19
- /* empty css */
19
+ /* empty css */
20
20
  import me from "../IconPicker.vue.js";
21
21
  /* empty css */
22
22
  /* empty css */
@@ -1,5 +1,5 @@
1
- import o from "./ColorIro.vue2.js";
2
- /* empty css */
1
+ import o from "./ColorIro.vue.js";
2
+ /* empty css */
3
3
  export {
4
4
  o as default
5
5
  };
@@ -6,8 +6,8 @@ import O from "../Input.vue.js";
6
6
  import "../../core/config.js";
7
7
  /* empty css */
8
8
  import y from "../Button.vue.js";
9
- import E from "./ColorIro.vue2.js";
10
- /* empty css */
9
+ import E from "./ColorIro.vue.js";
10
+ /* empty css */
11
11
  import { useEyeDropper as P } from "@vueuse/core";
12
12
  const I = {
13
13
  key: 0,
@@ -4,7 +4,7 @@ import k from "../Icon.vue.js";
4
4
  import { $t as E } from "../../utils/i18n.js";
5
5
  import { useCommandPaletteItems as Y } from "./useCommandPaletteItems.js";
6
6
  import { useCommandPaletteNav as Z } from "./useCommandPaletteNav.js";
7
- import ee from "./CommandPaletteItem.vue.js";
7
+ import ee from "./CommandPaletteItem.vue2.js";
8
8
  const te = { class: "command-palette-content flex flex-col w-full h-full max-h-[70vh]" }, oe = { class: "flex items-center gap-3 px-4 py-3 border-b border-border/80 shrink-0" }, se = ["placeholder"], ne = ["aria-label"], re = {
9
9
  key: 0,
10
10
  class: "flex flex-col items-center justify-center py-14 px-6 text-center select-none",
@@ -1,5 +1,5 @@
1
1
  import t from "./CommandPaletteItem.vue3.js";
2
- /* empty css */
2
+ /* empty css */
3
3
  import o from "../../_virtual/_plugin-vue_export-helper.js";
4
4
  const r = /* @__PURE__ */ o(t, [["__scopeId", "data-v-66b1ae06"]]);
5
5
  export {
@@ -3,7 +3,7 @@ import L from "./Icon.vue.js";
3
3
  import v from "./Modal.vue.js";
4
4
  import N from "./CommandPalette/CommandPaletteContent.vue.js";
5
5
  import { $t as U } from "../utils/i18n.js";
6
- /* empty css */
6
+ /* empty css */
7
7
  const V = { class: "block truncate -text-fs-1.5" }, S = { class: "ml-auto inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-mono font-medium border border-border/80 bg-background text-muted-foreground ml-1" }, A = /* @__PURE__ */ x({
8
8
  __name: "NavbarCommandPalette",
9
9
  props: {
@@ -14,7 +14,7 @@ import "v-datepicker-lite";
14
14
  import "v-datepicker-lite/style.css";
15
15
  import "@jaames/iro";
16
16
  import "@vueuse/core";
17
- /* empty css */
17
+ /* empty css */
18
18
  import "iconify-icon-picker";
19
19
  import "iconify-icon-picker/style.css";
20
20
  /* empty css */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "description": "A Vue 3 UI component library built with Tailwind CSS.",
5
5
  "license": "MIT",
6
- "version": "1.2.12",
6
+ "version": "1.2.13",
7
7
  "type": "module",
8
8
  "main": "index.js",
9
9
  "module": "index.js",
@@ -28,11 +28,6 @@
28
28
  "import": "./index.js",
29
29
  "require": "./index.js"
30
30
  },
31
- "./test": {
32
- "types": "./test/index.d.ts",
33
- "import": "./test/index.js",
34
- "require": "./test/index.js"
35
- },
36
31
  "./style.css": "./style.css"
37
32
  },
38
33
  "dependencies": {
@@ -62,22 +57,16 @@
62
57
  "xlsx": "^0.18.5"
63
58
  },
64
59
  "peerDependencies": {
65
- "@vue/test-utils": "^2.4.0",
66
60
  "vue": "^3.5.24",
67
61
  "vue-router": "4"
68
62
  },
69
- "peerDependenciesMeta": {
70
- "@vue/test-utils": {
71
- "optional": true
72
- }
73
- },
63
+ "peerDependenciesMeta": {},
74
64
  "devDependencies": {
75
65
  "@types/jsbarcode": "^3.11.4",
76
66
  "@types/node": "^25.0.10",
77
67
  "@types/qrcode": "^1.5.6",
78
68
  "@vitejs/plugin-vue": "^6.0.1",
79
69
  "@vitejs/plugin-vue-jsx": "^4.1.1",
80
- "@vue/test-utils": "^2.4.8",
81
70
  "@vue/tsconfig": "^0.8.1",
82
71
  "typescript": "~5.9.3",
83
72
  "vite": "^7.2.4",
package/style.css CHANGED
@@ -550,26 +550,24 @@
550
550
  .dark .sidepanel-body {
551
551
  --color-white: #171717 !important;
552
552
  --color-body: #171717 !important;
553
- --color-mixture-1: #1c1c1c !important;
553
+ --color-mixture-1: #1f1f1f !important;
554
554
  --color-mixture-2: #ffffff !important;
555
- --color-input: color-mix(in oklab, var(--color-mixture-1) 92%, var(--color-mixture-2));
556
555
  }
557
556
 
558
557
  .dark .tooltip-container {
559
558
  --color-body: #171717 !important;
560
559
  --color-white: #171717 !important;
561
- --color-mixture-1: #1c1c1c !important;
560
+ --color-mixture-1: #1f1f1f !important;
562
561
  --color-mixture-2: #ffffff !important;
563
- --tooltip-border: color-mix(in oklab, var(--color-mixture-1) 94%, var(--color-mixture-2)) !important;
564
562
 
565
563
  }
566
564
 
567
565
  .dark .modal-body .bg-card,
568
566
  .dark .sidepanel-body .bg-card,
569
567
  .dark .tooltip-container .bg-card {
570
- --color-body: #121212 !important;
571
- --color-white: #121212 !important;
572
- --color-mixture-1: #171919 !important;
568
+ --color-body: #1D1D1D !important;
569
+ --color-white: #1D1D1D !important;
570
+ --color-mixture-1: #222222 !important;
573
571
  --color-mixture-2: #ffffff !important;
574
572
  background-color: var(--color-body) !important;
575
573
  }
@@ -662,7 +660,7 @@
662
660
  }
663
661
 
664
662
  .dark .text-destructive {
665
- color: rgb(187, 1, 1) !important
663
+ color: #e8201f !important
666
664
  }
667
665
 
668
666
  .text-success {
@@ -670,11 +668,11 @@
670
668
  }
671
669
 
672
670
  .dark .text-success {
673
- color: #049043 !important
671
+ color: #29b411 !important
674
672
  }
675
673
 
676
674
  .dark .text-danger {
677
- color: #ee1f1f !important
675
+ color: #e8201f !important
678
676
  }
679
677
 
680
678
 
@@ -1,120 +0,0 @@
1
- import { IForm } from '../components/Form/types';
2
- import { IVliteScreen } from './types';
3
- import { VueWrapper, DOMWrapper } from '@vue/test-utils';
4
- /**
5
- * Fluent DOM wrapper that understands vlite3 component conventions.
6
- *
7
- * Provides a high-level API for interacting with vlite3 forms, buttons,
8
- * modals, and other components in tests — eliminating the need to write
9
- * complex DOM selectors or manually manage form state.
10
- *
11
- * @example
12
- * ```typescript
13
- * const screen = renderVlite(MyForm, { props: { data: {} } })
14
- * await screen.fillForm(schema, mockData)
15
- * const { emittedPayload } = await screen.submitForm()
16
- * ```
17
- */
18
- export declare class VliteScreen implements IVliteScreen {
19
- readonly wrapper: VueWrapper<any>;
20
- constructor(wrapper: VueWrapper<any>);
21
- /**
22
- * Click a button by its visible text content or data-testid.
23
- * Searches for: `[data-testid]` match, then falls back to text matching.
24
- */
25
- clickButton(textOrTestId: string): Promise<void>;
26
- /**
27
- * Wait for a modal to appear in the DOM.
28
- * Checks for modals by title text or data-testid.
29
- */
30
- waitForModal(titleOrTestId: string): Promise<void>;
31
- /**
32
- * Fill an entire form using schema definitions and a data object.
33
- *
34
- * For each field in the schema:
35
- * 1. Looks up the corresponding value in `data`
36
- * 2. Finds the DOM element using vlite3's `data-testid` system
37
- * 3. Sets the value through both DOM interaction and the Form component's API
38
- *
39
- * @param schema - The vlite3 form schema
40
- * @param data - Key-value pairs of field names → values
41
- */
42
- fillForm(schema: IForm[] | IForm[][], data: Record<string, any>): Promise<void>;
43
- /**
44
- * Fill a single form field by name.
45
- *
46
- * Uses vlite3's data-testid conventions to find elements, then sets
47
- * the value through both DOM events and the Form component's internal API.
48
- */
49
- fillField(name: string, value: any): Promise<void>;
50
- /**
51
- * Toggle a switch field by name.
52
- */
53
- toggleSwitch(name: string): Promise<void>;
54
- /**
55
- * Select a dropdown option by value.
56
- */
57
- selectDropdownOption(name: string, value: string): Promise<void>;
58
- /**
59
- * Submit the form and capture the emitted payload.
60
- *
61
- * Triggers a native form submit, waits for async processing,
62
- * then captures the `onSubmit` event emitted by the vlite3 Form component.
63
- *
64
- * @returns The payload emitted by the form, or null if no emission was captured
65
- */
66
- submitForm(): Promise<{
67
- emittedPayload: Record<string, any> | null;
68
- }>;
69
- /**
70
- * Trigger form submission without capturing the payload.
71
- * Useful when you want to handle the payload via fetch interception instead.
72
- */
73
- triggerSubmit(): Promise<void>;
74
- /**
75
- * Get the current form values from the Form component's internal state.
76
- */
77
- getFormValues(): Record<string, any>;
78
- /**
79
- * Get the current validation errors from the Form component.
80
- */
81
- getFormErrors(): Record<string, string>;
82
- /**
83
- * Find an element by its data-testid attribute.
84
- */
85
- findByTestId(testId: string): DOMWrapper<Element>;
86
- /**
87
- * Find a button by its visible text.
88
- */
89
- findButton(text: string): DOMWrapper<Element> | null;
90
- /**
91
- * Flush all pending promises and optionally wait an additional delay.
92
- */
93
- flushAll(delayMs?: number): Promise<void>;
94
- /**
95
- * Find a field's DOM element using vlite3's data-testid conventions.
96
- * Uses the same resolution chain as the original formTester.ts.
97
- */
98
- private _findFieldElement;
99
- /**
100
- * Check if a DOMWrapper points to a native form element.
101
- */
102
- private _isNativeInput;
103
- /**
104
- * Fill a boolean/checkbox/switch field.
105
- */
106
- private _fillBoolean;
107
- /**
108
- * Fill a native input/textarea element.
109
- */
110
- private _fillNativeInput;
111
- /**
112
- * Fill a native <select> element.
113
- */
114
- private _fillNativeSelect;
115
- /**
116
- * Set a value directly on the Form component's internal state.
117
- * Uses setFieldValue if available, otherwise mutates formValues directly.
118
- */
119
- private _setFormValue;
120
- }
@@ -1,328 +0,0 @@
1
- import { flushPromises as a } from "@vue/test-utils";
2
- import { extractSchemaFields as u } from "./extractSchemaFields.js";
3
- class h {
4
- wrapper;
5
- constructor(t) {
6
- this.wrapper = t;
7
- }
8
- // ── Navigation & Interaction ───────────────────────────────────────────────
9
- /**
10
- * Click a button by its visible text content or data-testid.
11
- * Searches for: `[data-testid]` match, then falls back to text matching.
12
- */
13
- async clickButton(t) {
14
- const i = t.toLowerCase().replace(/\s+/g, "-"), e = this.wrapper.find(`[data-testid="btn-${i}"]`);
15
- if (e.exists()) {
16
- await e.trigger("click"), await this.flushAll(50);
17
- return;
18
- }
19
- const o = this.wrapper.findAll("button").find((n) => n.text().toLowerCase().includes(t.toLowerCase()));
20
- o ? (await o.trigger("click"), await this.flushAll(50)) : console.warn(`[vlite3/test] clickButton: No button found for "${t}"`);
21
- }
22
- /**
23
- * Wait for a modal to appear in the DOM.
24
- * Checks for modals by title text or data-testid.
25
- */
26
- async waitForModal(t) {
27
- await this.flushAll(300), document.querySelectorAll('[role="dialog"], .modal, [data-testid*="modal"]').length === 0 && console.warn(`[vlite3/test] waitForModal: No modal found for "${t}"`);
28
- }
29
- // ── Form Interaction ───────────────────────────────────────────────────────
30
- /**
31
- * Fill an entire form using schema definitions and a data object.
32
- *
33
- * For each field in the schema:
34
- * 1. Looks up the corresponding value in `data`
35
- * 2. Finds the DOM element using vlite3's `data-testid` system
36
- * 3. Sets the value through both DOM interaction and the Form component's API
37
- *
38
- * @param schema - The vlite3 form schema
39
- * @param data - Key-value pairs of field names → values
40
- */
41
- async fillForm(t, i) {
42
- const e = u(t);
43
- for (const s of e) {
44
- const o = s.name, n = d(i, o);
45
- if (n === void 0) continue;
46
- const l = typeof s.type == "string" ? s.type : void 0;
47
- if (l && ["file", "avatarUpload", "fileUploader"].includes(l)) {
48
- console.log(` [Skip] ${o} -> File input`);
49
- continue;
50
- }
51
- if (s.when)
52
- try {
53
- if (!s.when({ values: {} })) continue;
54
- } catch {
55
- }
56
- await this.fillField(o, n);
57
- }
58
- await this.flushAll(200);
59
- }
60
- /**
61
- * Fill a single form field by name.
62
- *
63
- * Uses vlite3's data-testid conventions to find elements, then sets
64
- * the value through both DOM events and the Form component's internal API.
65
- */
66
- async fillField(t, i) {
67
- const e = this._findFieldElement(t);
68
- if (!e) {
69
- console.log(` [Skip] ${t} -> No DOM element found`);
70
- return;
71
- }
72
- const s = this._isNativeInput(e), o = s ? e.attributes("type") : void 0;
73
- if (typeof i == "boolean" || o === "checkbox")
74
- await this._fillBoolean(e, t, i);
75
- else if (s && e.element.tagName === "SELECT")
76
- await this._fillNativeSelect(e, i), console.log(` [Fill] ${t} -> Selected native option: ${i}`);
77
- else if (s)
78
- await this._fillNativeInput(e, t, i);
79
- else {
80
- const n = e.find("input, select, textarea");
81
- if (n.exists())
82
- await this._fillNativeInput(n, t, i);
83
- else {
84
- try {
85
- await e.setValue(i);
86
- } catch {
87
- }
88
- this._setFormValue(t, i), console.log(` [Fill] ${t} -> Set via direct value mutation: ${i}`);
89
- }
90
- }
91
- await a(), await new Promise((n) => setTimeout(n, 20));
92
- }
93
- /**
94
- * Toggle a switch field by name.
95
- */
96
- async toggleSwitch(t) {
97
- const i = this._findFieldElement(t);
98
- if (i) {
99
- const e = i.find('input[type="checkbox"]');
100
- if (e.exists()) {
101
- const s = e.element;
102
- s.checked = !s.checked, s.dispatchEvent(new Event("change", { bubbles: !0 })), s.dispatchEvent(new Event("input", { bubbles: !0 })), await e.trigger("change");
103
- } else
104
- await i.trigger("click");
105
- }
106
- await this.flushAll(20);
107
- }
108
- /**
109
- * Select a dropdown option by value.
110
- */
111
- async selectDropdownOption(t, i) {
112
- const e = this._findFieldElement(t);
113
- if (!e) {
114
- this._setFormValue(t, i);
115
- return;
116
- }
117
- await e.trigger("click"), await new Promise((n) => setTimeout(n, 400));
118
- const s = document.querySelectorAll(
119
- '[data-testid^="dropdown-item-"], [role="option"], .v-dropdown-item, li'
120
- );
121
- let o = !1;
122
- for (const n of s)
123
- if ((n.getAttribute("data-testid")?.replace("dropdown-item-", "") || n.textContent?.trim())?.toLowerCase() === i.toLowerCase()) {
124
- n.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), o = !0;
125
- break;
126
- }
127
- !o && s.length > 0 && s[s.length - 1].dispatchEvent(new MouseEvent("click", { bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: !0 })), this._setFormValue(t, i), await this.flushAll(50);
128
- }
129
- // ── Form Submission ────────────────────────────────────────────────────────
130
- /**
131
- * Submit the form and capture the emitted payload.
132
- *
133
- * Triggers a native form submit, waits for async processing,
134
- * then captures the `onSubmit` event emitted by the vlite3 Form component.
135
- *
136
- * @returns The payload emitted by the form, or null if no emission was captured
137
- */
138
- async submitForm() {
139
- await this.triggerSubmit();
140
- const t = this.wrapper.findComponent({ name: "Form" });
141
- let i = null;
142
- if (t.exists()) {
143
- const e = t.emitted("onSubmit");
144
- if (e && e.length > 0) {
145
- const s = e[e.length - 1];
146
- i = s[0]?.values || s[0] || null;
147
- }
148
- }
149
- return { emittedPayload: i };
150
- }
151
- /**
152
- * Trigger form submission without capturing the payload.
153
- * Useful when you want to handle the payload via fetch interception instead.
154
- */
155
- async triggerSubmit() {
156
- const t = this.wrapper.find("form");
157
- if (t.exists())
158
- await t.trigger("submit");
159
- else {
160
- const i = this.wrapper.findAll('button[type="submit"]');
161
- if (i.length > 0)
162
- await i[i.length - 1].trigger("click");
163
- else {
164
- const s = this.wrapper.findAll("button").find((o) => {
165
- const n = o.text().toLowerCase();
166
- return n.includes("save") || n.includes("submit") || n.includes("create") || n.includes("update") || n.includes("add");
167
- });
168
- s && await s.trigger("click");
169
- }
170
- }
171
- await a(), await new Promise((i) => setTimeout(i, 1200));
172
- }
173
- // ── Form State ─────────────────────────────────────────────────────────────
174
- /**
175
- * Get the current form values from the Form component's internal state.
176
- */
177
- getFormValues() {
178
- const t = this.wrapper.findComponent({ name: "Form" });
179
- return t.exists() ? t.vm.formValues || {} : {};
180
- }
181
- /**
182
- * Get the current validation errors from the Form component.
183
- */
184
- getFormErrors() {
185
- const t = this.wrapper.findComponent({ name: "Form" });
186
- return t.exists() ? t.vm.errors || {} : {};
187
- }
188
- // ── Queries ────────────────────────────────────────────────────────────────
189
- /**
190
- * Find an element by its data-testid attribute.
191
- */
192
- findByTestId(t) {
193
- return this.wrapper.find(`[data-testid="${t}"]`);
194
- }
195
- /**
196
- * Find a button by its visible text.
197
- */
198
- findButton(t) {
199
- return this.wrapper.findAll("button").find((e) => e.text().toLowerCase().includes(t.toLowerCase())) || null;
200
- }
201
- // ── Utilities ──────────────────────────────────────────────────────────────
202
- /**
203
- * Flush all pending promises and optionally wait an additional delay.
204
- */
205
- async flushAll(t = 0) {
206
- await a(), t > 0 && await new Promise((i) => setTimeout(i, t));
207
- }
208
- // ── Private Helpers ────────────────────────────────────────────────────────
209
- /**
210
- * Find a field's DOM element using vlite3's data-testid conventions.
211
- * Uses the same resolution chain as the original formTester.ts.
212
- */
213
- _findFieldElement(t) {
214
- const i = t.replace(/\./g, "-"), e = t.split(".").pop() || t, s = [
215
- "input",
216
- "select",
217
- "textarea",
218
- "switch",
219
- "checkbox",
220
- "number",
221
- "datepicker",
222
- "timepicker",
223
- "daterange",
224
- "multiselect",
225
- "choicebox",
226
- "filepicker",
227
- "avatar",
228
- "colorpicker",
229
- "iconpicker",
230
- "tags"
231
- ], o = [
232
- `[data-testid="${t}"]`,
233
- `[data-testid="${i}"]`,
234
- `[data-testid="${e}"]`,
235
- ...s.flatMap((n) => [
236
- `[data-testid="${n}-${t}"]`,
237
- `[data-testid="${n}-${i}"]`,
238
- `[data-testid="${n}-${e}"]`
239
- ]),
240
- `input[name="${t}"]`,
241
- `textarea[name="${t}"]`,
242
- `select[name="${t}"]`,
243
- `input[name="${e}"]`,
244
- `textarea[name="${e}"]`,
245
- `select[name="${e}"]`,
246
- `[name="${t}"]`,
247
- `[id="${t}"]`,
248
- `[id="${i}"]`
249
- ];
250
- for (const n of o) {
251
- const l = this.wrapper.find(n);
252
- if (l.exists()) return l;
253
- }
254
- return null;
255
- }
256
- /**
257
- * Check if a DOMWrapper points to a native form element.
258
- */
259
- _isNativeInput(t) {
260
- return ["INPUT", "SELECT", "TEXTAREA"].includes(t.element.tagName);
261
- }
262
- /**
263
- * Fill a boolean/checkbox/switch field.
264
- */
265
- async _fillBoolean(t, i, e) {
266
- if (this._isNativeInput(t) && t.element.tagName === "INPUT") {
267
- const o = t.element;
268
- o.checked = e, o.dispatchEvent(new Event("change", { bubbles: !0 })), o.dispatchEvent(new Event("input", { bubbles: !0 })), await t.trigger("change");
269
- } else {
270
- const o = t.find('input[type="checkbox"]');
271
- if (o.exists()) {
272
- const n = o.element;
273
- n.checked = e, n.dispatchEvent(new Event("change", { bubbles: !0 })), n.dispatchEvent(new Event("input", { bubbles: !0 })), await o.trigger("change");
274
- } else
275
- await t.trigger("click");
276
- }
277
- this._setFormValue(i, e), console.log(` [Fill] ${i} -> ${e}`);
278
- }
279
- /**
280
- * Fill a native input/textarea element.
281
- */
282
- async _fillNativeInput(t, i, e) {
283
- const s = t.element;
284
- Object.getOwnPropertyDescriptor(
285
- t.element.tagName === "TEXTAREA" ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype,
286
- "value"
287
- )?.set?.call(s, e), s.dispatchEvent(new Event("input", { bubbles: !0 })), s.dispatchEvent(new Event("change", { bubbles: !0 })), s.dispatchEvent(new FocusEvent("blur", { bubbles: !0 })), await t.setValue(e), this._setFormValue(i, e), console.log(` [Fill] ${i} -> "${e}"`);
288
- }
289
- /**
290
- * Fill a native <select> element.
291
- */
292
- async _fillNativeSelect(t, i) {
293
- await t.setValue(i);
294
- }
295
- /**
296
- * Set a value directly on the Form component's internal state.
297
- * Uses setFieldValue if available, otherwise mutates formValues directly.
298
- */
299
- _setFormValue(t, i) {
300
- const e = this.wrapper.findComponent({ name: "Form" });
301
- if (!e.exists()) {
302
- console.log(` -> Form component not found for ${t}`);
303
- return;
304
- }
305
- const s = e.vm, o = e.getCurrentComponent()?.exposed;
306
- console.log(" -> Exposed internal:", o ? Object.keys(o) : null), o && typeof o.setFieldValue == "function" ? (console.log(` -> Using exposed.setFieldValue for ${t}`), o.setFieldValue(t, i)) : typeof s.setFieldValue == "function" ? (console.log(` -> Using formVm.setFieldValue for ${t}`), s.setFieldValue(t, i)) : o && o.formValues ? (console.log(` -> Using exposed.formValues setDeepValue for ${t}`), c(o.formValues, t, i)) : s.formValues ? (console.log(` -> Using formVm.formValues setDeepValue for ${t}`), c(s.formValues, t, i)) : console.log(` -> FAILED to find exposed setFieldValue or formValues on Form component for ${t}!`);
307
- }
308
- }
309
- function d(r, t) {
310
- if (!t || !r) return;
311
- const i = t.split(".");
312
- let e = r;
313
- for (const s of i) {
314
- if (e == null) return;
315
- e = e[s];
316
- }
317
- return e;
318
- }
319
- function c(r, t, i) {
320
- const e = t.split(".");
321
- let s = r;
322
- for (let o = 0; o < e.length - 1; o++)
323
- (!s[e[o]] || typeof s[e[o]] != "object") && (s[e[o]] = {}), s = s[e[o]];
324
- s[e[e.length - 1]] = i;
325
- }
326
- export {
327
- h as VliteScreen
328
- };
@@ -1,24 +0,0 @@
1
- import { IForm } from '../components/Form/types';
2
- import { DataFactoryOptions } from './types';
3
- /**
4
- * Generates a mock data object from a vlite3 schema definition.
5
- *
6
- * Uses the schema's `type`, `name`, and `options` metadata to produce
7
- * realistic test values that satisfy common database constraints
8
- * (unique emails, valid formats, etc.).
9
- *
10
- * @example
11
- * ```typescript
12
- * import { createDataFactory } from 'vlite3/test'
13
- * import { customerSchema } from '../schema/crm.schema'
14
- *
15
- * // Auto-generate all fields
16
- * const mockData = createDataFactory(customerSchema)
17
- *
18
- * // Override specific fields
19
- * const specificData = createDataFactory(customerSchema, {
20
- * overrides: { status: 'ACTIVE', workspaceName: `ws-${Date.now()}` }
21
- * })
22
- * ```
23
- */
24
- export declare function createDataFactory(schema: IForm[] | IForm[][], options?: DataFactoryOptions): Record<string, any>;
@@ -1,59 +0,0 @@
1
- import { extractSchemaFields as p } from "./extractSchemaFields.js";
2
- function y(e, r) {
3
- const n = r?.uniqueId || Math.random().toString(36).substring(2, 8), t = r?.overrides || {}, o = r?.evaluateConditions ?? !1, s = r?.valuesContext || {}, m = p(e), a = {};
4
- for (const i of m) {
5
- if (o && i.when)
6
- try {
7
- if (!i.when({ values: s })) continue;
8
- } catch {
9
- }
10
- const u = i.name;
11
- if (u in t) {
12
- c(a, u, t[u]);
13
- continue;
14
- }
15
- const l = v(i, n);
16
- l !== void 0 && c(a, u, l);
17
- }
18
- for (const [i, u] of Object.entries(t))
19
- c(a, i, u);
20
- return a;
21
- }
22
- function v(e, r) {
23
- const n = g(e), t = e.name.toLowerCase();
24
- if (!d(n)) {
25
- if (n === "switch" || n === "check") return !0;
26
- if (n === "select" || n === "choiceBox") {
27
- const o = f(e);
28
- return o !== null ? o : `Test String ${r}`;
29
- }
30
- if (n === "multiSelect") {
31
- const o = f(e);
32
- return o !== null ? [o] : [];
33
- }
34
- return n === "email" || t.includes("email") ? `test_${r}@example.com` : n === "password" || t.includes("password") ? "SecurePass123!" : n === "number" ? 42 : n === "time" || t.includes("time") ? "09:00" : n === "date" || t.includes("date") ? "2026-04-26" : n === "tags" ? [`tag_${r}`] : n === "color" ? "#4f46e5" : n === "url" || t.includes("website") ? `https://test-${r}.example.com` : n === "tel" || t === "phone" || t.includes("phonenumber") || t.includes("mobilenumber") ? `+1555${r.substring(0, 4).replace(/\D/g, "0000").substring(0, 4)}` : e.name === "workspaceName" || t === "workspacename" ? `ws-${r}` : e.name === "username" || t === "name" ? `user_${r}` : `Test String ${r}`;
35
- }
36
- }
37
- function g(e) {
38
- if (e.type && typeof e.type == "string")
39
- return e.type;
40
- }
41
- function d(e) {
42
- return e ? ["file", "avatarUpload", "fileUploader"].includes(e) : !1;
43
- }
44
- function f(e) {
45
- if (!e.options || !Array.isArray(e.options) || e.options.length === 0)
46
- return null;
47
- const r = e.options[0];
48
- return typeof r == "object" ? r.value : r;
49
- }
50
- function c(e, r, n) {
51
- const t = r.split(".");
52
- let o = e;
53
- for (let s = 0; s < t.length - 1; s++)
54
- (!o[t[s]] || typeof o[t[s]] != "object") && (o[t[s]] = {}), o = o[t[s]];
55
- o[t[t.length - 1]] = n;
56
- }
57
- export {
58
- y as createDataFactory
59
- };
@@ -1,14 +0,0 @@
1
- import { IForm } from '../components/Form/types';
2
- /**
3
- * Recursively extracts all individual field definitions from a complex
4
- * nested vlite3 schema structure.
5
- *
6
- * Handles:
7
- * - Flat arrays: `IForm[]`
8
- * - Grouped arrays: `IForm[][]`
9
- * - Nested structures: `fields`, `children`, `tabs`, `steps`, `schema`
10
- *
11
- * @param schema - Any level of a vlite3 schema hierarchy
12
- * @returns A flat list of all individual field definitions
13
- */
14
- export declare function extractSchemaFields(schema: any): IForm[];
@@ -1,11 +0,0 @@
1
- function f(t) {
2
- let i = [];
3
- if (Array.isArray(t))
4
- for (const n of t)
5
- i = i.concat(f(n));
6
- else t && typeof t == "object" && (t.name && i.push(t), t.fields && (i = i.concat(f(t.fields))), t.children && (i = i.concat(f(t.children))), t.tabs && (i = i.concat(f(t.tabs))), t.steps && (i = i.concat(f(t.steps))), t.schema && (i = i.concat(f(t.schema))));
7
- return i;
8
- }
9
- export {
10
- f as extractSchemaFields
11
- };
package/test/index.d.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * @vlite3/test — Testing utilities for vlite3 components
3
- *
4
- * This package provides composable, framework-agnostic utilities for testing
5
- * vlite3 forms, components, and pages. It is a companion to the main `vlite3`
6
- * library and should be used as a dev dependency.
7
- *
8
- * Core exports:
9
- * - `createDataFactory` — Schema-driven mock data generation
10
- * - `renderVlite` — Fluent DOM wrapper around @vue/test-utils
11
- * - `extractSchemaFields` — Recursive schema field extractor
12
- *
13
- * @example
14
- * ```typescript
15
- * import { renderVlite, createDataFactory } from 'vlite3/test'
16
- * import { customerSchema } from '../schema/crm.schema'
17
- * import CrmCustomerForm from '../components/CrmCustomerForm.vue'
18
- *
19
- * it('fills and submits a form', async () => {
20
- * const screen = await renderVlite(CrmCustomerForm, {
21
- * props: { data: {} },
22
- * global: { plugins: [apollo] },
23
- * })
24
- *
25
- * const mockData = createDataFactory(customerSchema)
26
- * await screen.fillForm(customerSchema, mockData)
27
- *
28
- * const { emittedPayload } = await screen.submitForm()
29
- * expect(emittedPayload).toBeTruthy()
30
- * })
31
- * ```
32
- *
33
- * @packageDocumentation
34
- */
35
- export { createDataFactory } from './createDataFactory';
36
- export { renderVlite } from './renderVlite';
37
- export { VliteScreen } from './VliteScreen';
38
- export { extractSchemaFields } from './extractSchemaFields';
39
- export type { DataFactoryOptions, RenderVliteOptions, IVliteScreen, } from './types';
package/test/index.js DELETED
@@ -1,10 +0,0 @@
1
- import { createDataFactory as t } from "./createDataFactory.js";
2
- import { renderVlite as a } from "./renderVlite.js";
3
- import { VliteScreen as m } from "./VliteScreen.js";
4
- import { extractSchemaFields as f } from "./extractSchemaFields.js";
5
- export {
6
- m as VliteScreen,
7
- t as createDataFactory,
8
- f as extractSchemaFields,
9
- a as renderVlite
10
- };
@@ -1,30 +0,0 @@
1
- import { Component } from 'vue';
2
- import { VliteScreen } from './VliteScreen';
3
- import { RenderVliteOptions } from './types';
4
- /**
5
- * Mount a vlite3 component and return a fluent `VliteScreen` wrapper.
6
- *
7
- * This is the primary entry point for testing vlite3 components.
8
- * It wraps `@vue/test-utils` `mount()` and returns a `VliteScreen`
9
- * that understands vlite3's component conventions.
10
- *
11
- * **Important**: This function is framework-agnostic. It does NOT inject
12
- * any Apollo client, authentication, or ERP-specific configuration.
13
- * Pass those via the `global.plugins` option.
14
- *
15
- * @example
16
- * ```typescript
17
- * import { renderVlite } from 'vlite3/test'
18
- * import { apollo } from '@/config/apollo.config'
19
- * import MyForm from './MyForm.vue'
20
- *
21
- * const screen = renderVlite(MyForm, {
22
- * props: { data: {} },
23
- * global: { plugins: [apollo] },
24
- * })
25
- *
26
- * await screen.fillForm(schema, mockData)
27
- * await screen.triggerSubmit()
28
- * ```
29
- */
30
- export declare function renderVlite(component: Component, options?: RenderVliteOptions): Promise<VliteScreen>;
@@ -1,12 +0,0 @@
1
- import { mount as a, flushPromises as m } from "@vue/test-utils";
2
- import { VliteScreen as i } from "./VliteScreen.js";
3
- async function p(o, e) {
4
- const r = e?.mountDelay ?? 250, t = a(o, {
5
- props: e?.props,
6
- global: e?.global
7
- });
8
- return await m(), r > 0 && await new Promise((n) => setTimeout(n, r)), new i(t);
9
- }
10
- export {
11
- p as renderVlite
12
- };
package/test/types.d.ts DELETED
@@ -1,39 +0,0 @@
1
- import { IForm } from '../components/Form/types';
2
- import { VueWrapper, DOMWrapper } from '@vue/test-utils';
3
- export interface DataFactoryOptions {
4
- /** Override specific fields — these take priority over auto-generated values */
5
- overrides?: Record<string, any>;
6
- /** Unique suffix for generated strings (auto-generated if not provided) */
7
- uniqueId?: string;
8
- /** Whether to evaluate `when` conditions (default: false — generate all fields) */
9
- evaluateConditions?: boolean;
10
- /** Form values context for evaluating `when` conditions */
11
- valuesContext?: Record<string, any>;
12
- }
13
- export interface RenderVliteOptions {
14
- /** Props to pass to the component */
15
- props?: Record<string, any>;
16
- /** Global mount options (plugins, mocks, stubs, etc.) */
17
- global?: Record<string, any>;
18
- /** Delay in ms after mount before returning (default: 250) */
19
- mountDelay?: number;
20
- }
21
- export interface IVliteScreen {
22
- /** The underlying @vue/test-utils wrapper */
23
- readonly wrapper: VueWrapper<any>;
24
- clickButton(textOrTestId: string): Promise<void>;
25
- waitForModal(titleOrTestId: string): Promise<void>;
26
- fillForm(schema: IForm[] | IForm[][], data: Record<string, any>): Promise<void>;
27
- fillField(name: string, value: any): Promise<void>;
28
- toggleSwitch(name: string): Promise<void>;
29
- selectDropdownOption(name: string, value: string): Promise<void>;
30
- submitForm(): Promise<{
31
- emittedPayload: Record<string, any> | null;
32
- }>;
33
- triggerSubmit(): Promise<void>;
34
- getFormValues(): Record<string, any>;
35
- getFormErrors(): Record<string, string>;
36
- findByTestId(testId: string): DOMWrapper<Element>;
37
- findButton(text: string): DOMWrapper<Element> | null;
38
- flushAll(delayMs?: number): Promise<void>;
39
- }