@thekestongroup/ui 0.7.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.
Files changed (68) hide show
  1. package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +0 -1
  2. package/dist/components/Checkbox/Checkbox.vue.d.ts +2 -0
  3. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +45 -0
  4. package/dist/components/Chip/Chip.vue.d.ts +0 -1
  5. package/dist/components/Header/Header.vue.d.ts +0 -1
  6. package/dist/components/InputDate/InputDate.vue.d.ts +1 -1
  7. package/dist/components/InputTextArea/InputTextArea.vue.d.ts +49 -0
  8. package/dist/components/LanguageSwitcher/LanguageSwitcher.vue.d.ts +24 -0
  9. package/dist/components/Notification/NotificationPane.vue.d.ts +1 -4
  10. package/dist/components/Select/Select.vue.d.ts +0 -1
  11. package/dist/components/SettingsRow/SettingsRow.vue.d.ts +28 -0
  12. package/dist/components/Sidebar/Sidebar.vue.d.ts +0 -1
  13. package/dist/components/Slideover/Slideover.vue.d.ts +0 -1
  14. package/dist/components/Spinner/Spinner.vue.d.ts +0 -1
  15. package/dist/components/Steps/Steps.vue.d.ts +20 -0
  16. package/dist/components/Switch/Switch.vue.d.ts +2 -0
  17. package/dist/components/Table/Table.vue.d.ts +21 -1
  18. package/dist/i18n/en.d.ts +146 -0
  19. package/dist/i18n/index.d.ts +32 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/keston-ui.js +2189 -1691
  22. package/package.json +4 -2
  23. package/src/components/Age/Age.vue +4 -2
  24. package/src/components/AppShell/AppShell.vue +4 -2
  25. package/src/components/AvatarGroup/AvatarGroup.vue +4 -2
  26. package/src/components/Breadcrumb/Breadcrumb.vue +3 -2
  27. package/src/components/Calendar/Calendar.vue +8 -6
  28. package/src/components/Card/Card.vue +3 -1
  29. package/src/components/Checkbox/Checkbox.stories.ts +3 -0
  30. package/src/components/Checkbox/Checkbox.vue +3 -1
  31. package/src/components/CheckboxGroup/CheckboxGroup.stories.ts +48 -0
  32. package/src/components/CheckboxGroup/CheckboxGroup.vue +96 -0
  33. package/src/components/Chip/Chip.vue +3 -2
  34. package/src/components/FormField/FormField.vue +3 -1
  35. package/src/components/Header/Header.vue +6 -5
  36. package/src/components/Input/Input.vue +4 -2
  37. package/src/components/InputCode/InputCode.vue +4 -2
  38. package/src/components/InputDate/InputDate.vue +4 -2
  39. package/src/components/InputPassword/InputPassword.vue +4 -2
  40. package/src/components/InputRichText/InputRichText.vue +6 -4
  41. package/src/components/InputTextArea/InputTextArea.stories.ts +53 -0
  42. package/src/components/InputTextArea/InputTextArea.vue +89 -0
  43. package/src/components/LanguageSwitcher/LanguageSwitcher.stories.ts +21 -0
  44. package/src/components/LanguageSwitcher/LanguageSwitcher.vue +57 -0
  45. package/src/components/Link/Link.vue +1 -0
  46. package/src/components/Notification/Notification.vue +3 -1
  47. package/src/components/Notification/NotificationPane.vue +10 -8
  48. package/src/components/Notification/Toaster.vue +9 -7
  49. package/src/components/PageHeader/PageHeader.vue +13 -2
  50. package/src/components/Progress/Progress.vue +3 -1
  51. package/src/components/RadioGroup/RadioGroup.vue +3 -1
  52. package/src/components/Select/Select.vue +6 -5
  53. package/src/components/SettingsRow/SettingsRow.stories.ts +59 -0
  54. package/src/components/SettingsRow/SettingsRow.vue +39 -0
  55. package/src/components/Sidebar/Sidebar.vue +5 -4
  56. package/src/components/Slideover/Slideover.vue +8 -7
  57. package/src/components/Spinner/Spinner.vue +4 -3
  58. package/src/components/StatTile/StatTile.vue +3 -1
  59. package/src/components/Steps/Steps.stories.ts +38 -0
  60. package/src/components/Steps/Steps.vue +38 -0
  61. package/src/components/SummaryList/SummaryList.vue +5 -4
  62. package/src/components/Switch/Switch.vue +3 -1
  63. package/src/components/Table/Table.stories.ts +34 -0
  64. package/src/components/Table/Table.vue +98 -8
  65. package/src/i18n/en.ts +127 -0
  66. package/src/i18n/i18n.test.ts +56 -0
  67. package/src/i18n/index.ts +89 -0
  68. package/src/index.ts +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thekestongroup/ui",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Keston UI — Vue 3 + Reka UI + Tailwind CSS component library",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -38,7 +38,8 @@
