foldkit 0.111.1 → 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,317 +0,0 @@
1
- import { Function, Match as M, Option, Schema as S } from 'effect';
2
- import * as Calendar from '../../calendar/index.js';
3
- import * as Command from '../../command/index.js';
4
- import { defineView, html, } from '../../html/index.js';
5
- import { m } from '../../message/index.js';
6
- import { evo } from '../../struct/index.js';
7
- import * as UiCalendar from '../calendar/index.js';
8
- import * as Popover from '../popover/index.js';
9
- // MODEL
10
- /** Schema for the date picker component's state. Holds the selected date,
11
- * the embedded Calendar submodel (the visible grid), and the embedded Popover
12
- * submodel (the open/close + transition layer). */
13
- export const Model = S.Struct({
14
- id: S.String,
15
- maybeSelectedDate: S.Option(Calendar.CalendarDate),
16
- calendar: UiCalendar.Model,
17
- popover: Popover.Model,
18
- });
19
- // MESSAGE
20
- /** Wraps a Calendar submodel message for delegation. */
21
- export const GotCalendarMessage = m('GotCalendarMessage', {
22
- message: UiCalendar.Message,
23
- });
24
- /** Wraps a Popover submodel message for delegation. */
25
- export const GotPopoverMessage = m('GotPopoverMessage', {
26
- message: Popover.Message,
27
- });
28
- /** Sent when the user commits a date via click or keyboard. Updates the
29
- * selected date, syncs the calendar, and closes the popover. */
30
- export const RequestedSelectDate = m('RequestedSelectDate', {
31
- date: Calendar.CalendarDate,
32
- });
33
- /** Sent when the user clears the selected date. Does not close the popover. */
34
- export const Cleared = m('Cleared');
35
- /** Sent when the popover should open. Triggers focus-grid on the embedded
36
- * Calendar so keyboard focus lands inside the grid instead of the panel. */
37
- export const Opened = m('Opened');
38
- /** Sent when the popover should close. Delegates to Popover which returns
39
- * focus to the trigger button. */
40
- export const Closed = m('Closed');
41
- /** Union of all messages the date picker component can produce. */
42
- export const Message = S.Union([
43
- GotCalendarMessage,
44
- GotPopoverMessage,
45
- RequestedSelectDate,
46
- Cleared,
47
- Opened,
48
- Closed,
49
- ]);
50
- // OUT MESSAGE
51
- /** Emitted when the visible month changes (propagated from the embedded
52
- * Calendar). Useful for month-scoped data loading. */
53
- export const ChangedViewMonth = m('ChangedViewMonth', {
54
- year: S.Int,
55
- month: S.Int,
56
- });
57
- /** Emitted when the user commits a date selection (propagated from the
58
- * embedded Calendar). The popover has already closed; the parent reads the
59
- * committed date and lifts it into domain state. */
60
- export const SelectedDate = m('SelectedDate', {
61
- date: Calendar.CalendarDate,
62
- });
63
- /** Union of out-messages the date picker can produce. */
64
- export const OutMessage = S.Union([ChangedViewMonth, SelectedDate]);
65
- /** Creates an initial date picker model from a config. The calendar and
66
- * popover submodels are created with derived ids so their DOM elements stay
67
- * addressable. The popover is opened in `contentFocus` mode so focus lands on
68
- * the calendar grid instead of the panel. */
69
- export const init = (config) => ({
70
- id: config.id,
71
- maybeSelectedDate: Option.fromNullishOr(config.initialSelectedDate),
72
- calendar: UiCalendar.init({
73
- id: `${config.id}-calendar`,
74
- today: config.today,
75
- ...(config.initialSelectedDate !== undefined && {
76
- initialSelectedDate: config.initialSelectedDate,
77
- }),
78
- ...(config.locale !== undefined && { locale: config.locale }),
79
- ...(config.minDate !== undefined && { minDate: config.minDate }),
80
- ...(config.maxDate !== undefined && { maxDate: config.maxDate }),
81
- ...(config.disabledDaysOfWeek !== undefined && {
82
- disabledDaysOfWeek: config.disabledDaysOfWeek,
83
- }),
84
- ...(config.disabledDates !== undefined && {
85
- disabledDates: config.disabledDates,
86
- }),
87
- }),
88
- popover: Popover.init({
89
- id: `${config.id}-popover`,
90
- contentFocus: true,
91
- ...(config.isAnimated !== undefined && { isAnimated: config.isAnimated }),
92
- }),
93
- });
94
- const withUpdateReturn = M.withReturnType();
95
- const mapCalendarCommands = (commands) => Command.mapMessages(commands, message => GotCalendarMessage({ message }));
96
- const mapPopoverCommands = (commands) => Command.mapMessages(commands, message => GotPopoverMessage({ message }));
97
- const delegateToCalendar = (model, calendarMessage) => {
98
- const [nextCalendar, calendarCommands, maybeCalendarOutMessage] = UiCalendar.update(model.calendar, calendarMessage);
99
- const modelWithCalendar = evo(model, { calendar: () => nextCalendar });
100
- return Option.match(maybeCalendarOutMessage, {
101
- onNone: () => [
102
- modelWithCalendar,
103
- mapCalendarCommands(calendarCommands),
104
- Option.none(),
105
- ],
106
- onSome: M.type().pipe(M.withReturnType(), M.tagsExhaustive({
107
- ChangedViewMonth: ({ year, month }) => [
108
- modelWithCalendar,
109
- mapCalendarCommands(calendarCommands),
110
- Option.some(ChangedViewMonth({ year, month })),
111
- ],
112
- SelectedDate: ({ date }) => {
113
- const [nextPopover, popoverCommands] = Popover.close(model.popover);
114
- return [
115
- evo(modelWithCalendar, {
116
- maybeSelectedDate: () => Option.some(date),
117
- popover: () => nextPopover,
118
- }),
119
- [
120
- ...mapCalendarCommands(calendarCommands),
121
- ...mapPopoverCommands(popoverCommands),
122
- ],
123
- Option.some(SelectedDate({ date })),
124
- ];
125
- },
126
- })),
127
- });
128
- };
129
- const delegateToPopover = (model, popoverMessage) => {
130
- const [nextPopover, popoverCommands, maybePopoverOutMessage] = Popover.update(model.popover, popoverMessage);
131
- const modelWithPopover = evo(model, { popover: () => nextPopover });
132
- return Option.match(maybePopoverOutMessage, {
133
- onNone: () => [
134
- modelWithPopover,
135
- mapPopoverCommands(popoverCommands),
136
- Option.none(),
137
- ],
138
- onSome: () => [
139
- evo(modelWithPopover, {
140
- calendar: () => UiCalendar.dropToDays(modelWithPopover.calendar),
141
- }),
142
- mapPopoverCommands(popoverCommands),
143
- Option.none(),
144
- ],
145
- });
146
- };
147
- /** Processes a date picker message and returns the next model, commands, and
148
- * optional OutMessage. */
149
- export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
150
- GotCalendarMessage: ({ message: calendarMessage }) => delegateToCalendar(model, calendarMessage),
151
- GotPopoverMessage: ({ message: popoverMessage }) => delegateToPopover(model, popoverMessage),
152
- Opened: () => {
153
- const [nextPopover, popoverCommands] = Popover.open(model.popover);
154
- return [
155
- evo(model, {
156
- popover: () => nextPopover,
157
- calendar: () => UiCalendar.dropToDays(model.calendar),
158
- }),
159
- mapPopoverCommands(popoverCommands),
160
- Option.none(),
161
- ];
162
- },
163
- Closed: () => {
164
- const [nextPopover, popoverCommands] = Popover.close(model.popover);
165
- return [
166
- evo(model, {
167
- popover: () => nextPopover,
168
- calendar: () => UiCalendar.dropToDays(model.calendar),
169
- }),
170
- mapPopoverCommands(popoverCommands),
171
- Option.none(),
172
- ];
173
- },
174
- RequestedSelectDate: ({ date }) => {
175
- const [nextCalendar, calendarCommands] = UiCalendar.selectDate(model.calendar, date);
176
- const [nextPopover, popoverCommands] = Popover.close(model.popover);
177
- return [
178
- evo(model, {
179
- maybeSelectedDate: () => Option.some(date),
180
- calendar: () => nextCalendar,
181
- popover: () => nextPopover,
182
- }),
183
- [
184
- ...mapCalendarCommands(calendarCommands),
185
- ...mapPopoverCommands(popoverCommands),
186
- ],
187
- Option.some(SelectedDate({ date })),
188
- ];
189
- },
190
- Cleared: () => [
191
- evo(model, {
192
- maybeSelectedDate: () => Option.none(),
193
- calendar: UiCalendar.reflectSelectedDate(Option.none()),
194
- }),
195
- [],
196
- Option.none(),
197
- ],
198
- }));
199
- /** Programmatically opens the date picker, updating the model and returning
200
- * focus and popover commands. Use this in domain-event handlers. */
201
- export const open = (model) => update(model, Opened());
202
- /** Programmatically closes the date picker. Use this in domain-event handlers. */
203
- export const close = (model) => update(model, Closed());
204
- /** Programmatically selects a date, committing it and closing the popover. Emits a `SelectedDate` OutMessage just like a user-initiated selection. */
205
- export const selectDate = (model, date) => update(model, RequestedSelectDate({ date }));
206
- /** Programmatically clears the selected date. */
207
- export const clear = (model) => update(model, Cleared());
208
- /** Reflects an externally-sourced selected date onto the date picker
209
- * without emitting an OutMessage or touching the popover. Sets the
210
- * picker's selection and reflects it onto the embedded calendar (moving
211
- * the calendar's view to the date), mirroring `selectDate`'s state change
212
- * minus the `SelectedDate` announcement and the popover close. Pass
213
- * `Option.none()` to clear. Use this to mirror external truth (a URL
214
- * parameter, a saved draft) onto the picker. Contrast with `selectDate`,
215
- * a user or programmatic *choice* that emits `SelectedDate`. Returns the
216
- * model directly because it produces no commands and no OutMessage. */
217
- export const reflectSelectedDate = Function.dual(2, (model, maybeDate) => evo(model, {
218
- maybeSelectedDate: () => maybeDate,
219
- calendar: () => UiCalendar.reflectSelectedDate(model.calendar, maybeDate),
220
- }));
221
- /** Reflects the minimum selectable date onto the embedded calendar. Pass
222
- * `Option.none()` to remove the minimum. Use this when the minimum derives
223
- * from other Model state (e.g. a start date field whose current selection
224
- * constrains an end date picker).
225
- *
226
- * Does NOT reconcile the current selection. If a previously-selected date
227
- * is now below the new minimum, it remains selected. Callers should `clear`
228
- * or reassign the selection explicitly if their domain requires it. */
229
- export const reflectMinDate = Function.dual(2, (model, maybeMinDate) => evo(model, {
230
- calendar: () => UiCalendar.reflectMinDate(model.calendar, maybeMinDate),
231
- }));
232
- /** Reflects the maximum selectable date onto the embedded calendar. Pass
233
- * `Option.none()` to remove the maximum. Does NOT reconcile the current
234
- * selection. */
235
- export const reflectMaxDate = Function.dual(2, (model, maybeMaxDate) => evo(model, {
236
- calendar: () => UiCalendar.reflectMaxDate(model.calendar, maybeMaxDate),
237
- }));
238
- /** Reflects the list of individually-disabled dates onto the embedded
239
- * calendar. Pass an empty array to clear. Does NOT reconcile the current
240
- * selection. */
241
- export const reflectDisabledDates = Function.dual(2, (model, disabledDates) => evo(model, {
242
- calendar: () => UiCalendar.reflectDisabledDates(model.calendar, disabledDates),
243
- }));
244
- /** Reflects the days of the week that are disabled onto the embedded calendar
245
- * (e.g. weekends). Pass an empty array to clear. Does NOT reconcile the
246
- * current selection. */
247
- export const reflectDisabledDaysOfWeek = Function.dual(2, (model, disabledDaysOfWeek) => evo(model, {
248
- calendar: () => UiCalendar.reflectDisabledDaysOfWeek(model.calendar, disabledDaysOfWeek),
249
- }));
250
- // VIEW
251
- const encodeIsoDate = S.encodeSync(Calendar.CalendarDateFromIsoString);
252
- /** Renders an accessible date picker: a trigger button that opens a popover
253
- * containing an accessible calendar grid. The date picker assembles the
254
- * embedded Calendar and Popover components into one flat API. Consumers
255
- * provide the trigger face and the calendar grid layout, DatePicker handles
256
- * focus choreography, open/close state, and form submission. */
257
- export const view = defineView((model, viewInputs) => {
258
- const h = html();
259
- const { anchor, triggerContent, toCalendarView, isDisabled, name, className, attributes = [], triggerClassName, triggerAttributes = [], panelClassName, panelAttributes = [], backdropClassName, backdropAttributes = [], } = viewInputs;
260
- const calendarVNode = h.submodel({
261
- slotId: model.calendar.id,
262
- model: model.calendar,
263
- view: UiCalendar.view,
264
- viewInputs: { toView: toCalendarView },
265
- toParentMessage: message => GotCalendarMessage({ message }),
266
- });
267
- const popoverVNode = h.submodel({
268
- slotId: model.popover.id,
269
- model: model.popover,
270
- view: Popover.view,
271
- viewInputs: {
272
- anchor,
273
- ...(isDisabled !== undefined && { isDisabled }),
274
- focusSelector: `#${model.calendar.id}-grid`,
275
- toView: ({ button, panel, backdrop, isVisible }) => h.div([], [
276
- h.button([
277
- ...button,
278
- ...(triggerClassName !== undefined
279
- ? [h.Class(triggerClassName)]
280
- : []),
281
- ...triggerAttributes,
282
- ], [triggerContent(model.maybeSelectedDate)]),
283
- ...(isVisible
284
- ? [
285
- h.div([
286
- ...backdrop,
287
- ...(backdropClassName !== undefined
288
- ? [h.Class(backdropClassName)]
289
- : []),
290
- ...backdropAttributes,
291
- ], []),
292
- h.div([
293
- ...panel,
294
- ...(panelClassName !== undefined
295
- ? [h.Class(panelClassName)]
296
- : []),
297
- ...panelAttributes,
298
- ], [calendarVNode]),
299
- ]
300
- : []),
301
- ]),
302
- },
303
- toParentMessage: message => GotPopoverMessage({ message }),
304
- });
305
- const hiddenInputValue = Option.match(model.maybeSelectedDate, {
306
- onNone: () => '',
307
- onSome: encodeIsoDate,
308
- });
309
- const maybeHiddenInput = name !== undefined
310
- ? [h.input([h.Type('hidden'), h.Name(name), h.Value(hiddenInputValue)])]
311
- : [];
312
- const wrapperAttributes = [
313
- ...(className !== undefined ? [h.Class(className)] : []),
314
- ...attributes,
315
- ];
316
- return h.div(wrapperAttributes, [popoverVNode, ...maybeHiddenInput]);
317
- });
@@ -1,3 +0,0 @@
1
- export { init, update, view, open, close, selectDate, clear, reflectSelectedDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
2
- export type { InitConfig, ViewInputs } from './index.js';
3
- //# sourceMappingURL=public.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../../src/ui/datePicker/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,UAAU,EACV,KAAK,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,EACL,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,OAAO,EACP,MAAM,EACN,MAAM,EACN,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +0,0 @@
1
- export { init, update, view, open, close, selectDate, clear, reflectSelectedDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
@@ -1,155 +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
- /** Schema for the dialog component's state, tracking its unique ID, open/closed status, animation support, and animation lifecycle phase. */
5
- export declare const Model: S.Struct<{
6
- readonly id: S.String;
7
- readonly isOpen: S.Boolean;
8
- readonly isAnimated: S.Boolean;
9
- readonly animation: S.Struct<{
10
- readonly id: S.String;
11
- readonly isShowing: S.Boolean;
12
- readonly transitionState: S.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>;
13
- }>;
14
- readonly maybeFocusSelector: S.Option<S.String>;
15
- }>;
16
- export type Model = typeof Model.Type;
17
- /** Sent when the dialog should open. Triggers the showModal command. */
18
- export declare const RequestedOpen: import("../../schema/index.js").CallableTaggedStruct<"RequestedOpen", {}>;
19
- /** Sent when the dialog should close (Escape key, backdrop click, or programmatic). */
20
- export declare const RequestedClose: import("../../schema/index.js").CallableTaggedStruct<"RequestedClose", {}>;
21
- /** Sent when the show-dialog command completes. */
22
- export declare const CompletedShowDialog: import("../../schema/index.js").CallableTaggedStruct<"CompletedShowDialog", {}>;
23
- /** Sent when the close-dialog command completes. */
24
- export declare const CompletedCloseDialog: import("../../schema/index.js").CallableTaggedStruct<"CompletedCloseDialog", {}>;
25
- /** Wraps an Animation submodel message for delegation. */
26
- export declare const GotAnimationMessage: import("../../schema/index.js").CallableTaggedStruct<"GotAnimationMessage", {
27
- 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", {}>]>;
28
- }>;
29
- /** Union of all messages the dialog component can produce. */
30
- export declare const Message: S.Union<[
31
- typeof RequestedOpen,
32
- typeof RequestedClose,
33
- typeof CompletedShowDialog,
34
- typeof CompletedCloseDialog,
35
- typeof GotAnimationMessage
36
- ]>;
37
- export type RequestedOpen = typeof RequestedOpen.Type;
38
- export type RequestedClose = typeof RequestedClose.Type;
39
- export type CompletedShowDialog = typeof CompletedShowDialog.Type;
40
- export type CompletedCloseDialog = typeof CompletedCloseDialog.Type;
41
- export type Message = typeof Message.Type;
42
- /** Sent once the dialog has transitioned to open. Fires after `update`
43
- * has processed `RequestedOpen` and `isOpen` reflects the new state.
44
- * Programmatic `Dialog.open` on an already-open model is a no-op that
45
- * does not re-emit. */
46
- export declare const Opened: import("../../schema/index.js").CallableTaggedStruct<"Opened", {}>;
47
- /** Sent once the dialog has transitioned to closed. Programmatic
48
- * `Dialog.close` on an already-closed model is a no-op that does not
49
- * re-emit; calling close while a leave animation is in progress is
50
- * also a no-op. */
51
- export declare const Closed: import("../../schema/index.js").CallableTaggedStruct<"Closed", {}>;
52
- /** Union of out-messages the dialog component can produce. */
53
- export declare const OutMessage: S.Union<readonly [import("../../schema/index.js").CallableTaggedStruct<"Opened", {}>, import("../../schema/index.js").CallableTaggedStruct<"Closed", {}>]>;
54
- export type Opened = typeof Opened.Type;
55
- export type Closed = typeof Closed.Type;
56
- export type OutMessage = typeof OutMessage.Type;
57
- /** Configuration for creating a dialog model with `init`. */
58
- export type InitConfig = Readonly<{
59
- id: string;
60
- isOpen?: boolean;
61
- isAnimated?: boolean;
62
- focusSelector?: string;
63
- }>;
64
- /** Creates an initial dialog model from a config. Defaults to closed and non-animated. */
65
- export declare const init: (config: InitConfig) => Model;
66
- type UpdateReturn = readonly [
67
- Model,
68
- ReadonlyArray<Command.Command<Message>>,
69
- Option.Option<OutMessage>
70
- ];
71
- /** Locks page scroll and calls `showModal()` on the native dialog element. */
72
- export declare const ShowDialog: Command.CommandDefinitionWithArgs<"ShowDialog", {
73
- id: S.String;
74
- maybeFocusSelector: S.Option<S.String>;
75
- }, Effect.Effect<{
76
- readonly _tag: "CompletedShowDialog";
77
- }, never, never>>;
78
- /** Calls `close()` on the native dialog element and unlocks page scroll. */
79
- export declare const CloseDialog: Command.CommandDefinitionWithArgs<"CloseDialog", {
80
- id: S.String;
81
- }, Effect.Effect<{
82
- readonly _tag: "CompletedCloseDialog";
83
- }, never, never>>;
84
- /** Processes a dialog message and returns the next model and commands. */
85
- export declare const update: (model: Model, message: Message) => UpdateReturn;
86
- /** Programmatically opens the dialog. */
87
- export declare const open: (model: Model) => UpdateReturn;
88
- /** Programmatically closes the dialog. */
89
- export declare const close: (model: Model) => UpdateReturn;
90
- /** Returns the ID used for `aria-labelledby` on the dialog. Apply this to your title element. */
91
- export declare const titleId: (model: Model) => string;
92
- /** Returns the ID used for `aria-describedby` on the dialog. Apply this to your description element. */
93
- export declare const descriptionId: (model: Model) => string;
94
- /** Render-time payload published to the consumer's `toView`.
95
- *
96
- * - `dialog`: attributes for the native `<dialog>` element. Carries
97
- * the id, ARIA labelling, `open` prop, positioning style, and the
98
- * `OnCancel` handler that wires Escape to `RequestedClose`. The
99
- * consumer MUST render an `h.dialog(...)` element so the framework's
100
- * `showModal`/`close()` commands can target it.
101
- * - `backdrop`: attributes for the backdrop element. Includes the
102
- * Animation data attributes and the `OnClick` handler that closes
103
- * the dialog on outside-click (suppressed while a leave animation
104
- * is in progress).
105
- * - `panel`: attributes for the panel element. Includes the panel id
106
- * (`${model.id}-panel`) and the Animation data attributes.
107
- * - `isVisible`: derived from `isOpen` and the Animation
108
- * `transitionState`. The consumer renders backdrop + panel only
109
- * while this is true. */
110
- export type RenderInfo = Readonly<{
111
- dialog: ReadonlyArray<ChildAttribute>;
112
- backdrop: ReadonlyArray<ChildAttribute>;
113
- panel: ReadonlyArray<ChildAttribute>;
114
- isVisible: boolean;
115
- }>;
116
- /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field. */
117
- export type ViewInputs = Readonly<{
118
- toView: (render: RenderInfo) => Html;
119
- }>;
120
- /** Renders a headless dialog component backed by the native `<dialog>`
121
- * element with `showModal()`. */
122
- export declare const view: import("../../html/submodel.js").SubmodelView<{
123
- readonly id: string;
124
- readonly isOpen: boolean;
125
- readonly isAnimated: boolean;
126
- readonly animation: {
127
- readonly id: string;
128
- readonly isShowing: boolean;
129
- readonly transitionState: "Idle" | "EnterStart" | "EnterAnimating" | "LeaveStart" | "LeaveAnimating";
130
- };
131
- readonly maybeFocusSelector: Option.Option<string>;
132
- }, {
133
- readonly _tag: "RequestedOpen";
134
- } | {
135
- readonly _tag: "RequestedClose";
136
- } | {
137
- readonly _tag: "CompletedShowDialog";
138
- } | {
139
- readonly _tag: "CompletedCloseDialog";
140
- } | {
141
- readonly _tag: "GotAnimationMessage";
142
- readonly message: {
143
- readonly _tag: "Showed";
144
- } | {
145
- readonly _tag: "Hid";
146
- } | {
147
- readonly _tag: "AdvancedAnimationFrame";
148
- } | {
149
- readonly _tag: "EndedAnimation";
150
- };
151
- }, Readonly<{
152
- toView: (render: RenderInfo) => Html;
153
- }>>;
154
- export {};
155
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/dialog/index.ts"],"names":[],"mappings":"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"}