@foldkit/ui 0.127.0 → 0.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/calendar/index.d.ts +17 -23
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +16 -25
- package/dist/calendar/public.d.ts +1 -1
- package/dist/calendar/public.d.ts.map +1 -1
- package/dist/calendar/public.js +1 -1
- package/dist/checkbox/index.d.ts +47 -104
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +48 -87
- package/dist/checkbox/public.d.ts +2 -2
- package/dist/checkbox/public.d.ts.map +1 -1
- package/dist/checkbox/public.js +1 -1
- package/dist/combobox/multi.d.ts +19 -30
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +32 -53
- package/dist/combobox/public.d.ts +2 -2
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +59 -35
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +58 -45
- package/dist/combobox/single.d.ts +36 -48
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +49 -76
- package/dist/datePicker/index.d.ts +33 -41
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +31 -40
- package/dist/datePicker/public.d.ts +1 -1
- package/dist/datePicker/public.d.ts.map +1 -1
- package/dist/datePicker/public.js +1 -1
- package/dist/disclosure/index.d.ts +49 -113
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +35 -92
- package/dist/disclosure/public.d.ts +2 -2
- package/dist/disclosure/public.d.ts.map +1 -1
- package/dist/disclosure/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -21
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +12 -36
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/shared.d.ts +28 -20
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +6 -7
- package/dist/listbox/single.d.ts +17 -27
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +18 -30
- package/dist/radioGroup/index.d.ts +57 -142
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +44 -119
- package/dist/radioGroup/public.d.ts +2 -2
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +51 -27
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +66 -66
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/switch/index.d.ts +45 -92
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/switch/index.js +36 -81
- package/dist/switch/public.d.ts +2 -2
- package/dist/switch/public.d.ts.map +1 -1
- package/dist/switch/public.js +1 -1
- package/dist/tabs/index.d.ts +33 -33
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +36 -49
- package/dist/toast/index.d.ts +1 -0
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +1 -0
- package/dist/toast/public.d.ts +2 -0
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -0
- package/dist/toast/test.d.ts +41 -0
- package/dist/toast/test.d.ts.map +1 -0
- package/dist/toast/test.js +36 -0
- package/package.json +2 -2
package/dist/combobox/multi.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import type * as Command from 'foldkit/command';
|
|
3
|
-
import type {
|
|
3
|
+
import type { View as SubmodelView } from 'foldkit/submodel';
|
|
4
4
|
import { type BaseInitConfig, type BaseViewInputs, type Message, type OutMessage } from './shared.js';
|
|
5
|
-
/** Schema for the multi-select combobox
|
|
5
|
+
/** Schema for the multi-select combobox's private interaction state (open/closed status, active item, activation trigger, typed input value). The selection is owned by the parent and passed in via `ViewInputs.selectedValues`. */
|
|
6
6
|
export declare const Model: S.Struct<{
|
|
7
|
-
readonly selectedItems: S.$Array<S.String>;
|
|
8
7
|
readonly id: S.String;
|
|
9
8
|
readonly isOpen: S.Boolean;
|
|
10
9
|
readonly isAnimated: S.Boolean;
|
|
@@ -26,15 +25,12 @@ export declare const Model: S.Struct<{
|
|
|
26
25
|
}>>;
|
|
27
26
|
}>;
|
|
28
27
|
export type Model = typeof Model.Type;
|
|
29
|
-
/** Configuration for creating a multi-select combobox model with `init`. `isAnimated` enables CSS transition coordination (default `false`). `isModal` locks page scroll and inerts other elements when open (default `false`).
|
|
30
|
-
export type InitConfig = BaseInitConfig
|
|
31
|
-
|
|
32
|
-
}>;
|
|
33
|
-
/** Creates an initial multi-select combobox model from a config. Defaults to closed with no active item, empty input, and no selection. */
|
|
28
|
+
/** Configuration for creating a multi-select combobox model with `init`. `isAnimated` enables CSS transition coordination (default `false`). `isModal` locks page scroll and inerts other elements when open (default `false`). */
|
|
29
|
+
export type InitConfig = BaseInitConfig;
|
|
30
|
+
/** Creates an initial multi-select combobox model from a config. Defaults to closed with no active item and an empty input. */
|
|
34
31
|
export declare const init: (config: InitConfig) => Model;
|
|
35
|
-
/** Processes a combobox message and returns the next model and
|
|
32
|
+
/** Processes a combobox message and returns the next model, commands, and optional OutMessage. Stays open on selection (multi-select behavior); emits a `Selected({ value })` OutMessage the parent folds by toggling the value's membership, and `ClearedSelection` when a nullable combobox closes with an empty input. The multi-select input always rests empty on close, so it ignores the message's `restingInputValue`; multi consumers pass `''`. */
|
|
36
33
|
export declare const update: (model: S.Struct.ReadonlySide<{
|
|
37
|
-
readonly selectedItems: S.$Array<S.String>;
|
|
38
34
|
readonly id: S.String;
|
|
39
35
|
readonly isOpen: S.Boolean;
|
|
40
36
|
readonly isAnimated: S.Boolean;
|
|
@@ -55,7 +51,6 @@ export declare const update: (model: S.Struct.ReadonlySide<{
|
|
|
55
51
|
readonly screenY: S.Number;
|
|
56
52
|
}>>;
|
|
57
53
|
}, "Type">, message: Message) => readonly [S.Struct.ReadonlySide<{
|
|
58
|
-
readonly selectedItems: S.$Array<S.String>;
|
|
59
54
|
readonly id: S.String;
|
|
60
55
|
readonly isOpen: S.Boolean;
|
|
61
56
|
readonly isAnimated: S.Boolean;
|
|
@@ -86,20 +81,21 @@ export declare const update: (model: S.Struct.ReadonlySide<{
|
|
|
86
81
|
readonly _tag: S.tag<"CompletedInertOthers">;
|
|
87
82
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
88
83
|
readonly _tag: S.tag<"CompletedRestoreInert">;
|
|
89
|
-
}, "Type"> | S.Struct.ReadonlySide<{
|
|
90
|
-
readonly _tag: S.tag<"Closed">;
|
|
91
84
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
92
85
|
readonly _tag: S.tag<"Opened">;
|
|
93
86
|
maybeActiveItemIndex: S.Option<S.Number>;
|
|
87
|
+
}, "Type"> | S.Struct.ReadonlySide<{
|
|
88
|
+
readonly _tag: S.tag<"Closed">;
|
|
89
|
+
restingInputValue: S.String;
|
|
94
90
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
95
91
|
readonly _tag: S.tag<"BlurredInput">;
|
|
92
|
+
restingInputValue: S.String;
|
|
96
93
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
97
94
|
readonly _tag: S.tag<"ActivatedItem">;
|
|
98
95
|
index: S.Number;
|
|
99
96
|
activationTrigger: S.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
100
97
|
maybeImmediateSelection: S.Option<S.Struct<{
|
|
101
98
|
readonly item: S.String;
|
|
102
|
-
readonly displayText: S.String;
|
|
103
99
|
}>>;
|
|
104
100
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
105
101
|
readonly _tag: S.tag<"DeactivatedItem">;
|
|
@@ -107,6 +103,7 @@ export declare const update: (model: S.Struct.ReadonlySide<{
|
|
|
107
103
|
readonly _tag: S.tag<"SelectedItem">;
|
|
108
104
|
item: S.String;
|
|
109
105
|
displayText: S.String;
|
|
106
|
+
wasSelected: S.Boolean;
|
|
110
107
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
111
108
|
readonly _tag: S.tag<"MovedPointerOverItem">;
|
|
112
109
|
index: S.Number;
|
|
@@ -126,6 +123,7 @@ export declare const update: (model: S.Struct.ReadonlySide<{
|
|
|
126
123
|
value: S.String;
|
|
127
124
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
128
125
|
readonly _tag: S.tag<"PressedToggleButton">;
|
|
126
|
+
restingInputValue: S.String;
|
|
129
127
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
130
128
|
readonly _tag: S.tag<"CompletedAnchorCombobox">;
|
|
131
129
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
@@ -138,38 +136,29 @@ export declare const update: (model: S.Struct.ReadonlySide<{
|
|
|
138
136
|
readonly _tag: S.tag<"GotAnimationMessage">;
|
|
139
137
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
140
138
|
}, "Type">, never, never>;
|
|
141
|
-
}>[], Option.Option<
|
|
142
|
-
readonly _tag: "Selected";
|
|
143
|
-
readonly value: string;
|
|
144
|
-
readonly wasAdded: boolean;
|
|
145
|
-
}>>];
|
|
139
|
+
}>[], Option.Option<OutMessage<string>>];
|
|
146
140
|
type UpdateReturn = ReturnType<typeof update>;
|
|
147
141
|
/** Programmatically opens the combobox, updating the model and returning
|
|
148
142
|
* focus and modal commands. Use this in domain-event handlers to open the combobox. */
|
|
149
143
|
export declare const open: (model: Model) => UpdateReturn;
|
|
150
144
|
/** Programmatically closes the combobox, updating the model and returning
|
|
151
|
-
* focus and modal commands.
|
|
145
|
+
* focus and modal commands. The multi-select input always rests empty on
|
|
146
|
+
* close. Use this in domain-event handlers to close the combobox. */
|
|
152
147
|
export declare const close: (model: Model) => UpdateReturn;
|
|
153
|
-
/** Programmatically
|
|
148
|
+
/** Programmatically activates an item in the multi-select combobox. Emits
|
|
149
|
+
* `Selected({ value })`; the parent toggles the value's membership. */
|
|
154
150
|
export declare const selectItem: (model: Model, item: string) => UpdateReturn;
|
|
155
|
-
/** Reflects an externally-sourced selection set onto the model without
|
|
156
|
-
* emitting an OutMessage or running selection side effects. Use this to
|
|
157
|
-
* mirror external truth (URL parameters, restored storage, a server push)
|
|
158
|
-
* onto the combobox's selected items. Contrast with `selectItem`, which
|
|
159
|
-
* toggles a single item as a user *choice* and emits `Selected`. Returns
|
|
160
|
-
* the model directly because it produces no commands and no OutMessage. */
|
|
161
|
-
export declare const reflectSelectedItems: Reflect<Model, ReadonlyArray<string>>;
|
|
162
151
|
/** Per-render view inputs passed to the view via `h.submodel`'s `viewInputs` field. */
|
|
163
152
|
export type ViewInputs<Item extends string> = BaseViewInputs<Item>;
|
|
164
153
|
/** Pairs the multi-select combobox's `view` and `update` (and programmatic
|
|
165
|
-
* helpers) behind a single Item-typed entry point.
|
|
154
|
+
* helpers) behind a single Item-typed entry point. `selectItem` emits
|
|
155
|
+
* `Selected({ value })`; the parent toggles the value's membership. */
|
|
166
156
|
export declare const create: <Item extends string = string>() => Readonly<{
|
|
167
157
|
view: SubmodelView<Model, Message, BaseViewInputs<Item>>;
|
|
168
158
|
update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
169
159
|
selectItem: (model: Model, item: Item) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
170
160
|
open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
171
161
|
close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
|
|
172
|
-
reflectSelectedItems: Reflect<Model, ReadonlyArray<Item>>;
|
|
173
162
|
}>;
|
|
174
163
|
export {};
|
|
175
164
|
//# sourceMappingURL=multi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi.d.ts","sourceRoot":"","sources":["../../src/combobox/multi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"multi.d.ts","sourceRoot":"","sources":["../../src/combobox/multi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,KAAK,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE/C,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE5D,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EAGnB,KAAK,OAAO,EAEZ,KAAK,UAAU,EAOhB,MAAM,aAAa,CAAA;AAIpB,qOAAqO;AACrO,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;EAEhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,mOAAmO;AACnO,MAAM,MAAM,UAAU,GAAG,cAAc,CAAA;AAEvC,+HAA+H;AAC/H,eAAO,MAAM,IAAI,GAAI,QAAQ,UAAU,KAAG,KAAyB,CAAA;AAInE,6bAA6b;AAC7b,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAyBjB,CAAA;AAEF,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAA;AAE7C;wFACwF;AACxF,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,KAAG,YAC4B,CAAA;AAEhE;;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AU,CAAC,IAAI,CAAC,CAAC,CAChC,CAAA;CACF,CAoBA,CAAA"}
|
package/dist/combobox/multi.js
CHANGED
|
@@ -1,81 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import { evo } from 'foldkit/struct';
|
|
3
|
-
import { BaseModel, Closed, Opened, SelectedItem, Selected as SharedSelected, baseInit, closedBaseModel, makeUpdate, makeView, } from './shared.js';
|
|
3
|
+
import { BaseModel, ClearedSelection, Closed, Opened, SelectedItem, Selected as SharedSelected, baseInit, closedBaseModel, makeUpdate, makeView, } from './shared.js';
|
|
4
4
|
// MODEL
|
|
5
|
-
/** Schema for the multi-select combobox
|
|
5
|
+
/** Schema for the multi-select combobox's private interaction state (open/closed status, active item, activation trigger, typed input value). The selection is owned by the parent and passed in via `ViewInputs.selectedValues`. */
|
|
6
6
|
export const Model = S.Struct({
|
|
7
7
|
...BaseModel.fields,
|
|
8
|
-
selectedItems: S.Array(S.String),
|
|
9
|
-
});
|
|
10
|
-
/** Creates an initial multi-select combobox model from a config. Defaults to closed with no active item, empty input, and no selection. */
|
|
11
|
-
export const init = (config) => ({
|
|
12
|
-
...baseInit(config),
|
|
13
|
-
selectedItems: config.selectedItems ?? [],
|
|
14
8
|
});
|
|
9
|
+
/** Creates an initial multi-select combobox model from a config. Defaults to closed with no active item and an empty input. */
|
|
10
|
+
export const init = (config) => baseInit(config);
|
|
15
11
|
// UPDATE
|
|
16
|
-
|
|
17
|
-
? Array.filter(selectedItems, selected => selected !== item)
|
|
18
|
-
: Array.append(selectedItems, item);
|
|
19
|
-
const emptySelection = [];
|
|
20
|
-
/** Processes a combobox message and returns the next model and commands. Stays open on selection and toggles item membership (multi-select behavior). */
|
|
12
|
+
/** Processes a combobox message and returns the next model, commands, and optional OutMessage. Stays open on selection (multi-select behavior); emits a `Selected({ value })` OutMessage the parent folds by toggling the value's membership, and `ClearedSelection` when a nullable combobox closes with an empty input. The multi-select input always rests empty on close, so it ignores the message's `restingInputValue`; multi consumers pass `''`. */
|
|
21
13
|
export const update = makeUpdate({
|
|
22
14
|
handleClose: model => {
|
|
23
15
|
if (model.nullable && model.inputValue === '') {
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
return [
|
|
17
|
+
evo(closedBaseModel(model), { inputValue: () => '' }),
|
|
18
|
+
Option.some(ClearedSelection()),
|
|
19
|
+
];
|
|
28
20
|
}
|
|
29
|
-
return evo(closedBaseModel(model), {
|
|
30
|
-
inputValue: () => '',
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
handleSelectedItem: (model, item) => {
|
|
34
|
-
const wasAdded = !Array.contains(model.selectedItems, item);
|
|
35
|
-
const nextSelectedItems = wasAdded
|
|
36
|
-
? Array.append(model.selectedItems, item)
|
|
37
|
-
: Array.filter(model.selectedItems, selected => selected !== item);
|
|
38
21
|
return [
|
|
39
|
-
evo(model, {
|
|
40
|
-
|
|
41
|
-
Option.some(SharedSelected({ value: item, wasAdded })),
|
|
22
|
+
evo(closedBaseModel(model), { inputValue: () => '' }),
|
|
23
|
+
Option.none(),
|
|
42
24
|
];
|
|
43
25
|
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
26
|
+
handleSelectedItem: (model, item) => [
|
|
27
|
+
model,
|
|
28
|
+
[],
|
|
29
|
+
Option.some(SharedSelected({ value: item })),
|
|
30
|
+
],
|
|
31
|
+
handleImmediateActivation: (model, item) => [
|
|
32
|
+
model,
|
|
33
|
+
Option.some(SharedSelected({ value: item })),
|
|
34
|
+
],
|
|
47
35
|
});
|
|
48
36
|
/** Programmatically opens the combobox, updating the model and returning
|
|
49
37
|
* focus and modal commands. Use this in domain-event handlers to open the combobox. */
|
|
50
38
|
export const open = (model) => update(model, Opened({ maybeActiveItemIndex: Option.none() }));
|
|
51
39
|
/** Programmatically closes the combobox, updating the model and returning
|
|
52
|
-
* focus and modal commands.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* onto the combobox's selected items. Contrast with `selectItem`, which
|
|
60
|
-
* toggles a single item as a user *choice* and emits `Selected`. Returns
|
|
61
|
-
* the model directly because it produces no commands and no OutMessage. */
|
|
62
|
-
export const reflectSelectedItems = Function.dual(2, (model, items) => evo(model, { selectedItems: () => items }));
|
|
63
|
-
const internalView = makeView({
|
|
64
|
-
isItemSelected: (model, itemValue) => Array.contains(model.selectedItems, itemValue),
|
|
65
|
-
ariaMultiSelectable: true,
|
|
66
|
-
});
|
|
40
|
+
* focus and modal commands. The multi-select input always rests empty on
|
|
41
|
+
* close. Use this in domain-event handlers to close the combobox. */
|
|
42
|
+
export const close = (model) => update(model, Closed({ restingInputValue: '' }));
|
|
43
|
+
/** Programmatically activates an item in the multi-select combobox. Emits
|
|
44
|
+
* `Selected({ value })`; the parent toggles the value's membership. */
|
|
45
|
+
export const selectItem = (model, item) => update(model, SelectedItem({ item, displayText: item, wasSelected: false }));
|
|
46
|
+
const internalView = makeView({ ariaMultiSelectable: true });
|
|
67
47
|
/** Pairs the multi-select combobox's `view` and `update` (and programmatic
|
|
68
|
-
* helpers) behind a single Item-typed entry point.
|
|
48
|
+
* helpers) behind a single Item-typed entry point. `selectItem` emits
|
|
49
|
+
* `Selected({ value })`; the parent toggles the value's membership. */
|
|
69
50
|
export const create = () => {
|
|
70
51
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
71
52
|
const typedUpdate = update;
|
|
72
53
|
return {
|
|
73
54
|
view: internalView(),
|
|
74
55
|
update: typedUpdate,
|
|
75
|
-
selectItem: (model, item) => typedUpdate(model, SelectedItem({ item, displayText: item })),
|
|
56
|
+
selectItem: (model, item) => typedUpdate(model, SelectedItem({ item, displayText: item, wasSelected: false })),
|
|
76
57
|
open: model => typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() })),
|
|
77
|
-
close: model => typedUpdate(model, Closed()),
|
|
78
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
79
|
-
reflectSelectedItems: reflectSelectedItems,
|
|
58
|
+
close: model => typedUpdate(model, Closed({ restingInputValue: '' })),
|
|
80
59
|
};
|
|
81
60
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { init, create, Model } from './single.js';
|
|
2
2
|
export { inputId } from './shared.js';
|
|
3
|
-
export { Message, OutMessage, Selected, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedInertOthers, CompletedRestoreInert, CompletedFocusInput, CompletedScrollIntoView, CompletedClickItem, CompletedAnchorCombobox, CompletedAttachComboboxPreventBlur, CompletedAttachComboboxSelectOnFocus, CompletedPortalComboboxBackdrop, AnchorCombobox, AttachComboboxPreventBlur, AttachComboboxSelectOnFocus, PortalComboboxBackdrop, GotAnimationMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusInput, ScrollIntoView, ClickItem, DetectMovementOrAnimationEnd, } from './shared.js';
|
|
4
|
-
export type { ActivationTrigger, Opened, Closed, BlurredInput, ActivatedItem, DeactivatedItem, MovedPointerOverItem, RequestedItemClick, UpdatedInputValue, PressedToggleButton, ItemConfig, GroupHeading, } from './shared.js';
|
|
3
|
+
export { Message, OutMessage, Selected, ClearedSelection, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedInertOthers, CompletedRestoreInert, CompletedFocusInput, CompletedScrollIntoView, CompletedClickItem, CompletedAnchorCombobox, CompletedAttachComboboxPreventBlur, CompletedAttachComboboxSelectOnFocus, CompletedPortalComboboxBackdrop, AnchorCombobox, AttachComboboxPreventBlur, AttachComboboxSelectOnFocus, PortalComboboxBackdrop, GotAnimationMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusInput, ScrollIntoView, ClickItem, DetectMovementOrAnimationEnd, } from './shared.js';
|
|
4
|
+
export type { ActivationTrigger, Opened, Closed, BlurredInput, ActivatedItem, DeactivatedItem, MovedPointerOverItem, RequestedItemClick, UpdatedInputValue, PressedToggleButton, ItemConfig, GroupHeading, BaseViewInputsCommon, } from './shared.js';
|
|
5
5
|
export type { InitConfig, ViewInputs } from './single.js';
|
|
6
6
|
export type { AnchorConfig } from '../anchor.js';
|
|
7
7
|
export * as Multi from './multiPublic.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/combobox/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EACL,OAAO,EACP,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kCAAkC,EAClC,oCAAoC,EACpC,+BAA+B,EAC/B,cAAc,EACd,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,iBAAiB,EACjB,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/combobox/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,OAAO,EACL,OAAO,EACP,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,kCAAkC,EAClC,oCAAoC,EACpC,+BAA+B,EAC/B,cAAc,EACd,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,iBAAiB,EACjB,MAAM,EACN,MAAM,EACN,YAAY,EACZ,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,oBAAoB,GACrB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEzD,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA"}
|
package/dist/combobox/public.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { init, create, Model } from './single.js';
|
|
2
2
|
export { inputId } from './shared.js';
|
|
3
|
-
export { Message, OutMessage, Selected, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedInertOthers, CompletedRestoreInert, CompletedFocusInput, CompletedScrollIntoView, CompletedClickItem, CompletedAnchorCombobox, CompletedAttachComboboxPreventBlur, CompletedAttachComboboxSelectOnFocus, CompletedPortalComboboxBackdrop, AnchorCombobox, AttachComboboxPreventBlur, AttachComboboxSelectOnFocus, PortalComboboxBackdrop, GotAnimationMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusInput, ScrollIntoView, ClickItem, DetectMovementOrAnimationEnd, } from './shared.js';
|
|
3
|
+
export { Message, OutMessage, Selected, ClearedSelection, SelectedItem, CompletedLockScroll, CompletedUnlockScroll, CompletedInertOthers, CompletedRestoreInert, CompletedFocusInput, CompletedScrollIntoView, CompletedClickItem, CompletedAnchorCombobox, CompletedAttachComboboxPreventBlur, CompletedAttachComboboxSelectOnFocus, CompletedPortalComboboxBackdrop, AnchorCombobox, AttachComboboxPreventBlur, AttachComboboxSelectOnFocus, PortalComboboxBackdrop, GotAnimationMessage, LockScroll, UnlockScroll, InertOthers, RestoreInert, FocusInput, ScrollIntoView, ClickItem, DetectMovementOrAnimationEnd, } from './shared.js';
|
|
4
4
|
export * as Multi from './multiPublic.js';
|
|
@@ -38,6 +38,11 @@ export type BaseInitConfig = Readonly<{
|
|
|
38
38
|
isAnimated?: boolean;
|
|
39
39
|
isModal?: boolean;
|
|
40
40
|
nullable?: boolean;
|
|
41
|
+
/** Emits `Selected` on every keyboard activation while open, so arrow keys
|
|
42
|
+
* commit as they move instead of waiting for Enter. Combining `immediate`
|
|
43
|
+
* with `nullable` is discouraged: a nullable toggle fold would deselect as
|
|
44
|
+
* the arrows pass back over the selected item (see issue #693). Default
|
|
45
|
+
* `false`. */
|
|
41
46
|
immediate?: boolean;
|
|
42
47
|
selectInputOnFocus?: boolean;
|
|
43
48
|
}>;
|
|
@@ -47,25 +52,29 @@ export declare const baseInit: (config: BaseInitConfig) => BaseModel;
|
|
|
47
52
|
export declare const Opened: import("foldkit/schema").CallableTaggedStruct<"Opened", {
|
|
48
53
|
maybeActiveItemIndex: S.Option<S.Number>;
|
|
49
54
|
}>;
|
|
50
|
-
/** Sent when the combobox closes via Escape key or backdrop click. */
|
|
51
|
-
export declare const Closed: import("foldkit/schema").CallableTaggedStruct<"Closed", {
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
/** Sent when the combobox closes via Escape key or backdrop click. `restingInputValue` is what the input returns to on close (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. */
|
|
56
|
+
export declare const Closed: import("foldkit/schema").CallableTaggedStruct<"Closed", {
|
|
57
|
+
restingInputValue: S.String;
|
|
58
|
+
}>;
|
|
59
|
+
/** Sent when the combobox input loses focus. `restingInputValue` is what the input returns to on close (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. */
|
|
60
|
+
export declare const BlurredInput: import("foldkit/schema").CallableTaggedStruct<"BlurredInput", {
|
|
61
|
+
restingInputValue: S.String;
|
|
62
|
+
}>;
|
|
54
63
|
/** Sent when an item is highlighted via arrow keys or mouse hover. Includes activation trigger and optional immediate selection info. */
|
|
55
64
|
export declare const ActivatedItem: import("foldkit/schema").CallableTaggedStruct<"ActivatedItem", {
|
|
56
65
|
index: S.Number;
|
|
57
66
|
activationTrigger: S.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
58
67
|
maybeImmediateSelection: S.Option<S.Struct<{
|
|
59
68
|
readonly item: S.String;
|
|
60
|
-
readonly displayText: S.String;
|
|
61
69
|
}>>;
|
|
62
70
|
}>;
|
|
63
71
|
/** Sent when the mouse leaves an enabled item. */
|
|
64
72
|
export declare const DeactivatedItem: import("foldkit/schema").CallableTaggedStruct<"DeactivatedItem", {}>;
|
|
65
|
-
/** Sent when an item is selected via Enter or click.
|
|
73
|
+
/** Sent when an item is selected via Enter or click. `displayText` is the item's resting input text, and `wasSelected` reports whether the item was already in the parent-owned selection when activated, so nullable deselect logic works without the Model knowing the selection. */
|
|
66
74
|
export declare const SelectedItem: import("foldkit/schema").CallableTaggedStruct<"SelectedItem", {
|
|
67
75
|
item: S.String;
|
|
68
76
|
displayText: S.String;
|
|
77
|
+
wasSelected: S.Boolean;
|
|
69
78
|
}>;
|
|
70
79
|
/** Sent when the pointer moves over a combobox item. */
|
|
71
80
|
export declare const MovedPointerOverItem: import("foldkit/schema").CallableTaggedStruct<"MovedPointerOverItem", {
|
|
@@ -107,8 +116,10 @@ export declare const GotAnimationMessage: import("foldkit/schema").CallableTagge
|
|
|
107
116
|
export declare const UpdatedInputValue: import("foldkit/schema").CallableTaggedStruct<"UpdatedInputValue", {
|
|
108
117
|
value: S.String;
|
|
109
118
|
}>;
|
|
110
|
-
/** Sent when the optional toggle button is clicked. */
|
|
111
|
-
export declare const PressedToggleButton: import("foldkit/schema").CallableTaggedStruct<"PressedToggleButton", {
|
|
119
|
+
/** Sent when the optional toggle button is clicked. `restingInputValue` is what the input returns to when the press closes the combobox (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. */
|
|
120
|
+
export declare const PressedToggleButton: import("foldkit/schema").CallableTaggedStruct<"PressedToggleButton", {
|
|
121
|
+
restingInputValue: S.String;
|
|
122
|
+
}>;
|
|
112
123
|
/** Union of all messages the combobox component can produce. */
|
|
113
124
|
export declare const Message: S.Union<[
|
|
114
125
|
typeof Opened,
|
|
@@ -152,26 +163,26 @@ export type CompletedClickItem = typeof CompletedClickItem.Type;
|
|
|
152
163
|
export type UpdatedInputValue = typeof UpdatedInputValue.Type;
|
|
153
164
|
export type PressedToggleButton = typeof PressedToggleButton.Type;
|
|
154
165
|
export type Message = typeof Message.Type;
|
|
155
|
-
/** Sent when
|
|
166
|
+
/** Sent when the user activates an item. Carries the neutral fact that the item was activated; the parent owns the selection and decides what it means (single-select stores the value, nullable single-select toggles it, multi-select toggles the value's membership). Generic over `Value extends string`: the runtime schema stores `value: string`, but the type-level OutMessage exposes `value: Value` so consumers who supply `items: ReadonlyArray<MyUnion>` receive `value: MyUnion` from the factory's `update` without casting. */
|
|
156
167
|
export declare const Selected: import("foldkit/schema").CallableTaggedStruct<"Selected", {
|
|
157
168
|
value: S.String;
|
|
158
|
-
wasAdded: S.Boolean;
|
|
159
169
|
}>;
|
|
160
170
|
export type Selected<Value extends string = string> = Readonly<{
|
|
161
171
|
readonly _tag: 'Selected';
|
|
162
172
|
readonly value: Value;
|
|
163
|
-
readonly wasAdded: boolean;
|
|
164
173
|
}>;
|
|
165
|
-
/**
|
|
174
|
+
/** Sent when a nullable combobox closes with an empty input, meaning the user cleared it. The parent clears the selection it owns. */
|
|
175
|
+
export declare const ClearedSelection: import("foldkit/schema").CallableTaggedStruct<"ClearedSelection", {}>;
|
|
176
|
+
export type ClearedSelection = typeof ClearedSelection.Type;
|
|
177
|
+
/** Union of out-messages the combobox component can produce. The parent folds `Selected` into the selection it owns and clears that selection on `ClearedSelection`. */
|
|
166
178
|
export declare const OutMessage: S.Union<readonly [import("foldkit/schema").CallableTaggedStruct<"Selected", {
|
|
167
179
|
value: S.String;
|
|
168
|
-
|
|
169
|
-
}>]>;
|
|
180
|
+
}>, import("foldkit/schema").CallableTaggedStruct<"ClearedSelection", {}>]>;
|
|
170
181
|
/** Generic over `Value extends string` so consumers who create the combobox
|
|
171
182
|
* via `Combobox.create<MyUnion>()` receive `value: MyUnion` in the
|
|
172
183
|
* `Selected` OutMessage from the factory's `update`, instead of
|
|
173
184
|
* `value: string`. Defaults to `string`. */
|
|
174
|
-
export type OutMessage<Value extends string = string> = Selected<Value
|
|
185
|
+
export type OutMessage<Value extends string = string> = Selected<Value> | ClearedSelection;
|
|
175
186
|
/** Returns the bare DOM id of the combobox input, derived from the
|
|
176
187
|
* combobox's base id. Use this to associate an external label with the
|
|
177
188
|
* input via a native `<label for={Combobox.inputId(id)}>` or an
|
|
@@ -183,7 +194,7 @@ export declare const inputWrapperSelector: (id: string) => string;
|
|
|
183
194
|
export declare const itemsSelector: (id: string) => string;
|
|
184
195
|
export declare const itemSelector: (id: string, index: number) => string;
|
|
185
196
|
export declare const itemId: (id: string, index: number) => string;
|
|
186
|
-
/** Resets only shared base fields to their closed state. Does not touch inputValue
|
|
197
|
+
/** Resets only shared base fields to their closed state. Does not touch inputValue. That is variant-specific. */
|
|
187
198
|
export declare const closedBaseModel: <Model extends BaseModel>(model: Model) => Model;
|
|
188
199
|
/** Context passed to the `handleSelectedItem` handler with commands for focus management and modal cleanup. */
|
|
189
200
|
export type SelectedItemContext = Readonly<{
|
|
@@ -248,9 +259,9 @@ export declare const DetectMovementOrAnimationEnd: Command.CommandDefinitionWith
|
|
|
248
259
|
}, never, never>>;
|
|
249
260
|
/** Creates a combobox update function from variant-specific handlers. Shared logic (open, close, activate, transition) is handled internally; only close, selection, and immediate-activation behavior varies by variant. */
|
|
250
261
|
export declare const makeUpdate: <Model extends BaseModel>(handlers: Readonly<{
|
|
251
|
-
handleClose: (model: Model) => Model;
|
|
252
|
-
handleSelectedItem: (model: Model, item: string, displayText: string, context: SelectedItemContext) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage>];
|
|
253
|
-
handleImmediateActivation: (model: Model, item: string
|
|
262
|
+
handleClose: (model: Model, restingInputValue: string) => readonly [Model, Option.Option<OutMessage>];
|
|
263
|
+
handleSelectedItem: (model: Model, item: string, displayText: string, wasSelected: boolean, context: SelectedItemContext) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage>];
|
|
264
|
+
handleImmediateActivation: (model: Model, item: string) => readonly [Model, Option.Option<OutMessage>];
|
|
254
265
|
}>) => (model: Model, message: Message) => readonly [Model, readonly Readonly<{
|
|
255
266
|
name: string;
|
|
256
267
|
args?: Record<string, unknown>;
|
|
@@ -262,20 +273,21 @@ export declare const makeUpdate: <Model extends BaseModel>(handlers: Readonly<{
|
|
|
262
273
|
readonly _tag: S.tag<"CompletedInertOthers">;
|
|
263
274
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
264
275
|
readonly _tag: S.tag<"CompletedRestoreInert">;
|
|
265
|
-
}, "Type"> | S.Struct.ReadonlySide<{
|
|
266
|
-
readonly _tag: S.tag<"Closed">;
|
|
267
276
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
268
277
|
readonly _tag: S.tag<"Opened">;
|
|
269
278
|
maybeActiveItemIndex: S.Option<S.Number>;
|
|
279
|
+
}, "Type"> | S.Struct.ReadonlySide<{
|
|
280
|
+
readonly _tag: S.tag<"Closed">;
|
|
281
|
+
restingInputValue: S.String;
|
|
270
282
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
271
283
|
readonly _tag: S.tag<"BlurredInput">;
|
|
284
|
+
restingInputValue: S.String;
|
|
272
285
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
273
286
|
readonly _tag: S.tag<"ActivatedItem">;
|
|
274
287
|
index: S.Number;
|
|
275
288
|
activationTrigger: S.Literals<readonly ["Pointer", "Keyboard"]>;
|
|
276
289
|
maybeImmediateSelection: S.Option<S.Struct<{
|
|
277
290
|
readonly item: S.String;
|
|
278
|
-
readonly displayText: S.String;
|
|
279
291
|
}>>;
|
|
280
292
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
281
293
|
readonly _tag: S.tag<"DeactivatedItem">;
|
|
@@ -283,6 +295,7 @@ export declare const makeUpdate: <Model extends BaseModel>(handlers: Readonly<{
|
|
|
283
295
|
readonly _tag: S.tag<"SelectedItem">;
|
|
284
296
|
item: S.String;
|
|
285
297
|
displayText: S.String;
|
|
298
|
+
wasSelected: S.Boolean;
|
|
286
299
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
287
300
|
readonly _tag: S.tag<"MovedPointerOverItem">;
|
|
288
301
|
index: S.Number;
|
|
@@ -302,6 +315,7 @@ export declare const makeUpdate: <Model extends BaseModel>(handlers: Readonly<{
|
|
|
302
315
|
value: S.String;
|
|
303
316
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
304
317
|
readonly _tag: S.tag<"PressedToggleButton">;
|
|
318
|
+
restingInputValue: S.String;
|
|
305
319
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
306
320
|
readonly _tag: S.tag<"CompletedAnchorCombobox">;
|
|
307
321
|
}, "Type"> | S.Struct.ReadonlySide<{
|
|
@@ -314,11 +328,7 @@ export declare const makeUpdate: <Model extends BaseModel>(handlers: Readonly<{
|
|
|
314
328
|
readonly _tag: S.tag<"GotAnimationMessage">;
|
|
315
329
|
message: S.Union<[import("foldkit/schema").CallableTaggedStruct<"Showed", {}>, import("foldkit/schema").CallableTaggedStruct<"Hid", {}>, import("foldkit/schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("foldkit/schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
|
|
316
330
|
}, "Type">, never, never>;
|
|
317
|
-
}>[], Option.Option<
|
|
318
|
-
readonly _tag: "Selected";
|
|
319
|
-
readonly value: string;
|
|
320
|
-
readonly wasAdded: boolean;
|
|
321
|
-
}>>];
|
|
331
|
+
}>[], Option.Option<OutMessage<string>>];
|
|
322
332
|
/** The anchor-positioning Mount this Combobox renders on its items panel.
|
|
323
333
|
* The panel is always anchored to the input wrapper via Floating UI and
|
|
324
334
|
* portaled to the document body (opt out of portaling with
|
|
@@ -370,11 +380,16 @@ export type GroupHeading = Readonly<{
|
|
|
370
380
|
}>;
|
|
371
381
|
/** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
|
|
372
382
|
*
|
|
373
|
-
* The Combobox emits a `Selected({ value
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
|
|
383
|
+
* The Combobox emits a `Selected({ value })` OutMessage on commit.
|
|
384
|
+
* Consumers pattern-match this in their `GotComboboxMessage` handler:
|
|
385
|
+
* single-select stores the value, multi-select toggles the value's
|
|
386
|
+
* membership. `restingInputValue` is the text the input returns to on
|
|
387
|
+
* close (the selection's display text for single-select, empty for
|
|
388
|
+
* multi-select). Everything here except the selection itself; each
|
|
389
|
+
* variant composes its own selection field on top. */
|
|
390
|
+
export type BaseViewInputsCommon<Item extends string> = Readonly<{
|
|
377
391
|
items: ReadonlyArray<Item>;
|
|
392
|
+
restingInputValue: string;
|
|
378
393
|
itemToConfig: (item: Item, context: Readonly<{
|
|
379
394
|
isActive: boolean;
|
|
380
395
|
isDisabled: boolean;
|
|
@@ -413,11 +428,20 @@ export type BaseViewInputs<Item extends string> = Readonly<{
|
|
|
413
428
|
ariaLabel?: string;
|
|
414
429
|
ariaLabelledBy?: string;
|
|
415
430
|
}>;
|
|
431
|
+
/** Per-render view inputs for the shared array-based Combobox view. The
|
|
432
|
+
* multi-select variant exposes this shape directly; the single-select
|
|
433
|
+
* variant swaps `selectedValues` for `maybeSelectedValue` at its public
|
|
434
|
+
* seam and adapts to this shape internally. */
|
|
435
|
+
export type BaseViewInputs<Item extends string> = BaseViewInputsCommon<Item> & Readonly<{
|
|
436
|
+
/** The selection the parent owns, passed in fresh on every render.
|
|
437
|
+
* Marks items as selected and drives the hidden form inputs
|
|
438
|
+
* submitted under `formName`. */
|
|
439
|
+
selectedValues: ReadonlyArray<Item>;
|
|
440
|
+
}>;
|
|
416
441
|
/** Variant-specific view behavior injected into the shared combobox view factory. */
|
|
417
|
-
export type ViewBehavior
|
|
418
|
-
isItemSelected: (model: Model, itemValue: string) => boolean;
|
|
442
|
+
export type ViewBehavior = Readonly<{
|
|
419
443
|
ariaMultiSelectable: boolean;
|
|
420
444
|
}>;
|
|
421
|
-
/** Creates a combobox view function from variant-specific behavior. Shared rendering logic (input, items, transitions, keyboard navigation) is handled internally; only
|
|
422
|
-
export declare const makeView: <Model extends BaseModel>(behavior: ViewBehavior
|
|
445
|
+
/** Creates a combobox view function from variant-specific behavior. Shared rendering logic (input, items, transitions, keyboard navigation) is handled internally; only listbox multi-select semantics vary by variant. */
|
|
446
|
+
export declare const makeView: <Model extends BaseModel>(behavior: ViewBehavior) => <Item extends string>() => SubmodelView<Model, Message, BaseViewInputs<Item>>;
|
|
423
447
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/combobox/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,MAAM,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/combobox/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,MAAM,EAEN,MAAM,IAAI,CAAC,EAEZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAQ,MAAM,cAAc,CAAA;AAEnE,OAA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