@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/src/types/index.ts
CHANGED
|
@@ -1,11 +1,126 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ColumnSchema, FieldValidation, TableViewConfig, ValueField } from '@stonecrop/schema'
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// InteractionMode — canonical home is @stonecrop/schema
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Controls the level of user interaction for a field, container, or table.
|
|
9
|
+
* `'edit'` — interactive; `'read'` — non-interactive with form chrome;
|
|
10
|
+
* `'display'` — non-interactive plain-text rendering.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export type { InteractionMode } from '@stonecrop/schema'
|
|
14
|
+
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// ResolvedField — the output-space type that AForm consumes
|
|
17
|
+
// Produced by resolveSchema(); never authored directly.
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A resolved scalar field. Derived from ValueField with `cardinality` omitted
|
|
22
|
+
* (consumed by resolveSchema) and an optional `doctype` added for unresolved Link fields.
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export type ResolvedScalar = Omit<ValueField, 'cardinality'> & {
|
|
26
|
+
/** Doctype slug for unresolved Link fields — added by resolveSchema when AFormLink is available */
|
|
27
|
+
doctype?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A resolved Link field with cardinality `one` or `atMostOne` — embedded as a nested form.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface ResolvedLink {
|
|
35
|
+
/** Discriminator */
|
|
36
|
+
kind: 'link'
|
|
37
|
+
/** Field identifier */
|
|
38
|
+
fieldname: string
|
|
39
|
+
/** Component to render; defaults to `'AForm'` */
|
|
40
|
+
component: string
|
|
41
|
+
/** Human-readable label */
|
|
42
|
+
label?: string
|
|
43
|
+
/** Interaction mode */
|
|
44
|
+
mode?: import('@stonecrop/schema').InteractionMode
|
|
45
|
+
/** Resolved child fields */
|
|
46
|
+
schema: ResolvedField[]
|
|
47
|
+
/** Preserved from the original ValueField */
|
|
48
|
+
required?: boolean
|
|
49
|
+
/** Preserved from the original ValueField */
|
|
50
|
+
readOnly?: boolean
|
|
51
|
+
/** Preserved from the original ValueField */
|
|
52
|
+
hidden?: boolean
|
|
53
|
+
/** Preserved from the original ValueField */
|
|
54
|
+
default?: unknown
|
|
55
|
+
/** Preserved from the original ValueField */
|
|
56
|
+
validation?: FieldValidation
|
|
57
|
+
}
|
|
3
58
|
|
|
4
59
|
/**
|
|
5
|
-
*
|
|
60
|
+
* A resolved table — either from a Link with `noneOrMany`/`atLeastOne` cardinality,
|
|
61
|
+
* or from an inline TableField. ATable receives columns via `:schema` (ColumnSchema[])
|
|
62
|
+
* and row data via `:rows` from formData at render time.
|
|
6
63
|
* @public
|
|
7
64
|
*/
|
|
8
|
-
export
|
|
65
|
+
export interface ResolvedTable {
|
|
66
|
+
/** Discriminator */
|
|
67
|
+
kind: 'table'
|
|
68
|
+
/** Field identifier */
|
|
69
|
+
fieldname: string
|
|
70
|
+
/** Component to render; defaults to `'ATable'` */
|
|
71
|
+
component: string
|
|
72
|
+
/** Human-readable label */
|
|
73
|
+
label?: string
|
|
74
|
+
/** Interaction mode for all cells */
|
|
75
|
+
mode?: import('@stonecrop/schema').InteractionMode
|
|
76
|
+
/** Column definitions — passed to ATable's `:schema` prop */
|
|
77
|
+
schema: ColumnSchema[]
|
|
78
|
+
/** View configuration — always present; defaults to `{ view: 'list' }` */
|
|
79
|
+
config: TableViewConfig
|
|
80
|
+
/** Preserved from the original ValueField or TableField */
|
|
81
|
+
required?: boolean
|
|
82
|
+
/** Preserved from the original ValueField or TableField */
|
|
83
|
+
readOnly?: boolean
|
|
84
|
+
/** Preserved from the original ValueField or TableField */
|
|
85
|
+
hidden?: boolean
|
|
86
|
+
/** Preserved from the original ValueField or TableField */
|
|
87
|
+
default?: unknown
|
|
88
|
+
/** Preserved from the original ValueField or TableField */
|
|
89
|
+
validation?: FieldValidation
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A resolved fieldset — groups child fields inside an AFieldset component.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export interface ResolvedFieldset {
|
|
97
|
+
/** Discriminator */
|
|
98
|
+
kind: 'fieldset'
|
|
99
|
+
/** Field identifier */
|
|
100
|
+
fieldname: string
|
|
101
|
+
/** Component to render; defaults to `'AFieldset'` */
|
|
102
|
+
component?: string
|
|
103
|
+
/** Human-readable label for the legend */
|
|
104
|
+
label?: string
|
|
105
|
+
/** Whether the fieldset can be collapsed */
|
|
106
|
+
collapsible?: boolean
|
|
107
|
+
/** Interaction mode for all children */
|
|
108
|
+
mode?: import('@stonecrop/schema').InteractionMode
|
|
109
|
+
/** Resolved child fields */
|
|
110
|
+
schema: ResolvedField[]
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The discriminated union of all resolved field types — what AForm consumes
|
|
115
|
+
* after `resolveSchema()` has transformed the authoring `DoctypeField[]`.
|
|
116
|
+
* Narrowed by `kind`: `'field'` | `'link'` | `'table'` | `'fieldset'`.
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export type ResolvedField = ResolvedScalar | ResolvedLink | ResolvedTable | ResolvedFieldset
|
|
120
|
+
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
// Utility types
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
9
124
|
|
|
10
125
|
/**
|
|
11
126
|
* Defined props for AForm components
|
|
@@ -16,7 +131,7 @@ export type ComponentProps = {
|
|
|
16
131
|
* The schema object to pass to the component
|
|
17
132
|
* @public
|
|
18
133
|
*/
|
|
19
|
-
schema?:
|
|
134
|
+
schema?: ResolvedField
|
|
20
135
|
|
|
21
136
|
/**
|
|
22
137
|
* The label to display in the component
|
|
@@ -46,7 +161,7 @@ export type ComponentProps = {
|
|
|
46
161
|
* The rendering mode for the component
|
|
47
162
|
* @public
|
|
48
163
|
*/
|
|
49
|
-
mode?:
|
|
164
|
+
mode?: import('@stonecrop/schema').InteractionMode
|
|
50
165
|
|
|
51
166
|
/**
|
|
52
167
|
* Set a unique identifier for elements inside the component
|
|
@@ -69,162 +184,6 @@ export type ComponentProps = {
|
|
|
69
184
|
}
|
|
70
185
|
}
|
|
71
186
|
|
|
72
|
-
/**
|
|
73
|
-
* Basic field structure for AForm schemas
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export type BaseSchema = {
|
|
77
|
-
/**
|
|
78
|
-
* The fieldname for the schema field
|
|
79
|
-
* @public
|
|
80
|
-
*/
|
|
81
|
-
fieldname: string
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The component to render
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* This must be a string that represents the component to render. The registration of the component
|
|
88
|
-
* should be done in the main application.
|
|
89
|
-
*
|
|
90
|
-
* @public
|
|
91
|
-
*/
|
|
92
|
-
component?: string
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Per-field rendering mode override; takes precedence over the AForm-level `mode` prop
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
|
-
mode?: FormMode
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Hide the field from the form UI while keeping it in the data model.
|
|
102
|
-
* Consumed by AForm — not passed down to field components.
|
|
103
|
-
* @public
|
|
104
|
-
*/
|
|
105
|
-
hidden?: boolean
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Schema structure for defining forms inside AForm
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
export type FormSchema = BaseSchema & {
|
|
113
|
-
/**
|
|
114
|
-
* Align the field in the form
|
|
115
|
-
* @beta
|
|
116
|
-
*/
|
|
117
|
-
align?: CanvasTextAlign
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Indicate whether the field is editable
|
|
121
|
-
* @beta
|
|
122
|
-
*/
|
|
123
|
-
edit?: boolean
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* The field type for the schema field
|
|
127
|
-
* @public
|
|
128
|
-
*/
|
|
129
|
-
fieldtype?: string
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The label to display in the form
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
135
|
-
label?: string
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* The unique identifier for the field
|
|
139
|
-
* @beta
|
|
140
|
-
*/
|
|
141
|
-
name?: string
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* CSS width for the field's flex item in the AForm grid.
|
|
145
|
-
* Applied as `flex-basis` and `width` on the rendered component element.
|
|
146
|
-
* Use `"100%"` to make the field span the full form row.
|
|
147
|
-
*/
|
|
148
|
-
width?: string
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The mask to apply to the field. Accepts either a plain mask string
|
|
152
|
-
* (e.g. `"##/##/####"`) or a stringified arrow function that receives `locale`
|
|
153
|
-
* and returns a mask string
|
|
154
|
-
* (e.g. `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`).
|
|
155
|
-
* @public
|
|
156
|
-
*/
|
|
157
|
-
mask?: string
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Schema structure for defining tables inside AForm.
|
|
162
|
-
*
|
|
163
|
-
* Two mutually exclusive forms:
|
|
164
|
-
* - **Columns-based** (no `kind`): caller provides `columns` directly
|
|
165
|
-
* - **Schema-delegated** (`kind: 'table'`): caller provides `schema`; ATable runs
|
|
166
|
-
* `schemaToColumns` to derive columns at render time
|
|
167
|
-
*
|
|
168
|
-
* @public
|
|
169
|
-
*/
|
|
170
|
-
export type TableSchema = BaseSchema & {
|
|
171
|
-
/**
|
|
172
|
-
* The configuration for the table
|
|
173
|
-
* @public
|
|
174
|
-
*/
|
|
175
|
-
config?: TableConfig
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* The rows to display in the table
|
|
179
|
-
* @public
|
|
180
|
-
*/
|
|
181
|
-
rows?: TableRow[]
|
|
182
|
-
} & (
|
|
183
|
-
| {
|
|
184
|
-
/** Explicit column definitions; `schema` and `kind` must not be set */
|
|
185
|
-
columns?: TableColumn[]
|
|
186
|
-
kind?: never
|
|
187
|
-
schema?: never
|
|
188
|
-
}
|
|
189
|
-
| {
|
|
190
|
-
/** Marks this entry as schema-delegated; ATable derives columns from `schema` */
|
|
191
|
-
kind: 'table'
|
|
192
|
-
/** Child schema passed to ATable's `schema` prop */
|
|
193
|
-
schema: ColumnSchema[]
|
|
194
|
-
columns?: never
|
|
195
|
-
}
|
|
196
|
-
)
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Schema structure for defining fieldsets inside AForm
|
|
200
|
-
* @public
|
|
201
|
-
*/
|
|
202
|
-
export type FieldsetSchema = BaseSchema & {
|
|
203
|
-
/**
|
|
204
|
-
* The label to display in the fieldset
|
|
205
|
-
* @public
|
|
206
|
-
*/
|
|
207
|
-
label?: string
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* The schemas to be rendered inside the fieldset
|
|
211
|
-
* @public
|
|
212
|
-
*/
|
|
213
|
-
schema?: SchemaTypes[]
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Indicate whether the fieldset is collapsible
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
collapsible?: boolean
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Superset of all schema types for AForm
|
|
224
|
-
* @public
|
|
225
|
-
*/
|
|
226
|
-
export type SchemaTypes = FormSchema | TableSchema | FieldsetSchema
|
|
227
|
-
|
|
228
187
|
/**
|
|
229
188
|
* The value shape for AFormLink — a linked document reference with optional display text
|
|
230
189
|
* @public
|
|
@@ -234,6 +193,7 @@ export interface AFormLinkValue {
|
|
|
234
193
|
id: string | number
|
|
235
194
|
/** Display text shown in the input. Falls back to `String(id)` if omitted. */
|
|
236
195
|
displayText?: string
|
|
196
|
+
/** Additional properties passed through to the underlying input component */
|
|
237
197
|
[extra: string]: any
|
|
238
198
|
}
|
|
239
199
|
|