@thekestongroup/ui 0.16.0 → 0.18.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 (33) hide show
  1. package/dist/components/ActionList/ActionList.vue.d.ts +13 -2
  2. package/dist/components/AsyncState/AsyncState.vue.d.ts +53 -0
  3. package/dist/components/ConfirmDialog/ConfirmDialog.vue.d.ts +62 -0
  4. package/dist/components/InputRichText/InputRichText.vue.d.ts +12 -6
  5. package/dist/components/Prose/Prose.vue.d.ts +36 -0
  6. package/dist/components/ResultState/ResultState.vue.d.ts +48 -0
  7. package/dist/components/Steps/Steps.vue.d.ts +16 -5
  8. package/dist/i18n/en.d.ts +16 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/keston-ui.js +2149 -1749
  11. package/dist/lib/initials.d.ts +6 -1
  12. package/package.json +3 -1
  13. package/src/components/ActionList/ActionList.stories.ts +34 -1
  14. package/src/components/ActionList/ActionList.vue +27 -5
  15. package/src/components/AsyncState/AsyncState.stories.ts +46 -0
  16. package/src/components/AsyncState/AsyncState.vue +78 -0
  17. package/src/components/Button/Button.vue +4 -4
  18. package/src/components/ConfirmDialog/ConfirmDialog.stories.ts +54 -0
  19. package/src/components/ConfirmDialog/ConfirmDialog.vue +119 -0
  20. package/src/components/InputRichText/InputRichText.stories.ts +19 -0
  21. package/src/components/InputRichText/InputRichText.vue +129 -13
  22. package/src/components/Notification/Toaster.vue +3 -1
  23. package/src/components/Prose/Prose.stories.ts +46 -0
  24. package/src/components/Prose/Prose.vue +54 -0
  25. package/src/components/ResultState/ResultState.stories.ts +44 -0
  26. package/src/components/ResultState/ResultState.vue +76 -0
  27. package/src/components/Steps/Steps.stories.ts +18 -0
  28. package/src/components/Steps/Steps.vue +28 -8
  29. package/src/i18n/en.ts +12 -2
  30. package/src/index.ts +8 -0
  31. package/src/lib/initials.test.ts +19 -0
  32. package/src/lib/initials.ts +12 -3
  33. package/src/styles/theme.css +11 -2
@@ -16,12 +16,16 @@ export interface ActionListItem {
16
16
  current?: boolean;
17
17
  /** Show a spinner in place of the arrow, e.g. while switching to it. */
18
18
  loading?: boolean;
19
+ /** A short note at the top right of the row, e.g. "Signed out" or "Needs a code". */
20
+ note?: string;
19
21
  }
20
22
  /**
21
23
  * A list of things to pick one of and go to: accounts to switch to,
22
24
  * organisations, connected apps. Each row is a single button or link with an
23
25
  * optional icon or avatar, a name and a line under it, and an arrow, in a
24
- * bordered box with lines between rows.
26
+ * bordered box with lines between rows. `appearance="plain"` drops the box
27
+ * (rows sit straight on the card, with a line under each), for a list that
28
+ * is the main thing on its card, like an account chooser.
25
29
  *
26
30
  * Rows without `to` / `href` are buttons that emit `select`.
27
31
  *
@@ -35,6 +39,10 @@ export interface ActionListProps {
35
39
  label: string;
36
40
  /** Component used for rows with `to`, e.g. RouterLink. */
37
41
  linkComponent?: string | Component;
42
+ /** boxed (default): a bordered box. plain: no box, a line under each row, rows lined up with the text around them. */
43
+ appearance?: 'boxed' | 'plain';
44
+ /** Show the arrow at the end of each row. */
45
+ chevron?: boolean;
38
46
  class?: HTMLAttributes['class'];
39
47
  }
