@foldkit/ui 0.129.0 → 0.131.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/anchor.js +12 -11
- package/dist/animation/index.js +11 -10
- package/dist/animation/schema.js +3 -2
- package/dist/animation/update.js +26 -25
- package/dist/button/index.js +3 -2
- package/dist/calendar/index.js +159 -158
- package/dist/checkbox/index.js +9 -8
- package/dist/combobox/multi.js +20 -19
- package/dist/combobox/shared.js +169 -168
- package/dist/combobox/single.js +23 -22
- package/dist/datePicker/index.js +69 -68
- package/dist/dialog/index.js +52 -51
- package/dist/disclosure/index.js +11 -10
- package/dist/dragAndDrop/index.js +122 -121
- package/dist/fieldset/index.js +5 -4
- package/dist/fileDrop/index.js +23 -22
- package/dist/group.js +7 -6
- package/dist/input/index.js +4 -3
- package/dist/internal/optionExtensions.js +2 -1
- package/dist/internal/selectors.js +2 -1
- package/dist/keyboard.js +5 -4
- package/dist/listbox/multi.js +12 -11
- package/dist/listbox/shared.js +171 -170
- package/dist/listbox/single.js +13 -12
- package/dist/menu/index.js +167 -166
- package/dist/nav/index.js +7 -6
- package/dist/popover/index.js +87 -86
- package/dist/radioGroup/index.js +23 -22
- package/dist/select/index.js +4 -3
- package/dist/slider/index.js +72 -71
- package/dist/switch/index.js +6 -5
- package/dist/tabs/index.js +34 -33
- package/dist/test/apps/disabledButton.js +17 -16
- package/dist/textarea/index.js +4 -3
- package/dist/toast/index.js +19 -18
- package/dist/toast/schema.js +10 -9
- package/dist/toast/test.js +2 -1
- package/dist/toast/update.js +79 -78
- package/dist/tooltip/index.js +59 -58
- package/dist/typeahead.js +6 -5
- package/dist/virtualList/index.js +66 -65
- package/package.json +4 -3
package/dist/combobox/shared.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Effect, Match as M, Option, Predicate, Schema as S, pipe, } from 'effect';
|
|
2
3
|
import * as Command from 'foldkit/command';
|
|
3
4
|
import * as Dom from 'foldkit/dom';
|
|
@@ -36,7 +37,7 @@ export const BaseModel = S.Struct({
|
|
|
36
37
|
maybeLastPointerPosition: S.Option(S.Struct({ screenX: S.Number, screenY: S.Number })),
|
|
37
38
|
});
|
|
38
39
|
/** Creates the shared base fields for a combobox model from a config. Each variant spreads this and adds its selection fields. */
|
|
39
|
-
export const baseInit = (config) => ({
|
|
40
|
+
export const baseInit = (config) => (__foldkitBrandViewResult(({
|
|
40
41
|
id: config.id,
|
|
41
42
|
isOpen: false,
|
|
42
43
|
isAnimated: config.isAnimated ?? false,
|
|
@@ -49,7 +50,7 @@ export const baseInit = (config) => ({
|
|
|
49
50
|
activationTrigger: 'Keyboard',
|
|
50
51
|
inputValue: '',
|
|
51
52
|
maybeLastPointerPosition: Option.none(),
|
|
52
|
-
});
|
|
53
|
+
}), "@foldkit/ui/combobox/shared.js#baseInit"));
|
|
53
54
|
// MESSAGE
|
|
54
55
|
/** Sent when the combobox popup opens. Contains an optional initial active item index. */
|
|
55
56
|
export const Opened = m('Opened', {
|
|
@@ -159,54 +160,54 @@ export const OutMessage = S.Union([Selected, ClearedSelection]);
|
|
|
159
160
|
* input via a native `<label for={Combobox.inputId(id)}>` or an
|
|
160
161
|
* `aria-labelledby` reference. Mirrors `inputSelector`, which returns the
|
|
161
162
|
* CSS selector form (`#${id}-input`) rather than the bare id. */
|
|
162
|
-
export const inputId = (id) => `${id}-input
|
|
163
|
-
export const inputSelector = (id) => idSelector(`${id}-input`);
|
|
164
|
-
export const inputWrapperSelector = (id) => idSelector(`${id}-input-wrapper`);
|
|
165
|
-
export const itemsSelector = (id) => idSelector(`${id}-items`);
|
|
166
|
-
export const itemSelector = (id, index) => idSelector(`${id}-item-${index}`);
|
|
167
|
-
export const itemId = (id, index) => `${id}-item-${index}
|
|
163
|
+
export const inputId = (id) => __foldkitBrandViewResult((`${id}-input`), "@foldkit/ui/combobox/shared.js#inputId");
|
|
164
|
+
export const inputSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-input`)), "@foldkit/ui/combobox/shared.js#inputSelector");
|
|
165
|
+
export const inputWrapperSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-input-wrapper`)), "@foldkit/ui/combobox/shared.js#inputWrapperSelector");
|
|
166
|
+
export const itemsSelector = (id) => __foldkitBrandViewResult((idSelector(`${id}-items`)), "@foldkit/ui/combobox/shared.js#itemsSelector");
|
|
167
|
+
export const itemSelector = (id, index) => __foldkitBrandViewResult((idSelector(`${id}-item-${index}`)), "@foldkit/ui/combobox/shared.js#itemSelector");
|
|
168
|
+
export const itemId = (id, index) => __foldkitBrandViewResult((`${id}-item-${index}`), "@foldkit/ui/combobox/shared.js#itemId");
|
|
168
169
|
// HELPERS
|
|
169
170
|
const constrainedEvo = makeConstrainedEvo();
|
|
170
171
|
/** Resets only shared base fields to their closed state. Does not touch inputValue. That is variant-specific. */
|
|
171
|
-
export const closedBaseModel = (model) => constrainedEvo(model, {
|
|
172
|
-
isOpen: () => false,
|
|
173
|
-
maybeActiveItemIndex: () => Option.none(),
|
|
174
|
-
activationTrigger: () => 'Keyboard',
|
|
175
|
-
maybeLastPointerPosition: () => Option.none(),
|
|
176
|
-
});
|
|
172
|
+
export const closedBaseModel = (model) => __foldkitBrandViewResult((constrainedEvo(model, {
|
|
173
|
+
isOpen: () => __foldkitBrandViewResult((false), "@foldkit/ui/combobox/shared.js#isOpen"),
|
|
174
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex"),
|
|
175
|
+
activationTrigger: () => __foldkitBrandViewResult(('Keyboard'), "@foldkit/ui/combobox/shared.js#activationTrigger"),
|
|
176
|
+
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeLastPointerPosition"),
|
|
177
|
+
})), "@foldkit/ui/combobox/shared.js#closedBaseModel");
|
|
177
178
|
/** Prevents page scrolling while the combobox popup is open in modal mode. */
|
|
178
179
|
export const LockScroll = Command.define('LockScroll', CompletedLockScroll)(Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())));
|
|
179
180
|
/** Re-enables page scrolling after the combobox popup closes. */
|
|
180
181
|
export const UnlockScroll = Command.define('UnlockScroll', CompletedUnlockScroll)(Dom.unlockScroll.pipe(Effect.as(CompletedUnlockScroll())));
|
|
181
182
|
/** Marks all elements outside the combobox as inert for modal behavior. */
|
|
182
|
-
export const InertOthers = Command.define('InertOthers', { id: S.String }, CompletedInertOthers)(({ id }) => Dom.inertOthers(id, [inputWrapperSelector(id), itemsSelector(id)]).pipe(Effect.as(CompletedInertOthers())));
|
|
183
|
+
export const InertOthers = Command.define('InertOthers', { id: S.String }, CompletedInertOthers)(({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [inputWrapperSelector(id), itemsSelector(id)]).pipe(Effect.as(CompletedInertOthers()))), "@foldkit/ui/combobox/shared.js#anonymous"));
|
|
183
184
|
/** Removes the inert attribute from elements outside the combobox. */
|
|
184
|
-
export const RestoreInert = Command.define('RestoreInert', { id: S.String }, CompletedRestoreInert)(({ id }) => Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert())));
|
|
185
|
+
export const RestoreInert = Command.define('RestoreInert', { id: S.String }, CompletedRestoreInert)(({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert()))), "@foldkit/ui/combobox/shared.js#anonymous~2"));
|
|
185
186
|
/** Moves focus to the combobox input after selection or close. */
|
|
186
|
-
export const FocusInput = Command.define('FocusInput', { id: S.String }, CompletedFocusInput)(({ id }) => Dom.focus(inputSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusInput())));
|
|
187
|
+
export const FocusInput = Command.define('FocusInput', { id: S.String }, CompletedFocusInput)(({ id }) => __foldkitBrandViewResult((Dom.focus(inputSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusInput()))), "@foldkit/ui/combobox/shared.js#anonymous~3"));
|
|
187
188
|
/** Scrolls the active combobox item into view after keyboard navigation. */
|
|
188
|
-
export const ScrollIntoView = Command.define('ScrollIntoView', { id: S.String, index: S.Number }, CompletedScrollIntoView)(({ id, index }) => Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedScrollIntoView())));
|
|
189
|
+
export const ScrollIntoView = Command.define('ScrollIntoView', { id: S.String, index: S.Number }, CompletedScrollIntoView)(({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedScrollIntoView()))), "@foldkit/ui/combobox/shared.js#anonymous~4"));
|
|
189
190
|
/** Programmatically clicks the active combobox item's DOM element. */
|
|
190
|
-
export const ClickItem = Command.define('ClickItem', { id: S.String, index: S.Number }, CompletedClickItem)(({ id, index }) => Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedClickItem())));
|
|
191
|
+
export const ClickItem = Command.define('ClickItem', { id: S.String, index: S.Number }, CompletedClickItem)(({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedClickItem()))), "@foldkit/ui/combobox/shared.js#anonymous~5"));
|
|
191
192
|
/** Detects whether the combobox input wrapper moved or the leave animation ended. Whichever comes first; both outcomes signal the Animation submodel that leave is complete. */
|
|
192
|
-
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', { id: S.String }, GotAnimationMessage)(({ id }) => Effect.raceFirst(Dom.detectElementMovement(inputWrapperSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() })))));
|
|
193
|
+
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', { id: S.String }, GotAnimationMessage)(({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(inputWrapperSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(GotAnimationMessage({ message: AnimationEndedAnimation() }))))), "@foldkit/ui/combobox/shared.js#anonymous~6"));
|
|
193
194
|
const delegateToAnimation = (model, animationMessage) => {
|
|
194
195
|
const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(model.animation, animationMessage);
|
|
195
|
-
const mappedCommands = Command.mapMessages(animationCommands, message => GotAnimationMessage({ message }));
|
|
196
|
+
const mappedCommands = Command.mapMessages(animationCommands, message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/combobox/shared.js#anonymous~7"));
|
|
196
197
|
const additionalCommands = Option.match(maybeOutMessage, {
|
|
197
|
-
onNone: () => [],
|
|
198
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#onNone"),
|
|
198
199
|
onSome: M.type().pipe(M.tagsExhaustive({
|
|
199
|
-
StartedLeaveAnimating: () => [
|
|
200
|
+
StartedLeaveAnimating: () => __foldkitBrandViewResult(([
|
|
200
201
|
DetectMovementOrAnimationEnd({ id: model.id }),
|
|
201
|
-
],
|
|
202
|
-
TransitionedOut: () => [],
|
|
202
|
+
]), "@foldkit/ui/combobox/shared.js#StartedLeaveAnimating"),
|
|
203
|
+
TransitionedOut: () => __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#TransitionedOut"),
|
|
203
204
|
})),
|
|
204
205
|
});
|
|
205
|
-
return [
|
|
206
|
-
constrainedEvo(model, { animation: () => nextAnimation }),
|
|
206
|
+
return __foldkitBrandViewResult(([
|
|
207
|
+
constrainedEvo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/combobox/shared.js#animation") }),
|
|
207
208
|
[...mappedCommands, ...additionalCommands],
|
|
208
209
|
Option.none(),
|
|
209
|
-
];
|
|
210
|
+
]), "@foldkit/ui/combobox/shared.js#delegateToAnimation");
|
|
210
211
|
};
|
|
211
212
|
/** 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. */
|
|
212
213
|
export const makeUpdate = (handlers) => {
|
|
@@ -220,94 +221,94 @@ export const makeUpdate = (handlers) => {
|
|
|
220
221
|
const openCombobox = (baseModel) => {
|
|
221
222
|
if (model.isAnimated) {
|
|
222
223
|
const [nextModel, animationCommands] = delegateToAnimation(baseModel, AnimationShowed());
|
|
223
|
-
return [
|
|
224
|
-
constrainedEvo(nextModel, { isOpen: () => true }),
|
|
224
|
+
return __foldkitBrandViewResult(([
|
|
225
|
+
constrainedEvo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/combobox/shared.js#isOpen~2") }),
|
|
225
226
|
[
|
|
226
227
|
...Array.getSomes([maybeLockScroll, maybeInertOthers]),
|
|
227
228
|
...animationCommands,
|
|
228
229
|
],
|
|
229
230
|
Option.none(),
|
|
230
|
-
];
|
|
231
|
+
]), "@foldkit/ui/combobox/shared.js#openCombobox");
|
|
231
232
|
}
|
|
232
|
-
return [
|
|
233
|
-
constrainedEvo(baseModel, { isOpen: () => true }),
|
|
233
|
+
return __foldkitBrandViewResult(([
|
|
234
|
+
constrainedEvo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/combobox/shared.js#isOpen~3") }),
|
|
234
235
|
Array.getSomes([maybeLockScroll, maybeInertOthers]),
|
|
235
236
|
Option.none(),
|
|
236
|
-
];
|
|
237
|
+
]), "@foldkit/ui/combobox/shared.js#openCombobox");
|
|
237
238
|
};
|
|
238
239
|
const closeCombobox = (baseModel, commands, restingInputValue) => {
|
|
239
240
|
const [closed, maybeCloseOutMessage] = handlers.handleClose(baseModel, restingInputValue);
|
|
240
241
|
if (model.isAnimated) {
|
|
241
242
|
const [nextModel, animationCommands] = delegateToAnimation(closed, AnimationHid());
|
|
242
|
-
return [
|
|
243
|
+
return __foldkitBrandViewResult(([
|
|
243
244
|
nextModel,
|
|
244
245
|
[...commands, ...animationCommands],
|
|
245
246
|
maybeCloseOutMessage,
|
|
246
|
-
];
|
|
247
|
+
]), "@foldkit/ui/combobox/shared.js#closeCombobox");
|
|
247
248
|
}
|
|
248
|
-
return [closed, commands, maybeCloseOutMessage];
|
|
249
|
+
return __foldkitBrandViewResult(([closed, commands, maybeCloseOutMessage]), "@foldkit/ui/combobox/shared.js#closeCombobox");
|
|
249
250
|
};
|
|
250
|
-
return M.value(message).pipe(withUpdateReturn, M.tag('CompletedLockScroll', 'CompletedUnlockScroll', 'CompletedInertOthers', 'CompletedRestoreInert', 'CompletedFocusInput', 'CompletedScrollIntoView', 'CompletedClickItem', 'CompletedAnchorCombobox', 'CompletedAttachComboboxPreventBlur', 'CompletedAttachComboboxSelectOnFocus', 'CompletedPortalComboboxBackdrop', () => [model, [], Option.none()]), M.tagsExhaustive({
|
|
251
|
-
Opened: ({ maybeActiveItemIndex }) => openCombobox(constrainedEvo(model, {
|
|
252
|
-
maybeActiveItemIndex: () => maybeActiveItemIndex,
|
|
253
|
-
activationTrigger: () => Option.match(maybeActiveItemIndex, {
|
|
254
|
-
onNone: () => 'Pointer',
|
|
255
|
-
onSome: () => 'Keyboard',
|
|
256
|
-
}),
|
|
257
|
-
maybeLastPointerPosition: () => Option.none(),
|
|
258
|
-
})),
|
|
251
|
+
return __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tag('CompletedLockScroll', 'CompletedUnlockScroll', 'CompletedInertOthers', 'CompletedRestoreInert', 'CompletedFocusInput', 'CompletedScrollIntoView', 'CompletedClickItem', 'CompletedAnchorCombobox', 'CompletedAttachComboboxPreventBlur', 'CompletedAttachComboboxSelectOnFocus', 'CompletedPortalComboboxBackdrop', () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/combobox/shared.js#anonymous~8")), M.tagsExhaustive({
|
|
252
|
+
Opened: ({ maybeActiveItemIndex }) => __foldkitBrandViewResult((openCombobox(constrainedEvo(model, {
|
|
253
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((maybeActiveItemIndex), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~2"),
|
|
254
|
+
activationTrigger: () => __foldkitBrandViewResult((Option.match(maybeActiveItemIndex, {
|
|
255
|
+
onNone: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/combobox/shared.js#onNone~2"),
|
|
256
|
+
onSome: () => __foldkitBrandViewResult(('Keyboard'), "@foldkit/ui/combobox/shared.js#onSome"),
|
|
257
|
+
})), "@foldkit/ui/combobox/shared.js#activationTrigger~2"),
|
|
258
|
+
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeLastPointerPosition~2"),
|
|
259
|
+
}))), "@foldkit/ui/combobox/shared.js#Opened"),
|
|
259
260
|
// NOTE: guard on isOpen so a close-path message baked from a stale
|
|
260
261
|
// render (a sub-frame blur after a selection already closed the
|
|
261
262
|
// combobox) cannot rewrite inputValue with an outdated
|
|
262
263
|
// restingInputValue or re-emit ClearedSelection while closed.
|
|
263
|
-
Closed: ({ restingInputValue }) => model.isOpen
|
|
264
|
+
Closed: ({ restingInputValue }) => __foldkitBrandViewResult((model.isOpen
|
|
264
265
|
? closeCombobox(model, [focusInput], restingInputValue)
|
|
265
|
-
: [model, [], Option.none()],
|
|
266
|
-
BlurredInput: ({ restingInputValue }) => model.isOpen
|
|
266
|
+
: [model, [], Option.none()]), "@foldkit/ui/combobox/shared.js#Closed"),
|
|
267
|
+
BlurredInput: ({ restingInputValue }) => __foldkitBrandViewResult((model.isOpen
|
|
267
268
|
? closeCombobox(model, [], restingInputValue)
|
|
268
|
-
: [model, [], Option.none()],
|
|
269
|
+
: [model, [], Option.none()]), "@foldkit/ui/combobox/shared.js#BlurredInput"),
|
|
269
270
|
ActivatedItem: ({ index, activationTrigger, maybeImmediateSelection, }) => {
|
|
270
271
|
const highlightedModel = constrainedEvo(model, {
|
|
271
|
-
maybeActiveItemIndex: () => Option.some(index),
|
|
272
|
-
activationTrigger: () => activationTrigger,
|
|
272
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~3"),
|
|
273
|
+
activationTrigger: () => __foldkitBrandViewResult((activationTrigger), "@foldkit/ui/combobox/shared.js#activationTrigger~3"),
|
|
273
274
|
});
|
|
274
275
|
const skippedActivation = [highlightedModel, Option.none()];
|
|
275
276
|
const [nextModel, maybeOutMessage] = Option.match(maybeImmediateSelection, {
|
|
276
|
-
onNone: () => skippedActivation,
|
|
277
|
-
onSome: ({ item }) => handlers.handleImmediateActivation(highlightedModel, item),
|
|
277
|
+
onNone: () => __foldkitBrandViewResult((skippedActivation), "@foldkit/ui/combobox/shared.js#onNone~3"),
|
|
278
|
+
onSome: ({ item }) => __foldkitBrandViewResult((handlers.handleImmediateActivation(highlightedModel, item)), "@foldkit/ui/combobox/shared.js#onSome~2"),
|
|
278
279
|
});
|
|
279
|
-
return [
|
|
280
|
+
return __foldkitBrandViewResult(([
|
|
280
281
|
nextModel,
|
|
281
282
|
activationTrigger === 'Keyboard'
|
|
282
283
|
? [ScrollIntoView({ id: model.id, index })]
|
|
283
284
|
: [],
|
|
284
285
|
maybeOutMessage,
|
|
285
|
-
];
|
|
286
|
+
]), "@foldkit/ui/combobox/shared.js#ActivatedItem");
|
|
286
287
|
},
|
|
287
288
|
MovedPointerOverItem: ({ index, screenX, screenY }) => {
|
|
288
|
-
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => position.screenX === screenX && position.screenY === screenY);
|
|
289
|
+
const isSamePosition = Option.exists(model.maybeLastPointerPosition, position => __foldkitBrandViewResult((position.screenX === screenX && position.screenY === screenY), "@foldkit/ui/combobox/shared.js#anonymous~9"));
|
|
289
290
|
if (isSamePosition) {
|
|
290
|
-
return [model, [], Option.none()];
|
|
291
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/combobox/shared.js#MovedPointerOverItem");
|
|
291
292
|
}
|
|
292
|
-
return [
|
|
293
|
+
return __foldkitBrandViewResult(([
|
|
293
294
|
constrainedEvo(model, {
|
|
294
|
-
maybeActiveItemIndex: () => Option.some(index),
|
|
295
|
-
activationTrigger: () => 'Pointer',
|
|
296
|
-
maybeLastPointerPosition: () => Option.some({ screenX, screenY }),
|
|
295
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~4"),
|
|
296
|
+
activationTrigger: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/combobox/shared.js#activationTrigger~4"),
|
|
297
|
+
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.some({ screenX, screenY })), "@foldkit/ui/combobox/shared.js#maybeLastPointerPosition~3"),
|
|
297
298
|
}),
|
|
298
299
|
[],
|
|
299
300
|
Option.none(),
|
|
300
|
-
];
|
|
301
|
+
]), "@foldkit/ui/combobox/shared.js#MovedPointerOverItem");
|
|
301
302
|
},
|
|
302
|
-
DeactivatedItem: () => model.activationTrigger === 'Pointer'
|
|
303
|
+
DeactivatedItem: () => __foldkitBrandViewResult((model.activationTrigger === 'Pointer'
|
|
303
304
|
? [
|
|
304
305
|
constrainedEvo(model, {
|
|
305
|
-
maybeActiveItemIndex: () => Option.none(),
|
|
306
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~5"),
|
|
306
307
|
}),
|
|
307
308
|
[],
|
|
308
309
|
Option.none(),
|
|
309
310
|
]
|
|
310
|
-
: [model, [], Option.none()],
|
|
311
|
+
: [model, [], Option.none()]), "@foldkit/ui/combobox/shared.js#DeactivatedItem"),
|
|
311
312
|
SelectedItem: ({ item, displayText, wasSelected }) => {
|
|
312
313
|
const [nextModel, commands, maybeOutMessage] = handlers.handleSelectedItem(model, item, displayText, wasSelected, {
|
|
313
314
|
focusInput,
|
|
@@ -316,53 +317,53 @@ export const makeUpdate = (handlers) => {
|
|
|
316
317
|
});
|
|
317
318
|
if (model.isOpen && !nextModel.isOpen && model.isAnimated) {
|
|
318
319
|
const [transitionedModel, animationCommands] = delegateToAnimation(nextModel, AnimationHid());
|
|
319
|
-
return [
|
|
320
|
+
return __foldkitBrandViewResult(([
|
|
320
321
|
transitionedModel,
|
|
321
322
|
[...commands, ...animationCommands],
|
|
322
323
|
maybeOutMessage,
|
|
323
|
-
];
|
|
324
|
+
]), "@foldkit/ui/combobox/shared.js#SelectedItem");
|
|
324
325
|
}
|
|
325
|
-
return [nextModel, commands, maybeOutMessage];
|
|
326
|
+
return __foldkitBrandViewResult(([nextModel, commands, maybeOutMessage]), "@foldkit/ui/combobox/shared.js#SelectedItem");
|
|
326
327
|
},
|
|
327
|
-
RequestedItemClick: ({ index }) => [
|
|
328
|
+
RequestedItemClick: ({ index }) => __foldkitBrandViewResult(([
|
|
328
329
|
model,
|
|
329
330
|
[ClickItem({ id: model.id, index })],
|
|
330
331
|
Option.none(),
|
|
331
|
-
],
|
|
332
|
+
]), "@foldkit/ui/combobox/shared.js#RequestedItemClick"),
|
|
332
333
|
UpdatedInputValue: ({ value }) => {
|
|
333
334
|
if (model.isOpen) {
|
|
334
|
-
return [
|
|
335
|
+
return __foldkitBrandViewResult(([
|
|
335
336
|
constrainedEvo(model, {
|
|
336
|
-
inputValue: () => value,
|
|
337
|
-
maybeActiveItemIndex: () => Option.some(0),
|
|
338
|
-
activationTrigger: () => 'Keyboard',
|
|
337
|
+
inputValue: () => __foldkitBrandViewResult((value), "@foldkit/ui/combobox/shared.js#inputValue"),
|
|
338
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(0)), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~6"),
|
|
339
|
+
activationTrigger: () => __foldkitBrandViewResult(('Keyboard'), "@foldkit/ui/combobox/shared.js#activationTrigger~5"),
|
|
339
340
|
}),
|
|
340
341
|
[],
|
|
341
342
|
Option.none(),
|
|
342
|
-
];
|
|
343
|
+
]), "@foldkit/ui/combobox/shared.js#UpdatedInputValue");
|
|
343
344
|
}
|
|
344
|
-
return openCombobox(constrainedEvo(model, {
|
|
345
|
-
inputValue: () => value,
|
|
346
|
-
maybeActiveItemIndex: () => Option.some(0),
|
|
347
|
-
activationTrigger: () => 'Keyboard',
|
|
348
|
-
maybeLastPointerPosition: () => Option.none(),
|
|
349
|
-
}));
|
|
345
|
+
return __foldkitBrandViewResult((openCombobox(constrainedEvo(model, {
|
|
346
|
+
inputValue: () => __foldkitBrandViewResult((value), "@foldkit/ui/combobox/shared.js#inputValue~2"),
|
|
347
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.some(0)), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~7"),
|
|
348
|
+
activationTrigger: () => __foldkitBrandViewResult(('Keyboard'), "@foldkit/ui/combobox/shared.js#activationTrigger~6"),
|
|
349
|
+
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeLastPointerPosition~4"),
|
|
350
|
+
}))), "@foldkit/ui/combobox/shared.js#UpdatedInputValue");
|
|
350
351
|
},
|
|
351
352
|
PressedToggleButton: ({ restingInputValue }) => {
|
|
352
353
|
if (model.isOpen) {
|
|
353
|
-
return closeCombobox(model, [focusInput], restingInputValue);
|
|
354
|
+
return __foldkitBrandViewResult((closeCombobox(model, [focusInput], restingInputValue)), "@foldkit/ui/combobox/shared.js#PressedToggleButton");
|
|
354
355
|
}
|
|
355
356
|
const [nextModel, commands] = openCombobox(constrainedEvo(model, {
|
|
356
|
-
maybeActiveItemIndex: () => Option.none(),
|
|
357
|
-
activationTrigger: () => 'Pointer',
|
|
358
|
-
maybeLastPointerPosition: () => Option.none(),
|
|
357
|
+
maybeActiveItemIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeActiveItemIndex~8"),
|
|
358
|
+
activationTrigger: () => __foldkitBrandViewResult(('Pointer'), "@foldkit/ui/combobox/shared.js#activationTrigger~7"),
|
|
359
|
+
maybeLastPointerPosition: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#maybeLastPointerPosition~5"),
|
|
359
360
|
}));
|
|
360
|
-
return [nextModel, [focusInput, ...commands], Option.none()];
|
|
361
|
+
return __foldkitBrandViewResult(([nextModel, [focusInput, ...commands], Option.none()]), "@foldkit/ui/combobox/shared.js#PressedToggleButton");
|
|
361
362
|
},
|
|
362
|
-
GotAnimationMessage: ({ message: animationMessage }) => delegateToAnimation(model, animationMessage),
|
|
363
|
-
}));
|
|
363
|
+
GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((delegateToAnimation(model, animationMessage)), "@foldkit/ui/combobox/shared.js#GotAnimationMessage"),
|
|
364
|
+
}))), "@foldkit/ui/combobox/shared.js#internalUpdate");
|
|
364
365
|
};
|
|
365
|
-
return internalUpdate;
|
|
366
|
+
return __foldkitBrandViewResult((internalUpdate), "@foldkit/ui/combobox/shared.js#makeUpdate");
|
|
366
367
|
};
|
|
367
368
|
/** The anchor-positioning Mount this Combobox renders on its items panel.
|
|
368
369
|
* The panel is always anchored to the input wrapper via Floating UI and
|
|
@@ -372,7 +373,7 @@ export const makeUpdate = (handlers) => {
|
|
|
372
373
|
* capture listener that prevents input blur on item presses. Exposed so
|
|
373
374
|
* Scene tests can call
|
|
374
375
|
* `Scene.Mount.resolve(AnchorCombobox, CompletedAnchorCombobox())`. */
|
|
375
|
-
export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorCombobox)(({ buttonId, anchor }) => element => Effect.gen(function* () {
|
|
376
|
+
export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorCombobox)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
376
377
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
377
378
|
const preventBlur = (event) => {
|
|
378
379
|
event.preventDefault();
|
|
@@ -385,35 +386,35 @@ export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.Strin
|
|
|
385
386
|
anchor,
|
|
386
387
|
interceptTab: false,
|
|
387
388
|
})(element);
|
|
388
|
-
return () => {
|
|
389
|
+
return __foldkitBrandViewResult((() => {
|
|
389
390
|
element.removeEventListener('pointerdown', preventBlur, {
|
|
390
391
|
capture: true,
|
|
391
392
|
});
|
|
392
393
|
teardownAnchor();
|
|
393
|
-
};
|
|
394
|
-
}), cleanup => Effect.sync(cleanup));
|
|
395
|
-
return CompletedAnchorCombobox();
|
|
396
|
-
}));
|
|
394
|
+
}), "@foldkit/ui/combobox/shared.js#anonymous~13");
|
|
395
|
+
}), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/combobox/shared.js#anonymous~15"));
|
|
396
|
+
return __foldkitBrandViewResult((CompletedAnchorCombobox()), "@foldkit/ui/combobox/shared.js#anonymous~12");
|
|
397
|
+
})), "@foldkit/ui/combobox/shared.js#anonymous~11")), "@foldkit/ui/combobox/shared.js#anonymous~10"));
|
|
397
398
|
/** The Mount this Combobox renders to install a `pointerdown`-cancelling
|
|
398
399
|
* capture listener that prevents blur on item presses. Exposed so Scene
|
|
399
400
|
* tests can call
|
|
400
401
|
* `Scene.Mount.resolve(AttachComboboxPreventBlur, CompletedAttachComboboxPreventBlur())`. */
|
|
401
|
-
export const AttachComboboxPreventBlur = Mount.define('AttachComboboxPreventBlur', CompletedAttachComboboxPreventBlur)(element => Effect.gen(function* () {
|
|
402
|
+
export const AttachComboboxPreventBlur = Mount.define('AttachComboboxPreventBlur', CompletedAttachComboboxPreventBlur)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
402
403
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
403
404
|
const handler = (event) => {
|
|
404
405
|
event.preventDefault();
|
|
405
406
|
};
|
|
406
407
|
element.addEventListener('pointerdown', handler, { capture: true });
|
|
407
|
-
return handler;
|
|
408
|
-
}), handler => Effect.sync(() => element.removeEventListener('pointerdown', handler, {
|
|
408
|
+
return __foldkitBrandViewResult((handler), "@foldkit/ui/combobox/shared.js#anonymous~18");
|
|
409
|
+
}), handler => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((element.removeEventListener('pointerdown', handler, {
|
|
409
410
|
capture: true,
|
|
410
|
-
})));
|
|
411
|
-
return CompletedAttachComboboxPreventBlur();
|
|
412
|
-
}));
|
|
411
|
+
})), "@foldkit/ui/combobox/shared.js#anonymous~20"))), "@foldkit/ui/combobox/shared.js#anonymous~19"));
|
|
412
|
+
return __foldkitBrandViewResult((CompletedAttachComboboxPreventBlur()), "@foldkit/ui/combobox/shared.js#anonymous~17");
|
|
413
|
+
})), "@foldkit/ui/combobox/shared.js#anonymous~16"));
|
|
413
414
|
/** The Mount this Combobox renders to install the input's select-on-focus
|
|
414
415
|
* behavior. Exposed so Scene tests can call
|
|
415
416
|
* `Scene.Mount.resolve(AttachComboboxSelectOnFocus, CompletedAttachComboboxSelectOnFocus())`. */
|
|
416
|
-
export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnFocus', CompletedAttachComboboxSelectOnFocus)(element => Effect.gen(function* () {
|
|
417
|
+
export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnFocus', CompletedAttachComboboxSelectOnFocus)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
417
418
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
418
419
|
const handler = () => {
|
|
419
420
|
if (element instanceof HTMLInputElement) {
|
|
@@ -421,17 +422,17 @@ export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnF
|
|
|
421
422
|
}
|
|
422
423
|
};
|
|
423
424
|
element.addEventListener('focus', handler);
|
|
424
|
-
return handler;
|
|
425
|
-
}), handler => Effect.sync(() => element.removeEventListener('focus', handler)));
|
|
426
|
-
return CompletedAttachComboboxSelectOnFocus();
|
|
427
|
-
}));
|
|
425
|
+
return __foldkitBrandViewResult((handler), "@foldkit/ui/combobox/shared.js#anonymous~23");
|
|
426
|
+
}), handler => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((element.removeEventListener('focus', handler)), "@foldkit/ui/combobox/shared.js#anonymous~25"))), "@foldkit/ui/combobox/shared.js#anonymous~24"));
|
|
427
|
+
return __foldkitBrandViewResult((CompletedAttachComboboxSelectOnFocus()), "@foldkit/ui/combobox/shared.js#anonymous~22");
|
|
428
|
+
})), "@foldkit/ui/combobox/shared.js#anonymous~21"));
|
|
428
429
|
/** The backdrop-portaling Mount this Combobox renders. Exposed so Scene tests can
|
|
429
430
|
* call `Scene.Mount.resolve(PortalComboboxBackdrop, CompletedPortalComboboxBackdrop())` to
|
|
430
431
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
431
|
-
export const PortalComboboxBackdrop = Mount.define('PortalComboboxBackdrop', CompletedPortalComboboxBackdrop)(element => Effect.gen(function* () {
|
|
432
|
-
yield* Effect.acquireRelease(Effect.sync(() => portalToContainingRoot(element)), cleanup => Effect.sync(cleanup));
|
|
433
|
-
return CompletedPortalComboboxBackdrop();
|
|
434
|
-
}));
|
|
432
|
+
export const PortalComboboxBackdrop = Mount.define('PortalComboboxBackdrop', CompletedPortalComboboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
433
|
+
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/combobox/shared.js#anonymous~28")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/combobox/shared.js#anonymous~29"));
|
|
434
|
+
return __foldkitBrandViewResult((CompletedPortalComboboxBackdrop()), "@foldkit/ui/combobox/shared.js#anonymous~27");
|
|
435
|
+
})), "@foldkit/ui/combobox/shared.js#anonymous~26"));
|
|
435
436
|
/** 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. */
|
|
436
437
|
export const makeView = (behavior) => {
|
|
437
438
|
const impl = defineView((model, viewInputs) => {
|
|
@@ -440,90 +441,90 @@ export const makeView = (behavior) => {
|
|
|
440
441
|
const { items, selectedValues, restingInputValue, itemToConfig, itemToValue, itemToDisplayText, isItemDisabled, inputClassName, inputAttributes = [], inputPlaceholder, inputWrapperClassName, inputWrapperAttributes = [], itemsClassName, itemsAttributes = [], itemsScrollClassName, itemsScrollAttributes = [], backdropClassName, backdropAttributes = [], className, attributes = [], buttonContent, buttonClassName, buttonAttributes = [], formName, isDisabled, isInvalid, openOnFocus, itemGroupKey, groupToHeading, groupClassName, groupAttributes = [], separatorClassName, separatorAttributes = [], anchor = {}, ariaLabel, ariaLabelledBy, } = viewInputs;
|
|
441
442
|
const resolveInputLabel = () => {
|
|
442
443
|
if (Predicate.isNotUndefined(ariaLabel)) {
|
|
443
|
-
return [h.AriaLabel(ariaLabel)];
|
|
444
|
+
return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/combobox/shared.js#resolveInputLabel");
|
|
444
445
|
}
|
|
445
446
|
else if (Predicate.isNotUndefined(ariaLabelledBy)) {
|
|
446
|
-
return [h.AriaLabelledBy(ariaLabelledBy)];
|
|
447
|
+
return __foldkitBrandViewResult(([h.AriaLabelledBy(ariaLabelledBy)]), "@foldkit/ui/combobox/shared.js#resolveInputLabel");
|
|
447
448
|
}
|
|
448
449
|
else {
|
|
449
|
-
return [];
|
|
450
|
+
return __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#resolveInputLabel");
|
|
450
451
|
}
|
|
451
452
|
};
|
|
452
453
|
const inputLabelAttributes = resolveInputLabel();
|
|
453
|
-
const isValueSelected = (itemValue) => Array.contains(selectedValues, itemValue);
|
|
454
|
+
const isValueSelected = (itemValue) => __foldkitBrandViewResult((Array.contains(selectedValues, itemValue)), "@foldkit/ui/combobox/shared.js#isValueSelected");
|
|
454
455
|
const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
|
|
455
456
|
const isVisible = isOpen || isLeaving;
|
|
456
|
-
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
|
|
457
|
+
const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => __foldkitBrandViewResult(([
|
|
457
458
|
h.DataAttribute('closed', ''),
|
|
458
459
|
h.DataAttribute('enter', ''),
|
|
459
460
|
h.DataAttribute('transition', ''),
|
|
460
|
-
]), M.when('EnterAnimating', () => [
|
|
461
|
+
]), "@foldkit/ui/combobox/shared.js#anonymous~31")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
|
|
461
462
|
h.DataAttribute('enter', ''),
|
|
462
463
|
h.DataAttribute('transition', ''),
|
|
463
|
-
]), M.when('LeaveStart', () => [
|
|
464
|
+
]), "@foldkit/ui/combobox/shared.js#anonymous~32")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
|
|
464
465
|
h.DataAttribute('leave', ''),
|
|
465
466
|
h.DataAttribute('transition', ''),
|
|
466
|
-
]), M.when('LeaveAnimating', () => [
|
|
467
|
+
]), "@foldkit/ui/combobox/shared.js#anonymous~33")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
|
|
467
468
|
h.DataAttribute('closed', ''),
|
|
468
469
|
h.DataAttribute('leave', ''),
|
|
469
470
|
h.DataAttribute('transition', ''),
|
|
470
|
-
]), M.orElse(() => []));
|
|
471
|
-
const isDisabledAtIndex = (index) => Predicate.isNotUndefined(isItemDisabled) &&
|
|
472
|
-
pipe(items, Array.get(index), Option.exists(item => isItemDisabled(item, index)));
|
|
471
|
+
]), "@foldkit/ui/combobox/shared.js#anonymous~34")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#anonymous~35")));
|
|
472
|
+
const isDisabledAtIndex = (index) => __foldkitBrandViewResult((Predicate.isNotUndefined(isItemDisabled) &&
|
|
473
|
+
pipe(items, Array.get(index), Option.exists(item => __foldkitBrandViewResult((isItemDisabled(item, index)), "@foldkit/ui/combobox/shared.js#anonymous~36")))), "@foldkit/ui/combobox/shared.js#isDisabledAtIndex");
|
|
473
474
|
const firstEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabledAtIndex)(0, 1);
|
|
474
475
|
const lastEnabledIndex = findFirstEnabledIndex(items.length, 0, isDisabledAtIndex)(items.length - 1, -1);
|
|
475
|
-
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => -1), isDisabledAtIndex);
|
|
476
|
-
const resolveImmediateSelection = (targetIndex) => pipe(OptionExt.when(immediate, targetIndex), Option.flatMap(index => Array.get(items, index)), Option.map(targetItem => ({
|
|
476
|
+
const resolveActiveIndex = keyToIndex('ArrowDown', 'ArrowUp', items.length, Option.getOrElse(maybeActiveItemIndex, () => __foldkitBrandViewResult((-1), "@foldkit/ui/combobox/shared.js#anonymous~37")), isDisabledAtIndex);
|
|
477
|
+
const resolveImmediateSelection = (targetIndex) => __foldkitBrandViewResult((pipe(OptionExt.when(immediate, targetIndex), Option.flatMap(index => __foldkitBrandViewResult((Array.get(items, index)), "@foldkit/ui/combobox/shared.js#anonymous~38")), Option.map(targetItem => (__foldkitBrandViewResult(({
|
|
477
478
|
item: itemToValue(targetItem, targetIndex),
|
|
478
|
-
})));
|
|
479
|
-
const handleInputKeyDown = (key) => M.value(key).pipe(M.when('ArrowDown', () => {
|
|
479
|
+
}), "@foldkit/ui/combobox/shared.js#anonymous~39"))))), "@foldkit/ui/combobox/shared.js#resolveImmediateSelection");
|
|
480
|
+
const handleInputKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('ArrowDown', () => {
|
|
480
481
|
if (!isOpen) {
|
|
481
|
-
return Option.some(Opened({
|
|
482
|
+
return __foldkitBrandViewResult((Option.some(Opened({
|
|
482
483
|
maybeActiveItemIndex: Option.some(firstEnabledIndex),
|
|
483
|
-
}));
|
|
484
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~40");
|
|
484
485
|
}
|
|
485
486
|
const targetIndex = resolveActiveIndex('ArrowDown');
|
|
486
|
-
return Option.some(ActivatedItem({
|
|
487
|
+
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
487
488
|
index: targetIndex,
|
|
488
489
|
activationTrigger: 'Keyboard',
|
|
489
490
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
490
|
-
}));
|
|
491
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~40");
|
|
491
492
|
}), M.when('ArrowUp', () => {
|
|
492
493
|
if (!isOpen) {
|
|
493
|
-
return Option.some(Opened({
|
|
494
|
+
return __foldkitBrandViewResult((Option.some(Opened({
|
|
494
495
|
maybeActiveItemIndex: Option.some(lastEnabledIndex),
|
|
495
|
-
}));
|
|
496
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~41");
|
|
496
497
|
}
|
|
497
498
|
const targetIndex = resolveActiveIndex('ArrowUp');
|
|
498
|
-
return Option.some(ActivatedItem({
|
|
499
|
+
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
499
500
|
index: targetIndex,
|
|
500
501
|
activationTrigger: 'Keyboard',
|
|
501
502
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
502
|
-
}));
|
|
503
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~41");
|
|
503
504
|
}), M.when('Enter', () => {
|
|
504
505
|
if (!isOpen) {
|
|
505
|
-
return Option.none();
|
|
506
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~42");
|
|
506
507
|
}
|
|
507
|
-
return Option.map(maybeActiveItemIndex, index => RequestedItemClick({ index }));
|
|
508
|
+
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/combobox/shared.js#anonymous~43"))), "@foldkit/ui/combobox/shared.js#anonymous~42");
|
|
508
509
|
}), M.when('Escape', () => {
|
|
509
510
|
if (!isOpen) {
|
|
510
|
-
return Option.none();
|
|
511
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~44");
|
|
511
512
|
}
|
|
512
|
-
return Option.some(Closed({ restingInputValue }));
|
|
513
|
+
return __foldkitBrandViewResult((Option.some(Closed({ restingInputValue }))), "@foldkit/ui/combobox/shared.js#anonymous~44");
|
|
513
514
|
}), M.whenOr('Home', 'End', () => {
|
|
514
515
|
if (!isOpen) {
|
|
515
|
-
return Option.none();
|
|
516
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~45");
|
|
516
517
|
}
|
|
517
518
|
const targetIndex = resolveActiveIndex(key);
|
|
518
|
-
return Option.some(ActivatedItem({
|
|
519
|
+
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
519
520
|
index: targetIndex,
|
|
520
521
|
activationTrigger: 'Keyboard',
|
|
521
522
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
522
|
-
}));
|
|
523
|
-
}), M.orElse(() => Option.none()));
|
|
523
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~45");
|
|
524
|
+
}), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~46")))), "@foldkit/ui/combobox/shared.js#handleInputKeyDown");
|
|
524
525
|
const maybeActiveDescendant = Option.match(maybeActiveItemIndex, {
|
|
525
|
-
onNone: () => [],
|
|
526
|
-
onSome: index => [h.AriaActiveDescendant(itemId(id, index))],
|
|
526
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#onNone~4"),
|
|
527
|
+
onSome: index => __foldkitBrandViewResult(([h.AriaActiveDescendant(itemId(id, index))]), "@foldkit/ui/combobox/shared.js#onSome~3"),
|
|
527
528
|
});
|
|
528
529
|
const resolvedInputAttributes = [
|
|
529
530
|
h.Id(`${id}-input`),
|
|
@@ -540,7 +541,7 @@ export const makeView = (behavior) => {
|
|
|
540
541
|
...(isDisabled
|
|
541
542
|
? [h.AriaDisabled(true), h.DataAttribute('disabled', '')]
|
|
542
543
|
: [
|
|
543
|
-
h.OnInput(value => UpdatedInputValue({ value })),
|
|
544
|
+
h.OnInput(value => __foldkitBrandViewResult((UpdatedInputValue({ value })), "@foldkit/ui/combobox/shared.js#anonymous~47")),
|
|
544
545
|
h.OnKeyDownPreventDefault(handleInputKeyDown),
|
|
545
546
|
h.OnBlur(BlurredInput({ restingInputValue })),
|
|
546
547
|
...(openOnFocus
|
|
@@ -580,7 +581,7 @@ export const makeView = (behavior) => {
|
|
|
580
581
|
...itemsAttributes,
|
|
581
582
|
];
|
|
582
583
|
const comboboxItems = Array.map(items, (item, index) => {
|
|
583
|
-
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => activeIndex === index);
|
|
584
|
+
const isActiveItem = Option.exists(maybeActiveItemIndex, activeIndex => __foldkitBrandViewResult((activeIndex === index), "@foldkit/ui/combobox/shared.js#anonymous~49"));
|
|
584
585
|
const isDisabledItem = isDisabledAtIndex(index);
|
|
585
586
|
const isSelectedItem = isValueSelected(itemToValue(item, index));
|
|
586
587
|
const itemConfig = itemToConfig(item, {
|
|
@@ -589,7 +590,7 @@ export const makeView = (behavior) => {
|
|
|
589
590
|
isSelected: isSelectedItem,
|
|
590
591
|
});
|
|
591
592
|
const isInteractive = !isDisabledItem && !isLeaving;
|
|
592
|
-
return h.keyed('div')(itemId(id, index), [
|
|
593
|
+
return __foldkitBrandViewResult((h.keyed('div')(itemId(id, index), [
|
|
593
594
|
h.Id(itemId(id, index)),
|
|
594
595
|
h.Role('option'),
|
|
595
596
|
h.AriaSelected(isSelectedItem),
|
|
@@ -608,34 +609,34 @@ export const makeView = (behavior) => {
|
|
|
608
609
|
...(isActiveItem
|
|
609
610
|
? []
|
|
610
611
|
: [
|
|
611
|
-
h.OnPointerMove((screenX, screenY, pointerType) => OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({ index, screenX, screenY }))),
|
|
612
|
+
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({ index, screenX, screenY }))), "@foldkit/ui/combobox/shared.js#anonymous~50")),
|
|
612
613
|
]),
|
|
613
|
-
h.OnPointerLeave(pointerType => OptionExt.when(pointerType !== 'touch', DeactivatedItem())),
|
|
614
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/combobox/shared.js#anonymous~51")),
|
|
614
615
|
]
|
|
615
616
|
: []),
|
|
616
617
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
617
|
-
], [itemConfig.content]);
|
|
618
|
+
], [itemConfig.content])), "@foldkit/ui/combobox/shared.js#anonymous~48");
|
|
618
619
|
});
|
|
619
620
|
const renderGroupedItems = () => {
|
|
620
621
|
if (!itemGroupKey) {
|
|
621
|
-
return comboboxItems;
|
|
622
|
+
return __foldkitBrandViewResult((comboboxItems), "@foldkit/ui/combobox/shared.js#renderGroupedItems");
|
|
622
623
|
}
|
|
623
|
-
const segments = groupContiguous(comboboxItems, (_, index) => Array.get(items, index).pipe(Option.match({
|
|
624
|
-
onNone: () => '',
|
|
625
|
-
onSome: item => itemGroupKey(item, index),
|
|
626
|
-
})));
|
|
627
|
-
return Array.flatMap(segments, (segment, segmentIndex) => {
|
|
624
|
+
const segments = groupContiguous(comboboxItems, (_, index) => __foldkitBrandViewResult((Array.get(items, index).pipe(Option.match({
|
|
625
|
+
onNone: () => __foldkitBrandViewResult((''), "@foldkit/ui/combobox/shared.js#onNone~5"),
|
|
626
|
+
onSome: item => __foldkitBrandViewResult((itemGroupKey(item, index)), "@foldkit/ui/combobox/shared.js#onSome~4"),
|
|
627
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~52"));
|
|
628
|
+
return __foldkitBrandViewResult((Array.flatMap(segments, (segment, segmentIndex) => {
|
|
628
629
|
const maybeHeading = Option.fromNullishOr(groupToHeading && groupToHeading(segment.key));
|
|
629
630
|
const headingId = `${id}-heading-${segment.key}`;
|
|
630
631
|
const headingElement = Option.match(maybeHeading, {
|
|
631
|
-
onNone: () => [],
|
|
632
|
-
onSome: heading => [
|
|
632
|
+
onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/combobox/shared.js#onNone~6"),
|
|
633
|
+
onSome: heading => __foldkitBrandViewResult(([
|
|
633
634
|
h.keyed('div')(headingId, [
|
|
634
635
|
h.Id(headingId),
|
|
635
636
|
h.Role('presentation'),
|
|
636
637
|
...(heading.className ? [h.Class(heading.className)] : []),
|
|
637
638
|
], [heading.content]),
|
|
638
|
-
],
|
|
639
|
+
]), "@foldkit/ui/combobox/shared.js#onSome~5"),
|
|
639
640
|
});
|
|
640
641
|
const groupContent = [...headingElement, ...segment.items];
|
|
641
642
|
const groupElement = h.keyed('div')(`${id}-group-${segment.key}`, [
|
|
@@ -659,8 +660,8 @@ export const makeView = (behavior) => {
|
|
|
659
660
|
], []),
|
|
660
661
|
]
|
|
661
662
|
: [];
|
|
662
|
-
return [...separator, groupElement];
|
|
663
|
-
});
|
|
663
|
+
return __foldkitBrandViewResult(([...separator, groupElement]), "@foldkit/ui/combobox/shared.js#anonymous~53");
|
|
664
|
+
})), "@foldkit/ui/combobox/shared.js#renderGroupedItems");
|
|
664
665
|
};
|
|
665
666
|
const backdrop = h.keyed('div')(`${id}-backdrop`, [
|
|
666
667
|
h.OnMount(PortalComboboxBackdrop()),
|
|
@@ -709,12 +710,12 @@ export const makeView = (behavior) => {
|
|
|
709
710
|
: [];
|
|
710
711
|
const hiddenInputs = formName
|
|
711
712
|
? Array.match(selectedValues, {
|
|
712
|
-
onEmpty: () => [h.input([h.Type('hidden'), h.Name(formName)])],
|
|
713
|
-
onNonEmpty: Array.map(selectedValue => h.input([
|
|
713
|
+
onEmpty: () => __foldkitBrandViewResult(([h.input([h.Type('hidden'), h.Name(formName)])]), "@foldkit/ui/combobox/shared.js#onEmpty"),
|
|
714
|
+
onNonEmpty: Array.map(selectedValue => __foldkitBrandViewResult((h.input([
|
|
714
715
|
h.Type('hidden'),
|
|
715
716
|
h.Name(formName),
|
|
716
717
|
h.Value(selectedValue),
|
|
717
|
-
])),
|
|
718
|
+
])), "@foldkit/ui/combobox/shared.js#anonymous~54")),
|
|
718
719
|
})
|
|
719
720
|
: [];
|
|
720
721
|
const wrapperAttributes = [
|
|
@@ -724,7 +725,7 @@ export const makeView = (behavior) => {
|
|
|
724
725
|
...(isDisabled ? [h.DataAttribute('disabled', '')] : []),
|
|
725
726
|
...(isInvalid ? [h.DataAttribute('invalid', '')] : []),
|
|
726
727
|
];
|
|
727
|
-
return h.div(wrapperAttributes, [
|
|
728
|
+
return __foldkitBrandViewResult((h.div(wrapperAttributes, [
|
|
728
729
|
h.div(resolvedInputWrapperAttributes, [
|
|
729
730
|
h.input(resolvedInputAttributes),
|
|
730
731
|
...toggleButton,
|
|
@@ -733,9 +734,9 @@ export const makeView = (behavior) => {
|
|
|
733
734
|
? visibleContent
|
|
734
735
|
: []),
|
|
735
736
|
...hiddenInputs,
|
|
736
|
-
]);
|
|
737
|
+
])), "@foldkit/ui/combobox/shared.js#anonymous~30");
|
|
737
738
|
});
|
|
738
|
-
return () =>
|
|
739
|
+
return __foldkitBrandViewResult((() =>
|
|
739
740
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
740
|
-
impl;
|
|
741
|
+
__foldkitBrandViewResult((impl), "@foldkit/ui/combobox/shared.js#anonymous~55")), "@foldkit/ui/combobox/shared.js#makeView");
|
|
741
742
|
};
|