@foldkit/ui 0.141.2 → 0.142.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/README.md +2 -2
- package/dist/checkbox/index.d.ts +4 -0
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +71 -73
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +76 -89
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +27 -29
- package/dist/listbox/multi.d.ts +2 -0
- package/dist/listbox/multi.d.ts.map +1 -1
- 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 +20 -0
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +83 -64
- package/dist/listbox/single.d.ts +2 -0
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +53 -55
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +33 -35
- package/dist/radioGroup/index.d.ts +137 -51
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +149 -60
- package/dist/radioGroup/public.d.ts +2 -2
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +28 -0
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +11 -8
- package/dist/switch/index.d.ts +4 -0
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +16 -10
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +44 -50
- package/package.json +2 -2
package/dist/menu/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { m } 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';
|
|
9
|
+
import * as Update from 'foldkit/update';
|
|
9
10
|
import { AnchorConfig, anchorSetup, portalToContainingRoot } from '../anchor.js';
|
|
10
11
|
// NOTE: Animation imports are split across schema + update to avoid a circular
|
|
11
12
|
// dependency: animation → html → runtime → devtools → menu → animation.
|
|
@@ -255,24 +256,21 @@ export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnim
|
|
|
255
256
|
messages: [GotAnimationMessage],
|
|
256
257
|
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))))), "@foldkit/ui/menu/index.js#execute~8"),
|
|
257
258
|
});
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
Option.none(),
|
|
274
|
-
]), "@foldkit/ui/menu/index.js#delegateToAnimation");
|
|
275
|
-
};
|
|
259
|
+
const foldAnimationOutMessage = M.type().pipe(M.withReturnType(), M.tagsExhaustive({
|
|
260
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([
|
|
261
|
+
model,
|
|
262
|
+
[DetectMovementOrAnimationEnd({ id: model.id })],
|
|
263
|
+
]), "@foldkit/ui/menu/index.js#anonymous")), "@foldkit/ui/menu/index.js#StartedLeaveAnimating"),
|
|
264
|
+
TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/menu/index.js#anonymous~2")), "@foldkit/ui/menu/index.js#TransitionedOut"),
|
|
265
|
+
}));
|
|
266
|
+
const foldAnimation = Update.foldChild({
|
|
267
|
+
update: animationUpdate,
|
|
268
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/menu/index.js#read"),
|
|
269
|
+
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"),
|
|
271
|
+
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#toParentOutMessage"),
|
|
272
|
+
foldOutMessage: foldAnimationOutMessage,
|
|
273
|
+
});
|
|
276
274
|
/** Processes a menu message and returns the next model and commands. */
|
|
277
275
|
export const update = (model, message) => {
|
|
278
276
|
const maybeLockScroll = OptionExt.when(model.isModal, LockScroll());
|
|
@@ -293,7 +291,7 @@ export const update = (model, message) => {
|
|
|
293
291
|
]);
|
|
294
292
|
const openMenu = (baseModel) => {
|
|
295
293
|
if (model.isAnimated) {
|
|
296
|
-
const [nextModel, animationCommands] =
|
|
294
|
+
const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationShowed());
|
|
297
295
|
return __foldkitBrandViewResult(([
|
|
298
296
|
evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/menu/index.js#isOpen~2") }),
|
|
299
297
|
[...openCommands, ...animationCommands],
|
|
@@ -308,16 +306,16 @@ export const update = (model, message) => {
|
|
|
308
306
|
}
|
|
309
307
|
const closed = closedModel(baseModel);
|
|
310
308
|
if (model.isAnimated) {
|
|
311
|
-
const [nextModel, animationCommands] =
|
|
309
|
+
const [nextModel, animationCommands] = foldAnimation(closed, AnimationHid());
|
|
312
310
|
return __foldkitBrandViewResult(([nextModel, [...commands, ...animationCommands], maybeOutMessage]), "@foldkit/ui/menu/index.js#closeMenu");
|
|
313
311
|
}
|
|
314
312
|
return __foldkitBrandViewResult(([closed, commands, maybeOutMessage]), "@foldkit/ui/menu/index.js#closeMenu");
|
|
315
313
|
};
|
|
316
|
-
return __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tag('CompletedFocusItems', 'CompletedFocusButton', 'CompletedLockScroll', 'CompletedUnlockScroll', 'CompletedInertOthers', 'CompletedRestoreInert', 'CompletedScrollIntoView', 'CompletedClickItem', 'SuppressedSpaceScroll', 'CompletedAnchorMenu', 'CompletedPortalMenuBackdrop', () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#anonymous~
|
|
314
|
+
return __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tag('CompletedFocusItems', 'CompletedFocusButton', 'CompletedLockScroll', 'CompletedUnlockScroll', 'CompletedInertOthers', 'CompletedRestoreInert', 'CompletedScrollIntoView', 'CompletedClickItem', 'SuppressedSpaceScroll', 'CompletedAnchorMenu', 'CompletedPortalMenuBackdrop', () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#anonymous~3")), M.tagsExhaustive({
|
|
317
315
|
Opened: ({ maybeActiveItemIndex }) => __foldkitBrandViewResult((openMenu(evo(model, {
|
|
318
316
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((maybeActiveItemIndex), "@foldkit/ui/menu/index.js#maybeActiveItemIndex~2"),
|
|
319
317
|
activationTrigger: () => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
320
|
-
onNone: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/menu/index.js#onNone
|
|
318
|
+
onNone: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/menu/index.js#onNone"),
|
|
321
319
|
onSome: () => __foldkitBrandViewResult(('Keyboard'), "@foldkit/ui/menu/index.js#onSome"),
|
|
322
320
|
})), "@foldkit/ui/menu/index.js#activationTrigger"),
|
|
323
321
|
searchQuery: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#searchQuery~2"),
|
|
@@ -342,7 +340,7 @@ export const update = (model, message) => {
|
|
|
342
340
|
Option.none(),
|
|
343
341
|
]), "@foldkit/ui/menu/index.js#ActivatedItem"),
|
|
344
342
|
MovedPointerOverItem: ({ index, screenX, screenY }) => {
|
|
345
|
-
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/menu/index.js#anonymous~
|
|
343
|
+
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/menu/index.js#anonymous~4"));
|
|
346
344
|
if (isSamePosition) {
|
|
347
345
|
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/menu/index.js#MovedPointerOverItem");
|
|
348
346
|
}
|
|
@@ -376,7 +374,7 @@ export const update = (model, message) => {
|
|
|
376
374
|
evo(model, {
|
|
377
375
|
searchQuery: () => __foldkitBrandViewResult((nextSearchQuery), "@foldkit/ui/menu/index.js#searchQuery~3"),
|
|
378
376
|
searchVersion: () => __foldkitBrandViewResult((nextSearchVersion), "@foldkit/ui/menu/index.js#searchVersion~3"),
|
|
379
|
-
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/menu/index.js#anonymous~
|
|
377
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/menu/index.js#anonymous~5"))), "@foldkit/ui/menu/index.js#maybeActiveItemIndex~6"),
|
|
380
378
|
}),
|
|
381
379
|
[DelayClearSearch({ version: nextSearchVersion })],
|
|
382
380
|
Option.none(),
|
|
@@ -388,7 +386,7 @@ export const update = (model, message) => {
|
|
|
388
386
|
}
|
|
389
387
|
return __foldkitBrandViewResult(([evo(model, { searchQuery: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#searchQuery~4") }), [], Option.none()]), "@foldkit/ui/menu/index.js#CompletedDelayClearSearch");
|
|
390
388
|
},
|
|
391
|
-
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((
|
|
389
|
+
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/menu/index.js#GotAnimationMessage"),
|
|
392
390
|
PressedPointerOnButton: ({ pointerType, button, screenX, screenY, timeStamp, }) => {
|
|
393
391
|
const withPointerType = evo(model, {
|
|
394
392
|
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/menu/index.js#maybeLastButtonPointerType~2"),
|
|
@@ -421,8 +419,8 @@ export const update = (model, message) => {
|
|
|
421
419
|
const isMovementBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((Math.abs(screenX - origin.screenX) <
|
|
422
420
|
POINTER_MOVEMENT_THRESHOLD_PIXELS &&
|
|
423
421
|
Math.abs(screenY - origin.screenY) <
|
|
424
|
-
POINTER_MOVEMENT_THRESHOLD_PIXELS), "@foldkit/ui/menu/index.js#anonymous~
|
|
425
|
-
const isHoldTimeBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((timeStamp - origin.timeStamp < POINTER_HOLD_THRESHOLD_MILLISECONDS), "@foldkit/ui/menu/index.js#anonymous~
|
|
422
|
+
POINTER_MOVEMENT_THRESHOLD_PIXELS), "@foldkit/ui/menu/index.js#anonymous~6"));
|
|
423
|
+
const isHoldTimeBelowThreshold = Option.exists(model.maybePointerOrigin, origin => __foldkitBrandViewResult((timeStamp - origin.timeStamp < POINTER_HOLD_THRESHOLD_MILLISECONDS), "@foldkit/ui/menu/index.js#anonymous~7"));
|
|
426
424
|
if (hasNoOrigin ||
|
|
427
425
|
isMovementBelowThreshold ||
|
|
428
426
|
isHoldTimeBelowThreshold ||
|
|
@@ -462,16 +460,16 @@ export const update = (model, message) => {
|
|
|
462
460
|
* Exposed so Scene tests can call
|
|
463
461
|
* `Scene.Mount.resolve(AnchorMenu, CompletedAnchorMenu())`. */
|
|
464
462
|
export const AnchorMenu = Mount.define('AnchorMenu', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorMenu)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
465
|
-
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup({ buttonId, anchor, focusAfterPosition: true })(element)), "@foldkit/ui/menu/index.js#anonymous~
|
|
466
|
-
return __foldkitBrandViewResult((CompletedAnchorMenu()), "@foldkit/ui/menu/index.js#anonymous~
|
|
467
|
-
})), "@foldkit/ui/menu/index.js#anonymous~
|
|
463
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup({ buttonId, anchor, focusAfterPosition: true })(element)), "@foldkit/ui/menu/index.js#anonymous~11")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~12"));
|
|
464
|
+
return __foldkitBrandViewResult((CompletedAnchorMenu()), "@foldkit/ui/menu/index.js#anonymous~10");
|
|
465
|
+
})), "@foldkit/ui/menu/index.js#anonymous~9")), "@foldkit/ui/menu/index.js#anonymous~8"));
|
|
468
466
|
/** The backdrop-portaling Mount this Menu renders. Exposed so Scene tests can
|
|
469
467
|
* call `Scene.Mount.resolve(PortalMenuBackdrop, CompletedPortalMenuBackdrop())` to
|
|
470
468
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
471
469
|
export const PortalMenuBackdrop = Mount.define('PortalMenuBackdrop', CompletedPortalMenuBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
472
|
-
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/menu/index.js#anonymous~
|
|
473
|
-
return __foldkitBrandViewResult((CompletedPortalMenuBackdrop()), "@foldkit/ui/menu/index.js#anonymous~
|
|
474
|
-
})), "@foldkit/ui/menu/index.js#anonymous~
|
|
470
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/menu/index.js#anonymous~15")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~16"));
|
|
471
|
+
return __foldkitBrandViewResult((CompletedPortalMenuBackdrop()), "@foldkit/ui/menu/index.js#anonymous~14");
|
|
472
|
+
})), "@foldkit/ui/menu/index.js#anonymous~13"));
|
|
475
473
|
/** Programmatically opens the menu, updating the model and returning
|
|
476
474
|
* focus and modal commands. Use this in domain-event handlers to open the menu. */
|
|
477
475
|
export const open = (model) => __foldkitBrandViewResult((update(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/menu/index.js#open");
|
|
@@ -490,7 +488,7 @@ const internalView = () =>
|
|
|
490
488
|
__foldkitBrandViewResult((menuViewImpl), "@foldkit/ui/menu/index.js#internalView");
|
|
491
489
|
const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
492
490
|
const { id, isOpen, animation: { transitionState }, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, } = model;
|
|
493
|
-
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~
|
|
491
|
+
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~18"), isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor = {}, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
494
492
|
const dispatchSelectedItem = (item, index) => __foldkitBrandViewResult((SelectedItem({ index, item })), "@foldkit/ui/menu/index.js#dispatchSelectedItem");
|
|
495
493
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
496
494
|
const isVisible = isOpen || isLeaving;
|
|
@@ -498,26 +496,26 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
498
496
|
h.DataAttribute('closed', ''),
|
|
499
497
|
h.DataAttribute('enter', ''),
|
|
500
498
|
h.DataAttribute('transition', ''),
|
|
501
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
499
|
+
]), "@foldkit/ui/menu/index.js#anonymous~19")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
502
500
|
h.DataAttribute('enter', ''),
|
|
503
501
|
h.DataAttribute('transition', ''),
|
|
504
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
502
|
+
]), "@foldkit/ui/menu/index.js#anonymous~20")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
505
503
|
h.DataAttribute('leave', ''),
|
|
506
504
|
h.DataAttribute('transition', ''),
|
|
507
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
505
|
+
]), "@foldkit/ui/menu/index.js#anonymous~21")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
508
506
|
h.DataAttribute('closed', ''),
|
|
509
507
|
h.DataAttribute('leave', ''),
|
|
510
508
|
h.DataAttribute('transition', ''),
|
|
511
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
509
|
+
]), "@foldkit/ui/menu/index.js#anonymous~22")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#anonymous~23")));
|
|
512
510
|
const isDisabled = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
513
|
-
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~
|
|
511
|
+
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~24")))), "@foldkit/ui/menu/index.js#isDisabled");
|
|
514
512
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(0, 1);
|
|
515
513
|
const lastEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(items.length - 1, -1);
|
|
516
514
|
const handleButtonKeyDown = (key) => {
|
|
517
515
|
if (isOpen) {
|
|
518
516
|
return __foldkitBrandViewResult((handleItemsKeyDown(key)), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
519
517
|
}
|
|
520
|
-
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Opened({ maybeActiveItemIndex: Option.some(firstEnabledIndex) }))), "@foldkit/ui/menu/index.js#anonymous~
|
|
518
|
+
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Opened({ maybeActiveItemIndex: Option.some(firstEnabledIndex) }))), "@foldkit/ui/menu/index.js#anonymous~25")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Opened({ maybeActiveItemIndex: Option.some(lastEnabledIndex) }))), "@foldkit/ui/menu/index.js#anonymous~26")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~27")))), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
521
519
|
};
|
|
522
520
|
const handleButtonPointerDown = (pointerType, button, screenX, screenY, timeStamp) => __foldkitBrandViewResult((Option.some(PressedPointerOnButton({
|
|
523
521
|
pointerType,
|
|
@@ -527,7 +525,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
527
525
|
timeStamp,
|
|
528
526
|
}))), "@foldkit/ui/menu/index.js#handleButtonPointerDown");
|
|
529
527
|
const handleButtonClick = () => {
|
|
530
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~
|
|
528
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~28"));
|
|
531
529
|
if (isMouse) {
|
|
532
530
|
return __foldkitBrandViewResult((IgnoredMouseClick()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
533
531
|
}
|
|
@@ -539,18 +537,18 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
539
537
|
}
|
|
540
538
|
};
|
|
541
539
|
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', SuppressedSpaceScroll())), "@foldkit/ui/menu/index.js#handleSpaceKeyUp");
|
|
542
|
-
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~
|
|
540
|
+
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~29")), isDisabled);
|
|
543
541
|
const searchForKey = (key) => {
|
|
544
542
|
const nextQuery = searchQuery + key;
|
|
545
543
|
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isDisabled, itemToSearchText, Str.isNonEmpty(searchQuery));
|
|
546
544
|
return __foldkitBrandViewResult((Option.some(Searched({ key, maybeTargetIndex }))), "@foldkit/ui/menu/index.js#searchForKey");
|
|
547
545
|
};
|
|
548
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Closed())), "@foldkit/ui/menu/index.js#anonymous~
|
|
546
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Closed())), "@foldkit/ui/menu/index.js#anonymous~30")), M.when('Enter', () => __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~32"))), "@foldkit/ui/menu/index.js#anonymous~31")), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
549
547
|
? searchForKey(' ')
|
|
550
|
-
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~
|
|
548
|
+
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~34"))), "@foldkit/ui/menu/index.js#anonymous~33")), M.whenOr('ArrowDown', 'ArrowUp', 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
551
549
|
index: resolveActiveIndex(key),
|
|
552
550
|
activationTrigger: 'Keyboard',
|
|
553
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
551
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~35")), M.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/menu/index.js#anonymous~36")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~37")))), "@foldkit/ui/menu/index.js#handleItemsKeyDown");
|
|
554
552
|
const handleItemsPointerUp = (screenX, screenY, pointerType, timeStamp) => __foldkitBrandViewResult((OptionExt.when(pointerType === 'mouse', ReleasedPointerOnItems({ screenX, screenY, timeStamp }))), "@foldkit/ui/menu/index.js#handleItemsPointerUp");
|
|
555
553
|
const resolveButtonLabel = () => {
|
|
556
554
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
@@ -589,7 +587,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
589
587
|
...buttonAttributes,
|
|
590
588
|
];
|
|
591
589
|
const maybeActiveDescendant = Option.match(maybeActiveItemIndex, {
|
|
592
|
-
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#onNone~
|
|
590
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#onNone~2"),
|
|
593
591
|
onSome: index => __foldkitBrandViewResult(([h.AriaActiveDescendant(itemId(id, index))]), "@foldkit/ui/menu/index.js#onSome~2"),
|
|
594
592
|
});
|
|
595
593
|
const anchorAttributes = [
|
|
@@ -616,7 +614,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
616
614
|
...itemsAttributes,
|
|
617
615
|
];
|
|
618
616
|
const menuItems = Array.map(items, (item, index) => {
|
|
619
|
-
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~
|
|
617
|
+
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~39"));
|
|
620
618
|
const isDisabledItem = isDisabled(index);
|
|
621
619
|
const itemConfig = itemToConfig(item, {
|
|
622
620
|
isActive: isActiveItem,
|
|
@@ -636,27 +634,27 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
636
634
|
...(isActiveItem
|
|
637
635
|
? []
|
|
638
636
|
: [
|
|
639
|
-
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({ index, screenX, screenY }))), "@foldkit/ui/menu/index.js#anonymous~
|
|
637
|
+
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({ index, screenX, screenY }))), "@foldkit/ui/menu/index.js#anonymous~40")),
|
|
640
638
|
]),
|
|
641
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~
|
|
639
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~41")),
|
|
642
640
|
]
|
|
643
641
|
: []),
|
|
644
642
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
645
|
-
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~
|
|
643
|
+
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~38");
|
|
646
644
|
});
|
|
647
645
|
const renderGroupedItems = () => {
|
|
648
646
|
if (!itemGroupKey) {
|
|
649
647
|
return __foldkitBrandViewResult((menuItems), "@foldkit/ui/menu/index.js#renderGroupedItems");
|
|
650
648
|
}
|
|
651
649
|
const segments = groupContiguous(menuItems, (_, index) => __foldkitBrandViewResult((Array.get(items, index).pipe(Option.match({
|
|
652
|
-
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#onNone~
|
|
650
|
+
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#onNone~3"),
|
|
653
651
|
onSome: item => __foldkitBrandViewResult((itemGroupKey(item, index)), "@foldkit/ui/menu/index.js#onSome~3"),
|
|
654
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
652
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~42"));
|
|
655
653
|
return __foldkitBrandViewResult((Array.flatMap(segments, (segment, segmentIndex) => {
|
|
656
654
|
const maybeHeading = Option.fromNullishOr(groupToHeading && groupToHeading(segment.key));
|
|
657
655
|
const headingId = `${id}-heading-${segment.key}`;
|
|
658
656
|
const headingElement = Option.match(maybeHeading, {
|
|
659
|
-
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#onNone~
|
|
657
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#onNone~4"),
|
|
660
658
|
onSome: heading => __foldkitBrandViewResult(([
|
|
661
659
|
h.keyed('div')(headingId, [
|
|
662
660
|
h.Id(headingId),
|
|
@@ -685,7 +683,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
685
683
|
]),
|
|
686
684
|
]
|
|
687
685
|
: [];
|
|
688
|
-
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~
|
|
686
|
+
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~43");
|
|
689
687
|
})), "@foldkit/ui/menu/index.js#renderGroupedItems");
|
|
690
688
|
};
|
|
691
689
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
@@ -720,7 +718,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
720
718
|
buttonContent,
|
|
721
719
|
]),
|
|
722
720
|
...(isVisible ? visibleContent : []),
|
|
723
|
-
])), "@foldkit/ui/menu/index.js#anonymous~
|
|
721
|
+
])), "@foldkit/ui/menu/index.js#anonymous~17");
|
|
724
722
|
});
|
|
725
723
|
/** Pairs the menu's `view` and `update` (and programmatic helpers)
|
|
726
724
|
* behind a single Item-typed entry point. Declaring the menu once at
|
|
@@ -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,EACZ,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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,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AIjC;;;;;;;;;;;4BAW4B;AAC5B,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACrC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACvC,SAAS,EAAE,OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,qFAAqF;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,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF,6EAA6E;AAC7E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YATP,YAAY;YACZ,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;iBACvB,OAAO;oBACJ,MAAM;gBACV,MAAM;qBACD,MAAM;GAgKxB,CAAA"}
|
package/dist/popover/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { m } from 'foldkit/message';
|
|
|
7
7
|
import * as Mount from 'foldkit/mount';
|
|
8
8
|
import { evo } from 'foldkit/struct';
|
|
9
9
|
import { defineView } from 'foldkit/submodel';
|
|
10
|
+
import * as Update from 'foldkit/update';
|
|
10
11
|
import { AnchorConfig, anchorSetup, portalToContainingRoot } from '../anchor.js';
|
|
11
12
|
// NOTE: Animation imports are split across schema + update to avoid a circular
|
|
12
13
|
// dependency: animation → html → runtime → devtools → popover → animation.
|
|
@@ -152,24 +153,21 @@ export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnim
|
|
|
152
153
|
messages: [GotAnimationMessage],
|
|
153
154
|
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(panelSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))))), "@foldkit/ui/popover/index.js#execute~5"),
|
|
154
155
|
});
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Option.none(),
|
|
171
|
-
]), "@foldkit/ui/popover/index.js#delegateToAnimation");
|
|
172
|
-
};
|
|
156
|
+
const foldAnimationOutMessage = M.type().pipe(M.withReturnType(), M.tagsExhaustive({
|
|
157
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([
|
|
158
|
+
model,
|
|
159
|
+
[DetectMovementOrAnimationEnd({ id: model.id })],
|
|
160
|
+
]), "@foldkit/ui/popover/index.js#anonymous")), "@foldkit/ui/popover/index.js#StartedLeaveAnimating"),
|
|
161
|
+
TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/popover/index.js#anonymous~2")), "@foldkit/ui/popover/index.js#TransitionedOut"),
|
|
162
|
+
}));
|
|
163
|
+
const foldAnimation = Update.foldChild({
|
|
164
|
+
update: animationUpdate,
|
|
165
|
+
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/popover/index.js#read"),
|
|
166
|
+
write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/popover/index.js#animation") })), "@foldkit/ui/popover/index.js#write"),
|
|
167
|
+
toParentMessage: message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/popover/index.js#toParentMessage"),
|
|
168
|
+
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#toParentOutMessage"),
|
|
169
|
+
foldOutMessage: foldAnimationOutMessage,
|
|
170
|
+
});
|
|
173
171
|
/** Processes a popover message and returns the next model, commands, and optional OutMessage. */
|
|
174
172
|
export const update = (model, message) => {
|
|
175
173
|
const maybeLockScroll = OptionExt.when(model.isModal, LockScroll());
|
|
@@ -188,7 +186,7 @@ export const update = (model, message) => {
|
|
|
188
186
|
]);
|
|
189
187
|
const openPopover = (baseModel) => {
|
|
190
188
|
if (model.isAnimated) {
|
|
191
|
-
const [nextModel, animationCommands] =
|
|
189
|
+
const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationShowed());
|
|
192
190
|
return __foldkitBrandViewResult(([
|
|
193
191
|
evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~2") }),
|
|
194
192
|
[...openCommands, ...animationCommands],
|
|
@@ -207,7 +205,7 @@ export const update = (model, message) => {
|
|
|
207
205
|
}
|
|
208
206
|
const closed = closedModel(baseModel);
|
|
209
207
|
if (model.isAnimated) {
|
|
210
|
-
const [nextModel, animationCommands] =
|
|
208
|
+
const [nextModel, animationCommands] = foldAnimation(closed, AnimationHid());
|
|
211
209
|
return __foldkitBrandViewResult(([
|
|
212
210
|
nextModel,
|
|
213
211
|
[...commands, ...animationCommands],
|
|
@@ -244,7 +242,7 @@ export const update = (model, message) => {
|
|
|
244
242
|
}
|
|
245
243
|
return __foldkitBrandViewResult((openPopover(withPointerType)), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
|
|
246
244
|
},
|
|
247
|
-
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((
|
|
245
|
+
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/popover/index.js#GotAnimationMessage"),
|
|
248
246
|
CompletedFocusPanel: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusPanel"),
|
|
249
247
|
CompletedFocusButton: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusButton"),
|
|
250
248
|
CompletedLockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedLockScroll"),
|
|
@@ -275,16 +273,16 @@ export const AnchorPopover = Mount.define('AnchorPopover', {
|
|
|
275
273
|
interceptTab: false,
|
|
276
274
|
focusAfterPosition: true,
|
|
277
275
|
...(focusSelector !== undefined && { focusSelector }),
|
|
278
|
-
})(element)), "@foldkit/ui/popover/index.js#anonymous~
|
|
279
|
-
return __foldkitBrandViewResult((CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~
|
|
280
|
-
})), "@foldkit/ui/popover/index.js#anonymous~
|
|
276
|
+
})(element)), "@foldkit/ui/popover/index.js#anonymous~6")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~7"));
|
|
277
|
+
return __foldkitBrandViewResult((CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~5");
|
|
278
|
+
})), "@foldkit/ui/popover/index.js#anonymous~4")), "@foldkit/ui/popover/index.js#anonymous~3"));
|
|
281
279
|
/** The backdrop-portaling Mount this Popover renders. Exposed so Scene tests can
|
|
282
280
|
* call `Scene.Mount.resolve(PortalPopoverBackdrop, CompletedPortalPopoverBackdrop())` to
|
|
283
281
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
284
282
|
export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop', CompletedPortalPopoverBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
285
|
-
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~
|
|
286
|
-
return __foldkitBrandViewResult((CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~
|
|
287
|
-
})), "@foldkit/ui/popover/index.js#anonymous~
|
|
283
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~10")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~11"));
|
|
284
|
+
return __foldkitBrandViewResult((CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~9");
|
|
285
|
+
})), "@foldkit/ui/popover/index.js#anonymous~8"));
|
|
288
286
|
/** Programmatically opens the popover, updating the model and returning
|
|
289
287
|
* focus and modal commands plus an `Opened` OutMessage. */
|
|
290
288
|
export const open = (model) => __foldkitBrandViewResult((update(model, RequestedOpen())), "@foldkit/ui/popover/index.js#open");
|
|
@@ -302,21 +300,21 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
302
300
|
h.DataAttribute('closed', ''),
|
|
303
301
|
h.DataAttribute('enter', ''),
|
|
304
302
|
h.DataAttribute('transition', ''),
|
|
305
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
303
|
+
]), "@foldkit/ui/popover/index.js#anonymous~13")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
306
304
|
h.DataAttribute('enter', ''),
|
|
307
305
|
h.DataAttribute('transition', ''),
|
|
308
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
306
|
+
]), "@foldkit/ui/popover/index.js#anonymous~14")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
309
307
|
h.DataAttribute('leave', ''),
|
|
310
308
|
h.DataAttribute('transition', ''),
|
|
311
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
309
|
+
]), "@foldkit/ui/popover/index.js#anonymous~15")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
312
310
|
h.DataAttribute('closed', ''),
|
|
313
311
|
h.DataAttribute('leave', ''),
|
|
314
312
|
h.DataAttribute('transition', ''),
|
|
315
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
316
|
-
const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? RequestedClose() : RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~
|
|
313
|
+
]), "@foldkit/ui/popover/index.js#anonymous~16")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#anonymous~17")));
|
|
314
|
+
const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? RequestedClose() : RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~18")), M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~19")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~20")))), "@foldkit/ui/popover/index.js#handleButtonKeyDown");
|
|
317
315
|
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/popover/index.js#handleButtonPointerDown");
|
|
318
316
|
const handleButtonClick = () => {
|
|
319
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~
|
|
317
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~21"));
|
|
320
318
|
if (isMouse) {
|
|
321
319
|
return __foldkitBrandViewResult((IgnoredMouseClick()), "@foldkit/ui/popover/index.js#handleButtonClick");
|
|
322
320
|
}
|
|
@@ -328,7 +326,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
328
326
|
}
|
|
329
327
|
};
|
|
330
328
|
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', SuppressedSpaceScroll())), "@foldkit/ui/popover/index.js#handleSpaceKeyUp");
|
|
331
|
-
const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~
|
|
329
|
+
const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~22")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~23")))), "@foldkit/ui/popover/index.js#handlePanelKeyDown");
|
|
332
330
|
const resolveButtonLabel = () => {
|
|
333
331
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
334
332
|
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
|
|
@@ -388,5 +386,5 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
388
386
|
panel: childAttributes(panelAttributes),
|
|
389
387
|
backdrop: childAttributes(backdropAttributes),
|
|
390
388
|
isVisible,
|
|
391
|
-
})), "@foldkit/ui/popover/index.js#anonymous~
|
|
389
|
+
})), "@foldkit/ui/popover/index.js#anonymous~12");
|
|
392
390
|
});
|