foldkit 0.71.0 → 0.73.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 (94) hide show
  1. package/dist/html/index.d.ts +4 -4
  2. package/dist/html/index.d.ts.map +1 -1
  3. package/dist/html/index.js +1 -1
  4. package/dist/task/index.d.ts +1 -1
  5. package/dist/task/index.d.ts.map +1 -1
  6. package/dist/task/index.js +1 -1
  7. package/dist/task/public.d.ts +1 -1
  8. package/dist/task/public.d.ts.map +1 -1
  9. package/dist/task/public.js +1 -1
  10. package/dist/task/timing.d.ts +9 -5
  11. package/dist/task/timing.d.ts.map +1 -1
  12. package/dist/task/timing.js +11 -11
  13. package/dist/test/apps/disabledButton.d.ts +5 -5
  14. package/dist/test/apps/pointer.d.ts.map +1 -1
  15. package/dist/test/apps/pointer.js +2 -2
  16. package/dist/test/scene.d.ts +2 -0
  17. package/dist/test/scene.d.ts.map +1 -1
  18. package/dist/test/scene.js +12 -2
  19. package/dist/ui/{transition → animation}/index.d.ts +9 -8
  20. package/dist/ui/animation/index.d.ts.map +1 -0
  21. package/dist/ui/{transition → animation}/index.js +8 -7
  22. package/dist/ui/animation/public.d.ts +3 -0
  23. package/dist/ui/animation/public.d.ts.map +1 -0
  24. package/dist/ui/animation/public.js +1 -0
  25. package/dist/ui/{transition → animation}/schema.d.ts +14 -14
  26. package/dist/ui/animation/schema.d.ts.map +1 -0
  27. package/dist/ui/animation/schema.js +35 -0
  28. package/dist/ui/{transition → animation}/update.d.ts +7 -7
  29. package/dist/ui/animation/update.d.ts.map +1 -0
  30. package/dist/ui/{transition → animation}/update.js +12 -12
  31. package/dist/ui/combobox/multi.d.ts +7 -7
  32. package/dist/ui/combobox/public.d.ts +1 -1
  33. package/dist/ui/combobox/public.d.ts.map +1 -1
  34. package/dist/ui/combobox/public.js +1 -1
  35. package/dist/ui/combobox/shared.d.ts +13 -13
  36. package/dist/ui/combobox/shared.d.ts.map +1 -1
  37. package/dist/ui/combobox/shared.js +31 -31
  38. package/dist/ui/combobox/single.d.ts +7 -7
  39. package/dist/ui/datePicker/index.d.ts +3 -3
  40. package/dist/ui/dialog/index.d.ts +7 -7
  41. package/dist/ui/dialog/index.d.ts.map +1 -1
  42. package/dist/ui/dialog/index.js +28 -28
  43. package/dist/ui/dialog/public.d.ts +1 -1
  44. package/dist/ui/dialog/public.d.ts.map +1 -1
  45. package/dist/ui/dialog/public.js +1 -1
  46. package/dist/ui/index.d.ts +2 -1
  47. package/dist/ui/index.d.ts.map +1 -1
  48. package/dist/ui/index.js +2 -1
  49. package/dist/ui/listbox/multi.d.ts +7 -7
  50. package/dist/ui/listbox/public.d.ts +1 -1
  51. package/dist/ui/listbox/public.d.ts.map +1 -1
  52. package/dist/ui/listbox/public.js +1 -1
  53. package/dist/ui/listbox/shared.d.ts +13 -13
  54. package/dist/ui/listbox/shared.d.ts.map +1 -1
  55. package/dist/ui/listbox/shared.js +29 -29
  56. package/dist/ui/listbox/single.d.ts +7 -7
  57. package/dist/ui/menu/index.d.ts +11 -11
  58. package/dist/ui/menu/index.d.ts.map +1 -1
  59. package/dist/ui/menu/index.js +29 -29
  60. package/dist/ui/menu/public.d.ts +1 -1
  61. package/dist/ui/menu/public.d.ts.map +1 -1
  62. package/dist/ui/menu/public.js +1 -1
  63. package/dist/ui/popover/index.d.ts +12 -12
  64. package/dist/ui/popover/index.d.ts.map +1 -1
  65. package/dist/ui/popover/index.js +30 -30
  66. package/dist/ui/popover/public.d.ts +1 -1
  67. package/dist/ui/popover/public.d.ts.map +1 -1
  68. package/dist/ui/popover/public.js +1 -1
  69. package/dist/ui/slider/index.d.ts +171 -0
  70. package/dist/ui/slider/index.d.ts.map +1 -0
  71. package/dist/ui/slider/index.js +319 -0
  72. package/dist/ui/slider/public.d.ts +3 -0
  73. package/dist/ui/slider/public.d.ts.map +1 -0
  74. package/dist/ui/slider/public.js +1 -0
  75. package/dist/ui/toast/index.d.ts +44 -44
  76. package/dist/ui/toast/index.d.ts.map +1 -1
  77. package/dist/ui/toast/index.js +7 -7
  78. package/dist/ui/toast/public.d.ts +1 -1
  79. package/dist/ui/toast/public.d.ts.map +1 -1
  80. package/dist/ui/toast/public.js +1 -1
  81. package/dist/ui/toast/schema.d.ts +11 -11
  82. package/dist/ui/toast/schema.d.ts.map +1 -1
  83. package/dist/ui/toast/schema.js +7 -7
  84. package/dist/ui/toast/update.d.ts +35 -35
  85. package/dist/ui/toast/update.d.ts.map +1 -1
  86. package/dist/ui/toast/update.js +16 -16
  87. package/package.json +9 -5
  88. package/dist/ui/transition/index.d.ts.map +0 -1
  89. package/dist/ui/transition/public.d.ts +0 -3
  90. package/dist/ui/transition/public.d.ts.map +0 -1
  91. package/dist/ui/transition/public.js +0 -1
  92. package/dist/ui/transition/schema.d.ts.map +0 -1
  93. package/dist/ui/transition/schema.js +0 -35
  94. package/dist/ui/transition/update.d.ts.map +0 -1
