@framesquared/form 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +781 -0
- package/dist/index.js +2256 -0
- package/dist/index.js.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,781 @@
|
|
|
1
|
+
import { Component, ComponentConfig, Container, ContainerConfig } from '@framesquared/component';
|
|
2
|
+
import { Panel, PanelConfig } from '@framesquared/ui';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @framesquared/form – Field (base class)
|
|
6
|
+
*
|
|
7
|
+
* Abstract base for all form fields. Provides label rendering,
|
|
8
|
+
* value management, dirty tracking, validation framework, and
|
|
9
|
+
* error display. Subclasses implement the actual input element.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface FieldConfig extends ComponentConfig {
|
|
13
|
+
name?: string;
|
|
14
|
+
value?: unknown;
|
|
15
|
+
fieldLabel?: string;
|
|
16
|
+
labelAlign?: 'left' | 'top' | 'right';
|
|
17
|
+
labelWidth?: number;
|
|
18
|
+
labelSeparator?: string;
|
|
19
|
+
hideLabel?: boolean;
|
|
20
|
+
emptyText?: string;
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
validateOnChange?: boolean;
|
|
24
|
+
validateOnBlur?: boolean;
|
|
25
|
+
msgTarget?: 'side' | 'under' | 'qtip' | 'title' | 'none';
|
|
26
|
+
submitValue?: boolean;
|
|
27
|
+
}
|
|
28
|
+
declare class Field extends Component {
|
|
29
|
+
static $className: string;
|
|
30
|
+
protected _name: string;
|
|
31
|
+
protected _originalValue: unknown;
|
|
32
|
+
protected _value: unknown;
|
|
33
|
+
protected _errors: string[];
|
|
34
|
+
protected _wasValid: boolean;
|
|
35
|
+
protected _wasDirty: boolean;
|
|
36
|
+
protected _labelEl: HTMLElement | null;
|
|
37
|
+
protected _bodyWrapEl: HTMLElement | null;
|
|
38
|
+
protected _errorEl: HTMLElement | null;
|
|
39
|
+
constructor(config?: FieldConfig);
|
|
40
|
+
protected initialize(): void;
|
|
41
|
+
protected afterRender(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Called after the full subclass afterRender chain completes.
|
|
44
|
+
* Subclasses that need post-render init should call super.afterRender()
|
|
45
|
+
* then do their work — this method sets initial validity once
|
|
46
|
+
* the input element exists.
|
|
47
|
+
*/
|
|
48
|
+
protected initFieldValidity(): void;
|
|
49
|
+
getValue(): unknown;
|
|
50
|
+
setValue(value: unknown): void;
|
|
51
|
+
getRawValue(): string;
|
|
52
|
+
setRawValue(value: string): void;
|
|
53
|
+
protected onValueChange(oldValue: unknown, newValue: unknown): void;
|
|
54
|
+
isDirty(): boolean;
|
|
55
|
+
reset(): void;
|
|
56
|
+
protected checkDirty(): void;
|
|
57
|
+
getErrors(): string[];
|
|
58
|
+
isValid(): boolean;
|
|
59
|
+
validate(): boolean;
|
|
60
|
+
/** Subclasses override to add field-specific validation. */
|
|
61
|
+
protected computeErrors(): string[];
|
|
62
|
+
markInvalid(errors: string | string[]): void;
|
|
63
|
+
clearInvalid(): void;
|
|
64
|
+
protected checkValidity(): void;
|
|
65
|
+
protected showErrors(): void;
|
|
66
|
+
protected removeErrorEl(): void;
|
|
67
|
+
getSubmitValue(): string;
|
|
68
|
+
getName(): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @framesquared/form – TextField
|
|
73
|
+
*
|
|
74
|
+
* A text input field with validation (allowBlank, minLength, maxLength,
|
|
75
|
+
* regex, vtype), character masking, triggers, and keyboard events.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
interface TriggerConfig {
|
|
79
|
+
type: string;
|
|
80
|
+
handler?: (field: TextField, trigger: HTMLElement, event: Event) => void;
|
|
81
|
+
cls?: string;
|
|
82
|
+
}
|
|
83
|
+
interface TextFieldConfig extends FieldConfig {
|
|
84
|
+
maxLength?: number;
|
|
85
|
+
minLength?: number;
|
|
86
|
+
allowBlank?: boolean;
|
|
87
|
+
regex?: RegExp;
|
|
88
|
+
regexText?: string;
|
|
89
|
+
vtype?: string;
|
|
90
|
+
maskRe?: RegExp;
|
|
91
|
+
stripCharsRe?: RegExp;
|
|
92
|
+
inputType?: string;
|
|
93
|
+
triggers?: TriggerConfig[];
|
|
94
|
+
}
|
|
95
|
+
declare class TextField extends Field {
|
|
96
|
+
static $className: string;
|
|
97
|
+
protected _inputEl: HTMLInputElement;
|
|
98
|
+
constructor(config?: TextFieldConfig);
|
|
99
|
+
protected afterRender(): void;
|
|
100
|
+
getInputEl(): HTMLInputElement;
|
|
101
|
+
getValue(): string;
|
|
102
|
+
setValue(value: unknown): void;
|
|
103
|
+
getRawValue(): string;
|
|
104
|
+
setRawValue(value: string): void;
|
|
105
|
+
getSubmitValue(): string;
|
|
106
|
+
protected computeErrors(): string[];
|
|
107
|
+
protected attachInputEvents(cfg: TextFieldConfig): void;
|
|
108
|
+
protected renderTrigger(trig: TriggerConfig): void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @framesquared/form – TextArea
|
|
113
|
+
* Multi-line text field using <textarea>. Supports rows, cols,
|
|
114
|
+
* and auto-grow (grow, growMin, growMax).
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
interface TextAreaConfig extends TextFieldConfig {
|
|
118
|
+
rows?: number;
|
|
119
|
+
cols?: number;
|
|
120
|
+
grow?: boolean;
|
|
121
|
+
growMin?: number;
|
|
122
|
+
growMax?: number;
|
|
123
|
+
}
|
|
124
|
+
declare class TextArea extends TextField {
|
|
125
|
+
static $className: string;
|
|
126
|
+
private _textareaEl;
|
|
127
|
+
constructor(config?: TextAreaConfig);
|
|
128
|
+
protected afterRender(): void;
|
|
129
|
+
getInputEl(): HTMLInputElement;
|
|
130
|
+
getValue(): string;
|
|
131
|
+
setValue(value: unknown): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @framesquared/form – DisplayField
|
|
136
|
+
* Read-only display of a value. No input element, no form submission.
|
|
137
|
+
*/
|
|
138
|
+
|
|
139
|
+
interface DisplayFieldConfig extends FieldConfig {
|
|
140
|
+
renderer?: (value: unknown) => string;
|
|
141
|
+
}
|
|
142
|
+
declare class DisplayField extends Field {
|
|
143
|
+
static $className: string;
|
|
144
|
+
private _displayEl;
|
|
145
|
+
constructor(config?: DisplayFieldConfig);
|
|
146
|
+
protected initialize(): void;
|
|
147
|
+
protected afterRender(): void;
|
|
148
|
+
setValue(value: unknown): void;
|
|
149
|
+
getSubmitValue(): string;
|
|
150
|
+
private updateDisplay;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @framesquared/form – HiddenField
|
|
155
|
+
* Renders as <input type="hidden">. No label, no visible UI.
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
declare class HiddenField extends Field {
|
|
159
|
+
static $className: string;
|
|
160
|
+
private _hiddenInput;
|
|
161
|
+
constructor(config?: FieldConfig);
|
|
162
|
+
protected afterRender(): void;
|
|
163
|
+
getValue(): string;
|
|
164
|
+
setValue(value: unknown): void;
|
|
165
|
+
getSubmitValue(): string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @framesquared/form – VTypes
|
|
170
|
+
* Predefined validation types for text fields.
|
|
171
|
+
*/
|
|
172
|
+
interface VTypeEntry {
|
|
173
|
+
test: (value: string) => boolean;
|
|
174
|
+
regex: RegExp;
|
|
175
|
+
text: string;
|
|
176
|
+
}
|
|
177
|
+
declare const VTypes: Record<string, VTypeEntry>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @framesquared/form – NumberField
|
|
181
|
+
*
|
|
182
|
+
* Numeric input with spinner triggers for increment/decrement,
|
|
183
|
+
* min/max validation, and decimal precision formatting.
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
interface NumberFieldConfig extends TextFieldConfig {
|
|
187
|
+
minValue?: number;
|
|
188
|
+
maxValue?: number;
|
|
189
|
+
step?: number;
|
|
190
|
+
allowDecimals?: boolean;
|
|
191
|
+
decimalPrecision?: number;
|
|
192
|
+
decimalSeparator?: string;
|
|
193
|
+
autoStripChars?: boolean;
|
|
194
|
+
}
|
|
195
|
+
declare class NumberField extends TextField {
|
|
196
|
+
static $className: string;
|
|
197
|
+
private _minValue;
|
|
198
|
+
private _maxValue;
|
|
199
|
+
private _step;
|
|
200
|
+
private _allowDecimals;
|
|
201
|
+
private _decimalPrecision;
|
|
202
|
+
constructor(config?: NumberFieldConfig);
|
|
203
|
+
protected initialize(): void;
|
|
204
|
+
protected afterRender(): void;
|
|
205
|
+
getNumberValue(): number;
|
|
206
|
+
setValue(value: unknown): void;
|
|
207
|
+
private formatInputValue;
|
|
208
|
+
spinUp(): void;
|
|
209
|
+
spinDown(): void;
|
|
210
|
+
setMinValue(value: number): void;
|
|
211
|
+
setMaxValue(value: number): void;
|
|
212
|
+
protected computeErrors(): string[];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @framesquared/form – DateField
|
|
217
|
+
*
|
|
218
|
+
* A text field for date input. Formats/parses dates using a
|
|
219
|
+
* configurable format string. Has an expand trigger for opening
|
|
220
|
+
* a DatePicker dropdown. Validates min/max date boundaries.
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
interface DateFieldConfig extends TextFieldConfig {
|
|
224
|
+
format?: string;
|
|
225
|
+
minValue?: Date;
|
|
226
|
+
maxValue?: Date;
|
|
227
|
+
disabledDates?: string[];
|
|
228
|
+
disabledDays?: number[];
|
|
229
|
+
showToday?: boolean;
|
|
230
|
+
}
|
|
231
|
+
declare class DateField extends TextField {
|
|
232
|
+
static $className: string;
|
|
233
|
+
private _format;
|
|
234
|
+
private _minDate;
|
|
235
|
+
private _maxDate;
|
|
236
|
+
private _dateValue;
|
|
237
|
+
constructor(config?: DateFieldConfig);
|
|
238
|
+
protected initialize(): void;
|
|
239
|
+
protected afterRender(): void;
|
|
240
|
+
getDateValue(): Date | null;
|
|
241
|
+
setValue(value: unknown): void;
|
|
242
|
+
setMinValue(date: Date): void;
|
|
243
|
+
setMaxValue(date: Date): void;
|
|
244
|
+
protected computeErrors(): string[];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @framesquared/form – DatePicker
|
|
249
|
+
*
|
|
250
|
+
* Full calendar widget. Shows a month grid with day cells,
|
|
251
|
+
* prev/next navigation, today button, and disabled date support.
|
|
252
|
+
* Fires 'select' when a date is clicked.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
interface DatePickerConfig extends ComponentConfig {
|
|
256
|
+
value?: Date;
|
|
257
|
+
minValue?: Date;
|
|
258
|
+
maxValue?: Date;
|
|
259
|
+
disabledDays?: number[];
|
|
260
|
+
disabledDates?: string[];
|
|
261
|
+
showToday?: boolean;
|
|
262
|
+
}
|
|
263
|
+
declare class DatePicker extends Component {
|
|
264
|
+
static $className: string;
|
|
265
|
+
private _viewDate;
|
|
266
|
+
private _selectedDate;
|
|
267
|
+
private _minDate;
|
|
268
|
+
private _maxDate;
|
|
269
|
+
private _disabledDays;
|
|
270
|
+
private _gridEl;
|
|
271
|
+
private _headerEl;
|
|
272
|
+
constructor(config?: DatePickerConfig);
|
|
273
|
+
protected initialize(): void;
|
|
274
|
+
protected afterRender(): void;
|
|
275
|
+
private buildUI;
|
|
276
|
+
private renderGrid;
|
|
277
|
+
private navigate;
|
|
278
|
+
private isDateDisabled;
|
|
279
|
+
private startOfDay;
|
|
280
|
+
getSelectedDate(): Date;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @framesquared/form – ColorPicker
|
|
285
|
+
*
|
|
286
|
+
* A grid of color swatches. Fires 'select' with the hex color string.
|
|
287
|
+
*/
|
|
288
|
+
|
|
289
|
+
interface ColorPickerConfig extends ComponentConfig {
|
|
290
|
+
colors?: string[];
|
|
291
|
+
}
|
|
292
|
+
declare class ColorPicker extends Component {
|
|
293
|
+
static $className: string;
|
|
294
|
+
private _colors;
|
|
295
|
+
private _selectedColor;
|
|
296
|
+
constructor(config?: ColorPickerConfig);
|
|
297
|
+
protected initialize(): void;
|
|
298
|
+
protected afterRender(): void;
|
|
299
|
+
private buildSwatches;
|
|
300
|
+
getSelectedColor(): string | null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* @framesquared/form – ComboBox
|
|
305
|
+
*
|
|
306
|
+
* A text field with a dropdown list of options. Supports local
|
|
307
|
+
* and remote query modes, multi-select, forceSelection, typeAhead,
|
|
308
|
+
* and keyboard navigation.
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
interface ComboBoxConfig extends TextFieldConfig {
|
|
312
|
+
store?: any;
|
|
313
|
+
displayField?: string;
|
|
314
|
+
valueField?: string;
|
|
315
|
+
queryMode?: 'local' | 'remote';
|
|
316
|
+
queryParam?: string;
|
|
317
|
+
queryDelay?: number;
|
|
318
|
+
minChars?: number;
|
|
319
|
+
triggerAction?: 'all' | 'last' | 'query';
|
|
320
|
+
forceSelection?: boolean;
|
|
321
|
+
typeAhead?: boolean;
|
|
322
|
+
multiSelect?: boolean;
|
|
323
|
+
delimiter?: string;
|
|
324
|
+
editable?: boolean;
|
|
325
|
+
autoSelect?: boolean;
|
|
326
|
+
pageSize?: number;
|
|
327
|
+
}
|
|
328
|
+
declare class ComboBox extends TextField {
|
|
329
|
+
static $className: string;
|
|
330
|
+
_store: any;
|
|
331
|
+
private _displayField;
|
|
332
|
+
private _valueField;
|
|
333
|
+
private _queryMode;
|
|
334
|
+
private _forceSelection;
|
|
335
|
+
private _multiSelect;
|
|
336
|
+
private _delimiter;
|
|
337
|
+
private _expanded;
|
|
338
|
+
private _selection;
|
|
339
|
+
private _boundList;
|
|
340
|
+
private _selectedValue;
|
|
341
|
+
constructor(config?: ComboBoxConfig);
|
|
342
|
+
protected initialize(): void;
|
|
343
|
+
protected afterRender(): void;
|
|
344
|
+
expand(): void;
|
|
345
|
+
collapse(): void;
|
|
346
|
+
isExpanded(): boolean;
|
|
347
|
+
select(record: any): void;
|
|
348
|
+
deselect(record: any): void;
|
|
349
|
+
getSelection(): any[];
|
|
350
|
+
private updateMultiDisplay;
|
|
351
|
+
doQuery(queryString: string): void;
|
|
352
|
+
findRecord(field: string, value: unknown): any | null;
|
|
353
|
+
getValue(): any;
|
|
354
|
+
protected onDestroy(): void;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @framesquared/form – TagField
|
|
359
|
+
*
|
|
360
|
+
* A ComboBox variant that shows selected values as removable tag
|
|
361
|
+
* chips in the input area. Always multi-select.
|
|
362
|
+
*/
|
|
363
|
+
|
|
364
|
+
interface TagFieldConfig extends ComboBoxConfig {
|
|
365
|
+
filterPickList?: boolean;
|
|
366
|
+
stacked?: boolean;
|
|
367
|
+
createNewOnEnter?: boolean;
|
|
368
|
+
}
|
|
369
|
+
declare class TagField extends ComboBox {
|
|
370
|
+
static $className: string;
|
|
371
|
+
private _tagWrapEl;
|
|
372
|
+
constructor(config?: TagFieldConfig);
|
|
373
|
+
protected initialize(): void;
|
|
374
|
+
protected afterRender(): void;
|
|
375
|
+
select(record: any): void;
|
|
376
|
+
deselect(record: any): void;
|
|
377
|
+
private renderTags;
|
|
378
|
+
getValue(): any;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* @framesquared/form – Checkbox
|
|
383
|
+
*
|
|
384
|
+
* A checkbox field using native <input type="checkbox">.
|
|
385
|
+
* Returns inputValue when checked, uncheckedValue when unchecked.
|
|
386
|
+
*/
|
|
387
|
+
|
|
388
|
+
interface CheckboxConfig extends FieldConfig {
|
|
389
|
+
inputValue?: string;
|
|
390
|
+
uncheckedValue?: string;
|
|
391
|
+
checked?: boolean;
|
|
392
|
+
boxLabel?: string;
|
|
393
|
+
}
|
|
394
|
+
declare class Checkbox extends Field {
|
|
395
|
+
static $className: string;
|
|
396
|
+
protected _inputEl: HTMLInputElement;
|
|
397
|
+
protected _checked: boolean;
|
|
398
|
+
protected _inputValue: string;
|
|
399
|
+
protected _uncheckedValue: string;
|
|
400
|
+
constructor(config?: CheckboxConfig);
|
|
401
|
+
protected initialize(): void;
|
|
402
|
+
protected afterRender(): void;
|
|
403
|
+
getValue(): string;
|
|
404
|
+
isChecked(): boolean;
|
|
405
|
+
setChecked(checked: boolean): void;
|
|
406
|
+
getSubmitValue(): string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @framesquared/form – Radio
|
|
411
|
+
*
|
|
412
|
+
* A radio button field. Uses native <input type="radio"> with
|
|
413
|
+
* group tracking to ensure single selection per name group.
|
|
414
|
+
*/
|
|
415
|
+
|
|
416
|
+
declare class Radio extends Checkbox {
|
|
417
|
+
static $className: string;
|
|
418
|
+
constructor(config?: CheckboxConfig);
|
|
419
|
+
protected afterRender(): void;
|
|
420
|
+
setChecked(checked: boolean): void;
|
|
421
|
+
getGroupValue(): string;
|
|
422
|
+
protected onDestroy(): void;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @framesquared/form – CheckboxGroup
|
|
427
|
+
*
|
|
428
|
+
* A container for Checkbox fields arranged in columns.
|
|
429
|
+
* getValue returns array of checked values.
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
interface CheckboxGroupConfig extends ContainerConfig {
|
|
433
|
+
columns?: number;
|
|
434
|
+
vertical?: boolean;
|
|
435
|
+
}
|
|
436
|
+
declare class CheckboxGroup extends Container {
|
|
437
|
+
static $className: string;
|
|
438
|
+
constructor(config?: CheckboxGroupConfig);
|
|
439
|
+
protected afterRender(): void;
|
|
440
|
+
getValue(): string[];
|
|
441
|
+
setValue(values: string[]): void;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @framesquared/form – RadioGroup
|
|
446
|
+
*
|
|
447
|
+
* A container for Radio fields. Only one radio can be selected
|
|
448
|
+
* at a time (enforced by Radio's group mechanism).
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
interface RadioGroupConfig extends ContainerConfig {
|
|
452
|
+
columns?: number;
|
|
453
|
+
vertical?: boolean;
|
|
454
|
+
}
|
|
455
|
+
declare class RadioGroup extends Container {
|
|
456
|
+
static $className: string;
|
|
457
|
+
constructor(config?: RadioGroupConfig);
|
|
458
|
+
protected afterRender(): void;
|
|
459
|
+
getValue(): string;
|
|
460
|
+
setValue(value: string): void;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* @framesquared/form – BoundList
|
|
465
|
+
*
|
|
466
|
+
* The dropdown list used by ComboBox. Renders items from a Store,
|
|
467
|
+
* supports hover highlighting, keyboard navigation (up/down/enter/esc),
|
|
468
|
+
* and fires itemclick/select events.
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
interface BoundListConfig extends ComponentConfig {
|
|
472
|
+
store?: any;
|
|
473
|
+
displayField?: string;
|
|
474
|
+
}
|
|
475
|
+
declare class BoundList extends Component {
|
|
476
|
+
static $className: string;
|
|
477
|
+
private _store;
|
|
478
|
+
private _displayField;
|
|
479
|
+
private _highlightIndex;
|
|
480
|
+
constructor(config?: BoundListConfig);
|
|
481
|
+
protected initialize(): void;
|
|
482
|
+
protected afterRender(): void;
|
|
483
|
+
refresh(): void;
|
|
484
|
+
private renderItems;
|
|
485
|
+
private highlightItem;
|
|
486
|
+
private onKeyDown;
|
|
487
|
+
getStore(): any;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @framesquared/form – BasicForm
|
|
492
|
+
*
|
|
493
|
+
* Core form logic separated from UI. Manages a collection of
|
|
494
|
+
* Field instances, collects/distributes values, validates,
|
|
495
|
+
* and handles submit/load via fetch().
|
|
496
|
+
*/
|
|
497
|
+
|
|
498
|
+
interface SubmitOptions {
|
|
499
|
+
url?: string;
|
|
500
|
+
method?: string;
|
|
501
|
+
params?: Record<string, unknown>;
|
|
502
|
+
headers?: Record<string, string>;
|
|
503
|
+
clientValidation?: boolean;
|
|
504
|
+
jsonSubmit?: boolean;
|
|
505
|
+
}
|
|
506
|
+
interface SubmitResult {
|
|
507
|
+
success: boolean;
|
|
508
|
+
data?: any;
|
|
509
|
+
errors?: any;
|
|
510
|
+
}
|
|
511
|
+
declare class BasicForm {
|
|
512
|
+
private fields;
|
|
513
|
+
addField(field: Field): void;
|
|
514
|
+
removeField(field: Field): void;
|
|
515
|
+
getFields(): Field[];
|
|
516
|
+
findField(name: string): Field | undefined;
|
|
517
|
+
getValues(asString?: boolean, dirtyOnly?: boolean): Record<string, unknown> | string;
|
|
518
|
+
setValues(values: Record<string, unknown>): void;
|
|
519
|
+
isValid(): boolean;
|
|
520
|
+
isDirty(): boolean;
|
|
521
|
+
reset(): void;
|
|
522
|
+
clearInvalid(): void;
|
|
523
|
+
markInvalid(errors: {
|
|
524
|
+
field: string;
|
|
525
|
+
message: string;
|
|
526
|
+
}[]): void;
|
|
527
|
+
submit(url: string, options?: SubmitOptions): Promise<SubmitResult>;
|
|
528
|
+
load(url: string, options?: SubmitOptions): Promise<SubmitResult>;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* @framesquared/form – FormPanel
|
|
533
|
+
*
|
|
534
|
+
* A Panel that manages form fields. Extends Panel to provide
|
|
535
|
+
* automatic field collection, validation, value management,
|
|
536
|
+
* and submit/load via fetch().
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
interface FormPanelConfig extends PanelConfig {
|
|
540
|
+
url?: string;
|
|
541
|
+
method?: 'GET' | 'POST';
|
|
542
|
+
standardSubmit?: boolean;
|
|
543
|
+
jsonSubmit?: boolean;
|
|
544
|
+
waitMsg?: string;
|
|
545
|
+
trackResetOnLoad?: boolean;
|
|
546
|
+
fieldDefaults?: Record<string, unknown>;
|
|
547
|
+
timeout?: number;
|
|
548
|
+
}
|
|
549
|
+
declare class FormPanel extends Panel {
|
|
550
|
+
static $className: string;
|
|
551
|
+
private _basicForm;
|
|
552
|
+
private _url;
|
|
553
|
+
private _method;
|
|
554
|
+
private _jsonSubmit;
|
|
555
|
+
constructor(config?: FormPanelConfig);
|
|
556
|
+
protected initialize(): void;
|
|
557
|
+
protected afterRender(): void;
|
|
558
|
+
private collectFields;
|
|
559
|
+
private walkItems;
|
|
560
|
+
getValues(asString?: boolean, dirtyOnly?: boolean): Record<string, unknown> | string;
|
|
561
|
+
setValues(values: Record<string, unknown>): void;
|
|
562
|
+
isFormValid(): boolean;
|
|
563
|
+
isValid(): boolean;
|
|
564
|
+
isDirty(): boolean;
|
|
565
|
+
getFields(): Field[];
|
|
566
|
+
findField(name: string): Field | undefined;
|
|
567
|
+
reset(): void;
|
|
568
|
+
clearInvalid(): void;
|
|
569
|
+
markInvalid(errors: {
|
|
570
|
+
field: string;
|
|
571
|
+
message: string;
|
|
572
|
+
}[]): void;
|
|
573
|
+
hasInvalidField(): boolean;
|
|
574
|
+
submit(options?: SubmitOptions & {
|
|
575
|
+
clientValidation?: boolean;
|
|
576
|
+
}): Promise<SubmitResult>;
|
|
577
|
+
load(options?: SubmitOptions): Promise<void>;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @framesquared/form – Validators
|
|
582
|
+
*
|
|
583
|
+
* Built-in validator functions and chain runner.
|
|
584
|
+
* Each validator returns `true` on success or an error string on failure.
|
|
585
|
+
*/
|
|
586
|
+
declare function presence(value: unknown): true | string;
|
|
587
|
+
declare function length(value: unknown, opts: {
|
|
588
|
+
min?: number;
|
|
589
|
+
max?: number;
|
|
590
|
+
}): true | string;
|
|
591
|
+
declare function email(value: unknown): true | string;
|
|
592
|
+
declare function url(value: unknown): true | string;
|
|
593
|
+
declare function alpha(value: unknown): true | string;
|
|
594
|
+
declare function alphanum(value: unknown): true | string;
|
|
595
|
+
declare function range(value: unknown, opts: {
|
|
596
|
+
min?: number;
|
|
597
|
+
max?: number;
|
|
598
|
+
}): true | string;
|
|
599
|
+
declare function format(value: unknown, opts: {
|
|
600
|
+
matcher: RegExp;
|
|
601
|
+
message?: string;
|
|
602
|
+
}): true | string;
|
|
603
|
+
declare function inclusion(value: unknown, opts: {
|
|
604
|
+
list: unknown[];
|
|
605
|
+
}): true | string;
|
|
606
|
+
declare function exclusion(value: unknown, opts: {
|
|
607
|
+
list: unknown[];
|
|
608
|
+
}): true | string;
|
|
609
|
+
declare function custom(value: unknown, opts: {
|
|
610
|
+
fn: (v: unknown) => true | string;
|
|
611
|
+
}): true | string;
|
|
612
|
+
interface ChainEntry {
|
|
613
|
+
type: 'presence' | 'length' | 'email' | 'url' | 'alpha' | 'alphanum' | 'range' | 'format' | 'inclusion' | 'exclusion' | 'custom';
|
|
614
|
+
[key: string]: unknown;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Run a chain of validators against a value.
|
|
618
|
+
* Returns an array of error strings (empty if all pass).
|
|
619
|
+
*/
|
|
620
|
+
declare function validateChain(value: unknown, chain: ChainEntry[]): string[];
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* @framesquared/form – FieldContainer
|
|
624
|
+
*
|
|
625
|
+
* A Container that groups multiple Field children under a single
|
|
626
|
+
* label. Optionally combines child validation errors.
|
|
627
|
+
*/
|
|
628
|
+
|
|
629
|
+
interface FieldContainerConfig extends ContainerConfig {
|
|
630
|
+
fieldLabel?: string;
|
|
631
|
+
labelSeparator?: string;
|
|
632
|
+
combineErrors?: boolean;
|
|
633
|
+
}
|
|
634
|
+
declare class FieldContainer extends Container {
|
|
635
|
+
static $className: string;
|
|
636
|
+
constructor(config?: FieldContainerConfig);
|
|
637
|
+
protected afterRender(): void;
|
|
638
|
+
getErrors(): string[];
|
|
639
|
+
isValid(): boolean;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* @framesquared/form – Slider
|
|
644
|
+
*
|
|
645
|
+
* A slider field with draggable thumb(s) on a track. Supports
|
|
646
|
+
* min/max, increment snapping, multi-thumb, vertical mode,
|
|
647
|
+
* and full ARIA attributes.
|
|
648
|
+
*/
|
|
649
|
+
|
|
650
|
+
interface SliderConfig extends FieldConfig {
|
|
651
|
+
minValue?: number;
|
|
652
|
+
maxValue?: number;
|
|
653
|
+
increment?: number;
|
|
654
|
+
vertical?: boolean;
|
|
655
|
+
useTips?: boolean;
|
|
656
|
+
values?: number[];
|
|
657
|
+
clickToChange?: boolean;
|
|
658
|
+
animate?: boolean;
|
|
659
|
+
}
|
|
660
|
+
declare class Slider extends Field {
|
|
661
|
+
static $className: string;
|
|
662
|
+
private _min;
|
|
663
|
+
private _max;
|
|
664
|
+
private _increment;
|
|
665
|
+
private _vertical;
|
|
666
|
+
private _values;
|
|
667
|
+
private _trackEl;
|
|
668
|
+
private _thumbEls;
|
|
669
|
+
private _dragIndex;
|
|
670
|
+
private _dragCleanup;
|
|
671
|
+
constructor(config?: SliderConfig);
|
|
672
|
+
protected initialize(): void;
|
|
673
|
+
protected afterRender(): void;
|
|
674
|
+
getValue(): number;
|
|
675
|
+
setValue(value: unknown): void;
|
|
676
|
+
getValues(): number[];
|
|
677
|
+
setMinValue(min: number): void;
|
|
678
|
+
setMaxValue(max: number): void;
|
|
679
|
+
setIncrement(inc: number): void;
|
|
680
|
+
private clamp;
|
|
681
|
+
private snap;
|
|
682
|
+
private positionThumbs;
|
|
683
|
+
private updateAria;
|
|
684
|
+
private updateAllAria;
|
|
685
|
+
private setupThumbDrag;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* @framesquared/form – FileField
|
|
690
|
+
*
|
|
691
|
+
* A file upload field with a hidden <input type="file">,
|
|
692
|
+
* a browse button, and a text display showing selected filename(s).
|
|
693
|
+
*/
|
|
694
|
+
|
|
695
|
+
interface FileFieldConfig extends FieldConfig {
|
|
696
|
+
buttonText?: string;
|
|
697
|
+
buttonOnly?: boolean;
|
|
698
|
+
accept?: string;
|
|
699
|
+
multiple?: boolean;
|
|
700
|
+
}
|
|
701
|
+
declare class FileField extends Field {
|
|
702
|
+
static $className: string;
|
|
703
|
+
private _fileInput;
|
|
704
|
+
private _textDisplay;
|
|
705
|
+
private _files;
|
|
706
|
+
constructor(config?: FileFieldConfig);
|
|
707
|
+
protected initialize(): void;
|
|
708
|
+
protected afterRender(): void;
|
|
709
|
+
getValue(): FileList | null;
|
|
710
|
+
getFileInput(): HTMLInputElement;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* @framesquared/form – HtmlEditor
|
|
715
|
+
*
|
|
716
|
+
* Rich text editor using contentEditable. Provides a toolbar with
|
|
717
|
+
* formatting buttons, source edit mode, and XSS sanitization.
|
|
718
|
+
*/
|
|
719
|
+
|
|
720
|
+
interface HtmlEditorConfig extends FieldConfig {
|
|
721
|
+
enableFont?: boolean;
|
|
722
|
+
enableColors?: boolean;
|
|
723
|
+
enableLists?: boolean;
|
|
724
|
+
enableLinks?: boolean;
|
|
725
|
+
enableSourceEdit?: boolean;
|
|
726
|
+
}
|
|
727
|
+
declare class HtmlEditor extends Field {
|
|
728
|
+
static $className: string;
|
|
729
|
+
private _toolbarEl;
|
|
730
|
+
private _editorEl;
|
|
731
|
+
private _sourceEl;
|
|
732
|
+
private _sourceMode;
|
|
733
|
+
constructor(config?: HtmlEditorConfig);
|
|
734
|
+
protected initialize(): void;
|
|
735
|
+
protected afterRender(): void;
|
|
736
|
+
getValue(): string;
|
|
737
|
+
setValue(value: unknown): void;
|
|
738
|
+
execCommand(cmd: string, value?: string): void;
|
|
739
|
+
toggleSourceEdit(): void;
|
|
740
|
+
isSourceEdit(): boolean;
|
|
741
|
+
private sanitize;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* @framesquared/form – Spinner
|
|
746
|
+
*
|
|
747
|
+
* Abstract base for fields with up/down spin behavior.
|
|
748
|
+
* Extends TextField with spinner triggers and ArrowUp/ArrowDown keyboard.
|
|
749
|
+
* Subclasses implement onSpinUp() and onSpinDown().
|
|
750
|
+
*/
|
|
751
|
+
|
|
752
|
+
interface SpinnerConfig extends TextFieldConfig {
|
|
753
|
+
}
|
|
754
|
+
declare abstract class Spinner extends TextField {
|
|
755
|
+
static $className: string;
|
|
756
|
+
constructor(config?: SpinnerConfig);
|
|
757
|
+
protected afterRender(): void;
|
|
758
|
+
spinUp(): void;
|
|
759
|
+
spinDown(): void;
|
|
760
|
+
protected abstract onSpinUp(): void;
|
|
761
|
+
protected abstract onSpinDown(): void;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* @framesquared/form – DateUtil
|
|
766
|
+
*
|
|
767
|
+
* Date utility functions: format, parse, add, diff, isLeapYear, getDaysInMonth.
|
|
768
|
+
* Format tokens: Y (4-digit year), m (01-12), d (01-31),
|
|
769
|
+
* H (00-23), i (00-59), s (00-59), g (1-12), A (AM/PM).
|
|
770
|
+
*/
|
|
771
|
+
type DateUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
|
|
772
|
+
declare function formatDate(date: Date, format: string): string;
|
|
773
|
+
declare function parseDate(input: string, format: string): Date;
|
|
774
|
+
declare function addDate(date: Date, unit: DateUnit, amount: number): Date;
|
|
775
|
+
declare function diffDate(date1: Date, date2: Date, unit: DateUnit): number;
|
|
776
|
+
declare function isLeapYear(year: number): boolean;
|
|
777
|
+
declare function getDaysInMonth(year: number, month: number): number;
|
|
778
|
+
declare function getMonthName(month: number): string;
|
|
779
|
+
declare function getMonthShortName(month: number): string;
|
|
780
|
+
|
|
781
|
+
export { BasicForm, BoundList, type BoundListConfig, Checkbox, type CheckboxConfig, CheckboxGroup, type CheckboxGroupConfig, ColorPicker, type ColorPickerConfig, ComboBox, type ComboBoxConfig, DateField, type DateFieldConfig, DatePicker, type DatePickerConfig, type DateUnit, DisplayField, type DisplayFieldConfig, Field, type FieldConfig, FieldContainer, type FieldContainerConfig, FileField, type FileFieldConfig, FormPanel, type FormPanelConfig, HiddenField, HtmlEditor, type HtmlEditorConfig, NumberField, type NumberFieldConfig, Radio, RadioGroup, type RadioGroupConfig, Slider, type SliderConfig, Spinner, type SpinnerConfig, type SubmitOptions, type SubmitResult, TagField, type TagFieldConfig, TextArea, type TextAreaConfig, TextField, type TextFieldConfig, type TriggerConfig, type VTypeEntry, VTypes, addDate, alpha, alphanum, custom, diffDate, email, exclusion, format, formatDate, getDaysInMonth, getMonthName, getMonthShortName, inclusion, isLeapYear, length, parseDate, presence, range, url, validateChain };
|