foldkit 0.111.1 → 0.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/README.md +2 -2
  2. package/dist/devTools/host.d.ts +6 -0
  3. package/dist/devTools/host.d.ts.map +1 -0
  4. package/dist/devTools/host.js +4 -0
  5. package/dist/dom/dom.d.ts +6 -1
  6. package/dist/dom/dom.d.ts.map +1 -1
  7. package/dist/dom/dom.js +24 -1
  8. package/dist/html/index.d.ts +4 -3
  9. package/dist/html/index.d.ts.map +1 -1
  10. package/dist/html/index.js +4 -3
  11. package/dist/html/submodel.d.ts +2 -2
  12. package/dist/html/submodel.d.ts.map +1 -1
  13. package/dist/index.d.ts +0 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +0 -1
  16. package/dist/runtime/browserListeners.d.ts.map +1 -1
  17. package/dist/runtime/browserListeners.js +12 -7
  18. package/dist/runtime/public.d.ts +1 -1
  19. package/dist/runtime/public.d.ts.map +1 -1
  20. package/dist/runtime/runtime.d.ts +14 -1
  21. package/dist/runtime/runtime.d.ts.map +1 -1
  22. package/dist/runtime/runtime.js +25 -8
  23. package/dist/runtime/subscription.d.ts +1 -1
  24. package/dist/subscription/public.d.ts +1 -1
  25. package/dist/subscription/public.d.ts.map +1 -1
  26. package/package.json +12 -93
  27. package/dist/devTools/overlay-styles.d.ts +0 -3
  28. package/dist/devTools/overlay-styles.d.ts.map +0 -1
  29. package/dist/devTools/overlay-styles.js +0 -706
  30. package/dist/devTools/overlay.d.ts +0 -63
  31. package/dist/devTools/overlay.d.ts.map +0 -1
  32. package/dist/devTools/overlay.js +0 -1244
  33. package/dist/test/apps/disabledButton.d.ts +0 -38
  34. package/dist/test/apps/disabledButton.d.ts.map +0 -1
  35. package/dist/test/apps/disabledButton.js +0 -71
  36. package/dist/ui/anchor.d.ts +0 -38
  37. package/dist/ui/anchor.d.ts.map +0 -1
  38. package/dist/ui/anchor.js +0 -142
  39. package/dist/ui/animation/index.d.ts +0 -49
  40. package/dist/ui/animation/index.d.ts.map +0 -1
  41. package/dist/ui/animation/index.js +0 -74
  42. package/dist/ui/animation/public.d.ts +0 -3
  43. package/dist/ui/animation/public.d.ts.map +0 -1
  44. package/dist/ui/animation/public.js +0 -1
  45. package/dist/ui/animation/schema.d.ts +0 -43
  46. package/dist/ui/animation/schema.d.ts.map +0 -1
  47. package/dist/ui/animation/schema.js +0 -41
  48. package/dist/ui/animation/update.d.ts +0 -24
  49. package/dist/ui/animation/update.d.ts.map +0 -1
  50. package/dist/ui/animation/update.js +0 -67
  51. package/dist/ui/button/index.d.ts +0 -17
  52. package/dist/ui/button/index.d.ts.map +0 -1
  53. package/dist/ui/button/index.js +0 -22
  54. package/dist/ui/button/public.d.ts +0 -3
  55. package/dist/ui/button/public.d.ts.map +0 -1
  56. package/dist/ui/button/public.js +0 -1
  57. package/dist/ui/calendar/index.d.ts +0 -462
  58. package/dist/ui/calendar/index.d.ts.map +0 -1
  59. package/dist/ui/calendar/index.js +0 -824
  60. package/dist/ui/calendar/public.d.ts +0 -3
  61. package/dist/ui/calendar/public.d.ts.map +0 -1
  62. package/dist/ui/calendar/public.js +0 -1
  63. package/dist/ui/checkbox/index.d.ts +0 -119
  64. package/dist/ui/checkbox/index.d.ts.map +0 -1
  65. package/dist/ui/checkbox/index.js +0 -110
  66. package/dist/ui/checkbox/public.d.ts +0 -3
  67. package/dist/ui/checkbox/public.d.ts.map +0 -1
  68. package/dist/ui/checkbox/public.js +0 -1
  69. package/dist/ui/combobox/multi.d.ts +0 -184
  70. package/dist/ui/combobox/multi.d.ts.map +0 -1
  71. package/dist/ui/combobox/multi.js +0 -81
  72. package/dist/ui/combobox/multiPublic.d.ts +0 -3
  73. package/dist/ui/combobox/multiPublic.d.ts.map +0 -1
  74. package/dist/ui/combobox/multiPublic.js +0 -1
  75. package/dist/ui/combobox/public.d.ts +0 -7
  76. package/dist/ui/combobox/public.d.ts.map +0 -1
  77. package/dist/ui/combobox/public.js +0 -3
  78. package/dist/ui/combobox/shared.d.ts +0 -422
  79. package/dist/ui/combobox/shared.d.ts.map +0 -1
  80. package/dist/ui/combobox/shared.js +0 -707
  81. package/dist/ui/combobox/single.d.ts +0 -199
  82. package/dist/ui/combobox/single.d.ts.map +0 -1
  83. package/dist/ui/combobox/single.js +0 -106
  84. package/dist/ui/datePicker/index.d.ts +0 -457
  85. package/dist/ui/datePicker/index.d.ts.map +0 -1
  86. package/dist/ui/datePicker/index.js +0 -317
  87. package/dist/ui/datePicker/public.d.ts +0 -3
  88. package/dist/ui/datePicker/public.d.ts.map +0 -1
  89. package/dist/ui/datePicker/public.js +0 -1
  90. package/dist/ui/dialog/index.d.ts +0 -155
  91. package/dist/ui/dialog/index.d.ts.map +0 -1
  92. package/dist/ui/dialog/index.js +0 -208
  93. package/dist/ui/dialog/public.d.ts +0 -3
  94. package/dist/ui/dialog/public.d.ts.map +0 -1
  95. package/dist/ui/dialog/public.js +0 -1
  96. package/dist/ui/disclosure/index.d.ts +0 -110
  97. package/dist/ui/disclosure/index.d.ts.map +0 -1
  98. package/dist/ui/disclosure/index.js +0 -110
  99. package/dist/ui/disclosure/public.d.ts +0 -3
  100. package/dist/ui/disclosure/public.d.ts.map +0 -1
  101. package/dist/ui/disclosure/public.js +0 -1
  102. package/dist/ui/dragAndDrop/index.d.ts +0 -540
  103. package/dist/ui/dragAndDrop/index.d.ts.map +0 -1
  104. package/dist/ui/dragAndDrop/index.js +0 -535
  105. package/dist/ui/dragAndDrop/public.d.ts +0 -3
  106. package/dist/ui/dragAndDrop/public.d.ts.map +0 -1
  107. package/dist/ui/dragAndDrop/public.js +0 -1
  108. package/dist/ui/fieldset/index.d.ts +0 -21
  109. package/dist/ui/fieldset/index.d.ts.map +0 -1
  110. package/dist/ui/fieldset/index.js +0 -25
  111. package/dist/ui/fieldset/public.d.ts +0 -3
  112. package/dist/ui/fieldset/public.d.ts.map +0 -1
  113. package/dist/ui/fieldset/public.js +0 -1
  114. package/dist/ui/fileDrop/index.d.ts +0 -109
  115. package/dist/ui/fileDrop/index.d.ts.map +0 -1
  116. package/dist/ui/fileDrop/index.js +0 -126
  117. package/dist/ui/fileDrop/public.d.ts +0 -3
  118. package/dist/ui/fileDrop/public.d.ts.map +0 -1
  119. package/dist/ui/fileDrop/public.js +0 -1
  120. package/dist/ui/group.d.ts +0 -8
  121. package/dist/ui/group.d.ts.map +0 -1
  122. package/dist/ui/group.js +0 -13
  123. package/dist/ui/index.d.ts +0 -25
  124. package/dist/ui/index.d.ts.map +0 -1
  125. package/dist/ui/index.js +0 -24
  126. package/dist/ui/input/index.d.ts +0 -26
  127. package/dist/ui/input/index.d.ts.map +0 -1
  128. package/dist/ui/input/index.js +0 -43
  129. package/dist/ui/input/public.d.ts +0 -3
  130. package/dist/ui/input/public.d.ts.map +0 -1
  131. package/dist/ui/input/public.js +0 -1
  132. package/dist/ui/keyboard.d.ts +0 -6
  133. package/dist/ui/keyboard.d.ts.map +0 -1
  134. package/dist/ui/keyboard.js +0 -9
  135. package/dist/ui/listbox/multi.d.ts +0 -190
  136. package/dist/ui/listbox/multi.d.ts.map +0 -1
  137. package/dist/ui/listbox/multi.js +0 -65
  138. package/dist/ui/listbox/multiPublic.d.ts +0 -3
  139. package/dist/ui/listbox/multiPublic.d.ts.map +0 -1
  140. package/dist/ui/listbox/multiPublic.js +0 -1
  141. package/dist/ui/listbox/public.d.ts +0 -7
  142. package/dist/ui/listbox/public.d.ts.map +0 -1
  143. package/dist/ui/listbox/public.js +0 -3
  144. package/dist/ui/listbox/shared.d.ts +0 -431
  145. package/dist/ui/listbox/shared.d.ts.map +0 -1
  146. package/dist/ui/listbox/shared.js +0 -669
  147. package/dist/ui/listbox/single.d.ts +0 -208
  148. package/dist/ui/listbox/single.d.ts.map +0 -1
  149. package/dist/ui/listbox/single.js +0 -73
  150. package/dist/ui/menu/index.d.ts +0 -367
  151. package/dist/ui/menu/index.d.ts.map +0 -1
  152. package/dist/ui/menu/index.js +0 -681
  153. package/dist/ui/menu/public.d.ts +0 -4
  154. package/dist/ui/menu/public.d.ts.map +0 -1
  155. package/dist/ui/menu/public.js +0 -1
  156. package/dist/ui/popover/index.d.ts +0 -267
  157. package/dist/ui/popover/index.d.ts.map +0 -1
  158. package/dist/ui/popover/index.js +0 -345
  159. package/dist/ui/popover/public.d.ts +0 -4
  160. package/dist/ui/popover/public.d.ts.map +0 -1
  161. package/dist/ui/popover/public.js +0 -1
  162. package/dist/ui/radioGroup/index.d.ts +0 -169
  163. package/dist/ui/radioGroup/index.d.ts.map +0 -1
  164. package/dist/ui/radioGroup/index.js +0 -196
  165. package/dist/ui/radioGroup/public.d.ts +0 -3
  166. package/dist/ui/radioGroup/public.d.ts.map +0 -1
  167. package/dist/ui/radioGroup/public.js +0 -1
  168. package/dist/ui/select/index.d.ts +0 -24
  169. package/dist/ui/select/index.d.ts.map +0 -1
  170. package/dist/ui/select/index.js +0 -40
  171. package/dist/ui/select/public.d.ts +0 -3
  172. package/dist/ui/select/public.d.ts.map +0 -1
  173. package/dist/ui/select/public.js +0 -1
  174. package/dist/ui/slider/index.d.ts +0 -318
  175. package/dist/ui/slider/index.d.ts.map +0 -1
  176. package/dist/ui/slider/index.js +0 -336
  177. package/dist/ui/slider/public.d.ts +0 -3
  178. package/dist/ui/slider/public.d.ts.map +0 -1
  179. package/dist/ui/slider/public.js +0 -1
  180. package/dist/ui/switch/index.d.ts +0 -99
  181. package/dist/ui/switch/index.d.ts.map +0 -1
  182. package/dist/ui/switch/index.js +0 -106
  183. package/dist/ui/switch/public.d.ts +0 -3
  184. package/dist/ui/switch/public.d.ts.map +0 -1
  185. package/dist/ui/switch/public.js +0 -1
  186. package/dist/ui/tabs/index.d.ts +0 -155
  187. package/dist/ui/tabs/index.d.ts.map +0 -1
  188. package/dist/ui/tabs/index.js +0 -184
  189. package/dist/ui/tabs/public.d.ts +0 -3
  190. package/dist/ui/tabs/public.d.ts.map +0 -1
  191. package/dist/ui/tabs/public.js +0 -1
  192. package/dist/ui/textarea/index.d.ts +0 -26
  193. package/dist/ui/textarea/index.d.ts.map +0 -1
  194. package/dist/ui/textarea/index.js +0 -44
  195. package/dist/ui/textarea/public.d.ts +0 -3
  196. package/dist/ui/textarea/public.d.ts.map +0 -1
  197. package/dist/ui/textarea/public.js +0 -1
  198. package/dist/ui/toast/index.d.ts +0 -608
  199. package/dist/ui/toast/index.d.ts.map +0 -1
  200. package/dist/ui/toast/index.js +0 -145
  201. package/dist/ui/toast/public.d.ts +0 -4
  202. package/dist/ui/toast/public.d.ts.map +0 -1
  203. package/dist/ui/toast/public.js +0 -1
  204. package/dist/ui/toast/schema.d.ts +0 -154
  205. package/dist/ui/toast/schema.d.ts.map +0 -1
  206. package/dist/ui/toast/schema.js +0 -93
  207. package/dist/ui/toast/update.d.ts +0 -510
  208. package/dist/ui/toast/update.d.ts.map +0 -1
  209. package/dist/ui/toast/update.js +0 -225
  210. package/dist/ui/tooltip/index.d.ts +0 -170
  211. package/dist/ui/tooltip/index.d.ts.map +0 -1
  212. package/dist/ui/tooltip/index.js +0 -252
  213. package/dist/ui/tooltip/public.d.ts +0 -4
  214. package/dist/ui/tooltip/public.d.ts.map +0 -1
  215. package/dist/ui/tooltip/public.js +0 -1
  216. package/dist/ui/typeahead.d.ts +0 -4
  217. package/dist/ui/typeahead.d.ts.map +0 -1
  218. package/dist/ui/typeahead.js +0 -14
  219. package/dist/ui/virtualList/index.d.ts +0 -202
  220. package/dist/ui/virtualList/index.d.ts.map +0 -1
  221. package/dist/ui/virtualList/index.js +0 -391
  222. package/dist/ui/virtualList/public.d.ts +0 -3
  223. package/dist/ui/virtualList/public.d.ts.map +0 -1
  224. package/dist/ui/virtualList/public.js +0 -1
