@thekestongroup/ui 0.4.0 → 0.6.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 (38) hide show
  1. package/dist/components/AppShell/AppShell.vue.d.ts +4 -2
  2. package/dist/components/FormField/FormField.vue.d.ts +5 -0
  3. package/dist/components/Header/Header.vue.d.ts +9 -1
  4. package/dist/components/Input/Input.vue.d.ts +2 -0
  5. package/dist/components/InputDate/InputDate.vue.d.ts +2 -0
  6. package/dist/components/InputNumber/InputNumber.vue.d.ts +2 -0
  7. package/dist/components/InputPassword/InputPassword.vue.d.ts +2 -0
  8. package/dist/components/InputRichText/InputRichText.vue.d.ts +2 -0
  9. package/dist/components/Menu/Menu.vue.d.ts +38 -0
  10. package/dist/components/PageHeader/PageHeader.vue.d.ts +23 -1
  11. package/dist/components/Select/Select.vue.d.ts +2 -0
  12. package/dist/components/Sidebar/Sidebar.vue.d.ts +1 -1
  13. package/dist/components/Table/Table.vue.d.ts +14 -1
  14. package/dist/components/Tabs/Tabs.vue.d.ts +42 -0
  15. package/dist/index.d.ts +5 -1
  16. package/dist/keston-ui.js +817 -589
  17. package/package.json +1 -1
  18. package/src/components/AppShell/AppShell.stories.ts +5 -0
  19. package/src/components/AppShell/AppShell.vue +6 -2
  20. package/src/components/FormField/FormField.vue +7 -2
  21. package/src/components/Header/Header.stories.ts +9 -0
  22. package/src/components/Header/Header.vue +27 -4
  23. package/src/components/Input/Input.stories.ts +21 -0
  24. package/src/components/Input/Input.vue +3 -0
  25. package/src/components/InputDate/InputDate.vue +3 -0
  26. package/src/components/InputNumber/InputNumber.vue +3 -0
  27. package/src/components/InputPassword/InputPassword.vue +3 -0
  28. package/src/components/InputRichText/InputRichText.vue +3 -0
  29. package/src/components/Menu/Menu.stories.ts +40 -0
  30. package/src/components/Menu/Menu.vue +104 -0
  31. package/src/components/PageHeader/PageHeader.stories.ts +33 -1
  32. package/src/components/PageHeader/PageHeader.vue +52 -1
  33. package/src/components/Select/Select.vue +3 -0
  34. package/src/components/Table/Table.stories.ts +59 -1
  35. package/src/components/Table/Table.vue +57 -4
  36. package/src/components/Tabs/Tabs.stories.ts +47 -0
  37. package/src/components/Tabs/Tabs.vue +69 -0
  38. package/src/index.ts +5 -1
