@foldkit/ui 0.153.0 → 0.154.0-canary.2d85d5ae9536
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anchor/anchor.d.ts +14 -1
- package/dist/anchor/anchor.d.ts.map +1 -1
- package/dist/anchor/anchor.js +58 -5
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +91 -78
- package/dist/dialog/index.d.ts +27 -7
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +66 -39
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +46 -39
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +39 -32
- package/dist/popover/index.d.ts +15 -0
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +46 -26
- 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/test/apps/disabledButton.d.ts +5 -2
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -11
- package/package.json +4 -4
package/dist/menu/index.js
CHANGED
|
@@ -395,21 +395,28 @@ export const update = (model, message) => {
|
|
|
395
395
|
*
|
|
396
396
|
* Exposed so Scene tests can call
|
|
397
397
|
* `Scene.Mount.resolve(AnchorMenu, Message.CompletedAnchorMenu())`. */
|
|
398
|
-
export const AnchorMenu = Mount.define('AnchorMenu', {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
398
|
+
export const AnchorMenu = Mount.define('AnchorMenu', {
|
|
399
|
+
args: { buttonId: S.String, anchor: AnchorConfig },
|
|
400
|
+
messages: [Message.CompletedAnchorMenu],
|
|
401
|
+
execute: ({ element, buttonId, anchor }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
402
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
403
|
+
buttonId,
|
|
404
|
+
anchor,
|
|
405
|
+
focusAfterPosition: true,
|
|
406
|
+
})), "@foldkit/ui/menu/index.js#anonymous~13")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~14"));
|
|
407
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorMenu()), "@foldkit/ui/menu/index.js#anonymous~12");
|
|
408
|
+
})), "@foldkit/ui/menu/index.js#execute~9"),
|
|
409
|
+
});
|
|
406
410
|
/** The backdrop-portaling Mount this Menu renders. Exposed so Scene tests can
|
|
407
411
|
* call `Scene.Mount.resolve(PortalMenuBackdrop, Message.CompletedPortalMenuBackdrop())` to
|
|
408
412
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
409
|
-
export const PortalMenuBackdrop = Mount.define('PortalMenuBackdrop',
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
+
export const PortalMenuBackdrop = Mount.define('PortalMenuBackdrop', {
|
|
414
|
+
messages: [Message.CompletedPortalMenuBackdrop],
|
|
415
|
+
execute: ({ element }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
416
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/menu/index.js#anonymous~16")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/menu/index.js#anonymous~17"));
|
|
417
|
+
return __foldkitBrandViewResult((Message.CompletedPortalMenuBackdrop()), "@foldkit/ui/menu/index.js#anonymous~15");
|
|
418
|
+
})), "@foldkit/ui/menu/index.js#execute~10"),
|
|
419
|
+
});
|
|
413
420
|
/** Programmatically opens the Menu, updating the Model and returning focus and
|
|
414
421
|
* modal Commands. Use this in domain-event handlers. */
|
|
415
422
|
export const open = (model) => __foldkitBrandViewResult((update(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/menu/index.js#open");
|
|
@@ -428,7 +435,7 @@ const internalView = () =>
|
|
|
428
435
|
__foldkitBrandViewResult((menuViewImpl), "@foldkit/ui/menu/index.js#internalView");
|
|
429
436
|
const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
430
437
|
const { id, isOpen, animation: { transitionState }, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, } = model;
|
|
431
|
-
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~
|
|
438
|
+
const { items, itemToConfig, isItemDisabled, itemToSearchText = (item) => __foldkitBrandViewResult((item), "@foldkit/ui/menu/index.js#anonymous~19"), isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor = {}, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
432
439
|
const dispatchSelectedItem = (item, index) => __foldkitBrandViewResult((Message.SelectedItem({ index, item })), "@foldkit/ui/menu/index.js#dispatchSelectedItem");
|
|
433
440
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
434
441
|
const isVisible = isOpen || isLeaving;
|
|
@@ -436,19 +443,19 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
436
443
|
h.DataAttribute('closed', ''),
|
|
437
444
|
h.DataAttribute('enter', ''),
|
|
438
445
|
h.DataAttribute('transition', ''),
|
|
439
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
446
|
+
]), "@foldkit/ui/menu/index.js#anonymous~20")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
440
447
|
h.DataAttribute('enter', ''),
|
|
441
448
|
h.DataAttribute('transition', ''),
|
|
442
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
449
|
+
]), "@foldkit/ui/menu/index.js#anonymous~21")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
443
450
|
h.DataAttribute('leave', ''),
|
|
444
451
|
h.DataAttribute('transition', ''),
|
|
445
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
452
|
+
]), "@foldkit/ui/menu/index.js#anonymous~22")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
446
453
|
h.DataAttribute('closed', ''),
|
|
447
454
|
h.DataAttribute('leave', ''),
|
|
448
455
|
h.DataAttribute('transition', ''),
|
|
449
|
-
]), "@foldkit/ui/menu/index.js#anonymous~
|
|
456
|
+
]), "@foldkit/ui/menu/index.js#anonymous~23")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/menu/index.js#anonymous~24")));
|
|
450
457
|
const isDisabled = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
451
|
-
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~
|
|
458
|
+
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/menu/index.js#anonymous~25")))), "@foldkit/ui/menu/index.js#isDisabled");
|
|
452
459
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(0, 1);
|
|
453
460
|
const lastEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabled)(items.length - 1, -1);
|
|
454
461
|
const handleButtonKeyDown = (key) => {
|
|
@@ -457,9 +464,9 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
457
464
|
}
|
|
458
465
|
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
459
466
|
maybeActiveItemIndex: Option.some(firstEnabledIndex),
|
|
460
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
467
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~26")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
461
468
|
maybeActiveItemIndex: Option.some(lastEnabledIndex),
|
|
462
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
469
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~27")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~28")))), "@foldkit/ui/menu/index.js#handleButtonKeyDown");
|
|
463
470
|
};
|
|
464
471
|
const handleButtonPointerDown = (pointerType, button, screenX, screenY, timeStamp) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({
|
|
465
472
|
pointerType,
|
|
@@ -469,7 +476,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
469
476
|
timeStamp,
|
|
470
477
|
}))), "@foldkit/ui/menu/index.js#handleButtonPointerDown");
|
|
471
478
|
const handleButtonClick = () => {
|
|
472
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~
|
|
479
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/menu/index.js#anonymous~29"));
|
|
473
480
|
if (isMouse) {
|
|
474
481
|
return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/menu/index.js#handleButtonClick");
|
|
475
482
|
}
|
|
@@ -481,18 +488,18 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
481
488
|
}
|
|
482
489
|
};
|
|
483
490
|
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/menu/index.js#handleSpaceKeyUp");
|
|
484
|
-
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~
|
|
491
|
+
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((0), "@foldkit/ui/menu/index.js#anonymous~30")), isDisabled);
|
|
485
492
|
const searchForKey = (key) => {
|
|
486
493
|
const nextQuery = searchQuery + key;
|
|
487
494
|
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isDisabled, itemToSearchText, Str.isNonEmpty(searchQuery));
|
|
488
495
|
return __foldkitBrandViewResult((Option.some(Message.Searched({ key, maybeTargetIndex }))), "@foldkit/ui/menu/index.js#searchForKey");
|
|
489
496
|
};
|
|
490
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/menu/index.js#anonymous~
|
|
497
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/menu/index.js#anonymous~31")), M.when('Enter', () => __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~33"))), "@foldkit/ui/menu/index.js#anonymous~32")), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
491
498
|
? searchForKey(' ')
|
|
492
|
-
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~
|
|
499
|
+
: Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/menu/index.js#anonymous~35"))), "@foldkit/ui/menu/index.js#anonymous~34")), M.whenOr('ArrowDown', 'ArrowUp', 'Home', 'End', 'PageUp', 'PageDown', () => __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
493
500
|
index: resolveActiveIndex(key),
|
|
494
501
|
activationTrigger: 'Keyboard',
|
|
495
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
502
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~36")), M.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/menu/index.js#anonymous~37")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/menu/index.js#anonymous~38")))), "@foldkit/ui/menu/index.js#handleItemsKeyDown");
|
|
496
503
|
const handleItemsPointerUp = (screenX, screenY, pointerType, timeStamp) => __foldkitBrandViewResult((OptionExt.when(pointerType === 'mouse', Message.ReleasedPointerOnItems({ screenX, screenY, timeStamp }))), "@foldkit/ui/menu/index.js#handleItemsPointerUp");
|
|
497
504
|
const resolveButtonLabel = () => {
|
|
498
505
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
@@ -558,7 +565,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
558
565
|
...itemsAttributes,
|
|
559
566
|
];
|
|
560
567
|
const menuItems = Array.map(items, (item, index) => {
|
|
561
|
-
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~
|
|
568
|
+
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/menu/index.js#anonymous~40"));
|
|
562
569
|
const isDisabledItem = isDisabled(index);
|
|
563
570
|
const itemConfig = itemToConfig(item, {
|
|
564
571
|
isActive: isActiveItem,
|
|
@@ -582,13 +589,13 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
582
589
|
index,
|
|
583
590
|
screenX,
|
|
584
591
|
screenY,
|
|
585
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
592
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~41")),
|
|
586
593
|
]),
|
|
587
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~
|
|
594
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/menu/index.js#anonymous~42")),
|
|
588
595
|
]
|
|
589
596
|
: []),
|
|
590
597
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
591
|
-
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~
|
|
598
|
+
], [itemConfig.content])), "@foldkit/ui/menu/index.js#anonymous~39");
|
|
592
599
|
});
|
|
593
600
|
const renderGroupedItems = () => {
|
|
594
601
|
if (!itemGroupKey) {
|
|
@@ -597,7 +604,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
597
604
|
const segments = groupContiguous(menuItems, (_, index) => __foldkitBrandViewResult((Array.get(items, index).pipe(Option.match({
|
|
598
605
|
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/menu/index.js#onNone~3"),
|
|
599
606
|
onSome: item => __foldkitBrandViewResult((itemGroupKey(item, index)), "@foldkit/ui/menu/index.js#onSome~3"),
|
|
600
|
-
}))), "@foldkit/ui/menu/index.js#anonymous~
|
|
607
|
+
}))), "@foldkit/ui/menu/index.js#anonymous~43"));
|
|
601
608
|
return __foldkitBrandViewResult((Array.flatMap(segments, (segment, segmentIndex) => {
|
|
602
609
|
const maybeHeading = Option.fromNullishOr(groupToHeading && groupToHeading(segment.key));
|
|
603
610
|
const headingId = `${id}-heading-${segment.key}`;
|
|
@@ -631,7 +638,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
631
638
|
]),
|
|
632
639
|
]
|
|
633
640
|
: [];
|
|
634
|
-
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~
|
|
641
|
+
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/menu/index.js#anonymous~44");
|
|
635
642
|
})), "@foldkit/ui/menu/index.js#renderGroupedItems");
|
|
636
643
|
};
|
|
637
644
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
@@ -666,7 +673,7 @@ const menuViewImpl = defineView((model, viewInputs, h) => {
|
|
|
666
673
|
buttonContent,
|
|
667
674
|
]),
|
|
668
675
|
...(isVisible ? visibleContent : []),
|
|
669
|
-
])), "@foldkit/ui/menu/index.js#anonymous~
|
|
676
|
+
])), "@foldkit/ui/menu/index.js#anonymous~18");
|
|
670
677
|
});
|
|
671
678
|
/** Pairs the menu's `view` and `update` (and programmatic helpers)
|
|
672
679
|
* behind a single Item-typed entry point. Declaring the menu once at
|
package/dist/popover/index.d.ts
CHANGED
|
@@ -78,6 +78,11 @@ export declare const init: (config: InitConfig) => Model;
|
|
|
78
78
|
* trigger via a native `<label for={Popover.buttonId(id)}>` or an
|
|
79
79
|
* `aria-labelledby` reference. */
|
|
80
80
|
export declare const buttonId: (id: string) => string;
|
|
81
|
+
/** Returns the bare DOM id of the popover arrow, derived from the popover's
|
|
82
|
+
* base id. The `arrow` bundle already carries this id, so reach for this when
|
|
83
|
+
* you need the id on its own, such as asserting the panel Mount's `arrowId`
|
|
84
|
+
* argument in a Scene test. */
|
|
85
|
+
export declare const arrowId: (id: string) => string;
|
|
81
86
|
type UpdateReturn = Update.ReturnWithOutMessage<Model, Message, OutMessage>;
|
|
82
87
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
83
88
|
export declare const LockScroll: Command.CommandDefinitionNoArgs<"LockScroll", Effect.Effect<{
|
|
@@ -209,6 +214,8 @@ export declare const AnchorPopover: Mount.MountDefinitionWithArgs<"AnchorPopover
|
|
|
209
214
|
readonly isPlacementLocked: S.optional<S.Boolean>;
|
|
210
215
|
}>;
|
|
211
216
|
focusSelector: S.optional<S.String>;
|
|
217
|
+
arrowId: S.optional<S.String>;
|
|
218
|
+
arrowPadding: S.optional<S.Number>;
|
|
212
219
|
}, {
|
|
213
220
|
readonly _tag: "CompletedAnchorPopover";
|
|
214
221
|
}>;
|
|
@@ -234,6 +241,11 @@ export declare const close: (model: Model) => UpdateReturn;
|
|
|
234
241
|
* - `backdrop`: attribute bundle for the modal backdrop. Includes the
|
|
235
242
|
* portal Mount that moves the backdrop to document.body. The
|
|
236
243
|
* backdrop's OnClick closes the popover.
|
|
244
|
+
* - `arrow`: attribute bundle for an arrow element inside the panel.
|
|
245
|
+
* Carries the id the anchor Mount resolves and hides the element from
|
|
246
|
+
* assistive technology. Spread it onto your own element and place it
|
|
247
|
+
* with the `--arrow-x` and `--arrow-y` custom properties Anchor
|
|
248
|
+
* publishes on the panel. Nothing renders until you do.
|
|
237
249
|
* - `isVisible`: derived from `isOpen` and the Animation
|
|
238
250
|
* `transitionState`. The consumer renders the panel + backdrop only
|
|
239
251
|
* while this is true. */
|
|
@@ -241,6 +253,7 @@ export type RenderInfo = Readonly<{
|
|
|
241
253
|
button: ReadonlyArray<ChildAttribute>;
|
|
242
254
|
panel: ReadonlyArray<ChildAttribute>;
|
|
243
255
|
backdrop: ReadonlyArray<ChildAttribute>;
|
|
256
|
+
arrow: ReadonlyArray<ChildAttribute>;
|
|
244
257
|
isVisible: boolean;
|
|
245
258
|
}>;
|
|
246
259
|
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */
|
|
@@ -249,6 +262,7 @@ export type ViewInputs = Readonly<{
|
|
|
249
262
|
toView: (render: RenderInfo) => Html;
|
|
250
263
|
isDisabled?: boolean;
|
|
251
264
|
focusSelector?: string;
|
|
265
|
+
arrowPadding?: number;
|
|
252
266
|
ariaLabel?: string;
|
|
253
267
|
ariaLabelledBy?: string;
|
|
254
268
|
}>;
|
|
@@ -311,6 +325,7 @@ export declare const view: import("foldkit/submodel").View<{
|
|
|
311
325
|
toView: (render: RenderInfo) => Html;
|
|
312
326
|
isDisabled?: boolean;
|
|
313
327
|
focusSelector?: string;
|
|
328
|
+
arrowPadding?: number;
|
|
314
329
|
ariaLabel?: string;
|
|
315
330
|
ariaLabelledBy?: string;
|
|
316
331
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,CAAC,EAEZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAE9E,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AAGtC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAExC,OAAO,EACL,YAAY,EAGb,MAAM,oBAAoB,CAAA;AAgB3B,qGAAqG;AACrG,eAAO,MAAM,KAAK;;;;;;;;;;;;EAQhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,+DAA+D;AAC/D,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBlB,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAA;AAC7D,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAA;AAC/D,MAAM,MAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAY,CAAC,IAAI,CAAA;AAC3D,MAAM,MAAM,sBAAsB,GAAG,OAAO,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAA;AAC/E,MAAM,MAAM,iBAAiB,GAAG,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAA;AACrE,MAAM,MAAM,qBAAqB,GAAG,OAAO,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAA;AAE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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAVP,YAAY;YACZ,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;iBACvB,OAAO;oBACJ,MAAM;mBACP,MAAM;gBACT,MAAM;qBACD,MAAM;GA0KxB,CAAA"}
|
package/dist/popover/index.js
CHANGED
|
@@ -81,6 +81,11 @@ const panelSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-panel`
|
|
|
81
81
|
* trigger via a native `<label for={Popover.buttonId(id)}>` or an
|
|
82
82
|
* `aria-labelledby` reference. */
|
|
83
83
|
export const buttonId = (id) => __foldkitBrandViewResult((`${id}-button`), "@foldkit/ui/popover/index.js#buttonId");
|
|
84
|
+
/** Returns the bare DOM id of the popover arrow, derived from the popover's
|
|
85
|
+
* base id. The `arrow` bundle already carries this id, so reach for this when
|
|
86
|
+
* you need the id on its own, such as asserting the panel Mount's `arrowId`
|
|
87
|
+
* argument in a Scene test. */
|
|
88
|
+
export const arrowId = (id) => __foldkitBrandViewResult((`${id}-arrow`), "@foldkit/ui/popover/index.js#arrowId");
|
|
84
89
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
85
90
|
export const LockScroll = Command.define('LockScroll', {
|
|
86
91
|
messages: [Message.CompletedLockScroll],
|
|
@@ -240,26 +245,37 @@ export const update = (model, message) => {
|
|
|
240
245
|
* Scene tests can call `Scene.Mount.resolve(AnchorPopover, CompletedAnchorPopover())`
|
|
241
246
|
* to acknowledge the mount produced by the rendered panel. */
|
|
242
247
|
export const AnchorPopover = Mount.define('AnchorPopover', {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
248
|
+
args: {
|
|
249
|
+
buttonId: S.String,
|
|
250
|
+
anchor: AnchorConfig,
|
|
251
|
+
focusSelector: S.optional(S.String),
|
|
252
|
+
arrowId: S.optional(S.String),
|
|
253
|
+
arrowPadding: S.optional(S.Number),
|
|
254
|
+
},
|
|
255
|
+
messages: [Message.CompletedAnchorPopover],
|
|
256
|
+
execute: ({ element, buttonId, anchor, focusSelector, arrowId, arrowPadding, }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
257
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
258
|
+
buttonId,
|
|
259
|
+
anchor,
|
|
260
|
+
interceptTab: false,
|
|
261
|
+
focusAfterPosition: true,
|
|
262
|
+
...(focusSelector !== undefined && { focusSelector }),
|
|
263
|
+
...(arrowId !== undefined && { arrowId }),
|
|
264
|
+
...(arrowPadding !== undefined && { arrowPadding }),
|
|
265
|
+
})), "@foldkit/ui/popover/index.js#anonymous~9")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~10"));
|
|
266
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~8");
|
|
267
|
+
})), "@foldkit/ui/popover/index.js#execute~6"),
|
|
268
|
+
});
|
|
256
269
|
/** The backdrop-portaling Mount this Popover renders. Exposed so Scene tests can
|
|
257
270
|
* call `Scene.Mount.resolve(PortalPopoverBackdrop, CompletedPortalPopoverBackdrop())` to
|
|
258
271
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
259
|
-
export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop',
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop', {
|
|
273
|
+
messages: [Message.CompletedPortalPopoverBackdrop],
|
|
274
|
+
execute: ({ element }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
275
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~12")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~13"));
|
|
276
|
+
return __foldkitBrandViewResult((Message.CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~11");
|
|
277
|
+
})), "@foldkit/ui/popover/index.js#execute~7"),
|
|
278
|
+
});
|
|
263
279
|
/** Programmatically opens the Popover, updating the Model and returning
|
|
264
280
|
* focus and modal Commands plus an `Opened` OutMessage. */
|
|
265
281
|
export const open = (model) => __foldkitBrandViewResult((update(model, Message.RequestedOpen())), "@foldkit/ui/popover/index.js#open");
|
|
@@ -270,28 +286,28 @@ export const close = (model) => __foldkitBrandViewResult((update(model, Message.
|
|
|
270
286
|
/** Renders a headless popover with a trigger button and a floating panel. */
|
|
271
287
|
export const view = defineView((model, viewInputs, h) => {
|
|
272
288
|
const { id, isOpen, contentFocus, animation: { transitionState }, maybeLastButtonPointerType, } = model;
|
|
273
|
-
const { anchor, toView, isDisabled, focusSelector, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
289
|
+
const { anchor, toView, isDisabled, focusSelector, arrowPadding, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
274
290
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
275
291
|
const isVisible = isOpen || isLeaving;
|
|
276
292
|
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
277
293
|
h.DataAttribute('closed', ''),
|
|
278
294
|
h.DataAttribute('enter', ''),
|
|
279
295
|
h.DataAttribute('transition', ''),
|
|
280
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
296
|
+
]), "@foldkit/ui/popover/index.js#anonymous~15")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
281
297
|
h.DataAttribute('enter', ''),
|
|
282
298
|
h.DataAttribute('transition', ''),
|
|
283
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
299
|
+
]), "@foldkit/ui/popover/index.js#anonymous~16")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
284
300
|
h.DataAttribute('leave', ''),
|
|
285
301
|
h.DataAttribute('transition', ''),
|
|
286
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
302
|
+
]), "@foldkit/ui/popover/index.js#anonymous~17")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
287
303
|
h.DataAttribute('closed', ''),
|
|
288
304
|
h.DataAttribute('leave', ''),
|
|
289
305
|
h.DataAttribute('transition', ''),
|
|
290
|
-
]), "@foldkit/ui/popover/index.js#anonymous~
|
|
291
|
-
const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? Message.RequestedClose() : Message.RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~
|
|
306
|
+
]), "@foldkit/ui/popover/index.js#anonymous~18")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#anonymous~19")));
|
|
307
|
+
const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? Message.RequestedClose() : Message.RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~20")), M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~21")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~22")))), "@foldkit/ui/popover/index.js#handleButtonKeyDown");
|
|
292
308
|
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/popover/index.js#handleButtonPointerDown");
|
|
293
309
|
const handleButtonClick = () => {
|
|
294
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~
|
|
310
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~23"));
|
|
295
311
|
if (isMouse) {
|
|
296
312
|
return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/popover/index.js#handleButtonClick");
|
|
297
313
|
}
|
|
@@ -303,7 +319,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
303
319
|
}
|
|
304
320
|
};
|
|
305
321
|
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/popover/index.js#handleSpaceKeyUp");
|
|
306
|
-
const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~
|
|
322
|
+
const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~24")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~25")))), "@foldkit/ui/popover/index.js#handlePanelKeyDown");
|
|
307
323
|
const resolveButtonLabel = () => {
|
|
308
324
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
309
325
|
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
|
|
@@ -345,6 +361,8 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
345
361
|
buttonId: `${id}-button`,
|
|
346
362
|
anchor,
|
|
347
363
|
...(focusSelector !== undefined && { focusSelector }),
|
|
364
|
+
arrowId: arrowId(id),
|
|
365
|
+
...(arrowPadding !== undefined && { arrowPadding }),
|
|
348
366
|
})),
|
|
349
367
|
...animationAttributes,
|
|
350
368
|
...(isLeaving
|
|
@@ -358,10 +376,12 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
358
376
|
h.OnMount(PortalPopoverBackdrop()),
|
|
359
377
|
...(isLeaving ? [] : [h.OnClick(Message.RequestedClose())]),
|
|
360
378
|
];
|
|
379
|
+
const arrowAttributes = [h.Id(arrowId(id)), h.AriaHidden(true)];
|
|
361
380
|
return __foldkitBrandViewResult((toView({
|
|
362
381
|
button: childAttributes(buttonAttributes),
|
|
363
382
|
panel: childAttributes(panelAttributes),
|
|
364
383
|
backdrop: childAttributes(backdropAttributes),
|
|
384
|
+
arrow: childAttributes(arrowAttributes),
|
|
365
385
|
isVisible,
|
|
366
|
-
})), "@foldkit/ui/popover/index.js#anonymous~
|
|
386
|
+
})), "@foldkit/ui/popover/index.js#anonymous~14");
|
|
367
387
|
});
|
package/dist/popover/public.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { init, update, open, close, view, buttonId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, type BlurredPanel, type PressedPointerOnButton, type IgnoredMouseClick, type SuppressedSpaceScroll, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, buttonId, arrowId, Model, Message, OutMessage, type Opened, type Closed, type RequestedOpen, type RequestedClose, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, type BlurredPanel, type PressedPointerOnButton, type IgnoredMouseClick, type SuppressedSpaceScroll, } from './index.js';
|
|
2
2
|
export type { InitConfig, ViewInputs, RenderInfo } from './index.js';
|
|
3
3
|
export type { AnchorConfig } from '../anchor/index.js';
|
|
4
4
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/popover/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/popover/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,UAAU,EACV,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/popover/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { init, update, open, close, view, buttonId, Model, Message, OutMessage, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, } from './index.js';
|
|
1
|
+
export { init, update, open, close, view, buttonId, arrowId, Model, Message, OutMessage, AnchorPopover, PortalPopoverBackdrop, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusPanel, FocusButton, DetectMovementOrAnimationEnd, } from './index.js';
|
|
@@ -23,7 +23,8 @@ export declare const Message: import("foldkit/message").MessageUnion<{
|
|
|
23
23
|
readonly message: import("foldkit/message").MessageUnion<{
|
|
24
24
|
readonly RequestedOpen: {};
|
|
25
25
|
readonly RequestedClose: {};
|
|
26
|
-
readonly
|
|
26
|
+
readonly SucceededShowDialog: {};
|
|
27
|
+
readonly FailedShowDialog: {};
|
|
27
28
|
readonly CompletedCloseDialog: {};
|
|
28
29
|
readonly Unmounted: {};
|
|
29
30
|
readonly CompletedReleaseDialogResources: {};
|
|
@@ -66,7 +67,9 @@ export declare const update: (model: Model, message: Message) => Readonly<{
|
|
|
66
67
|
} | {
|
|
67
68
|
readonly _tag: "RequestedClose";
|
|
68
69
|
} | {
|
|
69
|
-
readonly _tag: "
|
|
70
|
+
readonly _tag: "SucceededShowDialog";
|
|
71
|
+
} | {
|
|
72
|
+
readonly _tag: "FailedShowDialog";
|
|
70
73
|
} | {
|
|
71
74
|
readonly _tag: "CompletedCloseDialog";
|
|
72
75
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disabledButton.d.ts","sourceRoot":"","sources":["../../../src/test/apps/disabledButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAMxC,eAAO,MAAM,KAAK;;;;;;;;;;;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"disabledButton.d.ts","sourceRoot":"","sources":["../../../src/test/apps/disabledButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGrD,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAA;AAMxC,eAAO,MAAM,KAAK;;;;;;;;;;;;;EAGhB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;EAIlB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,eAAO,MAAM,YAAY,EAAE,KAG1B,CAAA;AAoBD,eAAO,MAAM,MAAM,GAAI,OAAO,KAAK,EAAE,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQjD,CAAA;AAeJ,qCAAqC;AACrC,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,IAQ5D,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,cAAc,GAAI,OAAO,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,KAAG,IAyBtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../src/tooltip/tooltip.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,MAAM,EAKN,MAAM,EAEN,MAAM,IAAI,CAAC,EAEZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK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AC,CAAA;IACpC,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,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC,CAAA;AAEF;;uEAEuE;AACvE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAVP,YAAY;YACZ,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;iBACvB,OAAO;gBACR,MAAM;qBACD,MAAM;GAyExB,CAAA"}
|
package/dist/tooltip/tooltip.js
CHANGED
|
@@ -52,14 +52,18 @@ export const WaitBeforeShowing = Command.define('WaitBeforeShowing', {
|
|
|
52
52
|
execute: ({ delay, version }) => __foldkitBrandViewResult((Effect.sleep(delay).pipe(Effect.as(Message.CompletedWaitBeforeShowing({ version })))), "@foldkit/ui/tooltip/tooltip.js#execute"),
|
|
53
53
|
});
|
|
54
54
|
/** The anchor-positioning Mount this Tooltip renders on its panel. */
|
|
55
|
-
export const AnchorTooltip = Mount.define('AnchorTooltip', {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
export const AnchorTooltip = Mount.define('AnchorTooltip', {
|
|
56
|
+
args: { buttonId: S.String, anchor: AnchorConfig },
|
|
57
|
+
messages: [Message.CompletedAnchorTooltip],
|
|
58
|
+
execute: ({ element, buttonId, anchor }) => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
59
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
60
|
+
buttonId,
|
|
61
|
+
anchor,
|
|
62
|
+
interceptTab: false,
|
|
63
|
+
})), "@foldkit/ui/tooltip/tooltip.js#anonymous~2")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/tooltip/tooltip.js#anonymous~3"));
|
|
64
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorTooltip()), "@foldkit/ui/tooltip/tooltip.js#anonymous");
|
|
65
|
+
})), "@foldkit/ui/tooltip/tooltip.js#execute~2"),
|
|
66
|
+
});
|
|
63
67
|
const computeUpdate = (model, message) => __foldkitBrandViewResult((Message.match(message, {
|
|
64
68
|
EnteredTrigger: () => {
|
|
65
69
|
if (model.isOpen || model.isDismissed) {
|
|
@@ -164,7 +168,7 @@ export const update = (model, message) => {
|
|
|
164
168
|
/** Reflects an externally-sourced hover show-delay onto the Model without
|
|
165
169
|
* emitting an OutMessage. Use to mirror an external config value (a user
|
|
166
170
|
* preference, a restored setting) onto the tooltip. */
|
|
167
|
-
export const reflectShowDelay = Function.dual(2, (model, showDelay) => __foldkitBrandViewResult((evo(model, { showDelay: () => __foldkitBrandViewResult((Duration.fromInputUnsafe(showDelay)), "@foldkit/ui/tooltip/tooltip.js#showDelay") })), "@foldkit/ui/tooltip/tooltip.js#anonymous~
|
|
171
|
+
export const reflectShowDelay = Function.dual(2, (model, showDelay) => __foldkitBrandViewResult((evo(model, { showDelay: () => __foldkitBrandViewResult((Duration.fromInputUnsafe(showDelay)), "@foldkit/ui/tooltip/tooltip.js#showDelay") })), "@foldkit/ui/tooltip/tooltip.js#anonymous~4"));
|
|
168
172
|
/** Renders a headless tooltip with an anchored non-interactive panel.
|
|
169
173
|
* Shows on hover (after delay) or focus (from keyboard, touch, or pen;
|
|
170
174
|
* mouse-click focus is excluded). Hides on leave, blur, or Escape. */
|
|
@@ -183,7 +187,7 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
183
187
|
}
|
|
184
188
|
};
|
|
185
189
|
const triggerLabelAttributes = resolveTriggerLabel();
|
|
186
|
-
const handleTriggerKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.PressedEscape())), "@foldkit/ui/tooltip/tooltip.js#anonymous~
|
|
190
|
+
const handleTriggerKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.PressedEscape())), "@foldkit/ui/tooltip/tooltip.js#anonymous~6")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/tooltip/tooltip.js#anonymous~7")))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerKeyDown");
|
|
187
191
|
const handleTriggerPointerDown = (pointerType) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnTrigger({ pointerType }))), "@foldkit/ui/tooltip/tooltip.js#handleTriggerPointerDown");
|
|
188
192
|
const triggerAttributes = [
|
|
189
193
|
h.Id(triggerId(id)),
|
|
@@ -218,5 +222,5 @@ export const view = defineView((model, viewInputs, h) => {
|
|
|
218
222
|
trigger: childAttributes(triggerAttributes),
|
|
219
223
|
panel: childAttributes(panelAttributes),
|
|
220
224
|
isVisible: isOpen,
|
|
221
|
-
})), "@foldkit/ui/tooltip/tooltip.js#anonymous~
|
|
225
|
+
})), "@foldkit/ui/tooltip/tooltip.js#anonymous~5");
|
|
222
226
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foldkit/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.154.0-canary.2d85d5ae9536",
|
|
4
4
|
"description": "Headless, accessible UI components for Foldkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
],
|
|
119
119
|
"peerDependencies": {
|
|
120
120
|
"effect": "4.0.0-rc.112",
|
|
121
|
-
"foldkit": "
|
|
121
|
+
"foldkit": "0.154.0-canary.2d85d5ae9536"
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
124
|
"@floating-ui/dom": "^1.7.6"
|
|
@@ -131,8 +131,8 @@
|
|
|
131
131
|
"typedoc": "^0.28.19",
|
|
132
132
|
"typescript": "^6.0.3",
|
|
133
133
|
"vitest": "^4.1.9",
|
|
134
|
-
"@foldkit/vite-plugin": "0.19.0",
|
|
135
|
-
"foldkit": "0.
|
|
134
|
+
"@foldkit/vite-plugin": "0.19.0-canary.2d85d5ae9536",
|
|
135
|
+
"foldkit": "0.154.0-canary.2d85d5ae9536"
|
|
136
136
|
},
|
|
137
137
|
"keywords": [
|
|
138
138
|
"foldkit",
|