@foldkit/ui 0.150.0 → 0.151.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/animation/update.d.ts +10 -9
  2. package/dist/animation/update.d.ts.map +1 -1
  3. package/dist/animation/update.js +27 -35
  4. package/dist/calendar/index.d.ts +100 -11
  5. package/dist/calendar/index.d.ts.map +1 -1
  6. package/dist/calendar/index.js +66 -80
  7. package/dist/checkbox/index.d.ts +3 -4
  8. package/dist/checkbox/index.d.ts.map +1 -1
  9. package/dist/checkbox/index.js +3 -4
  10. package/dist/combobox/multi.d.ts +40 -51
  11. package/dist/combobox/multi.d.ts.map +1 -1
  12. package/dist/combobox/multi.js +19 -16
  13. package/dist/combobox/shared.d.ts +20 -20
  14. package/dist/combobox/shared.d.ts.map +1 -1
  15. package/dist/combobox/shared.js +134 -128
  16. package/dist/combobox/single.d.ts +38 -51
  17. package/dist/combobox/single.d.ts.map +1 -1
  18. package/dist/combobox/single.js +21 -17
  19. package/dist/datePicker/index.d.ts +182 -15
  20. package/dist/datePicker/index.d.ts.map +1 -1
  21. package/dist/datePicker/index.js +37 -54
  22. package/dist/dialog/index.d.ts +45 -7
  23. package/dist/dialog/index.d.ts.map +1 -1
  24. package/dist/dialog/index.js +54 -49
  25. package/dist/disclosure/index.d.ts +3 -4
  26. package/dist/disclosure/index.d.ts.map +1 -1
  27. package/dist/disclosure/index.js +3 -4
  28. package/dist/dragAndDrop/index.d.ts +96 -7
  29. package/dist/dragAndDrop/index.d.ts.map +1 -1
  30. package/dist/dragAndDrop/index.js +49 -61
  31. package/dist/fileDrop/index.d.ts +26 -11
  32. package/dist/fileDrop/index.d.ts.map +1 -1
  33. package/dist/fileDrop/index.js +16 -23
  34. package/dist/listbox/multi.d.ts +39 -52
  35. package/dist/listbox/multi.d.ts.map +1 -1
  36. package/dist/listbox/multi.js +9 -7
  37. package/dist/listbox/shared.d.ts +14 -22
  38. package/dist/listbox/shared.d.ts.map +1 -1
  39. package/dist/listbox/shared.js +113 -114
  40. package/dist/listbox/single.d.ts +40 -55
  41. package/dist/listbox/single.d.ts.map +1 -1
  42. package/dist/listbox/single.js +8 -7
  43. package/dist/menu/index.d.ts +131 -37
  44. package/dist/menu/index.d.ts.map +1 -1
  45. package/dist/menu/index.js +111 -120
  46. package/dist/popover/index.d.ts +71 -10
  47. package/dist/popover/index.d.ts.map +1 -1
  48. package/dist/popover/index.js +80 -73
  49. package/dist/radioGroup/index.d.ts +31 -19
  50. package/dist/radioGroup/index.d.ts.map +1 -1
  51. package/dist/radioGroup/index.js +18 -18
  52. package/dist/slider/index.d.ts +44 -13
  53. package/dist/slider/index.d.ts.map +1 -1
  54. package/dist/slider/index.js +33 -38
  55. package/dist/switch/index.d.ts +3 -4
  56. package/dist/switch/index.d.ts.map +1 -1
  57. package/dist/switch/index.js +3 -4
  58. package/dist/tabs/index.d.ts +31 -17
  59. package/dist/tabs/index.d.ts.map +1 -1
  60. package/dist/tabs/index.js +17 -17
  61. package/dist/test/apps/disabledButton.d.ts +17 -17
  62. package/dist/test/apps/disabledButton.d.ts.map +1 -1
  63. package/dist/test/apps/disabledButton.js +6 -4
  64. package/dist/toast/index.d.ts +96 -100
  65. package/dist/toast/index.d.ts.map +1 -1
  66. package/dist/toast/update.d.ts +97 -100
  67. package/dist/toast/update.d.ts.map +1 -1
  68. package/dist/toast/update.js +60 -58
  69. package/dist/tooltip/index.d.ts +2 -1
  70. package/dist/tooltip/index.d.ts.map +1 -1
  71. package/dist/tooltip/index.js +1 -1
  72. package/dist/tooltip/tooltip.d.ts +5 -10
  73. package/dist/tooltip/tooltip.d.ts.map +1 -1
  74. package/dist/tooltip/tooltip.js +45 -48
  75. package/dist/virtualList/index.d.ts +30 -29
  76. package/dist/virtualList/index.d.ts.map +1 -1
  77. package/dist/virtualList/index.js +21 -21
  78. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
