@foldkit/ui 0.127.0 → 0.128.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 (79) hide show
  1. package/README.md +2 -2
  2. package/dist/calendar/index.d.ts +17 -23
  3. package/dist/calendar/index.d.ts.map +1 -1
  4. package/dist/calendar/index.js +16 -25
  5. package/dist/calendar/public.d.ts +1 -1
  6. package/dist/calendar/public.d.ts.map +1 -1
  7. package/dist/calendar/public.js +1 -1
  8. package/dist/checkbox/index.d.ts +47 -104
  9. package/dist/checkbox/index.d.ts.map +1 -1
  10. package/dist/checkbox/index.js +48 -87
  11. package/dist/checkbox/public.d.ts +2 -2
  12. package/dist/checkbox/public.d.ts.map +1 -1
  13. package/dist/checkbox/public.js +1 -1
  14. package/dist/combobox/multi.d.ts +19 -30
  15. package/dist/combobox/multi.d.ts.map +1 -1
  16. package/dist/combobox/multi.js +32 -53
  17. package/dist/combobox/public.d.ts +2 -2
  18. package/dist/combobox/public.d.ts.map +1 -1
  19. package/dist/combobox/public.js +1 -1
  20. package/dist/combobox/shared.d.ts +59 -35
  21. package/dist/combobox/shared.d.ts.map +1 -1
  22. package/dist/combobox/shared.js +58 -45
  23. package/dist/combobox/single.d.ts +36 -48
  24. package/dist/combobox/single.d.ts.map +1 -1
  25. package/dist/combobox/single.js +49 -76
  26. package/dist/datePicker/index.d.ts +33 -41
  27. package/dist/datePicker/index.d.ts.map +1 -1
  28. package/dist/datePicker/index.js +31 -40
  29. package/dist/datePicker/public.d.ts +1 -1
  30. package/dist/datePicker/public.d.ts.map +1 -1
  31. package/dist/datePicker/public.js +1 -1
  32. package/dist/disclosure/index.d.ts +49 -113
  33. package/dist/disclosure/index.d.ts.map +1 -1
  34. package/dist/disclosure/index.js +35 -92
  35. package/dist/disclosure/public.d.ts +2 -2
  36. package/dist/disclosure/public.d.ts.map +1 -1
  37. package/dist/disclosure/public.js +1 -1
  38. package/dist/listbox/multi.d.ts +7 -21
  39. package/dist/listbox/multi.d.ts.map +1 -1
  40. package/dist/listbox/multi.js +12 -36
  41. package/dist/listbox/public.d.ts +1 -1
  42. package/dist/listbox/public.d.ts.map +1 -1
  43. package/dist/listbox/shared.d.ts +28 -20
  44. package/dist/listbox/shared.d.ts.map +1 -1
  45. package/dist/listbox/shared.js +6 -7
  46. package/dist/listbox/single.d.ts +17 -27
  47. package/dist/listbox/single.d.ts.map +1 -1
  48. package/dist/listbox/single.js +18 -30
  49. package/dist/radioGroup/index.d.ts +57 -142
  50. package/dist/radioGroup/index.d.ts.map +1 -1
  51. package/dist/radioGroup/index.js +44 -119
  52. package/dist/radioGroup/public.d.ts +2 -2
  53. package/dist/radioGroup/public.d.ts.map +1 -1
  54. package/dist/radioGroup/public.js +1 -1
  55. package/dist/slider/index.d.ts +51 -27
  56. package/dist/slider/index.d.ts.map +1 -1
  57. package/dist/slider/index.js +66 -66
  58. package/dist/slider/public.d.ts +1 -1
  59. package/dist/slider/public.d.ts.map +1 -1
  60. package/dist/slider/public.js +1 -1
  61. package/dist/switch/index.d.ts +45 -92
  62. package/dist/switch/index.d.ts.map +1 -1
  63. package/dist/switch/index.js +36 -81
  64. package/dist/switch/public.d.ts +2 -2
  65. package/dist/switch/public.d.ts.map +1 -1
  66. package/dist/switch/public.js +1 -1
  67. package/dist/tabs/index.d.ts +33 -33
  68. package/dist/tabs/index.d.ts.map +1 -1
  69. package/dist/tabs/index.js +36 -49
  70. package/dist/toast/index.d.ts +1 -0
  71. package/dist/toast/index.d.ts.map +1 -1
  72. package/dist/toast/index.js +1 -0
  73. package/dist/toast/public.d.ts +2 -0
  74. package/dist/toast/public.d.ts.map +1 -1
  75. package/dist/toast/public.js +1 -0
  76. package/dist/toast/test.d.ts +41 -0
  77. package/dist/toast/test.d.ts.map +1 -0
  78. package/dist/toast/test.js +36 -0
  79. package/package.json +5 -5
