@foldkit/ui 0.150.0 → 0.151.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/update.d.ts +10 -9
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +27 -35
- package/dist/calendar/index.d.ts +100 -11
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +66 -80
- package/dist/checkbox/index.d.ts +3 -4
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +3 -4
- package/dist/combobox/multi.d.ts +40 -51
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +19 -16
- package/dist/combobox/shared.d.ts +20 -20
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +134 -128
- package/dist/combobox/single.d.ts +38 -51
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +21 -17
- package/dist/datePicker/index.d.ts +182 -15
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +37 -54
- package/dist/dialog/index.d.ts +45 -7
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +54 -49
- package/dist/disclosure/index.d.ts +3 -4
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +3 -4
- package/dist/dragAndDrop/index.d.ts +96 -7
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +49 -61
- package/dist/fileDrop/index.d.ts +26 -11
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +16 -23
- package/dist/listbox/multi.d.ts +39 -52
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +9 -7
- package/dist/listbox/shared.d.ts +14 -22
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +113 -114
- package/dist/listbox/single.d.ts +40 -55
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -7
- package/dist/menu/index.d.ts +131 -37
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +111 -120
- package/dist/popover/index.d.ts +71 -10
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +80 -73
- package/dist/radioGroup/index.d.ts +31 -19
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +18 -18
- package/dist/slider/index.d.ts +44 -13
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +33 -38
- package/dist/switch/index.d.ts +3 -4
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/switch/index.js +3 -4
- package/dist/tabs/index.d.ts +31 -17
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +17 -17
- package/dist/test/apps/disabledButton.d.ts +17 -17
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +6 -4
- package/dist/toast/index.d.ts +96 -100
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/update.d.ts +97 -100
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +60 -58
- package/dist/tooltip/index.d.ts +2 -1
- package/dist/tooltip/index.d.ts.map +1 -1
- package/dist/tooltip/index.js +1 -1
- package/dist/tooltip/tooltip.d.ts +5 -10
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +45 -48
- package/dist/virtualList/index.d.ts +30 -29
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +21 -21
- package/package.json +3 -3
package/dist/listbox/shared.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
2
|
-
import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, String as Str, pipe, } from 'effect';
|
|
2
|
+
import { Array, Effect, Equal, Match as M, Number, 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
5
|
import { defineMessageUnion } from 'foldkit/message';
|
|
@@ -187,47 +187,50 @@ export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnim
|
|
|
187
187
|
}))))), "@foldkit/ui/listbox/shared.js#execute~8"),
|
|
188
188
|
});
|
|
189
189
|
export const makeUpdate = (handleSelectedItem) => {
|
|
190
|
-
const withUpdateReturn = M.withReturnType();
|
|
191
190
|
const foldAnimationOutMessage = M.type().pipe(M.withReturnType(), M.tagsExhaustive({
|
|
192
|
-
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((
|
|
191
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
|
|
193
192
|
model,
|
|
194
|
-
[DetectMovementOrAnimationEnd({ id: model.id })],
|
|
195
|
-
|
|
196
|
-
TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult((
|
|
193
|
+
commands: [DetectMovementOrAnimationEnd({ id: model.id })],
|
|
194
|
+
}), "@foldkit/ui/listbox/shared.js#anonymous"))), "@foldkit/ui/listbox/shared.js#StartedLeaveAnimating"),
|
|
195
|
+
TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#anonymous~2"))), "@foldkit/ui/listbox/shared.js#TransitionedOut"),
|
|
197
196
|
}));
|
|
198
197
|
const foldAnimation = Update.foldChild({
|
|
199
198
|
update: animationUpdate,
|
|
200
199
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/listbox/shared.js#read"),
|
|
201
200
|
write: (model, nextAnimation) => __foldkitBrandViewResult((constrainedEvo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/listbox/shared.js#animation") })), "@foldkit/ui/listbox/shared.js#write"),
|
|
202
201
|
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/listbox/shared.js#toParentMessage"),
|
|
203
|
-
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#toParentOutMessage"),
|
|
204
202
|
foldOutMessage: foldAnimationOutMessage,
|
|
205
203
|
});
|
|
206
204
|
const openListbox = (baseModel, openCommands) => {
|
|
207
205
|
if (baseModel.isAnimated) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
206
|
+
return __foldkitBrandViewResult((Update.combine(baseModel, [
|
|
207
|
+
stepModel => (__foldkitBrandViewResult(({
|
|
208
|
+
model: stepModel,
|
|
209
|
+
commands: openCommands,
|
|
210
|
+
}), "@foldkit/ui/listbox/shared.js#anonymous~3")),
|
|
211
|
+
foldAnimation(AnimationMessage.Showed()),
|
|
212
|
+
stepModel => (__foldkitBrandViewResult(({
|
|
213
|
+
model: constrainedEvo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/listbox/shared.js#isOpen~2") }),
|
|
214
|
+
}), "@foldkit/ui/listbox/shared.js#anonymous~4")),
|
|
215
|
+
])), "@foldkit/ui/listbox/shared.js#openListbox");
|
|
214
216
|
}
|
|
215
|
-
return __foldkitBrandViewResult((
|
|
216
|
-
constrainedEvo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/listbox/shared.js#isOpen~3") }),
|
|
217
|
-
openCommands,
|
|
218
|
-
|
|
219
|
-
]), "@foldkit/ui/listbox/shared.js#openListbox");
|
|
217
|
+
return __foldkitBrandViewResult(({
|
|
218
|
+
model: constrainedEvo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/listbox/shared.js#isOpen~3") }),
|
|
219
|
+
commands: openCommands,
|
|
220
|
+
}), "@foldkit/ui/listbox/shared.js#openListbox");
|
|
220
221
|
};
|
|
221
|
-
const closeListbox = (baseModel, commands
|
|
222
|
+
const closeListbox = (baseModel, commands) => {
|
|
222
223
|
if (!baseModel.isOpen) {
|
|
223
|
-
return __foldkitBrandViewResult((
|
|
224
|
+
return __foldkitBrandViewResult(({ model: baseModel }), "@foldkit/ui/listbox/shared.js#closeListbox");
|
|
224
225
|
}
|
|
225
226
|
const closed = closedModel(baseModel);
|
|
226
227
|
if (baseModel.isAnimated) {
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
return __foldkitBrandViewResult((Update.combine(closed, [
|
|
229
|
+
stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/listbox/shared.js#anonymous~5")),
|
|
230
|
+
foldAnimation(AnimationMessage.Hid()),
|
|
231
|
+
])), "@foldkit/ui/listbox/shared.js#closeListbox");
|
|
229
232
|
}
|
|
230
|
-
return __foldkitBrandViewResult((
|
|
233
|
+
return __foldkitBrandViewResult(({ model: closed, commands }), "@foldkit/ui/listbox/shared.js#closeListbox");
|
|
231
234
|
};
|
|
232
235
|
const internalUpdate = (model, message) => {
|
|
233
236
|
const maybeLockScroll = OptionExt.when(model.isModal, LockScroll());
|
|
@@ -244,11 +247,20 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
244
247
|
focusButton,
|
|
245
248
|
...Array.getSomes([maybeUnlockScroll, maybeRestoreInert]),
|
|
246
249
|
];
|
|
247
|
-
const closeWithoutFocusCommands = Array.getSomes([
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
const closeWithoutFocusCommands = Array.getSomes([maybeUnlockScroll, maybeRestoreInert]);
|
|
251
|
+
return __foldkitBrandViewResult((Message.match(message, {
|
|
252
|
+
CompletedLockScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedLockScroll")),
|
|
253
|
+
CompletedUnlockScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedUnlockScroll")),
|
|
254
|
+
CompletedInertOthers: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedInertOthers")),
|
|
255
|
+
CompletedRestoreInert: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedRestoreInert")),
|
|
256
|
+
CompletedFocusButton: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedFocusButton")),
|
|
257
|
+
CompletedFocusItems: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedFocusItems")),
|
|
258
|
+
CompletedScrollIntoView: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedScrollIntoView")),
|
|
259
|
+
CompletedClickItem: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedClickItem")),
|
|
260
|
+
SuppressedSpaceScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#SuppressedSpaceScroll")),
|
|
261
|
+
SuppressedItemCommit: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#SuppressedItemCommit")),
|
|
262
|
+
CompletedAnchorListbox: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedAnchorListbox")),
|
|
263
|
+
CompletedPortalListboxBackdrop: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedPortalListboxBackdrop")),
|
|
252
264
|
Opened: ({ maybeActiveItemIndex }) => __foldkitBrandViewResult((openListbox(constrainedEvo(model, {
|
|
253
265
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((maybeActiveItemIndex), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~2"),
|
|
254
266
|
activationTrigger: () => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
@@ -262,75 +274,64 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
262
274
|
Closed: () => __foldkitBrandViewResult((closeListbox(model, closeWithFocusCommands)), "@foldkit/ui/listbox/shared.js#Closed"),
|
|
263
275
|
BlurredItems: () => {
|
|
264
276
|
if (Option.exists(model.maybeLastButtonPointerType, Equal.equals('mouse'))) {
|
|
265
|
-
return __foldkitBrandViewResult((
|
|
277
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#BlurredItems");
|
|
266
278
|
}
|
|
267
279
|
return __foldkitBrandViewResult((closeListbox(model, closeWithoutFocusCommands)), "@foldkit/ui/listbox/shared.js#BlurredItems");
|
|
268
280
|
},
|
|
269
|
-
ActivatedItem: ({ index, activationTrigger }) => __foldkitBrandViewResult((
|
|
270
|
-
constrainedEvo(model, {
|
|
281
|
+
ActivatedItem: ({ index, activationTrigger }) => (__foldkitBrandViewResult(({
|
|
282
|
+
model: constrainedEvo(model, {
|
|
271
283
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~3"),
|
|
272
284
|
activationTrigger: () => __foldkitBrandViewResult((activationTrigger), "@foldkit/ui/listbox/shared.js#activationTrigger~2"),
|
|
273
285
|
}),
|
|
274
|
-
activationTrigger === 'Keyboard'
|
|
286
|
+
commands: activationTrigger === 'Keyboard'
|
|
275
287
|
? [ScrollIntoView({ id: model.id, index })]
|
|
276
288
|
: [],
|
|
277
|
-
|
|
278
|
-
]), "@foldkit/ui/listbox/shared.js#ActivatedItem"),
|
|
289
|
+
}), "@foldkit/ui/listbox/shared.js#ActivatedItem")),
|
|
279
290
|
MovedPointerOverItem: ({ index, screenX, screenY }) => {
|
|
280
|
-
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
291
|
+
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/listbox/shared.js#anonymous~6"));
|
|
281
292
|
if (isSamePosition) {
|
|
282
|
-
return __foldkitBrandViewResult((
|
|
293
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#MovedPointerOverItem");
|
|
283
294
|
}
|
|
284
|
-
return __foldkitBrandViewResult((
|
|
285
|
-
constrainedEvo(model, {
|
|
295
|
+
return __foldkitBrandViewResult(({
|
|
296
|
+
model: constrainedEvo(model, {
|
|
286
297
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~4"),
|
|
287
298
|
activationTrigger: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/listbox/shared.js#activationTrigger~3"),
|
|
288
299
|
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.some({ screenX, screenY })), "@foldkit/ui/listbox/shared.js#maybeLastPointerPosition~3"),
|
|
289
300
|
}),
|
|
290
|
-
|
|
291
|
-
Option.none(),
|
|
292
|
-
]), "@foldkit/ui/listbox/shared.js#MovedPointerOverItem");
|
|
301
|
+
}), "@foldkit/ui/listbox/shared.js#MovedPointerOverItem");
|
|
293
302
|
},
|
|
294
303
|
DeactivatedItem: () => __foldkitBrandViewResult((model.activationTrigger === 'Pointer'
|
|
295
|
-
?
|
|
296
|
-
constrainedEvo(model, {
|
|
304
|
+
? {
|
|
305
|
+
model: constrainedEvo(model, {
|
|
297
306
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~5"),
|
|
298
307
|
}),
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
]
|
|
302
|
-
: [model, [], Option.none()]), "@foldkit/ui/listbox/shared.js#DeactivatedItem"),
|
|
308
|
+
}
|
|
309
|
+
: { model }), "@foldkit/ui/listbox/shared.js#DeactivatedItem"),
|
|
303
310
|
SelectedItem: ({ item }) => __foldkitBrandViewResult((handleSelectedItem(model, item, {
|
|
304
|
-
closeWithFocus: (closeModel,
|
|
305
|
-
closeWithoutFocus: (closeModel,
|
|
311
|
+
closeWithFocus: (closeModel, outMessage) => __foldkitBrandViewResult((pipe(closeListbox(closeModel, closeWithFocusCommands), Update.withOutMessage(outMessage))), "@foldkit/ui/listbox/shared.js#closeWithFocus"),
|
|
312
|
+
closeWithoutFocus: (closeModel, outMessage) => __foldkitBrandViewResult((pipe(closeListbox(closeModel, closeWithoutFocusCommands), Update.withOutMessage(outMessage))), "@foldkit/ui/listbox/shared.js#closeWithoutFocus"),
|
|
306
313
|
})), "@foldkit/ui/listbox/shared.js#SelectedItem"),
|
|
307
|
-
RequestedItemClick: ({ index }) => __foldkitBrandViewResult((
|
|
314
|
+
RequestedItemClick: ({ index }) => (__foldkitBrandViewResult(({
|
|
308
315
|
model,
|
|
309
|
-
[ClickItem({ id: model.id, index })],
|
|
310
|
-
|
|
311
|
-
]), "@foldkit/ui/listbox/shared.js#RequestedItemClick"),
|
|
316
|
+
commands: [ClickItem({ id: model.id, index })],
|
|
317
|
+
}), "@foldkit/ui/listbox/shared.js#RequestedItemClick")),
|
|
312
318
|
Searched: ({ key, maybeTargetIndex }) => {
|
|
313
319
|
const nextSearchQuery = model.searchQuery + key;
|
|
314
|
-
const nextSearchVersion = model.searchVersion
|
|
315
|
-
return __foldkitBrandViewResult((
|
|
316
|
-
constrainedEvo(model, {
|
|
320
|
+
const nextSearchVersion = Number.increment(model.searchVersion);
|
|
321
|
+
return __foldkitBrandViewResult(({
|
|
322
|
+
model: constrainedEvo(model, {
|
|
317
323
|
searchQuery: () => __foldkitBrandViewResult((nextSearchQuery), "@foldkit/ui/listbox/shared.js#searchQuery~3"),
|
|
318
324
|
searchVersion: () => __foldkitBrandViewResult((nextSearchVersion), "@foldkit/ui/listbox/shared.js#searchVersion~3"),
|
|
319
|
-
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
325
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.orElse(maybeTargetIndex, () => __foldkitBrandViewResult((model.maybeActiveItemIndex), "@foldkit/ui/listbox/shared.js#anonymous~7"))), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~6"),
|
|
320
326
|
}),
|
|
321
|
-
[DelayClearSearch({ version: nextSearchVersion })],
|
|
322
|
-
|
|
323
|
-
]), "@foldkit/ui/listbox/shared.js#Searched");
|
|
327
|
+
commands: [DelayClearSearch({ version: nextSearchVersion })],
|
|
328
|
+
}), "@foldkit/ui/listbox/shared.js#Searched");
|
|
324
329
|
},
|
|
325
330
|
CompletedDelayClearSearch: ({ version }) => {
|
|
326
331
|
if (version !== model.searchVersion) {
|
|
327
|
-
return __foldkitBrandViewResult((
|
|
332
|
+
return __foldkitBrandViewResult(({ model }), "@foldkit/ui/listbox/shared.js#CompletedDelayClearSearch");
|
|
328
333
|
}
|
|
329
|
-
return __foldkitBrandViewResult((
|
|
330
|
-
constrainedEvo(model, { searchQuery: () => __foldkitBrandViewResult((''), "@foldkit/ui/listbox/shared.js#searchQuery~4") }),
|
|
331
|
-
[],
|
|
332
|
-
Option.none(),
|
|
333
|
-
]), "@foldkit/ui/listbox/shared.js#CompletedDelayClearSearch");
|
|
334
|
+
return __foldkitBrandViewResult(({ model: constrainedEvo(model, { searchQuery: () => __foldkitBrandViewResult((''), "@foldkit/ui/listbox/shared.js#searchQuery~4") }) }), "@foldkit/ui/listbox/shared.js#CompletedDelayClearSearch");
|
|
334
335
|
},
|
|
335
336
|
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/listbox/shared.js#GotAnimationMessage"),
|
|
336
337
|
PressedPointerOnButton: ({ pointerType, button }) => {
|
|
@@ -338,17 +339,17 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
338
339
|
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/listbox/shared.js#maybeLastButtonPointerType~2"),
|
|
339
340
|
});
|
|
340
341
|
if (pointerType !== 'mouse' || button !== LEFT_MOUSE_BUTTON) {
|
|
341
|
-
return __foldkitBrandViewResult((
|
|
342
|
+
return __foldkitBrandViewResult(({ model: withPointerType }), "@foldkit/ui/listbox/shared.js#PressedPointerOnButton");
|
|
342
343
|
}
|
|
343
344
|
if (model.isOpen) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
]), "@foldkit/ui/listbox/shared.js#PressedPointerOnButton");
|
|
345
|
+
return __foldkitBrandViewResult((Update.combine(withPointerType, [
|
|
346
|
+
stepModel => __foldkitBrandViewResult((closeListbox(stepModel, closeWithFocusCommands)), "@foldkit/ui/listbox/shared.js#anonymous~8"),
|
|
347
|
+
stepModel => (__foldkitBrandViewResult(({
|
|
348
|
+
model: constrainedEvo(stepModel, {
|
|
349
|
+
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/listbox/shared.js#maybeLastButtonPointerType~3"),
|
|
350
|
+
}),
|
|
351
|
+
}), "@foldkit/ui/listbox/shared.js#anonymous~9")),
|
|
352
|
+
])), "@foldkit/ui/listbox/shared.js#PressedPointerOnButton");
|
|
352
353
|
}
|
|
353
354
|
return __foldkitBrandViewResult((openListbox(constrainedEvo(withPointerType, {
|
|
354
355
|
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#maybeActiveItemIndex~7"),
|
|
@@ -358,14 +359,12 @@ export const makeUpdate = (handleSelectedItem) => {
|
|
|
358
359
|
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#maybeLastPointerPosition~4"),
|
|
359
360
|
}), openCommands)), "@foldkit/ui/listbox/shared.js#PressedPointerOnButton");
|
|
360
361
|
},
|
|
361
|
-
IgnoredMouseClick: () => __foldkitBrandViewResult((
|
|
362
|
-
constrainedEvo(model, {
|
|
362
|
+
IgnoredMouseClick: () => (__foldkitBrandViewResult(({
|
|
363
|
+
model: constrainedEvo(model, {
|
|
363
364
|
maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#maybeLastButtonPointerType~4"),
|
|
364
365
|
}),
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
]), "@foldkit/ui/listbox/shared.js#IgnoredMouseClick"),
|
|
368
|
-
}))), "@foldkit/ui/listbox/shared.js#internalUpdate");
|
|
366
|
+
}), "@foldkit/ui/listbox/shared.js#IgnoredMouseClick")),
|
|
367
|
+
})), "@foldkit/ui/listbox/shared.js#internalUpdate");
|
|
369
368
|
};
|
|
370
369
|
return __foldkitBrandViewResult((internalUpdate), "@foldkit/ui/listbox/shared.js#makeUpdate");
|
|
371
370
|
};
|
|
@@ -388,42 +387,42 @@ export const AnchorListbox = Mount.define('AnchorListbox', { buttonId: S.String,
|
|
|
388
387
|
buttonId,
|
|
389
388
|
anchor,
|
|
390
389
|
focusAfterPosition: true,
|
|
391
|
-
})), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
392
|
-
return __foldkitBrandViewResult((Message.CompletedAnchorListbox()), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
393
|
-
})), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
390
|
+
})), "@foldkit/ui/listbox/shared.js#anonymous~13")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/listbox/shared.js#anonymous~14"));
|
|
391
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorListbox()), "@foldkit/ui/listbox/shared.js#anonymous~12");
|
|
392
|
+
})), "@foldkit/ui/listbox/shared.js#anonymous~11")), "@foldkit/ui/listbox/shared.js#anonymous~10"));
|
|
394
393
|
/** The backdrop-portaling Mount this Listbox renders. Exposed so Scene tests can
|
|
395
394
|
* call `Scene.Mount.resolve(PortalListboxBackdrop, CompletedPortalListboxBackdrop())` to
|
|
396
395
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
397
396
|
export const PortalListboxBackdrop = Mount.define('PortalListboxBackdrop', Message.CompletedPortalListboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
398
|
-
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
399
|
-
return __foldkitBrandViewResult((Message.CompletedPortalListboxBackdrop()), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
400
|
-
})), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
397
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/listbox/shared.js#anonymous~17")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/listbox/shared.js#anonymous~18"));
|
|
398
|
+
return __foldkitBrandViewResult((Message.CompletedPortalListboxBackdrop()), "@foldkit/ui/listbox/shared.js#anonymous~16");
|
|
399
|
+
})), "@foldkit/ui/listbox/shared.js#anonymous~15"));
|
|
401
400
|
export const makeView = (behavior) => {
|
|
402
401
|
const impl = defineView((model, viewInputs, h) => {
|
|
403
402
|
const { id, isOpen, orientation, animation: { transitionState }, maybeActiveItemIndex, searchQuery, maybeLastButtonPointerType, } = model;
|
|
404
403
|
const { items, itemToConfig, isItemDisabled, isButtonDisabled, buttonContent, buttonClassName, buttonAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor = {}, name, form, isDisabled, isReadOnly = false, isInvalid, ariaLabel, ariaLabelledBy, selectedValues, } = viewInputs;
|
|
405
|
-
const itemToValue = viewInputs.itemToValue ?? ((item) => __foldkitBrandViewResult((String(item)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
404
|
+
const itemToValue = viewInputs.itemToValue ?? ((item) => __foldkitBrandViewResult((String(item)), "@foldkit/ui/listbox/shared.js#anonymous~20"));
|
|
406
405
|
const isValueSelected = (itemValue) => __foldkitBrandViewResult((Array.contains(selectedValues, itemValue)), "@foldkit/ui/listbox/shared.js#isValueSelected");
|
|
407
|
-
const itemToSearchText = viewInputs.itemToSearchText ?? ((item) => __foldkitBrandViewResult((itemToValue(item)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
406
|
+
const itemToSearchText = viewInputs.itemToSearchText ?? ((item) => __foldkitBrandViewResult((itemToValue(item)), "@foldkit/ui/listbox/shared.js#anonymous~21"));
|
|
408
407
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
409
408
|
const isVisible = isOpen || isLeaving;
|
|
410
409
|
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
411
410
|
h.DataAttribute('closed', ''),
|
|
412
411
|
h.DataAttribute('enter', ''),
|
|
413
412
|
h.DataAttribute('transition', ''),
|
|
414
|
-
]), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
413
|
+
]), "@foldkit/ui/listbox/shared.js#anonymous~22")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
415
414
|
h.DataAttribute('enter', ''),
|
|
416
415
|
h.DataAttribute('transition', ''),
|
|
417
|
-
]), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
416
|
+
]), "@foldkit/ui/listbox/shared.js#anonymous~23")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
418
417
|
h.DataAttribute('leave', ''),
|
|
419
418
|
h.DataAttribute('transition', ''),
|
|
420
|
-
]), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
419
|
+
]), "@foldkit/ui/listbox/shared.js#anonymous~24")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
421
420
|
h.DataAttribute('closed', ''),
|
|
422
421
|
h.DataAttribute('leave', ''),
|
|
423
422
|
h.DataAttribute('transition', ''),
|
|
424
|
-
]), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
423
|
+
]), "@foldkit/ui/listbox/shared.js#anonymous~25")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/listbox/shared.js#anonymous~26")));
|
|
425
424
|
const isItemDisabledByIndex = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
426
|
-
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
425
|
+
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/listbox/shared.js#anonymous~27")))), "@foldkit/ui/listbox/shared.js#isItemDisabledByIndex");
|
|
427
426
|
const isButtonEffectivelyDisabled = isDisabled || isButtonDisabled;
|
|
428
427
|
const nextKey = orientation === 'Horizontal' ? 'ArrowRight' : 'ArrowDown';
|
|
429
428
|
const previousKey = orientation === 'Horizontal' ? 'ArrowLeft' : 'ArrowUp';
|
|
@@ -438,20 +437,20 @@ export const makeView = (behavior) => {
|
|
|
438
437
|
const isNavigationKey = (key) => __foldkitBrandViewResult((Array.contains(navigationKeys, key)), "@foldkit/ui/listbox/shared.js#isNavigationKey");
|
|
439
438
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isItemDisabledByIndex)(0, 1);
|
|
440
439
|
const lastEnabledIndex = findFirstEnabledIndex(items.length, 0, isItemDisabledByIndex)(items.length - 1, -1);
|
|
441
|
-
const selectedItemIndex = pipe(selectedValues, Array.head, Option.flatMap(selectedValue => __foldkitBrandViewResult((Array.findFirstIndex(items, item => __foldkitBrandViewResult((itemToValue(item) === selectedValue), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
440
|
+
const selectedItemIndex = pipe(selectedValues, Array.head, Option.flatMap(selectedValue => __foldkitBrandViewResult((Array.findFirstIndex(items, item => __foldkitBrandViewResult((itemToValue(item) === selectedValue), "@foldkit/ui/listbox/shared.js#anonymous~29"))), "@foldkit/ui/listbox/shared.js#anonymous~28")));
|
|
442
441
|
const handleButtonKeyDown = (key) => {
|
|
443
442
|
if (isOpen) {
|
|
444
443
|
return __foldkitBrandViewResult((handleItemsKeyDown(key)), "@foldkit/ui/listbox/shared.js#handleButtonKeyDown");
|
|
445
444
|
}
|
|
446
445
|
return __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
447
|
-
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(firstEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
448
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
449
|
-
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(lastEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
450
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
446
|
+
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(firstEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~31")),
|
|
447
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~30")), M.when('ArrowUp', () => __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
448
|
+
maybeActiveItemIndex: Option.orElse(selectedItemIndex, () => __foldkitBrandViewResult((Option.some(lastEnabledIndex)), "@foldkit/ui/listbox/shared.js#anonymous~33")),
|
|
449
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~32")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#anonymous~34")))), "@foldkit/ui/listbox/shared.js#handleButtonKeyDown");
|
|
451
450
|
};
|
|
452
451
|
const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/listbox/shared.js#handleButtonPointerDown");
|
|
453
452
|
const handleButtonClick = () => {
|
|
454
|
-
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
453
|
+
const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/listbox/shared.js#anonymous~35"));
|
|
455
454
|
if (isMouse) {
|
|
456
455
|
return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/listbox/shared.js#handleButtonClick");
|
|
457
456
|
}
|
|
@@ -464,7 +463,7 @@ export const makeView = (behavior) => {
|
|
|
464
463
|
};
|
|
465
464
|
const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/listbox/shared.js#handleSpaceKeyUp");
|
|
466
465
|
const resolveActiveIndex = (key) => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
467
|
-
onNone: () => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(previousKey, 'End', 'PageDown', () => __foldkitBrandViewResult((lastEnabledIndex), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
466
|
+
onNone: () => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr(previousKey, 'End', 'PageDown', () => __foldkitBrandViewResult((lastEnabledIndex), "@foldkit/ui/listbox/shared.js#anonymous~36")), M.orElse(() => __foldkitBrandViewResult((firstEnabledIndex), "@foldkit/ui/listbox/shared.js#anonymous~37")))), "@foldkit/ui/listbox/shared.js#onNone~2"),
|
|
468
467
|
onSome: activeIndex => __foldkitBrandViewResult((keyToIndex(nextKey, previousKey, items.length, activeIndex, isItemDisabledByIndex)(key)), "@foldkit/ui/listbox/shared.js#onSome~2"),
|
|
469
468
|
})), "@foldkit/ui/listbox/shared.js#resolveActiveIndex");
|
|
470
469
|
const searchForKey = (key) => {
|
|
@@ -477,15 +476,15 @@ export const makeView = (behavior) => {
|
|
|
477
476
|
return __foldkitBrandViewResult((Option.as(maybeActiveItemIndex, Message.SuppressedItemCommit())), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
478
477
|
}
|
|
479
478
|
else {
|
|
480
|
-
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
479
|
+
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/listbox/shared.js#anonymous~38"))), "@foldkit/ui/listbox/shared.js#resolveCommitMessage");
|
|
481
480
|
}
|
|
482
481
|
};
|
|
483
|
-
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
482
|
+
const handleItemsKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.Closed())), "@foldkit/ui/listbox/shared.js#anonymous~39")), M.when('Enter', resolveCommitMessage), M.when(' ', () => __foldkitBrandViewResult((Str.isNonEmpty(searchQuery)
|
|
484
483
|
? searchForKey(' ')
|
|
485
|
-
: resolveCommitMessage()), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
484
|
+
: resolveCommitMessage()), "@foldkit/ui/listbox/shared.js#anonymous~40")), M.when(isNavigationKey, () => __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
486
485
|
index: resolveActiveIndex(key),
|
|
487
486
|
activationTrigger: 'Keyboard',
|
|
488
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
487
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~41")), M.when(isPrintableKey, () => __foldkitBrandViewResult((searchForKey(key)), "@foldkit/ui/listbox/shared.js#anonymous~42")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/listbox/shared.js#anonymous~43")))), "@foldkit/ui/listbox/shared.js#handleItemsKeyDown");
|
|
489
488
|
const resolveButtonLabel = () => {
|
|
490
489
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
491
490
|
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/listbox/shared.js#resolveButtonLabel");
|
|
@@ -560,7 +559,7 @@ export const makeView = (behavior) => {
|
|
|
560
559
|
...itemsAttributes,
|
|
561
560
|
];
|
|
562
561
|
const listboxItems = Array.map(items, (item, index) => {
|
|
563
|
-
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
562
|
+
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/listbox/shared.js#anonymous~45"));
|
|
564
563
|
const isDisabledItem = isItemDisabledByIndex(index);
|
|
565
564
|
const isSelectedItem = isValueSelected(itemToValue(item));
|
|
566
565
|
const itemConfig = itemToConfig(item, {
|
|
@@ -593,13 +592,13 @@ export const makeView = (behavior) => {
|
|
|
593
592
|
index,
|
|
594
593
|
screenX,
|
|
595
594
|
screenY,
|
|
596
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
595
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~46")),
|
|
597
596
|
]),
|
|
598
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
597
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/listbox/shared.js#anonymous~47")),
|
|
599
598
|
]
|
|
600
599
|
: []),
|
|
601
600
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
602
|
-
], [itemConfig.content])), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
601
|
+
], [itemConfig.content])), "@foldkit/ui/listbox/shared.js#anonymous~44");
|
|
603
602
|
});
|
|
604
603
|
const renderGroupedItems = () => {
|
|
605
604
|
if (!itemGroupKey) {
|
|
@@ -608,7 +607,7 @@ export const makeView = (behavior) => {
|
|
|
608
607
|
const segments = groupContiguous(listboxItems, (_, index) => __foldkitBrandViewResult((Array.get(items, index).pipe(Option.match({
|
|
609
608
|
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/listbox/shared.js#onNone~4"),
|
|
610
609
|
onSome: item => __foldkitBrandViewResult((itemGroupKey(item, index)), "@foldkit/ui/listbox/shared.js#onSome~4"),
|
|
611
|
-
}))), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
610
|
+
}))), "@foldkit/ui/listbox/shared.js#anonymous~48"));
|
|
612
611
|
return __foldkitBrandViewResult((Array.flatMap(segments, (segment, segmentIndex) => {
|
|
613
612
|
const maybeHeading = Option.fromNullishOr(groupToHeading?.(segment.key));
|
|
614
613
|
const headingId = `${id}-heading-${segment.key}`;
|
|
@@ -644,7 +643,7 @@ export const makeView = (behavior) => {
|
|
|
644
643
|
]),
|
|
645
644
|
]
|
|
646
645
|
: [];
|
|
647
|
-
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
646
|
+
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/listbox/shared.js#anonymous~49");
|
|
648
647
|
})), "@foldkit/ui/listbox/shared.js#renderGroupedItems");
|
|
649
648
|
};
|
|
650
649
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
@@ -680,7 +679,7 @@ export const makeView = (behavior) => {
|
|
|
680
679
|
h.Name(name),
|
|
681
680
|
h.Value(selectedValue),
|
|
682
681
|
...formAttribute,
|
|
683
|
-
])), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
682
|
+
])), "@foldkit/ui/listbox/shared.js#anonymous~50")),
|
|
684
683
|
})
|
|
685
684
|
: [];
|
|
686
685
|
const wrapperAttributes = [
|
|
@@ -697,9 +696,9 @@ export const makeView = (behavior) => {
|
|
|
697
696
|
]),
|
|
698
697
|
...hiddenInputs,
|
|
699
698
|
...(isVisible ? visibleContent : []),
|
|
700
|
-
])), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
699
|
+
])), "@foldkit/ui/listbox/shared.js#anonymous~19");
|
|
701
700
|
});
|
|
702
701
|
return __foldkitBrandViewResult((() =>
|
|
703
702
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
704
|
-
__foldkitBrandViewResult((impl), "@foldkit/ui/listbox/shared.js#anonymous~
|
|
703
|
+
__foldkitBrandViewResult((impl), "@foldkit/ui/listbox/shared.js#anonymous~51")), "@foldkit/ui/listbox/shared.js#makeView");
|
|
705
704
|
};
|
package/dist/listbox/single.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
|
-
import type
|
|
2
|
+
import { type Update } from 'foldkit';
|
|
3
3
|
import { type View as SubmodelView } from 'foldkit/submodel';
|
|
4
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`. */
|
|
@@ -29,7 +29,9 @@ export type Model = typeof Model.Type;
|
|
|
29
29
|
export type InitConfig = BaseInitConfig;
|
|
30
30
|
/** Creates an initial single-select listbox model from a config. Defaults to closed with no active item. */
|
|
31
31
|
export declare const init: (config: InitConfig) => Model;
|
|
32
|
-
/** Processes a
|
|
32
|
+
/** Processes a Listbox Message and returns the next Model, optional Commands,
|
|
33
|
+
* and an optional OutMessage. Selection closes the Listbox and emits
|
|
34
|
+
* `Selected({ value })` for the parent to store. */
|
|
33
35
|
export declare const update: (model: {
|
|
34
36
|
readonly id: string;
|
|
35
37
|
readonly isOpen: boolean;
|
|
@@ -50,31 +52,29 @@ export declare const update: (model: {
|
|
|
50
52
|
readonly screenY: number;
|
|
51
53
|
}>;
|
|
52
54
|
readonly maybeLastButtonPointerType: Option.Option<string>;
|
|
53
|
-
}, message: Message) =>
|
|
54
|
-
|
|
55
|
-
readonly isOpen: boolean;
|
|
56
|
-
readonly isAnimated: boolean;
|
|
57
|
-
readonly isModal: boolean;
|
|
58
|
-
readonly orientation: "Horizontal" | "Vertical";
|
|
59
|
-
readonly animation: {
|
|
55
|
+
}, message: Message) => Readonly<{
|
|
56
|
+
model: {
|
|
60
57
|
readonly id: string;
|
|
61
|
-
readonly
|
|
62
|
-
readonly
|
|
58
|
+
readonly isOpen: boolean;
|
|
59
|
+
readonly isAnimated: boolean;
|
|
60
|
+
readonly isModal: boolean;
|
|
61
|
+
readonly orientation: "Horizontal" | "Vertical";
|
|
62
|
+
readonly animation: {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly isShowing: boolean;
|
|
65
|
+
readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
|
|
66
|
+
};
|
|
67
|
+
readonly maybeActiveItemIndex: Option.Option<number>;
|
|
68
|
+
readonly activationTrigger: "Pointer" | "Keyboard";
|
|
69
|
+
readonly searchQuery: string;
|
|
70
|
+
readonly searchVersion: number;
|
|
71
|
+
readonly maybeLastPointerPosition: Option.Option<{
|
|
72
|
+
readonly screenX: number;
|
|
73
|
+
readonly screenY: number;
|
|
74
|
+
}>;
|
|
75
|
+
readonly maybeLastButtonPointerType: Option.Option<string>;
|
|
63
76
|
};
|
|
64
|
-
|
|
65
|
-
readonly activationTrigger: "Pointer" | "Keyboard";
|
|
66
|
-
readonly searchQuery: string;
|
|
67
|
-
readonly searchVersion: number;
|
|
68
|
-
readonly maybeLastPointerPosition: Option.Option<{
|
|
69
|
-
readonly screenX: number;
|
|
70
|
-
readonly screenY: number;
|
|
71
|
-
}>;
|
|
72
|
-
readonly maybeLastButtonPointerType: Option.Option<string>;
|
|
73
|
-
}, readonly Readonly<{
|
|
74
|
-
name: string;
|
|
75
|
-
args?: Record<string, unknown>;
|
|
76
|
-
key?: string;
|
|
77
|
-
effect: import("effect/Effect").Effect<{
|
|
77
|
+
commands?: Update.Commands<{
|
|
78
78
|
readonly _tag: "IgnoredMouseClick";
|
|
79
79
|
} | {
|
|
80
80
|
readonly _tag: "SuppressedSpaceScroll";
|
|
@@ -146,14 +146,15 @@ export declare const update: (model: {
|
|
|
146
146
|
readonly _tag: "CompletedAnchorListbox";
|
|
147
147
|
} | {
|
|
148
148
|
readonly _tag: "CompletedPortalListboxBackdrop";
|
|
149
|
-
}, never
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
149
|
+
}, never>;
|
|
150
|
+
outMessage?: Readonly<{
|
|
151
|
+
readonly _tag: "Selected";
|
|
152
|
+
readonly value: string;
|
|
153
|
+
}>;
|
|
154
|
+
}>;
|
|
154
155
|
type UpdateReturn = ReturnType<typeof update>;
|
|
155
|
-
/** Programmatically opens the
|
|
156
|
-
*
|
|
156
|
+
/** Programmatically opens the Listbox, updating the Model and returning focus
|
|
157
|
+
* and modal Commands. Use this in domain-event handlers. */
|
|
157
158
|
export declare const open: (model: Model) => UpdateReturn;
|
|
158
159
|
/** Programmatically closes the listbox. If it is open, returns the closed Model
|
|
159
160
|
* with focus and modal Commands. If it is already closed, returns the Model
|
|
@@ -171,6 +172,7 @@ export type ViewInputs<Item, Value extends string = string> = BaseViewInputsComm
|
|
|
171
172
|
* form input submitted under `name`. */
|
|
172
173
|
maybeSelectedValue: Option.Option<Value>;
|
|
173
174
|
}> & ItemToValueInput<Item, Value>;
|
|
175
|
+
type BundleUpdateReturn<Value extends string> = Update.ReturnWithOutMessage<Model, Message, OutMessage<Value>>;
|
|
174
176
|
/** The `view`, `update`, and programmatic helpers that `Listbox.create`
|
|
175
177
|
* returns, bound to one `Item` and `Value` pair. Name it to annotate a
|
|
176
178
|
* value that holds a created bundle, such as a field on a config object
|
|
@@ -178,26 +180,10 @@ export type ViewInputs<Item, Value extends string = string> = BaseViewInputsComm
|
|
|
178
180
|
* `create` itself. */
|
|
179
181
|
export type Bundle<Item = string, Value extends string = Item extends string ? Item : string> = Readonly<{
|
|
180
182
|
view: SubmodelView<Model, Message, ViewInputs<Item, Value>>;
|
|
181
|
-
update: (model: Model, message: Message) =>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
];
|
|
186
|
-
selectItem: (model: Model, item: Value) => readonly [
|
|
187
|
-
Model,
|
|
188
|
-
ReadonlyArray<Command.Command<Message>>,
|
|
189
|
-
Option.Option<OutMessage<Value>>
|
|
190
|
-
];
|
|
191
|
-
open: (model: Model) => readonly [
|
|
192
|
-
Model,
|
|
193
|
-
ReadonlyArray<Command.Command<Message>>,
|
|
194
|
-
Option.Option<OutMessage<Value>>
|
|
195
|
-
];
|
|
196
|
-
close: (model: Model) => readonly [
|
|
197
|
-
Model,
|
|
198
|
-
ReadonlyArray<Command.Command<Message>>,
|
|
199
|
-
Option.Option<OutMessage<Value>>
|
|
200
|
-
];
|
|
183
|
+
update: (model: Model, message: Message) => BundleUpdateReturn<Value>;
|
|
184
|
+
selectItem: (model: Model, item: Value) => BundleUpdateReturn<Value>;
|
|
185
|
+
open: (model: Model) => BundleUpdateReturn<Value>;
|
|
186
|
+
close: (model: Model) => BundleUpdateReturn<Value>;
|
|
201
187
|
}>;
|
|
202
188
|
/** Pairs the single-select listbox's `view` and `update` (and programmatic
|
|
203
189
|
* helpers) behind a single Item-typed entry point. Declaring the listbox
|
|
@@ -210,9 +196,8 @@ export type Bundle<Item = string, Value extends string = Item extends string ? I
|
|
|
210
196
|
* // In view:
|
|
211
197
|
* h.submodel({ view: ColorListbox.view, ... })
|
|
212
198
|
*
|
|
213
|
-
* // In update
|
|
214
|
-
*
|
|
215
|
-
* // maybeOutMessage: Option<Listbox.OutMessage<Color>>
|
|
199
|
+
* // In the parent update, pass ColorListbox.update to Update.foldChild and
|
|
200
|
+
* // handle Listbox.OutMessage<Color> in foldOutMessage.
|
|
216
201
|
* ```
|
|
217
202
|
*
|
|
218
203
|
* Two type params support object-typed items with an `itemToValue`
|
|
@@ -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,
|
|
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,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AAExE,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,OAAO,EACP,UAAU,EAIX,MAAM,aAAa,CAAA;AAIpB,wOAAwO;AACxO,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,4GAA4G;AAC5G,eAAO,MAAM,IAAI,GAAI,QAAQ,UAAU,KAAG,KAAyB,CAAA;AAInE;;qDAEqD;AACrD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAElB,CAAA;AAED,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAA;AAE7C;6DAC6D;AAC7D,eAAO,MAAM,IAAI,GAAI,OAAO,KAAK,KAAG,YACoC,CAAA;AAExE;;;eAGe;AACf,eAAO,MAAM,KAAK,GAAI,OAAO,KAAK,KAAG,YACJ,CAAA;AAEjC,0IAA0I;AAC1I,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,EAAE,MAAM,MAAM,KAAG,YACT,CAAA;AAI/C,uFAAuF;AACvF,MAAM,MAAM,UAAU,CACpB,IAAI,EACJ,KAAK,SAAS,MAAM,GAAG,MAAM,IAC3B,oBAAoB,CAAC,IAAI,CAAC,GAC5B,QAAQ,CAAC;IACP;;;;6CAIyC;IACzC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;CACzC,CAAC,GACF,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAkB/B,KAAK,kBAAkB,CAAC,KAAK,SAAS,MAAM,IAAI,MAAM,CAAC,oBAAoB,CACzE,KAAK,EACL,OAAO,EACP,UAAU,CAAC,KAAK,CAAC,CAClB,CAAA;AAED;;;;uBAIuB;AACvB,MAAM,MAAM,MAAM,CAChB,IAAI,GAAG,MAAM,EACb,KAAK,SAAS,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,IAAI,GAAG,MAAM,IACxD,QAAQ,CAAC;IACX,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAA;IACrE,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAA;IACpE,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAA;IACjD,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,kBAAkB,CAAC,KAAK,CAAC,CAAA;CACnD,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;wDAkBwD;AACxD,eAAO,MAAM,MAAM,GACjB,IAAI,GAAG,MAAM,EACb,KAAK,SAAS,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,IAAI,GAAG,MAAM,OACvD,MAAM,CAAC,IAAI,EAAE,KAAK,CA2BtB,CAAA"}
|