- import { Array, Effect, Equal, Match as M, Option, Predicate, Schema as S, } from 'effect';
2
+ import { Array, Effect, Equal, 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
5
  import { childAttributes } from 'foldkit/html';
@@ -50,7 +50,9 @@ export const Message = defineMessageUnion({
50
50
  GotAnimationMessage: { message: AnimationMessage },
51
51
  });
52
52
  // OUT MESSAGE
53
- /** Union of out-messages the popover component can produce. Parents reacting to open/close transitions (e.g. to reset related state, fire analytics) read this from the third element of `update`'s return tuple. */
53
+ /** Union of OutMessages the popover component can produce. Handle open and
54
+ * close transitions in the `foldOutMessage` of the Popover's
55
+ * `Update.foldChild` config. */
54
56
  export const OutMessage = defineMessageUnion({
55
57
  Opened: {},
56
58
  Closed: {},
@@ -124,72 +126,78 @@ export const DetectMovementOrAnimationEnd = Command.define('DetectMovementOrAnim
124
126
  }))))), "@foldkit/ui/popover/index.js#execute~5"),
125
127
  });
126
128
  const foldAnimationOutMessage = M.type().pipe(M.withReturnType(), M.tagsExhaustive({
127
- StartedLeaveAnimating: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([
129
+ StartedLeaveAnimating: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({
128
130
  model,
129
- [DetectMovementOrAnimationEnd({ id: model.id })],
130
- ]), "@foldkit/ui/popover/index.js#anonymous")), "@foldkit/ui/popover/index.js#StartedLeaveAnimating"),
131
- TransitionedOut: () => __foldkitBrandViewResult((model => __foldkitBrandViewResult(([model, []]), "@foldkit/ui/popover/index.js#anonymous~2")), "@foldkit/ui/popover/index.js#TransitionedOut"),
131
+ commands: [DetectMovementOrAnimationEnd({ id: model.id })],
132
+ }), "@foldkit/ui/popover/index.js#anonymous"))), "@foldkit/ui/popover/index.js#StartedLeaveAnimating"),
133
+ TransitionedOut: () => __foldkitBrandViewResult((model => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#anonymous~2"))), "@foldkit/ui/popover/index.js#TransitionedOut"),
132
134
  }));
133
135
  const foldAnimation = Update.foldChild({
134
136
  update: animationUpdate,
135
137
  read: (model) => __foldkitBrandViewResult((Option.some(model.animation)), "@foldkit/ui/popover/index.js#read"),
136
138
  write: (model, nextAnimation) => __foldkitBrandViewResult((evo(model, { animation: () => __foldkitBrandViewResult((nextAnimation), "@foldkit/ui/popover/index.js#animation") })), "@foldkit/ui/popover/index.js#write"),
137
139
  toParentMessage: message => __foldkitBrandViewResult((Message.GotAnimationMessage({ message })), "@foldkit/ui/popover/index.js#toParentMessage"),
138
- toParentOutMessage: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#toParentOutMessage"),
139
140
  foldOutMessage: foldAnimationOutMessage,
140
141
  });
141
- /** Processes a popover message and returns the next model, commands, and optional OutMessage. */
142
+ /** Processes a Popover Message and returns the next Model, optional Commands,
143
+ * and an optional OutMessage. */
142
144
  export const update = (model, message) => {
143
145
  const maybeLockScroll = OptionExt.when(model.isModal, LockScroll());
144
146
  const maybeUnlockScroll = OptionExt.when(model.isModal, UnlockScroll());
145
147
  const maybeInertOthers = OptionExt.when(model.isModal, InertOthers({ id: model.id }));
146
148
  const maybeRestoreInert = OptionExt.when(model.isModal, RestoreInert({ id: model.id }));
147
149
  const focusButton = FocusButton({ id: model.id });
148
- const openCommands = Array.getSomes([maybeLockScroll, maybeInertOthers]);
150
+ const openCommands = Array.getSomes([
151
+ maybeLockScroll,
152
+ maybeInertOthers,
153
+ ]);
149
154
  const closeWithFocusCommands = [
150
155
  focusButton,
151
156
  ...Array.getSomes([maybeUnlockScroll, maybeRestoreInert]),
152
157
  ];
153
- const closeWithoutFocusCommands = Array.getSomes([
154
- maybeUnlockScroll,
155
- maybeRestoreInert,
156
- ]);
158
+ const closeWithoutFocusCommands = Array.getSomes([maybeUnlockScroll, maybeRestoreInert]);
157
159
  const openPopover = (baseModel) => {
158
160
  if (model.isAnimated) {
159
- const [nextModel, animationCommands] = foldAnimation(baseModel, AnimationMessage.Showed());
160
- return __foldkitBrandViewResult(([
161
- evo(nextModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~2") }),
162
- [...openCommands, ...animationCommands],
163
- Option.some(OutMessage.Opened()),
164
- ]), "@foldkit/ui/popover/index.js#openPopover");
161
+ const popoverOpen = Update.combine(baseModel, [
162
+ stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands: openCommands }), "@foldkit/ui/popover/index.js#anonymous~3")),
163
+ foldAnimation(AnimationMessage.Showed()),
164
+ stepModel => (__foldkitBrandViewResult(({
165
+ model: evo(stepModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~2") }),
166
+ }), "@foldkit/ui/popover/index.js#anonymous~4")),
167
+ ]);
168
+ return __foldkitBrandViewResult((pipe(popoverOpen, Update.withOutMessage(OutMessage.Opened()))), "@foldkit/ui/popover/index.js#openPopover");
165
169
  }
