foldkit 0.111.1 → 0.112.1

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.
Files changed (224) hide show
  1. package/README.md +2 -2
  2. package/dist/devTools/host.d.ts +6 -0
  3. package/dist/devTools/host.d.ts.map +1 -0
  4. package/dist/devTools/host.js +4 -0
  5. package/dist/dom/dom.d.ts +6 -1
  6. package/dist/dom/dom.d.ts.map +1 -1
  7. package/dist/dom/dom.js +24 -1
  8. package/dist/html/index.d.ts +4 -3
  9. package/dist/html/index.d.ts.map +1 -1
  10. package/dist/html/index.js +4 -3
  11. package/dist/html/submodel.d.ts +2 -2
  12. package/dist/html/submodel.d.ts.map +1 -1
  13. package/dist/index.d.ts +0 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +0 -1
  16. package/dist/runtime/browserListeners.d.ts.map +1 -1
  17. package/dist/runtime/browserListeners.js +12 -7
  18. package/dist/runtime/public.d.ts +1 -1
  19. package/dist/runtime/public.d.ts.map +1 -1
  20. package/dist/runtime/runtime.d.ts +14 -1
  21. package/dist/runtime/runtime.d.ts.map +1 -1
  22. package/dist/runtime/runtime.js +25 -8
  23. package/dist/runtime/subscription.d.ts +1 -1
  24. package/dist/subscription/public.d.ts +1 -1
  25. package/dist/subscription/public.d.ts.map +1 -1
  26. package/package.json +12 -93
  27. package/dist/devTools/overlay-styles.d.ts +0 -3
  28. package/dist/devTools/overlay-styles.d.ts.map +0 -1
  29. package/dist/devTools/overlay-styles.js +0 -706
  30. package/dist/devTools/overlay.d.ts +0 -63
  31. package/dist/devTools/overlay.d.ts.map +0 -1
  32. package/dist/devTools/overlay.js +0 -1244
  33. package/dist/test/apps/disabledButton.d.ts +0 -38
  34. package/dist/test/apps/disabledButton.d.ts.map +0 -1
  35. package/dist/test/apps/disabledButton.js +0 -71
  36. package/dist/ui/anchor.d.ts +0 -38
  37. package/dist/ui/anchor.d.ts.map +0 -1
  38. package/dist/ui/anchor.js +0 -142
  39. package/dist/ui/animation/index.d.ts +0 -49
  40. package/dist/ui/animation/index.d.ts.map +0 -1
  41. package/dist/ui/animation/index.js +0 -74
  42. package/dist/ui/animation/public.d.ts +0 -3
  43. package/dist/ui/animation/public.d.ts.map +0 -1
  44. package/dist/ui/animation/public.js +0 -1
  45. package/dist/ui/animation/schema.d.ts +0 -43
  46. package/dist/ui/animation/schema.d.ts.map +0 -1
  47. package/dist/ui/animation/schema.js +0 -41
  48. package/dist/ui/animation/update.d.ts +0 -24
  49. package/dist/ui/animation/update.d.ts.map +0 -1
  50. package/dist/ui/animation/update.js +0 -67
  51. package/dist/ui/button/index.d.ts +0 -17
  52. package/dist/ui/button/index.d.ts.map +0 -1
  53. package/dist/ui/button/index.js +0 -22
  54. package/dist/ui/button/public.d.ts +0 -3
  55. package/dist/ui/button/public.d.ts.map +0 -1
  56. package/dist/ui/button/public.js +0 -1
  57. package/dist/ui/calendar/index.d.ts +0 -462
  58. package/dist/ui/calendar/index.d.ts.map +0 -1
  59. package/dist/ui/calendar/index.js +0 -824
  60. package/dist/ui/calendar/public.d.ts +0 -3
  61. package/dist/ui/calendar/public.d.ts.map +0 -1
  62. package/dist/ui/calendar/public.js +0 -1
  63. package/dist/ui/checkbox/index.d.ts +0 -119
  64. package/dist/ui/checkbox/index.d.ts.map +0 -1
  65. package/dist/ui/checkbox/index.js +0 -110
  66. package/dist/ui/checkbox/public.d.ts +0 -3
  67. package/dist/ui/checkbox/public.d.ts.map +0 -1
  68. package/dist/ui/checkbox/public.js +0 -1
  69. package/dist/ui/combobox/multi.d.ts +0 -184
  70. package/dist/ui/combobox/multi.d.ts.map +0 -1
  71. package/dist/ui/combobox/multi.js +0 -81
  72. package/dist/ui/combobox/multiPublic.d.ts +0 -3
  73. package/dist/ui/combobox/multiPublic.d.ts.map +0 -1
  74. package/dist/ui/combobox/multiPublic.js +0 -1
  75. package/dist/ui/combobox/public.d.ts +0 -7
  76. package/dist/ui/combobox/public.d.ts.map +0 -1
  77. package/dist/ui/combobox/public.js +0 -3
  78. package/dist/ui/combobox/shared.d.ts +0 -422
  79. package/dist/ui/combobox/shared.d.ts.map +0 -1
  80. package/dist/ui/combobox/shared.js +0 -707
  81. package/dist/ui/combobox/single.d.ts +0 -199
  82. package/dist/ui/combobox/single.d.ts.map +0 -1
  83. package/dist/ui/combobox/single.js +0 -106
  84. package/dist/ui/datePicker/index.d.ts +0 -457
  85. package/dist/ui/datePicker/index.d.ts.map +0 -1
  86. package/dist/ui/datePicker/index.js +0 -317
  87. package/dist/ui/datePicker/public.d.ts +0 -3
  88. package/dist/ui/datePicker/public.d.ts.map +0 -1
  89. package/dist/ui/datePicker/public.js +0 -1
  90. package/dist/ui/dialog/index.d.ts +0 -155
  91. package/dist/ui/dialog/index.d.ts.map +0 -1
  92. package/dist/ui/dialog/index.js +0 -208
  93. package/dist/ui/dialog/public.d.ts +0 -3
  94. package/dist/ui/dialog/public.d.ts.map +0 -1
  95. package/dist/ui/dialog/public.js +0 -1
  96. package/dist/ui/disclosure/index.d.ts +0 -110
  97. package/dist/ui/disclosure/index.d.ts.map +0 -1
  98. package/dist/ui/disclosure/index.js +0 -110
  99. package/dist/ui/disclosure/public.d.ts +0 -3
  100. package/dist/ui/disclosure/public.d.ts.map +0 -1
  101. package/dist/ui/disclosure/public.js +0 -1
  102. package/dist/ui/dragAndDrop/index.d.ts +0 -540
  103. package/dist/ui/dragAndDrop/index.d.ts.map +0 -1
  104. package/dist/ui/dragAndDrop/index.js +0 -535
  105. package/dist/ui/dragAndDrop/public.d.ts +0 -3
  106. package/dist/ui/dragAndDrop/public.d.ts.map +0 -1
  107. package/dist/ui/dragAndDrop/public.js +0 -1
  108. package/dist/ui/fieldset/index.d.ts +0 -21
  109. package/dist/ui/fieldset/index.d.ts.map +0 -1
  110. package/dist/ui/fieldset/index.js +0 -25
  111. package/dist/ui/fieldset/public.d.ts +0 -3
  112. package/dist/ui/fieldset/public.d.ts.map +0 -1
  113. package/dist/ui/fieldset/public.js +0 -1
  114. package/dist/ui/fileDrop/index.d.ts +0 -109
  115. package/dist/ui/fileDrop/index.d.ts.map +0 -1
  116. package/dist/ui/fileDrop/index.js +0 -126
  117. package/dist/ui/fileDrop/public.d.ts +0 -3
  118. package/dist/ui/fileDrop/public.d.ts.map +0 -1
  119. package/dist/ui/fileDrop/public.js +0 -1
  120. package/dist/ui/group.d.ts +0 -8
  121. package/dist/ui/group.d.ts.map +0 -1
  122. package/dist/ui/group.js +0 -13
  123. package/dist/ui/index.d.ts +0 -25
  124. package/dist/ui/index.d.ts.map +0 -1
  125. package/dist/ui/index.js +0 -24
  126. package/dist/ui/input/index.d.ts +0 -26
  127. package/dist/ui/input/index.d.ts.map +0 -1
  128. package/dist/ui/input/index.js +0 -43
  129. package/dist/ui/input/public.d.ts +0 -3
  130. package/dist/ui/input/public.d.ts.map +0 -1
  131. package/dist/ui/input/public.js +0 -1
  132. package/dist/ui/keyboard.d.ts +0 -6
  133. package/dist/ui/keyboard.d.ts.map +0 -1
  134. package/dist/ui/keyboard.js +0 -9
  135. package/dist/ui/listbox/multi.d.ts +0 -190
  136. package/dist/ui/listbox/multi.d.ts.map +0 -1
  137. package/dist/ui/listbox/multi.js +0 -65
  138. package/dist/ui/listbox/multiPublic.d.ts +0 -3
  139. package/dist/ui/listbox/multiPublic.d.ts.map +0 -1
  140. package/dist/ui/listbox/multiPublic.js +0 -1
  141. package/dist/ui/listbox/public.d.ts +0 -7
  142. package/dist/ui/listbox/public.d.ts.map +0 -1
  143. package/dist/ui/listbox/public.js +0 -3
  144. package/dist/ui/listbox/shared.d.ts +0 -431
  145. package/dist/ui/listbox/shared.d.ts.map +0 -1
  146. package/dist/ui/listbox/shared.js +0 -669
  147. package/dist/ui/listbox/single.d.ts +0 -208
  148. package/dist/ui/listbox/single.d.ts.map +0 -1
  149. package/dist/ui/listbox/single.js +0 -73
  150. package/dist/ui/menu/index.d.ts +0 -367
  151. package/dist/ui/menu/index.d.ts.map +0 -1
  152. package/dist/ui/menu/index.js +0 -681
  153. package/dist/ui/menu/public.d.ts +0 -4
  154. package/dist/ui/menu/public.d.ts.map +0 -1
  155. package/dist/ui/menu/public.js +0 -1
  156. package/dist/ui/popover/index.d.ts +0 -267
  157. package/dist/ui/popover/index.d.ts.map +0 -1
  158. package/dist/ui/popover/index.js +0 -345
  159. package/dist/ui/popover/public.d.ts +0 -4
  160. package/dist/ui/popover/public.d.ts.map +0 -1
  161. package/dist/ui/popover/public.js +0 -1
  162. package/dist/ui/radioGroup/index.d.ts +0 -169
  163. package/dist/ui/radioGroup/index.d.ts.map +0 -1
  164. package/dist/ui/radioGroup/index.js +0 -196
  165. package/dist/ui/radioGroup/public.d.ts +0 -3
  166. package/dist/ui/radioGroup/public.d.ts.map +0 -1
  167. package/dist/ui/radioGroup/public.js +0 -1
  168. package/dist/ui/select/index.d.ts +0 -24
  169. package/dist/ui/select/index.d.ts.map +0 -1
  170. package/dist/ui/select/index.js +0 -40
  171. package/dist/ui/select/public.d.ts +0 -3
  172. package/dist/ui/select/public.d.ts.map +0 -1
  173. package/dist/ui/select/public.js +0 -1
  174. package/dist/ui/slider/index.d.ts +0 -318
  175. package/dist/ui/slider/index.d.ts.map +0 -1
  176. package/dist/ui/slider/index.js +0 -336
  177. package/dist/ui/slider/public.d.ts +0 -3
  178. package/dist/ui/slider/public.d.ts.map +0 -1
  179. package/dist/ui/slider/public.js +0 -1
  180. package/dist/ui/switch/index.d.ts +0 -99
  181. package/dist/ui/switch/index.d.ts.map +0 -1
  182. package/dist/ui/switch/index.js +0 -106
  183. package/dist/ui/switch/public.d.ts +0 -3
  184. package/dist/ui/switch/public.d.ts.map +0 -1
  185. package/dist/ui/switch/public.js +0 -1
  186. package/dist/ui/tabs/index.d.ts +0 -155
  187. package/dist/ui/tabs/index.d.ts.map +0 -1
  188. package/dist/ui/tabs/index.js +0 -184
  189. package/dist/ui/tabs/public.d.ts +0 -3
  190. package/dist/ui/tabs/public.d.ts.map +0 -1
  191. package/dist/ui/tabs/public.js +0 -1
  192. package/dist/ui/textarea/index.d.ts +0 -26
  193. package/dist/ui/textarea/index.d.ts.map +0 -1
  194. package/dist/ui/textarea/index.js +0 -44
  195. package/dist/ui/textarea/public.d.ts +0 -3
  196. package/dist/ui/textarea/public.d.ts.map +0 -1
  197. package/dist/ui/textarea/public.js +0 -1
  198. package/dist/ui/toast/index.d.ts +0 -608
  199. package/dist/ui/toast/index.d.ts.map +0 -1
  200. package/dist/ui/toast/index.js +0 -145
  201. package/dist/ui/toast/public.d.ts +0 -4
  202. package/dist/ui/toast/public.d.ts.map +0 -1
  203. package/dist/ui/toast/public.js +0 -1
  204. package/dist/ui/toast/schema.d.ts +0 -154
  205. package/dist/ui/toast/schema.d.ts.map +0 -1
  206. package/dist/ui/toast/schema.js +0 -93
  207. package/dist/ui/toast/update.d.ts +0 -510
  208. package/dist/ui/toast/update.d.ts.map +0 -1
  209. package/dist/ui/toast/update.js +0 -225
  210. package/dist/ui/tooltip/index.d.ts +0 -170
  211. package/dist/ui/tooltip/index.d.ts.map +0 -1
  212. package/dist/ui/tooltip/index.js +0 -252
  213. package/dist/ui/tooltip/public.d.ts +0 -4
  214. package/dist/ui/tooltip/public.d.ts.map +0 -1
  215. package/dist/ui/tooltip/public.js +0 -1
  216. package/dist/ui/typeahead.d.ts +0 -4
  217. package/dist/ui/typeahead.d.ts.map +0 -1
  218. package/dist/ui/typeahead.js +0 -14
  219. package/dist/ui/virtualList/index.d.ts +0 -202
  220. package/dist/ui/virtualList/index.d.ts.map +0 -1
  221. package/dist/ui/virtualList/index.js +0 -391
  222. package/dist/ui/virtualList/public.d.ts +0 -3
  223. package/dist/ui/virtualList/public.d.ts.map +0 -1
  224. package/dist/ui/virtualList/public.js +0 -1
