@stonecrop/aform 0.24.0 → 0.26.0
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 +28 -0
- package/dist/aform.js +274 -262
- package/dist/aform.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/types/index.d.ts +5 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/utils/columns.d.ts +24 -0
- package/dist/src/utils/columns.d.ts.map +1 -0
- package/dist/src/utils/columns.js +33 -0
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/types/index.ts +12 -1
- package/src/utils/columns.ts +38 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type * from '@stonecrop/atable/types';
|
|
2
2
|
export { deserializeFunction } from './utils/deserialize';
|
|
3
3
|
export { badgeInputAccentStyle, resolveFieldBadge } from './utils/badge';
|
|
4
|
+
export { resolvedFieldsToColumns } from './utils/columns';
|
|
4
5
|
export type { BadgeFormatContext, BadgeFormatFn } from './utils/badge';
|
|
5
6
|
import type { App } from 'vue';
|
|
6
7
|
import ACheckbox from './components/form/ACheckbox.vue';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,yBAAyB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACxE,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAEtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B,OAAO,SAAS,MAAM,iCAAiC,CAAA;AACvD,OAAO,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AAK,EACL,SAAS,EACT,MAAM,EACN,WAAW,EACX,UAAU,EACV,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,SAAS,EACT,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,UAAU,EACV,aAAa,EACb,KAAK,EACL,YAAY,EACZ,OAAO,GACP,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { deserializeFunction } from './utils/deserialize';
|
|
2
2
|
export { badgeInputAccentStyle, resolveFieldBadge } from './utils/badge';
|
|
3
|
+
export { resolvedFieldsToColumns } from './utils/columns';
|
|
3
4
|
import { install as installATable } from '@stonecrop/atable';
|
|
4
5
|
import ACheckbox from './components/form/ACheckbox.vue';
|
|
5
6
|
import ACurrencyInput from './components/form/ACurrencyInput.vue';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ColumnSchema, FieldValidation, TableViewConfig, ValueField } from '@stonecrop/schema';
|
|
1
|
+
import type { ColumnSchema, FieldValidation, GetRecordsOptions, GetRecordsResult, TableViewConfig, ValueField } from '@stonecrop/schema';
|
|
2
2
|
/**
|
|
3
3
|
* Controls the level of user interaction for a field, container, or table.
|
|
4
4
|
* `'edit'` — interactive; `'read'` — non-interactive with form chrome;
|
|
@@ -82,6 +82,10 @@ export interface ResolvedTable {
|
|
|
82
82
|
default?: unknown;
|
|
83
83
|
/** Preserved from the original ValueField or TableField */
|
|
84
84
|
validation?: FieldValidation;
|
|
85
|
+
/** When set, ATable fetches list pages through this callback (server paging). */
|
|
86
|
+
getRecords?: (options?: GetRecordsOptions) => Promise<GetRecordsResult>;
|
|
87
|
+
/** When this changes, ATable refetches from offset 0. */
|
|
88
|
+
sourceKey?: string;
|
|
85
89
|
}
|
|
86
90
|
/**
|
|
87
91
|
* A resolved fieldset — groups child fields inside an AFieldset component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,MAAM,mBAAmB,CAAA;AAM1B;;;;;GAKG;AACH,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAkBxD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG;IAC9D,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAA;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,IAAI,CAAC,EAAE,OAAO,mBAAmB,EAAE,eAAe,CAAA;IAClD,4BAA4B;IAC5B,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,aAAa;IAC7B,oBAAoB;IACpB,IAAI,EAAE,OAAO,CAAA;IACb,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,kDAAkD;IAClD,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AAA;IAChB,kFAAkF;IAClF,gBAAgB,EAAE,MAAM,CAAA;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,wGAAwG;IACxG,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC1C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC7B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,wEAAwE;IACxE,QAAQ,EAAE,cAAc,CAAA;IACxB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAA;IAClB,4DAA4D;IAC5D,YAAY,EAAE,cAAc,CAAA;IAC5B,6FAA6F;IAC7F,YAAY,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,gJAAgJ;IAChJ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wHAAwH;IACxH,YAAY,CAAC,EAAE,cAAc,GAAG,MAAM,CAAA;IACtC,+GAA+G;IAC/G,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,yXAAyX;IACzX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sGAAsG;IACtG,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IAC5F,+FAA+F;IAC/F,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ColumnSchema } from '@stonecrop/schema';
|
|
2
|
+
import type { ResolvedField } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* The resolved fields that can be columns in a list or table view, in declaration order.
|
|
5
|
+
*
|
|
6
|
+
* A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are
|
|
7
|
+
* containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`
|
|
8
|
+
* and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a
|
|
9
|
+
* container reaching `ACell` falls through to plain-text rendering and stringifies its children —
|
|
10
|
+
* no error and no log, just a wrong column.
|
|
11
|
+
*
|
|
12
|
+
* A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is
|
|
13
|
+
* the same silent defect in the other direction.
|
|
14
|
+
*
|
|
15
|
+
* One definition, called by both consumers: `Registry.buildTableConfig` (a child table's columns,
|
|
16
|
+
* from its target's resolved schema) and Desktop's records list. Re-deriving it at either call
|
|
17
|
+
* site produced exactly one of the two failures above at each.
|
|
18
|
+
*
|
|
19
|
+
* @param fields - resolved fields, as produced by `resolveSchema`
|
|
20
|
+
* @returns column definitions, with the `kind` discriminator stripped
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvedFieldsToColumns(fields: readonly ResolvedField[]): ColumnSchema[];
|
|
24
|
+
//# sourceMappingURL=columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../../src/utils/columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,YAAY,EAAE,CAaxF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resolved fields that can be columns in a list or table view, in declaration order.
|
|
3
|
+
*
|
|
4
|
+
* A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are
|
|
5
|
+
* containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`
|
|
6
|
+
* and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a
|
|
7
|
+
* container reaching `ACell` falls through to plain-text rendering and stringifies its children —
|
|
8
|
+
* no error and no log, just a wrong column.
|
|
9
|
+
*
|
|
10
|
+
* A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is
|
|
11
|
+
* the same silent defect in the other direction.
|
|
12
|
+
*
|
|
13
|
+
* One definition, called by both consumers: `Registry.buildTableConfig` (a child table's columns,
|
|
14
|
+
* from its target's resolved schema) and Desktop's records list. Re-deriving it at either call
|
|
15
|
+
* site produced exactly one of the two failures above at each.
|
|
16
|
+
*
|
|
17
|
+
* @param fields - resolved fields, as produced by `resolveSchema`
|
|
18
|
+
* @returns column definitions, with the `kind` discriminator stripped
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export function resolvedFieldsToColumns(fields) {
|
|
22
|
+
const columns = [];
|
|
23
|
+
for (const field of fields) {
|
|
24
|
+
if (field.kind === 'fieldset') {
|
|
25
|
+
columns.push(...resolvedFieldsToColumns(field.schema));
|
|
26
|
+
}
|
|
27
|
+
else if (field.kind === 'field') {
|
|
28
|
+
const { kind: _kind, ...column } = field;
|
|
29
|
+
columns.push(column);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return columns;
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/aform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Schema-driven form components for Stonecrop",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/agritheory/stonecrop/issues"
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@vueuse/components": "^14.2.1",
|
|
37
37
|
"@vueuse/core": "^14.2.1",
|
|
38
|
-
"@stonecrop/
|
|
39
|
-
"@stonecrop/
|
|
40
|
-
"@stonecrop/
|
|
41
|
-
"@stonecrop/
|
|
38
|
+
"@stonecrop/atable": "0.26.0",
|
|
39
|
+
"@stonecrop/schema": "0.26.0",
|
|
40
|
+
"@stonecrop/themes": "0.26.0",
|
|
41
|
+
"@stonecrop/utilities": "0.26.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@microsoft/api-documenter": "^7.30.5",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type * from '@stonecrop/atable/types'
|
|
2
2
|
export { deserializeFunction } from './utils/deserialize'
|
|
3
3
|
export { badgeInputAccentStyle, resolveFieldBadge } from './utils/badge'
|
|
4
|
+
export { resolvedFieldsToColumns } from './utils/columns'
|
|
4
5
|
export type { BadgeFormatContext, BadgeFormatFn } from './utils/badge'
|
|
5
6
|
import { install as installATable } from '@stonecrop/atable'
|
|
6
7
|
import type { App } from 'vue'
|
package/src/types/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ColumnSchema,
|
|
3
|
+
FieldValidation,
|
|
4
|
+
GetRecordsOptions,
|
|
5
|
+
GetRecordsResult,
|
|
6
|
+
TableViewConfig,
|
|
7
|
+
ValueField,
|
|
8
|
+
} from '@stonecrop/schema'
|
|
2
9
|
|
|
3
10
|
// ---------------------------------------------------------------------------
|
|
4
11
|
// InteractionMode — canonical home is @stonecrop/schema
|
|
@@ -106,6 +113,10 @@ export interface ResolvedTable {
|
|
|
106
113
|
default?: unknown
|
|
107
114
|
/** Preserved from the original ValueField or TableField */
|
|
108
115
|
validation?: FieldValidation
|
|
116
|
+
/** When set, ATable fetches list pages through this callback (server paging). */
|
|
117
|
+
getRecords?: (options?: GetRecordsOptions) => Promise<GetRecordsResult>
|
|
118
|
+
/** When this changes, ATable refetches from offset 0. */
|
|
119
|
+
sourceKey?: string
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
/**
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ColumnSchema } from '@stonecrop/schema'
|
|
2
|
+
|
|
3
|
+
import type { ResolvedField } from '../types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The resolved fields that can be columns in a list or table view, in declaration order.
|
|
7
|
+
*
|
|
8
|
+
* A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are
|
|
9
|
+
* containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`
|
|
10
|
+
* and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a
|
|
11
|
+
* container reaching `ACell` falls through to plain-text rendering and stringifies its children —
|
|
12
|
+
* no error and no log, just a wrong column.
|
|
13
|
+
*
|
|
14
|
+
* A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is
|
|
15
|
+
* the same silent defect in the other direction.
|
|
16
|
+
*
|
|
17
|
+
* One definition, called by both consumers: `Registry.buildTableConfig` (a child table's columns,
|
|
18
|
+
* from its target's resolved schema) and Desktop's records list. Re-deriving it at either call
|
|
19
|
+
* site produced exactly one of the two failures above at each.
|
|
20
|
+
*
|
|
21
|
+
* @param fields - resolved fields, as produced by `resolveSchema`
|
|
22
|
+
* @returns column definitions, with the `kind` discriminator stripped
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export function resolvedFieldsToColumns(fields: readonly ResolvedField[]): ColumnSchema[] {
|
|
26
|
+
const columns: ColumnSchema[] = []
|
|
27
|
+
|
|
28
|
+
for (const field of fields) {
|
|
29
|
+
if (field.kind === 'fieldset') {
|
|
30
|
+
columns.push(...resolvedFieldsToColumns(field.schema))
|
|
31
|
+
} else if (field.kind === 'field') {
|
|
32
|
+
const { kind: _kind, ...column } = field
|
|
33
|
+
columns.push(column)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return columns
|
|
38
|
+
}
|