@@ -0,0 +1,319 @@
1
+ import { Effect, Equal, Function, Match as M, Option, Schema as S, Stream, String as String_, pipe, } from 'effect';
2
+ import { createLazy, html } from '../../html';
3
+ import { m } from '../../message';
4
+ import { makeSubscriptions } from '../../runtime/subscription';
5
+ import { ts } from '../../schema';
6
+ import { evo } from '../../struct';
7
+ // MODEL
8
+ const Idle = ts('Idle');
9
+ const Dragging = ts('Dragging', { originValue: S.Number });
10
+ const DragState = S.Union(Idle, Dragging);
11
+ /** Schema for the slider component's state. Tracks the current value, the
12
+ * range (min/max/step), and the active drag phase. */
13
+ export const Model = S.Struct({
14
+ id: S.String,
15
+ value: S.Number,
16
+ min: S.Number,
17
+ max: S.Number,
18
+ step: S.Number,
19
+ dragState: DragState,
20
+ });
21
+ // MESSAGE
22
+ /** The user pressed the thumb. Starts a drag without changing the value. */
23
+ export const PressedThumb = m('PressedThumb');
24
+ /** The user pressed the track. Starts a drag and snaps the value to the
25
+ * cursor position. Ignored while already dragging, which absorbs the bubble
26
+ * from a thumb press so the value is not shifted. */
27
+ export const PressedPointer = m('PressedPointer', { value: S.Number });
28
+ /** The pointer moved during a drag, producing a new snapped value from the
29
+ * cursor position within the track. */
30
+ export const MovedDragPointer = m('MovedDragPointer', { value: S.Number });
31
+ /** The pointer was released during a drag. Commits the current value. */
32
+ export const ReleasedDragPointer = m('ReleasedDragPointer');
33
+ /** Escape was pressed during a drag. Restores the value from the drag origin. */
34
+ export const CancelledDrag = m('CancelledDrag');
35
+ /** The user pressed a keyboard navigation key on the focused thumb. */
36
+ export const PressedKeyboardNavigation = m('PressedKeyboardNavigation', {
37
+ direction: S.Literal('StepDecrement', 'StepIncrement', 'PageDecrement', 'PageIncrement', 'Min', 'Max'),
38
+ });
39
+ /** Union of all messages the slider component can produce. */
40
+ export const Message = S.Union(PressedThumb, PressedPointer, MovedDragPointer, ReleasedDragPointer, CancelledDrag, PressedKeyboardNavigation);
41
+ // OUT MESSAGE
42
+ /** Emitted when the slider value changes. The parent uses this to react to
43
+ * value updates — e.g. to run validation or trigger a side effect. */
44
+ export const ChangedValue = ts('ChangedValue', { value: S.Number });
45
+ /** Union of all out-messages the slider component can emit to its parent. */
46
+ export const OutMessage = ChangedValue;
47
+ /** Creates an initial slider model from a config. The initial value is
48
+ * snapped to the step and clamped into range. */
49
+ export const init = (config) => ({
50
+ id: config.id,
51
+ value: snapAndClamp(config.initialValue, config.min, config.max, config.step),
52
+ min: config.min,
53
+ max: config.max,
54
+ step: config.step,
55
+ dragState: Idle(),
56
+ });
57
+ // HELPERS
58
+ const stepDecimals = (step) => {
59
+ const text = step.toString();
60
+ return pipe(text, String_.indexOf('.'), Option.match({
61
+ onNone: () => 0,
62
+ onSome: dotIndex => text.length - dotIndex - 1,
63
+ }));
64
+ };
65
+ const roundToStepPrecision = (value, step) => {
66
+ const decimals = stepDecimals(step);
67
+ return Number(value.toFixed(decimals));
68
+ };
69
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
70
+ const snapAndClamp = (value, min, max, step) => {
71
+ const snapped = min + Math.round((value - min) / step) * step;
72
+ return roundToStepPrecision(clamp(snapped, min, max), step);
73
+ };
74
+ /** Computes the fraction (0–1) of a value between min and max. Returns 0 when
75
+ * the range has zero width. */
76
+ export const fractionOfValue = (model) => {
77
+ const range = model.max - model.min;
78
+ if (range <= 0) {
79
+ return 0;
80
+ }
81
+ else {
82
+ return clamp((model.value - model.min) / range, 0, 1);
83
+ }
84
+ };
85
+ const PAGE_STEP_MULTIPLIER = 10;
86
+ const nextValueForDirection = (model, direction) => M.value(direction).pipe(M.withReturnType(), M.when('StepIncrement', () => snapAndClamp(model.value + model.step, model.min, model.max, model.step)), M.when('StepDecrement', () => snapAndClamp(model.value - model.step, model.min, model.max, model.step)), M.when('PageIncrement', () => snapAndClamp(model.value + model.step * PAGE_STEP_MULTIPLIER, model.min, model.max, model.step)), M.when('PageDecrement', () => snapAndClamp(model.value - model.step * PAGE_STEP_MULTIPLIER, model.min, model.max, model.step)), M.when('Min', () => model.min), M.when('Max', () => model.max), M.exhaustive);
87
+ const withUpdateReturn = M.withReturnType();
88
+ const withValue = (model, nextValue, commands) => {
89
+ if (nextValue === model.value) {
90
+ return [model, commands, Option.none()];
91
+ }
92
+ else {
93
+ return [
94
+ evo(model, { value: () => nextValue }),
95
+ commands,
96
+ Option.some(ChangedValue({ value: nextValue })),
97
+ ];
98
+ }
99
+ };
100
+ /** Processes a slider message and returns the next model, commands, and an
101
+ * optional out-message for the parent. */
102
+ export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
103
+ PressedThumb: () => M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => [model, [], Option.none()]), M.orElse(() => [
104
+ evo(model, {
105
+ dragState: () => Dragging({ originValue: model.value }),
106
+ }),
107
+ [],
108
+ Option.none(),
109
+ ])),
110
+ // NOTE: the pointerdown event on the thumb bubbles to the track, so a
111
+ // thumb press also dispatches PressedPointer. Short-circuit when already
112
+ // Dragging so the bubbled track handler cannot shift the value away
113
+ // from the thumb's current position. Fine-grained sliders (e.g. step
114
+ // 0.05) see a visible jump without this guard, because the cursor sits
115
+ // off-center on a non-zero-width thumb.
116
+ PressedPointer: ({ value }) => M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => [model, [], Option.none()]), M.orElse(() => {
117
+ const snapped = snapAndClamp(value, model.min, model.max, model.step);
118
+ const [modelWithValue, commands, maybeOut] = withValue(model, snapped, []);
119
+ return [
120
+ evo(modelWithValue, {
121
+ dragState: () => Dragging({ originValue: model.value }),
122
+ }),
123
+ commands,
124
+ maybeOut,
125
+ ];
126
+ })),
127
+ MovedDragPointer: ({ value }) => M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => withValue(model, snapAndClamp(value, model.min, model.max, model.step), [])), M.orElse(() => [model, [], Option.none()])),
128
+ ReleasedDragPointer: () => M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', () => [
129
+ evo(model, { dragState: () => Idle() }),
130
+ [],
131
+ Option.none(),
132
+ ]), M.orElse(() => [model, [], Option.none()])),
133
+ CancelledDrag: () => M.value(model.dragState).pipe(withUpdateReturn, M.tag('Dragging', ({ originValue }) => {
134
+ const restored = evo(model, {
135
+ dragState: () => Idle(),
136
+ });
137
+ return withValue(restored, originValue, []);
138
+ }), M.orElse(() => [model, [], Option.none()])),
139
+ PressedKeyboardNavigation: ({ direction }) => withValue(model, nextValueForDirection(model, direction), []),
140
+ }));
141
+ // SUBSCRIPTION
142
+ const DragActivity = S.Literal('Idle', 'Active');
143
+ const dragActivityFromModel = (model) => M.value(model.dragState).pipe(M.withReturnType(), M.tag('Dragging', () => 'Active'), M.orElse(() => 'Idle'));
144
+ const trackElement = (id) => Option.fromNullable(document.querySelector(`[data-slider-track-id="${id}"]`));
145
+ const valueFromClientX = (clientX, trackElement_, min, max) => {
146
+ const rect = trackElement_.getBoundingClientRect();
147
+ if (rect.width === 0) {
148
+ return min;
149
+ }
150
+ else {
151
+ const fraction = clamp((clientX - rect.left) / rect.width, 0, 1);
152
+ return min + fraction * (max - min);
153
+ }
154
+ };
155
+ /** Schema describing the subscription dependencies for document-level drag
156
+ * tracking. */
157
+ export const SubscriptionDeps = S.Struct({
158
+ documentPointer: S.Struct({
159
+ dragActivity: DragActivity,
160
+ id: S.String,
161
+ min: S.Number,
162
+ max: S.Number,
163
+ }),
164
+ documentEscape: S.Struct({
165
+ dragActivity: DragActivity,
166
+ }),
167
+ });
168
+ /** Document-level subscriptions for pointer and keyboard events during slider
169
+ * drag. */
170
+ export const subscriptions = makeSubscriptions(SubscriptionDeps)({
171
+ documentPointer: {
172
+ modelToDependencies: model => ({
173
+ dragActivity: dragActivityFromModel(model),
174
+ id: model.id,
175
+ min: model.min,
176
+ max: model.max,
177
+ }),
178
+ dependenciesToStream: ({ dragActivity, id, min, max }) => {
179
+ const pointerEvents = Stream.merge(Stream.fromEventListener(document, 'pointermove').pipe(Stream.mapEffect(event => Effect.sync(() => Option.map(trackElement(id), element => MovedDragPointer({
180
+ value: valueFromClientX(event.clientX, element, min, max),
181
+ })))), Stream.filterMap(Function.identity)), Stream.fromEventListener(document, 'pointerup').pipe(Stream.map(() => ReleasedDragPointer())));
182
+ // NOTE: prevents text selection and locks cursor to grabbing while the
183
+ // user drags the thumb. Matches the approach used in drag-and-drop.
184
+ const documentDragStyles = Stream.async(_emit => {
185
+ document.documentElement.style.setProperty('user-select', 'none');
186
+ document.documentElement.style.setProperty('-webkit-user-select', 'none');
187
+ const cursorStyle = document.createElement('style');
188
+ cursorStyle.textContent = '* { cursor: grabbing !important; }';
189
+ document.head.appendChild(cursorStyle);
190
+ return Effect.sync(() => {
191
+ document.documentElement.style.removeProperty('user-select');
192
+ document.documentElement.style.removeProperty('-webkit-user-select');
193
+ cursorStyle.remove();
194
+ });
195
+ });
196
+ return Stream.when(Stream.merge(pointerEvents, documentDragStyles), () => dragActivity === 'Active');
197
+ },
198
+ },
199
+ documentEscape: {
200
+ modelToDependencies: model => ({
201
+ dragActivity: dragActivityFromModel(model),
202
+ }),
203
+ dependenciesToStream: ({ dragActivity }) => Stream.when(Stream.fromEventListener(document, 'keydown').pipe(Stream.filter(({ key }) => key === 'Escape'), Stream.map(() => CancelledDrag())), () => dragActivity === 'Active'),
204
+ },
205
+ });
206
+ // VIEW
207
+ const LEFT_MOUSE_BUTTON = 0;
208
+ const labelId = (id) => `${id}-label`;
209
+ const keyToDirection = (key) => M.value(key).pipe(M.withReturnType(), M.whenOr('ArrowRight', 'ArrowUp', () => 'StepIncrement'), M.whenOr('ArrowLeft', 'ArrowDown', () => 'StepDecrement'), M.when('PageUp', () => 'PageIncrement'), M.when('PageDown', () => 'PageDecrement'), M.when('Home', () => 'Min'), M.when('End', () => 'Max'), M.option);
210
+ const percentString = (fraction) => `${Math.round(fraction * 10000) / 100}%`;
211
+ /** Renders an accessible slider by building ARIA attribute groups and
212
+ * delegating layout to the consumer's `toView` callback. Follows the
213
+ * WAI-ARIA slider pattern — role="slider" on the thumb, aria-valuemin /
214
+ * aria-valuemax / aria-valuenow, keyboard navigation by step / page / home /
215
+ * end. Pointer drag is handled by the component's document-level
216
+ * subscriptions. */
217
+ export const view = (config) => {
218
+ const { AriaDisabled, AriaLabel, AriaLabelledBy, AriaOrientation, AriaValuemax, AriaValuemin, AriaValuenow, AriaValuetext, DataAttribute, Id, Name, OnKeyDownPreventDefault, OnPointerDown, Role, Style, Tabindex, Type, Value, } = html();
219
+ const { model, toParentMessage, formatValue, isDisabled = false, name, } = config;
220
+ const { id, value, min, max } = model;
221
+ const isDragging = model.dragState._tag === 'Dragging';
222
+ const fraction = fractionOfValue(model);
223
+ const handleKeyDown = (key) => Option.map(keyToDirection(key), direction => toParentMessage(PressedKeyboardNavigation({ direction })));
224
+ const pointerAtClientX = (clientX) => Option.map(trackElement(id), element => toParentMessage(PressedPointer({
225
+ value: valueFromClientX(clientX, element, min, max),
226
+ })));
227
+ const trackPointerHandler = (_pointerType, button, _screenX, _screenY, _timeStamp, clientX) => pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.flatMap(() => pointerAtClientX(clientX)));
228
+ const thumbPointerHandler = (_pointerType, button) => pipe(button, Option.liftPredicate(Equal.equals(LEFT_MOUSE_BUTTON)), Option.map(() => toParentMessage(PressedThumb())));
229
+ const stateAttributes = [
230
+ ...(isDragging ? [DataAttribute('dragging', '')] : []),
231
+ ...(isDisabled ? [DataAttribute('disabled', '')] : []),
232
+ ];
233
+ const rootAttributes = [
234
+ DataAttribute('slider-id', id),
235
+ DataAttribute('orientation', 'horizontal'),
236
+ ...stateAttributes,
237
+ ];
238
+ const trackInteractionAttributes = isDisabled
239
+ ? []
240
+ : [OnPointerDown(trackPointerHandler)];
241
+ const trackAttributes = [
242
+ DataAttribute('slider-track-id', id),
243
+ Style({ position: 'relative', 'touch-action': 'none' }),
244
+ ...stateAttributes,
245
+ ...trackInteractionAttributes,
246
+ ];
247
+ const filledTrackAttributes = [
248
+ Style({
249
+ position: 'absolute',
250
+ left: '0',
251
+ top: '0',
252
+ bottom: '0',
253
+ width: percentString(fraction),
254
+ 'pointer-events': 'none',
255
+ }),
256
+ ...stateAttributes,
257
+ ];
258
+ const resolveThumbLabel = () => {
259
+ if (config.ariaLabel !== undefined) {
260
+ return [AriaLabel(config.ariaLabel)];
261
+ }
262
+ else if (config.ariaLabelledBy !== undefined) {
263
+ return [AriaLabelledBy(config.ariaLabelledBy)];
264
+ }
265
+ else {
266
+ return [AriaLabelledBy(labelId(id))];
267
+ }
268
+ };
269
+ const thumbLabelAttributes = resolveThumbLabel();
270
+ const maybeAriaValuetext = formatValue !== undefined ? [AriaValuetext(formatValue(value))] : [];
271
+ const thumbInteractionAttributes = isDisabled
272
+ ? []
273
+ : [
274
+ OnPointerDown(thumbPointerHandler),
275
+ OnKeyDownPreventDefault(handleKeyDown),
276
+ ];
277
+ const thumbAttributes = [
278
+ Id(`${id}-thumb`),
279
+ Role('slider'),
280
+ Tabindex(0),
281
+ AriaOrientation('horizontal'),
282
+ AriaValuemin(min),
283
+ AriaValuemax(max),
284
+ AriaValuenow(value),
285
+ ...maybeAriaValuetext,
286
+ ...thumbLabelAttributes,
287
+ ...(isDisabled ? [AriaDisabled(true)] : []),
288
+ Style({
289
+ position: 'absolute',
290
+ left: percentString(fraction),
291
+ transform: 'translateX(-50%)',
292
+ 'touch-action': 'none',
293
+ }),
294
+ ...stateAttributes,
295
+ ...thumbInteractionAttributes,
296
+ ];
297
+ const labelAttributes = [Id(labelId(id))];
298
+ const hiddenInputAttributes = name !== undefined
299
+ ? [Type('hidden'), Name(name), Value(value.toString())]
300
+ : [];
301
+ return config.toView({
302
+ root: rootAttributes,
303
+ track: trackAttributes,
304
+ filledTrack: filledTrackAttributes,
305
+ thumb: thumbAttributes,
306
+ label: labelAttributes,
307
+ hiddenInput: hiddenInputAttributes,
308
+ });
309
+ };
310
+ /** Creates a memoized slider view. Static config is captured in a closure;
311
+ * only `model` and `toParentMessage` are compared per render via `createLazy`. */
312
+ export const lazy = (staticConfig) => {
313
+ const lazyView = createLazy();
314
+ return (model, toParentMessage) => lazyView((currentModel, currentToMessage) => view({
315
+ ...staticConfig,
316
+ model: currentModel,
317
+ toParentMessage: currentToMessage,
318
+ }), [model, toParentMessage]);
319
+ };
@@ -0,0 +1,3 @@
1
+ export { init, update, view, lazy, subscriptions, fractionOfValue, Model, Message, OutMessage, SubscriptionDeps, } from './index';
2
+ export type { InitConfig, ViewConfig, SliderAttributes, PressedThumb, PressedPointer, MovedDragPointer, ReleasedDragPointer, CancelledDrag, PressedKeyboardNavigation, } from './index';
3
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/slider/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,eAAe,EACf,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,GACjB,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EACb,yBAAyB,GAC1B,MAAM,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export { init, update, view, lazy, subscriptions, fractionOfValue, Model, Message, OutMessage, SubscriptionDeps, } from './index';
@@ -1,10 +1,10 @@
1
1
  import { Schema as S } from 'effect';
