@stonecrop/aform 0.10.11 → 0.10.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.
package/dist/aform.d.ts CHANGED
@@ -114,12 +114,72 @@ export declare type ComponentProps = {
114
114
  };
115
115
 
116
116
  /**
117
- * Schema structure for defining nested doctype fields inside AForm
117
+ * Schema structure for a 1:many child table field inside AForm
118
118
  *
119
119
  * @remarks
120
- * When a field has `fieldtype: 'Doctype'`, the `options` property contains the slug
121
- * of the referenced doctype. The `schema` property is populated by the framework's
122
- * `registry.resolveSchema()` method with the resolved child schema fields.
120
+ * When a field has `fieldtype: 'Doctype'` with `cardinality: 'many'`, it represents
121
+ * a 1:many child table. The `options` property contains the slug of the child doctype
122
+ * whose records appear as table rows.
123
+ *
124
+ * `Registry.resolveSchema()` auto-derives `columns` from the child doctype's schema
125
+ * fields and sets sensible defaults for `component` (`'ATable'`) and `config` (`{ view: 'list' }`).
126
+ *
127
+ * Users can override any auto-derived property by specifying it explicitly on the schema field.
128
+ * Row data comes from the parent form's data model at `data[fieldname]` (an array).
129
+ *
130
+ * @public
131
+ */
132
+ export declare type DoctypeManySchema = BaseSchema & {
133
+ /**
134
+ * The field type - must be 'Doctype' for nested doctype fields
135
+ * @public
136
+ */
137
+ fieldtype: 'Doctype';
138
+ /**
139
+ * The slug of the child doctype in the registry
140
+ * @public
141
+ */
142
+ options: string;
143
+ /**
144
+ * The label to display above the table section
145
+ * @public
146
+ */
147
+ label?: string;
148
+ /**
149
+ * The cardinality of the relationship — `'many'` means 1:many child table
150
+ * @public
151
+ */
152
+ cardinality: 'many';
153
+ /**
154
+ * Table columns — auto-derived from child doctype schema if not provided
155
+ * @public
156
+ */
157
+ columns?: TableColumn[];
158
+ /**
159
+ * Table configuration — defaults to `{ view: 'list' }` if not provided
160
+ * @public
161
+ */
162
+ config?: TableConfig;
163
+ /**
164
+ * Table rows — populated from the parent form's data model at `data[fieldname]`
165
+ * @public
166
+ */
167
+ rows?: TableRow[];
168
+ /**
169
+ * The component to render — defaults to `'ATable'` when resolved
170
+ * @public
171
+ */
172
+ component?: string;
173
+ };
174
+
175
+ /**
176
+ * Schema structure for a 1:1 nested doctype field inside AForm
177
+ *
178
+ * @remarks
179
+ * When a field has `fieldtype: 'Doctype'` without `cardinality: 'many'`, it represents
180
+ * a 1:1 nested form. The `options` property contains the slug of the referenced doctype.
181
+ * The `schema` property is populated by the framework's `registry.resolveSchema()` method
182
+ * with the resolved child schema fields.
123
183
  *
124
184
  * Before resolution: `{ fieldname: 'address', fieldtype: 'Doctype', options: 'address' }`
125
185
  * After resolution: `{ fieldname: 'address', fieldtype: 'Doctype', options: 'address', schema: [...resolved fields...] }`
@@ -128,7 +188,7 @@ export declare type ComponentProps = {
128
188
  *
129
189
  * @public
130
190
  */
