foldkit 0.111.0 → 0.112.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 (222) 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/public.d.ts +1 -1
  17. package/dist/runtime/public.d.ts.map +1 -1
  18. package/dist/runtime/runtime.d.ts +14 -1
  19. package/dist/runtime/runtime.d.ts.map +1 -1
  20. package/dist/runtime/runtime.js +7 -4
  21. package/dist/runtime/subscription.d.ts +1 -1
  22. package/dist/subscription/public.d.ts +1 -1
  23. package/dist/subscription/public.d.ts.map +1 -1
  24. package/package.json +12 -93
  25. package/dist/devTools/overlay-styles.d.ts +0 -3
  26. package/dist/devTools/overlay-styles.d.ts.map +0 -1
  27. package/dist/devTools/overlay-styles.js +0 -706
  28. package/dist/devTools/overlay.d.ts +0 -63
  29. package/dist/devTools/overlay.d.ts.map +0 -1
  30. package/dist/devTools/overlay.js +0 -1244
  31. package/dist/test/apps/disabledButton.d.ts +0 -38
  32. package/dist/test/apps/disabledButton.d.ts.map +0 -1
  33. package/dist/test/apps/disabledButton.js +0 -71
  34. package/dist/ui/anchor.d.ts +0 -38
  35. package/dist/ui/anchor.d.ts.map +0 -1
  36. package/dist/ui/anchor.js +0 -142
  37. package/dist/ui/animation/index.d.ts +0 -49
  38. package/dist/ui/animation/index.d.ts.map +0 -1
  39. package/dist/ui/animation/index.js +0 -74
  40. package/dist/ui/animation/public.d.ts +0 -3
  41. package/dist/ui/animation/public.d.ts.map +0 -1
  42. package/dist/ui/animation/public.js +0 -1
  43. package/dist/ui/animation/schema.d.ts +0 -43
  44. package/dist/ui/animation/schema.d.ts.map +0 -1
  45. package/dist/ui/animation/schema.js +0 -41
  46. package/dist/ui/animation/update.d.ts +0 -24
  47. package/dist/ui/animation/update.d.ts.map +0 -1
  48. package/dist/ui/animation/update.js +0 -67
  49. package/dist/ui/button/index.d.ts +0 -17
  50. package/dist/ui/button/index.d.ts.map +0 -1
  51. package/dist/ui/button/index.js +0 -22
  52. package/dist/ui/button/public.d.ts +0 -3
  53. package/dist/ui/button/public.d.ts.map +0 -1
  54. package/dist/ui/button/public.js +0 -1
  55. package/dist/ui/calendar/index.d.ts +0 -462
  56. package/dist/ui/calendar/index.d.ts.map +0 -1
  57. package/dist/ui/calendar/index.js +0 -824
  58. package/dist/ui/calendar/public.d.ts +0 -3
  59. package/dist/ui/calendar/public.d.ts.map +0 -1
  60. package/dist/ui/calendar/public.js +0 -1
  61. package/dist/ui/checkbox/index.d.ts +0 -119
  62. package/dist/ui/checkbox/index.d.ts.map +0 -1
  63. package/dist/ui/checkbox/index.js +0 -110
  64. package/dist/ui/checkbox/public.d.ts +0 -3
  65. package/dist/ui/checkbox/public.d.ts.map +0 -1
  66. package/dist/ui/checkbox/public.js +0 -1
  67. package/dist/ui/combobox/multi.d.ts +0 -184
  68. package/dist/ui/combobox/multi.d.ts.map +0 -1
  69. package/dist/ui/combobox/multi.js +0 -81
  70. package/dist/ui/combobox/multiPublic.d.ts +0 -3
  71. package/dist/ui/combobox/multiPublic.d.ts.map +0 -1
  72. package/dist/ui/combobox/multiPublic.js +0 -1
  73. package/dist/ui/combobox/public.d.ts +0 -7
  74. package/dist/ui/combobox/public.d.ts.map +0 -1
  75. package/dist/ui/combobox/public.js +0 -3
  76. package/dist/ui/combobox/shared.d.ts +0 -422
  77. package/dist/ui/combobox/shared.d.ts.map +0 -1
  78. package/dist/ui/combobox/shared.js +0 -707
  79. package/dist/ui/combobox/single.d.ts +0 -199
  80. package/dist/ui/combobox/single.d.ts.map +0 -1
  81. package/dist/ui/combobox/single.js +0 -106
  82. package/dist/ui/datePicker/index.d.ts +0 -457
  83. package/dist/ui/datePicker/index.d.ts.map +0 -1
  84. package/dist/ui/datePicker/index.js +0 -317
  85. package/dist/ui/datePicker/public.d.ts +0 -3
  86. package/dist/ui/datePicker/public.d.ts.map +0 -1
  87. package/dist/ui/datePicker/public.js +0 -1
  88. package/dist/ui/dialog/index.d.ts +0 -155
  89. package/dist/ui/dialog/index.d.ts.map +0 -1
  90. package/dist/ui/dialog/index.js +0 -208
  91. package/dist/ui/dialog/public.d.ts +0 -3
  92. package/dist/ui/dialog/public.d.ts.map +0 -1
  93. package/dist/ui/dialog/public.js +0 -1
  94. package/dist/ui/disclosure/index.d.ts +0 -110
  95. package/dist/ui/disclosure/index.d.ts.map +0 -1
  96. package/dist/ui/disclosure/index.js +0 -110
  97. package/dist/ui/disclosure/public.d.ts +0 -3
  98. package/dist/ui/disclosure/public.d.ts.map +0 -1
  99. package/dist/ui/disclosure/public.js +0 -1
  100. package/dist/ui/dragAndDrop/index.d.ts +0 -540
  101. package/dist/ui/dragAndDrop/index.d.ts.map +0 -1
  102. package/dist/ui/dragAndDrop/index.js +0 -535
  103. package/dist/ui/dragAndDrop/public.d.ts +0 -3
  104. package/dist/ui/dragAndDrop/public.d.ts.map +0 -1
  105. package/dist/ui/dragAndDrop/public.js +0 -1
  106. package/dist/ui/fieldset/index.d.ts +0 -21
  107. package/dist/ui/fieldset/index.d.ts.map +0 -1
  108. package/dist/ui/fieldset/index.js +0 -25
  109. package/dist/ui/fieldset/public.d.ts +0 -3
  110. package/dist/ui/fieldset/public.d.ts.map +0 -1
  111. package/dist/ui/fieldset/public.js +0 -1
  112. package/dist/ui/fileDrop/index.d.ts +0 -109
  113. package/dist/ui/fileDrop/index.d.ts.map +0 -1
  114. package/dist/ui/fileDrop/index.js +0 -126
  115. package/dist/ui/fileDrop/public.d.ts +0 -3
  116. package/dist/ui/fileDrop/public.d.ts.map +0 -1
  117. package/dist/ui/fileDrop/public.js +0 -1
  118. package/dist/ui/group.d.ts +0 -8
  119. package/dist/ui/group.d.ts.map +0 -1
  120. package/dist/ui/group.js +0 -13
  121. package/dist/ui/index.d.ts +0 -25
  122. package/dist/ui/index.d.ts.map +0 -1
  123. package/dist/ui/index.js +0 -24
  124. package/dist/ui/input/index.d.ts +0 -26
  125. package/dist/ui/input/index.d.ts.map +0 -1
  126. package/dist/ui/input/index.js +0 -43
  127. package/dist/ui/input/public.d.ts +0 -3
  128. package/dist/ui/input/public.d.ts.map +0 -1
  129. package/dist/ui/input/public.js +0 -1
  130. package/dist/ui/keyboard.d.ts +0 -6
  131. package/dist/ui/keyboard.d.ts.map +0 -1
  132. package/dist/ui/keyboard.js +0 -9
  133. package/dist/ui/listbox/multi.d.ts +0 -190
  134. package/dist/ui/listbox/multi.d.ts.map +0 -1
  135. package/dist/ui/listbox/multi.js +0 -65
  136. package/dist/ui/listbox/multiPublic.d.ts +0 -3
  137. package/dist/ui/listbox/multiPublic.d.ts.map +0 -1
  138. package/dist/ui/listbox/multiPublic.js +0 -1
  139. package/dist/ui/listbox/public.d.ts +0 -7
  140. package/dist/ui/listbox/public.d.ts.map +0 -1
  141. package/dist/ui/listbox/public.js +0 -3
  142. package/dist/ui/listbox/shared.d.ts +0 -431
  143. package/dist/ui/listbox/shared.d.ts.map +0 -1
  144. package/dist/ui/listbox/shared.js +0 -669
  145. package/dist/ui/listbox/single.d.ts +0 -208
  146. package/dist/ui/listbox/single.d.ts.map +0 -1
  147. package/dist/ui/listbox/single.js +0 -73
  148. package/dist/ui/menu/index.d.ts +0 -367
  149. package/dist/ui/menu/index.d.ts.map +0 -1
  150. package/dist/ui/menu/index.js +0 -681
  151. package/dist/ui/menu/public.d.ts +0 -4
  152. package/dist/ui/menu/public.d.ts.map +0 -1
  153. package/dist/ui/menu/public.js +0 -1
  154. package/dist/ui/popover/index.d.ts +0 -267
  155. package/dist/ui/popover/index.d.ts.map +0 -1
  156. package/dist/ui/popover/index.js +0 -345
  157. package/dist/ui/popover/public.d.ts +0 -4
  158. package/dist/ui/popover/public.d.ts.map +0 -1
  159. package/dist/ui/popover/public.js +0 -1
  160. package/dist/ui/radioGroup/index.d.ts +0 -169
  161. package/dist/ui/radioGroup/index.d.ts.map +0 -1
  162. package/dist/ui/radioGroup/index.js +0 -196
  163. package/dist/ui/radioGroup/public.d.ts +0 -3
  164. package/dist/ui/radioGroup/public.d.ts.map +0 -1
  165. package/dist/ui/radioGroup/public.js +0 -1
  166. package/dist/ui/select/index.d.ts +0 -24
  167. package/dist/ui/select/index.d.ts.map +0 -1
  168. package/dist/ui/select/index.js +0 -40
  169. package/dist/ui/select/public.d.ts +0 -3
  170. package/dist/ui/select/public.d.ts.map +0 -1
  171. package/dist/ui/select/public.js +0 -1
  172. package/dist/ui/slider/index.d.ts +0 -318
  173. package/dist/ui/slider/index.d.ts.map +0 -1
  174. package/dist/ui/slider/index.js +0 -336
  175. package/dist/ui/slider/public.d.ts +0 -3
  176. package/dist/ui/slider/public.d.ts.map +0 -1
  177. package/dist/ui/slider/public.js +0 -1
  178. package/dist/ui/switch/index.d.ts +0 -99
  179. package/dist/ui/switch/index.d.ts.map +0 -1
  180. package/dist/ui/switch/index.js +0 -106
  181. package/dist/ui/switch/public.d.ts +0 -3
  182. package/dist/ui/switch/public.d.ts.map +0 -1
  183. package/dist/ui/switch/public.js +0 -1
  184. package/dist/ui/tabs/index.d.ts +0 -155
  185. package/dist/ui/tabs/index.d.ts.map +0 -1
  186. package/dist/ui/tabs/index.js +0 -184
  187. package/dist/ui/tabs/public.d.ts +0 -3
  188. package/dist/ui/tabs/public.d.ts.map +0 -1
  189. package/dist/ui/tabs/public.js +0 -1
  190. package/dist/ui/textarea/index.d.ts +0 -26
  191. package/dist/ui/textarea/index.d.ts.map +0 -1
  192. package/dist/ui/textarea/index.js +0 -44
  193. package/dist/ui/textarea/public.d.ts +0 -3
  194. package/dist/ui/textarea/public.d.ts.map +0 -1
  195. package/dist/ui/textarea/public.js +0 -1
  196. package/dist/ui/toast/index.d.ts +0 -608
  197. package/dist/ui/toast/index.d.ts.map +0 -1
  198. package/dist/ui/toast/index.js +0 -145
  199. package/dist/ui/toast/public.d.ts +0 -4
  200. package/dist/ui/toast/public.d.ts.map +0 -1
  201. package/dist/ui/toast/public.js +0 -1
  202. package/dist/ui/toast/schema.d.ts +0 -154
  203. package/dist/ui/toast/schema.d.ts.map +0 -1
  204. package/dist/ui/toast/schema.js +0 -93
  205. package/dist/ui/toast/update.d.ts +0 -510
  206. package/dist/ui/toast/update.d.ts.map +0 -1
  207. package/dist/ui/toast/update.js +0 -225
  208. package/dist/ui/tooltip/index.d.ts +0 -170
  209. package/dist/ui/tooltip/index.d.ts.map +0 -1
  210. package/dist/ui/tooltip/index.js +0 -252
  211. package/dist/ui/tooltip/public.d.ts +0 -4
  212. package/dist/ui/tooltip/public.d.ts.map +0 -1
  213. package/dist/ui/tooltip/public.js +0 -1
  214. package/dist/ui/typeahead.d.ts +0 -4
  215. package/dist/ui/typeahead.d.ts.map +0 -1
  216. package/dist/ui/typeahead.js +0 -14
  217. package/dist/ui/virtualList/index.d.ts +0 -202
  218. package/dist/ui/virtualList/index.d.ts.map +0 -1
  219. package/dist/ui/virtualList/index.js +0 -391
  220. package/dist/ui/virtualList/public.d.ts +0 -3
  221. package/dist/ui/virtualList/public.d.ts.map +0 -1
  222. package/dist/ui/virtualList/public.js +0 -1
