@foldkit/ui 0.126.0 → 0.128.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 (82) 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/dialog/index.d.ts +17 -1
  33. package/dist/dialog/index.d.ts.map +1 -1
  34. package/dist/dialog/index.js +12 -5
  35. package/dist/disclosure/index.d.ts +49 -113
  36. package/dist/disclosure/index.d.ts.map +1 -1
  37. package/dist/disclosure/index.js +35 -92
  38. package/dist/disclosure/public.d.ts +2 -2
  39. package/dist/disclosure/public.d.ts.map +1 -1
  40. package/dist/disclosure/public.js +1 -1
  41. package/dist/listbox/multi.d.ts +7 -21
  42. package/dist/listbox/multi.d.ts.map +1 -1
  43. package/dist/listbox/multi.js +12 -36
  44. package/dist/listbox/public.d.ts +1 -1
  45. package/dist/listbox/public.d.ts.map +1 -1
  46. package/dist/listbox/shared.d.ts +28 -20
  47. package/dist/listbox/shared.d.ts.map +1 -1
  48. package/dist/listbox/shared.js +6 -7
  49. package/dist/listbox/single.d.ts +17 -27
  50. package/dist/listbox/single.d.ts.map +1 -1
  51. package/dist/listbox/single.js +18 -30
  52. package/dist/radioGroup/index.d.ts +57 -142
  53. package/dist/radioGroup/index.d.ts.map +1 -1
  54. package/dist/radioGroup/index.js +44 -119
  55. package/dist/radioGroup/public.d.ts +2 -2
  56. package/dist/radioGroup/public.d.ts.map +1 -1
  57. package/dist/radioGroup/public.js +1 -1
  58. package/dist/slider/index.d.ts +51 -27
  59. package/dist/slider/index.d.ts.map +1 -1
  60. package/dist/slider/index.js +66 -66
  61. package/dist/slider/public.d.ts +1 -1
  62. package/dist/slider/public.d.ts.map +1 -1
  63. package/dist/slider/public.js +1 -1
  64. package/dist/switch/index.d.ts +45 -92
  65. package/dist/switch/index.d.ts.map +1 -1
  66. package/dist/switch/index.js +36 -81
  67. package/dist/switch/public.d.ts +2 -2
  68. package/dist/switch/public.d.ts.map +1 -1
  69. package/dist/switch/public.js +1 -1
  70. package/dist/tabs/index.d.ts +33 -33
  71. package/dist/tabs/index.d.ts.map +1 -1
  72. package/dist/tabs/index.js +36 -49
  73. package/dist/toast/index.d.ts +1 -0
  74. package/dist/toast/index.d.ts.map +1 -1
  75. package/dist/toast/index.js +1 -0
  76. package/dist/toast/public.d.ts +2 -0
  77. package/dist/toast/public.d.ts.map +1 -1
  78. package/dist/toast/public.js +1 -0
  79. package/dist/toast/test.d.ts +41 -0
  80. package/dist/toast/test.d.ts.map +1 -0
  81. package/dist/toast/test.js +36 -0
  82. package/package.json +2 -2
@@ -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,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ACL,aAAa,CAAC,cAAc,CAAC;GAyHnD,CAAA"}
@@ -9,12 +9,13 @@ import * as UiCalendar from '../calendar/index.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';
@@ -80,10 +80,21 @@ export type InitConfig = Readonly<{
80
80
  id: string;
81
81
  isOpen?: boolean;
82
82
  isAnimated?: boolean;
83
+ /** CSS selector for the element that receives focus when the dialog opens.
84
+ * A selector-based override of the `initialFocus` RenderInfo marker, for the
85
+ * cases a spread-on marker cannot express: an element whose id you do not
86
+ * own, or a descendant selector. Takes precedence over `initialFocus`. With
87
+ * neither set, focus falls to the first focusable element. */
83
88
  focusSelector?: string;
84
89
  }>;
