@thekestongroup/ui 0.6.0 → 0.9.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/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.vue.d.ts +2 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +45 -0
- package/dist/components/Chip/Chip.vue.d.ts +0 -1
- package/dist/components/Header/Header.vue.d.ts +0 -1
- package/dist/components/InputDate/InputDate.vue.d.ts +1 -1
- package/dist/components/InputTextArea/InputTextArea.vue.d.ts +49 -0
- package/dist/components/LanguageSwitcher/LanguageSwitcher.vue.d.ts +24 -0
- package/dist/components/Notification/NotificationPane.vue.d.ts +1 -4
- package/dist/components/PageHeader/PageHeader.vue.d.ts +8 -3
- package/dist/components/Select/Select.vue.d.ts +0 -1
- package/dist/components/SettingsRow/SettingsRow.vue.d.ts +28 -0
- package/dist/components/Sidebar/Sidebar.vue.d.ts +0 -1
- package/dist/components/Slideover/Slideover.vue.d.ts +0 -1
- package/dist/components/Spinner/Spinner.vue.d.ts +0 -1
- package/dist/components/Steps/Steps.vue.d.ts +20 -0
- package/dist/components/Switch/Switch.vue.d.ts +2 -0
- package/dist/components/Table/Table.vue.d.ts +21 -1
- package/dist/i18n/en.d.ts +146 -0
- package/dist/i18n/index.d.ts +32 -0
- package/dist/index.d.ts +12 -0
- package/dist/keston-ui.js +2288 -1718
- package/package.json +4 -2
- package/src/components/Age/Age.vue +4 -2
- package/src/components/AppShell/AppShell.vue +4 -2
- package/src/components/AvatarGroup/AvatarGroup.vue +4 -2
- package/src/components/Breadcrumb/Breadcrumb.vue +3 -2
- package/src/components/Calendar/Calendar.vue +8 -6
- package/src/components/Card/Card.vue +3 -1
- package/src/components/Checkbox/Checkbox.stories.ts +3 -0
- package/src/components/Checkbox/Checkbox.vue +3 -1
- package/src/components/CheckboxGroup/CheckboxGroup.stories.ts +48 -0
- package/src/components/CheckboxGroup/CheckboxGroup.vue +96 -0
- package/src/components/Chip/Chip.vue +3 -2
- package/src/components/FormField/FormField.vue +3 -1
- package/src/components/Header/Header.vue +6 -5
- package/src/components/Input/Input.vue +4 -2
- package/src/components/InputCode/InputCode.vue +4 -2
- package/src/components/InputDate/InputDate.vue +4 -2
- package/src/components/InputPassword/InputPassword.vue +4 -2
- package/src/components/InputRichText/InputRichText.vue +6 -4
- package/src/components/InputTextArea/InputTextArea.stories.ts +53 -0
- package/src/components/InputTextArea/InputTextArea.vue +89 -0
- package/src/components/LanguageSwitcher/LanguageSwitcher.stories.ts +21 -0
- package/src/components/LanguageSwitcher/LanguageSwitcher.vue +57 -0
- package/src/components/Link/Link.vue +1 -0
- package/src/components/Notification/Notification.vue +3 -1
- package/src/components/Notification/NotificationPane.vue +10 -8
- package/src/components/Notification/Toaster.vue +9 -7
- package/src/components/PageHeader/PageHeader.stories.ts +29 -1
- package/src/components/PageHeader/PageHeader.vue +108 -22
- package/src/components/Progress/Progress.vue +3 -1
- package/src/components/RadioGroup/RadioGroup.vue +3 -1
- package/src/components/Select/Select.vue +6 -5
- package/src/components/SettingsRow/SettingsRow.stories.ts +59 -0
- package/src/components/SettingsRow/SettingsRow.vue +39 -0
- package/src/components/Sidebar/Sidebar.vue +5 -4
- package/src/components/Slideover/Slideover.vue +8 -7
- package/src/components/Spinner/Spinner.vue +4 -3
- package/src/components/StatTile/StatTile.vue +3 -1
- package/src/components/Steps/Steps.stories.ts +38 -0
- package/src/components/Steps/Steps.vue +38 -0
- package/src/components/SummaryList/SummaryList.vue +5 -4
- package/src/components/Switch/Switch.vue +3 -1
- package/src/components/Table/Table.stories.ts +34 -0
- package/src/components/Table/Table.vue +98 -8
- package/src/i18n/en.ts +127 -0
- package/src/i18n/i18n.test.ts +56 -0
- package/src/i18n/index.ts +89 -0
- package/src/index.ts +14 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { computed, nextTick, onBeforeUnmount, onMounted, ref, useId, type Component, type HTMLAttributes } from 'vue'
|
|
3
4
|
import {
|
|
4
5
|
ComboboxAnchor,
|
|
@@ -119,10 +120,10 @@ export interface SelectProps {
|
|
|
119
120
|
class?: HTMLAttributes['class']
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
const { t } = useI18n()
|
|
122
124
|
const props = withDefaults(defineProps<SelectProps>(), {
|
|
123
125
|
options: () => [],
|
|
124
126
|
groups: () => [],
|
|
125
|
-
emptyText: 'No matches',
|
|
126
127
|
helperPlacement: 'below'
|
|
127
128
|
})
|
|
128
129
|
|
|
@@ -162,7 +163,7 @@ function setValue(next: unknown) {
|
|
|
162
163
|
if (props.searchable) nextTick(() => searchInput.value?.$el?.select?.())
|
|
163
164
|
}
|
|
164
165
|
|
|
165
|
-
const placeholderText = computed(() => props.placeholder ?? (props.searchable ? '
|
|
166
|
+
const placeholderText = computed(() => props.placeholder ?? (props.searchable ? t('ui.select.search') : t('ui.select.choose')))
|
|
166
167
|
|
|
167
168
|
const toOption = (option: SelectOption | string): SelectOption =>
|
|
168
169
|
typeof option === 'string' ? { label: option, value: option } : { ...option, value: option.value ?? option.label }
|
|
@@ -477,7 +478,7 @@ const chevron = 'transition-transform duration-150 in-data-[state=open]:rotate-1
|
|
|
477
478
|
:key="String(option.value)"
|
|
478
479
|
size="sm"
|
|
479
480
|
removable
|
|
480
|
-
:remove-label="
|
|
481
|
+
:remove-label="t('ui.select.remove', { name: option.label })"
|
|
481
482
|
:remove-focusable="false"
|
|
482
483
|
:disabled="disabled"
|
|
483
484
|
@pointerdown.stop
|
|
@@ -503,7 +504,7 @@ const chevron = 'transition-transform duration-150 in-data-[state=open]:rotate-1
|
|
|
503
504
|
@keydown.backspace="onSearchBackspace"
|
|
504
505
|
/>
|
|
505
506
|
</span>
|
|
506
|
-
<ComboboxTrigger tabindex="-1" aria-label="
|
|
507
|
+
<ComboboxTrigger tabindex="-1" :aria-label="t('ui.select.showOptions')" class="flex cursor-pointer disabled:cursor-not-allowed">
|
|
507
508
|
<ChevronDown aria-hidden="true" :class="chevron" />
|
|
508
509
|
</ComboboxTrigger>
|
|
509
510
|
</ComboboxAnchor>
|
|
@@ -555,7 +556,7 @@ const chevron = 'transition-transform duration-150 in-data-[state=open]:rotate-1
|
|
|
555
556
|
class="flex flex-col gap-0.5 p-1 [scrollbar-width:thin]! [&::-webkit-scrollbar]:block!"
|
|
556
557
|
>
|
|
557
558
|
<ComboboxEmpty v-if="searchable" class="px-2 py-1.5 text-sm text-black/65">
|
|
558
|
-
{{ emptyText }}
|
|
559
|
+
{{ emptyText ?? t('ui.select.noMatches') }}
|
|
559
560
|
</ComboboxEmpty>
|
|
560
561
|
|
|
561
562
|
<!-- Inside a nested option: back to the level above. -->
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import SettingsRow from "./SettingsRow.vue";
|
|
4
|
+
import Card from "../Card/Card.vue";
|
|
5
|
+
import Select from "../Select/Select.vue";
|
|
6
|
+
import InputNumber from "../InputNumber/InputNumber.vue";
|
|
7
|
+
import Switch from "../Switch/Switch.vue";
|
|
8
|
+
import Divider from "../Divider/Divider.vue";
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Components/Layout/SettingsRow",
|
|
12
|
+
component: SettingsRow,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
args: {
|
|
15
|
+
label: "Multi-factor authentication",
|
|
16
|
+
description: "Recommended for security. All users must verify with a second factor when they sign in.",
|
|
17
|
+
},
|
|
18
|
+
decorators: [() => ({ template: '<div class="max-w-3xl"><story /></div>' })],
|
|
19
|
+
render: (args) => ({
|
|
20
|
+
components: { SettingsRow, Select },
|
|
21
|
+
setup: () => ({ args, mode: ref("required") }),
|
|
22
|
+
template: `
|
|
23
|
+
<SettingsRow v-bind="args">
|
|
24
|
+
<Select v-model="mode" :label="args.label" hide-label :options="[
|
|
25
|
+
{ label: 'Off', value: 'off' },
|
|
26
|
+
{ label: 'Require MFA', value: 'required' },
|
|
27
|
+
{ label: 'Custom rules', value: 'custom' },
|
|
28
|
+
]" />
|
|
29
|
+
</SettingsRow>`,
|
|
30
|
+
}),
|
|
31
|
+
} satisfies Meta<typeof SettingsRow>;
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
35
|
+
|
|
36
|
+
/** Label and description on the left, the control on the right. It stacks on narrow screens. */
|
|
37
|
+
export const Default: Story = {};
|
|
38
|
+
|
|
39
|
+
/** Several settings in a Card, with a Divider between them. */
|
|
40
|
+
export const InACard: Story = {
|
|
41
|
+
render: () => ({
|
|
42
|
+
components: { SettingsRow, Select, InputNumber, Switch, Card, Divider },
|
|
43
|
+
setup: () => ({ mode: ref("required"), days: ref(14), everyone: ref(true) }),
|
|
44
|
+
template: `
|
|
45
|
+
<Card class="flex flex-col gap-6 p-6">
|
|
46
|
+
<SettingsRow label="Multi-factor authentication" description="All users must verify with a second factor when they sign in.">
|
|
47
|
+
<Select v-model="mode" label="Multi-factor authentication" hide-label :options="[{ label: 'Off', value: 'off' }, { label: 'Require MFA', value: 'required' }]" />
|
|
48
|
+
</SettingsRow>
|
|
49
|
+
<Divider />
|
|
50
|
+
<SettingsRow label="Grace period" description="How many days people have to set it up before it's enforced.">
|
|
51
|
+
<InputNumber v-model="days" label="Grace period" hide-label :min="0" :max="90" />
|
|
52
|
+
</SettingsRow>
|
|
53
|
+
<Divider />
|
|
54
|
+
<SettingsRow label="Remind people" description="Show a reminder each time they sign in during the grace period.">
|
|
55
|
+
<Switch v-model="everyone" label="Remind people" hide-label />
|
|
56
|
+
</SettingsRow>
|
|
57
|
+
</Card>`,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
import { cn } from '../../lib/cn'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One setting on a settings page: what it is and what it does on the left,
|
|
7
|
+
* the control that changes it on the right (it stacks, label first, on narrow
|
|
8
|
+
* screens). Put a Select, InputNumber, Switch, Input… in the default slot and
|
|
9
|
+
* give it the same label with `hide-label`, so the label is only said once.
|
|
10
|
+
* Stack rows inside a Card, with a Divider between them if there are several.
|
|
11
|
+
*/
|
|
12
|
+
export interface SettingsRowProps {
|
|
13
|
+
/** What the setting is called, e.g. "Multi-factor authentication". */
|
|
14
|
+
label: string
|
|
15
|
+
/** What it does, in smaller text under the label. */
|
|
16
|
+
description?: string
|
|
17
|
+
class?: HTMLAttributes['class']
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const props = defineProps<SettingsRowProps>()
|
|
21
|
+
|
|
22
|
+
defineSlots<{
|
|
23
|
+
/** The control. */
|
|
24
|
+
default(): unknown
|
|
25
|
+
}>()
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div :class="cn('flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-6', props.class)">
|
|
30
|
+
<div class="flex min-w-0 flex-col gap-0.5">
|
|
31
|
+
<!-- The control has this name too (hide-label), so it isn't read twice. -->
|
|
32
|
+
<p class="text-sm" aria-hidden="true">{{ label }}</p>
|
|
33
|
+
<p v-if="description" class="text-xs text-black/65">{{ description }}</p>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="w-full shrink-0 sm:w-80">
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { computed, nextTick, ref, useId, watch, type Component, type HTMLAttributes } from 'vue'
|
|
3
4
|
import { ChevronLeft, ChevronRight, PanelLeftClose, PanelLeftOpen } from '@lucide/vue'
|
|
4
5
|
import { cn } from '../../lib/cn'
|
|
@@ -73,10 +74,10 @@ export interface SidebarProps {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
const { t } = useI18n()
|
|
76
78
|
const props = withDefaults(defineProps<SidebarProps>(), {
|
|
77
79
|
items: () => [],
|
|
78
80
|
sections: () => [],
|
|
79
|
-
label: 'Main',
|
|
80
81
|
collapsible: false,
|
|
81
82
|
linkComponent: 'a'
|
|
82
83
|
})
|
|
@@ -276,7 +277,7 @@ const itemActiveParent = 'font-bold text-primary'
|
|
|
276
277
|
|
|
277
278
|
<nav
|
|
278
279
|
ref="navRef"
|
|
279
|
-
:aria-label="label"
|
|
280
|
+
:aria-label="label ?? t('ui.sidebar.main')"
|
|
280
281
|
:class="cn(
|
|
281
282
|
'relative flex-1 overflow-x-hidden overflow-y-auto p-2 [scrollbar-width:thin]',
|
|
282
283
|
// Collapsed, a scrollbar would take a third of the 40px strip and cut
|
|
@@ -293,7 +294,7 @@ const itemActiveParent = 'font-bold text-primary'
|
|
|
293
294
|
<button
|
|
294
295
|
type="button"
|
|
295
296
|
data-back
|
|
296
|
-
:title="collapsed ?
|
|
297
|
+
:title="collapsed ? t('ui.sidebar.backFrom', { name: current.label }) : undefined"
|
|
297
298
|
:class="cn(itemBase, 'font-bold', ui?.item)"
|
|
298
299
|
@click="goBack"
|
|
299
300
|
>
|
|
@@ -369,7 +370,7 @@ const itemActiveParent = 'font-bold text-primary'
|
|
|
369
370
|
v-if="collapsible"
|
|
370
371
|
variant="ghost"
|
|
371
372
|
square
|
|
372
|
-
:aria-label="collapsed ? '
|
|
373
|
+
:aria-label="collapsed ? t('ui.sidebar.expand') : t('ui.sidebar.collapse')"
|
|
373
374
|
:aria-expanded="!collapsed"
|
|
374
375
|
class="self-start"
|
|
375
376
|
@click="collapsed = !collapsed"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { computed, nextTick, ref, useId, watch, type HTMLAttributes } from 'vue'
|
|
3
4
|
import {
|
|
4
5
|
DialogClose,
|
|
@@ -86,6 +87,7 @@ export interface SlideoverProps {
|
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
const { t } = useI18n()
|
|
89
91
|
const props = withDefaults(defineProps<SlideoverProps>(), {
|
|
90
92
|
side: 'right',
|
|
91
93
|
overlay: true,
|
|
@@ -93,8 +95,7 @@ const props = withDefaults(defineProps<SlideoverProps>(), {
|
|
|
93
95
|
dismissible: true,
|
|
94
96
|
modal: true,
|
|
95
97
|
portal: true,
|
|
96
|
-
initialFocus: 'none'
|
|
97
|
-
finishLabel: 'Finish'
|
|
98
|
+
initialFocus: 'none'
|
|
98
99
|
})
|
|
99
100
|
|
|
100
101
|
const emit = defineEmits<{
|
|
@@ -144,7 +145,7 @@ const nextStatus = ref<ButtonStatus>('idle')
|
|
|
144
145
|
// - otherwise (Next / Previous buttons, touch screens): the same words are
|
|
145
146
|
// announced. Never both, so it isn't read twice.
|
|
146
147
|
const stepLabelId = `${useId()}-step`
|
|
147
|
-
const stepText = computed(() => (props.steps ?
|
|
148
|
+
const stepText = computed(() => (props.steps ? t('ui.slideover.stepOf', { current: step.value + 1, total: stepCount.value, name: props.steps[step.value] }) : ''))
|
|
148
149
|
const announcement = ref('')
|
|
149
150
|
const body = ref<HTMLElement>()
|
|
150
151
|
|
|
@@ -294,7 +295,7 @@ const panel = [
|
|
|
294
295
|
v-if="title || description || close || steps || $slots.header || $slots.title"
|
|
295
296
|
:class="cn('flex flex-col gap-4 border-b border-black/15 px-6 py-4', ui?.header)"
|
|
296
297
|
>
|
|
297
|
-
<Progress v-if="steps" :label="title ?? '
|
|
298
|
+
<Progress v-if="steps" :label="title ?? t('ui.slideover.steps')" segments :value="step + 1" :max="stepCount" />
|
|
298
299
|
<div class="flex items-start gap-4">
|
|
299
300
|
<slot name="header" :close="closePanel">
|
|
300
301
|
<div class="flex min-w-0 flex-1 flex-col gap-1">
|
|
@@ -318,7 +319,7 @@ const panel = [
|
|
|
318
319
|
<!-- A ghost icon Button; the negative margins keep it from making
|
|
319
320
|
the header taller and line its icon up with the panel edge. -->
|
|
320
321
|
<DialogClose v-if="close" as-child>
|
|
321
|
-
<Button variant="ghost" square aria-label="
|
|
322
|
+
<Button variant="ghost" square :aria-label="t('ui.slideover.close')" class="-my-1.5 -mr-3 shrink-0">
|
|
322
323
|
<X />
|
|
323
324
|
</Button>
|
|
324
325
|
</DialogClose>
|
|
@@ -350,10 +351,10 @@ const panel = [
|
|
|
350
351
|
@click="step === 0 ? closePanel() : goTo(step - 1)"
|
|
351
352
|
>
|
|
352
353
|
<template v-if="step > 0" #leading><ChevronLeft /></template>
|
|
353
|
-
{{ step === 0 ? '
|
|
354
|
+
{{ step === 0 ? t('ui.slideover.cancel') : t('ui.slideover.previous') }}
|
|
354
355
|
</Button>
|
|
355
356
|
<Button variant="primary" :status="nextStatus" @click="next">
|
|
356
|
-
{{ isLastStep ? finishLabel : '
|
|
357
|
+
{{ isLastStep ? (finishLabel ?? t('ui.slideover.finish')) : t('ui.slideover.next') }}
|
|
357
358
|
<template v-if="!isLastStep" #trailing><ChevronRight /></template>
|
|
358
359
|
</Button>
|
|
359
360
|
</slot>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { computed, type HTMLAttributes } from 'vue'
|
|
3
4
|
import { ProgressRoot } from 'reka-ui'
|
|
4
5
|
import { cn } from '../../lib/cn'
|
|
@@ -26,10 +27,10 @@ export interface SpinnerProps {
|
|
|
26
27
|
class?: HTMLAttributes['class']
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
const { t } = useI18n()
|
|
29
31
|
const props = withDefaults(defineProps<SpinnerProps>(), {
|
|
30
32
|
max: 100,
|
|
31
|
-
size: 'md'
|
|
32
|
-
label: 'Loading'
|
|
33
|
+
size: 'md'
|
|
33
34
|
})
|
|
34
35
|
|
|
35
36
|
const indeterminate = computed(() => props.value === null || props.value === undefined)
|
|
@@ -57,7 +58,7 @@ const sizes: Record<NonNullable<SpinnerProps['size']>, string> = {
|
|
|
57
58
|
as="span"
|
|
58
59
|
:model-value="indeterminate ? null : fraction * max"
|
|
59
60
|
:max="max"
|
|
60
|
-
:aria-label="label"
|
|
61
|
+
:aria-label="label ?? t('ui.spinner.loading')"
|
|
61
62
|
:class="cn('relative inline-flex shrink-0 items-center justify-center', sizes[size], props.class)"
|
|
62
63
|
>
|
|
63
64
|
<svg
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import { computed, type Component, type HTMLAttributes } from 'vue'
|
|
3
4
|
import { ArrowDownRight, ArrowRight, ArrowUpRight } from '@lucide/vue'
|
|
4
5
|
import { cn } from '../../lib/cn'
|
|
@@ -36,6 +37,7 @@ export interface StatTileProps {
|
|
|
36
37
|
class?: HTMLAttributes['class']
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
const { t } = useI18n()
|
|
39
41
|
const props = defineProps<StatTileProps>()
|
|
40
42
|
|
|
41
43
|
defineSlots<{
|
|
@@ -56,7 +58,7 @@ const trendIcon = computed(() =>
|
|
|
56
58
|
props.trend === 'up' ? ArrowUpRight : props.trend === 'down' ? ArrowDownRight : props.trend === 'flat' ? ArrowRight : undefined
|
|
57
59
|
)
|
|
58
60
|
// The arrow is decorative, so say the direction in words for screen readers.
|
|
59
|
-
const trendWords = { up: '
|
|
61
|
+
const trendWords = computed(() => ({ up: t('ui.statTile.up'), down: t('ui.statTile.down'), flat: t('ui.statTile.flat') }))
|
|
60
62
|
</script>
|
|
61
63
|
|
|
62
64
|
<template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import Steps from "./Steps.vue";
|
|
4
|
+
import Button from "../Button/Button.vue";
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: "Components/Navigation/Steps",
|
|
8
|
+
component: Steps,
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
args: {
|
|
11
|
+
label: "Add a user",
|
|
12
|
+
steps: ["User info", "Licences", "Confirmation"],
|
|
13
|
+
step: 1,
|
|
14
|
+
},
|
|
15
|
+
argTypes: { step: { control: { type: "number", min: 0, max: 2 } } },
|
|
16
|
+
decorators: [() => ({ template: '<div class="max-w-120"><story /></div>' })],
|
|
17
|
+
} satisfies Meta<typeof Steps>;
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {};
|
|
23
|
+
|
|
24
|
+
/** Drive it from Previous and Next buttons. The words are announced as the step changes. */
|
|
25
|
+
export const WithButtons: Story = {
|
|
26
|
+
render: (args) => ({
|
|
27
|
+
components: { Steps, Button },
|
|
28
|
+
setup: () => ({ args, step: ref(0) }),
|
|
29
|
+
template: `
|
|
30
|
+
<div class="flex flex-col gap-6">
|
|
31
|
+
<Steps v-bind="args" :step="step" />
|
|
32
|
+
<div class="flex gap-2">
|
|
33
|
+
<Button :disabled="step === 0" @click="step--">Previous</Button>
|
|
34
|
+
<Button variant="primary" :disabled="step === args.steps.length - 1" @click="step++">Next</Button>
|
|
35
|
+
</div>
|
|
36
|
+
</div>`,
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue'
|
|
3
|
+
import { I18nT } from 'vue-i18n'
|
|
4
|
+
import { cn } from '../../lib/cn'
|
|
5
|
+
import Progress from '../Progress/Progress.vue'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Where someone is in a set of steps: a segment for each step, filled up to
|
|
9
|
+
* the current one, and "Step 2 of 3: Licences" under it. Put it at the top of
|
|
10
|
+
* a multi-step form. (Slideover's `steps` shows one for you; use this when
|
|
11
|
+
* the steps are on a page, or in a Slideover you drive yourself.) The words
|
|
12
|
+
* are announced when the step changes.
|
|
13
|
+
*/
|
|
14
|
+
export interface StepsProps {
|
|
15
|
+
/** The name of each step, in order, e.g. `['User info', 'Licences']`. */
|
|
16
|
+
steps: string[]
|
|
17
|
+
/** The current step, counting from 0. */
|
|
18
|
+
step: number
|
|
19
|
+
/** What the steps are for, e.g. "Add a user". The progress bar's accessible name; not shown. */
|
|
20
|
+
label: string
|
|
21
|
+
class?: HTMLAttributes['class']
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = defineProps<StepsProps>()
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<div :class="cn('flex flex-col gap-3', props.class)">
|
|
29
|
+
<Progress :label="label" segments :value="step + 1" :max="steps.length" />
|
|
30
|
+
<p class="text-sm text-black/65" aria-live="polite">
|
|
31
|
+
<I18nT keypath="ui.steps.stepOfNamed" scope="global" tag="span">
|
|
32
|
+
<template #current>{{ step + 1 }}</template>
|
|
33
|
+
<template #total>{{ steps.length }}</template>
|
|
34
|
+
<template #name><span class="text-black">{{ steps[step] }}</span></template>
|
|
35
|
+
</I18nT>
|
|
36
|
+
</p>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts" generic="Item extends SummaryListItem">
|
|
2
|
+
import { useI18n } from 'vue-i18n'
|
|
2
3
|
import type { HTMLAttributes } from 'vue'
|
|
3
4
|
import { cn } from '../../lib/cn'
|
|
4
5
|
|
|
@@ -38,10 +39,10 @@ export interface SummaryListProps<Item extends SummaryListItem = SummaryListItem
|
|
|
38
39
|
class?: HTMLAttributes['class']
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
const { t } = useI18n()
|
|
41
43
|
const props = withDefaults(defineProps<SummaryListProps<Item>>(), {
|
|
42
44
|
layout: 'rows',
|
|
43
|
-
labelWidth: 'md'
|
|
44
|
-
emptyLabel: 'Not set'
|
|
45
|
+
labelWidth: 'md'
|
|
45
46
|
})
|
|
46
47
|
|
|
47
48
|
defineSlots<{
|
|
@@ -86,7 +87,7 @@ const labelWidths = {
|
|
|
86
87
|
<dd :class="cn('min-w-0 break-words', item.emphasis && 'font-bold', !$slots.action && 'col-span-2')">
|
|
87
88
|
<slot name="value" :item="item" :index="index">
|
|
88
89
|
<template v-if="!isEmpty(item.value)">{{ item.value }}</template>
|
|
89
|
-
<template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel }}</span></template>
|
|
90
|
+
<template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
|
|
90
91
|
</slot>
|
|
91
92
|
<span v-if="item.description" class="mt-0.5 block text-black/65">{{ item.description }}</span>
|
|
92
93
|
</dd>
|
|
@@ -115,7 +116,7 @@ const labelWidths = {
|
|
|
115
116
|
>
|
|
116
117
|
<slot name="value" :item="item" :index="index">
|
|
117
118
|
<template v-if="!isEmpty(item.value)">{{ item.value }}</template>
|
|
118
|
-
<template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel }}</span></template>
|
|
119
|
+
<template v-else><span class="text-black/40" aria-hidden="true">—</span><span class="sr-only">{{ emptyLabel ?? t('ui.summaryList.notSet') }}</span></template>
|
|
119
120
|
</slot>
|
|
120
121
|
<span v-if="item.description" class="mt-0.5 block font-normal text-black/65">{{ item.description }}</span>
|
|
121
122
|
<span v-if="$slots.action" class="mt-1 block font-normal"><slot name="action" :item="item" :index="index" /></span>
|
|
@@ -26,6 +26,8 @@ export interface SwitchProps {
|
|
|
26
26
|
/** Name for native form submission. */
|
|
27
27
|
name?: string
|
|
28
28
|
disabled?: boolean
|
|
29
|
+
/** Keep the label (and description) for screen readers only, e.g. a switch in a SettingsRow. */
|
|
30
|
+
hideLabel?: boolean
|
|
29
31
|
class?: HTMLAttributes['class']
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -82,7 +84,7 @@ const thumb = 'size-4 rounded-full bg-white shadow-sm transition-transform data-
|
|
|
82
84
|
<SwitchThumb :class="thumb" />
|
|
83
85
|
</SwitchRoot>
|
|
84
86
|
<div
|
|
85
|
-
:class="cn('flex min-w-0 flex-col gap-0.5', disabled ? 'cursor-not-allowed' : 'cursor-pointer')"
|
|
87
|
+
:class="cn('flex min-w-0 flex-col gap-0.5', disabled ? 'cursor-not-allowed' : 'cursor-pointer', hideLabel && 'sr-only')"
|
|
86
88
|
@click="pressControl($event, controlId)"
|
|
87
89
|
>
|
|
88
90
|
<label :for="controlId" :class="cn('text-sm', disabled ? 'cursor-not-allowed' : 'cursor-pointer')">{{ label }}</label>
|
|
@@ -268,3 +268,37 @@ export const SomeRowsClickable: Story = {
|
|
|
268
268
|
},
|
|
269
269
|
render: ClickableRows.render,
|
|
270
270
|
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Ticking rows to act on several at once: `selectable` (here, everyone but
|
|
274
|
+
* declined applicants), `v-model:selected` for the ticked rows' keys, and
|
|
275
|
+
* `rowLabel` to name each box. Clicking anywhere in a checkbox's cell ticks
|
|
276
|
+
* it, without opening the row.
|
|
277
|
+
*/
|
|
278
|
+
export const SelectableRows: Story = {
|
|
279
|
+
args: {
|
|
280
|
+
rowLink: (row) => `/applicants/${row.id}`,
|
|
281
|
+
linkComponent: FakeRouterLink,
|
|
282
|
+
selectable: (row) => row.status !== "Declined",
|
|
283
|
+
rowLabel: (row) => `Select ${row.name}`,
|
|
284
|
+
},
|
|
285
|
+
render: (args) => ({
|
|
286
|
+
components: { Table, Card, Badge },
|
|
287
|
+
setup() {
|
|
288
|
+
const selected = ref<(string | number)[]>([2]);
|
|
289
|
+
opened.value = "";
|
|
290
|
+
return { args, statusColors, date, opened, selected };
|
|
291
|
+
},
|
|
292
|
+
template: `
|
|
293
|
+
<div class="flex flex-col gap-3">
|
|
294
|
+
<Card padding="none">
|
|
295
|
+
<Table v-bind="args" v-model:selected="selected">
|
|
296
|
+
<template #cell-applied="{ value }">{{ date(value) }}</template>
|
|
297
|
+
<template #cell-score="{ value }">{{ value ?? '—' }}</template>
|
|
298
|
+
<template #cell-status="{ value }"><Badge size="sm" :color="statusColors[value]">{{ value }}</Badge></template>
|
|
299
|
+
</Table>
|
|
300
|
+
</Card>
|
|
301
|
+
<p class="text-sm">Selected: <code>{{ selected.join(', ') || 'none' }}</code> · Opened: <code>{{ opened || 'none' }}</code></p>
|
|
302
|
+
</div>`,
|
|
303
|
+
}),
|
|
304
|
+
};
|