@xleddyl/443-components-vue 0.16.35 → 0.16.36

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/CATALOG.md CHANGED
@@ -110,7 +110,7 @@ Playground paths in this file are relative to `playground/nuxt/app/pages/compone
110
110
  | Actions in a settings section header ("Add user") | `#actions-<id>` on `SettingsModal`, `#settings-actions-<id>` on `DashboardLayout` (gets `page`, `openPage`, `back`) |
111
111
  | Page that fills the panel height (a full height grid) | `content="fill"` or `"centered"` on `DashboardLayout` / `AppShell`, `definePageMeta({ content: 'fill' })` |
112
112
  | Custom app frame with your own sidebar | `AppShell` + `Sidebar` + `SidebarNav` |
113
- | Login, sign up, reset password page | `AuthLayout` (or the Nuxt layout `k-auth`) |
113
+ | Login, sign up, reset password page | `AuthLogin` + `AuthLogout` (two step flow); `AuthLayout` (or `k-auth`) for other pages |
114
114
  | Settings in a modal (account, appearance, your sections) | `SettingsModal` (the `DashboardLayout` embeds it) |
115
115
  | Settings as a page with sections | `SettingsPage` + `SettingsSection` + `SettingsGroup` |
116
116
  | Theme and preset choice | `AppearanceSettings`, `ThemeSwitch`, `useTheme`, `usePreset` |