85
90
  /** Creates an initial dialog model from a config. Defaults to closed and non-animated. */
86
91
  export declare const init: (config: InitConfig) => Model;
92
+ /** Data attribute the dialog places on the `initialFocus` RenderInfo group and
93
+ * focuses on open. */
94
+ export declare const initialFocusMarkerAttribute = "foldkit-dialog-initial-focus";
95
+ /** Selector for {@link initialFocusMarkerAttribute}, focused against the open
96
+ * dialog when no `focusSelector` is configured. */
97
+ export declare const initialFocusMarkerSelector = "[data-foldkit-dialog-initial-focus]";
87
98
  type UpdateReturn = readonly [
88
99
  Model,
89
100
  ReadonlyArray<Command.Command<Message>>,
@@ -96,7 +107,7 @@ type UpdateReturn = readonly [
96
107
  * component supplies its own backdrop. */
97
108
  export declare const ShowDialog: Command.CommandDefinitionWithArgs<"ShowDialog", {
98
109
  id: S.String;
99
- maybeFocusSelector: S.Option<S.String>;
110
+ focusSelector: S.String;
100
111
  }, Effect.Effect<{
101
112
  readonly _tag: "CompletedShowDialog";
102
113
  }, never, never>>;
@@ -162,6 +173,10 @@ export declare const descriptionId: (model: Model) => string;
162
173
  * - `description`: attributes for the description element. Carries the
163
174
  * framework-managed id the dialog's `aria-describedby` points at. Spread
164
175
  * onto your description element (`h.p([...description], [...])`).
176
+ * - `initialFocus`: attributes for the element that should receive focus when
177
+ * the dialog opens. Spread onto that element (`h.input([...initialFocus])`).
178
+ * A configured `focusSelector` (see `init`) takes precedence, and focus
179
+ * falls back to the default when no element carries the group.
165
180
  * - `closeButton`: attributes for an in-panel close control such as a Cancel
166
181
  * or dismiss button. Carries the `OnClick` handler that closes the
167
182
  * dialog (suppressed while a leave animation is in progress). Spread
@@ -175,6 +190,7 @@ export type RenderInfo = Readonly<{
175
190
  panel: ReadonlyArray<ChildAttribute>;
176
191
  title: ReadonlyArray<ChildAttribute>;
177
192
  description: ReadonlyArray<ChildAttribute>;
193
+ initialFocus: ReadonlyArray<ChildAttribute>;
178
194
  closeButton: ReadonlyArray<ChildAttribute>;
179
195
  isVisible: boolean;
180
196
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAE1C,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EAGV,MAAM,cAAc,CAAA;AAwBrB,6IAA6I;AAC7I,eAAO,MAAM,KAAK;;;;;;;;;;EAMhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAA;AAIrC,yEAAyE;AACzE,eAAO,MAAM,aAAa,oEAAqB,CAAA;AAC/C,uFAAuF;AACvF,eAAO,MAAM,cAAc,qEAAsB,CAAA;AACjD,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,0EAA2B,CAAA;AAC3D,oDAAoD;AACpD,eAAO,MAAM,oBAAoB,2EAA4B,CAAA;AAC7D;;;;;4DAK4D;AAC5D,eAAO,MAAM,SAAS,gEAAiB,CAAA;AACvC,gEAAgE;AAChE,eAAO,MAAM,+BAA+B,sFAE3C,CAAA;AACD,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB;;EAE9B,CAAA;AAEF,8DAA8D;AAC9D,eAAO,MAAM,OAAO,EAAE,CAAC,C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OAAO,CAAA;CACnB,CAAC,CAAA;AAEF,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA;CACrC,CAAC,CAAA;AAEF;;;2EAG2E;AAC3E,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;YAPP,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI;GA8FrC,CAAA"}
@@ -78,16 +78,19 @@ export const init = (config) => ({
78
78
  });
79
79
  // UPDATE
80
80
  const dialogSelector = (id) => idSelector(id);
81
+ /** Data attribute the dialog places on the `initialFocus` RenderInfo group and
82
+ * focuses on open. */
83
+ export const initialFocusMarkerAttribute = 'foldkit-dialog-initial-focus';
84
+ /** Selector for {@link initialFocusMarkerAttribute}, focused against the open
85
+ * dialog when no `focusSelector` is configured. */
86
+ export const initialFocusMarkerSelector = `[data-${initialFocusMarkerAttribute}]`;
81
87
  const withUpdateReturn = M.withReturnType();
82
88
  /** Locks page scroll and opens the native dialog element through
83
89
  * `Dom.showDialog`, which calls `show()` (not native `showModal()`) so other
84
90
  * high-z-index overlays stay interactive. It layers the dialog with a high
85
91
  * z-index, traps focus, and dispatches a `cancel` event on Esc. The Dialog
86
92
  * component supplies its own backdrop. */
87
- export const ShowDialog = Command.define('ShowDialog', { id: S.String, maybeFocusSelector: S.Option(S.String) }, CompletedShowDialog)(({ id, maybeFocusSelector }) => Dom.lockScroll.pipe(Effect.andThen(() => Dom.showDialog(dialogSelector(id), Option.match(maybeFocusSelector, {
88
- onNone: () => undefined,
89
- onSome: focusSelector => ({ focusSelector }),
90
- }))), Effect.ignore, Effect.as(CompletedShowDialog())));
93
+ export const ShowDialog = Command.define('ShowDialog', { id: S.String, focusSelector: S.String }, CompletedShowDialog)(({ id, focusSelector }) => Dom.lockScroll.pipe(Effect.andThen(() => Dom.showDialog(dialogSelector(id), { focusSelector })), Effect.ignore, Effect.as(CompletedShowDialog())));
91
94
  /** Calls `close()` on the native dialog element and unlocks page scroll. */
92
95
  export const CloseDialog = Command.define('CloseDialog', { id: S.String }, CompletedCloseDialog)(({ id }) => Dom.closeDialog(dialogSelector(id)).pipe(Effect.andThen(() => Dom.unlockScroll), Effect.ignore, Effect.as(CompletedCloseDialog())));
93
96
  /** Releases the framework hygiene the dialog holds while open (scroll lock,
@@ -120,7 +123,7 @@ export const update = (model, message) => M.value(message).pipe(withUpdateReturn
120
123
  const wasClosed = !model.isOpen;
121
124
  const maybeShow = Option.liftPredicate(ShowDialog({
122
125
  id: model.id,
123
- maybeFocusSelector: model.maybeFocusSelector,
126
+ focusSelector: Option.getOrElse(model.maybeFocusSelector, () => initialFocusMarkerSelector),
124
127
  }), () => wasClosed);
125
128
  const maybeOutMessage = wasClosed
126
129
  ? Option.some(Opened())
@@ -259,6 +262,9 @@ export const view = defineView((model, viewInputs) => {
259
262
  const panelAttributes = [h.Id(`${id}-panel`), ...animationAttributes];
260
263
  const titleAttributes = [h.Id(titleId(model))];
261
264
  const descriptionAttributes = [h.Id(descriptionId(model))];
265
+ const initialFocusAttributes = [
266
+ h.DataAttribute(initialFocusMarkerAttribute, ''),
267
+ ];
262
268
  const closeButtonAttributes = isLeaving ? [] : [h.OnClick(RequestedClose())];
263
269
  return toView({
264
270
  dialog: childAttributes(dialogAttributes),
@@ -266,6 +272,7 @@ export const view = defineView((model, viewInputs) => {
266
272
  panel: childAttributes(panelAttributes),
267
273
  title: childAttributes(titleAttributes),
268
274
  description: childAttributes(descriptionAttributes),
275
+ initialFocus: childAttributes(initialFocusAttributes),
269
276
  closeButton: childAttributes(closeButtonAttributes),
270
277
  isVisible,
271
278
  });