foldkit 0.101.0 → 0.102.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 -1
- package/dist/canvas/view.d.ts +1 -1
- package/dist/canvas/view.d.ts.map +1 -1
- package/dist/canvas/view.js +5 -5
- package/dist/command/index.d.ts +71 -0
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +34 -1
- package/dist/command/public.d.ts +1 -1
- package/dist/command/public.d.ts.map +1 -1
- package/dist/command/public.js +1 -1
- package/dist/devTools/overlay.d.ts.map +1 -1
- package/dist/devTools/overlay.js +137 -110
- package/dist/dom/dom.d.ts +8 -11
- package/dist/dom/dom.d.ts.map +1 -1
- package/dist/dom/dom.js +8 -11
- package/dist/dom/elementMovement.d.ts +1 -3
- package/dist/dom/elementMovement.d.ts.map +1 -1
- package/dist/dom/elementMovement.js +1 -3
- package/dist/dom/inert.d.ts +2 -4
- package/dist/dom/inert.d.ts.map +1 -1
- package/dist/dom/inert.js +2 -4
- package/dist/dom/scrollLock.d.ts +2 -2
- package/dist/dom/scrollLock.js +2 -2
- package/dist/dom/waitForAnimation.d.ts +1 -1
- package/dist/dom/waitForAnimation.js +1 -1
- package/dist/html/boundary.d.ts +98 -0
- package/dist/html/boundary.d.ts.map +1 -0
- package/dist/html/boundary.js +176 -0
- package/dist/html/childAttribute.d.ts +44 -0
- package/dist/html/childAttribute.d.ts.map +1 -0
- package/dist/html/childAttribute.js +34 -0
- package/dist/html/index.d.ts +70 -23
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +639 -575
- package/dist/html/lazy.d.ts +12 -7
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +30 -11
- package/dist/html/public.d.ts +2 -2
- package/dist/html/public.d.ts.map +1 -1
- package/dist/html/public.js +1 -1
- package/dist/html/runtimeSingleton.d.ts +72 -0
- package/dist/html/runtimeSingleton.d.ts.map +1 -0
- package/dist/html/runtimeSingleton.js +112 -0
- package/dist/html/submodel.d.ts +98 -0
- package/dist/html/submodel.d.ts.map +1 -0
- package/dist/html/submodel.js +190 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/render/render.d.ts +1 -1
- package/dist/render/render.js +1 -1
- package/dist/runtime/messagePriority.d.ts +5 -1
- package/dist/runtime/messagePriority.d.ts.map +1 -1
- package/dist/runtime/messagePriority.js +25 -4
- package/dist/runtime/runtime.d.ts +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +115 -61
- package/dist/submodel/public.d.ts +4 -0
- package/dist/submodel/public.d.ts.map +1 -0
- package/dist/submodel/public.js +1 -0
- package/dist/submodel/submodel.d.ts +32 -0
- package/dist/submodel/submodel.d.ts.map +1 -0
- package/dist/submodel/submodel.js +1 -0
- package/dist/test/apps/disabledButton.d.ts +4 -5
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +16 -16
- package/dist/test/scene.d.ts +8 -8
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +25 -13
- package/dist/test/story.d.ts +15 -8
- package/dist/test/story.d.ts.map +1 -1
- package/dist/test/story.js +21 -9
- package/dist/ui/animation/index.d.ts +30 -14
- package/dist/ui/animation/index.d.ts.map +1 -1
- package/dist/ui/animation/index.js +9 -19
- package/dist/ui/animation/public.d.ts +2 -2
- package/dist/ui/animation/public.d.ts.map +1 -1
- package/dist/ui/animation/public.js +1 -1
- package/dist/ui/calendar/index.d.ts +199 -84
- package/dist/ui/calendar/index.d.ts.map +1 -1
- package/dist/ui/calendar/index.js +129 -140
- package/dist/ui/calendar/public.d.ts +2 -2
- package/dist/ui/calendar/public.d.ts.map +1 -1
- package/dist/ui/calendar/public.js +1 -1
- package/dist/ui/checkbox/index.d.ts +93 -21
- package/dist/ui/checkbox/index.d.ts.map +1 -1
- package/dist/ui/checkbox/index.js +62 -33
- package/dist/ui/checkbox/public.d.ts +2 -2
- package/dist/ui/checkbox/public.d.ts.map +1 -1
- package/dist/ui/checkbox/public.js +1 -1
- package/dist/ui/combobox/multi.d.ts +35 -91
- package/dist/ui/combobox/multi.d.ts.map +1 -1
- package/dist/ui/combobox/multi.js +34 -17
- package/dist/ui/combobox/multiPublic.d.ts +2 -2
- package/dist/ui/combobox/multiPublic.d.ts.map +1 -1
- package/dist/ui/combobox/multiPublic.js +1 -1
- package/dist/ui/combobox/public.d.ts +3 -3
- package/dist/ui/combobox/public.d.ts.map +1 -1
- package/dist/ui/combobox/public.js +2 -2
- package/dist/ui/combobox/shared.d.ts +56 -31
- package/dist/ui/combobox/shared.d.ts.map +1 -1
- package/dist/ui/combobox/shared.js +333 -322
- package/dist/ui/combobox/single.d.ts +46 -93
- package/dist/ui/combobox/single.d.ts.map +1 -1
- package/dist/ui/combobox/single.js +44 -17
- package/dist/ui/datePicker/index.d.ts +256 -48
- package/dist/ui/datePicker/index.d.ts.map +1 -1
- package/dist/ui/datePicker/index.js +149 -104
- package/dist/ui/datePicker/public.d.ts +2 -2
- package/dist/ui/datePicker/public.d.ts.map +1 -1
- package/dist/ui/datePicker/public.js +1 -1
- package/dist/ui/dialog/index.d.ts +95 -39
- package/dist/ui/dialog/index.d.ts.map +1 -1
- package/dist/ui/dialog/index.js +71 -62
- package/dist/ui/dialog/public.d.ts +2 -2
- package/dist/ui/dialog/public.d.ts.map +1 -1
- package/dist/ui/dialog/public.js +1 -1
- package/dist/ui/disclosure/index.d.ts +71 -31
- package/dist/ui/disclosure/index.d.ts.map +1 -1
- package/dist/ui/disclosure/index.js +57 -62
- package/dist/ui/disclosure/public.d.ts +2 -2
- package/dist/ui/disclosure/public.d.ts.map +1 -1
- package/dist/ui/disclosure/public.js +1 -1
- package/dist/ui/dragAndDrop/index.d.ts +6 -6
- package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/index.js +7 -7
- package/dist/ui/dragAndDrop/public.d.ts +1 -1
- package/dist/ui/dragAndDrop/public.d.ts.map +1 -1
- package/dist/ui/dragAndDrop/public.js +1 -1
- package/dist/ui/fileDrop/index.d.ts +42 -46
- package/dist/ui/fileDrop/index.d.ts.map +1 -1
- package/dist/ui/fileDrop/index.js +30 -46
- package/dist/ui/fileDrop/public.d.ts +2 -2
- package/dist/ui/fileDrop/public.d.ts.map +1 -1
- package/dist/ui/fileDrop/public.js +1 -1
- package/dist/ui/listbox/multi.d.ts +39 -84
- package/dist/ui/listbox/multi.d.ts.map +1 -1
- package/dist/ui/listbox/multi.js +38 -20
- package/dist/ui/listbox/multiPublic.d.ts +2 -2
- package/dist/ui/listbox/multiPublic.d.ts.map +1 -1
- package/dist/ui/listbox/multiPublic.js +1 -1
- package/dist/ui/listbox/public.d.ts +3 -3
- package/dist/ui/listbox/public.d.ts.map +1 -1
- package/dist/ui/listbox/public.js +2 -2
- package/dist/ui/listbox/shared.d.ts +71 -30
- package/dist/ui/listbox/shared.d.ts.map +1 -1
- package/dist/ui/listbox/shared.js +319 -296
- package/dist/ui/listbox/single.d.ts +57 -85
- package/dist/ui/listbox/single.d.ts.map +1 -1
- package/dist/ui/listbox/single.js +48 -24
- package/dist/ui/menu/index.d.ts +80 -36
- package/dist/ui/menu/index.d.ts.map +1 -1
- package/dist/ui/menu/index.js +117 -86
- package/dist/ui/menu/public.d.ts +2 -2
- package/dist/ui/menu/public.d.ts.map +1 -1
- package/dist/ui/menu/public.js +1 -1
- package/dist/ui/popover/index.d.ts +117 -44
- package/dist/ui/popover/index.d.ts.map +1 -1
- package/dist/ui/popover/index.js +88 -101
- package/dist/ui/popover/public.d.ts +2 -2
- package/dist/ui/popover/public.d.ts.map +1 -1
- package/dist/ui/popover/public.js +1 -1
- package/dist/ui/radioGroup/index.d.ts +122 -45
- package/dist/ui/radioGroup/index.d.ts.map +1 -1
- package/dist/ui/radioGroup/index.js +111 -72
- package/dist/ui/radioGroup/public.d.ts +2 -2
- package/dist/ui/radioGroup/public.d.ts.map +1 -1
- package/dist/ui/radioGroup/public.js +1 -1
- package/dist/ui/slider/index.d.ts +72 -34
- package/dist/ui/slider/index.d.ts.map +1 -1
- package/dist/ui/slider/index.js +40 -49
- package/dist/ui/slider/public.d.ts +2 -2
- package/dist/ui/slider/public.d.ts.map +1 -1
- package/dist/ui/slider/public.js +1 -1
- package/dist/ui/switch/index.d.ts +74 -21
- package/dist/ui/switch/index.d.ts.map +1 -1
- package/dist/ui/switch/index.js +62 -33
- package/dist/ui/switch/public.d.ts +2 -2
- package/dist/ui/switch/public.d.ts.map +1 -1
- package/dist/ui/switch/public.js +1 -1
- package/dist/ui/tabs/index.d.ts +107 -45
- package/dist/ui/tabs/index.d.ts.map +1 -1
- package/dist/ui/tabs/index.js +99 -81
- package/dist/ui/tabs/public.d.ts +2 -2
- package/dist/ui/tabs/public.d.ts.map +1 -1
- package/dist/ui/tabs/public.js +1 -1
- package/dist/ui/toast/index.d.ts +93 -109
- package/dist/ui/toast/index.d.ts.map +1 -1
- package/dist/ui/toast/index.js +16 -29
- package/dist/ui/toast/schema.d.ts +15 -4
- package/dist/ui/toast/schema.d.ts.map +1 -1
- package/dist/ui/toast/schema.js +11 -4
- package/dist/ui/toast/update.d.ts +36 -18
- package/dist/ui/toast/update.d.ts.map +1 -1
- package/dist/ui/toast/update.js +33 -14
- package/dist/ui/tooltip/index.d.ts +94 -42
- package/dist/ui/tooltip/index.d.ts.map +1 -1
- package/dist/ui/tooltip/index.js +64 -73
- package/dist/ui/tooltip/public.d.ts +2 -2
- package/dist/ui/tooltip/public.d.ts.map +1 -1
- package/dist/ui/tooltip/public.js +1 -1
- package/dist/ui/virtualList/index.d.ts +18 -41
- package/dist/ui/virtualList/index.d.ts.map +1 -1
- package/dist/ui/virtualList/index.js +17 -37
- package/dist/ui/virtualList/public.d.ts +2 -2
- package/dist/ui/virtualList/public.d.ts.map +1 -1
- package/dist/ui/virtualList/public.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import type * as Command from '../../command/index.js';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { SubmodelView } from '../../html/index.js';
|
|
4
|
+
import type { Reflect } from '../../submodel/submodel.js';
|
|
5
|
+
import { type BaseInitConfig, type BaseViewInputs, type Message, type OutMessage } from './shared.js';
|
|
5
6
|
/** Schema for the listbox component's state, tracking open/closed status, active item, selected item, activation trigger, and typeahead search. */
|
|
6
7
|
export declare const Model: S.Struct<{
|
|
7
8
|
readonly maybeSelectedItem: S.Option<S.String>;
|
|
@@ -32,7 +33,7 @@ export type InitConfig = BaseInitConfig & Readonly<{
|
|
|
32
33
|
}>;
|
|
33
34
|
/** Creates an initial single-select listbox model from a config. Defaults to closed with no active item and no selection. */
|
|
34
35
|
export declare const init: (config: InitConfig) => Model;
|
|
35
|
-
/** Processes a listbox message and returns the next model and
|
|
36
|
+
/** Processes a listbox message and returns the next model, commands, and optional OutMessage. Closes the listbox on selection (single-select behavior); emits a `Selected({ value, wasAdded: true })` OutMessage. */
|
|
36
37
|
export declare const update: (model: {
|
|
37
38
|
readonly maybeSelectedItem: Option.Option<string>;
|
|
38
39
|
readonly id: string;
|
|
@@ -114,9 +115,9 @@ export declare const update: (model: {
|
|
|
114
115
|
} | {
|
|
115
116
|
readonly _tag: "CompletedUnlockScroll";
|
|
116
117
|
} | {
|
|
117
|
-
readonly _tag: "
|
|
118
|
+
readonly _tag: "CompletedInertOthers";
|
|
118
119
|
} | {
|
|
119
|
-
readonly _tag: "
|
|
120
|
+
readonly _tag: "CompletedRestoreInert";
|
|
120
121
|
} | {
|
|
121
122
|
readonly _tag: "CompletedFocusButton";
|
|
122
123
|
} | {
|
|
@@ -149,88 +150,59 @@ export declare const update: (model: {
|
|
|
149
150
|
readonly pointerType: string;
|
|
150
151
|
readonly button: number;
|
|
151
152
|
}, never, never>;
|
|
152
|
-
}>[]
|
|
153
|
+
}>[], Option.Option<Readonly<{
|
|
154
|
+
readonly _tag: "Selected";
|
|
155
|
+
readonly value: string;
|
|
156
|
+
readonly wasAdded: boolean;
|
|
157
|
+
}>>];
|
|
158
|
+
type UpdateReturn = ReturnType<typeof update>;
|
|
153
159
|
/** Programmatically opens the listbox, updating the model and returning
|
|
154
160
|
* focus and modal commands. Use this in domain-event handlers to open the listbox. */
|
|
155
|
-
export declare const open: (model: Model) =>
|
|
161
|
+
export declare const open: (model: Model) => UpdateReturn;
|
|
156
162
|
/** Programmatically closes the listbox, updating the model and returning
|
|
157
163
|
* focus and modal commands. Use this in domain-event handlers to close the listbox. */
|
|
158
|
-
export declare const close: (model: Model) =>
|
|
159
|
-
/** Programmatically selects an item in the single-select listbox, closing the listbox and
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}>;
|
|
203
|
-
isItemDisabled?: (item: Item, index: number) => boolean;
|
|
204
|
-
itemToSearchText?: (item: Item, index: number) => string;
|
|
205
|
-
itemToValue?: (item: Item) => string;
|
|
206
|
-
isButtonDisabled?: boolean;
|
|
207
|
-
buttonContent: Html;
|
|
208
|
-
buttonClassName?: string;
|
|
209
|
-
buttonAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
210
|
-
itemsClassName?: string;
|
|
211
|
-
itemsAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
212
|
-
itemsScrollClassName?: string;
|
|
213
|
-
itemsScrollAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
214
|
-
backdropClassName?: string;
|
|
215
|
-
backdropAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
216
|
-
className?: string;
|
|
217
|
-
attributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
218
|
-
itemGroupKey?: (item: Item, index: number) => string;
|
|
219
|
-
groupToHeading?: (groupKey: string) => Readonly<{
|
|
220
|
-
content: Html;
|
|
221
|
-
className?: string;
|
|
222
|
-
}> | undefined;
|
|
223
|
-
groupClassName?: string;
|
|
224
|
-
groupAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
225
|
-
separatorClassName?: string;
|
|
226
|
-
separatorAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
|
|
227
|
-
anchor?: import("./public.js").AnchorConfig;
|
|
228
|
-
name?: string;
|
|
229
|
-
form?: string;
|
|
230
|
-
isDisabled?: boolean;
|
|
231
|
-
isInvalid?: boolean;
|
|
232
|
-
}>) => Html;
|
|
233
|
-
/** Creates a memoized single-select listbox view. Static config is captured in a closure;
|
|
234
|
-
* only `model` and `toParentMessage` are compared per render via `createLazy`. */
|
|
235
|
-
export declare const lazy: <ParentMessage, Item>(staticConfig: Omit<ViewConfig<ParentMessage, Item>, "model" | "toParentMessage" | "onSelectedItem">) => ((model: Model, toParentMessage: BaseViewConfig<ParentMessage, Item, Model>["toParentMessage"]) => Html);
|
|
164
|
+
export declare const close: (model: Model) => UpdateReturn;
|
|
165
|
+
/** Programmatically selects an item in the single-select listbox, closing the listbox and emitting a `Selected({ value, wasAdded: true })` OutMessage. */
|
|
166
|
+
export declare const selectItem: (model: Model, item: string) => UpdateReturn;
|
|
167
|
+
/** Reflects an externally-sourced selection onto the model without
|
|
168
|
+
* emitting an OutMessage or running the user-selection side effects (no
|
|
169
|
+
* close, no focus). Use this to mirror external truth (a URL parameter,
|
|
170
|
+
* restored storage, a server push) onto the listbox's selection.
|
|
171
|
+
* Contrast with `selectItem`, which represents a user or programmatic
|
|
172
|
+
* *choice*: it closes the listbox, restores focus, and emits `Selected`.
|
|
173
|
+
* `reflect` returns the model directly because it produces no commands and
|
|
174
|
+
* no OutMessage, so a parent reflecting external state cannot
|
|
175
|
+
* accidentally echo it back out. */
|
|
176
|
+
export declare const reflectSelectedItem: Reflect<Model, Option.Option<string>>;
|
|
177
|
+
/** Per-render view inputs passed to the view via `h.submodel`'s `viewInputs` field. */
|
|
178
|
+
export type ViewInputs<Item, Value extends string = string> = BaseViewInputs<Item, Value>;
|
|
179
|
+
/** Pairs the single-select listbox's `view` and `update` (and programmatic
|
|
180
|
+
* helpers) behind a single Item-typed entry point. Declaring the listbox
|
|
181
|
+
* once at module scope ensures the view's `Item` type and the update's
|
|
182
|
+
* OutMessage `item` type can't drift:
|
|
183
|
+
*
|
|
184
|
+
* ```ts
|
|
185
|
+
* const ColorListbox = Ui.Listbox.create<Color>()
|
|
186
|
+
*
|
|
187
|
+
* // In view:
|
|
188
|
+
* h.submodel({ view: ColorListbox.view, ... })
|
|
189
|
+
*
|
|
190
|
+
* // In update:
|
|
191
|
+
* const [next, commands, maybeOutMessage] = ColorListbox.update(model, message)
|
|
192
|
+
* // maybeOutMessage: Option<Listbox.OutMessage<Color>>
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* Two type params support object-typed items with an `itemToValue`
|
|
196
|
+
* extractor: pass `<Person, string>` when items are objects whose
|
|
197
|
+
* extracted value is a plain string. `Value` defaults to `Item` when
|
|
198
|
+
* `Item extends string`, else defaults to `string`. */
|
|
199
|
+
export declare const create: <Item = string, Value extends string = Item extends string ? Item : string>() => Readonly<{
|
|
200
|
+
view: SubmodelView<Model, Message, BaseViewInputs<Item, Value>>;
|
|
201
|
+
update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
202
|
+
selectItem: (model: Model, item: Value) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
203
|
+
open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
204
|
+
close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
|
|
205
|
+
reflectSelectedItem: Reflect<Model, Option.Option<Value>>;
|
|
206
|
+
}>;
|
|
207
|
+
export {};
|
|
236
208
|
//# sourceMappingURL=single.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../../src/ui/listbox/single.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../../src/ui/listbox/single.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE7D,OAAO,KAAK,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EAEnB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAMhB,MAAM,aAAa,CAAA;AAIpB,mJAAmJ;AACnJ,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,6RAA6R;AAC7R,MAAM,MAAM,UAAU,GAAG,cAAc,GACrC,QAAQ,CAAC;IACP,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC,CAAA;AAEJ,6HA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,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,UAAU,EAAE,CACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,KAAK,KACR,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,IAAI,EAAE,CACJ,KAAK,EAAE,KAAK,KACT,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,KAAK,EAAE,CACL,KAAK,EAAE,KAAK,KACT,SAAS,CACZ,KAAK,EACL,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACvC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CACjC,CAAA;IACD,mBAAmB,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;CAC1D,CAqBA,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Array, Option, Schema as S } from 'effect';
|
|
2
|
-
import { createLazy } from '../../html/index.js';
|
|
1
|
+
import { Array, Function, Option, Schema as S } from 'effect';
|
|
3
2
|
import { evo } from '../../struct/index.js';
|
|
4
|
-
import { BaseModel, Closed, Opened, SelectedItem, baseInit, makeUpdate, makeView, } from './shared.js';
|
|
3
|
+
import { BaseModel, Closed, Opened, SelectedItem, Selected as SharedSelected, baseInit, makeUpdate, makeView, } from './shared.js';
|
|
5
4
|
// MODEL
|
|
6
5
|
/** Schema for the listbox component's state, tracking open/closed status, active item, selected item, activation trigger, and typeahead search. */
|
|
7
6
|
export const Model = S.Struct({
|
|
@@ -14,36 +13,61 @@ export const init = (config) => ({
|
|
|
14
13
|
maybeSelectedItem: Option.fromNullishOr(config.selectedItem),
|
|
15
14
|
});
|
|
16
15
|
// UPDATE
|
|
17
|
-
/** Processes a listbox message and returns the next model and
|
|
18
|
-
export const update = makeUpdate((model, item, context) => {
|
|
19
|
-
const [closedModelResult, commands] = context.closeWithFocus(model);
|
|
20
|
-
return [
|
|
21
|
-
evo(closedModelResult, { maybeSelectedItem: () => Option.some(item) }),
|
|
22
|
-
commands,
|
|
23
|
-
];
|
|
24
|
-
});
|
|
16
|
+
/** Processes a listbox message and returns the next model, commands, and optional OutMessage. Closes the listbox on selection (single-select behavior); emits a `Selected({ value, wasAdded: true })` OutMessage. */
|
|
17
|
+
export const update = makeUpdate((model, item, context) => context.closeWithFocus(evo(model, { maybeSelectedItem: () => Option.some(item) }), Option.some(SharedSelected({ value: item, wasAdded: true }))));
|
|
25
18
|
/** Programmatically opens the listbox, updating the model and returning
|
|
26
19
|
* focus and modal commands. Use this in domain-event handlers to open the listbox. */
|
|
27
20
|
export const open = (model) => update(model, Opened({ maybeActiveItemIndex: Option.none() }));
|
|
28
21
|
/** Programmatically closes the listbox, updating the model and returning
|
|
29
22
|
* focus and modal commands. Use this in domain-event handlers to close the listbox. */
|
|
30
23
|
export const close = (model) => update(model, Closed());
|
|
31
|
-
/** Programmatically selects an item in the single-select listbox, closing the listbox and
|
|
32
|
-
* focus commands. Use this in domain-event handlers when the listbox uses `onSelectedItem`. */
|
|
24
|
+
/** Programmatically selects an item in the single-select listbox, closing the listbox and emitting a `Selected({ value, wasAdded: true })` OutMessage. */
|
|
33
25
|
export const selectItem = (model, item) => update(model, SelectedItem({ item }));
|
|
34
|
-
/**
|
|
35
|
-
|
|
26
|
+
/** Reflects an externally-sourced selection onto the model without
|
|
27
|
+
* emitting an OutMessage or running the user-selection side effects (no
|
|
28
|
+
* close, no focus). Use this to mirror external truth (a URL parameter,
|
|
29
|
+
* restored storage, a server push) onto the listbox's selection.
|
|
30
|
+
* Contrast with `selectItem`, which represents a user or programmatic
|
|
31
|
+
* *choice*: it closes the listbox, restores focus, and emits `Selected`.
|
|
32
|
+
* `reflect` returns the model directly because it produces no commands and
|
|
33
|
+
* no OutMessage, so a parent reflecting external state cannot
|
|
34
|
+
* accidentally echo it back out. */
|
|
35
|
+
export const reflectSelectedItem = Function.dual(2, (model, maybeItem) => evo(model, { maybeSelectedItem: () => maybeItem }));
|
|
36
|
+
const internalView = makeView({
|
|
36
37
|
isItemSelected: (model, itemValue) => Option.exists(model.maybeSelectedItem, selectedItem => selectedItem === itemValue),
|
|
37
38
|
selectedItemIndex: (model, items, itemToValue) => Option.flatMap(model.maybeSelectedItem, selectedItem => Array.findFirstIndex(items, item => itemToValue(item) === selectedItem)),
|
|
38
39
|
ariaMultiSelectable: false,
|
|
39
40
|
});
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
/** Pairs the single-select listbox's `view` and `update` (and programmatic
|
|
42
|
+
* helpers) behind a single Item-typed entry point. Declaring the listbox
|
|
43
|
+
* once at module scope ensures the view's `Item` type and the update's
|
|
44
|
+
* OutMessage `item` type can't drift:
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* const ColorListbox = Ui.Listbox.create<Color>()
|
|
48
|
+
*
|
|
49
|
+
* // In view:
|
|
50
|
+
* h.submodel({ view: ColorListbox.view, ... })
|
|
51
|
+
*
|
|
52
|
+
* // In update:
|
|
53
|
+
* const [next, commands, maybeOutMessage] = ColorListbox.update(model, message)
|
|
54
|
+
* // maybeOutMessage: Option<Listbox.OutMessage<Color>>
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* Two type params support object-typed items with an `itemToValue`
|
|
58
|
+
* extractor: pass `<Person, string>` when items are objects whose
|
|
59
|
+
* extracted value is a plain string. `Value` defaults to `Item` when
|
|
60
|
+
* `Item extends string`, else defaults to `string`. */
|
|
61
|
+
export const create = () => {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
63
|
+
const typedUpdate = update;
|
|
64
|
+
return {
|
|
65
|
+
view: internalView(),
|
|
66
|
+
update: typedUpdate,
|
|
67
|
+
selectItem: (model, item) => typedUpdate(model, SelectedItem({ item })),
|
|
68
|
+
open: model => typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() })),
|
|
69
|
+
close: model => typedUpdate(model, Closed()),
|
|
70
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
71
|
+
reflectSelectedItem: reflectSelectedItem,
|
|
72
|
+
};
|
|
49
73
|
};
|
package/dist/ui/menu/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Effect, Schema as S } from 'effect';
|
|
1
|
+
import { Effect, Option, Schema as S } from 'effect';
|
|
2
2
|
import * as Command from '../../command/index.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ChildAttribute, type Html, type SubmodelView } from '../../html/index.js';
|
|
4
4
|
import * as Mount from '../../mount/index.js';
|
|
5
5
|
import { AnchorConfig } from '../anchor.js';
|
|
6
6
|
import { groupContiguous } from '../group.js';
|
|
7
7
|
import { resolveTypeaheadMatch } from '../typeahead.js';
|
|
8
|
-
/** Schema for the activation trigger
|
|
8
|
+
/** Schema for the activation trigger: whether the user interacted via mouse or keyboard. */
|
|
9
9
|
export declare const ActivationTrigger: S.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
10
10
|
export type ActivationTrigger = typeof ActivationTrigger.Type;
|
|
11
11
|
/** Schema for the menu component's state, tracking open/closed status, active item, activation trigger, and typeahead search. */
|
|
@@ -35,7 +35,7 @@ export declare const Model: S.Struct<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
}>;
|
|
37
37
|
export type Model = typeof Model.Type;
|
|
38
|
-
/** Sent when the menu opens via button click or keyboard. Contains an optional initial active item index
|
|
38
|
+
/** Sent when the menu opens via button click or keyboard. Contains an optional initial active item index: None for pointer, Some for keyboard. */
|
|
39
39
|
export declare const Opened: import("../../schema/index.js").CallableTaggedStruct<"Opened", {
|
|
40
40
|
maybeActiveItemIndex: S.Option<S.Number>;
|
|
41
41
|
}>;
|
|
@@ -53,6 +53,7 @@ export declare const DeactivatedItem: import("../../schema/index.js").CallableTa
|
|
|
53
53
|
/** Sent when an item is selected via Enter, Space, or click. */
|
|
54
54
|
export declare const SelectedItem: import("../../schema/index.js").CallableTaggedStruct<"SelectedItem", {
|
|
55
55
|
index: S.Number;
|
|
56
|
+
item: S.String;
|
|
56
57
|
}>;
|
|
57
58
|
/** Sent when Enter or Space is pressed on the active item, triggering a programmatic click on the DOM element. */
|
|
58
59
|
export declare const RequestedItemClick: import("../../schema/index.js").CallableTaggedStruct<"RequestedItemClick", {
|
|
@@ -82,15 +83,13 @@ export declare const CompletedLockScroll: import("../../schema/index.js").Callab
|
|
|
82
83
|
/** Sent when the scroll unlock command completes. */
|
|
83
84
|
export declare const CompletedUnlockScroll: import("../../schema/index.js").CallableTaggedStruct<"CompletedUnlockScroll", {}>;
|
|
84
85
|
/** Sent when the inert-others command completes. */
|
|
85
|
-
export declare const
|
|
86
|
+
export declare const CompletedInertOthers: import("../../schema/index.js").CallableTaggedStruct<"CompletedInertOthers", {}>;
|
|
86
87
|
/** Sent when the restore-inert command completes. */
|
|
87
|
-
export declare const
|
|
88
|
+
export declare const CompletedRestoreInert: import("../../schema/index.js").CallableTaggedStruct<"CompletedRestoreInert", {}>;
|
|
88
89
|
/** Sent when the scroll-into-view command completes after keyboard activation. */
|
|
89
90
|
export declare const CompletedScrollIntoView: import("../../schema/index.js").CallableTaggedStruct<"CompletedScrollIntoView", {}>;
|
|
90
91
|
/** Sent when the programmatic click command completes. */
|
|
91
92
|
export declare const CompletedClickItem: import("../../schema/index.js").CallableTaggedStruct<"CompletedClickItem", {}>;
|
|
92
|
-
/** Sent when the advance-focus command completes. */
|
|
93
|
-
export declare const CompletedAdvanceFocus: import("../../schema/index.js").CallableTaggedStruct<"CompletedAdvanceFocus", {}>;
|
|
94
93
|
/** Sent when a mouse click on the button is ignored because pointer-down already handled the toggle. */
|
|
95
94
|
export declare const IgnoredMouseClick: import("../../schema/index.js").CallableTaggedStruct<"IgnoredMouseClick", {}>;
|
|
96
95
|
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
@@ -133,11 +132,10 @@ export declare const Message: S.Union<[
|
|
|
133
132
|
typeof CompletedFocusButton,
|
|
134
133
|
typeof CompletedLockScroll,
|
|
135
134
|
typeof CompletedUnlockScroll,
|
|
136
|
-
typeof
|
|
137
|
-
typeof
|
|
135
|
+
typeof CompletedInertOthers,
|
|
136
|
+
typeof CompletedRestoreInert,
|
|
138
137
|
typeof CompletedScrollIntoView,
|
|
139
138
|
typeof CompletedClickItem,
|
|
140
|
-
typeof CompletedAdvanceFocus,
|
|
141
139
|
typeof IgnoredMouseClick,
|
|
142
140
|
typeof SuppressedSpaceScroll,
|
|
143
141
|
typeof CompletedAnchorMenu,
|
|
@@ -147,6 +145,25 @@ export declare const Message: S.Union<[
|
|
|
147
145
|
typeof ReleasedPointerOnItems
|
|
148
146
|
]>;
|
|
149
147
|
export type Message = typeof Message.Type;
|
|
148
|
+
/** Sent to the parent when a menu item is selected. Carries both the selected value (from the `viewInputs.items` array supplied at view time) and its index. The menu has already closed when this fires; the parent does not need to dispatch `Ui.Menu.close`. */
|
|
149
|
+
export declare const Selected: import("../../schema/index.js").CallableTaggedStruct<"Selected", {
|
|
150
|
+
value: S.String;
|
|
151
|
+
index: S.Number;
|
|
152
|
+
}>;
|
|
153
|
+
export type Selected<Value extends string = string> = Readonly<{
|
|
154
|
+
readonly _tag: 'Selected';
|
|
155
|
+
readonly value: Value;
|
|
156
|
+
readonly index: number;
|
|
157
|
+
}>;
|
|
158
|
+
/** Union of out-messages the menu component can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
|
|
159
|
+
export declare const OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"Selected", {
|
|
160
|
+
value: S.String;
|
|
161
|
+
index: S.Number;
|
|
162
|
+
}>]>;
|
|
163
|
+
/** Generic over `Value extends string` so consumers using the typed
|
|
164
|
+
* `Ui.Menu.create<MyUnion>()` factory receive `value: MyUnion` in the
|
|
165
|
+
* `Selected` OutMessage. Defaults to `string`. */
|
|
166
|
+
export type OutMessage<Value extends string = string> = Selected<Value>;
|
|
150
167
|
export type Opened = typeof Opened.Type;
|
|
151
168
|
export type Closed = typeof Closed.Type;
|
|
152
169
|
export type BlurredItems = typeof BlurredItems.Type;
|
|
@@ -169,7 +186,11 @@ export type InitConfig = Readonly<{
|
|
|
169
186
|
}>;
|
|
170
187
|
/** Creates an initial menu model from a config. Defaults to closed with no active item. */
|
|
171
188
|
export declare const init: (config: InitConfig) => Model;
|
|
172
|
-
type UpdateReturn = readonly [
|
|
189
|
+
type UpdateReturn = readonly [
|
|
190
|
+
Model,
|
|
191
|
+
ReadonlyArray<Command.Command<Message>>,
|
|
192
|
+
Option.Option<OutMessage>
|
|
193
|
+
];
|
|
173
194
|
/** Prevents page scrolling while the menu is open. */
|
|
174
195
|
export declare const LockScroll: Command.CommandDefinitionNoArgs<"LockScroll", Effect.Effect<{
|
|
175
196
|
readonly _tag: "CompletedLockScroll";
|
|
@@ -182,13 +203,13 @@ export declare const UnlockScroll: Command.CommandDefinitionNoArgs<"UnlockScroll
|
|
|
182
203
|
export declare const InertOthers: Command.CommandDefinitionWithArgs<"InertOthers", {
|
|
183
204
|
id: S.String;
|
|
184
205
|
}, Effect.Effect<{
|
|
185
|
-
readonly _tag: "
|
|
206
|
+
readonly _tag: "CompletedInertOthers";
|
|
186
207
|
}, never, never>>;
|
|
187
208
|
/** Removes the inert attribute from elements outside the menu. */
|
|
188
209
|
export declare const RestoreInert: Command.CommandDefinitionWithArgs<"RestoreInert", {
|
|
189
210
|
id: S.String;
|
|
190
211
|
}, Effect.Effect<{
|
|
191
|
-
readonly _tag: "
|
|
212
|
+
readonly _tag: "CompletedRestoreInert";
|
|
192
213
|
}, never, never>>;
|
|
193
214
|
/** Moves focus to the menu items container after opening. */
|
|
194
215
|
export declare const FocusItems: Command.CommandDefinitionWithArgs<"FocusItems", {
|
|
@@ -263,13 +284,13 @@ export declare const PortalMenuBackdrop: Mount.MountDefinitionNoArgs<"PortalMenu
|
|
|
263
284
|
}>;
|
|
264
285
|
/** Programmatically opens the menu, updating the model and returning
|
|
265
286
|
* focus and modal commands. Use this in domain-event handlers to open the menu. */
|
|
266
|
-
export declare const open: (model: Model) =>
|
|
287
|
+
export declare const open: (model: Model) => UpdateReturn;
|
|
267
288
|
/** Programmatically closes the menu, updating the model and returning
|
|
268
289
|
* focus and modal commands. Use this in domain-event handlers to close the menu. */
|
|
269
|
-
export declare const close: (model: Model) =>
|
|
270
|
-
/** Programmatically selects a menu item
|
|
271
|
-
* focus commands. Use this in domain-event handlers
|
|
272
|
-
export declare const selectItem: (model: Model, index: number) =>
|
|
290
|
+
export declare const close: (model: Model) => UpdateReturn;
|
|
291
|
+
/** Programmatically selects a menu item, closing the menu and returning
|
|
292
|
+
* focus commands plus a `Selected` OutMessage. Use this in domain-event handlers. */
|
|
293
|
+
export declare const selectItem: (model: Model, item: string, index: number) => UpdateReturn;
|
|
273
294
|
/** Configuration for an individual menu item's appearance. */
|
|
274
295
|
export type ItemConfig = Readonly<{
|
|
275
296
|
className?: string;
|
|
@@ -280,11 +301,12 @@ export type GroupHeading = Readonly<{
|
|
|
280
301
|
content: Html;
|
|
281
302
|
className?: string;
|
|
282
303
|
}>;
|
|
283
|
-
/**
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
304
|
+
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
|
|
305
|
+
*
|
|
306
|
+
* The Menu emits a `Selected({ value, index })` OutMessage on commit.
|
|
307
|
+
* The menu has already closed by the time this fires; consumers
|
|
308
|
+
* pattern-match it in their `GotMenuMessage` handler to react. */
|
|
309
|
+
export type ViewInputs<Item extends string> = Readonly<{
|
|
288
310
|
items: ReadonlyArray<Item>;
|
|
289
311
|
itemToConfig: (item: Item, context: Readonly<{
|
|
290
312
|
isActive: boolean;
|
|
@@ -295,27 +317,49 @@ export type ViewConfig<ParentMessage, Item extends string> = Readonly<{
|
|
|
295
317
|
isButtonDisabled?: boolean;
|
|
296
318
|
buttonContent: Html;
|
|
297
319
|
buttonClassName?: string;
|
|
298
|
-
buttonAttributes?: ReadonlyArray<
|
|
320
|
+
buttonAttributes?: ReadonlyArray<ChildAttribute>;
|
|
299
321
|
itemsClassName?: string;
|
|
300
|
-
itemsAttributes?: ReadonlyArray<
|
|
322
|
+
itemsAttributes?: ReadonlyArray<ChildAttribute>;
|
|
301
323
|
itemsScrollClassName?: string;
|
|
302
|
-
itemsScrollAttributes?: ReadonlyArray<
|
|
324
|
+
itemsScrollAttributes?: ReadonlyArray<ChildAttribute>;
|
|
303
325
|
backdropClassName?: string;
|
|
304
|
-
backdropAttributes?: ReadonlyArray<
|
|
326
|
+
backdropAttributes?: ReadonlyArray<ChildAttribute>;
|
|
305
327
|
className?: string;
|
|
306
|
-
attributes?: ReadonlyArray<
|
|
328
|
+
attributes?: ReadonlyArray<ChildAttribute>;
|
|
307
329
|
itemGroupKey?: (item: Item, index: number) => string;
|
|
308
330
|
groupToHeading?: (groupKey: string) => GroupHeading | undefined;
|
|
309
331
|
groupClassName?: string;
|
|
310
|
-
groupAttributes?: ReadonlyArray<
|
|
332
|
+
groupAttributes?: ReadonlyArray<ChildAttribute>;
|
|
311
333
|
separatorClassName?: string;
|
|
312
|
-
separatorAttributes?: ReadonlyArray<
|
|
334
|
+
separatorAttributes?: ReadonlyArray<ChildAttribute>;
|
|
313
335
|
anchor?: AnchorConfig;
|
|
314
336
|
}>;
|
|
315
337
|
export { groupContiguous, resolveTypeaheadMatch };
|
|
316
|
-
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
338
|
+
/** Headless menu view with typeahead search, keyboard navigation,
|
|
339
|
+
* and aria-activedescendant focus management. Obtained from
|
|
340
|
+
* `Ui.Menu.create<MyItem>().view`; not exported directly. */
|
|
341
|
+
type ViewForItem<Item extends string> = SubmodelView<Model, Message, ViewInputs<Item>>;
|
|
342
|
+
/** Pairs the menu's `view` and `update` (and programmatic helpers)
|
|
343
|
+
* behind a single Item-typed entry point. Declaring the menu once at
|
|
344
|
+
* module scope ensures the view's `Item` type and the OutMessage's
|
|
345
|
+
* `item` type can't drift:
|
|
346
|
+
*
|
|
347
|
+
* ```ts
|
|
348
|
+
* const ActionMenu = Ui.Menu.create<Action>()
|
|
349
|
+
*
|
|
350
|
+
* // In view:
|
|
351
|
+
* h.submodel({ view: ActionMenu.view, ... })
|
|
352
|
+
*
|
|
353
|
+
* // In update:
|
|
354
|
+
* const [next, commands, maybeOutMessage] = ActionMenu.update(model.menu, message)
|
|
355
|
+
* // maybeOutMessage: Option<Ui.Menu.OutMessage<Action>>
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
export declare const create: <Item extends string = string>() => Readonly<{
|
|
359
|
+
view: ViewForItem<Item>;
|
|
360
|
+
update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
361
|
+
selectItem: (model: Model, item: Item, index: number) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
362
|
+
open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
363
|
+
close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
364
|
+
}>;
|
|
321
365
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/menu/index.ts"],"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