@foldkit/ui 0.152.0 → 0.153.0-canary.35bd4564b299
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 +14 -1
- package/dist/anchor/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +58 -5
- 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/popover/index.d.ts +15 -0
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +15 -2
- 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/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
package/dist/anchor/anchor.d.ts
CHANGED
|
@@ -45,13 +45,26 @@ export declare const portalToContainingRoot: (element: Element) => (() => void);
|
|
|
45
45
|
* - `focusAfterPosition`: focuses the element once the first position
|
|
46
46
|
* resolves. Defaults to `false`.
|
|
47
47
|
* - `focusSelector`: focuses this descendant instead of the element itself.
|
|
48
|
-
* Read only when `focusAfterPosition` is true.
|
|
48
|
+
* Read only when `focusAfterPosition` is true.
|
|
49
|
+
* - `arrowId`: id of an arrow element inside the panel, resolved through the
|
|
50
|
+
* element's own root. An id that resolves to an element outside the panel is
|
|
51
|
+
* ignored, and any element type is accepted, so an `<svg>` arrow works. When
|
|
52
|
+
* it resolves, the arrow's offset along the panel edge is published as
|
|
53
|
+
* `--arrow-x` and `--arrow-y`, with the axis the placement does not use
|
|
54
|
+
* reset to `initial`, and the panel is no longer made a scroll container,
|
|
55
|
+
* since scrolling clips on both axes and an arrow sits half outside the
|
|
56
|
+
* panel's box.
|
|
57
|
+
* - `arrowPadding`: distance in pixels the arrow keeps from the panel's
|
|
58
|
+
* corners. Defaults to `0`. Separate from `anchor.padding`, which is the
|
|
59
|
+
* viewport padding. */
|
|
49
60
|
export type SetupConfig = Readonly<{
|
|
50
61
|
buttonId: string;
|
|
51
62
|
anchor: AnchorConfig;
|
|
52
63
|
interceptTab?: boolean;
|
|
53
64
|
focusAfterPosition?: boolean;
|
|
54
65
|
focusSelector?: string;
|
|
66
|
+
arrowId?: string;
|
|
67
|
+
arrowPadding?: number;
|
|
55
68
|
}>;
|
|
56
69
|
/** Positions a floating element relative to its button using Floating UI, then
|
|
57
70
|
* returns a cleanup function. Designed to be called inside an `OnMount`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/anchor/anchor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,IAAI,CAAC,EAAgB,MAAM,QAAQ,CAAA;AAa3E;mFACmF;AACnF,eAAO,MAAM,SAAS,qKAapB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAE7C;+DAC+D;AAC/D,eAAO,MAAM,OAAO;;;;;IAQlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,oGAAoG;AACpG,eAAO,MAAM,YAAY;;;;;;;;;;;;EAOvB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAkCnD;;;;;;0DAM0D;AAC1D,eAAO,MAAM,sBAAsB,GAAI,SAAS,OAAO,KAAG,CAAC,MAAM,IAAI,CAWpE,CAAA;AAKD;;;;;;;;;;;;;;;;;;;;;0BAqB0B;AAC1B,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,YAAY,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC,CAAA;AAsBF;;;;;;;;;;;;;;;gFAegF;AAChF,eAAO,MAAM,WAAW,GACtB,SAAS,OAAO,EAChB,QAAQ,WAAW,KAClB,CAAC,MAAM,IAAI,CAyOb,CAAA"}
|
package/dist/anchor/anchor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
-
import { Array, Function, Schema as S, String, pipe } from 'effect';
|
|
3
|
-
import { autoUpdate, computePosition, flip, offset as floatingOffset, shift, size, } from '@floating-ui/dom';
|
|
2
|
+
import { Array, Function, Option, Schema as S, String, pipe } from 'effect';
|
|
3
|
+
import { arrow, autoUpdate, computePosition, flip, offset as floatingOffset, shift, size, } from '@floating-ui/dom';
|
|
4
4
|
/** Schema mirroring `@floating-ui/dom`'s `Placement` literal union: a side
|
|
5
5
|
* (`top`/`right`/`bottom`/`left`) optionally suffixed with `-start` or `-end`. */
|
|
6
6
|
export const Placement = S.Literals([
|
|
@@ -84,6 +84,22 @@ export const portalToContainingRoot = (element) => {
|
|
|
84
84
|
}), "@foldkit/ui/anchor/anchor.js#portalToContainingRoot");
|
|
85
85
|
};
|
|
86
86
|
const toSide = (placement) => __foldkitBrandViewResult((pipe(placement, String.split('-'), Array.headNonEmpty)), "@foldkit/ui/anchor/anchor.js#toSide");
|
|
87
|
+
// NOTE: the unused axis is reset to `initial` rather than removed. Custom
|
|
88
|
+
// properties inherit, so removing it lets an ancestor's `--arrow-x` reach the
|
|
89
|
+
// arrow, and a `left` that resolves beats the side rule's `right` under
|
|
90
|
+
// over-constrained absolute positioning. An ancestor is not far-fetched: a
|
|
91
|
+
// `portal: false` popover nested inside another popover's panel sits under one.
|
|
92
|
+
// `initial` gives the property its guaranteed-invalid initial value, so
|
|
93
|
+
// `var(--arrow-x)` is invalid at computed-value time and `left` falls back to
|
|
94
|
+
// `auto`.
|
|
95
|
+
const setOrResetLength = (element, property, value) => {
|
|
96
|
+
if (value === undefined) {
|
|
97
|
+
element.style.setProperty(property, 'initial');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
element.style.setProperty(property, `${value}px`);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
87
103
|
/** Positions a floating element relative to its button using Floating UI, then
|
|
88
104
|
* returns a cleanup function. Designed to be called inside an `OnMount`
|
|
89
105
|
* action: the consumer wraps the call in `Effect.sync` and stashes the
|
|
@@ -123,6 +139,19 @@ export const anchorSetup = (element, config) => {
|
|
|
123
139
|
if (inShadow) {
|
|
124
140
|
element.style.position = 'fixed';
|
|
125
141
|
}
|
|
142
|
+
// NOTE: an id lookup searches the whole root, so an unrelated element that
|
|
143
|
+
// happens to carry the arrow id would be positioned as the arrow. The
|
|
144
|
+
// containment check holds the lookup to what `arrowId` documents, an arrow
|
|
145
|
+
// inside the panel. The candidate is not narrowed to `HTMLElement`, since
|
|
146
|
+
// Floating UI's `arrow` takes any `Element` and a triangle arrow is usually
|
|
147
|
+
// an `<svg>`.
|
|
148
|
+
const maybeArrowElement = pipe(Option.fromNullishOr(config.arrowId), Option.flatMapNullishOr(arrowId => __foldkitBrandViewResult((owner.getElementById(arrowId)), "@foldkit/ui/anchor/anchor.js#anonymous~2")), Option.filter(candidate => __foldkitBrandViewResult((element.contains(candidate)), "@foldkit/ui/anchor/anchor.js#anonymous~3")));
|
|
149
|
+
const arrowMiddleware = Option.match(maybeArrowElement, {
|
|
150
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/anchor/anchor.js#onNone"),
|
|
151
|
+
onSome: arrowElement => __foldkitBrandViewResult(([
|
|
152
|
+
arrow({ element: arrowElement, padding: config.arrowPadding ?? 0 }),
|
|
153
|
+
]), "@foldkit/ui/anchor/anchor.js#onSome"),
|
|
154
|
+
});
|
|
126
155
|
const { placement, gap, offset: crossAxis, padding, isPlacementLocked, } = config.anchor;
|
|
127
156
|
const shouldInterceptTab = config.interceptTab ?? true;
|
|
128
157
|
const isPlacementLockEnabled = isPlacementLocked ?? false;
|
|
@@ -168,15 +197,30 @@ export const anchorSetup = (element, config) => {
|
|
|
168
197
|
}
|
|
169
198
|
element.style.setProperty('--button-width', `${rects.reference.width}px`);
|
|
170
199
|
element.style.maxHeight = `${Math.max(0, availableHeight)}px`;
|
|
171
|
-
|
|
172
|
-
|
|
200
|
+
// NOTE: `overflow-y: auto` makes `overflow-x` compute to `auto`
|
|
201
|
+
// too, so a scrolling panel clips on every side. An arrow sits
|
|
202
|
+
// half outside the panel's padding box, so it would be clipped
|
|
203
|
+
// away entirely. A panel with an arrow keeps its scroll container
|
|
204
|
+
// inside itself instead.
|
|
205
|
+
if (Option.isNone(maybeArrowElement)) {
|
|
206
|
+
element.style.overflowY = 'auto';
|
|
207
|
+
element.style.overscrollBehavior = 'none';
|
|
208
|
+
}
|
|
173
209
|
},
|
|
174
210
|
}),
|
|
211
|
+
// NOTE: `arrow` runs last. Sitting after `shift` is the constraint: an
|
|
212
|
+
// offset computed before `shift` would ignore the displacement `shift`
|
|
213
|
+
// applied, which is the case this hook exists to handle. Running after
|
|
214
|
+
// `size` is safe for a different reason: when `size.apply` changes the
|
|
215
|
+
// panel's dimensions, `size` returns `reset: { rects: true }` and
|
|
216
|
+
// Floating UI reruns the whole chain, so `arrow` always resolves
|
|
217
|
+
// against the final rects rather than the ones `size` invalidated.
|
|
218
|
+
...arrowMiddleware,
|
|
175
219
|
],
|
|
176
220
|
});
|
|
177
221
|
isPositioning = true;
|
|
178
222
|
tick
|
|
179
|
-
.then(({ x, y, placement: resolvedPlacement }) => {
|
|
223
|
+
.then(({ x, y, placement: resolvedPlacement, middlewareData }) => {
|
|
180
224
|
hasWarnedFailure = false;
|
|
181
225
|
if (!isActive) {
|
|
182
226
|
return;
|
|
@@ -187,6 +231,11 @@ export const anchorSetup = (element, config) => {
|
|
|
187
231
|
lockedPlacement = lockedPlacement ?? resolvedPlacement;
|
|
188
232
|
}
|
|
189
233
|
element.setAttribute('data-placement', toSide(lockedPlacement ?? resolvedPlacement));
|
|
234
|
+
if (Option.isSome(maybeArrowElement)) {
|
|
235
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow ?? {};
|
|
236
|
+
setOrResetLength(element, '--arrow-x', arrowX);
|
|
237
|
+
setOrResetLength(element, '--arrow-y', arrowY);
|
|
238
|
+
}
|
|
190
239
|
if (isFirstUpdate) {
|
|
191
240
|
isFirstUpdate = false;
|
|
192
241
|
element.style.visibility = '';
|
|
@@ -242,6 +291,10 @@ export const anchorSetup = (element, config) => {
|
|
|
242
291
|
element.removeEventListener('keydown', handleTabKey);
|
|
243
292
|
}
|
|
244
293
|
element.removeAttribute('data-placement');
|
|
294
|
+
element.style.removeProperty('overflow-y');
|
|
295
|
+
element.style.removeProperty('overscroll-behavior');
|
|
296
|
+
element.style.removeProperty('--arrow-x');
|
|
297
|
+
element.style.removeProperty('--arrow-y');
|
|
245
298
|
portalCleanup?.();
|
|
246
299
|
}), "@foldkit/ui/anchor/anchor.js#anchorSetup");
|
|
247
300
|
};
|
|
@@ -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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,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,KAAG,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAEvE,CAAA;AAKD,kGAAkG;AAClG,eAAO,MAAM,UAAU,GACrB,OAAO,KAAK,KACX,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcpC,CAAA;AAEH,kFAAkF;AAClF,eAAO,MAAM,UAAU,GAAI,yBAAyB,KAAK,KAAG,OACR,CAAA;AAEpD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,GAAI,OAAO,KAAK,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAMnE,CAAA;AAEH,oJAAoJ;AACpJ,eAAO,MAAM,eAAe,GAC1B,OAAO,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/popover/index.d.ts
CHANGED
|
@@ -78,6 +78,11 @@ export declare const init: (config: InitConfig) => Model;
|
|
|
78
78
|
* trigger via a native `<label for={Popover.buttonId(id)}>` or an
|
|
79
79
|
* `aria-labelledby` reference. */
|
|
80
80
|
export declare const buttonId: (id: string) => string;
|
|
81
|
+
/** Returns the bare DOM id of the popover arrow, derived from the popover's
|
|
82
|
+
* base id. The `arrow` bundle already carries this id, so reach for this when
|
|
83
|
+
* you need the id on its own, such as asserting the panel Mount's `arrowId`
|
|
84
|
+
* argument in a Scene test. */
|
|
85
|
+
export declare const arrowId: (id: string) => string;
|
|
81
86
|
type UpdateReturn = Update.ReturnWithOutMessage<Model, Message, OutMessage>;
|
|
82
87
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
83
88
|
export declare const LockScroll: Command.CommandDefinitionNoArgs<"LockScroll", Effect.Effect<{
|
|
@@ -209,6 +214,8 @@ export declare const AnchorPopover: Mount.MountDefinitionWithArgs<"AnchorPopover
|
|
|
209
214
|
readonly isPlacementLocked: S.optional<S.Boolean>;
|
|
210
215
|
}>;
|
|
211
216
|
focusSelector: S.optional<S.String>;
|
|
217
|
+
arrowId: S.optional<S.String>;
|
|
218
|
+
arrowPadding: S.optional<S.Number>;
|
|
212
219
|
}, {
|
|
213
220
|
readonly _tag: "CompletedAnchorPopover";
|
|
214
221
|
}>;
|
|
@@ -234,6 +241,11 @@ export declare const close: (model: Model) => UpdateReturn;
|
|
|
234
241
|
* - `backdrop`: attribute bundle for the modal backdrop. Includes the
|
|
235
242
|
* portal Mount that moves the backdrop to document.body. The
|
|
236
243
|
* backdrop's OnClick closes the popover.
|
|
244
|
+
* - `arrow`: attribute bundle for an arrow element inside the panel.
|
|
245
|
+
* Carries the id the anchor Mount resolves and hides the element from
|
|
246
|
+
* assistive technology. Spread it onto your own element and place it
|
|
247
|
+
* with the `--arrow-x` and `--arrow-y` custom properties Anchor
|
|
248
|
+
* publishes on the panel. Nothing renders until you do.
|
|
237
249
|
* - `isVisible`: derived from `isOpen` and the Animation
|
|
238
250
|
* `transitionState`. The consumer renders the panel + backdrop only
|
|
239
251
|
* while this is true. */
|
|
@@ -241,6 +253,7 @@ export type RenderInfo = Readonly<{
|
|
|
241
253
|
button: ReadonlyArray<ChildAttribute>;
|
|
242
254
|
panel: ReadonlyArray<ChildAttribute>;
|
|
243
255
|
backdrop: ReadonlyArray<ChildAttribute>;
|
|
256
|
+
arrow: ReadonlyArray<ChildAttribute>;
|
|
244
257
|
isVisible: boolean;
|
|
245
258
|
}>;
|
|
246
259
|
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */
|
|
@@ -249,6 +262,7 @@ export type ViewInputs = Readonly<{
|
|
|
249
262
|
toView: (render: RenderInfo) => Html;
|
|
250
263
|
isDisabled?: boolean;
|
|
251
264
|
focusSelector?: string;
|
|
265
|
+
arrowPadding?: number;
|
|
252
266
|
ariaLabel?: string;
|
|
253
267
|
ariaLabelledBy?: string;
|
|
254
268
|
}>;
|
|
@@ -311,6 +325,7 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
311
325
|
toView: (render: RenderInfo) => Html;
|
|
312
326
|
isDisabled?: boolean;
|
|
313
327
|
focusSelector?: string;
|
|
328
|
+
arrowPadding?: number;
|
|
314
329
|
ariaLabel?: string;
|
|
315
330
|
ariaLabelledBy?: string;
|
|
316
331
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,CAAC,EAEZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAE9E,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AAGtC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAExC,OAAO,EACL,YAAY,EAGb,MAAM,oBAAoB,CAAA;AAgB3B,qGAAqG;AACrG,eAAO,MAAM,KAAK;;;;;;;;;;;;EAQhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,+DAA+D;AAC/D,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBlB,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,OAAO,CAAC,aAA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;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,6EAA6E;AAC7E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAVP,YAAY;YACZ,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;iBACvB,OAAO;oBACJ,MAAM;mBACP,MAAM;gBACT,MAAM;qBACD,MAAM;GA0KxB,CAAA"}
|
package/dist/popover/index.js
CHANGED
|
@@ -81,6 +81,11 @@ const panelSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-panel`
|
|
|
81
81
|
* trigger via a native `<label for={Popover.buttonId(id)}>` or an
|
|
82
82
|
* `aria-labelledby` reference. */
|
|
83
83
|
export const buttonId = (id) => __foldkitBrandViewResult((`${id}-button`), "@foldkit/ui/popover/index.js#buttonId");
|
|
84
|
+
/** Returns the bare DOM id of the popover arrow, derived from the popover's
|
|
85
|
+
* base id. The `arrow` bundle already carries this id, so reach for this when
|
|
86
|
+
* you need the id on its own, such as asserting the panel Mount's `arrowId`
|
|
87
|
+
* argument in a Scene test. */
|
|
88
|
+
export const arrowId = (id) => __foldkitBrandViewResult((`${id}-arrow`), "@foldkit/ui/popover/index.js#arrowId");
|
|
84
89
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
85
90
|
export const LockScroll = Command.define('LockScroll', {
|
|
86
91
|
messages: [Message.CompletedLockScroll],
|
|
@@ -243,13 +248,17 @@ export const AnchorPopover = Mount.define('AnchorPopover', {
|
|
|
243
248
|
buttonId: S.String,
|
|
244
249
|
anchor: AnchorConfig,
|
|
245
250
|
focusSelector: S.optional(S.String),
|
|
246
|
-
|
|
251
|
+
arrowId: S.optional(S.String),
|
|
252
|
+
arrowPadding: S.optional(S.Number),
|
|
253
|
+
}, Message.CompletedAnchorPopover)(({ buttonId, anchor, focusSelector, arrowId, arrowPadding }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
247
254
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
248
255
|
buttonId,
|
|
249
256
|
anchor,
|
|
250
257
|
interceptTab: false,
|
|
251
258
|
focusAfterPosition: true,
|
|
252
259
|
...(focusSelector !== undefined && { focusSelector }),
|
|
260
|
+
...(arrowId !== undefined && { arrowId }),
|
|
261
|
+
...(arrowPadding !== undefined && { arrowPadding }),
|
|
253
262
|
})), "@foldkit/ui/popover/index.js#anonymous~11")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~12"));
|
|
254
263
|
return __foldkitBrandViewResult((Message.CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~10");
|
|
255
264
|
})), "@foldkit/ui/popover/index.js#anonymous~9")), "@foldkit/ui/popover/index.js#anonymous~8"));
|
|
@@ -270,7 +279,7 @@ export const close = (model) => __foldkitBrandViewResult((update(model, Message.
|
|
|
270
279
|
/** Renders a headless popover with a trigger button and a floating panel. */
|
|
271
280
|
export const view = defineView((model, viewInputs, h) => {
|
|
272
281
|
const { id, isOpen, contentFocus, animation: { transitionState }, maybeLastButtonPointerType, } = model;
|
|
273
|
-
const { anchor, toView, isDisabled, focusSelector, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
282
|
+
const { anchor, toView, isDisabled, focusSelector, arrowPadding, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
274
283
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
275
284
|
const isVisible = isOpen || isLeaving;
|
|
276
285
|
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
@@ -345,6 +354,8 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
345
354
|
buttonId: `${id}-button`,
|
|
346
355
|
anchor,
|
|
347
356
|
...(focusSelector !== undefined && { focusSelector }),
|
|
357
|
+
arrowId: arrowId(id),
|
|
358
|
+
...(arrowPadding !== undefined && { arrowPadding }),
|
|
348
359
|
})),
|
|
349
360
|
...animationAttributes,
|
|
350
361
|
...(isLeaving
|
|
@@ -358,10 +369,12 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
358
369
|
h.OnMount(PortalPopoverBackdrop()),
|
|
359
370
|
...(isLeaving ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
360
371
|
];
|
|
372
|
+
const arrowAttributes = [h.Id(arrowId(id)), h.AriaHidden(true)];
|
|
361
373
|
return __foldkitBrandViewResult((toView({
|
|
362
374
|
button: childAttributes(buttonAttributes),
|
|
363
375
|
panel: childAttributes(panelAttributes),
|
|
364
376
|
backdrop: childAttributes(backdropAttributes),
|
|
377
|
+
arrow: childAttributes(arrowAttributes),
|
|
365
378
|
isVisible,
|
|
366
379
|
})), "@foldkit/ui/popover/index.js#anonymous~17");
|
|
367
380
|
});
|
package/dist/popover/public.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { init, update, open, close, view, buttonId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, type BlurredPanel, type PressedPointerOnButton, type IgnoredMouseClick, type SuppressedSpaceScroll, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, buttonId, arrowId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, type BlurredPanel, type PressedPointerOnButton, type IgnoredMouseClick, type SuppressedSpaceScroll, } 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/popover/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/popover/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,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/popover/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, open, close, view, buttonId, Model, Message, OutMessage, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, buttonId, arrowId, Model, Message, OutMessage, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, } from './index.js';
|
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,CA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G4B;iBACf,OAAO;IACpB;;;;;;;;eAQW;iBACE,OAAO;WACb,MAAM;IACb;;;4DAGwD;mBACzC,MAAM,QAAQ,GAAG,UAAU;GA2J3C,CAAA"}
|
package/dist/slider/index.js
CHANGED
|
@@ -2,15 +2,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,E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EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAChD,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/C,iBAAiB,CAAC,EAAE,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.35bd4564b299",
|
|
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.35bd4564b299"
|
|
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.35bd4564b299",
|
|
135
|
+
"foldkit": "0.153.0-canary.35bd4564b299"
|
|
136
136
|
},
|
|
137
137
|
"keywords": [
|
|
138
138
|
"foldkit",
|