@foldkit/ui 0.162.0 → 0.163.0-canary.1a3dd68616dc

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 (86) hide show
  1. package/dist/anchor/anchor.d.ts.map +1 -1
  2. package/dist/anchor/anchor.js +10 -1
  3. package/dist/animation/update.d.ts.map +1 -1
  4. package/dist/animation/update.js +11 -7
  5. package/dist/calendar/index.d.ts.map +1 -1
  6. package/dist/calendar/index.js +27 -19
  7. package/dist/checkbox/index.d.ts +1 -1
  8. package/dist/checkbox/index.js +1 -1
  9. package/dist/combobox/multi.js +2 -2
  10. package/dist/combobox/shared.js +15 -15
  11. package/dist/combobox/single.js +4 -4
  12. package/dist/datePicker/index.d.ts.map +1 -1
  13. package/dist/datePicker/index.js +10 -10
  14. package/dist/dialog/index.js +9 -9
  15. package/dist/disclosure/index.d.ts +2 -2
  16. package/dist/disclosure/index.js +1 -1
  17. package/dist/dragAndDrop/index.js +14 -14
  18. package/dist/fileDrop/index.d.ts.map +1 -1
  19. package/dist/fileDrop/index.js +7 -5
  20. package/dist/hoverIntent/hoverIntent.d.ts.map +1 -1
  21. package/dist/hoverIntent/hoverIntent.js +16 -16
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -0
  25. package/dist/internal/accessibleName.d.ts +9 -0
  26. package/dist/internal/accessibleName.d.ts.map +1 -0
  27. package/dist/internal/accessibleName.js +12 -0
  28. package/dist/internal/range.d.ts +7 -0
  29. package/dist/internal/range.d.ts.map +1 -0
  30. package/dist/internal/range.js +12 -0
  31. package/dist/listbox/shared.d.ts.map +1 -1
  32. package/dist/listbox/shared.js +20 -18
  33. package/dist/menu/index.d.ts.map +1 -1
  34. package/dist/menu/index.js +23 -17
  35. package/dist/meter/index.d.ts +26 -0
  36. package/dist/meter/index.d.ts.map +1 -0
  37. package/dist/meter/index.js +67 -0
  38. package/dist/meter/public.d.ts +3 -0
  39. package/dist/meter/public.d.ts.map +1 -0
  40. package/dist/meter/public.js +1 -0
  41. package/dist/popover/index.d.ts.map +1 -1
  42. package/dist/popover/index.js +12 -10
  43. package/dist/progress/index.d.ts +24 -0
  44. package/dist/progress/index.d.ts.map +1 -0
  45. package/dist/progress/index.js +85 -0
  46. package/dist/progress/public.d.ts +3 -0
  47. package/dist/progress/public.d.ts.map +1 -0
  48. package/dist/progress/public.js +1 -0
  49. package/dist/radioGroup/index.d.ts.map +1 -1
  50. package/dist/radioGroup/index.js +5 -3
  51. package/dist/slider/index.d.ts +61 -28
  52. package/dist/slider/index.d.ts.map +1 -1
  53. package/dist/slider/index.js +163 -87
  54. package/dist/slider/public.d.ts +1 -1
  55. package/dist/slider/public.d.ts.map +1 -1
  56. package/dist/slider/public.js +1 -1
  57. package/dist/switch/index.d.ts +1 -1
  58. package/dist/switch/index.js +1 -1
  59. package/dist/tabs/index.d.ts.map +1 -1
  60. package/dist/tabs/index.js +5 -3
  61. package/dist/test/apps/disabledButton.d.ts +2 -2
  62. package/dist/test/apps/disabledButton.d.ts.map +1 -1
  63. package/dist/test/apps/disabledButton.js +3 -3
  64. package/dist/toast/index.d.ts +822 -43
  65. package/dist/toast/index.d.ts.map +1 -1
  66. package/dist/toast/index.js +77 -17
  67. package/dist/toast/public.d.ts +2 -2
  68. package/dist/toast/public.d.ts.map +1 -1
  69. package/dist/toast/public.js +1 -1
  70. package/dist/toast/schema.d.ts +145 -2
  71. package/dist/toast/schema.d.ts.map +1 -1
  72. package/dist/toast/schema.js +69 -2
  73. package/dist/toast/swipeTarget.d.ts +5 -0
  74. package/dist/toast/swipeTarget.d.ts.map +1 -0
  75. package/dist/toast/swipeTarget.js +18 -0
  76. package/dist/toast/test.d.ts +1 -1
  77. package/dist/toast/test.js +1 -1
  78. package/dist/toast/update.d.ts +726 -5
  79. package/dist/toast/update.d.ts.map +1 -1
  80. package/dist/toast/update.js +283 -68
  81. package/dist/tooltip/tooltip.d.ts +7 -7
  82. package/dist/tooltip/tooltip.d.ts.map +1 -1
  83. package/dist/tooltip/tooltip.js +14 -12
  84. package/dist/virtualList/index.d.ts.map +1 -1
  85. package/dist/virtualList/index.js +8 -6
  86. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAmB,MAAM,cAAc,CAAA;AAG9E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAe,MAAM,aAAa,CAAA;AAE9D,YAAY,EACV,4BAA4B,EAC5B,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAA;AAwE1D;;;;qDAIqD;AACrD,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;CACvC,CAAC,CAAA;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,iBAAiB,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAU9C,QAAQ;qBACL,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAO,EAAE,QAAQ,EAAE,aAAa,KAAK,IAAI;oBAChD,MAAM;6BACG,MAAM;yBACV,MAAM;;CA6K1B,CAAA"}
