@byline/core 3.16.0 → 3.17.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/@types/field-types.d.ts +43 -0
- package/package.json +2 -2
|
@@ -71,6 +71,21 @@ export interface FieldHookContext {
|
|
|
71
71
|
* derived value at submit time while showing advisory errors on change.
|
|
72
72
|
*/
|
|
73
73
|
operation: 'change' | 'submit';
|
|
74
|
+
/**
|
|
75
|
+
* Write **another** field's value in the form store.
|
|
76
|
+
*
|
|
77
|
+
* This is a raw write: the target field's own hooks do NOT run (which
|
|
78
|
+
* forecloses hook recursion), but the write is otherwise a normal form
|
|
79
|
+
* edit — it emits a `field.set` patch (so it persists on save), marks the
|
|
80
|
+
* form dirty, and store-subscribed widgets re-render immediately.
|
|
81
|
+
*
|
|
82
|
+
* Use for cross-field behaviour such as mutual exclusivity across array
|
|
83
|
+
* items (a checkbox that unchecks its siblings) or clearing a dependent
|
|
84
|
+
* field when its driver changes. Paths use the same dot + bracket
|
|
85
|
+
* notation as `FieldHookContext.path`, e.g.
|
|
86
|
+
* `files[1].filesGroup.generateThumbnail`.
|
|
87
|
+
*/
|
|
88
|
+
setFieldValue: (path: string, value: any) => void;
|
|
74
89
|
}
|
|
75
90
|
/**
|
|
76
91
|
* Return type of `beforeValidate` hooks.
|
|
@@ -140,6 +155,17 @@ export interface ValidationRule {
|
|
|
140
155
|
message?: string;
|
|
141
156
|
}
|
|
142
157
|
type FieldValidateFn = (value: any, data: Record<string, any>) => string | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Visibility predicate for a field — see {@link BaseField.condition}.
|
|
160
|
+
*
|
|
161
|
+
* @param data - The full live form data (the document's field values).
|
|
162
|
+
* @param siblingData - The field's immediate scope: the enclosing group /
|
|
163
|
+
* array item's values. For a field at `files[2].filesGroup.thumbnailPage`
|
|
164
|
+
* this is the item's `filesGroup` object, so conditions inside array items
|
|
165
|
+
* observe their own item, not the document root. For root-level fields
|
|
166
|
+
* `siblingData` is the same object as `data`.
|
|
167
|
+
*/
|
|
168
|
+
export type FieldCondition = (data: Record<string, any>, siblingData: Record<string, any>) => boolean;
|
|
143
169
|
/**
|
|
144
170
|
* Base properties shared by all fields
|
|
145
171
|
*/
|
|
@@ -178,6 +204,23 @@ interface BaseField {
|
|
|
178
204
|
* @see FieldHooks
|
|
179
205
|
*/
|
|
180
206
|
hooks?: FieldHooks;
|
|
207
|
+
/**
|
|
208
|
+
* Optional visibility condition. When provided, the admin form renders
|
|
209
|
+
* this field only while the function returns `true`. Receives the full
|
|
210
|
+
* live form data plus the field's sibling scope (the enclosing group /
|
|
211
|
+
* array item), and is re-evaluated on every form edit — so a field can
|
|
212
|
+
* appear and disappear in response to its neighbours, e.g.
|
|
213
|
+
*
|
|
214
|
+
* condition: (_data, siblingData) => Boolean(siblingData.generateThumbnail)
|
|
215
|
+
*
|
|
216
|
+
* Like `readOnly`, this is a **rendering hint only** — it is not enforced
|
|
217
|
+
* server-side. While hidden, the field's stored value is retained (no
|
|
218
|
+
* clearing write is emitted) and the field is exempt from client-side
|
|
219
|
+
* validation. Server-side schema validation knows nothing about
|
|
220
|
+
* conditions, so pair conditionally-hidden required fields with
|
|
221
|
+
* `optional: true` or a `defaultValue`.
|
|
222
|
+
*/
|
|
223
|
+
condition?: FieldCondition;
|
|
181
224
|
/**
|
|
182
225
|
* Optional submit-time validator. Called by `validateForm()` for every field
|
|
183
226
|
* type — including structure fields (group, array, blocks).
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/core",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.17.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"pino": "^10.3.1",
|
|
77
77
|
"sharp": "^0.34.5",
|
|
78
78
|
"zod": "^4.4.3",
|
|
79
|
-
"@byline/auth": "3.
|
|
79
|
+
"@byline/auth": "3.17.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@biomejs/biome": "2.4.15",
|