foldkit 0.100.1 → 0.102.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/README.md +3 -2
- package/dist/canvas/view.d.ts +1 -1
- package/dist/canvas/view.d.ts.map +1 -1
- package/dist/canvas/view.js +5 -5
- package/dist/command/index.d.ts +71 -0
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +34 -1
- package/dist/command/public.d.ts +1 -1
- package/dist/command/public.d.ts.map +1 -1
- package/dist/command/public.js +1 -1
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/overlay.js +156 -149
- package/dist/dom/dom.d.ts +8 -11
- package/dist/dom/dom.d.ts.map +1 -1
- package/dist/dom/dom.js +8 -11
- package/dist/dom/elementMovement.d.ts +1 -3
- package/dist/dom/elementMovement.d.ts.map +1 -1
- package/dist/dom/elementMovement.js +1 -3
- package/dist/dom/inert.d.ts +2 -4
- package/dist/dom/inert.d.ts.map +1 -1
- package/dist/dom/inert.js +2 -4
- package/dist/dom/scrollLock.d.ts +2 -2
- package/dist/dom/scrollLock.js +2 -2
- package/dist/dom/waitForAnimation.d.ts +1 -1
- package/dist/dom/waitForAnimation.js +1 -1
- package/dist/html/boundary.d.ts +98 -0
- package/dist/html/boundary.d.ts.map +1 -0
- package/dist/html/boundary.js +176 -0
- package/dist/html/childAttribute.d.ts +44 -0
- package/dist/html/childAttribute.d.ts.map +1 -0
- package/dist/html/childAttribute.js +34 -0
- package/dist/html/index.d.ts +70 -23
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +639 -575
- package/dist/html/lazy.d.ts +12 -7
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +30 -11
- package/dist/html/public.d.ts +2 -2
- package/dist/html/public.d.ts.map +1 -1
- package/dist/html/public.js +1 -1
- package/dist/html/runtimeSingleton.d.ts +72 -0
- package/dist/html/runtimeSingleton.d.ts.map +1 -0
- package/dist/html/runtimeSingleton.js +112 -0
- package/dist/html/submodel.d.ts +98 -0
- package/dist/html/submodel.d.ts.map +1 -0
- package/dist/html/submodel.js +190 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/render/render.d.ts +1 -1
- package/dist/render/render.js +1 -1
- package/dist/runtime/messagePriority.d.ts +5 -1
- package/dist/runtime/messagePriority.d.ts.map +1 -1
- package/dist/runtime/messagePriority.js +25 -4
- package/dist/runtime/runtime.d.ts +11 -11
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +118 -63
- package/dist/runtime/subscription.d.ts +139 -19
- package/dist/runtime/subscription.d.ts.map +1 -1
- package/dist/runtime/subscription.js +90 -9
- package/dist/submodel/public.d.ts +4 -0
- package/dist/submodel/public.d.ts.map +1 -0
- package/dist/submodel/public.js +1 -0
- package/dist/submodel/submodel.d.ts +32 -0
- package/dist/submodel/submodel.d.ts.map +1 -0
- package/dist/submodel/submodel.js +1 -0
- package/dist/subscription/animationFrame.d.ts +23 -26
- package/dist/subscription/animationFrame.d.ts.map +1 -1
- package/dist/subscription/animationFrame.js +17 -18
- package/dist/subscription/public.d.ts +2 -2
- package/dist/subscription/public.d.ts.map +1 -1
- package/dist/subscription/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +4 -5
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +16 -16
- package/dist/test/scene.d.ts +8 -8
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +25 -13
- package/dist/test/story.d.ts +15 -8
- package/dist/test/story.d.ts.map +1 -1
- package/dist/test/story.js +21 -9
- package/dist/ui/animation/index.d.ts +30 -14
- package/dist/ui/animation/index.d.ts.map +1 -1
- package/dist/ui/animation/index.js +9 -19
- package/dist/ui/animation/public.d.ts +2 -2
- package/dist/ui/animation/public.d.ts.map +1 -1
- package/dist/ui/animation/public.js +1 -1
- package/dist/ui/calendar/index.d.ts +199 -84
- package/dist/ui/calendar/index.d.ts.map +1 -1
- package/dist/ui/calendar/index.js +129 -140
- package/dist/ui/calendar/public.d.ts +2 -2
- package/dist/ui/calendar/public.d.ts.map +1 -1
- package/dist/ui/calendar/public.js +1 -1
- package/dist/ui/checkbox/index.d.ts +93 -21
- package/dist/ui/checkbox/index.d.ts.map +1 -1
- package/dist/ui/checkbox/index.js +62 -33
- package/dist/ui/checkbox/public.d.ts +2 -2
- package/dist/ui/checkbox/public.d.ts.map +1 -1
- package/dist/ui/checkbox/public.js +1 -1
- package/dist/ui/combobox/multi.d.ts +35 -91
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/multi.js +34 -17
- package/dist/ui/combobox/multiPublic.d.ts +2 -2
- package/dist/ui/combobox/multiPublic.d.ts.map +1 -1
- package/dist/ui/combobox/multiPublic.js +1 -1
- package/dist/ui/combobox/public.d.ts +3 -3
- package/dist/ui/combobox/public.d.ts.map +1 -1
- package/dist/ui/combobox/public.js +2 -2
- package/dist/ui/combobox/shared.d.ts +56 -31
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +333 -322
- package/dist/ui/combobox/single.d.ts +46 -93
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/combobox/single.js +44 -17
- package/dist/ui/datePicker/index.d.ts +256 -48
- package/dist/ui/datePicker/index.d.ts.map +1 -1
- package/dist/ui/datePicker/index.js +149 -104
- package/dist/ui/datePicker/public.d.ts +2 -2
- package/dist/ui/datePicker/public.d.ts.map +1 -1
- package/dist/ui/datePicker/public.js +1 -1
- package/dist/ui/dialog/index.d.ts +95 -39
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +71 -62
- package/dist/ui/dialog/public.d.ts +2 -2
- package/dist/ui/dialog/public.d.ts.map +1 -1
- package/dist/ui/dialog/public.js +1 -1
- package/dist/ui/disclosure/index.d.ts +71 -31
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +57 -62
- package/dist/ui/disclosure/public.d.ts +2 -2
- package/dist/ui/disclosure/public.d.ts.map +1 -1
- package/dist/ui/disclosure/public.js +1 -1
- package/dist/ui/dragAndDrop/index.d.ts +385 -103
- package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/index.js +26 -31
- package/dist/ui/dragAndDrop/public.d.ts +1 -1
- package/dist/ui/dragAndDrop/public.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/public.js +1 -1
- package/dist/ui/fileDrop/index.d.ts +42 -46
- package/dist/ui/fileDrop/index.d.ts.map +1 -1
- package/dist/ui/fileDrop/index.js +30 -46
- package/dist/ui/fileDrop/public.d.ts +2 -2
- package/dist/ui/fileDrop/public.d.ts.map +1 -1
- package/dist/ui/fileDrop/public.js +1 -1
- package/dist/ui/listbox/multi.d.ts +39 -84
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/multi.js +38 -20
- package/dist/ui/listbox/multiPublic.d.ts +2 -2
- package/dist/ui/listbox/multiPublic.d.ts.map +1 -1
- package/dist/ui/listbox/multiPublic.js +1 -1
- package/dist/ui/listbox/public.d.ts +3 -3
- package/dist/ui/listbox/public.d.ts.map +1 -1
- package/dist/ui/listbox/public.js +2 -2
- package/dist/ui/listbox/shared.d.ts +71 -30
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +319 -296
- package/dist/ui/listbox/single.d.ts +57 -85
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/listbox/single.js +48 -24
- package/dist/ui/menu/index.d.ts +80 -36
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +117 -86
- package/dist/ui/menu/public.d.ts +2 -2
- package/dist/ui/menu/public.d.ts.map +1 -1
- package/dist/ui/menu/public.js +1 -1
- package/dist/ui/popover/index.d.ts +117 -44
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +88 -101
- package/dist/ui/popover/public.d.ts +2 -2
- package/dist/ui/popover/public.d.ts.map +1 -1
- package/dist/ui/popover/public.js +1 -1
- package/dist/ui/radioGroup/index.d.ts +122 -45
- package/dist/ui/radioGroup/index.d.ts.map +1 -1
- package/dist/ui/radioGroup/index.js +111 -72
- package/dist/ui/radioGroup/public.d.ts +2 -2
- package/dist/ui/radioGroup/public.d.ts.map +1 -1
- package/dist/ui/radioGroup/public.js +1 -1
- package/dist/ui/slider/index.d.ts +247 -103
- package/dist/ui/slider/index.d.ts.map +1 -1
- package/dist/ui/slider/index.js +52 -68
- package/dist/ui/slider/public.d.ts +2 -2
- package/dist/ui/slider/public.d.ts.map +1 -1
- package/dist/ui/slider/public.js +1 -1
- package/dist/ui/switch/index.d.ts +74 -21
- package/dist/ui/switch/index.d.ts.map +1 -1
- package/dist/ui/switch/index.js +62 -33
- package/dist/ui/switch/public.d.ts +2 -2
- package/dist/ui/switch/public.d.ts.map +1 -1
- package/dist/ui/switch/public.js +1 -1
- package/dist/ui/tabs/index.d.ts +107 -45
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +99 -81
- package/dist/ui/tabs/public.d.ts +2 -2
- package/dist/ui/tabs/public.d.ts.map +1 -1
- package/dist/ui/tabs/public.js +1 -1
- package/dist/ui/toast/index.d.ts +93 -109
- package/dist/ui/toast/index.d.ts.map +1 -1
- package/dist/ui/toast/index.js +16 -29
- package/dist/ui/toast/schema.d.ts +15 -4
- package/dist/ui/toast/schema.d.ts.map +1 -1
- package/dist/ui/toast/schema.js +11 -4
- package/dist/ui/toast/update.d.ts +36 -18
- package/dist/ui/toast/update.d.ts.map +1 -1
- package/dist/ui/toast/update.js +33 -14
- package/dist/ui/tooltip/index.d.ts +94 -42
- package/dist/ui/tooltip/index.d.ts.map +1 -1
- package/dist/ui/tooltip/index.js +64 -73
- package/dist/ui/tooltip/public.d.ts +2 -2
- package/dist/ui/tooltip/public.d.ts.map +1 -1
- package/dist/ui/tooltip/public.js +1 -1
- package/dist/ui/virtualList/index.d.ts +63 -80
- package/dist/ui/virtualList/index.d.ts.map +1 -1
- package/dist/ui/virtualList/index.js +22 -49
- package/dist/ui/virtualList/public.d.ts +2 -2
- package/dist/ui/virtualList/public.d.ts.map +1 -1
- package/dist/ui/virtualList/public.js +1 -1
- package/package.json +1 -1
package/dist/ui/toast/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
|
-
import { type
|
|
2
|
+
import { type ChildAttribute, type Html } from '../../html/index.js';
|
|
3
3
|
import { Dismissed, DismissedAll, ElapsedDuration, GotAnimationMessage, HoveredEntry, LeftEntry, Position, Variant } from './schema.js';
|
|
4
4
|
import { DismissAfter } from './update.js';
|
|
5
5
|
export type { InitConfig } from './schema.js';
|
|
6
6
|
export type { ShowInput } from './update.js';
|
|
7
7
|
export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, };
|
|
8
|
-
/** Handlers passed to `
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/** Handlers passed to `entryToView`. Spread `dismiss` onto a close
|
|
9
|
+
* button's attribute array (typically inside `h.button([...dismiss])`)
|
|
10
|
+
* to let users dismiss the entry manually. The attribute carries the
|
|
11
|
+
* Toast's dismiss handler bound to this entry's id; it routes through
|
|
12
|
+
* the Toast boundary's wrap chain at click time. */
|
|
13
|
+
export type EntryHandlers = Readonly<{
|
|
14
|
+
dismiss: ReadonlyArray<ChildAttribute>;
|
|
12
15
|
}>;
|
|
13
16
|
/** Factory that binds `Ui.Toast` to a user-provided payload schema. The
|
|
14
17
|
* returned module contains everything needed to wire a toast stack into an
|
|
@@ -16,11 +19,11 @@ export type EntryHandlers<ParentMessage> = Readonly<{
|
|
|
16
19
|
* `dismiss` / `dismissAll` helpers, and the headless `view`.
|
|
17
20
|
*
|
|
18
21
|
* The payload is whatever content shape the consumer supplies via Schema.
|
|
19
|
-
* The component never reads it
|
|
22
|
+
* The component never reads it. It flows through to `entryToView`. The
|
|
20
23
|
* component itself owns only lifecycle and a11y fields (id, variant,
|
|
21
24
|
* animation, dismiss timer, hover state).
|
|
22
25
|
*
|
|
23
|
-
* Consume the bound module's exports everywhere
|
|
26
|
+
* Consume the bound module's exports everywhere. `Toast.Model` in your app
|
|
24
27
|
* Model, `Toast.Message` in your parent Message union, `Toast.show` /
|
|
25
28
|
* `Toast.dismiss` in your update, `Toast.view` in your view. The top-level
|
|
26
29
|
* exports (`Variant`, `Position`, static message tags, `DismissAfter`) are
|
|
@@ -40,30 +43,12 @@ export type EntryHandlers<ParentMessage> = Readonly<{
|
|
|
40
43
|
* ```
|
|
41
44
|
*/
|
|
42
45
|
export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
43
|
-
readonly view:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
readonly entries: readonly {
|
|
48
|
-
readonly id: string;
|
|
49
|
-
readonly variant: "Success" | "Error" | "Info" | "Warning";
|
|
50
|
-
readonly animation: {
|
|
51
|
-
readonly id: string;
|
|
52
|
-
readonly isShowing: boolean;
|
|
53
|
-
readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
|
|
54
|
-
};
|
|
55
|
-
readonly maybeDuration: import("effect/Option").Option<import("effect/Duration").Duration>;
|
|
56
|
-
readonly pendingDismissVersion: number;
|
|
57
|
-
readonly isHovered: boolean;
|
|
58
|
-
readonly payload: A;
|
|
59
|
-
}[];
|
|
60
|
-
readonly nextEntryKey: number;
|
|
61
|
-
};
|
|
62
|
-
position: Position;
|
|
63
|
-
toParentMessage: (message: Dismissed | HoveredEntry | LeftEntry) => ParentMessage;
|
|
64
|
-
renderEntry: (entry: {
|
|
46
|
+
readonly view: import("../../html/submodel.js").SubmodelView<{
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly defaultDuration: import("effect/Duration").Duration;
|
|
49
|
+
readonly entries: readonly {
|
|
65
50
|
readonly id: string;
|
|
66
|
-
readonly variant: "
|
|
51
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
67
52
|
readonly animation: {
|
|
68
53
|
readonly id: string;
|
|
69
54
|
readonly isShowing: boolean;
|
|
@@ -73,39 +58,40 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
73
58
|
readonly pendingDismissVersion: number;
|
|
74
59
|
readonly isHovered: boolean;
|
|
75
60
|
readonly payload: A;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
61
|
+
}[];
|
|
62
|
+
readonly nextEntryKey: number;
|
|
63
|
+
}, {
|
|
64
|
+
readonly _tag: "Dismissed";
|
|
65
|
+
readonly entryId: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly _tag: "DismissedAll";
|
|
68
|
+
} | {
|
|
69
|
+
readonly _tag: "ElapsedDuration";
|
|
70
|
+
readonly entryId: string;
|
|
71
|
+
readonly version: number;
|
|
72
|
+
} | {
|
|
73
|
+
readonly _tag: "HoveredEntry";
|
|
74
|
+
readonly entryId: string;
|
|
75
|
+
} | {
|
|
76
|
+
readonly _tag: "LeftEntry";
|
|
77
|
+
readonly entryId: string;
|
|
78
|
+
} | {
|
|
79
|
+
readonly _tag: "GotAnimationMessage";
|
|
80
|
+
readonly entryId: string;
|
|
81
|
+
readonly message: {
|
|
82
|
+
readonly _tag: "Showed";
|
|
83
|
+
} | {
|
|
84
|
+
readonly _tag: "Hid";
|
|
85
|
+
} | {
|
|
86
|
+
readonly _tag: "AdvancedAnimationFrame";
|
|
87
|
+
} | {
|
|
88
|
+
readonly _tag: "EndedAnimation";
|
|
103
89
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
} | {
|
|
91
|
+
readonly _tag: "Added";
|
|
92
|
+
readonly entry: {
|
|
107
93
|
readonly id: string;
|
|
108
|
-
readonly variant: "
|
|
94
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
109
95
|
readonly animation: {
|
|
110
96
|
readonly id: string;
|
|
111
97
|
readonly isShowing: boolean;
|
|
@@ -115,20 +101,12 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
115
101
|
readonly pendingDismissVersion: number;
|
|
116
102
|
readonly isHovered: boolean;
|
|
117
103
|
readonly payload: A;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
className?: string;
|
|
123
|
-
attributes?: readonly Attribute<ParentMessage>[];
|
|
124
|
-
entryClassName?: string;
|
|
125
|
-
entryAttributes?: readonly Attribute<ParentMessage>[];
|
|
126
|
-
}>, "model" | "toParentMessage" | "renderEntry">) => ((model: {
|
|
127
|
-
readonly id: string;
|
|
128
|
-
readonly defaultDuration: import("effect/Duration").Duration;
|
|
129
|
-
readonly entries: readonly {
|
|
104
|
+
};
|
|
105
|
+
}, Readonly<{
|
|
106
|
+
position: Position;
|
|
107
|
+
entryToView: (entry: {
|
|
130
108
|
readonly id: string;
|
|
131
|
-
readonly variant: "
|
|
109
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
132
110
|
readonly animation: {
|
|
133
111
|
readonly id: string;
|
|
134
112
|
readonly isShowing: boolean;
|
|
@@ -138,23 +116,11 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
138
116
|
readonly pendingDismissVersion: number;
|
|
139
117
|
readonly isHovered: boolean;
|
|
140
118
|
readonly payload: A;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
readonly animation: {
|
|
147
|
-
readonly id: string;
|
|
148
|
-
readonly isShowing: boolean;
|
|
149
|
-
readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
|
|
150
|
-
};
|
|
151
|
-
readonly maybeDuration: import("effect/Option").Option<import("effect/Duration").Duration>;
|
|
152
|
-
readonly pendingDismissVersion: number;
|
|
153
|
-
readonly isHovered: boolean;
|
|
154
|
-
readonly payload: A;
|
|
155
|
-
}, handlers: Readonly<{
|
|
156
|
-
dismiss: ParentMessage;
|
|
157
|
-
}>) => Html) => Html);
|
|
119
|
+
}, handlers: EntryHandlers) => Html;
|
|
120
|
+
ariaLabel?: string;
|
|
121
|
+
containerClassName?: string;
|
|
122
|
+
entryClassName?: string;
|
|
123
|
+
}>>;
|
|
158
124
|
readonly Entry: S.Struct<{
|
|
159
125
|
readonly id: S.String;
|
|
160
126
|
readonly variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
|
|
@@ -213,6 +179,9 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
213
179
|
entryId: S.String;
|
|
214
180
|
message: S.Union<[import("../../schema/index.js").CallableTaggedStruct<"Showed", {}>, import("../../schema/index.js").CallableTaggedStruct<"Hid", {}>, import("../../schema/index.js").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("../../schema/index.js").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
215
181
|
}>]>;
|
|
182
|
+
readonly OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
|
|
183
|
+
payload: S.Codec<A, I, never, never>;
|
|
184
|
+
}>]>;
|
|
216
185
|
readonly Added: import("../../schema/index.js").CallableTaggedStruct<"Added", {
|
|
217
186
|
entry: S.Struct<{
|
|
218
187
|
readonly id: S.String;
|
|
@@ -228,6 +197,9 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
228
197
|
readonly payload: S.Codec<A, I, never, never>;
|
|
229
198
|
}>;
|
|
230
199
|
}>;
|
|
200
|
+
readonly DismissedToast: import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
|
|
201
|
+
payload: S.Codec<A, I, never, never>;
|
|
202
|
+
}>;
|
|
231
203
|
readonly init: (config: Readonly<{
|
|
232
204
|
id: string;
|
|
233
205
|
defaultDuration?: import("effect/Duration").Input;
|
|
@@ -236,7 +208,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
236
208
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
237
209
|
readonly entries: readonly {
|
|
238
210
|
readonly id: string;
|
|
239
|
-
readonly variant: "
|
|
211
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
240
212
|
readonly animation: {
|
|
241
213
|
readonly id: string;
|
|
242
214
|
readonly isShowing: boolean;
|
|
@@ -254,7 +226,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
254
226
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
255
227
|
readonly entries: readonly {
|
|
256
228
|
readonly id: string;
|
|
257
|
-
readonly variant: "
|
|
229
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
258
230
|
readonly animation: {
|
|
259
231
|
readonly id: string;
|
|
260
232
|
readonly isShowing: boolean;
|
|
@@ -297,7 +269,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
297
269
|
readonly _tag: "Added";
|
|
298
270
|
readonly entry: {
|
|
299
271
|
readonly id: string;
|
|
300
|
-
readonly variant: "
|
|
272
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
301
273
|
readonly animation: {
|
|
302
274
|
readonly id: string;
|
|
303
275
|
readonly isShowing: boolean;
|
|
@@ -313,7 +285,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
313
285
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
314
286
|
readonly entries: readonly {
|
|
315
287
|
readonly id: string;
|
|
316
|
-
readonly variant: "
|
|
288
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
317
289
|
readonly animation: {
|
|
318
290
|
readonly id: string;
|
|
319
291
|
readonly isShowing: boolean;
|
|
@@ -359,7 +331,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
359
331
|
readonly _tag: "Added";
|
|
360
332
|
readonly entry: {
|
|
361
333
|
readonly id: string;
|
|
362
|
-
readonly variant: "
|
|
334
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
363
335
|
readonly animation: {
|
|
364
336
|
readonly id: string;
|
|
365
337
|
readonly isShowing: boolean;
|
|
@@ -371,13 +343,16 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
371
343
|
readonly payload: A;
|
|
372
344
|
};
|
|
373
345
|
}, never, never>;
|
|
374
|
-
}>[]
|
|
346
|
+
}>[], import("effect/Option").Option<{
|
|
347
|
+
readonly _tag: "DismissedToast";
|
|
348
|
+
readonly payload: A;
|
|
349
|
+
}>];
|
|
375
350
|
readonly show: (model: {
|
|
376
351
|
readonly id: string;
|
|
377
352
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
378
353
|
readonly entries: readonly {
|
|
379
354
|
readonly id: string;
|
|
380
|
-
readonly variant: "
|
|
355
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
381
356
|
readonly animation: {
|
|
382
357
|
readonly id: string;
|
|
383
358
|
readonly isShowing: boolean;
|
|
@@ -399,7 +374,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
399
374
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
400
375
|
readonly entries: readonly {
|
|
401
376
|
readonly id: string;
|
|
402
|
-
readonly variant: "
|
|
377
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
403
378
|
readonly animation: {
|
|
404
379
|
readonly id: string;
|
|
405
380
|
readonly isShowing: boolean;
|
|
@@ -445,7 +420,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
445
420
|
readonly _tag: "Added";
|
|
446
421
|
readonly entry: {
|
|
447
422
|
readonly id: string;
|
|
448
|
-
readonly variant: "
|
|
423
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
449
424
|
readonly animation: {
|
|
450
425
|
readonly id: string;
|
|
451
426
|
readonly isShowing: boolean;
|
|
@@ -457,13 +432,16 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
457
432
|
readonly payload: A;
|
|
458
433
|
};
|
|
459
434
|
}, never, never>;
|
|
460
|
-
}>[]
|
|
435
|
+
}>[], import("effect/Option").Option<{
|
|
436
|
+
readonly _tag: "DismissedToast";
|
|
437
|
+
readonly payload: A;
|
|
438
|
+
}>];
|
|
461
439
|
readonly dismiss: (model: {
|
|
462
440
|
readonly id: string;
|
|
463
441
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
464
442
|
readonly entries: readonly {
|
|
465
443
|
readonly id: string;
|
|
466
|
-
readonly variant: "
|
|
444
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
467
445
|
readonly animation: {
|
|
468
446
|
readonly id: string;
|
|
469
447
|
readonly isShowing: boolean;
|
|
@@ -480,7 +458,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
480
458
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
481
459
|
readonly entries: readonly {
|
|
482
460
|
readonly id: string;
|
|
483
|
-
readonly variant: "
|
|
461
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
484
462
|
readonly animation: {
|
|
485
463
|
readonly id: string;
|
|
486
464
|
readonly isShowing: boolean;
|
|
@@ -526,7 +504,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
526
504
|
readonly _tag: "Added";
|
|
527
505
|
readonly entry: {
|
|
528
506
|
readonly id: string;
|
|
529
|
-
readonly variant: "
|
|
507
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
530
508
|
readonly animation: {
|
|
531
509
|
readonly id: string;
|
|
532
510
|
readonly isShowing: boolean;
|
|
@@ -538,13 +516,16 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
538
516
|
readonly payload: A;
|
|
539
517
|
};
|
|
540
518
|
}, never, never>;
|
|
541
|
-
}>[]
|
|
519
|
+
}>[], import("effect/Option").Option<{
|
|
520
|
+
readonly _tag: "DismissedToast";
|
|
521
|
+
readonly payload: A;
|
|
522
|
+
}>];
|
|
542
523
|
readonly dismissAll: (model: {
|
|
543
524
|
readonly id: string;
|
|
544
525
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
545
526
|
readonly entries: readonly {
|
|
546
527
|
readonly id: string;
|
|
547
|
-
readonly variant: "
|
|
528
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
548
529
|
readonly animation: {
|
|
549
530
|
readonly id: string;
|
|
550
531
|
readonly isShowing: boolean;
|
|
@@ -561,7 +542,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
561
542
|
readonly defaultDuration: import("effect/Duration").Duration;
|
|
562
543
|
readonly entries: readonly {
|
|
563
544
|
readonly id: string;
|
|
564
|
-
readonly variant: "
|
|
545
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
565
546
|
readonly animation: {
|
|
566
547
|
readonly id: string;
|
|
567
548
|
readonly isShowing: boolean;
|
|
@@ -607,7 +588,7 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
607
588
|
readonly _tag: "Added";
|
|
608
589
|
readonly entry: {
|
|
609
590
|
readonly id: string;
|
|
610
|
-
readonly variant: "
|
|
591
|
+
readonly variant: "Error" | "Success" | "Info" | "Warning";
|
|
611
592
|
readonly animation: {
|
|
612
593
|
readonly id: string;
|
|
613
594
|
readonly isShowing: boolean;
|
|
@@ -619,6 +600,9 @@ export declare const make: <A, I>(payloadSchema: S.Codec<A, I>) => {
|
|
|
619
600
|
readonly payload: A;
|
|
620
601
|
};
|
|
621
602
|
}, never, never>;
|
|
622
|
-
}>[]
|
|
603
|
+
}>[], import("effect/Option").Option<{
|
|
604
|
+
readonly _tag: "DismissedToast";
|
|
605
|
+
readonly payload: A;
|
|
606
|
+
}>];
|
|
623
607
|
};
|
|
624
608
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAIV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,OAAO,EACR,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAA;AAEvD,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,YAAY,GACb,CAAA;AA0ED;;;;qDAIqD;AACrD,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CACvC,CAAC,CAAA;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAUzC,QAAQ;qBACL,CAAC,KAAK;;;;;;;;;;;;SAAO,EAAE,QAAQ,EAAE,aAAa,KAAK,IAAI;oBAChD,MAAM;6BACG,MAAM;yBACV,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2F1B,CAAA"}
|
package/dist/ui/toast/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Match as M } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { childAttributes, defineView, html, } from '../../html/index.js';
|
|
3
3
|
import { Dismissed, DismissedAll, ElapsedDuration, GotAnimationMessage, HoveredEntry, LeftEntry, Position, Variant, } from './schema.js';
|
|
4
4
|
import { DismissAfter, makeRuntime } from './update.js';
|
|
5
5
|
export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, };
|
|
@@ -56,11 +56,11 @@ const DEFAULT_ARIA_LABEL = 'Notifications';
|
|
|
56
56
|
* `dismiss` / `dismissAll` helpers, and the headless `view`.
|
|
57
57
|
*
|
|
58
58
|
* The payload is whatever content shape the consumer supplies via Schema.
|
|
59
|
-
* The component never reads it
|
|
59
|
+
* The component never reads it. It flows through to `entryToView`. The
|
|
60
60
|
* component itself owns only lifecycle and a11y fields (id, variant,
|
|
61
61
|
* animation, dismiss timer, hover state).
|
|
62
62
|
*
|
|
63
|
-
* Consume the bound module's exports everywhere
|
|
63
|
+
* Consume the bound module's exports everywhere. `Toast.Model` in your app
|
|
64
64
|
* Model, `Toast.Message` in your parent Message union, `Toast.show` /
|
|
65
65
|
* `Toast.dismiss` in your update, `Toast.view` in your view. The top-level
|
|
66
66
|
* exports (`Variant`, `Position`, static message tags, `DismissAfter`) are
|
|
@@ -87,17 +87,17 @@ export const make = (payloadSchema) => {
|
|
|
87
87
|
* animation data attributes (`data-enter`, `data-leave`,
|
|
88
88
|
* `data-transition`, `data-closed`) and `data-variant` reflecting the
|
|
89
89
|
* entry's variant. */
|
|
90
|
-
const view = (
|
|
90
|
+
const view = defineView((model, viewInputs) => {
|
|
91
91
|
const h = html();
|
|
92
|
-
const {
|
|
92
|
+
const { id, entries } = model;
|
|
93
|
+
const { position, entryToView, ariaLabel = DEFAULT_ARIA_LABEL, containerClassName, entryClassName, } = viewInputs;
|
|
93
94
|
const containerAttributes = [
|
|
94
95
|
h.Id(id),
|
|
95
96
|
h.Role('region'),
|
|
96
97
|
h.AriaLabel(ariaLabel),
|
|
97
98
|
h.AriaLive('polite'),
|
|
98
99
|
h.Style(positionToContainerStyle(position)),
|
|
99
|
-
...(
|
|
100
|
-
...attributes,
|
|
100
|
+
...(containerClassName ? [h.Class(containerClassName)] : []),
|
|
101
101
|
];
|
|
102
102
|
const renderEntryItem = (entry) => {
|
|
103
103
|
const { transitionState } = entry.animation;
|
|
@@ -116,43 +116,30 @@ export const make = (payloadSchema) => {
|
|
|
116
116
|
h.DataAttribute('leave', ''),
|
|
117
117
|
h.DataAttribute('transition', ''),
|
|
118
118
|
]), M.orElse(() => []));
|
|
119
|
-
const handlers = {
|
|
120
|
-
dismiss: toParentMessage(Dismissed({ entryId: entry.id })),
|
|
121
|
-
};
|
|
122
119
|
const itemAttributes = [
|
|
123
120
|
h.Id(entry.id),
|
|
124
121
|
h.Role(variantToRole(entry.variant)),
|
|
125
122
|
h.AriaAtomic(true),
|
|
126
123
|
h.DataAttribute('variant', entry.variant),
|
|
127
124
|
h.Style({ pointerEvents: 'auto' }),
|
|
128
|
-
h.OnMouseEnter(
|
|
129
|
-
h.OnMouseLeave(
|
|
125
|
+
h.OnMouseEnter(HoveredEntry({ entryId: entry.id })),
|
|
126
|
+
h.OnMouseLeave(LeftEntry({ entryId: entry.id })),
|
|
130
127
|
...animationAttributes,
|
|
131
128
|
...(entryClassName ? [h.Class(entryClassName)] : []),
|
|
132
|
-
...entryAttributes,
|
|
133
129
|
];
|
|
130
|
+
const handlers = {
|
|
131
|
+
dismiss: childAttributes([
|
|
132
|
+
h.OnClick(Dismissed({ entryId: entry.id })),
|
|
133
|
+
]),
|
|
134
|
+
};
|
|
134
135
|
return h.keyed('li')(entry.id, itemAttributes, [
|
|
135
|
-
|
|
136
|
+
entryToView(entry, handlers),
|
|
136
137
|
]);
|
|
137
138
|
};
|
|
138
139
|
return h.keyed('ol')(id, containerAttributes, entries.map(renderEntryItem));
|
|
139
|
-
};
|
|
140
|
-
/** Creates a memoized toast container view. Static config (className,
|
|
141
|
-
* entryClassName, etc.) is captured in a closure. Dynamic fields —
|
|
142
|
-
* `model`, `toParentMessage`, and `renderEntry` — are compared by
|
|
143
|
-
* reference per render via `createLazy`. */
|
|
144
|
-
const lazy = (staticConfig) => {
|
|
145
|
-
const lazyView = createLazy();
|
|
146
|
-
return (model, toParentMessage, renderEntry) => lazyView((currentModel, currentToParentMessage, currentRenderEntry) => view({
|
|
147
|
-
...staticConfig,
|
|
148
|
-
model: currentModel,
|
|
149
|
-
toParentMessage: currentToParentMessage,
|
|
150
|
-
renderEntry: currentRenderEntry,
|
|
151
|
-
}), [model, toParentMessage, renderEntry]);
|
|
152
|
-
};
|
|
140
|
+
});
|
|
153
141
|
return {
|
|
154
142
|
...runtime,
|
|
155
143
|
view,
|
|
156
|
-
lazy,
|
|
157
144
|
};
|
|
158
145
|
};
|
|
@@ -2,7 +2,7 @@ import { Duration, Schema as S } from 'effect';
|
|
|
2
2
|
/** Semantic category of a toast. Drives the default ARIA role: `status` for
|
|
3
3
|
* `Info` / `Success`, `alert` for `Warning` / `Error`. Also surfaced as
|
|
4
4
|
* `data-variant` on each entry for per-variant CSS. This is the only
|
|
5
|
-
* content-adjacent field the component owns
|
|
5
|
+
* content-adjacent field the component owns. The rest of the entry's
|
|
6
6
|
* content lives in the user-provided payload. */
|
|
7
7
|
export declare const Variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
|
|
8
8
|
export type Variant = typeof Variant.Type;
|
|
@@ -10,7 +10,7 @@ export type Variant = typeof Variant.Type;
|
|
|
10
10
|
export declare const Position: S.Literals<readonly ["TopLeft", "TopCenter", "TopRight", "BottomLeft", "BottomCenter", "BottomRight"]>;
|
|
11
11
|
export type Position = typeof Position.Type;
|
|
12
12
|
/** Schema factory for a single toast entry. `payloadSchema` is user-provided
|
|
13
|
-
* and defines the shape of per-entry content
|
|
13
|
+
* and defines the shape of per-entry content, whatever the consumer wants
|
|
14
14
|
* to encode. The component itself owns only lifecycle + a11y fields: `id`,
|
|
15
15
|
* `variant` (for ARIA role), `animation`, `maybeDuration`,
|
|
16
16
|
* `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
|
|
@@ -30,8 +30,8 @@ export declare const makeEntry: <A, I>(payloadSchema: S.Codec<A, I>) => S.Struct
|
|
|
30
30
|
}>;
|
|
31
31
|
/** Schema factory for the toast container's state. `nextEntryKey` is a
|
|
32
32
|
* monotonic counter used to generate unique entry IDs purely from Model
|
|
33
|
-
* state. Thread the updated model through successive `show()` calls
|
|
34
|
-
*
|
|
33
|
+
* state. Thread the updated model through successive `show()` calls.
|
|
34
|
+
* Calling `show()` twice against the same pre-update model in the same tick
|
|
35
35
|
* will produce duplicate entry IDs. */
|
|
36
36
|
export declare const makeModel: <A, I>(payloadSchema: S.Codec<A, I>) => S.Struct<{
|
|
37
37
|
readonly id: S.String;
|
|
@@ -131,6 +131,17 @@ export declare const makeMessage: <A, I>(payloadSchema: S.Codec<A, I>) => S.Unio
|
|
|
131
131
|
entryId: S.String;
|
|
132
132
|
message: S.Union<[import("../../schema/index.js").CallableTaggedStruct<"Showed", {}>, import("../../schema/index.js").CallableTaggedStruct<"Hid", {}>, import("../../schema/index.js").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("../../schema/index.js").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
133
133
|
}>]>;
|
|
134
|
+
/** Factory for `DismissedToast`, the OutMessage emitted once an entry has
|
|
135
|
+
* finished dismissing (leave-animation `TransitionedOut`). Carries the
|
|
136
|
+
* payload so consumers can lift the dismissal into a domain Message
|
|
137
|
+
* without looking the entry up from a stale model. */
|
|
138
|
+
export declare const makeDismissedToast: <A, I>(payloadSchema: S.Codec<A, I>) => import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
|
|
139
|
+
payload: S.Codec<A, I, never, never>;
|
|
140
|
+
}>;
|
|
141
|
+
/** Factory for the union of out-messages the toast component can produce. */
|
|
142
|
+
export declare const makeOutMessage: <A, I>(payloadSchema: S.Codec<A, I>) => S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
|
|
143
|
+
payload: S.Codec<A, I, never, never>;
|
|
144
|
+
}>]>;
|
|
134
145
|
/** Configuration for creating a toast container model. `defaultDuration` is
|
|
135
146
|
* applied to any `show()` call that doesn't provide its own `duration` or
|
|
136
147
|
* pass `sticky: true`. Accepts any Effect Duration input; a bare number is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAU9C;;;;kDAIkD;AAClD,eAAO,MAAM,OAAO,8DAAsD,CAAA;AAC1E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,gFAAgF;AAChF,eAAO,MAAM,QAAQ,wGAOnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAI3C;;;;;4BAK4B;AAC5B,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;EASxD,CAAA;AAIJ;;;;wCAIwC;AACxC,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;EAMxD,CAAA;AAIJ;wEACwE;AACxE,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,uEAAuE;AACvE,eAAO,MAAM,YAAY,0EAAoB,CAAA;AAC7C;;qBAEqB;AACrB,eAAO,MAAM,eAAe;;;EAG1B,CAAA;AACF;qCACqC;AACrC,eAAO,MAAM,YAAY;;EAA2C,CAAA;AACpE;sCACsC;AACtC,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,wEAAwE;AACxE,eAAO,MAAM,mBAAmB;;;EAG9B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAEjE;wDACwD;AACxD,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;EACX,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;IAS1D,CAAA;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAU9C;;;;kDAIkD;AAClD,eAAO,MAAM,OAAO,8DAAsD,CAAA;AAC1E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,gFAAgF;AAChF,eAAO,MAAM,QAAQ,wGAOnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAI3C;;;;;4BAK4B;AAC5B,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;EASxD,CAAA;AAIJ;;;;wCAIwC;AACxC,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;EAMxD,CAAA;AAIJ;wEACwE;AACxE,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,uEAAuE;AACvE,eAAO,MAAM,YAAY,0EAAoB,CAAA;AAC7C;;qBAEqB;AACrB,eAAO,MAAM,eAAe;;;EAG1B,CAAA;AACF;qCACqC;AACrC,eAAO,MAAM,YAAY;;EAA2C,CAAA;AACpE;sCACsC;AACtC,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,wEAAwE;AACxE,eAAO,MAAM,mBAAmB;;;EAG9B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAEjE;wDACwD;AACxD,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;EACX,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;IAS1D,CAAA;AAEJ;;;uDAGuD;AACvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;EACpB,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;IACnB,CAAA;AAI9C;;;mCAGmC;AACnC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,eAAe,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAA;CACjC,CAAC,CAAA;AAEF,eAAO,MAAM,gBAAgB,mBAAsB,CAAA"}
|
package/dist/ui/toast/schema.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Message as AnimationMessage, Model as AnimationModel, } from '../animat
|
|
|
5
5
|
/** Semantic category of a toast. Drives the default ARIA role: `status` for
|
|
6
6
|
* `Info` / `Success`, `alert` for `Warning` / `Error`. Also surfaced as
|
|
7
7
|
* `data-variant` on each entry for per-variant CSS. This is the only
|
|
8
|
-
* content-adjacent field the component owns
|
|
8
|
+
* content-adjacent field the component owns. The rest of the entry's
|
|
9
9
|
* content lives in the user-provided payload. */
|
|
10
10
|
export const Variant = S.Literals(['Info', 'Success', 'Warning', 'Error']);
|
|
11
11
|
// POSITION
|
|
@@ -20,7 +20,7 @@ export const Position = S.Literals([
|
|
|
20
20
|
]);
|
|
21
21
|
// ENTRY
|
|
22
22
|
/** Schema factory for a single toast entry. `payloadSchema` is user-provided
|
|
23
|
-
* and defines the shape of per-entry content
|
|
23
|
+
* and defines the shape of per-entry content, whatever the consumer wants
|
|
24
24
|
* to encode. The component itself owns only lifecycle + a11y fields: `id`,
|
|
25
25
|
* `variant` (for ARIA role), `animation`, `maybeDuration`,
|
|
26
26
|
* `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
|
|
@@ -37,8 +37,8 @@ export const makeEntry = (payloadSchema) => S.Struct({
|
|
|
37
37
|
// MODEL
|
|
38
38
|
/** Schema factory for the toast container's state. `nextEntryKey` is a
|
|
39
39
|
* monotonic counter used to generate unique entry IDs purely from Model
|
|
40
|
-
* state. Thread the updated model through successive `show()` calls
|
|
41
|
-
*
|
|
40
|
+
* state. Thread the updated model through successive `show()` calls.
|
|
41
|
+
* Calling `show()` twice against the same pre-update model in the same tick
|
|
42
42
|
* will produce duplicate entry IDs. */
|
|
43
43
|
export const makeModel = (payloadSchema) => S.Struct({
|
|
44
44
|
id: S.String,
|
|
@@ -83,4 +83,11 @@ export const makeMessage = (payloadSchema) => S.Union([
|
|
|
83
83
|
LeftEntry,
|
|
84
84
|
GotAnimationMessage,
|
|
85
85
|
]);
|
|
86
|
+
/** Factory for `DismissedToast`, the OutMessage emitted once an entry has
|
|
87
|
+
* finished dismissing (leave-animation `TransitionedOut`). Carries the
|
|
88
|
+
* payload so consumers can lift the dismissal into a domain Message
|
|
89
|
+
* without looking the entry up from a stale model. */
|
|
90
|
+
export const makeDismissedToast = (payloadSchema) => m('DismissedToast', { payload: payloadSchema });
|
|
91
|
+
/** Factory for the union of out-messages the toast component can produce. */
|
|
92
|
+
export const makeOutMessage = (payloadSchema) => S.Union([makeDismissedToast(payloadSchema)]);
|
|
86
93
|
export const DEFAULT_DURATION = Duration.seconds(4);
|