@@ -1,199 +0,0 @@
1
- import { Option, Schema as S } from 'effect';
2
- import type * as Command from '../../command/index.js';
3
- import type { SubmodelView } from '../../html/index.js';
4
- import type { Reflect } from '../../submodel/submodel.js';
5
- import { type BaseInitConfig, type BaseViewInputs, type Message, type OutMessage } from './shared.js';
6
- /** Schema for the single-select combobox component's state, tracking open/closed status, active item, input value, selected item, and display text. */
7
- export declare const Model: S.Struct<{
8
- readonly maybeSelectedItem: S.Option<S.String>;
9
- readonly maybeSelectedDisplayText: S.Option<S.String>;
10
- readonly id: S.String;
11
- readonly isOpen: S.Boolean;
12
- readonly isAnimated: S.Boolean;
13
- readonly isModal: S.Boolean;
14
- readonly nullable: S.Boolean;
15
- readonly immediate: S.Boolean;
16
- readonly selectInputOnFocus: S.Boolean;
17
- readonly animation: S.Struct<{
18
- readonly id: S.String;
19
- readonly isShowing: S.Boolean;
20
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
21
- }>;
22
- readonly maybeActiveItemIndex: S.Option<S.Number>;
23
- readonly activationTrigger: S.Literals<readonly ["Pointer", "Keyboard"]>;
24
- readonly inputValue: S.String;
25
- readonly maybeLastPointerPosition: S.Option<S.Struct<{
26
- readonly screenX: S.Number;
27
- readonly screenY: S.Number;
28
- }>>;
29
- }>;
30
- export type Model = typeof Model.Type;
31
- /** Configuration for creating a single-select combobox model with `init`. `isAnimated` enables CSS transition coordination (default `false`). `isModal` locks page scroll and inerts other elements when open (default `false`). `selectedItem` sets the initial selection (default none). */
32
- export type InitConfig = BaseInitConfig & Readonly<{
33
- selectedItem?: string;
34
- selectedDisplayText?: string;
35
- }>;
36
- /** Creates an initial single-select combobox model from a config. Defaults to closed with no active item, empty input, and no selection. */
37
- export declare const init: (config: InitConfig) => Model;
38
- /** Processes a combobox message and returns the next model and commands. Closes the combobox on selection (single-select behavior). */
39
- export declare const update: (model: {
40
- readonly maybeSelectedItem: Option.Option<string>;
41
- readonly maybeSelectedDisplayText: Option.Option<string>;
42
- readonly id: string;
43
- readonly isOpen: boolean;
44
- readonly isAnimated: boolean;
45
- readonly isModal: boolean;
46
- readonly nullable: boolean;
47
- readonly immediate: boolean;
48
- readonly selectInputOnFocus: boolean;
49
- readonly animation: {
50
- readonly id: string;
51
- readonly isShowing: boolean;
52
- readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
53
- };
54
- readonly maybeActiveItemIndex: Option.Option<number>;
55
- readonly activationTrigger: "Pointer" | "Keyboard";
56
- readonly inputValue: string;
57
- readonly maybeLastPointerPosition: Option.Option<{
58
- readonly screenX: number;
59
- readonly screenY: number;
60
- }>;
61
- }, message: Message) => readonly [{
62
- readonly maybeSelectedItem: Option.Option<string>;
63
- readonly maybeSelectedDisplayText: Option.Option<string>;
64
- readonly id: string;
65
- readonly isOpen: boolean;
66
- readonly isAnimated: boolean;
67
- readonly isModal: boolean;
68
- readonly nullable: boolean;
69
- readonly immediate: boolean;
70
- readonly selectInputOnFocus: boolean;
71
- readonly animation: {
72
- readonly id: string;
73
- readonly isShowing: boolean;
74
- readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
75
- };
76
- readonly maybeActiveItemIndex: Option.Option<number>;
77
- readonly activationTrigger: "Pointer" | "Keyboard";
78
- readonly inputValue: string;
79
- readonly maybeLastPointerPosition: Option.Option<{
80
- readonly screenX: number;
81
- readonly screenY: number;
82
- }>;
83
- }, readonly Readonly<{
84
- name: string;
85
- args?: Record<string, unknown>;
86
- effect: import("effect/Effect").Effect<{
87
- readonly _tag: "Closed";
88
- } | {
89
- readonly _tag: "DeactivatedItem";
90
- } | {
91
- readonly _tag: "CompletedLockScroll";
92
- } | {
93
- readonly _tag: "CompletedUnlockScroll";
94
- } | {
95
- readonly _tag: "CompletedInertOthers";
96
- } | {
97
- readonly _tag: "CompletedRestoreInert";
98
- } | {
99
- readonly _tag: "CompletedScrollIntoView";
100
- } | {
101
- readonly _tag: "CompletedClickItem";
102
- } | {
103
- readonly _tag: "Opened";
104
- readonly maybeActiveItemIndex: Option.Option<number>;
105
- } | {
106
- readonly _tag: "BlurredInput";
107
- } | {
108
- readonly _tag: "ActivatedItem";
109
- readonly index: number;
110
- readonly activationTrigger: "Pointer" | "Keyboard";
111
- readonly maybeImmediateSelection: Option.Option<{
112
- readonly item: string;
113
- readonly displayText: string;
114
- }>;
115
- } | {
116
- readonly _tag: "SelectedItem";
117
- readonly item: string;
118
- readonly displayText: string;
119
- } | {
120
- readonly _tag: "MovedPointerOverItem";
121
- readonly index: number;
122
- readonly screenX: number;
123
- readonly screenY: number;
124
- } | {
125
- readonly _tag: "RequestedItemClick";
126
- readonly index: number;
127
- } | {
128
- readonly _tag: "CompletedFocusInput";
129
- } | {
130
- readonly _tag: "CompletedAnchorCombobox";
131
- } | {
132
- readonly _tag: "CompletedAttachComboboxPreventBlur";
133
- } | {
134
- readonly _tag: "CompletedAttachComboboxSelectOnFocus";
135
- } | {
136
- readonly _tag: "CompletedPortalComboboxBackdrop";
137
- } | {
138
- readonly _tag: "GotAnimationMessage";
139
- readonly message: {
140
- readonly _tag: "Showed";
141
- } | {
142
- readonly _tag: "Hid";
143
- } | {
144
- readonly _tag: "AdvancedAnimationFrame";
145
- } | {
146
- readonly _tag: "EndedAnimation";
147
- };
148
- } | {
149
- readonly _tag: "UpdatedInputValue";
150
- readonly value: string;
151
- } | {
152
- readonly _tag: "PressedToggleButton";
153
- }, never, never>;
154
- }>[], Option.Option<Readonly<{
155
- readonly _tag: "Selected";
156
- readonly value: string;
157
- readonly wasAdded: boolean;
158
- }>>];
159
- type UpdateReturn = ReturnType<typeof update>;
160
- /** Programmatically opens the combobox, updating the model and returning
161
- * focus and modal commands. Use this in domain-event handlers to open the combobox. */
162
- export declare const open: (model: Model) => UpdateReturn;
163
- /** Programmatically closes the combobox, updating the model and returning
164
- * focus and modal commands. Use this in domain-event handlers to close the combobox. */
165
- export declare const close: (model: Model) => UpdateReturn;
166
- /** Programmatically selects an item in the single-select combobox. Emits `Selected({ value, wasAdded })`. */
167
- export declare const selectItem: (model: Model, item: string, displayText: string) => UpdateReturn;
168
- /** Reflects an externally-sourced selection onto the model without
169
- * emitting an OutMessage or running selection side effects (no close, no
170
- * focus). Sets the selected item, its display text, and the input text
171
- * together, so the input shows the reflected selection. Pass
172
- * `Option.none()` to clear. Use this to mirror external truth (a URL
173
- * parameter, restored storage, a server push) onto the combobox.
174
- * Contrast with `selectItem`, a user/programmatic *choice* that emits
175
- * `Selected`. Returns the model directly because it produces no commands
176
- * and no OutMessage. */
177
- export declare const reflectSelectedItem: Reflect<Model, Option.Option<{
178
- readonly item: string;
179
- readonly displayText: string;
180
- }>>;
181
- /** Per-render view inputs passed to the view via `h.submodel`'s `viewInputs` field. */
182
- export type ViewInputs<Item extends string> = BaseViewInputs<Item>;
183
- /** Pairs the single-select combobox's `view` and `update` (and programmatic
184
- * helpers) behind a single Item-typed entry point. See `Ui.Listbox.create`
185
- * for the rationale; the combobox factory follows the same shape with
186
- * `selectItem` taking both `item` and `displayText`. */
187
- export declare const create: <Item extends string = string>() => Readonly<{
188
- view: SubmodelView<Model, Message, BaseViewInputs<Item>>;
189
- update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
190
- selectItem: (model: Model, item: Item, displayText: string) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
191
- open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
192
- close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Item>>];
193
- reflectSelectedItem: Reflect<Model, Option.Option<{
194
- readonly item: Item;
195
- readonly displayText: string;
196
- }>>;
197
- }>;
198
- export {};
199
- //# sourceMappingURL=single.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"single.d.ts","sourceRoot":"","sources":["../../../src/ui/combobox/single.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAE,MAAM,IAAI,CAAC,EAAQ,MAAM,QAAQ,CAAA;AAEnE,OAAO,KAAK,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,Y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BAAmB,EAAE,OAAO,CAC1B,KAAK,EACL,MAAM,CAAC,MAAM,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CACrE,CAAA;CACF,CAsBA,CAAA"}
@@ -1,106 +0,0 @@
1
- import { Array, Function, Option, Schema as S, pipe } from 'effect';
2
- import { evo } from '../../struct/index.js';
3
- import { BaseModel, Closed, Opened, SelectedItem, Selected as SharedSelected, baseInit, closedBaseModel, makeUpdate, makeView, } from './shared.js';
4
- // MODEL
5
- /** Schema for the single-select combobox component's state, tracking open/closed status, active item, input value, selected item, and display text. */
6
- export const Model = S.Struct({
7
- ...BaseModel.fields,
8
- maybeSelectedItem: S.Option(S.String),
9
- maybeSelectedDisplayText: S.Option(S.String),
10
- });
11
- /** Creates an initial single-select combobox model from a config. Defaults to closed with no active item, empty input, and no selection. */
12
- export const init = (config) => ({
13
- ...baseInit(config),
14
- maybeSelectedItem: Option.fromNullishOr(config.selectedItem),
15
- maybeSelectedDisplayText: Option.fromNullishOr(config.selectedDisplayText ?? config.selectedItem),
16
- });
17
- // UPDATE
18
- /** Processes a combobox message and returns the next model and commands. Closes the combobox on selection (single-select behavior). */
19
- export const update = makeUpdate({
20
- handleClose: model => {
21
- if (model.nullable && model.inputValue === '') {
22
- return evo(closedBaseModel(model), {
23
- maybeSelectedItem: () => Option.none(),
24
- maybeSelectedDisplayText: () => Option.none(),
25
- inputValue: () => '',
26
- });
27
- }
28
- return evo(closedBaseModel(model), {
29
- inputValue: () => Option.getOrElse(model.maybeSelectedDisplayText, () => ''),
30
- });
31
- },
32
- handleSelectedItem: (model, item, displayText, context) => {
33
- const isAlreadySelected = Option.exists(model.maybeSelectedItem, selectedItem => selectedItem === item);
34
- const nullableDeselect = model.nullable && isAlreadySelected;
35
- const nextModel = nullableDeselect
36
- ? evo(closedBaseModel(model), {
37
- inputValue: () => '',
38
- maybeSelectedItem: () => Option.none(),
39
- maybeSelectedDisplayText: () => Option.none(),
40
- })
41
- : evo(closedBaseModel(model), {
42
- inputValue: () => displayText,
43
- maybeSelectedItem: () => Option.some(item),
44
- maybeSelectedDisplayText: () => Option.some(displayText),
45
- });
46
- return [
47
- nextModel,
48
- pipe(Array.getSomes([context.maybeUnlockScroll, context.maybeRestoreInert]), Array.prepend(context.focusInput)),
49
- Option.some(SharedSelected({ value: item, wasAdded: !nullableDeselect })),
50
- ];
51
- },
52
- handleImmediateActivation: (model, item, displayText) => evo(model, {
53
- maybeSelectedItem: () => Option.some(item),
54
- maybeSelectedDisplayText: () => Option.some(displayText),
55
- }),
56
- });
57
- /** Programmatically opens the combobox, updating the model and returning
58
- * focus and modal commands. Use this in domain-event handlers to open the combobox. */
59
- export const open = (model) => update(model, Opened({ maybeActiveItemIndex: Option.none() }));
60
- /** Programmatically closes the combobox, updating the model and returning
61
- * focus and modal commands. Use this in domain-event handlers to close the combobox. */
62
- export const close = (model) => update(model, Closed());
63
- /** Programmatically selects an item in the single-select combobox. Emits `Selected({ value, wasAdded })`. */
64
- export const selectItem = (model, item, displayText) => update(model, SelectedItem({ item, displayText }));
65
- /** Reflects an externally-sourced selection onto the model without
66
- * emitting an OutMessage or running selection side effects (no close, no
67
- * focus). Sets the selected item, its display text, and the input text
68
- * together, so the input shows the reflected selection. Pass
69
- * `Option.none()` to clear. Use this to mirror external truth (a URL
70
- * parameter, restored storage, a server push) onto the combobox.
71
- * Contrast with `selectItem`, a user/programmatic *choice* that emits
72
- * `Selected`. Returns the model directly because it produces no commands
73
- * and no OutMessage. */
74
- export const reflectSelectedItem = Function.dual(2, (model, maybeSelection) => Option.match(maybeSelection, {
75
- onNone: () => evo(model, {
76
- maybeSelectedItem: () => Option.none(),
77
- maybeSelectedDisplayText: () => Option.none(),
78
- inputValue: () => '',
79
- }),
80
- onSome: ({ item, displayText }) => evo(model, {
81
- maybeSelectedItem: () => Option.some(item),
82
- maybeSelectedDisplayText: () => Option.some(displayText),
83
- inputValue: () => displayText,
84
- }),
85
- }));
86
- const internalView = makeView({
87
- isItemSelected: (model, itemValue) => Option.exists(model.maybeSelectedItem, selectedItem => selectedItem === itemValue),
88
- ariaMultiSelectable: false,
89
- });
90
- /** Pairs the single-select combobox's `view` and `update` (and programmatic
91
- * helpers) behind a single Item-typed entry point. See `Ui.Listbox.create`
92
- * for the rationale; the combobox factory follows the same shape with
93
- * `selectItem` taking both `item` and `displayText`. */
94
- export const create = () => {
95
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
96
- const typedUpdate = update;
97
- return {
98
- view: internalView(),
99
- update: typedUpdate,
100
- selectItem: (model, item, displayText) => typedUpdate(model, SelectedItem({ item, displayText })),
101
- open: model => typedUpdate(model, Opened({ maybeActiveItemIndex: Option.none() })),
102
- close: model => typedUpdate(model, Closed()),
103
- /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
104
- reflectSelectedItem: reflectSelectedItem,
105
- };
106
- };