@thekestongroup/ui 0.9.2 → 0.11.1

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 (28) hide show
  1. package/README.md +8 -12
  2. package/dist/components/AppShell/AppShell.vue.d.ts +4 -1
  3. package/dist/components/CardSelect/CardSelect.vue.d.ts +59 -0
  4. package/dist/components/ChangeIndicator/ChangeIndicator.vue.d.ts +20 -0
  5. package/dist/components/ChangeIndicator/changeIndicator.d.ts +5 -0
  6. package/dist/components/Header/Header.vue.d.ts +6 -1
  7. package/dist/components/StatTile/StatTile.vue.d.ts +10 -1
  8. package/dist/components/UnsavedChangesBar/UnsavedChangesBar.vue.d.ts +46 -0
  9. package/dist/i18n/en.d.ts +8 -0
  10. package/dist/index.d.ts +6 -0
  11. package/dist/keston-ui.js +698 -441
  12. package/package.json +1 -1
  13. package/src/components/AppShell/AppShell.vue +3 -1
  14. package/src/components/CardSelect/CardSelect.stories.ts +88 -0
  15. package/src/components/CardSelect/CardSelect.vue +151 -0
  16. package/src/components/ChangeIndicator/ChangeIndicator.stories.ts +32 -0
  17. package/src/components/ChangeIndicator/ChangeIndicator.vue +42 -0
  18. package/src/components/ChangeIndicator/changeIndicator.test.ts +21 -0
  19. package/src/components/ChangeIndicator/changeIndicator.ts +11 -0
  20. package/src/components/Header/Header.stories.ts +29 -0
  21. package/src/components/Header/Header.vue +14 -9
  22. package/src/components/StatTile/StatTile.stories.ts +10 -1
  23. package/src/components/StatTile/StatTile.vue +43 -6
  24. package/src/components/UnsavedChangesBar/UnsavedChangesBar.stories.ts +62 -0
  25. package/src/components/UnsavedChangesBar/UnsavedChangesBar.vue +87 -0
  26. package/src/i18n/en.ts +6 -0
  27. package/src/i18n/i18n.test.ts +10 -0
  28. package/src/index.ts +6 -0
package/README.md CHANGED
@@ -112,19 +112,15 @@ prop, component or token).
112
112
 
113
113
  1. With each change, run `pnpm changeset` and commit the file it creates.
114
114
  Merging only collects changes: nothing is released yet.
115
- 2. When you want a release, run the **Release** workflow: Actions → Release →
116
- Run workflow, or:
117
-
118
- ```sh
119
- gh workflow run release.yml -R thekestongroup/ui
120
- ```
121
-
122
- It tests and builds, works out the version from the changesets waiting,
123
- updates `package.json` and `CHANGELOG.md`, commits and tags that on
124
- `main`, and creates a GitHub Release. Then it starts the **Publish**
115
+ 2. The **Release PR** workflow keeps a "Release vX" pull request up to date
116
+ with every changeset waiting on `main`: the new version in `package.json`
117
+ and the entry in `CHANGELOG.md`. It only proposes the release. You can also
118
+ run it by hand: Actions → Release PR → Run workflow.
119
+ 3. When you want a release, merge that pull request. The **Tag release**
120
+ workflow then tags it, creates a GitHub Release and starts the **Publish**
125
121
  workflow, which stages the release on npm (trusted publishing, no token
126
- needed). With no changesets waiting, it stops without releasing.
127
- 3. Approve the staged release on npmjs.com to make it live.
122
+ needed).
123
+ 4. Approve the staged release on npmjs.com to make it live.
128
124
 
129
125
  If staging on npm fails, run **Publish** again by hand on the release's tag
130
126
  (e.g. `v0.4.0`); it skips a version that's already on npm.
@@ -21,7 +21,7 @@ import { SidebarItem, SidebarProps } from '../Sidebar/Sidebar.vue';
21
21
  * account-settings, switch-account, log-out (and sign-in when signed out).
22
22
  *
23
23
  * Slots: default (the page), header-leading, header-middle, header-trailing,