166
- return __foldkitBrandViewResult(([
167
- evo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~3") }),
168
- openCommands,
169
- Option.some(OutMessage.Opened()),
170
- ]), "@foldkit/ui/popover/index.js#openPopover");
170
+ return __foldkitBrandViewResult(({
171
+ model: evo(baseModel, { isOpen: () => __foldkitBrandViewResult((true), "@foldkit/ui/popover/index.js#isOpen~3") }),
172
+ commands: openCommands,
173
+ outMessage: OutMessage.Opened(),
174
+ }), "@foldkit/ui/popover/index.js#openPopover");
171
175
  };
172
- const closePopover = (baseModel, commands) => {
176
+ const closePopoverModel = (baseModel, commands) => {
173
177
  if (!baseModel.isOpen) {
174
- return __foldkitBrandViewResult(([baseModel, [], Option.none()]), "@foldkit/ui/popover/index.js#closePopover");
178
+ return __foldkitBrandViewResult(({ model: baseModel }), "@foldkit/ui/popover/index.js#closePopoverModel");
175
179
  }
176
180
  const closed = closedModel(baseModel);
177
181
  if (model.isAnimated) {
178
- const [nextModel, animationCommands] = foldAnimation(closed, AnimationMessage.Hid());
179
- return __foldkitBrandViewResult(([
180
- nextModel,
181
- [...commands, ...animationCommands],
182
- Option.some(OutMessage.Closed()),
183
- ]), "@foldkit/ui/popover/index.js#closePopover");
182
+ return __foldkitBrandViewResult((Update.combine(closed, [
183
+ stepModel => (__foldkitBrandViewResult(({ model: stepModel, commands }), "@foldkit/ui/popover/index.js#anonymous~5")),
184
+ foldAnimation(AnimationMessage.Hid()),
185
+ ])), "@foldkit/ui/popover/index.js#closePopoverModel");
186
+ }
187
+ return __foldkitBrandViewResult(({ model: closed, commands }), "@foldkit/ui/popover/index.js#closePopoverModel");
188
+ };
189
+ const closePopover = (baseModel, commands) => {
190
+ if (!baseModel.isOpen) {
191
+ return __foldkitBrandViewResult(({ model: baseModel }), "@foldkit/ui/popover/index.js#closePopover");
184
192
  }
185
- return __foldkitBrandViewResult(([closed, commands, Option.some(OutMessage.Closed())]), "@foldkit/ui/popover/index.js#closePopover");
193
+ return __foldkitBrandViewResult((pipe(closePopoverModel(baseModel, commands), Update.withOutMessage(OutMessage.Closed()))), "@foldkit/ui/popover/index.js#closePopover");
186
194
  };
187
195
  return __foldkitBrandViewResult((Message.match(message, {
188
196
  RequestedOpen: () => __foldkitBrandViewResult((openPopover(model)), "@foldkit/ui/popover/index.js#RequestedOpen"),
189
197
  RequestedClose: () => __foldkitBrandViewResult((closePopover(model, closeWithFocusCommands)), "@foldkit/ui/popover/index.js#RequestedClose"),
190
198
  BlurredPanel: () => {
191
199
  if (Option.exists(model.maybeLastButtonPointerType, Equal.equals('mouse'))) {
192
- return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#BlurredPanel");
200
+ return __foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#BlurredPanel");
193
201
  }
194
202
  return __foldkitBrandViewResult((closePopover(model, closeWithoutFocusCommands)), "@foldkit/ui/popover/index.js#BlurredPanel");
195
203
  },
@@ -198,35 +206,34 @@ export const update = (model, message) => {
198
206
  maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~2"),
199
207
  });
200
208
  if (pointerType !== 'mouse' || button !== LEFT_MOUSE_BUTTON) {
201
- return __foldkitBrandViewResult(([withPointerType, [], Option.none()]), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
209
+ return __foldkitBrandViewResult(({ model: withPointerType }), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
202
210
  }
203
211
  if (model.isOpen) {
204
- const [closed, commands, maybeOutMessage] = closePopover(withPointerType, closeWithFocusCommands);
205
- return __foldkitBrandViewResult(([
206
- evo(closed, {
207
- maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~3"),
208
- }),
209
- commands,
210
- maybeOutMessage,
211
- ]), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
212
+ const popoverClose = Update.combine(withPointerType, [
213
+ stepModel => __foldkitBrandViewResult((closePopoverModel(stepModel, closeWithFocusCommands)), "@foldkit/ui/popover/index.js#anonymous~6"),
214
+ stepModel => (__foldkitBrandViewResult(({
215
+ model: evo(stepModel, {
216
+ maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.some(pointerType)), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~3"),
217
+ }),
218
+ }), "@foldkit/ui/popover/index.js#anonymous~7")),
219
+ ]);
220
+ return __foldkitBrandViewResult((pipe(popoverClose, Update.withOutMessage(OutMessage.Closed()))), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
212
221
  }
213
222
  return __foldkitBrandViewResult((openPopover(withPointerType)), "@foldkit/ui/popover/index.js#PressedPointerOnButton");
214
223
  },
215
224
  GotAnimationMessage: ({ message: animationMessage }) => __foldkitBrandViewResult((foldAnimation(model, animationMessage)), "@foldkit/ui/popover/index.js#GotAnimationMessage"),
216
- CompletedFocusPanel: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusPanel"),
217
- CompletedFocusButton: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedFocusButton"),
218
- CompletedLockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedLockScroll"),
219
- CompletedUnlockScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedUnlockScroll"),
220
- CompletedInertOthers: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedInertOthers"),
221
- CompletedRestoreInert: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedRestoreInert"),
222
- IgnoredMouseClick: () => __foldkitBrandViewResult(([
223
- evo(model, { maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~4") }),
224
- [],
225
- Option.none(),
226
- ]), "@foldkit/ui/popover/index.js#IgnoredMouseClick"),
227
- SuppressedSpaceScroll: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#SuppressedSpaceScroll"),
228
- CompletedAnchorPopover: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedAnchorPopover"),
229
- CompletedPortalPopoverBackdrop: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/popover/index.js#CompletedPortalPopoverBackdrop"),
225
+ CompletedFocusPanel: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedFocusPanel")),
226
+ CompletedFocusButton: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedFocusButton")),
227
+ CompletedLockScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedLockScroll")),
228
+ CompletedUnlockScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedUnlockScroll")),
229
+ CompletedInertOthers: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedInertOthers")),
230
+ CompletedRestoreInert: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedRestoreInert")),
231
+ IgnoredMouseClick: () => (__foldkitBrandViewResult(({
232
+ model: evo(model, { maybeLastButtonPointerType: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#maybeLastButtonPointerType~4") }),
233
+ }), "@foldkit/ui/popover/index.js#IgnoredMouseClick")),
234
+ SuppressedSpaceScroll: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#SuppressedSpaceScroll")),
235
+ CompletedAnchorPopover: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedAnchorPopover")),
236
+ CompletedPortalPopoverBackdrop: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/popover/index.js#CompletedPortalPopoverBackdrop")),
230
237
  })), "@foldkit/ui/popover/index.js#update");
231
238
  };
232
239
  /** The anchor-positioning Mount this Popover renders on its panel. Exposed so
@@ -243,18 +250,18 @@ export const AnchorPopover = Mount.define('AnchorPopover', {
243
250
  interceptTab: false,
244
251
  focusAfterPosition: true,
245
252
  ...(focusSelector !== undefined && { focusSelector }),
246
- })), "@foldkit/ui/popover/index.js#anonymous~6")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~7"));
247
- return __foldkitBrandViewResult((Message.CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~5");
248
- })), "@foldkit/ui/popover/index.js#anonymous~4")), "@foldkit/ui/popover/index.js#anonymous~3"));
253
+ })), "@foldkit/ui/popover/index.js#anonymous~11")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~12"));
254
+ return __foldkitBrandViewResult((Message.CompletedAnchorPopover()), "@foldkit/ui/popover/index.js#anonymous~10");
255
+ })), "@foldkit/ui/popover/index.js#anonymous~9")), "@foldkit/ui/popover/index.js#anonymous~8"));
249
256
  /** The backdrop-portaling Mount this Popover renders. Exposed so Scene tests can
250
257
  * call `Scene.Mount.resolve(PortalPopoverBackdrop, CompletedPortalPopoverBackdrop())` to
251
258
  * acknowledge the mount produced by the rendered backdrop. */
252
259
  export const PortalPopoverBackdrop = Mount.define('PortalPopoverBackdrop', Message.CompletedPortalPopoverBackdrop)(element => __foldkitBrandViewResult((Effect.gen(function* () {
253
- yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~10")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~11"));
254
- return __foldkitBrandViewResult((Message.CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~9");
255
- })), "@foldkit/ui/popover/index.js#anonymous~8"));
256
- /** Programmatically opens the popover, updating the model and returning
257
- * focus and modal commands plus an `Opened` OutMessage. */
260
+ yield* Effect.acquireRelease(Effect.sync(() => __foldkitBrandViewResult((portalToContainingRoot(element)), "@foldkit/ui/popover/index.js#anonymous~15")), cleanup => __foldkitBrandViewResult((Effect.sync(cleanup)), "@foldkit/ui/popover/index.js#anonymous~16"));
261
+ return __foldkitBrandViewResult((Message.CompletedPortalPopoverBackdrop()), "@foldkit/ui/popover/index.js#anonymous~14");
262
+ })), "@foldkit/ui/popover/index.js#anonymous~13"));
263
+ /** Programmatically opens the Popover, updating the Model and returning
264
+ * focus and modal Commands plus an `Opened` OutMessage. */
258
265
  export const open = (model) => __foldkitBrandViewResult((update(model, Message.RequestedOpen())), "@foldkit/ui/popover/index.js#open");
