@stonecrop/aform 0.12.0 → 0.12.2
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 +33 -3
- package/dist/aform.d.ts +3 -2
- package/dist/aform.js +899 -882
- package/dist/aform.js.map +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/src/types/index.d.ts +3 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/components/AForm.vue +12 -1
- package/src/components/form/AFormLink.vue +23 -2
- package/src/types/index.ts +3 -2
package/README.md
CHANGED
|
@@ -30,6 +30,26 @@ This registers all components globally. They can also be imported individually.
|
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
+
## AForm
|
|
34
|
+
|
|
35
|
+
### Field width
|
|
36
|
+
|
|
37
|
+
Set `width` on any schema field to control its share of the form row. The value is any valid CSS size and is applied as `flex-basis` + `width` directly on the field's flex item:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{ "fieldname": "notes", "fieldtype": "Text", "component": "ATextInput", "label": "Notes", "width": "100%" }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Value | Effect |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `"100%"` | Field spans the full form row (forces a line-break before and after) |
|
|
46
|
+
| `"50%"` | Field takes half the row; neighbouring fields fill the rest |
|
|
47
|
+
| `"40ch"` | Field starts at 40 characters wide and grows with available space |
|
|
48
|
+
|
|
49
|
+
Fields without `width` continue to share space equally (`flex-grow: 1; min-width: 20ch`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
33
53
|
## AFormLink
|
|
34
54
|
|
|
35
55
|
A form input for selecting and navigating to linked documents (`fieldtype: 'Link'`). Combines a searchable text input, an optional dropdown of results, and a navigation arrow button.
|
|
@@ -72,18 +92,28 @@ When `id` is falsy, the component shows a `—` placeholder and hides the naviga
|
|
|
72
92
|
|
|
73
93
|
### Filter function
|
|
74
94
|
|
|
75
|
-
Provide `filterFunction` to enable the search dropdown. The function receives
|
|
95
|
+
Provide `filterFunction` to enable the search dropdown. The function receives a search string and must return `AFormLinkValue[]` or a `Promise<AFormLinkValue[]>`.
|
|
96
|
+
|
|
97
|
+
The function is called in two distinct situations:
|
|
98
|
+
|
|
99
|
+
1. **On user interaction** — when the user focuses or types into the field, the current input text is passed as the search string.
|
|
100
|
+
2. **On mount (and on id change)** — when the field has an `id` but no `displayText`, the function is called automatically with the existing `id` string so the display name can be resolved without user interaction. The first result whose `id` matches is used.
|
|
101
|
+
|
|
102
|
+
Because of case 2, implementations should handle both name-based searches (partial strings typed by the user) and exact id lookups (full id strings passed on mount). A common pattern is to attempt both:
|
|
76
103
|
|
|
77
104
|
```typescript
|
|
78
105
|
// Sync
|
|
79
106
|
const filterFunction = (search: string): AFormLinkValue[] =>
|
|
80
107
|
records
|
|
81
|
-
.filter(r =>
|
|
108
|
+
.filter(r =>
|
|
109
|
+
r.id === search || // exact id match (mount-time resolution)
|
|
110
|
+
r.name.toLowerCase().includes(search.toLowerCase()) // name search (user typing)
|
|
111
|
+
)
|
|
82
112
|
.map(r => ({ id: r.id, displayText: r.name }))
|
|
83
113
|
|
|
84
114
|
// Async — set isAsync: true for loading indicator
|
|
85
115
|
const filterFunction = async (search: string): Promise<AFormLinkValue[]> => {
|
|
86
|
-
const results = await api.search(search)
|
|
116
|
+
const results = await api.search(search) // API should handle both id and name queries
|
|
87
117
|
return results.map(r => ({ id: r.id, displayText: r.name }))
|
|
88
118
|
}
|
|
89
119
|
```
|
package/dist/aform.d.ts
CHANGED
|
@@ -219,8 +219,9 @@ export declare type FormSchema = BaseSchema & {
|
|
|
219
219
|
*/
|
|
220
220
|
name?: string;
|
|
221
221
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
222
|
+
* CSS width for the field's flex item in the AForm grid.
|
|
223
|
+
* Applied as `flex-basis` and `width` on the rendered component element.
|
|
224
|
+
* Use `"100%"` to make the field span the full form row.
|
|
224
225
|
*/
|
|
225
226
|
width?: string;
|
|
226
227
|
/**
|