24
- * account, account-menu (passed to Header), sidebar-header and sidebar-footer (passed to Sidebar;
24
+ * account, account-menu and organisation (passed to Header), sidebar-header and sidebar-footer (passed to Sidebar;
25
25
  * sidebar-header is only shown on wide screens, as the Slideover has its own
26
26
  * title).
27
27
  */
@@ -64,6 +64,9 @@ type __VLS_Slots = {
64
64
  'account-menu'?(props: {
65
65
  close: () => void;
66
66
  }): unknown;
67
+ organisation?(props: {
68
+ close: () => void;
69
+ }): unknown;
67
70
  'sidebar-header'?(props: {
68
71
  collapsed: boolean;
69
72
  }): unknown;
@@ -0,0 +1,59 @@
1
+ import { Component, HTMLAttributes } from 'vue';
2
+ /**
3
+ * One choice from a few, shown as side-by-side cards, e.g. a preset ("Baseline",
4
+ * "Recommended", "Strict", "Custom"). Behaves as a radio group: Tab moves into
5
+ * it, the arrow keys move and choose. Choosing never moves anything: every
6
+ * card keeps the same size, border width and padding whether chosen or not,
7
+ * and the space for the round indicator is always reserved.
8
+ *
9
+ * For a plain list of options with small text, use RadioGroup.
10
+ */
11
+ export type CardSelectValue = string | number;
12
+ export interface CardSelectOption {
13
+ /** The card's heading, e.g. "Recommended". */
14
+ title: string;
15
+ value: CardSelectValue;
16
+ /** A line or two under the title. */
17
+ description?: string;
18
+ /** A Lucide icon (or any component) shown before the title. */
19
+ icon?: Component;
20
+ disabled?: boolean;
21
+ }
22
+ export interface CardSelectProps {
23
+ /** The question. Also the group's accessible name. */
24
+ label: string;
25
+ options: CardSelectOption[];
26
+ /** Visually hide the label (it stays the accessible name). */
27
+ hideLabel?: boolean;
28
+ /** Extra guidance about the choice. */
29
+ helper?: string;
30
+ /** Show helper text under the label, or behind a `?` icon next to it. */
31
+ helperPlacement?: 'below' | 'icon';
32
+ /** Error message. */
33
+ errorText?: string;
34
+ /**
35
+ * Cards per row on wide screens (1–4). Always one or two per row on
36
+ * narrow screens. By default as many as fit, at least 10rem each.
37
+ */
38
+ columns?: 1 | 2 | 3 | 4;
39
+ /** Name for native form submission. */
40
+ name?: string;
41
+ required?: boolean;
42
+ disabled?: boolean;
43
+ class?: HTMLAttributes['class'];
44
+ }
45
+ type __VLS_Props = CardSelectProps;
46
+ type __VLS_ModelProps = {
47
+ /** The chosen card's value; undefined until one is chosen. */
48
+ modelValue?: CardSelectValue | undefined;
49
+ };
50
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
51
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
52
+ "update:modelValue": (value: CardSelectValue | undefined) => any;
53
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
54
+ "onUpdate:modelValue"?: ((value: CardSelectValue | undefined) => any) | undefined;
55
+ }>, {
56
+ helperPlacement: "below" | "icon";
57
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
58
+ declare const _default: typeof __VLS_export;
59
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import { HTMLAttributes } from 'vue';
2
+ import { ChangeValue } from './changeIndicator';
3
+ /**
4
+ * Shows that a setting has been edited and not yet saved, as old value → new
5
+ * value, e.g. `15 → 5` or `3 → 5 phrases`. Put it next to the setting's label.
6
+ * It renders nothing when `from` and `to` are the same, so it can sit in the
7
+ * template permanently and appear only while the setting is edited.
8
+ */
9
+ export interface ChangeIndicatorProps {
10
+ /** The saved value. */
11
+ from: ChangeValue;
12
+ /** The edited value. */
13
+ to: ChangeValue;
14
+ /** Unit shown after the new value only, e.g. "phrases". */
15
+ unit?: string;
16
+ class?: HTMLAttributes['class'];
17
+ }
18
+ declare const __VLS_export: import('vue').DefineComponent<ChangeIndicatorProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ChangeIndicatorProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
@@ -0,0 +1,5 @@
1
+ export type ChangeValue = string | number;
2
+ /** A value with its unit, e.g. "5 phrases"; just the value when there is no unit. */
3
+ export declare function withUnit(value: ChangeValue, unit?: string): string;
4
+ /** True when there is something to show: the value really changed. */
5
+ export declare function hasChanged(from: ChangeValue, to: ChangeValue): boolean;
@@ -19,7 +19,9 @@ export type HeaderUserAction = 'account-settings' | 'switch-account' | 'log-out'
19
19
  * fills the space between title and trailing), trailing (actions before the
20
20
  * account menu), account (replaces the account menu, or the Sign in button),
21
21
  * account-menu (extra content in the account menu, above Switch account /
22
- * Log out: `{ close }`).
22
+ * Log out: `{ close }`), organisation (replaces the organisation heading at the
23
+ * very top of the account menu, e.g. with a row that switches organisation:
24
+ * `{ close }`).
23
25
  */