@@ -1,11 +1,13 @@
1
1
  import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
- import { Match } from 'effect';
2
+ import { Match, Option } from 'effect';
3
3
  import { childAttributes } from 'foldkit/html';
4
4
  import { defineView } from 'foldkit/submodel';
5
- import { Message, Position, Variant } from './schema.js';
6
- import { WaitBeforeDismissal, makeRuntime } from './update.js';
5
+ import { SwipeState } from './schema.js';
6
+ import { isSwipeExcludedTarget } from './swipeTarget.js';
7
+ import { makeRuntime } from './update.js';
7
8
  export * as test from './test.js';
8
- export { Message, Variant, Position, WaitBeforeDismissal };
9
+ export { Message, Variant, Position, SwipeDirection, SwipeState, DEFAULT_SWIPE_DIRECTION, DEFAULT_SWIPE_THRESHOLD, SWIPE_SETTLE_DURATION, } from './schema.js';
10
+ export { WaitBeforeDismissal, WaitForSwipeSettled, swipeOffset, } from './update.js';
9
11
  const variantToRole = (variant) => __foldkitBrandViewResult((Match.value(variant).pipe(Match.withReturnType(), Match.when('Info', () => __foldkitBrandViewResult(('status'), "@foldkit/ui/toast/index.js#anonymous")), Match.when('Success', () => __foldkitBrandViewResult(('status'), "@foldkit/ui/toast/index.js#anonymous~2")), Match.when('Warning', () => __foldkitBrandViewResult(('alert'), "@foldkit/ui/toast/index.js#anonymous~3")), Match.when('Error', () => __foldkitBrandViewResult(('alert'), "@foldkit/ui/toast/index.js#anonymous~4")), Match.exhaustive)), "@foldkit/ui/toast/index.js#variantToRole");
10
12
  const positionToContainerStyle = (position) => {
11
13
  const base = {
@@ -51,6 +53,7 @@ const positionToContainerStyle = (position) => {
51
53
  }), "@foldkit/ui/toast/index.js#anonymous~10"))), Match.exhaustive)), "@foldkit/ui/toast/index.js#positionToContainerStyle");
52
54
  };
53
55
  const DEFAULT_ARIA_LABEL = 'Notifications';
56
+ const LEFT_MOUSE_BUTTON = 0;
54
57
  /** Factory that binds `Toast` to a user-provided payload schema. The
55
58
  * returned module contains everything needed to wire a toast stack into an
56
59
  * app: `Model`, `Message`, `Entry`, `Added`, `init`, `update`, `show` /
@@ -58,16 +61,15 @@ const DEFAULT_ARIA_LABEL = 'Notifications';
58
61
  *
59
62
  * The payload is whatever content shape the consumer supplies via Schema.
60
63
  * The component never reads it. It flows through to `entryToView`. The
61
- * component itself owns only lifecycle and a11y fields (id, variant,
62
- * animation, dismiss timer, hover state).
64
+ * component owns the entry's lifecycle, accessibility role, dismiss timer,
65
+ * hover state, and swipe state.
63
66
  *
64
67
  * Consume the bound module's exports everywhere. `Toast.Model` in your app
65
68
  * Model, `Toast.Message` in your parent Message union, `Toast.show` /
66
69
  * `Toast.dismiss` in your update, `Toast.view` in your view. The top-level
67
- * exports (`Variant`, `Position`, static message tags,
68
- * `WaitBeforeDismissal`) are
69
- * payload-independent and safe to reference when you need them without a
70
- * bound module, but the typical path is through the factory return.
70
+ * exports provide payload-independent Schemas, constants, and Commands.
71
+ * Use the bound module for the payload-specific Model, Message, helpers,
72
+ * and view.
71
73
  *
72
74
  * @example
73
75
  * ```ts
@@ -82,13 +84,19 @@ const DEFAULT_ARIA_LABEL = 'Notifications';
82
84
  * ```
83
85
  */