@@ -230,7 +230,7 @@ Mount `OverlayHost` once for the imperative hooks (see [Composables](#composable
230
230
  | ---------------- | --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
231
231
  | `Card` | Container with optional title, description, icon, actions and footer. Can be a link or a selectable button. | Props: `title`, `description`, `icon`, `variant` (raised, outline, subtle), `padding`, `as`, `to`, `href`, `selected`, `disabled`, `animated`. Slots: default, `header`, `title`, `description`, `icon`, `actions`, `footer`. | `layout/card.vue` |
232
232
  | `PageHeader` | Page title with description, breadcrumbs, badge and actions. The page templates include it. | Props: `title`, `description`, `icon`, `breadcrumbs`, `level`, `bordered`, `align`, `truncate`. Slots: `actions`, `badge`, `description`, `title`, `icon`, `breadcrumbs`. | `layout/page-header.vue` |
233
- | `Breadcrumbs` | Path navigation. | Props: `items` (`label`, `to`, `href`, `icon`), `separator`, `linkLast`, `ancestors`. Slot: `item`. | `layout/breadcrumbs.vue` |
233
+ | `Breadcrumbs` | Path navigation. | Props: `items` (`label`, `to`, `href`, `icon`), `separator`, `linkLast`, `ancestors`, `size` (`md`, `lg` for a title sized trail). Slot: `item`. | `layout/breadcrumbs.vue` |
234
234
  | `Stepper` | Step indicator for wizards and multi step flows (import, checkout). Horizontal or vertical, compact on narrow widths. | Model: `v-model` (current step value). Props: `steps` (`value`, `label`, `description`, `icon`, `disabled`, `state`: `complete` or `error`), `label`, `orientation`, `size`, `linear` (only completed and current steps clickable), `readonly`, `compact` (`'auto'` by default, `true`, `false`), `summary` (false hides the compact "Step 2 of 4" line), `positionLabel`, `completeLabel`, `errorLabel`. Event: `select`. | `layout/stepper.vue` |
235
235
  | `Tabs` | Tabs with panels, badges and dots. Segmented or underline. | Model: `v-model` (active value). Props: `items` (`value`, `label`, `icon`, `badge`, `badgeTone`, `dot`, `disabled`), `variant`, `size`, `lazy`, `fill`, `stretch`, `inset`, `controls` (id of a panel outside the component: only the tab list renders). Slots: `panel-<value>`, `panel`. | `layout/tabs.vue` |
236
236
  | `Accordion` | Collapsible sections. | Model: `v-model` (open value or values). Props: `items` (`value`, `title`, `description`, `content`, `icon`), `multiple`, `collapsible`, `variant`. Slots: default, `title`. | `layout/accordion.vue` |
@@ -267,7 +267,9 @@ Templates combine core parts into whole pages and layouts. Start from them for n
267
267
  | Component | Purpose and when to use it | Main props, models, slots, events | Playground |
268
268
  | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
269
269
  | `DashboardLayout` | Ready app frame: brand, navigation, command search, account menu, settings modal, breadcrumbs, theme switch. Put it in `layouts/default.vue`. | Models: `v-model:collapsed`, `v-model:open`, `v-model:settingsOpen`, `v-model:settingsSection`. Props: `navigation` (`NavItem[]` or `NavSection[]`), `account` (`name`, `email`, `avatar`, `role`, `menu`), `brandName`, `brandIcon`, `brandLogo`, `breadcrumbs`, `search` (true, groups or function), `settingsSections`, `settingsRoute`, `settingsRouteLocation`, `settingsAccountSection`, `settingsResolvePage`, `settingsHideSession`, `variant`, `content` (`page`, `fill`, `centered`, `bleed`; per page with `definePageMeta({ content })` in `k-dashboard`), `fluid`, `fill`, `onSignOut`. Slots: default, `actions`, `brand`, `sidebar`, `sidebar-footer`, `account`, `topbar`, `search-item`, `settings-account-fields`, `settings-section-<id>`, `settings-actions-<id>`. Event: `accountSelect`. | `templates/dashboard-layout.vue` |
270
- | `AuthLayout` | Login, sign up and reset password frame. Centered card or split with aside. | Props: `variant` (centered, split), `title`, `description`, `footer`, `brandName`, `brandIcon`, `brandLogo`, `asideTitle`, `asideDescription`, `themeSwitch`. Slots: default, `links`, `footer`, `brand`, `aside`, `corner`. | `templates/auth-layout.vue` |
270
+ | `AuthLayout` | Frame of sign in, sign up and reset password pages: left column with brand, title (or a large breadcrumb), form and footer; aside panel on the right from 960px. | Props: `title`, `description`, `breadcrumbs`, `footer`, `brandName`, `brandIcon`, `brandLogo`, `aside`, `asideTitle`, `asideDescription`, `themeSwitch`. Slots: default, `links`, `footer`, `brand`, `aside`, `corner`. | `templates/auth-layout.vue` |
271
+ | `AuthLogin` | Complete sign in page in two steps (email, then password with a breadcrumb back). Offers to sign in again after `AuthLogout`. | Props: `submit` (`{ email, password }`), `submitError`, `title`, `description`, `emailLabel`, `emailPlaceholder`, `passwordLabel`, `submitLabel`, `stepKey`, `reasonKey`, frame props of `AuthLayout`. Slots: `links` (`{ email, step }`), `footer`, `brand`, `aside`, `corner`. | `templates/auth-login.vue` |
272
+ | `AuthLogout` | Sign out page: runs `logout()`, remembers the account, reloads the sign in page. Retry on error. | Props: `logout`, `account` (`{ email, name }`), `loginTo`, `reasonKey`, frame props of `AuthLayout`. Slots: `footer`, `brand`, `aside`, `corner`. Helpers: `rememberSignedOutAccount`, `takeSignedOutAccount`, `SIGNED_OUT_REASON`. | `templates/auth-login.vue` |
271
273
  | `ListPage` | Whole list page: header, search, filters, table, pagination, bulk actions, loading, empty, no results and error states. Client or server mode (`total`). | Models: `page`, `pageSize`, `search`, `filter`, `sort`, `selected`. Props: `title`, `rows`, `columns`, `rowKey`, `rowTo`, `selectable`, `loading`, `error`, `total`, `paginate`, `searchable`, `searchKeys`, `filters`, `filterKey`, `filterMultiple`, `emptyTitle`. Slots: `actions`, `toolbar`, `toolbar-end`, `bulk`, `empty`, `empty-actions`, `no-results`, `error`, `cell-<key>`, `table`. Events: `retry`, `clear`, `rowClick`. | `templates/list-page.vue` |
272
274
  | `DetailPage` | Record page: back link, title, status, actions, tabs, main column and aside with description lists. | Model: `v-model:tab`. Props: `title`, `backTo`, `backLabel`, `status` (`label`, `tone`, `dot`), `tabs`, `sections` (`title`, `items`), `loading`, `error`. Slots: default, `actions`, `badge`, `meta`, `aside`, `aside-before`, `panel-<value>`. | `templates/detail-page.vue` |
273
275
  | `FormDrawer` | Drawer with a form: `Form` around the body, footer with delete (left), cancel and submit, a discard confirmation on close when the form is dirty, `SkeletonForm` while `loading`. | Models: `v-model:open`, `v-model:tab`. Props: `title`, `description`, `side`, `size`, `fill` (per tab, for a full height table), `tabs` (`FormDrawerTab`: `fields` gives the error dot and opens the tab on a failed submit), `tabRoute` (keeps the tab in the hash under this key), `trail`, `backLabel`, `form`, `loading`, `readonly`, `creating` (submit says Create, no dirty needed), `requireDirty`, `deletable`, `deleteDisabled`, `deleteHint`, `submitLabel`, `cancelLabel`, `deleteLabel`, `guard`, `guardTitle`, `guardMessage`, `beforeClose`, `onCancel`. Slots: default (`{ tab }`), `actions`, `title-trailing`, `skeleton`, `footer`. Events: `delete`, `navigate`, `afterLeave`. Exposes `confirmDiscard()`, `close()`. | `templates/form-drawer.vue` |
package/README.md CHANGED
@@ -424,18 +424,18 @@ Several controls in one `FormField`. Only the primary control takes the field id
424
424
 
425
425
  ## Components
426
426
 
427
- | Group | Components |
428
- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
429
- | core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden |
430
- | forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, InputAddon, InputGroup, NumberInput, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput |
431
- | overlays | CommandPalette, ConfirmDialog, ConfirmHost, ContextMenu, Drawer, DropdownMenu, HoverCard, Modal, OverlayHost, Popover, Toaster, Tooltip |
432
- | data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, SelectionBar, Stat, Table, Tag, TagList, Timeline, Tree |
433
- | layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar |
434
- | templates | DashboardLayout, AuthLayout, DashboardPage, ListPage, DetailPage, FormPage, SettingsPage, SettingsSection, SettingsModal, SettingsGroup, AppearanceSettings, SaveBar, ErrorPage, NotFoundPage, EmptyPage, Brand, AccountMenu |
435
- | feedback | Alert, EmptyState, LoadingOverlay, Meter, Progress, ProgressRing, Skeleton |
436
- | grid | DataGrid, GridToolbar, cell renderers (BadgeCell, BooleanCell, ButtonCell, DateCell, EmptyCell, ImageCell, LinkCell) |
437
- | editor | RichTextEditor |
438
- | chart | ChartPanel, ChartLegend, LineChart, BarChart, DoughnutChart |
427
+ | Group | Components |
428
+ | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
429
+ | core | Root, Icon, Button, Spinner, Input, Textarea, FormField, FieldMessage, FieldBoundary, Form, FormAlerts, Kbd, VisuallyHidden |
430
+ | forms | Calendar, Checkbox, CheckboxGroup, ColorInput, Combobox, DateInput, DatePicker, FileInput, InputAddon, InputGroup, NumberInput, PasswordInput, PinInput, Radio, RadioGroup, SegmentedControl, Select, Slider, Switch, TimeInput |
431
+ | overlays | CommandPalette, ConfirmDialog, ConfirmHost, ContextMenu, Drawer, DropdownMenu, HoverCard, Modal, OverlayHost, Popover, Toaster, Tooltip |
432
+ | data | Avatar, AvatarGroup, Badge, DescriptionList, FilterPill, FilterPills, Pagination, SelectionBar, Stat, Table, Tag, TagList, Timeline, Tree |
433
+ | layout | Accordion, AppShell, Breadcrumbs, Card, CopyButton, Grid, NavLink, PageHeader, Separator, Sidebar, SidebarNav, SidebarSection, Stack, Stepper, Tabs, ThemeSwitch, Toolbar |
434
+ | templates | DashboardLayout, AuthLayout, AuthLogin, AuthLogout, DashboardPage, ListPage, DetailPage, FormPage, SettingsPage, SettingsSection, SettingsModal, SettingsGroup, AppearanceSettings, SaveBar, ErrorPage, NotFoundPage, EmptyPage, Brand, AccountMenu |
435
+ | feedback | Alert, EmptyState, LoadingOverlay, Meter, Progress, ProgressRing, Skeleton |
436
+ | grid | DataGrid, GridToolbar, cell renderers (BadgeCell, BooleanCell, ButtonCell, DateCell, EmptyCell, ImageCell, LinkCell) |
437
+ | editor | RichTextEditor |
438
+ | chart | ChartPanel, ChartLegend, LineChart, BarChart, DoughnutChart |
439
439
 
440
440
  Composables: `useTheme`, `usePreset`, `useForm`, `useField`, `useFieldControl`, `useToast` (and `toast`), `useConfirm`, `useAlert`, `usePrompt`, `useModal`, `useDrawer`, `useOverlay`, `useModalContext`, `useLoading` (and `withLoading`), `useLoadingState`, `useHotkey`, `useCopy`, `useFileDrop` (with `readDroppedFiles`), `useSortable`, `usePasswordStrength`, `useTableSort`, `useAppShell`, `useRouteState`, `useScrollLock`, `useDirtyGuard`, `useIcons` helpers and `useLinkComponent`, `provideFieldBoundary`, `provideAuxiliaryControls`, `provideForm`, `useLocale`. With the Nuxt module also `useDashboard()` (runtime account, breadcrumbs and badges for the `k-dashboard` layout).
441
441
 
@@ -714,7 +714,20 @@ A large dialog (60rem) with a section nav on the left and the content on the rig
714
714
 
715
715
  ### AuthLayout
716
716
 
717
- Centered card on the canvas (`variant="centered"`) or form plus an accent aside panel (`variant="split"`, the aside hides below 960px). Props: `title`, `description`, `footer`, `brandName`, `brandIcon`, `brandLogo`, `brandTo`, `asideTitle`, `asideDescription`, `themeSwitch`. Slots: default (card content), `links` (under the card), `footer`, `brand`, `aside`, `corner`.
717
+ Two columns: on the left the brand at the top, then the title, the description and the form (aligned left, `--k-auth-width`, default 24rem), and the footer at the bottom. On the right an aside panel that shows from 960px (`:aside="false"` hides it). `breadcrumbs` replaces the title with a large trail (`Breadcrumbs size="lg"`), for a step of a flow. Props: `title`, `description`, `breadcrumbs`, `footer`, `brandName`, `brandSubtitle`, `brandIcon`, `brandLogo`, `brandTo`, `aside`, `asideTitle`, `asideDescription`, `themeSwitch`. Slots: default (form), `title`, `description`, `links` (under the form), `footer`, `brand`, `aside`, `corner`.
718
+
719
+ ### AuthLogin and AuthLogout
720
+
721
+ `AuthLogin` is the complete sign in page, built on `AuthLayout`. Step one asks for the email and checks its format. Step two asks for the password and shows the email in a breadcrumb that goes back to step one. The step is in the query (`?step=password`, `stepKey`), so the browser back button works. `submit({ email, password })` signs in and navigates. A thrown error goes through `submitError` and shows on the form.
722
+
723
+ `AuthLogout` signs out on mount (`logout()`), keeps `account` (`{ email, name }`) in the session storage and reloads `loginTo` (default `/login`) with `?reason=signed-out`. The full reload clears the state of the previous account. `AuthLogin` then shows "See you soon, {name}" with "Sign in again" (straight to the password step) and "Use another account". If `logout()` fails, the page shows retry and a link to the sign in page.
724
+
725
+ ```vue
726
+ <KAuthLogin :submit="signIn" :submit-error="toFormError" brand-name="Acme" />
727
+ <KAuthLogout :logout="signOut" :account="{ email: user.email, name: user.firstName }" />
728
+ ```
729
+
730
+ Both take the `AuthLayout` frame props and the `brand`, `corner`, `footer` and `aside` slots. `AuthLogin` also has `#links` (`{ email, step }`), for example a password reset link. `rememberSignedOutAccount()`, `takeSignedOutAccount()` and `SIGNED_OUT_REASON` are exported for a custom flow.
718
731
 
719
732
  ### Page templates
720
733
 
@@ -804,14 +817,14 @@ export default defineAppConfig({
804
817
  signOutTo: '/logout',
805
818
  },
806
819
  dashboard: { variant: 'inset', search: true },
807
- auth: { variant: 'split', footer: 'Acme Inc.', asideTitle: 'Run the store.' },
820
+ auth: { footer: 'Acme Inc.', asideTitle: 'Run the store.' },
808
821
  },
809
822
  })
