@chocbite/ts-lib-ui 1.1.5 → 1.2.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.
Files changed (52) hide show
  1. package/AGENTS.md +547 -9
  2. package/README.md +3 -0
  3. package/SOURCE.md +10313 -7355
  4. package/base/index.d.mts +2 -2
  5. package/base/index.mjs +68 -5
  6. package/base/index.mjs.map +1 -1
  7. package/canvas/index.d.mts +1 -1
  8. package/canvas/index.mjs +1 -1
  9. package/composition/index.d.mts +283 -0
  10. package/composition/index.mjs +2 -0
  11. package/composition-BlntkKR0.mjs +869 -0
  12. package/composition-BlntkKR0.mjs.map +1 -0
  13. package/context-menu/index.d.mts +1 -1
  14. package/context-menu/index.mjs +1 -1
  15. package/{context-menu-CZxEGjBi.mjs → context-menu-C0KTV5zC.mjs} +2 -2
  16. package/{context-menu-CZxEGjBi.mjs.map → context-menu-C0KTV5zC.mjs.map} +1 -1
  17. package/depot_ui/index.d.mts +60 -0
  18. package/depot_ui/index.mjs +280 -0
  19. package/depot_ui/index.mjs.map +1 -0
  20. package/form/index.d.mts +2 -758
  21. package/form/index.mjs +1 -2953
  22. package/form-CJA3s46n.mjs +2961 -0
  23. package/form-CJA3s46n.mjs.map +1 -0
  24. package/icons/index.d.mts +1 -1
  25. package/{index-YNZjMIO7.d.mts → index-CApVOEcI.d.mts} +2 -2
  26. package/{index-BDWg5GX2.d.mts → index-Czy8O3me.d.mts} +6 -2
  27. package/index-DD09-bGe.d.mts +761 -0
  28. package/{index-DlBJdGaQ.d.mts → index-U3pqQjLg.d.mts} +4 -4
  29. package/{index-CvzH3M_5.d.mts → index-_y7vmunA.d.mts} +72 -8
  30. package/keyboard/index.d.mts +1 -1
  31. package/keyboard/index.mjs +1 -1
  32. package/list/index.d.mts +1 -1
  33. package/list/index.mjs +1 -1
  34. package/{list-C52-ExFw.mjs → list-CVrn4y2k.mjs} +3 -3
  35. package/{list-C52-ExFw.mjs.map → list-CVrn4y2k.mjs.map} +1 -1
  36. package/package.json +2 -2
  37. package/prompts/index.d.mts +48 -0
  38. package/prompts/index.mjs +107 -0
  39. package/prompts/index.mjs.map +1 -0
  40. package/spinner/index.d.mts +1 -1
  41. package/spinner/index.mjs +1 -1
  42. package/style.css +2049 -1640
  43. package/svg/index.d.mts +1 -1
  44. package/svg-Yz7elqnU.mjs.map +1 -1
  45. package/theme/index.d.mts +1 -1
  46. package/theme/index.mjs +1 -1
  47. package/{theme-D3YluyYr.mjs → theme-D0pRMLyT.mjs} +2 -2
  48. package/{theme-D3YluyYr.mjs.map → theme-D0pRMLyT.mjs.map} +1 -1
  49. package/form/index.mjs.map +0 -1
  50. package/test/index.d.mts +0 -98
  51. package/test/index.mjs +0 -193
  52. package/test/index.mjs.map +0 -1
package/form/index.d.mts CHANGED
@@ -1,759 +1,3 @@
1
1
  import '../style.css';
