@foldkit/ui 0.162.0 → 0.163.0-canary.1a3dd68616dc
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/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +10 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +11 -7
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +27 -19
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/combobox/multi.js +2 -2
- package/dist/combobox/shared.js +15 -15
- package/dist/combobox/single.js +4 -4
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +10 -10
- package/dist/dialog/index.js +9 -9
- package/dist/disclosure/index.d.ts +2 -2
- package/dist/disclosure/index.js +1 -1
- package/dist/dragAndDrop/index.js +14 -14
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +7 -5
- package/dist/hoverIntent/hoverIntent.d.ts.map +1 -1
- package/dist/hoverIntent/hoverIntent.js +16 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/internal/accessibleName.d.ts +9 -0
- package/dist/internal/accessibleName.d.ts.map +1 -0
- package/dist/internal/accessibleName.js +12 -0
- package/dist/internal/range.d.ts +7 -0
- package/dist/internal/range.d.ts.map +1 -0
- package/dist/internal/range.js +12 -0
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +20 -18
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +23 -17
- package/dist/meter/index.d.ts +26 -0
- package/dist/meter/index.d.ts.map +1 -0
- package/dist/meter/index.js +67 -0
- package/dist/meter/public.d.ts +3 -0
- package/dist/meter/public.d.ts.map +1 -0
- package/dist/meter/public.js +1 -0
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +12 -10
- package/dist/progress/index.d.ts +24 -0
- package/dist/progress/index.d.ts.map +1 -0
- package/dist/progress/index.js +85 -0
- package/dist/progress/public.d.ts +3 -0
- package/dist/progress/public.d.ts.map +1 -0
- package/dist/progress/public.js +1 -0
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +5 -3
- package/dist/slider/index.d.ts +61 -28
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +163 -87
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/switch/index.d.ts +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +5 -3
- package/dist/test/apps/disabledButton.d.ts +2 -2
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +3 -3
- package/dist/toast/index.d.ts +822 -43
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +77 -17
- package/dist/toast/public.d.ts +2 -2
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +145 -2
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +69 -2
- package/dist/toast/swipeTarget.d.ts +5 -0
- package/dist/toast/swipeTarget.d.ts.map +1 -0
- package/dist/toast/swipeTarget.js +18 -0
- package/dist/toast/test.d.ts +1 -1
- package/dist/toast/test.js +1 -1
- package/dist/toast/update.d.ts +726 -5
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +283 -68
- package/dist/tooltip/tooltip.d.ts +7 -7
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +14 -12
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +8 -6
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/toast/update.ts"],"names":[],"m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;;;;;;;;;;;;;;CAiG/C,CAAA"}
|
package/dist/toast/update.js
CHANGED
|
@@ -1,26 +1,67 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
-
import { Array, Duration, Effect, Number, Option, Schema, pipe } from 'effect';
|
|
2
|
+
import { Array, Duration, Effect, Match, Number, Option, Schema, Stream, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
|
-
import {
|
|
4
|
+
import { modifyFields } from 'foldkit/struct';
|
|
5
|
+
import * as Subscription from 'foldkit/subscription';
|
|
5
6
|
import * as Update from 'foldkit/update';
|
|
6
|
-
import
|
|
7
|
-
import { defaultLeaveCommand as animationDefaultLeaveCommand,
|
|
7
|
+
import { Message as AnimationMessage, OutMessage as AnimationOutMessage, init as animationInit, } from '../animation/schema.js';
|
|
8
|
+
import { defaultLeaveCommand as animationDefaultLeaveCommand, update as animationUpdate, } from '../animation/update.js';
|
|
8
9
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
9
|
-
import { DEFAULT_DURATION, Message
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* the update function. Static. The Command definition doesn't depend on
|
|
13
|
-
* payload. */
|
|
10
|
+
import { DEFAULT_DURATION, DEFAULT_SWIPE_DIRECTION, DEFAULT_SWIPE_THRESHOLD, Message, SWIPE_SETTLE_DURATION, SwipeState, makeEntry, makeMessage, makeModel, makeOutMessage, } from './schema.js';
|
|
11
|
+
/** Waits for an entry's auto-dismiss duration, then emits a versioned
|
|
12
|
+
* `CompletedWaitBeforeDismissal` Message so update can ignore stale timers. */
|
|
14
13
|
export const WaitBeforeDismissal = Command.define('WaitBeforeDismissal', {
|
|
15
14
|
args: {
|
|
16
15
|
entryId: Schema.String,
|
|
17
16
|
version: Schema.Number,
|
|
18
17
|
duration: Schema.DurationFromMillis,
|
|
19
18
|
},
|
|
20
|
-
messages: [
|
|
21
|
-
execute: ({ entryId, version, duration }) => __foldkitBrandViewResult((Effect.
|
|
19
|
+
messages: [Message.CompletedWaitBeforeDismissal],
|
|
20
|
+
execute: ({ entryId, version, duration }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
21
|
+
yield* Effect.sleep(duration);
|
|
22
|
+
return __foldkitBrandViewResult((Message.CompletedWaitBeforeDismissal({ entryId, version })), "@foldkit/ui/toast/update.js#anonymous");
|
|
23
|
+
})), "@foldkit/ui/toast/update.js#execute"),
|
|
22
24
|
});
|
|
23
25
|
const DEFAULT_VARIANT = 'Info';
|
|
26
|
+
/** Waits for a short or cancelled swipe to animate back, then emits
|
|
27
|
+
* `CompletedWaitForSwipeSettled` so update can clear `Settling`. */
|
|
28
|
+
export const WaitForSwipeSettled = Command.define('WaitForSwipeSettled', {
|
|
29
|
+
args: {
|
|
30
|
+
entryId: Schema.String,
|
|
31
|
+
version: Schema.Number,
|
|
32
|
+
},
|
|
33
|
+
messages: [Message.CompletedWaitForSwipeSettled],
|
|
34
|
+
execute: ({ entryId, version }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
35
|
+
yield* Effect.sleep(SWIPE_SETTLE_DURATION);
|
|
36
|
+
return __foldkitBrandViewResult((Message.CompletedWaitForSwipeSettled({ entryId, version })), "@foldkit/ui/toast/update.js#anonymous~2");
|
|
37
|
+
})), "@foldkit/ui/toast/update.js#execute~2"),
|
|
38
|
+
});
|
|
39
|
+
/** Horizontal offset in pixels for an entry's swipe state. `Dragging`
|
|
40
|
+
* reports the distance travelled from the press point; `Dismissing` reports
|
|
41
|
+
* the offset the release left behind; `Idle` and `Settling` report zero. */
|
|
42
|
+
export const swipeOffset = (swipeState) => __foldkitBrandViewResult((SwipeState.match(swipeState, {
|
|
43
|
+
Idle: () => __foldkitBrandViewResult((0), "@foldkit/ui/toast/update.js#Idle"),
|
|
44
|
+
Dragging: dragging => __foldkitBrandViewResult((dragging.currentX - dragging.startX), "@foldkit/ui/toast/update.js#Dragging"),
|
|
45
|
+
Settling: settling => __foldkitBrandViewResult((settling.offsetX), "@foldkit/ui/toast/update.js#Settling"),
|
|
46
|
+
Dismissing: dismissing => __foldkitBrandViewResult((dismissing.offsetX), "@foldkit/ui/toast/update.js#Dismissing"),
|
|
47
|
+
})), "@foldkit/ui/toast/update.js#swipeOffset");
|
|
48
|
+
const clampSwipeClientX = (startX, clientX, direction) => __foldkitBrandViewResult((Match.value(direction).pipe(Match.when('Right', () => __foldkitBrandViewResult((Math.max(startX, clientX)), "@foldkit/ui/toast/update.js#anonymous~3")), Match.when('Left', () => __foldkitBrandViewResult((Math.min(startX, clientX)), "@foldkit/ui/toast/update.js#anonymous~4")), Match.exhaustive)), "@foldkit/ui/toast/update.js#clampSwipeClientX");
|
|
49
|
+
const documentStylesWhileSwiping = Stream.callback(() => __foldkitBrandViewResult((Effect.acquireRelease(Effect.sync(() => {
|
|
50
|
+
const styleElement = document.createElement('style');
|
|
51
|
+
styleElement.textContent = `
|
|
52
|
+
:root {
|
|
53
|
+
user-select: none !important;
|
|
54
|
+
-webkit-user-select: none !important;
|
|
55
|
+
}
|
|
56
|
+
* {
|
|
57
|
+
cursor: grabbing !important;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
document.head.appendChild(styleElement);
|
|
61
|
+
return __foldkitBrandViewResult((styleElement), "@foldkit/ui/toast/update.js#anonymous~6");
|
|
62
|
+
}), styleElement => __foldkitBrandViewResult((Effect.sync(() => {
|
|
63
|
+
styleElement.remove();
|
|
64
|
+
})), "@foldkit/ui/toast/update.js#anonymous~7")).pipe(Effect.flatMap(() => __foldkitBrandViewResult((Effect.never), "@foldkit/ui/toast/update.js#anonymous~9")))), "@foldkit/ui/toast/update.js#anonymous~5"));
|
|
24
65
|
/** Factory that binds Toast's runtime (update fn, helpers, commands) to a
|
|
25
66
|
* specific payload schema. Called by `make` in index.ts; inner helpers close
|
|
26
67
|
* over the payload-specific Entry / Model / Added types so generics don't
|
|
@@ -35,49 +76,72 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
35
76
|
const OutMessageSchema = makeOutMessage(payloadSchema);
|
|
36
77
|
const Added = MessageSchema.Added;
|
|
37
78
|
const DismissedToast = OutMessageSchema.DismissedToast;
|
|
38
|
-
const updateEntry = (model, entryId, f) => __foldkitBrandViewResult((
|
|
39
|
-
entries: Array.map(entry => (__foldkitBrandViewResult((entry.id === entryId ? f(entry) : entry), "@foldkit/ui/toast/update.js#anonymous"))),
|
|
79
|
+
const updateEntry = (model, entryId, f) => __foldkitBrandViewResult((modifyFields(model, {
|
|
80
|
+
entries: Array.map(entry => (__foldkitBrandViewResult((entry.id === entryId ? f(entry) : entry), "@foldkit/ui/toast/update.js#anonymous~10"))),
|
|
40
81
|
})), "@foldkit/ui/toast/update.js#updateEntry");
|
|
41
|
-
const removeEntry = (model, entryId) => __foldkitBrandViewResult((
|
|
42
|
-
entries: Array.filter(({ id }) => __foldkitBrandViewResult((id !== entryId), "@foldkit/ui/toast/update.js#anonymous~
|
|
82
|
+
const removeEntry = (model, entryId) => __foldkitBrandViewResult((modifyFields(model, {
|
|
83
|
+
entries: Array.filter(({ id }) => __foldkitBrandViewResult((id !== entryId), "@foldkit/ui/toast/update.js#anonymous~11")),
|
|
43
84
|
})), "@foldkit/ui/toast/update.js#removeEntry");
|
|
44
85
|
const isEntryLeaving = (entry) => {
|
|
45
86
|
const { transitionState } = entry.animation;
|
|
46
87
|
return (__foldkitBrandViewResult((transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating'), "@foldkit/ui/toast/update.js#isEntryLeaving"));
|
|
47
88
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
89
|
+
const isDraggingWithPointerId = (pointerId) => __foldkitBrandViewResult(((entry) => __foldkitBrandViewResult((SwipeState.guards.Dragging(entry.swipeState) &&
|
|
90
|
+
entry.swipeState.pointerId === pointerId), "@foldkit/ui/toast/update.js#anonymous~12")), "@foldkit/ui/toast/update.js#isDraggingWithPointerId");
|
|
91
|
+
const isPointerActive = (model, pointerId) => __foldkitBrandViewResult((Array.some(model.entries, isDraggingWithPointerId(pointerId))), "@foldkit/ui/toast/update.js#isPointerActive");
|
|
92
|
+
const isAnyDragging = (model) => __foldkitBrandViewResult((Array.some(model.entries, entry => __foldkitBrandViewResult((SwipeState.guards.Dragging(entry.swipeState)), "@foldkit/ui/toast/update.js#anonymous~13"))), "@foldkit/ui/toast/update.js#isAnyDragging");
|
|
93
|
+
const findDraggingEntry = (model, pointerId) => __foldkitBrandViewResult((pipe(Array.findFirst(model.entries, isDraggingWithPointerId(pointerId)), Option.flatMap(entry => __foldkitBrandViewResult((SwipeState.matchOrElse(entry.swipeState, {
|
|
94
|
+
Dragging: dragging => __foldkitBrandViewResult((Option.some({ entry, startX: dragging.startX })), "@foldkit/ui/toast/update.js#Dragging~2"),
|
|
95
|
+
}, () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/toast/update.js#anonymous~15"))), "@foldkit/ui/toast/update.js#anonymous~14")))), "@foldkit/ui/toast/update.js#findDraggingEntry");
|
|
96
|
+
const scheduleWaitBeforeDismissal = (entry) => {
|
|
97
|
+
if (isEntryLeaving(entry) ||
|
|
98
|
+
entry.isHovered ||
|
|
99
|
+
SwipeState.guards.Dragging(entry.swipeState)) {
|
|
100
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/toast/update.js#scheduleWaitBeforeDismissal");
|
|
52
101
|
}
|
|
53
102
|
else {
|
|
54
|
-
return __foldkitBrandViewResult((Option.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})), "@foldkit/ui/toast/update.js#rescheduleDismissCommands");
|
|
103
|
+
return __foldkitBrandViewResult((Option.map(entry.maybeDuration, duration => __foldkitBrandViewResult((WaitBeforeDismissal({
|
|
104
|
+
entryId: entry.id,
|
|
105
|
+
version: entry.pendingDismissVersion,
|
|
106
|
+
duration,
|
|
107
|
+
})), "@foldkit/ui/toast/update.js#anonymous~16"))), "@foldkit/ui/toast/update.js#scheduleWaitBeforeDismissal");
|
|
60
108
|
}
|
|
61
109
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
110
|
+
const settleSnapBack = (entry) => __foldkitBrandViewResult((model => {
|
|
111
|
+
const nextSwipeVersion = Number.increment(entry.swipeVersion);
|
|
112
|
+
const nextEntry = modifyFields(entry, {
|
|
113
|
+
pendingDismissVersion: Number.increment,
|
|
114
|
+
swipeState: () => __foldkitBrandViewResult((SwipeState.Settling({ offsetX: 0 })), "@foldkit/ui/toast/update.js#swipeState"),
|
|
115
|
+
swipeVersion: () => __foldkitBrandViewResult((nextSwipeVersion), "@foldkit/ui/toast/update.js#swipeVersion"),
|
|
116
|
+
});
|
|
117
|
+
const nextModel = updateEntry(model, entry.id, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~18"));
|
|
118
|
+
return __foldkitBrandViewResult(({
|
|
119
|
+
model: nextModel,
|
|
120
|
+
commands: [
|
|
121
|
+
WaitForSwipeSettled({ entryId: entry.id, version: nextSwipeVersion }),
|
|
122
|
+
...Array.fromOption(scheduleWaitBeforeDismissal(nextEntry)),
|
|
123
|
+
],
|
|
124
|
+
}), "@foldkit/ui/toast/update.js#anonymous~17");
|
|
125
|
+
}), "@foldkit/ui/toast/update.js#settleSnapBack");
|
|
126
|
+
const readEntryAnimation = (entryId) => __foldkitBrandViewResult(((model) => __foldkitBrandViewResult((pipe(Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~20")), Option.map(({ animation }) => __foldkitBrandViewResult((animation), "@foldkit/ui/toast/update.js#anonymous~21")))), "@foldkit/ui/toast/update.js#anonymous~19")), "@foldkit/ui/toast/update.js#readEntryAnimation");
|
|
127
|
+
const writeEntryAnimation = (entryId) => __foldkitBrandViewResult(((model, nextAnimation) => __foldkitBrandViewResult((updateEntry(model, entryId, entry => __foldkitBrandViewResult((modifyFields(entry, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/toast/update.js#animation") })), "@foldkit/ui/toast/update.js#anonymous~23"))), "@foldkit/ui/toast/update.js#anonymous~22")), "@foldkit/ui/toast/update.js#writeEntryAnimation");
|
|
128
|
+
const toGotAnimationMessage = (entryId) => __foldkitBrandViewResult(((message) => __foldkitBrandViewResult((MessageSchema.GotAnimationMessage({ entryId, message })), "@foldkit/ui/toast/update.js#anonymous~24")), "@foldkit/ui/toast/update.js#toGotAnimationMessage");
|
|
129
|
+
const toDismissedToastOutMessage = (payload) => __foldkitBrandViewResult(((outMessage) => __foldkitBrandViewResult((AnimationOutMessage.match(outMessage, {
|
|
66
130
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((undefined), "@foldkit/ui/toast/update.js#StartedLeaveAnimating"),
|
|
67
131
|
TransitionedOut: () => __foldkitBrandViewResult((OutMessageSchema.DismissedToast({ payload })), "@foldkit/ui/toast/update.js#TransitionedOut"),
|
|
68
|
-
})), "@foldkit/ui/toast/update.js#toDismissedToastOutMessage");
|
|
69
|
-
const foldEntryAnimationOutMessage = entryId => __foldkitBrandViewResult(((outMessage, { liftCommand }) => __foldkitBrandViewResult((
|
|
132
|
+
})), "@foldkit/ui/toast/update.js#anonymous~25")), "@foldkit/ui/toast/update.js#toDismissedToastOutMessage");
|
|
133
|
+
const foldEntryAnimationOutMessage = entryId => __foldkitBrandViewResult(((outMessage, { liftCommand }) => __foldkitBrandViewResult((AnimationOutMessage.match(outMessage, {
|
|
70
134
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((Option.match(readEntryAnimation(entryId)(model), {
|
|
71
|
-
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone
|
|
135
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone")),
|
|
72
136
|
onSome: animation => (__foldkitBrandViewResult(({
|
|
73
137
|
model,
|
|
74
138
|
commands: [liftCommand(animationDefaultLeaveCommand(animation))],
|
|
75
|
-
}), "@foldkit/ui/toast/update.js#onSome
|
|
76
|
-
})), "@foldkit/ui/toast/update.js#anonymous~
|
|
139
|
+
}), "@foldkit/ui/toast/update.js#onSome")),
|
|
140
|
+
})), "@foldkit/ui/toast/update.js#anonymous~27")), "@foldkit/ui/toast/update.js#StartedLeaveAnimating~2"),
|
|
77
141
|
TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
78
142
|
model: removeEntry(model, entryId),
|
|
79
|
-
}), "@foldkit/ui/toast/update.js#anonymous~
|
|
80
|
-
})), "@foldkit/ui/toast/update.js#anonymous~
|
|
143
|
+
}), "@foldkit/ui/toast/update.js#anonymous~28"))), "@foldkit/ui/toast/update.js#TransitionedOut~2"),
|
|
144
|
+
})), "@foldkit/ui/toast/update.js#anonymous~26")), "@foldkit/ui/toast/update.js#foldEntryAnimationOutMessage");
|
|
81
145
|
const foldEntryAnimation = (entry) => __foldkitBrandViewResult((Update.foldChild({
|
|
82
146
|
update: animationUpdate,
|
|
83
147
|
read: readEntryAnimation(entry.id),
|
|
@@ -87,20 +151,20 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
87
151
|
foldOutMessage: foldEntryAnimationOutMessage(entry.id),
|
|
88
152
|
})), "@foldkit/ui/toast/update.js#foldEntryAnimation");
|
|
89
153
|
const foldEntryAnimationShow = (entry) => __foldkitBrandViewResult((Update.foldChildStep({
|
|
90
|
-
update:
|
|
154
|
+
update: (animation) => __foldkitBrandViewResult((animationUpdate(animation, AnimationMessage.Showed())), "@foldkit/ui/toast/update.js#update"),
|
|
91
155
|
read: readEntryAnimation(entry.id),
|
|
92
156
|
write: writeEntryAnimation(entry.id),
|
|
93
157
|
toParentMessage: toGotAnimationMessage(entry.id),
|
|
94
158
|
})), "@foldkit/ui/toast/update.js#foldEntryAnimationShow");
|
|
95
159
|
const foldEntryAnimationHide = (entry) => __foldkitBrandViewResult((Update.foldChildStep({
|
|
96
|
-
update:
|
|
160
|
+
update: (animation) => __foldkitBrandViewResult((animationUpdate(animation, AnimationMessage.Hid())), "@foldkit/ui/toast/update.js#update~2"),
|
|
97
161
|
read: readEntryAnimation(entry.id),
|
|
98
162
|
write: writeEntryAnimation(entry.id),
|
|
99
163
|
toParentMessage: toGotAnimationMessage(entry.id),
|
|
100
164
|
})), "@foldkit/ui/toast/update.js#foldEntryAnimationHide");
|
|
101
|
-
const delegateToEntryAnimation = (model, entryId, animationMessage) => __foldkitBrandViewResult((Option.match(Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~
|
|
102
|
-
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~
|
|
103
|
-
onSome: entry => __foldkitBrandViewResult((foldEntryAnimation(entry)(model, animationMessage)), "@foldkit/ui/toast/update.js#onSome~
|
|
165
|
+
const delegateToEntryAnimation = (model, entryId, animationMessage) => __foldkitBrandViewResult((Option.match(Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~29")), {
|
|
166
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~2")),
|
|
167
|
+
onSome: entry => __foldkitBrandViewResult((foldEntryAnimation(entry)(model, animationMessage)), "@foldkit/ui/toast/update.js#onSome~2"),
|
|
104
168
|
})), "@foldkit/ui/toast/update.js#delegateToEntryAnimation");
|
|
105
169
|
const createEntry = (model, input) => {
|
|
106
170
|
const entryId = `${model.id}-entry-${model.nextEntryKey}`;
|
|
@@ -111,14 +175,17 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
111
175
|
return __foldkitBrandViewResult(({
|
|
112
176
|
id: entryId,
|
|
113
177
|
variant: input.variant ?? DEFAULT_VARIANT,
|
|
114
|
-
animation:
|
|
178
|
+
animation: animationInit({ id: entryId, isShowing: false }),
|
|
115
179
|
maybeDuration,
|
|
116
180
|
pendingDismissVersion: 0,
|
|
117
181
|
isHovered: false,
|
|
182
|
+
swipeState: SwipeState.Idle(),
|
|
183
|
+
swipeVersion: 0,
|
|
118
184
|
payload: input.payload,
|
|
119
185
|
}), "@foldkit/ui/toast/update.js#createEntry");
|
|
120
186
|
};
|
|
121
|
-
/** Creates an initial toast container model from a config. Starts empty
|
|
187
|
+
/** Creates an initial toast container model from a config. Starts empty
|
|
188
|
+
* with swipe disabled unless `swipeToDismiss` opts in. */
|
|
122
189
|
const init = (config) => (__foldkitBrandViewResult(({
|
|
123
190
|
id: config.id,
|
|
124
191
|
defaultDuration: config.defaultDuration === undefined
|
|
@@ -126,6 +193,10 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
126
193
|
: Duration.fromInputUnsafe(config.defaultDuration),
|
|
127
194
|
entries: [],
|
|
128
195
|
nextEntryKey: 0,
|
|
196
|
+
maybeSwipeConfig: pipe(Option.fromNullishOr(config.swipeToDismiss), Option.map(({ threshold, direction }) => (__foldkitBrandViewResult(({
|
|
197
|
+
threshold: threshold ?? DEFAULT_SWIPE_THRESHOLD,
|
|
198
|
+
direction: direction ?? DEFAULT_SWIPE_DIRECTION,
|
|
199
|
+
}), "@foldkit/ui/toast/update.js#anonymous~30")))),
|
|
129
200
|
}), "@foldkit/ui/toast/update.js#init"));
|
|
130
201
|
/** Processes a Toast Message and returns the next Model, optional Commands,
|
|
131
202
|
* and an optional `DismissedToast` OutMessage emitted once an entry has
|
|
@@ -134,81 +205,223 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
134
205
|
Added: ({ entry }) => {
|
|
135
206
|
return __foldkitBrandViewResult((Update.combine(model, [
|
|
136
207
|
stepModel => (__foldkitBrandViewResult(({
|
|
137
|
-
model:
|
|
208
|
+
model: modifyFields(stepModel, {
|
|
138
209
|
entries: entries => __foldkitBrandViewResult((Array.append(entries, entry)), "@foldkit/ui/toast/update.js#entries"),
|
|
139
210
|
nextEntryKey: Number.increment,
|
|
140
211
|
}),
|
|
141
|
-
}), "@foldkit/ui/toast/update.js#anonymous~
|
|
212
|
+
}), "@foldkit/ui/toast/update.js#anonymous~31")),
|
|
142
213
|
foldEntryAnimationShow(entry),
|
|
143
214
|
stepModel => (__foldkitBrandViewResult(({
|
|
144
215
|
model: stepModel,
|
|
145
|
-
commands:
|
|
146
|
-
|
|
147
|
-
onSome: rescheduleDismissCommands,
|
|
148
|
-
}),
|
|
149
|
-
}), "@foldkit/ui/toast/update.js#anonymous~14")),
|
|
216
|
+
commands: pipe(Array.findFirst(stepModel.entries, ({ id }) => __foldkitBrandViewResult((id === entry.id), "@foldkit/ui/toast/update.js#anonymous~33")), Option.flatMap(scheduleWaitBeforeDismissal), Array.fromOption),
|
|
217
|
+
}), "@foldkit/ui/toast/update.js#anonymous~32")),
|
|
150
218
|
])), "@foldkit/ui/toast/update.js#Added");
|
|
151
219
|
},
|
|
152
220
|
Dismissed: ({ entryId }) => {
|
|
153
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~
|
|
221
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~34"));
|
|
154
222
|
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
155
|
-
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~
|
|
223
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~3")),
|
|
156
224
|
onSome: entry => {
|
|
157
225
|
if (isEntryLeaving(entry)) {
|
|
158
|
-
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~
|
|
226
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~3");
|
|
159
227
|
}
|
|
160
228
|
else {
|
|
161
|
-
return __foldkitBrandViewResult((foldEntryAnimationHide(entry)(model)), "@foldkit/ui/toast/update.js#onSome~
|
|
229
|
+
return __foldkitBrandViewResult((foldEntryAnimationHide(entry)(model)), "@foldkit/ui/toast/update.js#onSome~3");
|
|
162
230
|
}
|
|
163
231
|
},
|
|
164
232
|
})), "@foldkit/ui/toast/update.js#Dismissed");
|
|
165
233
|
},
|
|
166
|
-
DismissedAll: () => __foldkitBrandViewResult((Update.combine(model, pipe(model.entries, Array.filter(entry => __foldkitBrandViewResult((!isEntryLeaving(entry)), "@foldkit/ui/toast/update.js#anonymous~
|
|
234
|
+
DismissedAll: () => __foldkitBrandViewResult((Update.combine(model, pipe(model.entries, Array.filter(entry => __foldkitBrandViewResult((!isEntryLeaving(entry)), "@foldkit/ui/toast/update.js#anonymous~35")), Array.map(foldEntryAnimationHide)))), "@foldkit/ui/toast/update.js#DismissedAll"),
|
|
167
235
|
CompletedWaitBeforeDismissal: ({ entryId, version }) => {
|
|
168
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~
|
|
236
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~36"));
|
|
169
237
|
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
170
|
-
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~
|
|
238
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~4")),
|
|
171
239
|
onSome: entry => {
|
|
172
240
|
const isStale = version !== entry.pendingDismissVersion;
|
|
173
241
|
if (isStale || isEntryLeaving(entry)) {
|
|
174
|
-
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~
|
|
242
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~4");
|
|
175
243
|
}
|
|
176
244
|
else {
|
|
177
|
-
return __foldkitBrandViewResult((foldEntryAnimationHide(entry)(model)), "@foldkit/ui/toast/update.js#onSome~
|
|
245
|
+
return __foldkitBrandViewResult((foldEntryAnimationHide(entry)(model)), "@foldkit/ui/toast/update.js#onSome~4");
|
|
178
246
|
}
|
|
179
247
|
},
|
|
180
248
|
})), "@foldkit/ui/toast/update.js#CompletedWaitBeforeDismissal");
|
|
181
249
|
},
|
|
182
250
|
HoveredEntry: ({ entryId }) => (__foldkitBrandViewResult(({
|
|
183
|
-
model: updateEntry(model, entryId, entry => __foldkitBrandViewResult((
|
|
251
|
+
model: updateEntry(model, entryId, entry => __foldkitBrandViewResult((modifyFields(entry, {
|
|
184
252
|
isHovered: () => __foldkitBrandViewResult((true), "@foldkit/ui/toast/update.js#isHovered"),
|
|
185
253
|
pendingDismissVersion: Number.increment,
|
|
186
|
-
})), "@foldkit/ui/toast/update.js#anonymous~
|
|
254
|
+
})), "@foldkit/ui/toast/update.js#anonymous~37")),
|
|
187
255
|
}), "@foldkit/ui/toast/update.js#HoveredEntry")),
|
|
188
256
|
LeftEntry: ({ entryId }) => {
|
|
189
|
-
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~
|
|
257
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~38"));
|
|
190
258
|
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
191
|
-
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~
|
|
259
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~5")),
|
|
192
260
|
onSome: entry => {
|
|
193
|
-
const nextEntry =
|
|
261
|
+
const nextEntry = modifyFields(entry, {
|
|
194
262
|
isHovered: () => __foldkitBrandViewResult((false), "@foldkit/ui/toast/update.js#isHovered~2"),
|
|
195
263
|
pendingDismissVersion: Number.increment,
|
|
196
264
|
});
|
|
265
|
+
const nextModel = updateEntry(model, entryId, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~39"));
|
|
197
266
|
return __foldkitBrandViewResult(({
|
|
198
|
-
model:
|
|
199
|
-
commands:
|
|
200
|
-
}), "@foldkit/ui/toast/update.js#onSome~
|
|
267
|
+
model: nextModel,
|
|
268
|
+
commands: Array.fromOption(scheduleWaitBeforeDismissal(nextEntry)),
|
|
269
|
+
}), "@foldkit/ui/toast/update.js#onSome~5");
|
|
201
270
|
},
|
|
202
271
|
})), "@foldkit/ui/toast/update.js#LeftEntry");
|
|
203
272
|
},
|
|
273
|
+
PressedEntryPointer: ({ entryId, pointerId, clientX }) => {
|
|
274
|
+
if (Option.isNone(model.maybeSwipeConfig)) {
|
|
275
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#PressedEntryPointer");
|
|
276
|
+
}
|
|
277
|
+
const maybeEntry = Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~40"));
|
|
278
|
+
return __foldkitBrandViewResult((Option.match(maybeEntry, {
|
|
279
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~6")),
|
|
280
|
+
onSome: entry => {
|
|
281
|
+
if (isEntryLeaving(entry) ||
|
|
282
|
+
SwipeState.guards.Dragging(entry.swipeState) ||
|
|
283
|
+
isPointerActive(model, pointerId)) {
|
|
284
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~6");
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
const nextEntry = modifyFields(entry, {
|
|
288
|
+
pendingDismissVersion: Number.increment,
|
|
289
|
+
swipeState: () => __foldkitBrandViewResult((SwipeState.Dragging({
|
|
290
|
+
pointerId,
|
|
291
|
+
startX: clientX,
|
|
292
|
+
currentX: clientX,
|
|
293
|
+
})), "@foldkit/ui/toast/update.js#swipeState~2"),
|
|
294
|
+
swipeVersion: Number.increment,
|
|
295
|
+
});
|
|
296
|
+
return __foldkitBrandViewResult(({ model: updateEntry(model, entryId, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~41")) }), "@foldkit/ui/toast/update.js#onSome~6");
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
})), "@foldkit/ui/toast/update.js#PressedEntryPointer");
|
|
300
|
+
},
|
|
301
|
+
MovedSwipePointer: ({ pointerId, clientX }) => __foldkitBrandViewResult((Option.match(Option.all({
|
|
302
|
+
swipeConfig: model.maybeSwipeConfig,
|
|
303
|
+
draggingEntry: findDraggingEntry(model, pointerId),
|
|
304
|
+
}), {
|
|
305
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~7")),
|
|
306
|
+
onSome: ({ swipeConfig, draggingEntry: { entry, startX } }) => (__foldkitBrandViewResult(({
|
|
307
|
+
model: updateEntry(model, entry.id, currentEntry => __foldkitBrandViewResult((modifyFields(currentEntry, {
|
|
308
|
+
swipeState: () => __foldkitBrandViewResult((SwipeState.Dragging({
|
|
309
|
+
pointerId,
|
|
310
|
+
startX,
|
|
311
|
+
currentX: clampSwipeClientX(startX, clientX, swipeConfig.direction),
|
|
312
|
+
})), "@foldkit/ui/toast/update.js#swipeState~3"),
|
|
313
|
+
})), "@foldkit/ui/toast/update.js#anonymous~42")),
|
|
314
|
+
}), "@foldkit/ui/toast/update.js#onSome~7")),
|
|
315
|
+
})), "@foldkit/ui/toast/update.js#MovedSwipePointer"),
|
|
316
|
+
ReleasedSwipePointer: ({ pointerId, clientX }) => __foldkitBrandViewResult((Option.match(Option.all({
|
|
317
|
+
swipeConfig: model.maybeSwipeConfig,
|
|
318
|
+
draggingEntry: findDraggingEntry(model, pointerId),
|
|
319
|
+
}), {
|
|
320
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~8")),
|
|
321
|
+
onSome: ({ swipeConfig, draggingEntry: { entry, startX } }) => {
|
|
322
|
+
const offset = clampSwipeClientX(startX, clientX, swipeConfig.direction) -
|
|
323
|
+
startX;
|
|
324
|
+
const isPastSwipeThreshold = Math.abs(offset) > swipeConfig.threshold;
|
|
325
|
+
if (!isPastSwipeThreshold) {
|
|
326
|
+
return __foldkitBrandViewResult((settleSnapBack(entry)(model)), "@foldkit/ui/toast/update.js#onSome~8");
|
|
327
|
+
}
|
|
328
|
+
const nextSwipeVersion = Number.increment(entry.swipeVersion);
|
|
329
|
+
const nextEntry = modifyFields(entry, {
|
|
330
|
+
swipeState: () => __foldkitBrandViewResult((SwipeState.Dismissing({
|
|
331
|
+
offsetX: offset,
|
|
332
|
+
direction: swipeConfig.direction,
|
|
333
|
+
})), "@foldkit/ui/toast/update.js#swipeState~4"),
|
|
334
|
+
swipeVersion: () => __foldkitBrandViewResult((nextSwipeVersion), "@foldkit/ui/toast/update.js#swipeVersion~2"),
|
|
335
|
+
});
|
|
336
|
+
const nextModel = updateEntry(model, entry.id, () => __foldkitBrandViewResult((nextEntry), "@foldkit/ui/toast/update.js#anonymous~43"));
|
|
337
|
+
if (isEntryLeaving(entry)) {
|
|
338
|
+
return __foldkitBrandViewResult(({ model: nextModel }), "@foldkit/ui/toast/update.js#onSome~8");
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
return __foldkitBrandViewResult((foldEntryAnimationHide(entry)(nextModel)), "@foldkit/ui/toast/update.js#onSome~8");
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
})), "@foldkit/ui/toast/update.js#ReleasedSwipePointer"),
|
|
345
|
+
CancelledSwipe: ({ pointerId }) => __foldkitBrandViewResult((Option.match(findDraggingEntry(model, pointerId), {
|
|
346
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~9")),
|
|
347
|
+
onSome: ({ entry }) => __foldkitBrandViewResult((settleSnapBack(entry)(model)), "@foldkit/ui/toast/update.js#onSome~9"),
|
|
348
|
+
})), "@foldkit/ui/toast/update.js#CancelledSwipe"),
|
|
349
|
+
PressedEscape: () => {
|
|
350
|
+
const draggingEntries = Array.filter(model.entries, entry => __foldkitBrandViewResult((SwipeState.guards.Dragging(entry.swipeState)), "@foldkit/ui/toast/update.js#anonymous~44"));
|
|
351
|
+
return __foldkitBrandViewResult((Update.combine(model, Array.map(draggingEntries, settleSnapBack))), "@foldkit/ui/toast/update.js#PressedEscape");
|
|
352
|
+
},
|
|
353
|
+
CompletedWaitForSwipeSettled: ({ entryId, version }) => __foldkitBrandViewResult((Option.match(Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~45")), {
|
|
354
|
+
onNone: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onNone~10")),
|
|
355
|
+
onSome: entry => {
|
|
356
|
+
if (SwipeState.guards.Settling(entry.swipeState) &&
|
|
357
|
+
entry.swipeVersion === version) {
|
|
358
|
+
return __foldkitBrandViewResult(({
|
|
359
|
+
model: updateEntry(model, entryId, current => __foldkitBrandViewResult((modifyFields(current, {
|
|
360
|
+
swipeState: () => __foldkitBrandViewResult((SwipeState.Idle()), "@foldkit/ui/toast/update.js#swipeState~5"),
|
|
361
|
+
})), "@foldkit/ui/toast/update.js#anonymous~46")),
|
|
362
|
+
}), "@foldkit/ui/toast/update.js#onSome~10");
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/toast/update.js#onSome~10");
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
})), "@foldkit/ui/toast/update.js#CompletedWaitForSwipeSettled"),
|
|
204
369
|
GotAnimationMessage: ({ entryId, message: animationMessage }) => __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, animationMessage)), "@foldkit/ui/toast/update.js#GotAnimationMessage"),
|
|
205
|
-
})), "@foldkit/ui/toast/update.js#update");
|
|
370
|
+
})), "@foldkit/ui/toast/update.js#update~3");
|
|
206
371
|
/** Adds a new toast entry. */
|
|
207
372
|
const show = (model, input) => __foldkitBrandViewResult((update(model, MessageSchema.Added({ entry: createEntry(model, input) }))), "@foldkit/ui/toast/update.js#show");
|
|
208
373
|
/** Begins dismissing a specific entry. */
|
|
209
374
|
const dismiss = (model, entryId) => __foldkitBrandViewResult((update(model, MessageSchema.Dismissed({ entryId }))), "@foldkit/ui/toast/update.js#dismiss");
|
|
210
375
|
/** Begins dismissing every currently-visible entry. */
|
|
211
376
|
const dismissAll = (model) => __foldkitBrandViewResult((update(model, MessageSchema.DismissedAll())), "@foldkit/ui/toast/update.js#dismissAll");
|
|
377
|
+
const swipeDependencies = (model) => (__foldkitBrandViewResult(({
|
|
378
|
+
isSwipeEnabled: Option.isSome(model.maybeSwipeConfig),
|
|
379
|
+
isAnyDragging: isAnyDragging(model),
|
|
380
|
+
}), "@foldkit/ui/toast/update.js#swipeDependencies"));
|
|
381
|
+
const subscriptions = Subscription.make()(entry => (__foldkitBrandViewResult(({
|
|
382
|
+
swipePointer: entry({
|
|
383
|
+
isSwipeEnabled: Schema.Boolean,
|
|
384
|
+
isAnyDragging: Schema.Boolean,
|
|
385
|
+
}, {
|
|
386
|
+
modelToDependencies: swipeDependencies,
|
|
387
|
+
dependenciesToStream: ({ isSwipeEnabled, isAnyDragging }) => {
|
|
388
|
+
const pointerMoveStream = Subscription.fromEvent({
|
|
389
|
+
target: document,
|
|
390
|
+
type: 'pointermove',
|
|
391
|
+
mapEvent: event => __foldkitBrandViewResult((MessageSchema.MovedSwipePointer({
|
|
392
|
+
pointerId: event.pointerId,
|
|
393
|
+
clientX: event.clientX,
|
|
394
|
+
})), "@foldkit/ui/toast/update.js#mapEvent"),
|
|
395
|
+
});
|
|
396
|
+
const pointerUpStream = Subscription.fromEvent({
|
|
397
|
+
target: document,
|
|
398
|
+
type: 'pointerup',
|
|
399
|
+
mapEvent: event => __foldkitBrandViewResult((MessageSchema.ReleasedSwipePointer({
|
|
400
|
+
pointerId: event.pointerId,
|
|
401
|
+
clientX: event.clientX,
|
|
402
|
+
})), "@foldkit/ui/toast/update.js#mapEvent~2"),
|
|
403
|
+
});
|
|
404
|
+
const pointerCancelStream = Subscription.fromEvent({
|
|
405
|
+
target: document,
|
|
406
|
+
type: 'pointercancel',
|
|
407
|
+
mapEvent: event => __foldkitBrandViewResult((MessageSchema.CancelledSwipe({ pointerId: event.pointerId })), "@foldkit/ui/toast/update.js#mapEvent~3"),
|
|
408
|
+
});
|
|
409
|
+
const pointerMessages = Stream.mergeAll([pointerMoveStream, pointerUpStream, pointerCancelStream], { concurrency: 'unbounded' });
|
|
410
|
+
return __foldkitBrandViewResult((Stream.when(Stream.merge(pointerMessages, documentStylesWhileSwiping), Effect.sync(() => __foldkitBrandViewResult((isSwipeEnabled && isAnyDragging), "@foldkit/ui/toast/update.js#anonymous~48")))), "@foldkit/ui/toast/update.js#dependenciesToStream");
|
|
411
|
+
},
|
|
412
|
+
}),
|
|
413
|
+
swipeEscape: entry({
|
|
414
|
+
isSwipeEnabled: Schema.Boolean,
|
|
415
|
+
isAnyDragging: Schema.Boolean,
|
|
416
|
+
}, {
|
|
417
|
+
modelToDependencies: swipeDependencies,
|
|
418
|
+
dependenciesToStream: ({ isSwipeEnabled, isAnyDragging }) => __foldkitBrandViewResult((Stream.when(Subscription.fromEventFilterMap({
|
|
419
|
+
target: document,
|
|
420
|
+
type: 'keydown',
|
|
421
|
+
filterMapEvent: event => __foldkitBrandViewResult((pipe(Option.liftPredicate(event.key, key => __foldkitBrandViewResult((key === 'Escape'), "@foldkit/ui/toast/update.js#anonymous~49")), Option.map(() => __foldkitBrandViewResult((MessageSchema.PressedEscape()), "@foldkit/ui/toast/update.js#anonymous~50")))), "@foldkit/ui/toast/update.js#filterMapEvent"),
|
|
422
|
+
}), Effect.sync(() => __foldkitBrandViewResult((isSwipeEnabled && isAnyDragging), "@foldkit/ui/toast/update.js#anonymous~51")))), "@foldkit/ui/toast/update.js#dependenciesToStream~2"),
|
|
423
|
+
}),
|
|
424
|
+
}), "@foldkit/ui/toast/update.js#anonymous~47")));
|
|
212
425
|
return __foldkitBrandViewResult(({
|
|
213
426
|
Entry: EntrySchema,
|
|
214
427
|
Model: ModelSchema,
|
|
@@ -221,5 +434,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
221
434
|
show,
|
|
222
435
|
dismiss,
|
|
223
436
|
dismissAll,
|
|
437
|
+
subscriptions,
|
|
438
|
+
swipeOffset,
|
|
224
439
|
}), "@foldkit/ui/toast/update.js#makeRuntime");
|
|
225
440
|
};
|
|
@@ -103,6 +103,13 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
103
103
|
readonly pendingShowVersion: number;
|
|
104
104
|
readonly maybeLastPointerType: Option.Option<string>;
|
|
105
105
|
}, {
|
|
106
|
+
readonly _tag: "PressedEscape";
|
|
107
|
+
} | {
|
|
108
|
+
readonly _tag: "CompletedWaitBeforeShowing";
|
|
109
|
+
readonly version: number;
|
|
110
|
+
} | {
|
|
111
|
+
readonly _tag: "CompletedAnchorTooltip";
|
|
112
|
+
} | {
|
|
106
113
|
readonly _tag: "BlurredTrigger";
|
|
107
114
|
} | {
|
|
108
115
|
readonly _tag: "EnteredTrigger";
|
|
@@ -110,13 +117,6 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
110
117
|
readonly _tag: "FocusedTrigger";
|
|
111
118
|
} | {
|
|
112
119
|
readonly _tag: "LeftTrigger";
|
|
113
|
-
} | {
|
|
114
|
-
readonly _tag: "CompletedWaitBeforeShowing";
|
|
115
|
-
readonly version: number;
|
|
116
|
-
} | {
|
|
117
|
-
readonly _tag: "CompletedAnchorTooltip";
|
|
118
|
-
} | {
|
|
119
|
-
readonly _tag: "PressedEscape";
|
|
120
120
|
} | {
|
|
121
121
|
readonly _tag: "PressedPointerOnTrigger";
|
|
122
122
|
readonly pointerType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAC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