@foldkit/ui 0.156.0 → 0.157.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anchor/anchor.d.ts +18 -18
- package/dist/anchor/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +16 -16
- package/dist/animation/index.d.ts +4 -4
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/animation/index.js +8 -8
- 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 +6 -6
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/schema.js +5 -5
- package/dist/animation/update.d.ts +8 -2
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +22 -9
- package/dist/calendar/index.d.ts +56 -56
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +49 -37
- package/dist/checkbox/index.js +2 -2
- package/dist/combobox/multi.d.ts +19 -19
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +2 -2
- package/dist/combobox/shared.d.ts +61 -61
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +74 -62
- package/dist/combobox/single.d.ts +19 -19
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +2 -2
- package/dist/datePicker/index.d.ts +72 -72
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +12 -12
- package/dist/dialog/index.d.ts +14 -14
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +35 -23
- package/dist/disclosure/index.js +2 -2
- package/dist/dragAndDrop/index.d.ts +61 -61
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +85 -85
- package/dist/fileDrop/index.d.ts +6 -6
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +6 -6
- package/dist/hoverIntent/hoverIntent.d.ts +15 -15
- package/dist/hoverIntent/hoverIntent.d.ts.map +1 -1
- package/dist/hoverIntent/hoverIntent.js +17 -17
- package/dist/hoverIntent/message.d.ts +4 -4
- package/dist/hoverIntent/message.d.ts.map +1 -1
- package/dist/hoverIntent/message.js +4 -4
- package/dist/keyboard.js +2 -2
- package/dist/listbox/multi.d.ts +19 -19
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +2 -2
- package/dist/listbox/shared.d.ts +58 -58
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +74 -62
- package/dist/listbox/single.d.ts +19 -19
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +2 -2
- package/dist/menu/index.d.ts +67 -67
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +82 -67
- package/dist/popover/index.d.ts +34 -34
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +49 -37
- package/dist/radioGroup/index.d.ts +12 -12
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +16 -16
- package/dist/slider/index.d.ts +14 -14
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +31 -31
- package/dist/switch/index.js +2 -2
- package/dist/tabs/index.d.ts +14 -14
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +18 -18
- package/dist/test/apps/disabledButton.d.ts +12 -12
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +5 -5
- package/dist/textarea/index.d.ts +2 -2
- package/dist/textarea/index.d.ts.map +1 -1
- package/dist/toast/index.d.ts +63 -63
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +19 -19
- package/dist/toast/schema.d.ts +55 -55
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +29 -29
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/test.js +3 -3
- package/dist/toast/update.d.ts +61 -61
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +13 -13
- package/dist/tooltip/message.d.ts +3 -3
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/message.js +3 -3
- package/dist/tooltip/tooltip.d.ts +24 -24
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +13 -13
- package/dist/typeahead.d.ts.map +1 -1
- package/dist/typeahead.js +3 -3
- package/dist/virtualList/index.d.ts +16 -16
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +13 -13
- package/package.json +3 -3
package/dist/menu/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Option, Schema
|
|
1
|
+
import { Effect, Option, Schema } from 'effect';
|
|
2
2
|
import * as Command from 'foldkit/command';
|
|
3
3
|
import type { ChildAttribute, Html } from 'foldkit/html';
|
|
4
4
|
import * as Mount from 'foldkit/mount';
|
|
@@ -8,65 +8,65 @@ import { AnchorConfig } from '../anchor/index.js';
|
|
|
8
8
|
import { groupContiguous } from '../group.js';
|
|
9
9
|
import { resolveTypeaheadMatch } from '../typeahead.js';
|
|
10
10
|
/** Schema for the activation trigger: whether the user interacted via mouse or keyboard. */
|
|
11
|
-
export declare const ActivationTrigger:
|
|
11
|
+
export declare const ActivationTrigger: Schema.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
12
12
|
export type ActivationTrigger = typeof ActivationTrigger.Type;
|
|
13
13
|
/** Schema for the menu component's state, tracking open/closed status, active item, activation trigger, and typeahead search. */
|
|
14
|
-
export declare const Model:
|
|
15
|
-
readonly id:
|
|
16
|
-
readonly isOpen:
|
|
17
|
-
readonly isAnimated:
|
|
18
|
-
readonly isModal:
|
|
19
|
-
readonly animation:
|
|
20
|
-
readonly id:
|
|
21
|
-
readonly isShowing:
|
|
22
|
-
readonly transitionState:
|
|
14
|
+
export declare const Model: Schema.Struct<{
|
|
15
|
+
readonly id: Schema.String;
|
|
16
|
+
readonly isOpen: Schema.Boolean;
|
|
17
|
+
readonly isAnimated: Schema.Boolean;
|
|
18
|
+
readonly isModal: Schema.Boolean;
|
|
19
|
+
readonly animation: Schema.Struct<{
|
|
20
|
+
readonly id: Schema.String;
|
|
21
|
+
readonly isShowing: Schema.Boolean;
|
|
22
|
+
readonly transitionState: Schema.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
|
|
23
23
|
}>;
|
|
24
|
-
readonly maybeActiveItemIndex:
|
|
25
|
-
readonly activationTrigger:
|
|
26
|
-
readonly searchQuery:
|
|
27
|
-
readonly searchVersion:
|
|
28
|
-
readonly maybeLastPointerPosition:
|
|
29
|
-
readonly screenX:
|
|
30
|
-
readonly screenY:
|
|
24
|
+
readonly maybeActiveItemIndex: Schema.Option<Schema.Number>;
|
|
25
|
+
readonly activationTrigger: Schema.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
26
|
+
readonly searchQuery: Schema.String;
|
|
27
|
+
readonly searchVersion: Schema.Number;
|
|
28
|
+
readonly maybeLastPointerPosition: Schema.Option<Schema.Struct<{
|
|
29
|
+
readonly screenX: Schema.Number;
|
|
30
|
+
readonly screenY: Schema.Number;
|
|
31
31
|
}>>;
|
|
32
|
-
readonly maybeLastButtonPointerType:
|
|
33
|
-
readonly maybePointerOrigin:
|
|
34
|
-
readonly screenX:
|
|
35
|
-
readonly screenY:
|
|
36
|
-
readonly timeStamp:
|
|
32
|
+
readonly maybeLastButtonPointerType: Schema.Option<Schema.String>;
|
|
33
|
+
readonly maybePointerOrigin: Schema.Option<Schema.Struct<{
|
|
34
|
+
readonly screenX: Schema.Number;
|
|
35
|
+
readonly screenY: Schema.Number;
|
|
36
|
+
readonly timeStamp: Schema.Number;
|
|
37
37
|
}>>;
|
|
38
38
|
}>;
|
|
39
39
|
export type Model = typeof Model.Type;
|
|
40
40
|
/** Union of all messages the menu component can produce. */
|
|
41
41
|
export declare const Message: import("foldkit/message").MessageUnion<{
|
|
42
42
|
readonly Opened: {
|
|
43
|
-
maybeActiveItemIndex:
|
|
43
|
+
maybeActiveItemIndex: Schema.Option<Schema.Number>;
|
|
44
44
|
};
|
|
45
45
|
readonly Closed: {};
|
|
46
46
|
readonly BlurredItems: {};
|
|
47
47
|
readonly ActivatedItem: {
|
|
48
|
-
index:
|
|
49
|
-
activationTrigger:
|
|
48
|
+
index: Schema.Number;
|
|
49
|
+
activationTrigger: Schema.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
50
50
|
};
|
|
51
51
|
readonly DeactivatedItem: {};
|
|
52
52
|
readonly SelectedItem: {
|
|
53
|
-
index:
|
|
54
|
-
item:
|
|
53
|
+
index: Schema.Number;
|
|
54
|
+
item: Schema.String;
|
|
55
55
|
};
|
|
56
56
|
readonly RequestedItemClick: {
|
|
57
|
-
index:
|
|
57
|
+
index: Schema.Number;
|
|
58
58
|
};
|
|
59
59
|
readonly Searched: {
|
|
60
|
-
key:
|
|
61
|
-
maybeTargetIndex:
|
|
60
|
+
key: Schema.String;
|
|
61
|
+
maybeTargetIndex: Schema.Option<Schema.Number>;
|
|
62
62
|
};
|
|
63
63
|
readonly CompletedDelayClearSearch: {
|
|
64
|
-
version:
|
|
64
|
+
version: Schema.Number;
|
|
65
65
|
};
|
|
66
66
|
readonly MovedPointerOverItem: {
|
|
67
|
-
index:
|
|
68
|
-
screenX:
|
|
69
|
-
screenY:
|
|
67
|
+
index: Schema.Number;
|
|
68
|
+
screenX: Schema.Number;
|
|
69
|
+
screenY: Schema.Number;
|
|
70
70
|
};
|
|
71
71
|
readonly CompletedFocusItems: {};
|
|
72
72
|
readonly CompletedFocusButton: {};
|
|
@@ -89,16 +89,16 @@ export declare const Message: import("foldkit/message").MessageUnion<{
|
|
|
89
89
|
}>;
|
|
90
90
|
};
|
|
91
91
|
readonly PressedPointerOnButton: {
|
|
92
|
-
pointerType:
|
|
93
|
-
button:
|
|
94
|
-
screenX:
|
|
95
|
-
screenY:
|
|
96
|
-
timeStamp:
|
|
92
|
+
pointerType: Schema.String;
|
|
93
|
+
button: Schema.Number;
|
|
94
|
+
screenX: Schema.Number;
|
|
95
|
+
screenY: Schema.Number;
|
|
96
|
+
timeStamp: Schema.Number;
|
|
97
97
|
};
|
|
98
98
|
readonly ReleasedPointerOnItems: {
|
|
99
|
-
screenX:
|
|
100
|
-
screenY:
|
|
101
|
-
timeStamp:
|
|
99
|
+
screenX: Schema.Number;
|
|
100
|
+
screenY: Schema.Number;
|
|
101
|
+
timeStamp: Schema.Number;
|
|
102
102
|
};
|
|
103
103
|
}>;
|
|
104
104
|
export type Message = typeof Message.Type;
|
|
@@ -106,8 +106,8 @@ export type Message = typeof Message.Type;
|
|
|
106
106
|
* `Update.foldChild` config handles them through `foldOutMessage`. */
|
|
107
107
|
export declare const OutMessage: import("foldkit/message").MessageUnion<{
|
|
108
108
|
readonly Selected: {
|
|
109
|
-
value:
|
|
110
|
-
index:
|
|
109
|
+
value: Schema.String;
|
|
110
|
+
index: Schema.Number;
|
|
111
111
|
};
|
|
112
112
|
}>;
|
|
113
113
|
export type Selected<Value extends string = string> = Readonly<{
|
|
@@ -157,52 +157,52 @@ export declare const UnlockScroll: Command.CommandDefinitionNoArgs<"UnlockScroll
|
|
|
157
157
|
}, never, never>>;
|
|
158
158
|
/** Marks all elements outside the menu as inert for modal behavior. */
|
|
159
159
|
export declare const InertOthers: Command.CommandDefinitionWithArgs<"InertOthers", {
|
|
160
|
-
id:
|
|
160
|
+
id: Schema.String;
|
|
161
161
|
}, Effect.Effect<{
|
|
162
162
|
readonly _tag: "CompletedInertOthers";
|
|
163
163
|
}, never, never>>;
|
|
164
164
|
/** Removes the inert attribute from elements outside the menu. */
|
|
165
165
|
export declare const RestoreInert: Command.CommandDefinitionWithArgs<"RestoreInert", {
|
|
166
|
-
id:
|
|
166
|
+
id: Schema.String;
|
|
167
167
|
}, Effect.Effect<{
|
|
168
168
|
readonly _tag: "CompletedRestoreInert";
|
|
169
169
|
}, never, never>>;
|
|
170
170
|
/** Moves focus to the menu items container after opening. */
|
|
171
171
|
export declare const FocusItems: Command.CommandDefinitionWithArgs<"FocusItems", {
|
|
172
|
-
id:
|
|
172
|
+
id: Schema.String;
|
|
173
173
|
}, Effect.Effect<{
|
|
174
174
|
readonly _tag: "CompletedFocusItems";
|
|
175
175
|
}, never, never>>;
|
|
176
176
|
/** Moves focus back to the menu button after closing. */
|
|
177
177
|
export declare const FocusButton: Command.CommandDefinitionWithArgs<"FocusButton", {
|
|
178
|
-
id:
|
|
178
|
+
id: Schema.String;
|
|
179
179
|
}, Effect.Effect<{
|
|
180
180
|
readonly _tag: "CompletedFocusButton";
|
|
181
181
|
}, never, never>>;
|
|
182
182
|
/** Scrolls the active menu item into view after keyboard navigation. */
|
|
183
183
|
export declare const ScrollIntoView: Command.CommandDefinitionWithArgs<"ScrollIntoView", {
|
|
184
|
-
id:
|
|
185
|
-
index:
|
|
184
|
+
id: Schema.String;
|
|
185
|
+
index: Schema.Number;
|
|
186
186
|
}, Effect.Effect<{
|
|
187
187
|
readonly _tag: "CompletedScrollIntoView";
|
|
188
188
|
}, never, never>>;
|
|
189
189
|
/** Programmatically clicks the active menu item's DOM element. */
|
|
190
190
|
export declare const ClickItem: Command.CommandDefinitionWithArgs<"ClickItem", {
|
|
191
|
-
id:
|
|
192
|
-
index:
|
|
191
|
+
id: Schema.String;
|
|
192
|
+
index: Schema.Number;
|
|
193
193
|
}, Effect.Effect<{
|
|
194
194
|
readonly _tag: "CompletedClickItem";
|
|
195
195
|
}, never, never>>;
|
|
196
196
|
/** Waits for the typeahead search debounce period before clearing the query. */
|
|
197
197
|
export declare const DelayClearSearch: Command.CommandDefinitionWithArgs<"DelayClearSearch", {
|
|
198
|
-
version:
|
|
198
|
+
version: Schema.Number;
|
|
199
199
|
}, Effect.Effect<{
|
|
200
200
|
readonly _tag: "CompletedDelayClearSearch";
|
|
201
201
|
readonly version: number;
|
|
202
202
|
}, never, never>>;
|
|
203
203
|
/** Detects whether the menu button moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
204
204
|
export declare const DetectMovementOrAnimationEnd: Command.CommandDefinitionWithArgs<"DetectMovementOrAnimationEnd", {
|
|
205
|
-
id:
|
|
205
|
+
id: Schema.String;
|
|
206
206
|
}, Effect.Effect<{
|
|
207
207
|
readonly _tag: "GotAnimationMessage";
|
|
208
208
|
readonly message: {
|
|
@@ -344,19 +344,19 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
344
344
|
* Exposed so Scene tests can call
|
|
345
345
|
* `Scene.Mount.resolve(AnchorMenu, Message.CompletedAnchorMenu())`. */
|
|
346
346
|
export declare const AnchorMenu: Mount.MountDefinitionWithArgs<"AnchorMenu", {
|
|
347
|
-
buttonId:
|
|
348
|
-
anchor:
|
|
349
|
-
readonly placement:
|
|
350
|
-
readonly gap:
|
|
351
|
-
readonly offset:
|
|
352
|
-
readonly padding:
|
|
353
|
-
readonly top:
|
|
354
|
-
readonly right:
|
|
355
|
-
readonly bottom:
|
|
356
|
-
readonly left:
|
|
347
|
+
buttonId: Schema.String;
|
|
348
|
+
anchor: Schema.Struct<{
|
|
349
|
+
readonly placement: Schema.optional<Schema.Literals<readonly ["top", "right", "bottom", "left", "top-start", "top-end", "right-start", "right-end", "bottom-start", "bottom-end", "left-start", "left-end"]>>;
|
|
350
|
+
readonly gap: Schema.optional<Schema.Number>;
|
|
351
|
+
readonly offset: Schema.optional<Schema.Number>;
|
|
352
|
+
readonly padding: Schema.optional<Schema.Union<readonly [Schema.Number, Schema.Struct<{
|
|
353
|
+
readonly top: Schema.optionalKey<Schema.Number>;
|
|
354
|
+
readonly right: Schema.optionalKey<Schema.Number>;
|
|
355
|
+
readonly bottom: Schema.optionalKey<Schema.Number>;
|
|
356
|
+
readonly left: Schema.optionalKey<Schema.Number>;
|
|
357
357
|
}>]>>;
|
|
358
|
-
readonly portal:
|
|
359
|
-
readonly isPlacementLocked:
|
|
358
|
+
readonly portal: Schema.optional<Schema.Boolean>;
|
|
359
|
+
readonly isPlacementLocked: Schema.optional<Schema.Boolean>;
|
|
360
360
|
}>;
|
|
361
361
|
}, {
|
|
362
362
|
readonly _tag: "CompletedAnchorMenu";
|
package/dist/menu/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,EAGP,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AAEtC,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAExC,OAAO,EACL,YAAY,EAGb,MAAM,oBAAoB,CAAA;AAU3B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAQ7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAIvD,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,mDAA2C,CAAA;AACzE,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAA;AAQ7D,iIAAiI;AACjI,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;EAehB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,4DAA4D;AAC5D,eAAO,MAAM,OAAO;;QACR,oBAAoB;;;;;QAGb,KAAK;QAAiB,iBAAiB;;;;QAExC,KAAK;QAAiB,IAAI;;;QACp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brand'
|
|
2
|
-
import { Array, Effect, Equal, Match
|
|
2
|
+
import { Array, Effect, Equal, Match, Option, Predicate, Schema, String, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
5
|
import { defineMessageUnion } from 'foldkit/message';
|
|
@@ -11,8 +11,8 @@ import { AnchorConfig, anchorSetup, portalToContainingRoot, } from '../anchor/in
|
|
|
11
11
|
// NOTE: Animation imports are split across schema + update to avoid a circular
|
|
12
12
|
// dependency: animation → html → runtime → devtools → menu → animation.
|
|
13
13
|
// The barrel (../animation) imports from html, which starts the cycle.
|
|
14
|
-
import
|
|
15
|
-
import { update as animationUpdate } from '../animation/update.js';
|
|
14
|
+
import * as Animation from '../animation/schema.js';
|
|
15
|
+
import { hide as animationHide, show as animationShow, update as animationUpdate, } from '../animation/update.js';
|
|
16
16
|
import { groupContiguous } from '../group.js';
|
|
17
17
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
18
18
|
import { idSelector } from '../internal/selectors.js';
|
|
@@ -20,43 +20,46 @@ import { findFirstEnabledIndex, isPrintableKey, keyToIndex, } from '../keyboard.
|
|
|
20
20
|
import { resolveTypeaheadMatch } from '../typeahead.js';
|
|
21
21
|
// MODEL
|
|
22
22
|
/** Schema for the activation trigger: whether the user interacted via mouse or keyboard. */
|
|
23
|
-
export const ActivationTrigger =
|
|
24
|
-
const PointerOrigin =
|
|
25
|
-
screenX:
|
|
26
|
-
screenY:
|
|
27
|
-
timeStamp:
|
|
23
|
+
export const ActivationTrigger = Schema.Literals(['Pointer', 'Keyboard']);
|
|
24
|
+
const PointerOrigin = Schema.Struct({
|
|
25
|
+
screenX: Schema.Number,
|
|
26
|
+
screenY: Schema.Number,
|
|
27
|
+
timeStamp: Schema.Number,
|
|
28
28
|
});
|
|
29
29
|
/** Schema for the menu component's state, tracking open/closed status, active item, activation trigger, and typeahead search. */
|
|
30
|
-
export const Model =
|
|
31
|
-
id:
|
|
32
|
-
isOpen:
|
|
33
|
-
isAnimated:
|
|
34
|
-
isModal:
|
|
35
|
-
animation:
|
|
36
|
-
maybeActiveItemIndex:
|
|
30
|
+
export const Model = Schema.Struct({
|
|
31
|
+
id: Schema.String,
|
|
32
|
+
isOpen: Schema.Boolean,
|
|
33
|
+
isAnimated: Schema.Boolean,
|
|
34
|
+
isModal: Schema.Boolean,
|
|
35
|
+
animation: Animation.Model,
|
|
36
|
+
maybeActiveItemIndex: Schema.Option(Schema.Number),
|
|
37
37
|
activationTrigger: ActivationTrigger,
|
|
38
|
-
searchQuery:
|
|
39
|
-
searchVersion:
|
|
40
|
-
maybeLastPointerPosition:
|
|
41
|
-
maybeLastButtonPointerType:
|
|
42
|
-
maybePointerOrigin:
|
|
38
|
+
searchQuery: Schema.String,
|
|
39
|
+
searchVersion: Schema.Number,
|
|
40
|
+
maybeLastPointerPosition: Schema.Option(Schema.Struct({ screenX: Schema.Number, screenY: Schema.Number })),
|
|
41
|
+
maybeLastButtonPointerType: Schema.Option(Schema.String),
|
|
42
|
+
maybePointerOrigin: Schema.Option(PointerOrigin),
|
|
43
43
|
});
|
|
44
44
|
// MESSAGE
|
|
45
45
|
/** Union of all messages the menu component can produce. */
|
|
46
46
|
export const Message = defineMessageUnion({
|
|
47
|
-
Opened: { maybeActiveItemIndex:
|
|
47
|
+
Opened: { maybeActiveItemIndex: Schema.Option(Schema.Number) },
|
|
48
48
|
Closed: {},
|
|
49
49
|
BlurredItems: {},
|
|
50
|
-
ActivatedItem: { index:
|
|
50
|
+
ActivatedItem: { index: Schema.Number, activationTrigger: ActivationTrigger },
|
|
51
51
|
DeactivatedItem: {},
|
|
52
|
-
SelectedItem: { index:
|
|
53
|
-
RequestedItemClick: { index:
|
|
54
|
-
Searched: {
|
|
55
|
-
|
|
52
|
+
SelectedItem: { index: Schema.Number, item: Schema.String },
|
|
53
|
+
RequestedItemClick: { index: Schema.Number },
|
|
54
|
+
Searched: {
|
|
55
|
+
key: Schema.String,
|
|
56
|
+
maybeTargetIndex: Schema.Option(Schema.Number),
|
|
57
|
+
},
|
|
58
|
+
CompletedDelayClearSearch: { version: Schema.Number },
|
|
56
59
|
MovedPointerOverItem: {
|
|
57
|
-
index:
|
|
58
|
-
screenX:
|
|
59
|
-
screenY:
|
|
60
|
+
index: Schema.Number,
|
|
61
|
+
screenX: Schema.Number,
|
|
62
|
+
screenY: Schema.Number,
|
|
60
63
|
},
|
|
61
64
|
CompletedFocusItems: {},
|
|
62
65
|
CompletedFocusButton: {},
|
|
@@ -70,25 +73,25 @@ export const Message = defineMessageUnion({
|
|
|
70
73
|
SuppressedSpaceScroll: {},
|
|
71
74
|
CompletedAnchorMenu: {},
|
|
72
75
|
CompletedPortalMenuBackdrop: {},
|
|
73
|
-
GotAnimationMessage: { message:
|
|
76
|
+
GotAnimationMessage: { message: Animation.Message },
|
|
74
77
|
PressedPointerOnButton: {
|
|
75
|
-
pointerType:
|
|
76
|
-
button:
|
|
77
|
-
screenX:
|
|
78
|
-
screenY:
|
|
79
|
-
timeStamp:
|
|
78
|
+
pointerType: Schema.String,
|
|
79
|
+
button: Schema.Number,
|
|
80
|
+
screenX: Schema.Number,
|
|
81
|
+
screenY: Schema.Number,
|
|
82
|
+
timeStamp: Schema.Number,
|
|
80
83
|
},
|
|
81
84
|
ReleasedPointerOnItems: {
|
|
82
|
-
screenX:
|
|
83
|
-
screenY:
|
|
84
|
-
timeStamp:
|
|
85
|
+
screenX: Schema.Number,
|
|
86
|
+
screenY: Schema.Number,
|
|
87
|
+
timeStamp: Schema.Number,
|
|
85
88
|
},
|
|
86
89
|
});
|
|
87
90
|
// OUT MESSAGE
|
|
88
91
|
/** Union of OutMessages the menu component can produce. The parent's
|
|
89
92
|
* `Update.foldChild` config handles them through `foldOutMessage`. */
|
|
90
93
|
export const OutMessage = defineMessageUnion({
|
|
91
|
-
Selected: { value:
|
|
94
|
+
Selected: { value: Schema.String, index: Schema.Number },
|
|
92
95
|
});
|
|
93
96
|
// INIT
|
|
94
97
|
const SEARCH_DEBOUNCE_MILLISECONDS = 350;
|
|
@@ -101,7 +104,7 @@ export const init = (config) => (__foldkitBrandViewResult(({
|
|
|
101
104
|
isOpen: false,
|
|
102
105
|
isAnimated: config.isAnimated ?? false,
|
|
103
106
|
isModal: config.isModal ?? false,
|
|
104
|
-
animation:
|
|
107
|
+
animation: Animation.init({ id: `${config.id}-items` }),
|
|
105
108
|
maybeActiveItemIndex: Option.none(),
|
|
106
109
|
activationTrigger: 'Keyboard',
|
|
107
110
|
searchQuery: '',
|
|
@@ -140,63 +143,63 @@ export const UnlockScroll = Command.define('UnlockScroll', {
|
|
|
140
143
|
});
|
|
141
144
|
/** Marks all elements outside the menu as inert for modal behavior. */
|
|
142
145
|
export const InertOthers = Command.define('InertOthers', {
|
|
143
|
-
args: { id:
|
|
146
|
+
args: { id: Schema.String },
|
|
144
147
|
messages: [Message.CompletedInertOthers],
|
|
145
148
|
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), itemsSelector(id)]).pipe(Effect.as(Message.CompletedInertOthers()))), "@foldkit/ui/menu/index.js#execute"),
|
|
146
149
|
});
|
|
147
150
|
/** Removes the inert attribute from elements outside the menu. */
|
|
148
151
|
export const RestoreInert = Command.define('RestoreInert', {
|
|
149
|
-
args: { id:
|
|
152
|
+
args: { id: Schema.String },
|
|
150
153
|
messages: [Message.CompletedRestoreInert],
|
|
151
154
|
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(Message.CompletedRestoreInert()))), "@foldkit/ui/menu/index.js#execute~2"),
|
|
152
155
|
});
|
|
153
156
|
/** Moves focus to the menu items container after opening. */
|
|
154
157
|
export const FocusItems = Command.define('FocusItems', {
|
|
155
|
-
args: { id:
|
|
158
|
+
args: { id: Schema.String },
|
|
156
159
|
messages: [Message.CompletedFocusItems],
|
|
157
160
|
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(itemsSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusItems()))), "@foldkit/ui/menu/index.js#execute~3"),
|
|
158
161
|
});
|
|
159
162
|
/** Moves focus back to the menu button after closing. */
|
|
160
163
|
export const FocusButton = Command.define('FocusButton', {
|
|
161
|
-
args: { id:
|
|
164
|
+
args: { id: Schema.String },
|
|
162
165
|
messages: [Message.CompletedFocusButton],
|
|
163
166
|
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusButton()))), "@foldkit/ui/menu/index.js#execute~4"),
|
|
164
167
|
});
|
|
165
168
|
/** Scrolls the active menu item into view after keyboard navigation. */
|
|
166
169
|
export const ScrollIntoView = Command.define('ScrollIntoView', {
|
|
167
|
-
args: { id:
|
|
170
|
+
args: { id: Schema.String, index: Schema.Number },
|
|
168
171
|
messages: [Message.CompletedScrollIntoView],
|
|
169
172
|
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedScrollIntoView()))), "@foldkit/ui/menu/index.js#execute~5"),
|
|
170
173
|
});
|
|
171
174
|
/** Programmatically clicks the active menu item's DOM element. */
|
|
172
175
|
export const ClickItem = Command.define('ClickItem', {
|
|
173
|
-
args: { id:
|
|
176
|
+
args: { id: Schema.String, index: Schema.Number },
|
|
174
177
|
messages: [Message.CompletedClickItem],
|
|
175
178
|
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedClickItem()))), "@foldkit/ui/menu/index.js#execute~6"),
|
|
176
179
|
});
|
|
177
180
|
/** Waits for the typeahead search debounce period before clearing the query. */
|
|
178
181
|
export const DelayClearSearch = Command.define('DelayClearSearch', {
|
|
179
|
-
args: { version:
|
|
182
|
+
args: { version: Schema.Number },
|
|
180
183
|
messages: [Message.CompletedDelayClearSearch],
|
|
181
184
|
execute: ({ version }) => __foldkitBrandViewResult((Effect.sleep(SEARCH_DEBOUNCE_MILLISECONDS).pipe(Effect.as(Message.CompletedDelayClearSearch({ version })))), "@foldkit/ui/menu/index.js#execute~7"),
|
|
182
185
|
});
|
|
183
186
|
/** Detects whether the menu button moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
184
187
|
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', {
|
|
185
|
-
args: { id:
|
|
188
|
+
args: { id: Schema.String },
|
|
186
189
|
messages: [Message.GotAnimationMessage],
|
|
187
190
|
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
188
|
-
message:
|
|
191
|
+
message: Animation.Message.EndedAnimation(),
|
|
189
192
|
}))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
190
|
-
message:
|
|
193
|
+
message: Animation.Message.EndedAnimation(),
|
|
191
194
|
}))))), "@foldkit/ui/menu/index.js#execute~8"),
|
|
192
195
|
});
|
|
193
|
-
const foldAnimationOutMessage =
|
|
196
|
+
const foldAnimationOutMessage = Animation.OutMessage.match({
|
|
194
197
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
195
198
|
model,
|
|
196
199
|
commands: [DetectMovementOrAnimationEnd({ id: model.id })],
|
|
197
200
|
}), "@foldkit/ui/menu/index.js#anonymous"))), "@foldkit/ui/menu/index.js#StartedLeaveAnimating"),
|
|
198
201
|
TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/menu/index.js#anonymous~2"))), "@foldkit/ui/menu/index.js#TransitionedOut"),
|
|
199
|
-
})
|
|
202
|
+
});
|
|
200
203
|
const foldAnimation = Update.foldChild({
|
|
201
204
|
update: animationUpdate,
|
|
202
205
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/menu/index.js#read"),
|
|
@@ -204,6 +207,18 @@ const foldAnimation = Update.foldChild({
|
|
|
204
207
|
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/menu/index.js#toParentMessage"),
|
|
205
208
|
foldOutMessage: foldAnimationOutMessage,
|
|
206
209
|
});
|
|
210
|
+
const foldAnimationShow = Update.foldChildStep({
|
|
211
|
+
update: animationShow,
|
|
212
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/menu/index.js#read~2"),
|
|
213
|
+
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/menu/index.js#animation~2") })), "@foldkit/ui/menu/index.js#write~2"),
|
|
214
|
+
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/menu/index.js#toParentMessage~2"),
|
|
215
|
+
});
|
|
216
|
+
const foldAnimationHide = Update.foldChildStep({
|
|
217
|
+
update: animationHide,
|
|
218
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/menu/index.js#read~3"),
|
|
219
|
+
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/menu/index.js#animation~3") })), "@foldkit/ui/menu/index.js#write~3"),
|
|
220
|
+
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/menu/index.js#toParentMessage~3"),
|
|
221
|
+
});
|
|
207
222
|
/** Processes a Menu Message and returns the next Model, optional Commands, and
|
|
208
223
|
* an optional OutMessage. */
|
|
209
224
|
export const update = (model, message) => {
|
|
@@ -224,7 +239,7 @@ export const update = (model, message) => {
|
|
|
224
239
|
if (model.isAnimated) {
|
|
225
240
|
return __foldkitBrandViewResult((Update.combine(baseModel, [
|
|
226
241
|
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands: openCommands }), "@foldkit/ui/menu/index.js#anonymous~3")),
|
|
227
|
-
|
|
242
|
+
foldAnimationShow,
|
|
228
243
|
stepModel => (__foldkitBrandViewResult(({
|
|
229
244
|
model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/menu/index.js#isOpen~2") }),
|
|
230
245
|
}), "@foldkit/ui/menu/index.js#anonymous~4")),
|
|
@@ -243,7 +258,7 @@ export const update = (model, message) => {
|
|
|
243
258
|
if (model.isAnimated) {
|
|
244
259
|
return __foldkitBrandViewResult((Update.combine(closed, [
|
|
245
260
|
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/menu/index.js#anonymous~5")),
|
|
246
|
-
|
|
261
|
+
foldAnimationHide,
|
|
247
262
|
])), "@foldkit/ui/menu/index.js#closeMenu");
|
|
248
263
|
}
|
|
249
264
|
return __foldkitBrandViewResult(({ model: closed, commands }), "@foldkit/ui/menu/index.js#closeMenu");
|
|
@@ -396,7 +411,7 @@ export const update = (model, message) => {
|
|
|
396
411
|
* Exposed so Scene tests can call
|
|
397
412
|
* `Scene.Mount.resolve(AnchorMenu, Message.CompletedAnchorMenu())`. */
|
|
398
413
|
export const AnchorMenu = Mount.define('AnchorMenu', {
|
|
399
|
-
args: { buttonId:
|
|
414
|
+
args: { buttonId: Schema.String, anchor: AnchorConfig },
|
|
400
415
|
messages: [Message.CompletedAnchorMenu],
|
|
401
416
|
execute: ({ element, buttonId, anchor }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
402
417
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
@@ -439,21 +454,21 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
439
454
|
const dispatchSelectedItem = (item, index) => __foldkitBrandViewResult((Message.SelectedItem({ index, item })), "@foldkit/ui/menu/index.js#dispatchSelectedItem");
|
|
440
455
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
441
456
|
const isVisible = isOpen || isLeaving;
|
|
442
|
-
const animationAttributes =
|
|
457
|
+
const animationAttributes = Match.value(transitionState).pipe(Match.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
443
458
|
h.DataAttribute('closed', ''),
|
|
444
459
|
h.DataAttribute('enter', ''),
|
|
445
460
|
h.DataAttribute('transition', ''),
|
|
446
|
-
]), "@foldkit/ui/menu/index.js#anonymous~20")),
|
|
461
|
+
]), "@foldkit/ui/menu/index.js#anonymous~20")), Match.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
447
462
|
h.DataAttribute('enter', ''),
|
|
448
463
|
h.DataAttribute('transition', ''),
|
|
449
|
-
]), "@foldkit/ui/menu/index.js#anonymous~21")),
|
|
464
|
+
]), "@foldkit/ui/menu/index.js#anonymous~21")), Match.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
450
465
|
h.DataAttribute('leave', ''),
|
|
451
466
|
h.DataAttribute('transition', ''),
|
|
452
|
-
]), "@foldkit/ui/menu/index.js#anonymous~22")),
|
|
467
|
+
]), "@foldkit/ui/menu/index.js#anonymous~22")), Match.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
453
468
|
h.DataAttribute('closed', ''),
|
|
454
469
|
h.DataAttribute('leave', ''),
|
|
455
470
|
h.DataAttribute('transition', ''),
|
|
456
|
-
]), "@foldkit/ui/menu/index.js#anonymous~23")),
|
|
471
|
+
]), "@foldkit/ui/menu/index.js#anonymous~23")), Match.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#anonymous~24")));
|
|
457
472
|
const isDisabled = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
458
473
|
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~25")))), "@foldkit/ui/menu/index.js#isDisabled");
|
|
459
474
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(0, 1);
|
|
@@ -462,11 +477,11 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
462
477
|
if (isOpen) {
|
|
463
478
|
return __foldkitBrandViewResult((handleItemsKeyDown(key)), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
464
479
|
}
|
|
465
|
-
return __foldkitBrandViewResult((
|
|
480
|
+
return __foldkitBrandViewResult((Match.value(key).pipe(Match.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
466
481
|
maybeActiveItemIndex: Option.some(firstEnabledIndex),
|
|
467
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~26")),
|
|
482
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~26")), Match.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
468
483
|
maybeActiveItemIndex: Option.some(lastEnabledIndex),
|
|
469
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~27")),
|
|
484
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~27")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~28")))), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
470
485
|
};
|
|
471
486
|
const handleButtonPointerDown = (pointerType, button, screenX, screenY, timeStamp) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({
|
|
472
487
|
pointerType,
|
|
@@ -491,15 +506,15 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
491
506
|
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~30")), isDisabled);
|
|
492
507
|
const searchForKey = (key) => {
|
|
493
508
|
const nextQuery = searchQuery + key;
|
|
494
|
-
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isDisabled, itemToSearchText,
|
|
509
|
+
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isDisabled, itemToSearchText, String.isNonEmpty(searchQuery));
|
|
495
510
|
return __foldkitBrandViewResult((Option.some(Message.Searched({ key, maybeTargetIndex }))), "@foldkit/ui/menu/index.js#searchForKey");
|
|
496
511
|
};
|
|
497
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((
|
|
512
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((Match.value(key).pipe(Match.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/menu/index.js#anonymous~31")), Match.when('Enter', () => __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~33"))), "@foldkit/ui/menu/index.js#anonymous~32")), Match.when(' ', () => __foldkitBrandViewResult((String.isNonEmpty(searchQuery)
|
|
498
513
|
? searchForKey(' ')
|
|
499
|
-
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~35"))), "@foldkit/ui/menu/index.js#anonymous~34")),
|
|
514
|
+
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~35"))), "@foldkit/ui/menu/index.js#anonymous~34")), Match.whenOr('ArrowDown', 'ArrowUp', 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
500
515
|
index: resolveActiveIndex(key),
|
|
501
516
|
activationTrigger: 'Keyboard',
|
|
502
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~36")),
|
|
517
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~36")), Match.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/menu/index.js#anonymous~37")), Match.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~38")))), "@foldkit/ui/menu/index.js#handleItemsKeyDown");
|
|
503
518
|
const handleItemsPointerUp = (screenX, screenY, pointerType, timeStamp) => __foldkitBrandViewResult((OptionExt.when(pointerType === 'mouse', Message.ReleasedPointerOnItems({ screenX, screenY, timeStamp }))), "@foldkit/ui/menu/index.js#handleItemsPointerUp");
|
|
504
519
|
const resolveButtonLabel = () => {
|
|
505
520
|
if (Predicate.isNotUndefined(ariaLabel)) {
|