@gecko-ui-kit/vue 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2052 -2
- package/index.d.ts +13 -0
- package/index.js +16 -0
- package/package.json +48 -4
- package/src/actions.d.ts +186 -0
- package/src/actions.js +329 -0
- package/src/basics.d.ts +315 -0
- package/src/basics.js +475 -0
- package/src/charts.d.ts +219 -0
- package/src/charts.js +93 -0
- package/src/controls.d.ts +149 -0
- package/src/controls.js +354 -0
- package/src/core.d.ts +109 -0
- package/src/core.js +414 -0
- package/src/data.d.ts +754 -0
- package/src/data.js +718 -0
- package/src/effects.d.ts +407 -0
- package/src/effects.js +699 -0
- package/src/forms.d.ts +757 -0
- package/src/forms.js +481 -0
- package/src/motion.d.ts +127 -0
- package/src/motion.js +216 -0
- package/src/overlays.d.ts +467 -0
- package/src/overlays.js +710 -0
- package/src/plugin.d.ts +6 -0
- package/src/plugin.js +27 -0
- package/src/shell.d.ts +210 -0
- package/src/shell.js +716 -0
- package/src/text.d.ts +309 -0
- package/src/text.js +383 -0
package/src/basics.d.ts
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import type { VNodeChild } from 'vue';
|
|
2
|
+
import type { GeckoComponent, IconLike, DefaultSlot, ModelProps } from './core.js';
|
|
3
|
+
|
|
4
|
+
type Tone = 'good' | 'warn' | 'bad' | 'accent' | 'plain' | (string & {});
|
|
5
|
+
type AvatarTone = 'indigo' | 'teal' | 'rose' | 'amber' | 'violet' | 'green' | 'slate' | 'sky' | (string & {});
|
|
6
|
+
type Slot<P = {}> = (props: P) => VNodeChild;
|
|
7
|
+
|
|
8
|
+
export interface SpinnerProps {
|
|
9
|
+
/** px (number) or any CSS length; the loader is 1em, so it follows the text size by default. */
|
|
10
|
+
size?: number | string;
|
|
11
|
+
tone?: 'accent' | 'ink' | 'muted' | 'good' | 'warn' | 'bad' | 'current';
|
|
12
|
+
/** Seconds per turn (1). */
|
|
13
|
+
speed?: number | string;
|
|
14
|
+
/** The faint ring behind the arc (true). */
|
|
15
|
+
track?: boolean;
|
|
16
|
+
/** Text beside (or under, with stack) the loader. */
|
|
17
|
+
label?: string;
|
|
18
|
+
stack?: boolean;
|
|
19
|
+
words?: { loading?: string };
|
|
20
|
+
/** Hide it from screen readers (inside a busy button). */
|
|
21
|
+
decorative?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** <Spinner :size="28" label="Loading bookings…" /> */
|
|
24
|
+
export const Spinner: GeckoComponent<SpinnerProps>;
|
|
25
|
+
|
|
26
|
+
export interface ButtonProps {
|
|
27
|
+
variant?: 'primary' | 'ghost' | 'danger' | 'soft' | (string & {});
|
|
28
|
+
size?: 'sm' | 'lg' | (string & {});
|
|
29
|
+
/** An icon before the label. */
|
|
30
|
+
icon?: IconLike;
|
|
31
|
+
/** An icon after the label. */
|
|
32
|
+
iconRight?: IconLike;
|
|
33
|
+
/** Full width. */
|
|
34
|
+
block?: boolean;
|
|
35
|
+
/** Leans toward the pointer. */
|
|
36
|
+
magnetic?: boolean;
|
|
37
|
+
/** Locks the button and shows a spinner. */
|
|
38
|
+
busy?: boolean;
|
|
39
|
+
/** The label while busy. */
|
|
40
|
+
busyText?: string;
|
|
41
|
+
type?: 'button' | 'submit' | 'reset';
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** <Button variant="primary" icon="check" @click="save">Save</Button> */
|
|
45
|
+
export const Button: GeckoComponent<ButtonProps, DefaultSlot>;
|
|
46
|
+
|
|
47
|
+
export interface IconButtonProps {
|
|
48
|
+
/** The icon: a name ('bell'), a component or a VNode. */
|
|
49
|
+
icon: IconLike;
|
|
50
|
+
/** What it does, read by screen readers (aria-label). */
|
|
51
|
+
label: string;
|
|
52
|
+
size?: 'sm' | (string & {});
|
|
53
|
+
/** On/off button (aria-pressed); use v-model:pressed. */
|
|
54
|
+
pressed?: boolean;
|
|
55
|
+
/** On/off button that keeps its own state, starting here. */
|
|
56
|
+
defaultPressed?: boolean;
|
|
57
|
+
'onUpdate:pressed'?: (pressed: boolean) => void;
|
|
58
|
+
/** Runs when an on/off button is pressed. */
|
|
59
|
+
onChange?: (pressed: boolean, event: MouseEvent) => void;
|
|
60
|
+
/** Runs first; call event.preventDefault() to keep the pressed state as it is. */
|
|
61
|
+
onClick?: (event: MouseEvent) => void;
|
|
62
|
+
type?: 'button' | 'submit' | 'reset';
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** <IconButton icon="bell" label="Notifications" />, <IconButton icon="heart" label="Favourite" v-model:pressed="fav" /> */
|
|
66
|
+
export const IconButton: GeckoComponent<IconButtonProps, DefaultSlot>;
|
|
67
|
+
|
|
68
|
+
export interface TagProps {
|
|
69
|
+
/** Colour: good | warn | bad | accent | plain (default). */
|
|
70
|
+
tone?: Tone;
|
|
71
|
+
/** The small dot before the text (default true). */
|
|
72
|
+
dot?: boolean;
|
|
73
|
+
/** An icon instead of the dot. */
|
|
74
|
+
icon?: IconLike;
|
|
75
|
+
}
|
|
76
|
+
/** <Tag tone="good">Paid</Tag> */
|
|
77
|
+
export const Tag: GeckoComponent<TagProps, DefaultSlot>;
|
|
78
|
+
|
|
79
|
+
export interface BadgeProps {
|
|
80
|
+
/** 'accent' fills it with the accent colour. */
|
|
81
|
+
tone?: 'accent' | (string & {});
|
|
82
|
+
}
|
|
83
|
+
/** <Badge tone="accent">3</Badge> */
|
|
84
|
+
export const Badge: GeckoComponent<BadgeProps, DefaultSlot>;
|
|
85
|
+
|
|
86
|
+
/** A person for Avatar, AvatarGroup and Cell. */
|
|
87
|
+
export interface Person {
|
|
88
|
+
/** Full name (the tooltip; initials come from it). */
|
|
89
|
+
name?: string;
|
|
90
|
+
/** Initials to show instead of the ones from name. */
|
|
91
|
+
ini?: string;
|
|
92
|
+
/** Colour: indigo teal rose amber violet green slate sky. */
|
|
93
|
+
tone?: AvatarTone;
|
|
94
|
+
}
|
|
95
|
+
export interface AvatarProps extends Person {
|
|
96
|
+
size?: 'sm' | 'lg' | (string & {});
|
|
97
|
+
/** A green "online" dot. */
|
|
98
|
+
online?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/** <Avatar name="Pim Wong" tone="teal" /> — no name and no ini: an empty "open slot". */
|
|
101
|
+
export const Avatar: GeckoComponent<AvatarProps>;
|
|
102
|
+
|
|
103
|
+
export interface AvatarGroupProps {
|
|
104
|
+
/** The people; an id (or the name) keys each one. */
|
|
105
|
+
people: (Person & { id?: string | number })[];
|
|
106
|
+
/** How many to show before "+N" (default 4). */
|
|
107
|
+
max?: number;
|
|
108
|
+
}
|
|
109
|
+
/** <AvatarGroup :people="team" :max="4" /> */
|
|
110
|
+
export const AvatarGroup: GeckoComponent<AvatarGroupProps>;
|
|
111
|
+
|
|
112
|
+
export interface CellProps extends Person {
|
|
113
|
+
/** The small line under the name (role, email…), or the #sub slot. */
|
|
114
|
+
sub?: string | number;
|
|
115
|
+
online?: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** <Cell name="Pim Wong" tone="teal" sub="Mechanic" /> */
|
|
118
|
+
export const Cell: GeckoComponent<CellProps, { sub?: Slot }>;
|
|
119
|
+
|
|
120
|
+
export interface CardHeadProps {
|
|
121
|
+
/** The heading (or the #title slot). */
|
|
122
|
+
title?: string | number;
|
|
123
|
+
/** Small line under the title (or #sub). */
|
|
124
|
+
sub?: string | number;
|
|
125
|
+
/** Text on the right; use the #right slot for buttons, chips… */
|
|
126
|
+
right?: string | number;
|
|
127
|
+
}
|
|
128
|
+
type HeadSlots = { title?: Slot; sub?: Slot; right?: Slot };
|
|
129
|
+
/** <CardHead title="Today" sub="12 bookings"><template #right>…</template></CardHead> */
|
|
130
|
+
export const CardHead: GeckoComponent<CardHeadProps, HeadSlots>;
|
|
131
|
+
|
|
132
|
+
export interface CardProps extends CardHeadProps {
|
|
133
|
+
/** No padding, so a table or list reaches the edges. */
|
|
134
|
+
flush?: boolean;
|
|
135
|
+
/** Rises a little when the mouse is over it. */
|
|
136
|
+
lift?: boolean;
|
|
137
|
+
}
|
|
138
|
+
/** <Card title="Today" sub="12 bookings" lift>…</Card> — the head shows when there is a title (prop or #title). */
|
|
139
|
+
export const Card: GeckoComponent<CardProps, HeadSlots & DefaultSlot>;
|
|
140
|
+
|
|
141
|
+
export interface KpiProps {
|
|
142
|
+
/** Small caption on top (or #label). */
|
|
143
|
+
label?: string | number;
|
|
144
|
+
/** The big number (or #value). */
|
|
145
|
+
value?: string | number;
|
|
146
|
+
/** Small line under it (or #sub). */
|
|
147
|
+
sub?: string | number;
|
|
148
|
+
/** accent: tinted tile; good / bad: coloured number. */
|
|
149
|
+
tone?: 'accent' | 'good' | 'bad' | (string & {});
|
|
150
|
+
}
|
|
151
|
+
/** <Kpi label="Revenue" value="฿48,250" sub="This month" /> */
|
|
152
|
+
export const Kpi: GeckoComponent<KpiProps, { label?: Slot; value?: Slot; sub?: Slot }>;
|
|
153
|
+
|
|
154
|
+
export interface EmptyProps {
|
|
155
|
+
/** Icon name, component or VNode (default 'inbox'). */
|
|
156
|
+
icon?: IconLike;
|
|
157
|
+
/** The heading (or #title). */
|
|
158
|
+
title?: string;
|
|
159
|
+
/** A line of text under it (or #body). */
|
|
160
|
+
body?: string;
|
|
161
|
+
}
|
|
162
|
+
/** <Empty icon="search" title="No bikes match" body="Try a shorter word."><template #action>…</template></Empty> */
|
|
163
|
+
export const Empty: GeckoComponent<EmptyProps, { title?: Slot; body?: Slot; action?: Slot } & DefaultSlot>;
|
|
164
|
+
|
|
165
|
+
export interface TableColumn<R = any> {
|
|
166
|
+
/** Field of the row to show (and the key of the column; #cell-<key> / #head-<key> slots use it). */
|
|
167
|
+
key: string;
|
|
168
|
+
/** Column title (default: key). */
|
|
169
|
+
title?: string;
|
|
170
|
+
/** 'right' for numbers. */
|
|
171
|
+
align?: 'left' | 'right';
|
|
172
|
+
/** Draw the cell from code (a slot is usually nicer): text or a VNode, never HTML. */
|
|
173
|
+
render?: (row: R, index: number) => VNodeChild;
|
|
174
|
+
/** Class on the column's <th> and <td>s. */
|
|
175
|
+
class?: string;
|
|
176
|
+
}
|
|
177
|
+
/** What a #cell / #cell-<key> slot gets. */
|
|
178
|
+
export interface TableCellSlotProps<R = any> {
|
|
179
|
+
row: R;
|
|
180
|
+
column: TableColumn<R>;
|
|
181
|
+
/** row[column.key] */
|
|
182
|
+
value: any;
|
|
183
|
+
index: number;
|
|
184
|
+
}
|
|
185
|
+
export interface TableProps<R = any> {
|
|
186
|
+
/** Columns; with rows, the table draws its own head and body. Leave out to write <thead>/<tbody> in the default slot. */
|
|
187
|
+
columns?: TableColumn<R>[];
|
|
188
|
+
rows?: R[];
|
|
189
|
+
/** A field name or function giving each row a stable key (default 'id'). */
|
|
190
|
+
rowKey?: string | ((row: R, index: number) => string | number);
|
|
191
|
+
/** Wrap in .gk-table-wrap so it scrolls sideways on small screens (default true). */
|
|
192
|
+
wrap?: boolean;
|
|
193
|
+
/** Rows slide in when they first appear (also rows added later). */
|
|
194
|
+
slideRows?: boolean;
|
|
195
|
+
}
|
|
196
|
+
export type TableSlots = {
|
|
197
|
+
/** Your own <thead> / <tbody> (without columns). */
|
|
198
|
+
default?: () => VNodeChild;
|
|
199
|
+
/** Any cell; when it renders nothing, the plain value shows. */
|
|
200
|
+
cell?: Slot<TableCellSlotProps>;
|
|
201
|
+
/** Any column title. */
|
|
202
|
+
head?: Slot<{ column: TableColumn }>;
|
|
203
|
+
/** <tr>s for a <tfoot> (e.g. a total row). */
|
|
204
|
+
foot?: () => VNodeChild;
|
|
205
|
+
} & { [cell: `cell-${string}`]: Slot<TableCellSlotProps> | undefined } & { [head: `head-${string}`]: Slot<{ column: TableColumn }> | undefined };
|
|
206
|
+
/** <Table :columns="[{ key: 'bike', title: 'Bike' }]" :rows="bookings"><template #cell-bike="{ row }">…</template></Table> */
|
|
207
|
+
export const Table: GeckoComponent<TableProps, TableSlots>;
|
|
208
|
+
|
|
209
|
+
export interface MeterProps {
|
|
210
|
+
/** How full, 0 to 1. */
|
|
211
|
+
value: number;
|
|
212
|
+
tone?: 'good' | 'warn' | 'bad' | (string & {});
|
|
213
|
+
/** Seconds before it starts filling the first time (default 0.15). */
|
|
214
|
+
delay?: number;
|
|
215
|
+
}
|
|
216
|
+
/** <Meter :value="0.7" tone="good" /> */
|
|
217
|
+
export const Meter: GeckoComponent<MeterProps>;
|
|
218
|
+
|
|
219
|
+
export interface RingProps {
|
|
220
|
+
/** How full, 0 to 1. */
|
|
221
|
+
value: number;
|
|
222
|
+
/** Width and height in px (default 56). */
|
|
223
|
+
size?: number;
|
|
224
|
+
/** Line thickness in px (default 6). */
|
|
225
|
+
stroke?: number;
|
|
226
|
+
/** In the middle, e.g. "72%" (or the #label slot). */
|
|
227
|
+
label?: string | number;
|
|
228
|
+
}
|
|
229
|
+
/** <Ring :value="0.72" label="72%" /> */
|
|
230
|
+
export const Ring: GeckoComponent<RingProps, { label?: Slot }>;
|
|
231
|
+
|
|
232
|
+
export interface StepsProps {
|
|
233
|
+
labels: (string | number)[];
|
|
234
|
+
/** The current step, from 0; steps before it are done. */
|
|
235
|
+
now: number;
|
|
236
|
+
}
|
|
237
|
+
/** <Steps :labels="['Bike', 'Dates', 'Pay']" :now="1" /> */
|
|
238
|
+
export const Steps: GeckoComponent<StepsProps, { label?: Slot<{ label: string | number; index: number }> }>;
|
|
239
|
+
|
|
240
|
+
export interface BarsProps {
|
|
241
|
+
values: number[];
|
|
242
|
+
/** The value of a full-height bar (default: the biggest value). */
|
|
243
|
+
max?: number;
|
|
244
|
+
/** A caption under each bar. */
|
|
245
|
+
labels?: (string | number)[];
|
|
246
|
+
/** The number above each bar. */
|
|
247
|
+
showValues?: boolean;
|
|
248
|
+
/** How a shown value is written (default: as is). */
|
|
249
|
+
format?: (value: number, index: number) => VNodeChild;
|
|
250
|
+
/** The tallest bar in full accent, the others lighter (default true). */
|
|
251
|
+
highlightTop?: boolean;
|
|
252
|
+
/** Chart height (default 210 px): px or any CSS length. */
|
|
253
|
+
height?: number | string;
|
|
254
|
+
/** What screen readers hear (default: the labels and values). */
|
|
255
|
+
label?: string;
|
|
256
|
+
}
|
|
257
|
+
/** <Bars :values="[12, 30, 22]" :labels="['Mon', 'Tue', 'Wed']" show-values /> */
|
|
258
|
+
export const Bars: GeckoComponent<BarsProps>;
|
|
259
|
+
|
|
260
|
+
export interface FieldProps {
|
|
261
|
+
/** The title above the control (or #label). */
|
|
262
|
+
label?: string;
|
|
263
|
+
/** A small line under the control (or #hint). */
|
|
264
|
+
hint?: string;
|
|
265
|
+
/** Red border and red hint. */
|
|
266
|
+
invalid?: boolean;
|
|
267
|
+
}
|
|
268
|
+
/** <Field label="Email" hint="…"><Input v-model="email" type="email" /></Field> */
|
|
269
|
+
export const Field: GeckoComponent<FieldProps, { label?: Slot; hint?: Slot } & DefaultSlot>;
|
|
270
|
+
|
|
271
|
+
/** Attributes of a text box that fall through to the <input> / <textarea>. */
|
|
272
|
+
export interface TextBoxAttrs {
|
|
273
|
+
placeholder?: string;
|
|
274
|
+
name?: string;
|
|
275
|
+
autocomplete?: string;
|
|
276
|
+
disabled?: boolean;
|
|
277
|
+
readonly?: boolean;
|
|
278
|
+
required?: boolean;
|
|
279
|
+
maxlength?: number | string;
|
|
280
|
+
minlength?: number | string;
|
|
281
|
+
autofocus?: boolean;
|
|
282
|
+
inputmode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
283
|
+
/** The native input event (v-model already follows it). */
|
|
284
|
+
onInput?: (event: Event) => void;
|
|
285
|
+
/** The native change event (when the box is left after a change). */
|
|
286
|
+
onChange?: (event: Event) => void;
|
|
287
|
+
onKeyup?: (event: KeyboardEvent) => void;
|
|
288
|
+
}
|
|
289
|
+
/** v-model modifiers, as on a native input: v-model.trim, .number, .lazy. */
|
|
290
|
+
export interface TextModelProps<T> extends ModelProps<T> {
|
|
291
|
+
modelModifiers?: { trim?: boolean; number?: boolean; lazy?: boolean };
|
|
292
|
+
}
|
|
293
|
+
export interface InputProps extends TextModelProps<string | number>, TextBoxAttrs {
|
|
294
|
+
/** 'sm': 34px tall. */
|
|
295
|
+
size?: 'sm' | (string & {});
|
|
296
|
+
/** Default 'text'. */
|
|
297
|
+
type?: string;
|
|
298
|
+
pattern?: string;
|
|
299
|
+
min?: number | string;
|
|
300
|
+
max?: number | string;
|
|
301
|
+
step?: number | string;
|
|
302
|
+
}
|
|
303
|
+
/** <Input v-model="email" type="email" placeholder="you@shop.com" /> */
|
|
304
|
+
export const Input: GeckoComponent<InputProps>;
|
|
305
|
+
|
|
306
|
+
export interface TextareaProps extends TextModelProps<string>, TextBoxAttrs {
|
|
307
|
+
/** Grows with each line up to this many lines (true = 6), then scrolls. */
|
|
308
|
+
autoGrow?: boolean | number;
|
|
309
|
+
size?: 'sm' | (string & {});
|
|
310
|
+
rows?: number | string;
|
|
311
|
+
}
|
|
312
|
+
/** <Textarea v-model="note" :rows="2" :auto-grow="6" /> */
|
|
313
|
+
export const Textarea: GeckoComponent<TextareaProps>;
|
|
314
|
+
|
|
315
|
+
export {};
|