@gecko-ui-kit/vue 0.1.0 → 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/README.md +69 -33
- package/package.json +7 -7
- package/src/actions.d.ts +1 -1
- package/src/actions.js +28 -28
- package/src/basics.d.ts +1 -1
- package/src/basics.js +55 -55
- package/src/controls.d.ts +3 -3
- package/src/controls.js +31 -31
- package/src/core.d.ts +1 -1
- package/src/core.js +3 -3
- package/src/data.js +15 -15
- package/src/effects.d.ts +5 -5
- package/src/effects.js +34 -34
- package/src/forms.js +10 -10
- package/src/motion.d.ts +4 -4
- package/src/motion.js +10 -10
- package/src/overlays.d.ts +6 -2
- package/src/overlays.js +20 -17
- package/src/shell.js +77 -77
- package/src/text.js +10 -10
package/src/basics.js
CHANGED
|
@@ -25,13 +25,13 @@ export const Spinner = defineComponent({
|
|
|
25
25
|
const t = SPIN_TONES.includes(props.tone) ? props.tone : 'accent';
|
|
26
26
|
const st = {};
|
|
27
27
|
if (has(props.size)) st.fontSize = typeof props.size === 'number' ? props.size + 'px' : props.size;
|
|
28
|
-
if (+props.speed && +props.speed !== 1) st['--orb-speed'] = +props.speed + 's';
|
|
29
|
-
const text = has(props.label) ? h('span', { class: 'orb__label' }, props.label)
|
|
30
|
-
: props.decorative ? null : h('span', { class: 'orb__sr' }, props.words?.loading ?? 'Loading…');
|
|
28
|
+
if (+props.speed && +props.speed !== 1) st['--gk-orb-speed'] = +props.speed + 's';
|
|
29
|
+
const text = has(props.label) ? h('span', { class: 'gk-orb__label' }, props.label)
|
|
30
|
+
: props.decorative ? null : h('span', { class: 'gk-orb__sr' }, props.words?.loading ?? 'Loading…');
|
|
31
31
|
return h('span', {
|
|
32
32
|
...(props.decorative ? { 'aria-hidden': 'true' } : { role: 'status' }), style: st,
|
|
33
|
-
class: ['orb', 'orb--' + t, props.track === false && 'orb--bare', props.stack && has(props.label) && 'orb--stack', still.value && 'orb--still'],
|
|
34
|
-
}, [h('span', { class: 'orb__dial', 'aria-hidden': 'true' }, [h('span', { class: 'orb__spin' })]), text]);
|
|
33
|
+
class: ['gk-orb', 'gk-orb--' + t, props.track === false && 'gk-orb--bare', props.stack && has(props.label) && 'gk-orb--stack', still.value && 'gk-orb--still'],
|
|
34
|
+
}, [h('span', { class: 'gk-orb__dial', 'aria-hidden': 'true' }, [h('span', { class: 'gk-orb__spin' })]), text]);
|
|
35
35
|
};
|
|
36
36
|
},
|
|
37
37
|
});
|
|
@@ -53,7 +53,7 @@ export const Button = defineComponent({
|
|
|
53
53
|
const spin = busy ? h(Spinner, { size: '1.15em', tone: 'current', decorative: true }) : null;
|
|
54
54
|
return h('button', {
|
|
55
55
|
ref: el, type: props.type, disabled: props.disabled || busy || undefined, 'aria-busy': busy ? 'true' : undefined,
|
|
56
|
-
class: ['btn', props.variant && 'btn--' + props.variant, props.size && 'btn--' + props.size, props.block && 'btn--block', props.magnetic && 'magnetic'],
|
|
56
|
+
class: ['gk-btn', props.variant && 'gk-btn--' + props.variant, props.size && 'gk-btn--' + props.size, props.block && 'gk-btn--block', props.magnetic && 'gk-magnetic'],
|
|
57
57
|
}, [
|
|
58
58
|
busy ? (props.icon || !props.iconRight ? spin : null) : iconNode(props.icon),
|
|
59
59
|
label != null && label !== false ? h('span', null, label) : null,
|
|
@@ -77,7 +77,7 @@ export const IconButton = defineComponent({
|
|
|
77
77
|
const toggle = () => props.pressed !== undefined || props.defaultPressed !== undefined;
|
|
78
78
|
return () => h('button', {
|
|
79
79
|
type: props.type, 'aria-label': props.label, 'aria-pressed': toggle() ? String(!!on.value) : undefined,
|
|
80
|
-
class: ['iconbtn', props.size && 'iconbtn--' + props.size],
|
|
80
|
+
class: ['gk-iconbtn', props.size && 'gk-iconbtn--' + props.size],
|
|
81
81
|
onClick: (e) => {
|
|
82
82
|
props.onClick?.(e);
|
|
83
83
|
if (!toggle() || e.defaultPrevented) return;
|
|
@@ -93,7 +93,7 @@ export const Tag = defineComponent({
|
|
|
93
93
|
name: 'Tag',
|
|
94
94
|
props: { tone: { type: String, default: 'plain' }, dot: { type: Boolean, default: true }, icon: ANY },
|
|
95
95
|
setup(props, { slots }) {
|
|
96
|
-
return () => h('span', { class: ['tag', 'tag--' + (props.tone || 'plain')] },
|
|
96
|
+
return () => h('span', { class: ['gk-tag', 'gk-tag--' + (props.tone || 'plain')] },
|
|
97
97
|
[props.dot && !props.icon ? h('i') : null, iconNode(props.icon), slots.default?.()]);
|
|
98
98
|
},
|
|
99
99
|
});
|
|
@@ -103,7 +103,7 @@ export const Badge = defineComponent({
|
|
|
103
103
|
name: 'Badge',
|
|
104
104
|
props: { tone: String },
|
|
105
105
|
setup(props, { slots }) {
|
|
106
|
-
return () => h('span', { class: ['badge', props.tone && 'badge--' + props.tone] }, slots.default?.());
|
|
106
|
+
return () => h('span', { class: ['gk-badge', props.tone && 'gk-badge--' + props.tone] }, slots.default?.());
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
|
|
@@ -117,9 +117,9 @@ export const Avatar = defineComponent({
|
|
|
117
117
|
props: { name: String, ini: String, tone: String, size: String, online: B },
|
|
118
118
|
setup(props) {
|
|
119
119
|
return () => {
|
|
120
|
-
if (!has(props.name) && !has(props.ini)) return h('span', { class: ['av', 'av--open', props.size && 'av--' + props.size] }, [iconNode('plus')]);
|
|
121
|
-
return h('span', { title: props.name, class: ['av', 'av--' + (props.tone || 'indigo'), props.size && 'av--' + props.size] },
|
|
122
|
-
[props.ini ?? C.initials(props.name || ''), props.online ? h('i', { class: 'av__on' }) : null]);
|
|
120
|
+
if (!has(props.name) && !has(props.ini)) return h('span', { class: ['gk-av', 'gk-av--open', props.size && 'gk-av--' + props.size] }, [iconNode('plus')]);
|
|
121
|
+
return h('span', { title: props.name, class: ['gk-av', 'gk-av--' + (props.tone || 'indigo'), props.size && 'gk-av--' + props.size] },
|
|
122
|
+
[props.ini ?? C.initials(props.name || ''), props.online ? h('i', { class: 'gk-av__on' }) : null]);
|
|
123
123
|
};
|
|
124
124
|
},
|
|
125
125
|
});
|
|
@@ -131,9 +131,9 @@ export const AvatarGroup = defineComponent({
|
|
|
131
131
|
setup(props) {
|
|
132
132
|
return () => {
|
|
133
133
|
const { people, max } = props;
|
|
134
|
-
return h('span', { class: 'avs' }, [
|
|
134
|
+
return h('span', { class: 'gk-avs' }, [
|
|
135
135
|
...people.slice(0, max).map((p, i) => h(Avatar, { key: p.id ?? p.name ?? i, name: p.name, ini: p.ini, tone: p.tone, size: 'sm' })),
|
|
136
|
-
people.length > max ? h('span', { class: 'av av--sm av--more' }, '+' + (people.length - max)) : null,
|
|
136
|
+
people.length > max ? h('span', { class: 'gk-av gk-av--sm gk-av--more' }, '+' + (people.length - max)) : null,
|
|
137
137
|
]);
|
|
138
138
|
};
|
|
139
139
|
},
|
|
@@ -144,17 +144,17 @@ export const Cell = defineComponent({
|
|
|
144
144
|
name: 'Cell',
|
|
145
145
|
props: { name: String, ini: String, tone: String, sub: ANY, online: B },
|
|
146
146
|
setup(props, { slots }) {
|
|
147
|
-
return () => h('span', { class: 'cell' }, [
|
|
147
|
+
return () => h('span', { class: 'gk-cell' }, [
|
|
148
148
|
h(Avatar, { name: props.name, ini: props.ini, tone: props.tone, online: props.online }),
|
|
149
|
-
h('span', { class: 'cell__text' }, [h('b', null, props.name ?? ''), slots.sub || props.sub != null ? h('small', null, slotOr(slots.sub, props.sub)) : null]),
|
|
149
|
+
h('span', { class: 'gk-cell__text' }, [h('b', null, props.name ?? ''), slots.sub || props.sub != null ? h('small', null, slotOr(slots.sub, props.sub)) : null]),
|
|
150
150
|
]);
|
|
151
151
|
},
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
/* ---------------- cards ---------------- */
|
|
155
155
|
const headParts = (props, slots) => [
|
|
156
|
-
h('div', { class: 'chead__text' }, [h('h2', null, slotOr(slots.title, props.title)), slots.sub || has(props.sub) ? h('p', null, slotOr(slots.sub, props.sub)) : null]),
|
|
157
|
-
slots.right || has(props.right) ? h('div', { class: 'chead__right' }, slotOr(slots.right, props.right)) : null,
|
|
156
|
+
h('div', { class: 'gk-chead__text' }, [h('h2', null, slotOr(slots.title, props.title)), slots.sub || has(props.sub) ? h('p', null, slotOr(slots.sub, props.sub)) : null]),
|
|
157
|
+
slots.right || has(props.right) ? h('div', { class: 'gk-chead__right' }, slotOr(slots.right, props.right)) : null,
|
|
158
158
|
];
|
|
159
159
|
/**
|
|
160
160
|
* <CardHead title="Today" sub="12 bookings"><template #right><Button size="sm">See all</Button></template></CardHead>
|
|
@@ -164,13 +164,13 @@ export const CardHead = defineComponent({
|
|
|
164
164
|
name: 'CardHead',
|
|
165
165
|
props: { title: ANY, sub: ANY, right: ANY },
|
|
166
166
|
setup(props, { slots }) {
|
|
167
|
-
return () => h('div', { class: 'chead' }, headParts(props, slots));
|
|
167
|
+
return () => h('div', { class: 'gk-chead' }, headParts(props, slots));
|
|
168
168
|
},
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* <Card title="Today" sub="12 bookings" lift flush>…body…<template #right>…</template></Card>
|
|
173
|
-
* Same as card({ title, sub, right, body, flush, lift }): a <section class="card">; the head shows when there is a
|
|
173
|
+
* Same as card({ title, sub, right, body, flush, lift }): a <section class="gk-card">; the head shows when there is a
|
|
174
174
|
* title (prop or #title slot). The default slot is the body.
|
|
175
175
|
*/
|
|
176
176
|
export const Card = defineComponent({
|
|
@@ -178,8 +178,8 @@ export const Card = defineComponent({
|
|
|
178
178
|
props: { title: ANY, sub: ANY, right: ANY, flush: B, lift: B },
|
|
179
179
|
setup(props, { slots }) {
|
|
180
180
|
const el = useMotion((n) => (props.lift ? M.lift(n) : undefined), () => !!props.lift);
|
|
181
|
-
return () => h('section', { ref: el, 'data-lift': props.lift ? '' : undefined, class: ['card', props.flush && 'card--flush'] }, [
|
|
182
|
-
slots.title || has(props.title) ? h('div', { class: 'chead' }, headParts(props, slots)) : null,
|
|
181
|
+
return () => h('section', { ref: el, 'data-lift': props.lift ? '' : undefined, class: ['gk-card', props.flush && 'gk-card--flush'] }, [
|
|
182
|
+
slots.title || has(props.title) ? h('div', { class: 'gk-chead' }, headParts(props, slots)) : null,
|
|
183
183
|
slots.default?.(),
|
|
184
184
|
]);
|
|
185
185
|
},
|
|
@@ -190,9 +190,9 @@ export const Kpi = defineComponent({
|
|
|
190
190
|
name: 'Kpi',
|
|
191
191
|
props: { label: ANY, value: ANY, sub: ANY, tone: String },
|
|
192
192
|
setup(props, { slots }) {
|
|
193
|
-
return () => h('div', { class: ['kpi', props.tone && 'kpi--' + props.tone] }, [
|
|
193
|
+
return () => h('div', { class: ['gk-kpi', props.tone && 'gk-kpi--' + props.tone] }, [
|
|
194
194
|
h('small', null, slotOr(slots.label, props.label)), h('b', null, slotOr(slots.value, props.value)),
|
|
195
|
-
slots.sub || has(props.sub) ? h('span', { class: 'kpi__sub' }, slotOr(slots.sub, props.sub)) : null,
|
|
195
|
+
slots.sub || has(props.sub) ? h('span', { class: 'gk-kpi__sub' }, slotOr(slots.sub, props.sub)) : null,
|
|
196
196
|
]);
|
|
197
197
|
},
|
|
198
198
|
});
|
|
@@ -206,8 +206,8 @@ export const Empty = defineComponent({
|
|
|
206
206
|
name: 'Empty',
|
|
207
207
|
props: { icon: { type: null, default: 'inbox' }, title: ANY, body: ANY, action: ANY },
|
|
208
208
|
setup(props, { slots }) {
|
|
209
|
-
return () => h('div', { class: 'empty' }, [
|
|
210
|
-
h('span', { class: 'empty__icon' }, [iconNode(props.icon)]), h('b', null, slotOr(slots.title, props.title)),
|
|
209
|
+
return () => h('div', { class: 'gk-empty' }, [
|
|
210
|
+
h('span', { class: 'gk-empty__icon' }, [iconNode(props.icon)]), h('b', null, slotOr(slots.title, props.title)),
|
|
211
211
|
slots.body || has(props.body) ? h('p', null, slotOr(slots.body, props.body)) : null,
|
|
212
212
|
slotOr(slots.action, props.action ?? null), slots.default?.(),
|
|
213
213
|
]);
|
|
@@ -216,7 +216,7 @@ export const Empty = defineComponent({
|
|
|
216
216
|
|
|
217
217
|
/* ---------------- table ---------------- */
|
|
218
218
|
/**
|
|
219
|
-
* A table styled by .table, inside .table-wrap (scrolls sideways on small screens).
|
|
219
|
+
* A table styled by .gk-table, inside .gk-table-wrap (scrolls sideways on small screens).
|
|
220
220
|
* Data: <Table :columns="[{ key: 'bike', title: 'Bike' }, { key: 'days', title: 'Days', align: 'right' }]" :rows="bookings" row-key="id" />
|
|
221
221
|
* cells: #cell-<key>="{ row, column, value, index }" for one column, #cell="{ … }" for any column (when it
|
|
222
222
|
* renders nothing the plain value shows); heads: #head-<key> / #head="{ column }"; #foot: <tr>s for a <tfoot>.
|
|
@@ -241,7 +241,7 @@ export const Table = defineComponent({
|
|
|
241
241
|
onUpdated(slide);
|
|
242
242
|
onBeforeUnmount(() => { tweens.forEach((t) => t.progress(1).kill()); tweens = []; seen = null; });
|
|
243
243
|
const key = (r, i) => (typeof props.rowKey === 'function' ? props.rowKey(r, i) : r?.[props.rowKey] ?? i);
|
|
244
|
-
const cls = (c) => { const k = normalizeClass([c.align === 'right' && 'r', c.class]); return k ? { key: c.key, class: k } : { key: c.key }; };
|
|
244
|
+
const cls = (c) => { const k = normalizeClass([c.align === 'right' && 'gk-r', c.class]); return k ? { key: c.key, class: k } : { key: c.key }; };
|
|
245
245
|
const fill = (slot, args, fallback) => { if (slot) { const out = slot(args); if (hasContent(out)) return out; } return fallback(); };
|
|
246
246
|
return () => {
|
|
247
247
|
const cols = props.columns;
|
|
@@ -251,8 +251,8 @@ export const Table = defineComponent({
|
|
|
251
251
|
fill(slots['cell-' + c.key] || slots.cell, { row: r, column: c, value: r?.[c.key], index: i }, () => (c.render ? c.render(r, i) : r?.[c.key]))))))),
|
|
252
252
|
slots.foot ? h('tfoot', null, slots.foot()) : null,
|
|
253
253
|
] : slots.default?.();
|
|
254
|
-
const table = h('table', { ...attrs, ref: el, class: ['table', attrs.class] }, body);
|
|
255
|
-
return props.wrap ? h('div', { class: 'table-wrap' }, [table]) : table;
|
|
254
|
+
const table = h('table', { ...attrs, ref: el, class: ['gk-table', attrs.class] }, body);
|
|
255
|
+
return props.wrap ? h('div', { class: 'gk-table-wrap' }, [table]) : table;
|
|
256
256
|
};
|
|
257
257
|
},
|
|
258
258
|
});
|
|
@@ -281,7 +281,7 @@ export const Meter = defineComponent({
|
|
|
281
281
|
}, { immediate: true, flush: 'post' });
|
|
282
282
|
});
|
|
283
283
|
onBeforeUnmount(done);
|
|
284
|
-
return () => h('span', { class: ['meter', props.tone && 'is-' + props.tone] }, [h('i', { ref: bar, 'data-f': f.value, style: ZERO_X })]);
|
|
284
|
+
return () => h('span', { class: ['gk-meter', props.tone && 'gk-is-' + props.tone] }, [h('i', { ref: bar, 'data-f': f.value, style: ZERO_X })]);
|
|
285
285
|
},
|
|
286
286
|
});
|
|
287
287
|
|
|
@@ -308,10 +308,10 @@ export const Ring = defineComponent({
|
|
|
308
308
|
onBeforeUnmount(done);
|
|
309
309
|
return () => {
|
|
310
310
|
const { size, stroke } = props, r = (size - stroke) / 2, c = size / 2, l = len.value;
|
|
311
|
-
return h('span', { class: 'ring', style: { width: size + 'px', height: size + 'px' } }, [
|
|
311
|
+
return h('span', { class: 'gk-ring', style: { width: size + 'px', height: size + 'px' } }, [
|
|
312
312
|
h('svg', { viewBox: `0 0 ${size} ${size}` }, [
|
|
313
|
-
h('circle', { cx: c, cy: c, r, 'stroke-width': stroke, class: 'ring__bg' }),
|
|
314
|
-
h('circle', { ref: fg, cx: c, cy: c, r, 'stroke-width': stroke, class: 'ring__fg', 'data-len': l, 'data-f': f.value, 'stroke-dasharray': l, 'stroke-dashoffset': l }),
|
|
313
|
+
h('circle', { cx: c, cy: c, r, 'stroke-width': stroke, class: 'gk-ring__bg' }),
|
|
314
|
+
h('circle', { ref: fg, cx: c, cy: c, r, 'stroke-width': stroke, class: 'gk-ring__fg', 'data-len': l, 'data-f': f.value, 'stroke-dasharray': l, 'stroke-dashoffset': l }),
|
|
315
315
|
]),
|
|
316
316
|
h('b', null, slotOr(slots.label, props.label)),
|
|
317
317
|
]);
|
|
@@ -335,15 +335,15 @@ export const Steps = defineComponent({
|
|
|
335
335
|
done();
|
|
336
336
|
const p = prev === null ? now : prev; prev = now;
|
|
337
337
|
M.steps(el.value, now, p);
|
|
338
|
-
parts = [...el.value.querySelectorAll('.steps__fill, .steps__dot')];
|
|
338
|
+
parts = [...el.value.querySelectorAll('.gk-steps__fill, .gk-steps__dot')];
|
|
339
339
|
}, { immediate: true, flush: 'post' });
|
|
340
340
|
});
|
|
341
341
|
onBeforeUnmount(done);
|
|
342
342
|
return () => {
|
|
343
343
|
const { labels, now } = props;
|
|
344
|
-
return h('ol', { ref: el, class: 'steps' }, labels.map((l, i) => h('li', { key: i, ...(i < now ? { class: 'is-done' } : i === now ? { class: 'is-now', 'aria-current': 'step' } : null) }, [
|
|
345
|
-
h('span', { class: 'steps__dot' }, [iconNode('check')]),
|
|
346
|
-
i < labels.length - 1 ? h('span', { class: 'steps__bar' }, [h('i', { class: 'steps__fill', style: ZERO_X })]) : null,
|
|
344
|
+
return h('ol', { ref: el, class: 'gk-steps' }, labels.map((l, i) => h('li', { key: i, ...(i < now ? { class: 'gk-is-done' } : i === now ? { class: 'gk-is-now', 'aria-current': 'step' } : null) }, [
|
|
345
|
+
h('span', { class: 'gk-steps__dot' }, [iconNode('check')]),
|
|
346
|
+
i < labels.length - 1 ? h('span', { class: 'gk-steps__bar' }, [h('i', { class: 'gk-steps__fill', style: ZERO_X })]) : null,
|
|
347
347
|
h('small', null, slotOr(slots.label, l, { label: l, index: i })),
|
|
348
348
|
])));
|
|
349
349
|
};
|
|
@@ -352,14 +352,14 @@ export const Steps = defineComponent({
|
|
|
352
352
|
|
|
353
353
|
/* Bars has no stylesheet of its own in the library yet, so its look is written inline (same look as the
|
|
354
354
|
playground's "Bars, meter & ring" chart). The class names are there for your own CSS. The bar colour comes in
|
|
355
|
-
through --bar-c on its column, so the bar itself keeps one style object (see ZERO_X). */
|
|
355
|
+
through --gk-bar-c on its column, so the bar itself keeps one style object (see ZERO_X). */
|
|
356
356
|
const BAR_S = {
|
|
357
357
|
root: { display: 'flex', gap: '8px', width: '100%' },
|
|
358
358
|
col: { flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '6px' },
|
|
359
359
|
track: { position: 'relative', flex: 1, width: '100%' },
|
|
360
|
-
bar: { position: 'absolute', inset: 0, borderRadius: '7px 7px 3px 3px', transform: 'scaleY(0)', transformOrigin: '50% 100%', transition: 'background .4s', background: 'var(--bar-c)' },
|
|
361
|
-
v: { position: 'absolute', left: 0, right: 0, paddingBottom: '4px', textAlign: 'center', fontSize: '11px', fontWeight:
|
|
362
|
-
label: { color: 'var(--muted)', fontSize: '11px', fontWeight:
|
|
360
|
+
bar: { position: 'absolute', inset: 0, borderRadius: '7px 7px 3px 3px', transform: 'scaleY(0)', transformOrigin: '50% 100%', transition: 'background .4s', background: 'var(--gk-bar-c)' },
|
|
361
|
+
v: { position: 'absolute', left: 0, right: 0, paddingBottom: '4px', textAlign: 'center', fontSize: '11px', fontWeight: 'var(--gk-w-bold)', color: 'var(--gk-ink-2)', fontVariantNumeric: 'tabular-nums', transition: 'bottom .75s var(--gk-ease-in-out, ease)' },
|
|
362
|
+
label: { color: 'var(--gk-muted)', fontSize: '11px', fontWeight: 'var(--gk-w-semibold)', maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
|
|
363
363
|
};
|
|
364
364
|
/**
|
|
365
365
|
* <Bars :values="[12, 30, 22]" :labels="['Mon', 'Tue', 'Wed']" :max="40" show-values />
|
|
@@ -377,7 +377,7 @@ export const Bars = defineComponent({
|
|
|
377
377
|
onMounted(() => {
|
|
378
378
|
watch(() => props.values.join(',') + '|' + m.value, () => {
|
|
379
379
|
done();
|
|
380
|
-
bars = [...el.value.querySelectorAll('.bars__bar')];
|
|
380
|
+
bars = [...el.value.querySelectorAll('.gk-bars__bar')];
|
|
381
381
|
M.bars(bars, props.values, m.value, { first }); first = false;
|
|
382
382
|
}, { immediate: true, flush: 'post' });
|
|
383
383
|
});
|
|
@@ -386,15 +386,15 @@ export const Bars = defineComponent({
|
|
|
386
386
|
const { values, labels, highlightTop, height } = props;
|
|
387
387
|
return h('div', {
|
|
388
388
|
ref: el, role: 'img', 'aria-label': props.label ?? values.map((v, i) => (labels?.[i] != null ? `${labels[i]}: ${v}` : v)).join(', '),
|
|
389
|
-
class: 'bars', style: { ...BAR_S.root, height: typeof height === 'number' ? height + 'px' : height },
|
|
389
|
+
class: 'gk-bars', style: { ...BAR_S.root, height: typeof height === 'number' ? height + 'px' : height },
|
|
390
390
|
}, values.map((v, i) => {
|
|
391
391
|
const isTop = highlightTop && +v === top.value && top.value > 0;
|
|
392
|
-
return h('div', { key: i, class: ['bars__col', isTop && 'is-top'], style: { ...BAR_S.col, '--bar-c': isTop || !highlightTop ? 'var(--accent)' : 'color-mix(in oklab, var(--accent) 35%, var(--card))' } }, [
|
|
393
|
-
h('span', { class: 'bars__track', style: BAR_S.track }, [
|
|
394
|
-
h('i', { class: 'bars__bar', style: BAR_S.bar }),
|
|
395
|
-
props.showValues ? h('b', { class: 'bars__v', 'aria-hidden': 'true', style: { ...BAR_S.v, bottom: Math.min(100, ((+v || 0) / m.value) * 100) + '%' } }, props.format(v, i)) : null,
|
|
392
|
+
return h('div', { key: i, class: ['gk-bars__col', isTop && 'gk-is-top'], style: { ...BAR_S.col, '--gk-bar-c': isTop || !highlightTop ? 'var(--gk-accent)' : 'color-mix(in oklab, var(--gk-accent) 35%, var(--gk-card))' } }, [
|
|
393
|
+
h('span', { class: 'gk-bars__track', style: BAR_S.track }, [
|
|
394
|
+
h('i', { class: 'gk-bars__bar', style: BAR_S.bar }),
|
|
395
|
+
props.showValues ? h('b', { class: 'gk-bars__v', 'aria-hidden': 'true', style: { ...BAR_S.v, bottom: Math.min(100, ((+v || 0) / m.value) * 100) + '%' } }, props.format(v, i)) : null,
|
|
396
396
|
]),
|
|
397
|
-
labels?.[i] != null ? h('small', { class: 'bars__label', style: BAR_S.label }, labels[i]) : null,
|
|
397
|
+
labels?.[i] != null ? h('small', { class: 'gk-bars__label', style: BAR_S.label }, labels[i]) : null,
|
|
398
398
|
]);
|
|
399
399
|
}));
|
|
400
400
|
};
|
|
@@ -410,9 +410,9 @@ export const Field = defineComponent({
|
|
|
410
410
|
name: 'Field',
|
|
411
411
|
props: { label: ANY, hint: ANY, invalid: B },
|
|
412
412
|
setup(props, { slots }) {
|
|
413
|
-
return () => h('label', { class: ['field', props.invalid && 'is-bad'] }, [
|
|
413
|
+
return () => h('label', { class: ['gk-field', props.invalid && 'gk-is-bad'] }, [
|
|
414
414
|
h('span', null, slotOr(slots.label, props.label)), slots.default?.(),
|
|
415
|
-
slots.hint || has(props.hint) ? h('small', { class: 'field__hint' }, slotOr(slots.hint, props.hint)) : null,
|
|
415
|
+
slots.hint || has(props.hint) ? h('small', { class: 'gk-field__hint' }, slotOr(slots.hint, props.hint)) : null,
|
|
416
416
|
]);
|
|
417
417
|
},
|
|
418
418
|
});
|
|
@@ -426,7 +426,7 @@ const textModel = (props, node, v) => {
|
|
|
426
426
|
|
|
427
427
|
/**
|
|
428
428
|
* <Input v-model="email" type="email" placeholder="you@shop.com" size="sm" />
|
|
429
|
-
* Same as input({ type, value, placeholder }): an <input class="input">. v-model works like on a native input
|
|
429
|
+
* Same as input({ type, value, placeholder }): an <input class="gk-input">. v-model works like on a native input
|
|
430
430
|
* (also .lazy / .trim / .number); every other attribute and listener (@input, @change, @blur…) goes on the <input>.
|
|
431
431
|
*/
|
|
432
432
|
export const Input = defineComponent({
|
|
@@ -435,13 +435,13 @@ export const Input = defineComponent({
|
|
|
435
435
|
setup(props) {
|
|
436
436
|
const [v, set] = useModel(props, { event: null });
|
|
437
437
|
return () => textModel(props, h('input', {
|
|
438
|
-
type: props.type, class: ['input', props.size && 'input--' + props.size], 'onUpdate:modelValue': (x) => set(x),
|
|
438
|
+
type: props.type, class: ['gk-input', props.size && 'gk-input--' + props.size], 'onUpdate:modelValue': (x) => set(x),
|
|
439
439
|
}), v.value);
|
|
440
440
|
},
|
|
441
441
|
});
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
|
-
* <Textarea v-model="note" :rows="3" :auto-grow="6" /> — a <textarea class="input">. auto-grow: the box gets taller
|
|
444
|
+
* <Textarea v-model="note" :rows="3" :auto-grow="6" /> — a <textarea class="gk-input">. auto-grow: the box gets taller
|
|
445
445
|
* with each line, up to that many lines (true = 6), then scrolls. v-model works like on a native <textarea>.
|
|
446
446
|
*/
|
|
447
447
|
export const Textarea = defineComponent({
|
|
@@ -468,7 +468,7 @@ export const Textarea = defineComponent({
|
|
|
468
468
|
onMounted(() => { watch([lines, () => v.value], fit, { immediate: true, flush: 'post' }); });
|
|
469
469
|
return () => textModel(props, h('textarea', {
|
|
470
470
|
ref: el, ...(lines() ? { style: NO_RESIZE } : null), onInput: fit,
|
|
471
|
-
class: ['input', props.size && 'input--' + props.size], 'onUpdate:modelValue': (x) => set(x),
|
|
471
|
+
class: ['gk-input', props.size && 'gk-input--' + props.size], 'onUpdate:modelValue': (x) => set(x),
|
|
472
472
|
}), v.value);
|
|
473
473
|
},
|
|
474
474
|
});
|
package/src/controls.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ interface FormAttrs {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/** An option: [value, label, icon?], { value, label, icon, disabled } or a plain string. */
|
|
10
|
-
export type Option<V extends string = string> = [V, string?, IconLike?] | { value: V; label?: string; icon?: IconLike; disabled?: boolean } | V;
|
|
11
|
-
export function normOption<V extends string>(o: Option<V>): { value: V; label: string; icon?: IconLike; disabled?: boolean };
|
|
9
|
+
/** An option: [value, label, icon?, count?], { value, label, icon, count, disabled } or a plain string. count: a number shown after the label (Segmented). */
|
|
10
|
+
export type Option<V extends string = string> = [V, string?, IconLike?, (number | string)?] | { value: V; label?: string; icon?: IconLike; count?: number | string; disabled?: boolean } | V;
|
|
11
|
+
export function normOption<V extends string>(o: Option<V>): { value: V; label: string; icon?: IconLike; count?: number | string; disabled?: boolean };
|
|
12
12
|
|
|
13
13
|
export interface SwitchProps extends ModelProps<boolean> {
|
|
14
14
|
/** Accessible name (aria-label). */
|
package/src/controls.js
CHANGED
|
@@ -24,20 +24,20 @@ export const Switch = defineComponent({
|
|
|
24
24
|
watch(() => !!on.value, (v) => { M.switchKnob(el.value, v, !first); first = false; }, { immediate: true, flush: 'post' });
|
|
25
25
|
});
|
|
26
26
|
return () => h('button', {
|
|
27
|
-
ref: el, type: 'button', role: 'switch', 'aria-checked': String(!!on.value), 'aria-label': props.label, class: 'switch',
|
|
27
|
+
ref: el, type: 'button', role: 'switch', 'aria-checked': String(!!on.value), 'aria-label': props.label, class: 'gk-switch',
|
|
28
28
|
onClick: (e) => { props.onClick?.(e); if (!e.defaultPrevented) set(!on.value, e); },
|
|
29
29
|
}, [h('i')]);
|
|
30
30
|
},
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
/** [id, label, icon] | { value, label, icon, disabled } | 'id' → { value, label, icon, disabled } */
|
|
34
|
-
export const normOption = (o) => Array.isArray(o) ? { value: o[0], label: o[1] ?? o[0], icon: o[2] }
|
|
34
|
+
export const normOption = (o) => Array.isArray(o) ? { value: o[0], label: o[1] ?? o[0], icon: o[2], count: o[3] }
|
|
35
35
|
: o && typeof o === 'object' ? { label: o.value, ...o } : { value: o, label: o };
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* <Segmented v-model="view" :options="[['list', 'List', 'list'], ['grid', 'Grid', 'cards']]" />
|
|
39
39
|
* Same as seg(name, options, value, { size }): the thumb stretches to the pressed button.
|
|
40
|
-
* options: [id, label, icon?] arrays, { value, label, icon } objects or plain strings. @change(value, event)
|
|
40
|
+
* options: [id, label, icon?, count?] arrays, { value, label, icon, count } objects or plain strings. @change(value, event)
|
|
41
41
|
*/
|
|
42
42
|
export const Segmented = defineComponent({
|
|
43
43
|
name: 'Segmented',
|
|
@@ -50,16 +50,16 @@ export const Segmented = defineComponent({
|
|
|
50
50
|
let untrack = null;
|
|
51
51
|
onMounted(() => {
|
|
52
52
|
let first = true;
|
|
53
|
-
watch([v, () => list.value.length], () => { M.indicator(thumb.value, current(), { animate: !first, radius:
|
|
54
|
-
untrack = M.trackIndicator(thumb.value, current, { radius:
|
|
53
|
+
watch([v, () => list.value.length], () => { M.indicator(thumb.value, current(), { animate: !first, radius: 'auto' }); first = false; }, { immediate: true, flush: 'post' });
|
|
54
|
+
untrack = M.trackIndicator(thumb.value, current, { radius: 'auto' });
|
|
55
55
|
});
|
|
56
56
|
onBeforeUnmount(() => { untrack?.(); untrack = null; });
|
|
57
|
-
return () => h('div', { ref: root, role: 'group', 'data-seg': props.name, class: ['seg', props.size && 'seg--' + props.size] }, [
|
|
58
|
-
h('span', { class: 'seg__thumb', ref: thumb }),
|
|
57
|
+
return () => h('div', { ref: root, role: 'group', 'data-seg': props.name, class: ['gk-seg', props.size && 'gk-seg--' + props.size] }, [
|
|
58
|
+
h('span', { class: 'gk-seg__thumb', ref: thumb }),
|
|
59
59
|
...list.value.map((o) => h('button', {
|
|
60
60
|
key: o.value, type: 'button', 'data-v': o.value, 'aria-pressed': String(o.value === v.value), disabled: o.disabled || undefined,
|
|
61
61
|
onClick: (e) => { if (o.value === v.value) return; M.pop(e.currentTarget); set(o.value, e); },
|
|
62
|
-
}, [iconNode(o.icon), o.label])),
|
|
62
|
+
}, [iconNode(o.icon), o.label, o.count != null && o.count !== '' ? h('span', { class: 'gk-seg__count' }, String(o.count)) : null])),
|
|
63
63
|
]);
|
|
64
64
|
},
|
|
65
65
|
});
|
|
@@ -75,7 +75,7 @@ export const Checkbox = defineComponent({
|
|
|
75
75
|
setup(props) {
|
|
76
76
|
const [on, set] = useModel(props, { initial: false });
|
|
77
77
|
return () => h('button', {
|
|
78
|
-
type: 'button', role: 'checkbox', 'aria-checked': String(!!on.value), 'aria-label': props.label, class: 'check',
|
|
78
|
+
type: 'button', role: 'checkbox', 'aria-checked': String(!!on.value), 'aria-label': props.label, class: 'gk-check',
|
|
79
79
|
onClick: (e) => { props.onClick?.(e); if (e.defaultPrevented) return; M.pop(e.currentTarget); set(!on.value, e); },
|
|
80
80
|
}, [iconNode('check')]);
|
|
81
81
|
},
|
|
@@ -105,12 +105,12 @@ export const Tabs = defineComponent({
|
|
|
105
105
|
untrack = M.trackIndicator(line.value, current, { radius: 2, line: true });
|
|
106
106
|
});
|
|
107
107
|
onBeforeUnmount(() => { untrack?.(); untrack = null; });
|
|
108
|
-
return () => h('div', { ref: root, role: 'tablist', 'data-tabs': props.name, class: 'tabs' }, [
|
|
109
|
-
h('span', { class: 'tabs__line', ref: line }),
|
|
108
|
+
return () => h('div', { ref: root, role: 'tablist', 'data-tabs': props.name, class: 'gk-tabs' }, [
|
|
109
|
+
h('span', { class: 'gk-tabs__line', ref: line }),
|
|
110
110
|
...list.value.map((o) => h('button', {
|
|
111
111
|
key: o.value, type: 'button', role: 'tab', 'data-v': o.value, 'aria-selected': String(o.value === v.value), disabled: o.disabled || undefined,
|
|
112
112
|
onClick: (e) => { if (o.value !== v.value) set(o.value, e); },
|
|
113
|
-
}, [o.label, o.count ? h('span', { class: 'badge' }, o.count) : null])),
|
|
113
|
+
}, [o.label, o.count ? h('span', { class: 'gk-badge' }, o.count) : null])),
|
|
114
114
|
]);
|
|
115
115
|
},
|
|
116
116
|
});
|
|
@@ -127,8 +127,8 @@ export const Chips = defineComponent({
|
|
|
127
127
|
const list = computed(() => props.options.map(normOption));
|
|
128
128
|
const [v, set] = useModel(props, { initial: props.multi ? [] : list.value[0]?.value });
|
|
129
129
|
const isOn = (id) => (props.multi ? (v.value || []).includes(id) : id === v.value);
|
|
130
|
-
return () => h('div', { 'data-chips': props.name, 'data-multi': props.multi ? '' : undefined, class: 'chips' }, list.value.map((o) => h('button', {
|
|
131
|
-
key: o.value, type: 'button', class: 'chip', 'data-v': o.value, 'aria-pressed': String(isOn(o.value)), disabled: o.disabled || undefined,
|
|
130
|
+
return () => h('div', { 'data-chips': props.name, 'data-multi': props.multi ? '' : undefined, class: 'gk-chips' }, list.value.map((o) => h('button', {
|
|
131
|
+
key: o.value, type: 'button', class: 'gk-chip', 'data-v': o.value, 'aria-pressed': String(isOn(o.value)), disabled: o.disabled || undefined,
|
|
132
132
|
onClick: (e) => {
|
|
133
133
|
if (props.multi) {
|
|
134
134
|
const cur = v.value || []; M.pop(e.currentTarget);
|
|
@@ -156,13 +156,13 @@ export const Range = defineComponent({
|
|
|
156
156
|
let tw = null;
|
|
157
157
|
onMounted(() => {
|
|
158
158
|
const r = el.value;
|
|
159
|
-
if (!M.RM()) tw = M.g.fromTo(r, { '--p': '0%' }, { '--p': p.value, duration: 0.9, ease: 'expo.out' });
|
|
160
|
-
watch(p, (x) => { M.g.killTweensOf(r); tw = null; r.style.setProperty('--p', x); }, { flush: 'post' });
|
|
159
|
+
if (!M.RM()) tw = M.g.fromTo(r, { '--gk-p': '0%' }, { '--gk-p': p.value, duration: 0.9, ease: 'expo.out' });
|
|
160
|
+
watch(p, (x) => { M.g.killTweensOf(r); tw = null; r.style.setProperty('--gk-p', x); }, { flush: 'post' });
|
|
161
161
|
});
|
|
162
162
|
onBeforeUnmount(() => { tw?.kill(); tw = null; });
|
|
163
163
|
return () => h('input', {
|
|
164
164
|
ref: el, type: 'range', min: props.min, max: props.max, step: props.step, value: v.value,
|
|
165
|
-
class: 'range', style: { '--p': p.value },
|
|
165
|
+
class: 'gk-range', style: { '--gk-p': p.value },
|
|
166
166
|
onInput: (e) => { M.g.killTweensOf(e.currentTarget); set(+e.currentTarget.value, e); },
|
|
167
167
|
});
|
|
168
168
|
},
|
|
@@ -179,7 +179,7 @@ export const Swatch = defineComponent({
|
|
|
179
179
|
setup(props) {
|
|
180
180
|
const [v, set] = useModel(props, { initial: '#5b4cf0' });
|
|
181
181
|
return () => h('input', {
|
|
182
|
-
type: 'color', value: v.value, class: 'swatch',
|
|
182
|
+
type: 'color', value: v.value, class: 'gk-swatch',
|
|
183
183
|
onInput: (e) => set(e.currentTarget.value, e),
|
|
184
184
|
onChange: (e) => M.pop(e.currentTarget), // the native "picked" event
|
|
185
185
|
});
|
|
@@ -207,10 +207,10 @@ export const SearchBox = defineComponent({
|
|
|
207
207
|
const box = ref(null);
|
|
208
208
|
return () => {
|
|
209
209
|
const { class: cls, style, ...rest } = attrs;
|
|
210
|
-
return h('label', { ref: box, class: ['searchbox', cls], style }, [
|
|
210
|
+
return h('label', { ref: box, class: ['gk-searchbox', cls], style }, [
|
|
211
211
|
iconNode('search'),
|
|
212
212
|
h('input', mergeProps({ 'aria-label': props.placeholder }, rest, {
|
|
213
|
-
placeholder: props.placeholder, value: v.value ?? '', class: ['input', props.size && 'input--' + props.size], ...composing,
|
|
213
|
+
placeholder: props.placeholder, value: v.value ?? '', class: ['gk-input', props.size && 'gk-input--' + props.size], ...composing,
|
|
214
214
|
onInput: (e) => { if (!e.target.composing) set(e.currentTarget.value, e); },
|
|
215
215
|
onKeydown: (e) => {
|
|
216
216
|
if (e.defaultPrevented || e.key !== 'Enter' || !props.onSearch || e.isComposing) return;
|
|
@@ -229,7 +229,7 @@ const firstValue = (list) => { for (const o of list) { if (o.options) { const f
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* <Select v-model="bike" :options="[['scooter', 'Scooter 125', 'moto'], ['ebike', 'E-bike', 'bike']]" />
|
|
232
|
-
* A real <select class="input"> (forms, FormData and labels keep working) that dropdown() from
|
|
232
|
+
* A real <select class="gk-input"> (forms, FormData and labels keep working) that dropdown() from
|
|
233
233
|
* @gecko-ui-kit/overlays turns into the animated dropdown: the list pops out of the button, a highlight follows
|
|
234
234
|
* the mouse and ↑ ↓, and the chosen text rolls in. Options: [value, label, icon?], { value, label, icon, disabled },
|
|
235
235
|
* 'value', or a group { group: 'Bikes', options: [...] }. @change(value, event). Attributes (name, disabled,
|
|
@@ -251,7 +251,7 @@ export const Select = defineComponent({
|
|
|
251
251
|
if (s.value !== want) {
|
|
252
252
|
s.value = want;
|
|
253
253
|
// the pick is already rolling in: drop it, so the kept value snaps back instead of rolling over it
|
|
254
|
-
const val = dd?.button.querySelector('.dd__val');
|
|
254
|
+
const val = dd?.button.querySelector('.gk-dd__val');
|
|
255
255
|
if (val) { M.g.killTweensOf([...val.children]); val.replaceChildren(); delete val.dataset.t; }
|
|
256
256
|
}
|
|
257
257
|
dd?.sync();
|
|
@@ -262,10 +262,10 @@ export const Select = defineComponent({
|
|
|
262
262
|
const opt = (o) => h('option', { key: o.value, value: o.value, selected: String(o.value) === String(v.value ?? ''), disabled: o.disabled || undefined, 'data-icon': typeof o.icon === 'string' ? o.icon : undefined }, o.label);
|
|
263
263
|
return () => {
|
|
264
264
|
const { class: cls, tabindex, ...rest } = attrs;
|
|
265
|
-
return h('span', { class: 'dd-host', style: HOST }, [
|
|
265
|
+
return h('span', { class: 'gk-dd-host', style: HOST }, [
|
|
266
266
|
h('select', {
|
|
267
267
|
...rest, ref: sel, tabindex: up.value ? -1 : tabindex, 'aria-hidden': up.value ? 'true' : undefined,
|
|
268
|
-
class: ['input', props.size && 'input--' + props.size, up.value && 'dd__native', cls],
|
|
268
|
+
class: ['gk-input', props.size && 'gk-input--' + props.size, up.value && 'gk-dd__native', cls],
|
|
269
269
|
onChange: (e) => { set(e.currentTarget.value, e); nextTick(show); },
|
|
270
270
|
}, list.value.map((o, i) => (o.options ? h('optgroup', { key: 'g' + i, label: o.group }, o.options.map(opt)) : opt(o)))),
|
|
271
271
|
]);
|
|
@@ -284,7 +284,7 @@ const ANSWER = { true: 'good', good: 'good', false: 'bad', bad: 'bad' };
|
|
|
284
284
|
* Backspace goes back, paste / the phone's code autofill fills every box. @complete(code, el) runs when the last box
|
|
285
285
|
* is filled; return (or resolve) true / 'good' to play the green wave (and gather into a tick), false / 'bad' to shake
|
|
286
286
|
* and clear. v-model / @change(code) follow the code as it is typed; a new v-model value is written into the boxes.
|
|
287
|
-
* The template ref's $el is the .otp element (otpState / otpClear from @gecko-ui-kit/components work on it).
|
|
287
|
+
* The template ref's $el is the .gk-otp element (otpState / otpClear from @gecko-ui-kit/components work on it).
|
|
288
288
|
*/
|
|
289
289
|
export const Otp = defineComponent({
|
|
290
290
|
name: 'Otp',
|
|
@@ -299,7 +299,7 @@ export const Otp = defineComponent({
|
|
|
299
299
|
const write = (code) => {
|
|
300
300
|
const box = el.value; if (!box) return;
|
|
301
301
|
const chars = [...cleanCode(code, props.letters)];
|
|
302
|
-
box.querySelectorAll('.otp__box').forEach((b, i) => { b.value = chars[i] ?? ''; b.classList.toggle('is-filled', !!b.value); });
|
|
302
|
+
box.querySelectorAll('.gk-otp__box').forEach((b, i) => { b.value = chars[i] ?? ''; b.classList.toggle('gk-is-filled', !!b.value); });
|
|
303
303
|
last = C.otpValue(box);
|
|
304
304
|
};
|
|
305
305
|
const report = () => {
|
|
@@ -322,7 +322,7 @@ export const Otp = defineComponent({
|
|
|
322
322
|
};
|
|
323
323
|
C.bindOtp(box, done);
|
|
324
324
|
evs.forEach((t) => box.addEventListener(t, report));
|
|
325
|
-
if (props.autofocus) box.querySelector('.otp__box')?.focus();
|
|
325
|
+
if (props.autofocus) box.querySelector('.gk-otp__box')?.focus();
|
|
326
326
|
watch(() => props.modelValue, (v) => { if (v !== undefined && cleanCode(v, props.letters) !== C.otpValue(box)) write(v); }, { flush: 'post' });
|
|
327
327
|
});
|
|
328
328
|
onBeforeUnmount(() => {
|
|
@@ -336,17 +336,17 @@ export const Otp = defineComponent({
|
|
|
336
336
|
const half = split ? Math.ceil(length / 2) : -1;
|
|
337
337
|
const boxes = [];
|
|
338
338
|
for (let i = 0; i < length; i++) {
|
|
339
|
-
if (i === half) boxes.push(h('span', { key: 'dash', class: 'otp__dash', 'aria-hidden': 'true' }));
|
|
339
|
+
if (i === half) boxes.push(h('span', { key: 'dash', class: 'gk-otp__dash', 'aria-hidden': 'true' }));
|
|
340
340
|
boxes.push(h('input', {
|
|
341
|
-
key: i, class: 'otp__box', type: mask ? 'password' : 'text', inputmode: letters ? 'text' : 'numeric', pattern: letters ? undefined : '[0-9]*',
|
|
341
|
+
key: i, class: 'gk-otp__box', type: mask ? 'password' : 'text', inputmode: letters ? 'text' : 'numeric', pattern: letters ? undefined : '[0-9]*',
|
|
342
342
|
autocomplete: i === 0 ? 'one-time-code' : 'off', autocapitalize: 'characters', spellcheck: 'false', disabled: props.disabled || undefined,
|
|
343
343
|
'aria-label': `${label}, ${i + 1} of ${length}`,
|
|
344
344
|
}));
|
|
345
345
|
}
|
|
346
346
|
return h('div', {
|
|
347
347
|
ref: el, role: 'group', 'aria-label': label, 'data-otp': props.name || 'code', 'data-len': length,
|
|
348
|
-
'data-letters': letters ? '' : undefined, class: ['otp', letters && 'otp--letters'],
|
|
349
|
-
}, [...boxes, h('span', { class: 'otp__done', 'aria-hidden': 'true' }, [
|
|
348
|
+
'data-letters': letters ? '' : undefined, class: ['gk-otp', letters && 'gk-otp--letters'],
|
|
349
|
+
}, [...boxes, h('span', { class: 'gk-otp__done', 'aria-hidden': 'true' }, [
|
|
350
350
|
h('svg', { viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': 2.6, 'stroke-linecap': 'round', 'stroke-linejoin': 'round' }, [h('path', { d: 'M5.5 12.5l4 4L18.5 7.5' })]),
|
|
351
351
|
])]);
|
|
352
352
|
};
|
package/src/core.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export interface IconProps {
|
|
|
95
95
|
/** Stroke width (1.7). */
|
|
96
96
|
stroke?: number | string;
|
|
97
97
|
}
|
|
98
|
-
/** <Icon name="search" /> — the kit's stroke icon as a real <svg class="ico">. */
|
|
98
|
+
/** <Icon name="search" /> — the kit's stroke icon as a real <svg class="gk-ico">. */
|
|
99
99
|
export const Icon: GeckoComponent<IconProps>;
|
|
100
100
|
/** An icon: a name ('check'), a component or a VNode. */
|
|
101
101
|
export type IconLike = string | Component | VNode;
|
package/src/core.js
CHANGED
|
@@ -267,7 +267,7 @@ export function mounted(name, mount, spec = {}) {
|
|
|
267
267
|
* Turn a motion `fn(el, options) → handle | tween | stop()` into a wrapper component around slot content.
|
|
268
268
|
*
|
|
269
269
|
* export const Tilt = enhancer('Tilt', tilt, { props: { ...anyProps('max', 'scale'), glare: B } });
|
|
270
|
-
* <Tilt :max="10" glare class="card"><h3>Lamp</h3></Tilt>
|
|
270
|
+
* <Tilt :max="10" glare class="gk-card"><h3>Lamp</h3></Tilt>
|
|
271
271
|
*
|
|
272
272
|
* spec:
|
|
273
273
|
* props the option props (B / ANY / Function); every other attribute goes on the element
|
|
@@ -370,14 +370,14 @@ export function useMotion(fn, opts) {
|
|
|
370
370
|
|
|
371
371
|
/**
|
|
372
372
|
* <Icon name="search" /> — the same 24×24 stroke icon as icon('search') from @gecko-ui-kit/icons,
|
|
373
|
-
* as a real <svg class="ico">, so `.btn > svg` style rules keep working. size: px or any CSS length.
|
|
373
|
+
* as a real <svg class="gk-ico">, so `.gk-btn > svg` style rules keep working. size: px or any CSS length.
|
|
374
374
|
*/
|
|
375
375
|
export const Icon = defineComponent({
|
|
376
376
|
name: 'Icon',
|
|
377
377
|
props: { name: { type: String, required: true }, size: ANY, stroke: { type: [Number, String], default: 1.7 } },
|
|
378
378
|
setup(props) {
|
|
379
379
|
return () => h('svg', {
|
|
380
|
-
class: 'ico', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': props.stroke,
|
|
380
|
+
class: 'gk-ico', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', 'stroke-width': props.stroke,
|
|
381
381
|
'stroke-linecap': 'round', 'stroke-linejoin': 'round', 'aria-hidden': 'true',
|
|
382
382
|
...(props.size != null ? { width: props.size, height: props.size, style: { width: px(props.size), height: px(props.size) } } : null),
|
|
383
383
|
innerHTML: PATHS[props.name] ?? PATHS.sparkle,
|