@yoyaflow/yoya-ui 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.
@@ -0,0 +1,486 @@
1
+ import type {
2
+ ChildInput,
3
+ ElementFactory,
4
+ ElementOptions,
5
+ SetupCallback,
6
+ SetupInput
7
+ } from './core.js';
8
+ import type { HtmlElementNode } from './html.js';
9
+
10
+ export interface SelectOption {
11
+ label?: ChildInput;
12
+ value?: unknown;
13
+ disabled?: boolean;
14
+ [key: string]: any;
15
+ }
16
+
17
+ export interface CheckboxOption {
18
+ label?: ChildInput;
19
+ value?: unknown;
20
+ disabled?: boolean;
21
+ [key: string]: any;
22
+ }
23
+
24
+ export interface RadioOption {
25
+ label?: ChildInput;
26
+ value?: unknown;
27
+ disabled?: boolean;
28
+ [key: string]: any;
29
+ }
30
+
31
+ export interface UploadFileEntry {
32
+ name?: string;
33
+ size?: number;
34
+ status?: 'ready' | 'uploading' | 'success' | 'error' | string;
35
+ progress?: number;
36
+ [key: string]: any;
37
+ }
38
+
39
+ export interface UploadOptions {
40
+ name?: string;
41
+ accept?: string;
42
+ multiple?: boolean;
43
+ disabled?: boolean;
44
+ [key: string]: any;
45
+ }
46
+
47
+ /** Color picker with a custom popup: palette, alpha slider and effect preview. */
48
+ export class VColorPicker extends HtmlElementNode {
49
+ value(): string | null;
50
+ value(next: string | null): VColorPicker;
51
+ alpha(): number;
52
+ alpha(next: number): VColorPicker;
53
+ rgba(): string | null;
54
+ clearValue(): VColorPicker;
55
+ open(value?: boolean): VColorPicker;
56
+ close(): VColorPicker;
57
+ toggle(): VColorPicker;
58
+ palette(): string[];
59
+ palette(next: Array<string>): VColorPicker;
60
+ change(): Array<(color: string | null, alpha: number, picker: VColorPicker) => void>;
61
+ change(
62
+ handler: (color: string | null, alpha: number, picker: VColorPicker) => void
63
+ ): VColorPicker;
64
+ onChange(
65
+ handler: (color: string | null, alpha: number, picker: VColorPicker) => void
66
+ ): VColorPicker;
67
+ }
68
+
69
+ /** Slider input with min/max/step constraints. */
70
+ export class VSlider extends HtmlElementNode {
71
+ value(): number;
72
+ value(next: number): VSlider;
73
+ min(): number;
74
+ min(next: number): VSlider;
75
+ max(): number;
76
+ max(next: number): VSlider;
77
+ step(): number;
78
+ step(next: number): VSlider;
79
+ showValue(): boolean;
80
+ showValue(next: boolean): VSlider;
81
+ vertical(): boolean;
82
+ vertical(next: boolean): VSlider;
83
+ disabled(): boolean;
84
+ disabled(next: boolean): VSlider;
85
+ required(): boolean;
86
+ required(next: boolean): VSlider;
87
+ change(): Array<(value: number, slider: VSlider) => void>;
88
+ change(handler: (value: number, slider: VSlider) => void): VSlider;
89
+ onChange(handler: (value: number, slider: VSlider) => void): VSlider;
90
+ }
91
+
92
+ export interface CascaderOption {
93
+ label: string;
94
+ value: string | number;
95
+ children?: CascaderOption[];
96
+ }
97
+
98
+ /** Cascader: multi-level selection from an option tree. */
99
+ export class VCascader extends HtmlElementNode {
100
+ options(): CascaderOption[];
101
+ options(next: Array<CascaderOption>): VCascader;
102
+ value(): Array<string | number>;
103
+ value(next: Array<string | number> | string | number | null): VCascader;
104
+ disabled(): boolean;
105
+ disabled(next: boolean): VCascader;
106
+ required(): boolean;
107
+ required(next: boolean): VCascader;
108
+ placeholder(): string;
109
+ placeholder(next: string): VCascader;
110
+ open(value?: boolean): VCascader;
111
+ close(): VCascader;
112
+ toggle(): VCascader;
113
+ change(): Array<(value: Array<string | number>, cascader: VCascader) => void>;
114
+ change(handler: (value: Array<string | number>, cascader: VCascader) => void): VCascader;
115
+ onChange(handler: (value: Array<string | number>, cascader: VCascader) => void): VCascader;
116
+ }
117
+
118
+ /** Tags input: enter/comma adds tags, backspace/× removes. */
119
+ export class VTagsInput extends HtmlElementNode {
120
+ value(): string[];
121
+ value(next: Array<string | number>): VTagsInput;
122
+ disabled(): boolean;
123
+ disabled(next: boolean): VTagsInput;
124
+ required(): boolean;
125
+ required(next: boolean): VTagsInput;
126
+ placeholder(): string;
127
+ placeholder(next: string): VTagsInput;
128
+ change(): Array<(value: string[], tagsInput: VTagsInput) => void>;
129
+ change(handler: (value: string[], tagsInput: VTagsInput) => void): VTagsInput;
130
+ onChange(handler: (value: string[], tagsInput: VTagsInput) => void): VTagsInput;
131
+ }
132
+
133
+ export interface AutocompleteOption {
134
+ label: string;
135
+ value: string | number;
136
+ }
137
+
138
+ /** Autocomplete input with a suggestion list. */
139
+ export class VAutocomplete extends HtmlElementNode {
140
+ value(): string;
141
+ value(next: string | number | null): VAutocomplete;
142
+ options(
143
+ next:
144
+ | Array<AutocompleteOption | string | number>
145
+ | ((query: string) => Array<AutocompleteOption | string | number>)
146
+ ): VAutocomplete;
147
+ limit(): number;
148
+ limit(next: number): VAutocomplete;
149
+ disabled(): boolean;
150
+ disabled(next: boolean): VAutocomplete;
151
+ required(): boolean;
152
+ required(next: boolean): VAutocomplete;
153
+ placeholder(): string;
154
+ placeholder(next: string): VAutocomplete;
155
+ close(): VAutocomplete;
156
+ change(): Array<(value: string, autocomplete: VAutocomplete) => void>;
157
+ change(handler: (value: string, autocomplete: VAutocomplete) => void): VAutocomplete;
158
+ onChange(handler: (value: string, autocomplete: VAutocomplete) => void): VAutocomplete;
159
+ }
160
+
161
+ /** Text input control. */
162
+ export class VInput extends HtmlElementNode {
163
+ type(): string;
164
+ type(value: string): VInput;
165
+ value(): string | number | null;
166
+ value(value: string | number | null): VInput;
167
+ text(value?: ChildInput): this;
168
+ content(value: ChildInput): VInput;
169
+ placeholder(value: string): VInput;
170
+ disabled(value: boolean): VInput;
171
+ readonly(value: boolean): VInput;
172
+ required(value: boolean): VInput;
173
+ error(value: string | boolean | null): VInput;
174
+ clearable(value: boolean): VInput;
175
+ clear(): VInput;
176
+ }
177
+
178
+ /** Time input with mode support. */
179
+ export class VTimer extends VInput {
180
+ mode(): string;
181
+ mode(value: string): VTimer;
182
+ type(): string;
183
+ type(value: string): this;
184
+ }
185
+
186
+ /** Time range input (start/end). */
187
+ export class VTimerRange extends HtmlElementNode {
188
+ mode(): string;
189
+ mode(value: string): VTimerRange;
190
+ start(): string;
191
+ start(value: string): VTimerRange;
192
+ end(): string;
193
+ end(value: string): VTimerRange;
194
+ value(): { start: string; end: string };
195
+ value(value: { start?: string; end?: string }): VTimerRange;
196
+ disabled(value: boolean): VTimerRange;
197
+ readonly(value: boolean): VTimerRange;
198
+ required(value: boolean): VTimerRange;
199
+ }
200
+
201
+ /** Multi-line textarea. */
202
+ export class VTextarea extends HtmlElementNode {
203
+ value(): string | number | null;
204
+ value(value: string | number | null): VTextarea;
205
+ text(value?: ChildInput): this;
206
+ content(value: ChildInput): VTextarea;
207
+ placeholder(value: string): VTextarea;
208
+ disabled(value: boolean): VTextarea;
209
+ readonly(value: boolean): VTextarea;
210
+ required(value: boolean): VTextarea;
211
+ error(value: string | boolean | null): VTextarea;
212
+ rows(value: number): VTextarea;
213
+ clearable(value: boolean): VTextarea;
214
+ clear(): VTextarea;
215
+ }
216
+
217
+ /** Select control. */
218
+ export class VSelect extends HtmlElementNode {
219
+ value(): unknown;
220
+ value(value: unknown): VSelect;
221
+ text(value?: ChildInput): this;
222
+ content(value: ChildInput): VSelect;
223
+ placeholder(value: string): VSelect;
224
+ options(value: Array<string | number | SelectOption>): VSelect;
225
+ disabled(value: boolean): VSelect;
226
+ required(value: boolean): VSelect;
227
+ error(value: string | boolean | null): VSelect;
228
+ clearable(value: boolean): VSelect;
229
+ clear(): VSelect;
230
+ }
231
+
232
+ /** Shared boolean control (checkbox/switch/radio) surface. */
233
+ export interface BooleanControl extends HtmlElementNode {
234
+ label(content?: ChildInput): this;
235
+ text(content?: ChildInput): this;
236
+ content(content: ChildInput): BooleanControl;
237
+ description(content: ChildInput): BooleanControl;
238
+ checked(): boolean;
239
+ checked(value: boolean): BooleanControl;
240
+ value(): unknown;
241
+ value(value: unknown): BooleanControl;
242
+ optionValue(value: unknown): BooleanControl;
243
+ disabled(value: boolean): BooleanControl;
244
+ required(value: boolean): BooleanControl;
245
+ indeterminate(value: boolean): BooleanControl;
246
+ }
247
+
248
+ export class VCheckbox extends HtmlElementNode {
249
+ label(content?: ChildInput): this;
250
+ text(content?: ChildInput): this;
251
+ content(content: ChildInput): VCheckbox;
252
+ description(content: ChildInput): VCheckbox;
253
+ checked(): boolean;
254
+ checked(value: boolean): VCheckbox;
255
+ value(): unknown;
256
+ value(value: unknown): VCheckbox;
257
+ optionValue(value: unknown): VCheckbox;
258
+ disabled(value: boolean): VCheckbox;
259
+ required(value: boolean): VCheckbox;
260
+ indeterminate(value: boolean): VCheckbox;
261
+ }
262
+
263
+ export class VSwitch extends HtmlElementNode {
264
+ label(content?: ChildInput): this;
265
+ text(content?: ChildInput): this;
266
+ content(content: ChildInput): VSwitch;
267
+ description(content: ChildInput): VSwitch;
268
+ checked(): boolean;
269
+ checked(value: boolean): VSwitch;
270
+ value(): unknown;
271
+ value(value: unknown): VSwitch;
272
+ optionValue(value: unknown): VSwitch;
273
+ disabled(value: boolean): VSwitch;
274
+ required(value: boolean): VSwitch;
275
+ }
276
+
277
+ export class VRadio extends HtmlElementNode {
278
+ label(content?: ChildInput): this;
279
+ text(content?: ChildInput): this;
280
+ content(content: ChildInput): VRadio;
281
+ description(content: ChildInput): VRadio;
282
+ checked(): boolean;
283
+ checked(value: boolean): VRadio;
284
+ value(): unknown;
285
+ value(value: unknown): VRadio;
286
+ optionValue(value: unknown): VRadio;
287
+ disabled(value: boolean): VRadio;
288
+ required(value: boolean): VRadio;
289
+ }
290
+
291
+ /** Checkbox group. */
292
+ export class VCheckboxes extends HtmlElementNode {
293
+ multiple(value: boolean): VCheckboxes;
294
+ required(value: boolean): VCheckboxes;
295
+ disabled(value: boolean): VCheckboxes;
296
+ options(value: Array<string | number | CheckboxOption>): VCheckboxes;
297
+ value(): unknown[];
298
+ value(value: Array<unknown>): VCheckboxes;
299
+ checkedValues(value: Array<unknown>): VCheckboxes;
300
+ clear(): VCheckboxes;
301
+ }
302
+
303
+ /** Radio group. */
304
+ export class VRadios extends HtmlElementNode {
305
+ required(value: boolean): VRadios;
306
+ disabled(value: boolean): VRadios;
307
+ change(handler: (value: unknown) => void): VRadios;
308
+ options(value: Array<string | number | RadioOption>): VRadios;
309
+ value(): unknown;
310
+ value(value: unknown): VRadios;
311
+ checkedValue(value: unknown): VRadios;
312
+ clear(): VRadios;
313
+ }
314
+
315
+ /** Field wrapper with view/edit modes. */
316
+ export class VField extends HtmlElementNode {
317
+ label(value?: ChildInput): this;
318
+ hint(value: ChildInput): VField;
319
+ error(value: string | boolean | null): VField;
320
+ display(value: ChildInput): VField;
321
+ control(setup: ChildInput | SetupCallback<HtmlElementNode>): VField;
322
+ editor(setup: ChildInput | SetupCallback<HtmlElementNode>): VField;
323
+ value(): unknown;
324
+ value(value: unknown): VField;
325
+ mode(): 'view' | 'edit';
326
+ mode(value: 'view' | 'edit'): VField;
327
+ view(): VField;
328
+ edit(): VField;
329
+ }
330
+
331
+ export type FormItemRule = (
332
+ value: unknown,
333
+ values: Record<string, unknown>
334
+ ) => string | boolean | undefined | void;
335
+
336
+ /** Form item with name/label/validation. */
337
+ export class VFormItem extends HtmlElementNode {
338
+ label(value?: ChildInput): this;
339
+ hint(value: ChildInput): VFormItem;
340
+ error(value: string | boolean | null): VFormItem;
341
+ control(setup: ChildInput | SetupCallback<HtmlElementNode>): VFormItem;
342
+ editor(setup: ChildInput | SetupCallback<HtmlElementNode>): VFormItem;
343
+ required(value?: boolean, messageOrOptions?: string | Record<string, unknown>): VFormItem;
344
+ validate(callback: (error: string | null, value: unknown) => void): VFormItem;
345
+ rules(callbacks: FormItemRule | FormItemRule[]): VFormItem;
346
+ value(): unknown;
347
+ value(value: unknown): VFormItem;
348
+ }
349
+
350
+ /** Form with values/validation/reset/submit. */
351
+ export class VForm extends HtmlElementNode {
352
+ values(): Record<string, unknown>;
353
+ values(value: Record<string, unknown>): VForm;
354
+ value(name: string): unknown;
355
+ validate(): boolean;
356
+ reset(): VForm;
357
+ submit(): boolean;
358
+ }
359
+
360
+ /** Star rating control. */
361
+ export class VRate extends HtmlElementNode {
362
+ value(): number;
363
+ value(value: number): VRate;
364
+ count(): number;
365
+ count(value: number): VRate;
366
+ max(): number;
367
+ max(value: number): VRate;
368
+ allowHalf(value: boolean): VRate;
369
+ allowClear(value: boolean): VRate;
370
+ clearable(value: boolean): VRate;
371
+ character(value: string): VRate;
372
+ size(): string;
373
+ size(value: string): VRate;
374
+ disabled(value: boolean): VRate;
375
+ readonly(value: boolean): VRate;
376
+ required(value: boolean): VRate;
377
+ error(value: string | boolean | null): VRate;
378
+ clear(): VRate;
379
+ }
380
+
381
+ /** File upload with dropzone. */
382
+ export class VUpload extends HtmlElementNode {
383
+ accept(value: string): VUpload;
384
+ multiple(value: boolean): VUpload;
385
+ disabled(value: boolean): VUpload;
386
+ files(): UploadFileEntry[];
387
+ files(value: Array<File | UploadFileEntry>): VUpload;
388
+ items(): UploadFileEntry[];
389
+ items(value: Array<File | UploadFileEntry>): VUpload;
390
+ value(): UploadFileEntry[];
391
+ value(value: Array<File | UploadFileEntry>): VUpload;
392
+ addFiles(fileList: FileList | File[]): VUpload;
393
+ remove(indexOrName: number | string): VUpload;
394
+ clear(): VUpload;
395
+ status(index: number, value: string): VUpload;
396
+ progress(index?: number, value?: number): this;
397
+ dropZone(setup: SetupInput<HtmlElementNode>): VUpload;
398
+ }
399
+
400
+ /** Avatar upload with preview. */
401
+ export class VAvatarUpload extends HtmlElementNode {
402
+ accept(value: string): VAvatarUpload;
403
+ shape(): string;
404
+ shape(value: 'circle' | 'square' | string): VAvatarUpload;
405
+ size(): number | string;
406
+ size(value: number | string): VAvatarUpload;
407
+ disabled(value: boolean): VAvatarUpload;
408
+ value(): UploadFileEntry | null;
409
+ value(value: File | UploadFileEntry | null): VAvatarUpload;
410
+ files(): UploadFileEntry[];
411
+ files(value: Array<File | UploadFileEntry>): VAvatarUpload;
412
+ items(): UploadFileEntry[];
413
+ items(value: Array<File | UploadFileEntry>): VAvatarUpload;
414
+ addFiles(fileList: FileList | File[]): VAvatarUpload;
415
+ remove(): VAvatarUpload;
416
+ clear(): VAvatarUpload;
417
+ }
418
+
419
+ export const vInput: ElementFactory<VInput>;
420
+ export const vTimer: ElementFactory<VTimer>;
421
+ export const vTimerRange: ElementFactory<VTimerRange>;
422
+ export const vTextarea: ElementFactory<VTextarea>;
423
+ export const vSelect: ElementFactory<VSelect>;
424
+ export const vCheckbox: ElementFactory<VCheckbox>;
425
+ export const vSwitch: ElementFactory<VSwitch>;
426
+ export const vRadio: ElementFactory<VRadio>;
427
+ export const vCheckboxes: ElementFactory<VCheckboxes>;
428
+ export const vRadios: ElementFactory<VRadios>;
429
+ export const vField: ElementFactory<VField>;
430
+ export const vFormItem: ElementFactory<VFormItem>;
431
+ export const vForm: ElementFactory<VForm>;
432
+ export const vRate: ElementFactory<VRate>;
433
+ export const vUpload: ElementFactory<VUpload>;
434
+ export const vAvatarUpload: ElementFactory<VAvatarUpload>;
435
+ export const vColorPicker: ElementFactory<VColorPicker> & {
436
+ (first?: SetupInput<VColorPicker> | null, callback?: SetupCallback<VColorPicker>): VColorPicker;
437
+ };
438
+ export const vSlider: ElementFactory<VSlider>;
439
+ export const vCascader: ElementFactory<VCascader>;
440
+ export const vTagsInput: ElementFactory<VTagsInput>;
441
+ export const vAutocomplete: ElementFactory<VAutocomplete>;
442
+
443
+ /** Parent-shortcut surface merged onto HtmlElementNode. */
444
+ export interface FormParentShortcuts {
445
+ vInput(first?: SetupInput<VInput> | null, callback?: SetupCallback<VInput>): VInput;
446
+ vTimer(first?: SetupInput<VTimer> | null, callback?: SetupCallback<VTimer>): VTimer;
447
+ vTimerRange(
448
+ first?: SetupInput<VTimerRange> | null,
449
+ callback?: SetupCallback<VTimerRange>
450
+ ): VTimerRange;
451
+ vTextarea(first?: SetupInput<VTextarea> | null, callback?: SetupCallback<VTextarea>): VTextarea;
452
+ vSelect(first?: SetupInput<VSelect> | null, callback?: SetupCallback<VSelect>): VSelect;
453
+ vCheckbox(first?: SetupInput<VCheckbox> | null, callback?: SetupCallback<VCheckbox>): VCheckbox;
454
+ vSwitch(first?: SetupInput<VSwitch> | null, callback?: SetupCallback<VSwitch>): VSwitch;
455
+ vRadio(first?: SetupInput<VRadio> | null, callback?: SetupCallback<VRadio>): VRadio;
456
+ vCheckboxes(
457
+ first?: SetupInput<VCheckboxes> | null,
458
+ callback?: SetupCallback<VCheckboxes>
459
+ ): VCheckboxes;
460
+ vRadios(first?: SetupInput<VRadios> | null, callback?: SetupCallback<VRadios>): VRadios;
461
+ vField(first?: SetupInput<VField> | null, callback?: SetupCallback<VField>): VField;
462
+ vFormItem(first?: SetupInput<VFormItem> | null, callback?: SetupCallback<VFormItem>): VFormItem;
463
+ vForm(first?: SetupInput<VForm> | null, callback?: SetupCallback<VForm>): VForm;
464
+ vRate(first?: SetupInput<VRate> | null, callback?: SetupCallback<VRate>): VRate;
465
+ vUpload(first?: SetupInput<VUpload> | null, callback?: SetupCallback<VUpload>): VUpload;
466
+ vAvatarUpload(
467
+ first?: SetupInput<VAvatarUpload> | null,
468
+ callback?: SetupCallback<VAvatarUpload>
469
+ ): VAvatarUpload;
470
+ vColorPicker(
471
+ first?: SetupInput<VColorPicker> | null,
472
+ callback?: SetupCallback<VColorPicker>
473
+ ): VColorPicker;
474
+ vSlider(first?: SetupInput<VSlider> | null, callback?: SetupCallback<VSlider>): VSlider;
475
+ vCascader(first?: SetupInput<VCascader> | null, callback?: SetupCallback<VCascader>): VCascader;
476
+ vTagsInput(
477
+ first?: SetupInput<VTagsInput> | null,
478
+ callback?: SetupCallback<VTagsInput>
479
+ ): VTagsInput;
480
+ vAutocomplete(
481
+ first?: SetupInput<VAutocomplete> | null,
482
+ callback?: SetupCallback<VAutocomplete>
483
+ ): VAutocomplete;
484
+ }
485
+
486
+ export type { ElementOptions };