@mapomodule/form 2.0.0-beta.0 → 2.0.0-beta.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.
- package/dist/__tests__/__mocks__/nuxt-imports.d.ts +4 -0
- package/dist/__tests__/__mocks__/nuxt-imports.d.ts.map +1 -0
- package/dist/__tests__/registry.test.d.ts +2 -0
- package/dist/__tests__/registry.test.d.ts.map +1 -0
- package/dist/__tests__/useFormFromSchema.test.d.ts +2 -0
- package/dist/__tests__/useFormFromSchema.test.d.ts.map +1 -0
- package/dist/__tests__/useMapoForm.test.d.ts +2 -0
- package/dist/__tests__/useMapoForm.test.d.ts.map +1 -0
- package/dist/index.d.mts +9 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +7 -34
- package/dist/module.d.mts +20 -2
- package/dist/module.d.ts +12 -2
- package/dist/module.d.ts.map +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +167 -13
- package/dist/runtime/components/MapoFocusPortal.vue +113 -0
- package/dist/runtime/components/MapoFocusPortal.vue.d.ts +4 -0
- package/dist/runtime/components/MapoFocusPortal.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoForm.vue +168 -0
- package/dist/runtime/components/MapoForm.vue.d.ts +47 -0
- package/dist/runtime/components/MapoForm.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormField.vue +269 -0
- package/dist/runtime/components/MapoFormField.vue.d.ts +46 -0
- package/dist/runtime/components/MapoFormField.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormFlatSection.vue +149 -0
- package/dist/runtime/components/MapoFormFlatSection.vue.d.ts +15 -0
- package/dist/runtime/components/MapoFormFlatSection.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormGroup.vue +247 -0
- package/dist/runtime/components/MapoFormGroup.vue.d.ts +44 -0
- package/dist/runtime/components/MapoFormGroup.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoFormTabs.vue +108 -0
- package/dist/runtime/components/MapoFormTabs.vue.d.ts +15 -0
- package/dist/runtime/components/MapoFormTabs.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoUnknownField.vue +62 -0
- package/dist/runtime/components/MapoUnknownField.vue.d.ts +16 -0
- package/dist/runtime/components/MapoUnknownField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoDateField.vue +86 -0
- package/dist/runtime/components/fields/MapoDateField.vue.d.ts +17 -0
- package/dist/runtime/components/fields/MapoDateField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoDateTimeField.vue +157 -0
- package/dist/runtime/components/fields/MapoDateTimeField.vue.d.ts +17 -0
- package/dist/runtime/components/fields/MapoDateTimeField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoFileField.vue +97 -0
- package/dist/runtime/components/fields/MapoFileField.vue.d.ts +16 -0
- package/dist/runtime/components/fields/MapoFileField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoFksField.vue +118 -0
- package/dist/runtime/components/fields/MapoFksField.vue.d.ts +16 -0
- package/dist/runtime/components/fields/MapoFksField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoMapField.vue +97 -0
- package/dist/runtime/components/fields/MapoMapField.vue.d.ts +22 -0
- package/dist/runtime/components/fields/MapoMapField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoMapFieldClient.vue +67 -0
- package/dist/runtime/components/fields/MapoMapFieldClient.vue.d.ts +20 -0
- package/dist/runtime/components/fields/MapoMapFieldClient.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoRepeater.vue +449 -0
- package/dist/runtime/components/fields/MapoRepeater.vue.d.ts +16 -0
- package/dist/runtime/components/fields/MapoRepeater.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoRepeaterItem.vue +341 -0
- package/dist/runtime/components/fields/MapoRepeaterItem.vue.d.ts +55 -0
- package/dist/runtime/components/fields/MapoRepeaterItem.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoSeoPreview.vue +118 -0
- package/dist/runtime/components/fields/MapoSeoPreview.vue.d.ts +22 -0
- package/dist/runtime/components/fields/MapoSeoPreview.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoTimeField.vue +44 -0
- package/dist/runtime/components/fields/MapoTimeField.vue.d.ts +17 -0
- package/dist/runtime/components/fields/MapoTimeField.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/MapoWygEditor.vue +227 -0
- package/dist/runtime/components/fields/MapoWygEditor.vue.d.ts +16 -0
- package/dist/runtime/components/fields/MapoWygEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiCheckbox.vue +9 -0
- package/dist/runtime/components/fields/nui/NuiCheckbox.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiCheckbox.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiInput.vue +9 -0
- package/dist/runtime/components/fields/nui/NuiInput.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiInput.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiSelectMenu.vue +18 -0
- package/dist/runtime/components/fields/nui/NuiSelectMenu.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiSelectMenu.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiSlider.vue +9 -0
- package/dist/runtime/components/fields/nui/NuiSlider.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiSlider.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiSwitch.vue +9 -0
- package/dist/runtime/components/fields/nui/NuiSwitch.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiSwitch.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/NuiTextarea.vue +9 -0
- package/dist/runtime/components/fields/nui/NuiTextarea.vue.d.ts +4 -0
- package/dist/runtime/components/fields/nui/NuiTextarea.vue.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/useNuiFieldAttrs.d.ts +13 -0
- package/dist/runtime/components/fields/nui/useNuiFieldAttrs.d.ts.map +1 -0
- package/dist/runtime/components/fields/nui/useNuiFieldAttrs.js +19 -0
- package/dist/runtime/composables/defineFormField.d.ts +25 -0
- package/dist/runtime/composables/defineFormField.d.ts.map +1 -0
- package/dist/runtime/composables/defineFormField.js +27 -0
- package/dist/runtime/composables/useCurrentLang.d.ts +6 -0
- package/dist/runtime/composables/useCurrentLang.d.ts.map +1 -0
- package/dist/runtime/composables/useCurrentLang.js +9 -0
- package/dist/runtime/composables/useFocusMode.d.ts +40 -0
- package/dist/runtime/composables/useFocusMode.d.ts.map +1 -0
- package/dist/runtime/composables/useFocusMode.js +31 -0
- package/dist/runtime/composables/useFormDraft.d.ts +60 -0
- package/dist/runtime/composables/useFormDraft.d.ts.map +1 -0
- package/dist/runtime/composables/useFormDraft.js +52 -0
- package/dist/runtime/composables/useFormFromSchema.d.ts +21 -0
- package/dist/runtime/composables/useFormFromSchema.d.ts.map +1 -0
- package/dist/runtime/composables/useFormFromSchema.js +142 -0
- package/dist/runtime/composables/useMapoForm.d.ts +96 -0
- package/dist/runtime/composables/useMapoForm.d.ts.map +1 -0
- package/dist/runtime/composables/useMapoForm.js +323 -0
- package/dist/runtime/composables/useProgressiveDisclosure.d.ts +44 -0
- package/dist/runtime/composables/useProgressiveDisclosure.d.ts.map +1 -0
- package/dist/runtime/composables/useProgressiveDisclosure.js +23 -0
- package/dist/runtime/composables/useUnsavedChangesGuard.d.ts +24 -0
- package/dist/runtime/composables/useUnsavedChangesGuard.d.ts.map +1 -0
- package/dist/runtime/composables/useUnsavedChangesGuard.js +27 -0
- package/dist/runtime/devtools/DevtoolsFormsPage.vue +235 -0
- package/dist/runtime/devtools/DevtoolsFormsPage.vue.d.ts +4 -0
- package/dist/runtime/devtools/DevtoolsFormsPage.vue.d.ts.map +1 -0
- package/dist/runtime/plugins/form-registry.d.ts +18 -0
- package/dist/runtime/plugins/form-registry.d.ts.map +1 -0
- package/dist/runtime/plugins/form-registry.js +19 -0
- package/dist/runtime/registry/defaults.d.ts +3 -0
- package/dist/runtime/registry/defaults.d.ts.map +1 -0
- package/dist/runtime/registry/defaults.js +87 -0
- package/dist/runtime/types/descriptor.d.ts +359 -0
- package/dist/runtime/types/descriptor.d.ts.map +1 -0
- package/dist/runtime/types/descriptor.js +26 -0
- package/dist/runtime/types/index.d.ts +11 -0
- package/dist/runtime/types/index.d.ts.map +1 -0
- package/dist/runtime/types/index.js +6 -0
- package/dist/runtime/types/layout.d.ts +21 -0
- package/dist/runtime/types/layout.d.ts.map +1 -0
- package/dist/runtime/types/layout.js +0 -0
- package/dist/runtime/types/registry.d.ts +62 -0
- package/dist/runtime/types/registry.d.ts.map +1 -0
- package/dist/runtime/types/registry.js +19 -0
- package/dist/runtime/utils/flattenFieldGroups.d.ts +50 -0
- package/dist/runtime/utils/flattenFieldGroups.d.ts.map +1 -0
- package/dist/runtime/utils/flattenFieldGroups.js +24 -0
- package/dist/types.d.mts +6 -10
- package/package.json +4 -4
- package/dist/index.d.cts +0 -1
- package/dist/module.d.cts +0 -2
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import type { Component } from "vue";
|
|
2
|
+
/** Lookup table for decrementing depth at compile time. */
|
|
3
|
+
type Prev = [never, 0, 1, 2, 3, 4];
|
|
4
|
+
/**
|
|
5
|
+
* Recursively builds all valid dotted-path keys of T up to depth D.
|
|
6
|
+
* Arrays are not expanded — repeater items declare their own nested `fields`.
|
|
7
|
+
* When T is the default `Record<string, unknown>`, this resolves to `string`
|
|
8
|
+
* so untyped field arrays remain unconstrained.
|
|
9
|
+
*/
|
|
10
|
+
export type DeepKeyOf<T, D extends number = 4> = [D] extends [never] ? never : T extends object ? {
|
|
11
|
+
[K in keyof T & string]: K | (NonNullable<T[K]> extends unknown[] ? never : NonNullable<T[K]> extends object ? `${K}.${DeepKeyOf<NonNullable<T[K]>, Prev[D]>}` : never);
|
|
12
|
+
}[keyof T & string] : never;
|
|
13
|
+
/**
|
|
14
|
+
* All field types recognised by the default Mapo form registry.
|
|
15
|
+
* Use {@link FieldType} when you need to accept custom (string) types too.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum KnownFieldType {
|
|
18
|
+
Text = "text",
|
|
19
|
+
Textarea = "textarea",
|
|
20
|
+
Email = "email",
|
|
21
|
+
Url = "url",
|
|
22
|
+
Number = "number",
|
|
23
|
+
Boolean = "boolean",
|
|
24
|
+
Switch = "switch",
|
|
25
|
+
Slider = "slider",
|
|
26
|
+
Color = "color",
|
|
27
|
+
File = "file",
|
|
28
|
+
Select = "select",
|
|
29
|
+
Fks = "fks",
|
|
30
|
+
M2m = "m2m",
|
|
31
|
+
Date = "date",
|
|
32
|
+
Time = "time",
|
|
33
|
+
Datetime = "datetime",
|
|
34
|
+
Editor = "editor",
|
|
35
|
+
Seo = "seo",
|
|
36
|
+
Map = "map",
|
|
37
|
+
Repeater = "repeater",
|
|
38
|
+
Media = "media",
|
|
39
|
+
MediaM2m = "media-m2m",
|
|
40
|
+
EnhancedMedia = "enhanced-media"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Accepts any {@link KnownFieldType} value **or** an arbitrary string for custom types
|
|
44
|
+
* registered by the consumer via `defineFormField()` or `nuxt.config`.
|
|
45
|
+
*/
|
|
46
|
+
export type FieldType = `${KnownFieldType}` | (string & {});
|
|
47
|
+
/**
|
|
48
|
+
* Custom get/set accessor pair for a field.
|
|
49
|
+
* Use this to redirect reads/writes to a different model path or to apply
|
|
50
|
+
* a transformation (e.g. serialise a Date object to an ISO string).
|
|
51
|
+
*/
|
|
52
|
+
export interface FieldAccessor<TValue = unknown, TModel = unknown> {
|
|
53
|
+
get?: (ctx: {
|
|
54
|
+
model: TModel;
|
|
55
|
+
val: TValue;
|
|
56
|
+
lang?: string;
|
|
57
|
+
}) => TValue;
|
|
58
|
+
set?: (ctx: {
|
|
59
|
+
model: TModel;
|
|
60
|
+
val: TValue;
|
|
61
|
+
lang?: string;
|
|
62
|
+
}) => TValue;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Common properties shared by every field descriptor.
|
|
66
|
+
* All concrete descriptor types extend this interface.
|
|
67
|
+
*/
|
|
68
|
+
interface FieldBase<T> {
|
|
69
|
+
/** Model key. Accepts a direct `keyof T` or a dotted path up to 4 levels deep (e.g. `"data.hero.title"`). */
|
|
70
|
+
key: DeepKeyOf<T>;
|
|
71
|
+
/** Human-readable label displayed above the field. */
|
|
72
|
+
label?: string;
|
|
73
|
+
/** Adds a required validation rule and marks the field visually. */
|
|
74
|
+
required?: boolean;
|
|
75
|
+
/** Renders the field in read-only mode (no user input allowed). */
|
|
76
|
+
readonly?: boolean;
|
|
77
|
+
/** `v-if` predicate — removes the field from the DOM entirely when `false`. */
|
|
78
|
+
visible?: (ctx: {
|
|
79
|
+
model: T;
|
|
80
|
+
}) => boolean;
|
|
81
|
+
/** `v-show` predicate — hides the field while keeping it in the DOM. */
|
|
82
|
+
show?: (ctx: {
|
|
83
|
+
model: T;
|
|
84
|
+
}) => boolean;
|
|
85
|
+
/** Callback fired after the field value changes. */
|
|
86
|
+
onChange?: (ctx: {
|
|
87
|
+
model: T;
|
|
88
|
+
val: unknown;
|
|
89
|
+
}) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Synchronous client-side validation.
|
|
92
|
+
* Return `null` if the value is valid, or an error message string otherwise.
|
|
93
|
+
* The first argument is the current field value, typed as the union of all
|
|
94
|
+
* model values (plus `null` / `undefined`) so TypeScript can contextually type
|
|
95
|
+
* the callback parameter without falling back to implicit `any`.
|
|
96
|
+
*/
|
|
97
|
+
validate?: (val: T[keyof T & string] | null | undefined, ctx: {
|
|
98
|
+
model: T;
|
|
99
|
+
}) => string | null;
|
|
100
|
+
/**
|
|
101
|
+
* Asynchronous validation (e.g. uniqueness check, server-side rule).
|
|
102
|
+
* Runs debounced after every value change.
|
|
103
|
+
* Return `null` if valid, or an error message string otherwise.
|
|
104
|
+
*/
|
|
105
|
+
validateAsync?: (val: T[keyof T & string] | null | undefined, ctx: {
|
|
106
|
+
model: T;
|
|
107
|
+
}) => Promise<string | null>;
|
|
108
|
+
/** Debounce delay in milliseconds for `validateAsync`. Default: `600`. */
|
|
109
|
+
validateAsyncDebounce?: number;
|
|
110
|
+
/** Custom get/set accessor. Overrides the registry-level accessor for this field. */
|
|
111
|
+
accessor?: FieldAccessor;
|
|
112
|
+
/** When `true`, reads/writes `model.translations[currentLang][key]` instead of `model[key]`. */
|
|
113
|
+
translatable?: boolean;
|
|
114
|
+
/** When `true`, propagates the value to all available language translations simultaneously. */
|
|
115
|
+
synci18n?: boolean;
|
|
116
|
+
/** Group name. Fields sharing the same group are rendered inside a collapsible group card. */
|
|
117
|
+
group?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Sub-tab name inside the group card. When set, the field is placed in a
|
|
120
|
+
* tab bar rendered within its parent group card. Requires `group` to be set.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* { group: 'seo', subtab: 'basic', key: 'meta_title' }
|
|
124
|
+
* { group: 'seo', subtab: 'advanced', key: 'og_image' }
|
|
125
|
+
* // → "seo" group card shows a "basic" / "advanced" tab bar inside
|
|
126
|
+
*/
|
|
127
|
+
subtab?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Tab name. Fields sharing the same tab are rendered under the same tab panel.
|
|
130
|
+
*
|
|
131
|
+
* Supports nested tabs via an array path or a `/`-separated string:
|
|
132
|
+
* - `tab: 'settings'` — top-level tab (backward-compatible)
|
|
133
|
+
* - `tab: ['settings', 'seo']` — nested: "seo" sub-tab inside "settings"
|
|
134
|
+
* - `tab: 'settings/seo'` — equivalent slash-separated form
|
|
135
|
+
*/
|
|
136
|
+
tab?: string | string[];
|
|
137
|
+
/**
|
|
138
|
+
* Column span (out of 12) for the field wrapper.
|
|
139
|
+
* Accepts a plain number or a responsive breakpoint map `{ sm, md, lg }`.
|
|
140
|
+
* Default: `12` (full width).
|
|
141
|
+
*/
|
|
142
|
+
cols?: number | {
|
|
143
|
+
sm?: number;
|
|
144
|
+
md?: number;
|
|
145
|
+
lg?: number;
|
|
146
|
+
};
|
|
147
|
+
/** CSS class applied to the outer field wrapper element. */
|
|
148
|
+
class?: string | string[] | Record<string, boolean>;
|
|
149
|
+
/**
|
|
150
|
+
* When `true`, the field renders an expand button that fills the group container.
|
|
151
|
+
* The group becomes a full-screen overlay and all other fields are hidden.
|
|
152
|
+
* Useful for large textarea, rich-text editors, maps, etc.
|
|
153
|
+
*/
|
|
154
|
+
expandable?: boolean;
|
|
155
|
+
/** Debounce delay in milliseconds for the `update:modelValue` emit. Default: `300`. Use `0` for immediate. */
|
|
156
|
+
debounce?: number;
|
|
157
|
+
/**
|
|
158
|
+
* Extra props forwarded verbatim to the underlying input component via `v-bind`
|
|
159
|
+
* (e.g. Nuxt UI props: `icon`, `variant`, `color`, `size`…).
|
|
160
|
+
*
|
|
161
|
+
* Use `attrs` for the field's own typed configuration; `passthrough` is the
|
|
162
|
+
* escape hatch for anything the wrapped component accepts.
|
|
163
|
+
*/
|
|
164
|
+
passthrough?: Record<string, unknown>;
|
|
165
|
+
/** Direct component override. Takes priority over `registry.mapping[type]`. */
|
|
166
|
+
is?: Component;
|
|
167
|
+
/**
|
|
168
|
+
* When `true`, this field's value is excluded from draft snapshots saved to localStorage.
|
|
169
|
+
* Use for sensitive fields (passwords, API keys, tokens) that should never be persisted client-side.
|
|
170
|
+
*/
|
|
171
|
+
noDraft?: boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Descriptor for plain text input (`type: 'text'`), multi-line textarea
|
|
175
|
+
* (`type: 'textarea'`), and native email / url inputs.
|
|
176
|
+
*/
|
|
177
|
+
export interface TextDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
178
|
+
type: `${KnownFieldType.Text}` | `${KnownFieldType.Textarea}` | `${KnownFieldType.Email}` | `${KnownFieldType.Url}`;
|
|
179
|
+
attrs?: {
|
|
180
|
+
placeholder?: string;
|
|
181
|
+
maxLength?: number;
|
|
182
|
+
minLength?: number;
|
|
183
|
+
/** Visible rows for `type: 'textarea'`. */
|
|
184
|
+
rows?: number;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** Descriptor for numeric input (`type: 'number'`) and range slider (`type: 'slider'`). */
|
|
188
|
+
export interface NumberDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
189
|
+
type: `${KnownFieldType.Number}` | `${KnownFieldType.Slider}`;
|
|
190
|
+
attrs?: {
|
|
191
|
+
min?: number;
|
|
192
|
+
max?: number;
|
|
193
|
+
step?: number;
|
|
194
|
+
placeholder?: string;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/** Descriptor for checkbox (`type: 'boolean'`) and toggle switch (`type: 'switch'`). */
|
|
198
|
+
export interface BooleanDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
199
|
+
type: `${KnownFieldType.Boolean}` | `${KnownFieldType.Switch}`;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Descriptor for a single-value or multi-value select menu.
|
|
203
|
+
* Provide the choices via `attrs.items` (Nuxt UI shape) or the legacy
|
|
204
|
+
* `attrs.options` (Mapo v1 shape).
|
|
205
|
+
*/
|
|
206
|
+
export interface SelectDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
207
|
+
type: `${KnownFieldType.Select}`;
|
|
208
|
+
attrs: {
|
|
209
|
+
/** Choices in Nuxt UI shape (or plain strings) — forwarded to `USelectMenu`. */
|
|
210
|
+
items?: ReadonlyArray<string | {
|
|
211
|
+
label: string;
|
|
212
|
+
value: unknown;
|
|
213
|
+
}>;
|
|
214
|
+
/** Choices in Mapo v1 shape (`text`/`value`). Used when `items` is absent. */
|
|
215
|
+
options?: ReadonlyArray<{
|
|
216
|
+
text: string;
|
|
217
|
+
value: unknown;
|
|
218
|
+
}>;
|
|
219
|
+
multiple?: boolean;
|
|
220
|
+
placeholder?: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Descriptor for FK autocomplete (`type: 'fks'`) and many-to-many autocomplete (`type: 'm2m'`).
|
|
225
|
+
* Requires `attrs.endpoint`.
|
|
226
|
+
*/
|
|
227
|
+
export interface FksDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
228
|
+
type: `${KnownFieldType.Fks}` | `${KnownFieldType.M2m}`;
|
|
229
|
+
attrs: {
|
|
230
|
+
endpoint: string;
|
|
231
|
+
itemText?: string;
|
|
232
|
+
itemValue?: string;
|
|
233
|
+
returnObject?: boolean;
|
|
234
|
+
multiple?: boolean;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Descriptor for date (`type: 'date'`), time (`type: 'time'`), and datetime (`type: 'datetime'`) pickers. */
|
|
238
|
+
export interface DateDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
239
|
+
type: `${KnownFieldType.Date}` | `${KnownFieldType.Time}` | `${KnownFieldType.Datetime}`;
|
|
240
|
+
attrs?: {
|
|
241
|
+
min?: string;
|
|
242
|
+
max?: string;
|
|
243
|
+
granularity?: string;
|
|
244
|
+
/** Timezone strategy for datetime parsing/serialisation. Default: `"naive"`. */
|
|
245
|
+
tz?: "naive" | "utc";
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** Descriptor for a colour picker field. */
|
|
249
|
+
export interface ColorDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
250
|
+
type: `${KnownFieldType.Color}`;
|
|
251
|
+
}
|
|
252
|
+
/** Descriptor for a file upload field. */
|
|
253
|
+
export interface FileDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
254
|
+
type: `${KnownFieldType.File}`;
|
|
255
|
+
attrs?: {
|
|
256
|
+
accept?: string;
|
|
257
|
+
maxSize?: number;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/** Descriptor for a Tiptap rich-text editor. */
|
|
261
|
+
export interface EditorDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
262
|
+
type: `${KnownFieldType.Editor}`;
|
|
263
|
+
attrs?: {
|
|
264
|
+
extensions?: unknown[];
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
/** Descriptor for the SEO preview field (title + description + live SERP preview). */
|
|
268
|
+
export interface SeoDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
269
|
+
type: `${KnownFieldType.Seo}`;
|
|
270
|
+
}
|
|
271
|
+
/** Descriptor for a Leaflet map field. Model value is `{ lat: number; lng: number }`. */
|
|
272
|
+
export interface MapDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
273
|
+
type: `${KnownFieldType.Map}`;
|
|
274
|
+
attrs?: {
|
|
275
|
+
defaultLat?: number;
|
|
276
|
+
defaultLng?: number;
|
|
277
|
+
zoom?: number;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** Descriptor for a drag-and-drop repeater with nested field descriptors. */
|
|
281
|
+
export interface RepeaterDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
282
|
+
type: `${KnownFieldType.Repeater}`;
|
|
283
|
+
/**
|
|
284
|
+
* Field descriptors for each item inside the repeater.
|
|
285
|
+
* Optional when `attrs.templates` provides per-template fields.
|
|
286
|
+
*/
|
|
287
|
+
fields?: AnyFieldDescriptor[];
|
|
288
|
+
attrs?: {
|
|
289
|
+
/** Multiple templates for heterogeneous items (`oneOf` discriminated union). */
|
|
290
|
+
templates?: Record<string, AnyFieldDescriptor[]>;
|
|
291
|
+
/** Label shown when an item is collapsed. Receives the item and its index. */
|
|
292
|
+
previewLabel?: (item: unknown, index: number) => string;
|
|
293
|
+
confirmDelete?: boolean;
|
|
294
|
+
allowDuplicate?: boolean;
|
|
295
|
+
/** Show a numeric position input alongside the reorder buttons. */
|
|
296
|
+
showPositionField?: boolean;
|
|
297
|
+
defaultExpanded?: boolean;
|
|
298
|
+
maxItems?: number;
|
|
299
|
+
minItems?: number;
|
|
300
|
+
/**
|
|
301
|
+
* Renders a compact preview card for inactive items.
|
|
302
|
+
* Activated when the number of items exceeds `compressThreshold`.
|
|
303
|
+
*/
|
|
304
|
+
miniCard?: (item: unknown, index: number) => {
|
|
305
|
+
title: string;
|
|
306
|
+
subtitle?: string;
|
|
307
|
+
/** URL or base64 string for a thumbnail image. */
|
|
308
|
+
thumbnail?: string;
|
|
309
|
+
statusColor?: "success" | "info" | "warning" | "error" | "neutral";
|
|
310
|
+
};
|
|
311
|
+
/** Minimum item count above which contextual scaling activates. Default: `3`. */
|
|
312
|
+
compressThreshold?: number;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/** Descriptor for media/file manager fields. */
|
|
316
|
+
export interface MediaDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
317
|
+
type: `${KnownFieldType.Media}` | `${KnownFieldType.MediaM2m}` | `${KnownFieldType.EnhancedMedia}`;
|
|
318
|
+
attrs?: {
|
|
319
|
+
mime?: string;
|
|
320
|
+
multiple?: boolean;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Escape-hatch descriptor for custom field types registered by the consumer.
|
|
325
|
+
* `attrs` stays fully open here: the wrapped component is user-defined, so its
|
|
326
|
+
* props cannot be known in advance.
|
|
327
|
+
*/
|
|
328
|
+
export interface CustomDescriptor<T = Record<string, unknown>> extends FieldBase<T> {
|
|
329
|
+
type: string & {};
|
|
330
|
+
attrs?: Record<string, unknown>;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Union of the built-in (known) field descriptor types.
|
|
334
|
+
* Use this as the type for a `fields` array passed to `<MapoForm>` or `useMapoForm()`.
|
|
335
|
+
*
|
|
336
|
+
* This union is **strict**: object literals get full excess-property checking
|
|
337
|
+
* on `attrs` (typos and wrong-type keys are compile errors). If the form mixes
|
|
338
|
+
* in custom field types registered via `defineFormField()` / the registry,
|
|
339
|
+
* annotate the array with {@link AnyFieldDescriptor} instead.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* const fields: FieldDescriptor<Article>[] = [
|
|
343
|
+
* { key: 'title', type: KnownFieldType.Text, label: 'Title', required: true },
|
|
344
|
+
* { key: 'body', type: KnownFieldType.Editor, label: 'Body', translatable: true },
|
|
345
|
+
* ]
|
|
346
|
+
*/
|
|
347
|
+
export type FieldDescriptor<T = Record<string, unknown>> = TextDescriptor<T> | NumberDescriptor<T> | BooleanDescriptor<T> | SelectDescriptor<T> | FksDescriptor<T> | DateDescriptor<T> | ColorDescriptor<T> | FileDescriptor<T> | EditorDescriptor<T> | SeoDescriptor<T> | MapDescriptor<T> | RepeaterDescriptor<T> | MediaDescriptor<T>;
|
|
348
|
+
/**
|
|
349
|
+
* {@link FieldDescriptor} plus the {@link CustomDescriptor} escape hatch.
|
|
350
|
+
*
|
|
351
|
+
* This is what the form engine accepts everywhere (MapoForm, useMapoForm,
|
|
352
|
+
* MapoDetail / MapoList editFields…). Annotate your `fields` array with this
|
|
353
|
+
* type when it contains custom field types — note that the open
|
|
354
|
+
* `CustomDescriptor.attrs` disables excess-property checking on the union, so
|
|
355
|
+
* prefer the strict {@link FieldDescriptor} when no custom types are used.
|
|
356
|
+
*/
|
|
357
|
+
export type AnyFieldDescriptor<T = Record<string, unknown>> = FieldDescriptor<T> | CustomDescriptor<T>;
|
|
358
|
+
export {};
|
|
359
|
+
//# sourceMappingURL=descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,2DAA2D;AAC3D,KAAK,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,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
|
|
2
|
+
KnownFieldType2["Text"] = "text";
|
|
3
|
+
KnownFieldType2["Textarea"] = "textarea";
|
|
4
|
+
KnownFieldType2["Email"] = "email";
|
|
5
|
+
KnownFieldType2["Url"] = "url";
|
|
6
|
+
KnownFieldType2["Number"] = "number";
|
|
7
|
+
KnownFieldType2["Boolean"] = "boolean";
|
|
8
|
+
KnownFieldType2["Switch"] = "switch";
|
|
9
|
+
KnownFieldType2["Slider"] = "slider";
|
|
10
|
+
KnownFieldType2["Color"] = "color";
|
|
11
|
+
KnownFieldType2["File"] = "file";
|
|
12
|
+
KnownFieldType2["Select"] = "select";
|
|
13
|
+
KnownFieldType2["Fks"] = "fks";
|
|
14
|
+
KnownFieldType2["M2m"] = "m2m";
|
|
15
|
+
KnownFieldType2["Date"] = "date";
|
|
16
|
+
KnownFieldType2["Time"] = "time";
|
|
17
|
+
KnownFieldType2["Datetime"] = "datetime";
|
|
18
|
+
KnownFieldType2["Editor"] = "editor";
|
|
19
|
+
KnownFieldType2["Seo"] = "seo";
|
|
20
|
+
KnownFieldType2["Map"] = "map";
|
|
21
|
+
KnownFieldType2["Repeater"] = "repeater";
|
|
22
|
+
KnownFieldType2["Media"] = "media";
|
|
23
|
+
KnownFieldType2["MediaM2m"] = "media-m2m";
|
|
24
|
+
KnownFieldType2["EnhancedMedia"] = "enhanced-media";
|
|
25
|
+
return KnownFieldType2;
|
|
26
|
+
})(KnownFieldType || {});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form engine type barrel.
|
|
3
|
+
* Re-exports all descriptor types, the {@link KnownFieldType} enum,
|
|
4
|
+
* and registry helpers.
|
|
5
|
+
*/
|
|
6
|
+
export { KnownFieldType } from "./descriptor.js";
|
|
7
|
+
export type { FieldType, FieldAccessor, FieldDescriptor, AnyFieldDescriptor, TextDescriptor, NumberDescriptor, BooleanDescriptor, SelectDescriptor, FksDescriptor, DateDescriptor, ColorDescriptor, FileDescriptor, EditorDescriptor, SeoDescriptor, MapDescriptor, RepeaterDescriptor, MediaDescriptor, CustomDescriptor, } from "./descriptor.js";
|
|
8
|
+
export type { FieldComponentEntry, FieldRegistry, PartialFieldRegistry, } from "./registry.js";
|
|
9
|
+
export { resolveFieldComponent, resolveFieldAttrs, resolveFieldAccessor, } from "./registry.js";
|
|
10
|
+
export type { MapoFormRuntimeConfig } from "./registry.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AnyFieldDescriptor } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A group of fields rendered inside a single group card.
|
|
4
|
+
* `subtabs` holds fields assigned to a sub-tab bar within the group.
|
|
5
|
+
*
|
|
6
|
+
* Shared by `MapoForm` and `MapoFormTabs` so the grouped tree is a single
|
|
7
|
+
* structural type (avoids "two unrelated types with the same name").
|
|
8
|
+
*/
|
|
9
|
+
export interface GroupEntry {
|
|
10
|
+
label?: string;
|
|
11
|
+
fields: AnyFieldDescriptor[];
|
|
12
|
+
subtabs: Map<string, AnyFieldDescriptor[]>;
|
|
13
|
+
}
|
|
14
|
+
/** A tab panel; may nest further tabs through `children`. */
|
|
15
|
+
export interface TabEntry {
|
|
16
|
+
name: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
groups: Map<string, GroupEntry>;
|
|
19
|
+
children: Map<string, TabEntry>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC;CAC5C;AAED,6DAA6D;AAC7D,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAChC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACjC"}
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Component } from "vue";
|
|
2
|
+
import type { AnyFieldDescriptor, FieldAccessor } from "./descriptor.js";
|
|
3
|
+
/**
|
|
4
|
+
* Accepted values for a registry entry:
|
|
5
|
+
* - `string` — Nuxt UI component name, resolved at runtime via `resolveComponent()`
|
|
6
|
+
* - `Component` — synchronous Vue component object
|
|
7
|
+
* - `() => Promise<{ default: Component }>` — async lazy import
|
|
8
|
+
*/
|
|
9
|
+
export type FieldComponentEntry = string | Component | (() => Promise<{
|
|
10
|
+
default: Component;
|
|
11
|
+
}>);
|
|
12
|
+
/** The global form field registry injected as `$mapoFormRegistry`. */
|
|
13
|
+
export interface FieldRegistry {
|
|
14
|
+
/** Maps a field `type` string to its component entry. */
|
|
15
|
+
mapping: Record<string, FieldComponentEntry>;
|
|
16
|
+
/**
|
|
17
|
+
* Default `attrs` merged into every field of the given type.
|
|
18
|
+
* The special key `'All'` is applied to all field types.
|
|
19
|
+
*/
|
|
20
|
+
attrs: Record<string, Record<string, unknown>>;
|
|
21
|
+
/** Default `get`/`set` accessor applied per field type. */
|
|
22
|
+
accessor: Record<string, FieldAccessor>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Partial version of {@link FieldRegistry} for consumer overrides
|
|
26
|
+
* (e.g. `mapoForm.fields` in `nuxt.config`).
|
|
27
|
+
*/
|
|
28
|
+
export type PartialFieldRegistry = {
|
|
29
|
+
mapping?: Partial<FieldRegistry["mapping"]>;
|
|
30
|
+
attrs?: Partial<FieldRegistry["attrs"]>;
|
|
31
|
+
accessor?: Partial<FieldRegistry["accessor"]>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the component entry for a given field descriptor.
|
|
35
|
+
* Returns the `descriptor.is` override if set, otherwise looks up `registry.mapping`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveFieldComponent(descriptor: AnyFieldDescriptor<any>, registry: FieldRegistry): FieldComponentEntry | null;
|
|
38
|
+
/**
|
|
39
|
+
* Merges the registry-level default attrs for a field type with the descriptor's
|
|
40
|
+
* own typed `attrs` and its open `passthrough` props.
|
|
41
|
+
* Order: `registry.attrs['All']` → `registry.attrs[type]` → `descriptor.attrs`
|
|
42
|
+
* → `descriptor.passthrough` (most specific wins).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveFieldAttrs(descriptor: AnyFieldDescriptor<any>, registry: FieldRegistry): Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Merges the registry-level default accessor for a field type with the descriptor's own `accessor`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveFieldAccessor(descriptor: AnyFieldDescriptor<any>, registry: FieldRegistry): FieldAccessor;
|
|
49
|
+
/**
|
|
50
|
+
* Shape of `runtimeConfig.public.mapoForm` as written by the module setup.
|
|
51
|
+
* `groups` and `debounce` are guaranteed by the module `defaults`.
|
|
52
|
+
*/
|
|
53
|
+
export interface MapoFormRuntimeConfig {
|
|
54
|
+
groups: {
|
|
55
|
+
expanded: boolean;
|
|
56
|
+
};
|
|
57
|
+
debounce: number;
|
|
58
|
+
fields: {
|
|
59
|
+
attrs: Record<string, Record<string, unknown>>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN,SAAS,GACT,CAAC,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC,CAAC;AAE5C,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC7C;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC/C,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AAIH,wBAAgB,qBAAqB,CAEnC,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACnC,QAAQ,EAAE,aAAa,GACtB,mBAAmB,GAAG,IAAI,CAG5B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAE/B,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACnC,QAAQ,EAAE,aAAa,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAElC,UAAU,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACnC,QAAQ,EAAE,aAAa,GACtB,aAAa,CAGf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,CAAC;CAC5D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function resolveFieldComponent(descriptor, registry) {
|
|
2
|
+
if (descriptor.is) return descriptor.is;
|
|
3
|
+
return registry.mapping[descriptor.type] ?? null;
|
|
4
|
+
}
|
|
5
|
+
export function resolveFieldAttrs(descriptor, registry) {
|
|
6
|
+
const allAttrs = registry.attrs["All"] ?? {};
|
|
7
|
+
const typeAttrs = registry.attrs[descriptor.type] ?? {};
|
|
8
|
+
const ownAttrs = descriptor.attrs ?? {};
|
|
9
|
+
return {
|
|
10
|
+
...allAttrs,
|
|
11
|
+
...typeAttrs,
|
|
12
|
+
...ownAttrs,
|
|
13
|
+
...descriptor.passthrough ?? {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function resolveFieldAccessor(descriptor, registry) {
|
|
17
|
+
const typeAccessor = registry.accessor[descriptor.type] ?? {};
|
|
18
|
+
return { ...typeAccessor, ...descriptor.accessor ?? {} };
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AnyFieldDescriptor } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hierarchical authoring structure. Lets you group field descriptors under a
|
|
4
|
+
* named group without repeating `group` on every field.
|
|
5
|
+
*
|
|
6
|
+
* Pass an array of these to {@link flattenFieldGroups} to get the flat
|
|
7
|
+
* `AnyFieldDescriptor<T>[]` expected by `<MapoForm>` / `<MapoDetail>`.
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldGroupDescriptor<T = Record<string, unknown>> {
|
|
10
|
+
/** Group name — propagated to every field in `fields`. */
|
|
11
|
+
group: string;
|
|
12
|
+
/** Optional tab — propagated to every field unless the field already has a `tab`. */
|
|
13
|
+
tab?: string | string[];
|
|
14
|
+
/** Fields belonging to this group. May contain nested `FieldGroupDescriptor` objects. */
|
|
15
|
+
fields: Array<AnyFieldDescriptor<T> | FieldGroupDescriptor<T>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Flattens a mixed array of `AnyFieldDescriptor` and `FieldGroupDescriptor` objects
|
|
19
|
+
* into a plain `AnyFieldDescriptor<T>[]` ready to be passed to `<MapoForm>` or `<MapoDetail>`.
|
|
20
|
+
*
|
|
21
|
+
* Each `FieldGroupDescriptor` propagates its `group` (and optionally `tab`) to
|
|
22
|
+
* every leaf field it contains. Fields that already declare a `group` or `tab`
|
|
23
|
+
* are left unchanged.
|
|
24
|
+
*
|
|
25
|
+
* Groups can be arbitrarily nested — the function recurses until every item is
|
|
26
|
+
* a leaf `AnyFieldDescriptor`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const fields = flattenFieldGroups<Article>([
|
|
31
|
+
* { key: 'title', type: 'text', label: 'Title', tab: 'content' },
|
|
32
|
+
* {
|
|
33
|
+
* group: 'seo',
|
|
34
|
+
* tab: 'seo',
|
|
35
|
+
* fields: [
|
|
36
|
+
* { key: 'seo_title', type: 'text', label: 'SEO Title' },
|
|
37
|
+
* { key: 'seo_description', type: 'textarea', label: 'SEO Description' },
|
|
38
|
+
* ],
|
|
39
|
+
* },
|
|
40
|
+
* ])
|
|
41
|
+
* // Result:
|
|
42
|
+
* // [
|
|
43
|
+
* // { key: 'title', type: 'text', label: 'Title', tab: 'content' },
|
|
44
|
+
* // { key: 'seo_title', type: 'text', label: 'SEO Title', group: 'seo', tab: 'seo' },
|
|
45
|
+
* // { key: 'seo_description', type: 'textarea', label: 'SEO Description', group: 'seo', tab: 'seo' },
|
|
46
|
+
* // ]
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function flattenFieldGroups<T = Record<string, unknown>>(items: Array<AnyFieldDescriptor<T> | FieldGroupDescriptor<T>>, _inheritedGroup?: string, _inheritedTab?: string | string[]): AnyFieldDescriptor<T>[];
|
|
50
|
+
//# sourceMappingURL=flattenFieldGroups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flattenFieldGroups.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/flattenFieldGroups.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,yFAAyF;IACzF,MAAM,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;CAChE;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5D,KAAK,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAC7D,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAChC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAsBzB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function isGroupDescriptor(item) {
|
|
2
|
+
return "fields" in item && Array.isArray(item.fields);
|
|
3
|
+
}
|
|
4
|
+
export function flattenFieldGroups(items, _inheritedGroup, _inheritedTab) {
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
if (isGroupDescriptor(item)) {
|
|
8
|
+
const group = item.group ?? _inheritedGroup;
|
|
9
|
+
const tab = item.tab ?? _inheritedTab;
|
|
10
|
+
result.push(...flattenFieldGroups(item.fields, group, tab));
|
|
11
|
+
} else {
|
|
12
|
+
const field = item;
|
|
13
|
+
const merged = { ...field };
|
|
14
|
+
if (_inheritedGroup && !merged.group) {
|
|
15
|
+
Object.assign(merged, { group: _inheritedGroup });
|
|
16
|
+
}
|
|
17
|
+
if (_inheritedTab && !merged.tab) {
|
|
18
|
+
Object.assign(merged, { tab: _inheritedTab });
|
|
19
|
+
}
|
|
20
|
+
result.push(merged);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
interface RuntimeNuxtHooks extends ModuleRuntimeHooks {}
|
|
5
|
-
}
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
interface NuxtHooks extends ModuleHooks {}
|
|
9
|
-
interface RuntimeConfig extends ModuleRuntimeConfig {}
|
|
10
|
-
interface PublicRuntimeConfig extends ModulePublicRuntimeConfig {}
|
|
11
|
-
}
|
|
5
|
+
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
12
6
|
|
|
13
|
-
export
|
|
7
|
+
export { default } from './module.mjs'
|
|
8
|
+
|
|
9
|
+
export { type MapoFormOptions } from './module.mjs'
|