vue-wswg-editor 0.0.11 → 0.0.12

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/dist/style.css +1 -1
  2. package/dist/types/components/AddBlockItem/AddBlockItem.vue.d.ts +6 -0
  3. package/dist/types/components/BlockBrowser/BlockBrowser.vue.d.ts +2 -0
  4. package/dist/types/components/BlockComponent/BlockComponent.vue.d.ts +15 -0
  5. package/dist/types/components/BlockEditorFieldNode/BlockEditorFieldNode.vue.d.ts +15 -0
  6. package/dist/types/components/BlockEditorFields/BlockEditorFields.vue.d.ts +16 -0
  7. package/dist/types/components/BlockImageFieldNode/BlockImageNode.vue.d.ts +19 -0
  8. package/dist/types/components/BlockMarginFieldNode/BlockMarginNode.vue.d.ts +23 -0
  9. package/dist/types/components/BlockRepeaterFieldNode/BlockRepeaterNode.vue.d.ts +15 -0
  10. package/dist/types/components/BrowserNavigation/BrowserNavigation.vue.d.ts +5 -0
  11. package/dist/types/components/EmptyState/EmptyState.vue.d.ts +15 -0
  12. package/dist/types/components/PageBlockList/PageBlockList.vue.d.ts +19 -0
  13. package/dist/types/components/PageBuilderSidebar/PageBuilderSidebar.vue.d.ts +35 -0
  14. package/dist/types/components/PageBuilderToolbar/PageBuilderToolbar.vue.d.ts +28 -0
  15. package/dist/types/components/PageRenderer/PageRenderer.vue.d.ts +13 -0
  16. package/dist/types/components/PageRenderer/blockModules.d.ts +3 -0
  17. package/dist/types/components/PageRenderer/layoutModules.d.ts +3 -0
  18. package/dist/types/components/PageSettings/PageSettings.vue.d.ts +17 -0
  19. package/dist/types/components/ResizeHandle/ResizeHandle.vue.d.ts +6 -0
  20. package/dist/types/components/WswgJsonEditor/WswgJsonEditor.test.d.ts +1 -0
  21. package/dist/types/components/WswgJsonEditor/WswgJsonEditor.vue.d.ts +36 -0
  22. package/dist/types/index.d.ts +7 -0
  23. package/dist/types/util/fieldConfig.d.ts +87 -0
  24. package/dist/types/util/helpers.d.ts +28 -0
  25. package/dist/types/util/registry.d.ts +25 -0
  26. package/dist/types/util/validation.d.ts +26 -0
  27. package/dist/types/vite-plugin.d.ts +9 -0
  28. package/dist/vite-plugin.js +76 -0
  29. package/dist/vue-wswg-editor.es.js +727 -705
  30. package/package.json +1 -1
  31. package/src/util/validation.ts +2 -2
@@ -0,0 +1,26 @@
1
+ import type { EditorFieldConfig, ValidatorFunction } from "./fieldConfig";
2
+ export declare function validateField(value: any, fieldConfig: EditorFieldConfig): true | Promise<string | boolean>;
3
+ export interface ValidationResult {
4
+ title: string;
5
+ isValid: boolean;
6
+ errors: Record<string, string | boolean>;
7
+ }
8
+ /**
9
+ * Validate all fields in the value
10
+ * @param value - The value to validate
11
+ * @param blocksKey - The key of the blocks in the value
12
+ * @param settingsKey - The key of the settings in the value
13
+ * @returns A record of validation results
14
+ */
15
+ export declare function validateAllFields(value: any, blocksKey?: string, settingsKey?: string): Promise<Record<string, ValidationResult>>;
16
+ /**
17
+ * Creates a generic validator function based on field config properties
18
+ * Handles: required, minLength, maxLength, min, max, minItems, maxItems
19
+ * Returns a ValidatorFunction that can be combined with custom validators
20
+ */
21
+ export declare function createGenericValidator(fieldConfig: EditorFieldConfig): ValidatorFunction | null;
22
+ /**
23
+ * Combines a generic validator (built-in validations) with a custom validator
24
+ * Runs built-in validations first, then custom validator if provided
25
+ */
26
+ export declare function combineValidators(genericValidator: ValidatorFunction | null, customValidator?: ValidatorFunction): ValidatorFunction | undefined;
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "vite";
2
+ export interface VueWswgEditorPluginOptions {
3
+ /**
4
+ * Root directory in the host project.
5
+ * Example: "@/features/homepage"
6
+ */
7
+ rootDir: string;
8
+ }
9
+ export declare function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin;
@@ -0,0 +1,76 @@
1
+ function a(u) {
2
+ const t = {
3
+ blocks: "\0vue-wswg-editor:blocks",
4
+ fields: "\0vue-wswg-editor:fields",
5
+ layouts: "\0vue-wswg-editor:layouts",
6
+ thumbnails: "\0vue-wswg-editor:thumbnails"
7
+ };
8
+ return {
9
+ name: "vue-wswg-editor-glob-plugin",
10
+ enforce: "pre",
11
+ // Run before other plugins to ensure import.meta.glob is processed correctly
12
+ config(e) {
13
+ var l;
14
+ const s = e.optimizeDeps || {}, o = s.exclude;
15
+ let r;
16
+ Array.isArray(o) ? r = [...o] : typeof o == "string" ? r = [o] : r = [];
17
+ const n = [
18
+ "vue-wswg-editor",
19
+ "vue-wswg-editor:layouts",
20
+ "vue-wswg-editor:blocks",
21
+ "vue-wswg-editor:fields",
22
+ "vue-wswg-editor:thumbnails"
23
+ ];
24
+ for (const i of n)
25
+ r.includes(i) || r.push(i);
26
+ return {
27
+ optimizeDeps: {
28
+ ...s,
29
+ exclude: r,
30
+ esbuildOptions: {
31
+ ...s.esbuildOptions,
32
+ plugins: [
33
+ ...((l = s.esbuildOptions) == null ? void 0 : l.plugins) || [],
34
+ {
35
+ name: "vue-wswg-editor-virtual-modules",
36
+ setup(i) {
37
+ i.onResolve({ filter: /^vue-wswg-editor:/ }, () => ({ external: !0 }));
38
+ }
39
+ }
40
+ ]
41
+ }
42
+ }
43
+ };
44
+ },
45
+ resolveId(e) {
46
+ if (e.startsWith("vue-wswg-editor:")) {
47
+ const o = e.replace("vue-wswg-editor:", "");
48
+ if (o in t)
49
+ return t[o];
50
+ }
51
+ if (Object.values(t).includes(e))
52
+ return e;
53
+ },
54
+ load(e) {
55
+ switch (e) {
56
+ case t.layouts:
57
+ return `export const modules = import.meta.glob("${u.rootDir}/layout/**/*.vue", { eager: true });`;
58
+ case t.blocks:
59
+ return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/*.vue", { eager: true });`;
60
+ case t.fields:
61
+ return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/fields.ts", { eager: true });`;
62
+ case t.thumbnails:
63
+ return `export const modules = import.meta.glob("${u.rootDir}/blocks/**/thumbnail.png", { eager: true });`;
64
+ default:
65
+ return;
66
+ }
67
+ },
68
+ transform(e, s) {
69
+ if (Object.values(t).includes(s))
70
+ return null;
71
+ }
72
+ };
73
+ }
74
+ export {
75
+ a as vueWswgEditorPlugin
76
+ };