@foldkit/ui 0.152.0 → 0.153.0-canary.51ee84596c4f
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/dragAndDrop/index.d.ts +35 -30
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +36 -35
- package/dist/slider/index.d.ts +6 -3
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +14 -9
- package/dist/virtualList/index.d.ts +13 -7
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +17 -16
- package/package.json +4 -4
|
@@ -12,37 +12,42 @@ export declare const Model: S.Struct<{
|
|
|
12
12
|
readonly id: S.String;
|
|
13
13
|
readonly orientation: S.Literals<readonly ["Horizontal", "Vertical"]>;
|
|
14
14
|
readonly activationThreshold: S.Number;
|
|
15
|
-
readonly dragState:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
origin: S.Struct<{
|
|
20
|
-
readonly screenX: S.Number;
|
|
21
|
-
readonly screenY: S.Number;
|
|
22
|
-
}>;
|
|
23
|
-
}>, import("foldkit/schema").CallableTaggedStruct<"Dragging", {
|
|
24
|
-
itemId: S.String;
|
|
25
|
-
sourceContainerId: S.String;
|
|
26
|
-
sourceIndex: S.Number;
|
|
27
|
-
origin: S.Struct<{
|
|
28
|
-
readonly screenX: S.Number;
|
|
29
|
-
readonly screenY: S.Number;
|
|
30
|
-
}>;
|
|
31
|
-
current: S.Struct<{
|
|
32
|
-
readonly clientX: S.Number;
|
|
33
|
-
readonly clientY: S.Number;
|
|
34
|
-
}>;
|
|
35
|
-
maybeDropTarget: S.Option<S.Struct<{
|
|
15
|
+
readonly dragState: import("foldkit/schema").TaggedUnion<{
|
|
16
|
+
readonly Idle: {};
|
|
17
|
+
readonly Pending: {
|
|
18
|
+
readonly itemId: S.String;
|
|
36
19
|
readonly containerId: S.String;
|
|
37
20
|
readonly index: S.Number;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
21
|
+
readonly origin: S.Struct<{
|
|
22
|
+
readonly screenX: S.Number;
|
|
23
|
+
readonly screenY: S.Number;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
readonly Dragging: {
|
|
27
|
+
readonly itemId: S.String;
|
|
28
|
+
readonly sourceContainerId: S.String;
|
|
29
|
+
readonly sourceIndex: S.Number;
|
|
30
|
+
readonly origin: S.Struct<{
|
|
31
|
+
readonly screenX: S.Number;
|
|
32
|
+
readonly screenY: S.Number;
|
|
33
|
+
}>;
|
|
34
|
+
readonly current: S.Struct<{
|
|
35
|
+
readonly clientX: S.Number;
|
|
36
|
+
readonly clientY: S.Number;
|
|
37
|
+
}>;
|
|
38
|
+
readonly maybeDropTarget: S.Option<S.Struct<{
|
|
39
|
+
readonly containerId: S.String;
|
|
40
|
+
readonly index: S.Number;
|
|
41
|
+
}>>;
|
|
42
|
+
};
|
|
43
|
+
readonly KeyboardDragging: {
|
|
44
|
+
readonly itemId: S.String;
|
|
45
|
+
readonly sourceContainerId: S.String;
|
|
46
|
+
readonly sourceIndex: S.Number;
|
|
47
|
+
readonly targetContainerId: S.String;
|
|
48
|
+
readonly targetIndex: S.Number;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
46
51
|
}>;
|
|
47
52
|
export type Model = typeof Model.Type;
|
|
48
53
|
/** Union of all messages the drag-and-drop component can produce. */
|
|
@@ -100,7 +105,7 @@ export type InitConfig = Readonly<{
|
|
|
100
105
|
orientation?: 'Horizontal' | 'Vertical';
|
|
101
106
|
activationThreshold?: number;
|
|
102
107
|
}>;
|
|
103
|
-
/** Creates an initial drag-and-drop model. Starts
|
|
108
|
+
/** Creates an initial drag-and-drop model. Starts idle with Vertical orientation and a 5px activation threshold by default. */
|
|
104
109
|
export declare const init: (config: InitConfig) => Model;
|
|
105
110
|
/** Focuses a draggable item by ID after a keyboard move, drop, or cancel. */
|
|
106
111
|
export declare const FocusItem: Command.CommandDefinitionWithArgs<"FocusItem", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragAndDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,WAAW,EAEX,MAAM,EAEN,MAAM,IAAI,CAAC,EACX,MAAM,EAEP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,cAAc,CAAA;AAIhF,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAkBxC,QAAA,MAAM,UAAU;;;EAGd,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dragAndDrop/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,WAAW,EAEX,MAAM,EAEN,MAAM,IAAI,CAAC,EACX,MAAM,EAEP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAmB,MAAM,cAAc,CAAA;AAIhF,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAkBxC,QAAA,MAAM,UAAU;;;EAGd,CAAA;AA2BF,mHAAmH;AACnH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,qEAAqE;AACrE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuClB,C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KAAK,KACX,MAAM,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,IAAI,CAUpC,CAAA"}
|
|
@@ -4,7 +4,7 @@ import * as Command from 'foldkit/command';
|
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
5
|
import { inertHtml as ih } from 'foldkit/html';
|
|
6
6
|
import { defineMessageUnion } from 'foldkit/message';
|
|
7
|
-
import {
|
|
7
|
+
import { defineTaggedUnion } from 'foldkit/schema';
|
|
8
8
|
import { evo } from 'foldkit/struct';
|
|
9
9
|
import * as Subscription from 'foldkit/subscription';
|
|
10
10
|
import * as Update from 'foldkit/update';
|
|
@@ -23,29 +23,30 @@ const DropTarget = S.Struct({
|
|
|
23
23
|
containerId: S.String,
|
|
24
24
|
index: S.Number,
|
|
25
25
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
const DragState = defineTaggedUnion({
|
|
27
|
+
Idle: {},
|
|
28
|
+
Pending: {
|
|
29
|
+
itemId: S.String,
|
|
30
|
+
containerId: S.String,
|
|
31
|
+
index: S.Number,
|
|
32
|
+
origin: ScreenPoint,
|
|
33
|
+
},
|
|
34
|
+
Dragging: {
|
|
35
|
+
itemId: S.String,
|
|
36
|
+
sourceContainerId: S.String,
|
|
37
|
+
sourceIndex: S.Number,
|
|
38
|
+
origin: ScreenPoint,
|
|
39
|
+
current: ClientPoint,
|
|
40
|
+
maybeDropTarget: S.Option(DropTarget),
|
|
41
|
+
},
|
|
42
|
+
KeyboardDragging: {
|
|
43
|
+
itemId: S.String,
|
|
44
|
+
sourceContainerId: S.String,
|
|
45
|
+
sourceIndex: S.Number,
|
|
46
|
+
targetContainerId: S.String,
|
|
47
|
+
targetIndex: S.Number,
|
|
48
|
+
},
|
|
47
49
|
});
|
|
48
|
-
const DragState = S.Union([Idle, Pending, Dragging, KeyboardDragging]);
|
|
49
50
|
/** Schema for the drag-and-drop component's state, tracking its unique ID, orientation, and current drag phase. */
|
|
50
51
|
export const Model = S.Struct({
|
|
51
52
|
id: S.String,
|
|
@@ -110,12 +111,12 @@ export const OutMessage = defineMessageUnion({
|
|
|
110
111
|
// INIT
|
|
111
112
|
/** Configuration for creating a drag-and-drop model with `init`. */
|
|
112
113
|
const DEFAULT_ACTIVATION_THRESHOLD_PIXELS = 5;
|
|
113
|
-
/** Creates an initial drag-and-drop model. Starts
|
|
114
|
+
/** Creates an initial drag-and-drop model. Starts idle with Vertical orientation and a 5px activation threshold by default. */
|
|
114
115
|
export const init = (config) => (__foldkitBrandViewResult(({
|
|
115
116
|
id: config.id,
|
|
116
117
|
orientation: config.orientation ?? 'Vertical',
|
|
117
118
|
activationThreshold: config.activationThreshold ?? DEFAULT_ACTIVATION_THRESHOLD_PIXELS,
|
|
118
|
-
dragState: Idle(),
|
|
119
|
+
dragState: DragState.Idle(),
|
|
119
120
|
}), "@foldkit/ui/dragAndDrop/index.js#init"));
|
|
120
121
|
/** Focuses a draggable item by ID after a keyboard move, drop, or cancel. */
|
|
121
122
|
export const FocusItem = Command.define('FocusItem', {
|
|
@@ -194,7 +195,7 @@ const withUpdateReturn = M.withReturnType();
|
|
|
194
195
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
195
196
|
PressedDraggable: ({ itemId, containerId, index, screenX, screenY }) => (__foldkitBrandViewResult(({
|
|
196
197
|
model: evo(model, {
|
|
197
|
-
dragState: () => __foldkitBrandViewResult((Pending({
|
|
198
|
+
dragState: () => __foldkitBrandViewResult((DragState.Pending({
|
|
198
199
|
itemId,
|
|
199
200
|
containerId,
|
|
200
201
|
index,
|
|
@@ -211,7 +212,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
211
212
|
}
|
|
212
213
|
return __foldkitBrandViewResult(({
|
|
213
214
|
model: evo(model, {
|
|
214
|
-
dragState: () => __foldkitBrandViewResult((Dragging({
|
|
215
|
+
dragState: () => __foldkitBrandViewResult((DragState.Dragging({
|
|
215
216
|
itemId: pending.itemId,
|
|
216
217
|
sourceContainerId: pending.containerId,
|
|
217
218
|
sourceIndex: pending.index,
|
|
@@ -223,7 +224,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
223
224
|
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~9");
|
|
224
225
|
}), M.tag('Dragging', dragging => (__foldkitBrandViewResult(({
|
|
225
226
|
model: evo(model, {
|
|
226
|
-
dragState: () => __foldkitBrandViewResult((Dragging({
|
|
227
|
+
dragState: () => __foldkitBrandViewResult((DragState.Dragging({
|
|
227
228
|
...dragging,
|
|
228
229
|
current: { clientX, clientY },
|
|
229
230
|
maybeDropTarget,
|
|
@@ -231,14 +232,14 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
231
232
|
}),
|
|
232
233
|
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~10"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~11"))))), "@foldkit/ui/dragAndDrop/index.js#MovedPointer"),
|
|
233
234
|
ReleasedPointer: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Pending', () => (__foldkitBrandViewResult(({
|
|
234
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~4") }),
|
|
235
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~4") }),
|
|
235
236
|
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~12"))), M.tag('Dragging', dragging => __foldkitBrandViewResult((Option.match(dragging.maybeDropTarget, {
|
|
236
237
|
onNone: () => (__foldkitBrandViewResult(({
|
|
237
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~5") }),
|
|
238
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~5") }),
|
|
238
239
|
outMessage: OutMessage.Cancelled(),
|
|
239
240
|
}), "@foldkit/ui/dragAndDrop/index.js#onNone")),
|
|
240
241
|
onSome: dropTarget => (__foldkitBrandViewResult(({
|
|
241
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~6") }),
|
|
242
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~6") }),
|
|
242
243
|
outMessage: OutMessage.Reordered({
|
|
243
244
|
itemId: dragging.itemId,
|
|
244
245
|
fromContainerId: dragging.sourceContainerId,
|
|
@@ -252,14 +253,14 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
252
253
|
const maybeFocusCommand = Option.liftPredicate(model.dragState, dragState => __foldkitBrandViewResult((dragState._tag === 'KeyboardDragging'), "@foldkit/ui/dragAndDrop/index.js#anonymous~15")).pipe(Option.map(({ itemId }) => __foldkitBrandViewResult((FocusItem({ itemId })), "@foldkit/ui/dragAndDrop/index.js#anonymous~16")));
|
|
253
254
|
const maybeOutMessage = Option.liftPredicate(model.dragState._tag, _tag => __foldkitBrandViewResult((_tag === 'Dragging' || _tag === 'KeyboardDragging'), "@foldkit/ui/dragAndDrop/index.js#anonymous~17")).pipe(Option.map(() => __foldkitBrandViewResult((OutMessage.Cancelled()), "@foldkit/ui/dragAndDrop/index.js#anonymous~18")));
|
|
254
255
|
const dragCancellation = {
|
|
255
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~7") }),
|
|
256
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~7") }),
|
|
256
257
|
commands: Option.toArray(maybeFocusCommand),
|
|
257
258
|
};
|
|
258
259
|
return __foldkitBrandViewResult((pipe(dragCancellation, Update.withOutMessage(Option.getOrUndefined(maybeOutMessage)))), "@foldkit/ui/dragAndDrop/index.js#CancelledDrag");
|
|
259
260
|
},
|
|
260
261
|
ActivatedKeyboardDrag: ({ itemId, containerId, index }) => (__foldkitBrandViewResult(({
|
|
261
262
|
model: evo(model, {
|
|
262
|
-
dragState: () => __foldkitBrandViewResult((KeyboardDragging({
|
|
263
|
+
dragState: () => __foldkitBrandViewResult((DragState.KeyboardDragging({
|
|
263
264
|
itemId,
|
|
264
265
|
sourceContainerId: containerId,
|
|
265
266
|
sourceIndex: index,
|
|
@@ -270,7 +271,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
270
271
|
}), "@foldkit/ui/dragAndDrop/index.js#ActivatedKeyboardDrag")),
|
|
271
272
|
CompletedResolveKeyboardMove: ({ targetContainerId, targetIndex }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => (__foldkitBrandViewResult(({
|
|
272
273
|
model: evo(model, {
|
|
273
|
-
dragState: () => __foldkitBrandViewResult((KeyboardDragging({
|
|
274
|
+
dragState: () => __foldkitBrandViewResult((DragState.KeyboardDragging({
|
|
274
275
|
...keyboardDragging,
|
|
275
276
|
targetContainerId,
|
|
276
277
|
targetIndex,
|
|
@@ -279,7 +280,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
279
280
|
commands: [FocusItem({ itemId: keyboardDragging.itemId })],
|
|
280
281
|
}), "@foldkit/ui/dragAndDrop/index.js#anonymous~19"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/dragAndDrop/index.js#anonymous~20"))))), "@foldkit/ui/dragAndDrop/index.js#CompletedResolveKeyboardMove"),
|
|
281
282
|
ConfirmedKeyboardDrop: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('KeyboardDragging', keyboardDragging => (__foldkitBrandViewResult(({
|
|
282
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~10") }),
|
|
283
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/dragAndDrop/index.js#dragState~10") }),
|
|
283
284
|
commands: [FocusItem({ itemId: keyboardDragging.itemId })],
|
|
284
285
|
outMessage: OutMessage.Reordered({
|
|
285
286
|
itemId: keyboardDragging.itemId,
|
package/dist/slider/index.d.ts
CHANGED
|
@@ -13,9 +13,12 @@ export declare const Model: S.Struct<{
|
|
|
13
13
|
readonly min: S.Number;
|
|
14
14
|
readonly max: S.Number;
|
|
15
15
|
readonly step: S.Number;
|
|
16
|
-
readonly dragState:
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
readonly dragState: import("foldkit/schema").TaggedUnion<{
|
|
17
|
+
readonly Idle: {};
|
|
18
|
+
readonly Dragging: {
|
|
19
|
+
readonly originValue: S.Number;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
19
22
|
}>;
|
|
20
23
|
export type Model = typeof Model.Type;
|
|
21
24
|
/** Union of all messages the slider component can produce. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,MAAM,IAAI,CAAC,EAIZ,MAAM,QAAQ,CAAA;AACf,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAI9E,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,YAAY,MAA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,16 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Effect, Equal, Function, Match as M, Option, Schema as S, Stream, String as String_, pipe, } from 'effect';
|
|
3
3
|
import { childAttributes } from 'foldkit/html';
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message';
|
|
5
|
-
import {
|
|
5
|
+
import { defineTaggedUnion } from 'foldkit/schema';
|
|
6
6
|
import { evo } from 'foldkit/struct';
|
|
7
7
|
import { defineView } from 'foldkit/submodel';
|
|
8
8
|
import * as Subscription from 'foldkit/subscription';
|
|
9
9
|
import { attributeSelector } from '../internal/selectors.js';
|
|
10
10
|
// MODEL
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const DragState = defineTaggedUnion({
|
|
12
|
+
Idle: {},
|
|
13
|
+
Dragging: { originValue: S.Number },
|
|
14
|
+
});
|
|
14
15
|
/** Schema for the slider component's private interaction state. The current
|
|
15
16
|
* value is owned by the parent and passed in via `ViewInputs.value`, so it is
|
|
16
17
|
* not stored here. `min`/`max`/`step` are configuration the drag subscription
|
|
@@ -58,7 +59,7 @@ export const init = (config) => (__foldkitBrandViewResult(({
|
|
|
58
59
|
min: config.min,
|
|
59
60
|
max: config.max,
|
|
60
61
|
step: config.step,
|
|
61
|
-
dragState: Idle(),
|
|
62
|
+
dragState: DragState.Idle(),
|
|
62
63
|
}), "@foldkit/ui/slider/index.js#init"));
|
|
63
64
|
// HELPERS
|
|
64
65
|
const stepDecimals = (step) => {
|
|
@@ -112,7 +113,9 @@ const withChangedValue = (model, currentValue, nextValue) => {
|
|
|
112
113
|
* Model. */
|
|
113
114
|
export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
114
115
|
PressedThumb: ({ originValue }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~7"))), M.orElse(() => (__foldkitBrandViewResult(({
|
|
115
|
-
model: evo(model, {
|
|
116
|
+
model: evo(model, {
|
|
117
|
+
dragState: () => __foldkitBrandViewResult((DragState.Dragging({ originValue })), "@foldkit/ui/slider/index.js#dragState"),
|
|
118
|
+
}),
|
|
116
119
|
}), "@foldkit/ui/slider/index.js#anonymous~8"))))), "@foldkit/ui/slider/index.js#PressedThumb"),
|
|
117
120
|
// NOTE: the pointerdown event on the thumb bubbles to the track, so a
|
|
118
121
|
// thumb press also dispatches PressedPointer. Short-circuit when already
|
|
@@ -122,7 +125,9 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
122
125
|
// off-center on a non-zero-width thumb.
|
|
123
126
|
PressedPointer: ({ value, originValue }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~9"))), M.orElse(() => {
|
|
124
127
|
const snapped = snapAndClamp(value, model.min, model.max, model.step);
|
|
125
|
-
return __foldkitBrandViewResult((withChangedValue(evo(model, {
|
|
128
|
+
return __foldkitBrandViewResult((withChangedValue(evo(model, {
|
|
129
|
+
dragState: () => __foldkitBrandViewResult((DragState.Dragging({ originValue })), "@foldkit/ui/slider/index.js#dragState~2"),
|
|
130
|
+
}), originValue, snapped)), "@foldkit/ui/slider/index.js#anonymous~10");
|
|
126
131
|
}))), "@foldkit/ui/slider/index.js#PressedPointer"),
|
|
127
132
|
MovedDragPointer: ({ value }) => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => (__foldkitBrandViewResult(({
|
|
128
133
|
model,
|
|
@@ -131,10 +136,10 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
131
136
|
}),
|
|
132
137
|
}), "@foldkit/ui/slider/index.js#anonymous~11"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~12"))))), "@foldkit/ui/slider/index.js#MovedDragPointer"),
|
|
133
138
|
ReleasedDragPointer: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => (__foldkitBrandViewResult(({
|
|
134
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/slider/index.js#dragState~3") }),
|
|
139
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/slider/index.js#dragState~3") }),
|
|
135
140
|
}), "@foldkit/ui/slider/index.js#anonymous~13"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~14"))))), "@foldkit/ui/slider/index.js#ReleasedDragPointer"),
|
|
136
141
|
CancelledDrag: () => __foldkitBrandViewResult((M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', ({ originValue }) => (__foldkitBrandViewResult(({
|
|
137
|
-
model: evo(model, { dragState: () => __foldkitBrandViewResult((Idle()), "@foldkit/ui/slider/index.js#dragState~4") }),
|
|
142
|
+
model: evo(model, { dragState: () => __foldkitBrandViewResult((DragState.Idle()), "@foldkit/ui/slider/index.js#dragState~4") }),
|
|
138
143
|
outMessage: OutMessage.ChangedValue({ value: originValue }),
|
|
139
144
|
}), "@foldkit/ui/slider/index.js#anonymous~15"))), M.orElse(() => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/slider/index.js#anonymous~16"))))), "@foldkit/ui/slider/index.js#CancelledDrag"),
|
|
140
145
|
PressedKeyboardNavigation: ({ direction, value }) => __foldkitBrandViewResult((withChangedValue(model, value, nextValueForDirection(value, model.min, model.max, model.step, direction))), "@foldkit/ui/slider/index.js#PressedKeyboardNavigation"),
|
|
@@ -10,13 +10,19 @@ export declare const Model: S.Struct<{
|
|
|
10
10
|
readonly id: S.String;
|
|
11
11
|
readonly rowHeightPx: S.Number;
|
|
12
12
|
readonly scrollTop: S.Number;
|
|
13
|
-
readonly measurement:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
readonly measurement: import("foldkit/schema").TaggedUnion<{
|
|
14
|
+
readonly Unmeasured: {};
|
|
15
|
+
readonly Measured: {
|
|
16
|
+
readonly containerHeight: S.Number;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
readonly pendingScroll: import("foldkit/schema").TaggedUnion<{
|
|
20
|
+
readonly Idle: {};
|
|
21
|
+
readonly ScrollingToIndex: {
|
|
22
|
+
readonly index: S.Number;
|
|
23
|
+
readonly version: S.Number;
|
|
24
|
+
};
|
|
25
|
+
}>;
|
|
20
26
|
readonly pendingScrollVersion: S.Number;
|
|
21
27
|
}>;
|
|
22
28
|
export type Model = typeof Model.Type;
|
|
@@ -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,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,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;
|
|
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,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK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E,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CACpD,CAAC,CAAA;AAEF;;;;;;;YAOY;AACZ,KAAK,WAAW,CAAC,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAA;AAEvE,eAAO,MAAM,IAAI,GAAI,IAAI,OAEA,WAAW,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -3,13 +3,11 @@ import { Array, Effect, Match as M, Number, Option, Queue, Schema as S, Stream,
|
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import { childAttributes, } from 'foldkit/html';
|
|
5
5
|
import { defineMessageUnion } from 'foldkit/message';
|
|
6
|
-
import {
|
|
6
|
+
import { defineTaggedUnion } from 'foldkit/schema';
|
|
7
7
|
import { evo } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
9
9
|
import * as Subscription from 'foldkit/subscription';
|
|
10
10
|
// MODEL
|
|
11
|
-
const Unmeasured = ts('Unmeasured');
|
|
12
|
-
const Measured = ts('Measured', { containerHeight: S.Number });
|
|
13
11
|
/** Measurement state of the virtual list's scrollable container.
|
|
14
12
|
*
|
|
15
13
|
* Before the container's `ResizeObserver` fires for the first time we don't
|
|
@@ -17,14 +15,15 @@ const Measured = ts('Measured', { containerHeight: S.Number });
|
|
|
17
15
|
* `Unmeasured` explicitly, typically by rendering a placeholder until the
|
|
18
16
|
* first measurement arrives.
|
|
19
17
|
*/
|
|
20
|
-
const Measurement =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
index: S.Number,
|
|
24
|
-
version: S.Number,
|
|
18
|
+
const Measurement = defineTaggedUnion({
|
|
19
|
+
Unmeasured: {},
|
|
20
|
+
Measured: { containerHeight: S.Number },
|
|
25
21
|
});
|
|
26
22
|
/** State of a programmatic scroll initiated by `scrollToIndex`. */
|
|
27
|
-
const PendingScroll =
|
|
23
|
+
const PendingScroll = defineTaggedUnion({
|
|
24
|
+
Idle: {},
|
|
25
|
+
ScrollingToIndex: { index: S.Number, version: S.Number },
|
|
26
|
+
});
|
|
28
27
|
/** Schema for the virtual list's state. Tracks scroll position, container
|
|
29
28
|
* measurement, and any in-flight programmatic scroll. */
|
|
30
29
|
export const Model = S.Struct({
|
|
@@ -49,8 +48,8 @@ export const init = (config) => (__foldkitBrandViewResult(({
|
|
|
49
48
|
id: config.id,
|
|
50
49
|
rowHeightPx: config.rowHeightPx,
|
|
51
50
|
scrollTop: config.initialScrollTop ?? 0,
|
|
52
|
-
measurement: Unmeasured(),
|
|
53
|
-
pendingScroll: Idle(),
|
|
51
|
+
measurement: Measurement.Unmeasured(),
|
|
52
|
+
pendingScroll: PendingScroll.Idle(),
|
|
54
53
|
pendingScrollVersion: 0,
|
|
55
54
|
}), "@foldkit/ui/virtualList/index.js#init"));
|
|
56
55
|
// UPDATE
|
|
@@ -77,9 +76,9 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
77
76
|
const nextVersion = Number.increment(model.pendingScrollVersion);
|
|
78
77
|
return __foldkitBrandViewResult(({
|
|
79
78
|
model: evo(model, {
|
|
80
|
-
measurement: () => __foldkitBrandViewResult((Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement"),
|
|
79
|
+
measurement: () => __foldkitBrandViewResult((Measurement.Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement"),
|
|
81
80
|
pendingScrollVersion: () => __foldkitBrandViewResult((nextVersion), "@foldkit/ui/virtualList/index.js#pendingScrollVersion"),
|
|
82
|
-
pendingScroll: () => __foldkitBrandViewResult((ScrollingToIndex({
|
|
81
|
+
pendingScroll: () => __foldkitBrandViewResult((PendingScroll.ScrollingToIndex({
|
|
83
82
|
index: Math.floor(model.scrollTop / model.rowHeightPx),
|
|
84
83
|
version: nextVersion,
|
|
85
84
|
})), "@foldkit/ui/virtualList/index.js#pendingScroll"),
|
|
@@ -96,7 +95,7 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
96
95
|
else {
|
|
97
96
|
return __foldkitBrandViewResult(({
|
|
98
97
|
model: evo(model, {
|
|
99
|
-
measurement: () => __foldkitBrandViewResult((Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement~2"),
|
|
98
|
+
measurement: () => __foldkitBrandViewResult((Measurement.Measured({ containerHeight })), "@foldkit/ui/virtualList/index.js#measurement~2"),
|
|
100
99
|
}),
|
|
101
100
|
}), "@foldkit/ui/virtualList/index.js#MeasuredContainer");
|
|
102
101
|
}
|
|
@@ -106,7 +105,9 @@ export const update = (model, message) => __foldkitBrandViewResult((Message.matc
|
|
|
106
105
|
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/virtualList/index.js#CompletedApplyScroll");
|
|
107
106
|
}
|
|
108
107
|
else {
|
|
109
|
-
return __foldkitBrandViewResult(({
|
|
108
|
+
return __foldkitBrandViewResult(({
|
|
109
|
+
model: evo(model, { pendingScroll: () => __foldkitBrandViewResult((PendingScroll.Idle()), "@foldkit/ui/virtualList/index.js#pendingScroll~2") }),
|
|
110
|
+
}), "@foldkit/ui/virtualList/index.js#CompletedApplyScroll");
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
})), "@foldkit/ui/virtualList/index.js#update");
|
|
@@ -115,7 +116,7 @@ const buildScrollToIndex = (model, index, targetScrollTop) => {
|
|
|
115
116
|
return __foldkitBrandViewResult(({
|
|
116
117
|
model: evo(model, {
|
|
117
118
|
pendingScrollVersion: () => __foldkitBrandViewResult((nextVersion), "@foldkit/ui/virtualList/index.js#pendingScrollVersion~2"),
|
|
118
|
-
pendingScroll: () => __foldkitBrandViewResult((ScrollingToIndex({ index, version: nextVersion })), "@foldkit/ui/virtualList/index.js#pendingScroll~3"),
|
|
119
|
+
pendingScroll: () => __foldkitBrandViewResult((PendingScroll.ScrollingToIndex({ index, version: nextVersion })), "@foldkit/ui/virtualList/index.js#pendingScroll~3"),
|
|
119
120
|
}),
|
|
120
121
|
commands: [
|
|
121
122
|
ApplyScroll({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.153.0-canary.51ee84596c4f",
|
|
4
4
|
"description": "Headless, accessible UI components for Foldkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
],
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"effect": "4.0.0-rc.112",
|
|
121
|
-
"foldkit": "
|
|
121
|
+
"foldkit": "0.153.0-canary.51ee84596c4f"
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
124
|
"@floating-ui/dom": "^1.7.6"
|
|
@@ -131,8 +131,8 @@
|
|
|
131
131
|
"typedoc": "^0.28.19",
|
|
132
132
|
"typescript": "^6.0.3",
|
|
133
133
|
"vitest": "^4.1.9",
|
|
134
|
-
"@foldkit/vite-plugin": "0.
|
|
135
|
-
"foldkit": "0.
|
|
134
|
+
"@foldkit/vite-plugin": "0.19.0-canary.51ee84596c4f",
|
|
135
|
+
"foldkit": "0.153.0-canary.51ee84596c4f"
|
|
136
136
|
},
|
|
137
137
|
"keywords": [
|
|
138
138
|
"foldkit",
|