@foldkit/ui 0.148.2 → 0.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/index.d.ts +3 -3
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/animation/index.js +2 -2
- package/dist/animation/public.d.ts +1 -1
- package/dist/animation/public.d.ts.map +1 -1
- package/dist/animation/public.js +1 -1
- package/dist/animation/schema.d.ts +12 -21
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/schema.js +11 -15
- package/dist/animation/update.d.ts +1 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +9 -9
- package/dist/calendar/index.d.ts +50 -105
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +61 -98
- package/dist/calendar/public.d.ts +1 -1
- package/dist/calendar/public.d.ts.map +1 -1
- package/dist/calendar/public.js +1 -1
- package/dist/combobox/multi.d.ts +9 -9
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +9 -9
- package/dist/combobox/public.d.ts +1 -1
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +93 -137
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +108 -153
- package/dist/combobox/single.d.ts +9 -9
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +10 -10
- package/dist/datePicker/index.d.ts +88 -84
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +33 -63
- package/dist/datePicker/public.d.ts +1 -1
- package/dist/datePicker/public.d.ts.map +1 -1
- package/dist/datePicker/public.js +1 -1
- package/dist/dialog/index.d.ts +28 -49
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +39 -67
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/dialog/public.js +1 -1
- package/dist/dragAndDrop/index.d.ts +45 -72
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +72 -93
- package/dist/dragAndDrop/public.d.ts +1 -1
- package/dist/dragAndDrop/public.d.ts.map +1 -1
- package/dist/dragAndDrop/public.js +1 -1
- package/dist/fileDrop/index.d.ts +14 -35
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +20 -46
- package/dist/fileDrop/public.d.ts +1 -1
- package/dist/fileDrop/public.d.ts.map +1 -1
- package/dist/fileDrop/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -7
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +8 -8
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/public.js +1 -1
- package/dist/listbox/shared.d.ts +80 -127
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +92 -149
- package/dist/listbox/single.d.ts +7 -7
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -8
- package/dist/menu/index.d.ts +86 -134
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +141 -189
- package/dist/menu/public.d.ts +1 -1
- package/dist/menu/public.d.ts.map +1 -1
- package/dist/menu/public.js +1 -1
- package/dist/popover/index.d.ts +39 -65
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +68 -98
- package/dist/popover/public.d.ts +1 -1
- package/dist/popover/public.d.ts.map +1 -1
- package/dist/popover/public.js +1 -1
- package/dist/radioGroup/index.d.ts +18 -29
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +22 -27
- package/dist/radioGroup/public.d.ts +1 -1
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +29 -51
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +36 -56
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/tabs/index.d.ts +18 -28
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +22 -26
- package/dist/tabs/public.d.ts +1 -1
- package/dist/tabs/public.d.ts.map +1 -1
- package/dist/tabs/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +71 -14
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +14 -13
- package/dist/toast/index.d.ts +124 -109
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +5 -5
- package/dist/toast/public.d.ts +1 -1
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +72 -84
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +31 -41
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/test.js +6 -3
- package/dist/toast/update.d.ts +104 -89
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +19 -20
- package/dist/tooltip/message.d.ts +26 -47
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/message.js +15 -40
- package/dist/tooltip/public.d.ts +1 -1
- package/dist/tooltip/public.d.ts.map +1 -1
- package/dist/tooltip/public.js +1 -1
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -16
- package/dist/virtualList/index.d.ts +46 -23
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +12 -23
- package/dist/virtualList/public.d.ts +1 -1
- package/dist/virtualList/public.d.ts.map +1 -1
- package/dist/virtualList/public.js +1 -1
- package/package.json +3 -3
package/dist/menu/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, String as Str, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
|
-
import {
|
|
5
|
+
import { defineMessageUnion } from 'foldkit/message';
|
|
6
6
|
import * as Mount from 'foldkit/mount';
|
|
7
7
|
import { evo } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -11,7 +11,7 @@ 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 {
|
|
14
|
+
import { Message as AnimationMessage, Model as AnimationModel, init as animationInit, } from '../animation/schema.js';
|
|
15
15
|
import { update as animationUpdate } from '../animation/update.js';
|
|
16
16
|
import { groupContiguous } from '../group.js';
|
|
17
17
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
@@ -42,123 +42,53 @@ export const Model = S.Struct({
|
|
|
42
42
|
maybePointerOrigin: S.Option(PointerOrigin),
|
|
43
43
|
});
|
|
44
44
|
// MESSAGE
|
|
45
|
-
/** Sent when the menu opens via button click or keyboard. Contains an optional initial active item index: None for pointer, Some for keyboard. */
|
|
46
|
-
export const Opened = m('Opened', {
|
|
47
|
-
maybeActiveItemIndex: S.Option(S.Number),
|
|
48
|
-
});
|
|
49
|
-
/** Sent when the menu closes via Escape key or backdrop click. */
|
|
50
|
-
export const Closed = m('Closed');
|
|
51
|
-
/** Sent when the menu items container loses focus. */
|
|
52
|
-
export const BlurredItems = m('BlurredItems');
|
|
53
|
-
/** Sent when an item is highlighted via arrow keys or mouse hover. Includes activation trigger. */
|
|
54
|
-
export const ActivatedItem = m('ActivatedItem', {
|
|
55
|
-
index: S.Number,
|
|
56
|
-
activationTrigger: ActivationTrigger,
|
|
57
|
-
});
|
|
58
|
-
/** Sent when the mouse leaves an enabled item. */
|
|
59
|
-
export const DeactivatedItem = m('DeactivatedItem');
|
|
60
|
-
/** Sent when an item is selected via Enter, Space, or click. */
|
|
61
|
-
export const SelectedItem = m('SelectedItem', {
|
|
62
|
-
index: S.Number,
|
|
63
|
-
item: S.String,
|
|
64
|
-
});
|
|
65
|
-
/** Sent when Enter or Space is pressed on the active item, triggering a programmatic click on the DOM element. */
|
|
66
|
-
export const RequestedItemClick = m('RequestedItemClick', {
|
|
67
|
-
index: S.Number,
|
|
68
|
-
});
|
|
69
|
-
/** Sent when a printable character is typed for typeahead search. */
|
|
70
|
-
export const Searched = m('Searched', {
|
|
71
|
-
key: S.String,
|
|
72
|
-
maybeTargetIndex: S.Option(S.Number),
|
|
73
|
-
});
|
|
74
|
-
/** Sent after the search debounce period to clear the accumulated query. */
|
|
75
|
-
export const CompletedDelayClearSearch = m('CompletedDelayClearSearch', {
|
|
76
|
-
version: S.Number,
|
|
77
|
-
});
|
|
78
|
-
/** Sent when the pointer moves over a menu item, carrying screen coordinates for tracked-pointer comparison. */
|
|
79
|
-
export const MovedPointerOverItem = m('MovedPointerOverItem', {
|
|
80
|
-
index: S.Number,
|
|
81
|
-
screenX: S.Number,
|
|
82
|
-
screenY: S.Number,
|
|
83
|
-
});
|
|
84
|
-
/** Sent when the focus-items command completes after opening the menu. */
|
|
85
|
-
export const CompletedFocusItems = m('CompletedFocusItems');
|
|
86
|
-
/** Sent when the focus-button command completes after closing or selecting. */
|
|
87
|
-
export const CompletedFocusButton = m('CompletedFocusButton');
|
|
88
|
-
/** Sent when the scroll lock command completes. */
|
|
89
|
-
export const CompletedLockScroll = m('CompletedLockScroll');
|
|
90
|
-
/** Sent when the scroll unlock command completes. */
|
|
91
|
-
export const CompletedUnlockScroll = m('CompletedUnlockScroll');
|
|
92
|
-
/** Sent when the inert-others command completes. */
|
|
93
|
-
export const CompletedInertOthers = m('CompletedInertOthers');
|
|
94
|
-
/** Sent when the restore-inert command completes. */
|
|
95
|
-
export const CompletedRestoreInert = m('CompletedRestoreInert');
|
|
96
|
-
/** Sent when the scroll-into-view command completes after keyboard activation. */
|
|
97
|
-
export const CompletedScrollIntoView = m('CompletedScrollIntoView');
|
|
98
|
-
/** Sent when the programmatic click command completes. */
|
|
99
|
-
export const CompletedClickItem = m('CompletedClickItem');
|
|
100
|
-
/** Sent when a mouse click on the button is ignored because pointer-down already handled the toggle. */
|
|
101
|
-
export const IgnoredMouseClick = m('IgnoredMouseClick');
|
|
102
|
-
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
103
|
-
export const SuppressedSpaceScroll = m('SuppressedSpaceScroll');
|
|
104
|
-
/** Sent when the menu items panel mounts and Floating UI has positioned it. Update no-ops; the side effect is the act of positioning, surfaced for DevTools observability. */
|
|
105
|
-
export const CompletedAnchorMenu = m('CompletedAnchorMenu');
|
|
106
|
-
/** Sent when the menu backdrop mounts and is portaled to the document body. Update no-ops; surfaces the portal side effect for DevTools. */
|
|
107
|
-
export const CompletedPortalMenuBackdrop = m('CompletedPortalMenuBackdrop');
|
|
108
|
-
/** Wraps an Animation submodel message for delegation. */
|
|
109
|
-
export const GotAnimationMessage = m('GotAnimationMessage', {
|
|
110
|
-
message: AnimationMessage,
|
|
111
|
-
});
|
|
112
|
-
/** Sent when the user presses a pointer device on the menu button. Records pointer type and toggles for mouse. */
|
|
113
|
-
export const PressedPointerOnButton = m('PressedPointerOnButton', {
|
|
114
|
-
pointerType: S.String,
|
|
115
|
-
button: S.Number,
|
|
116
|
-
screenX: S.Number,
|
|
117
|
-
screenY: S.Number,
|
|
118
|
-
timeStamp: S.Number,
|
|
119
|
-
});
|
|
120
|
-
/** Sent when the user releases a pointer on the items container, enabling drag-to-select for mouse. */
|
|
121
|
-
export const ReleasedPointerOnItems = m('ReleasedPointerOnItems', {
|
|
122
|
-
screenX: S.Number,
|
|
123
|
-
screenY: S.Number,
|
|
124
|
-
timeStamp: S.Number,
|
|
125
|
-
});
|
|
126
45
|
/** Union of all messages the menu component can produce. */
|
|
127
|
-
export const Message =
|
|
128
|
-
Opened,
|
|
129
|
-
Closed,
|
|
130
|
-
BlurredItems,
|
|
131
|
-
ActivatedItem,
|
|
132
|
-
DeactivatedItem,
|
|
133
|
-
SelectedItem,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
46
|
+
export const Message = defineMessageUnion({
|
|
47
|
+
Opened: { maybeActiveItemIndex: S.Option(S.Number) },
|
|
48
|
+
Closed: {},
|
|
49
|
+
BlurredItems: {},
|
|
50
|
+
ActivatedItem: { index: S.Number, activationTrigger: ActivationTrigger },
|
|
51
|
+
DeactivatedItem: {},
|
|
52
|
+
SelectedItem: { index: S.Number, item: S.String },
|
|
53
|
+
RequestedItemClick: { index: S.Number },
|
|
54
|
+
Searched: { key: S.String, maybeTargetIndex: S.Option(S.Number) },
|
|
55
|
+
CompletedDelayClearSearch: { version: S.Number },
|
|
56
|
+
MovedPointerOverItem: {
|
|
57
|
+
index: S.Number,
|
|
58
|
+
screenX: S.Number,
|
|
59
|
+
screenY: S.Number,
|
|
60
|
+
},
|
|
61
|
+
CompletedFocusItems: {},
|
|
62
|
+
CompletedFocusButton: {},
|
|
63
|
+
CompletedLockScroll: {},
|
|
64
|
+
CompletedUnlockScroll: {},
|
|
65
|
+
CompletedInertOthers: {},
|
|
66
|
+
CompletedRestoreInert: {},
|
|
67
|
+
CompletedScrollIntoView: {},
|
|
68
|
+
CompletedClickItem: {},
|
|
69
|
+
IgnoredMouseClick: {},
|
|
70
|
+
SuppressedSpaceScroll: {},
|
|
71
|
+
CompletedAnchorMenu: {},
|
|
72
|
+
CompletedPortalMenuBackdrop: {},
|
|
73
|
+
GotAnimationMessage: { message: AnimationMessage },
|
|
74
|
+
PressedPointerOnButton: {
|
|
75
|
+
pointerType: S.String,
|
|
76
|
+
button: S.Number,
|
|
77
|
+
screenX: S.Number,
|
|
78
|
+
screenY: S.Number,
|
|
79
|
+
timeStamp: S.Number,
|
|
80
|
+
},
|
|
81
|
+
ReleasedPointerOnItems: {
|
|
82
|
+
screenX: S.Number,
|
|
83
|
+
screenY: S.Number,
|
|
84
|
+
timeStamp: S.Number,
|
|
85
|
+
},
|
|
159
86
|
});
|
|
87
|
+
// OUT MESSAGE
|
|
160
88
|
/** Union of out-messages the menu component can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
|
|
161
|
-
export const OutMessage =
|
|
89
|
+
export const OutMessage = defineMessageUnion({
|
|
90
|
+
Selected: { value: S.String, index: S.Number },
|
|
91
|
+
});
|
|
162
92
|
// INIT
|
|
163
93
|
const SEARCH_DEBOUNCE_MILLISECONDS = 350;
|
|
164
94
|
const LEFT_MOUSE_BUTTON = 0;
|
|
@@ -197,64 +127,67 @@ export const buttonId = (id) => __foldkitBrandViewResult((`${id}-button`), "@fol
|
|
|
197
127
|
const buttonSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-button`)), "@foldkit/ui/menu/index.js#buttonSelector");
|
|
198
128
|
const itemsSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-items`)), "@foldkit/ui/menu/index.js#itemsSelector");
|
|
199
129
|
const itemSelector = (id, index) => __foldkitBrandViewResult((idSelector(`${id}-item-${index}`)), "@foldkit/ui/menu/index.js#itemSelector");
|
|
200
|
-
const withUpdateReturn = M.withReturnType();
|
|
201
130
|
/** Prevents page scrolling while the menu is open. */
|
|
202
131
|
export const LockScroll = Command.define('LockScroll', {
|
|
203
|
-
messages: [CompletedLockScroll],
|
|
204
|
-
execute: Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())),
|
|
132
|
+
messages: [Message.CompletedLockScroll],
|
|
133
|
+
execute: Dom.lockScroll.pipe(Effect.as(Message.CompletedLockScroll())),
|
|
205
134
|
});
|
|
206
135
|
/** Re-enables page scrolling after the menu closes. */
|
|
207
136
|
export const UnlockScroll = Command.define('UnlockScroll', {
|
|
208
|
-
messages: [CompletedUnlockScroll],
|
|
209
|
-
execute: Dom.unlockScroll.pipe(Effect.as(CompletedUnlockScroll())),
|
|
137
|
+
messages: [Message.CompletedUnlockScroll],
|
|
138
|
+
execute: Dom.unlockScroll.pipe(Effect.as(Message.CompletedUnlockScroll())),
|
|
210
139
|
});
|
|
211
140
|
/** Marks all elements outside the menu as inert for modal behavior. */
|
|
212
141
|
export const InertOthers = Command.define('InertOthers', {
|
|
213
142
|
args: { id: S.String },
|
|
214
|
-
messages: [CompletedInertOthers],
|
|
215
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), itemsSelector(id)]).pipe(Effect.as(CompletedInertOthers()))), "@foldkit/ui/menu/index.js#execute"),
|
|
143
|
+
messages: [Message.CompletedInertOthers],
|
|
144
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), itemsSelector(id)]).pipe(Effect.as(Message.CompletedInertOthers()))), "@foldkit/ui/menu/index.js#execute"),
|
|
216
145
|
});
|
|
217
146
|
/** Removes the inert attribute from elements outside the menu. */
|
|
218
147
|
export const RestoreInert = Command.define('RestoreInert', {
|
|
219
148
|
args: { id: S.String },
|
|
220
|
-
messages: [CompletedRestoreInert],
|
|
221
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert()))), "@foldkit/ui/menu/index.js#execute~2"),
|
|
149
|
+
messages: [Message.CompletedRestoreInert],
|
|
150
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(Message.CompletedRestoreInert()))), "@foldkit/ui/menu/index.js#execute~2"),
|
|
222
151
|
});
|
|
223
152
|
/** Moves focus to the menu items container after opening. */
|
|
224
153
|
export const FocusItems = Command.define('FocusItems', {
|
|
225
154
|
args: { id: S.String },
|
|
226
|
-
messages: [CompletedFocusItems],
|
|
227
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(itemsSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusItems()))), "@foldkit/ui/menu/index.js#execute~3"),
|
|
155
|
+
messages: [Message.CompletedFocusItems],
|
|
156
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(itemsSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusItems()))), "@foldkit/ui/menu/index.js#execute~3"),
|
|
228
157
|
});
|
|
229
158
|
/** Moves focus back to the menu button after closing. */
|
|
230
159
|
export const FocusButton = Command.define('FocusButton', {
|
|
231
160
|
args: { id: S.String },
|
|
232
|
-
messages: [CompletedFocusButton],
|
|
233
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))), "@foldkit/ui/menu/index.js#execute~4"),
|
|
161
|
+
messages: [Message.CompletedFocusButton],
|
|
162
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusButton()))), "@foldkit/ui/menu/index.js#execute~4"),
|
|
234
163
|
});
|
|
235
164
|
/** Scrolls the active menu item into view after keyboard navigation. */
|
|
236
165
|
export const ScrollIntoView = Command.define('ScrollIntoView', {
|
|
237
166
|
args: { id: S.String, index: S.Number },
|
|
238
|
-
messages: [CompletedScrollIntoView],
|
|
239
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedScrollIntoView()))), "@foldkit/ui/menu/index.js#execute~5"),
|
|
167
|
+
messages: [Message.CompletedScrollIntoView],
|
|
168
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedScrollIntoView()))), "@foldkit/ui/menu/index.js#execute~5"),
|
|
240
169
|
});
|
|
241
170
|
/** Programmatically clicks the active menu item's DOM element. */
|
|
242
171
|
export const ClickItem = Command.define('ClickItem', {
|
|
243
172
|
args: { id: S.String, index: S.Number },
|
|
244
|
-
messages: [CompletedClickItem],
|
|
245
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedClickItem()))), "@foldkit/ui/menu/index.js#execute~6"),
|
|
173
|
+
messages: [Message.CompletedClickItem],
|
|
174
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedClickItem()))), "@foldkit/ui/menu/index.js#execute~6"),
|
|
246
175
|
});
|
|
247
176
|
/** Waits for the typeahead search debounce period before clearing the query. */
|
|
248
177
|
export const DelayClearSearch = Command.define('DelayClearSearch', {
|
|
249
178
|
args: { version: S.Number },
|
|
250
|
-
messages: [CompletedDelayClearSearch],
|
|
251
|
-
execute: ({ version }) => __foldkitBrandViewResult((Effect.sleep(SEARCH_DEBOUNCE_MILLISECONDS).pipe(Effect.as(CompletedDelayClearSearch({ version })))), "@foldkit/ui/menu/index.js#execute~7"),
|
|
179
|
+
messages: [Message.CompletedDelayClearSearch],
|
|
180
|
+
execute: ({ version }) => __foldkitBrandViewResult((Effect.sleep(SEARCH_DEBOUNCE_MILLISECONDS).pipe(Effect.as(Message.CompletedDelayClearSearch({ version })))), "@foldkit/ui/menu/index.js#execute~7"),
|
|
252
181
|
});
|
|
253
182
|
/** Detects whether the menu button moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
254
183
|
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', {
|
|
255
184
|
args: { id: S.String },
|
|
256
|
-
messages: [GotAnimationMessage],
|
|
257
|
-
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(
|
|
185
|
+
messages: [Message.GotAnimationMessage],
|
|
186
|
+
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
187
|
+
message: AnimationMessage.EndedAnimation(),
|
|
188
|
+
}))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
189
|
+
message: AnimationMessage.EndedAnimation(),
|
|
190
|
+
}))))), "@foldkit/ui/menu/index.js#execute~8"),
|
|
258
191
|
});
|
|
259
192
|
const foldAnimationOutMessage = M.type().pipe(M.withReturnType(), M.tagsExhaustive({
|
|
260
193
|
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([
|
|
@@ -267,7 +200,7 @@ const foldAnimation = Update.foldChild({
|
|
|
267
200
|
update: animationUpdate,
|
|
268
201
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/menu/index.js#read"),
|
|
269
202
|
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/menu/index.js#animation") })), "@foldkit/ui/menu/index.js#write"),
|
|
270
|
-
toParentMessage: message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/menu/index.js#toParentMessage"),
|
|
203
|
+
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/menu/index.js#toParentMessage"),
|
|
271
204
|
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#toParentOutMessage"),
|
|
272
205
|
foldOutMessage: foldAnimationOutMessage,
|
|
273
206
|
});
|
|
@@ -291,7 +224,7 @@ export const update = (model, message) => {
|
|
|
291
224
|
]);
|
|
292
225
|
const openMenu = (baseModel) => {
|
|
293
226
|
if (model.isAnimated) {
|
|
294
|
-
const [nextModel, animationCommands] = foldAnimation(baseModel,
|
|
227
|
+
const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationMessage.Showed());
|
|
295
228
|
return __foldkitBrandViewResult(([
|
|
296
229
|
evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/menu/index.js#isOpen~2") }),
|
|
297
230
|
[...openCommands, ...animationCommands],
|
|
@@ -306,12 +239,23 @@ export const update = (model, message) => {
|
|
|
306
239
|
}
|
|
307
240
|
const closed = closedModel(baseModel);
|
|
308
241
|
if (model.isAnimated) {
|
|
309
|
-
const [nextModel, animationCommands] = foldAnimation(closed,
|
|
242
|
+
const [nextModel, animationCommands] = foldAnimation(closed, AnimationMessage.Hid());
|
|
310
243
|
return __foldkitBrandViewResult(([nextModel, [...commands, ...animationCommands], maybeOutMessage]), "@foldkit/ui/menu/index.js#closeMenu");
|
|
311
244
|
}
|
|
312
245
|
return __foldkitBrandViewResult(([closed, commands, maybeOutMessage]), "@foldkit/ui/menu/index.js#closeMenu");
|
|
313
246
|
};
|
|
314
|
-
return __foldkitBrandViewResult((
|
|
247
|
+
return __foldkitBrandViewResult((Message.match(message, {
|
|
248
|
+
CompletedFocusItems: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedFocusItems"),
|
|
249
|
+
CompletedFocusButton: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedFocusButton"),
|
|
250
|
+
CompletedLockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedLockScroll"),
|
|
251
|
+
CompletedUnlockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedUnlockScroll"),
|
|
252
|
+
CompletedInertOthers: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedInertOthers"),
|
|
253
|
+
CompletedRestoreInert: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedRestoreInert"),
|
|
254
|
+
CompletedScrollIntoView: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedScrollIntoView"),
|
|
255
|
+
CompletedClickItem: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedClickItem"),
|
|
256
|
+
SuppressedSpaceScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#SuppressedSpaceScroll"),
|
|
257
|
+
CompletedAnchorMenu: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedAnchorMenu"),
|
|
258
|
+
CompletedPortalMenuBackdrop: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedPortalMenuBackdrop"),
|
|
315
259
|
Opened: ({ maybeActiveItemIndex }) => __foldkitBrandViewResult((openMenu(evo(model, {
|
|
316
260
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((maybeActiveItemIndex), "@foldkit/ui/menu/index.js#maybeActiveItemIndex~2"),
|
|
317
261
|
activationTrigger: () => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
@@ -340,7 +284,7 @@ export const update = (model, message) => {
|
|
|
340
284
|
Option.none(),
|
|
341
285
|
]), "@foldkit/ui/menu/index.js#ActivatedItem"),
|
|
342
286
|
MovedPointerOverItem: ({ index, screenX, screenY }) => {
|
|
343
|
-
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/menu/index.js#anonymous~
|
|
287
|
+
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/menu/index.js#anonymous~3"));
|
|
344
288
|
if (isSamePosition) {
|
|
345
289
|
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#MovedPointerOverItem");
|
|
346
290
|
}
|
|
@@ -361,7 +305,7 @@ export const update = (model, message) => {
|
|
|
361
305
|
Option.none(),
|
|
362
306
|
]
|
|
363
307
|
: [model, [], Option.none()]), "@foldkit/ui/menu/index.js#DeactivatedItem"),
|
|
364
|
-
SelectedItem: ({ index, item }) => __foldkitBrandViewResult((closeMenu(model, closeWithFocusCommands, Option.some(Selected({ value: item, index })))), "@foldkit/ui/menu/index.js#SelectedItem"),
|
|
308
|
+
SelectedItem: ({ index, item }) => __foldkitBrandViewResult((closeMenu(model, closeWithFocusCommands, Option.some(OutMessage.Selected({ value: item, index })))), "@foldkit/ui/menu/index.js#SelectedItem"),
|
|
365
309
|
RequestedItemClick: ({ index }) => __foldkitBrandViewResult(([
|
|
366
310
|
model,
|
|
367
311
|
[ClickItem({ id: model.id, index })],
|
|
@@ -374,7 +318,7 @@ export const update = (model, message) => {
|
|
|
374
318
|
evo(model, {
|
|
375
319
|
searchQuery: () => __foldkitBrandViewResult((nextSearchQuery), "@foldkit/ui/menu/index.js#searchQuery~3"),
|
|
376
320
|
searchVersion: () => __foldkitBrandViewResult((nextSearchVersion), "@foldkit/ui/menu/index.js#searchVersion~3"),
|
|
377
|
-
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/menu/index.js#anonymous~
|
|
321
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/menu/index.js#anonymous~4"))), "@foldkit/ui/menu/index.js#maybeActiveItemIndex~6"),
|
|
378
322
|
}),
|
|
379
323
|
[DelayClearSearch({ version: nextSearchVersion })],
|
|
380
324
|
Option.none(),
|
|
@@ -419,8 +363,8 @@ export const update = (model, message) => {
|
|
|
419
363
|
const isMovementBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((Math.abs(screenX - origin.screenX) <
|
|
420
364
|
POINTER_MOVEMENT_THRESHOLD_PIXELS &&
|
|
421
365
|
Math.abs(screenY - origin.screenY) <
|
|
422
|
-
POINTER_MOVEMENT_THRESHOLD_PIXELS), "@foldkit/ui/menu/index.js#anonymous~
|
|
423
|
-
const isHoldTimeBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((timeStamp - origin.timeStamp < POINTER_HOLD_THRESHOLD_MILLISECONDS), "@foldkit/ui/menu/index.js#anonymous~
|
|
366
|
+
POINTER_MOVEMENT_THRESHOLD_PIXELS), "@foldkit/ui/menu/index.js#anonymous~5"));
|
|
367
|
+
const isHoldTimeBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((timeStamp - origin.timeStamp < POINTER_HOLD_THRESHOLD_MILLISECONDS), "@foldkit/ui/menu/index.js#anonymous~6"));
|
|
424
368
|
if (hasNoOrigin ||
|
|
425
369
|
isMovementBelowThreshold ||
|
|
426
370
|
isHoldTimeBelowThreshold ||
|
|
@@ -443,7 +387,7 @@ export const update = (model, message) => {
|
|
|
443
387
|
[],
|
|
444
388
|
Option.none(),
|
|
445
389
|
]), "@foldkit/ui/menu/index.js#IgnoredMouseClick"),
|
|
446
|
-
}))
|
|
390
|
+
})), "@foldkit/ui/menu/index.js#update");
|
|
447
391
|
};
|
|
448
392
|
/** The anchor-positioning Mount this Menu renders on its panel. The panel is
|
|
449
393
|
* always anchored to the button via Floating UI and portaled to the document
|
|
@@ -458,33 +402,33 @@ export const update = (model, message) => {
|
|
|
458
402
|
* configured, where the panel is visible as soon as the render commits.
|
|
459
403
|
*
|
|
460
404
|
* Exposed so Scene tests can call
|
|
461
|
-
* `Scene.Mount.resolve(AnchorMenu, CompletedAnchorMenu())`. */
|
|
462
|
-
export const AnchorMenu = Mount.define('AnchorMenu', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorMenu)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
405
|
+
* `Scene.Mount.resolve(AnchorMenu, Message.CompletedAnchorMenu())`. */
|
|
406
|
+
export const AnchorMenu = Mount.define('AnchorMenu', { buttonId: S.String, anchor: AnchorConfig }, Message.CompletedAnchorMenu)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
463
407
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
464
408
|
buttonId,
|
|
465
409
|
anchor,
|
|
466
410
|
focusAfterPosition: true,
|
|
467
|
-
})), "@foldkit/ui/menu/index.js#anonymous~
|
|
468
|
-
return __foldkitBrandViewResult((CompletedAnchorMenu()), "@foldkit/ui/menu/index.js#anonymous~
|
|
469
|
-
})), "@foldkit/ui/menu/index.js#anonymous~
|
|
411
|
+
})), "@foldkit/ui/menu/index.js#anonymous~10")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~11"));
|
|
412
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorMenu()), "@foldkit/ui/menu/index.js#anonymous~9");
|
|
413
|
+
})), "@foldkit/ui/menu/index.js#anonymous~8")), "@foldkit/ui/menu/index.js#anonymous~7"));
|
|
470
414
|
/** The backdrop-portaling Mount this Menu renders. Exposed so Scene tests can
|
|
471
|
-
* call `Scene.Mount.resolve(PortalMenuBackdrop, CompletedPortalMenuBackdrop())` to
|
|
415
|
+
* call `Scene.Mount.resolve(PortalMenuBackdrop, Message.CompletedPortalMenuBackdrop())` to
|
|
472
416
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
473
|
-
export const PortalMenuBackdrop = Mount.define('PortalMenuBackdrop', CompletedPortalMenuBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
474
|
-
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/menu/index.js#anonymous~
|
|
475
|
-
return __foldkitBrandViewResult((CompletedPortalMenuBackdrop()), "@foldkit/ui/menu/index.js#anonymous~
|
|
476
|
-
})), "@foldkit/ui/menu/index.js#anonymous~
|
|
417
|
+
export const PortalMenuBackdrop = Mount.define('PortalMenuBackdrop', Message.CompletedPortalMenuBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
418
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/menu/index.js#anonymous~14")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~15"));
|
|
419
|
+
return __foldkitBrandViewResult((Message.CompletedPortalMenuBackdrop()), "@foldkit/ui/menu/index.js#anonymous~13");
|
|
420
|
+
})), "@foldkit/ui/menu/index.js#anonymous~12"));
|
|
477
421
|
/** Programmatically opens the menu, updating the model and returning
|
|
478
422
|
* focus and modal commands. Use this in domain-event handlers to open the menu. */
|
|
479
|
-
export const open = (model) => __foldkitBrandViewResult((update(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/menu/index.js#open");
|
|
423
|
+
export const open = (model) => __foldkitBrandViewResult((update(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/menu/index.js#open");
|
|
480
424
|
/** Programmatically closes the menu. If it is open, returns the closed Model
|
|
481
425
|
* with focus and modal Commands. If it is already closed, returns the Model
|
|
482
426
|
* unchanged with no Commands. Use this in domain-event handlers to close the
|
|
483
427
|
* menu. */
|
|
484
|
-
export const close = (model) => __foldkitBrandViewResult((update(model, Closed())), "@foldkit/ui/menu/index.js#close");
|
|
428
|
+
export const close = (model) => __foldkitBrandViewResult((update(model, Message.Closed())), "@foldkit/ui/menu/index.js#close");
|
|
485
429
|
/** Programmatically selects a menu item, closing the menu and returning
|
|
486
430
|
* focus commands plus a `Selected` OutMessage. Use this in domain-event handlers. */
|
|
487
|
-
export const selectItem = (model, item, index) => __foldkitBrandViewResult((update(model, SelectedItem({ index, item }))), "@foldkit/ui/menu/index.js#selectItem");
|
|
431
|
+
export const selectItem = (model, item, index) => __foldkitBrandViewResult((update(model, Message.SelectedItem({ index, item }))), "@foldkit/ui/menu/index.js#selectItem");
|
|
488
432
|
export { groupContiguous, resolveTypeaheadMatch };
|
|
489
433
|
const itemId = (id, index) => __foldkitBrandViewResult((`${id}-item-${index}`), "@foldkit/ui/menu/index.js#itemId");
|
|
490
434
|
const internalView = () =>
|
|
@@ -492,36 +436,40 @@ const internalView = () =>
|
|
|
492
436
|
__foldkitBrandViewResult((menuViewImpl), "@foldkit/ui/menu/index.js#internalView");
|
|
493
437
|
const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
494
438
|
const { id, isOpen, animation: { transitionState }, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, } = model;
|
|
495
|
-
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~
|
|
496
|
-
const dispatchSelectedItem = (item, index) => __foldkitBrandViewResult((SelectedItem({ index, item })), "@foldkit/ui/menu/index.js#dispatchSelectedItem");
|
|
439
|
+
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~17"), isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor = {}, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
440
|
+
const dispatchSelectedItem = (item, index) => __foldkitBrandViewResult((Message.SelectedItem({ index, item })), "@foldkit/ui/menu/index.js#dispatchSelectedItem");
|
|
497
441
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
498
442
|
const isVisible = isOpen || isLeaving;
|
|
499
443
|
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
500
444
|
h.DataAttribute('closed', ''),
|
|
501
445
|
h.DataAttribute('enter', ''),
|
|
502
446
|
h.DataAttribute('transition', ''),
|
|
503
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
447
|
+
]), "@foldkit/ui/menu/index.js#anonymous~18")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
504
448
|
h.DataAttribute('enter', ''),
|
|
505
449
|
h.DataAttribute('transition', ''),
|
|
506
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
450
|
+
]), "@foldkit/ui/menu/index.js#anonymous~19")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
507
451
|
h.DataAttribute('leave', ''),
|
|
508
452
|
h.DataAttribute('transition', ''),
|
|
509
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
453
|
+
]), "@foldkit/ui/menu/index.js#anonymous~20")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
510
454
|
h.DataAttribute('closed', ''),
|
|
511
455
|
h.DataAttribute('leave', ''),
|
|
512
456
|
h.DataAttribute('transition', ''),
|
|
513
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
457
|
+
]), "@foldkit/ui/menu/index.js#anonymous~21")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#anonymous~22")));
|
|
514
458
|
const isDisabled = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
515
|
-
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~
|
|
459
|
+
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~23")))), "@foldkit/ui/menu/index.js#isDisabled");
|
|
516
460
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(0, 1);
|
|
517
461
|
const lastEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(items.length - 1, -1);
|
|
518
462
|
const handleButtonKeyDown = (key) => {
|
|
519
463
|
if (isOpen) {
|
|
520
464
|
return __foldkitBrandViewResult((handleItemsKeyDown(key)), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
521
465
|
}
|
|
522
|
-
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(
|
|
466
|
+
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
467
|
+
maybeActiveItemIndex: Option.some(firstEnabledIndex),
|
|
468
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~24")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
469
|
+
maybeActiveItemIndex: Option.some(lastEnabledIndex),
|
|
470
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~25")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~26")))), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
523
471
|
};
|
|
524
|
-
const handleButtonPointerDown = (pointerType, button, screenX, screenY, timeStamp) => __foldkitBrandViewResult((Option.some(PressedPointerOnButton({
|
|
472
|
+
const handleButtonPointerDown = (pointerType, button, screenX, screenY, timeStamp) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({
|
|
525
473
|
pointerType,
|
|
526
474
|
button,
|
|
527
475
|
screenX,
|
|
@@ -529,31 +477,31 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
529
477
|
timeStamp,
|
|
530
478
|
}))), "@foldkit/ui/menu/index.js#handleButtonPointerDown");
|
|
531
479
|
const handleButtonClick = () => {
|
|
532
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~
|
|
480
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~27"));
|
|
533
481
|
if (isMouse) {
|
|
534
|
-
return __foldkitBrandViewResult((IgnoredMouseClick()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
482
|
+
return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
535
483
|
}
|
|
536
484
|
else if (isOpen) {
|
|
537
|
-
return __foldkitBrandViewResult((Closed()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
485
|
+
return __foldkitBrandViewResult((Message.Closed()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
538
486
|
}
|
|
539
487
|
else {
|
|
540
|
-
return __foldkitBrandViewResult((Opened({ maybeActiveItemIndex: Option.none() })), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
488
|
+
return __foldkitBrandViewResult((Message.Opened({ maybeActiveItemIndex: Option.none() })), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
541
489
|
}
|
|
542
490
|
};
|
|
543
|
-
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', SuppressedSpaceScroll())), "@foldkit/ui/menu/index.js#handleSpaceKeyUp");
|
|
544
|
-
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~
|
|
491
|
+
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/menu/index.js#handleSpaceKeyUp");
|
|
492
|
+
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~28")), isDisabled);
|
|
545
493
|
const searchForKey = (key) => {
|
|
546
494
|
const nextQuery = searchQuery + key;
|
|
547
495
|
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isDisabled, itemToSearchText, Str.isNonEmpty(searchQuery));
|
|
548
|
-
return __foldkitBrandViewResult((Option.some(Searched({ key, maybeTargetIndex }))), "@foldkit/ui/menu/index.js#searchForKey");
|
|
496
|
+
return __foldkitBrandViewResult((Option.some(Message.Searched({ key, maybeTargetIndex }))), "@foldkit/ui/menu/index.js#searchForKey");
|
|
549
497
|
};
|
|
550
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Closed())), "@foldkit/ui/menu/index.js#anonymous~
|
|
498
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/menu/index.js#anonymous~29")), M.when('Enter', () => __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~31"))), "@foldkit/ui/menu/index.js#anonymous~30")), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
551
499
|
? searchForKey(' ')
|
|
552
|
-
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~
|
|
500
|
+
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~33"))), "@foldkit/ui/menu/index.js#anonymous~32")), M.whenOr('ArrowDown', 'ArrowUp', 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
553
501
|
index: resolveActiveIndex(key),
|
|
554
502
|
activationTrigger: 'Keyboard',
|
|
555
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
556
|
-
const handleItemsPointerUp = (screenX, screenY, pointerType, timeStamp) => __foldkitBrandViewResult((OptionExt.when(pointerType === 'mouse', ReleasedPointerOnItems({ screenX, screenY, timeStamp }))), "@foldkit/ui/menu/index.js#handleItemsPointerUp");
|
|
503
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~34")), M.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/menu/index.js#anonymous~35")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~36")))), "@foldkit/ui/menu/index.js#handleItemsKeyDown");
|
|
504
|
+
const handleItemsPointerUp = (screenX, screenY, pointerType, timeStamp) => __foldkitBrandViewResult((OptionExt.when(pointerType === 'mouse', Message.ReleasedPointerOnItems({ screenX, screenY, timeStamp }))), "@foldkit/ui/menu/index.js#handleItemsPointerUp");
|
|
557
505
|
const resolveButtonLabel = () => {
|
|
558
506
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
559
507
|
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/menu/index.js#resolveButtonLabel");
|
|
@@ -612,13 +560,13 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
612
560
|
h.OnKeyDownPreventDefault(handleItemsKeyDown),
|
|
613
561
|
h.OnKeyUpPreventDefault(handleSpaceKeyUp),
|
|
614
562
|
h.OnPointerUp(handleItemsPointerUp),
|
|
615
|
-
h.OnBlur(BlurredItems()),
|
|
563
|
+
h.OnBlur(Message.BlurredItems()),
|
|
616
564
|
]),
|
|
617
565
|
...(itemsClassName ? [h.Class(itemsClassName)] : []),
|
|
618
566
|
...itemsAttributes,
|
|
619
567
|
];
|
|
620
568
|
const menuItems = Array.map(items, (item, index) => {
|
|
621
|
-
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~
|
|
569
|
+
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~38"));
|
|
622
570
|
const isDisabledItem = isDisabled(index);
|
|
623
571
|
const itemConfig = itemToConfig(item, {
|
|
624
572
|
isActive: isActiveItem,
|
|
@@ -638,13 +586,17 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
638
586
|
...(isActiveItem
|
|
639
587
|
? []
|
|
640
588
|
: [
|
|
641
|
-
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({
|
|
589
|
+
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.MovedPointerOverItem({
|
|
590
|
+
index,
|
|
591
|
+
screenX,
|
|
592
|
+
screenY,
|
|
593
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~39")),
|
|
642
594
|
]),
|
|
643
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~
|
|
595
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~40")),
|
|
644
596
|
]
|
|
645
597
|
: []),
|
|
646
598
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
647
|
-
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~
|
|
599
|
+
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~37");
|
|
648
600
|
});
|
|
649
601
|
const renderGroupedItems = () => {
|
|
650
602
|
if (!itemGroupKey) {
|
|
@@ -653,7 +605,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
653
605
|
const segments = groupContiguous(menuItems, (_, index) => __foldkitBrandViewResult((Array.get(items, index).pipe(Option.match({
|
|
654
606
|
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#onNone~3"),
|
|
655
607
|
onSome: item => __foldkitBrandViewResult((itemGroupKey(item, index)), "@foldkit/ui/menu/index.js#onSome~3"),
|
|
656
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
608
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~41"));
|
|
657
609
|
return __foldkitBrandViewResult((Array.flatMap(segments, (segment, segmentIndex) => {
|
|
658
610
|
const maybeHeading = Option.fromNullishOr(groupToHeading && groupToHeading(segment.key));
|
|
659
611
|
const headingId = `${id}-heading-${segment.key}`;
|
|
@@ -687,12 +639,12 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
687
639
|
]),
|
|
688
640
|
]
|
|
689
641
|
: [];
|
|
690
|
-
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~
|
|
642
|
+
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~42");
|
|
691
643
|
})), "@foldkit/ui/menu/index.js#renderGroupedItems");
|
|
692
644
|
};
|
|
693
645
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
694
646
|
h.OnMount(PortalMenuBackdrop()),
|
|
695
|
-
...(isLeaving ? [] : [h.OnClick(Closed())]),
|
|
647
|
+
...(isLeaving ? [] : [h.OnClick(Message.Closed())]),
|
|
696
648
|
...(backdropClassName ? [h.Class(backdropClassName)] : []),
|
|
697
649
|
...backdropAttributes,
|
|
698
650
|
]);
|
|
@@ -722,7 +674,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
722
674
|
buttonContent,
|
|
723
675
|
]),
|
|
724
676
|
...(isVisible ? visibleContent : []),
|
|
725
|
-
])), "@foldkit/ui/menu/index.js#anonymous~
|
|
677
|
+
])), "@foldkit/ui/menu/index.js#anonymous~16");
|
|
726
678
|
});
|
|
727
679
|
/** Pairs the menu's `view` and `update` (and programmatic helpers)
|
|
728
680
|
* behind a single Item-typed entry point. Declaring the menu once at
|
package/dist/menu/public.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { init, create, buttonId, Model, Message, OutMessage, Selected, SelectedItem,
|
|
1
|
+
export { init, create, buttonId, Model, Message, OutMessage, type Selected, type SelectedItem, AnchorMenu, PortalMenuBackdrop, type CompletedDelayClearSearch, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusItems, FocusButton, ScrollIntoView, ClickItem, DelayClearSearch, DetectMovementOrAnimationEnd, type Opened, type Closed, type BlurredItems, type ActivatedItem, type DeactivatedItem, type MovedPointerOverItem, type RequestedItemClick, type Searched, type PressedPointerOnButton, type ReleasedPointerOnItems, type IgnoredMouseClick, type SuppressedSpaceScroll, } from './index.js';
|
|
2
2
|
export type { ActivationTrigger, InitConfig, ViewInputs, ItemConfig, GroupHeading, Bundle, } 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/menu/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/menu/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,UAAU,EACV,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,4BAA4B,EAC5B,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,QAAQ,EACb,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,GACP,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/menu/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, create, buttonId, Model, Message, OutMessage,
|
|
1
|
+
export { init, create, buttonId, Model, Message, OutMessage, AnchorMenu, PortalMenuBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusItems, FocusButton, ScrollIntoView, ClickItem, DelayClearSearch, DetectMovementOrAnimationEnd, } from './index.js';
|