@gecko-ui-kit/vue 0.0.0-stage → 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/src/forms.d.ts ADDED
@@ -0,0 +1,757 @@
1
+ import type { VNodeChild } from 'vue';
2
+ import type { GeckoComponent, ModelProps, DateLike } from './core.js';
3
+
4
+ /** Attributes that go on the <input> of PasswordToggle / PasswordMeter (any other attribute works too). */
5
+ export interface PasswordInputAttrs {
6
+ id?: string;
7
+ name?: string;
8
+ placeholder?: string;
9
+ autocomplete?: string;
10
+ required?: boolean;
11
+ disabled?: boolean;
12
+ readonly?: boolean;
13
+ minlength?: number | string;
14
+ maxlength?: number | string;
15
+ autofocus?: boolean;
16
+ form?: string;
17
+ onInput?: (event: Event) => void;
18
+ onBlur?: (event: FocusEvent) => void;
19
+ onFocus?: (event: FocusEvent) => void;
20
+ onKeydown?: (event: KeyboardEvent) => void;
21
+ }
22
+
23
+ /* ---------------- MultiSelect ---------------- */
24
+ /** An option: a plain string or an object. */
25
+ export type MultiSelectOption = string | {
26
+ value?: string; label?: string; sub?: string; group?: string;
27
+ /** Show an avatar: true (from the label) or { name, ini, tone }. */
28
+ person?: true | { name: string; ini?: string; tone?: string };
29
+ /** A colour dot: a hue name ('teal') or any CSS colour. */
30
+ color?: string;
31
+ icon?: string;
32
+ disabled?: boolean;
33
+ };
34
+ export interface MultiSelectOptionObject { value: string; label: string; sub?: string; group?: string; person?: true | { name: string; ini?: string; tone?: string }; color?: string; icon?: string; disabled?: boolean; created?: boolean }
35
+ export interface MultiSelectHandle {
36
+ readonly value: string[];
37
+ readonly selected: MultiSelectOptionObject[];
38
+ readonly isOpen: boolean;
39
+ /** Replace the selection (no @change). */
40
+ set(values: string[]): MultiSelectHandle;
41
+ add(value: string): MultiSelectHandle;
42
+ remove(value: string): MultiSelectHandle;
43
+ clear(): MultiSelectHandle;
44
+ open(): MultiSelectHandle;
45
+ close(): MultiSelectHandle;
46
+ focus(): MultiSelectHandle;
47
+ setOptions(options: MultiSelectOption[]): MultiSelectHandle;
48
+ destroy(): void;
49
+ readonly el: HTMLElement;
50
+ }
51
+ export interface MultiSelectProps extends ModelProps<string[]> {
52
+ options?: MultiSelectOption[];
53
+ placeholder?: string;
54
+ /** Most you can pick (0 = no limit). */
55
+ max?: number;
56
+ /** Offer to create what was typed: true, or (text) => option | Promise<option>. */
57
+ creatable?: boolean | ((text: string) => MultiSelectOption | null | Promise<MultiSelectOption | null>);
58
+ /** Close the list after each pick. */
59
+ closeOnSelect?: boolean;
60
+ /** Adds hidden inputs with this name, so a plain <form> sends the values. */
61
+ name?: string;
62
+ disabled?: boolean;
63
+ words?: { placeholder?: string; more?: string; empty?: string; create?: (text: string) => string; remove?: string; clear?: string; added?: (label: string) => string; removed?: (label: string) => string; max?: (n: number) => string; count?: (n: number) => string };
64
+ onChange?: (values: string[], options: MultiSelectOptionObject[], ms: MultiSelectHandle) => void;
65
+ onCreate?: (option: MultiSelectOptionObject, ms: MultiSelectHandle) => void;
66
+ }
67
+ /** <MultiSelect v-model="ids" :options="people" /> — template ref → MultiSelectHandle */
68
+ export const MultiSelect: GeckoComponent<MultiSelectProps>;
69
+
70
+ /* ---------------- Combobox ---------------- */
71
+ export type ComboboxOption = string | { value?: string; label?: string; sub?: string; icon?: string; group?: string; disabled?: boolean };
72
+ export interface ComboboxOptionObject { value: string; label: string; sub?: string; icon?: string; group?: string; disabled?: boolean; custom?: boolean }
73
+ export interface ComboboxHandle {
74
+ /** The picked value, or null. */
75
+ readonly value: string | null;
76
+ /** The picked option (custom text has custom: true), or null. */
77
+ readonly option: ComboboxOptionObject | null;
78
+ readonly isOpen: boolean;
79
+ /** Pick a value (or { value, label }) without calling @change; null clears. */
80
+ set(value: string | { value: string; label?: string } | null): ComboboxHandle;
81
+ clear(): ComboboxHandle;
82
+ open(): ComboboxHandle;
83
+ close(): ComboboxHandle;
84
+ focus(): ComboboxHandle;
85
+ setOptions(options: ComboboxOption[]): ComboboxHandle;
86
+ destroy(): void;
87
+ readonly el: HTMLElement;
88
+ }
89
+ export interface ComboboxProps {
90
+ /** The pick (v-model): a value, or { value, label } with a source. Gets the picked value (or null). */
91
+ modelValue?: string | { value: string; label?: string } | null;
92
+ /** The pick at the start when there is no v-model. */
93
+ defaultValue?: string | { value: string; label?: string } | null;
94
+ 'onUpdate:modelValue'?: (value: string | null) => void;
95
+ options?: ComboboxOption[];
96
+ /** Ask your server instead of options. */
97
+ source?: (query: string, ctx: { signal: AbortSignal }) => Promise<ComboboxOption[]> | ComboboxOption[];
98
+ placeholder?: string;
99
+ /** An × button; Escape on a closed list clears (default true). */
100
+ clearable?: boolean;
101
+ /** Enter (or leaving the field) keeps the typed text as the value. */
102
+ allowCustom?: boolean;
103
+ /** Letters needed before the list (or the source) is asked. */
104
+ minChars?: number;
105
+ /** ms to wait after typing before calling source (150). */
106
+ debounce?: number;
107
+ /** Rows shown at most (50; 0 = all). */
108
+ maxResults?: number;
109
+ /** A hidden input with this name, so a plain <form> sends the value. */
110
+ name?: string;
111
+ disabled?: boolean;
112
+ /** A visible label (else the placeholder names the field). */
113
+ label?: string;
114
+ words?: Record<string, string | ((...a: any[]) => string)>;
115
+ onChange?: (value: string | null, option: ComboboxOptionObject | null, cb: ComboboxHandle) => void;
116
+ onInput?: (text: string, cb: ComboboxHandle) => void;
117
+ }
118
+ /** <Combobox v-model="country" :options="countries" /> — template ref → ComboboxHandle */
119
+ export const Combobox: GeckoComponent<ComboboxProps>;
120
+
121
+ /* ---------------- TagsInput ---------------- */
122
+ export interface TagsInputHandle {
123
+ readonly value: string[];
124
+ /** Add a tag (through transform, unique, max and validate); true when added. */
125
+ add(text: string): boolean;
126
+ /** Remove a tag by its text or index. */
127
+ remove(tag: string | number): boolean;
128
+ clear(): TagsInputHandle;
129
+ /** Replace every tag (no @change). */
130
+ set(tags: string[]): TagsInputHandle;
131
+ focus(): TagsInputHandle;
132
+ destroy(): void;
133
+ readonly el: HTMLElement;
134
+ }
135
+ export interface TagsInputProps extends ModelProps<string[]> {
136
+ placeholder?: string;
137
+ /** A short list under the field, narrowed as you type. */
138
+ suggestions?: string[];
139
+ /** Most tags (0 = no limit); a counter shows n/max. */
140
+ max?: number;
141
+ /** No repeats (ignores case and accents; default true). */
142
+ unique?: boolean;
143
+ /** Characters or the keys 'Enter' / 'Tab' that make a tag (default [',', 'Enter']). */
144
+ separators?: string[];
145
+ /** true, or a message to refuse the text (false shows words.invalid). */
146
+ validate?: (text: string) => true | false | string;
147
+ /** Runs before the checks, e.g. (t) => t.toLowerCase(). */
148
+ transform?: (text: string) => string;
149
+ /** A hidden input with the tags joined by commas. */
150
+ name?: string;
151
+ disabled?: boolean;
152
+ words?: { label?: string; placeholder?: string; hint?: string; remove?: (t: string) => string; added?: (t: string) => string; removed?: (t: string) => string; duplicate?: (t: string) => string; invalid?: (t: string) => string; max?: (n: number) => string; count?: (n: number, max: number) => string; suggestions?: string };
153
+ onChange?: (tags: string[], ti: TagsInputHandle) => void;
154
+ }
155
+ /** <TagsInput v-model="tags" /> — template ref → TagsInputHandle */
156
+ export const TagsInput: GeckoComponent<TagsInputProps>;
157
+
158
+ /* ---------------- RangeSlider ---------------- */
159
+ export interface RangeSliderHandle {
160
+ readonly value: [number, number];
161
+ /** Go to [low, high] (snapped, inside the limits); @change runs unless { silent: true }. */
162
+ set(value: [number, number], opts?: { silent?: boolean }): RangeSliderHandle;
163
+ destroy(): void;
164
+ readonly el: HTMLElement;
165
+ }
166
+ export interface RangeSliderProps extends ModelProps<[number, number]> {
167
+ min?: number;
168
+ max?: number;
169
+ step?: number;
170
+ /** The least the two may be apart. */
171
+ minGap?: number;
172
+ /** Text for the bubble, aria-valuetext, marks and inputs. */
173
+ format?: (value: number) => string;
174
+ /** Reads the number inputs. */
175
+ parse?: (text: string) => number;
176
+ /** Ticks + labels under the track (a number: every n). */
177
+ marks?: number[] | number;
178
+ /** Bars behind the track, spread evenly from min to max. */
179
+ histogram?: number[];
180
+ /** Two number boxes under the track. */
181
+ inputs?: boolean;
182
+ /** Two hidden inputs: name_min and name_max. */
183
+ name?: string;
184
+ /** A heading with the range written out next to it. */
185
+ label?: string;
186
+ disabled?: boolean;
187
+ words?: { min?: string; max?: string; to?: string; range?: string };
188
+ /** Every change while dragging. */
189
+ onInput?: (value: [number, number], rs: RangeSliderHandle) => void;
190
+ /** When a drag ends, a key is pressed or a box is committed (v-model follows this). */
191
+ onChange?: (value: [number, number], rs: RangeSliderHandle) => void;
192
+ }
193
+ /** <RangeSlider v-model="price" :min="0" :max="2000" /> — template ref → RangeSliderHandle */
194
+ export const RangeSlider: GeckoComponent<RangeSliderProps>;
195
+
196
+ /* ---------------- Stepper ---------------- */
197
+ export interface StepperHandle {
198
+ readonly value: number;
199
+ /** Go to a number (clamped and snapped); @change runs unless { silent: true }. */
200
+ set(value: number, opts?: { silent?: boolean }): StepperHandle;
201
+ /** One step up (1) or down (-1); false at the limit. */
202
+ stepBy(dir: 1 | -1): boolean;
203
+ setRange(range: { min?: number; max?: number }): StepperHandle;
204
+ destroy(): void;
205
+ readonly el: HTMLElement;
206
+ }
207
+ export interface StepperProps extends ModelProps<number> {
208
+ /** Applied in place (a value outside is pulled in). */
209
+ min?: number;
210
+ max?: number;
211
+ /** 0.5 shows one decimal, 0.25 two. */
212
+ step?: number;
213
+ /** After the number: 'days' or (n) => (n === 1 ? 'day' : 'days'). */
214
+ unit?: string | ((n: number) => string);
215
+ /** Before the number, e.g. '฿'. */
216
+ prefix?: string;
217
+ /** Default: grouped digits for the locale (1,250). */
218
+ format?: (n: number) => string;
219
+ locale?: string;
220
+ size?: '' | 'sm' | 'lg';
221
+ /** A hidden input, so a plain <form> sends the value. */
222
+ name?: string;
223
+ disabled?: boolean;
224
+ words?: { label?: string; less?: string; more?: string; min?: (n: string) => string; max?: (n: string) => string };
225
+ onChange?: (value: number, st: StepperHandle) => void;
226
+ }
227
+ /** <Stepper v-model="days" :min="1" :max="30" /> — template ref → StepperHandle */
228
+ export const Stepper: GeckoComponent<StepperProps>;
229
+
230
+ /* ---------------- Rating ---------------- */
231
+ export interface RatingHandle {
232
+ readonly value: number;
233
+ /** Go to a score; onChange runs unless { silent: true }. */
234
+ set(value: number, opts?: { silent?: boolean }): void;
235
+ setReadOnly(readOnly: boolean): void;
236
+ destroy(): void;
237
+ readonly el: HTMLElement;
238
+ }
239
+ export interface RatingProps extends ModelProps<number> {
240
+ max?: number;
241
+ /** Pick in halves (3.5). */
242
+ half?: boolean;
243
+ /** Show a score; any number fills partly (4.3). */
244
+ readOnly?: boolean;
245
+ /** Picking the same score again clears it (default true). */
246
+ clearable?: boolean;
247
+ icon?: 'star' | 'heart' | (string & {});
248
+ size?: '' | 'sm' | 'lg';
249
+ /** A word beside the stars for each score. */
250
+ labels?: string[] | null;
251
+ /** The number beside the stars. */
252
+ showValue?: boolean;
253
+ /** A hidden input with this name, so a plain <form> sends the score. */
254
+ name?: string;
255
+ disabled?: boolean;
256
+ words?: { label?: string; of?: (value: number, max: number) => string; none?: string; cleared?: string };
257
+ onChange?: (value: number, handle: RatingHandle) => void;
258
+ }
259
+ /** <Rating v-model="score" :max="5" half /> — template ref → RatingHandle */
260
+ export const Rating: GeckoComponent<RatingProps>;
261
+
262
+ /* ---------------- RadioCards ---------------- */
263
+ export interface RadioCardOption { value: string; title?: string; desc?: string; price?: string | number; icon?: string; badge?: string; disabled?: boolean }
264
+ export interface RadioCardsHandle {
265
+ readonly value: string;
266
+ /** Pick from code (no @change unless { silent: false }); '' clears. */
267
+ set(value: string, opts?: { silent?: boolean }): RadioCardsHandle;
268
+ focus(): void;
269
+ destroy(): void;
270
+ readonly el: HTMLElement;
271
+ }
272
+ export interface RadioCardsProps extends ModelProps<string> {
273
+ /** The group name (a <legend>). */
274
+ label?: string;
275
+ /** Keep the label for screen readers only. */
276
+ hideLabel?: boolean;
277
+ options: (RadioCardOption | string)[];
278
+ /** list: one card per row; grid: side by side. */
279
+ layout?: 'list' | 'grid';
280
+ /** grid only: the narrowest a card gets, in px (160). */
281
+ min?: number;
282
+ /** The radios' name (sent with a form). */
283
+ name?: string;
284
+ required?: boolean;
285
+ disabled?: boolean;
286
+ words?: { group?: string };
287
+ onChange?: (value: string, option: RadioCardOption, plan: RadioCardsHandle) => void;
288
+ }
289
+ /** <RadioCards v-model="how" :options="[…]" /> — template ref → RadioCardsHandle */
290
+ export const RadioCards: GeckoComponent<RadioCardsProps>;
291
+
292
+ /* ---------------- PricingToggle ---------------- */
293
+ export interface PricingPeriod { id: string; label: string; per?: string; badge?: string }
294
+ export interface PricingPlan {
295
+ id?: string; name: string; desc?: string;
296
+ /** { month: 12, year: 9 }, one number, or a string ('Free', 'Custom'). */
297
+ price?: Record<string, number | string> | number | string;
298
+ /** A line under the price, per period or (periodId, plan) => text. */
299
+ note?: Record<string, string> | string | ((periodId: string, plan: PricingPlan) => string);
300
+ features?: string[];
301
+ /** The button's label (no action: no button). */
302
+ action?: string;
303
+ featured?: boolean;
304
+ /** A small tag beside the name ('Popular'). */
305
+ tag?: string;
306
+ }
307
+ export interface PricingToggleHandle {
308
+ readonly period: string;
309
+ /** Show another period's prices; @change runs unless { silent: true }. */
310
+ set(periodId: string, opts?: { silent?: boolean }): boolean;
311
+ destroy(): void;
312
+ readonly el: HTMLElement;
313
+ }
314
+ export interface PricingToggleProps extends ModelProps<string> {
315
+ periods?: PricingPeriod[];
316
+ plans: PricingPlan[];
317
+ /** Intl.NumberFormat options, or (value, periodId, plan) => text. */
318
+ format?: Intl.NumberFormatOptions | ((value: number, periodId: string, plan: PricingPlan) => string);
319
+ locale?: string;
320
+ /** Roll digit by digit or count to the new number. */
321
+ motion?: 'roll' | 'count';
322
+ /** Show the first period's higher price crossed out (default true). */
323
+ strike?: boolean;
324
+ words?: { label?: string; showing?: (periodLabel: string) => string; was?: string; features?: (planName: string) => string };
325
+ onChange?: (periodId: string, prices: PricingToggleHandle) => void;
326
+ /** A plan's action button was pressed. */
327
+ onSelect?: (plan: PricingPlan, periodId: string, prices: PricingToggleHandle) => void;
328
+ }
329
+ /** <PricingToggle v-model="period" :plans="plans" /> — template ref → PricingToggleHandle */
330
+ export const PricingToggle: GeckoComponent<PricingToggleProps>;
331
+
332
+ /* ---------------- DateRange ---------------- */
333
+ export interface DateRangeValue { start: string | null; end: string | null; count: number | null }
334
+ export interface DateRangeHandle {
335
+ readonly value: DateRangeValue;
336
+ /** Pick from code (no @change); null clears. */
337
+ set(value: { start: DateLike; end?: DateLike | null } | DateLike | null, opts?: { animate?: boolean }): DateRangeHandle;
338
+ clear(): DateRangeHandle;
339
+ /** Show another month: a date, or +1 / -1. */
340
+ go(where: DateLike | number): DateRangeHandle;
341
+ destroy(): void;
342
+ readonly el: HTMLElement;
343
+ }
344
+ /** What v-model / default-value take: { start, end } (end may be null), or one date in single mode. */
345
+ export type DateRangeInput = { start: DateLike | null; end?: DateLike | null; count?: number | null } | DateLike | null;
346
+ export interface DateRangeProps {
347
+ /** The pick (v-model). Gets { start, end, count } back. */
348
+ modelValue?: DateRangeInput;
349
+ defaultValue?: DateRangeInput;
350
+ 'onUpdate:modelValue'?: (value: DateRangeValue) => void;
351
+ mode?: 'range' | 'single';
352
+ /** Two months side by side (drops to one when narrow). */
353
+ months?: 1 | 2;
354
+ min?: DateLike;
355
+ max?: DateLike;
356
+ /** Days that cannot be picked: dates, { start, end } spans, or (date) => true. */
357
+ disabled?: (DateLike | { start: DateLike; end: DateLike })[] | ((date: string) => boolean);
358
+ /** 4–7 Dec = 4 days, or 3 nights. */
359
+ count?: 'days' | 'nights';
360
+ minDays?: number;
361
+ /** 0 = no limit. */
362
+ maxDays?: number;
363
+ /** A range may not run across a day that is not free (default true). */
364
+ blockSpan?: boolean;
365
+ presets?: ({ label: string; days: number } | { label: string; start: DateLike; end: DateLike })[];
366
+ locale?: string;
367
+ /** 1 = Monday, 0 = Sunday. */
368
+ weekStart?: number;
369
+ words?: Record<string, string | ((...a: any[]) => string)>;
370
+ onChange?: (value: DateRangeValue, dp: DateRangeHandle) => void;
371
+ onInvalid?: (reason: 'blocked' | 'short' | 'long' | 'off', dp: DateRangeHandle) => void;
372
+ }
373
+ /** <DateRange v-model="dates" /> — template ref → DateRangeHandle */
374
+ export const DateRange: GeckoComponent<DateRangeProps>;
375
+
376
+ /* ---------------- TimePicker ---------------- */
377
+ export interface TimePickerHandle {
378
+ /** 'HH:MM' (24-hour), or null when nothing is picked (slots). */
379
+ readonly value: string | null;
380
+ set(time: string | null, opts?: { silent?: boolean }): TimePickerHandle;
381
+ /** Change which times are taken. */
382
+ setDisabled(disabled: string[] | ((time: string) => boolean) | null): TimePickerHandle;
383
+ /** '14:30' or '2:30 PM' with hour12. */
384
+ format(time?: string): string;
385
+ destroy(): void;
386
+ readonly el: HTMLElement;
387
+ }
388
+ export interface TimePickerProps extends ModelProps<string | null> {
389
+ look?: 'wheel' | 'slots';
390
+ /** Minutes between choices (wheel 5, slots 30). */
391
+ step?: number;
392
+ min?: string;
393
+ max?: string;
394
+ /** Times that can't be picked (applied in place when it changes). */
395
+ disabled?: string[] | ((time: string) => boolean) | null;
396
+ /** Show 2:30 PM (the value stays 24-hour). */
397
+ hour12?: boolean;
398
+ words?: Record<string, string | ((...a: any[]) => string)>;
399
+ onChange?: (value: string | null, tp: TimePickerHandle) => void;
400
+ }
401
+ /** <TimePicker v-model="time" look="slots" /> — template ref → TimePickerHandle */
402
+ export const TimePicker: GeckoComponent<TimePickerProps>;
403
+
404
+ /* ---------------- SubscribeForm ---------------- */
405
+ export interface SubscribeFormHandle {
406
+ readonly value: string;
407
+ readonly state: 'idle' | 'bad' | 'busy' | 'done';
408
+ /** Show your own message under the field (red); '' clears it. */
409
+ setError(text: string): void;
410
+ /** Back to an empty field (also after success). */
411
+ reset(): void;
412
+ destroy(): void;
413
+ readonly el: HTMLElement;
414
+ }
415
+ export interface SubscribeFormProps {
416
+ /** The email in the field at the start. */
417
+ defaultValue?: string;
418
+ /** The input's name ('email'). */
419
+ name?: string;
420
+ /** An icon inside the field on the left, e.g. 'mail'. */
421
+ icon?: string;
422
+ /** Button beside the field (wraps under it when narrow) or always under it. */
423
+ layout?: 'row' | 'stack';
424
+ /** Your own extra check: return a message to refuse the address. */
425
+ validate?: (email: string) => string | null | undefined;
426
+ /** ms after success before the empty form comes back (0 = stay thanked). */
427
+ resetAfter?: number;
428
+ words?: { label?: string; button?: string; hint?: string; missing?: string; bad?: string; busy?: string; done?: string; doneText?: string; failed?: string };
429
+ /** Resolve (a string replaces doneText); reject or throw to show the error. */
430
+ onSubmit?: (email: string, sub: SubscribeFormHandle) => unknown | Promise<unknown>;
431
+ }
432
+ /** <SubscribeForm @submit="join" /> — template ref → SubscribeFormHandle */
433
+ export const SubscribeForm: GeckoComponent<SubscribeFormProps>;
434
+
435
+ /* ---------------- AuthForm ---------------- */
436
+ export type AuthMode = 'in' | 'up';
437
+ export interface AuthValues { name?: string; email: string; password: string; remember?: boolean }
438
+ export interface PasswordRule { id?: string; test: (value: string) => boolean; label: string }
439
+ export interface PasswordMeterOptions {
440
+ /** Default: length (min), upper + lower, number, symbol. */
441
+ rules?: PasswordRule[] | null;
442
+ /** Length for the default first rule (8). */
443
+ min?: number;
444
+ /** valid needs this score (0–4; 3 = “okay”). */
445
+ minScore?: number;
446
+ /** Your own scoring 0–4; met = [true, false, …] in rule order. */
447
+ score?: ((value: string, met: boolean[]) => number) | null;
448
+ /** The rules checklist (default true). */
449
+ list?: boolean;
450
+ /** The padlock that clicks shut when strong (default true). */
451
+ lock?: boolean;
452
+ words?: Record<string, string | ((...a: any[]) => string)>;
453
+ }
454
+ export interface AuthFormHandle {
455
+ readonly mode: AuthMode;
456
+ setMode(mode: AuthMode): boolean;
457
+ readonly values: AuthValues;
458
+ readonly busy: boolean;
459
+ /** Mark a field red with a message ('' clears). */
460
+ setError(field: 'name' | 'email' | 'password' | 'confirm', message: string): void;
461
+ reset(): void;
462
+ destroy(): void;
463
+ readonly el: HTMLElement;
464
+ }
465
+ export interface AuthFormProps {
466
+ /** Sign in or create account (v-model:mode; applied in place). */
467
+ mode?: AuthMode;
468
+ 'onUpdate:mode'?: (mode: AuthMode) => void;
469
+ /** The mode at the start when there is no v-model:mode. */
470
+ defaultMode?: AuthMode;
471
+ /** forgot: true (a button → @forgot) or a URL. */
472
+ fields?: { name?: boolean; confirm?: boolean; remember?: boolean; forgot?: boolean | string };
473
+ /** Strength meter on sign-up; or passwordMeter options. */
474
+ meter?: boolean | PasswordMeterOptions;
475
+ /** Shortest password on sign-up when meter is false. */
476
+ min?: number;
477
+ /** Fill the fields in when it mounts. */
478
+ values?: { name?: string; email?: string; remember?: boolean };
479
+ /** Your own extra checks: { email: 'message' }. */
480
+ validate?: (values: AuthValues, mode: AuthMode) => Partial<Record<'name' | 'email' | 'password' | 'confirm', string>> | null | undefined;
481
+ words?: Record<string, unknown>;
482
+ /** Reject (or throw) to show an error; Error.field = 'email' marks that field. Resolve a string to show it. */
483
+ onSubmit?: (values: AuthValues, mode: AuthMode, f: AuthFormHandle) => unknown | Promise<unknown>;
484
+ onModeChange?: (mode: AuthMode, f: AuthFormHandle) => void;
485
+ onForgot?: (email: string, f: AuthFormHandle) => void;
486
+ }
487
+ /** <AuthForm v-model:mode="mode" @submit="signIn" /> — template ref → AuthFormHandle */
488
+ export const AuthForm: GeckoComponent<AuthFormProps>;
489
+
490
+ /* ---------------- PasswordToggle / PasswordMeter ---------------- */
491
+ export interface PasswordToggleProps extends ModelProps<string>, PasswordInputAttrs {
492
+ /** Letters visible (v-model:shown). */
493
+ shown?: boolean;
494
+ 'onUpdate:shown'?: (shown: boolean) => void;
495
+ /** Letters visible at the start when there is no v-model:shown. */
496
+ defaultShown?: boolean;
497
+ onToggle?: (shown: boolean) => void;
498
+ words?: { show?: string; hide?: string };
499
+ }
500
+ /** What a template ref on PasswordToggle gives you. */
501
+ export interface PasswordToggleHandle {
502
+ /** The <input> (a ref, unwrapped). */
503
+ readonly input: HTMLInputElement | null;
504
+ focus(): void;
505
+ }
506
+ /** <PasswordToggle v-model="password" name="password" autocomplete="current-password" /> */
507
+ export const PasswordToggle: GeckoComponent<PasswordToggleProps>;
508
+
509
+ export interface PasswordState { score: number; level: 'empty' | 'tooWeak' | 'weak' | 'okay' | 'strong'; valid: boolean; rules: Record<string, boolean> }
510
+ export interface PasswordMeterHandle {
511
+ readonly score: number;
512
+ readonly level: PasswordState['level'];
513
+ readonly valid: boolean;
514
+ readonly rules: Record<string, boolean>;
515
+ /** Read the field again. */
516
+ check(): PasswordState;
517
+ /** Show or hide the letters (with reveal). */
518
+ reveal(on: boolean): void;
519
+ readonly input: HTMLInputElement;
520
+ readonly root: HTMLElement;
521
+ }
522
+ export interface PasswordMeterProps extends PasswordMeterOptions, ModelProps<string>, Omit<PasswordInputAttrs, 'onInput'> {
523
+ /** A show / hide eye inside the field. */
524
+ reveal?: boolean;
525
+ /** The text changed (also through v-model). */
526
+ onValueChange?: (value: string, event: Event) => void;
527
+ /** The meter changed: { score, level, valid, rules }. */
528
+ onChange?: (state: PasswordState, pw: PasswordMeterHandle) => void;
529
+ onInput?: (event: Event) => void;
530
+ }
531
+ /** <PasswordMeter v-model="pw" reveal @change="(s) => (ok = s.valid)" /> — template ref → PasswordMeterHandle */
532
+ export const PasswordMeter: GeckoComponent<PasswordMeterProps>;
533
+
534
+ /* ---------------- SignaturePad ---------------- */
535
+ /** Strokes saved with toJSON(). */
536
+ export interface SignatureData { v: number; ratio: number; strokes: [number, number, number, number][][] }
537
+ export interface SignaturePadHandle {
538
+ readonly isEmpty: boolean;
539
+ undo(): SignaturePadHandle;
540
+ clear(): SignaturePadHandle;
541
+ /** Draw it again, stroke by stroke. */
542
+ replay(): Promise<SignaturePadHandle>;
543
+ toJSON(): SignatureData;
544
+ fromJSON(data: SignatureData, opts?: { animate?: boolean }): Promise<SignaturePadHandle>;
545
+ /** A data URL; trim cuts it to the ink; background '' keeps it transparent. */
546
+ toImage(opts?: { type?: string; background?: string; color?: string; trim?: boolean; scale?: number; margin?: number }): string;
547
+ toSVG(opts?: { color?: string }): string;
548
+ destroy(): void;
549
+ readonly el: HTMLElement;
550
+ }
551
+ export interface SignaturePadProps {
552
+ /** 'currentColor' (follows the text colour) or any colour. */
553
+ color?: string;
554
+ /** Thinnest and thickest line in px. */
555
+ width?: [number, number];
556
+ /** Fast = thin, slow or pressed hard = thick (false: one even width). */
557
+ pressure?: boolean;
558
+ /** The line and × to sign on. */
559
+ guide?: boolean;
560
+ /** Undo and clear buttons in the corner. */
561
+ tools?: boolean;
562
+ /** Show a signature that can't be changed. */
563
+ readOnly?: boolean;
564
+ /** Strokes to show (loaded again when they change). */
565
+ defaultValue?: SignatureData | null;
566
+ words?: { label?: string; hint?: string; undo?: string; clear?: string; signed?: string; empty?: string; cleared?: string };
567
+ /** After every change. */
568
+ onChange?: (isEmpty: boolean, sig: SignaturePadHandle) => void;
569
+ /** After each stroke. */
570
+ onEnd?: (sig: SignaturePadHandle) => void;
571
+ }
572
+ /** <SignaturePad @change="(empty) => (signed = !empty)" /> — template ref → SignaturePadHandle */
573
+ export const SignaturePad: GeckoComponent<SignaturePadProps>;
574
+
575
+ /* ---------------- PhotoUpload ---------------- */
576
+ export interface UploadItem { id: string; name: string; size: number; type: string; file: File | null; url: string; status: 'queued' | 'uploading' | 'done' | 'error'; progress: number; result: unknown; error: unknown }
577
+ /** A photo that is already uploaded: its URL, or { url, … } (kept as its result). */
578
+ export type UploadedPhoto = string | { url: string; name?: string; [k: string]: unknown };
579
+ export interface PhotoUploadHandle {
580
+ readonly items: UploadItem[];
581
+ /** Each photo's upload result (or the File without upload), in order. */
582
+ readonly value: unknown[];
583
+ readonly busy: boolean;
584
+ /** Resolves with value once nothing is uploading. */
585
+ settled(): Promise<unknown[]>;
586
+ add(files: FileList | File[], from?: { x: number; y: number } | null): UploadItem[];
587
+ remove(id: string): PhotoUploadHandle;
588
+ move(id: string, index: number): PhotoUploadHandle;
589
+ retry(id: string): PhotoUploadHandle;
590
+ clear(): PhotoUploadHandle;
591
+ /** Open the file picker. */
592
+ open(): PhotoUploadHandle;
593
+ /** Show photos that are already uploaded. */
594
+ setValue(list: UploadedPhoto[]): PhotoUploadHandle;
595
+ destroy(): void;
596
+ readonly el: HTMLElement;
597
+ }
598
+ export interface PhotoUploadProps {
599
+ /** Photos already uploaded (v-model): [{ url, … }] or URLs. Gets each photo's upload result, in order. */
600
+ modelValue?: UploadedPhoto[];
601
+ defaultValue?: UploadedPhoto[];
602
+ 'onUpdate:modelValue'?: (value: any[]) => void;
603
+ /** Like <input accept> (default 'image/*'). */
604
+ accept?: string;
605
+ /** Most photos (8; 0 = no limit). */
606
+ max?: number;
607
+ /** MB per photo (10; 0 = no limit). */
608
+ maxSize?: number;
609
+ /** Your upload; call progress(0…1); resolve to anything (usually { url }). */
610
+ upload?: (file: File, ctx: { progress: (f: number) => void; signal: AbortSignal; item: UploadItem }) => Promise<unknown>;
611
+ /** Uploads at the same time (2). */
612
+ concurrent?: number;
613
+ /** Make big photos smaller first. */
614
+ resize?: boolean | { max?: number; quality?: number; type?: string } | null;
615
+ /** Label the first photo "Cover". */
616
+ cover?: boolean;
617
+ sortable?: boolean;
618
+ readOnly?: boolean;
619
+ /** 'environment' opens the camera on phones. */
620
+ capture?: string | null;
621
+ words?: Record<string, string | ((...a: any[]) => string)>;
622
+ onChange?: (items: UploadItem[], up: PhotoUploadHandle) => void;
623
+ onReject?: (file: File, reason: 'type' | 'size' | 'count', up: PhotoUploadHandle) => void;
624
+ onUploaded?: (item: UploadItem, up: PhotoUploadHandle) => void;
625
+ onError?: (item: UploadItem, error: unknown, up: PhotoUploadHandle) => void;
626
+ }
627
+ /** <PhotoUpload v-model="photos" :upload="send" /> — template ref → PhotoUploadHandle */
628
+ export const PhotoUpload: GeckoComponent<PhotoUploadProps>;
629
+
630
+ /* ---------------- FileDrop ---------------- */
631
+ export interface FileDropFile { id: string; file: File; name: string; size: number; type: string; status: 'queued' | 'uploading' | 'done' | 'error'; progress: number; error: string | null; reason: 'type' | 'size' | 'count' | 'upload' | null; result: unknown }
632
+ export interface FileDropHandle {
633
+ readonly files: FileDropFile[];
634
+ /** Results of finished uploads (or the Files without upload). */
635
+ readonly value: unknown[];
636
+ readonly busy: boolean;
637
+ add(files: FileList | File[]): FileDropFile[];
638
+ remove(id: string): FileDropHandle;
639
+ retry(id: string): FileDropHandle;
640
+ cancel(id: string): FileDropHandle;
641
+ clear(): FileDropHandle;
642
+ /** Open the file picker. */
643
+ browse(): FileDropHandle;
644
+ /** Start the queued uploads (with auto: false). */
645
+ upload(): Promise<unknown[]>;
646
+ destroy(): void;
647
+ readonly el: HTMLElement;
648
+ }
649
+ export interface FileDropProps {
650
+ /** Like <input accept> ('' = anything). */
651
+ accept?: string;
652
+ /** false: one file; a new one replaces it. */
653
+ multiple?: boolean;
654
+ /** Bytes per file (0 = no limit). */
655
+ maxSize?: number;
656
+ /** Most files (0 = no limit). */
657
+ maxFiles?: number;
658
+ /** Call progress(0…1); without it files are only listed. */
659
+ upload?: (file: File, ctx: { progress: (f: number) => void; signal: AbortSignal; id: string }) => Promise<unknown>;
660
+ /** Start uploading as files are added (false: call ref.upload()). */
661
+ auto?: boolean;
662
+ /** Uploads at the same time (3). */
663
+ concurrent?: number;
664
+ /** A slim one-line zone. */
665
+ compact?: boolean;
666
+ words?: Record<string, string | ((...a: any[]) => string)>;
667
+ onChange?: (files: FileDropFile[], fd: FileDropHandle) => void;
668
+ onError?: (problem: { id: string; file: File; name: string; reason: 'type' | 'size' | 'count' | 'upload'; message: string; error: unknown }, fd: FileDropHandle) => void;
669
+ }
670
+ /** <FileDrop :upload="send" /> — template ref → FileDropHandle */
671
+ export const FileDrop: GeckoComponent<FileDropProps>;
672
+
673
+ /* ---------------- Wizard ---------------- */
674
+ export interface WizardHandle {
675
+ /** The step on show (from 0); steps.length once finished. */
676
+ readonly index: number;
677
+ readonly finished: boolean;
678
+ /** Every named field in the panels: { name: value }. */
679
+ readonly values: Record<string, unknown>;
680
+ /** Show a step without checking the one you are on. */
681
+ go(index: number): WizardHandle;
682
+ /** Check this step and move on (or finish). */
683
+ next(): Promise<boolean>;
684
+ back(): WizardHandle;
685
+ /** Back to the first step with the fields as they started. */
686
+ reset(): WizardHandle;
687
+ setBusy(on: boolean): WizardHandle;
688
+ destroy(): void;
689
+ readonly el: HTMLElement;
690
+ }
691
+ export interface WizardStep {
692
+ /** Also the name of the slot with this step's content (#bike). */
693
+ id?: string;
694
+ title: string;
695
+ sub?: string;
696
+ /** Plain text for the panel when it has no slot. */
697
+ content?: string;
698
+ optional?: boolean;
699
+ /** true, a message, or a Promise of either; no validate: the browser's own checks on the fields. */
700
+ validate?: (panel: HTMLElement, wz: WizardHandle) => true | false | string | Promise<true | false | string>;
701
+ }
702
+ export interface WizardProps {
703
+ steps: WizardStep[];
704
+ /** The step shown (v-model:index; applied with go(), without checking). */
705
+ index?: number;
706
+ 'onUpdate:index'?: (index: number) => void;
707
+ /** The step shown first. */
708
+ start?: number;
709
+ /** The header cannot jump past steps that are not finished (default true). */
710
+ linear?: boolean;
711
+ header?: 'steps' | 'bar' | 'none';
712
+ /** Heading level of the panel titles (3). */
713
+ level?: number;
714
+ /** The progress header's name for screen readers. */
715
+ label?: string;
716
+ words?: { next?: string; back?: string; finish?: string; step?: (i: number, n: number) => string; done?: string; doneText?: string; optional?: string; completed?: string; locked?: string; busy?: string; invalid?: string; label?: string };
717
+ onStep?: (index: number, wz: WizardHandle) => void;
718
+ /** May return a Promise; false (or a message) keeps the last step open. */
719
+ onFinish?: (values: Record<string, unknown>, wz: WizardHandle) => unknown | Promise<unknown>;
720
+ }
721
+ /** What every step slot gets. */
722
+ export interface WizardSlotProps { step: WizardStep; index: number }
723
+ /** Slots: one per step, named after its id (#bike), or #step for every step. */
724
+ export type WizardSlots = { step?: (props: WizardSlotProps) => VNodeChild } & { [id: string]: ((props: WizardSlotProps) => VNodeChild) | undefined };
725
+ /** <Wizard :steps="[{ id: 'bike', title: 'Bike' }]"><template #bike>…</template></Wizard> — template ref → WizardHandle */
726
+ export const Wizard: GeckoComponent<WizardProps, WizardSlots>;
727
+
728
+ /* ---------------- useValidation ---------------- */
729
+ /** A rule: '' (or true / null) when fine, else the message to show. */
730
+ export type ValidationRule = (value: any, values: Record<string, any>) => string | boolean | null | undefined;
731
+ /** What v-bind="v.field(name)" puts on an <input>/<textarea>/<select>. */
732
+ export interface ValidationField<K extends string> {
733
+ name: K;
734
+ ref: (el: Element | { $el: Element } | null) => void;
735
+ onInput: () => void;
736
+ 'aria-invalid': true | undefined;
737
+ }
738
+ export interface Validation<K extends string> {
739
+ /** The message of every field that is wrong now (reactive). */
740
+ errors: Partial<Record<K, string>>;
741
+ /** Attributes for the field: <input v-bind="v.field('email')">. */
742
+ field(name: K): ValidationField<K>;
743
+ /** Check every field (or these): marks and shakes the bad ones; true when all are fine. */
744
+ validate(names?: K[]): boolean;
745
+ /** Check one field. */
746
+ check(name: K): boolean;
747
+ /** Mark a field from elsewhere (a server answer); '' clears. */
748
+ setError(name: K, message: string): void;
749
+ /** Clear every message. */
750
+ reset(): void;
751
+ /** The current values of the fields. */
752
+ values(): Record<K, any>;
753
+ }
754
+ /** const v = useValidation({ email: (v) => (v ? '' : 'Enter your email.') }) — call it in setup(). */
755
+ export function useValidation<K extends string>(rules: Record<K, ValidationRule>, options?: { live?: boolean; shake?: boolean }): Validation<K>;
756
+
757
+ export {};