@@ -6,16 +6,13 @@ import { type ChildAttribute, type Html } from 'foldkit/html';
6
6
  import { type Reflect } from 'foldkit/submodel';
7
7
  import type { AnchorConfig } from '../anchor.js';
8
8
  import * as UiCalendar from '../calendar/index.js';
9
- /** Schema for the date picker component's state. Holds the selected date,
10
- * the embedded Calendar submodel (the visible grid), and the embedded Popover
11
- * submodel (the open/close + transition layer). */
9
+ /** Schema for the date picker component's private interaction state. The
10
+ * selected date is owned by the parent and passed in via
11
+ * `ViewInputs.maybeSelectedDate`. This holds the embedded Calendar submodel
12
+ * (the visible grid) and the embedded Popover submodel (the open/close +
13
+ * transition layer). */
12
14
  export declare const Model: S.Struct<{
13
15
  readonly id: S.String;
14
- readonly maybeSelectedDate: S.Option<S.Struct<{
15
- readonly year: S.Int;
16
- readonly month: S.Int;
17
- readonly day: S.Int;
18
- }>>;
19
16
  readonly calendar: S.Struct<{
20
17
  readonly id: S.String;
21
18
  readonly today: S.Struct<{
@@ -31,11 +28,6 @@ export declare const Model: S.Struct<{
31
28
  readonly month: S.Int;
32
29
  readonly day: S.Int;
33
30
  }>>;
34
- readonly maybeSelectedDate: S.Option<S.Struct<{
35
- readonly year: S.Int;
36
- readonly month: S.Int;
37
- readonly day: S.Int;
38
- }>>;
39
31
  readonly isGridFocused: S.Boolean;
40
32
  readonly locale: S.Struct<{
41
33
  readonly firstDayOfWeek: S.Literals<readonly ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>;
@@ -144,8 +136,8 @@ export declare const ChangedViewMonth: import("foldkit/schema").CallableTaggedSt
144
136
  month: S.Int;
145
137
  }>;
146
138
  /** Emitted when the user commits a date selection (propagated from the
147
- * embedded Calendar). The popover has already closed; the parent reads the
148
- * committed date and lifts it into domain state. */
139
+ * embedded Calendar). The popover has already closed; the parent stores the
140
+ * committed date and passes it back in as `maybeSelectedDate`. */
149
141
  export declare const SelectedDate: import("foldkit/schema").CallableTaggedStruct<"SelectedDate", {
150
142
  date: S.Struct<{
151
143
  readonly year: S.Int;
@@ -153,6 +145,9 @@ export declare const SelectedDate: import("foldkit/schema").CallableTaggedStruct
153
145
  readonly day: S.Int;
154
146
  }>;
155
147
  }>;
148
+ /** Emitted when the user clears the selected date. The parent clears its own
149
+ * value field. */
150
+ export declare const ClearedDate: import("foldkit/schema").CallableTaggedStruct<"ClearedDate", {}>;
156
151
  /** Union of out-messages the date picker can produce. */
157
152
  export declare const OutMessage: S.Union<readonly [import("foldkit/schema").CallableTaggedStruct<"ChangedViewMonth", {
158
153
  year: S.Int;
@@ -163,15 +158,16 @@ export declare const OutMessage: S.Union<readonly [import("foldkit/schema").Call
163
158
  readonly month: S.Int;
164
159
  readonly day: S.Int;
165
160
  }>;
166
- }>]>;
161
+ }>, import("foldkit/schema").CallableTaggedStruct<"ClearedDate", {}>]>;
167
162
  export type OutMessage = typeof OutMessage.Type;
168
163
  export type ChangedViewMonth = typeof ChangedViewMonth.Type;
169
164
  export type SelectedDate = typeof SelectedDate.Type;