259
266
  /** Programmatically closes the popover. When it was open, updates the Model
260
267
  * and returns focus and modal Commands plus a `Closed` OutMessage. When it
@@ -270,21 +277,21 @@ export const view = defineView((model, viewInputs, h) => {
270
277
  h.DataAttribute('closed', ''),
271
278
  h.DataAttribute('enter', ''),
272
279
  h.DataAttribute('transition', ''),
273
- ]), "@foldkit/ui/popover/index.js#anonymous~13")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
280
+ ]), "@foldkit/ui/popover/index.js#anonymous~18")), M.when('EnterAnimating', () => __foldkitBrandViewResult(([
274
281
  h.DataAttribute('enter', ''),
275
282
  h.DataAttribute('transition', ''),
276
- ]), "@foldkit/ui/popover/index.js#anonymous~14")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
283
+ ]), "@foldkit/ui/popover/index.js#anonymous~19")), M.when('LeaveStart', () => __foldkitBrandViewResult(([
277
284
  h.DataAttribute('leave', ''),
278
285
  h.DataAttribute('transition', ''),
279
- ]), "@foldkit/ui/popover/index.js#anonymous~15")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
286
+ ]), "@foldkit/ui/popover/index.js#anonymous~20")), M.when('LeaveAnimating', () => __foldkitBrandViewResult(([
280
287
  h.DataAttribute('closed', ''),
281
288
  h.DataAttribute('leave', ''),
282
289
  h.DataAttribute('transition', ''),
283
- ]), "@foldkit/ui/popover/index.js#anonymous~16")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#anonymous~17")));
284
- const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? Message.RequestedClose() : Message.RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~18")), M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~19")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~20")))), "@foldkit/ui/popover/index.js#handleButtonKeyDown");
290
+ ]), "@foldkit/ui/popover/index.js#anonymous~21")), M.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/popover/index.js#anonymous~22")));
291
+ const handleButtonKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.whenOr('Enter', ' ', 'ArrowDown', () => __foldkitBrandViewResult((Option.some(isOpen ? Message.RequestedClose() : Message.RequestedOpen())), "@foldkit/ui/popover/index.js#anonymous~23")), M.when('Escape', () => __foldkitBrandViewResult((OptionExt.when(isOpen, Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~24")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~25")))), "@foldkit/ui/popover/index.js#handleButtonKeyDown");
285
292
  const handleButtonPointerDown = (pointerType, button) => __foldkitBrandViewResult((Option.some(Message.PressedPointerOnButton({ pointerType, button }))), "@foldkit/ui/popover/index.js#handleButtonPointerDown");
286
293
  const handleButtonClick = () => {
287
- const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~21"));
294
+ const isMouse = Option.exists(maybeLastButtonPointerType, type => __foldkitBrandViewResult((type === 'mouse'), "@foldkit/ui/popover/index.js#anonymous~26"));
288
295
  if (isMouse) {
289
296
  return __foldkitBrandViewResult((Message.IgnoredMouseClick()), "@foldkit/ui/popover/index.js#handleButtonClick");
290
297
  }
@@ -296,7 +303,7 @@ export const view = defineView((model, viewInputs, h) => {
296
303
  }
297
304
  };
298
305
  const handleSpaceKeyUp = (key) => __foldkitBrandViewResult((OptionExt.when(key === ' ', Message.SuppressedSpaceScroll())), "@foldkit/ui/popover/index.js#handleSpaceKeyUp");
299
- const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~22")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~23")))), "@foldkit/ui/popover/index.js#handlePanelKeyDown");
306
+ const handlePanelKeyDown = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.when('Escape', () => __foldkitBrandViewResult((Option.some(Message.RequestedClose())), "@foldkit/ui/popover/index.js#anonymous~27")), M.orElse(() => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/popover/index.js#anonymous~28")))), "@foldkit/ui/popover/index.js#handlePanelKeyDown");
300
307
  const resolveButtonLabel = () => {
301
308
  if (Predicate.isNotUndefined(ariaLabel)) {
302
309
  return __foldkitBrandViewResult(([h.AriaLabel(ariaLabel)]), "@foldkit/ui/popover/index.js#resolveButtonLabel");
@@ -356,5 +363,5 @@ export const view = defineView((model, viewInputs, h) => {
356
363
  panel: childAttributes(panelAttributes),
357
364
  backdrop: childAttributes(backdropAttributes),
358
365
  isVisible,
359
- })), "@foldkit/ui/popover/index.js#anonymous~12");
366
+ })), "@foldkit/ui/popover/index.js#anonymous~17");
360
367
  });
@@ -1,4 +1,5 @@
1
1
  import { Effect, Option, Schema as S } from 'effect';
2
+ import { type Update } from 'foldkit';
2
3
  import * as Command from 'foldkit/command';
3
4
  import { type ChildAttribute, type Html } from 'foldkit/html';
4
5
  import { type View as SubmodelView } from 'foldkit/submodel';
@@ -34,7 +35,8 @@ export type Selected<Value extends string = string> = Readonly<{
34
35
  readonly value: Value;
35
36
  readonly index: number;
36
37
  }>;
37
- /** Union of out-messages the radio group can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
38
+ /** Union of OutMessages the radio group can produce. The parent's
39
+ * `Update.foldChild` config handles them through `foldOutMessage`. */
38
40
  export declare const OutMessage: import("foldkit/message").MessageUnion<{
39
41
  readonly Selected: {
40
42
  readonly value: S.String;
@@ -60,16 +62,31 @@ export declare const FocusOption: Command.CommandDefinitionWithArgs<"FocusOption
60
62
  }, Effect.Effect<{
61
63
  readonly _tag: "CompletedFocusOption";
62
64
  }, never, never>>;
63
- type UpdateReturn = readonly [
64
- Model,
65
- ReadonlyArray<Command.Command<Message>>,
66
- Option.Option<OutMessage>
67
- ];
68
- /** Processes a radio group message and returns the next model, commands, and
69
- * an optional OutMessage. `Selected` fires when an option is committed via
70
- * click or keyboard; the parent stores the new value and passes it back in as
71
- * `selectedValue`. */
72
- export declare const update: (model: Model, message: Message) => UpdateReturn;
65
+ /** Processes a RadioGroup Message and returns the next Model, optional
66
+ * Commands, and an optional OutMessage. `Selected` fires when an option is
67
+ * committed via click or keyboard; the parent stores the new value and passes
68
+ * it back in as `selectedValue`. */
69
+ export declare const update: (model: Model, message: Message) => Readonly<{
70
+ model: {
71
+ readonly id: string;
72
+ readonly maybeFocusedIndex: Option.Option<number>;
73
+ };
74
+ commands?: Update.Commands<{
75
+ readonly _tag: "SelectedOption";
76
+ readonly index: number;
77
+ readonly value: string;
78
+ } | {
79
+ readonly _tag: "FocusedOption";
80
+ readonly index: number;
81
+ } | {
82
+ readonly _tag: "CompletedFocusOption";
83
+ }, never>;
84
+ outMessage?: Readonly<{
85
+ readonly _tag: "Selected";
86
+ readonly value: string;
87
+ readonly index: number;
88
+ }>;
89
+ }>;
73
90
  /** Per-option render info passed to the consumer's `toView`. The consumer
74
91
  * spreads `option`, `label`, and `description` onto whichever elements carry
75
92
  * that role in their layout. Generic over `Value extends string` so
@@ -139,11 +156,7 @@ export type ViewInputs<Value extends string = string> = Readonly<{
139
156
  * the bundle rather than calling `create` itself. */
140
157
  export type Bundle<Value extends string = string> = Readonly<{
141
158
  view: SubmodelView<Model, Message, ViewInputs<Value>>;
142
- update: (model: Model, message: Message) => readonly [
143
- Model,
144
- ReadonlyArray<Command.Command<Message>>,
145
- Option.Option<OutMessage<Value>>
146
- ];
159
+ update: (model: Model, message: Message) => Update.ReturnWithOutMessage<Model, Message, OutMessage<Value>>;
147
160
  }>;
148
161
  /** Pairs the radio group `view` and `update` behind a single Value-typed
149
162
  * entry point. Declare once at module scope so consumers receive
@@ -156,13 +169,12 @@ export type Bundle<Value extends string = string> = Readonly<{
156
169
  * // In view (selectedValue is the parent-owned selection):
157
170
  * h.submodel({ view: PlanRadioGroup.view, viewInputs: { selectedValue, ... }, ... })
158
171
  *
159
- * // In update, fold the Selected OutMessage into your Model:
160
- * const [next, commands, maybeOutMessage] = PlanRadioGroup.update(model, message)
172
+ * // In the parent update, pass PlanRadioGroup.update to Update.foldChild
173
+ * // and fold the Selected OutMessage into your Model.
161
174
  * ```
162
175
  *
163
176
  * The internal view stays typed `ReadonlyArray<string>`; consumers can
164
177
  * pass a `ReadonlyArray<MyUnion>` (assignable) and the fenced cast inside
165
178
  * `create` types `OptionInfo.value` as `MyUnion`. */
166
179
  export declare const create: <Value extends string = string>() => Bundle<Value>;
167
- export {};
168
180
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/radioGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,MAAM,EAEN,MAAM,IAAI,CAAC,EAGZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAG9E,OAAO,EAAE,KAAK,IAAI,IAAI,YAAY,EAAc,MAAM,kBAAkB,CAAA;AAOxE,+FAA+F;AAC/F,eAAO,MAAM,WAAW,iDAAyC,CAAA;AACjE,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAA;AAEjD;;;;+DAI+D;AAC/D,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,yDAAyD;AACzD,eAAO,MAAM,OAAO;;;;;;;;;EAOlB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,OAAO,CAAC,cAAc,CAAC,IAAI,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAA;AAE7D,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,MAAM,MAAM,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B,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;CACpE,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;sDAiBsD;AACtD,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,MAAM,GAAG,MAAM,OAAK,MAAM,CAAC,KAAK,CAmBpE,CAAA"}
@@ -30,7 +30,8 @@ export const Message = defineMessageUnion({
30
30
  FocusedOption: { index: S.Number },
31
31
  CompletedFocusOption: {},
32
32
  });
33
- /** Union of out-messages the radio group can produce. Surfaced as the third element of `update`'s return tuple and pattern-matched by the parent. */
33
+ /** Union of OutMessages the radio group can produce. The parent's
34
+ * `Update.foldChild` config handles them through `foldOutMessage`. */
34
35
  export const OutMessage = defineMessageUnion({
35
36
  Selected: {
36
37
  value: S.String,
@@ -54,22 +55,21 @@ export const FocusOption = Command.define('FocusOption', {
54
55
  messages: [Message.CompletedFocusOption],
55
56
  execute: ({ id, index }) => __foldkitBrandViewResult((Dom.focus(idSelector(optionId(id, index))).pipe(Effect.ignore, Effect.as(Message.CompletedFocusOption()))), "@foldkit/ui/radioGroup/index.js#execute"),
56
57
  });
57
- /** Processes a radio group message and returns the next model, commands, and
58
- * an optional OutMessage. `Selected` fires when an option is committed via
59
- * click or keyboard; the parent stores the new value and passes it back in as
60
- * `selectedValue`. */
58
+ /** Processes a RadioGroup Message and returns the next Model, optional
59
+ * Commands, and an optional OutMessage. `Selected` fires when an option is
60
+ * committed via click or keyboard; the parent stores the new value and passes
61
+ * it back in as `selectedValue`. */
61
62
  export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
62
- SelectedOption: ({ index, value }) => __foldkitBrandViewResult(([
63
- evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex") }),
64
- [FocusOption({ id: model.id, index })],
65
- Option.some(OutMessage.Selected({ value, index })),
66
- ]), "@foldkit/ui/radioGroup/index.js#SelectedOption"),
67
- FocusedOption: ({ index }) => __foldkitBrandViewResult(([
68
- evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex~2") }),
69
- [FocusOption({ id: model.id, index })],
70
- Option.none(),
71
- ]), "@foldkit/ui/radioGroup/index.js#FocusedOption"),
72
- CompletedFocusOption: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/radioGroup/index.js#CompletedFocusOption"),
63
+ SelectedOption: ({ index, value }) => (__foldkitBrandViewResult(({
64
+ model: evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex") }),
65
+ commands: [FocusOption({ id: model.id, index })],
66
+ outMessage: OutMessage.Selected({ value, index }),
67
+ }), "@foldkit/ui/radioGroup/index.js#SelectedOption")),
68
+ FocusedOption: ({ index }) => (__foldkitBrandViewResult(({
69
+ model: evo(model, { maybeFocusedIndex: () => __foldkitBrandViewResult((Option.some(index)), "@foldkit/ui/radioGroup/index.js#maybeFocusedIndex~2") }),
70
+ commands: [FocusOption({ id: model.id, index })],
71
+ }), "@foldkit/ui/radioGroup/index.js#FocusedOption")),
72
+ CompletedFocusOption: () => (__foldkitBrandViewResult(({ model }), "@foldkit/ui/radioGroup/index.js#CompletedFocusOption")),
73
73
  })), "@foldkit/ui/radioGroup/index.js#update");