2
2
  import { type Attribute, type Html } from '../../html';
3
- import { Dismissed, DismissedAll, ElapsedDuration, GotTransitionMessage, HoveredEntry, LeftEntry, Position, Variant } from './schema';
3
+ import { Dismissed, DismissedAll, ElapsedDuration, GotAnimationMessage, HoveredEntry, LeftEntry, Position, Variant } from './schema';
4
4
  import { DismissAfter } from './update';
5
5
  export type { InitConfig } from './schema';
6
6
  export type { ShowInput } from './update';
7
- export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotTransitionMessage, DismissAfter, };
7
+ export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, };
8
8
  /** Handlers passed to `renderEntry`. Attach `dismiss` to a close button's
9
9
  * `OnClick` to let users dismiss the entry manually. */
10
10
  export type EntryHandlers<ParentMessage> = Readonly<{
@@ -18,7 +18,7 @@ export type EntryHandlers<ParentMessage> = Readonly<{
18
18
  * The payload is whatever content shape the consumer supplies via Schema.
19
19
  * The component never reads it — it flows through to `renderEntry`. The
20
20
  * component itself owns only lifecycle and a11y fields (id, variant,
21
- * transition, dismiss timer, hover state).
21
+ * animation, dismiss timer, hover state).
22
22
  *
23
23
  * Consume the bound module's exports everywhere — `Toast.Model` in your app
24
24
  * Model, `Toast.Message` in your parent Message union, `Toast.show` /
@@ -44,7 +44,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
44
44
  model: {
45
45
  readonly entries: readonly {
46
46
  readonly id: string;
47
- readonly transition: {
47
+ readonly animation: {
48
48
  readonly id: string;
49
49
  readonly isShowing: boolean;
50
50
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -63,7 +63,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
63
63
  toParentMessage: (message: Dismissed | HoveredEntry | LeftEntry) => ParentMessage;
64
64
  renderEntry: (entry: {
65
65
  readonly id: string;
66
- readonly transition: {
66
+ readonly animation: {
67
67
  readonly id: string;
68
68
  readonly isShowing: boolean;
69
69
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -86,7 +86,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
86
86
  model: {
87
87
  readonly entries: readonly {
88
88
  readonly id: string;
89
- readonly transition: {
89
+ readonly animation: {
90
90
  readonly id: string;
91
91
  readonly isShowing: boolean;
92
92
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -105,7 +105,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
105
105
  toParentMessage: (message: Dismissed | HoveredEntry | LeftEntry) => ParentMessage;
106
106
  renderEntry: (entry: {
107
107
  readonly id: string;
108
- readonly transition: {
108
+ readonly animation: {
109
109
  readonly id: string;
110
110
  readonly isShowing: boolean;
111
111
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -126,7 +126,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
126
126
  }>, "model" | "toParentMessage" | "renderEntry">) => ((model: {
127
127
  readonly entries: readonly {
128
128
  readonly id: string;
129
- readonly transition: {
129
+ readonly animation: {
130
130
  readonly id: string;
131
131
  readonly isShowing: boolean;
132
132
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -142,7 +142,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
142
142
  readonly nextEntryKey: number;
143
143
  }, toParentMessage: (message: Dismissed | HoveredEntry | LeftEntry) => ParentMessage, renderEntry: (entry: {
144
144
  readonly id: string;
145
- readonly transition: {
145
+ readonly animation: {
146
146
  readonly id: string;
147
147
  readonly isShowing: boolean;
148
148
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -158,7 +158,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
158
158
  readonly Entry: S.Struct<{
159
159
  id: typeof S.String;
160
160
  variant: S.Literal<["Info", "Success", "Warning", "Error"]>;
161
- transition: S.Struct<{
161
+ animation: S.Struct<{
162
162
  id: typeof S.String;
163
163
  isShowing: typeof S.Boolean;
164
164
  transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
@@ -174,7 +174,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
174
174
  entries: S.Array$<S.Struct<{
175
175
  id: typeof S.String;
176
176
  variant: S.Literal<["Info", "Success", "Warning", "Error"]>;
177
- transition: S.Struct<{
177
+ animation: S.Struct<{
178
178
  id: typeof S.String;
179
179
  isShowing: typeof S.Boolean;
180
180
  transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
@@ -190,7 +190,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
190
190
  entry: S.Struct<{
191
191
  id: typeof S.String;
192
192
  variant: S.Literal<["Info", "Success", "Warning", "Error"]>;
193
- transition: S.Struct<{
193
+ animation: S.Struct<{
194
194
  id: typeof S.String;
195
195
  isShowing: typeof S.Boolean;
196
196
  transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
@@ -209,15 +209,15 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
209
209
  entryId: typeof S.String;
210
210
  }>, import("../../schema").CallableTaggedStruct<"LeftEntry", {
211
211
  entryId: typeof S.String;
212
- }>, import("../../schema").CallableTaggedStruct<"GotTransitionMessage", {
212
+ }>, import("../../schema").CallableTaggedStruct<"GotAnimationMessage", {
213
213
  entryId: typeof S.String;
214
- message: S.Union<[import("../../schema").CallableTaggedStruct<"Showed", {}>, import("../../schema").CallableTaggedStruct<"Hid", {}>, import("../../schema").CallableTaggedStruct<"AdvancedTransitionFrame", {}>, import("../../schema").CallableTaggedStruct<"EndedTransition", {}>]>;
214
+ message: S.Union<[import("../../schema").CallableTaggedStruct<"Showed", {}>, import("../../schema").CallableTaggedStruct<"Hid", {}>, import("../../schema").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("../../schema").CallableTaggedStruct<"EndedAnimation", {}>]>;
215
215
  }>]>;
216
216
  readonly Added: import("../../schema").CallableTaggedStruct<"Added", {
217
217
  entry: S.Struct<{
218
218
  id: typeof S.String;
219
219
  variant: S.Literal<["Info", "Success", "Warning", "Error"]>;
220
- transition: S.Struct<{
220
+ animation: S.Struct<{
221
221
  id: typeof S.String;
222
222
  isShowing: typeof S.Boolean;
223
223
  transitionState: S.Literal<["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
@@ -234,7 +234,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
234
234
  }>) => {
235
235
  readonly entries: readonly {
236
236
  readonly id: string;
237
- readonly transition: {
237
+ readonly animation: {
238
238
  readonly id: string;
239
239
  readonly isShowing: boolean;
240
240
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -252,7 +252,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
252
252
  readonly update: (model: {
253
253
  readonly entries: readonly {
254
254
  readonly id: string;
255
- readonly transition: {
255
+ readonly animation: {
256
256
  readonly id: string;
257
257
  readonly isShowing: boolean;
258
258
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -282,22 +282,22 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
282
282
  readonly _tag: "LeftEntry";
283
283
  readonly entryId: string;
284
284
  } | {
285
- readonly _tag: "GotTransitionMessage";
285
+ readonly _tag: "GotAnimationMessage";
286
286
  readonly message: {
287
287
  readonly _tag: "Showed";
288
288
  } | {
289
289
  readonly _tag: "Hid";
290
290
  } | {
291
- readonly _tag: "AdvancedTransitionFrame";
291
+ readonly _tag: "AdvancedAnimationFrame";
292
292
  } | {
293
- readonly _tag: "EndedTransition";
293
+ readonly _tag: "EndedAnimation";
294
294
  };
295
295
  readonly entryId: string;
296
296
  } | {
297
297
  readonly _tag: "Added";
298
298
  readonly entry: {
299
299
  readonly id: string;
300
- readonly transition: {
300
+ readonly animation: {
301
301
  readonly id: string;
302
302
  readonly isShowing: boolean;
303
303
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -311,7 +311,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
311
311
  }) => readonly [{
312
312
  readonly entries: readonly {
313
313
  readonly id: string;
314
- readonly transition: {
314
+ readonly animation: {
315
315
  readonly id: string;
316
316
  readonly isShowing: boolean;
317
317
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -343,22 +343,22 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
343
343
  readonly _tag: "LeftEntry";
344
344
  readonly entryId: string;
345
345
  } | {
346
- readonly _tag: "GotTransitionMessage";
346
+ readonly _tag: "GotAnimationMessage";
347
347
  readonly message: {
348
348
  readonly _tag: "Showed";
349
349
  } | {
350
350
  readonly _tag: "Hid";
351
351
  } | {
352
- readonly _tag: "AdvancedTransitionFrame";
352
+ readonly _tag: "AdvancedAnimationFrame";
353
353
  } | {
354
- readonly _tag: "EndedTransition";
354
+ readonly _tag: "EndedAnimation";
355
355
  };
356
356
  readonly entryId: string;
357
357
  } | {
358
358
  readonly _tag: "Added";
359
359
  readonly entry: {
360
360
  readonly id: string;
361
- readonly transition: {
361
+ readonly animation: {
362
362
  readonly id: string;
363
363
  readonly isShowing: boolean;
364
364
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -374,7 +374,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
374
374
  readonly show: (model: {
375
375
  readonly entries: readonly {
376
376
  readonly id: string;
377
- readonly transition: {
377
+ readonly animation: {
378
378
  readonly id: string;
379
379
  readonly isShowing: boolean;
380
380
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -396,7 +396,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
396
396
  }>) => readonly [{
397
397
  readonly entries: readonly {
398
398
  readonly id: string;
399
- readonly transition: {
399
+ readonly animation: {
400
400
  readonly id: string;
401
401
  readonly isShowing: boolean;
402
402
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -428,22 +428,22 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
428
428
  readonly _tag: "LeftEntry";
429
429
  readonly entryId: string;
430
430
  } | {
431
- readonly _tag: "GotTransitionMessage";
431
+ readonly _tag: "GotAnimationMessage";
432
432
  readonly message: {
433
433
  readonly _tag: "Showed";
434
434
  } | {
435
435
  readonly _tag: "Hid";
436
436
  } | {
437
- readonly _tag: "AdvancedTransitionFrame";
437
+ readonly _tag: "AdvancedAnimationFrame";
438
438
  } | {
439
- readonly _tag: "EndedTransition";
439
+ readonly _tag: "EndedAnimation";
440
440
  };
441
441
  readonly entryId: string;
442
442
  } | {
443
443
  readonly _tag: "Added";
444
444
  readonly entry: {
445
445
  readonly id: string;
446
- readonly transition: {
446
+ readonly animation: {
447
447
  readonly id: string;
448
448
  readonly isShowing: boolean;
449
449
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -459,7 +459,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
459
459
  readonly dismiss: (model: {
460
460
  readonly entries: readonly {
461
461
  readonly id: string;
462
- readonly transition: {
462
+ readonly animation: {
463
463
  readonly id: string;
464
464
  readonly isShowing: boolean;
465
465
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -476,7 +476,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
476
476
  }, entryId: string) => readonly [{
477
477
  readonly entries: readonly {
478
478
  readonly id: string;
479
- readonly transition: {
479
+ readonly animation: {
480
480
  readonly id: string;
481
481
  readonly isShowing: boolean;
482
482
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -508,22 +508,22 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
508
508
  readonly _tag: "LeftEntry";
509
509
  readonly entryId: string;
510
510
  } | {
511
- readonly _tag: "GotTransitionMessage";
511
+ readonly _tag: "GotAnimationMessage";
512
512
  readonly message: {
513
513
  readonly _tag: "Showed";
514
514
  } | {
515
515
  readonly _tag: "Hid";
516
516
  } | {
517
- readonly _tag: "AdvancedTransitionFrame";
517
+ readonly _tag: "AdvancedAnimationFrame";
518
518
  } | {
519
- readonly _tag: "EndedTransition";
519
+ readonly _tag: "EndedAnimation";
520
520
  };
521
521
  readonly entryId: string;
522
522
  } | {
523
523
  readonly _tag: "Added";
524
524
  readonly entry: {
525
525
  readonly id: string;
526
- readonly transition: {
526
+ readonly animation: {
527
527
  readonly id: string;
528
528
  readonly isShowing: boolean;
529
529
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -539,7 +539,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
539
539
  readonly dismissAll: (model: {
540
540
  readonly entries: readonly {
541
541
  readonly id: string;
542
- readonly transition: {
542
+ readonly animation: {
543
543
  readonly id: string;
544
544
  readonly isShowing: boolean;
545
545
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -556,7 +556,7 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
556
556
  }) => readonly [{
557
557
  readonly entries: readonly {
558
558
  readonly id: string;
559
- readonly transition: {
559
+ readonly animation: {
560
560
  readonly id: string;
561
561
  readonly isShowing: boolean;
562
562
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
@@ -588,22 +588,22 @@ export declare const make: <A, I>(payloadSchema: S.Schema<A, I>) => {
588
588
  readonly _tag: "LeftEntry";
589
589
  readonly entryId: string;
590
590
  } | {
591
- readonly _tag: "GotTransitionMessage";
591
+ readonly _tag: "GotAnimationMessage";
592
592
  readonly message: {
593
593
  readonly _tag: "Showed";
594
594
  } | {
595
595
  readonly _tag: "Hid";
596
596
  } | {
597
- readonly _tag: "AdvancedTransitionFrame";
597
+ readonly _tag: "AdvancedAnimationFrame";
598
598
  } | {
599
- readonly _tag: "EndedTransition";
599
+ readonly _tag: "EndedAnimation";
600
600
  };
601
601
  readonly entryId: string;
602
602
  } | {
603
603
  readonly _tag: "Added";
604
604
  readonly entry: {
605
605
  readonly id: string;
606
- readonly transition: {
606
+ readonly animation: {
607
607
  readonly id: string;
608
608
  readonly isShowing: boolean;
609
609
  readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";