165
+ export type ClearedDate = typeof ClearedDate.Type;
170
166
  /** Configuration for creating a date picker model with `init`. */
171
167
  export type InitConfig = Readonly<{
172
168
  id: string;
173
169
  today: CalendarDate;
174
- initialSelectedDate?: CalendarDate;
170
+ initialViewDate?: CalendarDate;
175
171
  isAnimated?: boolean;
176
172
  locale?: Calendar.LocaleConfig;
177
173
  minDate?: CalendarDate;
@@ -179,10 +175,12 @@ export type InitConfig = Readonly<{
179
175
  disabledDaysOfWeek?: ReadonlyArray<Calendar.DayOfWeek>;
180
176
  disabledDates?: ReadonlyArray<CalendarDate>;
181
177
  }>;
182
- /** Creates an initial date picker model from a config. The calendar and
183
- * popover submodels are created with derived ids so their DOM elements stay
184
- * addressable. The popover is opened in `contentFocus` mode so focus lands on
185
- * the calendar grid instead of the panel. */
178
+ /** Creates an initial date picker model from a config. The selected date is
179
+ * owned by the parent; pass its current value as `initialViewDate` to open the
180
+ * calendar onto that month. The calendar and popover submodels are created
181
+ * with derived ids so their DOM elements stay addressable. The popover is
182
+ * opened in `contentFocus` mode so focus lands on the calendar grid instead of
183
+ * the panel. */
186
184
  export declare const init: (config: InitConfig) => Model;
187
185
  type UpdateReturn = readonly [
188
186
  Model,
@@ -201,16 +199,12 @@ export declare const close: (model: Model) => UpdateReturn;
201
199
  export declare const selectDate: (model: Model, date: CalendarDate) => UpdateReturn;
202
200
  /** Programmatically clears the selected date. */
203
201
  export declare const clear: (model: Model) => UpdateReturn;
204
- /** Reflects an externally-sourced selected date onto the date picker
205
- * without emitting an OutMessage or touching the popover. Sets the
206
- * picker's selection and reflects it onto the embedded calendar (moving
207
- * the calendar's view to the date), mirroring `selectDate`'s state change
208
- * minus the `SelectedDate` announcement and the popover close. Pass
209
- * `Option.none()` to clear. Use this to mirror external truth (a URL
210
- * parameter, a saved draft) onto the picker. Contrast with `selectDate`,
211
- * a user or programmatic *choice* that emits `SelectedDate`. Returns the
212
- * model directly because it produces no commands and no OutMessage. */
213
- export declare const reflectSelectedDate: Reflect<Model, Option.Option<CalendarDate>>;
202
+ /** Moves the embedded calendar's view and cursor to a date without changing
203
+ * the selection (which the parent owns). Use it to navigate the picker onto a
204
+ * known date, for example after the parent sets its value externally (a URL
205
+ * parameter, a saved draft) so opening the picker shows that month. Returns
206
+ * the model directly because it produces no commands and no OutMessage. */
207
+ export declare const focusDate: Reflect<Model, CalendarDate>;
214
208
  /** Reflects the minimum selectable date onto the embedded calendar. Pass
215
209
  * `Option.none()` to remove the minimum. Use this when the minimum derives
216
210
  * from other Model state (e.g. a start date field whose current selection
@@ -246,6 +240,10 @@ export declare const triggerId: (id: string) => string;
246
240
  * `DatePicker.update`'s return) to lift the date into domain state. */
247
241
  export type ViewInputs = Readonly<{
248
242
  anchor: AnchorConfig;
243
+ /** The selected date, read straight from the parent Model. The trigger
244
+ * content, the calendar's selected-day marker, and the hidden form input all
245
+ * derive from it. */
246
+ maybeSelectedDate: Option.Option<CalendarDate>;
249
247
  /** Renders the trigger button's content (typically the formatted selected
250
248
  * date or a placeholder). Receives the current selection. */
251
249
  triggerContent: (maybeDate: Option.Option<CalendarDate>) => Html;
@@ -276,11 +274,6 @@ export type ViewInputs = Readonly<{
276
274
  * focus choreography, open/close state, and form submission. */
277
275
  export declare const view: import("foldkit/submodel").View<S.Struct.ReadonlySide<{
278
276
  readonly id: S.String;
279
- readonly maybeSelectedDate: S.Option<S.Struct<{
280
- readonly year: S.Int;
281
- readonly month: S.Int;
282
- readonly day: S.Int;
283
- }>>;
284
277
  readonly calendar: S.Struct<{
285
278
  readonly id: S.String;
286
279
  readonly today: S.Struct<{
@@ -296,11 +289,6 @@ export declare const view: import("foldkit/submodel").View<S.Struct.ReadonlySide
296
289
  readonly month: S.Int;
297
290
  readonly day: S.Int;
298
291
  }>>;
299
- readonly maybeSelectedDate: S.Option<S.Struct<{
300
- readonly year: S.Int;
301
- readonly month: S.Int;
302
- readonly day: S.Int;
303
- }>>;
304
292
  readonly isGridFocused: S.Boolean;
305
293
  readonly locale: S.Struct<{
306
294
  readonly firstDayOfWeek: S.Literals<readonly ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>;
@@ -386,6 +374,10 @@ export declare const view: import("foldkit/submodel").View<S.Struct.ReadonlySide
386
374
  readonly _tag: S.tag<"Cleared">;
387
375
  }, "Type">, Readonly<{
388
376
  anchor: AnchorConfig;
377
+ /** The selected date, read straight from the parent Model. The trigger
378
+ * content, the calendar's selected-day marker, and the hidden form input all
379
+ * derive from it. */
380
+ maybeSelectedDate: Option.Option<CalendarDate>;
389
381
  /** Renders the trigger button's content (typically the formatted selected
390
382
  * date or a placeholder). Receives the current selection. */
391
383
  triggerContent: (maybeDate: Option.Option<CalendarDate>) => Html;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datePicker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAa,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC7E,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,O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js';
9
9
  import { idSelector } from '../internal/selectors.js';
10
10
  import * as Popover from '../popover/index.js';
11
11
  // MODEL
12
- /** Schema for the date picker component's state. Holds the selected date,
13
- * the embedded Calendar submodel (the visible grid), and the embedded Popover
14
- * submodel (the open/close + transition layer). */
12
+ /** Schema for the date picker component's private interaction state. The
13
+ * selected date is owned by the parent and passed in via
14
+ * `ViewInputs.maybeSelectedDate`. This holds the embedded Calendar submodel
15
+ * (the visible grid) and the embedded Popover submodel (the open/close +
16
+ * transition layer). */
15
17
  export const Model = S.Struct({
16
18
  id: S.String,
17
- maybeSelectedDate: S.Option(Calendar.CalendarDate),
18
19
  calendar: UiCalendar.Model,
19
20
  popover: Popover.Model,
20
21
  });
@@ -57,25 +58,29 @@ export const ChangedViewMonth = m('ChangedViewMonth', {
57
58
  month: S.Int,
58
59
  });
59
60
  /** Emitted when the user commits a date selection (propagated from the
60
- * embedded Calendar). The popover has already closed; the parent reads the
61
- * committed date and lifts it into domain state. */
61
+ * embedded Calendar). The popover has already closed; the parent stores the
62
+ * committed date and passes it back in as `maybeSelectedDate`. */
62
63
  export const SelectedDate = m('SelectedDate', {
63
64
  date: Calendar.CalendarDate,
64
65
  });
66
+ /** Emitted when the user clears the selected date. The parent clears its own
67
+ * value field. */
68
+ export const ClearedDate = m('ClearedDate');
65
69
  /** Union of out-messages the date picker can produce. */
66
- export const OutMessage = S.Union([ChangedViewMonth, SelectedDate]);
67
- /** Creates an initial date picker model from a config. The calendar and
68
- * popover submodels are created with derived ids so their DOM elements stay
69
- * addressable. The popover is opened in `contentFocus` mode so focus lands on
70
- * the calendar grid instead of the panel. */
70
+ export const OutMessage = S.Union([ChangedViewMonth, SelectedDate, ClearedDate]);
71
+ /** Creates an initial date picker model from a config. The selected date is
72
+ * owned by the parent; pass its current value as `initialViewDate` to open the
73
+ * calendar onto that month. The calendar and popover submodels are created
74
+ * with derived ids so their DOM elements stay addressable. The popover is
75
+ * opened in `contentFocus` mode so focus lands on the calendar grid instead of
76
+ * the panel. */
71
77
  export const init = (config) => ({
72
78
  id: config.id,
73
- maybeSelectedDate: Option.fromNullishOr(config.initialSelectedDate),
74
79
  calendar: UiCalendar.init({
75
80
  id: `${config.id}-calendar`,
76
81
  today: config.today,
77
- ...(config.initialSelectedDate !== undefined && {
78
- initialSelectedDate: config.initialSelectedDate,
82
+ ...(config.initialViewDate !== undefined && {
83
+ initialViewDate: config.initialViewDate,
79
84
  }),
80
85
  ...(config.locale !== undefined && { locale: config.locale }),
81
86
  ...(config.minDate !== undefined && { minDate: config.minDate }),
@@ -115,7 +120,6 @@ const delegateToCalendar = (model, calendarMessage) => {
115
120
  const [nextPopover, popoverCommands] = Popover.close(model.popover);
116
121
  return [
117
122
  evo(modelWithCalendar, {
118
- maybeSelectedDate: () => Option.some(date),
119
123
  popover: () => nextPopover,
120
124
  }),
121
125
  [
@@ -178,7 +182,6 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
178
182
  const [nextPopover, popoverCommands] = Popover.close(model.popover);
179
183
  return [
180
184
  evo(model, {
181
- maybeSelectedDate: () => Option.some(date),
182
185
  calendar: () => nextCalendar,
183
186
  popover: () => nextPopover,
184
187
  }),
@@ -189,14 +192,7 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
189
192
  Option.some(SelectedDate({ date })),
190
193
  ];
191
194
  },
192
- Cleared: () => [
193
- evo(model, {
194
- maybeSelectedDate: () => Option.none(),
195
- calendar: UiCalendar.reflectSelectedDate(Option.none()),
196
- }),
197
- [],
198
- Option.none(),
199
- ],
195
+ Cleared: () => [model, [], Option.some(ClearedDate())],
200
196
  }));
201
197
  /** Programmatically opens the date picker, updating the model and returning
202
198
  * focus and popover commands. Use this in domain-event handlers. */
@@ -207,18 +203,13 @@ export const close = (model) => update(model, Closed());
207
203
  export const selectDate = (model, date) => update(model, RequestedSelectDate({ date }));
208
204
  /** Programmatically clears the selected date. */
209
205
  export const clear = (model) => update(model, Cleared());
210
- /** Reflects an externally-sourced selected date onto the date picker
211
- * without emitting an OutMessage or touching the popover. Sets the
212
- * picker's selection and reflects it onto the embedded calendar (moving
213
- * the calendar's view to the date), mirroring `selectDate`'s state change
214
- * minus the `SelectedDate` announcement and the popover close. Pass
215
- * `Option.none()` to clear. Use this to mirror external truth (a URL
216
- * parameter, a saved draft) onto the picker. Contrast with `selectDate`,
217
- * a user or programmatic *choice* that emits `SelectedDate`. Returns the
218
- * model directly because it produces no commands and no OutMessage. */
219
- export const reflectSelectedDate = Function.dual(2, (model, maybeDate) => evo(model, {
220
- maybeSelectedDate: () => maybeDate,
221
- calendar: () => UiCalendar.reflectSelectedDate(model.calendar, maybeDate),
206
+ /** Moves the embedded calendar's view and cursor to a date without changing
207
+ * the selection (which the parent owns). Use it to navigate the picker onto a
208
+ * known date, for example after the parent sets its value externally (a URL
209
+ * parameter, a saved draft) so opening the picker shows that month. Returns
210
+ * the model directly because it produces no commands and no OutMessage. */
211
+ export const focusDate = Function.dual(2, (model, date) => evo(model, {
212
+ calendar: () => UiCalendar.focusDate(model.calendar, date),
222
213
  }));
223
214
  /** Reflects the minimum selectable date onto the embedded calendar. Pass
224
215
  * `Option.none()` to remove the minimum. Use this when the minimum derives
@@ -265,7 +256,7 @@ const encodeIsoDate = S.encodeSync(Calendar.CalendarDateFromIsoString);
265
256
  * focus choreography, open/close state, and form submission. */
266
257
  export const view = defineView((model, viewInputs) => {
267
258
  const h = html();
268
- const { anchor, triggerContent, toCalendarView, isDisabled, name, className, attributes = [], triggerClassName, triggerAttributes = [], ariaLabel, ariaLabelledBy, panelClassName, panelAttributes = [], backdropClassName, backdropAttributes = [], } = viewInputs;
259
+ const { anchor, maybeSelectedDate, triggerContent, toCalendarView, isDisabled, name, className, attributes = [], triggerClassName, triggerAttributes = [], ariaLabel, ariaLabelledBy, panelClassName, panelAttributes = [], backdropClassName, backdropAttributes = [], } = viewInputs;
269
260
  const resolveTriggerLabel = () => {
270
261
  if (Predicate.isNotUndefined(ariaLabel)) {
271
262
  return [h.AriaLabel(ariaLabel)];
@@ -282,7 +273,7 @@ export const view = defineView((model, viewInputs) => {
282
273
  slotId: model.calendar.id,
283
274
  model: model.calendar,
284
275
  view: UiCalendar.view,
285
- viewInputs: { toView: toCalendarView },
276
+ viewInputs: { maybeSelectedDate, toView: toCalendarView },
286
277
  toParentMessage: message => GotCalendarMessage({ message }),
287
278
  });
288
279
  const popoverVNode = h.submodel({
@@ -301,7 +292,7 @@ export const view = defineView((model, viewInputs) => {
301
292
  ? [h.Class(triggerClassName)]
302
293
  : []),
303
294
  ...triggerAttributes,
304
- ], [triggerContent(model.maybeSelectedDate)]),
295
+ ], [triggerContent(maybeSelectedDate)]),
305
296
  ...(isVisible
306
297
  ? [
307
298
  h.div([
@@ -324,7 +315,7 @@ export const view = defineView((model, viewInputs) => {
324
315
  },
325
316
  toParentMessage: message => GotPopoverMessage({ message }),
326
317
  });
327
- const hiddenInputValue = Option.match(model.maybeSelectedDate, {
318
+ const hiddenInputValue = Option.match(maybeSelectedDate, {
328
319
  onNone: () => '',
329
320
  onSome: encodeIsoDate,
330
321
  });
@@ -1,3 +1,3 @@
1
- export { init, update, view, triggerId, open, close, selectDate, clear, reflectSelectedDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
1
+ export { init, update, view, triggerId, open, close, selectDate, clear, focusDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, ClearedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
2
2
  export type { InitConfig, ViewInputs } from './index.js';
3
3
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/datePicker/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,SAAS,EACT,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
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/datePicker/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,UAAU,EACV,KAAK,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,KAAK,EACL,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,EACN,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAEnB,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { init, update, view, triggerId, open, close, selectDate, clear, reflectSelectedDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
1
+ export { init, update, view, triggerId, open, close, selectDate, clear, focusDate, reflectMinDate, reflectMaxDate, reflectDisabledDates, reflectDisabledDaysOfWeek, Model, Message, OutMessage, GotCalendarMessage, GotPopoverMessage, RequestedSelectDate, SelectedDate, ClearedDate, Cleared, Opened, Closed, ChangedViewMonth, } from './index.js';
@@ -1,128 +1,64 @@
1
- import { Effect, Option, Schema as S } from 'effect';
2
- import * as Command from 'foldkit/command';
3
- import { type ChildAttribute, type Html } from 'foldkit/html';
4
- import { type Reflect } from 'foldkit/submodel';
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("foldkit/schema").CallableTaggedStruct<"Toggled", {}>;
13
- /** Sent to explicitly close the disclosure, regardless of its current state. */
14
- export declare const Closed: import("foldkit/schema").CallableTaggedStruct<"Closed", {}>;
15
- /** Sent when the focus-button command completes after closing. */
16
- export declare const CompletedFocusButton: import("foldkit/schema").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("foldkit/schema").CallableTaggedStruct<"ToggledOpenState", {
29
- isOpen: S.Boolean;
30
- }>;
31
- export declare const OutMessage: S.Union<readonly [import("foldkit/schema").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;
1
+ import { type Attribute, type Html } from 'foldkit/html';
43
2
  /** Returns the bare DOM id of the disclosure toggle button, derived from the
44
3
  * disclosure's base id. Use this to associate an external label with the
45
4
  * button via a native `<label for={Disclosure.buttonId(id)}>` or an
46
5
  * `aria-labelledby` reference. */
47
6
  export declare const buttonId: (id: string) => string;
48
- /** Moves focus to the disclosure's toggle button. */
49
- export declare const FocusButton: Command.CommandDefinitionWithArgs<"FocusButton", {
50
- id: S.String;
51
- }, Effect.Effect<{
52
- readonly _tag: "CompletedFocusButton";
53
- }, never, never>>;
54
- type UpdateReturn = readonly [
55
- Model,
56
- ReadonlyArray<Command.Command<Message>>,
57
- Option.Option<OutMessage>
58
- ];
59
- /** Processes a disclosure message and returns the next model, commands, and optional OutMessage. */
60
- export declare const update: (model: Model, message: Message) => UpdateReturn;
61
- /** Programmatically toggles the disclosure, updating the model and returning
62
- * focus commands plus a `ToggledOpenState` OutMessage. */
63
- export declare const toggle: (model: Model) => UpdateReturn;
64
- /** Programmatically closes the disclosure, updating the model and returning
65
- * focus commands plus a `ToggledOpenState` OutMessage when it was open. */
66
- export declare const close: (model: Model) => UpdateReturn;
67
- /** Reflects an externally-sourced open state onto the model without
68
- * emitting an OutMessage or running the focus command. Use this to mirror
69
- * external truth (restored storage, a deep link) onto the disclosure.
70
- * Contrast with `toggle`/`close`, which represent user or programmatic
71
- * *choices* and emit `ToggledOpenState`. Returns the model directly
72
- * because it produces no commands and no OutMessage. */
73
- export declare const reflectOpenState: Reflect<Model, boolean>;
74
- /** Attribute groups the disclosure component provides to the consumer's
75
- * `toView` callback. The consumer composes the button + panel layout
76
- * themselves using these bundles. */
77
- export type DisclosureAttributes = Readonly<{
78
- button: ReadonlyArray<ChildAttribute>;
79
- panel: ReadonlyArray<ChildAttribute>;
7
+ /** Attribute groups the disclosure provides to the consumer's `toView`
8
+ * callback. The consumer composes the button + panel layout themselves using
9
+ * these bundles. The `button` bundle carries the click and Enter/Space
10
+ * handlers that dispatch the configured `onToggle` Message. */
11
+ export type DisclosureAttributes<Message> = Readonly<{
12
+ button: ReadonlyArray<Attribute<Message>>;
13
+ panel: ReadonlyArray<Attribute<Message>>;
80
14
  /** Wraps panel content in a CSS-grid container that smoothly animates
81
- * height (`grid-template-rows: 0fr → 1fr` with `overflow: hidden`) as
82
- * the disclosure opens and closes. Unlike the bare conditional render,
83
- * the panel stays mounted while collapsed, so the transition has
84
- * something to animate from and to. Spread the `panel` bundle onto the
85
- * element you pass in, and render it unconditionally rather than gating
86
- * on `isOpen`. The collapsed content is marked `aria-hidden`. Mirrors the
87
- * `Ui.Animation` `animateSize` flag. */
15
+ * height (`grid-template-rows: 0fr → 1fr` with `overflow: hidden`) as the
16
+ * disclosure opens and closes. The panel stays mounted while collapsed, so
17
+ * the transition has something to animate from and to. Spread the `panel`
18
+ * bundle onto the element you pass in, and render it unconditionally rather
19
+ * than gating on `isOpen`. The collapsed content is marked `aria-hidden`. */
88
20
  animatePanel: (content: Html) => Html;
89
21
  }>;
90
- /** Per-render view inputs passed to `view` via `h.submodel`'s `viewInputs` field.
22
+ /** Per-render view configuration for the stateless controlled {@link view}.
23
+ * Generic over `Message` (the message `onToggle` dispatches).
91
24
  *
92
- * - `toView`: receives the disclosure's `button` and `panel` attribute
93
- * bundles and returns the composed layout. The consumer reads
94
- * `isOpen` from their parent model when they need to render
95
- * conditionally on it.
96
- * - `isDisabled`: when true, the button is not clickable, gets
97
- * `aria-disabled` and a `data-disabled` attribute. */
98
- export type ViewInputs = Readonly<{
99
- toView: (attributes: DisclosureAttributes) => Html;
25
+ * - `isOpen`: the current open state, read straight from the parent Model.
26
+ * `aria-expanded`, the `data-open` marker, and `animatePanel` derive from
27
+ * it.
28
+ * - `onToggle`: dispatched with the new open state when the user clicks the
29
+ * button or presses Enter/Space. Handle it in the parent's `update` by
30
+ * storing the value.
31
+ * - `toView`: receives the {@link DisclosureAttributes} and lays out the
32
+ * disclosure. */
33
+ export type ViewConfig<Message> = Readonly<{
34
+ id: string;
35
+ isOpen: boolean;
36
+ onToggle: (isOpen: boolean) => Message;
37
+ toView: (attributes: DisclosureAttributes<Message>) => Html;
100
38
  isDisabled?: boolean;
101
39
  ariaLabel?: string;
102
40
  ariaLabelledBy?: string;
103
41
  }>;
104
- /** Renders a headless disclosure component with accessible ARIA
105
- * attributes and keyboard support. The consumer composes the layout
106
- * through the `toView` slot, spreading the published `button` and
107
- * `panel` attribute bundles onto their own elements.
42
+ /** Renders a headless disclosure as a stateless controlled component. The
43
+ * parent owns the open state (`isOpen`) and receives the new state via
44
+ * `onToggle` when the user toggles it. The consumer composes the layout
45
+ * through `toView`, spreading the `button` and `panel` bundles onto their own
46
+ * elements.
108
47
  *
109
- * Designed to be embedded via `h.submodel`. The consumer reacts to
110
- * toggle events by pattern-matching the `ToggledOpenState` OutMessage
111
- * from the third element of `update`'s return tuple. */
112
- export declare const view: import("foldkit/submodel").View<S.Struct.ReadonlySide<{
113
- readonly id: S.String;
114
- readonly isOpen: S.Boolean;
115
- }, "Type">, S.Struct.ReadonlySide<{
116
- readonly _tag: S.tag<"CompletedFocusButton">;
117
- }, "Type"> | S.Struct.ReadonlySide<{
118
- readonly _tag: S.tag<"Closed">;
119
- }, "Type"> | S.Struct.ReadonlySide<{
120
- readonly _tag: S.tag<"Toggled">;
121
- }, "Type">, Readonly<{
122
- toView: (attributes: DisclosureAttributes) => Html;
123
- isDisabled?: boolean;
124
- ariaLabel?: string;
125
- ariaLabelledBy?: string;
126
- }>>;
127
- export {};
48
+ * ```ts
49
+ * // In view:
50
+ * Disclosure.view<Message>({
51
+ * id: 'details',
52
+ * isOpen: model.isDetailsOpen,
53
+ * onToggle: isOpen => ToggledDetails({ isOpen }),
54
+ * toView: ({ button, panel, animatePanel }) => ...,
55
+ * })
56
+ *
57
+ * // In update:
58
+ * ToggledDetails: ({ isOpen }) => [
59
+ * evo(model, { isDetailsOpen: () => isOpen }),
60
+ * [],
61
+ * ],
62
+ * ``` */
63
+ export declare const view: <Message>(config: ViewConfig<Message>) => Html;
128
64
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/disclosure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAGN,MAAM,EAEN,MAAM,IAAI,CAAC,EACZ,MAAM,QAAQ,CAAA;AACf,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAGV,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAM3D,kGAAkG;AAClG,eAAO,MAAM,KAAK;;;EAGhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,iFAAiF;AACjF,eAAO,MAAM,OAAO,8DAAe,CAAA;AACnC,gFAAgF;AAChF,eAAO,MAAM,MAAM,6DAAc,CAAA;AACjC,kEAAkE;AAClE,eAAO,MAAM,oBAAoB,2EAA4B,CAAA;AAE7D,kEAAkE;AAClE,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,KAAK,CAC3B;IAAC,OAAO,OAAO;IAAE,OAAO,MAAM;IAAE,OAAO,oBAAoB;CAAC,CACV,CAAA;AAEpD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AACzC,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AACvC,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAA;AAIzC,4RAA4R;AAC5R,eAAO,MAAM,gBAAgB;;EAA+C,CAAA;AAE5E,eAAO,MAAM,UAAU;;IAA8B,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CA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