@thekestongroup/ui 0.9.2 → 0.10.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.
- package/dist/components/CardSelect/CardSelect.vue.d.ts +59 -0
- package/dist/components/ChangeIndicator/ChangeIndicator.vue.d.ts +20 -0
- package/dist/components/ChangeIndicator/changeIndicator.d.ts +5 -0
- package/dist/components/UnsavedChangesBar/UnsavedChangesBar.vue.d.ts +46 -0
- package/dist/i18n/en.d.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/keston-ui.js +612 -384
- package/package.json +1 -1
- package/src/components/CardSelect/CardSelect.stories.ts +88 -0
- package/src/components/CardSelect/CardSelect.vue +151 -0
- package/src/components/ChangeIndicator/ChangeIndicator.stories.ts +32 -0
- package/src/components/ChangeIndicator/ChangeIndicator.vue +42 -0
- package/src/components/ChangeIndicator/changeIndicator.test.ts +21 -0
- package/src/components/ChangeIndicator/changeIndicator.ts +11 -0
- package/src/components/UnsavedChangesBar/UnsavedChangesBar.stories.ts +62 -0
- package/src/components/UnsavedChangesBar/UnsavedChangesBar.vue +87 -0
- package/src/i18n/en.ts +6 -0
- package/src/i18n/i18n.test.ts +10 -0
- package/src/index.ts +6 -0
|
@@ -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;
|
|
@@ -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';
|