@foldkit/ui 0.148.2 → 0.149.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/animation/index.d.ts +3 -3
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/animation/index.js +2 -2
- package/dist/animation/public.d.ts +1 -1
- package/dist/animation/public.d.ts.map +1 -1
- package/dist/animation/public.js +1 -1
- package/dist/animation/schema.d.ts +12 -21
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/schema.js +11 -15
- package/dist/animation/update.d.ts +1 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +9 -9
- package/dist/calendar/index.d.ts +50 -105
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +61 -98
- package/dist/calendar/public.d.ts +1 -1
- package/dist/calendar/public.d.ts.map +1 -1
- package/dist/calendar/public.js +1 -1
- package/dist/combobox/multi.d.ts +9 -9
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +9 -9
- package/dist/combobox/public.d.ts +1 -1
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +93 -137
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +108 -153
- package/dist/combobox/single.d.ts +9 -9
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +10 -10
- package/dist/datePicker/index.d.ts +88 -84
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +33 -63
- package/dist/datePicker/public.d.ts +1 -1
- package/dist/datePicker/public.d.ts.map +1 -1
- package/dist/datePicker/public.js +1 -1
- package/dist/dialog/index.d.ts +28 -49
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +39 -67
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/dialog/public.js +1 -1
- package/dist/dragAndDrop/index.d.ts +45 -72
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +72 -93
- package/dist/dragAndDrop/public.d.ts +1 -1
- package/dist/dragAndDrop/public.d.ts.map +1 -1
- package/dist/dragAndDrop/public.js +1 -1
- package/dist/fileDrop/index.d.ts +14 -35
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +20 -46
- package/dist/fileDrop/public.d.ts +1 -1
- package/dist/fileDrop/public.d.ts.map +1 -1
- package/dist/fileDrop/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -7
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +8 -8
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/public.js +1 -1
- package/dist/listbox/shared.d.ts +80 -127
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +92 -149
- package/dist/listbox/single.d.ts +7 -7
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -8
- package/dist/menu/index.d.ts +86 -134
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +141 -189
- package/dist/menu/public.d.ts +1 -1
- package/dist/menu/public.d.ts.map +1 -1
- package/dist/menu/public.js +1 -1
- package/dist/popover/index.d.ts +39 -65
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +68 -98
- package/dist/popover/public.d.ts +1 -1
- package/dist/popover/public.d.ts.map +1 -1
- package/dist/popover/public.js +1 -1
- package/dist/radioGroup/index.d.ts +18 -29
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +22 -27
- package/dist/radioGroup/public.d.ts +1 -1
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +29 -51
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +36 -56
- 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/tabs/index.d.ts +18 -28
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +22 -26
- package/dist/tabs/public.d.ts +1 -1
- package/dist/tabs/public.d.ts.map +1 -1
- package/dist/tabs/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +71 -14
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +14 -13
- package/dist/toast/index.d.ts +124 -109
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +5 -5
- package/dist/toast/public.d.ts +1 -1
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +72 -84
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +31 -41
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/test.js +6 -3
- package/dist/toast/update.d.ts +104 -89
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +19 -20
- package/dist/tooltip/message.d.ts +26 -47
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/message.js +15 -40
- package/dist/tooltip/public.d.ts +1 -1
- package/dist/tooltip/public.d.ts.map +1 -1
- package/dist/tooltip/public.js +1 -1
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -16
- package/dist/virtualList/index.d.ts +46 -23
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +12 -23
- package/dist/virtualList/public.d.ts +1 -1
- package/dist/virtualList/public.d.ts.map +1 -1
- package/dist/virtualList/public.js +1 -1
- package/package.json +3 -3
package/dist/toast/update.js
CHANGED
|
@@ -3,10 +3,10 @@ import { Array, Duration, Effect, Match as M, Number, Option, Schema as S, pipe,
|
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import { evo } from 'foldkit/struct';
|
|
5
5
|
import * as Update from 'foldkit/update';
|
|
6
|
-
import {
|
|
6
|
+
import { Message as AnimationMessage, OutMessage as AnimationOutMessage, init as animationInit, } from '../animation/schema.js';
|
|
7
7
|
import { defaultLeaveCommand as animationDefaultLeaveCommand, update as animationUpdate, } from '../animation/update.js';
|
|
8
8
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
9
|
-
import {
|
|
9
|
+
import { DEFAULT_DURATION, Message as StaticMessage, makeEntry, makeMessage, makeModel, makeOutMessage, } from './schema.js';
|
|
10
10
|
/** Schedules an auto-dismiss timer for an entry. The result Message carries a
|
|
11
11
|
* version so stale timers (from hover or manual dismiss) are discarded in
|
|
12
12
|
* the update function. Static. The Command definition doesn't depend on
|
|
@@ -17,8 +17,8 @@ export const WaitBeforeDismissal = Command.define('WaitBeforeDismissal', {
|
|
|
17
17
|
version: S.Number,
|
|
18
18
|
duration: S.DurationFromMillis,
|
|
19
19
|
},
|
|
20
|
-
messages: [CompletedWaitBeforeDismissal],
|
|
21
|
-
execute: ({ entryId, version, duration }) => __foldkitBrandViewResult((Effect.sleep(duration).pipe(Effect.as(CompletedWaitBeforeDismissal({ entryId, version })))), "@foldkit/ui/toast/update.js#execute"),
|
|
20
|
+
messages: [StaticMessage.CompletedWaitBeforeDismissal],
|
|
21
|
+
execute: ({ entryId, version, duration }) => __foldkitBrandViewResult((Effect.sleep(duration).pipe(Effect.as(StaticMessage.CompletedWaitBeforeDismissal({ entryId, version })))), "@foldkit/ui/toast/update.js#execute"),
|
|
22
22
|
});
|
|
23
23
|
const DEFAULT_VARIANT = 'Info';
|
|
24
24
|
/** Factory that binds Toast's runtime (update fn, helpers, commands) to a
|
|
@@ -33,9 +33,8 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
33
33
|
const ModelSchema = makeModel(payloadSchema);
|
|
34
34
|
const MessageSchema = makeMessage(payloadSchema);
|
|
35
35
|
const OutMessageSchema = makeOutMessage(payloadSchema);
|
|
36
|
-
const Added =
|
|
37
|
-
const DismissedToast =
|
|
38
|
-
const withUpdateReturn = M.withReturnType();
|
|
36
|
+
const Added = MessageSchema.Added;
|
|
37
|
+
const DismissedToast = OutMessageSchema.DismissedToast;
|
|
39
38
|
const updateEntry = (model, entryId, f) => __foldkitBrandViewResult((evo(model, {
|
|
40
39
|
entries: Array.map(entry => (__foldkitBrandViewResult((entry.id === entryId ? f(entry) : entry), "@foldkit/ui/toast/update.js#anonymous"))),
|
|
41
40
|
})), "@foldkit/ui/toast/update.js#updateEntry");
|
|
@@ -62,12 +61,12 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
62
61
|
};
|
|
63
62
|
const readEntryAnimation = (entryId) => __foldkitBrandViewResult(((model) => __foldkitBrandViewResult((pipe(Array.findFirst(model.entries, ({ id }) => __foldkitBrandViewResult((id === entryId), "@foldkit/ui/toast/update.js#anonymous~4")), Option.map(({ animation }) => __foldkitBrandViewResult((animation), "@foldkit/ui/toast/update.js#anonymous~5")))), "@foldkit/ui/toast/update.js#anonymous~3")), "@foldkit/ui/toast/update.js#readEntryAnimation");
|
|
64
63
|
const writeEntryAnimation = (entryId) => __foldkitBrandViewResult(((model, nextAnimation) => __foldkitBrandViewResult((updateEntry(model, entryId, entry => __foldkitBrandViewResult((evo(entry, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/toast/update.js#animation") })), "@foldkit/ui/toast/update.js#anonymous~7"))), "@foldkit/ui/toast/update.js#anonymous~6")), "@foldkit/ui/toast/update.js#writeEntryAnimation");
|
|
65
|
-
const toGotAnimationMessage = (entryId) => __foldkitBrandViewResult(((message) => __foldkitBrandViewResult((GotAnimationMessage({ entryId, message })), "@foldkit/ui/toast/update.js#anonymous~8")), "@foldkit/ui/toast/update.js#toGotAnimationMessage");
|
|
64
|
+
const toGotAnimationMessage = (entryId) => __foldkitBrandViewResult(((message) => __foldkitBrandViewResult((MessageSchema.GotAnimationMessage({ entryId, message })), "@foldkit/ui/toast/update.js#anonymous~8")), "@foldkit/ui/toast/update.js#toGotAnimationMessage");
|
|
66
65
|
const toDismissedToastOutMessage = payload => __foldkitBrandViewResult((M.type().pipe(M.withReturnType(), M.tagsExhaustive({
|
|
67
66
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/toast/update.js#StartedLeaveAnimating"),
|
|
68
|
-
TransitionedOut: () => __foldkitBrandViewResult((Option.some(DismissedToast({ payload }))), "@foldkit/ui/toast/update.js#TransitionedOut"),
|
|
67
|
+
TransitionedOut: () => __foldkitBrandViewResult((Option.some(OutMessageSchema.DismissedToast({ payload }))), "@foldkit/ui/toast/update.js#TransitionedOut"),
|
|
69
68
|
}))), "@foldkit/ui/toast/update.js#toDismissedToastOutMessage");
|
|
70
|
-
const foldEntryAnimationOutMessage = entryId => __foldkitBrandViewResult(((outMessage, { liftCommand }) => __foldkitBrandViewResult((
|
|
69
|
+
const foldEntryAnimationOutMessage = entryId => __foldkitBrandViewResult(((outMessage, { liftCommand }) => __foldkitBrandViewResult((AnimationOutMessage.match(outMessage, {
|
|
71
70
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((Option.match(readEntryAnimation(entryId)(model), {
|
|
72
71
|
onNone: () => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/toast/update.js#onNone~2"),
|
|
73
72
|
onSome: animation => __foldkitBrandViewResult(([
|
|
@@ -76,7 +75,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
76
75
|
]), "@foldkit/ui/toast/update.js#onSome~2"),
|
|
77
76
|
})), "@foldkit/ui/toast/update.js#anonymous~10")), "@foldkit/ui/toast/update.js#StartedLeaveAnimating~2"),
|
|
78
77
|
TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([removeEntry(model, entryId), []]), "@foldkit/ui/toast/update.js#anonymous~11")), "@foldkit/ui/toast/update.js#TransitionedOut~2"),
|
|
79
|
-
}))
|
|
78
|
+
})), "@foldkit/ui/toast/update.js#anonymous~9")), "@foldkit/ui/toast/update.js#foldEntryAnimationOutMessage");
|
|
80
79
|
const foldEntryAnimation = (entry) => __foldkitBrandViewResult((Update.foldChild({
|
|
81
80
|
update: animationUpdate,
|
|
82
81
|
read: readEntryAnimation(entry.id),
|
|
@@ -117,13 +116,13 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
117
116
|
/** Processes a toast message and returns the next model, commands, and
|
|
118
117
|
* an optional `DismissedToast` OutMessage emitted once an entry has
|
|
119
118
|
* finished its leave animation. */
|
|
120
|
-
const update = (model, message) => __foldkitBrandViewResult((
|
|
119
|
+
const update = (model, message) => __foldkitBrandViewResult((MessageSchema.match(message, {
|
|
121
120
|
Added: ({ entry }) => {
|
|
122
121
|
const modelWithEntry = evo(model, {
|
|
123
122
|
entries: entries => __foldkitBrandViewResult((Array.append(entries, entry)), "@foldkit/ui/toast/update.js#entries"),
|
|
124
123
|
nextEntryKey: Number.increment,
|
|
125
124
|
});
|
|
126
|
-
const [modelAfterShow, showCommands] = delegateToEntryAnimation(modelWithEntry, entry.id,
|
|
125
|
+
const [modelAfterShow, showCommands] = delegateToEntryAnimation(modelWithEntry, entry.id, AnimationMessage.Showed());
|
|
127
126
|
const postShowEntry = Array.findFirst(modelAfterShow.entries, ({ id }) => __foldkitBrandViewResult((id === entry.id), "@foldkit/ui/toast/update.js#anonymous~13"));
|
|
128
127
|
const dismissCommands = Option.match(postShowEntry, {
|
|
129
128
|
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/update.js#onNone~4"),
|
|
@@ -144,7 +143,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
144
143
|
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onSome~4");
|
|
145
144
|
}
|
|
146
145
|
else {
|
|
147
|
-
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId,
|
|
146
|
+
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, AnimationMessage.Hid())), "@foldkit/ui/toast/update.js#onSome~4");
|
|
148
147
|
}
|
|
149
148
|
},
|
|
150
149
|
})), "@foldkit/ui/toast/update.js#Dismissed");
|
|
@@ -153,7 +152,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
153
152
|
if (isEntryLeaving(entry)) {
|
|
154
153
|
return __foldkitBrandViewResult(([currentModel, currentCommands, currentOut]), "@foldkit/ui/toast/update.js#anonymous~15");
|
|
155
154
|
}
|
|
156
|
-
const [nextModel, nextCommands] = delegateToEntryAnimation(currentModel, entry.id,
|
|
155
|
+
const [nextModel, nextCommands] = delegateToEntryAnimation(currentModel, entry.id, AnimationMessage.Hid());
|
|
157
156
|
return __foldkitBrandViewResult(([
|
|
158
157
|
nextModel,
|
|
159
158
|
[...currentCommands, ...nextCommands],
|
|
@@ -170,7 +169,7 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
170
169
|
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/toast/update.js#onSome~5");
|
|
171
170
|
}
|
|
172
171
|
else {
|
|
173
|
-
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId,
|
|
172
|
+
return __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, AnimationMessage.Hid())), "@foldkit/ui/toast/update.js#onSome~5");
|
|
174
173
|
}
|
|
175
174
|
},
|
|
176
175
|
})), "@foldkit/ui/toast/update.js#CompletedWaitBeforeDismissal");
|
|
@@ -201,13 +200,13 @@ export const makeRuntime = (payloadSchema) => {
|
|
|
201
200
|
})), "@foldkit/ui/toast/update.js#LeftEntry");
|
|
202
201
|
},
|
|
203
202
|
GotAnimationMessage: ({ entryId, message: animationMessage }) => __foldkitBrandViewResult((delegateToEntryAnimation(model, entryId, animationMessage)), "@foldkit/ui/toast/update.js#GotAnimationMessage"),
|
|
204
|
-
}))
|
|
203
|
+
})), "@foldkit/ui/toast/update.js#update");
|
|
205
204
|
/** Adds a new toast entry. */
|
|
206
|
-
const show = (model, input) => __foldkitBrandViewResult((update(model, Added({ entry: createEntry(model, input) }))), "@foldkit/ui/toast/update.js#show");
|
|
205
|
+
const show = (model, input) => __foldkitBrandViewResult((update(model, MessageSchema.Added({ entry: createEntry(model, input) }))), "@foldkit/ui/toast/update.js#show");
|
|
207
206
|
/** Begins dismissing a specific entry. */
|
|
208
|
-
const dismiss = (model, entryId) => __foldkitBrandViewResult((update(model, Dismissed({ entryId }))), "@foldkit/ui/toast/update.js#dismiss");
|
|
207
|
+
const dismiss = (model, entryId) => __foldkitBrandViewResult((update(model, MessageSchema.Dismissed({ entryId }))), "@foldkit/ui/toast/update.js#dismiss");
|
|
209
208
|
/** Begins dismissing every currently-visible entry. */
|
|
210
|
-
const dismissAll = (model) => __foldkitBrandViewResult((update(model, DismissedAll())), "@foldkit/ui/toast/update.js#dismissAll");
|
|
209
|
+
const dismissAll = (model) => __foldkitBrandViewResult((update(model, MessageSchema.DismissedAll())), "@foldkit/ui/toast/update.js#dismissAll");
|
|
211
210
|
return __foldkitBrandViewResult(({
|
|
212
211
|
Entry: EntrySchema,
|
|
213
212
|
Model: ModelSchema,
|
|
@@ -1,53 +1,32 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
|
-
/** Sent when the pointer enters the tooltip trigger. */
|
|
3
|
-
export declare const EnteredTrigger: import("foldkit/schema").CallableTaggedStruct<"EnteredTrigger", {}>;
|
|
4
|
-
/** Sent when the pointer leaves the tooltip trigger. */
|
|
5
|
-
export declare const LeftTrigger: import("foldkit/schema").CallableTaggedStruct<"LeftTrigger", {}>;
|
|
6
|
-
/** Sent when focus enters the trigger. */
|
|
7
|
-
export declare const FocusedTrigger: import("foldkit/schema").CallableTaggedStruct<"FocusedTrigger", {}>;
|
|
8
|
-
/** Sent when focus leaves the trigger. */
|
|
9
|
-
export declare const BlurredTrigger: import("foldkit/schema").CallableTaggedStruct<"BlurredTrigger", {}>;
|
|
10
|
-
/** Sent when Escape is pressed while the tooltip is visible. */
|
|
11
|
-
export declare const PressedEscape: import("foldkit/schema").CallableTaggedStruct<"PressedEscape", {}>;
|
|
12
|
-
/** Sent when a pointer presses the trigger. Recorded so the focus that
|
|
13
|
-
* follows a mouse press can be told apart from focus that affirms the
|
|
14
|
-
* tooltip (keyboard, touch, or pen). */
|
|
15
|
-
export declare const PressedPointerOnTrigger: import("foldkit/schema").CallableTaggedStruct<"PressedPointerOnTrigger", {
|
|
16
|
-
pointerType: S.String;
|
|
17
|
-
}>;
|
|
18
|
-
/** Sent when the show-delay timer fires. */
|
|
19
|
-
export declare const CompletedWaitBeforeShowing: import("foldkit/schema").CallableTaggedStruct<"CompletedWaitBeforeShowing", {
|
|
20
|
-
version: S.Number;
|
|
21
|
-
}>;
|
|
22
|
-
/** Sent when the tooltip panel mounts and Floating UI has positioned it. */
|
|
23
|
-
export declare const CompletedAnchorTooltip: import("foldkit/schema").CallableTaggedStruct<"CompletedAnchorTooltip", {}>;
|
|
24
2
|
/** Union of all messages the tooltip component can produce. */
|
|
25
|
-
export declare const Message:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export type
|
|
40
|
-
export type
|
|
3
|
+
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
4
|
+
readonly EnteredTrigger: {};
|
|
5
|
+
readonly LeftTrigger: {};
|
|
6
|
+
readonly FocusedTrigger: {};
|
|
7
|
+
readonly BlurredTrigger: {};
|
|
8
|
+
readonly PressedEscape: {};
|
|
9
|
+
readonly PressedPointerOnTrigger: {
|
|
10
|
+
readonly pointerType: S.String;
|
|
11
|
+
};
|
|
12
|
+
readonly CompletedWaitBeforeShowing: {
|
|
13
|
+
readonly version: S.Number;
|
|
14
|
+
};
|
|
15
|
+
readonly CompletedAnchorTooltip: {};
|
|
16
|
+
}>;
|
|
17
|
+
export type EnteredTrigger = typeof Message.EnteredTrigger.Type;
|
|
18
|
+
export type LeftTrigger = typeof Message.LeftTrigger.Type;
|
|
19
|
+
export type FocusedTrigger = typeof Message.FocusedTrigger.Type;
|
|
20
|
+
export type BlurredTrigger = typeof Message.BlurredTrigger.Type;
|
|
21
|
+
export type PressedEscape = typeof Message.PressedEscape.Type;
|
|
22
|
+
export type PressedPointerOnTrigger = typeof Message.PressedPointerOnTrigger.Type;
|
|
41
23
|
export type Message = typeof Message.Type;
|
|
42
|
-
/** Emitted once the tooltip transitions to visible (`isOpen` becomes true).
|
|
43
|
-
* Consumers typically use this for analytics, instrumentation, or to
|
|
44
|
-
* coordinate with other transient UI. */
|
|
45
|
-
export declare const Shown: import("foldkit/schema").CallableTaggedStruct<"Shown", {}>;
|
|
46
|
-
/** Emitted once the tooltip transitions to hidden (`isOpen` becomes false). */
|
|
47
|
-
export declare const Hidden: import("foldkit/schema").CallableTaggedStruct<"Hidden", {}>;
|
|
48
24
|
/** Union of out-messages the tooltip component can produce. */
|
|
49
|
-
export declare const OutMessage:
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
export declare const OutMessage: import("foldkit/message").MessageUnion<{
|
|
26
|
+
readonly Shown: {};
|
|
27
|
+
readonly Hidden: {};
|
|
28
|
+
}>;
|
|
29
|
+
export type Shown = typeof OutMessage.Shown.Type;
|
|
30
|
+
export type Hidden = typeof OutMessage.Hidden.Type;
|
|
52
31
|
export type OutMessage = typeof OutMessage.Type;
|
|
53
32
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/tooltip/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAKpC
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/tooltip/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAKpC,+DAA+D;AAC/D,eAAO,MAAM,OAAO;;;;;;;;;;;;;EASlB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAA;AAC/D,MAAM,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAA;AACzD,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAA;AAC/D,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAA;AAC7D,MAAM,MAAM,uBAAuB,GACjC,OAAO,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAA;AAE7C,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,+DAA+D;AAC/D,eAAO,MAAM,UAAU;;;EAGrB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAA;AAChD,MAAM,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAA;AAClD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
|
package/dist/tooltip/message.js
CHANGED
|
@@ -1,45 +1,20 @@
|
|
|
1
1
|
import { Schema as S } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { defineMessageUnion } from 'foldkit/message';
|
|
3
3
|
// MESSAGE
|
|
4
|
-
/** Sent when the pointer enters the tooltip trigger. */
|
|
5
|
-
export const EnteredTrigger = m('EnteredTrigger');
|
|
6
|
-
/** Sent when the pointer leaves the tooltip trigger. */
|
|
7
|
-
export const LeftTrigger = m('LeftTrigger');
|
|
8
|
-
/** Sent when focus enters the trigger. */
|
|
9
|
-
export const FocusedTrigger = m('FocusedTrigger');
|
|
10
|
-
/** Sent when focus leaves the trigger. */
|
|
11
|
-
export const BlurredTrigger = m('BlurredTrigger');
|
|
12
|
-
/** Sent when Escape is pressed while the tooltip is visible. */
|
|
13
|
-
export const PressedEscape = m('PressedEscape');
|
|
14
|
-
/** Sent when a pointer presses the trigger. Recorded so the focus that
|
|
15
|
-
* follows a mouse press can be told apart from focus that affirms the
|
|
16
|
-
* tooltip (keyboard, touch, or pen). */
|
|
17
|
-
export const PressedPointerOnTrigger = m('PressedPointerOnTrigger', {
|
|
18
|
-
pointerType: S.String,
|
|
19
|
-
});
|
|
20
|
-
/** Sent when the show-delay timer fires. */
|
|
21
|
-
export const CompletedWaitBeforeShowing = m('CompletedWaitBeforeShowing', {
|
|
22
|
-
version: S.Number,
|
|
23
|
-
});
|
|
24
|
-
/** Sent when the tooltip panel mounts and Floating UI has positioned it. */
|
|
25
|
-
export const CompletedAnchorTooltip = m('CompletedAnchorTooltip');
|
|
26
4
|
/** Union of all messages the tooltip component can produce. */
|
|
27
|
-
export const Message =
|
|
28
|
-
EnteredTrigger,
|
|
29
|
-
LeftTrigger,
|
|
30
|
-
FocusedTrigger,
|
|
31
|
-
BlurredTrigger,
|
|
32
|
-
PressedEscape,
|
|
33
|
-
PressedPointerOnTrigger,
|
|
34
|
-
CompletedWaitBeforeShowing,
|
|
35
|
-
CompletedAnchorTooltip,
|
|
36
|
-
|
|
5
|
+
export const Message = defineMessageUnion({
|
|
6
|
+
EnteredTrigger: {},
|
|
7
|
+
LeftTrigger: {},
|
|
8
|
+
FocusedTrigger: {},
|
|
9
|
+
BlurredTrigger: {},
|
|
10
|
+
PressedEscape: {},
|
|
11
|
+
PressedPointerOnTrigger: { pointerType: S.String },
|
|
12
|
+
CompletedWaitBeforeShowing: { version: S.Number },
|
|
13
|
+
CompletedAnchorTooltip: {},
|
|
14
|
+
});
|
|
37
15
|
// OUT MESSAGE
|
|
38
|
-
/** Emitted once the tooltip transitions to visible (`isOpen` becomes true).
|
|
39
|
-
* Consumers typically use this for analytics, instrumentation, or to
|
|
40
|
-
* coordinate with other transient UI. */
|
|
41
|
-
export const Shown = m('Shown');
|
|
42
|
-
/** Emitted once the tooltip transitions to hidden (`isOpen` becomes false). */
|
|
43
|
-
export const Hidden = m('Hidden');
|
|
44
16
|
/** Union of out-messages the tooltip component can produce. */
|
|
45
|
-
export const OutMessage =
|
|
17
|
+
export const OutMessage = defineMessageUnion({
|
|
18
|
+
Shown: {},
|
|
19
|
+
Hidden: {},
|
|
20
|
+
});
|
package/dist/tooltip/public.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { init, update, view, triggerId, reflectShowDelay, Model, Message, OutMessage, Shown, Hidden, EnteredTrigger, LeftTrigger, FocusedTrigger, BlurredTrigger, PressedEscape, PressedPointerOnTrigger,
|
|
1
|
+
export { init, update, view, triggerId, reflectShowDelay, Model, Message, OutMessage, type Shown, type Hidden, type EnteredTrigger, type LeftTrigger, type FocusedTrigger, type BlurredTrigger, type PressedEscape, type PressedPointerOnTrigger, WaitBeforeShowing, AnchorTooltip, } from './index.js';
|
|
2
2
|
export type { InitConfig, ViewInputs, RenderInfo } from './index.js';
|
|
3
3
|
export type { AnchorConfig } from '../anchor/index.js';
|
|
4
4
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/tooltip/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/tooltip/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/tooltip/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, view, triggerId, reflectShowDelay, Model, Message, OutMessage,
|
|
1
|
+
export { init, update, view, triggerId, reflectShowDelay, Model, Message, OutMessage, WaitBeforeShowing, AnchorTooltip, } from './index.js';
|
|
@@ -4,7 +4,7 @@ import { type ChildAttribute, type Html } from 'foldkit/html';
|
|
|
4
4
|
import * as Mount from 'foldkit/mount';
|
|
5
5
|
import { type Reflect } from 'foldkit/submodel';
|
|
6
6
|
import { AnchorConfig } from '../anchor/index.js';
|
|
7
|
-
import {
|
|
7
|
+
import { Message, OutMessage } from './message.js';
|
|
8
8
|
/** Schema for the tooltip component's state. `isOpen` is visibility; `isHovered` tracks pointer on trigger; `isFocused` tracks tooltip-affirming focus on the trigger (focus arriving without a preceding mouse press, like keyboard, touch, or pen; mouse-click-induced focus is excluded since it doesn't affirm the user wants the tooltip visible); `isDismissed` suppresses re-opening after the user dismissed the tooltip (via Escape) until they disengage (leave or blur). `showDelay` is the hover-to-show duration. `maybeLastPointerType` records the most recent pointer type that pressed the trigger, so a mouse-click-induced focus can be distinguished from other focus. */
|
|
9
9
|
export declare const Model: S.Struct<{
|
|
10
10
|
readonly id: S.String;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,MAAM,EAKN,MAAM,EAEN,MAAM,IAAI,CAAC,EACZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAA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'foldkit/submodel';
|
|
8
8
|
import { AnchorConfig, anchorSetup } from '../anchor/index.js';
|
|
9
9
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Message, OutMessage } from './message.js';
|
|
11
11
|
// MODEL
|
|
12
12
|
/** Schema for the tooltip component's state. `isOpen` is visibility; `isHovered` tracks pointer on trigger; `isFocused` tracks tooltip-affirming focus on the trigger (focus arriving without a preceding mouse press, like keyboard, touch, or pen; mouse-click-induced focus is excluded since it doesn't affirm the user wants the tooltip visible); `isDismissed` suppresses re-opening after the user dismissed the tooltip (via Escape) until they disengage (leave or blur). `showDelay` is the hover-to-show duration. `maybeLastPointerType` records the most recent pointer type that pressed the trigger, so a mouse-click-induced focus can be distinguished from other focus. */
|
|
13
13
|
export const Model = S.Struct({
|
|
@@ -42,24 +42,23 @@ export const init = (config) => (__foldkitBrandViewResult(({
|
|
|
42
42
|
pendingShowVersion: 0,
|
|
43
43
|
maybeLastPointerType: Option.none(),
|
|
44
44
|
}), "@foldkit/ui/tooltip/tooltip.js#init"));
|
|
45
|
-
const withUpdateReturn = M.withReturnType();
|
|
46
45
|
/** Waits for the tooltip's show delay before emitting
|
|
47
46
|
* `CompletedWaitBeforeShowing`. */
|
|
48
47
|
export const WaitBeforeShowing = Command.define('WaitBeforeShowing', {
|
|
49
48
|
args: { delay: S.DurationFromMillis, version: S.Number },
|
|
50
|
-
messages: [CompletedWaitBeforeShowing],
|
|
51
|
-
execute: ({ delay, version }) => __foldkitBrandViewResult((Effect.sleep(delay).pipe(Effect.as(CompletedWaitBeforeShowing({ version })))), "@foldkit/ui/tooltip/tooltip.js#execute"),
|
|
49
|
+
messages: [Message.CompletedWaitBeforeShowing],
|
|
50
|
+
execute: ({ delay, version }) => __foldkitBrandViewResult((Effect.sleep(delay).pipe(Effect.as(Message.CompletedWaitBeforeShowing({ version })))), "@foldkit/ui/tooltip/tooltip.js#execute"),
|
|
52
51
|
});
|
|
53
52
|
/** The anchor-positioning Mount this Tooltip renders on its panel. */
|
|
54
|
-
export const AnchorTooltip = Mount.define('AnchorTooltip', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorTooltip)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
53
|
+
export const AnchorTooltip = Mount.define('AnchorTooltip', { buttonId: S.String, anchor: AnchorConfig }, Message.CompletedAnchorTooltip)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
55
54
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
56
55
|
buttonId,
|
|
57
56
|
anchor,
|
|
58
57
|
interceptTab: false,
|
|
59
58
|
})), "@foldkit/ui/tooltip/tooltip.js#anonymous~4")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/tooltip/tooltip.js#anonymous~5"));
|
|
60
|
-
return __foldkitBrandViewResult((CompletedAnchorTooltip()), "@foldkit/ui/tooltip/tooltip.js#anonymous~3");
|
|
59
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorTooltip()), "@foldkit/ui/tooltip/tooltip.js#anonymous~3");
|
|
61
60
|
})), "@foldkit/ui/tooltip/tooltip.js#anonymous~2")), "@foldkit/ui/tooltip/tooltip.js#anonymous"));
|
|
62
|
-
const computeUpdate = (model, message) => __foldkitBrandViewResult((
|
|
61
|
+
const computeUpdate = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
63
62
|
EnteredTrigger: () => {
|
|
64
63
|
if (model.isOpen || model.isDismissed) {
|
|
65
64
|
return __foldkitBrandViewResult(([evo(model, { isHovered: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/tooltip.js#isHovered") }), []]), "@foldkit/ui/tooltip/tooltip.js#EnteredTrigger");
|
|
@@ -144,13 +143,13 @@ const computeUpdate = (model, message) => __foldkitBrandViewResult((M.value(mess
|
|
|
144
143
|
return __foldkitBrandViewResult(([evo(model, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/tooltip/tooltip.js#isOpen~5") }), []]), "@foldkit/ui/tooltip/tooltip.js#CompletedWaitBeforeShowing");
|
|
145
144
|
},
|
|
146
145
|
CompletedAnchorTooltip: () => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/tooltip/tooltip.js#CompletedAnchorTooltip"),
|
|
147
|
-
}))
|
|
146
|
+
})), "@foldkit/ui/tooltip/tooltip.js#computeUpdate");
|
|
148
147
|
const toMaybeVisibilityOutMessage = (isOpen, isNextOpen) => {
|
|
149
148
|
if (!isOpen && isNextOpen) {
|
|
150
|
-
return __foldkitBrandViewResult((Option.some(Shown())), "@foldkit/ui/tooltip/tooltip.js#toMaybeVisibilityOutMessage");
|
|
149
|
+
return __foldkitBrandViewResult((Option.some(OutMessage.Shown())), "@foldkit/ui/tooltip/tooltip.js#toMaybeVisibilityOutMessage");
|
|
151
150
|
}
|
|
152
151
|
else if (isOpen && !isNextOpen) {
|
|
153
|
-
return __foldkitBrandViewResult((Option.some(Hidden())), "@foldkit/ui/tooltip/tooltip.js#toMaybeVisibilityOutMessage");
|
|
152
|
+
return __foldkitBrandViewResult((Option.some(OutMessage.Hidden())), "@foldkit/ui/tooltip/tooltip.js#toMaybeVisibilityOutMessage");
|
|
154
153
|
}
|
|
155
154
|
else {
|
|
156
155
|
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/tooltip.js#toMaybeVisibilityOutMessage");
|
|
@@ -187,8 +186,8 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
187
186
|
}
|
|
188
187
|
};
|
|
189
188
|
const triggerLabelAttributes = resolveTriggerLabel();
|
|
190
|
-
const handleTriggerKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, PressedEscape())), "@foldkit/ui/tooltip/tooltip.js#anonymous~8")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/tooltip.js#anonymous~9")))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerKeyDown");
|
|
191
|
-
const handleTriggerPointerDown = (pointerType) => __foldkitBrandViewResult((Option.some(PressedPointerOnTrigger({ pointerType }))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerPointerDown");
|
|
189
|
+
const handleTriggerKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.PressedEscape())), "@foldkit/ui/tooltip/tooltip.js#anonymous~8")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/tooltip.js#anonymous~9")))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerKeyDown");
|
|
190
|
+
const handleTriggerPointerDown = (pointerType) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnTrigger({ pointerType }))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerPointerDown");
|
|
192
191
|
const triggerAttributes = [
|
|
193
192
|
h.Id(triggerId(id)),
|
|
194
193
|
h.Type('button'),
|
|
@@ -198,10 +197,10 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
198
197
|
...(isDisabled
|
|
199
198
|
? [h.AriaDisabled(true), h.DataAttribute('disabled', '')]
|
|
200
199
|
: [
|
|
201
|
-
h.OnMouseEnter(EnteredTrigger()),
|
|
202
|
-
h.OnMouseLeave(LeftTrigger()),
|
|
203
|
-
h.OnFocus(FocusedTrigger()),
|
|
204
|
-
h.OnBlur(BlurredTrigger()),
|
|
200
|
+
h.OnMouseEnter(Message.EnteredTrigger()),
|
|
201
|
+
h.OnMouseLeave(Message.LeftTrigger()),
|
|
202
|
+
h.OnFocus(Message.FocusedTrigger()),
|
|
203
|
+
h.OnBlur(Message.BlurredTrigger()),
|
|
205
204
|
h.OnKeyDownPreventDefault(handleTriggerKeyDown),
|
|
206
205
|
h.OnPointerDown(handleTriggerPointerDown),
|
|
207
206
|
]),
|
|
@@ -19,29 +19,20 @@ export declare const Model: S.Struct<{
|
|
|
19
19
|
readonly pendingScrollVersion: S.Number;
|
|
20
20
|
}>;
|
|
21
21
|
export type Model = typeof Model.Type;
|
|
22
|
-
/** Sent when the user scrolls the container. Carries the new scroll position
|
|
23
|
-
* read from the scroll event. */
|
|
24
|
-
export declare const ScrolledContainer: import("foldkit/schema").CallableTaggedStruct<"ScrolledContainer", {
|
|
25
|
-
scrollTop: S.Number;
|
|
26
|
-
}>;
|
|
27
|
-
/** Sent when the container resizes. Carries the new container height read
|
|
28
|
-
* from the `ResizeObserver` entry. */
|
|
29
|
-
export declare const MeasuredContainer: import("foldkit/schema").CallableTaggedStruct<"MeasuredContainer", {
|
|
30
|
-
containerHeight: S.Number;
|
|
31
|
-
}>;
|
|
32
|
-
/** Sent when a `scrollToIndex` Command completes. Carries the version it was
|
|
33
|
-
* issued with so the update can ignore stale completions. */
|
|
34
|
-
export declare const CompletedApplyScroll: import("foldkit/schema").CallableTaggedStruct<"CompletedApplyScroll", {
|
|
35
|
-
version: S.Number;
|
|
36
|
-
}>;
|
|
37
22
|
/** Union of all messages the virtual list component can produce. */
|
|
38
|
-
export declare const Message:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
24
|
+
readonly ScrolledContainer: {
|
|
25
|
+
readonly scrollTop: S.Number;
|
|
26
|
+
};
|
|
27
|
+
readonly MeasuredContainer: {
|
|
28
|
+
readonly containerHeight: S.Number;
|
|
29
|
+
};
|
|
30
|
+
readonly CompletedApplyScroll: {
|
|
31
|
+
readonly version: S.Number;
|
|
32
|
+
};
|
|
33
|
+
}>;
|
|
34
|
+
export type ScrolledContainer = typeof Message.ScrolledContainer.Type;
|
|
35
|
+
export type MeasuredContainer = typeof Message.MeasuredContainer.Type;
|
|
45
36
|
export type Message = typeof Message.Type;
|
|
46
37
|
/** Configuration for creating a virtual list model with `init`. */
|
|
47
38
|
export type InitConfig = Readonly<{
|
|
@@ -62,7 +53,39 @@ export declare const ApplyScroll: Command.CommandDefinitionWithArgs<"ApplyScroll
|
|
|
62
53
|
readonly version: number;
|
|
63
54
|
}, never, never>>;
|
|
64
55
|
/** Processes a virtual list message and returns the next model and commands. */
|
|
65
|
-
export declare const update: (model: Model, message: Message) => readonly [
|
|
56
|
+
export declare const update: (model: Model, message: Message) => readonly [{
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly rowHeightPx: number;
|
|
59
|
+
readonly scrollTop: number;
|
|
60
|
+
readonly measurement: {
|
|
61
|
+
readonly _tag: "Unmeasured";
|
|
62
|
+
} | {
|
|
63
|
+
readonly _tag: "Measured";
|
|
64
|
+
readonly containerHeight: number;
|
|
65
|
+
};
|
|
66
|
+
readonly pendingScroll: {
|
|
67
|
+
readonly _tag: "Idle";
|
|
68
|
+
} | {
|
|
69
|
+
readonly _tag: "ScrollingToIndex";
|
|
70
|
+
readonly index: number;
|
|
71
|
+
readonly version: number;
|
|
72
|
+
};
|
|
73
|
+
readonly pendingScrollVersion: number;
|
|
74
|
+
}, readonly Readonly<{
|
|
75
|
+
name: string;
|
|
76
|
+
args?: Record<string, unknown>;
|
|
77
|
+
key?: string;
|
|
78
|
+
effect: Effect.Effect<{
|
|
79
|
+
readonly _tag: "ScrolledContainer";
|
|
80
|
+
readonly scrollTop: number;
|
|
81
|
+
} | {
|
|
82
|
+
readonly _tag: "MeasuredContainer";
|
|
83
|
+
readonly containerHeight: number;
|
|
84
|
+
} | {
|
|
85
|
+
readonly _tag: "CompletedApplyScroll";
|
|
86
|
+
readonly version: number;
|
|
87
|
+
}, never, never>;
|
|
88
|
+
}>[]];
|
|
66
89
|
/** Programmatically scrolls the container so the row at `index` is visible.
|
|
67
90
|
* Returns the next model and a Command that mutates `element.scrollTop`. The
|
|
68
91
|
* natural scroll event then flows back through `ScrolledContainer` and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/virtualList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,CAAC,EAGZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,OAAO,EAEb,MAAM,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AAyBpD;0DAC0D;AAC1D,eAAO,MAAM,KAAK;;;;;;;;;;;;EAOhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/virtualList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,CAAC,EAGZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,OAAO,EAEb,MAAM,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AAyBpD;0DAC0D;AAC1D,eAAO,MAAM,KAAK;;;;;;;;;;;;EAOhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,oEAAoE;AACpE,eAAO,MAAM,OAAO;;;;;;;;;;EAIlB,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAA;AACrE,MAAM,MAAM,iBAAiB,GAAG,OAAO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MAAM,IAAI,GAAI,IAAI,OAEA,WAAW,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Array, Effect, Match as M, Number, Option, Queue, Schema as S, Stream, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import { childAttributes, } from 'foldkit/html';
|
|
5
|
-
import {
|
|
5
|
+
import { defineMessageUnion } from 'foldkit/message';
|
|
6
6
|
import { ts } from 'foldkit/schema';
|
|
7
7
|
import { evo } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -36,23 +36,12 @@ export const Model = S.Struct({
|
|
|
36
36
|
pendingScrollVersion: S.Number,
|
|
37
37
|
});
|
|
38
38
|
// MESSAGE
|
|
39
|
-
/** Sent when the user scrolls the container. Carries the new scroll position
|
|
40
|
-
* read from the scroll event. */
|
|
41
|
-
export const ScrolledContainer = m('ScrolledContainer', {
|
|
42
|
-
scrollTop: S.Number,
|
|
43
|
-
});
|
|
44
|
-
/** Sent when the container resizes. Carries the new container height read
|
|
45
|
-
* from the `ResizeObserver` entry. */
|
|
46
|
-
export const MeasuredContainer = m('MeasuredContainer', {
|
|
47
|
-
containerHeight: S.Number,
|
|
48
|
-
});
|
|
49
|
-
/** Sent when a `scrollToIndex` Command completes. Carries the version it was
|
|
50
|
-
* issued with so the update can ignore stale completions. */
|
|
51
|
-
export const CompletedApplyScroll = m('CompletedApplyScroll', {
|
|
52
|
-
version: S.Number,
|
|
53
|
-
});
|
|
54
39
|
/** Union of all messages the virtual list component can produce. */
|
|
55
|
-
export const Message =
|
|
40
|
+
export const Message = defineMessageUnion({
|
|
41
|
+
ScrolledContainer: { scrollTop: S.Number },
|
|
42
|
+
MeasuredContainer: { containerHeight: S.Number },
|
|
43
|
+
CompletedApplyScroll: { version: S.Number },
|
|
44
|
+
});
|
|
56
45
|
/** Creates an initial virtual list model from a config. The container starts
|
|
57
46
|
* in `Unmeasured` state. The first `ResizeObserver` entry transitions it to
|
|
58
47
|
* `Measured`. */
|
|
@@ -67,17 +56,17 @@ export const init = (config) => (__foldkitBrandViewResult(({
|
|
|
67
56
|
// UPDATE
|
|
68
57
|
export const ApplyScroll = Command.define('ApplyScroll', {
|
|
69
58
|
args: { id: S.String, scrollTop: S.Number, version: S.Number },
|
|
70
|
-
messages: [CompletedApplyScroll],
|
|
59
|
+
messages: [Message.CompletedApplyScroll],
|
|
71
60
|
execute: ({ id, scrollTop, version }) => __foldkitBrandViewResult((Effect.sync(() => {
|
|
72
61
|
const element = document.getElementById(id);
|
|
73
62
|
if (element !== null) {
|
|
74
63
|
element.scrollTop = scrollTop;
|
|
75
64
|
}
|
|
76
|
-
return __foldkitBrandViewResult((CompletedApplyScroll({ version })), "@foldkit/ui/virtualList/index.js#anonymous");
|
|
65
|
+
return __foldkitBrandViewResult((Message.CompletedApplyScroll({ version })), "@foldkit/ui/virtualList/index.js#anonymous");
|
|
77
66
|
})), "@foldkit/ui/virtualList/index.js#execute"),
|
|
78
67
|
});
|
|
79
68
|
/** Processes a virtual list message and returns the next model and commands. */
|
|
80
|
-
export const update = (model, message) => __foldkitBrandViewResult((
|
|
69
|
+
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
81
70
|
ScrolledContainer: ({ scrollTop }) => __foldkitBrandViewResult(([
|
|
82
71
|
evo(model, { scrollTop: () => __foldkitBrandViewResult((scrollTop), "@foldkit/ui/virtualList/index.js#scrollTop") }),
|
|
83
72
|
[],
|
|
@@ -120,7 +109,7 @@ export const update = (model, message) => __foldkitBrandViewResult((M.value(mess
|
|
|
120
109
|
return __foldkitBrandViewResult(([evo(model, { pendingScroll: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/virtualList/index.js#pendingScroll~2") }), []]), "@foldkit/ui/virtualList/index.js#CompletedApplyScroll");
|
|
121
110
|
}
|
|
122
111
|
},
|
|
123
|
-
}))
|
|
112
|
+
})), "@foldkit/ui/virtualList/index.js#update");
|
|
124
113
|
const buildScrollToIndex = (model, index, targetScrollTop) => {
|
|
125
114
|
const nextVersion = Number.increment(model.pendingScrollVersion);
|
|
126
115
|
return __foldkitBrandViewResult(([
|
|
@@ -277,14 +266,14 @@ export const subscriptions = Subscription.make()(entry => (__foldkitBrandViewRes
|
|
|
277
266
|
state.scrollListener = null;
|
|
278
267
|
};
|
|
279
268
|
const attach = (element) => {
|
|
280
|
-
const listener = () => __foldkitBrandViewResult((Queue.offerUnsafe(queue, ScrolledContainer({ scrollTop: element.scrollTop }))), "@foldkit/ui/virtualList/index.js#listener");
|
|
269
|
+
const listener = () => __foldkitBrandViewResult((Queue.offerUnsafe(queue, Message.ScrolledContainer({ scrollTop: element.scrollTop }))), "@foldkit/ui/virtualList/index.js#listener");
|
|
281
270
|
element.addEventListener('scroll', listener, { passive: true });
|
|
282
271
|
state.scrollListener = listener;
|
|
283
272
|
state.observedElement = element;
|
|
284
273
|
state.resizeObserver = new ResizeObserver(entries => {
|
|
285
274
|
const lastEntry = Array.last(entries);
|
|
286
275
|
if (Option.isSome(lastEntry)) {
|
|
287
|
-
Queue.offerUnsafe(queue, MeasuredContainer({
|
|
276
|
+
Queue.offerUnsafe(queue, Message.MeasuredContainer({
|
|
288
277
|
containerHeight: lastEntry.value.contentRect.height,
|
|
289
278
|
}));
|
|
290
279
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { init, update, scrollToIndex, scrollToIndexVariable, view, subscriptions, visibleWindow, visibleWindowVariable, Model, Message, ScrolledContainer, MeasuredContainer,
|
|
1
|
+
export { init, update, scrollToIndex, scrollToIndexVariable, view, subscriptions, visibleWindow, visibleWindowVariable, Model, Message, type ScrolledContainer, type MeasuredContainer, } from './index.js';
|
|
2
2
|
export type { InitConfig, ViewInputs, VisibleWindow } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/virtualList/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,IAAI,EACJ,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,iBAAiB,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/virtualList/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,IAAI,EACJ,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,KAAK,EACL,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, scrollToIndex, scrollToIndexVariable, view, subscriptions, visibleWindow, visibleWindowVariable, Model, Message,
|
|
1
|
+
export { init, update, scrollToIndex, scrollToIndexVariable, view, subscriptions, visibleWindow, visibleWindowVariable, Model, Message, } from './index.js';
|