@stonecrop/aform 0.13.7 → 0.13.9
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/README.md +1 -1
- package/dist/aform.d.ts +92 -134
- package/dist/aform.js +169 -172
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/src/types/index.d.ts +104 -142
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/AForm.vue +18 -21
- package/src/components/form/AFieldset.vue +5 -4
- package/src/types/index.ts +122 -162
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @stonecrop/aform
|
|
2
2
|
|
|
3
|
-
Schema-driven form components for the Stonecrop framework. Renders a `
|
|
3
|
+
Schema-driven form components for the Stonecrop framework. Renders a `ResolvedField[]` array (produced by `registry.resolveSchema()`) into a form, wiring field values to a `data` object via `v-model:data`.
|
|
4
4
|
|
|
5
5
|
## Components
|
|
6
6
|
|
package/dist/aform.d.ts
CHANGED
|
@@ -15,10 +15,11 @@ import ANumericInput from './components/form/ANumericInput.vue';
|
|
|
15
15
|
import type { App } from 'vue';
|
|
16
16
|
import ATextInput from './components/form/ATextInput.vue';
|
|
17
17
|
import type { ColumnSchema } from '@stonecrop/schema';
|
|
18
|
+
import type { FieldValidation } from '@stonecrop/schema';
|
|
19
|
+
import { InteractionMode } from '@stonecrop/schema';
|
|
18
20
|
import Login from './components/utilities/Login.vue';
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
21
|
-
import type { TableRow } from '@stonecrop/atable';
|
|
21
|
+
import type { TableViewConfig } from '@stonecrop/schema';
|
|
22
|
+
import type { ValueField } from '@stonecrop/schema';
|
|
22
23
|
|
|
23
24
|
export { ACheckbox }
|
|
24
25
|
|
|
@@ -64,6 +65,7 @@ export declare interface AFormLinkValue {
|
|
|
64
65
|
id: string | number;
|
|
65
66
|
/** Display text shown in the input. Falls back to `String(id)` if omitted. */
|
|
66
67
|
displayText?: string;
|
|
68
|
+
/** Additional properties passed through to the underlying input component */
|
|
67
69
|
[extra: string]: any;
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -71,39 +73,6 @@ export { ANumericInput }
|
|
|
71
73
|
|
|
72
74
|
export { ATextInput }
|
|
73
75
|
|
|
74
|
-
/**
|
|
75
|
-
* Basic field structure for AForm schemas
|
|
76
|
-
* @public
|
|
77
|
-
*/
|
|
78
|
-
export declare type BaseSchema = {
|
|
79
|
-
/**
|
|
80
|
-
* The fieldname for the schema field
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
fieldname: string;
|
|
84
|
-
/**
|
|
85
|
-
* The component to render
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* This must be a string that represents the component to render. The registration of the component
|
|
89
|
-
* should be done in the main application.
|
|
90
|
-
*
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
component?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Per-field rendering mode override; takes precedence over the AForm-level `mode` prop
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
|
-
mode?: FormMode;
|
|
99
|
-
/**
|
|
100
|
-
* Hide the field from the form UI while keeping it in the data model.
|
|
101
|
-
* Consumed by AForm — not passed down to field components.
|
|
102
|
-
* @public
|
|
103
|
-
*/
|
|
104
|
-
hidden?: boolean;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
76
|
/**
|
|
108
77
|
* Defined props for AForm components
|
|
109
78
|
* @public
|
|
@@ -113,7 +82,7 @@ export declare type ComponentProps = {
|
|
|
113
82
|
* The schema object to pass to the component
|
|
114
83
|
* @public
|
|
115
84
|
*/
|
|
116
|
-
schema?:
|
|
85
|
+
schema?: ResolvedField;
|
|
117
86
|
/**
|
|
118
87
|
* The label to display in the component
|
|
119
88
|
* @public
|
|
@@ -137,7 +106,7 @@ export declare type ComponentProps = {
|
|
|
137
106
|
* The rendering mode for the component
|
|
138
107
|
* @public
|
|
139
108
|
*/
|
|
140
|
-
mode?:
|
|
109
|
+
mode?: InteractionMode;
|
|
141
110
|
/**
|
|
142
111
|
* Set a unique identifier for elements inside the component
|
|
143
112
|
* @public
|
|
@@ -174,127 +143,116 @@ export declare type ComponentProps = {
|
|
|
174
143
|
export declare function deserializeFunction<T extends (...args: any[]) => any>(source: string): T;
|
|
175
144
|
|
|
176
145
|
/**
|
|
177
|
-
*
|
|
146
|
+
* Install all AForm components
|
|
147
|
+
* @param app - Vue app instance
|
|
178
148
|
* @public
|
|
179
149
|
*/
|
|
180
|
-
export declare
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
label?: string;
|
|
186
|
-
/**
|
|
187
|
-
* The schemas to be rendered inside the fieldset
|
|
188
|
-
* @public
|
|
189
|
-
*/
|
|
190
|
-
schema?: SchemaTypes[];
|
|
191
|
-
/**
|
|
192
|
-
* Indicate whether the fieldset is collapsible
|
|
193
|
-
* @public
|
|
194
|
-
*/
|
|
195
|
-
collapsible?: boolean;
|
|
196
|
-
};
|
|
150
|
+
export declare function install(app: App): void;
|
|
151
|
+
|
|
152
|
+
export { InteractionMode }
|
|
153
|
+
|
|
154
|
+
export { Login }
|
|
197
155
|
|
|
198
156
|
/**
|
|
199
|
-
* The
|
|
157
|
+
* The discriminated union of all resolved field types — what AForm consumes
|
|
158
|
+
* after `resolveSchema()` has transformed the authoring `DoctypeField[]`.
|
|
159
|
+
* Narrowed by `kind`: `'field'` | `'link'` | `'table'` | `'fieldset'`.
|
|
200
160
|
* @public
|
|
201
161
|
*/
|
|
202
|
-
export declare type
|
|
162
|
+
export declare type ResolvedField = ResolvedScalar | ResolvedLink | ResolvedTable | ResolvedFieldset;
|
|
203
163
|
|
|
204
164
|
/**
|
|
205
|
-
*
|
|
165
|
+
* A resolved fieldset — groups child fields inside an AFieldset component.
|
|
206
166
|
* @public
|
|
207
167
|
*/
|
|
208
|
-
export declare
|
|
209
|
-
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @beta
|
|
217
|
-
*/
|
|
218
|
-
edit?: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* The field type for the schema field
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
fieldtype?: string;
|
|
224
|
-
/**
|
|
225
|
-
* The label to display in the form
|
|
226
|
-
* @public
|
|
227
|
-
*/
|
|
168
|
+
export declare interface ResolvedFieldset {
|
|
169
|
+
/** Discriminator */
|
|
170
|
+
kind: 'fieldset';
|
|
171
|
+
/** Field identifier */
|
|
172
|
+
fieldname: string;
|
|
173
|
+
/** Component to render; defaults to `'AFieldset'` */
|
|
174
|
+
component?: string;
|
|
175
|
+
/** Human-readable label for the legend */
|
|
228
176
|
label?: string;
|
|
229
|
-
/**
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
* Applied as `flex-basis` and `width` on the rendered component element.
|
|
237
|
-
* Use `"100%"` to make the field span the full form row.
|
|
238
|
-
*/
|
|
239
|
-
width?: string;
|
|
240
|
-
/**
|
|
241
|
-
* The mask to apply to the field. Accepts either a plain mask string
|
|
242
|
-
* (e.g. `"##/##/####"`) or a stringified arrow function that receives `locale`
|
|
243
|
-
* and returns a mask string
|
|
244
|
-
* (e.g. `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`).
|
|
245
|
-
* @public
|
|
246
|
-
*/
|
|
247
|
-
mask?: string;
|
|
248
|
-
};
|
|
177
|
+
/** Whether the fieldset can be collapsed */
|
|
178
|
+
collapsible?: boolean;
|
|
179
|
+
/** Interaction mode for all children */
|
|
180
|
+
mode?: InteractionMode;
|
|
181
|
+
/** Resolved child fields */
|
|
182
|
+
schema: ResolvedField[];
|
|
183
|
+
}
|
|
249
184
|
|
|
250
185
|
/**
|
|
251
|
-
*
|
|
252
|
-
* @param app - Vue app instance
|
|
186
|
+
* A resolved Link field with cardinality `one` or `atMostOne` — embedded as a nested form.
|
|
253
187
|
* @public
|
|
254
188
|
*/
|
|
255
|
-
export declare
|
|
256
|
-
|
|
257
|
-
|
|
189
|
+
export declare interface ResolvedLink {
|
|
190
|
+
/** Discriminator */
|
|
191
|
+
kind: 'link';
|
|
192
|
+
/** Field identifier */
|
|
193
|
+
fieldname: string;
|
|
194
|
+
/** Component to render; defaults to `'AForm'` */
|
|
195
|
+
component: string;
|
|
196
|
+
/** Human-readable label */
|
|
197
|
+
label?: string;
|
|
198
|
+
/** Interaction mode */
|
|
199
|
+
mode?: InteractionMode;
|
|
200
|
+
/** Resolved child fields */
|
|
201
|
+
schema: ResolvedField[];
|
|
202
|
+
/** Preserved from the original ValueField */
|
|
203
|
+
required?: boolean;
|
|
204
|
+
/** Preserved from the original ValueField */
|
|
205
|
+
readOnly?: boolean;
|
|
206
|
+
/** Preserved from the original ValueField */
|
|
207
|
+
hidden?: boolean;
|
|
208
|
+
/** Preserved from the original ValueField */
|
|
209
|
+
default?: unknown;
|
|
210
|
+
/** Preserved from the original ValueField */
|
|
211
|
+
validation?: FieldValidation;
|
|
212
|
+
}
|
|
258
213
|
|
|
259
214
|
/**
|
|
260
|
-
*
|
|
215
|
+
* A resolved scalar field. Derived from ValueField with `cardinality` omitted
|
|
216
|
+
* (consumed by resolveSchema) and an optional `doctype` added for unresolved Link fields.
|
|
261
217
|
* @public
|
|
262
218
|
*/
|
|
263
|
-
export declare type
|
|
219
|
+
export declare type ResolvedScalar = Omit<ValueField, 'cardinality'> & {
|
|
220
|
+
/** Doctype slug for unresolved Link fields — added by resolveSchema when AFormLink is available */
|
|
221
|
+
doctype?: string;
|
|
222
|
+
};
|
|
264
223
|
|
|
265
224
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
* - **Columns-based** (no `kind`): caller provides `columns` directly
|
|
270
|
-
* - **Schema-delegated** (`kind: 'table'`): caller provides `schema`; ATable runs
|
|
271
|
-
* `schemaToColumns` to derive columns at render time
|
|
272
|
-
*
|
|
225
|
+
* A resolved table — either from a Link with `noneOrMany`/`atLeastOne` cardinality,
|
|
226
|
+
* or from an inline TableField. ATable receives columns via `:schema` (ColumnSchema[])
|
|
227
|
+
* and row data via `:rows` from formData at render time.
|
|
273
228
|
* @public
|
|
274
229
|
*/
|
|
275
|
-
export declare
|
|
276
|
-
/**
|
|
277
|
-
* The configuration for the table
|
|
278
|
-
* @public
|
|
279
|
-
*/
|
|
280
|
-
config?: TableConfig;
|
|
281
|
-
/**
|
|
282
|
-
* The rows to display in the table
|
|
283
|
-
* @public
|
|
284
|
-
*/
|
|
285
|
-
rows?: TableRow[];
|
|
286
|
-
} & ({
|
|
287
|
-
/** Explicit column definitions; `schema` and `kind` must not be set */
|
|
288
|
-
columns?: TableColumn[];
|
|
289
|
-
kind?: never;
|
|
290
|
-
schema?: never;
|
|
291
|
-
} | {
|
|
292
|
-
/** Marks this entry as schema-delegated; ATable derives columns from `schema` */
|
|
230
|
+
export declare interface ResolvedTable {
|
|
231
|
+
/** Discriminator */
|
|
293
232
|
kind: 'table';
|
|
294
|
-
/**
|
|
233
|
+
/** Field identifier */
|
|
234
|
+
fieldname: string;
|
|
235
|
+
/** Component to render; defaults to `'ATable'` */
|
|
236
|
+
component: string;
|
|
237
|
+
/** Human-readable label */
|
|
238
|
+
label?: string;
|
|
239
|
+
/** Interaction mode for all cells */
|
|
240
|
+
mode?: InteractionMode;
|
|
241
|
+
/** Column definitions — passed to ATable's `:schema` prop */
|
|
295
242
|
schema: ColumnSchema[];
|
|
296
|
-
|
|
297
|
-
|
|
243
|
+
/** View configuration — always present; defaults to `{ view: 'list' }` */
|
|
244
|
+
config: TableViewConfig;
|
|
245
|
+
/** Preserved from the original ValueField or TableField */
|
|
246
|
+
required?: boolean;
|
|
247
|
+
/** Preserved from the original ValueField or TableField */
|
|
248
|
+
readOnly?: boolean;
|
|
249
|
+
/** Preserved from the original ValueField or TableField */
|
|
250
|
+
hidden?: boolean;
|
|
251
|
+
/** Preserved from the original ValueField or TableField */
|
|
252
|
+
default?: unknown;
|
|
253
|
+
/** Preserved from the original ValueField or TableField */
|
|
254
|
+
validation?: FieldValidation;
|
|
255
|
+
}
|
|
298
256
|
|
|
299
257
|
|
|
300
258
|
export * from "@stonecrop/atable/types";
|