131
- export declare type DoctypeSchema = BaseSchema & {
191
+ export declare type DoctypeOneSchema = BaseSchema & {
132
192
  /**
133
193
  * The field type - must be 'Doctype' for nested doctype fields
134
194
  * @public
@@ -144,6 +204,11 @@ export declare type DoctypeSchema = BaseSchema & {
144
204
  * @public
145
205
  */
146
206
  label?: string;
207
+ /**
208
+ * The cardinality of the relationship — `'one'` or omitted means 1:1 nested form
209
+ * @public
210
+ */
211
+ cardinality?: 'one';
147
212
  /**
148
213
  * The resolved child schema fields, populated by `registry.resolveSchema()`
149
214
  * or provided manually for standalone usage
@@ -152,6 +217,17 @@ export declare type DoctypeSchema = BaseSchema & {
152
217
  schema?: SchemaTypes[];
153
218
  };
154
219
 
220
+ /**
221
+ * Discriminated union for Doctype fields — either 1:1 nested form or 1:many child table
222
+ *
223
+ * @remarks
224
+ * Use `isDoctypeMany()` type guard to narrow to `DoctypeManySchema`.
225
+ * When `cardinality` is `'many'` or omitted, the field is a 1:1 nested form.
226
+ *
227
+ * @public
228
+ */
229
+ export declare type DoctypeSchema = DoctypeOneSchema | DoctypeManySchema;
230
+
155
231
  /**
156
232
  * Schema structure for defining fieldsets inside AForm
157
233
  * @public
@@ -232,61 +308,22 @@ export declare type FormSchema = BaseSchema & {
232
308
  */
233
309
  export declare function install(app: App): void;
234
310
 
235
- export { Login }
236
-
237
311
  /**
238
- * Superset of all schema types for AForm
312
+ * Type guard that checks whether a Doctype schema field has `cardinality: 'many'`
313
+ *
314
+ * @param field - A DoctypeSchema field to check
315
+ * @returns `true` if the field has `cardinality: 'many'`
239
316
  * @public
240
317
  */
241
- export declare type SchemaTypes = FormSchema | TableSchema | FieldsetSchema | DoctypeSchema | TableDoctypeSchema;
318
+ export declare function isDoctypeMany(field: DoctypeSchema): field is DoctypeManySchema;
319
+
320
+ export { Login }
242
321
 
243
322
  /**
244
- * Schema structure for defining 1:many child table fields inside AForm
245
- *
246
- * @remarks
247
- * When a field has `fieldtype: 'Table'`, the `options` property contains the slug
248
- * of the child doctype whose records appear as table rows.
249
- *
250
- * `Registry.resolveSchema()` auto-derives `columns` from the child doctype's schema
251
- * fields and sets sensible defaults for `component` (`'ATable'`) and `config` (`{ view: 'list' }`).
252
- *
253
- * Users can override any auto-derived property by specifying it explicitly on the schema field.
254
- * Row data comes from the parent form's data model at `data[fieldname]` (an array).
255
- *
323
+ * Superset of all schema types for AForm
256
324
  * @public
257
325
  */
258
- export declare type TableDoctypeSchema = BaseSchema & {
259
- /**
260
- * The field type — must be 'Table' for 1:many child table fields
261
- * @public
262
- */
263
- fieldtype: 'Table';
264
- /**
265
- * The slug of the child doctype in the registry
266
- * @public
267
- */
268
- options: string;
269
- /**
270
- * The label to display above the table section
271
- * @public
272
- */
273
- label?: string;
274
- /**
275
- * Table columns — auto-derived from child doctype schema if not provided
276
- * @public
277
- */
278
- columns?: TableColumn[];
279
- /**
280
- * Table configuration — defaults to `{ view: 'list' }` if not provided
281
- * @public
282
- */
283
- config?: TableConfig;
284
- /**
285
- * Table rows — populated from the parent form's data model at `data[fieldname]`
286
- * @public
287
- */
288
- rows?: TableRow[];
289
- };
326
+ export declare type SchemaTypes = FormSchema | TableSchema | FieldsetSchema | DoctypeSchema;
290
327
 
291
328
  /**
292
329
  * Schema structure for defining tables inside AForm
package/dist/aform.js CHANGED
@@ -3836,7 +3836,10 @@ const ms = { class: "aform_form-element" }, hs = { class: "aform_display-value"
3836
3836
  }
3837
3837
  }), Ps = /* @__PURE__ */ Te(Hs, [["__scopeId", "data-v-d9ffd0a7"]]);
3838
3838
  function Os(e) {
3839
- e.use(Tl), e.component("ACheckbox", Ol), e.component("ACombobox", Bl), e.component("ADate", Gl), e.component("ADropdown", fa), e.component("ADatePicker", Fa), e.component("AFieldset", Ya), e.component("AFileAttach", ns), e.component("AForm", In), e.component("ANumericInput", us), e.component("ATextInput", xs);
3839
+ return e.cardinality === "many";
3840
+ }
3841
+ function Bs(e) {
3842
+ e.use(Tl), e.component("ACheckbox", Ol), e.component("AComboBox", Bl), e.component("ADate", Gl), e.component("ADropdown", fa), e.component("ADatePicker", Fa), e.component("AFieldset", Ya), e.component("AFileAttach", ns), e.component("AForm", In), e.component("ANumericInput", us), e.component("ATextInput", xs);
3840
3843
  }
3841
3844
  export {
3842
3845
  Ol as ACheckbox,
@@ -3850,6 +3853,7 @@ export {
3850
3853
  us as ANumericInput,
3851
3854
  xs as ATextInput,
3852
3855
  Ps as Login,
3853
- Os as install
3856
+ Bs as install,
3857
+ Os as isDoctypeMany
3854
3858
  };
3855
3859
  //# sourceMappingURL=aform.js.map