@stonecrop/aform 0.31.0 → 0.32.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.js +3024 -2256
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +1170 -1
- package/dist/src/components/AForm.vue.d.ts +20 -0
- package/dist/src/components/AForm.vue.d.ts.map +1 -0
- package/dist/src/components/AFormLoading.vue.d.ts +14 -0
- package/dist/src/components/AFormLoading.vue.d.ts.map +1 -0
- package/dist/src/components/base/CollapseButton.vue.d.ts +7 -0
- package/dist/src/components/base/CollapseButton.vue.d.ts.map +1 -0
- package/dist/src/components/base/ExpandButton.vue.d.ts +7 -0
- package/dist/src/components/base/ExpandButton.vue.d.ts.map +1 -0
- package/dist/src/components/form/ABadge.vue.d.ts +14 -0
- package/dist/src/components/form/ABadge.vue.d.ts.map +1 -0
- package/dist/src/components/form/ACheckbox.vue.d.ts +15 -0
- package/dist/src/components/form/ACheckbox.vue.d.ts.map +1 -0
- package/dist/src/components/form/ACurrencyInput.vue.d.ts +20 -0
- package/dist/src/components/form/ACurrencyInput.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADate.vue.d.ts +14 -0
- package/dist/src/components/form/ADate.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADatePicker.vue.d.ts +28 -0
- package/dist/src/components/form/ADatePicker.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADateRange.vue.d.ts +18 -0
- package/dist/src/components/form/ADateRange.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADateSelection.vue.d.ts +52 -0
- package/dist/src/components/form/ADateSelection.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADateTime.vue.d.ts +17 -0
- package/dist/src/components/form/ADateTime.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADateTimeInput.vue.d.ts +30 -0
- package/dist/src/components/form/ADateTimeInput.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADropdown.vue.d.ts +20 -0
- package/dist/src/components/form/ADropdown.vue.d.ts.map +1 -0
- package/dist/src/components/form/ADuration.vue.d.ts +18 -0
- package/dist/src/components/form/ADuration.vue.d.ts.map +1 -0
- package/dist/src/components/form/AFieldset.vue.d.ts +28 -0
- package/dist/src/components/form/AFieldset.vue.d.ts.map +1 -0
- package/dist/src/components/form/AFileAttach.vue.d.ts +5 -0
- package/dist/src/components/form/AFileAttach.vue.d.ts.map +1 -0
- package/dist/src/components/form/AFormLink.vue.d.ts +40 -0
- package/dist/src/components/form/AFormLink.vue.d.ts.map +1 -0
- package/dist/src/components/form/ANumericInput.vue.d.ts +14 -0
- package/dist/src/components/form/ANumericInput.vue.d.ts.map +1 -0
- package/dist/src/components/form/AQuantityInput.vue.d.ts +20 -0
- package/dist/src/components/form/AQuantityInput.vue.d.ts.map +1 -0
- package/dist/src/components/form/ASegmentedControl.vue.d.ts +23 -0
- package/dist/src/components/form/ASegmentedControl.vue.d.ts.map +1 -0
- package/dist/src/components/form/ATextInput.vue.d.ts +14 -0
- package/dist/src/components/form/ATextInput.vue.d.ts.map +1 -0
- package/dist/src/components/form/ATextboxInput.vue.d.ts +21 -0
- package/dist/src/components/form/ATextboxInput.vue.d.ts.map +1 -0
- package/dist/src/components/utilities/Login.vue.d.ts +14 -0
- package/dist/src/components/utilities/Login.vue.d.ts.map +1 -0
- package/dist/{tsdoc-metadata.json → src/tsdoc-metadata.json} +1 -1
- package/package.json +35 -30
- package/dist/aform.d.ts +0 -441
- package/dist/aform.tsbuildinfo +0 -1
- package/dist/src/directives/mask.js +0 -107
- package/dist/src/index.js +0 -58
- package/dist/src/types/index.js +0 -0
- package/dist/src/utils/badge.js +0 -71
- package/dist/src/utils/columns.js +0 -33
- package/dist/src/utils/deserialize.js +0 -20
- package/src/components/AForm.vue +0 -314
- package/src/components/AFormLoading.vue +0 -76
- package/src/components/base/CollapseButton.vue +0 -36
- package/src/components/base/ExpandButton.vue +0 -34
- package/src/components/form/ABadge.vue +0 -135
- package/src/components/form/ACheckbox.vue +0 -62
- package/src/components/form/ACurrencyInput.vue +0 -357
- package/src/components/form/ADate.vue +0 -93
- package/src/components/form/ADatePicker.vue +0 -470
- package/src/components/form/ADateRange.vue +0 -133
- package/src/components/form/ADateSelection.vue +0 -174
- package/src/components/form/ADateTime.vue +0 -149
- package/src/components/form/ADateTimeInput.vue +0 -299
- package/src/components/form/ADropdown.vue +0 -222
- package/src/components/form/ADuration.vue +0 -124
- package/src/components/form/AFieldset.vue +0 -72
- package/src/components/form/AFileAttach.vue +0 -97
- package/src/components/form/AFormLink.vue +0 -368
- package/src/components/form/ANumericInput.vue +0 -32
- package/src/components/form/AQuantityInput.vue +0 -349
- package/src/components/form/ASegmentedControl.vue +0 -342
- package/src/components/form/ATextInput.vue +0 -40
- package/src/components/form/ATextboxInput.vue +0 -66
- package/src/components/utilities/Login.vue +0 -189
- package/src/directives/mask.ts +0 -122
- package/src/index.ts +0 -92
- package/src/shims-vue.d.ts +0 -5
- package/src/types/index.ts +0 -333
- package/src/utils/badge.ts +0 -94
- package/src/utils/columns.ts +0 -38
- package/src/utils/deserialize.ts +0 -20
package/package.json
CHANGED
|
@@ -1,48 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/aform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Schema-driven form components for Stonecrop",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"components",
|
|
7
|
+
"forms",
|
|
8
|
+
"schema",
|
|
9
|
+
"stonecrop",
|
|
10
|
+
"vue"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/agritheory/stonecrop#readme",
|
|
5
13
|
"bugs": {
|
|
6
14
|
"url": "https://github.com/agritheory/stonecrop/issues"
|
|
7
15
|
},
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "https://github.com/agritheory/stonecrop",
|
|
11
|
-
"directory": "aform"
|
|
12
|
-
},
|
|
13
16
|
"license": "MIT",
|
|
14
17
|
"author": {
|
|
15
18
|
"name": "Tyler Matteson",
|
|
16
19
|
"email": "tyler@agritheory.com"
|
|
17
20
|
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/agritheory/stonecrop",
|
|
24
|
+
"directory": "aform"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
18
30
|
"sideEffects": [
|
|
19
31
|
"**/*.css"
|
|
20
32
|
],
|
|
21
|
-
"
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
22
34
|
"exports": {
|
|
23
35
|
".": {
|
|
24
|
-
"types": "./dist/
|
|
36
|
+
"types": "./dist/src/index.d.ts",
|
|
25
37
|
"import": "./dist/aform.js"
|
|
26
38
|
},
|
|
27
39
|
"./styles": "./dist/assets/index.css",
|
|
28
|
-
"./types": "./dist/src/types/index.d.ts"
|
|
40
|
+
"./types": "./dist/src/types/index.d.ts",
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
29
45
|
},
|
|
30
|
-
"types": "./dist/aform.d.ts",
|
|
31
|
-
"files": [
|
|
32
|
-
"dist/*",
|
|
33
|
-
"src/*"
|
|
34
|
-
],
|
|
35
46
|
"dependencies": {
|
|
36
47
|
"@vueuse/components": "^14.2.1",
|
|
37
48
|
"@vueuse/core": "^14.2.1",
|
|
38
|
-
"@stonecrop/atable": "0.
|
|
39
|
-
"@stonecrop/schema": "0.
|
|
40
|
-
"@stonecrop/
|
|
41
|
-
"@stonecrop/
|
|
49
|
+
"@stonecrop/atable": "0.32.0",
|
|
50
|
+
"@stonecrop/schema": "0.32.0",
|
|
51
|
+
"@stonecrop/utilities": "0.32.0",
|
|
52
|
+
"@stonecrop/themes": "0.32.0"
|
|
42
53
|
},
|
|
43
54
|
"devDependencies": {
|
|
44
|
-
"@microsoft/api-
|
|
45
|
-
"@rushstack/heft": "^1.2.17",
|
|
55
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
46
56
|
"@types/node": "^24.12.4",
|
|
47
57
|
"@vitejs/plugin-vue": "^6.0.6",
|
|
48
58
|
"@vitest/coverage-istanbul": "^4.1.5",
|
|
@@ -53,13 +63,13 @@
|
|
|
53
63
|
"oxlint-tsgolint": "0.23.0",
|
|
54
64
|
"pinia": "^3.0.4",
|
|
55
65
|
"typescript": "^6.0.3",
|
|
56
|
-
"vite": "^
|
|
66
|
+
"vite": "^8.2.2",
|
|
57
67
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
58
68
|
"vitest": "^4.1.5",
|
|
59
69
|
"vue": "^3.5.33",
|
|
70
|
+
"vue-component-meta": "^3.3.11",
|
|
60
71
|
"vue-router": "^5.0.6",
|
|
61
|
-
"vue-tsc": "^3.3.6"
|
|
62
|
-
"stonecrop-rig": "0.7.0"
|
|
72
|
+
"vue-tsc": "^3.3.6"
|
|
63
73
|
},
|
|
64
74
|
"peerDependencies": {
|
|
65
75
|
"pinia": "^3.0.4",
|
|
@@ -68,14 +78,9 @@
|
|
|
68
78
|
"engines": {
|
|
69
79
|
"node": ">=24.0.0"
|
|
70
80
|
},
|
|
71
|
-
"publishConfig": {
|
|
72
|
-
"access": "public"
|
|
73
|
-
},
|
|
74
81
|
"scripts": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"dev": "vite",
|
|
78
|
-
"docs": "bash ../common/scripts/run-docs.sh aform",
|
|
82
|
+
"dev": "vite build --watch",
|
|
83
|
+
"docs": "bash ../tools/scripts/run-docs.sh aform",
|
|
79
84
|
"lint": "oxlint",
|
|
80
85
|
"lint:fix": "oxlint --fix",
|
|
81
86
|
"preview": "vite preview",
|
package/dist/aform.d.ts
DELETED
|
@@ -1,441 +0,0 @@
|
|
|
1
|
-
import ABadge from './components/form/ABadge.vue';
|
|
2
|
-
import ACheckbox from './components/form/ACheckbox.vue';
|
|
3
|
-
import ACurrencyInput from './components/form/ACurrencyInput.vue';
|
|
4
|
-
import ADate from './components/form/ADate.vue';
|
|
5
|
-
import ADatePicker from './components/form/ADatePicker.vue';
|
|
6
|
-
import ADateRange from './components/form/ADateRange.vue';
|
|
7
|
-
import ADateSelection from './components/form/ADateSelection.vue';
|
|
8
|
-
import ADateTime from './components/form/ADateTime.vue';
|
|
9
|
-
import ADateTimeInput from './components/form/ADateTimeInput.vue';
|
|
10
|
-
import ADropdown from './components/form/ADropdown.vue';
|
|
11
|
-
import ADuration from './components/form/ADuration.vue';
|
|
12
|
-
import AFieldset from './components/form/AFieldset.vue';
|
|
13
|
-
import AFileAttach from './components/form/AFileAttach.vue';
|
|
14
|
-
import AForm from './components/AForm.vue';
|
|
15
|
-
import AFormLink from './components/form/AFormLink.vue';
|
|
16
|
-
import AFormLoading from './components/AFormLoading.vue';
|
|
17
|
-
import ANumericInput from './components/form/ANumericInput.vue';
|
|
18
|
-
import type { App } from 'vue';
|
|
19
|
-
import AQuantityInput from './components/form/AQuantityInput.vue';
|
|
20
|
-
import ASegmentedControl from './components/form/ASegmentedControl.vue';
|
|
21
|
-
import ATextboxInput from './components/form/ATextboxInput.vue';
|
|
22
|
-
import ATextInput from './components/form/ATextInput.vue';
|
|
23
|
-
import type { BadgeDescriptor } from '@stonecrop/schema';
|
|
24
|
-
import type { ColumnSchema } from '@stonecrop/schema';
|
|
25
|
-
import ExpandButton from './components/base/ExpandButton.vue';
|
|
26
|
-
import type { FieldOptions } from '@stonecrop/schema';
|
|
27
|
-
import type { FieldValidation } from '@stonecrop/schema';
|
|
28
|
-
import type { GetRecordsOptions } from '@stonecrop/schema';
|
|
29
|
-
import type { GetRecordsResult } from '@stonecrop/schema';
|
|
30
|
-
import { InteractionMode } from '@stonecrop/schema';
|
|
31
|
-
import Login from './components/utilities/Login.vue';
|
|
32
|
-
import type { TableViewConfig } from '@stonecrop/schema';
|
|
33
|
-
import type { ValueField } from '@stonecrop/schema';
|
|
34
|
-
|
|
35
|
-
export { ABadge }
|
|
36
|
-
|
|
37
|
-
export { ACheckbox }
|
|
38
|
-
|
|
39
|
-
export { ACurrencyInput }
|
|
40
|
-
|
|
41
|
-
export { ADate }
|
|
42
|
-
|
|
43
|
-
export { ADatePicker }
|
|
44
|
-
|
|
45
|
-
export { ADateRange }
|
|
46
|
-
|
|
47
|
-
export { ADateSelection }
|
|
48
|
-
|
|
49
|
-
export { ADateTime }
|
|
50
|
-
|
|
51
|
-
export { ADateTimeInput }
|
|
52
|
-
|
|
53
|
-
export { ADropdown }
|
|
54
|
-
|
|
55
|
-
export { ADuration }
|
|
56
|
-
|
|
57
|
-
export { AFieldset }
|
|
58
|
-
|
|
59
|
-
export { AFileAttach }
|
|
60
|
-
|
|
61
|
-
export { AForm }
|
|
62
|
-
|
|
63
|
-
export { AFormLink }
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* What AFormLink accepts as its `v-model`.
|
|
67
|
-
*
|
|
68
|
-
* Wider than {@link AFormLinkValue} because a link is as often bound straight to its FK column as
|
|
69
|
-
* to a resolved reference: a record loaded from the DB carries the raw scalar, and a parent bound
|
|
70
|
-
* to that column coerces every update it receives back to a scalar. The component reads through
|
|
71
|
-
* `linkId`/`linkDisplayText`/`asLinkValue`, so all three shapes render and resolve identically.
|
|
72
|
-
*
|
|
73
|
-
* Emitting is narrower — AFormLink always writes back an {@link AFormLinkValue}.
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export declare type AFormLinkModelValue = AFormLinkValue | string | number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Navigation contract for AFormLink. Provide via `provide('aformLinkNavigator', ...)` in the app plugin.
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export declare interface AFormLinkNavigator {
|
|
83
|
-
/** Navigate to the linked document. Implementation is app-defined. */
|
|
84
|
-
navigate(doctype: string, id: string | number): void;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The value shape for AFormLink — a linked document reference with optional display text
|
|
89
|
-
* @public
|
|
90
|
-
*/
|
|
91
|
-
export declare interface AFormLinkValue {
|
|
92
|
-
/** The FK/linked document ID. `id: 0` is a valid ID. */
|
|
93
|
-
id: string | number;
|
|
94
|
-
/** Display text shown in the input. Falls back to `String(id)` if omitted. */
|
|
95
|
-
displayText?: string;
|
|
96
|
-
/** Additional properties passed through to the underlying input component */
|
|
97
|
-
[extra: string]: any;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export { AFormLoading }
|
|
101
|
-
|
|
102
|
-
export { ANumericInput }
|
|
103
|
-
|
|
104
|
-
export { AQuantityInput }
|
|
105
|
-
|
|
106
|
-
export { ASegmentedControl }
|
|
107
|
-
|
|
108
|
-
export { ATextboxInput }
|
|
109
|
-
|
|
110
|
-
export { ATextInput }
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Row context passed to badge `format` functions in form fields.
|
|
114
|
-
* @public
|
|
115
|
-
*/
|
|
116
|
-
export declare type BadgeFormatContext = {
|
|
117
|
-
record?: Record<string, unknown>;
|
|
118
|
-
row?: Record<string, unknown>;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Badge-aware field `format` function signature.
|
|
123
|
-
* @public
|
|
124
|
-
*/
|
|
125
|
-
export declare type BadgeFormatFn = (value: unknown, context: BadgeFormatContext) => string | BadgeDescriptor;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* CSS custom properties for input-accent styling on a native input.
|
|
129
|
-
* @public
|
|
130
|
-
*/
|
|
131
|
-
export declare function badgeInputAccentStyle(descriptor: BadgeDescriptor | undefined): Record<string, string> | undefined;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Defined props for AForm components
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
|
-
export declare type ComponentProps = {
|
|
138
|
-
/**
|
|
139
|
-
* The schema object to pass to the component
|
|
140
|
-
* @public
|
|
141
|
-
*/
|
|
142
|
-
schema?: ResolvedField;
|
|
143
|
-
/**
|
|
144
|
-
* The label to display in the component
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
label?: string;
|
|
148
|
-
selectRange?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* The mask to apply to inputs inside the component. Accepts either a plain
|
|
151
|
-
* mask string (e.g. `"(###) ###-####"`) or a stringified arrow function that
|
|
152
|
-
* receives `locale` and returns a mask string
|
|
153
|
-
* (e.g. `"(locale) => locale === 'en-US' ? '(###) ###-####' : '####-######'"`).
|
|
154
|
-
* @public
|
|
155
|
-
*/
|
|
156
|
-
mask?: string;
|
|
157
|
-
/**
|
|
158
|
-
* Indicate whether input is required for text and/or select elements inside the component
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
required?: boolean;
|
|
162
|
-
/**
|
|
163
|
-
* The rendering mode for the component
|
|
164
|
-
* @public
|
|
165
|
-
*/
|
|
166
|
-
mode?: InteractionMode;
|
|
167
|
-
/**
|
|
168
|
-
* Set a unique identifier for elements inside the component
|
|
169
|
-
* @public
|
|
170
|
-
*/
|
|
171
|
-
uuid?: string;
|
|
172
|
-
/**
|
|
173
|
-
* Validation options for elements inside the component
|
|
174
|
-
* @public
|
|
175
|
-
*/
|
|
176
|
-
validation?: {
|
|
177
|
-
/**
|
|
178
|
-
* The error message to display when validation fails
|
|
179
|
-
* @public
|
|
180
|
-
*/
|
|
181
|
-
errorMessage: string;
|
|
182
|
-
[key: string]: any;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Inline validation error messages to display on this field. Fed by the host
|
|
186
|
-
* (e.g. mapped from the core validation store) — the renderer stays dumb and just
|
|
187
|
-
* shows what it is given. Takes precedence over the static `validation.errorMessage`.
|
|
188
|
-
* @public
|
|
189
|
-
*/
|
|
190
|
-
errors?: string[];
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Type-specific configuration for ACurrencyInput, passed via the field's `options` property.
|
|
195
|
-
* @public
|
|
196
|
-
*/
|
|
197
|
-
export declare interface CurrencyOptions {
|
|
198
|
-
/** Currency doctype name, used for FK resolution via `aformLinkResolver`. The currency picker is embedded, so it renders no navigate button. */
|
|
199
|
-
doctype?: string;
|
|
200
|
-
/** The record's base currency — fixed, not user-editable. A bare id resolves to displayText via `aformLinkResolver`. */
|
|
201
|
-
baseCurrency?: AFormLinkValue | string;
|
|
202
|
-
/** Exchange rate lookup for each non-base currency id, relative to `baseCurrency` (which is implicitly `1`) */
|
|
203
|
-
exchangeRates?: Record<string, number>;
|
|
204
|
-
/** Decimal places to round the derived `baseAmount` to — the base currency's scale (JPY carries 0, most carry 2, KWD 3). Applies only to `baseAmount`; the entered `amount` is left as typed. Omit to round only enough to shed binary floating-point noise, which never discards a digit the rate actually produced. A non-integer or out-of-range value falls back to that default. */
|
|
205
|
-
precision?: number;
|
|
206
|
-
/** Search function backing the `currency` autocomplete dropdown — see AFormLink's `filterFunction` */
|
|
207
|
-
filterFunction?: string | ((search: string) => AFormLinkValue[] | Promise<AFormLinkValue[]>);
|
|
208
|
-
/** Whether `filterFunction` results should show a loading state — see AFormLink's `isAsync` */
|
|
209
|
-
isAsync?: boolean;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* The value shape for ACurrencyInput — an amount paired with its currency (an
|
|
214
|
-
* {@link AFormLinkValue} FK reference), plus the derived base-currency-equivalent amount.
|
|
215
|
-
* `exchangeRate` is carried on the value so it round-trips with the record even though it is
|
|
216
|
-
* never directly edited by the user.
|
|
217
|
-
* @public
|
|
218
|
-
*/
|
|
219
|
-
export declare interface CurrencyValue {
|
|
220
|
-
/** The entered amount, in `currency` units */
|
|
221
|
-
amount: number;
|
|
222
|
-
/** FK reference to the Currency doctype the user entered `amount` in */
|
|
223
|
-
currency: AFormLinkValue;
|
|
224
|
-
/** `amount` converted into `baseCurrency` units — `amount * exchangeRate` */
|
|
225
|
-
baseAmount: number;
|
|
226
|
-
/** The record's base currency — fixed, not user-editable */
|
|
227
|
-
baseCurrency: AFormLinkValue;
|
|
228
|
-
/** Multiplier from `currency` to `baseCurrency` — hidden from the UI, drives `baseAmount` */
|
|
229
|
-
exchangeRate: number;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Deserializes a stringified function expression into a typed callable.
|
|
234
|
-
*
|
|
235
|
-
* Throws if the string cannot be parsed as a function (SyntaxError) or if the
|
|
236
|
-
* resulting expression is not callable (TypeError), or if the expression references
|
|
237
|
-
* an undefined variable (ReferenceError). Callers are responsible for try/catch.
|
|
238
|
-
*
|
|
239
|
-
* @example
|
|
240
|
-
* ```ts
|
|
241
|
-
* const fn = deserializeFunction<(x: number) => number>('(x) => x * 2')
|
|
242
|
-
* fn(5) // 10
|
|
243
|
-
* ```
|
|
244
|
-
* @public
|
|
245
|
-
*/
|
|
246
|
-
export declare function deserializeFunction<T extends (...args: any[]) => any>(source: string): T;
|
|
247
|
-
|
|
248
|
-
export { ExpandButton }
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Install all AForm components
|
|
252
|
-
* @param app - Vue app instance
|
|
253
|
-
* @public
|
|
254
|
-
*/
|
|
255
|
-
export declare function install(app: App): void;
|
|
256
|
-
|
|
257
|
-
export { InteractionMode }
|
|
258
|
-
|
|
259
|
-
export { Login }
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Type-specific configuration for AQuantityInput, passed via the field's `options` property.
|
|
263
|
-
* @public
|
|
264
|
-
*/
|
|
265
|
-
export declare interface QuantityOptions {
|
|
266
|
-
/** Dropdown choices for the `uom` field */
|
|
267
|
-
uoms?: string[];
|
|
268
|
-
/** The item's base/stock unit of measure — fixed, not user-editable */
|
|
269
|
-
stockUom?: string;
|
|
270
|
-
/** Conversion factor lookup for each non-stock UOM, relative to `stockUom` (which is implicitly `1`) */
|
|
271
|
-
conversionFactors?: Record<string, number>;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* The value shape for AQuantityInput — a quantity paired with its unit of measure, plus the
|
|
276
|
-
* derived stock-equivalent quantity/UOM. `conversionFactor` is carried on the value so it
|
|
277
|
-
* round-trips with the record even though it is never shown in the UI.
|
|
278
|
-
* @public
|
|
279
|
-
*/
|
|
280
|
-
export declare interface QuantityValue {
|
|
281
|
-
/** The entered quantity, in `uom` units */
|
|
282
|
-
qty: number;
|
|
283
|
-
/** Unit of measure the user entered `qty` in */
|
|
284
|
-
uom: string;
|
|
285
|
-
/** `qty` converted into `stockUom` units — `qty * conversionFactor` */
|
|
286
|
-
stockQty: number;
|
|
287
|
-
/** The item's base/stock unit of measure — fixed, not user-editable */
|
|
288
|
-
stockUom: string;
|
|
289
|
-
/** Multiplier from `uom` to `stockUom` — hidden from the UI, drives `stockQty` */
|
|
290
|
-
conversionFactor: number;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* The discriminated union of all resolved field types — what AForm consumes,
|
|
295
|
-
* usually after `resolveSchema()` has transformed the authoring `DoctypeField[]`,
|
|
296
|
-
* but also valid hand-authored for view chrome with no backing doctype.
|
|
297
|
-
* Narrowed by `kind`: `'field'` | `'link'` | `'table'` | `'fieldset'`.
|
|
298
|
-
*
|
|
299
|
-
* `kind` is required — AForm dispatches on it alone and does not infer a field's
|
|
300
|
-
* type from its structure.
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
303
|
-
export declare type ResolvedField = ResolvedScalar | ResolvedLink | ResolvedTable | ResolvedFieldset;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* A resolved fieldset — groups child fields inside an AFieldset component.
|
|
307
|
-
* @public
|
|
308
|
-
*/
|
|
309
|
-
export declare interface ResolvedFieldset {
|
|
310
|
-
/** Discriminator */
|
|
311
|
-
kind: 'fieldset';
|
|
312
|
-
/** Field identifier */
|
|
313
|
-
fieldname: string;
|
|
314
|
-
/** Component to render; defaults to `'AFieldset'` */
|
|
315
|
-
component?: string;
|
|
316
|
-
/** Human-readable label for the legend */
|
|
317
|
-
label?: string;
|
|
318
|
-
/** Whether the fieldset can be collapsed */
|
|
319
|
-
collapsible?: boolean;
|
|
320
|
-
/** Interaction mode for all children */
|
|
321
|
-
mode?: InteractionMode;
|
|
322
|
-
/** Resolved child fields */
|
|
323
|
-
schema: ResolvedField[];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* The resolved fields that can be columns in a list or table view, in declaration order.
|
|
328
|
-
*
|
|
329
|
-
* A cell renders one value, so only `kind: 'field'` qualifies. The other three kinds are
|
|
330
|
-
* containers: a `fieldset` groups fields for layout and has no value of its own, while a `link`
|
|
331
|
-
* and a `table` hold a nested record and an array of them. Neither has a `cellComponent`, so a
|
|
332
|
-
* container reaching `ACell` falls through to plain-text rendering and stringifies its children —
|
|
333
|
-
* no error and no log, just a wrong column.
|
|
334
|
-
*
|
|
335
|
-
* A fieldset's *children* are real columns, so it is flattened rather than dropped; losing them is
|
|
336
|
-
* the same silent defect in the other direction.
|
|
337
|
-
*
|
|
338
|
-
* One definition, called by both consumers: `Registry.buildTableConfig` (a child table's columns,
|
|
339
|
-
* from its target's resolved schema) and Desktop's records list. Re-deriving it at either call
|
|
340
|
-
* site produced exactly one of the two failures above at each.
|
|
341
|
-
*
|
|
342
|
-
* @param fields - resolved fields, as produced by `resolveSchema`
|
|
343
|
-
* @returns column definitions, with the `kind` discriminator stripped
|
|
344
|
-
* @public
|
|
345
|
-
*/
|
|
346
|
-
export declare function resolvedFieldsToColumns(fields: readonly ResolvedField[]): ColumnSchema[];
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* A resolved Link field with cardinality `one` or `atMostOne` — embedded as a nested form.
|
|
350
|
-
* @public
|
|
351
|
-
*/
|
|
352
|
-
export declare interface ResolvedLink {
|
|
353
|
-
/** Discriminator */
|
|
354
|
-
kind: 'link';
|
|
355
|
-
/** Field identifier */
|
|
356
|
-
fieldname: string;
|
|
357
|
-
/** Component to render; defaults to `'AForm'` */
|
|
358
|
-
component: string;
|
|
359
|
-
/** Human-readable label */
|
|
360
|
-
label?: string;
|
|
361
|
-
/** Interaction mode */
|
|
362
|
-
mode?: InteractionMode;
|
|
363
|
-
/** Resolved child fields */
|
|
364
|
-
schema: ResolvedField[];
|
|
365
|
-
/** Preserved from the original ValueField */
|
|
366
|
-
required?: boolean;
|
|
367
|
-
/** Preserved from the original ValueField */
|
|
368
|
-
readOnly?: boolean;
|
|
369
|
-
/** Preserved from the original ValueField */
|
|
370
|
-
hidden?: boolean;
|
|
371
|
-
/** Preserved from the original ValueField */
|
|
372
|
-
default?: unknown;
|
|
373
|
-
/** Preserved from the original ValueField */
|
|
374
|
-
validation?: FieldValidation;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* A resolved scalar field. Derived from ValueField with `cardinality` omitted
|
|
379
|
-
* (consumed by resolveSchema) and an optional `doctype` added for unresolved Link fields.
|
|
380
|
-
* @public
|
|
381
|
-
*/
|
|
382
|
-
export declare type ResolvedScalar = Omit<ValueField, 'cardinality'> & {
|
|
383
|
-
/** Doctype slug for unresolved Link fields — added by resolveSchema when AFormLink is available */
|
|
384
|
-
doctype?: string;
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* A resolved table — either from a Link with `noneOrMany`/`atLeastOne` cardinality,
|
|
389
|
-
* or from an inline TableField. ATable receives columns via `:schema` (ColumnSchema[])
|
|
390
|
-
* and row data via `:rows` from formData at render time.
|
|
391
|
-
*
|
|
392
|
-
* Note the key rename: an authoring `TableField` declares its columns under `columns`;
|
|
393
|
-
* `resolveSchema` moves them to `schema` here, because `schema` is the ATable prop that
|
|
394
|
-
* runs `schemaToColumns()` (ATable's own `columns` prop means already-converted
|
|
395
|
-
* `TableColumn[]`). A hand-authored table must therefore use `schema`, not `columns`.
|
|
396
|
-
*
|
|
397
|
-
* Rows are never part of the schema. AForm sources them from the data model at
|
|
398
|
-
* `dataModel[fieldname]`, so a `rows` key placed on this object is ignored.
|
|
399
|
-
* @public
|
|
400
|
-
*/
|
|
401
|
-
export declare interface ResolvedTable {
|
|
402
|
-
/** Discriminator */
|
|
403
|
-
kind: 'table';
|
|
404
|
-
/** Field identifier */
|
|
405
|
-
fieldname: string;
|
|
406
|
-
/** Component to render; defaults to `'ATable'` */
|
|
407
|
-
component: string;
|
|
408
|
-
/** Human-readable label */
|
|
409
|
-
label?: string;
|
|
410
|
-
/** Interaction mode for all cells */
|
|
411
|
-
mode?: InteractionMode;
|
|
412
|
-
/** Column definitions — passed to ATable's `:schema` prop */
|
|
413
|
-
schema: ColumnSchema[];
|
|
414
|
-
/** View configuration — always present; defaults to `{ view: 'list' }` */
|
|
415
|
-
config: TableViewConfig;
|
|
416
|
-
/** Preserved from the original ValueField or TableField */
|
|
417
|
-
required?: boolean;
|
|
418
|
-
/** Preserved from the original ValueField or TableField */
|
|
419
|
-
readOnly?: boolean;
|
|
420
|
-
/** Preserved from the original ValueField or TableField */
|
|
421
|
-
hidden?: boolean;
|
|
422
|
-
/** Preserved from the original ValueField or TableField */
|
|
423
|
-
default?: unknown;
|
|
424
|
-
/** Preserved from the original ValueField or TableField */
|
|
425
|
-
validation?: FieldValidation;
|
|
426
|
-
/** When set, ATable fetches list pages through this callback (server paging). */
|
|
427
|
-
getRecords?: (options?: GetRecordsOptions) => Promise<GetRecordsResult>;
|
|
428
|
-
/** When this changes, ATable refetches from offset 0. */
|
|
429
|
-
sourceKey?: string;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Resolve a field value to a badge descriptor using format (if present) then options map.
|
|
434
|
-
* @public
|
|
435
|
-
*/
|
|
436
|
-
export declare function resolveFieldBadge(value: unknown, options: FieldOptions | undefined, format: string | BadgeFormatFn | undefined, context?: BadgeFormatContext): BadgeDescriptor | undefined;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
export * from "@stonecrop/atable/types";
|
|
440
|
-
|
|
441
|
-
export { }
|
package/dist/aform.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"6.0.3"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { deserializeFunction } from '../utils/deserialize';
|
|
2
|
-
/**
|
|
3
|
-
* Extracts a mask function from a stringified function
|
|
4
|
-
* @param mask - Mask string
|
|
5
|
-
* @returns Mask function, or undefined if the string is not a valid function expression
|
|
6
|
-
*/
|
|
7
|
-
function extractMaskFn(mask) {
|
|
8
|
-
try {
|
|
9
|
-
return deserializeFunction(mask);
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Gets the mask for a given directive binding
|
|
17
|
-
* @param binding - Binding object from directive hook
|
|
18
|
-
* @returns Mask string
|
|
19
|
-
*/
|
|
20
|
-
function getMask(binding) {
|
|
21
|
-
const mask = binding.value;
|
|
22
|
-
if (!mask)
|
|
23
|
-
return undefined;
|
|
24
|
-
const maskFn = extractMaskFn(mask);
|
|
25
|
-
if (maskFn) {
|
|
26
|
-
// TODO: (state) replace with state management;
|
|
27
|
-
// pass the entire form/table data to the function
|
|
28
|
-
// Vue directive reads arbitrary fields off host component instance; type is unknown at this layer.
|
|
29
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
30
|
-
const instance = binding.instance;
|
|
31
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
32
|
-
const locale = instance?.['locale'];
|
|
33
|
-
return maskFn(locale);
|
|
34
|
-
}
|
|
35
|
-
return mask;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Unmasks the input string
|
|
39
|
-
* @param input - Input string
|
|
40
|
-
* @param maskToken - Mask token character
|
|
41
|
-
* @returns Unmasked input string
|
|
42
|
-
*/
|
|
43
|
-
function unmaskInput(input, maskToken) {
|
|
44
|
-
if (!maskToken) {
|
|
45
|
-
maskToken = '#';
|
|
46
|
-
}
|
|
47
|
-
let unmaskedInput = input;
|
|
48
|
-
const maskChars = [maskToken, '/', '-', '(', ')', ' '];
|
|
49
|
-
for (const char of maskChars) {
|
|
50
|
-
unmaskedInput = unmaskedInput.replaceAll(char, '');
|
|
51
|
-
}
|
|
52
|
-
return unmaskedInput;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Fills the mask with the input string
|
|
56
|
-
* @param input - Input string
|
|
57
|
-
* @param mask - Mask string
|
|
58
|
-
* @param maskToken - Mask token character
|
|
59
|
-
* @returns Masked input string
|
|
60
|
-
*/
|
|
61
|
-
function fillMask(input, mask, maskToken) {
|
|
62
|
-
if (!maskToken) {
|
|
63
|
-
maskToken = '#';
|
|
64
|
-
}
|
|
65
|
-
let replacement = mask;
|
|
66
|
-
for (const inputChar of input) {
|
|
67
|
-
const replaceIndex = replacement.indexOf(maskToken);
|
|
68
|
-
if (replaceIndex !== -1) {
|
|
69
|
-
const prefix = replacement.substring(0, replaceIndex);
|
|
70
|
-
const suffix = replacement.substring(replaceIndex + 1);
|
|
71
|
-
replacement = prefix + inputChar + suffix;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return replacement.slice(0, mask.length);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Applies a mask to an input element
|
|
78
|
-
* @param el - Input element
|
|
79
|
-
* @param binding - Binding object from directive hook
|
|
80
|
-
* @returns void
|
|
81
|
-
* @public
|
|
82
|
-
*/
|
|
83
|
-
export function useStringMask(el, binding) {
|
|
84
|
-
const mask = getMask(binding);
|
|
85
|
-
if (!mask)
|
|
86
|
-
return;
|
|
87
|
-
const maskToken = '#';
|
|
88
|
-
const inputText = el.value;
|
|
89
|
-
// process input value with mask
|
|
90
|
-
const unmaskedInput = unmaskInput(inputText, maskToken);
|
|
91
|
-
if (unmaskedInput) {
|
|
92
|
-
const replacement = fillMask(unmaskedInput, mask, maskToken);
|
|
93
|
-
// TODO: (state) this is very opinionated;
|
|
94
|
-
// most likely fixed with state management;
|
|
95
|
-
// a better way could be to emit back to instance;
|
|
96
|
-
// Vue directive reads/writes arbitrary fields on host component instance.
|
|
97
|
-
// oxlint-disable-next-line typescript/no-unsafe-type-assertion
|
|
98
|
-
const instance = binding.instance;
|
|
99
|
-
if (instance?.['maskFilled']) {
|
|
100
|
-
instance['maskFilled'] = !replacement.includes(maskToken);
|
|
101
|
-
}
|
|
102
|
-
el.value = replacement;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
el.value = mask;
|
|
106
|
-
}
|
|
107
|
-
}
|