@@ -28,6 +28,8 @@ import { SidebarItem, SidebarProps } from '../Sidebar/Sidebar.vue';
28
28
  export interface AppShellProps {
29
29
  /** Name of the app, shown in the header and as the mobile menu's title. */
30
30
  title?: string;
31
+ /** Make the header's title a link, e.g. to the app's dashboard (`to` for `linkComponent`, or an href). */
32
+ titleTo?: unknown;
31
33
  /** The signed-in user, for the account menu. Without it, Sign in is shown. */
32
34
  user?: HeaderUser;
33
35
  /** Which actions the account menu offers. Default all three. */
@@ -40,10 +42,10 @@ export interface AppShellProps {
40
42
  sections?: SidebarProps['sections'];
41
43
  /** Wide screens: show the header's menu button, which collapses the sidebar to icons. */
42
44
  collapsible?: boolean;
43
- /** Component used for sidebar items with `to`, e.g. RouterLink. */
45
+ /** Component used for sidebar items with `to`, and the title link, e.g. RouterLink. */
44
46
  linkComponent?: SidebarProps['linkComponent'];
45
47
  /** Other Header props, e.g. `{ ui: { title: '…' } }`. */
46
- header?: Omit<HeaderProps, 'title' | 'menu' | 'menuOpen' | 'sticky' | 'user' | 'userActions' | 'signIn'>;
48
+ header?: Omit<HeaderProps, 'title' | 'titleTo' | 'linkComponent' | 'menu' | 'menuOpen' | 'sticky' | 'user' | 'userActions' | 'signIn'>;
47
49
  /** Other Sidebar props, e.g. `{ label: 'Admissions' }`. */
48
50
  sidebar?: Omit<SidebarProps, 'items' | 'sections' | 'collapsible' | 'linkComponent'>;
49
51
  class?: HTMLAttributes['class'];
@@ -16,6 +16,11 @@ export interface FormFieldProps {
16
16
  helper?: string;
17
17
  /** Show helper text under the label, or behind a `?` icon next to it. */
18
18
  helperPlacement?: 'below' | 'icon';
19
+ /**
20
+ * Keep the label (and helper) for screen readers only, e.g. in a table of
21
+ * fields where the column headings say what each one is.
22
+ */
23
+ hideLabel?: boolean;
19
24
  /**
20
25
  * Error message, e.g. from a Zod / VeeValidate schema. When set (and not
21
26
  * empty) the field shows as an error with this text; leave it undefined
@@ -1,4 +1,4 @@
1
- import { HTMLAttributes } from 'vue';
1
+ import { Component, HTMLAttributes } from 'vue';
2
2
  export interface HeaderUser {
3
3
  name: string;
4
4
  email?: string;
@@ -24,6 +24,13 @@ export type HeaderUserAction = 'account-settings' | 'switch-account' | 'log-out'
24
24
  export interface HeaderProps {
25
25
  /** Name of the app or area, shown next to the menu button. */
26
26
  title?: string;
27
+ /**
28
+ * Make the title a link, e.g. to the app's dashboard: passed as `to` to
29
+ * `linkComponent` (e.g. a route), or as `href` without one.
30
+ */
31
+ titleTo?: unknown;
32
+ /** Component for the title link, e.g. RouterLink. It receives `to`. Default a plain `<a href>`. */
33
+ linkComponent?: string | Component;
27
34
  /**
28
35
  * Show the menu button, which emits `menu` when pressed. Hide it on wide
29
36
  * screens with `ui.menu`, e.g. `{ menu: 'lg:hidden' }`.
@@ -89,6 +96,7 @@ declare const __VLS_base: import('vue').DefineComponent<HeaderProps, {}, {}, {},
89
96
  }>, {
90
97
  menu: boolean;
91
98
  sticky: boolean;
99
+ linkComponent: string | Component;
92
100
  menuOpen: boolean;
93
101
  menuLabel: string;
94
102
  userActions: HeaderUserAction[];
@@ -8,6 +8,8 @@ export interface InputProps {
8
8
  helper?: string;
9
9
  /** Show helper text under the label, or behind a `?` icon next to it. */
10
10
  helperPlacement?: 'below' | 'icon';
11
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
12
+ hideLabel?: boolean;
11
13
  /**
12
14
  * Error message, e.g. from a Zod / VeeValidate schema. When set (and not
13
15
  * empty) the field shows as an error with this text; leave it undefined
@@ -8,6 +8,8 @@ export interface InputDateProps {
8
8
  helper?: string;
9
9
  /** Show helper text under the label, or behind a `?` icon next to it. */
10
10
  helperPlacement?: 'below' | 'icon';
11
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
12
+ hideLabel?: boolean;
11
13
  /** Error message, e.g. from a Zod schema. Overrides `status` / `statusText`. */
12
14
  errorText?: string;
13
15
  /** Colours the field and the status text. */
@@ -7,6 +7,8 @@ export interface InputNumberProps {
7
7
  helper?: string;
8
8
  /** Show helper text under the label, or behind a `?` icon next to it. */
9
9
  helperPlacement?: 'below' | 'icon';
10
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
11
+ hideLabel?: boolean;
10
12
  /** Error message, e.g. from a Zod schema. Overrides `status` / `statusText`. */
11
13
  errorText?: string;
12
14
  /** Colours the field and the status text. */
@@ -8,6 +8,8 @@ export interface InputPasswordProps {
8
8
  helper?: string;
9
9
  /** Show helper text under the label, or behind a `?` icon next to it. */
10
10
  helperPlacement?: 'below' | 'icon';
11
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
12
+ hideLabel?: boolean;
11
13
  /**
12
14
  * Error message, e.g. from a Zod / VeeValidate schema or "Incorrect
13
15
  * password". When set (and not empty) the field shows as an error with this
@@ -16,6 +16,8 @@ export interface InputRichTextProps {
16
16
  helper?: string;
17
17
  /** Show helper text under the label, or behind a `?` icon next to it. */
18
18
  helperPlacement?: 'below' | 'icon';
19
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
20
+ hideLabel?: boolean;
19
21
  /** Error message, e.g. from a Zod schema. Overrides `status` / `statusText`. */
20
22
  errorText?: string;
21
23
  /** Colours the field and the status text, e.g. 'loading' while it saves. */
@@ -0,0 +1,38 @@
1
+ import { Component, HTMLAttributes } from 'vue';
2
+ export interface MenuItem {
3
+ label: string;
4
+ /** A Lucide (or any) icon component, shown before the label. */
5
+ icon?: Component;
6
+ /** Called when it's chosen (click, Enter or Space). */
7
+ onSelect?: () => void;
8
+ /** Link with a plain <a href>. */
9
+ href?: string;
10
+ /** Link through `linkComponent` (e.g. RouterLink), which receives `to`. */
11
+ to?: unknown;
12
+ disabled?: boolean;
13
+ }
14
+ /**
15
+ * More actions behind a "⋯" button, e.g. on each row of a table: Open,
16
+ * Reset password, Delete… Built on Reka UI's DropdownMenu, so it's a proper
17
+ * menu: arrow keys move between items, typing jumps to one, Escape closes
18
+ * it and focus goes back to the button.
19
+ *
20
+ * Items run `onSelect`, or are links (`href`, or `to` through
21
+ * `linkComponent`).
22
+ */
23
+ export interface MenuProps {
24
+ items: MenuItem[];
25
+ /** The button's accessible name, e.g. "Actions for Jo Bloggs". It has no visible text. */
26
+ label: string;
27
+ /** The button's size; `sm` in compact tables. */
28
+ size?: 'sm' | 'md';
29
+ /** Component used for items with `to`, e.g. RouterLink or NuxtLink. */
30
+ linkComponent?: string | Component;
31
+ class?: HTMLAttributes['class'];
32
+ }
33
+ declare const __VLS_export: import('vue').DefineComponent<MenuProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MenuProps> & Readonly<{}>, {
34
+ size: "sm" | "md";
35
+ linkComponent: string | Component;
36
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
37
+ declare const _default: typeof __VLS_export;
38
+ export default _default;
@@ -1,10 +1,27 @@
1
1
  import { Component, HTMLAttributes } from 'vue';
2
2
  import { BreadcrumbItem } from '../Breadcrumb/Breadcrumb.vue';
3
+ /** One of the page's everyday actions, in the toolbar under the title. */
4
+ export interface PageHeaderAction {
5
+ label: string;
6
+ icon?: Component;
7
+ /** Runs on click, e.g. opens a Slideover. */
8
+ onSelect?: () => void;
9
+ /** Link with a plain <a href>. */
10
+ href?: string;
11
+ /** Link through `linkComponent` (e.g. RouterLink), which receives `to`. */
12
+ to?: unknown;
13
+ disabled?: boolean;
14
+ }
3
15
  /**
4
16
  * The top of a page: where it is (breadcrumb), what it is (the h1 title, with
5
17
  * an optional status badge and description), and its main actions on the
6
18
  * right. Actions wrap under the title on narrow screens.
7
19
  *
20
+ * `toolbar`: the everyday things people do to what the page is about (e.g.
21
+ * on a user: Reset password, Unblock sign-in, Delete user), as a row of quiet
22
+ * buttons under the title. Keep the one main action (Save, Add…) in the
23
+ * actions slot on the right; the toolbar is for the rest.
24
+ *
8
25
  * Slots: badge (after the title, e.g. a Badge), description (instead of the
9
26
  * prop, for links or formatting), actions (e.g. Buttons), default (anything
10
27
  * under, e.g. an alert or tabs).
@@ -18,12 +35,15 @@ export interface PageHeaderProps {
18
35
  breadcrumb?: BreadcrumbItem[];
19
36
  /** Component used for breadcrumb steps with `to`, e.g. RouterLink. */
20
37
  linkComponent?: string | Component;
38
+ /** Everyday actions, in a row under the title. */
39
+ toolbar?: PageHeaderAction[];
21
40
  class?: HTMLAttributes['class'];
22
41
  /** Extra classes for the parts. */
23
42
  ui?: {
24
43
  title?: HTMLAttributes['class'];
25
44
  description?: HTMLAttributes['class'];
26
45
  actions?: HTMLAttributes['class'];
46
+ toolbar?: HTMLAttributes['class'];
27
47
  };
28
48
  }
29
49
  type __VLS_Slots = {
@@ -32,7 +52,9 @@ type __VLS_Slots = {
32
52
  actions?(): unknown;
33
53
  default?(): unknown;
34
54
  };
35
- declare const __VLS_base: import('vue').DefineComponent<PageHeaderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PageHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
55
+ declare const __VLS_base: import('vue').DefineComponent<PageHeaderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<PageHeaderProps> & Readonly<{}>, {
56
+ linkComponent: string | Component;
57
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
36
58
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
37
59
  declare const _default: typeof __VLS_export;
38
60
  export default _default;
@@ -68,6 +68,8 @@ export interface SelectProps {
68
68
  helper?: string;
69
69
  /** Show helper text under the label, or behind a `?` icon next to it. */
70
70
  helperPlacement?: 'below' | 'icon';
71
+ /** Keep the label for screen readers only, e.g. in a table of fields with column headings. */
72
+ hideLabel?: boolean;
71
73
  /** Error message, e.g. from a Zod schema. Overrides `status` / `statusText`. */
72
74
  errorText?: string;
73
75
  /** Colours the field and the status text. */
@@ -91,10 +91,10 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {
91
91
  "onUpdate:collapsed"?: ((value: boolean) => any) | undefined;
92
92
  }>, {
93
93
  label: string;
94
+ linkComponent: string | Component;
94
95
  items: SidebarItem[];
95
96
  sections: SidebarSection[];
96
97
  collapsible: boolean;
97
- linkComponent: string | Component;
98
98
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
99
99
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
100
100
  declare const _default: typeof __VLS_export;
@@ -1,4 +1,4 @@
1
- import { HTMLAttributes } from 'vue';
1
+ import { Component, HTMLAttributes } from 'vue';
2
2
  import { TableColumn, TableSort } from './table';
3
3
  /**
4
4
  * Rows of data with column headings: applicants, classes, invoices.
@@ -13,6 +13,11 @@ import { TableColumn, TableSort } from './table';
13
13
  * `manualSort` it only reports the sort (`v-model:sort`) so you can sort on
14
14
  * the server.
15
15
  *
16
+ * Clickable rows: `rowLink` gives each row a page to go to. The row-header
17
+ * cell (or the first column) becomes a real link, stretched over the whole
18
+ * row, so the row highlights on hover and a click anywhere on it follows the
19
+ * link. Buttons and links in other cells still work on their own.
20
+ *
16
21
  * Slots: cell-{key}, header-{key}, empty, footer (rows for a `<tfoot>`,
17
22
  * e.g. totals), caption.
18
23
  */
@@ -37,6 +42,14 @@ export interface TableProps<Row = Record<string, any>> {
37
42
  stickyHeader?: boolean;
38
43
  /** Don't sort the rows: just update `sort`, e.g. to sort on the server. */
39
44
  manualSort?: boolean;
45
+ /**
46
+ * Where each row goes when clicked: passed as `to` to `linkComponent`
47
+ * (e.g. a route), or as `href` without one. Return undefined for rows that
48
+ * don't go anywhere.
49
+ */
50
+ rowLink?: (row: Row, index: number) => unknown;
51
+ /** Component for row links, e.g. RouterLink. It receives `to`. Default a plain `<a href>`. */
52
+ linkComponent?: string | Component;
40
53
  class?: HTMLAttributes['class'];
41
54
  ui?: {
42
55
  table?: HTMLAttributes['class'];
@@ -0,0 +1,42 @@
1
+ import { Component, HTMLAttributes } from 'vue';
2
+ export interface Tab {
3
+ /** Identifies the tab: v-model's value, and the name of its content slot. */
4
+ value: string;
5
+ label: string;
6
+ /** A Lucide (or any) icon component, shown before the label. */
7
+ icon?: Component;
8
+ disabled?: boolean;
9
+ }
10
+ /**
11
+ * Sections of one page, one shown at a time, e.g. a user's Account and
12
+ * Licences & Apps. Built on Reka UI's Tabs: a tab list (arrow keys move
13
+ * between tabs, Home / End jump), each tab's content in a slot named after
14
+ * its value. Use v-model to know or set the open tab (e.g. to keep it in
15
+ * the URL).
16
+ */
17
+ export interface TabsProps {
18
+ tabs: Tab[];
19
+ /** The tab list's accessible name, e.g. "User details". */
20
+ label: string;
21
+ class?: HTMLAttributes['class'];
22
+ }
23
+ type __VLS_Props = TabsProps;
24
+ type __VLS_Slots = Record<string, () => unknown>;
25
+ type __VLS_ModelProps = {
26
+ /** The open tab's value. Defaults to the first tab. */
27
+ modelValue?: string;
28
+ };
29
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
30
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
31
+ "update:modelValue": (value: string | undefined) => any;
32
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
33
+ "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
34
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
35
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
+ declare const _default: typeof __VLS_export;
37
+ export default _default;
38
+ type __VLS_WithSlots<T, S> = T & {
39
+ new (): {
40
+ $slots: S;
41
+ };
42
+ };
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export type { AppShellProps } from './components/AppShell/AppShell.vue';
4
4
  export { default as Header } from './components/Header/Header.vue';
5
5
  export type { HeaderProps, HeaderUser, HeaderUserAction } from './components/Header/Header.vue';
6
6
  export { default as PageHeader } from './components/PageHeader/PageHeader.vue';
7
- export type { PageHeaderProps } from './components/PageHeader/PageHeader.vue';
7
+ export type { PageHeaderAction, PageHeaderProps } from './components/PageHeader/PageHeader.vue';
8
8
  export { default as Avatar } from './components/Avatar/Avatar.vue';
9
9
  export type { AvatarProps, AvatarUser } from './components/Avatar/Avatar.vue';
10
10
  export { default as AvatarGroup } from './components/AvatarGroup/AvatarGroup.vue';
@@ -72,6 +72,10 @@ export { default as Link } from './components/Link/Link.vue';
72
72
  export type { LinkProps } from './components/Link/Link.vue';
73
73
  export { default as Popover } from './components/Popover/Popover.vue';
74
74
  export type { PopoverProps } from './components/Popover/Popover.vue';
75
+ export { default as Menu } from './components/Menu/Menu.vue';
76
+ export type { MenuItem, MenuProps } from './components/Menu/Menu.vue';
77
+ export { default as Tabs } from './components/Tabs/Tabs.vue';
78
+ export type { Tab, TabsProps } from './components/Tabs/Tabs.vue';
75
79
  export { default as Slideover } from './components/Slideover/Slideover.vue';
76
80
  export type { SlideoverProps } from './components/Slideover/Slideover.vue';
77
81
  export { default as Tooltip } from './components/Tooltip/Tooltip.vue';