@@ -1,145 +0,0 @@
1
- import { Match as M } from 'effect';
2
- import { childAttributes, defineView, html, } from '../../html/index.js';
3
- import { Dismissed, DismissedAll, ElapsedDuration, GotAnimationMessage, HoveredEntry, LeftEntry, Position, Variant, } from './schema.js';
4
- import { DismissAfter, makeRuntime } from './update.js';
5
- export { Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, };
6
- const variantToRole = (variant) => M.value(variant).pipe(M.withReturnType(), M.when('Info', () => 'status'), M.when('Success', () => 'status'), M.when('Warning', () => 'alert'), M.when('Error', () => 'alert'), M.exhaustive);
7
- const positionToContainerStyle = (position) => {
8
- const base = {
9
- position: 'fixed',
10
- display: 'flex',
11
- gap: '8px',
12
- padding: '16px',
13
- margin: '0',
14
- listStyle: 'none',
15
- pointerEvents: 'none',
16
- zIndex: '2147483600',
17
- };
18
- return M.value(position).pipe(M.withReturnType(), M.when('TopLeft', () => ({
19
- ...base,
20
- top: '0',
21
- left: '0',
22
- flexDirection: 'column-reverse',
23
- })), M.when('TopCenter', () => ({
24
- ...base,
25
- top: '0',
26
- left: '50%',
27
- transform: 'translateX(-50%)',
28
- flexDirection: 'column-reverse',
29
- })), M.when('TopRight', () => ({
30
- ...base,
31
- top: '0',
32
- right: '0',
33
- flexDirection: 'column-reverse',
34
- })), M.when('BottomLeft', () => ({
35
- ...base,
36
- bottom: '0',
37
- left: '0',
38
- flexDirection: 'column',
39
- })), M.when('BottomCenter', () => ({
40
- ...base,
41
- bottom: '0',
42
- left: '50%',
43
- transform: 'translateX(-50%)',
44
- flexDirection: 'column',
45
- })), M.when('BottomRight', () => ({
46
- ...base,
47
- bottom: '0',
48
- right: '0',
49
- flexDirection: 'column',
50
- })), M.exhaustive);
51
- };
52
- const DEFAULT_ARIA_LABEL = 'Notifications';
53
- /** Factory that binds `Ui.Toast` to a user-provided payload schema. The
54
- * returned module contains everything needed to wire a toast stack into an
55
- * app: `Model`, `Message`, `Entry`, `Added`, `init`, `update`, `show` /
56
- * `dismiss` / `dismissAll` helpers, and the headless `view`.
57
- *
58
- * The payload is whatever content shape the consumer supplies via Schema.
59
- * The component never reads it. It flows through to `entryToView`. The
60
- * component itself owns only lifecycle and a11y fields (id, variant,
61
- * animation, dismiss timer, hover state).
62
- *
63
- * Consume the bound module's exports everywhere. `Toast.Model` in your app
64
- * Model, `Toast.Message` in your parent Message union, `Toast.show` /
65
- * `Toast.dismiss` in your update, `Toast.view` in your view. The top-level
66
- * exports (`Variant`, `Position`, static message tags, `DismissAfter`) are
67
- * payload-independent and safe to reference when you need them without a
68
- * bound module, but the typical path is through the factory return.
69
- *
70
- * @example
71
- * ```ts
72
- * const ToastPayload = S.Struct({
73
- * bodyText: S.String,
74
- * maybeLink: S.Option(S.Struct({
75
- * href: S.String,
76
- * text: S.String,
77
- * })),
78
- * })
79
- * export const Toast = Ui.Toast.make(ToastPayload)
80
- * ```
81
- */
82
- export const make = (payloadSchema) => {
83
- const runtime = makeRuntime(payloadSchema);
84
- /** Renders a headless toast stack. The `<ol>` container is always present
85
- * in the DOM so screen readers can observe its `aria-live` region from
86
- * page load. Each entry becomes an `<li>` keyed by its id, with
87
- * animation data attributes (`data-enter`, `data-leave`,
88
- * `data-transition`, `data-closed`) and `data-variant` reflecting the
89
- * entry's variant. */
90
- const view = defineView((model, viewInputs) => {
91
- const h = html();
92
- const { id, entries } = model;
93
- const { position, entryToView, ariaLabel = DEFAULT_ARIA_LABEL, containerClassName, entryClassName, } = viewInputs;
94
- const containerAttributes = [
95
- h.Id(id),
96
- h.Role('region'),
97
- h.AriaLabel(ariaLabel),
98
- h.AriaLive('polite'),
99
- h.Style(positionToContainerStyle(position)),
100
- ...(containerClassName ? [h.Class(containerClassName)] : []),
101
- ];
102
- const renderEntryItem = (entry) => {
103
- const { transitionState } = entry.animation;
104
- const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
105
- h.DataAttribute('closed', ''),
106
- h.DataAttribute('enter', ''),
107
- h.DataAttribute('transition', ''),
108
- ]), M.when('EnterAnimating', () => [
109
- h.DataAttribute('enter', ''),
110
- h.DataAttribute('transition', ''),
111
- ]), M.when('LeaveStart', () => [
112
- h.DataAttribute('leave', ''),
113
- h.DataAttribute('transition', ''),
114
- ]), M.when('LeaveAnimating', () => [
115
- h.DataAttribute('closed', ''),
116
- h.DataAttribute('leave', ''),
117
- h.DataAttribute('transition', ''),
118
- ]), M.orElse(() => []));
119
- const itemAttributes = [
120
- h.Id(entry.id),
121
- h.Role(variantToRole(entry.variant)),
122
- h.AriaAtomic(true),
123
- h.DataAttribute('variant', entry.variant),
124
- h.Style({ pointerEvents: 'auto' }),
125
- h.OnMouseEnter(HoveredEntry({ entryId: entry.id })),
126
- h.OnMouseLeave(LeftEntry({ entryId: entry.id })),
127
- ...animationAttributes,
128
- ...(entryClassName ? [h.Class(entryClassName)] : []),
129
- ];
130
- const handlers = {
131
- dismiss: childAttributes([
132
- h.OnClick(Dismissed({ entryId: entry.id })),
133
- ]),
134
- };
135
- return h.keyed('li')(entry.id, itemAttributes, [
136
- entryToView(entry, handlers),
137
- ]);
138
- };
139
- return h.keyed('ol')(id, containerAttributes, entries.map(renderEntryItem));
140
- });
141
- return {
142
- ...runtime,
143
- view,
144
- };
145
- };
@@ -1,4 +0,0 @@
1
- export { make, Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, } from './index.js';
2
- export type { EntryHandlers } from './index.js';
3
- export type { InitConfig, ShowInput } from './index.js';
4
- //# sourceMappingURL=public.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,SAAS,EACT,mBAAmB,EACnB,YAAY,GACb,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- export { make, Variant, Position, Dismissed, DismissedAll, ElapsedDuration, HoveredEntry, LeftEntry, GotAnimationMessage, DismissAfter, } from './index.js';
@@ -1,154 +0,0 @@
1
- import { Duration, Schema as S } from 'effect';
2
- /** Semantic category of a toast. Drives the default ARIA role: `status` for
3
- * `Info` / `Success`, `alert` for `Warning` / `Error`. Also surfaced as
4
- * `data-variant` on each entry for per-variant CSS. This is the only
5
- * content-adjacent field the component owns. The rest of the entry's
6
- * content lives in the user-provided payload. */
7
- export declare const Variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
8
- export type Variant = typeof Variant.Type;
9
- /** Where the toast viewport is anchored on the screen and how entries stack. */
10
- export declare const Position: S.Literals<readonly ["TopLeft", "TopCenter", "TopRight", "BottomLeft", "BottomCenter", "BottomRight"]>;
11
- export type Position = typeof Position.Type;
12
- /** Schema factory for a single toast entry. `payloadSchema` is user-provided
13
- * and defines the shape of per-entry content, whatever the consumer wants
14
- * to encode. The component itself owns only lifecycle + a11y fields: `id`,
15
- * `variant` (for ARIA role), `animation`, `maybeDuration`,
16
- * `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
17
- * (for pause-on-hover). */
18
- export declare const makeEntry: <A, I>(payloadSchema: S.Codec<A, I>) => S.Struct<{
19
- readonly id: S.String;
20
- readonly variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
21
- readonly animation: S.Struct<{
22
- readonly id: S.String;
23
- readonly isShowing: S.Boolean;
24
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
25
- }>;
26
- readonly maybeDuration: S.Option<S.DurationFromMillis>;
27
- readonly pendingDismissVersion: S.Number;
28
- readonly isHovered: S.Boolean;
29
- readonly payload: S.Codec<A, I, never, never>;
30
- }>;
31
- /** Schema factory for the toast container's state. `nextEntryKey` is a
32
- * monotonic counter used to generate unique entry IDs purely from Model
33
- * state. Thread the updated model through successive `show()` calls.
34
- * Calling `show()` twice against the same pre-update model in the same tick
35
- * will produce duplicate entry IDs. */
36
- export declare const makeModel: <A, I>(payloadSchema: S.Codec<A, I>) => S.Struct<{
37
- readonly id: S.String;
38
- readonly defaultDuration: S.DurationFromMillis;
39
- readonly entries: S.$Array<S.Struct<{
40
- readonly id: S.String;
41
- readonly variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
42
- readonly animation: S.Struct<{
43
- readonly id: S.String;
44
- readonly isShowing: S.Boolean;
45
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
46
- }>;
47
- readonly maybeDuration: S.Option<S.DurationFromMillis>;
48
- readonly pendingDismissVersion: S.Number;
49
- readonly isHovered: S.Boolean;
50
- readonly payload: S.Codec<A, I, never, never>;
51
- }>>;
52
- readonly nextEntryKey: S.Number;
53
- }>;
54
- /** Sent when an entry should begin dismissing. Starts the leave animation;
55
- * the entry is removed from the stack when `TransitionedOut` fires. */
56
- export declare const Dismissed: import("../../schema/index.js").CallableTaggedStruct<"Dismissed", {
57
- entryId: S.String;
58
- }>;
59
- /** Sent when every currently-visible entry should begin dismissing. */
60
- export declare const DismissedAll: import("../../schema/index.js").CallableTaggedStruct<"DismissedAll", {}>;
61
- /** Sent when an entry's auto-dismiss timer fires. Carries a version echoed
62
- * from the scheduling moment so stale timers (from hover or manual dismiss)
63
- * are discarded. */
64
- export declare const ElapsedDuration: import("../../schema/index.js").CallableTaggedStruct<"ElapsedDuration", {
65
- entryId: S.String;
66
- version: S.Number;
67
- }>;
68
- /** Sent when the pointer enters an entry. Pauses the auto-dismiss timer by
69
- * advancing the entry's version. */
70
- export declare const HoveredEntry: import("../../schema/index.js").CallableTaggedStruct<"HoveredEntry", {
71
- entryId: S.String;
72
- }>;
73
- /** Sent when the pointer leaves an entry. Restarts the auto-dismiss timer
74
- * with the entry's full duration. */
75
- export declare const LeftEntry: import("../../schema/index.js").CallableTaggedStruct<"LeftEntry", {
76
- entryId: S.String;
77
- }>;
78
- /** Wraps a single entry's Animation submodel message for delegation. */
79
- export declare const GotAnimationMessage: import("../../schema/index.js").CallableTaggedStruct<"GotAnimationMessage", {
80
- entryId: S.String;
81
- message: S.Union<[import("../../schema/index.js").CallableTaggedStruct<"Showed", {}>, import("../../schema/index.js").CallableTaggedStruct<"Hid", {}>, import("../../schema/index.js").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("../../schema/index.js").CallableTaggedStruct<"EndedAnimation", {}>]>;
82
- }>;
83
- export type Dismissed = typeof Dismissed.Type;
84
- export type DismissedAll = typeof DismissedAll.Type;
85
- export type ElapsedDuration = typeof ElapsedDuration.Type;
86
- export type HoveredEntry = typeof HoveredEntry.Type;
87
- export type LeftEntry = typeof LeftEntry.Type;
88
- export type GotAnimationMessage = typeof GotAnimationMessage.Type;
89
- /** Factory for the `Added` message, which carries a fully-constructed entry
90
- * whose shape depends on the user-provided payload. */
91
- export declare const makeAdded: <A, I>(payloadSchema: S.Codec<A, I>) => import("../../schema/index.js").CallableTaggedStruct<"Added", {
92
- entry: S.Struct<{
93
- readonly id: S.String;
94
- readonly variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
95
- readonly animation: S.Struct<{
96
- readonly id: S.String;
97
- readonly isShowing: S.Boolean;
98
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
99
- }>;
100
- readonly maybeDuration: S.Option<S.DurationFromMillis>;
101
- readonly pendingDismissVersion: S.Number;
102
- readonly isHovered: S.Boolean;
103
- readonly payload: S.Codec<A, I, never, never>;
104
- }>;
105
- }>;
106
- /** Factory for the union of all messages the toast component can produce. */
107
- export declare const makeMessage: <A, I>(payloadSchema: S.Codec<A, I>) => S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"Added", {
108
- entry: S.Struct<{
109
- readonly id: S.String;
110
- readonly variant: S.Literals<readonly ["Info", "Success", "Warning", "Error"]>;
111
- readonly animation: S.Struct<{
112
- readonly id: S.String;
113
- readonly isShowing: S.Boolean;
114
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
115
- }>;
116
- readonly maybeDuration: S.Option<S.DurationFromMillis>;
117
- readonly pendingDismissVersion: S.Number;
118
- readonly isHovered: S.Boolean;
119
- readonly payload: S.Codec<A, I, never, never>;
120
- }>;
121
- }>, import("../../schema/index.js").CallableTaggedStruct<"Dismissed", {
122
- entryId: S.String;
123
- }>, import("../../schema/index.js").CallableTaggedStruct<"DismissedAll", {}>, import("../../schema/index.js").CallableTaggedStruct<"ElapsedDuration", {
124
- entryId: S.String;
125
- version: S.Number;
126
- }>, import("../../schema/index.js").CallableTaggedStruct<"HoveredEntry", {
127
- entryId: S.String;
128
- }>, import("../../schema/index.js").CallableTaggedStruct<"LeftEntry", {
129
- entryId: S.String;
130
- }>, import("../../schema/index.js").CallableTaggedStruct<"GotAnimationMessage", {
131
- entryId: S.String;
132
- message: S.Union<[import("../../schema/index.js").CallableTaggedStruct<"Showed", {}>, import("../../schema/index.js").CallableTaggedStruct<"Hid", {}>, import("../../schema/index.js").CallableTaggedStruct<"AdvancedAnimationFrame", {}>, import("../../schema/index.js").CallableTaggedStruct<"EndedAnimation", {}>]>;
133
- }>]>;
134
- /** Factory for `DismissedToast`, the OutMessage emitted once an entry has
135
- * finished dismissing (leave-animation `TransitionedOut`). Carries the
136
- * payload so consumers can lift the dismissal into a domain Message
137
- * without looking the entry up from a stale model. */
138
- export declare const makeDismissedToast: <A, I>(payloadSchema: S.Codec<A, I>) => import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
139
- payload: S.Codec<A, I, never, never>;
140
- }>;
141
- /** Factory for the union of out-messages the toast component can produce. */
142
- export declare const makeOutMessage: <A, I>(payloadSchema: S.Codec<A, I>) => S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"DismissedToast", {
143
- payload: S.Codec<A, I, never, never>;
144
- }>]>;
145
- /** Configuration for creating a toast container model. `defaultDuration` is
146
- * applied to any `show()` call that doesn't provide its own `duration` or
147
- * pass `sticky: true`. Accepts any Effect Duration input; a bare number is
148
- * interpreted as milliseconds. */
149
- export type InitConfig = Readonly<{
150
- id: string;
151
- defaultDuration?: Duration.Input;
152
- }>;
153
- export declare const DEFAULT_DURATION: Duration.Duration;
154
- //# sourceMappingURL=schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/ui/toast/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAU9C;;;;kDAIkD;AAClD,eAAO,MAAM,OAAO,8DAAsD,CAAA;AAC1E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,gFAAgF;AAChF,eAAO,MAAM,QAAQ,wGAOnB,CAAA;AACF,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAI3C;;;;;4BAK4B;AAC5B,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;EASxD,CAAA;AAIJ;;;;wCAIwC;AACxC,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;EAMxD,CAAA;AAIJ;wEACwE;AACxE,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,uEAAuE;AACvE,eAAO,MAAM,YAAY,0EAAoB,CAAA;AAC7C;;qBAEqB;AACrB,eAAO,MAAM,eAAe;;;EAG1B,CAAA;AACF;qCACqC;AACrC,eAAO,MAAM,YAAY;;EAA2C,CAAA;AACpE;sCACsC;AACtC,eAAO,MAAM,SAAS;;EAAwC,CAAA;AAC9D,wEAAwE;AACxE,eAAO,MAAM,mBAAmB;;;EAG9B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AAC7C,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAA;AAEjE;wDACwD;AACxD,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;EACX,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;IAS1D,CAAA;AAEJ;;;uDAGuD;AACvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;EACpB,CAAA;AAEjD,6EAA6E;AAC7E,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;;IACnB,CAAA;AAI9C;;;mCAGmC;AACnC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,eAAe,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAA;CACjC,CAAC,CAAA;AAEF,eAAO,MAAM,gBAAgB,mBAAsB,CAAA"}
@@ -1,93 +0,0 @@
1
- import { Duration, Schema as S } from 'effect';
2
- import { m } from '../../message/index.js';
3
- import { Message as AnimationMessage, Model as AnimationModel, } from '../animation/schema.js';
4
- // VARIANT
5
- /** Semantic category of a toast. Drives the default ARIA role: `status` for
6
- * `Info` / `Success`, `alert` for `Warning` / `Error`. Also surfaced as
7
- * `data-variant` on each entry for per-variant CSS. This is the only
8
- * content-adjacent field the component owns. The rest of the entry's
9
- * content lives in the user-provided payload. */
10
- export const Variant = S.Literals(['Info', 'Success', 'Warning', 'Error']);
11
- // POSITION
12
- /** Where the toast viewport is anchored on the screen and how entries stack. */
13
- export const Position = S.Literals([
14
- 'TopLeft',
15
- 'TopCenter',
16
- 'TopRight',
17
- 'BottomLeft',
18
- 'BottomCenter',
19
- 'BottomRight',
20
- ]);
21
- // ENTRY
22
- /** Schema factory for a single toast entry. `payloadSchema` is user-provided
23
- * and defines the shape of per-entry content, whatever the consumer wants
24
- * to encode. The component itself owns only lifecycle + a11y fields: `id`,
25
- * `variant` (for ARIA role), `animation`, `maybeDuration`,
26
- * `pendingDismissVersion` (for cancellable auto-dismiss), and `isHovered`
27
- * (for pause-on-hover). */
28
- export const makeEntry = (payloadSchema) => S.Struct({
29
- id: S.String,
30
- variant: Variant,
31
- animation: AnimationModel,
32
- maybeDuration: S.Option(S.DurationFromMillis),
33
- pendingDismissVersion: S.Number,
34
- isHovered: S.Boolean,
35
- payload: payloadSchema,
36
- });
37
- // MODEL
38
- /** Schema factory for the toast container's state. `nextEntryKey` is a
39
- * monotonic counter used to generate unique entry IDs purely from Model
40
- * state. Thread the updated model through successive `show()` calls.
41
- * Calling `show()` twice against the same pre-update model in the same tick
42
- * will produce duplicate entry IDs. */
43
- export const makeModel = (payloadSchema) => S.Struct({
44
- id: S.String,
45
- defaultDuration: S.DurationFromMillis,
46
- entries: S.Array(makeEntry(payloadSchema)),
47
- nextEntryKey: S.Number,
48
- });
49
- // MESSAGE
50
- /** Sent when an entry should begin dismissing. Starts the leave animation;
51
- * the entry is removed from the stack when `TransitionedOut` fires. */
52
- export const Dismissed = m('Dismissed', { entryId: S.String });
53
- /** Sent when every currently-visible entry should begin dismissing. */
54
- export const DismissedAll = m('DismissedAll');
55
- /** Sent when an entry's auto-dismiss timer fires. Carries a version echoed
56
- * from the scheduling moment so stale timers (from hover or manual dismiss)
57
- * are discarded. */
58
- export const ElapsedDuration = m('ElapsedDuration', {
59
- entryId: S.String,
60
- version: S.Number,
61
- });
62
- /** Sent when the pointer enters an entry. Pauses the auto-dismiss timer by
63
- * advancing the entry's version. */
64
- export const HoveredEntry = m('HoveredEntry', { entryId: S.String });
65
- /** Sent when the pointer leaves an entry. Restarts the auto-dismiss timer
66
- * with the entry's full duration. */
67
- export const LeftEntry = m('LeftEntry', { entryId: S.String });
68
- /** Wraps a single entry's Animation submodel message for delegation. */
69
- export const GotAnimationMessage = m('GotAnimationMessage', {
70
- entryId: S.String,
71
- message: AnimationMessage,
72
- });
73
- /** Factory for the `Added` message, which carries a fully-constructed entry
74
- * whose shape depends on the user-provided payload. */
75
- export const makeAdded = (payloadSchema) => m('Added', { entry: makeEntry(payloadSchema) });
76
- /** Factory for the union of all messages the toast component can produce. */
77
- export const makeMessage = (payloadSchema) => S.Union([
78
- makeAdded(payloadSchema),
79
- Dismissed,
80
- DismissedAll,
81
- ElapsedDuration,
82
- HoveredEntry,
83
- LeftEntry,
84
- GotAnimationMessage,
85
- ]);
86
- /** Factory for `DismissedToast`, the OutMessage emitted once an entry has
87
- * finished dismissing (leave-animation `TransitionedOut`). Carries the
88
- * payload so consumers can lift the dismissal into a domain Message
89
- * without looking the entry up from a stale model. */
90
- export const makeDismissedToast = (payloadSchema) => m('DismissedToast', { payload: payloadSchema });
91
- /** Factory for the union of out-messages the toast component can produce. */
92
- export const makeOutMessage = (payloadSchema) => S.Union([makeDismissedToast(payloadSchema)]);
93
- export const DEFAULT_DURATION = Duration.seconds(4);