40
48
  type __VLS_Slots = {
@@ -52,7 +60,10 @@ declare const __VLS_base: import('vue').DefineComponent<ActionListProps, {}, {},
52
60
  select: (item: ActionListItem) => any;
53
61
  }, string, import('vue').PublicProps, Readonly<ActionListProps> & Readonly<{
54
62
  onSelect?: ((item: ActionListItem) => any) | undefined;
55
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
63
+ }>, {
64
+ appearance: "boxed" | "plain";
65
+ chevron: boolean;
66
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
56
67
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
57
68
  declare const _default: typeof __VLS_export;
58
69
  export default _default;
@@ -0,0 +1,53 @@
1
+ import { Component, HTMLAttributes } from 'vue';
2
+ /**
3
+ * The three states every page or panel that loads data has, the same way
4
+ * everywhere:
5
+ * - error: "Couldn't load …" with the reason and Try again (emits `retry`);
6
+ * - loading: a spinner, centred;
7
+ * - empty: an EmptyState with what goes here and what to do;
8
+ * - otherwise the content (default slot).
9
+ *
10
+ * In that order, so an error wins over stale content. With `card`, the
11
+ * error and empty states sit in a Card, as on a page of Cards.
12
+ *
13
+ * Slots: default (the content), empty (instead of the EmptyState), empty-actions
14
+ * (under the empty state, e.g. "Add a student").
15
+ */
16
+ export interface AsyncStateProps {
17
+ loading?: boolean;
18
+ /** Why it couldn't load. Shows the error state. */
19
+ error?: string | null;
20
+ /** Loaded, with nothing in it. Shows the empty state. */
21
+ empty?: boolean;
22
+ /** The error's title. Default "Couldn't load this". */
23
+ errorTitle?: string;
24
+ /** Show Try again under the error (emits `retry`). */
25
+ retryable?: boolean;
26
+ /** The empty state's title, e.g. "No applications yet". */
27
+ emptyTitle?: string;
28
+ emptyDescription?: string;
29
+ emptyIcon?: Component;
30
+ /** What the spinner says to screen readers. Default "Loading". */
31
+ loadingLabel?: string;
32
+ /** Put the error and empty states in a Card. */
33
+ card?: boolean;
34
+ class?: HTMLAttributes['class'];
35
+ }
36
+ type __VLS_Slots = {
37
+ default?(): unknown;
38
+ empty?(): unknown;
39
+ 'empty-actions'?(): unknown;
40
+ };
41
+ declare const __VLS_base: import('vue').DefineComponent<AsyncStateProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
42
+ retry: () => any;
43
+ }, string, import('vue').PublicProps, Readonly<AsyncStateProps> & Readonly<{
44
+ onRetry?: (() => any) | undefined;
45
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
46
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
47
+ declare const _default: typeof __VLS_export;
48
+ export default _default;
49
+ type __VLS_WithSlots<T, S> = T & {
50
+ new (): {
51
+ $slots: S;
52
+ };
53
+ };
@@ -0,0 +1,62 @@
1
+ import { HTMLAttributes } from 'vue';
2
+ import { ButtonStatus } from '../Button/Button.vue';
3
+ /**
4
+ * "Are you sure?" before something that can't easily be undone: deleting,
5
+ * leaving, removing access. A small panel in the middle of the screen with a
6
+ * title that asks the question, what will happen, and Cancel / the action.
7
+ *
8
+ * Focus starts on Cancel, so pressing Enter by accident doesn't do it.
9
+ * Escape and Cancel close it; clicking outside doesn't (it's a decision).
10
+ * Built on Reka UI's AlertDialog, so it's announced as an alert dialog.
11
+ *
12
+ * Open it with `v-model:open`, or put the button that opens it in the
13
+ * default slot. While `status` is loading, the action shows a spinner and
14
+ * the dialog can't be closed; set it back to idle (and `open` to false) when
15
+ * the work is done.
16
+ *
17
+ * Slots: default (the trigger), description (instead of `description`, for
18
+ * bold text or a list of what will be lost).
19
+ */
20
+ export interface ConfirmDialogProps {
21
+ /** The question, e.g. "Delete 3 applications?" */
22
+ title: string;
23
+ /** What will happen, and whether it can be undone. */
24
+ description?: string;
25
+ /** The action's text: a verb, e.g. "Delete applications". Default "Confirm". */
26
+ confirmLabel?: string;
27
+ /** Default "Cancel". */
28
+ cancelLabel?: string;
29
+ /** Destroys something: the action is a danger Button. */
30
+ danger?: boolean;
31
+ /** Progress of the action, e.g. loading while it runs. */
32
+ status?: ButtonStatus;
33
+ /** Text beside the spinner while loading, e.g. "Deleting…". */
34
+ loadingText?: string;
35
+ class?: HTMLAttributes['class'];
36
+ }
37
+ type __VLS_Props = ConfirmDialogProps;
38
+ type __VLS_Slots = {
39
+ default?(): unknown;
40
+ description?(): unknown;
41
+ };
42
+ type __VLS_ModelProps = {
43
+ 'open'?: boolean;
44
+ };
45
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
46
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
47
+ "update:open": (value: boolean) => any;
48
+ confirm: () => any;
49
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
50
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
51
+ onConfirm?: (() => any) | undefined;
52
+ }>, {
53
+ status: ButtonStatus;
54
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
55
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
56
+ declare const _default: typeof __VLS_export;
57
+ export default _default;
58
+ type __VLS_WithSlots<T, S> = T & {
59
+ new (): {
60
+ $slots: S;
61
+ };
62
+ };
@@ -1,13 +1,19 @@
1
1
  import { HTMLAttributes } from 'vue';
2
2
  import { FormFieldStatus } from '../FormField/FormField.vue';
3
3
  /**
4
- * Several lines of text with bold, italic and underline, e.g. notes on a
5
- * student or an application. Only those three: no headings, lists, links or
6
- * colours, so notes look the same everywhere. Pasted text keeps its bold,
7
- * italic and underline and loses everything else.
4
+ * Several lines of text with bold, italic, underline and links, e.g. notes
5
+ * on a student, or a company's sign-in page text with a link to its help
6
+ * pages. No headings, lists or colours, so text looks the same everywhere.
7
+ * Pasted text keeps those and loses everything else.
8
8
  *
9
- * The value is HTML using only <p>, <br>, <strong>, <em> and <u>. Sanitise
10
- * it on the server like any HTML from a browser before showing it elsewhere.
9
+ * Links: the Link button or Ctrl/⌘+K opens a small panel for the address.
10
+ * Only https://, mailto: and tel: addresses are allowed (never javascript:
11
+ * or plain http). Typed and pasted https:// addresses become links too.
12
+ * Links open in the same tab, so nobody is sent to a new tab unannounced.
13
+ *
14
+ * The value is HTML using only <p>, <br>, <strong>, <em>, <u> and
15
+ * <a href rel>. Sanitise it on the server like any HTML from a browser
16
+ * before showing it elsewhere.
11
17
  */
12
18
  export interface InputRichTextProps {
13
19
  /** Visible label. Always set it: it is also the editor's accessible name. */
@@ -0,0 +1,36 @@
1
+ import { HTMLAttributes } from 'vue';
2
+ /**
3
+ * Long-form text written as plain HTML: privacy policies, terms, help
4
+ * articles, release notes. Gives headings, paragraphs, lists, links, quotes,
5
+ * code and tables Keston's look without a class on each, at a readable line
6
+ * length (about 65 characters).
7
+ *
8
+ * Headings follow the guide's scale: h1 text-2xl (when the page has no
9
+ * PageHeader), h2 text-lg, h3 text-base, h4 text-sm. Links look and behave
10
+ * like Link (Keston blue, underlined, focus ring); use Link itself for
11
+ * links that open in a new tab, so they get its icon and screen-reader text.
12
+ *
13
+ * Not for app screens: those are built from components.
14
+ */
15
+ export interface ProseProps {
16
+ /** The text size. base (default) for reading pages, sm in a panel or card. */
17
+ size?: 'sm' | 'base';
18
+ class?: HTMLAttributes['class'];
19
+ }
20
+ declare const __VLS_template: () => {
21
+ __VLS_Slots: {
22
+ default?: (props: {}) => any;
23
+ };
24
+ };
25
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
26
+ declare const __VLS_base: import('vue').DefineComponent<ProseProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ProseProps> & Readonly<{}>, {
27
+ size: "sm" | "base";
28
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
29
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
30
+ declare const _default: typeof __VLS_export;
31
+ export default _default;
32
+ type __VLS_WithSlots<T, S> = T & {
33
+ new (): {
34
+ $slots: S;
35
+ };
36
+ };
@@ -0,0 +1,48 @@
1
+ import { Component, HTMLAttributes } from 'vue';
2
+ /**
3
+ * The end of a task: what happened, and what next. "3 users added", "Nobody
4
+ * was added", "Password changed". A large icon, a heading, a line or two,
5
+ * and actions (e.g. Add more, Done), centred.
6
+ *
7
+ * It usually replaces the form that was just sent, so focus moves to its
8
+ * heading when it appears and screen readers read the outcome. Turn that off
9
+ * with `:focus="false"` when it's on the page from the start.
10
+ *
11
+ * For a list or table with nothing in it, use EmptyState.
12
+ *
13
+ * Slots: description (instead of `description`), default (under the
14
+ * description, e.g. a list of what failed), actions.
15
+ */
16
+ export interface ResultStateProps {
17
+ /** success (default), error (nothing happened), warning (partly), info. Sets the icon and its colour. */
18
+ type?: 'success' | 'error' | 'warning' | 'info';
19
+ /** What happened, e.g. "3 users added". */
20
+ title: string;
21
+ /** What it means or what to do next. */
22
+ description?: string;
23
+ /** A different icon from the type's own. */
24
+ icon?: Component;
25
+ /** The heading's level, to fit the page outline. */
26
+ headingLevel?: 1 | 2 | 3;
27
+ /** Move focus to the heading when it appears. */
28
+ focus?: boolean;
29
+ class?: HTMLAttributes['class'];
30
+ }
31
+ type __VLS_Slots = {
32
+ default?(): unknown;
33
+ description?(): unknown;
34
+ actions?(): unknown;
35
+ };
36
+ declare const __VLS_base: import('vue').DefineComponent<ResultStateProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ResultStateProps> & Readonly<{}>, {
37
+ focus: boolean;
38
+ type: "error" | "success" | "info" | "warning";
39
+ headingLevel: 1 | 2 | 3;
40
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
41
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
42
+ declare const _default: typeof __VLS_export;
43
+ export default _default;
44
+ type __VLS_WithSlots<T, S> = T & {
45
+ new (): {
46
+ $slots: S;
47
+ };
48
+ };
@@ -1,10 +1,15 @@
1
1
  import { HTMLAttributes } from 'vue';
2
2
  /**
3
3
  * Where someone is in a set of steps: a segment for each step, filled up to
4
- * the current one, and "Step 2 of 3: Licences" above it. Put it at the top of
5
- * a multi-step form. (Slideover's `steps` shows one for you; use this when
6
- * the steps are on a page, or in a Slideover you drive yourself.) The words
7
- * are announced when the step changes.
4
+ * the current one, and "Step 2 of 3 – Licences" under it, as in Slideover's
5
+ * multi-step form. Put it at the top of a multi-step form on a page, or in a
6
+ * Slideover you drive yourself. The words are announced when the step
7
+ * changes.
8
+ *
9
+ * With `v-model:step`, finished segments are buttons ("Back to step 1: User
10
+ * info") that go back to that step; steps ahead can't be picked, so each
11
+ * step's checks still run in order. With just `:step`, it only shows where
12
+ * you are.
8
13
  */
9
14
  export interface StepsProps {
10
15
  /** The name of each step, in order, e.g. `['User info', 'Licences']`. */
@@ -13,8 +18,14 @@ export interface StepsProps {
13
18
  step: number;
14
19
  /** What the steps are for, e.g. "Add a user". The progress bar's accessible name; not shown. */
15
20
  label: string;
21
+ /** Stops going back, e.g. while a step saves. */
22
+ disabled?: boolean;
16
23
  class?: HTMLAttributes['class'];
17
24
  }
18
- declare const __VLS_export: import('vue').DefineComponent<StepsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<StepsProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
25
+ declare const __VLS_export: import('vue').DefineComponent<StepsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
26
+ "update:step": (step: number) => any;
27
+ }, string, import('vue').PublicProps, Readonly<StepsProps> & Readonly<{
28
+ "onUpdate:step"?: ((step: number) => any) | undefined;
29
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
30
  declare const _default: typeof __VLS_export;
20
31
  export default _default;
package/dist/i18n/en.d.ts CHANGED
@@ -91,6 +91,12 @@ export declare const en: {
91
91
  bold: string;
92
92
  italic: string;
93
93
  underline: string;
94
+ link: string;
95
+ linkAddress: string;
96
+ addLink: string;
97
+ updateLink: string;
98
+ removeLink: string;
99
+ linkInvalid: string;
94
100
  };
95
101
  alert: {
96
102
  info: string;
@@ -105,6 +111,14 @@ export declare const en: {
105
111
  dropFile: string;
106
112
  dropFiles: string;
107
113
  };
114
+ confirmDialog: {
115
+ confirm: string;
116
+ cancel: string;
117
+ };
118
+ asyncState: {
119
+ error: string;
120
+ retry: string;
121
+ };
108
122
  languageSwitcher: {
109
123
  label: string;
110
124
  };
@@ -169,6 +183,8 @@ export declare const en: {
169
183
  steps: {
170
184
  stepOf: string;
171
185
  stepOfNamed: string;
186
+ /** Under the segments, e.g. "Step 2 of 3 – Licences", as in Slideover. */
187
+ stepOfDash: string;
172
188
  };
173
189
  summaryList: {
174
190
  notSet: string;
package/dist/index.d.ts CHANGED
@@ -40,6 +40,8 @@ export { default as Alert } from './components/Alert/Alert.vue';
40
40
  export type { AlertProps } from './components/Alert/Alert.vue';
41
41
  export { default as Collapsible } from './components/Collapsible/Collapsible.vue';
42
42
  export type { CollapsibleProps } from './components/Collapsible/Collapsible.vue';
43
+ export { default as Prose } from './components/Prose/Prose.vue';
44
+ export type { ProseProps } from './components/Prose/Prose.vue';
43
45
  export { default as FormField } from './components/FormField/FormField.vue';
44
46
  export type { FormFieldProps, FormFieldStatus } from './components/FormField/FormField.vue';
45
47
  export { default as Input } from './components/Input/Input.vue';
@@ -96,6 +98,10 @@ export { default as BarChart } from './components/BarChart/BarChart.vue';
96
98
  export type { BarChartProps } from './components/BarChart/BarChart.vue';
97
99
  export { default as LineChart } from './components/LineChart/LineChart.vue';
98
100
  export type { LineChartProps } from './components/LineChart/LineChart.vue';
101
+ export { default as AsyncState } from './components/AsyncState/AsyncState.vue';
102
+ export type { AsyncStateProps } from './components/AsyncState/AsyncState.vue';
103
+ export { default as ResultState } from './components/ResultState/ResultState.vue';
104
+ export type { ResultStateProps } from './components/ResultState/ResultState.vue';
99
105
  export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.vue';
100
106
  export type { BreadcrumbProps, BreadcrumbItem } from './components/Breadcrumb/Breadcrumb.vue';
101
107
  export { default as Sidebar } from './components/Sidebar/Sidebar.vue';
@@ -129,6 +135,8 @@ export { createNotifications, useNotifications, relativeTime } from './component
129
135
  export type { Notifications, NotificationItem, NotificationInput, NotificationAction, NotificationType, ToastOptions } from './components/Notification/notifications';
130
136
  export { default as UnsavedChangesBar } from './components/UnsavedChangesBar/UnsavedChangesBar.vue';
131
137
  export type { UnsavedChangesBarProps } from './components/UnsavedChangesBar/UnsavedChangesBar.vue';
138
+ export { default as ConfirmDialog } from './components/ConfirmDialog/ConfirmDialog.vue';
139
+ export type { ConfirmDialogProps } from './components/ConfirmDialog/ConfirmDialog.vue';
132
140
  export { createKestonI18n, uiMessages, en } from './i18n';
133
141
  export type { KestonI18nOptions, Messages, UiMessages } from './i18n';
134
142
  export { age, daysToBirthday, formatDate, formatDateTime, toDate } from './lib/dates';