24
26
  export interface HeaderProps {
25
27
  /** Name of the app or area, shown next to the menu button. */
@@ -80,6 +82,9 @@ type __VLS_Slots = {
80
82
  'account-menu'?(props: {
81
83
  close: () => void;
82
84
  }): unknown;
85
+ organisation?(props: {
86
+ close: () => void;
87
+ }): unknown;
83
88
  };
84
89
  declare const __VLS_base: import('vue').DefineComponent<HeaderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
85
90
  menu: () => any;
@@ -1,11 +1,16 @@
1
1
  import { Component, HTMLAttributes } from 'vue';
2
+ import { PrimitiveProps } from 'reka-ui';
2
3
  /**
3
4
  * One number that matters, in a small Card: "Open applications 48".
4
5
  * Put several in a grid. Optionally with how it's changed ("+12% on last
5
6
  * year") and a short description.
6
7
  *
8
+ * Give it an `href` (or `as`, e.g. a router link, with its own `to`) and the
9
+ * whole tile becomes one link: an arrow in the corner shows it's clickable,
10
+ * and it darkens its border on hover and its background when pressed.
11
+ *
7
12
  * Slots: value (e.g. a value with a unit in smaller text), description,
8
- * footer (e.g. a "View all" link).
13
+ * footer (e.g. a "View all" link; not in a tile that is itself a link).
9
14
  */
10
15
  export interface StatTileProps {
11
16
  /** What the number is, e.g. "Open applications". */
@@ -28,6 +33,10 @@ export interface StatTileProps {
28
33
  sentiment?: 'positive' | 'negative' | 'neutral';
29
34
  /** Grey text under the value. */
30
35
  description?: string;
36
+ /** Makes the whole tile a link to here. */
37
+ href?: string;
38
+ /** Element or component to render the link as, e.g. RouterLink (then pass its `to`). Makes the tile a link. */
39
+ as?: PrimitiveProps['as'];
31
40
  class?: HTMLAttributes['class'];
32
41
  }
33
42
  type __VLS_Slots = {
@@ -0,0 +1,46 @@
1
+ import { HTMLAttributes } from 'vue';
2
+ import { ButtonStatus } from '../Button/Button.vue';
3
+ /**
4
+ * A bar that slides up from the bottom of the screen while a page or form has
5
+ * edits that haven't been saved, with Discard and Save. It slides back down
6
+ * when `open` is false, e.g. after saving or discarding. With reduced motion
7
+ * it simply appears and disappears.
8
+ *
9
+ * It is fixed to the bottom of the screen, so it would cover the end of the
10
+ * page. By default it therefore leaves an empty space of its own height at its
11
+ * place in the page (put it last in the page content); set `reserveSpace` to
12
+ * false if you handle that yourself, e.g. with padding on the page.
13
+ *
14
+ * Next to a setting that has been edited, show the old and new values with
15
+ * ChangeIndicator.
16
+ */
17
+ export interface UnsavedChangesBarProps {
18
+ /** Whether it is shown. */
19
+ open: boolean;
20
+ /** What it says. Default "Unsaved changes". */
21
+ message?: string;
22
+ /** Text of the discard button. Default "Discard". */
23
+ discardLabel?: string;
24
+ /** Text of the save button. Default "Save". */
25
+ saveLabel?: string;
26
+ /** Progress of saving: `loading` shows a spinner on Save and disables both buttons. */
27
+ status?: ButtonStatus;
28
+ /**
29
+ * Keep the end of the page clear of the bar by leaving a blank space as tall
30
+ * as the bar where this component is placed.
31
+ */
32
+ reserveSpace?: boolean;
33
+ class?: HTMLAttributes['class'];
34
+ }
35
+ declare const __VLS_export: import('vue').DefineComponent<UnsavedChangesBarProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
36
+ discard: () => any;
37
+ save: () => any;
38
+ }, string, import('vue').PublicProps, Readonly<UnsavedChangesBarProps> & Readonly<{
39
+ onDiscard?: (() => any) | undefined;
40
+ onSave?: (() => any) | undefined;
41
+ }>, {
42
+ status: ButtonStatus;
43
+ reserveSpace: boolean;
44
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
45
+ declare const _default: typeof __VLS_export;
46
+ export default _default;
package/dist/i18n/en.d.ts CHANGED
@@ -42,6 +42,9 @@ export declare const en: {
42
42
  chooseMonth: string;
43
43
  chooseYear: string;
44
44
  };
45
+ changeIndicator: {
46
+ changed: string;
47
+ };
45
48
  chip: {
46
49
  remove: string;
47
50
  };
@@ -141,6 +144,11 @@ export declare const en: {
141
144
  selectRow: string;
142
145
  select: string;
143
146
  };
147
+ unsavedChangesBar: {
148
+ message: string;
149
+ discard: string;
150
+ save: string;
151
+ };
144
152
  };
145
153
  };
146
154
  export type UiMessages = typeof en;
package/dist/index.d.ts CHANGED
@@ -25,6 +25,8 @@ export { default as Spinner } from './components/Spinner/Spinner.vue';
25
25
  export type { SpinnerProps } from './components/Spinner/Spinner.vue';
26
26
  export { default as Progress } from './components/Progress/Progress.vue';
27
27
  export type { ProgressProps } from './components/Progress/Progress.vue';
28
+ export { default as ChangeIndicator } from './components/ChangeIndicator/ChangeIndicator.vue';
29
+ export type { ChangeIndicatorProps } from './components/ChangeIndicator/ChangeIndicator.vue';
28
30
  export { default as FormField } from './components/FormField/FormField.vue';
29
31
  export type { FormFieldProps, FormFieldStatus } from './components/FormField/FormField.vue';
30
32
  export { default as Input } from './components/Input/Input.vue';
@@ -55,6 +57,8 @@ export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGro
55
57
  export type { CheckboxGroupProps, CheckboxOption, CheckboxGroupValue } from './components/CheckboxGroup/CheckboxGroup.vue';
56
58
  export { default as LanguageSwitcher } from './components/LanguageSwitcher/LanguageSwitcher.vue';
57
59
  export type { LanguageSwitcherProps } from './components/LanguageSwitcher/LanguageSwitcher.vue';
60
+ export { default as CardSelect } from './components/CardSelect/CardSelect.vue';
61
+ export type { CardSelectProps } from './components/CardSelect/CardSelect.vue';
58
62
  export { default as Table } from './components/Table/Table.vue';
59
63
  export type { TableProps } from './components/Table/Table.vue';
60
64
  export type { TableColumn, TableSort, SortDirection } from './components/Table/table';
@@ -100,6 +104,8 @@ export { default as Toaster } from './components/Notification/Toaster.vue';
100
104
  export type { ToasterProps } from './components/Notification/Toaster.vue';
101
105
  export { createNotifications, useNotifications, relativeTime } from './components/Notification/notifications';
102
106
  export type { Notifications, NotificationItem, NotificationInput, NotificationAction, NotificationType, ToastOptions } from './components/Notification/notifications';
107
+ export { default as UnsavedChangesBar } from './components/UnsavedChangesBar/UnsavedChangesBar.vue';
108
+ export type { UnsavedChangesBarProps } from './components/UnsavedChangesBar/UnsavedChangesBar.vue';
103
109
  export { createKestonI18n, uiMessages, en } from './i18n';
104
110
  export type { KestonI18nOptions, Messages, UiMessages } from './i18n';
105
111
  export { age, daysToBirthday, formatDate, formatDateTime, toDate } from './lib/dates';