84
86
  export const make = (payloadSchema) => {
85
- const runtime = makeRuntime(payloadSchema);
87
+ const toast = makeRuntime(payloadSchema);
86
88
  /** Renders a headless toast stack. The `<div>` container is always present
87
89
  * in the DOM so screen readers can observe its `aria-live` region from
88
90
  * page load. Each entry becomes a `<div>` keyed by its id, with
89
91
  * animation data attributes (`data-enter`, `data-leave`,
90
92
  * `data-transition`, `data-closed`) and `data-variant` reflecting the
91
- * entry's variant. */
93
+ * entry's variant. When swipe is enabled via `swipeToDismiss`, entries
94
+ * also carry `data-swipe` (`move` while dragging, `settling` while
95
+ * returning to rest, and `end` while dismissing) with an inline
96
+ * `translate` property. On a successful swipe, the entry moves from its
97
+ * release offset to `100vw` or `-100vw` when leave animation begins.
98
+ * The offset lives on `translate` rather than `transform` so it composes
99
+ * with your `transform` animations instead of overriding them. */
92
100
  const view = defineView((model, viewInputs, h) => {
93
101
  const { id, entries } = model;
94
102
  const { position, entryToView, ariaLabel = DEFAULT_ARIA_LABEL, containerClassName, entryClassName, } = viewInputs;
@@ -117,20 +125,72 @@ export const make = (payloadSchema) => {
117
125
  h.DataAttribute('leave', ''),
118
126
  h.DataAttribute('transition', ''),
119
127
  ]), "@foldkit/ui/toast/index.js#anonymous~15")), Match.orElse(() => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/index.js#anonymous~16")));
128
+ const swipeOffset = toast.swipeOffset(entry.swipeState);
129
+ const maybeSwipePhase = SwipeState.match(entry.swipeState, {
130
+ Idle: () => __foldkitBrandViewResult((Option.none()), "@foldkit/ui/toast/index.js#Idle"),
131
+ Dragging: () => __foldkitBrandViewResult((Option.some('move')), "@foldkit/ui/toast/index.js#Dragging"),
132
+ Settling: () => __foldkitBrandViewResult((Option.some('settling')), "@foldkit/ui/toast/index.js#Settling"),
133
+ Dismissing: () => __foldkitBrandViewResult((Option.some('end')), "@foldkit/ui/toast/index.js#Dismissing"),
134
+ });
135
+ const swipeExitTranslate = SwipeState.match(entry.swipeState, {
136
+ Idle: () => __foldkitBrandViewResult((undefined), "@foldkit/ui/toast/index.js#Idle~2"),
137
+ Dragging: () => __foldkitBrandViewResult((undefined), "@foldkit/ui/toast/index.js#Dragging~2"),
138
+ Settling: () => __foldkitBrandViewResult((undefined), "@foldkit/ui/toast/index.js#Settling~2"),
139
+ Dismissing: ({ direction }) => {
140
+ if (transitionState !== 'LeaveAnimating') {
141
+ return __foldkitBrandViewResult((undefined), "@foldkit/ui/toast/index.js#Dismissing~2");
142
+ }
143
+ return __foldkitBrandViewResult((Match.value(direction).pipe(Match.when('Right', () => __foldkitBrandViewResult(('100vw'), "@foldkit/ui/toast/index.js#anonymous~17")), Match.when('Left', () => __foldkitBrandViewResult(('-100vw'), "@foldkit/ui/toast/index.js#anonymous~18")), Match.exhaustive)), "@foldkit/ui/toast/index.js#Dismissing~2");
144
+ },
145
+ });
146
+ const swipeTranslate = swipeExitTranslate ??
147
+ (swipeOffset !== 0 ? `${String(swipeOffset)}px` : undefined);
148
+ const swipeAttributes = Option.match(maybeSwipePhase, {
149
+ onNone: () => __foldkitBrandViewResult(([]), "@foldkit/ui/toast/index.js#onNone"),
150
+ onSome: phase => __foldkitBrandViewResult(([h.DataAttribute('swipe', phase)]), "@foldkit/ui/toast/index.js#onSome"),
151
+ });
152
+ const handlePointerDown = (pointerType, button, _screenX, _screenY, _timeStamp, clientX, _clientY, pointerId, target) => {
153
+ if ((pointerType === 'mouse' && button !== LEFT_MOUSE_BUTTON) ||
154
+ isSwipeExcludedTarget(pointerType, target)) {
155
+ return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/toast/index.js#handlePointerDown");
156
+ }
157
+ else {
158
+ return __foldkitBrandViewResult((Option.some(toast.Message.PressedEntryPointer({
159
+ entryId: entry.id,
160
+ pointerId,
161
+ clientX,
162
+ }))), "@foldkit/ui/toast/index.js#handlePointerDown");
163
+ }
164
+ };
120
165
  const itemAttributes = [
121
166
  h.Id(entry.id),
122
167
  h.Role(variantToRole(entry.variant)),
123
168
  h.AriaAtomic(true),
124
169
  h.DataAttribute('variant', entry.variant),
125
- h.Style({ pointerEvents: 'auto' }),
126
- h.OnMouseEnter(runtime.Message.HoveredEntry({ entryId: entry.id })),
127
- h.OnMouseLeave(runtime.Message.LeftEntry({ entryId: entry.id })),
170
+ h.Style({
171
+ pointerEvents: 'auto',
172
+ ...(Option.isSome(model.maybeSwipeConfig)
173
+ ? { touchAction: 'pan-y' }
174
+ : {}),
175
+ ...(swipeTranslate !== undefined
176
+ ? {
177
+ translate: swipeTranslate,
178
+ '--toast-swipe-move-x': `${String(swipeOffset)}px`,
179
+ }
180
+ : {}),
181
+ }),
182
+ h.OnMouseEnter(toast.Message.HoveredEntry({ entryId: entry.id })),
183
+ h.OnMouseLeave(toast.Message.LeftEntry({ entryId: entry.id })),
184
+ ...(Option.isSome(model.maybeSwipeConfig)
185
+ ? [h.OnPointerDown(handlePointerDown)]
186
+ : []),
128
187
  ...animationAttributes,
188
+ ...swipeAttributes,
129
189
  ...(entryClassName ? [h.Class(entryClassName)] : []),
130
190
  ];
131
191
  const handlers = {
132
192
  dismiss: childAttributes([
133
- h.OnClick(runtime.Message.Dismissed({ entryId: entry.id })),
193
+ h.OnClick(toast.Message.Dismissed({ entryId: entry.id })),
134
194
  ]),
135
195
  };
136
196
  return __foldkitBrandViewResult((h.keyed('div')(entry.id, itemAttributes, [
@@ -140,7 +200,7 @@ export const make = (payloadSchema) => {
140
200
  return __foldkitBrandViewResult((h.keyed('div')(id, containerAttributes, entries.map(renderEntryItem))), "@foldkit/ui/toast/index.js#anonymous~11");
141
201
  });
142
202
  return __foldkitBrandViewResult(({
143
- ...runtime,
203
+ ...toast,
144
204
  view,
145
205
  }), "@foldkit/ui/toast/index.js#make");
146
206
  };
@@ -1,6 +1,6 @@
1
- export { make, Message, Variant, Position, type Dismissed, type DismissedAll, type CompletedWaitBeforeDismissal, type HoveredEntry, type LeftEntry, type GotAnimationMessage, WaitBeforeDismissal, } from './index.js';
1
+ export { make, Message, Variant, Position, SwipeDirection, SwipeState, DEFAULT_SWIPE_DIRECTION, DEFAULT_SWIPE_THRESHOLD, SWIPE_SETTLE_DURATION, swipeOffset, type Dismissed, type DismissedAll, type CompletedWaitBeforeDismissal, type HoveredEntry, type LeftEntry, type GotAnimationMessage, type PressedEntryPointer, type MovedSwipePointer, type ReleasedSwipePointer, type CancelledSwipe, type PressedEscape, type CompletedWaitForSwipeSettled, WaitBeforeDismissal, WaitForSwipeSettled, } from './index.js';
2
2
  export * as test from './test.js';
3
3
  export type { EntryHandlers } from './index.js';
4
- export type { InitConfig, ShowInput } from './index.js';
4
+ export type { InitConfig, ShowInput, SwipeToDismissConfig } from './index.js';
5
5
  export type { DrainEntryInput } from './test.js';
6
6
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/toast/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,4BAA4B,EACjC,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/toast/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,cAAc,EACd,UAAU,EACV,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,WAAW,EACX,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,4BAA4B,EACjC,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,4BAA4B,EACjC,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC7E,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA"}
@@ -1,2 +1,2 @@
1
- export { make, Message, Variant, Position, WaitBeforeDismissal, } from './index.js';
1
+ export { make, Message, Variant, Position, SwipeDirection, SwipeState, DEFAULT_SWIPE_DIRECTION, DEFAULT_SWIPE_THRESHOLD, SWIPE_SETTLE_DURATION, swipeOffset, WaitBeforeDismissal, WaitForSwipeSettled, } from './index.js';
2
2
  export * as test from './test.js';
@@ -9,12 +9,46 @@ export type Variant = typeof Variant.Type;
9
9
  /** Where the toast viewport is anchored on the screen and how entries stack. */
10
10
  export declare const Position: Schema.Literals<readonly ["TopLeft", "TopCenter", "TopRight", "BottomLeft", "BottomCenter", "BottomRight"]>;
11
11
  export type Position = typeof Position.Type;
12
+ /** Direction in which a pointer can drag an entry to dismiss it. */
13
+ export declare const SwipeDirection: Schema.Literals<readonly ["Left", "Right"]>;
14
+ export type SwipeDirection = typeof SwipeDirection.Type;
15
+ /** Per-entry swipe gesture state. `Dragging` retains the initiating
16
+ * `pointerId`, so move, release, and cancel Messages update only the entry
17
+ * that started the gesture and ignore unrelated touches. `Settling` returns
18
+ * a cancelled or short swipe to rest. `Dismissing` retains the release offset
19
+ * and direction while the leave animation carries the entry off-screen. The
20
+ * settle generation lives in the entry's `swipeVersion` so a stale settle
21
+ * timer cannot clear a later gesture. */
22
+ export declare const SwipeState: import("foldkit/schema").TaggedUnion<{
23
+ readonly Idle: {};
24
+ readonly Dragging: {
25
+ pointerId: Schema.Number;
26
+ startX: Schema.Number;
27
+ currentX: Schema.Number;
28
+ };
29
+ readonly Settling: {
30
+ offsetX: Schema.Number;
31
+ };
32
+ readonly Dismissing: {
33
+ offsetX: Schema.Number;
34
+ direction: Schema.Literals<readonly ["Left", "Right"]>;
35
+ };
36
+ }>;
37
+ export type SwipeState = typeof SwipeState.Type;
38
+ /** Default distance in pixels a pointer must travel to dismiss a Toast. */
39
+ export declare const DEFAULT_SWIPE_THRESHOLD = 40;
40
+ /** Default direction in which a pointer can dismiss a Toast. */
41
+ export declare const DEFAULT_SWIPE_DIRECTION: SwipeDirection;
42
+ /** Time an entry remains in `Settling` after a short or cancelled swipe,
43
+ * allowing consumer CSS to animate it back to rest. */
44
+ export declare const SWIPE_SETTLE_DURATION: Duration.Duration;
12
45
  /** Schema factory for a single toast entry. `payloadSchema` is user-provided
13
46
  * and defines the shape of per-entry content, whatever the consumer wants
14
47
  * to encode. The component itself owns only lifecycle + a11y fields: `id`,
15
48
  * `variant` (for ARIA role), `animation`, `maybeDuration`,
16
- * `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
17
- * (for pause-on-hover). */
49
+ * `pendingDismissVersion` (for cancellable auto-dismiss), `isHovered`
50
+ * (for pause-on-hover), and `swipeState` + `swipeVersion` (for the
51
+ * opt-in swipe gesture). */
18
52
  export declare const makeEntry: <A, I>(payloadSchema: Schema.Codec<A, I>) => Schema.Struct<{
19
53
  readonly id: Schema.String;
20
54
  readonly variant: Schema.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
@@ -26,6 +60,22 @@ export declare const makeEntry: <A, I>(payloadSchema: Schema.Codec<A, I>) => Sch
26
60
  readonly maybeDuration: Schema.Option<Schema.DurationFromMillis>;
27
61
  readonly pendingDismissVersion: Schema.Number;
28
62
  readonly isHovered: Schema.Boolean;
63
+ readonly swipeState: import("foldkit/schema").TaggedUnion<{
64
+ readonly Idle: {};
65
+ readonly Dragging: {
66
+ pointerId: Schema.Number;
67
+ startX: Schema.Number;
68
+ currentX: Schema.Number;
69
+ };
70
+ readonly Settling: {
71
+ offsetX: Schema.Number;
72
+ };
73
+ readonly Dismissing: {
74
+ offsetX: Schema.Number;
75
+ direction: Schema.Literals<readonly ["Left", "Right"]>;
76
+ };
77
+ }>;
78
+ readonly swipeVersion: Schema.Number;
29
79
  readonly payload: Schema.Codec<A, I, never, never>;
30
80
  }>;
31
81
  /** Schema factory for the toast container's state. `nextEntryKey` is a
@@ -47,9 +97,29 @@ export declare const makeModel: <A, I>(payloadSchema: Schema.Codec<A, I>) => Sch
47
97
  readonly maybeDuration: Schema.Option<Schema.DurationFromMillis>;
48
98
  readonly pendingDismissVersion: Schema.Number;
49
99
  readonly isHovered: Schema.Boolean;
100
+ readonly swipeState: import("foldkit/schema").TaggedUnion<{
101
+ readonly Idle: {};
102
+ readonly Dragging: {
103
+ pointerId: Schema.Number;
104
+ startX: Schema.Number;
105
+ currentX: Schema.Number;
106
+ };
107
+ readonly Settling: {
108
+ offsetX: Schema.Number;
109
+ };
110
+ readonly Dismissing: {
111
+ offsetX: Schema.Number;
112
+ direction: Schema.Literals<readonly ["Left", "Right"]>;
113
+ };
114
+ }>;
115
+ readonly swipeVersion: Schema.Number;
50
116
  readonly payload: Schema.Codec<A, I, never, never>;
51
117
  }>>;
52
118
  readonly nextEntryKey: Schema.Number;
119
+ readonly maybeSwipeConfig: Schema.Option<Schema.Struct<{
120
+ readonly direction: Schema.Literals<readonly ["Left", "Right"]>;
121
+ readonly threshold: Schema.Number;
122
+ }>>;
53
123
  }>;
54
124
  /** Payload-independent Message variants shared by every bound Toast module. */
55
125
  export declare const Message: import("foldkit/message").MessageUnion<{
@@ -76,6 +146,27 @@ export declare const Message: import("foldkit/message").MessageUnion<{
76
146
  readonly EndedAnimation: {};
77
147
  }>;
78
148
  };
149
+ readonly PressedEntryPointer: {
150
+ entryId: Schema.String;
151
+ pointerId: Schema.Number;
152
+ clientX: Schema.Number;
153
+ };
154
+ readonly MovedSwipePointer: {
155
+ pointerId: Schema.Number;
156
+ clientX: Schema.Number;
157
+ };
158
+ readonly ReleasedSwipePointer: {
159
+ pointerId: Schema.Number;
160
+ clientX: Schema.Number;
161
+ };
162
+ readonly CancelledSwipe: {
163
+ pointerId: Schema.Number;
164
+ };
165
+ readonly PressedEscape: {};
166
+ readonly CompletedWaitForSwipeSettled: {
167
+ entryId: Schema.String;
168
+ version: Schema.Number;
169
+ };
79
170
  }>;
80
171
  export type Dismissed = typeof Message.Dismissed.Type;
81
172
  export type DismissedAll = typeof Message.DismissedAll.Type;
@@ -83,6 +174,12 @@ export type CompletedWaitBeforeDismissal = typeof Message.CompletedWaitBeforeDis
83
174
  export type HoveredEntry = typeof Message.HoveredEntry.Type;
84
175
  export type LeftEntry = typeof Message.LeftEntry.Type;
85
176
  export type GotAnimationMessage = typeof Message.GotAnimationMessage.Type;
177
+ export type PressedEntryPointer = typeof Message.PressedEntryPointer.Type;
178
+ export type MovedSwipePointer = typeof Message.MovedSwipePointer.Type;
179
+ export type ReleasedSwipePointer = typeof Message.ReleasedSwipePointer.Type;
180
+ export type CancelledSwipe = typeof Message.CancelledSwipe.Type;
181
+ export type PressedEscape = typeof Message.PressedEscape.Type;
182
+ export type CompletedWaitForSwipeSettled = typeof Message.CompletedWaitForSwipeSettled.Type;
86
183
  /** Factory for the union of all messages the toast component can produce. */
87
184
  export declare const makeMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) => import("foldkit/message").MessageUnion<{
88
185
  readonly Added: {
@@ -97,6 +194,22 @@ export declare const makeMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) => i
97
194
  readonly maybeDuration: Schema.Option<Schema.DurationFromMillis>;
98
195
  readonly pendingDismissVersion: Schema.Number;
99
196
  readonly isHovered: Schema.Boolean;
197
+ readonly swipeState: import("foldkit/schema").TaggedUnion<{
198
+ readonly Idle: {};
199
+ readonly Dragging: {
200
+ pointerId: Schema.Number;
201
+ startX: Schema.Number;
202
+ currentX: Schema.Number;
203
+ };
204
+ readonly Settling: {
205
+ offsetX: Schema.Number;
206
+ };
207
+ readonly Dismissing: {
208
+ offsetX: Schema.Number;
209
+ direction: Schema.Literals<readonly ["Left", "Right"]>;
210
+ };
211
+ }>;
212
+ readonly swipeVersion: Schema.Number;
100
213
  readonly payload: Schema.Codec<A, I, never, never>;
101
214
  }>;
102
215
  };