@@ -1,208 +0,0 @@
1
- import { Effect, Match as M, Option, Schema as S } from 'effect';
2
- import * as Command from '../../command/index.js';
3
- import * as Dom from '../../dom/index.js';
4
- import { childAttributes, defineView, html, } from '../../html/index.js';
5
- import { m } from '../../message/index.js';
6
- import { evo } from '../../struct/index.js';
7
- // NOTE: Animation imports are split across schema + update to avoid a circular
8
- // dependency: animation → html → runtime → devtools → dialog → animation.
9
- // The barrel (../animation) imports from html, which starts the cycle.
10
- import { Hid as AnimationHid, Message as AnimationMessage, Model as AnimationModel, Showed as AnimationShowed, init as animationInit, } from '../animation/schema.js';
11
- import { defaultLeaveCommand as animationDefaultLeaveCommand, update as animationUpdate, } from '../animation/update.js';
12
- // MODEL
13
- /** Schema for the dialog component's state, tracking its unique ID, open/closed status, animation support, and animation lifecycle phase. */
14
- export const Model = S.Struct({
15
- id: S.String,
16
- isOpen: S.Boolean,
17
- isAnimated: S.Boolean,
18
- animation: AnimationModel,
19
- maybeFocusSelector: S.Option(S.String),
20
- });
21
- // MESSAGE
22
- /** Sent when the dialog should open. Triggers the showModal command. */
23
- export const RequestedOpen = m('RequestedOpen');
24
- /** Sent when the dialog should close (Escape key, backdrop click, or programmatic). */
25
- export const RequestedClose = m('RequestedClose');
26
- /** Sent when the show-dialog command completes. */
27
- export const CompletedShowDialog = m('CompletedShowDialog');
28
- /** Sent when the close-dialog command completes. */
29
- export const CompletedCloseDialog = m('CompletedCloseDialog');
30
- /** Wraps an Animation submodel message for delegation. */
31
- export const GotAnimationMessage = m('GotAnimationMessage', {
32
- message: AnimationMessage,
33
- });
34
- /** Union of all messages the dialog component can produce. */
35
- export const Message = S.Union([
36
- RequestedOpen,
37
- RequestedClose,
38
- CompletedShowDialog,
39
- CompletedCloseDialog,
40
- GotAnimationMessage,
41
- ]);
42
- // OUT MESSAGE
43
- /** Sent once the dialog has transitioned to open. Fires after `update`
44
- * has processed `RequestedOpen` and `isOpen` reflects the new state.
45
- * Programmatic `Dialog.open` on an already-open model is a no-op that
46
- * does not re-emit. */
47
- export const Opened = m('Opened');
48
- /** Sent once the dialog has transitioned to closed. Programmatic
49
- * `Dialog.close` on an already-closed model is a no-op that does not
50
- * re-emit; calling close while a leave animation is in progress is
51
- * also a no-op. */
52
- export const Closed = m('Closed');
53
- /** Union of out-messages the dialog component can produce. */
54
- export const OutMessage = S.Union([Opened, Closed]);
55
- /** Creates an initial dialog model from a config. Defaults to closed and non-animated. */
56
- export const init = (config) => ({
57
- id: config.id,
58
- isOpen: config.isOpen ?? false,
59
- isAnimated: config.isAnimated ?? false,
60
- animation: animationInit({
61
- id: `${config.id}-panel`,
62
- ...(config.isOpen !== undefined ? { isShowing: config.isOpen } : {}),
63
- }),
64
- maybeFocusSelector: Option.fromNullishOr(config.focusSelector),
65
- });
66
- // UPDATE
67
- const dialogSelector = (id) => `#${id}`;
68
- const withUpdateReturn = M.withReturnType();
69
- /** Locks page scroll and calls `showModal()` on the native dialog element. */
70
- export const ShowDialog = Command.define('ShowDialog', { id: S.String, maybeFocusSelector: S.Option(S.String) }, CompletedShowDialog)(({ id, maybeFocusSelector }) => Dom.lockScroll.pipe(Effect.andThen(() => Dom.showModal(dialogSelector(id), Option.match(maybeFocusSelector, {
71
- onNone: () => undefined,
72
- onSome: focusSelector => ({ focusSelector }),
73
- }))), Effect.ignore, Effect.as(CompletedShowDialog())));
74
- /** Calls `close()` on the native dialog element and unlocks page scroll. */
75
- export const CloseDialog = Command.define('CloseDialog', { id: S.String }, CompletedCloseDialog)(({ id }) => Dom.closeModal(dialogSelector(id)).pipe(Effect.andThen(() => Dom.unlockScroll), Effect.ignore, Effect.as(CompletedCloseDialog())));
76
- const wrapAnimationMessage = (message) => GotAnimationMessage({ message });
77
- const delegateToAnimation = (model, animationMessage) => {
78
- const [nextAnimation, animationCommands, maybeOutMessage] = animationUpdate(model.animation, animationMessage);
79
- const mappedCommands = Command.mapMessages(animationCommands, wrapAnimationMessage);
80
- const additionalCommands = Option.match(maybeOutMessage, {
81
- onNone: () => [],
82
- onSome: M.type().pipe(M.tagsExhaustive({
83
- StartedLeaveAnimating: () => [
84
- Command.mapMessage(animationDefaultLeaveCommand(nextAnimation), wrapAnimationMessage),
85
- ],
86
- TransitionedOut: () => [CloseDialog({ id: model.id })],
87
- })),
88
- });
89
- return [
90
- evo(model, { animation: () => nextAnimation }),
91
- [...mappedCommands, ...additionalCommands],
92
- Option.none(),
93
- ];
94
- };
95
- /** Processes a dialog message and returns the next model and commands. */
96
- export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
97
- RequestedOpen: () => {
98
- const wasClosed = !model.isOpen;
99
- const maybeShow = Option.liftPredicate(ShowDialog({
100
- id: model.id,
101
- maybeFocusSelector: model.maybeFocusSelector,
102
- }), () => wasClosed);
103
- const maybeOutMessage = wasClosed
104
- ? Option.some(Opened())
105
- : Option.none();
106
- if (model.isAnimated) {
107
- const [nextModel, animationCommands] = delegateToAnimation(model, AnimationShowed());
108
- return [
109
- evo(nextModel, { isOpen: () => true }),
110
- [...Option.toArray(maybeShow), ...animationCommands],
111
- maybeOutMessage,
112
- ];
113
- }
114
- return [
115
- evo(model, { isOpen: () => true }),
116
- Option.toArray(maybeShow),
117
- maybeOutMessage,
118
- ];
119
- },
120
- RequestedClose: () => {
121
- const { transitionState } = model.animation;
122
- const isLeaving = transitionState === 'LeaveStart' ||
123
- transitionState === 'LeaveAnimating';
124
- if (isLeaving) {
125
- return [model, [], Option.none()];
126
- }
127
- const wasOpen = model.isOpen;
128
- const maybeOutMessage = wasOpen ? Option.some(Closed()) : Option.none();
129
- if (model.isAnimated) {
130
- const [nextModel, animationCommands] = delegateToAnimation(evo(model, { isOpen: () => false }), AnimationHid());
131
- return [nextModel, animationCommands, maybeOutMessage];
132
- }
133
- const maybeClose = Option.liftPredicate(CloseDialog({ id: model.id }), () => wasOpen);
134
- return [
135
- evo(model, { isOpen: () => false }),
136
- Option.toArray(maybeClose),
137
- maybeOutMessage,
138
- ];
139
- },
140
- GotAnimationMessage: ({ message: animationMessage }) => delegateToAnimation(model, animationMessage),
141
- CompletedShowDialog: () => [model, [], Option.none()],
142
- CompletedCloseDialog: () => [model, [], Option.none()],
143
- }));
144
- /** Programmatically opens the dialog. */
145
- export const open = (model) => update(model, RequestedOpen());
146
- /** Programmatically closes the dialog. */
147
- export const close = (model) => update(model, RequestedClose());
148
- // VIEW
149
- /** Returns the ID used for `aria-labelledby` on the dialog. Apply this to your title element. */
150
- export const titleId = (model) => `${model.id}-title`;
151
- /** Returns the ID used for `aria-describedby` on the dialog. Apply this to your description element. */
152
- export const descriptionId = (model) => `${model.id}-description`;
153
- /** Renders a headless dialog component backed by the native `<dialog>`
154
- * element with `showModal()`. */
155
- export const view = defineView((model, viewInputs) => {
156
- const h = html();
157
- const { id, isOpen, animation: { transitionState }, } = model;
158
- const { toView } = viewInputs;
159
- const isLeaving = transitionState === 'LeaveStart' || transitionState === 'LeaveAnimating';
160
- const isVisible = isOpen || isLeaving;
161
- const animationAttributes = M.value(transitionState).pipe(M.when('EnterStart', () => [
162
- h.DataAttribute('closed', ''),
163
- h.DataAttribute('enter', ''),
164
- h.DataAttribute('transition', ''),
165
- ]), M.when('EnterAnimating', () => [
166
- h.DataAttribute('enter', ''),
167
- h.DataAttribute('transition', ''),
168
- ]), M.when('LeaveStart', () => [
169
- h.DataAttribute('leave', ''),
170
- h.DataAttribute('transition', ''),
171
- ]), M.when('LeaveAnimating', () => [
172
- h.DataAttribute('closed', ''),
173
- h.DataAttribute('leave', ''),
174
- h.DataAttribute('transition', ''),
175
- ]), M.orElse(() => []));
176
- const dialogAttributes = [
177
- h.Id(id),
178
- h.AriaLabelledBy(`${id}-title`),
179
- h.AriaDescribedBy(`${id}-description`),
180
- h.OnCancel(RequestedClose()),
181
- h.Open(isVisible),
182
- h.Style({
183
- width: '100%',
184
- height: '100%',
185
- maxWidth: '100%',
186
- maxHeight: '100%',
187
- padding: '0',
188
- border: 'none',
189
- background: 'transparent',
190
- ...(isVisible
191
- ? { position: 'fixed', inset: '0', zIndex: '2147483600' }
192
- : {}),
193
- }),
194
- ...(isVisible ? [h.DataAttribute('open', '')] : []),
195
- ];
196
- const backdropAttributes = [
197
- h.Style({ minHeight: '100vh' }),
198
- ...animationAttributes,
199
- ...(isLeaving ? [] : [h.OnClick(RequestedClose())]),
200
- ];
201
- const panelAttributes = [h.Id(`${id}-panel`), ...animationAttributes];
202
- return toView({
203
- dialog: childAttributes(dialogAttributes),
204
- backdrop: childAttributes(backdropAttributes),
205
- panel: childAttributes(panelAttributes),
206
- isVisible,
207
- });
208
- });
@@ -1,3 +0,0 @@
1
- export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, GotAnimationMessage, ShowDialog, CloseDialog, } from './index.js';
2
- export type { InitConfig, ViewInputs, RenderInfo } from './index.js';
3
- //# sourceMappingURL=public.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/dialog/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,EACP,aAAa,EACb,KAAK,EACL,OAAO,EACP,UAAU,EACV,MAAM,EACN,MAAM,EACN,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- export { init, update, open, close, view, titleId, descriptionId, Model, Message, OutMessage, Opened, Closed, RequestedOpen, RequestedClose, CompletedShowDialog, CompletedCloseDialog, GotAnimationMessage, ShowDialog, CloseDialog, } from './index.js';
@@ -1,110 +0,0 @@
1
- import { Effect, Option, Schema as S } from 'effect';
2
- import * as Command from '../../command/index.js';
3
- import { type ChildAttribute, type Html } from '../../html/index.js';
4
- import type { Reflect } from '../../submodel/submodel.js';
5
- /** Schema for the disclosure component's state, tracking its unique ID and open/closed status. */
6
- export declare const Model: S.Struct<{
7
- readonly id: S.String;
8
- readonly isOpen: S.Boolean;
9
- }>;
10
- export type Model = typeof Model.Type;
11
- /** Sent when the disclosure button is clicked. Toggles the open/closed state. */
12
- export declare const Toggled: import("../../schema/index.js").CallableTaggedStruct<"Toggled", {}>;
13
- /** Sent to explicitly close the disclosure, regardless of its current state. */
14
- export declare const Closed: import("../../schema/index.js").CallableTaggedStruct<"Closed", {}>;
15
- /** Sent when the focus-button command completes after closing. */
16
- export declare const CompletedFocusButton: import("../../schema/index.js").CallableTaggedStruct<"CompletedFocusButton", {}>;
17
- /** Union of all messages the disclosure component can produce. */
18
- export declare const Message: S.Union<[
19
- typeof Toggled,
20
- typeof Closed,
21
- typeof CompletedFocusButton
22
- ]>;
23
- export type Toggled = typeof Toggled.Type;
24
- export type Closed = typeof Closed.Type;
25
- export type CompletedFocusButton = typeof CompletedFocusButton.Type;
26
- export type Message = typeof Message.Type;
27
- /** Sent to the parent each time the disclosure toggles. The new open state is available on the next model snapshot; this OutMessage signals only that the transition happened. Consumers typically use this for analytics, lazy content loading, or saving open/closed state to a store. */
28
- export declare const ToggledOpenState: import("../../schema/index.js").CallableTaggedStruct<"ToggledOpenState", {
29
- isOpen: S.Boolean;
30
- }>;
31
- export declare const OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"ToggledOpenState", {
32
- isOpen: S.Boolean;
33
- }>]>;
34
- export type OutMessage = typeof OutMessage.Type;
35
- export type ToggledOpenState = typeof ToggledOpenState.Type;
36
- /** Configuration for creating a disclosure model with `init`. */
37
- export type InitConfig = Readonly<{
38
- id: string;
39
- isOpen?: boolean;
40
- }>;
41
- /** Creates an initial disclosure model from a config. Defaults to closed. */
42
- export declare const init: (config: InitConfig) => Model;
43
- /** Moves focus to the disclosure's toggle button. */
44
- export declare const FocusButton: Command.CommandDefinitionWithArgs<"FocusButton", {
45
- id: S.String;
46
- }, Effect.Effect<{
47
- readonly _tag: "CompletedFocusButton";
48
- }, never, never>>;
49
- type UpdateReturn = readonly [
50
- Model,
51
- ReadonlyArray<Command.Command<Message>>,
52
- Option.Option<OutMessage>
53
- ];
54
- /** Processes a disclosure message and returns the next model, commands, and optional OutMessage. */
55
- export declare const update: (model: Model, message: Message) => UpdateReturn;
56
- /** Programmatically toggles the disclosure, updating the model and returning
57
- * focus commands plus a `ToggledOpenState` OutMessage. */
58
- export declare const toggle: (model: Model) => UpdateReturn;
59
- /** Programmatically closes the disclosure, updating the model and returning
60
- * focus commands plus a `ToggledOpenState` OutMessage when it was open. */
61
- export declare const close: (model: Model) => UpdateReturn;
62
- /** Reflects an externally-sourced open state onto the model without
63
- * emitting an OutMessage or running the focus command. Use this to mirror
64
- * external truth (restored storage, a deep link) onto the disclosure.
65
- * Contrast with `toggle`/`close`, which represent user or programmatic
66
- * *choices* and emit `ToggledOpenState`. Returns the model directly
67
- * because it produces no commands and no OutMessage. */
68
- export declare const reflectOpenState: Reflect<Model, boolean>;
69
- /** Attribute groups the disclosure component provides to the consumer's
70
- * `toView` callback. The consumer composes the button + panel layout
71
- * themselves using these bundles. */
72
- export type DisclosureAttributes = Readonly<{
73
- button: ReadonlyArray<ChildAttribute>;
74
- panel: ReadonlyArray<ChildAttribute>;
75
- }>;
76
- /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
77
- *
78
- * - `toView`: receives the disclosure's `button` and `panel` attribute
79
- * bundles and returns the composed layout. The consumer reads
80
- * `isOpen` from their parent model when they need to render
81
- * conditionally on it.
82
- * - `isDisabled`: when true, the button is not clickable, gets
83
- * `aria-disabled` and a `data-disabled` attribute. */
84
- export type ViewInputs = Readonly<{
85
- toView: (attributes: DisclosureAttributes) => Html;
86
- isDisabled?: boolean;
87
- }>;
88
- /** Renders a headless disclosure component with accessible ARIA
89
- * attributes and keyboard support. The consumer composes the layout
90
- * through the `toView` slot, spreading the published `button` and
91
- * `panel` attribute bundles onto their own elements.
92
- *
93
- * Designed to be embedded via `h.submodel`. The consumer reacts to
94
- * toggle events by pattern-matching the `ToggledOpenState` OutMessage
95
- * from the third element of `update`'s return tuple. */
96
- export declare const view: import("../../html/submodel.js").SubmodelView<{
97
- readonly id: string;
98
- readonly isOpen: boolean;
99
- }, {
100
- readonly _tag: "Closed";
101
- } | {
102
- readonly _tag: "CompletedFocusButton";
103
- } | {
104
- readonly _tag: "Toggled";
105
- }, Readonly<{
106
- toView: (attributes: DisclosureAttributes) => Html;
107
- isDisabled?: boolean;
108
- }>>;
109
- export {};
110
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/disclosure/index.ts"],"names":[],"mappings":"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"}
@@ -1,110 +0,0 @@
1
- import { Effect, Function, Match as M, Option, Schema as S } from 'effect';
2
- import * as Command from '../../command/index.js';
3
- import * as Dom from '../../dom/index.js';
4
- import { childAttributes, defineView, html, } from '../../html/index.js';
5
- import { m } from '../../message/index.js';
6
- import { evo } from '../../struct/index.js';
7
- // MODEL
8
- /** Schema for the disclosure component's state, tracking its unique ID and open/closed status. */
9
- export const Model = S.Struct({
10
- id: S.String,
11
- isOpen: S.Boolean,
12
- });
13
- // MESSAGE
14
- /** Sent when the disclosure button is clicked. Toggles the open/closed state. */
15
- export const Toggled = m('Toggled');
16
- /** Sent to explicitly close the disclosure, regardless of its current state. */
17
- export const Closed = m('Closed');
18
- /** Sent when the focus-button command completes after closing. */
19
- export const CompletedFocusButton = m('CompletedFocusButton');
20
- /** Union of all messages the disclosure component can produce. */
21
- export const Message = S.Union([Toggled, Closed, CompletedFocusButton]);
22
- // OUT MESSAGE
23
- /** Sent to the parent each time the disclosure toggles. The new open state is available on the next model snapshot; this OutMessage signals only that the transition happened. Consumers typically use this for analytics, lazy content loading, or saving open/closed state to a store. */
24
- export const ToggledOpenState = m('ToggledOpenState', { isOpen: S.Boolean });
25
- export const OutMessage = S.Union([ToggledOpenState]);
26
- /** Creates an initial disclosure model from a config. Defaults to closed. */
27
- export const init = (config) => ({
28
- id: config.id,
29
- isOpen: config.isOpen ?? false,
30
- });
31
- // UPDATE
32
- const buttonId = (id) => `${id}-button`;
33
- const buttonSelector = (id) => `#${CSS.escape(buttonId(id))}`;
34
- const panelId = (id) => `${id}-panel`;
35
- /** Moves focus to the disclosure's toggle button. */
36
- export const FocusButton = Command.define('FocusButton', { id: S.String }, CompletedFocusButton)(({ id }) => Dom.focus(buttonSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusButton())));
37
- const withUpdateReturn = M.withReturnType();
38
- /** Processes a disclosure message and returns the next model, commands, and optional OutMessage. */
39
- export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
40
- Toggled: () => {
41
- const nextIsOpen = !model.isOpen;
42
- const maybeFocus = Option.liftPredicate(FocusButton({ id: model.id }), () => model.isOpen);
43
- return [
44
- evo(model, { isOpen: () => nextIsOpen }),
45
- Option.toArray(maybeFocus),
46
- Option.some(ToggledOpenState({ isOpen: nextIsOpen })),
47
- ];
48
- },
49
- Closed: () => {
50
- if (!model.isOpen) {
51
- return [model, [], Option.none()];
52
- }
53
- const maybeFocus = Option.liftPredicate(FocusButton({ id: model.id }), () => model.isOpen);
54
- return [
55
- evo(model, { isOpen: () => false }),
56
- Option.toArray(maybeFocus),
57
- Option.some(ToggledOpenState({ isOpen: false })),
58
- ];
59
- },
60
- CompletedFocusButton: () => [model, [], Option.none()],
61
- }));
62
- /** Programmatically toggles the disclosure, updating the model and returning
63
- * focus commands plus a `ToggledOpenState` OutMessage. */
64
- export const toggle = (model) => update(model, Toggled());
65
- /** Programmatically closes the disclosure, updating the model and returning
66
- * focus commands plus a `ToggledOpenState` OutMessage when it was open. */
67
- export const close = (model) => update(model, Closed());
68
- /** Reflects an externally-sourced open state onto the model without
69
- * emitting an OutMessage or running the focus command. Use this to mirror
70
- * external truth (restored storage, a deep link) onto the disclosure.
71
- * Contrast with `toggle`/`close`, which represent user or programmatic
72
- * *choices* and emit `ToggledOpenState`. Returns the model directly
73
- * because it produces no commands and no OutMessage. */
74
- export const reflectOpenState = Function.dual(2, (model, isOpen) => evo(model, { isOpen: () => isOpen }));
75
- /** Renders a headless disclosure component with accessible ARIA
76
- * attributes and keyboard support. The consumer composes the layout
77
- * through the `toView` slot, spreading the published `button` and
78
- * `panel` attribute bundles onto their own elements.
79
- *
80
- * Designed to be embedded via `h.submodel`. The consumer reacts to
81
- * toggle events by pattern-matching the `ToggledOpenState` OutMessage
82
- * from the third element of `update`'s return tuple. */
83
- export const view = defineView((model, viewInputs) => {
84
- const h = html();
85
- const { id, isOpen } = model;
86
- const { toView, isDisabled = false } = viewInputs;
87
- const handleKeyDown = (key) => M.value(key).pipe(M.whenOr('Enter', ' ', () => Option.some(Toggled())), M.orElse(() => Option.none()));
88
- const disabledAttributes = isDisabled
89
- ? [h.AriaDisabled(true), h.DataAttribute('disabled', '')]
90
- : [];
91
- const buttonAttributes = [
92
- h.Id(buttonId(id)),
93
- h.AriaExpanded(isOpen),
94
- h.AriaControls(panelId(id)),
95
- h.Tabindex(0),
96
- ...(isOpen ? [h.DataAttribute('open', '')] : []),
97
- ...disabledAttributes,
98
- ...(isDisabled
99
- ? []
100
- : [h.OnClick(Toggled()), h.OnKeyDownPreventDefault(handleKeyDown)]),
101
- ];
102
- const panelAttributes = [
103
- h.Id(panelId(id)),
104
- ...(isOpen ? [h.DataAttribute('open', '')] : []),
105
- ];
106
- return toView({
107
- button: childAttributes(buttonAttributes),
108
- panel: childAttributes(panelAttributes),
109
- });
110
- });
@@ -1,3 +0,0 @@
1
- export { init, update, toggle, close, reflectOpenState, view, Model, Message, OutMessage, ToggledOpenState, Closed, CompletedFocusButton, FocusButton, } from './index.js';
2
- export type { InitConfig, ViewInputs, DisclosureAttributes, Toggled, } from './index.js';
3
- //# sourceMappingURL=public.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/disclosure/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,UAAU,EACV,gBAAgB,EAChB,MAAM,EACN,oBAAoB,EACpB,WAAW,GACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,OAAO,GACR,MAAM,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- export { init, update, toggle, close, reflectOpenState, view, Model, Message, OutMessage, ToggledOpenState, Closed, CompletedFocusButton, FocusButton, } from './index.js';