810
823
  ```
811
824
 
812
825
  The account row opens the SettingsModal (`account.action: 'menu'` with `account.menu` for a dropdown instead). Sections from `app.config` can be built-ins or links (`to`); `settings.presets` limits the preset cards, `settings.signOutTo` adds Sign out, `settings.route` (`true` or a query key) syncs the modal with the URL (see SettingsModal, deep links).
813
826
 
814
- Pages pick them with `definePageMeta({ layout: 'k-dashboard', title: 'Items' })` or `layout: 'k-auth'` (the auth card shows `title` and `description` from the page meta). Both layouts set the document title from `meta.title` and the brand name (`Items · Acme`; a page's own `useHead({ title })` wins) and announce route changes through a polite live region, unless the app already renders `<NuxtRouteAnnouncer />`. Breadcrumbs come from `meta.breadcrumbs`, otherwise from the matching navigation item (plus `meta.title` on deeper pages). At runtime `useDashboard().value = { account, breadcrumbs, badges: { '/items': 12 } }` overrides the account, the breadcrumbs and the badges. Set it in route middleware (`definePageMeta({ middleware })`) or a plugin, not in the page `setup`: the layout renders the sidebar and breadcrumbs before the page, so a value set during the page render would differ between the server HTML and hydration.
827
+ Pages pick them with `definePageMeta({ layout: 'k-dashboard', title: 'Items' })` or `layout: 'k-auth'` (the auth frame shows `title` and `description` from the page meta). Both layouts set the document title from `meta.title` and the brand name (`Items · Acme`; a page's own `useHead({ title })` wins) and announce route changes through a polite live region, unless the app already renders `<NuxtRouteAnnouncer />`. Breadcrumbs come from `meta.breadcrumbs`, otherwise from the matching navigation item (plus `meta.title` on deeper pages). At runtime `useDashboard().value = { account, breadcrumbs, badges: { '/items': 12 } }` overrides the account, the breadcrumbs and the badges. Set it in route middleware (`definePageMeta({ middleware })`) or a plugin, not in the page `setup`: the layout renders the sidebar and breadcrumbs before the page, so a value set during the page render would differ between the server HTML and hydration.
815
828
 
816
829
  ### Starter
817
830
 
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <nav class="k-breadcrumbs" :class="{ 'is-ancestors': ancestors }" :aria-label="navText">
2
+ <nav
3
+ class="k-breadcrumbs"
4
+ :class="[`k-breadcrumbs-${size}`, { 'is-ancestors': ancestors }]"
5
+ :aria-label="navText"
6
+ >
3
7
  <ol role="list" class="k-breadcrumbs-list">
4
8
  <li v-for="(part, index) in parts" :key="index" class="k-breadcrumbs-item">
5
9
  <component
@@ -32,7 +36,8 @@ const props = defineProps({
32
36
  label: { type: String, required: false },
33
37
  separator: { type: null, required: false, default: "chevron-right" },
34
38
  linkLast: { type: Boolean, required: false },
35
- ancestors: { type: Boolean, required: false }
39
+ ancestors: { type: Boolean, required: false },
40
+ size: { type: String, required: false, default: "md" }
36
41
  });
37
42
  defineSlots();
38
43
  const { t } = useLocale();
@@ -1,5 +1,5 @@
1
1
  import type { IconName } from '../../composables/useIcons';
2
- import type { BreadcrumbItem } from './types';
2
+ import type { BreadcrumbItem, BreadcrumbsSize } from './types';
3
3
  type __VLS_Slots = {
4
4
  item?: (props: {
5
5
  item: BreadcrumbItem;
@@ -13,6 +13,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
13
13
  separator?: IconName;
14
14
  linkLast?: boolean;
15
15
  ancestors?: boolean;
16
+ size?: BreadcrumbsSize;
16
17
  innerHTML?: string | undefined | undefined;
17
18
  class?: import("vue").ClassValue;
18
19
  style?: import("vue").StyleValue;
@@ -211,6 +212,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
211
212
  separator?: IconName;
212
213
  linkLast?: boolean;
213
214
  ancestors?: boolean;
215
+ size?: BreadcrumbsSize;
214
216
  innerHTML?: string | undefined | undefined;
215
217
  class?: import("vue").ClassValue;
216
218
  style?: import("vue").StyleValue;
@@ -404,6 +406,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
404
406
  ref_for?: boolean | undefined | undefined;
405
407
  ref_key?: string | undefined | undefined;
406
408
  }> & Readonly<{}>, {
409
+ size: BreadcrumbsSize;
407
410
  separator: IconName;
408
411
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
409
412
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -11,6 +11,7 @@ export interface GridColumns {
11
11
  lg?: number;
12
12
  xl?: number;
13
13
  }
14
+ export type BreadcrumbsSize = 'md' | 'lg';
14
15
  export interface BreadcrumbItem {
15
16
  label: string;
16
17
  to?: LinkTarget;
@@ -1,44 +1,51 @@
1
1
  <template>
2
- <div class="k-auth" :class="`k-auth-${variant}`">
2
+ <div class="k-auth" :class="{ 'has-aside': aside }">
3
3
  <a class="k-auth-skip k-visually-hidden-focusable" :href="`#${mainId}`">{{ skipText }}</a>