@@ -123,6 +236,27 @@ export declare const makeMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) => i
123
236
  readonly EndedAnimation: {};
124
237
  }>;
125
238
  };
239
+ readonly PressedEntryPointer: {
240
+ entryId: Schema.String;
241
+ pointerId: Schema.Number;
242
+ clientX: Schema.Number;
243
+ };
244
+ readonly MovedSwipePointer: {
245
+ pointerId: Schema.Number;
246
+ clientX: Schema.Number;
247
+ };
248
+ readonly ReleasedSwipePointer: {
249
+ pointerId: Schema.Number;
250
+ clientX: Schema.Number;
251
+ };
252
+ readonly CancelledSwipe: {
253
+ pointerId: Schema.Number;
254
+ };
255
+ readonly PressedEscape: {};
256
+ readonly CompletedWaitForSwipeSettled: {
257
+ entryId: Schema.String;
258
+ version: Schema.Number;
259
+ };
126
260
  }>;
127
261
  /** Factory for the union of out-messages the toast component can produce. */
128
262
  export declare const makeOutMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) => import("foldkit/message").MessageUnion<{
@@ -130,6 +264,14 @@ export declare const makeOutMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) =
130
264
  payload: Schema.Codec<A, I, never, never>;
131
265
  };
132
266
  }>;