38
38
  "test:watch": "vitest"
39
39
  },
40
40
  "peerDependencies": {
41
- "vue": "^3.5.0"
41
+ "vue": "^3.5.0",
42
+ "vue-i18n": "^11.0.0"
42
43
  },
43
44
  "packageManager": "pnpm@11.6.0",
44
45
  "publishConfig": {
@@ -83,6 +84,7 @@
83
84
  "vitepress": "1.6.4",
84
85
  "vitest": "^5.1.0",
85
86
  "vue": "^3.5.44",
87
+ "vue-i18n": "^11.4.20",
86
88
  "vue-tsc": "^3.3.14"
87
89
  }
88
90
  }
@@ -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 { cn } from '../../lib/cn'
4
5
  import { age, daysToBirthday, formatDate, toDate, type DateInput } from '../../lib/dates'
@@ -20,6 +21,7 @@ export interface AgeProps {
20
21
  class?: HTMLAttributes['class']
21
22
  }
22
23
 
24
+ const { t } = useI18n()
23
25
  const props = defineProps<AgeProps>()
24
26
 
25
27
  const liveNow = useNow()
@@ -28,8 +30,8 @@ const today = computed(() => props.now ?? liveNow.value)
28
30
  const years = computed(() => age(born.value, today.value))
29
31
  const tooltip = computed(() => {
30
32
  const days = daysToBirthday(born.value, today.value)
31
- const soon = days === 0 ? ' · Birthday today' : days === 1 ? ' · Birthday tomorrow' : days <= 7 ? ` · Birthday in ${days} days` : ''
32
- return `Born ${formatDate(born.value)}${soon}`
33
+ const soon = days === 0 ? ` · ${t('ui.age.birthdayToday')}` : days === 1 ? ` · ${t('ui.age.birthdayTomorrow')}` : days <= 7 ? ` · ${t('ui.age.birthdayInDays', { days })}` : ''
34
+ return `${t('ui.age.born', { date: formatDate(born.value) })}${soon}`
33
35
  })
