@navette-js/forms 1.0.0-beta.1 → 1.0.0-beta.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 +2 -2
- package/lib/builder.d.ts +23 -23
- package/lib/builder.js +29 -32
- package/lib/index.d.ts +170 -175
- package/lib/index.js +209 -219
- package/package.json +5 -6
- package/views/components/field-wrapper.ejs +3 -3
- package/views/components/rich-editor.ejs +2 -3
- package/views/components/text-input.ejs +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -29,11 +29,11 @@ export declare abstract class Field extends Component {
|
|
|
29
29
|
disabled(condition?: Lazy<boolean, ComponentContext>): this;
|
|
30
30
|
autofocus(condition?: boolean): this;
|
|
31
31
|
default(value: unknown): this;
|
|
32
|
-
/**
|
|
32
|
+
/** Helper text shown under the field. */
|
|
33
33
|
helperText(text: string | null): this;
|
|
34
|
-
/**
|
|
34
|
+
/** Helper text id, linked to the control through `aria-describedby`. */
|
|
35
35
|
protected getHelperTextId(): string | null;
|
|
36
|
-
/**
|
|
36
|
+
/** Keeps the label for screen readers only. */
|
|
37
37
|
hiddenLabel(condition?: boolean): this;
|
|
38
38
|
protected _hint: Lazy<string | HtmlString | null, ComponentContext>;
|
|
39
39
|
protected _hintColor: Lazy<string | null, ComponentContext>;
|
|
@@ -41,38 +41,38 @@ export declare abstract class Field extends Component {
|
|
|
41
41
|
protected _hintIconTooltip: Lazy<string | null, ComponentContext>;
|
|
42
42
|
protected _hintActions: Action[];
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* (`raw('<a href="…">…</a>')`)
|
|
44
|
+
* Hint shown to the right of the label (a `Text` component). The text is escaped; an `HtmlString` from `@navette-js/support`
|
|
45
|
+
* (`raw('<a href="…">…</a>')`) is inserted as is, so only put values escaped with `e()` in it.
|
|
46
46
|
*/
|
|
47
47
|
hint(hint: Lazy<string | HtmlString | null, ComponentContext>): this;
|
|
48
|
-
/**
|
|
48
|
+
/** Color of the hint and its icon (by default `gray` for the text, `primary` for the icon). */
|
|
49
49
|
hintColor(color: Lazy<string | null, ComponentContext>): this;
|
|
50
|
-
/**
|
|
50
|
+
/** Hint icon, with an optional tooltip (also used as its accessible name). */
|
|
51
51
|
hintIcon(name: Lazy<string | null, ComponentContext>, tooltip?: Lazy<string | null, ComponentContext>): this;
|
|
52
52
|
hintIconTooltip(tooltip: Lazy<string | null, ComponentContext>): this;
|
|
53
|
-
/** Action
|
|
53
|
+
/** Action shown after the hint (small link), mounted on the field. */
|
|
54
54
|
hintAction(action: Action): this;
|
|
55
55
|
hintActions(actions: Action[]): this;
|
|
56
56
|
getHintActions(): Action[];
|
|
57
|
-
/** Actions
|
|
57
|
+
/** Actions the field exposes for mounting (`schemaComponent` = field key): its hint actions. */
|
|
58
58
|
getActions(): Action[];
|
|
59
|
-
/**
|
|
59
|
+
/** Row after the label: hint, hint icon and hint actions. */
|
|
60
60
|
protected renderAfterLabel(): Promise<string>;
|
|
61
|
-
/**
|
|
61
|
+
/** Runs on the server when the field state changes (`live()` field). `set(name, value)` changes another field of the same form. */
|
|
62
62
|
afterStateUpdated(callback: (ctx: ComponentContext & {
|
|
63
63
|
set: (name: string, value: unknown) => void;
|
|
64
64
|
}) => unknown): this;
|
|
65
65
|
hasAfterStateUpdated(): boolean;
|
|
66
66
|
callAfterStateUpdated(set: (name: string, value: unknown) => void): Promise<void>;
|
|
67
|
-
/**
|
|
67
|
+
/** Forces the field into the submitted data, even when disabled (`.disabled().dehydrated()`). */
|
|
68
68
|
dehydrated(condition?: boolean): this;
|
|
69
|
-
/**
|
|
69
|
+
/** By default, a disabled field is neither validated nor saved. */
|
|
70
70
|
isDehydrated(): Promise<boolean>;
|
|
71
71
|
getDefaultState(): unknown;
|
|
72
|
-
/**
|
|
72
|
+
/** Shapes a record value as it enters the form (hydration). */
|
|
73
73
|
hydrateState(value: unknown): unknown;
|
|
74
74
|
rule(rule: Rule): this;
|
|
75
|
-
/**
|
|
75
|
+
/** `unique` rule: the value must not exist in the column of the same name; `ignoreRecord` excludes the record being edited. */
|
|
76
76
|
unique(options?: {
|
|
77
77
|
ignoreRecord?: boolean;
|
|
78
78
|
column?: string;
|
|
@@ -82,13 +82,12 @@ export declare abstract class Field extends Component {
|
|
|
82
82
|
isDisabled(): Promise<boolean>;
|
|
83
83
|
getErrors(): string[];
|
|
84
84
|
hasError(): boolean;
|
|
85
|
-
/**
|
|
85
|
+
/** Validation rules: `required` first, then the field's own. */
|
|
86
86
|
getValidationRules(): Promise<Rule[]>;
|
|
87
87
|
validate(): Promise<string[]>;
|
|
88
|
-
/**
|
|
89
|
-
/** Valeur écrite dans les données à enregistrer (les champs composés n'y laissent qu'une ossature, remplie par leurs enfants). */
|
|
88
|
+
/** Value written to the data to save (composite fields only leave a skeleton, filled by their children). */
|
|
90
89
|
dehydrateState(state: unknown): unknown;
|
|
91
|
-
/**
|
|
90
|
+
/** Final shaping of the saved value, once child fields are dehydrated (e.g. a Builder's item list). */
|
|
92
91
|
finalizeDehydratedState(state: unknown): unknown;
|
|
93
92
|
protected wrap(html: string, options?: {
|
|
94
93
|
labelPrefix?: string;
|
|
@@ -112,66 +111,65 @@ export declare class TextInput extends Field {
|
|
|
112
111
|
private _prefix;
|
|
113
112
|
private _live;
|
|
114
113
|
static make(name: string): TextInput;
|
|
115
|
-
/**
|
|
114
|
+
/** Decimal number: `type="number"`, `step="any"`. */
|
|
116
115
|
numeric(): this;
|
|
117
|
-
/**
|
|
116
|
+
/** Integer: `type="number"`, `step="1"`. */
|
|
118
117
|
integer(): this;
|
|
119
118
|
private _step;
|
|
120
|
-
/**
|
|
119
|
+
/** Input `step` of a numeric field, overriding the one implied by `numeric()` or `integer()`. */
|
|
121
120
|
step(step: number | 'any' | null): this;
|
|
122
121
|
minValue(value: number): this;
|
|
123
122
|
maxValue(value: number): this;
|
|
124
|
-
/**
|
|
123
|
+
/** Label shown before the input (e.g. `$`). */
|
|
125
124
|
prefix(label: string | null): this;
|
|
126
125
|
private _suffix;
|
|
127
|
-
/**
|
|
126
|
+
/** Label shown after the input ("hours", "kg"…). */
|
|
128
127
|
suffix(label: string | null): this;
|
|
129
|
-
/**
|
|
128
|
+
/** Sends the state to the server on every keystroke, or on blur with `onBlur`. */
|
|
130
129
|
live(options?: {
|
|
131
130
|
onBlur?: boolean;
|
|
132
131
|
}): this;
|
|
133
132
|
type(type: string): this;
|
|
134
133
|
password(condition?: boolean): this;
|
|
135
134
|
revealable(condition?: boolean): this;
|
|
136
|
-
/** `true` → "on", `false` → "off",
|
|
135
|
+
/** `true` → "on", `false` → "off", a string as is. */
|
|
137
136
|
autocomplete(value?: string | boolean): this;
|
|
138
137
|
placeholder(text: string | null): this;
|
|
139
|
-
/** Adresse web : champ de type `url`, valeur http(s) valide exigée. */
|
|
140
138
|
private _mask;
|
|
141
|
-
/**
|
|
139
|
+
/** Alpine input mask (`(999) 999-9999`): guides typing in the browser, with no validation value. */
|
|
142
140
|
mask(pattern: string | null): this;
|
|
143
|
-
/**
|
|
141
|
+
/** Phone number: digits, spaces and common punctuation. */
|
|
144
142
|
tel(): this;
|
|
143
|
+
/** Web address: `url` input type, a valid http(s) value is required. */
|
|
145
144
|
url(): this;
|
|
146
145
|
maxLength(length: number): this;
|
|
147
146
|
minLength(length: number): this;
|
|
148
|
-
/** Port de TextInput::toEmbeddedHtml (sans affixes libres, masque ni datalist pour l'instant). */
|
|
149
147
|
toHtml(): Promise<string>;
|
|
150
148
|
}
|
|
151
|
-
/**
|
|
149
|
+
/** Native date picker (`<input type="date">`). */
|
|
152
150
|
export declare class DatePicker extends Field {
|
|
153
151
|
private _maxDate;
|
|
154
152
|
private _minDate;
|
|
155
153
|
private _live;
|
|
156
154
|
static make(name: string): DatePicker;
|
|
157
155
|
private _datePlaceholder;
|
|
158
|
-
/**
|
|
156
|
+
/** Placeholder attribute (browsers do not display it on a native `date` input). */
|
|
159
157
|
placeholder(text: string | null): this;
|
|
160
|
-
/**
|
|
158
|
+
/** Sends the state to the server as soon as it changes (`wire:model.live`). */
|
|
161
159
|
live(condition?: boolean): this;
|
|
162
|
-
/**
|
|
160
|
+
/** The state is a `YYYY-MM-DD` date, whatever the stored precision. */
|
|
163
161
|
hydrateState(value: unknown): unknown;
|
|
164
162
|
private static resolve;
|
|
165
163
|
private bound;
|
|
166
|
-
/**
|
|
164
|
+
/** Latest accepted date: `'today'`, a `YYYY-MM-DD` date, or a context function (`({ get }) => get('endDate') || 'today'`). */
|
|
167
165
|
maxDate(date: Lazy<string | null, ComponentContext>): this;
|
|
168
166
|
minDate(date: Lazy<string | null, ComponentContext>): this;
|
|
169
167
|
toHtml(): Promise<string>;
|
|
170
168
|
}
|
|
171
169
|
type Options = [string, string][] | Record<string, string>;
|
|
172
170
|
/**
|
|
173
|
-
*
|
|
174
|
-
*
|
|
171
|
+
* Dropdown. Native (`<select>`) by default; `searchable()` switches to the JavaScript select,
|
|
172
|
+
* which queries the server through the exposed methods (`getSearchResultsForJs`…).
|
|
175
173
|
*/
|
|
176
174
|
export declare class Select extends Field {
|
|
177
175
|
private _options;
|
|
@@ -187,39 +185,38 @@ export declare class Select extends Field {
|
|
|
187
185
|
private _searchResultsUsing;
|
|
188
186
|
private _optionLabelUsing;
|
|
189
187
|
static make(name: string): Select;
|
|
190
|
-
/**
|
|
188
|
+
/** Search results computed by the server on every keystroke (no preloaded option list). */
|
|
191
189
|
getSearchResultsUsing(resolver: (search: string, ctx: ComponentContext) => Options | Promise<Options>): this;
|
|
192
|
-
/**
|
|
190
|
+
/** Label of a value; also used to validate that a searched value exists. */
|
|
193
191
|
getOptionLabelUsing(resolver: (value: string, ctx: ComponentContext) => string | null | Promise<string | null>): this;
|
|
194
|
-
/** Options fixes, ou fonction (éventuellement asynchrone) évaluée à chaque requête. */
|
|
195
|
-
/** `dynamic: false` : options fournies par une fonction mais fixes pour la durée de la page (annoncées comme statiques au navigateur). */
|
|
196
192
|
/**
|
|
197
|
-
*
|
|
198
|
-
* `
|
|
193
|
+
* Fixed options, or a (possibly async) function evaluated on every request.
|
|
194
|
+
* `dynamic: false`: options come from a function but stay fixed for the page's lifetime (announced as static to the browser).
|
|
195
|
+
* `searchOnServer: false`: search runs in the browser, among the options already sent (for a complete list).
|
|
199
196
|
*/
|
|
200
197
|
options(options: Options | ((ctx: ComponentContext) => Options | Promise<Options>), config?: {
|
|
201
198
|
dynamic?: boolean;
|
|
202
199
|
searchOnServer?: boolean;
|
|
203
200
|
}): this;
|
|
204
|
-
/**
|
|
201
|
+
/** Disables an option depending on the context (e.g. already picked in another row). */
|
|
205
202
|
disableOptionWhen(condition: (value: string, ctx: ComponentContext) => boolean): this;
|
|
206
|
-
/**
|
|
203
|
+
/** Sends the state to the server as soon as it changes. */
|
|
207
204
|
live(condition?: boolean): this;
|
|
208
205
|
placeholder(label: string | null): this;
|
|
209
206
|
private _selectablePlaceholder;
|
|
210
|
-
/** `false
|
|
207
|
+
/** `false`: the native select has no empty option. */
|
|
211
208
|
selectablePlaceholder(condition?: boolean): this;
|
|
212
209
|
searchable(condition?: boolean): this;
|
|
213
|
-
/**
|
|
210
|
+
/** Multiple selection: the state is a list of values; always uses the JavaScript select. */
|
|
214
211
|
multiple(condition?: boolean): this;
|
|
215
212
|
isMultiple(): boolean;
|
|
216
|
-
/**
|
|
213
|
+
/** Labels of several values at once (multiple selection with server search); also used to validate the values. */
|
|
217
214
|
getOptionLabelsUsing(resolver: (values: string[], ctx: ComponentContext) => Options | Promise<Options>): this;
|
|
218
215
|
getDefaultState(): unknown;
|
|
219
|
-
/**
|
|
216
|
+
/** Sanitized selected values: unique strings. */
|
|
220
217
|
private selectedValues;
|
|
221
218
|
private labelsOf;
|
|
222
|
-
/**
|
|
219
|
+
/** No-op: options are always loaded with the form. */
|
|
223
220
|
preload(): this;
|
|
224
221
|
hydrateState(value: unknown): unknown;
|
|
225
222
|
dehydrateState(state: unknown): unknown;
|
|
@@ -250,40 +247,40 @@ export declare class Select extends Field {
|
|
|
250
247
|
private _editOptionModalHeading;
|
|
251
248
|
private _modifyEditOptionAction;
|
|
252
249
|
/**
|
|
253
|
-
*
|
|
254
|
-
* `createOptionUsing()`
|
|
255
|
-
*
|
|
250
|
+
* Form of the "Create" modal opened by the field's "+" button, validated on the server.
|
|
251
|
+
* `createOptionUsing()` saves the option and returns its value, which becomes the field state (appended for `multiple()`).
|
|
252
|
+
* Options must come from a function (`options(() => …)`, or server search) for the new value to appear.
|
|
256
253
|
*/
|
|
257
254
|
createOptionForm(schema: Component[] | ((schema: Schema) => Component[] | Schema) | null): this;
|
|
258
|
-
/**
|
|
255
|
+
/** Saves the option from the validated modal data; returns the value (key) of the created option. */
|
|
259
256
|
createOptionUsing(callback: ((data: Record<string, unknown>, ctx: ComponentContext) => string | number | null | Promise<string | number | null>) | null): this;
|
|
260
257
|
createOptionModalHeading(heading: string | null): this;
|
|
261
|
-
/**
|
|
258
|
+
/** Customizes the create action (label, icon, modal width…). */
|
|
262
259
|
createOptionAction(modify: ((action: Action) => Action | void) | null): this;
|
|
263
260
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
261
|
+
* Form of the "Edit" modal for the selected option (single selection only). The field becomes `live()` so the button
|
|
262
|
+
* appears as soon as an option is picked. Filled by `fillEditOptionActionFormUsing()`, saved by `updateOptionUsing()`.
|
|
266
263
|
*/
|
|
267
264
|
editOptionForm(schema: Component[] | ((schema: Schema) => Component[] | Schema) | null): this;
|
|
268
265
|
updateOptionUsing(callback: ((data: Record<string, unknown>, ctx: ComponentContext) => unknown) | null): this;
|
|
269
|
-
/**
|
|
266
|
+
/** Initial data of the "Edit" modal (the context carries the current field state in `state`). */
|
|
270
267
|
fillEditOptionActionFormUsing(callback: ((ctx: ComponentContext) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>) | null): this;
|
|
271
268
|
editOptionModalHeading(heading: string | null): this;
|
|
272
269
|
editOptionAction(modify: ((action: Action) => Action | void) | null): this;
|
|
273
|
-
/**
|
|
270
|
+
/** Same form for creating and editing. */
|
|
274
271
|
manageOptionForm(schema: Component[] | ((schema: Schema) => Component[] | Schema) | null): this;
|
|
275
272
|
private setState;
|
|
276
273
|
private getCreateOptionAction;
|
|
277
274
|
private getEditOptionAction;
|
|
278
|
-
/** Actions
|
|
275
|
+
/** Actions mounted on the field: hint, create option and edit option. */
|
|
279
276
|
getActions(): Action[];
|
|
280
|
-
/**
|
|
277
|
+
/** "+" and "edit" buttons on the right of the field. */
|
|
281
278
|
private suffixHtml;
|
|
282
279
|
toHtml(): Promise<string>;
|
|
283
|
-
/**
|
|
280
|
+
/** JavaScript select rendering. */
|
|
284
281
|
private toJsHtml;
|
|
285
282
|
}
|
|
286
|
-
/**
|
|
283
|
+
/** Column of a table Repeater: label and width. */
|
|
287
284
|
export declare class TableColumn {
|
|
288
285
|
label: string;
|
|
289
286
|
private _width;
|
|
@@ -298,9 +295,9 @@ type ItemLink = {
|
|
|
298
295
|
url: string;
|
|
299
296
|
};
|
|
300
297
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
298
|
+
* List of repeated items sharing the same fields, displayed as a table.
|
|
299
|
+
* The state is a map `item key → fields`; key order is display order.
|
|
300
|
+
* Add, delete and move are component actions, mounted with `schemaComponent`.
|
|
304
301
|
*/
|
|
305
302
|
export declare class Repeater extends Field {
|
|
306
303
|
private _schema;
|
|
@@ -309,26 +306,26 @@ export declare class Repeater extends Field {
|
|
|
309
306
|
private _maxItems;
|
|
310
307
|
private _itemLinks;
|
|
311
308
|
static make(name: string): Repeater;
|
|
312
|
-
/**
|
|
309
|
+
/** Item fields: a function called for each item. */
|
|
313
310
|
schema(factory: () => Field[]): this;
|
|
314
|
-
/**
|
|
311
|
+
/** Table display, one column per field. */
|
|
315
312
|
table(columns: TableColumn[]): this;
|
|
316
313
|
defaultItems(count: number): this;
|
|
317
314
|
maxItems(count: number): this;
|
|
318
315
|
private _reorderable;
|
|
319
|
-
/**
|
|
316
|
+
/** `false`: items keep their order (e.g. a relationship without an order column). */
|
|
320
317
|
reorderable(condition?: boolean): this;
|
|
321
|
-
/**
|
|
318
|
+
/** Link shown on each row (an item action pointing to a URL). */
|
|
322
319
|
extraItemLink(resolver: (ctx: {
|
|
323
320
|
item: Record<string, unknown>;
|
|
324
321
|
key: string;
|
|
325
322
|
}) => ItemLink | null): this;
|
|
326
|
-
/**
|
|
323
|
+
/** Well-formed items only: keys come from the browser, so only simple keys are kept. */
|
|
327
324
|
getItems(): Record<string, Record<string, unknown>>;
|
|
328
325
|
private setItems;
|
|
329
326
|
private itemDefaults;
|
|
330
327
|
getDefaultState(): unknown;
|
|
331
|
-
/**
|
|
328
|
+
/** Relationship records → `record-<id>` items, limited to the declared fields. */
|
|
332
329
|
hydrateState(value: unknown): unknown;
|
|
333
330
|
dehydrateState(): unknown;
|
|
334
331
|
getChildSchemas(): Schema[];
|
|
@@ -336,8 +333,7 @@ export declare class Repeater extends Field {
|
|
|
336
333
|
getActions(): Action[];
|
|
337
334
|
toHtml(): Promise<string>;
|
|
338
335
|
}
|
|
339
|
-
/**
|
|
340
|
-
/** Heure (port de TimePicker, saisie native) : l'état est `HH:MM` avec `seconds(false)`, `HH:MM:SS` sinon. */
|
|
336
|
+
/** Native time input: the state is `HH:MM` with `seconds(false)`, `HH:MM:SS` otherwise. */
|
|
341
337
|
export declare class TimePicker extends Field {
|
|
342
338
|
private _seconds;
|
|
343
339
|
static make(name: string): TimePicker;
|
|
@@ -345,7 +341,7 @@ export declare class TimePicker extends Field {
|
|
|
345
341
|
hydrateState(value: unknown): unknown;
|
|
346
342
|
toHtml(): Promise<string>;
|
|
347
343
|
}
|
|
348
|
-
/**
|
|
344
|
+
/** Native `datetime-local` input: the saved state is `YYYY-MM-DD HH:MM:SS`. */
|
|
349
345
|
export declare class DateTimePicker extends Field {
|
|
350
346
|
private _seconds;
|
|
351
347
|
static make(name: string): DateTimePicker;
|
|
@@ -353,7 +349,7 @@ export declare class DateTimePicker extends Field {
|
|
|
353
349
|
dehydrateState(state: unknown): unknown;
|
|
354
350
|
toHtml(): Promise<string>;
|
|
355
351
|
}
|
|
356
|
-
/**
|
|
352
|
+
/** Single choice as radio buttons. */
|
|
357
353
|
export declare class Radio extends Field {
|
|
358
354
|
private _options;
|
|
359
355
|
private _descriptions;
|
|
@@ -361,9 +357,9 @@ export declare class Radio extends Field {
|
|
|
361
357
|
private _live;
|
|
362
358
|
static make(name: string): Radio;
|
|
363
359
|
options(options: Options): this;
|
|
364
|
-
/**
|
|
360
|
+
/** Helper text per value, under the option label. */
|
|
365
361
|
descriptions(descriptions: Record<string, string>): this;
|
|
366
|
-
/** Options
|
|
362
|
+
/** Options side by side. */
|
|
367
363
|
inline(condition?: boolean): this;
|
|
368
364
|
live(condition?: boolean): this;
|
|
369
365
|
getValidationRules(): Promise<Rule[]>;
|
|
@@ -377,31 +373,31 @@ export declare class Textarea extends Field {
|
|
|
377
373
|
maxLength(length: number): this;
|
|
378
374
|
toHtml(): Promise<string>;
|
|
379
375
|
}
|
|
380
|
-
/**
|
|
376
|
+
/** Tag list input: the state is an array of strings. */
|
|
381
377
|
export declare class TagsInput extends Field {
|
|
382
378
|
private _placeholder;
|
|
383
379
|
private _suggestions;
|
|
384
380
|
private _splitKeys;
|
|
385
381
|
static make(name: string): TagsInput;
|
|
386
382
|
placeholder(text: string | null): this;
|
|
387
|
-
/**
|
|
383
|
+
/** Values suggested while typing. */
|
|
388
384
|
suggestions(suggestions: string[]): this;
|
|
389
|
-
/**
|
|
385
|
+
/** Keys that confirm the current tag, besides Enter (`['Tab', ',']`). */
|
|
390
386
|
splitKeys(keys: string[]): this;
|
|
391
387
|
getDefaultState(): unknown;
|
|
392
388
|
hydrateState(value: unknown): unknown;
|
|
393
|
-
/**
|
|
389
|
+
/** Only non-empty strings are saved, whatever shape the browser sends. */
|
|
394
390
|
dehydrateState(state: unknown): unknown;
|
|
395
391
|
toHtml(): Promise<string>;
|
|
396
392
|
}
|
|
397
|
-
/**
|
|
393
|
+
/** On/off switch. */
|
|
398
394
|
export declare class Toggle extends Field {
|
|
399
395
|
static make(name: string): Toggle;
|
|
400
396
|
getDefaultState(): unknown;
|
|
401
397
|
hydrateState(value: unknown): unknown;
|
|
402
398
|
toHtml(): Promise<string>;
|
|
403
399
|
}
|
|
404
|
-
/**
|
|
400
|
+
/** Single choice shown as buttons. */
|
|
405
401
|
export declare class ToggleButtons extends Field {
|
|
406
402
|
private _options;
|
|
407
403
|
private _inline;
|
|
@@ -410,16 +406,16 @@ export declare class ToggleButtons extends Field {
|
|
|
410
406
|
private _icons;
|
|
411
407
|
static make(name: string): ToggleButtons;
|
|
412
408
|
private _live;
|
|
413
|
-
/**
|
|
409
|
+
/** Sends the state to the server as soon as it changes. */
|
|
414
410
|
live(condition?: boolean): this;
|
|
415
|
-
/**
|
|
411
|
+
/** Color per value (e.g. from an enum). */
|
|
416
412
|
colors(colors: Record<string, string>): this;
|
|
417
|
-
/**
|
|
413
|
+
/** Icon per value. */
|
|
418
414
|
icons(icons: Record<string, string>): this;
|
|
419
415
|
options(options: Options): this;
|
|
420
|
-
/**
|
|
416
|
+
/** Buttons side by side. */
|
|
421
417
|
inline(condition?: boolean): this;
|
|
422
|
-
/**
|
|
418
|
+
/** Buttons joined into a single group. */
|
|
423
419
|
grouped(condition?: boolean): this;
|
|
424
420
|
getValidationRules(): Promise<Rule[]>;
|
|
425
421
|
toHtml(): Promise<string>;
|
|
@@ -428,16 +424,16 @@ type RichDocument = {
|
|
|
428
424
|
type: 'doc';
|
|
429
425
|
content?: unknown[];
|
|
430
426
|
};
|
|
431
|
-
/** HTML
|
|
427
|
+
/** Stored HTML → TipTap document. Parsing drops anything the schema does not know (scripts, event attributes, `javascript:` links). */
|
|
432
428
|
export declare function richHtmlToDocument(html: string | null | undefined): RichDocument;
|
|
433
429
|
/**
|
|
434
|
-
*
|
|
435
|
-
*
|
|
430
|
+
* TipTap document → HTML to save, or null if empty or invalid. The document comes from the browser,
|
|
431
|
+
* so it is rendered then re-parsed to keep only what the schema accepts.
|
|
436
432
|
*/
|
|
437
433
|
export declare function richDocumentToHtml(document: unknown): string | null;
|
|
438
434
|
/**
|
|
439
|
-
*
|
|
440
|
-
*
|
|
435
|
+
* Rich text editor: the browser works on a TipTap document, the database receives HTML.
|
|
436
|
+
* Not supported yet: attachments, custom blocks, mentions.
|
|
441
437
|
*/
|
|
442
438
|
export declare class RichEditor extends Field {
|
|
443
439
|
static make(name: string): RichEditor;
|
|
@@ -451,14 +447,14 @@ export declare class RichEditor extends Field {
|
|
|
451
447
|
getCustomBlockPreviewsForJs(): unknown[];
|
|
452
448
|
getUploadedFileAttachmentTemporaryUrl(): null;
|
|
453
449
|
saveUploadedFileAttachmentAndGetUrl(): null;
|
|
454
|
-
/**
|
|
450
|
+
/** Toolbar "link" action: a modal (URL, new tab), then commands sent back to the browser editor. */
|
|
455
451
|
getActions(): Action[];
|
|
456
452
|
toHtml(): Promise<string>;
|
|
457
453
|
}
|
|
458
|
-
/**
|
|
454
|
+
/** Color picker (hex format). */
|
|
459
455
|
export declare class ColorPicker extends Field {
|
|
460
456
|
static make(name: string): ColorPicker;
|
|
461
|
-
/**
|
|
457
|
+
/** Hex format: the only one supported, kept for API compatibility. */
|
|
462
458
|
hex(): this;
|
|
463
459
|
constructor(name: string);
|
|
464
460
|
toHtml(): Promise<string>;
|
|
@@ -468,22 +464,22 @@ export declare class Checkbox extends Field {
|
|
|
468
464
|
getDefaultState(): unknown;
|
|
469
465
|
toHtml(): Promise<string>;
|
|
470
466
|
}
|
|
471
|
-
/**
|
|
467
|
+
/** Checkboxes for a list of values (no search or "select all" yet). */
|
|
472
468
|
export declare class CheckboxList extends Field {
|
|
473
469
|
private _options;
|
|
474
470
|
private _optionColumns;
|
|
475
471
|
static make(name: string): CheckboxList;
|
|
476
472
|
options(options: Options): this;
|
|
477
|
-
/**
|
|
473
|
+
/** Number of columns the options are spread over (from `lg`). */
|
|
478
474
|
columns(columns: number | null): this;
|
|
479
475
|
getDefaultState(): unknown;
|
|
480
476
|
hydrateState(value: unknown): unknown;
|
|
481
|
-
/**
|
|
477
|
+
/** Only offered values are kept, without duplicates, in option order. */
|
|
482
478
|
dehydrateState(state: unknown): unknown;
|
|
483
479
|
getValidationRules(): Promise<Rule[]>;
|
|
484
480
|
toHtml(): Promise<string>;
|
|
485
481
|
}
|
|
486
|
-
/**
|
|
482
|
+
/** Free-form key/value pairs, saved as an object. */
|
|
487
483
|
export declare class KeyValue extends Field {
|
|
488
484
|
private _keyLabel;
|
|
489
485
|
private _valueLabel;
|
|
@@ -495,11 +491,11 @@ export declare class KeyValue extends Field {
|
|
|
495
491
|
getDefaultState(): unknown;
|
|
496
492
|
private static toPairs;
|
|
497
493
|
hydrateState(value: unknown): unknown;
|
|
498
|
-
/**
|
|
494
|
+
/** Flat object of strings: empty keys, nested objects and dangerous keys are dropped; 200 pairs at most. */
|
|
499
495
|
dehydrateState(state: unknown): unknown;
|
|
500
496
|
toHtml(): Promise<string>;
|
|
501
497
|
}
|
|
502
|
-
/**
|
|
498
|
+
/** Developer-written JavaScript expression (e.g. a Slider tooltip formatter), inserted as is: never put user data in it. */
|
|
503
499
|
export declare class RawJs {
|
|
504
500
|
readonly js: string;
|
|
505
501
|
constructor(js: string);
|
|
@@ -507,9 +503,9 @@ export declare class RawJs {
|
|
|
507
503
|
toString(): string;
|
|
508
504
|
}
|
|
509
505
|
/**
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
506
|
+
* Markdown editor (EasyMDE). The state is raw Markdown text, to sanitize before any HTML display.
|
|
507
|
+
* Attachments are not supported (no `attachFiles` button by default); when read-only (`disabled()`),
|
|
508
|
+
* the text is shown escaped, without Markdown conversion.
|
|
513
509
|
*/
|
|
514
510
|
export declare class MarkdownEditor extends Field {
|
|
515
511
|
private _toolbarButtons;
|
|
@@ -518,20 +514,20 @@ export declare class MarkdownEditor extends Field {
|
|
|
518
514
|
private _placeholder;
|
|
519
515
|
private _live;
|
|
520
516
|
static make(name: string): MarkdownEditor;
|
|
521
|
-
/**
|
|
517
|
+
/** Toolbar buttons, grouped (`[['bold', 'italic'], ['undo', 'redo']]`) or flat. */
|
|
522
518
|
toolbarButtons(buttons: (string | string[])[]): this;
|
|
523
|
-
/**
|
|
519
|
+
/** Removes buttons; with no argument, removes them all. */
|
|
524
520
|
disableToolbarButtons(names?: string[]): this;
|
|
525
521
|
disableAllToolbarButtons(condition?: boolean): this;
|
|
526
|
-
/**
|
|
522
|
+
/** Adds buttons (in a separate group). */
|
|
527
523
|
enableToolbarButtons(names: string[]): this;
|
|
528
524
|
getToolbarButtons(): (string | string[])[];
|
|
529
525
|
hasToolbarButton(name: string): boolean;
|
|
530
|
-
/**
|
|
526
|
+
/** Minimum height of the editing area (`10rem` by default). */
|
|
531
527
|
minHeight(height: string | null): this;
|
|
532
528
|
maxHeight(height: string | null): this;
|
|
533
529
|
placeholder(text: string | null): this;
|
|
534
|
-
/**
|
|
530
|
+
/** Sends the state to the server while typing (`debounce` in milliseconds), or on blur with `onBlur`. */
|
|
535
531
|
live(options?: {
|
|
536
532
|
onBlur?: boolean;
|
|
537
533
|
debounce?: number | null;
|
|
@@ -545,18 +541,18 @@ export declare class MarkdownEditor extends Field {
|
|
|
545
541
|
saveUploadedFileAttachmentAndGetUrl(): null;
|
|
546
542
|
toHtml(): Promise<string>;
|
|
547
543
|
}
|
|
548
|
-
/**
|
|
544
|
+
/** Code editor (CodeMirror): highlighting from `language()`, line wrapping with `wrap()`. */
|
|
549
545
|
export declare class CodeEditor extends Field {
|
|
550
546
|
private _language;
|
|
551
547
|
private _canWrap;
|
|
552
548
|
private _live;
|
|
553
549
|
static make(name: string): CodeEditor;
|
|
554
|
-
/**
|
|
550
|
+
/** Language: `cpp`, `css`, `go`, `html`, `java`, `javascript`, `json`, `markdown`, `php`, `python`, `sql`, `xml`, `yaml`. */
|
|
555
551
|
language(language: string | null): this;
|
|
556
552
|
getLanguage(): string | null;
|
|
557
553
|
/**
|
|
558
|
-
*
|
|
559
|
-
*
|
|
554
|
+
* Wraps long lines. Called with an HTML string, it is the inherited field wrapper,
|
|
555
|
+
* which the component's rendering uses.
|
|
560
556
|
*/
|
|
561
557
|
wrap(condition?: any, options?: any): any;
|
|
562
558
|
canWrap(): boolean;
|
|
@@ -569,8 +565,8 @@ export declare class CodeEditor extends Field {
|
|
|
569
565
|
toHtml(): Promise<string>;
|
|
570
566
|
}
|
|
571
567
|
/**
|
|
572
|
-
*
|
|
573
|
-
*
|
|
568
|
+
* Slider (noUiSlider): one value, or several handles when the state is a list (`default([20, 70])`).
|
|
569
|
+
* Required by default; bounds, step and numeric type are checked on the server.
|
|
574
570
|
*/
|
|
575
571
|
export declare class Slider extends Field {
|
|
576
572
|
private _minValue;
|
|
@@ -598,35 +594,35 @@ export declare class Slider extends Field {
|
|
|
598
594
|
range(minValue: number, maxValue: number): this;
|
|
599
595
|
minValue(value: number): this;
|
|
600
596
|
maxValue(value: number): this;
|
|
601
|
-
/**
|
|
597
|
+
/** Step between values; `1` requires an integer, otherwise the value must be a multiple of the step. */
|
|
602
598
|
step(step: number | null): this;
|
|
603
|
-
/**
|
|
599
|
+
/** Minimum / maximum gap between two handles. */
|
|
604
600
|
minDifference(difference: number | null): this;
|
|
605
601
|
maxDifference(difference: number | null): this;
|
|
606
|
-
/**
|
|
602
|
+
/** Forbidden margin at the ends: a number, or `[start, end]`. */
|
|
607
603
|
rangePadding(padding: number | [number, number] | null): this;
|
|
608
|
-
/**
|
|
604
|
+
/** Colored track segments, one boolean per segment (`[true, false]` by default). */
|
|
609
605
|
fillTrack(fill?: boolean[] | null): this;
|
|
610
606
|
vertical(condition?: boolean): this;
|
|
611
|
-
/**
|
|
607
|
+
/** Right to left (top to bottom for a vertical slider, the default when vertical). */
|
|
612
608
|
rtl(condition?: boolean | null): this;
|
|
613
|
-
/**
|
|
609
|
+
/** Handle behavior (`tap`, `drag`, `fixed`, `snap`, `unconstrained`…); `null`: none. */
|
|
614
610
|
behavior(behavior?: string | string[] | null): this;
|
|
615
|
-
/**
|
|
611
|
+
/** Handle tooltips: a boolean, one boolean per handle, or a `RawJs` formatting `$value`. */
|
|
616
612
|
tooltips(tooltips?: boolean | RawJs | (boolean | RawJs)[]): this;
|
|
617
|
-
/**
|
|
613
|
+
/** Pips: `range` (default), `steps`, `positions`, `count`, `values`. */
|
|
618
614
|
pips(mode?: string | null, density?: number | null): this;
|
|
619
615
|
pipsMode(mode: string | null): this;
|
|
620
616
|
pipsDensity(density: number | null): this;
|
|
621
|
-
/**
|
|
617
|
+
/** Pip formatter (a `RawJs` receiving `$value`). */
|
|
622
618
|
pipsFormatter(formatter: RawJs | null): this;
|
|
623
619
|
pipsValues(values: number | number[] | null): this;
|
|
624
620
|
steppedPips(condition?: boolean): this;
|
|
625
|
-
/**
|
|
621
|
+
/** Pip filter (a `RawJs` receiving `$value`). */
|
|
626
622
|
pipsFilter(filter: RawJs | null): this;
|
|
627
|
-
/**
|
|
623
|
+
/** Non-linear scale (`{ '10%': 500, '50%': 4000 }`). */
|
|
628
624
|
nonLinearPoints(points: Record<string, number | number[]> | null): this;
|
|
629
|
-
/**
|
|
625
|
+
/** Decimal places of the saved value. */
|
|
630
626
|
decimalPlaces(places: number | null): this;
|
|
631
627
|
live(options?: {
|
|
632
628
|
onBlur?: boolean;
|
|
@@ -640,35 +636,34 @@ export declare class Slider extends Field {
|
|
|
640
636
|
hydrateState(value: unknown): unknown;
|
|
641
637
|
dehydrateState(state: unknown): unknown;
|
|
642
638
|
getValidationRules(): Promise<Rule[]>;
|
|
643
|
-
/**
|
|
639
|
+
/** A `RawJs` becomes a `{ to: ($value) => … }` formatter object. */
|
|
644
640
|
private static formatters;
|
|
645
641
|
toHtml(): Promise<string>;
|
|
646
642
|
}
|
|
647
|
-
/**
|
|
643
|
+
/** Hidden field: an `<input type="hidden">` bound to the state, with no label or grid slot. */
|
|
648
644
|
export declare class Hidden extends Field {
|
|
649
645
|
constructor(name: string);
|
|
650
646
|
static make(name: string): Hidden;
|
|
651
647
|
toHtml(): Promise<string>;
|
|
652
648
|
}
|
|
653
|
-
/**
|
|
649
|
+
/** One-time code: one box per digit; the state is a digit string of exactly `length()` characters. */
|
|
654
650
|
export declare class OneTimeCodeInput extends Field {
|
|
655
651
|
private _length;
|
|
656
652
|
private _submitOnCompletion;
|
|
657
653
|
private _readOnly;
|
|
658
654
|
constructor(name: string);
|
|
659
655
|
static make(name: string): OneTimeCodeInput;
|
|
660
|
-
/**
|
|
656
|
+
/** Number of digits (6 by default). */
|
|
661
657
|
length(length: number): this;
|
|
662
658
|
getLength(): number;
|
|
663
|
-
/**
|
|
659
|
+
/** Submits the form as soon as the last digit is typed. */
|
|
664
660
|
submitOnCompletion(condition?: boolean): this;
|
|
665
661
|
readOnly(condition?: boolean): this;
|
|
666
662
|
hydrateState(value: unknown): unknown;
|
|
667
663
|
toHtml(): Promise<string>;
|
|
668
664
|
}
|
|
669
665
|
/**
|
|
670
|
-
*
|
|
671
|
-
* Rien n'est enregistré. Une `HtmlString` est insérée telle quelle.
|
|
666
|
+
* Read-only text in a form. Nothing is saved. An `HtmlString` is inserted as is.
|
|
672
667
|
*/
|
|
673
668
|
export declare class Placeholder extends Component {
|
|
674
669
|
private _label;
|
|
@@ -682,20 +677,20 @@ export declare class Placeholder extends Component {
|
|
|
682
677
|
content(content: Lazy<string | number | HtmlString | null, ComponentContext>): this;
|
|
683
678
|
toHtml(): Promise<string>;
|
|
684
679
|
}
|
|
685
|
-
/**
|
|
680
|
+
/** Fills the default state of every field in a schema. */
|
|
686
681
|
export declare function fillSchema(schema: Schema, target: Record<string, unknown>): void;
|
|
687
|
-
/**
|
|
682
|
+
/** Fills the form state from a record, field by field. */
|
|
688
683
|
export declare function fillSchemaFromRecord(schema: Schema, target: Record<string, unknown>, record: Record<string, unknown>): void;
|
|
689
|
-
/**
|
|
684
|
+
/** Validates every visible field of a schema; returns errors by state path. */
|
|
690
685
|
export declare function validateSchema(schema: Schema): Promise<Record<string, string[]>>;
|
|
691
|
-
/**
|
|
686
|
+
/** State to save: only declared, visible, dehydrated fields; an empty string becomes `null`. */
|
|
692
687
|
export declare function getSchemaState(schema: Schema): Promise<Record<string, unknown>>;
|
|
693
688
|
type StepHook = (ctx: ComponentContext) => void | Promise<void>;
|
|
694
|
-
/**
|
|
689
|
+
/** Throw from a step's `beforeValidation` / `afterValidation` to stay on the current step. */
|
|
695
690
|
export declare class Halt extends Error {
|
|
696
691
|
constructor();
|
|
697
692
|
}
|
|
698
|
-
/**
|
|
693
|
+
/** A wizard step: a label, an optional description and icon, and its own schema. */
|
|
699
694
|
export declare class Step extends Component {
|
|
700
695
|
private children;
|
|
701
696
|
private _columns;
|
|
@@ -712,9 +707,9 @@ export declare class Step extends Component {
|
|
|
712
707
|
description(description: string | null): this;
|
|
713
708
|
icon(name: string | null): this;
|
|
714
709
|
completedIcon(name: string | null): this;
|
|
715
|
-
/**
|
|
710
|
+
/** Runs before the step is validated, on "Next"; throw `Halt` to stay on the step. */
|
|
716
711
|
beforeValidation(callback: StepHook | null): this;
|
|
717
|
-
/**
|
|
712
|
+
/** Runs after a successful validation, before moving to the next step; throw `Halt` to stay on the step. */
|
|
718
713
|
afterValidation(callback: StepHook | null): this;
|
|
719
714
|
getLabel(): string;
|
|
720
715
|
getDescription(): string | null;
|
|
@@ -724,12 +719,12 @@ export declare class Step extends Component {
|
|
|
724
719
|
callAfterValidation(): Promise<void>;
|
|
725
720
|
getChildSchemas(): Schema[];
|
|
726
721
|
toHtml(): Promise<string>;
|
|
727
|
-
/**
|
|
722
|
+
/** Step panel: a `<form>` when the wizard has a submit handler (Enter goes to the next step, or saves on the last one). */
|
|
728
723
|
toStepHtml(submitHandler: string | null, hasHeader: boolean): Promise<string>;
|
|
729
724
|
}
|
|
730
725
|
/**
|
|
731
|
-
*
|
|
732
|
-
*
|
|
726
|
+
* Multi-step wizard: every step is rendered, the browser only shows the current one.
|
|
727
|
+
* "Next" validates the current step on the server before moving on, unless the wizard is `skippable()`.
|
|
733
728
|
*/
|
|
734
729
|
export declare class Wizard extends Component {
|
|
735
730
|
private steps;
|
|
@@ -748,36 +743,36 @@ export declare class Wizard extends Component {
|
|
|
748
743
|
static make(steps?: Step[]): Wizard;
|
|
749
744
|
schema(steps: Step[]): this;
|
|
750
745
|
label(label: string | null): this;
|
|
751
|
-
/**
|
|
746
|
+
/** Steps can be visited in any order, without validation. */
|
|
752
747
|
skippable(condition?: boolean): this;
|
|
753
|
-
/**
|
|
748
|
+
/** Step shown on open (1-based). */
|
|
754
749
|
startOnStep(step: number): this;
|
|
755
|
-
/**
|
|
750
|
+
/** `false`: no card around the wizard (as on a resource page). */
|
|
756
751
|
contained(condition?: boolean): this;
|
|
757
752
|
hiddenHeader(condition?: boolean): this;
|
|
758
|
-
/** Action
|
|
753
|
+
/** Action shown instead of "Back" on the first step. */
|
|
759
754
|
cancelAction(action: Action | null): this;
|
|
760
|
-
/** Action
|
|
755
|
+
/** Action shown instead of "Next" on the last step. */
|
|
761
756
|
submitAction(action: Action | null): this;
|
|
762
|
-
/**
|
|
757
|
+
/** Alpine expression run when the last step is submitted from the keyboard (e.g. `$wire.create()`). */
|
|
763
758
|
alpineSubmitHandler(handler: string | null): this;
|
|
764
|
-
/**
|
|
759
|
+
/** Keeps the current step in the URL (`?step=…`). */
|
|
765
760
|
persistStepInQueryString(key?: string | null): this;
|
|
766
761
|
nextAction(modify: ((action: Action) => Action | void) | null): this;
|
|
767
762
|
previousAction(modify: ((action: Action) => Action | void) | null): this;
|
|
768
763
|
getKey(): string;
|
|
769
764
|
getExposedMethods(): string[];
|
|
770
|
-
/**
|
|
765
|
+
/** "Next" re-renders the component so the step's validation errors show up. */
|
|
771
766
|
isRenderlessMethod(): boolean;
|
|
772
767
|
getChildSchemas(): Schema[];
|
|
773
768
|
private getSteps;
|
|
774
|
-
/**
|
|
769
|
+
/** Called by the browser on "Next": validates the current step, then announces the next one. */
|
|
775
770
|
nextStep(currentStepIndex?: unknown, currentStepKey?: unknown): Promise<void>;
|
|
776
|
-
/**
|
|
771
|
+
/** Going back happens in the browser; this exposed method is a no-op the front end still calls. */
|
|
777
772
|
previousStep(): void;
|
|
778
773
|
toHtml(): Promise<string>;
|
|
779
774
|
}
|
|
780
|
-
/**
|
|
775
|
+
/** Temporary file received by the runtime (see @navette-js/wire). */
|
|
781
776
|
export type TemporaryUpload = {
|
|
782
777
|
id: string;
|
|
783
778
|
path: string;
|
|
@@ -792,19 +787,19 @@ export type UploadedFileInfo = {
|
|
|
792
787
|
type: string;
|
|
793
788
|
url: string;
|
|
794
789
|
};
|
|
795
|
-
/**
|
|
790
|
+
/** Saved state item when the field does not store files itself (`storeFiles(false)`): an already saved file, or a temporary file to process. */
|
|
796
791
|
export type FileUploadEntry = {
|
|
797
792
|
key: string;
|
|
798
793
|
} | {
|
|
799
794
|
file: TemporaryUpload;
|
|
800
795
|
};
|
|
801
|
-
/**
|
|
796
|
+
/** Where files go once the form is saved. */
|
|
802
797
|
export interface FileStorage {
|
|
803
|
-
/**
|
|
798
|
+
/** Stores a temporary file and returns its key (relative path). */
|
|
804
799
|
store(file: TemporaryUpload, directory: string | null): Promise<string>;
|
|
805
800
|
info(key: string): Promise<UploadedFileInfo | null>;
|
|
806
801
|
}
|
|
807
|
-
/**
|
|
802
|
+
/** Local disk storage, served under a public URL. File names are random; the extension comes from the detected type. */
|
|
808
803
|
export declare class LocalFileStorage implements FileStorage {
|
|
809
804
|
private root;
|
|
810
805
|
private baseUrl;
|
|
@@ -814,12 +809,12 @@ export declare class LocalFileStorage implements FileStorage {
|
|
|
814
809
|
info(key: string): Promise<UploadedFileInfo | null>;
|
|
815
810
|
}
|
|
816
811
|
/**
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
*
|
|
812
|
+
* File upload (FilePond).
|
|
813
|
+
* State: `{ <file key>: <stored key> | 'livewire-file:<temporary id>' }`. A stored key from the browser is only accepted
|
|
814
|
+
* if the record being edited already has it, so nobody can claim someone else's file.
|
|
820
815
|
*/
|
|
821
816
|
export declare class FileUpload extends Field {
|
|
822
|
-
/**
|
|
817
|
+
/** Application-wide default storage. */
|
|
823
818
|
static storage: FileStorage | null;
|
|
824
819
|
private _multiple;
|
|
825
820
|
private _maxFiles;
|
|
@@ -833,38 +828,38 @@ export declare class FileUpload extends Field {
|
|
|
833
828
|
static make(name: string): FileUpload;
|
|
834
829
|
multiple(condition?: boolean): this;
|
|
835
830
|
maxFiles(count: number | null): this;
|
|
836
|
-
/**
|
|
831
|
+
/** Maximum file size, in kilobytes. */
|
|
837
832
|
maxSize(kilobytes: number | null): this;
|
|
838
833
|
reorderable(condition?: boolean): this;
|
|
839
|
-
/**
|
|
834
|
+
/** Accepted MIME types (`image/jpeg`, `image/*`…), checked against the received file's content. */
|
|
840
835
|
acceptedFileTypes(types: string[] | null): this;
|
|
841
836
|
image(): this;
|
|
842
837
|
directory(directory: string | null): this;
|
|
843
838
|
storage(storage: FileStorage): this;
|
|
844
|
-
/** `false
|
|
839
|
+
/** `false`: the field stores nothing itself; the data receives `FileUploadEntry` items for the adapter to process (media). */
|
|
845
840
|
storeFiles(condition?: boolean): this;
|
|
846
|
-
/**
|
|
841
|
+
/** Info about an already saved file (name, size, type, URL), when it does not come from the storage. */
|
|
847
842
|
getUploadedFileUsing(resolver: (key: string, ctx: ComponentContext) => UploadedFileInfo | null | Promise<UploadedFileInfo | null>): this;
|
|
848
843
|
getDefaultState(): unknown;
|
|
849
844
|
hydrateState(value: unknown): unknown;
|
|
850
845
|
private get uploads();
|
|
851
846
|
private getStorage;
|
|
852
|
-
/**
|
|
847
|
+
/** Sanitized state entries: safe file key, string value. */
|
|
853
848
|
private entries;
|
|
854
|
-
/**
|
|
849
|
+
/** Stored keys the current record already owns: the only ones accepted back from the browser. */
|
|
855
850
|
private originalKeys;
|
|
856
851
|
private isTemporary;
|
|
857
852
|
getExposedMethods(): string[];
|
|
858
853
|
getUploadedFiles(): Promise<Record<string, UploadedFileInfo | null>>;
|
|
859
854
|
private writeState;
|
|
860
|
-
/**
|
|
855
|
+
/** Removes a file from the field. A stored file is only deleted by the application when the form is saved. */
|
|
861
856
|
removeUploadedFile(fileKey: unknown): void;
|
|
862
857
|
deleteUploadedFile(fileKey: unknown): void;
|
|
863
858
|
reorderUploadedFiles(fileKeys: unknown): void;
|
|
864
859
|
getValidationRules(): Promise<Rule[]>;
|
|
865
|
-
/**
|
|
860
|
+
/** Validates the whole state, even when empty (a required field without files must fail). */
|
|
866
861
|
validate(): Promise<string[]>;
|
|
867
|
-
/**
|
|
862
|
+
/** On save: temporary files are stored, unrecognized existing keys are dropped. */
|
|
868
863
|
dehydrateState(): Promise<unknown>;
|
|
869
864
|
toHtml(): Promise<string>;
|
|
870
865
|
}
|