@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.
- package/README.md +2 -2
- package/dist/calendar/index.d.ts +17 -23
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +16 -25
- package/dist/calendar/public.d.ts +1 -1
- package/dist/calendar/public.d.ts.map +1 -1
- package/dist/calendar/public.js +1 -1
- package/dist/checkbox/index.d.ts +47 -104
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +48 -87
- package/dist/checkbox/public.d.ts +2 -2
- package/dist/checkbox/public.d.ts.map +1 -1
- package/dist/checkbox/public.js +1 -1
- package/dist/combobox/multi.d.ts +19 -30
- package/dist/combobox/multi.d.ts.map +1 -1
- package/dist/combobox/multi.js +32 -53
- package/dist/combobox/public.d.ts +2 -2
- package/dist/combobox/public.d.ts.map +1 -1
- package/dist/combobox/public.js +1 -1
- package/dist/combobox/shared.d.ts +59 -35
- package/dist/combobox/shared.d.ts.map +1 -1
- package/dist/combobox/shared.js +58 -45
- package/dist/combobox/single.d.ts +36 -48
- package/dist/combobox/single.d.ts.map +1 -1
- package/dist/combobox/single.js +49 -76
- package/dist/datePicker/index.d.ts +33 -41
- package/dist/datePicker/index.d.ts.map +1 -1
- package/dist/datePicker/index.js +31 -40
- package/dist/datePicker/public.d.ts +1 -1
- package/dist/datePicker/public.d.ts.map +1 -1
- package/dist/datePicker/public.js +1 -1
- package/dist/dialog/index.d.ts +17 -1
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +12 -5
- package/dist/disclosure/index.d.ts +49 -113
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +35 -92
- package/dist/disclosure/public.d.ts +2 -2
- package/dist/disclosure/public.d.ts.map +1 -1
- package/dist/disclosure/public.js +1 -1
- package/dist/listbox/multi.d.ts +7 -21
- package/dist/listbox/multi.d.ts.map +1 -1
- package/dist/listbox/multi.js +12 -36
- package/dist/listbox/public.d.ts +1 -1
- package/dist/listbox/public.d.ts.map +1 -1
- package/dist/listbox/shared.d.ts +28 -20
- package/dist/listbox/shared.d.ts.map +1 -1
- package/dist/listbox/shared.js +6 -7
- package/dist/listbox/single.d.ts +17 -27
- package/dist/listbox/single.d.ts.map +1 -1
- package/dist/listbox/single.js +18 -30
- package/dist/radioGroup/index.d.ts +57 -142
- package/dist/radioGroup/index.d.ts.map +1 -1
- package/dist/radioGroup/index.js +44 -119
- package/dist/radioGroup/public.d.ts +2 -2
- package/dist/radioGroup/public.d.ts.map +1 -1
- package/dist/radioGroup/public.js +1 -1
- package/dist/slider/index.d.ts +51 -27
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +66 -66
- package/dist/slider/public.d.ts +1 -1
- package/dist/slider/public.d.ts.map +1 -1
- package/dist/slider/public.js +1 -1
- package/dist/switch/index.d.ts +45 -92
- package/dist/switch/index.d.ts.map +1 -1
- package/dist/switch/index.js +36 -81
- package/dist/switch/public.d.ts +2 -2
- package/dist/switch/public.d.ts.map +1 -1
- package/dist/switch/public.js +1 -1
- package/dist/tabs/index.d.ts +33 -33
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +36 -49
- package/dist/toast/index.d.ts +1 -0
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +1 -0
- package/dist/toast/public.d.ts +2 -0
- package/dist/toast/public.d.ts.map +1 -1
- package/dist/toast/public.js +1 -0
- package/dist/toast/test.d.ts +41 -0
- package/dist/toast/test.d.ts.map +1 -0
- package/dist/toast/test.js +36 -0
- 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.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
148
|
-
* committed date and
|
|
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
|
-
|
|
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
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
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
|
-
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
|
|
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,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,IAAI,EAAQ,MAAM,cAAc,CAAA;AAGnE,OAAO,EAAE,KAAK,OAAO,EAAc,MAAM,kBAAkB,CAAA;AAE3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAMlD
|
|
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,OAAO,KAAK,OAAO,MAAM,iBA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|
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.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
61
|
-
* committed date and
|
|
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
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
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.
|
|
78
|
-
|
|
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
|
-
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
|
|
216
|
-
|
|
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(
|
|
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(
|
|
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,
|
|
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,
|
|
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,
|
|
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';
|
package/dist/dialog/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,qEAA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,CAAC,cAAc,CAAC,CAAA;IACrC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACvC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IACpC,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,YAAY,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC3C,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1C,SAAS,EAAE,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"}
|
package/dist/dialog/index.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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
|
});
|