4
- <header v-if="themeSwitch || $slots.corner" class="k-auth-corner">
5
- <slot name="corner" />
6
- <ThemeSwitch v-if="themeSwitch" variant="icon" :label="themeLabel" />
7
- </header>
8
- <main :id="mainId" class="k-auth-main" tabindex="-1">
9
- <div class="k-auth-panel">
10
- <header class="k-auth-header">
11
- <slot name="brand">
12
- <Brand
13
- v-if="brandName || brandIcon || brandLogo"
14
- class="k-auth-brand"
15
- :name="brandName"
16
- :icon="brandIcon"
17
- :logo="brandLogo"
18
- :to="brandTo"
19
- size="lg"
20
- hide-text
21
- />
22
- </slot>
23
- <h1 v-if="title || $slots.title" class="k-auth-title">
24
- <slot name="title">{{ title }}</slot>
25
- </h1>
26
- <p v-if="description || $slots.description" class="k-auth-description">
27
- <slot name="description">{{ description }}</slot>
28
- </p>
29
- </header>
30
- <div v-if="$slots.default" class="k-auth-card">
31
- <slot />
4
+ <div class="k-auth-panel">
5
+ <header class="k-auth-top">
6
+ <slot name="brand">
7
+ <Brand
8
+ v-if="brandName || brandIcon || brandLogo"
9
+ class="k-auth-brand"
10
+ :name="brandName"
11
+ :icon="brandIcon"
12
+ :logo="brandLogo"
13
+ :to="brandTo"
14
+ hide-text
15
+ />
16
+ </slot>
17
+ <div v-if="themeSwitch || $slots.corner" class="k-auth-corner">
18
+ <slot name="corner" />
19
+ <ThemeSwitch v-if="themeSwitch" variant="icon" :label="themeLabel" />
32
20
  </div>
