foldkit 0.101.0 → 0.102.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.
Files changed (208) hide show
  1. package/README.md +2 -1
  2. package/dist/canvas/view.d.ts +1 -1
  3. package/dist/canvas/view.d.ts.map +1 -1
  4. package/dist/canvas/view.js +5 -5
  5. package/dist/command/index.d.ts +71 -0
  6. package/dist/command/index.d.ts.map +1 -1
  7. package/dist/command/index.js +34 -1
  8. package/dist/command/public.d.ts +1 -1
  9. package/dist/command/public.d.ts.map +1 -1
  10. package/dist/command/public.js +1 -1
  11. package/dist/devTools/overlay.d.ts.map +1 -1
  12. package/dist/devTools/overlay.js +137 -110
  13. package/dist/dom/dom.d.ts +8 -11
  14. package/dist/dom/dom.d.ts.map +1 -1
  15. package/dist/dom/dom.js +8 -11
  16. package/dist/dom/elementMovement.d.ts +1 -3
  17. package/dist/dom/elementMovement.d.ts.map +1 -1
  18. package/dist/dom/elementMovement.js +1 -3
  19. package/dist/dom/inert.d.ts +2 -4
  20. package/dist/dom/inert.d.ts.map +1 -1
  21. package/dist/dom/inert.js +2 -4
  22. package/dist/dom/scrollLock.d.ts +2 -2
  23. package/dist/dom/scrollLock.js +2 -2
  24. package/dist/dom/waitForAnimation.d.ts +1 -1
  25. package/dist/dom/waitForAnimation.js +1 -1
  26. package/dist/html/boundary.d.ts +98 -0
  27. package/dist/html/boundary.d.ts.map +1 -0
  28. package/dist/html/boundary.js +176 -0
  29. package/dist/html/childAttribute.d.ts +44 -0
  30. package/dist/html/childAttribute.d.ts.map +1 -0
  31. package/dist/html/childAttribute.js +34 -0
  32. package/dist/html/index.d.ts +70 -23
  33. package/dist/html/index.d.ts.map +1 -1
  34. package/dist/html/index.js +639 -575
  35. package/dist/html/lazy.d.ts +12 -7
  36. package/dist/html/lazy.d.ts.map +1 -1
  37. package/dist/html/lazy.js +30 -11
  38. package/dist/html/public.d.ts +2 -2
  39. package/dist/html/public.d.ts.map +1 -1
  40. package/dist/html/public.js +1 -1
  41. package/dist/html/runtimeSingleton.d.ts +72 -0
  42. package/dist/html/runtimeSingleton.d.ts.map +1 -0
  43. package/dist/html/runtimeSingleton.js +112 -0
  44. package/dist/html/submodel.d.ts +98 -0
  45. package/dist/html/submodel.d.ts.map +1 -0
  46. package/dist/html/submodel.js +190 -0
  47. package/dist/index.d.ts +1 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -0
  50. package/dist/render/render.d.ts +1 -1
  51. package/dist/render/render.js +1 -1
  52. package/dist/runtime/messagePriority.d.ts +5 -1
  53. package/dist/runtime/messagePriority.d.ts.map +1 -1
  54. package/dist/runtime/messagePriority.js +25 -4
  55. package/dist/runtime/runtime.d.ts +1 -1
  56. package/dist/runtime/runtime.d.ts.map +1 -1
  57. package/dist/runtime/runtime.js +115 -61
  58. package/dist/submodel/public.d.ts +4 -0
  59. package/dist/submodel/public.d.ts.map +1 -0
  60. package/dist/submodel/public.js +1 -0
  61. package/dist/submodel/submodel.d.ts +32 -0
  62. package/dist/submodel/submodel.d.ts.map +1 -0
  63. package/dist/submodel/submodel.js +1 -0
  64. package/dist/test/apps/disabledButton.d.ts +4 -5
  65. package/dist/test/apps/disabledButton.d.ts.map +1 -1
  66. package/dist/test/apps/disabledButton.js +16 -16
  67. package/dist/test/scene.d.ts +8 -8
  68. package/dist/test/scene.d.ts.map +1 -1
  69. package/dist/test/scene.js +25 -13
  70. package/dist/test/story.d.ts +15 -8
  71. package/dist/test/story.d.ts.map +1 -1
  72. package/dist/test/story.js +21 -9
  73. package/dist/ui/animation/index.d.ts +30 -14
  74. package/dist/ui/animation/index.d.ts.map +1 -1
  75. package/dist/ui/animation/index.js +9 -19
  76. package/dist/ui/animation/public.d.ts +2 -2
  77. package/dist/ui/animation/public.d.ts.map +1 -1
  78. package/dist/ui/animation/public.js +1 -1
  79. package/dist/ui/calendar/index.d.ts +199 -84
  80. package/dist/ui/calendar/index.d.ts.map +1 -1
  81. package/dist/ui/calendar/index.js +129 -140
  82. package/dist/ui/calendar/public.d.ts +2 -2
  83. package/dist/ui/calendar/public.d.ts.map +1 -1
  84. package/dist/ui/calendar/public.js +1 -1
  85. package/dist/ui/checkbox/index.d.ts +93 -21
  86. package/dist/ui/checkbox/index.d.ts.map +1 -1
  87. package/dist/ui/checkbox/index.js +62 -33
  88. package/dist/ui/checkbox/public.d.ts +2 -2
  89. package/dist/ui/checkbox/public.d.ts.map +1 -1
  90. package/dist/ui/checkbox/public.js +1 -1
  91. package/dist/ui/combobox/multi.d.ts +35 -91
  92. package/dist/ui/combobox/multi.d.ts.map +1 -1
  93. package/dist/ui/combobox/multi.js +34 -17
  94. package/dist/ui/combobox/multiPublic.d.ts +2 -2
  95. package/dist/ui/combobox/multiPublic.d.ts.map +1 -1
  96. package/dist/ui/combobox/multiPublic.js +1 -1
  97. package/dist/ui/combobox/public.d.ts +3 -3
  98. package/dist/ui/combobox/public.d.ts.map +1 -1
  99. package/dist/ui/combobox/public.js +2 -2
  100. package/dist/ui/combobox/shared.d.ts +56 -31
  101. package/dist/ui/combobox/shared.d.ts.map +1 -1
  102. package/dist/ui/combobox/shared.js +333 -322
  103. package/dist/ui/combobox/single.d.ts +46 -93
  104. package/dist/ui/combobox/single.d.ts.map +1 -1
  105. package/dist/ui/combobox/single.js +44 -17
  106. package/dist/ui/datePicker/index.d.ts +256 -48
  107. package/dist/ui/datePicker/index.d.ts.map +1 -1
  108. package/dist/ui/datePicker/index.js +149 -104
  109. package/dist/ui/datePicker/public.d.ts +2 -2
  110. package/dist/ui/datePicker/public.d.ts.map +1 -1
  111. package/dist/ui/datePicker/public.js +1 -1
  112. package/dist/ui/dialog/index.d.ts +95 -39
  113. package/dist/ui/dialog/index.d.ts.map +1 -1
  114. package/dist/ui/dialog/index.js +71 -62
  115. package/dist/ui/dialog/public.d.ts +2 -2
  116. package/dist/ui/dialog/public.d.ts.map +1 -1
  117. package/dist/ui/dialog/public.js +1 -1
  118. package/dist/ui/disclosure/index.d.ts +71 -31
  119. package/dist/ui/disclosure/index.d.ts.map +1 -1
  120. package/dist/ui/disclosure/index.js +57 -62
  121. package/dist/ui/disclosure/public.d.ts +2 -2
  122. package/dist/ui/disclosure/public.d.ts.map +1 -1
  123. package/dist/ui/disclosure/public.js +1 -1
  124. package/dist/ui/dragAndDrop/index.d.ts +6 -6
  125. package/dist/ui/dragAndDrop/index.d.ts.map +1 -1
  126. package/dist/ui/dragAndDrop/index.js +7 -7
  127. package/dist/ui/dragAndDrop/public.d.ts +1 -1
  128. package/dist/ui/dragAndDrop/public.d.ts.map +1 -1
  129. package/dist/ui/dragAndDrop/public.js +1 -1
  130. package/dist/ui/fileDrop/index.d.ts +42 -46
  131. package/dist/ui/fileDrop/index.d.ts.map +1 -1
  132. package/dist/ui/fileDrop/index.js +30 -46
  133. package/dist/ui/fileDrop/public.d.ts +2 -2
  134. package/dist/ui/fileDrop/public.d.ts.map +1 -1
  135. package/dist/ui/fileDrop/public.js +1 -1
  136. package/dist/ui/listbox/multi.d.ts +39 -84
  137. package/dist/ui/listbox/multi.d.ts.map +1 -1
  138. package/dist/ui/listbox/multi.js +38 -20
  139. package/dist/ui/listbox/multiPublic.d.ts +2 -2
  140. package/dist/ui/listbox/multiPublic.d.ts.map +1 -1
  141. package/dist/ui/listbox/multiPublic.js +1 -1
  142. package/dist/ui/listbox/public.d.ts +3 -3
  143. package/dist/ui/listbox/public.d.ts.map +1 -1
  144. package/dist/ui/listbox/public.js +2 -2
  145. package/dist/ui/listbox/shared.d.ts +71 -30
  146. package/dist/ui/listbox/shared.d.ts.map +1 -1
  147. package/dist/ui/listbox/shared.js +319 -296
  148. package/dist/ui/listbox/single.d.ts +57 -85
  149. package/dist/ui/listbox/single.d.ts.map +1 -1
  150. package/dist/ui/listbox/single.js +48 -24
  151. package/dist/ui/menu/index.d.ts +80 -36
  152. package/dist/ui/menu/index.d.ts.map +1 -1
  153. package/dist/ui/menu/index.js +117 -86
  154. package/dist/ui/menu/public.d.ts +2 -2
  155. package/dist/ui/menu/public.d.ts.map +1 -1
  156. package/dist/ui/menu/public.js +1 -1
  157. package/dist/ui/popover/index.d.ts +117 -44
  158. package/dist/ui/popover/index.d.ts.map +1 -1
  159. package/dist/ui/popover/index.js +88 -101
  160. package/dist/ui/popover/public.d.ts +2 -2
  161. package/dist/ui/popover/public.d.ts.map +1 -1
  162. package/dist/ui/popover/public.js +1 -1
  163. package/dist/ui/radioGroup/index.d.ts +122 -45
  164. package/dist/ui/radioGroup/index.d.ts.map +1 -1
  165. package/dist/ui/radioGroup/index.js +111 -72
  166. package/dist/ui/radioGroup/public.d.ts +2 -2
  167. package/dist/ui/radioGroup/public.d.ts.map +1 -1
  168. package/dist/ui/radioGroup/public.js +1 -1
  169. package/dist/ui/slider/index.d.ts +72 -34
  170. package/dist/ui/slider/index.d.ts.map +1 -1
  171. package/dist/ui/slider/index.js +40 -49
  172. package/dist/ui/slider/public.d.ts +2 -2
  173. package/dist/ui/slider/public.d.ts.map +1 -1
  174. package/dist/ui/slider/public.js +1 -1
  175. package/dist/ui/switch/index.d.ts +74 -21
  176. package/dist/ui/switch/index.d.ts.map +1 -1
  177. package/dist/ui/switch/index.js +62 -33
  178. package/dist/ui/switch/public.d.ts +2 -2
  179. package/dist/ui/switch/public.d.ts.map +1 -1
  180. package/dist/ui/switch/public.js +1 -1
  181. package/dist/ui/tabs/index.d.ts +107 -45
  182. package/dist/ui/tabs/index.d.ts.map +1 -1
  183. package/dist/ui/tabs/index.js +99 -81
  184. package/dist/ui/tabs/public.d.ts +2 -2
  185. package/dist/ui/tabs/public.d.ts.map +1 -1
  186. package/dist/ui/tabs/public.js +1 -1
  187. package/dist/ui/toast/index.d.ts +93 -109
  188. package/dist/ui/toast/index.d.ts.map +1 -1
  189. package/dist/ui/toast/index.js +16 -29
  190. package/dist/ui/toast/schema.d.ts +15 -4
  191. package/dist/ui/toast/schema.d.ts.map +1 -1
  192. package/dist/ui/toast/schema.js +11 -4
  193. package/dist/ui/toast/update.d.ts +36 -18
  194. package/dist/ui/toast/update.d.ts.map +1 -1
  195. package/dist/ui/toast/update.js +33 -14
  196. package/dist/ui/tooltip/index.d.ts +94 -42
  197. package/dist/ui/tooltip/index.d.ts.map +1 -1
  198. package/dist/ui/tooltip/index.js +64 -73
  199. package/dist/ui/tooltip/public.d.ts +2 -2
  200. package/dist/ui/tooltip/public.d.ts.map +1 -1
  201. package/dist/ui/tooltip/public.js +1 -1
  202. package/dist/ui/virtualList/index.d.ts +18 -41
  203. package/dist/ui/virtualList/index.d.ts.map +1 -1
  204. package/dist/ui/virtualList/index.js +17 -37
  205. package/dist/ui/virtualList/public.d.ts +2 -2
  206. package/dist/ui/virtualList/public.d.ts.map +1 -1
  207. package/dist/ui/virtualList/public.js +1 -1
  208. package/package.json +1 -1
