frontile 0.18.0-alpha.16 → 0.18.0-alpha.18
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/declarations/-private/manager.d.ts +10 -3
- package/declarations/-private/notification-stack.d.ts +76 -0
- package/declarations/-private/notification.d.ts +33 -8
- package/declarations/-private/types.d.ts +69 -3
- package/declarations/components/buttons/button.d.ts +29 -0
- package/declarations/components/buttons/index.d.ts +1 -0
- package/declarations/components/buttons/segmented-control/item.d.ts +50 -0
- package/declarations/components/buttons/segmented-control/segmented-control.d.ts +210 -0
- package/declarations/components/buttons/segmented-control.d.ts +3 -0
- package/declarations/components/collections/command/command.d.ts +195 -0
- package/declarations/components/collections/command/dialog.d.ts +44 -0
- package/declarations/components/collections/command/footer.d.ts +61 -0
- package/declarations/components/collections/command/index.d.ts +6 -0
- package/declarations/components/collections/command/input.d.ts +131 -0
- package/declarations/components/collections/command/list.d.ts +135 -0
- package/declarations/components/collections/command.d.ts +2 -0
- package/declarations/components/collections/dropdown.d.ts +1 -1
- package/declarations/components/collections/index.d.ts +1 -0
- package/declarations/components/collections/listbox/group.d.ts +62 -0
- package/declarations/components/collections/listbox/item.d.ts +13 -1
- package/declarations/components/collections/listbox/listbox.d.ts +10 -1
- package/declarations/components/collections/table/column-visibility.d.ts +1 -1
- package/declarations/components/collections/table/table.d.ts +5 -11
- package/declarations/components/forms/autocomplete.d.ts +9 -5
- package/declarations/components/forms/field.d.ts +2 -0
- package/declarations/components/forms/form.d.ts +5 -4
- package/declarations/components/forms/index.d.ts +1 -0
- package/declarations/components/forms/input-otp.d.ts +321 -0
- package/declarations/components/forms/input.d.ts +1 -1
- package/declarations/components/forms/select/select.d.ts +3 -3
- package/declarations/components/forms/select/types.d.ts +7 -3
- package/declarations/components/forms/switch.d.ts +16 -16
- package/declarations/components/navigation/index.d.ts +2 -0
- package/declarations/components/navigation/tab-nav/item.d.ts +79 -0
- package/declarations/components/navigation/tab-nav/tab-nav.d.ts +165 -0
- package/declarations/components/navigation/tab-nav.d.ts +3 -0
- package/declarations/components/navigation/tabs/panel.d.ts +28 -0
- package/declarations/components/navigation/tabs/tab.d.ts +46 -0
- package/declarations/components/navigation/tabs/tabs.d.ts +227 -0
- package/declarations/components/navigation/tabs.d.ts +4 -0
- package/declarations/components/notifications/icons.d.ts +9 -0
- package/declarations/components/notifications/index.d.ts +6 -3
- package/declarations/components/notifications/notification-card.d.ts +63 -12
- package/declarations/components/notifications/notifications-container.d.ts +108 -7
- package/declarations/components/overlays/drawer.d.ts +11 -11
- package/declarations/components/overlays/modal.d.ts +12 -12
- package/declarations/components/utilities/avatar.d.ts +6 -6
- package/declarations/components/utilities/index.d.ts +4 -0
- package/declarations/components/utilities/kbd.d.ts +92 -0
- package/declarations/index.d.ts +2 -1
- package/declarations/navigation.d.ts +1 -0
- package/declarations/services/notifications.d.ts +3 -2
- package/declarations/template-registry.d.ts +9 -3
- package/declarations/utils/deferred-work.d.ts +24 -0
- package/declarations/utils/filter.d.ts +87 -0
- package/declarations/utils/keys.d.ts +52 -0
- package/declarations/utils/listManager.d.ts +2 -5
- package/declarations/utils/roving-focus.d.ts +66 -0
- package/declarations/utils/selection-indicator.d.ts +65 -0
- package/dist/buttons.js +2 -0
- package/dist/buttons.js.map +1 -1
- package/dist/collections.js +6 -0
- package/dist/collections.js.map +1 -1
- package/dist/components/buttons/button.js +71 -6
- package/dist/components/buttons/button.js.map +1 -1
- package/dist/components/buttons/index.js +2 -0
- package/dist/components/buttons/index.js.map +1 -1
- package/dist/components/buttons/segmented-control/item.js +55 -0
- package/dist/components/buttons/segmented-control/item.js.map +1 -0
- package/dist/components/buttons/segmented-control/segmented-control.js +175 -0
- package/dist/components/buttons/segmented-control/segmented-control.js.map +1 -0
- package/dist/components/buttons/segmented-control.js +3 -0
- package/dist/components/buttons/segmented-control.js.map +1 -0
- package/dist/components/collections/command/command.js +263 -0
- package/dist/components/collections/command/command.js.map +1 -0
- package/dist/components/collections/command/dialog.js +100 -0
- package/dist/components/collections/command/dialog.js.map +1 -0
- package/dist/components/collections/command/footer.js +60 -0
- package/dist/components/collections/command/footer.js.map +1 -0
- package/dist/components/collections/command/index.js +6 -0
- package/dist/components/collections/command/index.js.map +1 -0
- package/dist/components/collections/command/input.js +45 -0
- package/dist/components/collections/command/input.js.map +1 -0
- package/dist/components/collections/command/list.js +70 -0
- package/dist/components/collections/command/list.js.map +1 -0
- package/dist/components/collections/command.js +6 -0
- package/dist/components/collections/command.js.map +1 -0
- package/dist/components/collections/dropdown.js +1 -1
- package/dist/components/collections/dropdown.js.map +1 -1
- package/dist/components/collections/index.js +6 -0
- package/dist/components/collections/index.js.map +1 -1
- package/dist/components/collections/listbox/group.js +60 -0
- package/dist/components/collections/listbox/group.js.map +1 -0
- package/dist/components/collections/listbox/item.js +8 -5
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js +5 -3
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/collections/listbox.js +1 -0
- package/dist/components/collections/listbox.js.map +1 -1
- package/dist/components/collections/table/table.js +43 -87
- package/dist/components/collections/table/table.js.map +1 -1
- package/dist/components/forms/autocomplete.js +3 -4
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/field.js +3 -1
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form.js +4 -3
- package/dist/components/forms/form.js.map +1 -1
- package/dist/components/forms/index.js +1 -0
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/input-otp.js +407 -0
- package/dist/components/forms/input-otp.js.map +1 -0
- package/dist/components/forms/select/select.js +3 -3
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/navigation/index.js +6 -0
- package/dist/components/navigation/index.js.map +1 -0
- package/dist/components/navigation/tab-nav/item.js +90 -0
- package/dist/components/navigation/tab-nav/item.js.map +1 -0
- package/dist/components/navigation/tab-nav/tab-nav.js +79 -0
- package/dist/components/navigation/tab-nav/tab-nav.js.map +1 -0
- package/dist/components/navigation/tab-nav.js +3 -0
- package/dist/components/navigation/tab-nav.js.map +1 -0
- package/dist/components/navigation/tabs/panel.js +23 -0
- package/dist/components/navigation/tabs/panel.js.map +1 -0
- package/dist/components/navigation/tabs/tab.js +45 -0
- package/dist/components/navigation/tabs/tab.js.map +1 -0
- package/dist/components/navigation/tabs/tabs.js +156 -0
- package/dist/components/navigation/tabs/tabs.js.map +1 -0
- package/dist/components/navigation/tabs.js +4 -0
- package/dist/components/navigation/tabs.js.map +1 -0
- package/dist/components/notifications/icons.js +19 -0
- package/dist/components/notifications/icons.js.map +1 -0
- package/dist/components/notifications/index.js +2 -2
- package/dist/components/notifications/notification-card.js +15 -118
- package/dist/components/notifications/notification-card.js.map +1 -1
- package/dist/components/notifications/notifications-container.js +220 -23
- package/dist/components/notifications/notifications-container.js.map +1 -1
- package/dist/components/overlays/drawer.js +1 -1
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/dist/components/utilities/index.js +4 -0
- package/dist/components/utilities/index.js.map +1 -1
- package/dist/components/utilities/kbd.js +88 -0
- package/dist/components/utilities/kbd.js.map +1 -0
- package/dist/forms.js +1 -0
- package/dist/forms.js.map +1 -1
- package/dist/index.js +20 -2
- package/dist/index.js.map +1 -1
- package/dist/manager-CDIZzrQ9.js +388 -0
- package/dist/manager-CDIZzrQ9.js.map +1 -0
- package/dist/navigation.js +6 -0
- package/dist/navigation.js.map +1 -0
- package/dist/notification-card-ByIC9X6o.js +330 -0
- package/dist/notification-card-ByIC9X6o.js.map +1 -0
- package/dist/notifications.js +2 -2
- package/dist/services/notifications.js +6 -3
- package/dist/services/notifications.js.map +1 -1
- package/dist/utilities.js +4 -0
- package/dist/utilities.js.map +1 -1
- package/dist/utils/deferred-work.js +66 -0
- package/dist/utils/deferred-work.js.map +1 -0
- package/dist/utils/filter.js +166 -0
- package/dist/utils/filter.js.map +1 -0
- package/dist/utils/keys.js +259 -0
- package/dist/utils/keys.js.map +1 -0
- package/dist/utils/listManager.js +2 -9
- package/dist/utils/listManager.js.map +1 -1
- package/dist/utils/roving-focus.js +206 -0
- package/dist/utils/roving-focus.js.map +1 -0
- package/dist/utils/selection-indicator.js +189 -0
- package/dist/utils/selection-indicator.js.map +1 -0
- package/package.json +9 -4
- package/dist/manager-BA-8yKMJ.js +0 -186
- package/dist/manager-BA-8yKMJ.js.map +0 -1
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import Notification from './notification';
|
|
2
|
-
import type { DefaultConfig } from './types';
|
|
3
|
-
import type { NotificationOptions } from './types';
|
|
2
|
+
import type { DefaultConfig, NotificationOptions, NotificationContent, PromiseNotificationOptions } from './types';
|
|
4
3
|
export default class NotificationsManager {
|
|
5
4
|
notifications: Notification<Record<string, unknown>>[];
|
|
6
5
|
config: DefaultConfig;
|
|
7
6
|
onRemove?: (notification: Notification<Record<string, unknown>>) => void;
|
|
8
7
|
constructor(context: object, onRemove?: (notification: Notification<Record<string, unknown>>) => void);
|
|
9
|
-
add<TMetadata extends Record<string, unknown> = Record<string, unknown>>(
|
|
8
|
+
add<TMetadata extends Record<string, unknown> = Record<string, unknown>>(content: string | NotificationContent, options?: NotificationOptions<TMetadata>): Notification<TMetadata>;
|
|
9
|
+
/**
|
|
10
|
+
* Show a notification driven by a promise: a spinner while pending, then
|
|
11
|
+
* the same notification mutated in place once it settles.
|
|
12
|
+
*
|
|
13
|
+
* Returns the original promise, so callers can still await it — and are
|
|
14
|
+
* still responsible for handling its rejection.
|
|
15
|
+
*/
|
|
16
|
+
promise<T, TMetadata extends Record<string, unknown> = Record<string, unknown>>(promise: Promise<T>, options: PromiseNotificationOptions<T, TMetadata>): Promise<T>;
|
|
10
17
|
remove(notification?: Notification<Record<string, unknown>>): void;
|
|
11
18
|
removeAll(): void;
|
|
12
19
|
private setupAutoRemoval;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { containerPlacement } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Cards are pinned to the placement edge, so a top placement stacks
|
|
4
|
+
* downwards and a bottom placement stacks upwards. Exported so
|
|
5
|
+
* notification-card.gts's own enter/exit slide direction can share this
|
|
6
|
+
* instead of re-deriving it from the placement string.
|
|
7
|
+
*/
|
|
8
|
+
declare function isTopPlacement(placement: containerPlacement): boolean;
|
|
9
|
+
interface NotificationStackInput {
|
|
10
|
+
/**
|
|
11
|
+
* Measured card heights in px, ordered front-first (index 0 is the newest
|
|
12
|
+
* notification). A card that has not been measured yet contributes 0.
|
|
13
|
+
*/
|
|
14
|
+
heights: number[];
|
|
15
|
+
isExpanded: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Peek offset between collapsed cards, and the gap between expanded cards.
|
|
18
|
+
*/
|
|
19
|
+
gap: number;
|
|
20
|
+
/**
|
|
21
|
+
* How many cards stay visible while collapsed.
|
|
22
|
+
*/
|
|
23
|
+
visibleToasts: number;
|
|
24
|
+
placement: containerPlacement;
|
|
25
|
+
}
|
|
26
|
+
interface CardGeometry {
|
|
27
|
+
transform: string;
|
|
28
|
+
zIndex: number;
|
|
29
|
+
opacity: number;
|
|
30
|
+
/**
|
|
31
|
+
* Fixed height in px while collapsed, so a taller card behind the front one
|
|
32
|
+
* cannot stick out past it. `null` means the card sizes to its content.
|
|
33
|
+
*/
|
|
34
|
+
height: number | null;
|
|
35
|
+
transformOrigin: 'top center' | 'bottom center';
|
|
36
|
+
/**
|
|
37
|
+
* `'none'` when the card is fully transparent (collapsed beyond
|
|
38
|
+
* `visibleToasts`), so it cannot swallow clicks meant for the page beneath
|
|
39
|
+
* it; `'auto'` otherwise.
|
|
40
|
+
*/
|
|
41
|
+
pointerEvents: 'auto' | 'none';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pure geometry for the notification stack: given measured card heights and
|
|
45
|
+
* the current expansion state, it produces the transform for each card and
|
|
46
|
+
* the height the container should animate to.
|
|
47
|
+
*
|
|
48
|
+
* Deliberately free of Ember and DOM dependencies so the layout maths can be
|
|
49
|
+
* tested on its own.
|
|
50
|
+
*/
|
|
51
|
+
declare class NotificationStack {
|
|
52
|
+
readonly heights: number[];
|
|
53
|
+
readonly isExpanded: boolean;
|
|
54
|
+
readonly gap: number;
|
|
55
|
+
readonly visibleToasts: number;
|
|
56
|
+
readonly placement: containerPlacement;
|
|
57
|
+
constructor(input: NotificationStackInput);
|
|
58
|
+
get isTopPlacement(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Cards are pinned to the placement edge, so a top placement stacks
|
|
61
|
+
* downwards and a bottom placement stacks upwards.
|
|
62
|
+
*/
|
|
63
|
+
get directionSign(): number;
|
|
64
|
+
get transformOrigin(): CardGeometry['transformOrigin'];
|
|
65
|
+
get count(): number;
|
|
66
|
+
get frontHeight(): number;
|
|
67
|
+
geometryFor(index: number): CardGeometry;
|
|
68
|
+
get containerHeight(): number;
|
|
69
|
+
/**
|
|
70
|
+
* Distance from the placement edge to the leading edge of `index`, i.e. the
|
|
71
|
+
* summed heights and gaps of every card in front of it.
|
|
72
|
+
*/
|
|
73
|
+
private offsetBefore;
|
|
74
|
+
}
|
|
75
|
+
export { NotificationStack, isTopPlacement };
|
|
76
|
+
export type { NotificationStackInput, CardGeometry };
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
import Timer from './timer';
|
|
2
|
-
import type { NotificationOptions, CustomAction, DefaultConfig } from './types';
|
|
2
|
+
import type { NotificationOptions, NotificationContent, NotificationIntent, NotificationUpdate, CustomAction, DefaultConfig } from './types';
|
|
3
3
|
export default class Notification<TMetadata extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The title of the notification. Named `message` for backwards
|
|
6
|
+
* compatibility with the original single-string API.
|
|
7
|
+
*/
|
|
8
|
+
message: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
intent: NotificationIntent;
|
|
11
|
+
allowClosing: boolean;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
customActions?: CustomAction[];
|
|
14
|
+
timer?: Timer;
|
|
15
|
+
isRemoving: boolean;
|
|
5
16
|
readonly transitionDuration: number;
|
|
6
|
-
readonly appearance: NonNullable<NotificationOptions['appearance']>;
|
|
7
|
-
readonly customActions?: CustomAction[];
|
|
8
|
-
readonly allowClosing: boolean;
|
|
9
17
|
readonly duration: number;
|
|
18
|
+
readonly hideIcon: boolean;
|
|
10
19
|
readonly metadata?: TMetadata;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
constructor(config: DefaultConfig, content: string | NotificationContent, options?: NotificationOptions<TMetadata>);
|
|
21
|
+
/** Read-only alias of `message` — do not add a setter. */
|
|
22
|
+
get title(): string;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Read `intent` instead.
|
|
25
|
+
*
|
|
26
|
+
* The return type is widened to include `'default'` because `default` is
|
|
27
|
+
* new vocabulary introduced alongside this getter's deprecation — it has
|
|
28
|
+
* no equivalent in the old `NotificationAppearance` names, so mapping it
|
|
29
|
+
* onto `'info'` here would silently lie about the notification's intent.
|
|
30
|
+
* Everything else keeps the old four-value shape.
|
|
31
|
+
*/
|
|
32
|
+
get appearance(): 'default' | 'info' | 'success' | 'warning' | 'error';
|
|
33
|
+
/**
|
|
34
|
+
* Mutate the notification in place. Used by `promise()` so a settling
|
|
35
|
+
* promise swaps the content of the toast already on screen rather than
|
|
36
|
+
* replacing it with a new one.
|
|
37
|
+
*/
|
|
38
|
+
update(changes: NotificationUpdate): void;
|
|
14
39
|
remove(): void;
|
|
15
40
|
}
|
|
@@ -9,6 +9,28 @@ export interface CustomAction {
|
|
|
9
9
|
*/
|
|
10
10
|
onClick: () => void;
|
|
11
11
|
}
|
|
12
|
+
export type NotificationIntent = 'default' | 'info' | 'success' | 'warning' | 'danger';
|
|
13
|
+
/**
|
|
14
|
+
* The deprecated intent names. `error` maps onto `danger`.
|
|
15
|
+
*/
|
|
16
|
+
export type NotificationAppearance = 'info' | 'success' | 'warning' | 'error';
|
|
17
|
+
export interface NotificationContent {
|
|
18
|
+
/**
|
|
19
|
+
* The heading line of the notification.
|
|
20
|
+
*/
|
|
21
|
+
title: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional supporting line rendered below the title.
|
|
24
|
+
*/
|
|
25
|
+
description?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface NotificationUpdate {
|
|
28
|
+
title?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
intent?: NotificationIntent;
|
|
31
|
+
allowClosing?: boolean;
|
|
32
|
+
isLoading?: boolean;
|
|
33
|
+
}
|
|
12
34
|
export interface NotificationOptions<TMetadata extends Record<string, unknown> = Record<string, unknown>> {
|
|
13
35
|
/**
|
|
14
36
|
* If set to false, the close button will not be displayed.
|
|
@@ -30,11 +52,36 @@ export interface NotificationOptions<TMetadata extends Record<string, unknown> =
|
|
|
30
52
|
duration?: number;
|
|
31
53
|
transitionDuration?: number;
|
|
32
54
|
/**
|
|
33
|
-
*
|
|
55
|
+
* Supporting text rendered below the title.
|
|
56
|
+
*
|
|
57
|
+
* @defaultValue undefined
|
|
58
|
+
*/
|
|
59
|
+
description?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The intent of the notification.
|
|
62
|
+
*
|
|
63
|
+
* @defaultValue 'default'
|
|
64
|
+
*/
|
|
65
|
+
intent?: NotificationIntent;
|
|
66
|
+
/**
|
|
67
|
+
* The appearance of the notification.
|
|
68
|
+
*
|
|
69
|
+
* @deprecated Use `intent` instead. `error` maps onto `danger`.
|
|
70
|
+
* @defaultValue undefined
|
|
71
|
+
*/
|
|
72
|
+
appearance?: NotificationAppearance;
|
|
73
|
+
/**
|
|
74
|
+
* Hide the leading icon.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue false
|
|
77
|
+
*/
|
|
78
|
+
hideIcon?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Render a spinner in place of the intent icon. Set by `promise()`.
|
|
34
81
|
*
|
|
35
|
-
* @defaultValue
|
|
82
|
+
* @defaultValue false
|
|
36
83
|
*/
|
|
37
|
-
|
|
84
|
+
isLoading?: boolean;
|
|
38
85
|
/**
|
|
39
86
|
* A list of custom actions
|
|
40
87
|
*
|
|
@@ -48,6 +95,25 @@ export interface NotificationOptions<TMetadata extends Record<string, unknown> =
|
|
|
48
95
|
*/
|
|
49
96
|
metadata?: TMetadata;
|
|
50
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* A promise notification message: a fixed string, a fixed content object, or
|
|
100
|
+
* a function of the settled value.
|
|
101
|
+
*/
|
|
102
|
+
export type PromiseMessage<T> = string | NotificationContent | ((value: T) => string | NotificationContent);
|
|
103
|
+
export interface PromiseNotificationOptions<T, TMetadata extends Record<string, unknown> = Record<string, unknown>> extends Omit<NotificationOptions<TMetadata>, 'isLoading'> {
|
|
104
|
+
/**
|
|
105
|
+
* Shown with a spinner while the promise is pending.
|
|
106
|
+
*/
|
|
107
|
+
loading: string | NotificationContent;
|
|
108
|
+
/**
|
|
109
|
+
* Shown when the promise resolves.
|
|
110
|
+
*/
|
|
111
|
+
success: PromiseMessage<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Shown when the promise rejects.
|
|
114
|
+
*/
|
|
115
|
+
error: PromiseMessage<unknown>;
|
|
116
|
+
}
|
|
51
117
|
export interface DefaultConfig extends NotificationOptions {
|
|
52
118
|
/**
|
|
53
119
|
* If set to true, we will preserve the notification, therefore skiping the timer.
|
|
@@ -34,6 +34,19 @@ export interface ButtonArgs {
|
|
|
34
34
|
* when using the ButtonGroup component.
|
|
35
35
|
*/
|
|
36
36
|
isInGroup?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Renders a spinner in place of the icon and disables the button.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue false
|
|
41
|
+
*/
|
|
42
|
+
isLoading?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Which side the `icon` block — and the loading spinner that replaces it —
|
|
45
|
+
* sits on.
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue 'start'
|
|
48
|
+
*/
|
|
49
|
+
iconPlacement?: 'start' | 'end';
|
|
37
50
|
/**
|
|
38
51
|
* Callback for when the button is pressed.
|
|
39
52
|
*/
|
|
@@ -44,14 +57,30 @@ interface ButtonSignature {
|
|
|
44
57
|
Blocks: {
|
|
45
58
|
default: [{
|
|
46
59
|
classNames: string;
|
|
60
|
+
isLoading: boolean;
|
|
47
61
|
}];
|
|
62
|
+
icon?: [];
|
|
63
|
+
loading?: [];
|
|
48
64
|
};
|
|
49
65
|
Element: HTMLButtonElement;
|
|
50
66
|
}
|
|
51
67
|
declare class Button extends Component<ButtonSignature> {
|
|
52
68
|
isPressed: boolean;
|
|
53
69
|
get type(): string;
|
|
70
|
+
get isLoading(): boolean;
|
|
71
|
+
get isIconAtEnd(): boolean;
|
|
72
|
+
get isIconAtStart(): boolean;
|
|
54
73
|
get classNames(): string;
|
|
74
|
+
get spinnerClassNames(): string;
|
|
75
|
+
/**
|
|
76
|
+
* The object yielded to the default block (and, when `@isRenderless`, in
|
|
77
|
+
* place of rendering). Hoisted so the shape is written once — it's part of
|
|
78
|
+
* this component's public contract, asserted on directly by tests.
|
|
79
|
+
*/
|
|
80
|
+
get yieldedHash(): {
|
|
81
|
+
classNames: string;
|
|
82
|
+
isLoading: boolean;
|
|
83
|
+
};
|
|
55
84
|
handlePressChange: (isPressed: boolean) => void;
|
|
56
85
|
onPress: (event: PressEvent) => void;
|
|
57
86
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type { SegmentedControlContext } from './segmented-control';
|
|
3
|
+
interface SegmentedControlItemArgs<T> {
|
|
4
|
+
/**
|
|
5
|
+
* The value this item represents. Selecting it calls the control's
|
|
6
|
+
* `@onChange` with exactly this value.
|
|
7
|
+
*/
|
|
8
|
+
value: T;
|
|
9
|
+
/**
|
|
10
|
+
* Disables this item alone: it cannot be clicked and keyboard navigation
|
|
11
|
+
* skips over it. The whole control can be disabled with the control's own
|
|
12
|
+
* `@isDisabled`.
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue false
|
|
15
|
+
*/
|
|
16
|
+
isDisabled?: boolean;
|
|
17
|
+
/** Class names appended to this item's theme classes. */
|
|
18
|
+
class?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Supplied by SegmentedControl. Not part of the public API.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
context: SegmentedControlContext<T>;
|
|
25
|
+
}
|
|
26
|
+
interface SegmentedControlItemSignature<T> {
|
|
27
|
+
Args: SegmentedControlItemArgs<T>;
|
|
28
|
+
Blocks: {
|
|
29
|
+
default: [{
|
|
30
|
+
isSelected: boolean;
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
Element: HTMLButtonElement | HTMLLabelElement;
|
|
34
|
+
}
|
|
35
|
+
declare class SegmentedControlItem<T> extends Component<SegmentedControlItemSignature<T>> {
|
|
36
|
+
get isSelected(): boolean;
|
|
37
|
+
get isDisabled(): boolean;
|
|
38
|
+
registerValue: import("ember-modifier").FunctionBasedModifier<{
|
|
39
|
+
Args: {
|
|
40
|
+
Positional: [T];
|
|
41
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
42
|
+
};
|
|
43
|
+
Element: HTMLElement;
|
|
44
|
+
}>;
|
|
45
|
+
handleClick: () => void;
|
|
46
|
+
get stringValue(): string;
|
|
47
|
+
handleChange: () => void;
|
|
48
|
+
}
|
|
49
|
+
export { SegmentedControlItem, type SegmentedControlItemSignature, type SegmentedControlItemArgs };
|
|
50
|
+
export default SegmentedControlItem;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type Owner from '@ember/owner';
|
|
3
|
+
import { type SlotsToClasses } from '@frontile/theme';
|
|
4
|
+
import { type SelectionIndicator } from '../../../utils/selection-indicator';
|
|
5
|
+
import { type RovingFocus } from '../../../utils/roving-focus';
|
|
6
|
+
import SegmentedControlItem from './item';
|
|
7
|
+
import type { SegmentedControlSlots, SegmentedControlVariants } from '@frontile/theme';
|
|
8
|
+
import type { WithBoundArgs } from '@glint/template';
|
|
9
|
+
interface SegmentedControlArgs<T> {
|
|
10
|
+
/**
|
|
11
|
+
* The currently selected value. Compared against each item's `@value` with
|
|
12
|
+
* `===`, so object values must be referentially stable.
|
|
13
|
+
*
|
|
14
|
+
* *Passing* this argument at all puts the component in controlled mode --
|
|
15
|
+
* passing it as `undefined` included, which is how a controlled control says
|
|
16
|
+
* "nothing is selected". The selection then only ever reflects what you
|
|
17
|
+
* pass, so pair it with `@onChange` and update your own state; setting it
|
|
18
|
+
* back to `undefined` clears the selection. Omit the argument entirely to
|
|
19
|
+
* let the control track the selection itself, seeded by `@defaultValue`.
|
|
20
|
+
*/
|
|
21
|
+
value?: T;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the initially selected value when the control is used uncontrolled
|
|
24
|
+
* (that is, when `@value` is not provided). Ignored in controlled mode.
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue undefined
|
|
27
|
+
*/
|
|
28
|
+
defaultValue?: T;
|
|
29
|
+
/** Called with the newly selected value when an item is chosen. */
|
|
30
|
+
onChange?: (value: T) => void;
|
|
31
|
+
/**
|
|
32
|
+
* When set, items render as `<label>` wrapping a native radio input under
|
|
33
|
+
* this name, so the control submits with its form. Without it the control
|
|
34
|
+
* renders buttons and reports only through `onChange`.
|
|
35
|
+
*/
|
|
36
|
+
name?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The colour intent applied to the selected item's indicator and label.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue 'default'
|
|
41
|
+
*/
|
|
42
|
+
intent?: SegmentedControlVariants['intent'];
|
|
43
|
+
/**
|
|
44
|
+
* The visual style of the control's track and indicator.
|
|
45
|
+
*
|
|
46
|
+
* @defaultValue 'solid'
|
|
47
|
+
*/
|
|
48
|
+
variant?: SegmentedControlVariants['variant'];
|
|
49
|
+
/**
|
|
50
|
+
* The size of the control, driving item padding and text size.
|
|
51
|
+
*
|
|
52
|
+
* @defaultValue 'md'
|
|
53
|
+
*/
|
|
54
|
+
size?: SegmentedControlVariants['size'];
|
|
55
|
+
/**
|
|
56
|
+
* Lays the items out in a row or a column, and switches the arrow keys that
|
|
57
|
+
* move between them to match.
|
|
58
|
+
*
|
|
59
|
+
* @defaultValue 'horizontal'
|
|
60
|
+
*/
|
|
61
|
+
orientation?: SegmentedControlVariants['orientation'];
|
|
62
|
+
/**
|
|
63
|
+
* Stretches the control to its container and gives every item equal width.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue false
|
|
66
|
+
*/
|
|
67
|
+
isFullWidth?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Draws a hairline between neighbouring items, hidden around the selected
|
|
70
|
+
* one so the indicator never crosses a visible line.
|
|
71
|
+
*
|
|
72
|
+
* @defaultValue false
|
|
73
|
+
*/
|
|
74
|
+
hasSeparators?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Disables every item. Individual items can be disabled with the item's own
|
|
77
|
+
* `@isDisabled`.
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue false
|
|
80
|
+
*/
|
|
81
|
+
isDisabled?: boolean;
|
|
82
|
+
/** Class names for each slot of the component, merged with the theme's. */
|
|
83
|
+
classes?: SlotsToClasses<SegmentedControlSlots>;
|
|
84
|
+
}
|
|
85
|
+
interface SegmentedControlContext<T> {
|
|
86
|
+
indicator: SelectionIndicator;
|
|
87
|
+
roving: RovingFocus;
|
|
88
|
+
isSelected: (value: T) => boolean;
|
|
89
|
+
select: (value: T) => void;
|
|
90
|
+
registerValue: (element: HTMLElement, value: T) => void;
|
|
91
|
+
unregisterValue: (element: HTMLElement) => void;
|
|
92
|
+
isGroupDisabled: boolean;
|
|
93
|
+
name?: string;
|
|
94
|
+
itemClass: string;
|
|
95
|
+
requestFormSync: () => void;
|
|
96
|
+
}
|
|
97
|
+
interface SegmentedControlSignature<T> {
|
|
98
|
+
Args: SegmentedControlArgs<T>;
|
|
99
|
+
Blocks: {
|
|
100
|
+
default: [
|
|
101
|
+
{
|
|
102
|
+
Item: WithBoundArgs<typeof SegmentedControlItem<T>, 'context'>;
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
};
|
|
106
|
+
Element: HTMLDivElement;
|
|
107
|
+
}
|
|
108
|
+
declare class SegmentedControl<T> extends Component<SegmentedControlSignature<T>> {
|
|
109
|
+
#private;
|
|
110
|
+
indicator: SelectionIndicator;
|
|
111
|
+
_value: T | undefined;
|
|
112
|
+
roving: RovingFocus;
|
|
113
|
+
constructor(owner: Owner, args: SegmentedControlSignature<T>['Args']);
|
|
114
|
+
get styles(): {
|
|
115
|
+
base: (slotProps?: ({
|
|
116
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
117
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
118
|
+
variant?: "solid" | "ghost" | undefined;
|
|
119
|
+
isDisabled?: boolean | undefined;
|
|
120
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
121
|
+
isFullWidth?: boolean | undefined;
|
|
122
|
+
hasSeparators?: boolean | undefined;
|
|
123
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
124
|
+
indicator: (slotProps?: ({
|
|
125
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
126
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
127
|
+
variant?: "solid" | "ghost" | undefined;
|
|
128
|
+
isDisabled?: boolean | undefined;
|
|
129
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
130
|
+
isFullWidth?: boolean | undefined;
|
|
131
|
+
hasSeparators?: boolean | undefined;
|
|
132
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
133
|
+
item: (slotProps?: ({
|
|
134
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
135
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
136
|
+
variant?: "solid" | "ghost" | undefined;
|
|
137
|
+
isDisabled?: boolean | undefined;
|
|
138
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
139
|
+
isFullWidth?: boolean | undefined;
|
|
140
|
+
hasSeparators?: boolean | undefined;
|
|
141
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
142
|
+
} & {
|
|
143
|
+
base: (slotProps?: ({
|
|
144
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
145
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
146
|
+
variant?: "solid" | "ghost" | undefined;
|
|
147
|
+
isDisabled?: boolean | undefined;
|
|
148
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
149
|
+
isFullWidth?: boolean | undefined;
|
|
150
|
+
hasSeparators?: boolean | undefined;
|
|
151
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
152
|
+
indicator: (slotProps?: ({
|
|
153
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
154
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
155
|
+
variant?: "solid" | "ghost" | undefined;
|
|
156
|
+
isDisabled?: boolean | undefined;
|
|
157
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
158
|
+
isFullWidth?: boolean | undefined;
|
|
159
|
+
hasSeparators?: boolean | undefined;
|
|
160
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
161
|
+
item: (slotProps?: ({
|
|
162
|
+
size?: "sm" | "md" | "lg" | undefined;
|
|
163
|
+
intent?: "default" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | undefined;
|
|
164
|
+
variant?: "solid" | "ghost" | undefined;
|
|
165
|
+
isDisabled?: boolean | undefined;
|
|
166
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
167
|
+
isFullWidth?: boolean | undefined;
|
|
168
|
+
hasSeparators?: boolean | undefined;
|
|
169
|
+
} & import("tailwind-variants").ClassProp<import("tailwind-variants").ClassValue>) | undefined) => string;
|
|
170
|
+
} & {};
|
|
171
|
+
get orientation(): 'horizontal' | 'vertical';
|
|
172
|
+
/**
|
|
173
|
+
* Whether `@value` was *passed* decides the mode -- not whether it holds a
|
|
174
|
+
* value. `@value` is generic, so `undefined` is a legitimate selection
|
|
175
|
+
* meaning "nothing is selected"; testing `!== undefined` (as `Switch` can,
|
|
176
|
+
* because its `@isSelected` is a boolean and `undefined` there really does
|
|
177
|
+
* mean "not passed") would run a controlled control uncontrolled until its
|
|
178
|
+
* first pick, and would make clearing the selection impossible.
|
|
179
|
+
*
|
|
180
|
+
* Glimmer's named-args object carries a key for every argument written in
|
|
181
|
+
* the invoking template, so `in` distinguishes `@value={{undefined}}` from
|
|
182
|
+
* an omitted `@value` -- which `undefined` alone cannot.
|
|
183
|
+
*/
|
|
184
|
+
get isControlled(): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* The selection everything else reads: the argument when controlled, the
|
|
187
|
+
* internal field otherwise. `requestFormSync` re-asserts the native radios
|
|
188
|
+
* from this (via `isSelected`) rather than from `@value`, so an uncontrolled
|
|
189
|
+
* form-mode control does not snap the user's click back.
|
|
190
|
+
*/
|
|
191
|
+
get selectedValue(): T | undefined;
|
|
192
|
+
isSelected: (value: T) => boolean;
|
|
193
|
+
select: (value: T) => void;
|
|
194
|
+
activateElement: (element: HTMLElement) => void;
|
|
195
|
+
registerValue: (element: HTMLElement, value: T) => void;
|
|
196
|
+
unregisterValue: (element: HTMLElement) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Form mode only. A native radio flips its own `checked` the moment it is
|
|
199
|
+
* clicked and Glimmer will not undo that, so the DOM can drift from `@value`
|
|
200
|
+
* when a consumer declines the change.
|
|
201
|
+
*
|
|
202
|
+
* It waits a frame rather than correcting synchronously: reading `@value`
|
|
203
|
+
* inside the change handler would see the stale value and stomp a legitimate
|
|
204
|
+
* update.
|
|
205
|
+
*/
|
|
206
|
+
requestFormSync: () => void;
|
|
207
|
+
get context(): SegmentedControlContext<T>;
|
|
208
|
+
}
|
|
209
|
+
export { SegmentedControl, type SegmentedControlSignature, type SegmentedControlArgs, type SegmentedControlContext };
|
|
210
|
+
export default SegmentedControl;
|