33
- <div v-if="$slots.links" class="k-auth-links">
34
- <slot name="links" />
21
+ </header>
22
+ <main :id="mainId" class="k-auth-main" tabindex="-1">
23
+ <div class="k-auth-content">
24
+ <header v-if="hasHeader" class="k-auth-header">
25
+ <template v-if="breadcrumbs?.length">
26
+ <h1 v-if="title" class="k-visually-hidden">{{ title }}</h1>
27
+ <Breadcrumbs class="k-auth-trail" :items="breadcrumbs" size="lg" />
28
+ </template>
29
+ <h1 v-else-if="title || $slots.title" class="k-auth-title">
30
+ <slot name="title">{{ title }}</slot>
31
+ </h1>
32
+ <p v-if="description || $slots.description" class="k-auth-description">
33
+ <slot name="description">{{ description }}</slot>
34
+ </p>
35
+ </header>
36
+ <div v-if="$slots.default" class="k-auth-body">
37
+ <slot />
38
+ </div>
39
+ <div v-if="$slots.links" class="k-auth-links">
40
+ <slot name="links" />
41
+ </div>
35
42
  </div>
36
- <footer v-if="footer || $slots.footer" class="k-auth-footer">
37
- <slot name="footer">{{ footer }}</slot>
38
- </footer>
39
- </div>
40
- </main>
41
- <aside v-if="variant === 'split'" class="k-auth-aside" :aria-label="asideText">
43
+ </main>
44
+ <footer v-if="footer || $slots.footer" class="k-auth-footer">
45
+ <slot name="footer">{{ footer }}</slot>
46
+ </footer>
47
+ </div>
48
+ <aside v-if="aside" class="k-auth-aside" :aria-label="asideText">
42
49
  <slot name="aside">
43
50
  <div class="k-auth-aside-art" aria-hidden="true">
44
51
  <span class="k-auth-aside-orb" />
@@ -63,20 +70,22 @@
63
70
  </template>
64
71
 
65
72
  <script setup>
