foldkit 0.56.0 → 0.57.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/devtools/overlay-styles.d.ts +1 -1
- package/dist/devtools/overlay-styles.d.ts.map +1 -1
- package/dist/devtools/overlay-styles.js +5 -1
- package/dist/devtools/overlay.d.ts.map +1 -1
- package/dist/devtools/overlay.js +52 -19
- package/dist/html/index.d.ts +3 -3
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/lazy.d.ts +7 -5
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +12 -8
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +2 -4
- package/dist/test/apps/disabledButton.d.ts +11 -3
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/ui/combobox/multi.d.ts +31 -10
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/public.d.ts +1 -2
- package/dist/ui/combobox/public.d.ts.map +1 -1
- package/dist/ui/combobox/public.js +1 -2
- package/dist/ui/combobox/shared.d.ts +33 -33
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +89 -112
- package/dist/ui/combobox/single.d.ts +31 -10
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/combobox/single.js +1 -5
- package/dist/ui/dialog/index.d.ts +10 -15
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +68 -73
- package/dist/ui/dialog/public.d.ts +1 -1
- package/dist/ui/dialog/public.d.ts.map +1 -1
- package/dist/ui/dialog/public.js +1 -1
- package/dist/ui/listbox/multi.d.ts +30 -9
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/public.d.ts +1 -2
- package/dist/ui/listbox/public.d.ts.map +1 -1
- package/dist/ui/listbox/public.js +1 -2
- package/dist/ui/listbox/shared.d.ts +35 -36
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +106 -104
- package/dist/ui/listbox/single.d.ts +30 -9
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/listbox/single.js +9 -12
- package/dist/ui/menu/index.d.ts +22 -26
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +103 -91
- package/dist/ui/menu/public.d.ts +1 -2
- package/dist/ui/menu/public.d.ts.map +1 -1
- package/dist/ui/menu/public.js +1 -2
- package/dist/ui/popover/index.d.ts +21 -22
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +92 -75
- package/dist/ui/popover/public.d.ts +1 -2
- package/dist/ui/popover/public.d.ts.map +1 -1
- package/dist/ui/popover/public.js +1 -2
- package/dist/ui/transition/index.d.ts +8 -58
- package/dist/ui/transition/index.d.ts.map +1 -1
- package/dist/ui/transition/index.js +21 -111
- package/dist/ui/transition/public.d.ts +1 -1
- package/dist/ui/transition/public.d.ts.map +1 -1
- package/dist/ui/transition/public.js +1 -1
- package/dist/ui/transition/schema.d.ts +43 -0
- package/dist/ui/transition/schema.d.ts.map +1 -0
- package/dist/ui/transition/schema.js +35 -0
- package/dist/ui/transition/update.d.ts +22 -0
- package/dist/ui/transition/update.d.ts.map +1 -0
- package/dist/ui/transition/update.js +68 -0
- package/package.json +1 -1
- package/dist/ui/transition.d.ts +0 -5
- package/dist/ui/transition.d.ts.map +0 -1
- package/dist/ui/transition.js +0 -3
package/dist/ui/menu/index.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export declare const Model: S.Struct<{
|
|
|
13
13
|
isOpen: typeof S.Boolean;
|
|
14
14
|
isAnimated: typeof S.Boolean;
|
|
15
15
|
isModal: typeof S.Boolean;
|
|
16
|
-
|
|
16
|
+
transition: S.Struct<{
|
|
17
|
+
id: typeof S.String;
|
|
18
|
+
isShowing: typeof S.Boolean;
|
|
19
|
+
transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
|
|
20
|
+
}>;
|
|
17
21
|
maybeActiveItemIndex: S.OptionFromSelf<typeof S.Number>;
|
|
18
22
|
activationTrigger: S.Literal<["Pointer", "Keyboard"]>;
|
|
19
23
|
searchQuery: typeof S.String;
|
|
@@ -90,12 +94,10 @@ export declare const CompletedAdvanceFocus: import("../../schema").CallableTagge
|
|
|
90
94
|
export declare const IgnoredMouseClick: import("../../schema").CallableTaggedStruct<"IgnoredMouseClick", {}>;
|
|
91
95
|
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
92
96
|
export declare const SuppressedSpaceScroll: import("../../schema").CallableTaggedStruct<"SuppressedSpaceScroll", {}>;
|
|
93
|
-
/**
|
|
94
|
-
export declare const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/** Sent internally when the menu button moves in the viewport during a leave transition, cancelling the animation. */
|
|
98
|
-
export declare const DetectedButtonMovement: import("../../schema").CallableTaggedStruct<"DetectedButtonMovement", {}>;
|
|
97
|
+
/** Wraps a Transition submodel message for delegation. */
|
|
98
|
+
export declare const GotTransitionMessage: import("../../schema").CallableTaggedStruct<"GotTransitionMessage", {
|
|
99
|
+
message: S.Union<[import("../../schema").CallableTaggedStruct<"Showed", {}>, import("../../schema").CallableTaggedStruct<"Hidden", {}>, import("../../schema").CallableTaggedStruct<"AdvancedTransitionFrame", {}>, import("../../schema").CallableTaggedStruct<"EndedTransition", {}>]>;
|
|
100
|
+
}>;
|
|
99
101
|
/** Sent when the user presses a pointer device on the menu button. Records pointer type and toggles for mouse. */
|
|
100
102
|
export declare const PressedPointerOnButton: import("../../schema").CallableTaggedStruct<"PressedPointerOnButton", {
|
|
101
103
|
pointerType: typeof S.String;
|
|
@@ -133,12 +135,11 @@ export declare const Message: S.Union<[
|
|
|
133
135
|
typeof CompletedAdvanceFocus,
|
|
134
136
|
typeof IgnoredMouseClick,
|
|
135
137
|
typeof SuppressedSpaceScroll,
|
|
136
|
-
typeof
|
|
137
|
-
typeof EndedTransition,
|
|
138
|
-
typeof DetectedButtonMovement,
|
|
138
|
+
typeof GotTransitionMessage,
|
|
139
139
|
typeof PressedPointerOnButton,
|
|
140
140
|
typeof ReleasedPointerOnItems
|
|
141
141
|
]>;
|
|
142
|
+
export type Message = typeof Message.Type;
|
|
142
143
|
export type Opened = typeof Opened.Type;
|
|
143
144
|
export type Closed = typeof Closed.Type;
|
|
144
145
|
export type ClosedByTab = typeof ClosedByTab.Type;
|
|
@@ -151,12 +152,8 @@ export type Searched = typeof Searched.Type;
|
|
|
151
152
|
export type ClearedSearch = typeof ClearedSearch.Type;
|
|
152
153
|
export type IgnoredMouseClick = typeof IgnoredMouseClick.Type;
|
|
153
154
|
export type SuppressedSpaceScroll = typeof SuppressedSpaceScroll.Type;
|
|
154
|
-
export type AdvancedTransitionFrame = typeof AdvancedTransitionFrame.Type;
|
|
155
|
-
export type EndedTransition = typeof EndedTransition.Type;
|
|
156
|
-
export type DetectedButtonMovement = typeof DetectedButtonMovement.Type;
|
|
157
155
|
export type PressedPointerOnButton = typeof PressedPointerOnButton.Type;
|
|
158
156
|
export type ReleasedPointerOnItems = typeof ReleasedPointerOnItems.Type;
|
|
159
|
-
export type Message = typeof Message.Type;
|
|
160
157
|
/** Configuration for creating a menu model with `init`. `isAnimated` enables CSS transition coordination (default `false`). `isModal` locks page scroll and inerts other elements when open (default `false`). */
|
|
161
158
|
export type InitConfig = Readonly<{
|
|
162
159
|
id: string;
|
|
@@ -166,10 +163,6 @@ export type InitConfig = Readonly<{
|
|
|
166
163
|
/** Creates an initial menu model from a config. Defaults to closed with no active item. */
|
|
167
164
|
export declare const init: (config: InitConfig) => Model;
|
|
168
165
|
type UpdateReturn = readonly [Model, ReadonlyArray<Command.Command<Message>>];
|
|
169
|
-
/** Advances the menu's enter/leave transition by waiting a double-rAF. */
|
|
170
|
-
export declare const RequestFrame: Command.CommandDefinition<"RequestFrame", {
|
|
171
|
-
readonly _tag: "AdvancedTransitionFrame";
|
|
172
|
-
}>;
|
|
173
166
|
/** Prevents page scrolling while the menu is open. */
|
|
174
167
|
export declare const LockScroll: Command.CommandDefinition<"LockScroll", {
|
|
175
168
|
readonly _tag: "CompletedLockScroll";
|
|
@@ -207,15 +200,18 @@ export declare const DelayClearSearch: Command.CommandDefinition<"DelayClearSear
|
|
|
207
200
|
readonly _tag: "ClearedSearch";
|
|
208
201
|
readonly version: number;
|
|
209
202
|
}>;
|
|
210
|
-
/**
|
|
211
|
-
export declare const WaitForTransitions: Command.CommandDefinition<"WaitForTransitions", {
|
|
212
|
-
readonly _tag: "EndedTransition";
|
|
213
|
-
}>;
|
|
214
|
-
/** Detects whether the menu button moved or the leave transition ended — whichever comes first. */
|
|
203
|
+
/** Detects whether the menu button moved or the leave transition ended — whichever comes first. Both outcomes signal the Transition submodel that leave is complete. */
|
|
215
204
|
export declare const DetectMovementOrTransitionEnd: Command.CommandDefinition<"DetectMovementOrTransitionEnd", {
|
|
216
|
-
readonly _tag: "
|
|
217
|
-
|
|
218
|
-
|
|
205
|
+
readonly _tag: "GotTransitionMessage";
|
|
206
|
+
readonly message: {
|
|
207
|
+
readonly _tag: "Showed";
|
|
208
|
+
} | {
|
|
209
|
+
readonly _tag: "Hidden";
|
|
210
|
+
} | {
|
|
211
|
+
readonly _tag: "AdvancedTransitionFrame";
|
|
212
|
+
} | {
|
|
213
|
+
readonly _tag: "EndedTransition";
|
|
214
|
+
};
|
|
219
215
|
}>;
|
|
220
216
|
/** Processes a menu message and returns the next model and commands. */
|
|
221
217
|
export declare const update: (model: Model, message: Message) => UpdateReturn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,MAAM,IAAI,CAAC,EAGZ,MAAM,QAAQ,CAAA;AAEf,OAAO,KAAK,OAA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C,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IACpD,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAA;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACnD,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mBAAmB,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACvD,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB,CAAC,CAAA;AAEF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,CAAA;AAIjD,sHAAsH;AACtH,eAAO,MAAM,IAAI,GAAI,OAAO,EAAE,IAAI,SAAS,MAAM,EAC/C,QAAQ,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,KAChC,IAseF,CAAA;AAED;mFACmF;AACnF,eAAO,MAAM,IAAI,GAAI,OAAO,EAAE,IAAI,SAAS,MAAM,EAC/C,cAAc,IAAI,CAChB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EACzB,OAAO,GAAG,iBAAiB,GAAG,gBAAgB,CAC/C,KACA,CAAC,CACF,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,iBAAiB,CAAC,KAC1D,IAAI,CAgBR,CAAA"}
|
package/dist/ui/menu/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array, Effect, Match as M, Option, Predicate, Schema as S, String as Str, pipe, } from 'effect';
|
|
1
|
+
import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, String as Str, pipe, } from 'effect';
|
|
2
2
|
import * as Command from '../../command';
|
|
3
3
|
import { OptionExt } from '../../effectExtensions';
|
|
4
4
|
import { createLazy, html } from '../../html';
|
|
@@ -8,7 +8,11 @@ import * as Task from '../../task';
|
|
|
8
8
|
import { anchorHooks } from '../anchor';
|
|
9
9
|
import { groupContiguous } from '../group';
|
|
10
10
|
import { findFirstEnabledIndex, isPrintableKey, keyToIndex } from '../keyboard';
|
|
11
|
-
|
|
11
|
+
// NOTE: Transition imports are split across schema + update to avoid a circular
|
|
12
|
+
// dependency: transition → html → runtime → devtools → menu → transition.
|
|
13
|
+
// The barrel (../transition) imports from html, which starts the cycle.
|
|
14
|
+
import { EndedTransition as TransitionEndedTransition, Hidden as TransitionHidden, Message as TransitionMessage, Model as TransitionModel, Showed as TransitionShowed, init as transitionInit, } from '../transition/schema';
|
|
15
|
+
import { update as transitionUpdate } from '../transition/update';
|
|
12
16
|
import { resolveTypeaheadMatch } from '../typeahead';
|
|
13
17
|
// MODEL
|
|
14
18
|
/** Schema for the activation trigger — whether the user interacted via mouse or keyboard. */
|
|
@@ -24,7 +28,7 @@ export const Model = S.Struct({
|
|
|
24
28
|
isOpen: S.Boolean,
|
|
25
29
|
isAnimated: S.Boolean,
|
|
26
30
|
isModal: S.Boolean,
|
|
27
|
-
|
|
31
|
+
transition: TransitionModel,
|
|
28
32
|
maybeActiveItemIndex: S.OptionFromSelf(S.Number),
|
|
29
33
|
activationTrigger: ActivationTrigger,
|
|
30
34
|
searchQuery: S.String,
|
|
@@ -90,12 +94,10 @@ export const CompletedAdvanceFocus = m('CompletedAdvanceFocus');
|
|
|
90
94
|
export const IgnoredMouseClick = m('IgnoredMouseClick');
|
|
91
95
|
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
92
96
|
export const SuppressedSpaceScroll = m('SuppressedSpaceScroll');
|
|
93
|
-
/**
|
|
94
|
-
export const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/** Sent internally when the menu button moves in the viewport during a leave transition, cancelling the animation. */
|
|
98
|
-
export const DetectedButtonMovement = m('DetectedButtonMovement');
|
|
97
|
+
/** Wraps a Transition submodel message for delegation. */
|
|
98
|
+
export const GotTransitionMessage = m('GotTransitionMessage', {
|
|
99
|
+
message: TransitionMessage,
|
|
100
|
+
});
|
|
99
101
|
/** Sent when the user presses a pointer device on the menu button. Records pointer type and toggles for mouse. */
|
|
100
102
|
export const PressedPointerOnButton = m('PressedPointerOnButton', {
|
|
101
103
|
pointerType: S.String,
|
|
@@ -111,7 +113,7 @@ export const ReleasedPointerOnItems = m('ReleasedPointerOnItems', {
|
|
|
111
113
|
timeStamp: S.Number,
|
|
112
114
|
});
|
|
113
115
|
/** Union of all messages the menu component can produce. */
|
|
114
|
-
export const Message = S.Union(Opened, Closed, ClosedByTab, ActivatedItem, DeactivatedItem, SelectedItem, MovedPointerOverItem, RequestedItemClick, Searched, ClearedSearch, CompletedFocusItems, CompletedFocusButton, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedScrollIntoView, CompletedClickItem, CompletedAdvanceFocus, IgnoredMouseClick, SuppressedSpaceScroll,
|
|
116
|
+
export const Message = S.Union(Opened, Closed, ClosedByTab, ActivatedItem, DeactivatedItem, SelectedItem, MovedPointerOverItem, RequestedItemClick, Searched, ClearedSearch, CompletedFocusItems, CompletedFocusButton, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedScrollIntoView, CompletedClickItem, CompletedAdvanceFocus, IgnoredMouseClick, SuppressedSpaceScroll, GotTransitionMessage, PressedPointerOnButton, ReleasedPointerOnItems);
|
|
115
117
|
// INIT
|
|
116
118
|
const SEARCH_DEBOUNCE_MILLISECONDS = 350;
|
|
117
119
|
const LEFT_MOUSE_BUTTON = 0;
|
|
@@ -123,7 +125,7 @@ export const init = (config) => ({
|
|
|
123
125
|
isOpen: false,
|
|
124
126
|
isAnimated: config.isAnimated ?? false,
|
|
125
127
|
isModal: config.isModal ?? false,
|
|
126
|
-
|
|
128
|
+
transition: transitionInit({ id: `${config.id}-items` }),
|
|
127
129
|
maybeActiveItemIndex: Option.none(),
|
|
128
130
|
activationTrigger: 'Keyboard',
|
|
129
131
|
searchQuery: '',
|
|
@@ -135,7 +137,6 @@ export const init = (config) => ({
|
|
|
135
137
|
// UPDATE
|
|
136
138
|
const closedModel = (model) => evo(model, {
|
|
137
139
|
isOpen: () => false,
|
|
138
|
-
transitionState: () => (model.isAnimated ? 'LeaveStart' : 'Idle'),
|
|
139
140
|
maybeActiveItemIndex: () => Option.none(),
|
|
140
141
|
searchQuery: () => '',
|
|
141
142
|
searchVersion: () => 0,
|
|
@@ -147,8 +148,6 @@ const buttonSelector = (id) => `#${id}-button`;
|
|
|
147
148
|
const itemsSelector = (id) => `#${id}-items`;
|
|
148
149
|
const itemSelector = (id, index) => `#${id}-item-${index}`;
|
|
149
150
|
const withUpdateReturn = M.withReturnType();
|
|
150
|
-
/** Advances the menu's enter/leave transition by waiting a double-rAF. */
|
|
151
|
-
export const RequestFrame = Command.define('RequestFrame', AdvancedTransitionFrame);
|
|
152
151
|
/** Prevents page scrolling while the menu is open. */
|
|
153
152
|
export const LockScroll = Command.define('LockScroll', CompletedLockScroll);
|
|
154
153
|
/** Re-enables page scrolling after the menu closes. */
|
|
@@ -167,13 +166,31 @@ export const ScrollIntoView = Command.define('ScrollIntoView', CompletedScrollIn
|
|
|
167
166
|
export const ClickItem = Command.define('ClickItem', CompletedClickItem);
|
|
168
167
|
/** Waits for the typeahead search debounce period before clearing the query. */
|
|
169
168
|
export const DelayClearSearch = Command.define('DelayClearSearch', ClearedSearch);
|
|
170
|
-
/**
|
|
171
|
-
export const
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
/** Detects whether the menu button moved or the leave transition ended — whichever comes first. Both outcomes signal the Transition submodel that leave is complete. */
|
|
170
|
+
export const DetectMovementOrTransitionEnd = Command.define('DetectMovementOrTransitionEnd', GotTransitionMessage);
|
|
171
|
+
const delegateToTransition = (model, transitionMessage) => {
|
|
172
|
+
const [nextTransition, transitionCommands, maybeOutMessage] = transitionUpdate(model.transition, transitionMessage);
|
|
173
|
+
const mappedCommands = transitionCommands.map(Command.mapEffect(Effect.map(message => GotTransitionMessage({ message }))));
|
|
174
|
+
const additionalCommands = Option.match(maybeOutMessage, {
|
|
175
|
+
onNone: () => [],
|
|
176
|
+
onSome: M.type().pipe(M.tagsExhaustive({
|
|
177
|
+
StartedLeaveAnimating: () => [
|
|
178
|
+
DetectMovementOrTransitionEnd(Effect.raceFirst(Task.detectElementMovement(buttonSelector(model.id)).pipe(Effect.as(GotTransitionMessage({
|
|
179
|
+
message: TransitionEndedTransition(),
|
|
180
|
+
}))), Task.waitForTransitions(itemsSelector(model.id)).pipe(Effect.as(GotTransitionMessage({
|
|
181
|
+
message: TransitionEndedTransition(),
|
|
182
|
+
}))))),
|
|
183
|
+
],
|
|
184
|
+
TransitionedOut: () => [],
|
|
185
|
+
})),
|
|
186
|
+
});
|
|
187
|
+
return [
|
|
188
|
+
evo(model, { transition: () => nextTransition }),
|
|
189
|
+
[...mappedCommands, ...additionalCommands],
|
|
190
|
+
];
|
|
191
|
+
};
|
|
174
192
|
/** Processes a menu message and returns the next model and commands. */
|
|
175
193
|
export const update = (model, message) => {
|
|
176
|
-
const maybeNextFrame = OptionExt.when(model.isAnimated, RequestFrame(Task.nextFrame.pipe(Effect.as(AdvancedTransitionFrame()))));
|
|
177
194
|
const maybeLockScroll = OptionExt.when(model.isModal, LockScroll(Task.lockScroll.pipe(Effect.as(CompletedLockScroll()))));
|
|
178
195
|
const maybeUnlockScroll = OptionExt.when(model.isModal, UnlockScroll(Task.unlockScroll.pipe(Effect.as(CompletedUnlockScroll()))));
|
|
179
196
|
const maybeInertOthers = OptionExt.when(model.isModal, InertOthers(Task.inertOthers(model.id, [
|
|
@@ -181,37 +198,56 @@ export const update = (model, message) => {
|
|
|
181
198
|
itemsSelector(model.id),
|
|
182
199
|
]).pipe(Effect.as(CompletedSetupInert()))));
|
|
183
200
|
const maybeRestoreInert = OptionExt.when(model.isModal, RestoreInert(Task.restoreInert(model.id).pipe(Effect.as(CompletedTeardownInert()))));
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
const focusItems = FocusItems(Task.focus(itemsSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusItems())));
|
|
202
|
+
const focusButton = FocusButton(Task.focus(buttonSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton())));
|
|
203
|
+
const openCommands = [
|
|
204
|
+
focusItems,
|
|
205
|
+
...Array.getSomes([maybeLockScroll, maybeInertOthers]),
|
|
206
|
+
];
|
|
207
|
+
const closeWithFocusCommands = [
|
|
208
|
+
focusButton,
|
|
209
|
+
...Array.getSomes([maybeUnlockScroll, maybeRestoreInert]),
|
|
210
|
+
];
|
|
211
|
+
const closeWithoutFocusCommands = Array.getSomes([
|
|
212
|
+
maybeUnlockScroll,
|
|
213
|
+
maybeRestoreInert,
|
|
214
|
+
]);
|
|
215
|
+
const openMenu = (baseModel) => {
|
|
216
|
+
if (model.isAnimated) {
|
|
217
|
+
const [nextModel, transitionCommands] = delegateToTransition(baseModel, TransitionShowed());
|
|
198
218
|
return [
|
|
199
|
-
nextModel,
|
|
200
|
-
|
|
219
|
+
evo(nextModel, { isOpen: () => true }),
|
|
220
|
+
[...openCommands, ...transitionCommands],
|
|
201
221
|
];
|
|
222
|
+
}
|
|
223
|
+
return [evo(baseModel, { isOpen: () => true }), openCommands];
|
|
224
|
+
};
|
|
225
|
+
const closeMenu = (baseModel, commands) => {
|
|
226
|
+
const closed = closedModel(baseModel);
|
|
227
|
+
if (model.isAnimated) {
|
|
228
|
+
const [nextModel, transitionCommands] = delegateToTransition(closed, TransitionHidden());
|
|
229
|
+
return [nextModel, [...commands, ...transitionCommands]];
|
|
230
|
+
}
|
|
231
|
+
return [closed, commands];
|
|
232
|
+
};
|
|
233
|
+
return M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
234
|
+
Opened: ({ maybeActiveItemIndex }) => openMenu(evo(model, {
|
|
235
|
+
maybeActiveItemIndex: () => maybeActiveItemIndex,
|
|
236
|
+
activationTrigger: () => Option.match(maybeActiveItemIndex, {
|
|
237
|
+
onNone: () => 'Pointer',
|
|
238
|
+
onSome: () => 'Keyboard',
|
|
239
|
+
}),
|
|
240
|
+
searchQuery: () => '',
|
|
241
|
+
searchVersion: () => 0,
|
|
242
|
+
maybeLastPointerPosition: () => Option.none(),
|
|
243
|
+
})),
|
|
244
|
+
Closed: () => closeMenu(model, closeWithFocusCommands),
|
|
245
|
+
ClosedByTab: () => {
|
|
246
|
+
if (Option.exists(model.maybeLastButtonPointerType, Equal.equals('mouse'))) {
|
|
247
|
+
return [model, []];
|
|
248
|
+
}
|
|
249
|
+
return closeMenu(model, closeWithoutFocusCommands);
|
|
202
250
|
},
|
|
203
|
-
Closed: () => [
|
|
204
|
-
closedModel(model),
|
|
205
|
-
pipe(Array.getSomes([
|
|
206
|
-
maybeNextFrame,
|
|
207
|
-
maybeUnlockScroll,
|
|
208
|
-
maybeRestoreInert,
|
|
209
|
-
]), Array.prepend(FocusButton(Task.focus(buttonSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))))),
|
|
210
|
-
],
|
|
211
|
-
ClosedByTab: () => [
|
|
212
|
-
closedModel(model),
|
|
213
|
-
Array.getSomes([maybeNextFrame, maybeUnlockScroll, maybeRestoreInert]),
|
|
214
|
-
],
|
|
215
251
|
ActivatedItem: ({ index, activationTrigger }) => [
|
|
216
252
|
evo(model, {
|
|
217
253
|
maybeActiveItemIndex: () => Option.some(index),
|
|
@@ -240,14 +276,7 @@ export const update = (model, message) => {
|
|
|
240
276
|
DeactivatedItem: () => model.activationTrigger === 'Pointer'
|
|
241
277
|
? [evo(model, { maybeActiveItemIndex: () => Option.none() }), []]
|
|
242
278
|
: [model, []],
|
|
243
|
-
SelectedItem: () =>
|
|
244
|
-
closedModel(model),
|
|
245
|
-
pipe(Array.getSomes([
|
|
246
|
-
maybeNextFrame,
|
|
247
|
-
maybeUnlockScroll,
|
|
248
|
-
maybeRestoreInert,
|
|
249
|
-
]), Array.prepend(FocusButton(Task.focus(buttonSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))))),
|
|
250
|
-
],
|
|
279
|
+
SelectedItem: () => closeMenu(model, closeWithFocusCommands),
|
|
251
280
|
RequestedItemClick: ({ index }) => [
|
|
252
281
|
model,
|
|
253
282
|
[
|
|
@@ -274,25 +303,7 @@ export const update = (model, message) => {
|
|
|
274
303
|
}
|
|
275
304
|
return [evo(model, { searchQuery: () => '' }), []];
|
|
276
305
|
},
|
|
277
|
-
|
|
278
|
-
evo(model, { transitionState: () => 'EnterAnimating' }),
|
|
279
|
-
[
|
|
280
|
-
WaitForTransitions(Task.waitForTransitions(itemsSelector(model.id)).pipe(Effect.as(EndedTransition()))),
|
|
281
|
-
],
|
|
282
|
-
]), M.when('LeaveStart', () => [
|
|
283
|
-
evo(model, { transitionState: () => 'LeaveAnimating' }),
|
|
284
|
-
[
|
|
285
|
-
DetectMovementOrTransitionEnd(Effect.raceFirst(Task.detectElementMovement(buttonSelector(model.id)).pipe(Effect.as(DetectedButtonMovement())), Task.waitForTransitions(itemsSelector(model.id)).pipe(Effect.as(EndedTransition())))),
|
|
286
|
-
],
|
|
287
|
-
]), M.orElse(() => [model, []])),
|
|
288
|
-
EndedTransition: () => M.value(model.transitionState).pipe(withUpdateReturn, M.whenOr('EnterAnimating', 'LeaveAnimating', () => [
|
|
289
|
-
evo(model, { transitionState: () => 'Idle' }),
|
|
290
|
-
[],
|
|
291
|
-
]), M.orElse(() => [model, []])),
|
|
292
|
-
DetectedButtonMovement: () => M.value(model.transitionState).pipe(withUpdateReturn, M.when('LeaveAnimating', () => [
|
|
293
|
-
evo(model, { transitionState: () => 'Idle' }),
|
|
294
|
-
[],
|
|
295
|
-
]), M.orElse(() => [model, []])),
|
|
306
|
+
GotTransitionMessage: ({ message: transitionMessage }) => delegateToTransition(model, transitionMessage),
|
|
296
307
|
PressedPointerOnButton: ({ pointerType, button, screenX, screenY, timeStamp, }) => {
|
|
297
308
|
const withPointerType = evo(model, {
|
|
298
309
|
maybeLastButtonPointerType: () => Option.some(pointerType),
|
|
@@ -301,29 +312,22 @@ export const update = (model, message) => {
|
|
|
301
312
|
return [withPointerType, []];
|
|
302
313
|
}
|
|
303
314
|
if (model.isOpen) {
|
|
315
|
+
const [closed, commands] = closeMenu(withPointerType, closeWithFocusCommands);
|
|
304
316
|
return [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
maybeRestoreInert,
|
|
310
|
-
]), Array.prepend(FocusButton(Task.focus(buttonSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))))),
|
|
317
|
+
evo(closed, {
|
|
318
|
+
maybeLastButtonPointerType: () => Option.some(pointerType),
|
|
319
|
+
}),
|
|
320
|
+
commands,
|
|
311
321
|
];
|
|
312
322
|
}
|
|
313
|
-
|
|
314
|
-
isOpen: () => true,
|
|
315
|
-
transitionState: () => (model.isAnimated ? 'EnterStart' : 'Idle'),
|
|
323
|
+
return openMenu(evo(withPointerType, {
|
|
316
324
|
maybeActiveItemIndex: () => Option.none(),
|
|
317
325
|
activationTrigger: () => 'Pointer',
|
|
318
326
|
searchQuery: () => '',
|
|
319
327
|
searchVersion: () => 0,
|
|
320
328
|
maybeLastPointerPosition: () => Option.none(),
|
|
321
329
|
maybePointerOrigin: () => Option.some({ screenX, screenY, timeStamp }),
|
|
322
|
-
});
|
|
323
|
-
return [
|
|
324
|
-
nextModel,
|
|
325
|
-
pipe(Array.getSomes([maybeNextFrame, maybeLockScroll, maybeInertOthers]), Array.prepend(FocusItems(Task.focus(itemsSelector(model.id)).pipe(Effect.ignore, Effect.as(CompletedFocusItems()))))),
|
|
326
|
-
];
|
|
330
|
+
}));
|
|
327
331
|
},
|
|
328
332
|
ReleasedPointerOnItems: ({ screenX, screenY, timeStamp }) => {
|
|
329
333
|
const hasNoOrigin = Option.isNone(model.maybePointerOrigin);
|
|
@@ -355,7 +359,10 @@ export const update = (model, message) => {
|
|
|
355
359
|
CompletedScrollIntoView: () => [model, []],
|
|
356
360
|
CompletedClickItem: () => [model, []],
|
|
357
361
|
CompletedAdvanceFocus: () => [model, []],
|
|
358
|
-
IgnoredMouseClick: () => [
|
|
362
|
+
IgnoredMouseClick: () => [
|
|
363
|
+
evo(model, { maybeLastButtonPointerType: () => Option.none() }),
|
|
364
|
+
[],
|
|
365
|
+
],
|
|
359
366
|
SuppressedSpaceScroll: () => [model, []],
|
|
360
367
|
}));
|
|
361
368
|
};
|
|
@@ -367,7 +374,7 @@ const itemId = (id, index) => `${id}-item-${index}`;
|
|
|
367
374
|
/** Renders a headless menu with typeahead search, keyboard navigation, and aria-activedescendant focus management. */
|
|
368
375
|
export const view = (config) => {
|
|
369
376
|
const { div, AriaActiveDescendant, AriaControls, AriaDisabled, AriaExpanded, AriaHasPopup, AriaLabelledBy, Class, DataAttribute, Id, OnBlur, OnClick, OnDestroy, OnInsert, OnKeyDownPreventDefault, OnKeyUpPreventDefault, OnPointerDown, OnPointerLeave, OnPointerMove, OnPointerUp, Role, Style, Tabindex, Type, keyed, } = html();
|
|
370
|
-
const { model: { id, isOpen, transitionState, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, }, toParentMessage, onSelectedItem, items, itemToConfig, isItemDisabled, itemToSearchText = (item) => item, isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor, } = config;
|
|
377
|
+
const { model: { id, isOpen, transition: { transitionState }, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, }, toParentMessage, onSelectedItem, items, itemToConfig, isItemDisabled, itemToSearchText = (item) => item, isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor, } = config;
|
|
371
378
|
const dispatchSelectedItem = (index) => onSelectedItem
|
|
372
379
|
? onSelectedItem(index)
|
|
373
380
|
: toParentMessage(SelectedItem({ index }));
|
|
@@ -449,7 +456,12 @@ export const view = (config) => {
|
|
|
449
456
|
OnKeyUpPreventDefault(handleSpaceKeyUp),
|
|
450
457
|
OnClick(handleButtonClick()),
|
|
451
458
|
]),
|
|
452
|
-
...(isVisible
|
|
459
|
+
...(isVisible
|
|
460
|
+
? [
|
|
461
|
+
DataAttribute('open', ''),
|
|
462
|
+
Style({ position: 'relative', zIndex: '1' }),
|
|
463
|
+
]
|
|
464
|
+
: []),
|
|
453
465
|
...(buttonClassName ? [Class(buttonClassName)] : []),
|
|
454
466
|
...buttonAttributes,
|
|
455
467
|
];
|
package/dist/ui/menu/public.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { init, update, selectItem, view, lazy, Model, Message, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedFocusItems, CompletedFocusButton, CompletedScrollIntoView, CompletedClickItem, ClearedSearch,
|
|
2
|
-
export { TransitionState } from '../transition';
|
|
1
|
+
export { init, update, selectItem, view, lazy, Model, Message, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedFocusItems, CompletedFocusButton, CompletedScrollIntoView, CompletedClickItem, ClearedSearch, GotTransitionMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusItems, FocusButton, ScrollIntoView, ClickItem, DelayClearSearch, DetectMovementOrTransitionEnd, } from './index';
|
|
3
2
|
export type { ActivationTrigger, Opened, Closed, ClosedByTab, ActivatedItem, DeactivatedItem, MovedPointerOverItem, RequestedItemClick, Searched, PressedPointerOnButton, ReleasedPointerOnItems, IgnoredMouseClick, SuppressedSpaceScroll, InitConfig, ViewConfig, ItemConfig, GroupHeading, } from './index';
|
|
4
3
|
export type { AnchorConfig } from '../anchor';
|
|
5
4
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/menu/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/menu/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,iBAAiB,EACjB,MAAM,EACN,MAAM,EACN,WAAW,EACX,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/ui/menu/public.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { init, update, selectItem, view, lazy, Model, Message, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedFocusItems, CompletedFocusButton, CompletedScrollIntoView, CompletedClickItem, ClearedSearch,
|
|
2
|
-
export { TransitionState } from '../transition';
|
|
1
|
+
export { init, update, selectItem, view, lazy, Model, Message, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedSetupInert, CompletedTeardownInert, CompletedFocusItems, CompletedFocusButton, CompletedScrollIntoView, CompletedClickItem, ClearedSearch, GotTransitionMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusItems, FocusButton, ScrollIntoView, ClickItem, DelayClearSearch, DetectMovementOrTransitionEnd, } from './index';
|
|
@@ -8,7 +8,11 @@ export declare const Model: S.Struct<{
|
|
|
8
8
|
isOpen: typeof S.Boolean;
|
|
9
9
|
isAnimated: typeof S.Boolean;
|
|
10
10
|
isModal: typeof S.Boolean;
|
|
11
|
-
|
|
11
|
+
transition: S.Struct<{
|
|
12
|
+
id: typeof S.String;
|
|
13
|
+
isShowing: typeof S.Boolean;
|
|
14
|
+
transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
|
|
15
|
+
}>;
|
|
12
16
|
maybeLastButtonPointerType: S.OptionFromSelf<typeof S.String>;
|
|
13
17
|
}>;
|
|
14
18
|
export type Model = typeof Model.Type;
|
|
@@ -39,12 +43,10 @@ export declare const CompletedTeardownInert: import("../../schema").CallableTagg
|
|
|
39
43
|
export declare const IgnoredMouseClick: import("../../schema").CallableTaggedStruct<"IgnoredMouseClick", {}>;
|
|
40
44
|
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
41
45
|
export declare const SuppressedSpaceScroll: import("../../schema").CallableTaggedStruct<"SuppressedSpaceScroll", {}>;
|
|
42
|
-
/**
|
|
43
|
-
export declare const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** Sent internally when the popover button moves in the viewport during a leave transition, cancelling the animation. */
|
|
47
|
-
export declare const DetectedButtonMovement: import("../../schema").CallableTaggedStruct<"DetectedButtonMovement", {}>;
|
|
46
|
+
/** Wraps a Transition submodel message for delegation. */
|
|
47
|
+
export declare const GotTransitionMessage: import("../../schema").CallableTaggedStruct<"GotTransitionMessage", {
|
|
48
|
+
message: S.Union<[import("../../schema").CallableTaggedStruct<"Showed", {}>, import("../../schema").CallableTaggedStruct<"Hidden", {}>, import("../../schema").CallableTaggedStruct<"AdvancedTransitionFrame", {}>, import("../../schema").CallableTaggedStruct<"EndedTransition", {}>]>;
|
|
49
|
+
}>;
|
|
48
50
|
/** Union of all messages the popover component can produce. */
|
|
49
51
|
export declare const Message: S.Union<[
|
|
50
52
|
typeof Opened,
|
|
@@ -59,9 +61,7 @@ export declare const Message: S.Union<[
|
|
|
59
61
|
typeof CompletedTeardownInert,
|
|
60
62
|
typeof IgnoredMouseClick,
|
|
61
63
|
typeof SuppressedSpaceScroll,
|
|
62
|
-
typeof
|
|
63
|
-
typeof EndedTransition,
|
|
64
|
-
typeof DetectedButtonMovement
|
|
64
|
+
typeof GotTransitionMessage
|
|
65
65
|
]>;
|
|
66
66
|
export type Opened = typeof Opened.Type;
|
|
67
67
|
export type Closed = typeof Closed.Type;
|
|
@@ -79,10 +79,6 @@ export type InitConfig = Readonly<{
|
|
|
79
79
|
/** Creates an initial popover model from a config. Defaults to closed. */
|
|
80
80
|
export declare const init: (config: InitConfig) => Model;
|
|
81
81
|
type UpdateReturn = readonly [Model, ReadonlyArray<Command.Command<Message>>];
|
|
82
|
-
/** Advances the popover's enter/leave transition by waiting a double-rAF. */
|
|
83
|
-
export declare const RequestFrame: Command.CommandDefinition<"RequestFrame", {
|
|
84
|
-
readonly _tag: "AdvancedTransitionFrame";
|
|
85
|
-
}>;
|
|
86
82
|
/** Prevents page scrolling while the popover is open in modal mode. */
|
|
87
83
|
export declare const LockScroll: Command.CommandDefinition<"LockScroll", {
|
|
88
84
|
readonly _tag: "CompletedLockScroll";
|
|
@@ -107,15 +103,18 @@ export declare const FocusPanel: Command.CommandDefinition<"FocusPanel", {
|
|
|
107
103
|
export declare const FocusButton: Command.CommandDefinition<"FocusButton", {
|
|
108
104
|
readonly _tag: "CompletedFocusButton";
|
|
109
105
|
}>;
|
|
110
|
-
/**
|
|
111
|
-
export declare const WaitForTransitions: Command.CommandDefinition<"WaitForTransitions", {
|
|
112
|
-
readonly _tag: "EndedTransition";
|
|
113
|
-
}>;
|
|
114
|
-
/** Detects whether the popover button moved or the leave transition ended — whichever comes first. */
|
|
106
|
+
/** Detects whether the popover button moved or the leave transition ended — whichever comes first. Both outcomes signal the Transition submodel that leave is complete. */
|
|
115
107
|
export declare const DetectMovementOrTransitionEnd: Command.CommandDefinition<"DetectMovementOrTransitionEnd", {
|
|
116
|
-
readonly _tag: "
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
readonly _tag: "GotTransitionMessage";
|
|
109
|
+
readonly message: {
|
|
110
|
+
readonly _tag: "Showed";
|
|
111
|
+
} | {
|
|
112
|
+
readonly _tag: "Hidden";
|
|
113
|
+
} | {
|
|
114
|
+
readonly _tag: "AdvancedTransitionFrame";
|
|
115
|
+
} | {
|
|
116
|
+
readonly _tag: "EndedTransition";
|
|
117
|
+
};
|
|
119
118
|
}>;
|
|
120
119
|
/** Processes a popover message and returns the next model and commands. */
|
|
121
120
|
export declare const update: (model: Model, message: Message) => UpdateReturn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/popover/index.ts"],"names":[],"mappings":"AA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