@@ -96,7 +96,7 @@ export const PressedArrowKey = m('PressedArrowKey', {
96
96
  ]),
97
97
  });
98
98
  /** An animation frame fired during auto-scroll. */
99
- export const CompletedAutoScroll = m('CompletedAutoScroll');
99
+ export const AdvancedAutoScrollFrame = m('AdvancedAutoScrollFrame');
100
100
  /** The FocusItem Command completed. */
101
101
  export const CompletedFocusItem = m('CompletedFocusItem');
102
102
  /** Union of all messages the drag-and-drop component can produce. */
@@ -109,12 +109,12 @@ export const Message = S.Union([
109
109
  ResolvedKeyboardMove,
110
110
  ConfirmedKeyboardDrop,
111
111
  PressedArrowKey,
112
- CompletedAutoScroll,
112
+ AdvancedAutoScrollFrame,
113
113
  CompletedFocusItem,
114
114
  ]);
115
115
  // OUT MESSAGE
116
116
  /** Emitted when a drag completes with a valid drop target. The parent uses this to commit the reorder. */
117
- export const Reordered = ts('Reordered', {
117
+ export const Reordered = m('Reordered', {
118
118
  itemId: S.String,
119
119
  fromContainerId: S.String,
120
120
  fromIndex: S.Number,
@@ -122,7 +122,7 @@ export const Reordered = ts('Reordered', {
122
122
  toIndex: S.Number,
123
123
  });
124
124
  /** Emitted when a drag is cancelled via Escape or pointer release without a drop target. */
125
- export const Cancelled = ts('Cancelled');
125
+ export const Cancelled = m('Cancelled');
126
126
  /** Union of all out-messages the drag-and-drop component can emit to its parent. */
127
127
  export const OutMessage = S.Union([Reordered, Cancelled]);
128
128
  // INIT
@@ -323,7 +323,7 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
323
323
  ],
324
324
  Option.none(),
325
325
  ]), M.orElse(() => [model, [], Option.none()])),