267
+ /** Opt-in configuration for swipe-to-dismiss. Without `swipeToDismiss`,
268
+ * the view attaches no pointer handler and swipe Messages do nothing.
269
+ * Pass `{}` for the default rightward swipe, `{ threshold }` to change
270
+ * the distance, or `{ direction: 'Left' }` to swipe left. */
271
+ export type SwipeToDismissConfig = Readonly<{
272
+ threshold?: number;
273
+ direction?: SwipeDirection;
274
+ }>;
133
275
  /** Configuration for creating a toast container model. `defaultDuration` is
134
276
  * applied to any `show()` call that doesn't provide its own `duration` or
135
277
  * pass `sticky: true`. Accepts any Effect Duration input; a bare number is
@@ -137,6 +279,7 @@ export declare const makeOutMessage: <A, I>(payloadSchema: Schema.Codec<A, I>) =
137
279
  export type InitConfig = Readonly<{
138
280
  id: string;
139
281
  defaultDuration?: Duration.Input;
282
+ swipeToDismiss?: SwipeToDismissConfig;
140
283
  }>;
141
284
  export declare const DEFAULT_DURATION: Duration.Duration;
142
285
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/toast/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAOzC;;;;kDAIkD;AAClD,eAAO,MAAM,OAAO,mEAA2D,CAAA;AAC/E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,gFAAgF;AAChF,eAAO,MAAM,QAAQ,6GAOnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAI3C;;;;;4BAK4B;AAC5B,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,iBAAiB,MAAM,CAAC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B,CAAA;CACtC,CAAC,CAAA;AAEF,eAAO,MAAM,gBAAgB,mBAAsB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
2
  import { Duration, Schema } from 'effect';
3
3
  import { defineMessageUnion } from 'foldkit/message';
4
+ import { defineTaggedUnion } from 'foldkit/schema';
4
5
  import * as Animation from '../animation/schema.js';
5
6
  // VARIANT
6
7
  /** Semantic category of a toast. Drives the default ARIA role: `status` for
@@ -19,13 +20,50 @@ export const Position = Schema.Literals([
19
20
  'BottomCenter',
20
21
  'BottomRight',
21
22
  ]);
23
+ // SWIPE
24
+ /** Direction in which a pointer can drag an entry to dismiss it. */
25
+ export const SwipeDirection = Schema.Literals(['Left', 'Right']);
26
+ const SwipeConfig = Schema.Struct({
27
+ direction: SwipeDirection,
28
+ threshold: Schema.Number,
29
+ });
30
+ /** Per-entry swipe gesture state. `Dragging` retains the initiating
31
+ * `pointerId`, so move, release, and cancel Messages update only the entry
32
+ * that started the gesture and ignore unrelated touches. `Settling` returns
33
+ * a cancelled or short swipe to rest. `Dismissing` retains the release offset
34
+ * and direction while the leave animation carries the entry off-screen. The
35
+ * settle generation lives in the entry's `swipeVersion` so a stale settle
36
+ * timer cannot clear a later gesture. */
37
+ export const SwipeState = defineTaggedUnion({
38
+ Idle: {},
39
+ Dragging: {
40
+ pointerId: Schema.Number,
41
+ startX: Schema.Number,
42
+ currentX: Schema.Number,
43
+ },
44
+ Settling: {
45
+ offsetX: Schema.Number,
46
+ },
47
+ Dismissing: {
48
+ offsetX: Schema.Number,
49
+ direction: SwipeDirection,
50
+ },
51
+ });
52
+ /** Default distance in pixels a pointer must travel to dismiss a Toast. */
53
+ export const DEFAULT_SWIPE_THRESHOLD = 40;
54
+ /** Default direction in which a pointer can dismiss a Toast. */
55
+ export const DEFAULT_SWIPE_DIRECTION = 'Right';
56
+ /** Time an entry remains in `Settling` after a short or cancelled swipe,
57
+ * allowing consumer CSS to animate it back to rest. */
58
+ export const SWIPE_SETTLE_DURATION = Duration.millis(150);
22
59
  // ENTRY