66
- import { computed, useId } from "vue";
73
+ import { computed, useId, useSlots } from "vue";
67
74
  import { useLocale } from "../../composables/useLocale";
75
+ import Breadcrumbs from "../layout/Breadcrumbs.vue";
68
76
  import ThemeSwitch from "../layout/ThemeSwitch.vue";
69
77
  import Brand from "./Brand.vue";
70
78
  const props = defineProps({
71
- variant: { type: String, required: false, default: "centered" },
72
79
  title: { type: String, required: false },
73
80
  description: { type: String, required: false },
81
+ breadcrumbs: { type: Array, required: false },
74
82
  footer: { type: String, required: false },
75
83
  brandName: { type: String, required: false },
76
84
  brandSubtitle: { type: String, required: false },
77
85
  brandIcon: { type: null, required: false },
78
- brandLogo: { type: String, required: false },
86
+ brandLogo: { type: null, required: false },
79
87
  brandTo: { type: [String, Object], required: false },
88
+ aside: { type: Boolean, required: false, default: true },
80
89
  asideTitle: { type: String, required: false },
81
90
  asideDescription: { type: String, required: false },
82
91
  asideLabel: { type: String, required: false },
@@ -84,8 +93,12 @@ const props = defineProps({
84
93
  themeLabel: { type: String, required: false },
85
94
  skipLabel: { type: String, required: false }
86
95
  });
96
+ const slots = useSlots();
87
97
  const { t } = useLocale();
88
98
  const asideText = computed(() => props.asideLabel ?? t("auth.aside"));
89
99
  const skipText = computed(() => props.skipLabel ?? t("shell.skipToContent"));
100
+ const hasHeader = computed(
101
+ () => !!(props.title || props.breadcrumbs?.length || props.description || slots.title || slots.description)
102
+ );
90
103
  const mainId = useId();
91
104
  </script>
@@ -1,34 +1,32 @@
1
- import type { IconName } from '../../composables/useIcons';
2
- import type { AuthLayoutVariant } from './types';
3
- import type { LinkTarget } from '../core/types';
4
- declare var __VLS_1: {}, __VLS_8: {}, __VLS_15: {}, __VLS_17: {}, __VLS_19: {}, __VLS_21: {}, __VLS_23: {}, __VLS_25: {};
1
+ declare var __VLS_1: {}, __VLS_8: {}, __VLS_20: {}, __VLS_22: {}, __VLS_24: {}, __VLS_26: {}, __VLS_28: {}, __VLS_30: {};
5
2
  type __VLS_Slots = {} & {
6
- corner?: (props: typeof __VLS_1) => any;
3
+ brand?: (props: typeof __VLS_1) => any;
7
4
  } & {
8
- brand?: (props: typeof __VLS_8) => any;
5
+ corner?: (props: typeof __VLS_8) => any;
9
6
  } & {
10
- title?: (props: typeof __VLS_15) => any;
7
+ title?: (props: typeof __VLS_20) => any;
11
8
  } & {
12
- description?: (props: typeof __VLS_17) => any;
9
+ description?: (props: typeof __VLS_22) => any;
13
10
  } & {
14
- default?: (props: typeof __VLS_19) => any;
11
+ default?: (props: typeof __VLS_24) => any;
15
12
  } & {
16
- links?: (props: typeof __VLS_21) => any;
13
+ links?: (props: typeof __VLS_26) => any;
17
14
  } & {
18
- footer?: (props: typeof __VLS_23) => any;
15
+ footer?: (props: typeof __VLS_28) => any;
19
16
  } & {
20
- aside?: (props: typeof __VLS_25) => any;
17
+ aside?: (props: typeof __VLS_30) => any;
21
18
  };
22
19
  declare const __VLS_base: import("vue").DefineComponent<{
23
- variant?: AuthLayoutVariant;
24
20
  title?: string | undefined;
25
21
  description?: string;
22
+ breadcrumbs?: import("../layout/types.ts").BreadcrumbItem[];
26
23
  footer?: string;
27
24
  brandName?: string;
28
25
  brandSubtitle?: string;
29
- brandIcon?: IconName;
30
- brandLogo?: string;
31
- brandTo?: LinkTarget;
26
+ brandIcon?: import("../../index.ts").IconName;
27
+ brandLogo?: import("./types").BrandLogo;
28
+ brandTo?: import("../core/types.ts").LinkTarget;
29
+ aside?: boolean;
32
30
  asideTitle?: string;
33
31
  asideDescription?: string;
34
32
  asideLabel?: string;
@@ -227,15 +225,16 @@ declare const __VLS_base: import("vue").DefineComponent<{
227
225
  ref_for?: boolean | undefined | undefined;
228
226
  ref_key?: string | undefined | undefined;
229
227
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
230
- variant?: AuthLayoutVariant;
231
228
  title?: string | undefined;
232
229
  description?: string;
230
+ breadcrumbs?: import("../layout/types.ts").BreadcrumbItem[];
233
231
  footer?: string;
234
232
  brandName?: string;
235
233
  brandSubtitle?: string;
236
- brandIcon?: IconName;
237
- brandLogo?: string;
238
- brandTo?: LinkTarget;
234
+ brandIcon?: import("../../index.ts").IconName;
235
+ brandLogo?: import("./types").BrandLogo;
236
+ brandTo?: import("../core/types.ts").LinkTarget;
237
+ aside?: boolean;
239
238
  asideTitle?: string;
240
239
  asideDescription?: string;
241
240
  asideLabel?: string;
@@ -434,7 +433,7 @@ declare const __VLS_base: import("vue").DefineComponent<{
434
433
  ref_for?: boolean | undefined | undefined;
435
434
  ref_key?: string | undefined | undefined;
436
435
  }> & Readonly<{}>, {
437
- variant: AuthLayoutVariant;
436
+ aside: boolean;
438
437
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
439
438
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
440
439
  declare const _default: typeof __VLS_export;
@@ -0,0 +1,220 @@
1
+ <template>
2
+ <AuthLayout v-bind="frame" :title="title" :description="description" :breadcrumbs="breadcrumbs">
3
+ <template v-if="$slots.brand" #brand><slot name="brand" /></template>
4
+ <template v-if="$slots.corner" #corner><slot name="corner" /></template>
5
+ <div ref="content" class="k-auth-login">
6
+ <Transition name="k-auth-step" mode="out-in" @after-enter="focusInput">
7
+ <div
8
+ v-if="view === 'signedOut'"
9
+ key="signedOut"
10
+ class="k-auth-login-actions"
11
+ :class="{ 'is-pending': !signedOutReady }"
12
+ >
13
+ <Button size="lg" block trailing-icon="arrow-right" @click="signInAgain">
14
+ {{ t("auth.signInAgain") }}
15
+ </Button>
16
+ <Button
17
+ v-if="account?.email"
18
+ size="lg"
19
+ block
20
+ variant="soft"
21
+ tone="neutral"
22
+ @click="useAnotherAccount"
23
+ >
24
+ {{ t("auth.otherAccount") }}
25
+ </Button>
26
+ </div>
27
+ <Form v-else-if="!passwordStep" key="email" class="k-auth-login-form" :form="emailForm">
28
+ <FormField name="email" :label="emailText" required>
29
+ <Input
30
+ :model-value="emailForm.values.email"
31
+ @update:model-value="emailForm.values.email = String($event ?? '')"
32
+ type="email"
33
+ icon="envelope"
34
+ autocomplete="username"
35
+ :placeholder="emailPlaceholder ?? t('auth.emailPlaceholder')"
36
+ />
37
+ </FormField>
38
+ <Button type="submit" size="lg" block trailing-icon="arrow-right">
39
+ {{ t("auth.continue") }}
40
+ </Button>
41
+ </Form>
42
+ <Form v-else key="password" class="k-auth-login-form" :form="passwordForm">
43
+ <input
44
+ :value="email"
45
+ type="email"
46
+ autocomplete="username"
47
+ class="k-visually-hidden"
48
+ tabindex="-1"
49
+ aria-hidden="true"
50
+ readonly
51
+ />
52
+ <FormField name="password" :label="passwordText" required>
53
+ <PasswordInput
54
+ :model-value="passwordForm.values.password"
55
+ @update:model-value="passwordForm.values.password = $event ?? ''"
56
+ icon="key"
57
+ autocomplete="current-password"
58
+ />
59
+ </FormField>
60
+ <Button
61
+ type="submit"
62
+ size="lg"
63
+ block
64
+ trailing-icon="arrow-right"
65
+ :loading="passwordForm.submitting.value"
66
+ >
67
+ {{ submitText }}
68
+ </Button>
69
+ </Form>
70
+ </Transition>
71
+ </div>
72
+ <template v-if="$slots.links && view === 'login'" #links>
73
+ <slot name="links" :email="email" :step="passwordStep ? 'password' : 'email'" />
74
+ </template>
75
+ <template v-if="$slots.footer" #footer><slot name="footer" /></template>
76
+ <template v-if="$slots.aside" #aside><slot name="aside" /></template>
77
+ </AuthLayout>
78
+ </template>
79
+
80
+ <script setup>
81
+ import { computed, onMounted, ref, watch } from "vue";
82
+ import { useForm } from "../../composables/useForm";
83
+ import { useLocale } from "../../composables/useLocale";
84
+ import { useRouteState } from "../../composables/useRouteState";
85
+ import { useRouterLike } from "../../internal/layout/route";
86
+ import Button from "../core/Button.vue";
87
+ import Form from "../core/Form.vue";
88
+ import FormField from "../core/FormField.vue";
89
+ import Input from "../core/Input.vue";
90
+ import PasswordInput from "../forms/PasswordInput.vue";
91
+ import AuthLayout from "./AuthLayout.vue";
92
+ import { SIGNED_OUT_REASON, takeSignedOutAccount } from "./auth";
93
+ const props = defineProps({
94
+ title: { type: String, required: false },
95
+ description: { type: String, required: false },
96
+ footer: { type: String, required: false },
97
+ brandName: { type: String, required: false },
98
+ brandSubtitle: { type: String, required: false },
99
+ brandIcon: { type: null, required: false },
100
+ brandLogo: { type: null, required: false },
101
+ brandTo: { type: [String, Object], required: false },
102
+ aside: { type: Boolean, required: false, default: true },
103
+ asideTitle: { type: String, required: false },
104
+ asideDescription: { type: String, required: false },
105
+ asideLabel: { type: String, required: false },
106
+ themeSwitch: { type: Boolean, required: false },
107
+ themeLabel: { type: String, required: false },
108
+ skipLabel: { type: String, required: false },
109
+ submit: { type: Function, required: true },
110
+ submitError: { type: Function, required: false },
111
+ emailLabel: { type: String, required: false },
112
+ emailPlaceholder: { type: String, required: false },
113
+ passwordLabel: { type: String, required: false },
114
+ submitLabel: { type: String, required: false },
115
+ stepKey: { type: String, required: false, default: "step" },
116
+ reasonKey: { type: String, required: false, default: "reason" }
117
+ });
118
+ defineSlots();
119
+ const { t } = useLocale();
120
+ const router = useRouterLike();
121
+ const step = useRouteState(props.stepKey, { location: "query" });
122
+ const reason = useRouteState(props.reasonKey, { location: "query", history: "replace" });
123
+ const stepReplace = useRouteState(props.stepKey, { location: "query", history: "replace" });
124
+ const view = ref(reason.value === SIGNED_OUT_REASON ? "signedOut" : "login");
125
+ const email = ref("");
126
+ const account = ref(null);
127
+ const signedOutReady = ref(false);
128
+ const content = ref();
129
+ const emailText = computed(() => props.emailLabel ?? t("auth.email"));
130
+ const passwordText = computed(() => props.passwordLabel ?? t("auth.password"));
131
+ const submitText = computed(() => props.submitLabel ?? t("auth.signIn"));
132
+ const frame = computed(() => ({
133
+ footer: props.footer,
134
+ brandName: props.brandName,
135
+ brandSubtitle: props.brandSubtitle,
136
+ brandIcon: props.brandIcon,
137
+ brandLogo: props.brandLogo,
138
+ brandTo: props.brandTo,
139
+ aside: props.aside,
140
+ asideTitle: props.asideTitle,
141
+ asideDescription: props.asideDescription,
142
+ asideLabel: props.asideLabel,
143
+ themeSwitch: props.themeSwitch,
144
+ themeLabel: props.themeLabel,
145
+ skipLabel: props.skipLabel
146
+ }));
147
+ const passwordStep = computed(
148
+ () => view.value === "login" && step.value === "password" && !!email.value
149
+ );
150
+ const title = computed(() => {
151
+ if (view.value === "login") return props.title ?? t("auth.loginTitle");
152
+ const name = account.value?.name;
153
+ return name ? t("auth.signedOutTitleNamed", { name }) : t("auth.signedOutTitle");
154
+ });
155
+ const description = computed(() => {
156
+ if (view.value === "login") return props.description;
157
+ const signedOutEmail = account.value?.email;
158
+ return signedOutEmail ? t("auth.signedOutDescriptionEmail", { email: signedOutEmail }) : t("auth.signedOutDescription");
159
+ });
160
+ const knownName = computed(
161
+ () => account.value?.email === email.value ? account.value?.name : void 0
162
+ );
163
+ const breadcrumbs = computed(
164
+ () => passwordStep.value ? [{ label: title.value, onClick: backToEmail }, { label: knownName.value || email.value }] : void 0
165
+ );
166
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
167
+ const emailForm = useForm({
168
+ schema: {
169
+ email: {
170
+ initial: "",
171
+ required: true,
172
+ validate: (value) => EMAIL_PATTERN.test(normalizeEmail(value)) ? void 0 : t("auth.emailInvalid")
173
+ }
174
+ },
175
+ onSubmit: (values) => openPasswordStep(normalizeEmail(values.email))
176
+ });
177
+ const passwordForm = useForm({
178
+ schema: { password: { initial: "", required: true } },
179
+ onSubmit: (values) => props.submit({ email: email.value, password: values.password }),
180
+ submitError: props.submitError
181
+ });
182
+ function normalizeEmail(value) {
183
+ return value.replace(/\s+/g, "").toLowerCase();
184
+ }
185
+ function openPasswordStep(value) {
186
+ email.value = value;
187
+ emailForm.values.email = value;
188
+ passwordForm.reset();
189
+ step.value = "password";
190
+ }
191
+ function backToEmail() {
192
+ if (router?.back) router.back();
193
+ else step.value = void 0;
194
+ }
195
+ function signInAgain() {
196
+ view.value = "login";
197
+ if (account.value?.email) openPasswordStep(account.value.email);
198
+ }
199
+ function useAnotherAccount() {
200
+ account.value = null;
201
+ email.value = "";
202
+ emailForm.reset();
203
+ view.value = "login";
204
+ }
205
+ function focusInput() {
206
+ content.value?.querySelector("input:not([readonly])")?.focus();
207
+ }
208
+ watch(step, (value) => {
209
+ if (value !== "password") passwordForm.reset();
210
+ });
211
+ onMounted(() => {
212
+ if (view.value === "signedOut") {
213
+ account.value = takeSignedOutAccount();
214
+ signedOutReady.value = true;
215
+ }
216
+ if (reason.value) reason.value = void 0;
217
+ if (step.value && !email.value) stepReplace.value = void 0;
218
+ focusInput();
219
+ });
220
+ </script>