@foldkit/ui 0.148.2 → 0.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/index.d.ts +3 -3
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/animation/index.js +2 -2
- package/dist/animation/public.d.ts +1 -1
- package/dist/animation/public.d.ts.map +1 -1
- package/dist/animation/public.js +1 -1
- package/dist/animation/schema.d.ts +12 -21
- package/dist/animation/schema.d.ts.map +1 -1
- package/dist/animation/schema.js +11 -15
- package/dist/animation/update.d.ts +1 -1
- package/dist/animation/update.d.ts.map +1 -1
- package/dist/animation/update.js +9 -9
- package/dist/calendar/index.d.ts +50 -105
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +61 -98
- package/dist/calendar/public.d.ts +1 -1
- package/dist/calendar/public.d.ts.map +1 -1
- package/dist/calendar/public.js +1 -1
- package/dist/combobox/multi.d.ts +9 -9
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +9 -9
- package/dist/combobox/public.d.ts +1 -1
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +93 -137
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +108 -153
- package/dist/combobox/single.d.ts +9 -9
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +10 -10
- package/dist/datePicker/index.d.ts +88 -84
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +33 -63
- package/dist/datePicker/public.d.ts +1 -1
- package/dist/datePicker/public.d.ts.map +1 -1
- package/dist/datePicker/public.js +1 -1
- package/dist/dialog/index.d.ts +28 -49
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +39 -67
- package/dist/dialog/public.d.ts +1 -1
- package/dist/dialog/public.d.ts.map +1 -1
- package/dist/dialog/public.js +1 -1
- package/dist/dragAndDrop/index.d.ts +45 -72
- package/dist/dragAndDrop/index.d.ts.map +1 -1
- package/dist/dragAndDrop/index.js +72 -93
- package/dist/dragAndDrop/public.d.ts +1 -1
- package/dist/dragAndDrop/public.d.ts.map +1 -1
- package/dist/dragAndDrop/public.js +1 -1
- package/dist/fileDrop/index.d.ts +14 -35
- package/dist/fileDrop/index.d.ts.map +1 -1
- package/dist/fileDrop/index.js +20 -46
- package/dist/fileDrop/public.d.ts +1 -1
- package/dist/fileDrop/public.d.ts.map +1 -1
- package/dist/fileDrop/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -7
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +8 -8
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/public.js +1 -1
- package/dist/listbox/shared.d.ts +80 -127
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +92 -149
- package/dist/listbox/single.d.ts +7 -7
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +8 -8
- package/dist/menu/index.d.ts +86 -134
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +141 -189
- package/dist/menu/public.d.ts +1 -1
- package/dist/menu/public.d.ts.map +1 -1
- package/dist/menu/public.js +1 -1
- package/dist/popover/index.d.ts +39 -65
- package/dist/popover/index.d.ts.map +1 -1
- package/dist/popover/index.js +68 -98
- package/dist/popover/public.d.ts +1 -1
- package/dist/popover/public.d.ts.map +1 -1
- package/dist/popover/public.js +1 -1
- package/dist/radioGroup/index.d.ts +18 -29
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +22 -27
- package/dist/radioGroup/public.d.ts +1 -1
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +29 -51
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +36 -56
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/tabs/index.d.ts +18 -28
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +22 -26
- package/dist/tabs/public.d.ts +1 -1
- package/dist/tabs/public.d.ts.map +1 -1
- package/dist/tabs/public.js +1 -1
- package/dist/test/apps/disabledButton.d.ts +71 -14
- package/dist/test/apps/disabledButton.d.ts.map +1 -1
- package/dist/test/apps/disabledButton.js +14 -13
- package/dist/toast/index.d.ts +124 -109
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +5 -5
- package/dist/toast/public.d.ts +1 -1
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -1
- package/dist/toast/schema.d.ts +72 -84
- package/dist/toast/schema.d.ts.map +1 -1
- package/dist/toast/schema.js +31 -41
- package/dist/toast/test.d.ts.map +1 -1
- package/dist/toast/test.js +6 -3
- package/dist/toast/update.d.ts +104 -89
- package/dist/toast/update.d.ts.map +1 -1
- package/dist/toast/update.js +19 -20
- package/dist/tooltip/message.d.ts +26 -47
- package/dist/tooltip/message.d.ts.map +1 -1
- package/dist/tooltip/message.js +15 -40
- package/dist/tooltip/public.d.ts +1 -1
- package/dist/tooltip/public.d.ts.map +1 -1
- package/dist/tooltip/public.js +1 -1
- package/dist/tooltip/tooltip.d.ts +1 -1
- package/dist/tooltip/tooltip.d.ts.map +1 -1
- package/dist/tooltip/tooltip.js +15 -16
- package/dist/virtualList/index.d.ts +46 -23
- package/dist/virtualList/index.d.ts.map +1 -1
- package/dist/virtualList/index.js +12 -23
- package/dist/virtualList/public.d.ts +1 -1
- package/dist/virtualList/public.d.ts.map +1 -1
- package/dist/virtualList/public.js +1 -1
- package/package.json +3 -3
package/dist/combobox/shared.js
CHANGED
|
@@ -2,7 +2,7 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Array, Effect, Match as M, Option, Predicate, Schema as S, pipe, } from 'effect';
|
|
3
3
|
import * as Command from 'foldkit/command';
|
|
4
4
|
import * as Dom from 'foldkit/dom';
|
|
5
|
-
import {
|
|
5
|
+
import { defineMessageUnion } from 'foldkit/message';
|
|
6
6
|
import * as Mount from 'foldkit/mount';
|
|
7
7
|
import { makeConstrainedEvo } from 'foldkit/struct';
|
|
8
8
|
import { defineView } from 'foldkit/submodel';
|
|
@@ -11,7 +11,7 @@ import { AnchorConfig, anchorSetup, portalToContainingRoot, } from '../anchor/in
|
|
|
11
11
|
// NOTE: Animation imports are split across schema + update to avoid a circular
|
|
12
12
|
// dependency: animation → html → runtime → devtools → combobox → animation.
|
|
13
13
|
// The barrel (../animation) imports from html, which starts the cycle.
|
|
14
|
-
import {
|
|
14
|
+
import { Message as AnimationMessage, Model as AnimationModel, init as animationInit, } from '../animation/schema.js';
|
|
15
15
|
import { update as animationUpdate } from '../animation/update.js';
|
|
16
16
|
import { groupContiguous } from '../group.js';
|
|
17
17
|
import * as OptionExt from '../internal/optionExtensions.js';
|
|
@@ -52,116 +52,58 @@ export const baseInit = (config) => (__foldkitBrandViewResult(({
|
|
|
52
52
|
maybeLastPointerPosition: Option.none(),
|
|
53
53
|
}), "@foldkit/ui/combobox/shared.js#baseInit"));
|
|
54
54
|
// MESSAGE
|
|
55
|
-
/** Sent when the combobox popup opens. Contains an optional initial active item index. */
|
|
56
|
-
export const Opened = m('Opened', {
|
|
57
|
-
maybeActiveItemIndex: S.Option(S.Number),
|
|
58
|
-
});
|
|
59
|
-
/** Sent when the combobox closes via Escape key or backdrop click. `restingInputValue` is what the input returns to on close (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. `isClearable` carries whether this close may emit `ClearedSelection`, which a read-only combobox denies; the view holds `isReadOnly` and the update does not. */
|
|
60
|
-
export const Closed = m('Closed', {
|
|
61
|
-
restingInputValue: S.String,
|
|
62
|
-
isClearable: S.Boolean,
|
|
63
|
-
});
|
|
64
|
-
/** Sent when the combobox input loses focus. `restingInputValue` is what the input returns to on close (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. `isClearable` carries whether this close may emit `ClearedSelection`, which a read-only combobox denies. */
|
|
65
|
-
export const BlurredInput = m('BlurredInput', {
|
|
66
|
-
restingInputValue: S.String,
|
|
67
|
-
isClearable: S.Boolean,
|
|
68
|
-
});
|
|
69
|
-
/** Sent when an item is highlighted via arrow keys or mouse hover. Includes activation trigger and optional immediate selection info. */
|
|
70
|
-
export const ActivatedItem = m('ActivatedItem', {
|
|
71
|
-
index: S.Number,
|
|
72
|
-
activationTrigger: ActivationTrigger,
|
|
73
|
-
maybeImmediateSelection: S.Option(S.Struct({ item: S.String })),
|
|
74
|
-
});
|
|
75
|
-
/** Sent when the mouse leaves an enabled item. */
|
|
76
|
-
export const DeactivatedItem = m('DeactivatedItem');
|
|
77
|
-
/** Sent when an item is selected via Enter or click. `displayText` is the item's resting input text, and `wasSelected` reports whether the item was already in the parent-owned selection when activated, so nullable deselect logic works without the Model knowing the selection. */
|
|
78
|
-
export const SelectedItem = m('SelectedItem', {
|
|
79
|
-
item: S.String,
|
|
80
|
-
displayText: S.String,
|
|
81
|
-
wasSelected: S.Boolean,
|
|
82
|
-
});
|
|
83
|
-
/** Sent when the pointer moves over a combobox item. */
|
|
84
|
-
export const MovedPointerOverItem = m('MovedPointerOverItem', {
|
|
85
|
-
index: S.Number,
|
|
86
|
-
screenX: S.Number,
|
|
87
|
-
screenY: S.Number,
|
|
88
|
-
});
|
|
89
|
-
/** Sent when Enter or Space is pressed on the active item, triggering a programmatic click. */
|
|
90
|
-
export const RequestedItemClick = m('RequestedItemClick', {
|
|
91
|
-
index: S.Number,
|
|
92
|
-
});
|
|
93
|
-
/** Sent when Enter is pressed on the active item of a read-only combobox. Update no-ops; the Message exists so the keydown handler returns `Option.some` and calls `preventDefault`, which stops a surrounding form from submitting, and so the keypress stays visible for DevTools. */
|
|
94
|
-
export const SuppressedItemCommit = m('SuppressedItemCommit');
|
|
95
|
-
/** Sent when the scroll lock command completes. */
|
|
96
|
-
export const CompletedLockScroll = m('CompletedLockScroll');
|
|
97
|
-
/** Sent when the scroll unlock command completes. */
|
|
98
|
-
export const CompletedUnlockScroll = m('CompletedUnlockScroll');
|
|
99
|
-
/** Sent when the inert-others command completes. */
|
|
100
|
-
export const CompletedInertOthers = m('CompletedInertOthers');
|
|
101
|
-
/** Sent when the restore-inert command completes. */
|
|
102
|
-
export const CompletedRestoreInert = m('CompletedRestoreInert');
|
|
103
|
-
/** Sent when the focus-input command completes. */
|
|
104
|
-
export const CompletedFocusInput = m('CompletedFocusInput');
|
|
105
|
-
/** Sent when the scroll-into-view command completes after keyboard activation. */
|
|
106
|
-
export const CompletedScrollIntoView = m('CompletedScrollIntoView');
|
|
107
|
-
/** Sent when the programmatic item click command completes. */
|
|
108
|
-
export const CompletedClickItem = m('CompletedClickItem');
|
|
109
|
-
/** Sent when the items panel mounts and Floating UI has positioned it. Update no-ops; surfaces the positioning side effect for DevTools. */
|
|
110
|
-
export const CompletedAnchorCombobox = m('CompletedAnchorCombobox');
|
|
111
|
-
/** Sent when the items panel mounts and the capture-phase pointerdown listener is attached (with or without anchor). Update no-ops; surfaces the listener-attach side effect for DevTools. */
|
|
112
|
-
export const CompletedAttachComboboxPreventBlur = m('CompletedAttachComboboxPreventBlur');
|
|
113
|
-
/** Sent when the input mounts and the focus listener that auto-selects on focus is attached. Update no-ops; surfaces the listener-attach side effect for DevTools. */
|
|
114
|
-
export const CompletedAttachComboboxSelectOnFocus = m('CompletedAttachComboboxSelectOnFocus');
|
|
115
|
-
/** Sent when the combobox backdrop mounts and is portaled to the document body. Update no-ops; surfaces the portal side effect for DevTools. */
|
|
116
|
-
export const CompletedPortalComboboxBackdrop = m('CompletedPortalComboboxBackdrop');
|
|
117
|
-
/** Wraps an Animation submodel message for delegation. */
|
|
118
|
-
export const GotAnimationMessage = m('GotAnimationMessage', {
|
|
119
|
-
message: AnimationMessage,
|
|
120
|
-
});
|
|
121
|
-
/** Sent when the user types in the input. */
|
|
122
|
-
export const UpdatedInputValue = m('UpdatedInputValue', {
|
|
123
|
-
value: S.String,
|
|
124
|
-
});
|
|
125
|
-
/** Sent when the optional toggle button is clicked. `restingInputValue` is what the input returns to when the press closes the combobox (the parent-owned selection's display text, or empty), computed by the view from `ViewInputs.restingInputValue`. `isClearable` carries whether a close from this press may emit `ClearedSelection`, which a read-only combobox denies. */
|
|
126
|
-
export const PressedToggleButton = m('PressedToggleButton', {
|
|
127
|
-
restingInputValue: S.String,
|
|
128
|
-
isClearable: S.Boolean,
|
|
129
|
-
});
|
|
130
55
|
/** Union of all messages the combobox component can produce. */
|
|
131
|
-
export const Message =
|
|
132
|
-
Opened,
|
|
133
|
-
Closed
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
56
|
+
export const Message = defineMessageUnion({
|
|
57
|
+
Opened: { maybeActiveItemIndex: S.Option(S.Number) },
|
|
58
|
+
Closed: {
|
|
59
|
+
restingInputValue: S.String,
|
|
60
|
+
isClearable: S.Boolean,
|
|
61
|
+
},
|
|
62
|
+
BlurredInput: {
|
|
63
|
+
restingInputValue: S.String,
|
|
64
|
+
isClearable: S.Boolean,
|
|
65
|
+
},
|
|
66
|
+
ActivatedItem: {
|
|
67
|
+
index: S.Number,
|
|
68
|
+
activationTrigger: ActivationTrigger,
|
|
69
|
+
maybeImmediateSelection: S.Option(S.Struct({ item: S.String })),
|
|
70
|
+
},
|
|
71
|
+
DeactivatedItem: {},
|
|
72
|
+
SelectedItem: {
|
|
73
|
+
item: S.String,
|
|
74
|
+
displayText: S.String,
|
|
75
|
+
wasSelected: S.Boolean,
|
|
76
|
+
},
|
|
77
|
+
MovedPointerOverItem: {
|
|
78
|
+
index: S.Number,
|
|
79
|
+
screenX: S.Number,
|
|
80
|
+
screenY: S.Number,
|
|
81
|
+
},
|
|
82
|
+
RequestedItemClick: { index: S.Number },
|
|
83
|
+
SuppressedItemCommit: {},
|
|
84
|
+
CompletedLockScroll: {},
|
|
85
|
+
CompletedUnlockScroll: {},
|
|
86
|
+
CompletedInertOthers: {},
|
|
87
|
+
CompletedRestoreInert: {},
|
|
88
|
+
CompletedFocusInput: {},
|
|
89
|
+
CompletedScrollIntoView: {},
|
|
90
|
+
CompletedClickItem: {},
|
|
91
|
+
CompletedAnchorCombobox: {},
|
|
92
|
+
CompletedAttachComboboxPreventBlur: {},
|
|
93
|
+
CompletedAttachComboboxSelectOnFocus: {},
|
|
94
|
+
CompletedPortalComboboxBackdrop: {},
|
|
95
|
+
GotAnimationMessage: { message: AnimationMessage },
|
|
96
|
+
UpdatedInputValue: { value: S.String },
|
|
97
|
+
PressedToggleButton: {
|
|
98
|
+
restingInputValue: S.String,
|
|
99
|
+
isClearable: S.Boolean,
|
|
100
|
+
},
|
|
160
101
|
});
|
|
161
|
-
/** Sent when a nullable combobox closes with an empty input, meaning the user cleared it. The parent clears the selection it owns. */
|
|
162
|
-
export const ClearedSelection = m('ClearedSelection');
|
|
163
102
|
/** Union of out-messages the combobox component can produce. The parent folds `Selected` into the selection it owns and clears that selection on `ClearedSelection`. */
|
|
164
|
-
export const OutMessage =
|
|
103
|
+
export const OutMessage = defineMessageUnion({
|
|
104
|
+
Selected: { value: S.String },
|
|
105
|
+
ClearedSelection: {},
|
|
106
|
+
});
|
|
165
107
|
// SELECTORS
|
|
166
108
|
/** Returns the bare DOM id of the combobox input, derived from the
|
|
167
109
|
* combobox's base id. Use this to associate an external label with the
|
|
@@ -185,49 +127,53 @@ export const closedBaseModel = (model) => __foldkitBrandViewResult((constrainedE
|
|
|
185
127
|
})), "@foldkit/ui/combobox/shared.js#closedBaseModel");
|
|
186
128
|
/** Prevents page scrolling while the combobox popup is open in modal mode. */
|
|
187
129
|
export const LockScroll = Command.define('LockScroll', {
|
|
188
|
-
messages: [CompletedLockScroll],
|
|
189
|
-
execute: Dom.lockScroll.pipe(Effect.as(CompletedLockScroll())),
|
|
130
|
+
messages: [Message.CompletedLockScroll],
|
|
131
|
+
execute: Dom.lockScroll.pipe(Effect.as(Message.CompletedLockScroll())),
|
|
190
132
|
});
|
|
191
133
|
/** Re-enables page scrolling after the combobox popup closes. */
|
|
192
134
|
export const UnlockScroll = Command.define('UnlockScroll', {
|
|
193
|
-
messages: [CompletedUnlockScroll],
|
|
194
|
-
execute: Dom.unlockScroll.pipe(Effect.as(CompletedUnlockScroll())),
|
|
135
|
+
messages: [Message.CompletedUnlockScroll],
|
|
136
|
+
execute: Dom.unlockScroll.pipe(Effect.as(Message.CompletedUnlockScroll())),
|
|
195
137
|
});
|
|
196
138
|
/** Marks all elements outside the combobox as inert for modal behavior. */
|
|
197
139
|
export const InertOthers = Command.define('InertOthers', {
|
|
198
140
|
args: { id: S.String },
|
|
199
|
-
messages: [CompletedInertOthers],
|
|
200
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [inputWrapperSelector(id), itemsSelector(id)]).pipe(Effect.as(CompletedInertOthers()))), "@foldkit/ui/combobox/shared.js#execute"),
|
|
141
|
+
messages: [Message.CompletedInertOthers],
|
|
142
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.inertOthers(id, [inputWrapperSelector(id), itemsSelector(id)]).pipe(Effect.as(Message.CompletedInertOthers()))), "@foldkit/ui/combobox/shared.js#execute"),
|
|
201
143
|
});
|
|
202
144
|
/** Removes the inert attribute from elements outside the combobox. */
|
|
203
145
|
export const RestoreInert = Command.define('RestoreInert', {
|
|
204
146
|
args: { id: S.String },
|
|
205
|
-
messages: [CompletedRestoreInert],
|
|
206
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(CompletedRestoreInert()))), "@foldkit/ui/combobox/shared.js#execute~2"),
|
|
147
|
+
messages: [Message.CompletedRestoreInert],
|
|
148
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.restoreInert(id).pipe(Effect.as(Message.CompletedRestoreInert()))), "@foldkit/ui/combobox/shared.js#execute~2"),
|
|
207
149
|
});
|
|
208
150
|
/** Moves focus to the combobox input after selection or close. */
|
|
209
151
|
export const FocusInput = Command.define('FocusInput', {
|
|
210
152
|
args: { id: S.String },
|
|
211
|
-
messages: [CompletedFocusInput],
|
|
212
|
-
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(inputSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusInput()))), "@foldkit/ui/combobox/shared.js#execute~3"),
|
|
153
|
+
messages: [Message.CompletedFocusInput],
|
|
154
|
+
execute: ({ id }) => __foldkitBrandViewResult((Dom.focus(inputSelector(id)).pipe(Effect.ignore, Effect.as(Message.CompletedFocusInput()))), "@foldkit/ui/combobox/shared.js#execute~3"),
|
|
213
155
|
});
|
|
214
156
|
/** Scrolls the active combobox item into view after keyboard navigation. */
|
|
215
157
|
export const ScrollIntoView = Command.define('ScrollIntoView', {
|
|
216
158
|
args: { id: S.String, index: S.Number },
|
|
217
|
-
messages: [CompletedScrollIntoView],
|
|
218
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedScrollIntoView()))), "@foldkit/ui/combobox/shared.js#execute~4"),
|
|
159
|
+
messages: [Message.CompletedScrollIntoView],
|
|
160
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.scrollIntoView(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedScrollIntoView()))), "@foldkit/ui/combobox/shared.js#execute~4"),
|
|
219
161
|
});
|
|
220
162
|
/** Programmatically clicks the active combobox item's DOM element. */
|
|
221
163
|
export const ClickItem = Command.define('ClickItem', {
|
|
222
164
|
args: { id: S.String, index: S.Number },
|
|
223
|
-
messages: [CompletedClickItem],
|
|
224
|
-
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(CompletedClickItem()))), "@foldkit/ui/combobox/shared.js#execute~5"),
|
|
165
|
+
messages: [Message.CompletedClickItem],
|
|
166
|
+
execute: ({ id, index }) => __foldkitBrandViewResult((Dom.clickElement(itemSelector(id, index)).pipe(Effect.ignore, Effect.as(Message.CompletedClickItem()))), "@foldkit/ui/combobox/shared.js#execute~5"),
|
|
225
167
|
});
|
|
226
168
|
/** 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. */
|
|
227
169
|
export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnimationEnd', {
|
|
228
170
|
args: { id: S.String },
|
|
229
|
-
messages: [GotAnimationMessage],
|
|
230
|
-
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(inputWrapperSelector(id)).pipe(Effect.as(
|
|
171
|
+
messages: [Message.GotAnimationMessage],
|
|
172
|
+
execute: ({ id }) => __foldkitBrandViewResult((Effect.raceFirst(Dom.detectElementMovement(inputWrapperSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
173
|
+
message: AnimationMessage.EndedAnimation(),
|
|
174
|
+
}))), Dom.waitForAnimationSettled(itemsSelector(id)).pipe(Effect.as(Message.GotAnimationMessage({
|
|
175
|
+
message: AnimationMessage.EndedAnimation(),
|
|
176
|
+
}))))), "@foldkit/ui/combobox/shared.js#execute~6"),
|
|
231
177
|
});
|
|
232
178
|
/** 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. */
|
|
233
179
|
export const makeUpdate = (handlers) => {
|
|
@@ -243,7 +189,7 @@ export const makeUpdate = (handlers) => {
|
|
|
243
189
|
update: animationUpdate,
|
|
244
190
|
read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/combobox/shared.js#read"),
|
|
245
191
|
write: (model, nextAnimation) => __foldkitBrandViewResult((constrainedEvo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/combobox/shared.js#animation") })), "@foldkit/ui/combobox/shared.js#write"),
|
|
246
|
-
toParentMessage: message => __foldkitBrandViewResult((GotAnimationMessage({ message })), "@foldkit/ui/combobox/shared.js#toParentMessage"),
|
|
192
|
+
toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/combobox/shared.js#toParentMessage"),
|
|
247
193
|
toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#toParentOutMessage"),
|
|
248
194
|
foldOutMessage: foldAnimationOutMessage,
|
|
249
195
|
});
|
|
@@ -265,7 +211,7 @@ export const makeUpdate = (handlers) => {
|
|
|
265
211
|
const didClose = model.isOpen && !nextModel.isOpen;
|
|
266
212
|
const commands = didClose ? closeWithFocusCommands : [focusInput];
|
|
267
213
|
if (didClose && model.isAnimated) {
|
|
268
|
-
const [transitionedModel, animationCommands] = foldAnimation(nextModel,
|
|
214
|
+
const [transitionedModel, animationCommands] = foldAnimation(nextModel, AnimationMessage.Hid());
|
|
269
215
|
return __foldkitBrandViewResult(([
|
|
270
216
|
transitionedModel,
|
|
271
217
|
[...commands, ...animationCommands],
|
|
@@ -276,7 +222,7 @@ export const makeUpdate = (handlers) => {
|
|
|
276
222
|
};
|
|
277
223
|
const openCombobox = (baseModel) => {
|
|
278
224
|
if (model.isAnimated) {
|
|
279
|
-
const [nextModel, animationCommands] = foldAnimation(baseModel,
|
|
225
|
+
const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationMessage.Showed());
|
|
280
226
|
return __foldkitBrandViewResult(([
|
|
281
227
|
constrainedEvo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/combobox/shared.js#isOpen~2") }),
|
|
282
228
|
[
|
|
@@ -295,7 +241,7 @@ export const makeUpdate = (handlers) => {
|
|
|
295
241
|
const closeCombobox = (baseModel, commands, restingInputValue, isClearable) => {
|
|
296
242
|
const [closed, maybeCloseOutMessage] = handlers.handleClose(baseModel, restingInputValue, isClearable);
|
|
297
243
|
if (model.isAnimated) {
|
|
298
|
-
const [nextModel, animationCommands] = foldAnimation(closed,
|
|
244
|
+
const [nextModel, animationCommands] = foldAnimation(closed, AnimationMessage.Hid());
|
|
299
245
|
return __foldkitBrandViewResult(([
|
|
300
246
|
nextModel,
|
|
301
247
|
[...commands, ...animationCommands],
|
|
@@ -416,7 +362,7 @@ export const makeUpdate = (handlers) => {
|
|
|
416
362
|
* capture listener that prevents input blur on item presses. Exposed so
|
|
417
363
|
* Scene tests can call
|
|
418
364
|
* `Scene.Mount.resolve(AnchorCombobox, CompletedAnchorCombobox())`. */
|
|
419
|
-
export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.String, anchor: AnchorConfig }, CompletedAnchorCombobox)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
365
|
+
export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.String, anchor: AnchorConfig }, Message.CompletedAnchorCombobox)(({ buttonId, anchor }) => __foldkitBrandViewResult((element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
420
366
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
421
367
|
const preventBlur = (event) => {
|
|
422
368
|
event.preventDefault();
|
|
@@ -436,13 +382,13 @@ export const AnchorCombobox = Mount.define('AnchorCombobox', { buttonId: S.Strin
|
|
|
436
382
|
teardownAnchor();
|
|
437
383
|
}), "@foldkit/ui/combobox/shared.js#anonymous~8");
|
|
438
384
|
}), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/combobox/shared.js#anonymous~10"));
|
|
439
|
-
return __foldkitBrandViewResult((CompletedAnchorCombobox()), "@foldkit/ui/combobox/shared.js#anonymous~7");
|
|
385
|
+
return __foldkitBrandViewResult((Message.CompletedAnchorCombobox()), "@foldkit/ui/combobox/shared.js#anonymous~7");
|
|
440
386
|
})), "@foldkit/ui/combobox/shared.js#anonymous~6")), "@foldkit/ui/combobox/shared.js#anonymous~5"));
|
|
441
387
|
/** The Mount this Combobox renders to install a `pointerdown`-cancelling
|
|
442
388
|
* capture listener that prevents blur on item presses. Exposed so Scene
|
|
443
389
|
* tests can call
|
|
444
390
|
* `Scene.Mount.resolve(AttachComboboxPreventBlur, CompletedAttachComboboxPreventBlur())`. */
|
|
445
|
-
export const AttachComboboxPreventBlur = Mount.define('AttachComboboxPreventBlur', CompletedAttachComboboxPreventBlur)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
391
|
+
export const AttachComboboxPreventBlur = Mount.define('AttachComboboxPreventBlur', Message.CompletedAttachComboboxPreventBlur)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
446
392
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
447
393
|
const handler = (event) => {
|
|
448
394
|
event.preventDefault();
|
|
@@ -452,12 +398,12 @@ export const AttachComboboxPreventBlur = Mount.define('AttachComboboxPreventBlur
|
|
|
452
398
|
}), handler => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((element.removeEventListener('pointerdown', handler, {
|
|
453
399
|
capture: true,
|
|
454
400
|
})), "@foldkit/ui/combobox/shared.js#anonymous~15"))), "@foldkit/ui/combobox/shared.js#anonymous~14"));
|
|
455
|
-
return __foldkitBrandViewResult((CompletedAttachComboboxPreventBlur()), "@foldkit/ui/combobox/shared.js#anonymous~12");
|
|
401
|
+
return __foldkitBrandViewResult((Message.CompletedAttachComboboxPreventBlur()), "@foldkit/ui/combobox/shared.js#anonymous~12");
|
|
456
402
|
})), "@foldkit/ui/combobox/shared.js#anonymous~11"));
|
|
457
403
|
/** The Mount this Combobox renders to install the input's select-on-focus
|
|
458
404
|
* behavior. Exposed so Scene tests can call
|
|
459
405
|
* `Scene.Mount.resolve(AttachComboboxSelectOnFocus, CompletedAttachComboboxSelectOnFocus())`. */
|
|
460
|
-
export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnFocus', CompletedAttachComboboxSelectOnFocus)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
406
|
+
export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnFocus', Message.CompletedAttachComboboxSelectOnFocus)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
461
407
|
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
462
408
|
const handler = () => {
|
|
463
409
|
if (element instanceof HTMLInputElement) {
|
|
@@ -467,14 +413,14 @@ export const AttachComboboxSelectOnFocus = Mount.define('AttachComboboxSelectOnF
|
|
|
467
413
|
element.addEventListener('focus', handler);
|
|
468
414
|
return __foldkitBrandViewResult((handler), "@foldkit/ui/combobox/shared.js#anonymous~18");
|
|
469
415
|
}), handler => __foldkitBrandViewResult((Effect.sync(() => __foldkitBrandViewResult((element.removeEventListener('focus', handler)), "@foldkit/ui/combobox/shared.js#anonymous~20"))), "@foldkit/ui/combobox/shared.js#anonymous~19"));
|
|
470
|
-
return __foldkitBrandViewResult((CompletedAttachComboboxSelectOnFocus()), "@foldkit/ui/combobox/shared.js#anonymous~17");
|
|
416
|
+
return __foldkitBrandViewResult((Message.CompletedAttachComboboxSelectOnFocus()), "@foldkit/ui/combobox/shared.js#anonymous~17");
|
|
471
417
|
})), "@foldkit/ui/combobox/shared.js#anonymous~16"));
|
|
472
418
|
/** The backdrop-portaling Mount this Combobox renders. Exposed so Scene tests can
|
|
473
419
|
* call `Scene.Mount.resolve(PortalComboboxBackdrop, CompletedPortalComboboxBackdrop())` to
|
|
474
420
|
* acknowledge the mount produced by the rendered backdrop. */
|
|
475
|
-
export const PortalComboboxBackdrop = Mount.define('PortalComboboxBackdrop', CompletedPortalComboboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
421
|
+
export const PortalComboboxBackdrop = Mount.define('PortalComboboxBackdrop', Message.CompletedPortalComboboxBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
|
|
476
422
|
yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/combobox/shared.js#anonymous~23")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/combobox/shared.js#anonymous~24"));
|
|
477
|
-
return __foldkitBrandViewResult((CompletedPortalComboboxBackdrop()), "@foldkit/ui/combobox/shared.js#anonymous~22");
|
|
423
|
+
return __foldkitBrandViewResult((Message.CompletedPortalComboboxBackdrop()), "@foldkit/ui/combobox/shared.js#anonymous~22");
|
|
478
424
|
})), "@foldkit/ui/combobox/shared.js#anonymous~21"));
|
|
479
425
|
/** 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. */
|
|
480
426
|
export const makeView = (behavior) => {
|
|
@@ -528,32 +474,32 @@ export const makeView = (behavior) => {
|
|
|
528
474
|
};
|
|
529
475
|
const resolveCommitMessage = () => {
|
|
530
476
|
if (isReadOnly) {
|
|
531
|
-
return __foldkitBrandViewResult((Option.as(maybeActiveItemIndex, SuppressedItemCommit())), "@foldkit/ui/combobox/shared.js#resolveCommitMessage");
|
|
477
|
+
return __foldkitBrandViewResult((Option.as(maybeActiveItemIndex, Message.SuppressedItemCommit())), "@foldkit/ui/combobox/shared.js#resolveCommitMessage");
|
|
532
478
|
}
|
|
533
479
|
else {
|
|
534
|
-
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((RequestedItemClick({ index })), "@foldkit/ui/combobox/shared.js#anonymous~35"))), "@foldkit/ui/combobox/shared.js#resolveCommitMessage");
|
|
480
|
+
return __foldkitBrandViewResult((Option.map(maybeActiveItemIndex, index => __foldkitBrandViewResult((Message.RequestedItemClick({ index })), "@foldkit/ui/combobox/shared.js#anonymous~35"))), "@foldkit/ui/combobox/shared.js#resolveCommitMessage");
|
|
535
481
|
}
|
|
536
482
|
};
|
|
537
483
|
const handleInputKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('ArrowDown', () => {
|
|
538
484
|
if (!isOpen) {
|
|
539
|
-
return __foldkitBrandViewResult((Option.some(Opened({
|
|
485
|
+
return __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
540
486
|
maybeActiveItemIndex: Option.some(firstEnabledIndex),
|
|
541
487
|
}))), "@foldkit/ui/combobox/shared.js#anonymous~36");
|
|
542
488
|
}
|
|
543
489
|
const targetIndex = resolveActiveIndex('ArrowDown');
|
|
544
|
-
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
490
|
+
return __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
545
491
|
index: targetIndex,
|
|
546
492
|
activationTrigger: 'Keyboard',
|
|
547
493
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
548
494
|
}))), "@foldkit/ui/combobox/shared.js#anonymous~36");
|
|
549
495
|
}), M.when('ArrowUp', () => {
|
|
550
496
|
if (!isOpen) {
|
|
551
|
-
return __foldkitBrandViewResult((Option.some(Opened({
|
|
497
|
+
return __foldkitBrandViewResult((Option.some(Message.Opened({
|
|
552
498
|
maybeActiveItemIndex: Option.some(lastEnabledIndex),
|
|
553
499
|
}))), "@foldkit/ui/combobox/shared.js#anonymous~37");
|
|
554
500
|
}
|
|
555
501
|
const targetIndex = resolveActiveIndex('ArrowUp');
|
|
556
|
-
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
502
|
+
return __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
557
503
|
index: targetIndex,
|
|
558
504
|
activationTrigger: 'Keyboard',
|
|
559
505
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
@@ -567,13 +513,13 @@ export const makeView = (behavior) => {
|
|
|
567
513
|
if (!isOpen) {
|
|
568
514
|
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~39");
|
|
569
515
|
}
|
|
570
|
-
return __foldkitBrandViewResult((Option.some(Closed({ restingInputValue, isClearable: !isReadOnly }))), "@foldkit/ui/combobox/shared.js#anonymous~39");
|
|
516
|
+
return __foldkitBrandViewResult((Option.some(Message.Closed({ restingInputValue, isClearable: !isReadOnly }))), "@foldkit/ui/combobox/shared.js#anonymous~39");
|
|
571
517
|
}), M.whenOr('Home', 'End', () => {
|
|
572
518
|
if (!isOpen) {
|
|
573
519
|
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/combobox/shared.js#anonymous~40");
|
|
574
520
|
}
|
|
575
521
|
const targetIndex = resolveActiveIndex(key);
|
|
576
|
-
return __foldkitBrandViewResult((Option.some(ActivatedItem({
|
|
522
|
+
return __foldkitBrandViewResult((Option.some(Message.ActivatedItem({
|
|
577
523
|
index: targetIndex,
|
|
578
524
|
activationTrigger: 'Keyboard',
|
|
579
525
|
maybeImmediateSelection: resolveImmediateSelection(targetIndex),
|
|
@@ -585,7 +531,7 @@ export const makeView = (behavior) => {
|
|
|
585
531
|
});
|
|
586
532
|
const onInputAttributes = isReadOnly
|
|
587
533
|
? []
|
|
588
|
-
: [h.OnInput(value => __foldkitBrandViewResult((UpdatedInputValue({ value })), "@foldkit/ui/combobox/shared.js#anonymous~42"))];
|
|
534
|
+
: [h.OnInput(value => __foldkitBrandViewResult((Message.UpdatedInputValue({ value })), "@foldkit/ui/combobox/shared.js#anonymous~42"))];
|
|
589
535
|
const resolvedInputAttributes = [
|
|
590
536
|
h.Id(`${id}-input`),
|
|
591
537
|
h.Role('combobox'),
|
|
@@ -603,9 +549,14 @@ export const makeView = (behavior) => {
|
|
|
603
549
|
: [
|
|
604
550
|
...onInputAttributes,
|
|
605
551
|
h.OnKeyDownPreventDefault(handleInputKeyDown),
|
|
606
|
-
h.OnBlur(BlurredInput({
|
|
552
|
+
h.OnBlur(Message.BlurredInput({
|
|
553
|
+
restingInputValue,
|
|
554
|
+
isClearable: !isReadOnly,
|
|
555
|
+
})),
|
|
607
556
|
...(openOnFocus
|
|
608
|
-
? [
|
|
557
|
+
? [
|
|
558
|
+
h.OnFocus(Message.Opened({ maybeActiveItemIndex: Option.none() })),
|
|
559
|
+
]
|
|
609
560
|
: []),
|
|
610
561
|
]),
|
|
611
562
|
...(isReadOnly
|
|
@@ -674,7 +625,7 @@ export const makeView = (behavior) => {
|
|
|
674
625
|
...(isReadOnly ? [h.DataAttribute('readonly', '')] : []),
|
|
675
626
|
...(isClickable
|
|
676
627
|
? [
|
|
677
|
-
h.OnClick(SelectedItem({
|
|
628
|
+
h.OnClick(Message.SelectedItem({
|
|
678
629
|
item: itemToValue(item, index),
|
|
679
630
|
displayText: itemToDisplayText(item, index),
|
|
680
631
|
wasSelected: isValueSelected(itemToValue(item, index)),
|
|
@@ -686,9 +637,13 @@ export const makeView = (behavior) => {
|
|
|
686
637
|
...(isActiveItem
|
|
687
638
|
? []
|
|
688
639
|
: [
|
|
689
|
-
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', MovedPointerOverItem({
|
|
640
|
+
h.OnPointerMove((screenX, screenY, pointerType) => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.MovedPointerOverItem({
|
|
641
|
+
index,
|
|
642
|
+
screenX,
|
|
643
|
+
screenY,
|
|
644
|
+
}))), "@foldkit/ui/combobox/shared.js#anonymous~45")),
|
|
690
645
|
]),
|
|
691
|
-
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', DeactivatedItem())), "@foldkit/ui/combobox/shared.js#anonymous~46")),
|
|
646
|
+
h.OnPointerLeave(pointerType => __foldkitBrandViewResult((OptionExt.when(pointerType !== 'touch', Message.DeactivatedItem())), "@foldkit/ui/combobox/shared.js#anonymous~46")),
|
|
692
647
|
]
|
|
693
648
|
: []),
|
|
694
649
|
...(itemConfig.className ? [h.Class(itemConfig.className)] : []),
|
|
@@ -745,7 +700,7 @@ export const makeView = (behavior) => {
|
|
|
745
700
|
...(isLeaving
|
|
746
701
|
? []
|
|
747
702
|
: [
|
|
748
|
-
h.OnClick(Closed({ restingInputValue, isClearable: !isReadOnly })),
|
|
703
|
+
h.OnClick(Message.Closed({ restingInputValue, isClearable: !isReadOnly })),
|
|
749
704
|
]),
|
|
750
705
|
...(backdropClassName ? [h.Class(backdropClassName)] : []),
|
|
751
706
|
...backdropAttributes,
|
|
@@ -783,7 +738,7 @@ export const makeView = (behavior) => {
|
|
|
783
738
|
...(isDisabled
|
|
784
739
|
? [h.AriaDisabled(true), h.DataAttribute('disabled', '')]
|
|
785
740
|
: [
|
|
786
|
-
h.OnClick(PressedToggleButton({
|
|
741
|
+
h.OnClick(Message.PressedToggleButton({
|
|
787
742
|
restingInputValue,
|
|
788
743
|
isClearable: !isReadOnly,
|
|
789
744
|
})),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Option, Schema as S } from 'effect';
|
|
2
2
|
import type * as Command from 'foldkit/command';
|
|
3
3
|
import { type View as SubmodelView } from 'foldkit/submodel';
|
|
4
|
-
import { type BaseInitConfig, type BaseViewInputsCommon,
|
|
4
|
+
import { type BaseInitConfig, type BaseViewInputsCommon, Message, OutMessage } from './shared.js';
|
|
5
5
|
/** Schema for the single-select combobox's private interaction state (open/closed status, active item, activation trigger, typed input value). The selection is owned by the parent and passed in via `ViewInputs.maybeSelectedValue`. */
|
|
6
6
|
export declare const Model: S.Struct<{
|
|
7
7
|
readonly id: S.String;
|
|
@@ -130,14 +130,6 @@ export declare const update: (model: {
|
|
|
130
130
|
readonly _tag: "PressedToggleButton";
|
|
131
131
|
readonly restingInputValue: string;
|
|
132
132
|
readonly isClearable: boolean;
|
|
133
|
-
} | {
|
|
134
|
-
readonly _tag: "CompletedAnchorCombobox";
|
|
135
|
-
} | {
|
|
136
|
-
readonly _tag: "CompletedAttachComboboxPreventBlur";
|
|
137
|
-
} | {
|
|
138
|
-
readonly _tag: "CompletedAttachComboboxSelectOnFocus";
|
|
139
|
-
} | {
|
|
140
|
-
readonly _tag: "CompletedPortalComboboxBackdrop";
|
|
141
133
|
} | {
|
|
142
134
|
readonly _tag: "GotAnimationMessage";
|
|
143
135
|
readonly message: {
|
|
@@ -149,6 +141,14 @@ export declare const update: (model: {
|
|
|
149
141
|
} | {
|
|
150
142
|
readonly _tag: "EndedAnimation";
|
|
151
143
|
};
|
|
144
|
+
} | {
|
|
145
|
+
readonly _tag: "CompletedAnchorCombobox";
|
|
146
|
+
} | {
|
|
147
|
+
readonly _tag: "CompletedAttachComboboxPreventBlur";
|
|
148
|
+
} | {
|
|
149
|
+
readonly _tag: "CompletedAttachComboboxSelectOnFocus";
|
|
150
|
+
} | {
|
|
151
|
+
readonly _tag: "CompletedPortalComboboxBackdrop";
|
|
152
152
|
}, never, never>;
|
|
153
153
|
}>[], Option.Option<OutMessage<string>>];
|
|
154
154
|
type UpdateReturn = ReturnType<typeof update>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/combobox/single.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,KAAK,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE/C,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AAExE,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../src/combobox/single.ts"],"names":[],"mappings":"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"}
|
package/dist/combobox/single.js
CHANGED
|
@@ -2,7 +2,7 @@ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
|
2
2
|
import { Option, Schema as S } from 'effect';
|
|
3
3
|
import { evo } from 'foldkit/struct';
|
|
4
4
|
import { defineView } from 'foldkit/submodel';
|
|
5
|
-
import { BaseModel,
|
|
5
|
+
import { BaseModel, Message, OutMessage, baseInit, closedBaseModel, makeUpdate, makeView, } from './shared.js';
|
|
6
6
|
// MODEL
|
|
7
7
|
/** Schema for the single-select combobox's private interaction state (open/closed status, active item, activation trigger, typed input value). The selection is owned by the parent and passed in via `ViewInputs.maybeSelectedValue`. */
|
|
8
8
|
export const Model = S.Struct({
|
|
@@ -17,7 +17,7 @@ export const update = makeUpdate({
|
|
|
17
17
|
if (isClearable && model.nullable && model.inputValue === '') {
|
|
18
18
|
return __foldkitBrandViewResult(([
|
|
19
19
|
evo(closedBaseModel(model), { inputValue: () => __foldkitBrandViewResult((''), "@foldkit/ui/combobox/single.js#inputValue") }),
|
|
20
|
-
Option.some(ClearedSelection()),
|
|
20
|
+
Option.some(OutMessage.ClearedSelection()),
|
|
21
21
|
]), "@foldkit/ui/combobox/single.js#handleClose");
|
|
22
22
|
}
|
|
23
23
|
return __foldkitBrandViewResult(([
|
|
@@ -29,28 +29,28 @@ export const update = makeUpdate({
|
|
|
29
29
|
const nullableDeselect = model.nullable && wasSelected;
|
|
30
30
|
return __foldkitBrandViewResult((context.closeWithFocus(evo(closedBaseModel(model), {
|
|
31
31
|
inputValue: () => (__foldkitBrandViewResult((nullableDeselect ? '' : displayText), "@foldkit/ui/combobox/single.js#inputValue~3")),
|
|
32
|
-
}), Option.some(
|
|
32
|
+
}), Option.some(OutMessage.Selected({ value: item })))), "@foldkit/ui/combobox/single.js#handleSelectedItem");
|
|
33
33
|
},
|
|
34
34
|
handleImmediateActivation: (model, item) => __foldkitBrandViewResult(([
|
|
35
35
|
model,
|
|
36
|
-
Option.some(
|
|
36
|
+
Option.some(OutMessage.Selected({ value: item })),
|
|
37
37
|
]), "@foldkit/ui/combobox/single.js#handleImmediateActivation"),
|
|
38
38
|
});
|
|
39
39
|
/** Programmatically opens the combobox, updating the model and returning
|
|
40
40
|
* focus and modal commands. Use this in domain-event handlers to open the combobox. */
|
|
41
|
-
export const open = (model) => __foldkitBrandViewResult((update(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/combobox/single.js#open");
|
|
41
|
+
export const open = (model) => __foldkitBrandViewResult((update(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/combobox/single.js#open");
|
|
42
42
|
/** Programmatically closes the combobox, updating the model and returning
|
|
43
43
|
* focus and modal commands. `restingInputValue` is the text the input
|
|
44
44
|
* returns to (the parent-owned selection's display text, or empty). Use
|
|
45
45
|
* this in domain-event handlers to close the combobox. */
|
|
46
|
-
export const close = (model, restingInputValue) => __foldkitBrandViewResult((update(model, Closed({ restingInputValue, isClearable: true }))), "@foldkit/ui/combobox/single.js#close");
|
|
46
|
+
export const close = (model, restingInputValue) => __foldkitBrandViewResult((update(model, Message.Closed({ restingInputValue, isClearable: true }))), "@foldkit/ui/combobox/single.js#close");
|
|
47
47
|
/** Programmatically selects an item in the single-select combobox, closing
|
|
48
48
|
* the combobox and emitting `Selected({ value })`. The Submodel treats the
|
|
49
49
|
* select as fresh (`wasSelected: false`), so the input rests on
|
|
50
50
|
* `displayText`; what the selection becomes is the parent's fold to decide,
|
|
51
51
|
* and a parent that toggles on its own state will still deselect an
|
|
52
52
|
* already-selected value. */
|
|
53
|
-
export const selectItem = (model, item, displayText) => __foldkitBrandViewResult((update(model, SelectedItem({ item, displayText, wasSelected: false }))), "@foldkit/ui/combobox/single.js#selectItem");
|
|
53
|
+
export const selectItem = (model, item, displayText) => __foldkitBrandViewResult((update(model, Message.SelectedItem({ item, displayText, wasSelected: false }))), "@foldkit/ui/combobox/single.js#selectItem");
|
|
54
54
|
const internalView = makeView({ ariaMultiSelectable: false });
|
|
55
55
|
/** Pairs the single-select combobox's `view` and `update` (and programmatic
|
|
56
56
|
* helpers) behind a single Item-typed entry point. See `Listbox.create`
|
|
@@ -69,8 +69,8 @@ export const create = () => {
|
|
|
69
69
|
return __foldkitBrandViewResult(({
|
|
70
70
|
view,
|
|
71
71
|
update: typedUpdate,
|
|
72
|
-
selectItem: (model, item, displayText) => __foldkitBrandViewResult((typedUpdate(model, SelectedItem({ item, displayText, wasSelected: false }))), "@foldkit/ui/combobox/single.js#selectItem~2"),
|
|
73
|
-
open: model => __foldkitBrandViewResult((typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/combobox/single.js#open~2"),
|
|
74
|
-
close: (model, restingInputValue) => __foldkitBrandViewResult((typedUpdate(model, Closed({ restingInputValue, isClearable: true }))), "@foldkit/ui/combobox/single.js#close~2"),
|
|
72
|
+
selectItem: (model, item, displayText) => __foldkitBrandViewResult((typedUpdate(model, Message.SelectedItem({ item, displayText, wasSelected: false }))), "@foldkit/ui/combobox/single.js#selectItem~2"),
|
|
73
|
+
open: model => __foldkitBrandViewResult((typedUpdate(model, Message.Opened({ maybeActiveItemIndex: Option.none() }))), "@foldkit/ui/combobox/single.js#open~2"),
|
|
74
|
+
close: (model, restingInputValue) => __foldkitBrandViewResult((typedUpdate(model, Message.Closed({ restingInputValue, isClearable: true }))), "@foldkit/ui/combobox/single.js#close~2"),
|
|
75
75
|
}), "@foldkit/ui/combobox/single.js#create");
|
|
76
76
|
};
|