34
36
  const iso = computed(() => {
35
37
  const d = born.value
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { onBeforeUnmount, onMounted, useId, type HTMLAttributes } from 'vue'
3
4
  import { Menu } from '@lucide/vue'
4
5
  import { TooltipProvider } from 'reka-ui'
@@ -62,6 +63,7 @@ export interface AppShellProps {
62
63
  }
63
64
  }
64
65
 
66
+ const { t } = useI18n()
65
67
  const props = withDefaults(defineProps<AppShellProps>(), {
66
68
  items: () => [],
67
69
  sections: () => [],
@@ -150,7 +152,7 @@ const sidebarId = `${uid}-sidebar`
150
152
  v-if="collapsible"
151
153
  variant="ghost"
152
154
  square
153
- :aria-label="collapsed ? 'Expand sidebar' : 'Collapse sidebar'"
155
+ :aria-label="collapsed ? t('ui.appShell.expandSidebar') : t('ui.appShell.collapseSidebar')"
154
156
  :aria-expanded="!collapsed"
155
157
  :aria-controls="sidebarId"
156
158
  class="-ml-2.5 max-lg:hidden"
@@ -188,7 +190,7 @@ const sidebarId = `${uid}-sidebar`
188
190
  <Slideover
189
191
  v-model:open="menuOpen"
190
192
  side="left"
191
- :title="title || 'Menu'"
193
+ :title="title || t('ui.appShell.menu')"
192
194
  :ui="{
193
195
  content: 'max-w-72',
194
196
  // The header is a column (it also holds a Progress for steps), so
@@ -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 { cn } from '../../lib/cn'
4
5
  import Avatar, { type AvatarProps, type AvatarUser } from '../Avatar/Avatar.vue'
@@ -21,6 +22,7 @@ export interface AvatarGroupProps {
21
22
  class?: HTMLAttributes['class']
22
23
  }
23
24
 
25
+ const { t } = useI18n()
24
26
  const props = withDefaults(defineProps<AvatarGroupProps>(), {
25
27
  size: 'md',
26
28
  max: 4,
@@ -58,7 +60,7 @@ const counterSizes: Record<NonNullable<AvatarProps['size']>, string> = {
58
60
  </script>
59
61
 
60
62
  <template>
61
- <div role="group" :aria-label="label ?? `${users.length} ${users.length === 1 ? 'person' : 'people'}`" :class="cn('flex items-center', props.class)">
63
+ <div role="group" :aria-label="label ?? t('ui.avatarGroup.people', users.length)" :class="cn('flex items-center', props.class)">
62
64
  <!-- A white ring keeps overlapping circles apart; the one pointed at or
63
65
  focused comes to the front, so its ring and focus outline show. -->
64
66
  <span
@@ -73,7 +75,7 @@ const counterSizes: Record<NonNullable<AvatarProps['size']>, string> = {
73
75
  <Popover mode="hover" :open-delay="300" :close-delay="150" :content="{ side: 'bottom', align: 'start', sideOffset: 6 }" :ui="{ content: 'w-56' }">
74
76
  <button
75
77
  type="button"
76
- :aria-label="`${hidden.length} more: ${hidden.map((u) => u.name).join(', ')}`"
78
+ :aria-label="t('ui.avatarGroup.more', { count: hidden.length, names: hidden.map((u) => u.name).join(', ') })"
77
79
  :class="cn(
78
80
  'inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface font-bold text-black select-none',
79
81
  'outline-2 outline-offset-1 outline-transparent transition focus-visible:outline-focus',
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import type { Component, HTMLAttributes } from 'vue'
3
4
  import { ChevronRight } from '@lucide/vue'
4
5
  import { cn } from '../../lib/cn'
@@ -33,8 +34,8 @@ export interface BreadcrumbProps {
33
34
  class?: HTMLAttributes['class']
34
35
  }
35
36
 
37
+ const { t } = useI18n()
36
38
  const props = withDefaults(defineProps<BreadcrumbProps>(), {
37
- label: 'Breadcrumb',
38
39
  linkComponent: 'a'
39
40
  })
40
41
 
@@ -74,7 +75,7 @@ const link = [
74
75
  </script>
75
76
 
76
77
  <template>
77
- <nav :aria-label="label" :class="cn('min-w-0 text-sm', props.class)">
78
+ <nav :aria-label="label ?? t('ui.breadcrumb.label')" :class="cn('min-w-0 text-sm', props.class)">
78
79
  <ol class="flex flex-wrap items-center gap-x-1.5 gap-y-1">
79
80
  <li v-for="(item, i) in items" :key="`${item.label}-${i}`" class="flex min-w-0 items-center gap-1.5">
80
81
  <!-- The current page. -->
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, ref, shallowRef, watch, type HTMLAttributes } from 'vue'
3
4
  import {
4
5
  CalendarCell,
@@ -45,6 +46,7 @@ export interface CalendarProps {
45
46
  class?: HTMLAttributes['class']
46
47
  }
47
48
 
49
+ const { t } = useI18n()
48
50
  const props = withDefaults(defineProps<CalendarProps>(), {
49
51
  locale: 'en-GB'
50
52
  })
@@ -242,14 +244,14 @@ const day = [
242
244
  <CalendarHeader class="flex items-center justify-between gap-1">
243
245
  <!-- Days: arrows change month. Months / years: arrows page years. -->
244
246
  <CalendarPrev v-if="view === 'days'" as-child>
245
- <Button variant="ghost" size="sm" square aria-label="Previous month"><ChevronLeft /></Button>
247
+ <Button variant="ghost" size="sm" square :aria-label="t('ui.calendar.previousMonth')"><ChevronLeft /></Button>
246
248
  </CalendarPrev>
247
249
  <Button
248
250
  v-else
249
251
  variant="ghost"
250
252
  size="sm"
251
253
  square
252
- :aria-label="view === 'months' ? 'Previous year' : 'Previous years'"
254
+ :aria-label="view === 'months' ? t('ui.calendar.previousYear') : t('ui.calendar.previousYears')"
253
255
  :disabled="disabled || pageBackDisabled"
254
256
  @click="page(-1)"
255
257
  >
@@ -261,7 +263,7 @@ const day = [
261
263
  v-if="view === 'days'"
262
264
  type="button"
263
265
  :class="headingButton"
264
- aria-label="Choose month"
266
+ :aria-label="t('ui.calendar.chooseMonth')"
265
267
  :disabled="disabled"
266
268
  @click="showMonths"
267
269
  >
@@ -271,7 +273,7 @@ const day = [
271
273
  v-if="view !== 'years'"
272
274
  type="button"
273
275
  :class="headingButton"
274
- aria-label="Choose year"
276
+ :aria-label="t('ui.calendar.chooseYear')"
275
277
  :disabled="disabled"
276
278
  @click="showYears"
277
279
  >
@@ -283,14 +285,14 @@ const day = [
283
285
  </div>
284
286
 
285
287
  <CalendarNext v-if="view === 'days'" as-child>
286
- <Button variant="ghost" size="sm" square aria-label="Next month"><ChevronRight /></Button>
288
+ <Button variant="ghost" size="sm" square :aria-label="t('ui.calendar.nextMonth')"><ChevronRight /></Button>
287
289
  </CalendarNext>
288
290
  <Button
289
291
  v-else
290
292
  variant="ghost"
291
293
  size="sm"
292
294
  square
293
- :aria-label="view === 'months' ? 'Next year' : 'Next years'"
295
+ :aria-label="view === 'months' ? t('ui.calendar.nextYear') : t('ui.calendar.nextYears')"
294
296
  :disabled="disabled || pageForwardDisabled"
295
297
  @click="page(1)"
296
298
  >
@@ -55,6 +55,8 @@ defineSlots<{
55
55
  const headingId = `${useId()}-title`
56
56
  const tag = computed(() => props.as ?? (props.title ? 'section' : 'div'))
57
57
 
58
+ // With no padding the content (e.g. a table) runs to the edges, but the
59
+ // title keeps 16px, like the footer.
58
60
  const paddings: Record<NonNullable<CardProps['padding']>, string> = {
59
61
  none: '',
60
62
  sm: 'p-4',
@@ -87,7 +89,7 @@ const footerPaddings: Record<NonNullable<CardProps['padding']>, string> = {
87
89
  <div :class="cn('flex min-w-0 flex-1 flex-col gap-4', paddings[padding], ui?.body)">
88
90
  <div
89
91
  v-if="title || description || $slots.header || $slots.actions"
90
- :class="cn('flex items-start justify-between gap-3', ui?.header)"
92
+ :class="cn('flex items-start justify-between gap-3', padding === 'none' && 'px-4 pt-4 sm:px-6 sm:pt-6', ui?.header)"
91
93
  >
92
94
  <slot name="header">
93
95
  <div class="flex min-w-0 flex-col gap-1">
@@ -92,6 +92,9 @@ export const SelectAll: Story = {
92
92
 
93
93
  export const Disabled: Story = { args: { disabled: true } };
94
94
 
95
+ /** For a row checkbox in a Table: the label is for screen readers, and the box has a larger area to press. */
96
+ export const HiddenLabel: Story = { args: { hideLabel: true } };
97
+
95
98
  export const DisabledTicked: Story = {
96
99
  args: { disabled: true },
97
100
  render: (args) => ({
@@ -26,6 +26,8 @@ export interface CheckboxProps {
26
26
  value?: string
27
27
  required?: boolean
28
28
  disabled?: boolean
29
+ /** Keep the label (and description) for screen readers only, e.g. a row's box in a table. */
30
+ hideLabel?: boolean
29
31
  class?: HTMLAttributes['class']
30
32
  }
31
33
 
@@ -88,7 +90,7 @@ const box = [
88
90
  </CheckboxIndicator>
89
91
  </CheckboxRoot>
90
92
  <div
91
- :class="cn('flex min-w-0 flex-col gap-0.5', disabled ? 'cursor-not-allowed' : 'cursor-pointer')"
93
+ :class="cn('flex min-w-0 flex-col gap-0.5', disabled ? 'cursor-not-allowed' : 'cursor-pointer', hideLabel && 'sr-only')"
92
94
  @click="pressControl($event, controlId)"
93
95
  >
94
96
  <label :for="controlId" :class="cn('text-sm', disabled ? 'cursor-not-allowed' : 'cursor-pointer')">{{ label }}</label>
@@ -0,0 +1,48 @@
1
+ import type { Meta, StoryObj } from "@storybook/vue3-vite";
2
+ import { ref } from "vue";
3
+ import CheckboxGroup from "./CheckboxGroup.vue";
4
+
5
+ const meta = {
6
+ title: "Components/Form/CheckboxGroup",
7
+ component: CheckboxGroup,
8
+ tags: ["autodocs"],
9
+ argTypes: {
10
+ helperPlacement: { options: ["below", "icon"], control: { type: "inline-radio" } },
11
+ },
12
+ args: {
13
+ label: "Licences",
14
+ helper: "",
15
+ helperPlacement: "below",
16
+ errorText: "",
17
+ disabled: false,
18
+ options: [
19
+ { label: "Keston Admissions", value: "admissions", description: "By Keston. 12 users have a licence." },
20
+ { label: "Keston Reports", value: "reports", description: "By Keston. 3 users have a licence." },
21
+ { label: "Keston Timetable", value: "timetable", description: "By Keston. 0 users have a licence." },
22
+ ],
23
+ },
24
+ decorators: [() => ({ template: '<div class="max-w-120"><story /></div>' })],
25
+ render: (args) => ({
26
+ components: { CheckboxGroup },
27
+ setup: () => ({ args, value: ref<(string | number)[]>(["admissions"]) }),
28
+ template: `
29
+ <CheckboxGroup v-bind="args" v-model="value" />
30
+ <pre class="mt-4 text-xs text-black/65">{{ value }}</pre>`,
31
+ }),
32
+ } satisfies Meta<typeof CheckboxGroup>;
33
+
34
+ export default meta;
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ export const Default: Story = {};
38
+
39
+ export const WithError: Story = {
40
+ args: { errorText: "Choose at least one licence" },
41
+ render: (args) => ({
42
+ components: { CheckboxGroup },
43
+ setup: () => ({ args, value: ref<(string | number)[]>([]) }),
44
+ template: '<CheckboxGroup v-bind="args" v-model="value" />',
45
+ }),
46
+ };
47
+
48
+ export const Disabled: Story = { args: { disabled: true } };
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ import { computed, useId, type HTMLAttributes } from 'vue'
3
+ import { useI18n } from 'vue-i18n'
4
+ import { cn } from '../../lib/cn'
5
+ import Checkbox from '../Checkbox/Checkbox.vue'
6
+ import FieldMessage from '../FormField/FieldMessage.vue'
7
+ import InfoTip from '../InfoTip/InfoTip.vue'
8
+
9
+ /**
10
+ * Several yes / no answers under one question, where any number can be
11
+ * ticked, e.g. "Which licences should they have?" or "Send it to". For one
12
+ * choice from a few, use RadioGroup; for a list of more than about eight,
13
+ * use Select with `multiple`.
14
+ */
15
+ export type CheckboxGroupValue = string | number
16
+
17
+ export interface CheckboxOption {
18
+ label: string
19
+ value: CheckboxGroupValue
20
+ /** More detail, in smaller text under the label. */
21
+ description?: string
22
+ disabled?: boolean
23
+ }
24
+
25
+ export interface CheckboxGroupProps {
26
+ /** The question, above the options. Also the group's accessible name. */
27
+ label: string
28
+ options: CheckboxOption[]
29
+ /** Extra guidance about the choice. */
30
+ helper?: string
31
+ /** Show helper text under the label, or behind a `?` icon next to it. */
32
+ helperPlacement?: 'below' | 'icon'
33
+ /** Keep the label (and helper) for screen readers only. */
34
+ hideLabel?: boolean
35
+ /** Error message, e.g. "Choose at least one". */
36
+ errorText?: string
37
+ disabled?: boolean
38
+ class?: HTMLAttributes['class']
39
+ }
40
+
41
+ const props = withDefaults(defineProps<CheckboxGroupProps>(), {
42
+ helperPlacement: 'below'
43
+ })
44
+ const { t } = useI18n()
45
+
46
+ /** The values of the ticked options. */
47
+ const model = defineModel<CheckboxGroupValue[]>({ default: () => [] })
48
+
49
+ const id = useId()
50
+ const labelId = `${id}-label`
51
+ const helperId = `${id}-helper`
52
+ const statusId = `${id}-status`
53
+
54
+ const describedBy = computed(
55
+ () => [props.helper && helperId, props.errorText && statusId].filter(Boolean).join(' ') || undefined
56
+ )
57
+
58
+ function toggle(value: CheckboxGroupValue, on: boolean) {
59
+ model.value = on ? [...model.value, value] : model.value.filter((v) => v !== value)
60
+ }
61
+ </script>
62
+
63
+ <template>
64
+ <div :class="cn('flex flex-col gap-1.5 text-black', props.class)">
65
+ <div :class="cn('flex flex-col gap-0.5', hideLabel && 'sr-only')">
66
+ <div class="flex items-center gap-1">
67
+ <span :id="labelId" class="text-sm">{{ label }}</span>
68
+ <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="t('ui.formField.about', { label })" />
69
+ </div>
70
+ <!-- Behind the ?: hidden, but still the group's description. -->
71
+ <p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-black/65">
72
+ {{ helper }}
73
+ </p>
74
+ </div>
75
+
76
+ <div
77
+ role="group"
78
+ :aria-labelledby="labelId"
79
+ :aria-describedby="describedBy"
80
+ :aria-invalid="errorText ? true : undefined"
81
+ class="flex flex-col gap-3"
82
+ >
83
+ <Checkbox
84
+ v-for="option in options"
85
+ :key="String(option.value)"
86
+ :model-value="model.includes(option.value)"
87
+ :label="option.label"
88
+ :description="option.description"
89
+ :disabled="disabled || option.disabled"
90
+ @update:model-value="toggle(option.value, $event === true)"
91
+ />
92
+ </div>
93
+
94
+ <FieldMessage :id="statusId" :status="errorText ? 'error' : undefined" :text="errorText" />
95
+ </div>
96
+ </template>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import type { HTMLAttributes } from 'vue'
3
4
  import { X } from '@lucide/vue'
4
5
  import { cn } from '../../lib/cn'
@@ -26,9 +27,9 @@ export interface ChipProps {
26
27
  class?: HTMLAttributes['class']
27
28
  }
28
29
 
30
+ const { t } = useI18n()
29
31
  const props = withDefaults(defineProps<ChipProps>(), {
30
32
  size: 'md',
31
- removeLabel: 'Remove',
32
33
  removeFocusable: true
33
34
  })
34
35
 
@@ -70,7 +71,7 @@ const removeSizes: Record<NonNullable<ChipProps['size']>, string> = {
70
71
  v-if="removable"
71
72
  type="button"
72
73
  :tabindex="removeFocusable ? undefined : -1"
73
- :aria-label="removeLabel"
74
+ :aria-label="removeLabel ?? t('ui.chip.remove')"
74
75
  :disabled="disabled"
75
76
  :class="cn(
76
77
  'flex shrink-0 cursor-pointer items-center justify-center rounded-sm transition',
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, useId, type HTMLAttributes } from 'vue'
3
4
  import { cn } from '../../lib/cn'
4
5
  import InfoTip from '../InfoTip/InfoTip.vue'
@@ -45,6 +46,7 @@ export interface FormFieldProps {
45
46
  class?: HTMLAttributes['class']
46
47
  }
47
48
 
49
+ const { t } = useI18n()
48
50
  const props = withDefaults(defineProps<FormFieldProps>(), {
49
51
  helperPlacement: 'below'
50
52
  })
@@ -132,7 +134,7 @@ const statusBorder: Record<FormFieldStatus, string> = {
132
134
 
133
135
  <!-- Screen readers get the helper from the control's aria-describedby
134
136
  (the hidden copy below), so the ? is for sighted users. -->
135
- <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="`About ${label}`" />
137
+ <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="t('ui.formField.about', { label })" />
136
138
  </div>
137
139
 
138
140
  <!-- Behind the ?: hidden, but still the control's description. -->
@@ -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 { ArrowLeftRight, LogOut, Menu, Settings } from '@lucide/vue'
4
5
  import { cn } from '../../lib/cn'
@@ -82,10 +83,10 @@ export interface HeaderProps {
82
83
  }
83
84
  }
84
85
 
86
+ const { t } = useI18n()
85
87
  const props = withDefaults(defineProps<HeaderProps>(), {
86
88
  menu: false,
87
89
  menuOpen: undefined,
88
- menuLabel: 'Menu',
89
90
  linkComponent: 'a',
90
91
  userActions: () => ['account-settings', 'switch-account', 'log-out'],
91
92
  signIn: true,
@@ -117,8 +118,8 @@ const initials = computed(() => toInitials(props.user?.name ?? ''))
117
118
  // BS"): "BS, account: Ben Smith". Not in brackets: axe doesn't match "(BS)".
118
119
  const accountLabel = computed(() => {
119
120
  if (!props.user) return ''
120
- if (props.user.avatar || !initials.value) return `Account: ${props.user.name}`
121
- return `${initials.value}, account: ${props.user.name}`
121
+ if (props.user.avatar || !initials.value) return t('ui.header.account', { name: props.user.name })
122
+ return t('ui.header.accountWithInitials', { initials: initials.value, name: props.user.name })
122
123
  })
123
124
 
124
125
  const titleLink = computed(() => {
@@ -158,7 +159,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
158
159
  v-if="menu"
159
160
  variant="ghost"
160
161
  square
161
- :aria-label="menuLabel"
162
+ :aria-label="menuLabel ?? t('ui.header.menu')"
162
163
  :aria-expanded="menuOpen"
163
164
  :aria-controls="menuControls"
164
165
  :class="cn('-ml-2.5', ui?.menu)"
@@ -248,7 +249,7 @@ function runAction(action: HeaderUserAction, close: () => void) {
248
249
  </template>
249
250
  </Popover>
250
251
 
251
- <Button v-else-if="signIn" size="sm" variant="primary" @click="emit('sign-in')">Sign in</Button>
252
+ <Button v-else-if="signIn" size="sm" variant="primary" @click="emit('sign-in')">{{ t('ui.header.signIn') }}</Button>
252
253
  </slot>
253
254
  </div>
254
255
  </header>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, ref, type HTMLAttributes } from 'vue'
3
4
  import FormField, { type FormFieldStatus } from '../FormField/FormField.vue'
4
5
 
@@ -36,6 +37,7 @@ export interface InputProps {
36
37
  class?: HTMLAttributes['class']
37
38
  }
38
39
 
40
+ const { t } = useI18n()
39
41
  const props = withDefaults(defineProps<InputProps>(), {
40
42
  helperPlacement: 'below'
41
43
  })
@@ -50,10 +52,10 @@ const touched = ref(false)
50
52
  const lengthError = computed(() => {
51
53
  const length = model.value.length
52
54
  if (props.maxLength !== undefined && length > props.maxLength) {
53
- return `Must be ${props.maxLength} characters or fewer`
55
+ return t('ui.input.maxLength', { count: props.maxLength })
54
56
  }
55
57
  if (touched.value && props.minLength !== undefined && length > 0 && length < props.minLength) {
56
- return `Must be at least ${props.minLength} characters`
58
+ return t('ui.input.minLength', { count: props.minLength })
57
59
  }
58
60
  return undefined
59
61
  })
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, useId, type HTMLAttributes } from 'vue'
3
4
  import { PinInputInput, PinInputRoot } from 'reka-ui'
4
5
  import { cn } from '../../lib/cn'
@@ -41,6 +42,7 @@ export interface InputCodeProps {
41
42
  class?: HTMLAttributes['class']
42
43
  }
43
44
 
45
+ const { t } = useI18n()
44
46
  const props = withDefaults(defineProps<InputCodeProps>(), {
45
47
  helperPlacement: 'below',
46
48
  length: 6
@@ -106,7 +108,7 @@ const statusBorder: Record<InputCodeStatus, string> = {
106
108
  <div class="flex flex-col gap-0.5">
107
109
  <div class="flex items-center gap-1">
108
110
  <label :id="labelId" :for="`${id}-0`" class="text-sm">{{ label }}</label>
109
- <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="`About ${label}`" />
111
+ <InfoTip v-if="helper && helperPlacement === 'icon'" :text="helper" :label="t('ui.formField.about', { label })" />
110
112
  </div>
111
113
  <!-- Behind the ?: hidden, but still the boxes' description. -->
112
114
  <p v-if="helper" :id="helperId" :hidden="helperPlacement === 'icon'" class="text-xs text-black/65">
@@ -132,7 +134,7 @@ const statusBorder: Record<InputCodeStatus, string> = {
132
134
  :id="`${id}-${i}`"
133
135
  :key="i"
134
136
  :index="i"
135
- :aria-label="i === 0 ? undefined : `Character ${i + 1} of ${length}`"
137
+ :aria-label="i === 0 ? undefined : t('ui.inputCode.character', { n: i + 1, total: length })"
136
138
  :aria-labelledby="i === 0 ? labelId : undefined"
137
139
  :aria-describedby="describedBy"
138
140
  :aria-invalid="currentStatus === 'error' || undefined"
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, ref, watch, type HTMLAttributes } from 'vue'
3
4
  import { DatePickerContent, DatePickerRoot, DatePickerTrigger } from 'reka-ui'
4
5
  import { getLocalTimeZone, parseDate, today, type DateValue } from '@internationalized/date'
@@ -43,6 +44,7 @@ export interface InputDateProps {
43
44
  class?: HTMLAttributes['class']
44
45
  }
45
46
 
47
+ const { t } = useI18n()
46
48
  const props = withDefaults(defineProps<InputDateProps>(), {
47
49
  helperPlacement: 'below',
48
50
  locale: 'en-GB',
@@ -164,7 +166,7 @@ function onTextBlur() {
164
166
  text.value = formatShort(date)
165
167
  formatError.value = undefined
166
168
  } else {
167
- formatError.value = `Enter a date like ${example.value}`
169
+ formatError.value = t('ui.inputDate.enterDate', { example: example.value })
168
170
  }
169
171
  }
170
172
 
@@ -244,7 +246,7 @@ const trigger = [
244
246
  {{ phrasePreview }}
245
247
  </span>
246
248
 
247
- <DatePickerTrigger aria-label="Open calendar" :class="trigger">
249
+ <DatePickerTrigger :aria-label="t('ui.inputDate.openCalendar')" :class="trigger">
248
250
  <CalendarDays />
249
251
  </DatePickerTrigger>
250
252
 
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { computed, onBeforeUnmount, onMounted, ref, useAttrs, type HTMLAttributes } from 'vue'
3
4
  import { Eye, EyeOff } from '@lucide/vue'
4
5
  import FormField, { type FormFieldStatus } from '../FormField/FormField.vue'
@@ -38,6 +39,7 @@ export interface InputPasswordProps {
38
39
  class?: HTMLAttributes['class']
39
40
  }
40
41
 
42
+ const { t } = useI18n()
41
43
  const props = withDefaults(defineProps<InputPasswordProps>(), {
42
44
  helperPlacement: 'below'
43
45
  })
@@ -71,7 +73,7 @@ function checkCapsLock(event: KeyboardEvent) {
71
73
  capsLock.value = event.getModifierState?.('CapsLock') ?? false
72
74
  }
73
75
 
74
- const statusText = computed(() => props.statusText ?? (capsLock.value ? 'Caps Lock is on' : undefined))
76
+ const statusText = computed(() => props.statusText ?? (capsLock.value ? t('ui.inputPassword.capsLock') : undefined))
75
77
 
76
78
  // Same square end segment as InputNumber's + button, so the field reads
77
79
  // [ password | 👁 ]. Pressing it keeps focus (and the caret) in the input.
@@ -126,7 +128,7 @@ const toggle = [
126
128
  @pointerdown.prevent
127
129
  @click="visible = !visible"
128
130
  >
129
- <span class="sr-only">Show password</span>
131
+ <span class="sr-only">{{ t('ui.inputPassword.show') }}</span>
130
132
  <EyeOff v-if="visible" aria-hidden="true" />
131
133
  <Eye v-else aria-hidden="true" />
132
134
  </button>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { useI18n } from 'vue-i18n'
2
3
  import { defineComponent, onBeforeUnmount, ref, watch, watchEffect, type HTMLAttributes, type PropType } from 'vue'
3
4
  import { EditorContent, useEditor } from '@tiptap/vue-3'
4
5
  import type { Editor } from '@tiptap/core'
@@ -46,6 +47,7 @@ export interface InputRichTextProps {
46
47
  class?: HTMLAttributes['class']
47
48
  }
48
49
 
50
+ const { t } = useI18n()
49
51
  const props = withDefaults(defineProps<InputRichTextProps>(), {
50
52
  helperPlacement: 'below'
51
53
  })
@@ -131,9 +133,9 @@ const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigat
131
133
  const mod = isMac ? '⌘' : 'Ctrl+'
132
134
 
133
135
  const marks = [
134
- { name: 'bold', label: 'Bold', icon: BoldIcon, key: 'B', toggle: () => editor.value?.chain().focus().toggleBold().run() },
135
- { name: 'italic', label: 'Italic', icon: ItalicIcon, key: 'I', toggle: () => editor.value?.chain().focus().toggleItalic().run() },
136
- { name: 'underline', label: 'Underline', icon: UnderlineIcon, key: 'U', toggle: () => editor.value?.chain().focus().toggleUnderline().run() }
136
+ { name: 'bold', get label() { return t('ui.inputRichText.bold') }, icon: BoldIcon, key: 'B', toggle: () => editor.value?.chain().focus().toggleBold().run() },
137
+ { name: 'italic', get label() { return t('ui.inputRichText.italic') }, icon: ItalicIcon, key: 'I', toggle: () => editor.value?.chain().focus().toggleItalic().run() },
138
+ { name: 'underline', get label() { return t('ui.inputRichText.underline') }, icon: UnderlineIcon, key: 'U', toggle: () => editor.value?.chain().focus().toggleUnderline().run() }
137
139
  ] as const
138
140
 
139
141
  // The text area: at least 4 lines, then it grows to 15 lines and scrolls.
@@ -168,7 +170,7 @@ const editable = [
168
170
  <!-- Pressing a button keeps focus (and the selection) in the text. -->
169
171
  <div
170
172
  role="toolbar"
171
- :aria-label="`Formatting for ${label}`"
173
+ :aria-label="t('ui.inputRichText.formattingFor', { label })"
172
174
  :aria-controls="slot.id"
173
175
  class="flex items-center gap-0.5 border-b border-black/15 px-1.5 py-1 [&_svg]:opacity-100!"
174
176
  @mousedown.prevent