@foldkit/ui 0.148.2 → 0.149.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/animation/index.d.ts +3 -3
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/animation/index.js +2 -2
- package/dist/animation/public.d.ts +1 -1
- package/dist/animation/public.d.ts.map +1 -1
- package/dist/animation/public.js +1 -1
- package/dist/animation/schema.d.ts +12 -21
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/schema.js +11 -15
- package/dist/animation/update.d.ts +1 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +9 -9
- package/dist/calendar/index.d.ts +50 -105
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +61 -98
- 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/combobox/multi.d.ts +9 -9
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +9 -9
- package/dist/combobox/public.d.ts +1 -1
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +93 -137
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +108 -153
- package/dist/combobox/single.d.ts +9 -9
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +10 -10
- package/dist/datePicker/index.d.ts +88 -84
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +33 -63
- 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/dialog/index.d.ts +28 -49
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +39 -67
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/dialog/public.js +1 -1
- package/dist/dragAndDrop/index.d.ts +45 -72
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +72 -93
- package/dist/dragAndDrop/public.d.ts +1 -1
- package/dist/dragAndDrop/public.d.ts.map +1 -1
- package/dist/dragAndDrop/public.js +1 -1
- package/dist/fileDrop/index.d.ts +14 -35
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +20 -46
- package/dist/fileDrop/public.d.ts +1 -1
- package/dist/fileDrop/public.d.ts.map +1 -1
- package/dist/fileDrop/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -7
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +8 -8
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/public.js +1 -1
- package/dist/listbox/shared.d.ts +80 -127
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +92 -149
- package/dist/listbox/single.d.ts +7 -7
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -8
- package/dist/menu/index.d.ts +86 -134
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +141 -189
- package/dist/menu/public.d.ts +1 -1
- package/dist/menu/public.d.ts.map +1 -1
- package/dist/menu/public.js +1 -1
- package/dist/popover/index.d.ts +39 -65
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +68 -98
- package/dist/popover/public.d.ts +1 -1
- package/dist/popover/public.d.ts.map +1 -1
- package/dist/popover/public.js +1 -1
- package/dist/radioGroup/index.d.ts +18 -29
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +22 -27
- package/dist/radioGroup/public.d.ts +1 -1
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +29 -51
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +36 -56
- 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/tabs/index.d.ts +18 -28
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +22 -26
- package/dist/tabs/public.d.ts +1 -1
- package/dist/tabs/public.d.ts.map +1 -1
- package/dist/tabs/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +71 -14
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +14 -13
- package/dist/toast/index.d.ts +124 -109
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +5 -5
- package/dist/toast/public.d.ts +1 -1
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +72 -84
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +31 -41
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/test.js +6 -3
- package/dist/toast/update.d.ts +104 -89
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +19 -20
- package/dist/tooltip/message.d.ts +26 -47
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/message.js +15 -40
- package/dist/tooltip/public.d.ts +1 -1
- package/dist/tooltip/public.d.ts.map +1 -1
- package/dist/tooltip/public.js +1 -1
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -16
- package/dist/virtualList/index.d.ts +46 -23
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +12 -23
- package/dist/virtualList/public.d.ts +1 -1
- package/dist/virtualList/public.d.ts.map +1 -1
- package/dist/virtualList/public.js +1 -1
- package/package.json +3 -3
package/dist/listbox/shared.js
CHANGED
|
@@ -2,7 +2,7 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, String as Str, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
|
-
import {
|
|
5
|
+
import { defineMessageUnion } from 'foldkit/message';
|
|
6
6
|
import * as Mount from 'foldkit/mount';
|
|
7
7
|
import { makeConstrainedEvo } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -11,7 +11,7 @@ import { AnchorConfig, anchorSetup, portalToContainingRoot, } from '../anchor/in
|
|
|
11
11
|
// NOTE: Animation imports are split across schema + update to avoid a circular
|
|
12
12
|
// dependency: animation → html → runtime → devtools → listbox → animation.
|
|
13
13
|
// The barrel (../animation) imports from html, which starts the cycle.
|
|
14
|
-
import {
|
|
14
|
+
import { Message as AnimationMessage, Model as AnimationModel, init as animationInit, } from '../animation/schema.js';
|
|
15
15
|
import { update as animationUpdate } from '../animation/update.js';
|
|
16
16
|
import { groupContiguous } from '../group.js';
|
|
17
17
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
@@ -55,112 +55,51 @@ export const baseInit = (config) => (__foldkitBrandViewResult(({
|
|
|
55
55
|
maybeLastButtonPointerType: Option.none(),
|
|
56
56
|
}), "@foldkit/ui/listbox/shared.js#baseInit"));
|
|
57
57
|
// MESSAGE
|
|
58
|
-
/** Sent when the listbox opens via button click or keyboard. Contains an optional initial active item index: None for pointer, Some for keyboard. */
|
|
59
|
-
export const Opened = m('Opened', {
|
|
60
|
-
maybeActiveItemIndex: S.Option(S.Number),
|
|
61
|
-
});
|
|
62
|
-
/** Sent when the listbox closes via Escape key or backdrop click. */
|
|
63
|
-
export const Closed = m('Closed');
|
|
64
|
-
/** Sent when the listbox items container loses focus. */
|
|
65
|
-
export const BlurredItems = m('BlurredItems');
|
|
66
|
-
/** Sent when an item is highlighted via arrow keys or mouse hover. Includes activation trigger. */
|
|
67
|
-
export const ActivatedItem = m('ActivatedItem', {
|
|
68
|
-
index: S.Number,
|
|
69
|
-
activationTrigger: ActivationTrigger,
|
|
70
|
-
});
|
|
71
|
-
/** Sent when the mouse leaves an enabled item. */
|
|
72
|
-
export const DeactivatedItem = m('DeactivatedItem');
|
|
73
|
-
/** Sent when an item is selected via Enter, Space, or click. Contains the item's string value. */
|
|
74
|
-
export const SelectedItem = m('SelectedItem', { item: S.String });
|
|
75
|
-
/** Sent when Enter or Space is pressed on the active item, triggering a programmatic click on the DOM element. */
|
|
76
|
-
export const RequestedItemClick = m('RequestedItemClick', {
|
|
77
|
-
index: S.Number,
|
|
78
|
-
});
|
|
79
|
-
/** Sent when a printable character is typed for typeahead search. */
|
|
80
|
-
export const Searched = m('Searched', {
|
|
81
|
-
key: S.String,
|
|
82
|
-
maybeTargetIndex: S.Option(S.Number),
|
|
83
|
-
});
|
|
84
|
-
/** Sent after the search debounce period to clear the accumulated query. */
|
|
85
|
-
export const CompletedDelayClearSearch = m('CompletedDelayClearSearch', {
|
|
86
|
-
version: S.Number,
|
|
87
|
-
});
|
|
88
|
-
/** Sent when the pointer moves over a listbox item, carrying screen coordinates for tracked-pointer comparison. */
|
|
89
|
-
export const MovedPointerOverItem = m('MovedPointerOverItem', {
|
|
90
|
-
index: S.Number,
|
|
91
|
-
screenX: S.Number,
|
|
92
|
-
screenY: S.Number,
|
|
93
|
-
});
|
|
94
|
-
/** Sent when the scroll lock command completes. */
|
|
95
|
-
export const CompletedLockScroll = m('CompletedLockScroll');
|
|
96
|
-
/** Sent when the scroll unlock command completes. */
|
|
97
|
-
export const CompletedUnlockScroll = m('CompletedUnlockScroll');
|
|
98
|
-
/** Sent when the inert-others command completes. */
|
|
99
|
-
export const CompletedInertOthers = m('CompletedInertOthers');
|
|
100
|
-
/** Sent when the restore-inert command completes. */
|
|
101
|
-
export const CompletedRestoreInert = m('CompletedRestoreInert');
|
|
102
|
-
/** Sent when the focus-button command completes after closing. */
|
|
103
|
-
export const CompletedFocusButton = m('CompletedFocusButton');
|
|
104
|
-
/** Sent when the focus-items command completes after opening. */
|
|
105
|
-
export const CompletedFocusItems = m('CompletedFocusItems');
|
|
106
|
-
/** Sent when the scroll-into-view command completes after keyboard activation. */
|
|
107
|
-
export const CompletedScrollIntoView = m('CompletedScrollIntoView');
|
|
108
|
-
/** Sent when the programmatic item click command completes. */
|
|
109
|
-
export const CompletedClickItem = m('CompletedClickItem');
|
|
110
|
-
/** Sent when a mouse click on the button is ignored because pointer-down already handled the toggle. */
|
|
111
|
-
export const IgnoredMouseClick = m('IgnoredMouseClick');
|
|
112
|
-
/** Sent when a Space key-up is captured to prevent page scrolling. */
|
|
113
|
-
export const SuppressedSpaceScroll = m('SuppressedSpaceScroll');
|
|
114
|
-
/** Sent when Enter or Space would commit the active item but the listbox is read-only. Update no-ops; the Message keeps the keypress visible and lets the view prevent the browser's default Space scroll. */
|
|
115
|
-
export const SuppressedItemCommit = m('SuppressedItemCommit');
|
|
116
|
-
/** Sent when the listbox items panel mounts and Floating UI has positioned it. Update no-ops; surfaces the positioning side effect for DevTools. */
|
|
117
|
-
export const CompletedAnchorListbox = m('CompletedAnchorListbox');
|
|
118
|
-
/** Sent when the listbox backdrop mounts and is portaled to the document body. Update no-ops; surfaces the portal side effect for DevTools. */
|
|
119
|
-
export const CompletedPortalListboxBackdrop = m('CompletedPortalListboxBackdrop');
|
|
120
|
-
/** Wraps an Animation submodel message for delegation. */
|
|
121
|
-
export const GotAnimationMessage = m('GotAnimationMessage', {
|
|
122
|
-
message: AnimationMessage,
|
|
123
|
-
});
|
|
124
|
-
/** Sent when the user presses a pointer device on the listbox button. Records pointer type for click handling. */
|
|
125
|
-
export const PressedPointerOnButton = m('PressedPointerOnButton', {
|
|
126
|
-
pointerType: S.String,
|
|
127
|
-
button: S.Number,
|
|
128
|
-
});
|
|
129
58
|
/** Union of all messages the listbox component can produce. */
|
|
130
|
-
export const Message =
|
|
131
|
-
Opened,
|
|
132
|
-
Closed,
|
|
133
|
-
BlurredItems,
|
|
134
|
-
ActivatedItem
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
59
|
+
export const Message = defineMessageUnion({
|
|
60
|
+
Opened: { maybeActiveItemIndex: S.Option(S.Number) },
|
|
61
|
+
Closed: {},
|
|
62
|
+
BlurredItems: {},
|
|
63
|
+
ActivatedItem: {
|
|
64
|
+
index: S.Number,
|
|
65
|
+
activationTrigger: ActivationTrigger,
|
|
66
|
+
},
|
|
67
|
+
DeactivatedItem: {},
|
|
68
|
+
SelectedItem: { item: S.String },
|
|
69
|
+
MovedPointerOverItem: {
|
|
70
|
+
index: S.Number,
|
|
71
|
+
screenX: S.Number,
|
|
72
|
+
screenY: S.Number,
|
|
73
|
+
},
|
|
74
|
+
RequestedItemClick: { index: S.Number },
|
|
75
|
+
Searched: {
|
|
76
|
+
key: S.String,
|
|
77
|
+
maybeTargetIndex: S.Option(S.Number),
|
|
78
|
+
},
|
|
79
|
+
CompletedDelayClearSearch: { version: S.Number },
|
|
80
|
+
CompletedLockScroll: {},
|
|
81
|
+
CompletedUnlockScroll: {},
|
|
82
|
+
CompletedInertOthers: {},
|
|
83
|
+
CompletedRestoreInert: {},
|
|
84
|
+
CompletedFocusButton: {},
|
|
85
|
+
CompletedFocusItems: {},
|
|
86
|
+
CompletedScrollIntoView: {},
|
|
87
|
+
CompletedClickItem: {},
|
|
88
|
+
IgnoredMouseClick: {},
|
|
89
|
+
SuppressedSpaceScroll: {},
|
|
90
|
+
SuppressedItemCommit: {},
|
|
91
|
+
CompletedAnchorListbox: {},
|
|
92
|
+
CompletedPortalListboxBackdrop: {},
|
|
93
|
+
GotAnimationMessage: { message: AnimationMessage },
|
|
94
|
+
PressedPointerOnButton: {
|
|
95
|
+
pointerType: S.String,
|
|
96
|
+
button: S.Number,
|
|
97
|
+
},
|
|
161
98
|
});
|
|
162
99
|
/** Union of out-messages the listbox component can produce. The parent folds `Selected` into the selection it owns: single-select stores the value, multi-select toggles the value's membership. */
|
|
163
|
-
export const OutMessage =
|
|
100
|
+
export const OutMessage = defineMessageUnion({
|
|
101
|
+
Selected: { value: S.String },
|
|
102
|
+
});
|
|
164
103
|
// CONSTANTS
|
|
165
104
|
export const SEARCH_DEBOUNCE_MILLISECONDS = 350;
|
|
166
105
|
export const LEFT_MOUSE_BUTTON = 0;
|
|
@@ -187,61 +126,65 @@ export const closedModel = (model) => __foldkitBrandViewResult((constrainedEvo(m
|
|
|
187
126
|
})), "@foldkit/ui/listbox/shared.js#closedModel");
|
|
188
127
|
/** Prevents page scrolling while the listbox is open in modal mode. */
|
|
189
128
|
export const LockScroll = Command.define('LockScroll', {
|
|
190
|
-
messages: [CompletedLockScroll],
|
|
191
|
-
execute: Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())),
|
|
129
|
+
messages: [Message.CompletedLockScroll],
|
|
130
|
+
execute: Dom.lockScroll.pipe(Effect.as(Message.CompletedLockScroll())),
|
|
192
131
|
});
|
|
193
132
|
/** Re-enables page scrolling after the listbox closes. */
|
|
194
133
|
export const UnlockScroll = Command.define('UnlockScroll', {
|
|
195
|
-
messages: [CompletedUnlockScroll],
|
|
196
|
-
execute: Dom.unlockScroll.pipe(Effect.as(CompletedUnlockScroll())),
|
|
134
|
+
messages: [Message.CompletedUnlockScroll],
|
|
135
|
+
execute: Dom.unlockScroll.pipe(Effect.as(Message.CompletedUnlockScroll())),
|
|
197
136
|
});
|
|
198
137
|
/** Marks all elements outside the listbox as inert for modal behavior. */
|
|
199
138
|
export const InertOthers = Command.define('InertOthers', {
|
|
200
139
|
args: { id: S.String },
|
|
201
|
-
messages: [CompletedInertOthers],
|
|
202
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), itemsSelector(id)]).pipe(Effect.as(CompletedInertOthers()))), "@foldkit/ui/listbox/shared.js#execute"),
|
|
140
|
+
messages: [Message.CompletedInertOthers],
|
|
141
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [buttonSelector(id), itemsSelector(id)]).pipe(Effect.as(Message.CompletedInertOthers()))), "@foldkit/ui/listbox/shared.js#execute"),
|
|
203
142
|
});
|
|
204
143
|
/** Removes the inert attribute from elements outside the listbox. */
|
|
205
144
|
export const RestoreInert = Command.define('RestoreInert', {
|
|
206
145
|
args: { id: S.String },
|
|
207
|
-
messages: [CompletedRestoreInert],
|
|
208
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert()))), "@foldkit/ui/listbox/shared.js#execute~2"),
|
|
146
|
+
messages: [Message.CompletedRestoreInert],
|
|
147
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(Message.CompletedRestoreInert()))), "@foldkit/ui/listbox/shared.js#execute~2"),
|
|
209
148
|
});
|
|
210
149
|
/** Moves focus back to the listbox button after closing. */
|
|
211
150
|
export const FocusButton = Command.define('FocusButton', {
|
|
212
151
|
args: { id: S.String },
|
|
213
|
-
messages: [CompletedFocusButton],
|
|
214
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton()))), "@foldkit/ui/listbox/shared.js#execute~3"),
|
|
152
|
+
messages: [Message.CompletedFocusButton],
|
|
153
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusButton()))), "@foldkit/ui/listbox/shared.js#execute~3"),
|
|
215
154
|
});
|
|
216
155
|
/** Moves focus to the listbox items container after opening. */
|
|
217
156
|
export const FocusItems = Command.define('FocusItems', {
|
|
218
157
|
args: { id: S.String },
|
|
219
|
-
messages: [CompletedFocusItems],
|
|
220
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(itemsSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusItems()))), "@foldkit/ui/listbox/shared.js#execute~4"),
|
|
158
|
+
messages: [Message.CompletedFocusItems],
|
|
159
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(itemsSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusItems()))), "@foldkit/ui/listbox/shared.js#execute~4"),
|
|
221
160
|
});
|
|
222
161
|
/** Scrolls the active listbox item into view after keyboard navigation. */
|
|
223
162
|
export const ScrollIntoView = Command.define('ScrollIntoView', {
|
|
224
163
|
args: { id: S.String, index: S.Number },
|
|
225
|
-
messages: [CompletedScrollIntoView],
|
|
226
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedScrollIntoView()))), "@foldkit/ui/listbox/shared.js#execute~5"),
|
|
164
|
+
messages: [Message.CompletedScrollIntoView],
|
|
165
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedScrollIntoView()))), "@foldkit/ui/listbox/shared.js#execute~5"),
|
|
227
166
|
});
|
|
228
167
|
/** Programmatically clicks the active listbox item's DOM element. */
|
|
229
168
|
export const ClickItem = Command.define('ClickItem', {
|
|
230
169
|
args: { id: S.String, index: S.Number },
|
|
231
|
-
messages: [CompletedClickItem],
|
|
232
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedClickItem()))), "@foldkit/ui/listbox/shared.js#execute~6"),
|
|
170
|
+
messages: [Message.CompletedClickItem],
|
|
171
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedClickItem()))), "@foldkit/ui/listbox/shared.js#execute~6"),
|
|
233
172
|
});
|
|
234
173
|
/** Waits for the typeahead search debounce period before clearing the query. */
|
|
235
174
|
export const DelayClearSearch = Command.define('DelayClearSearch', {
|
|
236
175
|
args: { version: S.Number },
|
|
237
|
-
messages: [CompletedDelayClearSearch],
|
|
238
|
-
execute: ({ version }) => __foldkitBrandViewResult((Effect.sleep(SEARCH_DEBOUNCE_MILLISECONDS).pipe(Effect.as(CompletedDelayClearSearch({ version })))), "@foldkit/ui/listbox/shared.js#execute~7"),
|
|
176
|
+
messages: [Message.CompletedDelayClearSearch],
|
|
177
|
+
execute: ({ version }) => __foldkitBrandViewResult((Effect.sleep(SEARCH_DEBOUNCE_MILLISECONDS).pipe(Effect.as(Message.CompletedDelayClearSearch({ version })))), "@foldkit/ui/listbox/shared.js#execute~7"),
|
|
239
178
|
});
|
|
240
179
|
/** Detects whether the listbox button moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
241
180
|
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', {
|
|
242
181
|
args: { id: S.String },
|
|
243
|
-
messages: [GotAnimationMessage],
|
|
244
|
-
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(
|
|
182
|
+
messages: [Message.GotAnimationMessage],
|
|
183
|
+
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(buttonSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
184
|
+
message: AnimationMessage.EndedAnimation(),
|
|
185
|
+
}))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
186
|
+
message: AnimationMessage.EndedAnimation(),
|
|
187
|
+
}))))), "@foldkit/ui/listbox/shared.js#execute~8"),
|
|
245
188
|
});
|
|
246
189
|
export const makeUpdate = (handleSelectedItem) => {
|
|
247
190
|
const withUpdateReturn = M.withReturnType();
|
|
@@ -256,13 +199,13 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
256
199
|
update: animationUpdate,
|
|
257
200
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/listbox/shared.js#read"),
|
|
258
201
|
write: (model, nextAnimation) => __foldkitBrandViewResult((constrainedEvo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/listbox/shared.js#animation") })), "@foldkit/ui/listbox/shared.js#write"),
|
|
259
|
-
toParentMessage: message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/listbox/shared.js#toParentMessage"),
|
|
202
|
+
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/listbox/shared.js#toParentMessage"),
|
|
260
203
|
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#toParentOutMessage"),
|
|
261
204
|
foldOutMessage: foldAnimationOutMessage,
|
|
262
205
|
});
|
|
263
206
|
const openListbox = (baseModel, openCommands) => {
|
|
264
207
|
if (baseModel.isAnimated) {
|
|
265
|
-
const [nextModel, animationCommands] = foldAnimation(baseModel,
|
|
208
|
+
const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationMessage.Showed());
|
|
266
209
|
return __foldkitBrandViewResult(([
|
|
267
210
|
constrainedEvo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/listbox/shared.js#isOpen~2") }),
|
|
268
211
|
[...openCommands, ...animationCommands],
|
|
@@ -281,7 +224,7 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
281
224
|
}
|
|
282
225
|
const closed = closedModel(baseModel);
|
|
283
226
|
if (baseModel.isAnimated) {
|
|
284
|
-
const [nextModel, animationCommands] = foldAnimation(closed,
|
|
227
|
+
const [nextModel, animationCommands] = foldAnimation(closed, AnimationMessage.Hid());
|
|
285
228
|
return __foldkitBrandViewResult(([nextModel, [...commands, ...animationCommands], maybeOutMessage]), "@foldkit/ui/listbox/shared.js#closeListbox");
|
|
286
229
|
}
|
|
287
230
|
return __foldkitBrandViewResult(([closed, commands, maybeOutMessage]), "@foldkit/ui/listbox/shared.js#closeListbox");
|
|
@@ -440,20 +383,20 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
440
383
|
*
|
|
441
384
|
* Exposed so Scene tests can call
|
|
442
385
|
* `Scene.Mount.resolve(AnchorListbox, CompletedAnchorListbox())`. */
|
|
443
|
-
export const AnchorListbox = Mount.define('AnchorListbox', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorListbox)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
386
|
+
export const AnchorListbox = Mount.define('AnchorListbox', { buttonId: S.String, anchor: AnchorConfig }, Message.CompletedAnchorListbox)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
444
387
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((anchorSetup(element, {
|
|
445
388
|
buttonId,
|
|
446
389
|
anchor,
|
|
447
390
|
focusAfterPosition: true,
|
|
448
391
|
})), "@foldkit/ui/listbox/shared.js#anonymous~9")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/listbox/shared.js#anonymous~10"));
|
|
449
|
-
return __foldkitBrandViewResult((CompletedAnchorListbox()), "@foldkit/ui/listbox/shared.js#anonymous~8");
|
|
392
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorListbox()), "@foldkit/ui/listbox/shared.js#anonymous~8");
|
|
450
393
|
})), "@foldkit/ui/listbox/shared.js#anonymous~7")), "@foldkit/ui/listbox/shared.js#anonymous~6"));
|
|
451
394
|
/** The backdrop-portaling Mount this Listbox renders. Exposed so Scene tests can
|
|
452
395
|
* call `Scene.Mount.resolve(PortalListboxBackdrop, CompletedPortalListboxBackdrop())` to
|
|
453
396
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
454
|
-
export const PortalListboxBackdrop = Mount.define('PortalListboxBackdrop', CompletedPortalListboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
397
|
+
export const PortalListboxBackdrop = Mount.define('PortalListboxBackdrop', Message.CompletedPortalListboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
455
398
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/listbox/shared.js#anonymous~13")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/listbox/shared.js#anonymous~14"));
|
|
456
|
-
return __foldkitBrandViewResult((CompletedPortalListboxBackdrop()), "@foldkit/ui/listbox/shared.js#anonymous~12");
|
|
399
|
+
return __foldkitBrandViewResult((Message.CompletedPortalListboxBackdrop()), "@foldkit/ui/listbox/shared.js#anonymous~12");
|
|
457
400
|
})), "@foldkit/ui/listbox/shared.js#anonymous~11"));
|
|
458
401
|
export const makeView = (behavior) => {
|
|
459
402
|
const impl = defineView((model, viewInputs, h) => {
|
|
@@ -500,26 +443,26 @@ export const makeView = (behavior) => {
|
|
|
500
443
|
if (isOpen) {
|
|
501
444
|
return __foldkitBrandViewResult((handleItemsKeyDown(key)), "@foldkit/ui/listbox/shared.js#handleButtonKeyDown");
|
|
502
445
|
}
|
|
503
|
-
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Opened({
|
|
446
|
+
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
504
447
|
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(firstEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~27")),
|
|
505
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~26")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Opened({
|
|
448
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~26")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
506
449
|
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(lastEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~29")),
|
|
507
450
|
}))), "@foldkit/ui/listbox/shared.js#anonymous~28")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#anonymous~30")))), "@foldkit/ui/listbox/shared.js#handleButtonKeyDown");
|
|
508
451
|
};
|
|
509
|
-
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/listbox/shared.js#handleButtonPointerDown");
|
|
452
|
+
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/listbox/shared.js#handleButtonPointerDown");
|
|
510
453
|
const handleButtonClick = () => {
|
|
511
454
|
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/listbox/shared.js#anonymous~31"));
|
|
512
455
|
if (isMouse) {
|
|
513
|
-
return __foldkitBrandViewResult((IgnoredMouseClick()), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
456
|
+
return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
514
457
|
}
|
|
515
458
|
else if (isOpen) {
|
|
516
|
-
return __foldkitBrandViewResult((Closed()), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
459
|
+
return __foldkitBrandViewResult((Message.Closed()), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
517
460
|
}
|
|
518
461
|
else {
|
|
519
|
-
return __foldkitBrandViewResult((Opened({ maybeActiveItemIndex: Option.none() })), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
462
|
+
return __foldkitBrandViewResult((Message.Opened({ maybeActiveItemIndex: Option.none() })), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
520
463
|
}
|
|
521
464
|
};
|
|
522
|
-
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', SuppressedSpaceScroll())), "@foldkit/ui/listbox/shared.js#handleSpaceKeyUp");
|
|
465
|
+
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/listbox/shared.js#handleSpaceKeyUp");
|
|
523
466
|
const resolveActiveIndex = (key) => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
524
467
|
onNone: () => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(previousKey, 'End', 'PageDown', () => __foldkitBrandViewResult((lastEnabledIndex), "@foldkit/ui/listbox/shared.js#anonymous~32")), M.orElse(() => __foldkitBrandViewResult((firstEnabledIndex), "@foldkit/ui/listbox/shared.js#anonymous~33")))), "@foldkit/ui/listbox/shared.js#onNone~2"),
|
|
525
468
|
onSome: activeIndex => __foldkitBrandViewResult((keyToIndex(nextKey, previousKey, items.length, activeIndex, isItemDisabledByIndex)(key)), "@foldkit/ui/listbox/shared.js#onSome~2"),
|
|
@@ -527,19 +470,19 @@ export const makeView = (behavior) => {
|
|
|
527
470
|
const searchForKey = (key) => {
|
|
528
471
|
const nextQuery = searchQuery + key;
|
|
529
472
|
const maybeTargetIndex = resolveTypeaheadMatch(items, nextQuery, maybeActiveItemIndex, isItemDisabledByIndex, itemToSearchText, Str.isNonEmpty(searchQuery));
|
|
530
|
-
return __foldkitBrandViewResult((Option.some(Searched({ key, maybeTargetIndex }))), "@foldkit/ui/listbox/shared.js#searchForKey");
|
|
473
|
+
return __foldkitBrandViewResult((Option.some(Message.Searched({ key, maybeTargetIndex }))), "@foldkit/ui/listbox/shared.js#searchForKey");
|
|
531
474
|
};
|
|
532
475
|
const resolveCommitMessage = () => {
|
|
533
476
|
if (isReadOnly) {
|
|
534
|
-
return __foldkitBrandViewResult((Option.as(maybeActiveItemIndex, SuppressedItemCommit())), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
477
|
+
return __foldkitBrandViewResult((Option.as(maybeActiveItemIndex, Message.SuppressedItemCommit())), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
535
478
|
}
|
|
536
479
|
else {
|
|
537
|
-
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/listbox/shared.js#anonymous~34"))), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
480
|
+
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/listbox/shared.js#anonymous~34"))), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
538
481
|
}
|
|
539
482
|
};
|
|
540
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Closed())), "@foldkit/ui/listbox/shared.js#anonymous~35")), M.when('Enter', resolveCommitMessage), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
483
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/listbox/shared.js#anonymous~35")), M.when('Enter', resolveCommitMessage), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
541
484
|
? searchForKey(' ')
|
|
542
|
-
: resolveCommitMessage()), "@foldkit/ui/listbox/shared.js#anonymous~36")), M.when(isNavigationKey, () => __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
485
|
+
: resolveCommitMessage()), "@foldkit/ui/listbox/shared.js#anonymous~36")), M.when(isNavigationKey, () => __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
543
486
|
index: resolveActiveIndex(key),
|
|
544
487
|
activationTrigger: 'Keyboard',
|
|
545
488
|
}))), "@foldkit/ui/listbox/shared.js#anonymous~37")), M.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/listbox/shared.js#anonymous~38")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#anonymous~39")))), "@foldkit/ui/listbox/shared.js#handleItemsKeyDown");
|
|
@@ -611,7 +554,7 @@ export const makeView = (behavior) => {
|
|
|
611
554
|
: [
|
|
612
555
|
h.OnKeyDownPreventDefault(handleItemsKeyDown),
|
|
613
556
|
h.OnKeyUpPreventDefault(handleSpaceKeyUp),
|
|
614
|
-
h.OnBlur(BlurredItems()),
|
|
557
|
+
h.OnBlur(Message.BlurredItems()),
|
|
615
558
|
]),
|
|
616
559
|
...(itemsClassName ? [h.Class(itemsClassName)] : []),
|
|
617
560
|
...itemsAttributes,
|
|
@@ -639,20 +582,20 @@ export const makeView = (behavior) => {
|
|
|
639
582
|
: []),
|
|
640
583
|
...(isReadOnly ? [h.DataAttribute('readonly', '')] : []),
|
|
641
584
|
...(isClickable
|
|
642
|
-
? [h.OnClick(SelectedItem({ item: itemToValue(item) }))]
|
|
585
|
+
? [h.OnClick(Message.SelectedItem({ item: itemToValue(item) }))]
|
|
643
586
|
: []),
|
|
644
587
|
...(isHoverable
|
|
645
588
|
? [
|
|
646
589
|
...(isActiveItem
|
|
647
590
|
? []
|
|
648
591
|
: [
|
|
649
|
-
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({
|
|
592
|
+
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.MovedPointerOverItem({
|
|
650
593
|
index,
|
|
651
594
|
screenX,
|
|
652
595
|
screenY,
|
|
653
596
|
}))), "@foldkit/ui/listbox/shared.js#anonymous~42")),
|
|
654
597
|
]),
|
|
655
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/listbox/shared.js#anonymous~43")),
|
|
598
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/listbox/shared.js#anonymous~43")),
|
|
656
599
|
]
|
|
657
600
|
: []),
|
|
658
601
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
@@ -706,7 +649,7 @@ export const makeView = (behavior) => {
|
|
|
706
649
|
};
|
|
707
650
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
708
651
|
h.OnMount(PortalListboxBackdrop()),
|
|
709
|
-
...(isLeaving ? [] : [h.OnClick(Closed())]),
|
|
652
|
+
...(isLeaving ? [] : [h.OnClick(Message.Closed())]),
|
|
710
653
|
...(backdropClassName ? [h.Class(backdropClassName)] : []),
|
|
711
654
|
...backdropAttributes,
|
|
712
655
|
]);
|
package/dist/listbox/single.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import type * as Command from 'foldkit/command';
|
|
3
3
|
import { type View as SubmodelView } from 'foldkit/submodel';
|
|
4
|
-
import { type BaseInitConfig, type BaseViewInputsCommon, type ItemToValueInput,
|
|
4
|
+
import { type BaseInitConfig, type BaseViewInputsCommon, type ItemToValueInput, Message, OutMessage } from './shared.js';
|
|
5
5
|
/** Schema for the single-select listbox's private interaction state (open/closed status, active item, activation trigger, typeahead search). The selection is owned by the parent and passed in via `ViewInputs.maybeSelectedValue`. */
|
|
6
6
|
export declare const Model: S.Struct<{
|
|
7
7
|
readonly id: S.String;
|
|
@@ -129,12 +129,6 @@ export declare const update: (model: {
|
|
|
129
129
|
readonly _tag: "PressedPointerOnButton";
|
|
130
130
|
readonly pointerType: string;
|
|
131
131
|
readonly button: number;
|
|
132
|
-
} | {
|
|
133
|
-
readonly _tag: "CompletedFocusItems";
|
|
134
|
-
} | {
|
|
135
|
-
readonly _tag: "CompletedAnchorListbox";
|
|
136
|
-
} | {
|
|
137
|
-
readonly _tag: "CompletedPortalListboxBackdrop";
|
|
138
132
|
} | {
|
|
139
133
|
readonly _tag: "GotAnimationMessage";
|
|
140
134
|
readonly message: {
|
|
@@ -146,6 +140,12 @@ export declare const update: (model: {
|
|
|
146
140
|
} | {
|
|
147
141
|
readonly _tag: "EndedAnimation";
|
|
148
142
|
};
|
|
143
|
+
} | {
|
|
144
|
+
readonly _tag: "CompletedFocusItems";
|
|
145
|
+
} | {
|
|
146
|
+
readonly _tag: "CompletedAnchorListbox";
|
|
147
|
+
} | {
|
|
148
|
+
readonly _tag: "CompletedPortalListboxBackdrop";
|
|
149
149
|
}, never, never>;
|
|
150
150
|
}>[], Option.Option<Readonly<{
|
|
151
151
|
readonly _tag: "Selected";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/listbox/single.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,KAAK,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AAExE,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/listbox/single.ts"],"names":[],"mappings":"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"}
|
package/dist/listbox/single.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
2
|
import { Option, Schema as S } from 'effect';
|
|
3
3
|
import { defineView } from 'foldkit/submodel';
|
|
4
|
-
import { BaseModel,
|
|
4
|
+
import { BaseModel, Message, OutMessage, baseInit, makeUpdate, makeView, } from './shared.js';
|
|
5
5
|
// MODEL
|
|
6
6
|
/** Schema for the single-select listbox's private interaction state (open/closed status, active item, activation trigger, typeahead search). The selection is owned by the parent and passed in via `ViewInputs.maybeSelectedValue`. */
|
|
7
7
|
export const Model = S.Struct({
|
|
@@ -11,17 +11,17 @@ export const Model = S.Struct({
|
|
|
11
11
|
export const init = (config) => __foldkitBrandViewResult((baseInit(config)), "@foldkit/ui/listbox/single.js#init");
|
|
12
12
|
// UPDATE
|
|
13
13
|
/** 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 })` OutMessage the parent stores as the selection. */
|
|
14
|
-
export const update = makeUpdate((model, item, context) => __foldkitBrandViewResult((context.closeWithFocus(model, Option.some(
|
|
14
|
+
export const update = makeUpdate((model, item, context) => __foldkitBrandViewResult((context.closeWithFocus(model, Option.some(OutMessage.Selected({ value: item })))), "@foldkit/ui/listbox/single.js#anonymous"));
|
|
15
15
|
/** Programmatically opens the listbox, updating the model and returning
|
|
16
16
|
* focus and modal commands. Use this in domain-event handlers to open the listbox. */
|
|
17
|
-
export const open = (model) => __foldkitBrandViewResult((update(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/single.js#open");
|
|
17
|
+
export const open = (model) => __foldkitBrandViewResult((update(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/single.js#open");
|
|
18
18
|
/** Programmatically closes the listbox. If it is open, returns the closed Model
|
|
19
19
|
* with focus and modal Commands. If it is already closed, returns the Model
|
|
20
20
|
* unchanged with no Commands. Use this in domain-event handlers to close the
|
|
21
21
|
* listbox. */
|
|
22
|
-
export const close = (model) => __foldkitBrandViewResult((update(model, Closed())), "@foldkit/ui/listbox/single.js#close");
|
|
22
|
+
export const close = (model) => __foldkitBrandViewResult((update(model, Message.Closed())), "@foldkit/ui/listbox/single.js#close");
|
|
23
23
|
/** Programmatically selects an item in the single-select listbox, closing the listbox and emitting a `Selected({ value })` OutMessage. */
|
|
24
|
-
export const selectItem = (model, item) => __foldkitBrandViewResult((update(model, SelectedItem({ item }))), "@foldkit/ui/listbox/single.js#selectItem");
|
|
24
|
+
export const selectItem = (model, item) => __foldkitBrandViewResult((update(model, Message.SelectedItem({ item }))), "@foldkit/ui/listbox/single.js#selectItem");
|
|
25
25
|
const internalView = makeView({ ariaMultiSelectable: false });
|
|
26
26
|
const arrayBasedView = internalView();
|
|
27
27
|
const singleViewImpl = defineView((model, { maybeSelectedValue, ...baseInputs }, h) => __foldkitBrandViewResult((arrayBasedView(model, {
|
|
@@ -57,8 +57,8 @@ export const create = () => {
|
|
|
57
57
|
return __foldkitBrandViewResult(({
|
|
58
58
|
view,
|
|
59
59
|
update: typedUpdate,
|
|
60
|
-
selectItem: (model, item) => __foldkitBrandViewResult((typedUpdate(model, SelectedItem({ item }))), "@foldkit/ui/listbox/single.js#selectItem~2"),
|
|
61
|
-
open: model => __foldkitBrandViewResult((typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/single.js#open~2"),
|
|
62
|
-
close: model => __foldkitBrandViewResult((typedUpdate(model, Closed())), "@foldkit/ui/listbox/single.js#close~2"),
|
|
60
|
+
selectItem: (model, item) => __foldkitBrandViewResult((typedUpdate(model, Message.SelectedItem({ item }))), "@foldkit/ui/listbox/single.js#selectItem~2"),
|
|
61
|
+
open: model => __foldkitBrandViewResult((typedUpdate(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/listbox/single.js#open~2"),
|
|
62
|
+
close: model => __foldkitBrandViewResult((typedUpdate(model, Message.Closed())), "@foldkit/ui/listbox/single.js#close~2"),
|
|
63
63
|
}), "@foldkit/ui/listbox/single.js#create");
|
|
64
64
|
};
|