74
74
  const internalView = defineView((model, viewInputs, h) => {
75
75
  const { id, maybeFocusedIndex } = model;
@@ -191,8 +191,8 @@ const internalView = defineView((model, viewInputs, h) => {
191
191
  * // In view (selectedValue is the parent-owned selection):
192
192
  * h.submodel({ view: PlanRadioGroup.view, viewInputs: { selectedValue, ... }, ... })
193
193
  *
194
- * // In update, fold the Selected OutMessage into your Model:
195
- * const [next, commands, maybeOutMessage] = PlanRadioGroup.update(model, message)
194
+ * // In the parent update, pass PlanRadioGroup.update to Update.foldChild
195
+ * // and fold the Selected OutMessage into your Model.
196
196
  * ```
197
197
  *
198
198
  * The internal view stays typed `ReadonlyArray<string>`; consumers can
@@ -1,5 +1,5 @@
1
- import { Option, Schema as S } from 'effect';
2
- import type { Command } from 'foldkit/command';
1
+ import { Schema as S } from 'effect';
2
+ import { type Update } from 'foldkit';
3
3
  import { type ChildAttribute, type Html } from 'foldkit/html';
4
4
  import { type Reflect } from 'foldkit/submodel';
5
5
  import * as Subscription from 'foldkit/subscription';
@@ -68,16 +68,48 @@ export declare const snapAndClamp: (value: number, min: number, max: number, ste
68
68
  /** Computes the fraction (0–1) of a value between min and max. Returns 0 when
69
69
  * the range has zero width. */
70
70
  export declare const fractionOfValue: (value: number, min: number, max: number) => number;
71
- type UpdateReturn = readonly [
72
- Model,
73
- ReadonlyArray<Command<Message>>,
74
- Option.Option<OutMessage>
75
- ];
76
- /** Processes a slider message and returns the next model, commands, and an
77
- * optional out-message for the parent. The value lives in the parent Model:
78
- * the view supplies the current value on the messages that need it, and value
79
- * changes surface as `ChangedValue` rather than mutating this Model. */
80
- export declare const update: (model: Model, message: Message) => UpdateReturn;
71
+ /** Processes a Slider Message and returns the next Model, optional Commands,
72
+ * and an optional OutMessage for the parent. The value lives in the parent
73
+ * Model: the view supplies the current value on the Messages that need it,
74
+ * and value changes surface as `ChangedValue` rather than mutating this
75
+ * Model. */
76
+ export declare const update: (model: Model, message: Message) => Readonly<{
77
+ model: {
78
+ readonly id: string;
79
+ readonly min: number;
80
+ readonly max: number;
81
+ readonly step: number;
82
+ readonly dragState: {
83
+ readonly _tag: "Idle";
84
+ } | {
85
+ readonly _tag: "Dragging";
86
+ readonly originValue: number;
87
+ };
88
+ };
89
+ commands?: Update.Commands<{
90
+ readonly _tag: "CancelledDrag";
91
+ } | {
92
+ readonly _tag: "PressedThumb";
93
+ readonly originValue: number;
94
+ } | {
95
+ readonly _tag: "PressedPointer";
96
+ readonly value: number;
97
+ readonly originValue: number;
98
+ } | {
99
+ readonly _tag: "MovedDragPointer";
100
+ readonly value: number;
101
+ } | {
102
+ readonly _tag: "ReleasedDragPointer";
103
+ } | {
104
+ readonly _tag: "PressedKeyboardNavigation";
105
+ readonly direction: "Max" | "Min" | "StepDecrement" | "StepIncrement" | "PageDecrement" | "PageIncrement";
106
+ readonly value: number;
107
+ }, never>;
108
+ outMessage?: {
109
+ readonly _tag: "ChangedValue";
110
+ readonly value: number;
111
+ };
112
+ }>;
81
113
  /** Reflects an externally-driven range onto the slider. Use this when min/max
82
114
  * derive from external state (e.g. a bounded buffer whose first/last index
83
115
  * shifts over time). The parent owns the value, so conform it to the new range
@@ -344,5 +376,4 @@ export declare const view: import("foldkit/submodel").View<{
344
376
  * events on the track can map clientX into a value. */
345
377
  getTrackRoot?: () => Document | ShadowRoot;
346
378
  }>>;
347
- export {};
348
379
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,MAAM,EACN,MAAM,IAAI,CAAC,EAIZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAI9E,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,YAAY,MAAM,sBAAsB,CAAA;AAWpD;;;;2EAI2E;AAC3E,eAAO,MAAM,KAAK;;;;;;;;EAMhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,8DAA8D;AAC9D,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;EAoBlB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAEzC,MAAM,MAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAY,CAAC,IAAI,CAAA;AAC3D,MAAM,MAAM,cAA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