@foldkit/ui 0.129.0 → 0.130.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/anchor.js +12 -11
- package/dist/animation/index.js +11 -10
- package/dist/animation/schema.js +3 -2
- package/dist/animation/update.js +26 -25
- package/dist/button/index.js +3 -2
- package/dist/calendar/index.js +159 -158
- package/dist/checkbox/index.js +9 -8
- package/dist/combobox/multi.js +20 -19
- package/dist/combobox/shared.js +169 -168
- package/dist/combobox/single.js +23 -22
- package/dist/datePicker/index.js +69 -68
- package/dist/dialog/index.js +52 -51
- package/dist/disclosure/index.js +11 -10
- package/dist/dragAndDrop/index.js +122 -121
- package/dist/fieldset/index.js +5 -4
- package/dist/fileDrop/index.js +23 -22
- package/dist/group.js +7 -6
- package/dist/input/index.js +4 -3
- package/dist/internal/optionExtensions.js +2 -1
- package/dist/internal/selectors.js +2 -1
- package/dist/keyboard.js +5 -4
- package/dist/listbox/multi.js +12 -11
- package/dist/listbox/shared.js +171 -170
- package/dist/listbox/single.js +13 -12
- package/dist/menu/index.js +167 -166
- package/dist/nav/index.js +7 -6
- package/dist/popover/index.js +87 -86
- package/dist/radioGroup/index.js +23 -22
- package/dist/select/index.js +4 -3
- package/dist/slider/index.js +72 -71
- package/dist/switch/index.js +6 -5
- package/dist/tabs/index.js +34 -33
- package/dist/test/apps/disabledButton.js +17 -16
- package/dist/textarea/index.js +4 -3
- package/dist/toast/index.js +19 -18
- package/dist/toast/schema.js +10 -9
- package/dist/toast/test.js +2 -1
- package/dist/toast/update.js +79 -78
- package/dist/tooltip/index.js +59 -58
- package/dist/typeahead.js +6 -5
- package/dist/virtualList/index.js +66 -65
- package/package.json +4 -3
package/dist/toast/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Match as M } from 'effect';
|
|
2
3
|
import { childAttributes, html, } from 'foldkit/html';
|
|
3
4
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -5,7 +6,7 @@ import { Dismissed, DismissedAll, ElapsedDuration, GotAnimationMessage, HoveredE
|
|
|
5
6
|
import { DismissAfter, makeRuntime } from './update.js';
|
|
6
7
|
export * as test from './test.js';
|
|
7
8
|
export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, };
|
|
8
|
-
const variantToRole = (variant) => M.value(variant).pipe(M.withReturnType(), M.when('Info', () => 'status'), M.when('Success', () => 'status'), M.when('Warning', () => 'alert'), M.when('Error', () => 'alert'), M.exhaustive);
|
|
9
|
+
const variantToRole = (variant) => __foldkitBrandViewResult((M.value(variant).pipe(M.withReturnType(), M.when('Info', () => __foldkitBrandViewResult(('status'), "@foldkit/ui/toast/index.js#anonymous")), M.when('Success', () => __foldkitBrandViewResult(('status'), "@foldkit/ui/toast/index.js#anonymous~2")), M.when('Warning', () => __foldkitBrandViewResult(('alert'), "@foldkit/ui/toast/index.js#anonymous~3")), M.when('Error', () => __foldkitBrandViewResult(('alert'), "@foldkit/ui/toast/index.js#anonymous~4")), M.exhaustive)), "@foldkit/ui/toast/index.js#variantToRole");
|
|
9
10
|
const positionToContainerStyle = (position) => {
|
|
10
11
|
const base = {
|
|
11
12
|
position: 'fixed',
|
|
@@ -17,39 +18,39 @@ const positionToContainerStyle = (position) => {
|
|
|
17
18
|
pointerEvents: 'none',
|
|
18
19
|
zIndex: '2147483600',
|
|
19
20
|
};
|
|
20
|
-
return M.value(position).pipe(M.withReturnType(), M.when('TopLeft', () => ({
|
|
21
|
+
return __foldkitBrandViewResult((M.value(position).pipe(M.withReturnType(), M.when('TopLeft', () => (__foldkitBrandViewResult(({
|
|
21
22
|
...base,
|
|
22
23
|
top: '0',
|
|
23
24
|
left: '0',
|
|
24
25
|
flexDirection: 'column-reverse',
|
|
25
|
-
})), M.when('TopCenter', () => ({
|
|
26
|
+
}), "@foldkit/ui/toast/index.js#anonymous~5"))), M.when('TopCenter', () => (__foldkitBrandViewResult(({
|
|
26
27
|
...base,
|
|
27
28
|
top: '0',
|
|
28
29
|
left: '50%',
|
|
29
30
|
transform: 'translateX(-50%)',
|
|
30
31
|
flexDirection: 'column-reverse',
|
|
31
|
-
})), M.when('TopRight', () => ({
|
|
32
|
+
}), "@foldkit/ui/toast/index.js#anonymous~6"))), M.when('TopRight', () => (__foldkitBrandViewResult(({
|
|
32
33
|
...base,
|
|
33
34
|
top: '0',
|
|
34
35
|
right: '0',
|
|
35
36
|
flexDirection: 'column-reverse',
|
|
36
|
-
})), M.when('BottomLeft', () => ({
|
|
37
|
+
}), "@foldkit/ui/toast/index.js#anonymous~7"))), M.when('BottomLeft', () => (__foldkitBrandViewResult(({
|
|
37
38
|
...base,
|
|
38
39
|
bottom: '0',
|
|
39
40
|
left: '0',
|
|
40
41
|
flexDirection: 'column',
|
|
41
|
-
})), M.when('BottomCenter', () => ({
|
|
42
|
+
}), "@foldkit/ui/toast/index.js#anonymous~8"))), M.when('BottomCenter', () => (__foldkitBrandViewResult(({
|
|
42
43
|
...base,
|
|
43
44
|
bottom: '0',
|
|
44
45
|
left: '50%',
|
|
45
46
|
transform: 'translateX(-50%)',
|
|
46
47
|
flexDirection: 'column',
|
|
47
|
-
})), M.when('BottomRight', () => ({
|
|
48
|
+
}), "@foldkit/ui/toast/index.js#anonymous~9"))), M.when('BottomRight', () => (__foldkitBrandViewResult(({
|
|
48
49
|
...base,
|
|
49
50
|
bottom: '0',
|
|
50
51
|
right: '0',
|
|
51
52
|
flexDirection: 'column',
|
|
52
|
-
})), M.exhaustive);
|
|
53
|
+
}), "@foldkit/ui/toast/index.js#anonymous~10"))), M.exhaustive)), "@foldkit/ui/toast/index.js#positionToContainerStyle");
|
|
53
54
|
};
|
|
54
55
|
const DEFAULT_ARIA_LABEL = 'Notifications';
|
|
55
56
|
/** Factory that binds `Toast` to a user-provided payload schema. The
|
|
@@ -103,21 +104,21 @@ export const make = (payloadSchema) => {
|
|
|
103
104
|
];
|
|
104
105
|
const renderEntryItem = (entry) => {
|
|
105
106
|
const { transitionState } = entry.animation;
|
|
106
|
-
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
|
|
107
|
+
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
107
108
|
h.DataAttribute('closed', ''),
|
|
108
109
|
h.DataAttribute('enter', ''),
|
|
109
110
|
h.DataAttribute('transition', ''),
|
|
110
|
-
]), M.when('EnterAnimating', () => [
|
|
111
|
+
]), "@foldkit/ui/toast/index.js#anonymous~12")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
111
112
|
h.DataAttribute('enter', ''),
|
|
112
113
|
h.DataAttribute('transition', ''),
|
|
113
|
-
]), M.when('LeaveStart', () => [
|
|
114
|
+
]), "@foldkit/ui/toast/index.js#anonymous~13")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
114
115
|
h.DataAttribute('leave', ''),
|
|
115
116
|
h.DataAttribute('transition', ''),
|
|
116
|
-
]), M.when('LeaveAnimating', () => [
|
|
117
|
+
]), "@foldkit/ui/toast/index.js#anonymous~14")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
117
118
|
h.DataAttribute('closed', ''),
|
|
118
119
|
h.DataAttribute('leave', ''),
|
|
119
120
|
h.DataAttribute('transition', ''),
|
|
120
|
-
]), M.orElse(() => []));
|
|
121
|
+
]), "@foldkit/ui/toast/index.js#anonymous~15")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/index.js#anonymous~16")));
|
|
121
122
|
const itemAttributes = [
|
|
122
123
|
h.Id(entry.id),
|
|
123
124
|
h.Role(variantToRole(entry.variant)),
|
|
@@ -134,14 +135,14 @@ export const make = (payloadSchema) => {
|
|
|
134
135
|
h.OnClick(Dismissed({ entryId: entry.id })),
|
|
135
136
|
]),
|
|
136
137
|
};
|
|
137
|
-
return h.keyed('li')(entry.id, itemAttributes, [
|
|
138
|
+
return __foldkitBrandViewResult((h.keyed('li')(entry.id, itemAttributes, [
|
|
138
139
|
entryToView(entry, handlers),
|
|
139
|
-
]);
|
|
140
|
+
])), "@foldkit/ui/toast/index.js#renderEntryItem");
|
|
140
141
|
};
|
|
141
|
-
return h.keyed('ol')(id, containerAttributes, entries.map(renderEntryItem));
|
|
142
|
+
return __foldkitBrandViewResult((h.keyed('ol')(id, containerAttributes, entries.map(renderEntryItem))), "@foldkit/ui/toast/index.js#anonymous~11");
|
|
142
143
|
});
|
|
143
|
-
return {
|
|
144
|
+
return __foldkitBrandViewResult(({
|
|
144
145
|
...runtime,
|
|
145
146
|
view,
|
|
146
|
-
};
|
|
147
|
+
}), "@foldkit/ui/toast/index.js#make");
|
|
147
148
|
};
|
package/dist/toast/schema.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Duration, Schema as S } from 'effect';
|
|
2
3
|
import { m } from 'foldkit/message';
|
|
3
4
|
import { Message as AnimationMessage, Model as AnimationModel, } from '../animation/schema.js';
|
|
@@ -25,7 +26,7 @@ export const Position = S.Literals([
|
|
|
25
26
|
* `variant` (for ARIA role), `animation`, `maybeDuration`,
|
|
26
27
|
* `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
|
|
27
28
|
* (for pause-on-hover). */
|
|
28
|
-
export const makeEntry = (payloadSchema) => S.Struct({
|
|
29
|
+
export const makeEntry = (payloadSchema) => __foldkitBrandViewResult((S.Struct({
|
|
29
30
|
id: S.String,
|
|
30
31
|
variant: Variant,
|
|
31
32
|
animation: AnimationModel,
|
|
@@ -33,19 +34,19 @@ export const makeEntry = (payloadSchema) => S.Struct({
|
|
|
33
34
|
pendingDismissVersion: S.Number,
|
|
34
35
|
isHovered: S.Boolean,
|
|
35
36
|
payload: payloadSchema,
|
|
36
|
-
});
|
|
37
|
+
})), "@foldkit/ui/toast/schema.js#makeEntry");
|
|
37
38
|
// MODEL
|
|
38
39
|
/** Schema factory for the toast container's state. `nextEntryKey` is a
|
|
39
40
|
* monotonic counter used to generate unique entry IDs purely from Model
|
|
40
41
|
* state. Thread the updated model through successive `show()` calls.
|
|
41
42
|
* Calling `show()` twice against the same pre-update model in the same tick
|
|
42
43
|
* will produce duplicate entry IDs. */
|
|
43
|
-
export const makeModel = (payloadSchema) => S.Struct({
|
|
44
|
+
export const makeModel = (payloadSchema) => __foldkitBrandViewResult((S.Struct({
|
|
44
45
|
id: S.String,
|
|
45
46
|
defaultDuration: S.DurationFromMillis,
|
|
46
47
|
entries: S.Array(makeEntry(payloadSchema)),
|
|
47
48
|
nextEntryKey: S.Number,
|
|
48
|
-
});
|
|
49
|
+
})), "@foldkit/ui/toast/schema.js#makeModel");
|
|
49
50
|
// MESSAGE
|
|
50
51
|
/** Sent when an entry should begin dismissing. Starts the leave animation;
|
|
51
52
|
* the entry is removed from the stack when `TransitionedOut` fires. */
|
|
@@ -72,9 +73,9 @@ export const GotAnimationMessage = m('GotAnimationMessage', {
|
|
|
72
73
|
});
|
|
73
74
|
/** Factory for the `Added` message, which carries a fully-constructed entry
|
|
74
75
|
* whose shape depends on the user-provided payload. */
|
|
75
|
-
export const makeAdded = (payloadSchema) => m('Added', { entry: makeEntry(payloadSchema) });
|
|
76
|
+
export const makeAdded = (payloadSchema) => __foldkitBrandViewResult((m('Added', { entry: makeEntry(payloadSchema) })), "@foldkit/ui/toast/schema.js#makeAdded");
|
|
76
77
|
/** Factory for the union of all messages the toast component can produce. */
|
|
77
|
-
export const makeMessage = (payloadSchema) => S.Union([
|
|
78
|
+
export const makeMessage = (payloadSchema) => __foldkitBrandViewResult((S.Union([
|
|
78
79
|
makeAdded(payloadSchema),
|
|
79
80
|
Dismissed,
|
|
80
81
|
DismissedAll,
|
|
@@ -82,12 +83,12 @@ export const makeMessage = (payloadSchema) => S.Union([
|
|
|
82
83
|
HoveredEntry,
|
|
83
84
|
LeftEntry,
|
|
84
85
|
GotAnimationMessage,
|
|
85
|
-
]);
|
|
86
|
+
])), "@foldkit/ui/toast/schema.js#makeMessage");
|
|
86
87
|
/** Factory for `DismissedToast`, the OutMessage emitted once an entry has
|
|
87
88
|
* finished dismissing (leave-animation `TransitionedOut`). Carries the
|
|
88
89
|
* payload so consumers can lift the dismissal into a domain Message
|
|
89
90
|
* without looking the entry up from a stale model. */
|
|
90
|
-
export const makeDismissedToast = (payloadSchema) => m('DismissedToast', { payload: payloadSchema });
|
|
91
|
+
export const makeDismissedToast = (payloadSchema) => __foldkitBrandViewResult((m('DismissedToast', { payload: payloadSchema })), "@foldkit/ui/toast/schema.js#makeDismissedToast");
|
|
91
92
|
/** Factory for the union of out-messages the toast component can produce. */
|
|
92
|
-
export const makeOutMessage = (payloadSchema) => S.Union([makeDismissedToast(payloadSchema)]);
|
|
93
|
+
export const makeOutMessage = (payloadSchema) => __foldkitBrandViewResult((S.Union([makeDismissedToast(payloadSchema)])), "@foldkit/ui/toast/schema.js#makeOutMessage");
|
|
93
94
|
export const DEFAULT_DURATION = Duration.seconds(4);
|
package/dist/toast/test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import * as Story from 'foldkit/story';
|
|
2
3
|
import { AdvancedAnimationFrame, EndedAnimation, RequestFrame, WaitForAnimationSettled, } from '../animation/index.js';
|
|
3
4
|
import { ElapsedDuration } from './schema.js';
|
|
@@ -33,4 +34,4 @@ const DEFAULT_VERSION = 0;
|
|
|
33
34
|
* )
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
export const drainEntry = ({ entryId, version = DEFAULT_VERSION, }) => Story.Command.resolveAll([RequestFrame, AdvancedAnimationFrame()], [WaitForAnimationSettled, EndedAnimation()], [DismissAfter, ElapsedDuration({ entryId, version })], [RequestFrame, AdvancedAnimationFrame()], [WaitForAnimationSettled, EndedAnimation()]);
|
|
37
|
+
export const drainEntry = ({ entryId, version = DEFAULT_VERSION, }) => __foldkitBrandViewResult((Story.Command.resolveAll([RequestFrame, AdvancedAnimationFrame()], [WaitForAnimationSettled, EndedAnimation()], [DismissAfter, ElapsedDuration({ entryId, version })], [RequestFrame, AdvancedAnimationFrame()], [WaitForAnimationSettled, EndedAnimation()])), "@foldkit/ui/toast/test.js#drainEntry");
|
package/dist/toast/update.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Duration, Effect, Match as M, Number, Option, Schema as S, } from 'effect';
|
|
2
3
|
import * as Command from 'foldkit/command';
|
|
3
4
|
import { evo } from 'foldkit/struct';
|
|
@@ -13,7 +14,7 @@ export const DismissAfter = Command.define('DismissAfter', {
|
|
|
13
14
|
entryId: S.String,
|
|
14
15
|
version: S.Number,
|
|
15
16
|
duration: S.DurationFromMillis,
|
|
16
|
-
}, ElapsedDuration)(({ entryId, version, duration }) => Effect.sleep(duration).pipe(Effect.as(ElapsedDuration({ entryId, version }))));
|
|
17
|
+
}, ElapsedDuration)(({ entryId, version, duration }) => __foldkitBrandViewResult((Effect.sleep(duration).pipe(Effect.as(ElapsedDuration({ entryId, version })))), "@foldkit/ui/toast/update.js#anonymous"));
|
|
17
18
|
const DEFAULT_VARIANT = 'Info';
|
|
18
19
|
/** Factory that binds Toast's runtime (update fn, helpers, commands) to a
|
|
19
20
|
* specific payload schema. Called by `make` in index.ts; inner helpers close
|
|
@@ -30,65 +31,65 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
30
31
|
const Added = makeAdded(payloadSchema);
|
|
31
32
|
const DismissedToast = makeDismissedToast(payloadSchema);
|
|
32
33
|
const withUpdateReturn = M.withReturnType();
|
|
33
|
-
const updateEntry = (model, entryId, f) => evo(model, {
|
|
34
|
-
entries: Array.map(entry => (entry.id === entryId ? f(entry) : entry)),
|
|
35
|
-
});
|
|
36
|
-
const removeEntry = (model, entryId) => evo(model, {
|
|
37
|
-
entries: Array.filter(({ id }) => id !== entryId),
|
|
38
|
-
});
|
|
34
|
+
const updateEntry = (model, entryId, f) => __foldkitBrandViewResult((evo(model, {
|
|
35
|
+
entries: Array.map(entry => (__foldkitBrandViewResult((entry.id === entryId ? f(entry) : entry), "@foldkit/ui/toast/update.js#anonymous~2"))),
|
|
36
|
+
})), "@foldkit/ui/toast/update.js#updateEntry");
|
|
37
|
+
const removeEntry = (model, entryId) => __foldkitBrandViewResult((evo(model, {
|
|
38
|
+
entries: Array.filter(({ id }) => __foldkitBrandViewResult((id !== entryId), "@foldkit/ui/toast/update.js#anonymous~3")),
|
|
39
|
+
})), "@foldkit/ui/toast/update.js#removeEntry");
|
|
39
40
|
const isEntryLeaving = (entry) => {
|
|
40
41
|
const { transitionState } = entry.animation;
|
|
41
|
-
return (transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating');
|
|
42
|
+
return (__foldkitBrandViewResult((transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating'), "@foldkit/ui/toast/update.js#isEntryLeaving"));
|
|
42
43
|
};
|
|
43
|
-
const scheduleDismiss = (entryId, version, duration) => DismissAfter({ entryId, version, duration });
|
|
44
|
+
const scheduleDismiss = (entryId, version, duration) => __foldkitBrandViewResult((DismissAfter({ entryId, version, duration })), "@foldkit/ui/toast/update.js#scheduleDismiss");
|
|
44
45
|
const rescheduleDismissCommands = (entry) => {
|
|
45
46
|
if (isEntryLeaving(entry) || entry.isHovered) {
|
|
46
|
-
return [];
|
|
47
|
+
return __foldkitBrandViewResult(([]), "@foldkit/ui/toast/update.js#rescheduleDismissCommands");
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
|
-
return Option.match(entry.maybeDuration, {
|
|
50
|
-
onNone: () => [],
|
|
51
|
-
onSome: duration => [
|
|
50
|
+
return __foldkitBrandViewResult((Option.match(entry.maybeDuration, {
|
|
51
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/update.js#onNone"),
|
|
52
|
+
onSome: duration => __foldkitBrandViewResult(([
|
|
52
53
|
scheduleDismiss(entry.id, entry.pendingDismissVersion, duration),
|
|
53
|
-
],
|
|
54
|
-
});
|
|
54
|
+
]), "@foldkit/ui/toast/update.js#onSome"),
|
|
55
|
+
})), "@foldkit/ui/toast/update.js#rescheduleDismissCommands");
|
|
55
56
|
}
|
|
56
57
|
};
|
|
57
58
|
const delegateToEntryAnimation = (model, entryId, animationMessage) => {
|
|
58
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => id === entryId);
|
|
59
|
-
return Option.match(maybeEntry, {
|
|
60
|
-
onNone: () => [model, [], Option.none()],
|
|
59
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~4"));
|
|
60
|
+
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
61
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onNone~2"),
|
|
61
62
|
onSome: entry => {
|
|
62
63
|
const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(entry.animation, animationMessage);
|
|
63
|
-
const toMessage = (message) => GotAnimationMessage({ entryId, message });
|
|
64
|
+
const toMessage = (message) => __foldkitBrandViewResult((GotAnimationMessage({ entryId, message })), "@foldkit/ui/toast/update.js#toMessage");
|
|
64
65
|
const mappedCommands = Command.mapMessages(animationCommands, toMessage);
|
|
65
66
|
const nextEntry = evo(entry, {
|
|
66
|
-
animation: () => nextAnimation,
|
|
67
|
+
animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/toast/update.js#animation"),
|
|
67
68
|
});
|
|
68
|
-
return Option.match(maybeOutMessage, {
|
|
69
|
-
onNone: () => [
|
|
70
|
-
updateEntry(model, entryId, () => nextEntry),
|
|
69
|
+
return __foldkitBrandViewResult((Option.match(maybeOutMessage, {
|
|
70
|
+
onNone: () => __foldkitBrandViewResult(([
|
|
71
|
+
updateEntry(model, entryId, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~5")),
|
|
71
72
|
mappedCommands,
|
|
72
73
|
Option.none(),
|
|
73
|
-
],
|
|
74
|
+
]), "@foldkit/ui/toast/update.js#onNone~3"),
|
|
74
75
|
onSome: M.type().pipe(withUpdateReturn, M.tagsExhaustive({
|
|
75
|
-
StartedLeaveAnimating: () => [
|
|
76
|
-
updateEntry(model, entryId, () => nextEntry),
|
|
76
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult(([
|
|
77
|
+
updateEntry(model, entryId, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~6")),
|
|
77
78
|
[
|
|
78
79
|
...mappedCommands,
|
|
79
80
|
Command.mapMessage(animationDefaultLeaveCommand(nextAnimation), toMessage),
|
|
80
81
|
],
|
|
81
82
|
Option.none(),
|
|
82
|
-
],
|
|
83
|
-
TransitionedOut: () => [
|
|
83
|
+
]), "@foldkit/ui/toast/update.js#StartedLeaveAnimating"),
|
|
84
|
+
TransitionedOut: () => __foldkitBrandViewResult(([
|
|
84
85
|
removeEntry(model, entryId),
|
|
85
86
|
mappedCommands,
|
|
86
87
|
Option.some(DismissedToast({ payload: entry.payload })),
|
|
87
|
-
],
|
|
88
|
+
]), "@foldkit/ui/toast/update.js#TransitionedOut"),
|
|
88
89
|
})),
|
|
89
|
-
});
|
|
90
|
+
})), "@foldkit/ui/toast/update.js#onSome~2");
|
|
90
91
|
},
|
|
91
|
-
});
|
|
92
|
+
})), "@foldkit/ui/toast/update.js#delegateToEntryAnimation");
|
|
92
93
|
};
|
|
93
94
|
const createEntry = (model, input) => {
|
|
94
95
|
const entryId = `${model.id}-entry-${model.nextEntryKey}`;
|
|
@@ -96,7 +97,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
96
97
|
? model.defaultDuration
|
|
97
98
|
: Duration.fromInputUnsafe(input.duration);
|
|
98
99
|
const maybeDuration = OptionExt.when(!input.sticky, duration);
|
|
99
|
-
return {
|
|
100
|
+
return __foldkitBrandViewResult(({
|
|
100
101
|
id: entryId,
|
|
101
102
|
variant: input.variant ?? DEFAULT_VARIANT,
|
|
102
103
|
animation: animationInit({ id: entryId, isShowing: false }),
|
|
@@ -104,112 +105,112 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
104
105
|
pendingDismissVersion: 0,
|
|
105
106
|
isHovered: false,
|
|
106
107
|
payload: input.payload,
|
|
107
|
-
};
|
|
108
|
+
}), "@foldkit/ui/toast/update.js#createEntry");
|
|
108
109
|
};
|
|
109
110
|
/** Creates an initial toast container model from a config. Starts empty. */
|
|
110
|
-
const init = (config) => ({
|
|
111
|
+
const init = (config) => (__foldkitBrandViewResult(({
|
|
111
112
|
id: config.id,
|
|
112
113
|
defaultDuration: config.defaultDuration === undefined
|
|
113
114
|
? DEFAULT_DURATION
|
|
114
115
|
: Duration.fromInputUnsafe(config.defaultDuration),
|
|
115
116
|
entries: [],
|
|
116
117
|
nextEntryKey: 0,
|
|
117
|
-
});
|
|
118
|
+
}), "@foldkit/ui/toast/update.js#init"));
|
|
118
119
|
/** Processes a toast message and returns the next model, commands, and
|
|
119
120
|
* an optional `DismissedToast` OutMessage emitted once an entry has
|
|
120
121
|
* finished its leave animation. */
|
|
121
|
-
const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
122
|
+
const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
122
123
|
Added: ({ entry }) => {
|
|
123
124
|
const modelWithEntry = evo(model, {
|
|
124
|
-
entries: entries => Array.append(entries, entry),
|
|
125
|
+
entries: entries => __foldkitBrandViewResult((Array.append(entries, entry)), "@foldkit/ui/toast/update.js#entries"),
|
|
125
126
|
nextEntryKey: Number.increment,
|
|
126
127
|
});
|
|
127
128
|
const [modelAfterShow, showCommands] = delegateToEntryAnimation(modelWithEntry, entry.id, AnimationShowed());
|
|
128
|
-
const postShowEntry = Array.findFirst(modelAfterShow.entries, ({ id }) => id === entry.id);
|
|
129
|
+
const postShowEntry = Array.findFirst(modelAfterShow.entries, ({ id }) => __foldkitBrandViewResult((id === entry.id), "@foldkit/ui/toast/update.js#anonymous~7"));
|
|
129
130
|
const dismissCommands = Option.match(postShowEntry, {
|
|
130
|
-
onNone: () => [],
|
|
131
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/update.js#onNone~4"),
|
|
131
132
|
onSome: rescheduleDismissCommands,
|
|
132
133
|
});
|
|
133
|
-
return [
|
|
134
|
+
return __foldkitBrandViewResult(([
|
|
134
135
|
modelAfterShow,
|
|
135
136
|
[...showCommands, ...dismissCommands],
|
|
136
137
|
Option.none(),
|
|
137
|
-
];
|
|
138
|
+
]), "@foldkit/ui/toast/update.js#Added");
|
|
138
139
|
},
|
|
139
140
|
Dismissed: ({ entryId }) => {
|
|
140
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => id === entryId);
|
|
141
|
-
return Option.match(maybeEntry, {
|
|
142
|
-
onNone: () => [model, [], Option.none()],
|
|
141
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~8"));
|
|
142
|
+
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
143
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onNone~5"),
|
|
143
144
|
onSome: entry => {
|
|
144
145
|
if (isEntryLeaving(entry)) {
|
|
145
|
-
return [model, [], Option.none()];
|
|
146
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onSome~3");
|
|
146
147
|
}
|
|
147
148
|
else {
|
|
148
|
-
return delegateToEntryAnimation(model, entryId, AnimationHid());
|
|
149
|
+
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, AnimationHid())), "@foldkit/ui/toast/update.js#onSome~3");
|
|
149
150
|
}
|
|
150
151
|
},
|
|
151
|
-
});
|
|
152
|
+
})), "@foldkit/ui/toast/update.js#Dismissed");
|
|
152
153
|
},
|
|
153
|
-
DismissedAll: () => Array.reduce(model.entries, [model, [], Option.none()], ([currentModel, currentCommands, currentOut], entry) => {
|
|
154
|
+
DismissedAll: () => __foldkitBrandViewResult((Array.reduce(model.entries, [model, [], Option.none()], ([currentModel, currentCommands, currentOut], entry) => {
|
|
154
155
|
if (isEntryLeaving(entry)) {
|
|
155
|
-
return [currentModel, currentCommands, currentOut];
|
|
156
|
+
return __foldkitBrandViewResult(([currentModel, currentCommands, currentOut]), "@foldkit/ui/toast/update.js#anonymous~9");
|
|
156
157
|
}
|
|
157
158
|
const [nextModel, nextCommands] = delegateToEntryAnimation(currentModel, entry.id, AnimationHid());
|
|
158
|
-
return [
|
|
159
|
+
return __foldkitBrandViewResult(([
|
|
159
160
|
nextModel,
|
|
160
161
|
[...currentCommands, ...nextCommands],
|
|
161
162
|
currentOut,
|
|
162
|
-
];
|
|
163
|
-
}),
|
|
163
|
+
]), "@foldkit/ui/toast/update.js#anonymous~9");
|
|
164
|
+
})), "@foldkit/ui/toast/update.js#DismissedAll"),
|
|
164
165
|
ElapsedDuration: ({ entryId, version }) => {
|
|
165
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => id === entryId);
|
|
166
|
-
return Option.match(maybeEntry, {
|
|
167
|
-
onNone: () => [model, [], Option.none()],
|
|
166
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~10"));
|
|
167
|
+
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
168
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onNone~6"),
|
|
168
169
|
onSome: entry => {
|
|
169
170
|
const isStale = version !== entry.pendingDismissVersion;
|
|
170
171
|
if (isStale || isEntryLeaving(entry)) {
|
|
171
|
-
return [model, [], Option.none()];
|
|
172
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onSome~4");
|
|
172
173
|
}
|
|
173
174
|
else {
|
|
174
|
-
return delegateToEntryAnimation(model, entryId, AnimationHid());
|
|
175
|
+
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, AnimationHid())), "@foldkit/ui/toast/update.js#onSome~4");
|
|
175
176
|
}
|
|
176
177
|
},
|
|
177
|
-
});
|
|
178
|
+
})), "@foldkit/ui/toast/update.js#ElapsedDuration");
|
|
178
179
|
},
|
|
179
|
-
HoveredEntry: ({ entryId }) => [
|
|
180
|
-
updateEntry(model, entryId, entry => evo(entry, {
|
|
181
|
-
isHovered: () => true,
|
|
180
|
+
HoveredEntry: ({ entryId }) => __foldkitBrandViewResult(([
|
|
181
|
+
updateEntry(model, entryId, entry => __foldkitBrandViewResult((evo(entry, {
|
|
182
|
+
isHovered: () => __foldkitBrandViewResult((true), "@foldkit/ui/toast/update.js#isHovered"),
|
|
182
183
|
pendingDismissVersion: Number.increment,
|
|
183
|
-
})),
|
|
184
|
+
})), "@foldkit/ui/toast/update.js#anonymous~11")),
|
|
184
185
|
[],
|
|
185
186
|
Option.none(),
|
|
186
|
-
],
|
|
187
|
+
]), "@foldkit/ui/toast/update.js#HoveredEntry"),
|
|
187
188
|
LeftEntry: ({ entryId }) => {
|
|
188
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => id === entryId);
|
|
189
|
-
return Option.match(maybeEntry, {
|
|
190
|
-
onNone: () => [model, [], Option.none()],
|
|
189
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~12"));
|
|
190
|
+
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
191
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onNone~7"),
|
|
191
192
|
onSome: entry => {
|
|
192
193
|
const nextEntry = evo(entry, {
|
|
193
|
-
isHovered: () => false,
|
|
194
|
+
isHovered: () => __foldkitBrandViewResult((false), "@foldkit/ui/toast/update.js#isHovered~2"),
|
|
194
195
|
pendingDismissVersion: Number.increment,
|
|
195
196
|
});
|
|
196
|
-
return [
|
|
197
|
-
updateEntry(model, entryId, () => nextEntry),
|
|
197
|
+
return __foldkitBrandViewResult(([
|
|
198
|
+
updateEntry(model, entryId, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~13")),
|
|
198
199
|
rescheduleDismissCommands(nextEntry),
|
|
199
200
|
Option.none(),
|
|
200
|
-
];
|
|
201
|
+
]), "@foldkit/ui/toast/update.js#onSome~5");
|
|
201
202
|
},
|
|
202
|
-
});
|
|
203
|
+
})), "@foldkit/ui/toast/update.js#LeftEntry");
|
|
203
204
|
},
|
|
204
|
-
GotAnimationMessage: ({ entryId, message: animationMessage }) => delegateToEntryAnimation(model, entryId, animationMessage),
|
|
205
|
-
}));
|
|
205
|
+
GotAnimationMessage: ({ entryId, message: animationMessage }) => __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, animationMessage)), "@foldkit/ui/toast/update.js#GotAnimationMessage"),
|
|
206
|
+
}))), "@foldkit/ui/toast/update.js#update");
|
|
206
207
|
/** Adds a new toast entry. */
|
|
207
|
-
const show = (model, input) => update(model, Added({ entry: createEntry(model, input) }));
|
|
208
|
+
const show = (model, input) => __foldkitBrandViewResult((update(model, Added({ entry: createEntry(model, input) }))), "@foldkit/ui/toast/update.js#show");
|
|
208
209
|
/** Begins dismissing a specific entry. */
|
|
209
|
-
const dismiss = (model, entryId) => update(model, Dismissed({ entryId }));
|
|
210
|
+
const dismiss = (model, entryId) => __foldkitBrandViewResult((update(model, Dismissed({ entryId }))), "@foldkit/ui/toast/update.js#dismiss");
|
|
210
211
|
/** Begins dismissing every currently-visible entry. */
|
|
211
|
-
const dismissAll = (model) => update(model, DismissedAll());
|
|
212
|
-
return {
|
|
212
|
+
const dismissAll = (model) => __foldkitBrandViewResult((update(model, DismissedAll())), "@foldkit/ui/toast/update.js#dismissAll");
|
|
213
|
+
return __foldkitBrandViewResult(({
|
|
213
214
|
Entry: EntrySchema,
|
|
214
215
|
Model: ModelSchema,
|
|
215
216
|
Message: MessageSchema,
|
|
@@ -221,5 +222,5 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
221
222
|
show,
|
|
222
223
|
dismiss,
|
|
223
224
|
dismissAll,
|
|
224
|
-
};
|
|
225
|
+
}), "@foldkit/ui/toast/update.js#makeRuntime");
|
|
225
226
|
};
|