23
60
  /** Schema factory for a single toast entry. `payloadSchema` is user-provided
24
61
  * and defines the shape of per-entry content, whatever the consumer wants
25
62
  * to encode. The component itself owns only lifecycle + a11y fields: `id`,
26
63
  * `variant` (for ARIA role), `animation`, `maybeDuration`,
27
- * `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
28
- * (for pause-on-hover). */
64
+ * `pendingDismissVersion` (for cancellable auto-dismiss), `isHovered`
65
+ * (for pause-on-hover), and `swipeState` + `swipeVersion` (for the
66
+ * opt-in swipe gesture). */
29
67
  export const makeEntry = (payloadSchema) => __foldkitBrandViewResult((Schema.Struct({
30
68
  id: Schema.String,
31
69
  variant: Variant,
@@ -33,6 +71,8 @@ export const makeEntry = (payloadSchema) => __foldkitBrandViewResult((Schema.Str
33
71
  maybeDuration: Schema.Option(Schema.DurationFromMillis),
34
72
  pendingDismissVersion: Schema.Number,
35
73
  isHovered: Schema.Boolean,
74
+ swipeState: SwipeState,
75
+ swipeVersion: Schema.Number,
36
76
  payload: payloadSchema,
37
77
  })), "@foldkit/ui/toast/schema.js#makeEntry");
38
78
  // MODEL
@@ -46,6 +86,7 @@ export const makeModel = (payloadSchema) => __foldkitBrandViewResult((Schema.Str
46
86
  defaultDuration: Schema.DurationFromMillis,
47
87
  entries: Schema.Array(makeEntry(payloadSchema)),
48
88
  nextEntryKey: Schema.Number,
89
+ maybeSwipeConfig: Schema.Option(SwipeConfig),
49
90
  })), "@foldkit/ui/toast/schema.js#makeModel");