2
- import { l as Base, p as AccessTypes } from "../index-CvzH3M_5.mjs";
3
- import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
4
- import { a as ListField } from "../index-DlBJdGaQ.mjs";
5
- import { State, StateEnumRelated, StateNumberRelated, StateREA, StateStringRelated } from "@chocbite/ts-lib/state";
6
- import { Option, Result } from "@chocbite/ts-lib/result";
7
- import { IPAddress, IPVersion, Prettify } from "@chocbite/ts-lib/common";
8
- interface FormOptions {}
9
- /**Colors for form elements that have selectable colors*/
10
- export declare const FormColors: {
11
- readonly None: "none";
12
- readonly Black: "black";
13
- readonly Green: "green";
14
- readonly Red: "red";
15
- readonly Blue: "blue";
16
- readonly Yellow: "yellow";
17
- };
18
- export type FormColors = (typeof FormColors)[keyof typeof FormColors];
19
- /**Shared component class for other components to inherit from*/
20
- export declare abstract class FormElement extends Base {
21
- static element_name(): string;
22
- static element_name_space(): string;
23
- static apply_options(_element: FormElement, _options: FormOptions): void;
24
- }
25
- interface FormValueOptions<RT, ID extends string | undefined> extends FormOptions {
26
- /**ID form form element */
27
- id?: ID;
28
- /**Value for form element */
29
- value?: RT;
30
- /**Longer description what form element does */
31
- description?: string;
32
- }
33
- /**Shared class for all components with values*/
34
- export declare abstract class FormValue<RT, ID extends string | undefined> extends FormElement {
35
- #private;
36
- static element_name(): string;
37
- static apply_options<RT, ID extends string | undefined>(element: FormValue<RT, ID>, options: FormValueOptions<RT, ID>): void;
38
- readonly form_id: ID;
39
- constructor(id?: ID);
40
- protected _description?: string;
41
- /**Sets the description of the element, shown as a tooltip*/
42
- set description(text: string);
43
- get description(): string;
44
- protected _buffer?: RT;
45
- get buffer(): RT | undefined;
46
- protected _state?: State<RT, Option<{}>, RT>;
47
- /**Binds the element to a state, a read only state is shown and changes to the element are refused with a warning*/
48
- bind(opts: {
49
- value: StateREA<RT, Option<{}>, RT>;
50
- }): this;
51
- /**This sets the value of the component*/
52
- set value(val: RT);
53
- /**Returns value of the component*/
54
- get get_value(): Result<RT, string>;
55
- set error(err: string | undefined);
56
- /**Clears the value and error of the component if not state based*/
57
- clear(): void;
58
- /**Called when value is set by value setter or state*/
59
- protected abstract new_value(val: RT): void;
60
- /**Clears form element graphically*/
61
- protected abstract clear_value(): void;
62
- /**Called when error is set by error or state*/
63
- protected abstract new_error(val: string): void;
64
- /**Called when error is cleared by error or state*/
65
- protected abstract clear_error(): void;
66
- /**Called when state has related information */
67
- protected abstract state_related(related: {}): void;
68
- }
69
- interface FormValueWriteOptions<RT, ID extends string | undefined> extends FormValueOptions<RT, ID> {
70
- /**Change listener function*/
71
- change?: (val: RT) => void;
72
- }
73
- /**Shared class for all components with values*/
74
- export declare abstract class FormValueWrite<RT, ID extends string | undefined> extends FormValue<RT, ID> {
75
- #private;
76
- static element_name(): string;
77
- protected selected: boolean;
78
- protected warn_input: HTMLInputElement;
79
- static apply_options<RT, ID extends string | undefined>(element: FormValueWrite<RT, ID>, options: FormValueWriteOptions<RT, ID>): void;
80
- constructor(id?: ID);
81
- focus(options?: FocusOptions): void;
82
- set change(func: (val: RT) => void);
83
- get change(): ((val: RT) => void) | undefined;
84
- /**Returns true if the value of the component has changed*/
85
- get changed(): boolean;
86
- set value(val: RT);
87
- warn(message: string): void;
88
- /**Function to limit value entered */
89
- protected limit_value(val: RT): PromiseLike<Result<RT, string>>;
90
- /**Function to check value, a state checks the value itself when it is written, so it is not checked here*/
91
- protected check_value(val: RT): PromiseLike<Result<RT, string>>;
92
- /**Function to update value*/
93
- protected set_value_limit(val: RT): Promise<Result<RT, string>>;
94
- /**Function to update value*/
95
- protected set_value_check(val: RT): Promise<Result<RT, string>>;
96
- /**Calls the change listener with a value the user changed, and lets a parent group know*/
97
- protected call_change(val: RT): void;
98
- /**Called when a child value element with a form id was changed by the user*/
99
- protected child_changed(_child: FormValueWrite<any, any>): void;
100
- }
101
- interface FormButtonOptions<ID extends string | undefined> extends FormValueWriteOptions<boolean, ID> {
102
- /**Buttons text */
103
- text?: string;
104
- /**Icon for button */
105
- icon?: SVGFunc;
106
- /**Function to call on button click */
107
- on_click?: () => void;
108
- /**Set true to make button toggle on click instead of normal */
109
- toggle?: boolean;
110
- /**Changes the buttons color */
111
- color?: FormColors;
112
- /**Centers text and icon */
113
- center?: boolean;
114
- }
115
- declare class FormButton<ID extends string | undefined> extends FormValueWrite<boolean, ID> {
116
- #private;
117
- static element_name(): string;
118
- static element_name_space(): string;
119
- constructor(id?: ID);
120
- focus(options?: FocusOptions): void;
121
- /**Sets the current text of the button*/
122
- set text(label: string);
123
- get text(): string;
124
- /**Changes the icon of the button*/
125
- set icon(icon: SVGFunc | undefined);
126
- /**Function to call on button click*/
127
- set on_click(func: (() => void) | undefined);
128
- get on_click(): (() => void) | undefined;
129
- /**Changes the color of the button*/
130
- set color(color: FormColors);
131
- /**Centers text and icon */
132
- set center(center: boolean);
133
- get center(): boolean;
134
- /**Called when value is changed */
135
- protected new_value(value: boolean): void;
136
- protected clear_value(): void;
137
- protected new_error(err: string): void;
138
- protected clear_error(): void;
139
- protected state_related(_related: Option<{}>): void;
140
- /**Changes whether the button is maintained or momentary*/
141
- set toggle(toggle: boolean | undefined);
142
- get toggle(): boolean | undefined;
143
- }
144
- /**Creates a button form element */
145
- declare function form_button<ID extends string | undefined>(options?: FormButtonOptions<ID>): FormButton<ID>;
146
- interface FormLampOptions<T extends boolean | number, C extends FormColors[], ID extends string | undefined> extends FormValueOptions<T, ID> {
147
- /**Sets the lamp colors */
148
- colors: C;
149
- /**Lamp text */
150
- text?: string;
151
- /**Icon for lamp */
152
- icon?: SVGFunc;
153
- /**Centers text and icon */
154
- center?: boolean;
155
- }
156
- declare class FormLamp<T extends boolean | number, C extends FormColors[], ID extends string | undefined> extends FormValue<T, ID> {
157
- #private;
158
- static element_name(): string;
159
- static element_name_space(): string;
160
- /**Sets the current text of the lamp*/
161
- set text(label: string);
162
- get text(): string;
163
- /**Changes the icon of the lamp*/
164
- set icon(icon: SVGFunc | undefined);
165
- /** Sets the background color of the lamp*/
166
- set colors(colors: C);
167
- /**Centers text and icon */
168
- set center(center: boolean);
169
- get center(): boolean;
170
- /**Called when value is changed */
171
- protected new_value(value: number | boolean): void;
172
- protected clear_value(): void;
173
- protected new_error(err: string): void;
174
- protected clear_error(): void;
175
- protected state_related(_related: Option<{}>): void;
176
- }
177
- interface FormSwitchOptions<ID extends string | undefined> extends FormValueWriteOptions<boolean, ID> {
178
- /**Icon to use for left side*/
179
- icon?: SVGFunc;
180
- /**Color when switch is on */
181
- on_color?: FormColors;
182
- /**Color when switch is off */
183
- off_color?: FormColors;
184
- }
185
- declare class FormSwitch<ID extends string | undefined> extends FormValueWrite<boolean, ID> {
186
- #private;
187
- static element_name(): string;
188
- static element_name_space(): string;
189
- constructor(id?: ID);
190
- /**Changes the icon of the switch*/
191
- set icon(icon: SVGFunc | undefined);
192
- set on_color(color: FormColors);
193
- set off_color(color: FormColors);
194
- set error_color(color: FormColors);
195
- /**Called when value is changed */
196
- protected new_value(value: boolean): void;
197
- protected clear_value(): void;
198
- protected new_error(_err: string): void;
199
- protected clear_error(): void;
200
- protected state_related(_related: Option<{}>): void;
201
- }
202
- /**Creates a switch form element */
203
- declare function form_switch<ID extends string | undefined>(options?: FormSwitchOptions<ID>): FormSwitch<ID>;
204
- /**Different border styles for the component group*/
205
- declare const FormGroupBorderStyle: {
206
- readonly None: "none";
207
- readonly Inset: "inset";
208
- readonly Outset: "outset";
209
- readonly Line: "line";
210
- };
211
- type FormGroupBorderStyle = (typeof FormGroupBorderStyle)[keyof typeof FormGroupBorderStyle];
212
- type GroupExtractVals<Arr extends any[]> = Arr extends [infer Head, ...infer Tail] ? Head extends FormValue<infer T, infer ID> ? [FormValue<T, ID>, ...GroupExtractVals<Tail>] : [...GroupExtractVals<Tail>] : [];
213
- type GroupToKeyVal<Arr extends FormValue<any, any>[]> = { [K in Arr[number] as K extends FormValue<any, infer ID> ? [ID] extends [string] ? ID : never : never]: K extends FormValue<infer T, any> ? T : never; };
214
- type GroupValueElements<Elements extends FormElement[]> = { [Element in Elements[number] as Element extends FormValueWrite<any, infer ID> ? [ID] extends [string] ? ID : never : never]: Element; };
215
- declare abstract class FormGroupBase<RT extends object, ID extends string | undefined, Elements extends FormElement[] = FormElement[]> extends FormValueWrite<Partial<RT>, ID> {
216
- #private;
217
- static element_name(): string;
218
- static element_name_space(): string;
219
- protected _value_elements: Map<string, FormValueWrite<any, any>>;
220
- /**Returns form elements indexed by their form IDs*/
221
- get value_elements(): GroupValueElements<Elements>;
222
- /**This places the group at an absolute position in one of the corners of the container*/
223
- set border(border: FormGroupBorderStyle | undefined);
224
- set max_height(height: number | undefined);
225
- set embed(embed: boolean);
226
- set value(val: Partial<RT>);
227
- /**Returns value of the group, returning err if any component has no value*/
228
- get get_value(): Result<RT, string>;
229
- /**Returns partial value of the group, containing all values of components that have values*/
230
- get value_partial(): Result<Partial<RT>, string>;
231
- /**The change listener of the group gets the values of all components that have values*/
232
- protected child_changed(child: FormValueWrite<any, any>): void;
233
- /**Returns partial value of the group, only containing values of components where value has changed*/
234
- get value_changed(): Result<Partial<RT>, string>;
235
- protected new_value(val: RT): void;
236
- protected clear_value(): void;
237
- protected new_error(err: string): void;
238
- protected clear_error(): void;
239
- protected state_related(_related: Option<{}>): void;
240
- protected on_access(access: AccessTypes): void;
241
- }
242
- interface FormGroupOptions<L extends FormElement[], ID extends string | undefined, T> extends FormValueWriteOptions<Partial<T>, ID> {
243
- /**Elements to add to the group*/
244
- elements?: [...L];
245
- /**Border style for group*/
246
- border?: FormGroupBorderStyle;
247
- /**Removes padding when true allows for putting groups in groups without padding building up */
248
- embed?: boolean;
249
- /**Group max height in rem, undefined means no limit*/
250
- max_height?: number;
251
- /**Columns, true is everything in one columns, just a number will make repeating columns of minimum that rem width, an array will make exactly that many colums with specified rem widths */
252
- column?: true | string | string[];
253
- /**Rows, true is everything in one row, just a number will make repeating rows of minimum that rem height, an array will make exactly that many rows with specified rem heights */
254
- row?: true | string | string[];
255
- }
256
- /**Component group class which allows to add elements and controls the flow of the elements*/
257
- declare class FormGroup<RT extends object, ID extends string | undefined, Elements extends FormElement[] = FormValueWrite<any, string>[]> extends FormGroupBase<RT, ID, Elements> {
258
- #private;
259
- static element_name(): string;
260
- static element_name_space(): string;
261
- constructor(id?: ID);
262
- set column(column: true | string | string[]);
263
- set row(row: true | string | string[]);
264
- set elements(elements: FormElement[]);
265
- /**All elements added to the group, also those without a form id*/
266
- get elements(): FormElement[];
267
- }
268
- /**Creates a form group with elements */
269
- declare function form_group<L extends FormElement[], ID extends string | undefined, T extends object = Prettify<GroupToKeyVal<GroupExtractVals<L>>>>(options?: FormGroupOptions<L, ID, T>): FormGroup<T, ID, L>;
270
- interface FormGroupCollapserOptions extends FormOptions {
271
- /**Wether the group is collapsed initially*/
272
- collapsed?: boolean;
273
- /**Text to show on the collapser when open*/
274
- opened_text?: string;
275
- /**Text to show on the collapser when closed*/
276
- closed_text?: string;
277
- }
278
- /**Component group class which allows to add elements and controls the flow of the elements*/
279
- declare class FormGroupCollapser extends FormElement {
280
- #private;
281
- static element_name(): string;
282
- static element_name_space(): string;
283
- constructor(group: FormGroupBase<any, any>, collapsed?: boolean);
284
- set group(group: FormGroupBase<any, any>);
285
- get group(): FormGroupBase<any, any>;
286
- set collapsed(collapsed: boolean);
287
- get collapsed(): boolean;
288
- set opened_text(text: string);
289
- set closed_text(text: string);
290
- }
291
- /**Creates a dropdown form element */
292
- declare function form_group_collapser(group: FormGroupBase<any, any>, options?: FormGroupCollapserOptions): FormGroupCollapser;
293
- declare class ListFormField<T extends FormElement> extends ListField {
294
- static element_name(): string;
295
- static element_name_space(): string;
296
- set element(component: T);
297
- get element(): T;
298
- }
299
- declare function form_list_field<T extends FormElement>(element: T): ListFormField<T>;
300
- interface FormNumberOptions<ID extends string | undefined, RT = number> extends FormValueOptions<RT, ID> {
301
- /**Lower limit for slider value*/
302
- min?: number;
303
- /**Upper limit for slider value*/
304
- max?: number;
305
- /**Amount of decimals to show*/
306
- decimals?: number;
307
- /**Unit to use for slider*/
308
- unit?: string;
309
- }
310
- interface FormNumberWriteOptions<ID extends string | undefined, RT = number> extends FormNumberOptions<ID, RT>, FormValueWriteOptions<RT, ID> {
311
- /**Step size, use 0 for automatic step size*/
312
- step?: number;
313
- /**Start for step, use 0 for automatic */
314
- start?: number;
315
- }
316
- interface FormStepperBaseOptions<ID extends string | undefined, RT = number> extends FormNumberWriteOptions<ID, RT> {
317
- /**wether the events are live as the slider is moved or only when moving stops */
318
- live?: boolean;
319
- /**Icon to use for decreasing value*/
320
- icon_decrease?: SVGFunc;
321
- /**Icon to use for increasing value*/
322
- icon_increase?: SVGFunc;
323
- }
324
- declare abstract class FormNumberWrite<ID extends string | undefined, RT = number> extends FormValueWrite<RT, ID> {
325
- #private;
326
- static apply_options<RT, ID extends string | undefined>(element: FormNumberWrite<ID, RT>, options: FormNumberWriteOptions<ID, RT>): void;
327
- /**Set the minimum value*/
328
- abstract set min(min: number | undefined);
329
- /**Set the minimum value*/
330
- abstract set max(max: number | undefined);
331
- /**Sets the size of number change steps*/
332
- abstract set step(step: number | undefined);
333
- /**Sets the start offset for number steps*/
334
- abstract set start(step: number | undefined);
335
- /**Sets the amount of decimals the element can have*/
336
- abstract set decimals(dec: number | undefined);
337
- /**Sets the unit of the element*/
338
- abstract set unit(unit: string | undefined);
339
- protected state_related(related: Partial<StateNumberRelated>): void;
340
- }
341
- declare class FormNumberInput<ID extends string | undefined> extends FormNumberWrite<ID> {
342
- #private;
343
- static element_name(): string;
344
- static element_name_space(): string;
345
- constructor(id?: ID);
346
- focus(options?: FocusOptions): void;
347
- set unit(unit: string | undefined);
348
- set decimals(dec: number | undefined);
349
- set min(min: number | undefined);
350
- set max(max: number | undefined);
351
- set step(step: number | undefined);
352
- set start(step: number | undefined);
353
- protected new_value(val: number): void;
354
- protected clear_value(): void;
355
- protected new_error(_val: string): void;
356
- protected clear_error(): void;
357
- protected limit_value(val: number): PromiseLike<Result<number, string>>;
358
- protected check_value(val: number): PromiseLike<Result<number, string>>;
359
- }
360
- /**Creates a number input form element */
361
- declare function form_number_input<ID extends string | undefined>(options?: FormNumberWriteOptions<ID>): FormNumberInput<ID>;
362
- declare class FormProgress<ID extends string | undefined> extends FormValue<number, ID> {
363
- #private;
364
- static element_name(): string;
365
- static element_name_space(): string;
366
- /**Set the minimum value*/
367
- set min(min: number);
368
- /**Set the minimum value*/
369
- set max(max: number);
370
- /**Sets the amount of decimals the element can have*/
371
- set decimals(dec: number | undefined);
372
- /**Sets the unit of the element*/
373
- set unit(unit: string | undefined);
374
- protected new_value(value: number): void;
375
- protected clear_value(): void;
376
- protected new_error(err: string): void;
377
- protected clear_error(): void;
378
- protected state_related(related: Partial<StateNumberRelated>): void;
379
- }
380
- /**Creates a progress form element */
381
- declare function form_progress<ID extends string | undefined>(options?: FormNumberOptions<ID>): FormProgress<ID>;
382
- /**Slide Selector, displays all options in a slider*/
383
- declare class FormSlider<ID extends string | undefined> extends FormNumberWrite<ID, number> {
384
- #private;
385
- static element_name(): string;
386
- static element_name_space(): string;
387
- constructor(id?: ID);
388
- focus(options?: FocusOptions): void;
389
- set unit(unit: string | undefined);
390
- set min(min: number | undefined);
391
- set max(max: number | undefined);
392
- set decimals(dec: number | undefined);
393
- set step(step: number | undefined);
394
- set start(step: number | undefined);
395
- /**Set wether the slider is in live mode*/
396
- set live(live: boolean | undefined);
397
- set icon_decrease(icon: SVGFunc | undefined);
398
- set icon_increase(icon: SVGFunc | undefined);
399
- protected new_value(value: number): void;
400
- protected clear_value(): void;
401
- protected new_error(err: string): void;
402
- protected clear_error(): void;
403
- protected limit_value(val: number): PromiseLike<Result<number, string>>;
404
- protected check_value(val: number): PromiseLike<Result<number, string>>;
405
- }
406
- /**Creates a dropdown form element */
407
- declare function form_slider<ID extends string | undefined>(options?: FormStepperBaseOptions<ID>): FormSlider<ID>;
408
- /**Slide Selector, displays all options in a slider*/
409
- declare class FormStepper<ID extends string | undefined> extends FormNumberWrite<ID, number> {
410
- #private;
411
- static element_name(): string;
412
- static element_name_space(): string;
413
- constructor(id?: ID);
414
- focus(options?: FocusOptions): void;
415
- set unit(unit: string | undefined);
416
- set decimals(dec: number | undefined);
417
- set min(min: number | undefined);
418
- set max(max: number | undefined);
419
- set step(step: number | undefined);
420
- set start(step: number | undefined);
421
- /**Set wether the slider is in live mode*/
422
- set live(live: boolean | undefined);
423
- set icon_decrease(icon: SVGFunc | undefined);
424
- set icon_increase(icon: SVGFunc | undefined);
425
- protected new_value(value: number): void;
426
- protected clear_value(): void;
427
- protected new_error(err: string): void;
428
- protected clear_error(): void;
429
- protected limit_value(val: number): PromiseLike<Result<number, string>>;
430
- protected check_value(val: number): PromiseLike<Result<number, string>>;
431
- }
432
- /**Creates a dropdown form element */
433
- declare function form_stepper<ID extends string | undefined>(options?: FormStepperBaseOptions<ID>): FormStepper<ID>;
434
- interface FormSelectorOption<RT> {
435
- /**Value to set when option is selected */
436
- value: RT;
437
- /**Text for selection */
438
- text: string;
439
- /**Icon to display for option*/
440
- icon?: SVGFunc;
441
- }
442
- /**Selection options for a form selector */
443
- type FormSelections<T> = FormSelectorOption<T>[];
444
- interface FormSelectorBaseOptions<T, ID extends string | undefined> extends FormValueWriteOptions<T, ID> {
445
- /**Options for selector*/
446
- selections?: FormSelections<T>;
447
- }
448
- /**Base for number elements elements*/
449
- declare abstract class FormSelectorBase<RT, ID extends string | undefined> extends FormValueWrite<RT, ID> {
450
- #private;
451
- /**Sets the selection options for the selector */
452
- abstract set selections(selections: FormSelections<RT> | undefined);
453
- static apply_options<RT, ID extends string | undefined>(element: FormSelectorBase<RT, ID>, options: FormSelectorBaseOptions<RT, ID>): void;
454
- protected state_related(related: Partial<StateEnumRelated>): void;
455
- }
456
- interface FormDropDownSelection {
457
- text: string;
458
- icon?: SVGFunc;
459
- }
460
- interface FormDropDownOptions<RT, ID extends string | undefined> extends FormSelectorBaseOptions<RT, ID> {
461
- /**Default text displayed*/
462
- default?: string;
463
- /**Default icon displayed*/
464
- default_icon?: SVGFunc;
465
- }
466
- /**Dropdown box for selecting between multiple choices in a small space*/
467
- declare class FormDropdown<RT, ID extends string | undefined> extends FormSelectorBase<RT, ID> {
468
- #private;
469
- static element_name(): string;
470
- static element_name_space(): string;
471
- private is_open;
472
- constructor(id?: ID);
473
- focus(options?: FocusOptions): void;
474
- /**Gets the default text displayed when nothing has been selected yet */
475
- get default(): string;
476
- /**Sets the default text displayed when nothing has been selected yet */
477
- set default(def: string);
478
- /**Sets the default text displayed when nothing has been selected yet */
479
- set default_icon(def: SVGFunc | undefined);
480
- set selections(selections: FormSelectorOption<RT>[] | undefined);
481
- set open(open: boolean);
482
- /**Called when Value is changed */
483
- protected new_value(value: RT): void;
484
- protected clear_value(): void;
485
- protected new_error(_val: string): void;
486
- protected clear_error(): void;
487
- warn(message: string): void;
488
- }
489
- /**Creates a dropdown form element */
490
- declare function form_dropdown<RT, ID extends string | undefined>(options?: FormDropDownOptions<RT, ID>): FormDropdown<RT, ID>;
491
- interface FormToggleButtonSelection {
492
- top: HTMLDivElement;
493
- bot: HTMLDivElement;
494
- }
495
- /**Toggle buttons, displays all options in a multi toggler*/
496
- declare class FormToggleButton<RT, ID extends string | undefined> extends FormSelectorBase<RT, ID> {
497
- #private;
498
- /**Returns the name used to define the element*/
499
- static element_name(): string;
500
- static element_name_space(): string;
501
- focus(options?: FocusOptions): void;
502
- set selections(selections: FormSelectorOption<RT>[] | undefined);
503
- protected new_value(value: RT): void;
504
- protected clear_value(): void;
505
- protected new_error(_val: string): void;
506
- protected clear_error(): void;
507
- }
508
- /**Creates a toggle button form element */
509
- declare function form_toggle_button<RT, ID extends string | undefined>(options?: FormSelectorBaseOptions<RT, ID>): FormToggleButton<RT, ID>;
510
- interface FormSpacerOptions {
511
- /**Spacing amount */
512
- space?: number;
513
- }
514
- declare class FormSpacer extends FormElement {
515
- static element_name(): string;
516
- static element_name_space(): string;
517
- constructor();
518
- /**Sets the amount of space, in rem */
519
- set space(space: number);
520
- get space(): number;
521
- }
522
- /**Creates a spacer form element */
523
- declare function form_spacer(options?: FormSpacerOptions): FormSpacer;
524
- interface FormColorOptions<ID extends string | undefined, RT = string> extends FormValueWriteOptions<RT, ID> {
525
- /**Whether the color input should update live*/
526
- live?: boolean;
527
- }
528
- declare class FormColor<ID extends string | undefined> extends FormValueWrite<string, ID> {
529
- #private;
530
- static element_name(): string;
531
- static element_name_space(): string;
532
- constructor(id?: ID);
533
- set live(val: boolean);
534
- get live(): boolean;
535
- protected new_value(val: string): void;
536
- protected clear_value(): void;
537
- protected new_error(_val: string): void;
538
- protected clear_error(): void;
539
- protected state_related(_related: Option<{}>): void;
540
- }
541
- /**Creates a color input form element */
542
- declare function form_color<ID extends string | undefined>(options?: FormColorOptions<ID, string>): FormColor<ID>;
543
- interface FormDateTimeOptions<MODE extends FormDateTimeMode, ID extends string | undefined> extends FormValueWriteOptions<FormDateTimeResult<MODE>, ID> {
544
- /**Type of date time*/
545
- type?: FormDateTimeType;
546
- /**Value representation used by the input*/
547
- mode: MODE;
548
- /**Force show milliseconds even when value is not precise to milliseconds */
549
- milliseconds?: boolean;
550
- }
551
- export declare const FormDateTimeType: {
552
- readonly DATE: "date";
553
- readonly TIME: "time";
554
- readonly DATETIME: "datetime";
555
- };
556
- export type FormDateTimeType = (typeof FormDateTimeType)[keyof typeof FormDateTimeType];
557
- export declare const FormDateTimeMode: {
558
- readonly DATE: "date";
559
- readonly STRING: "string";
560
- readonly NUMBER: "number";
561
- };
562
- export type FormDateTimeMode = (typeof FormDateTimeMode)[keyof typeof FormDateTimeMode];
563
- type FormDateTimeResult<MODE extends FormDateTimeMode> = MODE extends typeof FormDateTimeMode.DATE ? Date : MODE extends typeof FormDateTimeMode.STRING ? string : number;
564
- declare class FormDateTime<MODE extends FormDateTimeMode, ID extends string | undefined> extends FormValueWrite<FormDateTimeResult<MODE>, ID> {
565
- #private;
566
- static element_name(): string;
567
- static element_name_space(): string;
568
- constructor(mode: MODE, id?: ID);
569
- /**Returns the date time type*/
570
- get type(): FormDateTimeType;
571
- /**Sets the date time type*/
572
- set type(type: FormDateTimeType);
573
- /**Returns true if the input is set to show milliseconds*/
574
- get milliseconds(): boolean;
575
- /**Sets the input to show milliseconds*/
576
- set milliseconds(value: boolean);
577
- /**Returns the date time type*/
578
- get step(): number;
579
- /**Sets the date time type*/
580
- set step(step: number);
581
- protected new_value(value: FormDateTimeResult<MODE>): void;
582
- protected clear_value(): void;
583
- protected new_error(_val: string): void;
584
- protected clear_error(): void;
585
- protected state_related(_related: Option<{}>): void;
586
- }
587
- /**Creates a date time input form element
588
- * Number type is always UTC, Date and String is always local*/
589
- declare function form_date_time<MODE extends FormDateTimeMode, ID extends string | undefined>(options: FormDateTimeOptions<MODE, ID>): FormDateTime<MODE, ID>;
590
- interface FormIpOptions<ID extends string | undefined> extends FormValueWriteOptions<IPAddress, ID> {
591
- /**Ip address type, this is overwritten if supplied with an ipaddress with a different type*/
592
- type: IPVersion;
593
- }
594
- declare class FormIp<ID extends string | undefined> extends FormValueWrite<IPAddress, ID> {
595
- #private;
596
- static element_name(): string;
597
- static element_name_space(): string;
598
- constructor(type: IPVersion, id?: ID);
599
- focus(options?: FocusOptions): void;
600
- get value_as_ip(): IPAddress;
601
- set type(val: IPVersion);
602
- protected new_value(val: IPAddress): void;
603
- protected clear_value(): void;
604
- protected new_error(_val: string): void;
605
- protected clear_error(): void;
606
- protected state_related(_related: Option<{}>): void;
607
- }
608
- /**Creates an IP input form element */
609
- declare function form_ip<ID extends string | undefined>(options: FormIpOptions<ID>): FormIp<ID>;
610
- interface FormPasswordOptions<ID extends string | undefined> extends FormValueWriteOptions<string, ID> {
611
- /**Allowed characters for the password input */
612
- filter?: RegExp;
613
- }
614
- declare class FormPassword<ID extends string | undefined> extends FormValueWrite<string, ID> {
615
- #private;
616
- static element_name(): string;
617
- static element_name_space(): string;
618
- constructor(id?: ID);
619
- set filter(val: RegExp | undefined);
620
- protected new_value(val: string): void;
621
- protected clear_value(): void;
622
- protected new_error(_val: string): void;
623
- protected clear_error(): void;
624
- protected state_related(_related: Option<{}>): void;
625
- }
626
- /**Creates a password input form element */
627
- declare function form_password<ID extends string | undefined>(options?: FormPasswordOptions<ID>): FormPassword<ID>;
628
- interface FormTextInputOptions<ID extends string | undefined, RT = string> extends FormValueWriteOptions<RT, ID> {
629
- /**Placeholder text when input is empty */
630
- placeholder?: string;
631
- /**Maximum length of the input */
632
- max_length?: number;
633
- /**Maximum bytes of the input */
634
- max_bytes?: number;
635
- /**Allowed characters for the text input */
636
- filter?: RegExp;
637
- }
638
- declare class FormTextInput<ID extends string | undefined> extends FormValueWrite<string, ID> {
639
- #private;
640
- static element_name(): string;
641
- static element_name_space(): string;
642
- constructor(id?: ID);
643
- set filter(val: RegExp | undefined);
644
- get filter(): RegExp | undefined;
645
- set placeholder(val: string);
646
- get placeholder(): string;
647
- set max_length(val: number | undefined);
648
- get max_length(): number | undefined;
649
- set max_bytes(val: number | undefined);
650
- get max_bytes(): number | undefined;
651
- protected new_value(val: string): void;
652
- protected clear_value(): void;
653
- protected new_error(_val: string): void;
654
- protected clear_error(): void;
655
- protected limit_value(val: string): PromiseLike<Result<string, string>>;
656
- protected check_value(val: string): PromiseLike<Result<string, string>>;
657
- protected state_related(related: Partial<StateStringRelated>): void;
658
- }
659
- /**Creates a single line text input form element */
660
- declare function form_text_input<ID extends string | undefined>(options?: FormTextInputOptions<ID>): FormTextInput<ID>;
661
- interface FormTextMultilineOptions<ID extends string | undefined, RT = string> extends FormValueWriteOptions<RT, ID> {
662
- /**Placeholder text when input is empty */
663
- placeholder?: string;
664
- /**Maximum length of the input */
665
- max_length?: number;
666
- /**Maximum bytes of the input */
667
- max_bytes?: number;
668
- /**Allowed characters for the text input */
669
- filter?: RegExp;
670
- }
671
- declare class FormTextMultiline<ID extends string | undefined> extends FormValueWrite<string, ID> {
672
- #private;
673
- static element_name(): string;
674
- static element_name_space(): string;
675
- constructor(id?: ID);
676
- focus(options?: FocusOptions): void;
677
- set filter(val: RegExp | undefined);
678
- get filter(): RegExp | undefined;
679
- set placeholder(val: string);
680
- get placeholder(): string;
681
- set max_length(val: number | undefined);
682
- get max_length(): number | undefined;
683
- set max_bytes(val: number | undefined);
684
- get max_bytes(): number | undefined;
685
- protected new_value(val: string): void;
686
- protected clear_value(): void;
687
- protected new_error(_val: string): void;
688
- protected clear_error(): void;
689
- protected limit_value(val: string): PromiseLike<Result<string, string>>;
690
- protected check_value(val: string): PromiseLike<Result<string, string>>;
691
- protected state_related(related: Partial<StateStringRelated>): void;
692
- }
693
- /**Creates a multi line text input form element */
694
- declare function form_text_multiline<ID extends string | undefined>(options?: FormTextMultilineOptions<ID>): FormTextMultiline<ID>;
695
- interface FormTextOptions {
696
- /**Buttons text */
697
- text?: string;
698
- /**Text size */
699
- size?: number;
700
- }
701
- /**Component for simple text */
702
- declare class FormText extends FormElement {
703
- static element_name(): string;
704
- static element_name_space(): string;
705
- constructor(options: FormTextOptions);
706
- /**Sets the current text of the element*/
707
- set text(text: string);
708
- get text(): string;
709
- /**Sets the current text of the element*/
710
- set size(size: number);
711
- }
712
- /**Creates a button form element */
713
- declare function form_text(options: FormTextOptions): FormText;
714
- /**Form elements with label */
715
- export declare const form: {
716
- FormColors: {
717
- readonly None: "none";
718
- readonly Black: "black";
719
- readonly Green: "green";
720
- readonly Red: "red";
721
- readonly Blue: "blue";
722
- readonly Yellow: "yellow";
723
- };
724
- button: typeof form_button;
725
- switch: typeof form_switch;
726
- lamp: {
727
- <ID extends string | undefined>(options?: FormLampOptions<number, [FormColors, FormColors, FormColors, ...FormColors[]], ID>): FormLamp<number, [FormColors, FormColors, FormColors, ...FormColors[]], ID>;
728
- <ID extends string | undefined>(options?: FormLampOptions<boolean, [FormColors, FormColors], ID>): FormLamp<boolean, [FormColors, FormColors], ID>;
729
- };
730
- group: typeof form_group;
731
- group_collapser: typeof form_group_collapser;
732
- color: typeof form_color;
733
- date_time: typeof form_date_time;
734
- FormDateTimeMode: {
735
- readonly DATE: "date";
736
- readonly STRING: "string";
737
- readonly NUMBER: "number";
738
- };
739
- FormDateTimeType: {
740
- readonly DATE: "date";
741
- readonly TIME: "time";
742
- readonly DATETIME: "datetime";
743
- };
744
- ip: typeof form_ip;
745
- password: typeof form_password;
746
- progress: typeof form_progress;
747
- number_input: typeof form_number_input;
748
- slider: typeof form_slider;
749
- stepper: typeof form_stepper;
750
- dropdown: typeof form_dropdown;
751
- toggle_button: typeof form_toggle_button;
752
- spacer: typeof form_spacer;
753
- text: typeof form_text;
754
- text_input: typeof form_text_input;
755
- text_multiline: typeof form_text_multiline;
756
- list_field: typeof form_list_field;
757
- };
758
- export { type FormButton, type FormButtonOptions, type FormColor, type FormColorOptions, type FormDateTime, type FormDateTimeOptions, type FormDropDownOptions, type FormDropDownSelection, type FormDropdown, type FormGroup, type FormGroupCollapser, type FormGroupCollapserOptions, type FormGroupOptions, type FormIp, type FormIpOptions, type FormLamp, type FormLampOptions, type FormNumberInput, type FormNumberOptions, type FormNumberWriteOptions, type FormOptions, type FormPassword, type FormPasswordOptions, type FormProgress, type FormSelections, type FormSlider, type FormSpacer, type FormSpacerOptions, type FormStepper, type FormSwitch, type FormSwitchOptions, type FormText, type FormTextInput, type FormTextInputOptions, type FormTextMultiline, type FormTextMultilineOptions, type FormTextOptions, type FormToggleButton, type FormToggleButtonSelection, type FormValueOptions, type FormValueWriteOptions, type ListFormField, form as default };
759
- //# sourceMappingURL=index.d.mts.map
2
+ import { A as FormNumberOptions, B as FormLampOptions, C as FormDropDownSelection, D as FormSlider, E as FormStepper, F as FormGroup, G as FormOptions, H as FormButtonOptions, I as FormGroupOptions, J as FormValueWrite, K as FormValue, L as FormSwitch, M as ListFormField, N as FormGroupCollapser, O as FormProgress, P as FormGroupCollapserOptions, R as FormSwitchOptions, S as FormDropDownOptions, T as FormSelections, U as FormColors, V as FormButton, W as FormElement, Y as FormValueWriteOptions, _ as FormColorOptions, a as FormTextMultilineOptions, b as FormToggleButton, c as FormPassword, d as FormIpOptions, f as FormDateTime, g as FormColor, h as FormDateTimeType, i as FormTextMultiline, j as FormNumberWriteOptions, k as FormNumberInput, l as FormPasswordOptions, m as FormDateTimeOptions, n as FormText, o as FormTextInput, p as FormDateTimeMode, q as FormValueOptions, r as FormTextOptions, s as FormTextInputOptions, t as form, u as FormIp, v as FormSpacer, w as FormDropdown, x as FormToggleButtonSelection, y as FormSpacerOptions, z as FormLamp } from "../index-DD09-bGe.mjs";
3
+ export { type FormButton, type FormButtonOptions, type FormColor, type FormColorOptions, FormColors, type FormDateTime, FormDateTimeMode, type FormDateTimeOptions, FormDateTimeType, type FormDropDownOptions, type FormDropDownSelection, type FormDropdown, FormElement, type FormGroup, type FormGroupCollapser, type FormGroupCollapserOptions, type FormGroupOptions, type FormIp, type FormIpOptions, type FormLamp, type FormLampOptions, type FormNumberInput, type FormNumberOptions, type FormNumberWriteOptions, type FormOptions, type FormPassword, type FormPasswordOptions, type FormProgress, type FormSelections, type FormSlider, type FormSpacer, type FormSpacerOptions, type FormStepper, type FormSwitch, type FormSwitchOptions, type FormText, type FormTextInput, type FormTextInputOptions, type FormTextMultiline, type FormTextMultilineOptions, type FormTextOptions, type FormToggleButton, type FormToggleButtonSelection, FormValue, type FormValueOptions, FormValueWrite, type FormValueWriteOptions, type ListFormField, form as default, form };