326
- CompletedAutoScroll: () => [model, [], Option.none()],
326
+ AdvancedAutoScrollFrame: () => [model, [], Option.none()],
327
327
  CompletedFocusItem: () => [model, [], Option.none()],
328
328
  }));
329
329
  // SUBSCRIPTION
@@ -413,7 +413,7 @@ export const subscriptions = Subscription.make()(entry => ({
413
413
  }),
414
414
  dependenciesToStream: ({ dragActivity }) => Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.mapEffect((event) => Effect.sync(() => {
415
415
  // NOTE: the draggable's OnKeyDownPreventDefault calls preventDefault on
416
- // the Space that activates keyboard drag skip it here so the same
416
+ // the Space that activates keyboard drag. Skip it here so the same
417
417
  // keypress doesn't also confirm the drop in the same tick.
418
418
  if (event.defaultPrevented) {
419
419
  return Option.none();
@@ -453,7 +453,7 @@ export const subscriptions = Subscription.make()(entry => ({
453
453
  const ref = { id: 0 };
454
454
  const step = () => {
455
455
  autoScroll(readDependencies().clientY);
456
- Queue.offerUnsafe(queue, CompletedAutoScroll());
456
+ Queue.offerUnsafe(queue, AdvancedAutoScrollFrame());
457
457
  ref.id = requestAnimationFrame(step);
458
458
  };
459
459
  ref.id = requestAnimationFrame(step);
@@ -1,3 +1,3 @@
1
- export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, CompletedAutoScroll, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
1
+ export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, AdvancedAutoScrollFrame, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
2
2
  export type { InitConfig, DraggableConfig, DraggableMessage } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/dragAndDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/dragAndDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, CompletedAutoScroll, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
1
+ export { init, update, draggable, droppable, sortable, ghostStyle, isDragging, maybeDraggedItemId, maybeDropTarget, subscriptions, Model, Message, OutMessage, PressedDraggable, MovedPointer, ReleasedPointer, CancelledDrag, ActivatedKeyboardDrag, ResolvedKeyboardMove, ConfirmedKeyboardDrop, PressedArrowKey, AdvancedAutoScrollFrame, CompletedFocusItem, FocusItem, ResolveKeyboardMove, Reordered, Cancelled, } from './index.js';
@@ -1,6 +1,6 @@
1
1
  import { Option, Schema as S } from 'effect';
2
2
  import * as Command from '../../command/index.js';
3
- import { type Attribute, type Html } from '../../html/index.js';
3
+ import { type ChildAttribute, type Html } from '../../html/index.js';
4
4
  /** Schema for the file-drop component's state.
5
5
  *
6
6
  * `isDragOver` controls the `data-drag-over` attribute on the root while a
@@ -25,16 +25,16 @@ export declare const LeftDragZone: import("../../schema/index.js").CallableTagge
25
25
  export declare const DroppedFiles: import("../../schema/index.js").CallableTaggedStruct<"DroppedFiles", {
26
26
  files: S.NonEmptyArray<S.Schema<File>>;
27
27
  }>;
28
- /** Sent when a drop or input-change event fires without any files
28
+ /** Sent when a drop or input-change event fires without any files,
29
29
  * typically a drag of non-file data (text, URLs, images from another
30
- * page). Resets `isDragOver` and emits `DroppedWithoutFiles` as an
30
+ * page). Resets `isDragOver` and emits `RejectedNonFiles` as an
31
31
  * OutMessage so the consumer can surface a message (e.g. "Only files are
32
32
  * accepted"). */
33
- export declare const DroppedWithoutFiles: import("../../schema/index.js").CallableTaggedStruct<"DroppedWithoutFiles", {}>;
33
+ export declare const DroppedNonFiles: import("../../schema/index.js").CallableTaggedStruct<"DroppedNonFiles", {}>;
34
34
  /** Union of all messages the file-drop component can produce. */
35
35
  export declare const Message: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"EnteredDragZone", {}>, import("../../schema/index.js").CallableTaggedStruct<"LeftDragZone", {}>, import("../../schema/index.js").CallableTaggedStruct<"DroppedFiles", {
36
36
  files: S.NonEmptyArray<S.Schema<File>>;
37
- }>, import("../../schema/index.js").CallableTaggedStruct<"DroppedWithoutFiles", {}>]>;
37
+ }>, import("../../schema/index.js").CallableTaggedStruct<"DroppedNonFiles", {}>]>;
38
38
  export type Message = typeof Message.Type;
39
39
  /** Emitted when files arrive via drop or input-change. The consumer's
40
40
  * parent update handles this to process the files (validate, upload,
@@ -42,14 +42,15 @@ export type Message = typeof Message.Type;
42
42
  export declare const ReceivedFiles: import("../../schema/index.js").CallableTaggedStruct<"ReceivedFiles", {
43
43
  files: S.NonEmptyArray<S.Schema<File>>;
44
44
  }>;
45
+ /** Emitted when a drop or input-change event produces no files. The
46
+ * consumer's parent update handles this to surface a message (e.g. "Only
47
+ * files are accepted"). */
48
+ export declare const RejectedNonFiles: import("../../schema/index.js").CallableTaggedStruct<"RejectedNonFiles", {}>;
45
49
  /** The file-drop component's OutMessages: `ReceivedFiles` on the happy
46
- * path and `DroppedWithoutFiles` when a drop event fires without files.
47
- * `DroppedWithoutFiles` is reused from the Message definitions — the
48
- * fact is the same whether the component is handling it or reporting it
49
- * up. */
50
+ * path and `RejectedNonFiles` when a drop event fires without files. */
50
51
  export declare const OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"ReceivedFiles", {
51
52
  files: S.NonEmptyArray<S.Schema<File>>;
52
- }>, import("../../schema/index.js").CallableTaggedStruct<"DroppedWithoutFiles", {}>]>;
53
+ }>, import("../../schema/index.js").CallableTaggedStruct<"RejectedNonFiles", {}>]>;
53
54
  export type OutMessage = typeof OutMessage.Type;
54
55
  /** Configuration for creating a file-drop model with `init`. */
55
56
  export type InitConfig = Readonly<{
@@ -66,48 +67,43 @@ type UpdateReturn = readonly [
66
67
  * and optional OutMessage. */
67
68
  export declare const update: (model: Model, message: Message) => UpdateReturn;
68
69
  /** Attribute groups the file-drop component provides to the consumer's
69
- * `toView` callback. Spread each group onto the element that plays that
70
- * role: `root` typically goes on a `<label>` so clicking it focuses the
71
- * hidden input, `input` on the `<input type="file">`. */
72
- export type FileDropAttributes<ParentMessage> = Readonly<{
70
+ * `toView` callback. */
71
+ export type FileDropAttributes = Readonly<{
73
72
  /** Attributes for the outer drop zone element (typically a `<label>`):
74
- * drag-and-drop handlers, `data-drag-over` while a drag hovers, and
75
- * `data-disabled` when disabled. */
76
- root: ReadonlyArray<Attribute<ParentMessage>>;
73
+ * drag-and-drop handlers, `data-drag-over` while a drag hovers, and
74
+ * `data-disabled` when disabled. */
75
+ root: ReadonlyArray<ChildAttribute>;
77
76
  /** Attributes for a hidden `<input type="file">` nested inside the
78
- * root: file-change handler, `type`, `id`, `multiple`, `accept`, and
79
- * `sr-only` class. */
80
- input: ReadonlyArray<Attribute<ParentMessage>>;
77
+ * root: file-change handler, `type`, `id`, `multiple`, `accept`, and
78
+ * `sr-only` class. */
79
+ input: ReadonlyArray<ChildAttribute>;
81
80
  }>;
82
- /** Configuration for rendering a file-drop with `view`.
83
- *
84
- * The `ParentMessage` type parameter is your parent's Message type, not
85
- * FileDrop's. `toParentMessage` receives a FileDrop message and returns
86
- * your parent message. */
87
- export type ViewConfig<ParentMessage> = Readonly<{
88
- model: Model;
89
- toParentMessage: (message: Message) => ParentMessage;
90
- toView: (attributes: FileDropAttributes<ParentMessage>) => Html;
91
- /** List of accepted MIME types or file extensions (e.g.
92
- * `['application/pdf', '.doc']`). Joined with commas and forwarded to
93
- * the hidden input's `accept` attribute. Omit or pass an empty array
94
- * to accept any file type. */
81
+ /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */
82
+ export type ViewInputs = Readonly<{
83
+ toView: (attributes: FileDropAttributes) => Html;
95
84
  accept?: ReadonlyArray<string>;
96
- /** When true, the hidden input accepts multiple files per selection. */
97
85
  multiple?: boolean;
98
- /** When true, drag handlers are stripped from the root and the input
99
- * is disabled. Styling can react via `data-disabled` on the root. */
100
86
  isDisabled?: boolean;
101
87
  }>;
102
- /** Renders an accessible file-drop zone by building attribute groups for
103
- * a `<label>`-wrapped hidden file input. The consumer's `toView` callback
104
- * composes those groups into concrete markup. The component owns the
105
- * drag-state and file-arrival messaging; the consumer owns the visual
106
- * rendering. */
107
- export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>) => Html;
108
- /** Creates a memoized file-drop view. Static config is captured in a
109
- * closure; only `model` and `toParentMessage` are compared per render via
110
- * `createLazy`. */
111
- export declare const lazy: <ParentMessage>(staticConfig: Omit<ViewConfig<ParentMessage>, "model" | "toParentMessage">) => ((model: Model, toParentMessage: ViewConfig<ParentMessage>["toParentMessage"]) => Html);
88
+ /** Renders an accessible file-drop zone by publishing attribute groups
89
+ * for a `<label>`-wrapped hidden file input. */
90
+ export declare const view: import("../../html/submodel.js").SubmodelView<{
91
+ readonly id: string;
92
+ readonly isDragOver: boolean;
93
+ }, {
94
+ readonly _tag: "EnteredDragZone";
95
+ } | {
96
+ readonly _tag: "LeftDragZone";
97
+ } | {
98
+ readonly _tag: "DroppedFiles";
99
+ readonly files: readonly [File, ...File[]];
100
+ } | {
101
+ readonly _tag: "DroppedNonFiles";
102
+ }, Readonly<{
103
+ toView: (attributes: FileDropAttributes) => Html;
104
+ accept?: ReadonlyArray<string>;
105
+ multiple?: boolean;
106
+ isDisabled?: boolean;
107
+ }>>;
112
108
  export {};
113
109
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src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AAE,SAAS,OAAO,KAAG,YAyBrD,CAAA;AAIH;yBACyB;AACzB,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC;;yCAEqC;IACrC,IAAI,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACnC;;2BAEuB;IACvB,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CACrC,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,UAAU,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC,CAAA;AAQF;iDACiD;AACjD,eAAO,MAAM,IAAI;;;;;;;;;;;;;YAdP,CAAC,UAAU,EAAE,kBAAkB,KAAK,IAAI;aACvC,aAAa,CAAC,MAAM,CAAC;eACnB,OAAO;iBACL,OAAO;GAmDrB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Array, Match as M, Option, Schema as S } from 'effect';
2
2
  import * as File from '../../file/index.js';
3
- import { createLazy, html, } from '../../html/index.js';
3
+ import { childAttributes, defineView, html, } from '../../html/index.js';
4
4
  import { m } from '../../message/index.js';
5
5
  import { evo } from '../../struct/index.js';
6
6
  // MODEL
@@ -28,18 +28,18 @@ export const LeftDragZone = m('LeftDragZone');
28
28
  export const DroppedFiles = m('DroppedFiles', {
29
29
  files: S.NonEmptyArray(File.File),
30
30
  });
31
- /** Sent when a drop or input-change event fires without any files
31
+ /** Sent when a drop or input-change event fires without any files,
32
32
  * typically a drag of non-file data (text, URLs, images from another
33
- * page). Resets `isDragOver` and emits `DroppedWithoutFiles` as an
33
+ * page). Resets `isDragOver` and emits `RejectedNonFiles` as an
34
34
  * OutMessage so the consumer can surface a message (e.g. "Only files are
35
35
  * accepted"). */
36
- export const DroppedWithoutFiles = m('DroppedWithoutFiles');
36
+ export const DroppedNonFiles = m('DroppedNonFiles');
37
37
  /** Union of all messages the file-drop component can produce. */
38
38
  export const Message = S.Union([
39
39
  EnteredDragZone,
40
40
  LeftDragZone,
41
41
  DroppedFiles,
42
- DroppedWithoutFiles,
42
+ DroppedNonFiles,
43
43
  ]);
44
44
  // OUT MESSAGE
45
45
  /** Emitted when files arrive via drop or input-change. The consumer's
@@ -48,12 +48,13 @@ export const Message = S.Union([
48
48
  export const ReceivedFiles = m('ReceivedFiles', {
49
49
  files: S.NonEmptyArray(File.File),
50
50
  });
51
+ /** Emitted when a drop or input-change event produces no files. The
52
+ * consumer's parent update handles this to surface a message (e.g. "Only
53
+ * files are accepted"). */
54
+ export const RejectedNonFiles = m('RejectedNonFiles');
51
55
  /** The file-drop component's OutMessages: `ReceivedFiles` on the happy
52
- * path and `DroppedWithoutFiles` when a drop event fires without files.
53
- * `DroppedWithoutFiles` is reused from the Message definitions — the
54
- * fact is the same whether the component is handling it or reporting it
55
- * up. */
56
- export const OutMessage = S.Union([ReceivedFiles, DroppedWithoutFiles]);
56
+ * path and `RejectedNonFiles` when a drop event fires without files. */
57
+ export const OutMessage = S.Union([ReceivedFiles, RejectedNonFiles]);
57
58
  /** Creates an initial file-drop model. Drag state starts cleared. */
58
59
  export const init = (config) => ({
59
60
  id: config.id,
@@ -77,20 +78,22 @@ export const update = (model, message) => M.value(message).pipe(M.withReturnType
77
78
  [],
78
79
  Option.some(ReceivedFiles({ files })),
79
80
  ],
80
- DroppedWithoutFiles: () => [
81
+ DroppedNonFiles: () => [
81
82
  evo(model, { isDragOver: () => false }),
82
83
  [],
83
- Option.some(DroppedWithoutFiles()),
84
+ Option.some(RejectedNonFiles()),
84
85
  ],
85
86
  }));
86
- /** Renders an accessible file-drop zone by building attribute groups for
87
- * a `<label>`-wrapped hidden file input. The consumer's `toView` callback
88
- * composes those groups into concrete markup. The component owns the
89
- * drag-state and file-arrival messaging; the consumer owns the visual
90
- * rendering. */
91
- export const view = (config) => {
87
+ const dispatchDroppedFiles = (files) => Array.match(files, {
88
+ onEmpty: () => DroppedNonFiles(),
89
+ onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
90
+ });
91
+ /** Renders an accessible file-drop zone by publishing attribute groups
92
+ * for a `<label>`-wrapped hidden file input. */
93
+ export const view = defineView((model, viewInputs) => {
92
94
  const h = html();
93
- const { model: { id, isDragOver }, toParentMessage, accept, multiple = false, isDisabled = false, } = config;
95
+ const { id, isDragOver } = model;
96
+ const { toView, accept, multiple = false, isDisabled = false } = viewInputs;
94
97
  const stateAttributes = [
95
98
  ...(isDragOver ? [h.DataAttribute('drag-over', '')] : []),
96
99
  ...(isDisabled ? [h.DataAttribute('disabled', '')] : []),
@@ -99,13 +102,10 @@ export const view = (config) => {
99
102
  ? stateAttributes
100
103
  : [
101
104
  ...stateAttributes,
102
- h.OnDragEnter(toParentMessage(EnteredDragZone())),
103
- h.OnDragLeave(toParentMessage(LeftDragZone())),
105
+ h.OnDragEnter(EnteredDragZone()),
106
+ h.OnDragLeave(LeftDragZone()),
104
107
  h.AllowDrop(),
105
- h.OnDropFiles(files => toParentMessage(Array.match(files, {
106
- onEmpty: () => DroppedWithoutFiles(),
107
- onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
108
- }))),
108
+ h.OnDropFiles(dispatchDroppedFiles),
109
109
  ];
110
110
  const inputAttributes = [
111
111
  h.Id(id),
@@ -117,26 +117,10 @@ export const view = (config) => {
117
117
  : []),
118
118
  ...(isDisabled
119
119
  ? [h.Disabled(true)]
120
- : [
121
- h.OnFileChange(files => toParentMessage(Array.match(files, {
122
- onEmpty: () => DroppedWithoutFiles(),
123
- onNonEmpty: nonEmptyFiles => DroppedFiles({ files: [...nonEmptyFiles] }),
124
- }))),
125
- ]),
120
+ : [h.OnFileChange(dispatchDroppedFiles)]),
126
121
  ];
127
- return config.toView({
128
- root: rootAttributes,
129
- input: inputAttributes,
122
+ return toView({
123
+ root: childAttributes(rootAttributes),
124
+ input: childAttributes(inputAttributes),
130
125
  });
131
- };
132
- /** Creates a memoized file-drop view. Static config is captured in a
133
- * closure; only `model` and `toParentMessage` are compared per render via
134
- * `createLazy`. */
135
- export const lazy = (staticConfig) => {
136
- const lazyView = createLazy();
137
- return (model, toParentMessage) => lazyView((currentModel, currentToParentMessage) => view({
138
- ...staticConfig,
139
- model: currentModel,
140
- toParentMessage: currentToParentMessage,
141
- }), [model, toParentMessage]);
142
- };
126
+ });
@@ -1,3 +1,3 @@
1
- export { init, update, view, lazy, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedWithoutFiles, } from './index.js';
2
- export type { InitConfig, ViewConfig, FileDropAttributes } from './index.js';
1
+ export { init, update, view, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedNonFiles, RejectedNonFiles, } from './index.js';
2
+ export type { InitConfig, ViewInputs, FileDropAttributes } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/fileDrop/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { init, update, view, lazy, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedWithoutFiles, } from './index.js';
1
+ export { init, update, view, Model, Message, OutMessage, ReceivedFiles, EnteredDragZone, LeftDragZone, DroppedFiles, DroppedNonFiles, RejectedNonFiles, } from './index.js';
@@ -1,7 +1,8 @@
1
1
  import { Option, Schema as S } from 'effect';
2
2
  import type * as Command from '../../command/index.js';
3
- import { type Html } from '../../html/index.js';
4
- import { type BaseInitConfig, type BaseViewConfig, Closed, type Message, Opened, SelectedItem } from './shared.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';
5
6
  /** Schema for the multi-select listbox component's state, tracking open/closed status, active item, selected items, activation trigger, and typeahead search. */
6
7
  export declare const Model: S.Struct<{
7
8
  readonly selectedItems: S.$Array<S.String>;
@@ -32,7 +33,7 @@ export type InitConfig = BaseInitConfig & Readonly<{
32
33
  }>;
33
34
  /** Creates an initial multi-select listbox model from a config. Defaults to closed with no active item and no selection. */
34
35
  export declare const init: (config: InitConfig) => Model;
35
- /** Processes a listbox message and returns the next model and commands. Stays open on selection and toggles item membership (multi-select behavior). */
36
+ /** Processes a listbox message and returns the next model, commands, and optional OutMessage. Stays open on selection and toggles item membership (multi-select behavior); emits a `Selected({ value, wasAdded })` OutMessage indicating whether the value was added or removed. */
36
37
  export declare const update: (model: {
37
38
  readonly selectedItems: readonly string[];
38
39
  readonly id: string;
@@ -114,9 +115,9 @@ export declare const update: (model: {
114
115
  } | {
115
116
  readonly _tag: "CompletedUnlockScroll";
116
117
  } | {
117
- readonly _tag: "CompletedSetupInert";
118
+ readonly _tag: "CompletedInertOthers";
118
119
  } | {
119
- readonly _tag: "CompletedTeardownInert";
120
+ readonly _tag: "CompletedRestoreInert";
120
121
  } | {
121
122
  readonly _tag: "CompletedFocusButton";
122
123
  } | {
@@ -149,87 +150,41 @@ export declare const update: (model: {
149
150
  readonly pointerType: string;
150
151
  readonly button: number;
151
152
  }, never, never>;
152
- }>[]];
153
+ }>[], Option.Option<Readonly<{
154
+ readonly _tag: "Selected";
155
+ readonly value: string;
156
+ readonly wasAdded: boolean;
157
+ }>>];
158
+ type UpdateReturn = ReturnType<typeof update>;
153
159
  /** Programmatically opens the listbox, updating the model and returning
154
160
  * focus and modal commands. Use this in domain-event handlers to open the listbox. */
155
- export declare const open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>];
161
+ export declare const open: (model: Model) => UpdateReturn;
156
162
  /** Programmatically closes the listbox, updating the model and returning
157
163
  * focus and modal commands. Use this in domain-event handlers to close the listbox. */
158
- export declare const close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>];
159
- /** Programmatically toggles an item in the multi-select listbox. Use this in domain-event handlers when the listbox uses `onSelectedItem`. */
160
- export declare const selectItem: (model: Model, item: string) => readonly [Model, ReadonlyArray<Command.Command<Message>>];
161
- /** Configuration for rendering a multi-select listbox with `view`. */
162
- export type ViewConfig<ParentMessage, Item> = BaseViewConfig<ParentMessage, Item, Model>;
163
- /** Renders a headless multi-select listbox with typeahead search, keyboard navigation, selection tracking, and aria-activedescendant focus management. */
164
- export declare const view: <ParentMessage, Item>(config: Readonly<{
165
- model: {
166
- readonly selectedItems: readonly string[];
167
- readonly id: string;
168
- readonly isOpen: boolean;
169
- readonly isAnimated: boolean;
170
- readonly isModal: boolean;
171
- readonly orientation: "Vertical" | "Horizontal";
172
- readonly animation: {
173
- readonly id: string;
174
- readonly isShowing: boolean;
175
- readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
176
- };
177
- readonly maybeActiveItemIndex: Option.Option<number>;
178
- readonly activationTrigger: "Pointer" | "Keyboard";
179
- readonly searchQuery: string;
180
- readonly searchVersion: number;
181
- readonly maybeLastPointerPosition: Option.Option<{
182
- readonly screenX: number;
183
- readonly screenY: number;
184
- }>;
185
- readonly maybeLastButtonPointerType: Option.Option<string>;
186
- };
187
- toParentMessage: (message: Opened | Closed | import("./shared.js").BlurredItems | import("./shared.js").ActivatedItem | import("./shared.js").DeactivatedItem | SelectedItem | import("./shared.js").MovedPointerOverItem | import("./shared.js").RequestedItemClick | import("./shared.js").Searched | import("./shared.js").PressedPointerOnButton | import("./shared.js").IgnoredMouseClick | import("./shared.js").SuppressedSpaceScroll | {
188
- readonly _tag: "CompletedAnchorListbox";
189
- } | {
190
- readonly _tag: "CompletedPortalListboxBackdrop";
191
- }) => ParentMessage;
192
- onSelectedItem?: (value: string) => ParentMessage;
193
- items: readonly Item[];
194
- itemToConfig: (item: Item, context: Readonly<{
195
- isActive: boolean;
196
- isDisabled: boolean;
197
- isSelected: boolean;
198
- }>) => Readonly<{
199
- className?: string;
200
- content: Html;
201
- }>;
202
- isItemDisabled?: (item: Item, index: number) => boolean;
203
- itemToSearchText?: (item: Item, index: number) => string;
204
- itemToValue?: (item: Item) => string;
205
- isButtonDisabled?: boolean;
206
- buttonContent: Html;
207
- buttonClassName?: string;
208
- buttonAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
209
- itemsClassName?: string;
210
- itemsAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
211
- itemsScrollClassName?: string;
212
- itemsScrollAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
213
- backdropClassName?: string;
214
- backdropAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
215
- className?: string;
216
- attributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
217
- itemGroupKey?: (item: Item, index: number) => string;
218
- groupToHeading?: (groupKey: string) => Readonly<{
219
- content: Html;
220
- className?: string;
221
- }> | undefined;
222
- groupClassName?: string;
223
- groupAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
224
- separatorClassName?: string;
225
- separatorAttributes?: readonly import("../../html/index.js").Attribute<ParentMessage>[];
226
- anchor?: import("./public.js").AnchorConfig;
227
- name?: string;
228
- form?: string;
229
- isDisabled?: boolean;
230
- isInvalid?: boolean;
231
- }>) => Html;
232
- /** Creates a memoized multi-select listbox view. Static config is captured in a closure;
233
- * only `model` and `toParentMessage` are compared per render via `createLazy`. */
234
- export declare const lazy: <ParentMessage, Item>(staticConfig: Omit<ViewConfig<ParentMessage, Item>, "model" | "toParentMessage" | "onSelectedItem">) => ((model: Model, toParentMessage: BaseViewConfig<ParentMessage, Item, Model>["toParentMessage"]) => Html);
164
+ export declare const close: (model: Model) => UpdateReturn;
165
+ /** Programmatically toggles an item in the multi-select listbox. Emits `Selected({ value, wasAdded })`. */
166
+ export declare const selectItem: (model: Model, item: string) => UpdateReturn;
167
+ /** Reflects an externally-sourced selection set onto the model without
168
+ * emitting an OutMessage or running selection side effects. Use this to
169
+ * mirror external truth (URL parameters, restored storage, a server push)
170
+ * onto the listbox's selected items. Contrast with `selectItem`, which
171
+ * toggles a single item as a user *choice* and emits `Selected`. Returns
172
+ * the model directly because it produces no commands and no OutMessage. */
173
+ export declare const reflectSelectedItems: Reflect<Model, ReadonlyArray<string>>;
174
+ /** Per-render view inputs passed to the view via `h.submodel`'s `viewInputs` field. */
175
+ export type ViewInputs<Item, Value extends string = string> = BaseViewInputs<Item, Value>;
176
+ /** Pairs the multi-select listbox's `view` and `update` (and programmatic
177
+ * helpers) behind a single Item-typed entry point. Same shape as
178
+ * `Ui.Listbox.create`. Two type params support object-typed items via
179
+ * `itemToValue`: `Value` defaults to `Item` when `Item extends string`,
180
+ * else `string`. */
181
+ export declare const create: <Item = string, Value extends string = Item extends string ? Item : string>() => Readonly<{
182
+ view: SubmodelView<Model, Message, BaseViewInputs<Item, Value>>;
183
+ update: (model: Model, message: Message) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
184
+ selectItem: (model: Model, item: Value) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
185
+ open: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
186
+ close: (model: Model) => readonly [Model, ReadonlyArray<Command.Command<Message>>, Option.Option<OutMessage<Value>>];
187
+ reflectSelectedItems: Reflect<Model, ReadonlyArray<Value>>;
188
+ }>;
189
+ export {};
235
190
  //# sourceMappingURL=multi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi.d.ts","sourceRoot":"","sources":["../../../src/ui/listbox/multi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,IAAI,CAAC,EAAQ,MAAM,QAAQ,CAAA;AAEzD,OAAO,KAAK,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACtD,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,qBAAqB,CAAA;AAE3D,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,cAAc,EACnB,MAAM,EACN,KAAK,OAAO,EACZ,MAAM,EACN,YAAY,EAIb,MAAM,aAAa,CAAA;AAIpB,iKAAiK;AACjK,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,6RAA6R;AAC7R,MAAM,MAAM,UAAU,GAAG,cAAc,GACrC,QAAQ,CAAC;IACP,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CACtC,CAAC,CAAA;AAEJ,4HAA4H;AAC5H,eAAO,MAAM,IAAI,GAAI,QAAQ,UAAU,KAAG,KAGxC,CAAA;AAIF,wJAAwJ;AACxJ,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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