@foldkit/ui 0.129.0 → 0.131.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/dist/anchor.js +12 -11
- package/dist/animation/index.js +11 -10
- package/dist/animation/schema.js +3 -2
- package/dist/animation/update.js +26 -25
- package/dist/button/index.js +3 -2
- package/dist/calendar/index.js +159 -158
- package/dist/checkbox/index.js +9 -8
- package/dist/combobox/multi.js +20 -19
- package/dist/combobox/shared.js +169 -168
- package/dist/combobox/single.js +23 -22
- package/dist/datePicker/index.js +69 -68
- package/dist/dialog/index.js +52 -51
- package/dist/disclosure/index.js +11 -10
- package/dist/dragAndDrop/index.js +122 -121
- package/dist/fieldset/index.js +5 -4
- package/dist/fileDrop/index.js +23 -22
- package/dist/group.js +7 -6
- package/dist/input/index.js +4 -3
- package/dist/internal/optionExtensions.js +2 -1
- package/dist/internal/selectors.js +2 -1
- package/dist/keyboard.js +5 -4
- package/dist/listbox/multi.js +12 -11
- package/dist/listbox/shared.js +171 -170
- package/dist/listbox/single.js +13 -12
- package/dist/menu/index.js +167 -166
- package/dist/nav/index.js +7 -6
- package/dist/popover/index.js +87 -86
- package/dist/radioGroup/index.js +23 -22
- package/dist/select/index.js +4 -3
- package/dist/slider/index.js +72 -71
- package/dist/switch/index.js +6 -5
- package/dist/tabs/index.js +34 -33
- package/dist/test/apps/disabledButton.js +17 -16
- package/dist/textarea/index.js +4 -3
- package/dist/toast/index.js +19 -18
- package/dist/toast/schema.js +10 -9
- package/dist/toast/test.js +2 -1
- package/dist/toast/update.js +79 -78
- package/dist/tooltip/index.js +59 -58
- package/dist/typeahead.js +6 -5
- package/dist/virtualList/index.js +66 -65
- package/package.json +4 -3
package/dist/calendar/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
|
|
1
2
|
import { Array, Effect, Function, Match as M, Number, Option, Schema as S, pipe, } from 'effect';
|
|
2
3
|
import * as Calendar from 'foldkit/calendar';
|
|
3
4
|
import * as Command from 'foldkit/command';
|
|
@@ -109,7 +110,7 @@ export const OutMessage = S.Union([ChangedViewMonth, SelectedDate]);
|
|
|
109
110
|
* it), or today when omitted. */
|
|
110
111
|
export const init = (config) => {
|
|
111
112
|
const initialFocus = config.initialViewDate ?? config.today;
|
|
112
|
-
return {
|
|
113
|
+
return __foldkitBrandViewResult(({
|
|
113
114
|
id: config.id,
|
|
114
115
|
today: config.today,
|
|
115
116
|
viewYear: initialFocus.year,
|
|
@@ -122,31 +123,31 @@ export const init = (config) => {
|
|
|
122
123
|
maybeMaxDate: Option.fromNullishOr(config.maxDate),
|
|
123
124
|
disabledDaysOfWeek: config.disabledDaysOfWeek ?? [],
|
|
124
125
|
disabledDates: config.disabledDates ?? [],
|
|
125
|
-
};
|
|
126
|
+
}), "@foldkit/ui/calendar/index.js#init");
|
|
126
127
|
};
|
|
127
128
|
const withUpdateReturn = M.withReturnType();
|
|
128
|
-
const gridId = (modelId) => `${modelId}-grid
|
|
129
|
-
const gridSelector = (modelId) => idSelector(gridId(modelId));
|
|
129
|
+
const gridId = (modelId) => __foldkitBrandViewResult((`${modelId}-grid`), "@foldkit/ui/calendar/index.js#gridId");
|
|
130
|
+
const gridSelector = (modelId) => __foldkitBrandViewResult((idSelector(gridId(modelId))), "@foldkit/ui/calendar/index.js#gridSelector");
|
|
130
131
|
/** Focuses the calendar grid container. Parent components like DatePicker
|
|
131
132
|
* dispatch this after opening to hand focus to the grid's keyboard layer. */
|
|
132
|
-
export const FocusGrid = Command.define('FocusGrid', { id: S.String }, CompletedFocusGrid)(({ id }) => Dom.focus(gridSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusGrid())));
|
|
133
|
+
export const FocusGrid = Command.define('FocusGrid', { id: S.String }, CompletedFocusGrid)(({ id }) => __foldkitBrandViewResult((Dom.focus(gridSelector(id)).pipe(Effect.ignore, Effect.as(CompletedFocusGrid()))), "@foldkit/ui/calendar/index.js#anonymous"));
|
|
133
134
|
/** Programmatically selects a date on the calendar, committing it as the
|
|
134
135
|
* chosen value and moving the cursor onto it. Use this in controlled-mode
|
|
135
136
|
* handlers (when the view's `onSelectedDate` callback is provided) to write
|
|
136
137
|
* the selection back to the calendar's internal state.
|
|
137
138
|
*
|
|
138
139
|
* Equivalent to dispatching `ClickedDay({ date })` through `update`. */
|
|
139
|
-
export const selectDate = (model, date) => update(model, ClickedDay({ date }));
|
|
140
|
+
export const selectDate = (model, date) => __foldkitBrandViewResult((update(model, ClickedDay({ date }))), "@foldkit/ui/calendar/index.js#selectDate");
|
|
140
141
|
/** Moves the calendar's view and cursor to a date without changing the
|
|
141
142
|
* selection (which the parent owns). Use it to navigate to a known date, for
|
|
142
143
|
* example when opening a date picker onto its current value so the selected
|
|
143
144
|
* month is visible. Returns the model directly because it produces no
|
|
144
145
|
* commands and no OutMessage. */
|
|
145
|
-
export const focusDate = Function.dual(2, (model, date) => evo(model, {
|
|
146
|
-
maybeFocusedDate: () => Option.some(date),
|
|
147
|
-
viewYear: () => date.year,
|
|
148
|
-
viewMonth: () => date.month,
|
|
149
|
-
}));
|
|
146
|
+
export const focusDate = Function.dual(2, (model, date) => __foldkitBrandViewResult((evo(model, {
|
|
147
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(date)), "@foldkit/ui/calendar/index.js#maybeFocusedDate"),
|
|
148
|
+
viewYear: () => __foldkitBrandViewResult((date.year), "@foldkit/ui/calendar/index.js#viewYear"),
|
|
149
|
+
viewMonth: () => __foldkitBrandViewResult((date.month), "@foldkit/ui/calendar/index.js#viewMonth"),
|
|
150
|
+
})), "@foldkit/ui/calendar/index.js#anonymous~2"));
|
|
150
151
|
/** Reflects the minimum selectable date onto the model. Pass `Option.none()`
|
|
151
152
|
* to remove the minimum. Use this when the minimum derives from other Model
|
|
152
153
|
* state (e.g. a start date field whose current selection constrains an end
|
|
@@ -155,17 +156,17 @@ export const focusDate = Function.dual(2, (model, date) => evo(model, {
|
|
|
155
156
|
* Does NOT reconcile the current selection. If a previously-selected date
|
|
156
157
|
* is now below the new minimum, it remains selected. Callers should clear or
|
|
157
158
|
* reassign the selection explicitly if their domain requires it. */
|
|
158
|
-
export const reflectMinDate = Function.dual(2, (model, maybeMinDate) => evo(model, { maybeMinDate: () => maybeMinDate }));
|
|
159
|
+
export const reflectMinDate = Function.dual(2, (model, maybeMinDate) => __foldkitBrandViewResult((evo(model, { maybeMinDate: () => __foldkitBrandViewResult((maybeMinDate), "@foldkit/ui/calendar/index.js#maybeMinDate") })), "@foldkit/ui/calendar/index.js#anonymous~3"));
|
|
159
160
|
/** Reflects the maximum selectable date onto the model. Pass `Option.none()`
|
|
160
161
|
* to remove the maximum. Does NOT reconcile the current selection. */
|
|
161
|
-
export const reflectMaxDate = Function.dual(2, (model, maybeMaxDate) => evo(model, { maybeMaxDate: () => maybeMaxDate }));
|
|
162
|
+
export const reflectMaxDate = Function.dual(2, (model, maybeMaxDate) => __foldkitBrandViewResult((evo(model, { maybeMaxDate: () => __foldkitBrandViewResult((maybeMaxDate), "@foldkit/ui/calendar/index.js#maybeMaxDate") })), "@foldkit/ui/calendar/index.js#anonymous~4"));
|
|
162
163
|
/** Reflects the list of individually-disabled dates onto the model. Pass an
|
|
163
164
|
* empty array to clear. Does NOT reconcile the current selection. */
|
|
164
|
-
export const reflectDisabledDates = Function.dual(2, (model, disabledDates) => evo(model, { disabledDates: () => disabledDates }));
|
|
165
|
+
export const reflectDisabledDates = Function.dual(2, (model, disabledDates) => __foldkitBrandViewResult((evo(model, { disabledDates: () => __foldkitBrandViewResult((disabledDates), "@foldkit/ui/calendar/index.js#disabledDates") })), "@foldkit/ui/calendar/index.js#anonymous~5"));
|
|
165
166
|
/** Reflects the days of the week that are disabled (e.g. weekends) onto the
|
|
166
167
|
* model. Pass an empty array to clear. Does NOT reconcile the current
|
|
167
168
|
* selection. */
|
|
168
|
-
export const reflectDisabledDaysOfWeek = Function.dual(2, (model, disabledDaysOfWeek) => evo(model, { disabledDaysOfWeek: () => disabledDaysOfWeek }));
|
|
169
|
+
export const reflectDisabledDaysOfWeek = Function.dual(2, (model, disabledDaysOfWeek) => __foldkitBrandViewResult((evo(model, { disabledDaysOfWeek: () => __foldkitBrandViewResult((disabledDaysOfWeek), "@foldkit/ui/calendar/index.js#disabledDaysOfWeek") })), "@foldkit/ui/calendar/index.js#anonymous~6"));
|
|
169
170
|
/** Returns the calendar to Days mode regardless of current depth. Useful for
|
|
170
171
|
* standalone (non-popovered) consumers that want to wire their own back-out
|
|
171
172
|
* gesture. Popovered consumers like `DatePicker` don't need this. Escape
|
|
@@ -178,62 +179,62 @@ export const reflectDisabledDaysOfWeek = Function.dual(2, (model, disabledDaysOf
|
|
|
178
179
|
* next ArrowLeft to jump to the cursor's stale year. */
|
|
179
180
|
export const dropToDays = (model) => {
|
|
180
181
|
const focusedDay = Option.match(model.maybeFocusedDate, {
|
|
181
|
-
onNone: () => 1,
|
|
182
|
-
onSome: date => Math.min(date.day, Calendar.daysInMonth(model.viewYear, model.viewMonth)),
|
|
183
|
-
});
|
|
184
|
-
return evo(model, {
|
|
185
|
-
viewMode: () => 'Days',
|
|
186
|
-
maybeFocusedDate: () => Option.some(Calendar.make(model.viewYear, model.viewMonth, focusedDay)),
|
|
182
|
+
onNone: () => __foldkitBrandViewResult((1), "@foldkit/ui/calendar/index.js#onNone"),
|
|
183
|
+
onSome: date => __foldkitBrandViewResult((Math.min(date.day, Calendar.daysInMonth(model.viewYear, model.viewMonth))), "@foldkit/ui/calendar/index.js#onSome"),
|
|
187
184
|
});
|
|
185
|
+
return __foldkitBrandViewResult((evo(model, {
|
|
186
|
+
viewMode: () => __foldkitBrandViewResult(('Days'), "@foldkit/ui/calendar/index.js#viewMode"),
|
|
187
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(Calendar.make(model.viewYear, model.viewMonth, focusedDay))), "@foldkit/ui/calendar/index.js#maybeFocusedDate~2"),
|
|
188
|
+
})), "@foldkit/ui/calendar/index.js#dropToDays");
|
|
188
189
|
};
|
|
189
190
|
const DAY_SKIP_CAP = 31;
|
|
190
191
|
const MONTH_SKIP_CAP = 12;
|
|
191
192
|
/** Number of years per Years-mode page. A 3×4 grid renders one window. */
|
|
192
193
|
const YEARS_PAGE_SIZE = 12;
|
|
193
|
-
const isDateDisabled = (model, date) => Option.exists(model.maybeMinDate, min => Calendar.isBefore(date, min)) ||
|
|
194
|
-
Option.exists(model.maybeMaxDate, max => Calendar.isAfter(date, max)) ||
|
|
194
|
+
const isDateDisabled = (model, date) => __foldkitBrandViewResult((Option.exists(model.maybeMinDate, min => __foldkitBrandViewResult((Calendar.isBefore(date, min)), "@foldkit/ui/calendar/index.js#anonymous~7")) ||
|
|
195
|
+
Option.exists(model.maybeMaxDate, max => __foldkitBrandViewResult((Calendar.isAfter(date, max)), "@foldkit/ui/calendar/index.js#anonymous~8")) ||
|
|
195
196
|
model.disabledDaysOfWeek.includes(Calendar.dayOfWeek(date)) ||
|
|
196
|
-
model.disabledDates.some(Calendar.isEqual(date));
|
|
197
|
+
model.disabledDates.some(Calendar.isEqual(date))), "@foldkit/ui/calendar/index.js#isDateDisabled");
|
|
197
198
|
/** Walks from `start` in `direction`, returning the first non-disabled date
|
|
198
199
|
* within `cap` steps. Falls back to `start` if every candidate is disabled. */
|
|
199
|
-
const skipDisabled = (model, start, direction, cap) => pipe(cap, Array.makeBy(step => Calendar.addDays(start, step * direction)), Array.findFirst(date => !isDateDisabled(model, date)), Option.getOrElse(() => start));
|
|
200
|
+
const skipDisabled = (model, start, direction, cap) => __foldkitBrandViewResult((pipe(cap, Array.makeBy(step => __foldkitBrandViewResult((Calendar.addDays(start, step * direction)), "@foldkit/ui/calendar/index.js#anonymous~9")), Array.findFirst(date => __foldkitBrandViewResult((!isDateDisabled(model, date)), "@foldkit/ui/calendar/index.js#anonymous~10")), Option.getOrElse(() => __foldkitBrandViewResult((start), "@foldkit/ui/calendar/index.js#anonymous~11")))), "@foldkit/ui/calendar/index.js#skipDisabled");
|
|
200
201
|
const clampToRange = (model, candidate) => {
|
|
201
202
|
const afterMin = Option.match(model.maybeMinDate, {
|
|
202
|
-
onNone: () => candidate,
|
|
203
|
-
onSome: min => Calendar.max(candidate, min),
|
|
204
|
-
});
|
|
205
|
-
return Option.match(model.maybeMaxDate, {
|
|
206
|
-
onNone: () => afterMin,
|
|
207
|
-
onSome: max => Calendar.min(afterMin, max),
|
|
203
|
+
onNone: () => __foldkitBrandViewResult((candidate), "@foldkit/ui/calendar/index.js#onNone~2"),
|
|
204
|
+
onSome: min => __foldkitBrandViewResult((Calendar.max(candidate, min)), "@foldkit/ui/calendar/index.js#onSome~2"),
|
|
208
205
|
});
|
|
206
|
+
return __foldkitBrandViewResult((Option.match(model.maybeMaxDate, {
|
|
207
|
+
onNone: () => __foldkitBrandViewResult((afterMin), "@foldkit/ui/calendar/index.js#onNone~3"),
|
|
208
|
+
onSome: max => __foldkitBrandViewResult((Calendar.min(afterMin, max)), "@foldkit/ui/calendar/index.js#onSome~3"),
|
|
209
|
+
})), "@foldkit/ui/calendar/index.js#clampToRange");
|
|
209
210
|
};
|
|
210
211
|
/** Resolves a navigation key press to the next focused date candidate,
|
|
211
212
|
* along with the direction and search cap for disabled-date skipping. */
|
|
212
|
-
const resolveNavigationKey = (key, isShift, focused, firstDayOfWeek) => M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => [
|
|
213
|
+
const resolveNavigationKey = (key, isShift, focused, firstDayOfWeek) => __foldkitBrandViewResult((M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => __foldkitBrandViewResult(([
|
|
213
214
|
Calendar.addDays(focused, -1),
|
|
214
215
|
-1,
|
|
215
216
|
DAY_SKIP_CAP,
|
|
216
|
-
]), M.when('ArrowRight', () => [Calendar.addDays(focused, 1), 1, DAY_SKIP_CAP]), M.when('ArrowUp', () => [Calendar.addDays(focused, -7), -1, DAY_SKIP_CAP]), M.when('ArrowDown', () => [Calendar.addDays(focused, 7), 1, DAY_SKIP_CAP]), M.when('Home', () => [
|
|
217
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~12")), M.when('ArrowRight', () => __foldkitBrandViewResult(([Calendar.addDays(focused, 1), 1, DAY_SKIP_CAP]), "@foldkit/ui/calendar/index.js#anonymous~13")), M.when('ArrowUp', () => __foldkitBrandViewResult(([Calendar.addDays(focused, -7), -1, DAY_SKIP_CAP]), "@foldkit/ui/calendar/index.js#anonymous~14")), M.when('ArrowDown', () => __foldkitBrandViewResult(([Calendar.addDays(focused, 7), 1, DAY_SKIP_CAP]), "@foldkit/ui/calendar/index.js#anonymous~15")), M.when('Home', () => __foldkitBrandViewResult(([
|
|
217
218
|
Calendar.startOfWeek(focused, firstDayOfWeek),
|
|
218
219
|
-1,
|
|
219
220
|
DAY_SKIP_CAP,
|
|
220
|
-
]), M.when('End', () => [
|
|
221
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~16")), M.when('End', () => __foldkitBrandViewResult(([
|
|
221
222
|
Calendar.endOfWeek(focused, firstDayOfWeek),
|
|
222
223
|
1,
|
|
223
224
|
DAY_SKIP_CAP,
|
|
224
|
-
]), M.when('PageUp', () => [
|
|
225
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~17")), M.when('PageUp', () => __foldkitBrandViewResult(([
|
|
225
226
|
isShift
|
|
226
227
|
? Calendar.addYears(focused, -1)
|
|
227
228
|
: Calendar.addMonths(focused, -1),
|
|
228
229
|
-1,
|
|
229
230
|
MONTH_SKIP_CAP,
|
|
230
|
-
]), M.when('PageDown', () => [
|
|
231
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~18")), M.when('PageDown', () => __foldkitBrandViewResult(([
|
|
231
232
|
isShift ? Calendar.addYears(focused, 1) : Calendar.addMonths(focused, 1),
|
|
232
233
|
1,
|
|
233
234
|
MONTH_SKIP_CAP,
|
|
234
|
-
]), M.option);
|
|
235
|
-
const isCommitKey = (key) => key === 'Enter' || key === ' ';
|
|
236
|
-
const currentOrFallbackFocus = (model) => Option.getOrElse(model.maybeFocusedDate, () => Calendar.make(model.viewYear, model.viewMonth, 1));
|
|
235
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~19")), M.option)), "@foldkit/ui/calendar/index.js#resolveNavigationKey");
|
|
236
|
+
const isCommitKey = (key) => __foldkitBrandViewResult((key === 'Enter' || key === ' '), "@foldkit/ui/calendar/index.js#isCommitKey");
|
|
237
|
+
const currentOrFallbackFocus = (model) => __foldkitBrandViewResult((Option.getOrElse(model.maybeFocusedDate, () => __foldkitBrandViewResult((Calendar.make(model.viewYear, model.viewMonth, 1)), "@foldkit/ui/calendar/index.js#anonymous~20"))), "@foldkit/ui/calendar/index.js#currentOrFallbackFocus");
|
|
237
238
|
/** Applies a date selection to the model: commits the selection, moves the
|
|
238
239
|
* cursor onto the date, and syncs the view month if the selection crosses a
|
|
239
240
|
* month boundary. Always emits `SelectedDate` carrying the committed date;
|
|
@@ -241,11 +242,11 @@ const currentOrFallbackFocus = (model) => Option.getOrElse(model.maybeFocusedDat
|
|
|
241
242
|
* a separate `ChangedViewMonth` signal that would race with the selection. */
|
|
242
243
|
const commitSelection = (model, date) => {
|
|
243
244
|
const nextModel = evo(model, {
|
|
244
|
-
maybeFocusedDate: () => Option.some(date),
|
|
245
|
-
viewYear: () => date.year,
|
|
246
|
-
viewMonth: () => date.month,
|
|
245
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(date)), "@foldkit/ui/calendar/index.js#maybeFocusedDate~3"),
|
|
246
|
+
viewYear: () => __foldkitBrandViewResult((date.year), "@foldkit/ui/calendar/index.js#viewYear~2"),
|
|
247
|
+
viewMonth: () => __foldkitBrandViewResult((date.month), "@foldkit/ui/calendar/index.js#viewMonth~2"),
|
|
247
248
|
});
|
|
248
|
-
return [nextModel, Option.some(SelectedDate({ date }))];
|
|
249
|
+
return __foldkitBrandViewResult(([nextModel, Option.some(SelectedDate({ date }))]), "@foldkit/ui/calendar/index.js#commitSelection");
|
|
249
250
|
};
|
|
250
251
|
/** Applies a focus move to the model, clamping to the allowed range and
|
|
251
252
|
* skipping disabled dates. Emits `ChangedViewMonth` if the move crossed a
|
|
@@ -255,12 +256,12 @@ const applyFocusMove = (model, candidate, direction, cap) => {
|
|
|
255
256
|
const nextFocus = skipDisabled(model, clamped, direction, cap);
|
|
256
257
|
const crossedMonth = nextFocus.year !== model.viewYear || nextFocus.month !== model.viewMonth;
|
|
257
258
|
const nextModel = evo(model, {
|
|
258
|
-
maybeFocusedDate: () => Option.some(nextFocus),
|
|
259
|
-
viewYear: () => nextFocus.year,
|
|
260
|
-
viewMonth: () => nextFocus.month,
|
|
259
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(nextFocus)), "@foldkit/ui/calendar/index.js#maybeFocusedDate~4"),
|
|
260
|
+
viewYear: () => __foldkitBrandViewResult((nextFocus.year), "@foldkit/ui/calendar/index.js#viewYear~3"),
|
|
261
|
+
viewMonth: () => __foldkitBrandViewResult((nextFocus.month), "@foldkit/ui/calendar/index.js#viewMonth~3"),
|
|
261
262
|
});
|
|
262
263
|
const maybeOutMessage = OptionExt.when(crossedMonth, ChangedViewMonth({ year: nextFocus.year, month: nextFocus.month }));
|
|
263
|
-
return [nextModel, maybeOutMessage];
|
|
264
|
+
return __foldkitBrandViewResult(([nextModel, maybeOutMessage]), "@foldkit/ui/calendar/index.js#applyFocusMove");
|
|
264
265
|
};
|
|
265
266
|
/** Computes the focused-date cursor for a view-month change. Preserves the
|
|
266
267
|
* current day-of-month (clamping to the new month's length when needed),
|
|
@@ -268,25 +269,25 @@ const applyFocusMove = (model, candidate, direction, cap) => {
|
|
|
268
269
|
* so the cursor always lands on a real, navigable cell. */
|
|
269
270
|
const moveFocusForViewChange = (model, year, month, direction) => {
|
|
270
271
|
const currentDay = Option.match(model.maybeFocusedDate, {
|
|
271
|
-
onNone: () => 1,
|
|
272
|
-
onSome: focused => focused.day,
|
|
272
|
+
onNone: () => __foldkitBrandViewResult((1), "@foldkit/ui/calendar/index.js#onNone~4"),
|
|
273
|
+
onSome: focused => __foldkitBrandViewResult((focused.day), "@foldkit/ui/calendar/index.js#onSome~4"),
|
|
273
274
|
});
|
|
274
275
|
const dayInNewMonth = Math.min(currentDay, Calendar.daysInMonth(year, month));
|
|
275
276
|
const candidate = Calendar.make(year, month, dayInNewMonth);
|
|
276
277
|
const clamped = clampToRange(model, candidate);
|
|
277
|
-
return skipDisabled(model, clamped, direction, DAY_SKIP_CAP);
|
|
278
|
+
return __foldkitBrandViewResult((skipDisabled(model, clamped, direction, DAY_SKIP_CAP)), "@foldkit/ui/calendar/index.js#moveFocusForViewChange");
|
|
278
279
|
};
|
|
279
280
|
const applyViewMonthChange = (model, year, month, direction) => {
|
|
280
281
|
if (year === model.viewYear && month === model.viewMonth) {
|
|
281
|
-
return [model, [], Option.none()];
|
|
282
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#applyViewMonthChange");
|
|
282
283
|
}
|
|
283
284
|
const nextFocus = moveFocusForViewChange(model, year, month, direction);
|
|
284
285
|
const nextModel = evo(model, {
|
|
285
|
-
viewYear: () => year,
|
|
286
|
-
viewMonth: () => month,
|
|
287
|
-
maybeFocusedDate: () => Option.some(nextFocus),
|
|
286
|
+
viewYear: () => __foldkitBrandViewResult((year), "@foldkit/ui/calendar/index.js#viewYear~4"),
|
|
287
|
+
viewMonth: () => __foldkitBrandViewResult((month), "@foldkit/ui/calendar/index.js#viewMonth~4"),
|
|
288
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(nextFocus)), "@foldkit/ui/calendar/index.js#maybeFocusedDate~5"),
|
|
288
289
|
});
|
|
289
|
-
return [nextModel, [], Option.some(ChangedViewMonth({ year, month }))];
|
|
290
|
+
return __foldkitBrandViewResult(([nextModel, [], Option.some(ChangedViewMonth({ year, month }))]), "@foldkit/ui/calendar/index.js#applyViewMonthChange");
|
|
290
291
|
};
|
|
291
292
|
/** Direction the user moved when jumping to a new view year/month via grid
|
|
292
293
|
* selection. Used by `skipDisabled` so a forward jump skips forward through
|
|
@@ -294,30 +295,30 @@ const applyViewMonthChange = (model, year, month, direction) => {
|
|
|
294
295
|
const jumpDirection = (model, year, month) => {
|
|
295
296
|
const next = Calendar.make(year, month, 1);
|
|
296
297
|
const current = Calendar.make(model.viewYear, model.viewMonth, 1);
|
|
297
|
-
return Calendar.isAfter(next, current) ? 1 : -1;
|
|
298
|
+
return __foldkitBrandViewResult((Calendar.isAfter(next, current) ? 1 : -1), "@foldkit/ui/calendar/index.js#jumpDirection");
|
|
298
299
|
};
|
|
299
300
|
/** Maps a keyboard key to a months-grid focus shift (in months). Months
|
|
300
301
|
* mode supports horizontal (±1), vertical (±row width), and PageUp/Down
|
|
301
302
|
* (±12) navigation. */
|
|
302
|
-
const resolveMonthsKey = (key) => M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => -1), M.when('ArrowRight', () => 1), M.when('ArrowUp', () => -MONTHS_GRID_COLUMNS), M.when('ArrowDown', () => MONTHS_GRID_COLUMNS), M.when('PageUp', () => -MONTHS_IN_YEAR), M.when('PageDown', () => MONTHS_IN_YEAR), M.option);
|
|
303
|
+
const resolveMonthsKey = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => __foldkitBrandViewResult((-1), "@foldkit/ui/calendar/index.js#anonymous~21")), M.when('ArrowRight', () => __foldkitBrandViewResult((1), "@foldkit/ui/calendar/index.js#anonymous~22")), M.when('ArrowUp', () => __foldkitBrandViewResult((-MONTHS_GRID_COLUMNS), "@foldkit/ui/calendar/index.js#anonymous~23")), M.when('ArrowDown', () => __foldkitBrandViewResult((MONTHS_GRID_COLUMNS), "@foldkit/ui/calendar/index.js#anonymous~24")), M.when('PageUp', () => __foldkitBrandViewResult((-MONTHS_IN_YEAR), "@foldkit/ui/calendar/index.js#anonymous~25")), M.when('PageDown', () => __foldkitBrandViewResult((MONTHS_IN_YEAR), "@foldkit/ui/calendar/index.js#anonymous~26")), M.option)), "@foldkit/ui/calendar/index.js#resolveMonthsKey");
|
|
303
304
|
/** Maps a keyboard key to a years-grid focus shift (in years). Years mode
|
|
304
305
|
* supports horizontal (±1), vertical (±row width), and PageUp/Down (±12 =
|
|
305
306
|
* one window) navigation. */
|
|
306
|
-
const resolveYearsKey = (key) => M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => -1), M.when('ArrowRight', () => 1), M.when('ArrowUp', () => -YEARS_GRID_COLUMNS), M.when('ArrowDown', () => YEARS_GRID_COLUMNS), M.when('PageUp', () => -YEARS_PAGE_SIZE), M.when('PageDown', () => YEARS_PAGE_SIZE), M.option);
|
|
307
|
+
const resolveYearsKey = (key) => __foldkitBrandViewResult((M.value(key).pipe(M.withReturnType(), M.when('ArrowLeft', () => __foldkitBrandViewResult((-1), "@foldkit/ui/calendar/index.js#anonymous~27")), M.when('ArrowRight', () => __foldkitBrandViewResult((1), "@foldkit/ui/calendar/index.js#anonymous~28")), M.when('ArrowUp', () => __foldkitBrandViewResult((-YEARS_GRID_COLUMNS), "@foldkit/ui/calendar/index.js#anonymous~29")), M.when('ArrowDown', () => __foldkitBrandViewResult((YEARS_GRID_COLUMNS), "@foldkit/ui/calendar/index.js#anonymous~30")), M.when('PageUp', () => __foldkitBrandViewResult((-YEARS_PAGE_SIZE), "@foldkit/ui/calendar/index.js#anonymous~31")), M.when('PageDown', () => __foldkitBrandViewResult((YEARS_PAGE_SIZE), "@foldkit/ui/calendar/index.js#anonymous~32")), M.option)), "@foldkit/ui/calendar/index.js#resolveYearsKey");
|
|
307
308
|
/** Applies a months-grid focus shift, updating `maybeFocusedDate` and
|
|
308
309
|
* `viewYear` to reflect the new focused date. `viewMonth` is preserved.
|
|
309
310
|
* Months mode keyboard navigation moves the cursor without committing. */
|
|
310
311
|
const applyMonthsFocusShift = (model, monthShift) => {
|
|
311
312
|
const focused = currentOrFallbackFocus(model);
|
|
312
313
|
const nextFocus = Calendar.addMonths(focused, monthShift);
|
|
313
|
-
return [
|
|
314
|
+
return __foldkitBrandViewResult(([
|
|
314
315
|
evo(model, {
|
|
315
|
-
maybeFocusedDate: () => Option.some(nextFocus),
|
|
316
|
-
viewYear: () => nextFocus.year,
|
|
316
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(nextFocus)), "@foldkit/ui/calendar/index.js#maybeFocusedDate~6"),
|
|
317
|
+
viewYear: () => __foldkitBrandViewResult((nextFocus.year), "@foldkit/ui/calendar/index.js#viewYear~5"),
|
|
317
318
|
}),
|
|
318
319
|
[],
|
|
319
320
|
Option.none(),
|
|
320
|
-
];
|
|
321
|
+
]), "@foldkit/ui/calendar/index.js#applyMonthsFocusShift");
|
|
321
322
|
};
|
|
322
323
|
/** Applies a years-grid focus shift, updating only `maybeFocusedDate`.
|
|
323
324
|
* `viewYear` is preserved so the "selected" highlight (`year === viewYear`)
|
|
@@ -326,119 +327,119 @@ const applyMonthsFocusShift = (model, monthShift) => {
|
|
|
326
327
|
const applyYearsFocusShift = (model, yearShift) => {
|
|
327
328
|
const focused = currentOrFallbackFocus(model);
|
|
328
329
|
const nextFocus = Calendar.addYears(focused, yearShift);
|
|
329
|
-
return [
|
|
330
|
+
return __foldkitBrandViewResult(([
|
|
330
331
|
evo(model, {
|
|
331
|
-
maybeFocusedDate: () => Option.some(nextFocus),
|
|
332
|
+
maybeFocusedDate: () => __foldkitBrandViewResult((Option.some(nextFocus)), "@foldkit/ui/calendar/index.js#maybeFocusedDate~7"),
|
|
332
333
|
}),
|
|
333
334
|
[],
|
|
334
335
|
Option.none(),
|
|
335
|
-
];
|
|
336
|
+
]), "@foldkit/ui/calendar/index.js#applyYearsFocusShift");
|
|
336
337
|
};
|
|
337
338
|
/** Processes a calendar message and returns the next model, commands, and
|
|
338
339
|
* optional OutMessage. */
|
|
339
|
-
export const update = (model, message) => M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
340
|
+
export const update = (model, message) => __foldkitBrandViewResult((M.value(message).pipe(withUpdateReturn, M.tagsExhaustive({
|
|
340
341
|
ClickedDay: ({ date }) => {
|
|
341
342
|
if (isDateDisabled(model, date)) {
|
|
342
|
-
return [model, [], Option.none()];
|
|
343
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#ClickedDay");
|
|
343
344
|
}
|
|
344
345
|
else {
|
|
345
346
|
const [nextModel, maybeOutMessage] = commitSelection(model, date);
|
|
346
|
-
return [nextModel, [], maybeOutMessage];
|
|
347
|
+
return __foldkitBrandViewResult(([nextModel, [], maybeOutMessage]), "@foldkit/ui/calendar/index.js#ClickedDay");
|
|
347
348
|
}
|
|
348
349
|
},
|
|
349
|
-
PressedKeyOnGrid: ({ key, isShift }) => M.value(model.viewMode).pipe(withUpdateReturn, M.when('Days', () => {
|
|
350
|
+
PressedKeyOnGrid: ({ key, isShift }) => __foldkitBrandViewResult((M.value(model.viewMode).pipe(withUpdateReturn, M.when('Days', () => {
|
|
350
351
|
const focused = currentOrFallbackFocus(model);
|
|
351
352
|
if (isCommitKey(key)) {
|
|
352
353
|
if (isDateDisabled(model, focused)) {
|
|
353
|
-
return [model, [], Option.none()];
|
|
354
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#anonymous~33");
|
|
354
355
|
}
|
|
355
356
|
else {
|
|
356
357
|
const [nextModel, maybeOutMessage] = commitSelection(model, focused);
|
|
357
|
-
return [nextModel, [], maybeOutMessage];
|
|
358
|
+
return __foldkitBrandViewResult(([nextModel, [], maybeOutMessage]), "@foldkit/ui/calendar/index.js#anonymous~33");
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
else {
|
|
361
|
-
return Option.match(resolveNavigationKey(key, isShift, focused, model.locale.firstDayOfWeek), {
|
|
362
|
-
onNone: () => [model, [], Option.none()],
|
|
362
|
+
return __foldkitBrandViewResult((Option.match(resolveNavigationKey(key, isShift, focused, model.locale.firstDayOfWeek), {
|
|
363
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#onNone~5"),
|
|
363
364
|
onSome: ([candidate, direction, cap]) => {
|
|
364
365
|
const [nextModel, maybeOutMessage] = applyFocusMove(model, candidate, direction, cap);
|
|
365
|
-
return [nextModel, [], maybeOutMessage];
|
|
366
|
+
return __foldkitBrandViewResult(([nextModel, [], maybeOutMessage]), "@foldkit/ui/calendar/index.js#onSome~5");
|
|
366
367
|
},
|
|
367
|
-
});
|
|
368
|
+
})), "@foldkit/ui/calendar/index.js#anonymous~33");
|
|
368
369
|
}
|
|
369
|
-
}), M.when('Months', () => Option.match(resolveMonthsKey(key), {
|
|
370
|
-
onNone: () => [model, [], Option.none()],
|
|
371
|
-
onSome: shift => applyMonthsFocusShift(model, shift),
|
|
372
|
-
})), M.when('Years', () => Option.match(resolveYearsKey(key), {
|
|
373
|
-
onNone: () => [model, [], Option.none()],
|
|
374
|
-
onSome: shift => applyYearsFocusShift(model, shift),
|
|
375
|
-
})), M.exhaustive),
|
|
370
|
+
}), M.when('Months', () => __foldkitBrandViewResult((Option.match(resolveMonthsKey(key), {
|
|
371
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#onNone~6"),
|
|
372
|
+
onSome: shift => __foldkitBrandViewResult((applyMonthsFocusShift(model, shift)), "@foldkit/ui/calendar/index.js#onSome~6"),
|
|
373
|
+
})), "@foldkit/ui/calendar/index.js#anonymous~34")), M.when('Years', () => __foldkitBrandViewResult((Option.match(resolveYearsKey(key), {
|
|
374
|
+
onNone: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#onNone~7"),
|
|
375
|
+
onSome: shift => __foldkitBrandViewResult((applyYearsFocusShift(model, shift)), "@foldkit/ui/calendar/index.js#onSome~7"),
|
|
376
|
+
})), "@foldkit/ui/calendar/index.js#anonymous~35")), M.exhaustive)), "@foldkit/ui/calendar/index.js#PressedKeyOnGrid"),
|
|
376
377
|
ClickedPreviousMonthButton: () => {
|
|
377
378
|
const next = Calendar.subtractMonths(Calendar.make(model.viewYear, model.viewMonth, 1), 1);
|
|
378
|
-
return applyViewMonthChange(model, next.year, next.month, -1);
|
|
379
|
+
return __foldkitBrandViewResult((applyViewMonthChange(model, next.year, next.month, -1)), "@foldkit/ui/calendar/index.js#ClickedPreviousMonthButton");
|
|
379
380
|
},
|
|
380
381
|
ClickedNextMonthButton: () => {
|
|
381
382
|
const next = Calendar.addMonths(Calendar.make(model.viewYear, model.viewMonth, 1), 1);
|
|
382
|
-
return applyViewMonthChange(model, next.year, next.month, 1);
|
|
383
|
+
return __foldkitBrandViewResult((applyViewMonthChange(model, next.year, next.month, 1)), "@foldkit/ui/calendar/index.js#ClickedNextMonthButton");
|
|
383
384
|
},
|
|
384
|
-
ClickedHeading: () => M.value(model.viewMode).pipe(withUpdateReturn, M.when('Days', () => [
|
|
385
|
-
evo(model, { viewMode: () => 'Months' }),
|
|
385
|
+
ClickedHeading: () => __foldkitBrandViewResult((M.value(model.viewMode).pipe(withUpdateReturn, M.when('Days', () => __foldkitBrandViewResult(([
|
|
386
|
+
evo(model, { viewMode: () => __foldkitBrandViewResult(('Months'), "@foldkit/ui/calendar/index.js#viewMode~2") }),
|
|
386
387
|
[FocusGrid({ id: model.id })],
|
|
387
388
|
Option.none(),
|
|
388
|
-
]), M.when('Months', () => [
|
|
389
|
-
evo(model, { viewMode: () => 'Years' }),
|
|
389
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~36")), M.when('Months', () => __foldkitBrandViewResult(([
|
|
390
|
+
evo(model, { viewMode: () => __foldkitBrandViewResult(('Years'), "@foldkit/ui/calendar/index.js#viewMode~3") }),
|
|
390
391
|
[FocusGrid({ id: model.id })],
|
|
391
392
|
Option.none(),
|
|
392
|
-
]), M.when('Years', () => [model, [], Option.none()]), M.exhaustive),
|
|
393
|
+
]), "@foldkit/ui/calendar/index.js#anonymous~37")), M.when('Years', () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#anonymous~38")), M.exhaustive)), "@foldkit/ui/calendar/index.js#ClickedHeading"),
|
|
393
394
|
SelectedMonth: ({ month }) => {
|
|
394
395
|
if (isMonthDisabled(model, model.viewYear, month)) {
|
|
395
|
-
return [model, [], Option.none()];
|
|
396
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#SelectedMonth");
|
|
396
397
|
}
|
|
397
398
|
else {
|
|
398
399
|
const [nextModel, commands, maybeOutMessage] = applyViewMonthChange(model, model.viewYear, month, jumpDirection(model, model.viewYear, month));
|
|
399
|
-
return [
|
|
400
|
-
evo(nextModel, { viewMode: () => 'Days' }),
|
|
400
|
+
return __foldkitBrandViewResult(([
|
|
401
|
+
evo(nextModel, { viewMode: () => __foldkitBrandViewResult(('Days'), "@foldkit/ui/calendar/index.js#viewMode~4") }),
|
|
401
402
|
[...commands, FocusGrid({ id: model.id })],
|
|
402
403
|
maybeOutMessage,
|
|
403
|
-
];
|
|
404
|
+
]), "@foldkit/ui/calendar/index.js#SelectedMonth");
|
|
404
405
|
}
|
|
405
406
|
},
|
|
406
407
|
SelectedYear: ({ year }) => {
|
|
407
408
|
if (isYearDisabled(model, year)) {
|
|
408
|
-
return [model, [], Option.none()];
|
|
409
|
+
return __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#SelectedYear");
|
|
409
410
|
}
|
|
410
411
|
else {
|
|
411
412
|
const [nextModel, commands, maybeOutMessage] = applyViewMonthChange(model, year, model.viewMonth, jumpDirection(model, year, model.viewMonth));
|
|
412
|
-
return [
|
|
413
|
-
evo(nextModel, { viewMode: () => 'Months' }),
|
|
413
|
+
return __foldkitBrandViewResult(([
|
|
414
|
+
evo(nextModel, { viewMode: () => __foldkitBrandViewResult(('Months'), "@foldkit/ui/calendar/index.js#viewMode~5") }),
|
|
414
415
|
[...commands, FocusGrid({ id: model.id })],
|
|
415
416
|
maybeOutMessage,
|
|
416
|
-
];
|
|
417
|
+
]), "@foldkit/ui/calendar/index.js#SelectedYear");
|
|
417
418
|
}
|
|
418
419
|
},
|
|
419
|
-
PagedYears: ({ direction }) => applyYearsFocusShift(model, direction * YEARS_PAGE_SIZE),
|
|
420
|
-
FocusedGrid: () => [
|
|
421
|
-
evo(model, { isGridFocused: () => true }),
|
|
420
|
+
PagedYears: ({ direction }) => __foldkitBrandViewResult((applyYearsFocusShift(model, direction * YEARS_PAGE_SIZE)), "@foldkit/ui/calendar/index.js#PagedYears"),
|
|
421
|
+
FocusedGrid: () => __foldkitBrandViewResult(([
|
|
422
|
+
evo(model, { isGridFocused: () => __foldkitBrandViewResult((true), "@foldkit/ui/calendar/index.js#isGridFocused") }),
|
|
422
423
|
[],
|
|
423
424
|
Option.none(),
|
|
424
|
-
],
|
|
425
|
-
BlurredGrid: () => [
|
|
426
|
-
evo(model, { isGridFocused: () => false }),
|
|
425
|
+
]), "@foldkit/ui/calendar/index.js#FocusedGrid"),
|
|
426
|
+
BlurredGrid: () => __foldkitBrandViewResult(([
|
|
427
|
+
evo(model, { isGridFocused: () => __foldkitBrandViewResult((false), "@foldkit/ui/calendar/index.js#isGridFocused~2") }),
|
|
427
428
|
[],
|
|
428
429
|
Option.none(),
|
|
429
|
-
],
|
|
430
|
-
RefreshedToday: ({ today }) => [
|
|
431
|
-
evo(model, { today: () => today }),
|
|
430
|
+
]), "@foldkit/ui/calendar/index.js#BlurredGrid"),
|
|
431
|
+
RefreshedToday: ({ today }) => __foldkitBrandViewResult(([
|
|
432
|
+
evo(model, { today: () => __foldkitBrandViewResult((today), "@foldkit/ui/calendar/index.js#today") }),
|
|
432
433
|
[],
|
|
433
434
|
Option.none(),
|
|
434
|
-
],
|
|
435
|
-
CompletedFocusGrid: () => [model, [], Option.none()],
|
|
436
|
-
}));
|
|
435
|
+
]), "@foldkit/ui/calendar/index.js#RefreshedToday"),
|
|
436
|
+
CompletedFocusGrid: () => __foldkitBrandViewResult(([model, [], Option.none()]), "@foldkit/ui/calendar/index.js#CompletedFocusGrid"),
|
|
437
|
+
}))), "@foldkit/ui/calendar/index.js#update");
|
|
437
438
|
// VIEW
|
|
438
|
-
const headingId = (modelId) => `${modelId}-heading
|
|
439
|
-
const dayCellId = (modelId, date) => `${modelId}-cell-${date.year}-${date.month}-${date.day}
|
|
440
|
-
const monthCellId = (modelId, month) => `${modelId}-cell-month-${month}
|
|
441
|
-
const yearCellId = (modelId, year) => `${modelId}-cell-year-${year}
|
|
439
|
+
const headingId = (modelId) => __foldkitBrandViewResult((`${modelId}-heading`), "@foldkit/ui/calendar/index.js#headingId");
|
|
440
|
+
const dayCellId = (modelId, date) => __foldkitBrandViewResult((`${modelId}-cell-${date.year}-${date.month}-${date.day}`), "@foldkit/ui/calendar/index.js#dayCellId");
|
|
441
|
+
const monthCellId = (modelId, month) => __foldkitBrandViewResult((`${modelId}-cell-month-${month}`), "@foldkit/ui/calendar/index.js#monthCellId");
|
|
442
|
+
const yearCellId = (modelId, year) => __foldkitBrandViewResult((`${modelId}-cell-year-${year}`), "@foldkit/ui/calendar/index.js#yearCellId");
|
|
442
443
|
const DAY_NAMES_SUNDAY_FIRST = [
|
|
443
444
|
'Sunday',
|
|
444
445
|
'Monday',
|
|
@@ -461,7 +462,7 @@ const DAY_OF_WEEK_INDEX = {
|
|
|
461
462
|
* the first entry. Used to build column headers in locale-appropriate order. */
|
|
462
463
|
const rotateDayNames = (names, firstDayOfWeek) => {
|
|
463
464
|
const [front, back] = Array.splitAt(names, DAY_OF_WEEK_INDEX[firstDayOfWeek]);
|
|
464
|
-
return [...back, ...front];
|
|
465
|
+
return __foldkitBrandViewResult(([...back, ...front]), "@foldkit/ui/calendar/index.js#rotateDayNames");
|
|
465
466
|
};
|
|
466
467
|
const WEEKS_IN_GRID = 6;
|
|
467
468
|
const DAYS_IN_WEEK = 7;
|
|
@@ -472,8 +473,8 @@ const DAYS_IN_WEEK = 7;
|
|
|
472
473
|
const buildGrid = (viewYear, viewMonth, firstDayOfWeek) => {
|
|
473
474
|
const firstOfMonth = Calendar.make(viewYear, viewMonth, 1);
|
|
474
475
|
const gridStart = Calendar.startOfWeek(firstOfMonth, firstDayOfWeek);
|
|
475
|
-
const weeks = Array.makeBy(WEEKS_IN_GRID, weekIndex => Array.makeBy(DAYS_IN_WEEK, dayIndex => Calendar.addDays(gridStart, weekIndex * DAYS_IN_WEEK + dayIndex)));
|
|
476
|
-
return { gridStart, weeks };
|
|
476
|
+
const weeks = Array.makeBy(WEEKS_IN_GRID, weekIndex => __foldkitBrandViewResult((Array.makeBy(DAYS_IN_WEEK, dayIndex => __foldkitBrandViewResult((Calendar.addDays(gridStart, weekIndex * DAYS_IN_WEEK + dayIndex)), "@foldkit/ui/calendar/index.js#anonymous~40"))), "@foldkit/ui/calendar/index.js#anonymous~39"));
|
|
477
|
+
return __foldkitBrandViewResult(({ gridStart, weeks }), "@foldkit/ui/calendar/index.js#buildGrid");
|
|
477
478
|
};
|
|
478
479
|
const NAV_KEYS = new Set([
|
|
479
480
|
'ArrowLeft',
|
|
@@ -491,19 +492,19 @@ const MONTHS_GRID_COLUMNS = 3;
|
|
|
491
492
|
const YEARS_GRID_COLUMNS = 3;
|
|
492
493
|
const MONTHS_IN_YEAR = 12;
|
|
493
494
|
/** Returns the start year of the 12-year window the years grid renders. */
|
|
494
|
-
const yearsPageStart = (viewYear) => Math.floor(viewYear / YEARS_PAGE_SIZE) * YEARS_PAGE_SIZE;
|
|
495
|
+
const yearsPageStart = (viewYear) => __foldkitBrandViewResult((Math.floor(viewYear / YEARS_PAGE_SIZE) * YEARS_PAGE_SIZE), "@foldkit/ui/calendar/index.js#yearsPageStart");
|
|
495
496
|
/** A month range is fully disabled when its last day is below the minimum
|
|
496
497
|
* or its first day is above the maximum. */
|
|
497
498
|
const isMonthDisabled = (model, year, month) => {
|
|
498
499
|
const monthStart = Calendar.make(year, month, 1);
|
|
499
500
|
const monthEnd = Calendar.make(year, month, Calendar.daysInMonth(year, month));
|
|
500
|
-
return (Option.exists(model.maybeMinDate, min => Calendar.isBefore(monthEnd, min)) ||
|
|
501
|
-
Option.exists(model.maybeMaxDate, max => Calendar.isAfter(monthStart, max)));
|
|
501
|
+
return (__foldkitBrandViewResult((Option.exists(model.maybeMinDate, min => __foldkitBrandViewResult((Calendar.isBefore(monthEnd, min)), "@foldkit/ui/calendar/index.js#anonymous~41")) ||
|
|
502
|
+
Option.exists(model.maybeMaxDate, max => __foldkitBrandViewResult((Calendar.isAfter(monthStart, max)), "@foldkit/ui/calendar/index.js#anonymous~42"))), "@foldkit/ui/calendar/index.js#isMonthDisabled"));
|
|
502
503
|
};
|
|
503
504
|
/** A year is fully disabled when it falls entirely below the minimum date's
|
|
504
505
|
* year or entirely above the maximum date's year. */
|
|
505
|
-
const isYearDisabled = (model, year) => Option.exists(model.maybeMinDate, min => year < min.year) ||
|
|
506
|
-
Option.exists(model.maybeMaxDate, max => year > max.year);
|
|
506
|
+
const isYearDisabled = (model, year) => __foldkitBrandViewResult((Option.exists(model.maybeMinDate, min => __foldkitBrandViewResult((year < min.year), "@foldkit/ui/calendar/index.js#anonymous~43")) ||
|
|
507
|
+
Option.exists(model.maybeMaxDate, max => __foldkitBrandViewResult((year > max.year), "@foldkit/ui/calendar/index.js#anonymous~44"))), "@foldkit/ui/calendar/index.js#isYearDisabled");
|
|
507
508
|
const buildDaysAttributes = (model, viewInputs) => {
|
|
508
509
|
const h = html();
|
|
509
510
|
const { id, viewYear, viewMonth, maybeFocusedDate, today, locale, isGridFocused, } = model;
|
|
@@ -515,7 +516,7 @@ const buildDaysAttributes = (model, viewInputs) => {
|
|
|
515
516
|
const rotatedDayNames = rotateDayNames(DAY_NAMES_SUNDAY_FIRST, locale.firstDayOfWeek);
|
|
516
517
|
const rotatedShortDayNames = rotateDayNames(locale.shortDayNames, locale.firstDayOfWeek);
|
|
517
518
|
const { gridStart, weeks: weeksDates } = buildGrid(viewYear, viewMonth, locale.firstDayOfWeek);
|
|
518
|
-
const rootAttributes = [h.Id(id)
|
|
519
|
+
const rootAttributes = [h.Id(id)];
|
|
519
520
|
const previousMonthButton = [
|
|
520
521
|
h.Type('button'),
|
|
521
522
|
h.AriaLabel(previousMonthLabel),
|
|
@@ -533,17 +534,17 @@ const buildDaysAttributes = (model, viewInputs) => {
|
|
|
533
534
|
];
|
|
534
535
|
const handleKeyDown = (key, modifiers) => {
|
|
535
536
|
if (!NAV_KEYS.has(key)) {
|
|
536
|
-
return Option.none();
|
|
537
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/calendar/index.js#handleKeyDown");
|
|
537
538
|
}
|
|
538
539
|
if (isCommitKey(key)) {
|
|
539
|
-
const maybeCommit = pipe(maybeFocusedDate, Option.filter(date => !isDateDisabled(model, date)), Option.map(date => ClickedDay({ date })));
|
|
540
|
+
const maybeCommit = pipe(maybeFocusedDate, Option.filter(date => __foldkitBrandViewResult((!isDateDisabled(model, date)), "@foldkit/ui/calendar/index.js#anonymous~45")), Option.map(date => __foldkitBrandViewResult((ClickedDay({ date })), "@foldkit/ui/calendar/index.js#anonymous~46")));
|
|
540
541
|
if (Option.isSome(maybeCommit)) {
|
|
541
|
-
return maybeCommit;
|
|
542
|
+
return __foldkitBrandViewResult((maybeCommit), "@foldkit/ui/calendar/index.js#handleKeyDown");
|
|
542
543
|
}
|
|
543
544
|
}
|
|
544
|
-
return Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }));
|
|
545
|
+
return __foldkitBrandViewResult((Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }))), "@foldkit/ui/calendar/index.js#handleKeyDown");
|
|
545
546
|
};
|
|
546
|
-
const activeDescendantAttributes = pipe(maybeFocusedDate, Option.map(date => h.AriaActiveDescendant(dayCellId(id, date))), Option.toArray);
|
|
547
|
+
const activeDescendantAttributes = pipe(maybeFocusedDate, Option.map(date => __foldkitBrandViewResult((h.AriaActiveDescendant(dayCellId(id, date))), "@foldkit/ui/calendar/index.js#anonymous~47")), Option.toArray);
|
|
547
548
|
const gridAttributes = [
|
|
548
549
|
h.Id(gridId(id)),
|
|
549
550
|
h.Role('grid'),
|
|
@@ -584,7 +585,7 @@ const buildDaysAttributes = (model, viewInputs) => {
|
|
|
584
585
|
h.AriaDisabled(isDisabled),
|
|
585
586
|
...(isDisabled ? [] : [h.OnClick(ClickedDay({ date }))]),
|
|
586
587
|
];
|
|
587
|
-
return {
|
|
588
|
+
return __foldkitBrandViewResult(({
|
|
588
589
|
date,
|
|
589
590
|
label: String(date.day),
|
|
590
591
|
cellAttributes: childAttributes(cellAttributes),
|
|
@@ -594,28 +595,28 @@ const buildDaysAttributes = (model, viewInputs) => {
|
|
|
594
595
|
isToday,
|
|
595
596
|
isInViewMonth,
|
|
596
597
|
isDisabled,
|
|
597
|
-
};
|
|
598
|
+
}), "@foldkit/ui/calendar/index.js#buildDayCell");
|
|
598
599
|
};
|
|
599
600
|
const weeks = weeksDates.map((weekDates, weekIndex) => {
|
|
600
601
|
const weekStart = Calendar.addDays(gridStart, weekIndex * DAYS_IN_WEEK);
|
|
601
|
-
return {
|
|
602
|
+
return __foldkitBrandViewResult(({
|
|
602
603
|
attributes: childAttributes([
|
|
603
604
|
h.Role('row'),
|
|
604
605
|
h.AriaRowindex(weekIndex + 2),
|
|
605
606
|
h.AriaLabel(`Week of ${Calendar.formatLong(weekStart, locale)}`),
|
|
606
607
|
]),
|
|
607
608
|
cells: weekDates.map(buildDayCell),
|
|
608
|
-
};
|
|
609
|
+
}), "@foldkit/ui/calendar/index.js#anonymous~48");
|
|
609
610
|
});
|
|
610
|
-
const wrappedColumnHeaders = Array.zipWith(rotatedShortDayNames, rotatedDayNames, (name, fullName) => ({ name, fullName })).map(({ name, fullName }, columnIndex) => ({
|
|
611
|
+
const wrappedColumnHeaders = Array.zipWith(rotatedShortDayNames, rotatedDayNames, (name, fullName) => (__foldkitBrandViewResult(({ name, fullName }), "@foldkit/ui/calendar/index.js#anonymous~49"))).map(({ name, fullName }, columnIndex) => (__foldkitBrandViewResult(({
|
|
611
612
|
name,
|
|
612
613
|
attributes: childAttributes([
|
|
613
614
|
h.Role('columnheader'),
|
|
614
615
|
h.AriaLabel(fullName),
|
|
615
616
|
h.AriaColindex(Number.increment(columnIndex)),
|
|
616
617
|
]),
|
|
617
|
-
}));
|
|
618
|
-
return {
|
|
618
|
+
}), "@foldkit/ui/calendar/index.js#anonymous~50")));
|
|
619
|
+
return __foldkitBrandViewResult(({
|
|
619
620
|
_tag: 'Days',
|
|
620
621
|
root: childAttributes(rootAttributes),
|
|
621
622
|
previousMonthButton: childAttributes(previousMonthButton),
|
|
@@ -626,32 +627,32 @@ const buildDaysAttributes = (model, viewInputs) => {
|
|
|
626
627
|
headerRow: childAttributes(headerRowAttributes),
|
|
627
628
|
columnHeaders: wrappedColumnHeaders,
|
|
628
629
|
weeks,
|
|
629
|
-
};
|
|
630
|
+
}), "@foldkit/ui/calendar/index.js#buildDaysAttributes");
|
|
630
631
|
};
|
|
631
632
|
const buildMonthsAttributes = (model, viewInputs) => {
|
|
632
633
|
const h = html();
|
|
633
634
|
const { id, viewYear, viewMonth, maybeFocusedDate, today, locale, isGridFocused, } = model;
|
|
634
635
|
const headingButtonLabel = viewInputs.monthsHeadingButtonLabel ?? 'Switch to year picker';
|
|
635
636
|
const headingText = `${viewYear}`;
|
|
636
|
-
const rootAttributes = [h.Id(id)
|
|
637
|
+
const rootAttributes = [h.Id(id)];
|
|
637
638
|
const headingButton = [
|
|
638
639
|
h.Type('button'),
|
|
639
640
|
h.AriaLabel(headingButtonLabel),
|
|
640
641
|
h.OnClick(ClickedHeading()),
|
|
641
642
|
];
|
|
642
643
|
const focusedMonth = Option.match(maybeFocusedDate, {
|
|
643
|
-
onNone: () => viewMonth,
|
|
644
|
-
onSome: date => (date.year === viewYear ? date.month : viewMonth),
|
|
644
|
+
onNone: () => __foldkitBrandViewResult((viewMonth), "@foldkit/ui/calendar/index.js#onNone~8"),
|
|
645
|
+
onSome: date => (__foldkitBrandViewResult((date.year === viewYear ? date.month : viewMonth), "@foldkit/ui/calendar/index.js#onSome~8")),
|
|
645
646
|
});
|
|
646
647
|
const handleKeyDown = (key, modifiers) => {
|
|
647
648
|
if (!NAV_KEYS.has(key)) {
|
|
648
|
-
return Option.none();
|
|
649
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/calendar/index.js#handleKeyDown~2");
|
|
649
650
|
}
|
|
650
651
|
else if (isCommitKey(key)) {
|
|
651
|
-
return OptionExt.when(!isMonthDisabled(model, viewYear, focusedMonth), SelectedMonth({ month: focusedMonth }));
|
|
652
|
+
return __foldkitBrandViewResult((OptionExt.when(!isMonthDisabled(model, viewYear, focusedMonth), SelectedMonth({ month: focusedMonth }))), "@foldkit/ui/calendar/index.js#handleKeyDown~2");
|
|
652
653
|
}
|
|
653
654
|
else {
|
|
654
|
-
return Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }));
|
|
655
|
+
return __foldkitBrandViewResult((Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }))), "@foldkit/ui/calendar/index.js#handleKeyDown~2");
|
|
655
656
|
}
|
|
656
657
|
};
|
|
657
658
|
const activeDescendantAttributes = [
|
|
@@ -693,7 +694,7 @@ const buildMonthsAttributes = (model, viewInputs) => {
|
|
|
693
694
|
h.AriaDisabled(isDisabled),
|
|
694
695
|
...(isDisabled ? [] : [h.OnClick(SelectedMonth({ month }))]),
|
|
695
696
|
];
|
|
696
|
-
return {
|
|
697
|
+
return __foldkitBrandViewResult(({
|
|
697
698
|
month,
|
|
698
699
|
label,
|
|
699
700
|
shortLabel,
|
|
@@ -703,17 +704,17 @@ const buildMonthsAttributes = (model, viewInputs) => {
|
|
|
703
704
|
isFocused: isFocused && isGridFocused,
|
|
704
705
|
isCurrentMonth,
|
|
705
706
|
isDisabled,
|
|
706
|
-
};
|
|
707
|
+
}), "@foldkit/ui/calendar/index.js#buildMonthCell");
|
|
707
708
|
};
|
|
708
|
-
const cells = Array.makeBy(MONTHS_IN_YEAR, monthIndex => buildMonthCell(Number.increment(monthIndex)));
|
|
709
|
-
return {
|
|
709
|
+
const cells = Array.makeBy(MONTHS_IN_YEAR, monthIndex => __foldkitBrandViewResult((buildMonthCell(Number.increment(monthIndex))), "@foldkit/ui/calendar/index.js#anonymous~51"));
|
|
710
|
+
return __foldkitBrandViewResult(({
|
|
710
711
|
_tag: 'Months',
|
|
711
712
|
root: childAttributes(rootAttributes),
|
|
712
713
|
headingButton: childAttributes(headingButton),
|
|
713
714
|
heading: { id: headingId(id), text: headingText },
|
|
714
715
|
grid: childAttributes(gridAttributes),
|
|
715
716
|
cells,
|
|
716
|
-
};
|
|
717
|
+
}), "@foldkit/ui/calendar/index.js#buildMonthsAttributes");
|
|
717
718
|
};
|
|
718
719
|
const buildYearsAttributes = (model, viewInputs) => {
|
|
719
720
|
const h = html();
|
|
@@ -721,13 +722,13 @@ const buildYearsAttributes = (model, viewInputs) => {
|
|
|
721
722
|
const previousYearsPageLabel = viewInputs.previousYearsPageLabel ?? 'Previous 12 years';
|
|
722
723
|
const nextYearsPageLabel = viewInputs.nextYearsPageLabel ?? 'Next 12 years';
|
|
723
724
|
const cursorYear = Option.match(maybeFocusedDate, {
|
|
724
|
-
onNone: () => viewYear,
|
|
725
|
-
onSome: date => date.year,
|
|
725
|
+
onNone: () => __foldkitBrandViewResult((viewYear), "@foldkit/ui/calendar/index.js#onNone~9"),
|
|
726
|
+
onSome: date => __foldkitBrandViewResult((date.year), "@foldkit/ui/calendar/index.js#onSome~9"),
|
|
726
727
|
});
|
|
727
728
|
const pageStart = yearsPageStart(cursorYear);
|
|
728
729
|
const pageEnd = pageStart + YEARS_PAGE_SIZE - 1;
|
|
729
730
|
const headingText = `${pageStart}–${pageEnd}`;
|
|
730
|
-
const rootAttributes = [h.Id(id)
|
|
731
|
+
const rootAttributes = [h.Id(id)];
|
|
731
732
|
const previousPageButton = [
|
|
732
733
|
h.Type('button'),
|
|
733
734
|
h.AriaLabel(previousYearsPageLabel),
|
|
@@ -741,13 +742,13 @@ const buildYearsAttributes = (model, viewInputs) => {
|
|
|
741
742
|
const focusedYear = cursorYear;
|
|
742
743
|
const handleKeyDown = (key, modifiers) => {
|
|
743
744
|
if (!NAV_KEYS.has(key)) {
|
|
744
|
-
return Option.none();
|
|
745
|
+
return __foldkitBrandViewResult((Option.none()), "@foldkit/ui/calendar/index.js#handleKeyDown~3");
|
|
745
746
|
}
|
|
746
747
|
else if (isCommitKey(key)) {
|
|
747
|
-
return OptionExt.when(!isYearDisabled(model, focusedYear), SelectedYear({ year: focusedYear }));
|
|
748
|
+
return __foldkitBrandViewResult((OptionExt.when(!isYearDisabled(model, focusedYear), SelectedYear({ year: focusedYear }))), "@foldkit/ui/calendar/index.js#handleKeyDown~3");
|
|
748
749
|
}
|
|
749
750
|
else {
|
|
750
|
-
return Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }));
|
|
751
|
+
return __foldkitBrandViewResult((Option.some(PressedKeyOnGrid({ key, isShift: modifiers.shiftKey }))), "@foldkit/ui/calendar/index.js#handleKeyDown~3");
|
|
751
752
|
}
|
|
752
753
|
};
|
|
753
754
|
const activeDescendantAttributes = [
|
|
@@ -788,7 +789,7 @@ const buildYearsAttributes = (model, viewInputs) => {
|
|
|
788
789
|
h.AriaDisabled(isDisabled),
|
|
789
790
|
...(isDisabled ? [] : [h.OnClick(SelectedYear({ year }))]),
|
|
790
791
|
];
|
|
791
|
-
return {
|
|
792
|
+
return __foldkitBrandViewResult(({
|
|
792
793
|
year,
|
|
793
794
|
label,
|
|
794
795
|
cellAttributes: childAttributes(cellAttributes),
|
|
@@ -797,10 +798,10 @@ const buildYearsAttributes = (model, viewInputs) => {
|
|
|
797
798
|
isFocused: isFocused && isGridFocused,
|
|
798
799
|
isCurrentYear,
|
|
799
800
|
isDisabled,
|
|
800
|
-
};
|
|
801
|
+
}), "@foldkit/ui/calendar/index.js#buildYearCell");
|
|
801
802
|
};
|
|
802
|
-
const cells = Array.makeBy(YEARS_PAGE_SIZE, offset => buildYearCell(pageStart + offset));
|
|
803
|
-
return {
|
|
803
|
+
const cells = Array.makeBy(YEARS_PAGE_SIZE, offset => __foldkitBrandViewResult((buildYearCell(pageStart + offset)), "@foldkit/ui/calendar/index.js#anonymous~52"));
|
|
804
|
+
return __foldkitBrandViewResult(({
|
|
804
805
|
_tag: 'Years',
|
|
805
806
|
root: childAttributes(rootAttributes),
|
|
806
807
|
previousPageButton: childAttributes(previousPageButton),
|
|
@@ -808,10 +809,10 @@ const buildYearsAttributes = (model, viewInputs) => {
|
|
|
808
809
|
heading: { id: headingId(id), text: headingText },
|
|
809
810
|
grid: childAttributes(gridAttributes),
|
|
810
811
|
cells,
|
|
811
|
-
};
|
|
812
|
+
}), "@foldkit/ui/calendar/index.js#buildYearsAttributes");
|
|
812
813
|
};
|
|
813
814
|
/** Renders an accessible calendar. Publishes mode-specific ARIA attribute
|
|
814
815
|
* bundles + derived cell data, then delegates layout to the consumer's
|
|
815
816
|
* `toView` callback. The variant of `CalendarAttributes` passed to
|
|
816
817
|
* `toView` matches `model.viewMode`. */
|
|
817
|
-
export const view = defineView((model, viewInputs) => viewInputs.toView(M.value(model.viewMode).pipe(M.withReturnType(), M.when('Days', () => buildDaysAttributes(model, viewInputs)), M.when('Months', () => buildMonthsAttributes(model, viewInputs)), M.when('Years', () => buildYearsAttributes(model, viewInputs)), M.exhaustive)));
|
|
818
|
+
export const view = defineView((model, viewInputs) => __foldkitBrandViewResult((viewInputs.toView(M.value(model.viewMode).pipe(M.withReturnType(), M.when('Days', () => __foldkitBrandViewResult((buildDaysAttributes(model, viewInputs)), "@foldkit/ui/calendar/index.js#anonymous~54")), M.when('Months', () => __foldkitBrandViewResult((buildMonthsAttributes(model, viewInputs)), "@foldkit/ui/calendar/index.js#anonymous~55")), M.when('Years', () => __foldkitBrandViewResult((buildYearsAttributes(model, viewInputs)), "@foldkit/ui/calendar/index.js#anonymous~56")), M.exhaustive))), "@foldkit/ui/calendar/index.js#anonymous~53"));
|