50
91
  // MESSAGE
51
92
  /** Payload-independent Message variants shared by every bound Toast module. */
@@ -62,6 +103,19 @@ export const Message = defineMessageUnion({
62
103
  entryId: Schema.String,
63
104
  message: Animation.Message,
64
105
  },
106
+ PressedEntryPointer: {
107
+ entryId: Schema.String,
108
+ pointerId: Schema.Number,
109
+ clientX: Schema.Number,
110
+ },
111
+ MovedSwipePointer: { pointerId: Schema.Number, clientX: Schema.Number },
112
+ ReleasedSwipePointer: { pointerId: Schema.Number, clientX: Schema.Number },
113
+ CancelledSwipe: { pointerId: Schema.Number },
114
+ PressedEscape: {},
115
+ CompletedWaitForSwipeSettled: {
116
+ entryId: Schema.String,
117
+ version: Schema.Number,
118
+ },
65
119
  });
66
120
  /** Factory for the union of all messages the toast component can produce. */
67
121
  export const makeMessage = (payloadSchema) => __foldkitBrandViewResult((defineMessageUnion({
@@ -78,6 +132,19 @@ export const makeMessage = (payloadSchema) => __foldkitBrandViewResult((defineMe
78
132
  entryId: Schema.String,
79
133
  message: Animation.Message,
80
134
  },
135
+ PressedEntryPointer: {
136
+ entryId: Schema.String,
137
+ pointerId: Schema.Number,
138
+ clientX: Schema.Number,
139
+ },
140
+ MovedSwipePointer: { pointerId: Schema.Number, clientX: Schema.Number },
141
+ ReleasedSwipePointer: { pointerId: Schema.Number, clientX: Schema.Number },
142
+ CancelledSwipe: { pointerId: Schema.Number },
143
+ PressedEscape: {},
144
+ CompletedWaitForSwipeSettled: {
145
+ entryId: Schema.String,
146
+ version: Schema.Number,
147
+ },
81
148
  })), "@foldkit/ui/toast/schema.js#makeMessage");
82
149
  /** Factory for the union of out-messages the toast component can produce. */
83
150
  export const makeOutMessage = (payloadSchema) => __foldkitBrandViewResult((defineMessageUnion({ DismissedToast: { payload: payloadSchema } })), "@foldkit/ui/toast/schema.js#makeOutMessage");
@@ -0,0 +1,5 @@
1
+ /** Whether a pointerdown originated on a child that should not start a
2
+ * Toast swipe. Mouse and pen presses on explicitly marked text preserve
3
+ * selection, while touch can still swipe across that content. @internal */
4
+ export declare const isSwipeExcludedTarget: (pointerType: string, target: EventTarget | null) => boolean;
5
+ //# sourceMappingURL=swipeTarget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipeTarget.d.ts","sourceRoot":"","sources":["../../src/toast/swipeTarget.ts"],"names":[],"mappings":"AAGA;;4EAE4E;AAC5E,eAAO,MAAM,qBAAqB,gBACnB,MAAM,UACX,WAAW,GAAG,IAAI,KACzB,OAiBF,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ const SWIPE_EXCLUDED_TARGET_SELECTOR = 'button, a, input, select, textarea, [contenteditable], [role="button"], [role="link"]';
3
+ /** Whether a pointerdown originated on a child that should not start a
4
+ * Toast swipe. Mouse and pen presses on explicitly marked text preserve
5
+ * selection, while touch can still swipe across that content. @internal */
6
+ export const isSwipeExcludedTarget = (pointerType, target) => {
7
+ const targetElement = target instanceof Element ? target : null;
8
+ const parentElement = target instanceof Node ? target.parentElement : null;
9
+ const element = targetElement ?? parentElement;
10
+ if (element === null) {
11
+ return __foldkitBrandViewResult((false), "@foldkit/ui/toast/swipeTarget.js#isSwipeExcludedTarget");
12
+ }
13
+ if (element.closest(SWIPE_EXCLUDED_TARGET_SELECTOR) !== null) {
14
+ return __foldkitBrandViewResult((true), "@foldkit/ui/toast/swipeTarget.js#isSwipeExcludedTarget");
15
+ }
16
+ return (__foldkitBrandViewResult((pointerType !== 'touch' &&
17
+ element.closest('[data-toast-swipe-ignore]') !== null), "@foldkit/ui/toast/swipeTarget.js#isSwipeExcludedTarget"));
18
+ };
@@ -7,7 +7,7 @@ export type DrainEntryInput = Readonly<{
7
7
  entryId: string;
8
8
  version?: number;
9
9
  }>;
10
- /** Builds a {@link Story.Command.resolveAll} step that drains a single toast
10
+ /** Builds a `Story.Command.resolveAll` step that drains a single toast
11
11
  * entry's full animation and dismiss lifecycle. Resolving these Commands in
12
12
  * order takes a freshly shown entry from its enter animation through
13
13
  * auto-dismiss and its exit animation, ending with the entry removed from the
@@ -4,7 +4,7 @@ import * as Animation from '../animation/index.js';
4
4
  import { Message } from './schema.js';
5
5
  import { WaitBeforeDismissal } from './update.js';
6
6
  const DEFAULT_VERSION = 0;
7
- /** Builds a {@link Story.Command.resolveAll} step that drains a single toast
7
+ /** Builds a `Story.Command.resolveAll` step that drains a single toast
8
8
  * entry's full animation and dismiss lifecycle. Resolving these Commands in
9
9
  * order takes a freshly shown entry from its enter animation through
10
10
  * auto-dismiss and its exit animation, ending with the entry removed from the