@fusion.dev/helix-headless 0.154.0 → 0.155.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/custom-elements.json +1427 -88
- package/dist/accordion/item/accordion-item.d.ts +15 -0
- package/dist/accordion/item/accordion-item.js +12 -1
- package/dist/accordion/root/accordion-root.d.ts +2 -1
- package/dist/accordion/root/accordion-root.js +1 -0
- package/dist/breadcrumbs/breadcrumb/breadcrumb.d.ts +36 -3
- package/dist/breadcrumbs/breadcrumb/breadcrumb.js +42 -2
- package/dist/breadcrumbs/root/breadcrumbs-root.d.ts +15 -5
- package/dist/breadcrumbs/root/breadcrumbs-root.js +29 -4
- package/dist/button-group/root/button-group-root.d.ts +2 -0
- package/dist/button-group/root/button-group-root.js +1 -0
- package/dist/color-input/root/color-input-root.d.ts +9 -3
- package/dist/color-input/root/color-input-root.js +3 -1
- package/dist/color-picker/channels.d.ts +5 -3
- package/dist/color-picker/channels.js +79 -21
- package/dist/color-picker/root/color-picker-root.d.ts +58 -5
- package/dist/color-picker/root/color-picker-root.js +75 -13
- package/dist/date-input/root/date-input-root.d.ts +1 -0
- package/dist/date-input/root/date-input-root.js +2 -1
- package/dist/date-picker/root/date-picker-root.d.ts +43 -13
- package/dist/date-picker/root/date-picker-root.js +54 -31
- package/dist/element-events.generated.js +2 -1
- package/dist/navigation/root/navigation-root.d.ts +26 -0
- package/dist/navigation/root/navigation-root.js +58 -1
- package/dist/select/root/select-root.d.ts +29 -3
- package/dist/select/root/select-root.js +34 -9
- package/dist/slider/root/slider-root.d.ts +71 -9
- package/dist/slider/root/slider-root.js +129 -42
- package/dist/speed-dial/item/speed-dial-item.d.ts +29 -1
- package/dist/speed-dial/item/speed-dial-item.js +48 -7
- package/dist/speed-dial/root/speed-dial-root.d.ts +32 -6
- package/dist/speed-dial/root/speed-dial-root.js +50 -5
- package/dist/splitter/root/splitter-root.d.ts +22 -0
- package/dist/splitter/root/splitter-root.js +36 -7
- package/dist/steps/reach.d.ts +5 -1
- package/dist/steps/reach.js +2 -2
- package/dist/steps/root/steps-root.d.ts +37 -2
- package/dist/steps/root/steps-root.js +49 -7
- package/dist/steps/step/step.d.ts +6 -0
- package/dist/steps/step/step.js +4 -0
- package/dist/tabs/root/tabs-root.d.ts +37 -0
- package/dist/tabs/root/tabs-root.js +92 -2
- package/dist/tabs/tab/tab.d.ts +38 -2
- package/dist/tabs/tab/tab.js +45 -4
- package/dist/tag/group/tag-group.d.ts +29 -3
- package/dist/tag/group/tag-group.js +42 -11
- package/dist/toggle/root/toggle-root.d.ts +2 -0
- package/dist/toggle/root/toggle-root.js +1 -1
- package/dist/tree/item/tree-item.d.ts +10 -0
- package/dist/tree/item/tree-item.js +12 -0
- package/dist/tree/root/tree-root.d.ts +40 -1
- package/dist/tree/root/tree-root.js +120 -4
- package/dist/tree/selection.d.ts +6 -0
- package/dist/tree/selection.js +11 -0
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +984 -151
- package/types/vue.d.ts +221 -49
- package/types/words.d.ts +36 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CalendarView, type DateCalendar, HelixFormElement } from '@fusion.dev/helix-core';
|
|
1
|
+
import { type CalendarView, type DateCalendar, HelixFormElement, type MonthCalendar } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
declare const HelixHeadlessDatePicker_base: (new (...args: any[]) => import("@fusion.dev/helix-core").MixinPickerFeedbackInterface) & (new (...args: any[]) => import("@fusion.dev/helix-core").MixinControllerValueInterface) & typeof HelixFormElement;
|
|
4
4
|
/**
|
|
@@ -47,6 +47,8 @@ declare const HelixHeadlessDatePicker_base: (new (...args: any[]) => import("@fu
|
|
|
47
47
|
* @aliases Calendar, Date grid, Month view
|
|
48
48
|
* @documentation https://fusion.dev/helix/components/date-picker
|
|
49
49
|
*
|
|
50
|
+
* @slot footer - Content under the calendar, such as buttons for today or a common range.
|
|
51
|
+
* @slot header - Content above the calendar, such as a note on what the date is for.
|
|
50
52
|
* @slot next-icon - The glyph on the control that moves forward a month, usually a caret.
|
|
51
53
|
* @slot previous-icon - The glyph on the control that moves back a month, usually a caret.
|
|
52
54
|
*
|
|
@@ -64,6 +66,7 @@ declare const HelixHeadlessDatePicker_base: (new (...args: any[]) => import("@fu
|
|
|
64
66
|
* @csspart day-outside - A day from a neighboring month, filling the grid out, beside `day`.
|
|
65
67
|
* @csspart day-selected - The chosen day, or either end of a chosen range, beside `day`.
|
|
66
68
|
* @csspart day-today - Today, beside `day`.
|
|
69
|
+
* @csspart day-weekend - A day of the weekend where the calendar's language is spoken, beside `day`: Saturday and Sunday in `en-US`, Friday and Saturday in `ar-EG`.
|
|
67
70
|
* @csspart feedback - The message under the calendar, while `feedback` is set.
|
|
68
71
|
* @csspart grid - The grid of days.
|
|
69
72
|
* @csspart header - The month name and its controls.
|
|
@@ -82,7 +85,7 @@ declare const HelixHeadlessDatePicker_base: (new (...args: any[]) => import("@fu
|
|
|
82
85
|
* @csspart previous - The control that moves to the previous month.
|
|
83
86
|
* @csspart previous-mark - The glyph on the previous month control, where none is slotted.
|
|
84
87
|
* @csspart week - One row of days.
|
|
85
|
-
* @csspart weekday - A column header naming a day of the week.
|
|
88
|
+
* @csspart weekday - A column header naming a day of the week. It shows the short name and says the full one.
|
|
86
89
|
*
|
|
87
90
|
* @cssproperty --date-picker-column-count - How many month columns are drawn, capped at two. `--date-picker-columns` overrides it.
|
|
88
91
|
*
|
|
@@ -105,17 +108,24 @@ export declare class HelixHeadlessDatePicker extends HelixHeadlessDatePicker_bas
|
|
|
105
108
|
*/
|
|
106
109
|
badInputMessage: string;
|
|
107
110
|
/**
|
|
108
|
-
* The calendar the heading, the days, and the months are written in
|
|
109
|
-
* `gregory`, `buddhist`, `japanese`, `roc`, or `iso8601`, the five whose
|
|
110
|
-
* months are the Gregorian months.
|
|
111
|
+
* The calendar the heading, the days, and the months are written in.
|
|
111
112
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
113
|
+
* `gregory`, `buddhist`, `japanese`, `roc`, and `iso8601` are the five
|
|
114
|
+
* whose months are the Gregorian months. Absent is the locale's own where
|
|
115
|
+
* it is one of the five, such as `buddhist` for `th-TH` or `japanese` for
|
|
116
|
+
* `ja-JP-u-ca-japanese`, and `gregory` for every other, such as `persian`
|
|
117
|
+
* for `fa-IR`.
|
|
118
|
+
*
|
|
119
|
+
* `persian`, `hebrew`, `islamic-umalqura`, `islamic-civil`, `ethiopic`,
|
|
120
|
+
* `coptic`, and `indian` draw a calendar with months of its own, as React
|
|
121
|
+
* Aria's calendars do: each grid is one of that calendar's months, the
|
|
122
|
+
* Hebrew leap month and Ethiopia's five-day thirteenth month included, and
|
|
123
|
+
* Previous, Next and the page keys move by those months. `month` and
|
|
124
|
+
* `helix-navigate` then name a month by its first day, `YYYY-MM-DD`. The
|
|
125
|
+
* heading stays text, as the months and years views are drawn in Gregorian
|
|
126
|
+
* months only. The value is `YYYY-MM-DD` in every calendar.
|
|
117
127
|
*/
|
|
118
|
-
calendar?: DateCalendar;
|
|
128
|
+
calendar?: DateCalendar | MonthCalendar;
|
|
119
129
|
/**
|
|
120
130
|
* What each day shows, in place of its number: a function given the date as
|
|
121
131
|
* `YYYY-MM-DD` that returns text, an element or a Lit template.
|
|
@@ -198,8 +208,9 @@ export declare class HelixHeadlessDatePicker extends HelixHeadlessDatePicker_bas
|
|
|
198
208
|
/** The month on show, whoever set it, and `undefined` until somebody has. */
|
|
199
209
|
private monthState;
|
|
200
210
|
/**
|
|
201
|
-
* The month shown, as `YYYY-MM
|
|
202
|
-
*
|
|
211
|
+
* The month shown, as `YYYY-MM`, or as its first day, `YYYY-MM-DD`, under a
|
|
212
|
+
* `calendar` with months of its own. When it is not set, it follows
|
|
213
|
+
* `value`, then the current month.
|
|
203
214
|
*
|
|
204
215
|
* Separate from `value` on purpose, so paging selects nothing and a consumer
|
|
205
216
|
* can drive the view. Reading gives the month on show; writing sets it, and
|
|
@@ -258,6 +269,8 @@ export declare class HelixHeadlessDatePicker extends HelixHeadlessDatePicker_bas
|
|
|
258
269
|
private focused;
|
|
259
270
|
/** The selected dates, in order. */
|
|
260
271
|
private get selected();
|
|
272
|
+
/** The days of the weekend, `0` for Sunday: the locale's, or Saturday and Sunday where none is named. */
|
|
273
|
+
private get weekend();
|
|
261
274
|
/** The day the week starts on: `firstDayOfWeek`, or the locale's. */
|
|
262
275
|
private get weekStart();
|
|
263
276
|
/**
|
|
@@ -274,6 +287,13 @@ export declare class HelixHeadlessDatePicker extends HelixHeadlessDatePicker_bas
|
|
|
274
287
|
private isSelected;
|
|
275
288
|
/** The month being shown, resolved from `month`, then `value`, then today. */
|
|
276
289
|
private get shown();
|
|
290
|
+
/**
|
|
291
|
+
* The months the calendar pages through: its own under a `calendar` with
|
|
292
|
+
* months of its own, and the Gregorian months otherwise.
|
|
293
|
+
*/
|
|
294
|
+
private get system();
|
|
295
|
+
/** Whether `calendar` names a calendar with months of its own. */
|
|
296
|
+
private get ownMonths();
|
|
277
297
|
/**
|
|
278
298
|
* The month to open on when nothing has declared one.
|
|
279
299
|
*
|
|
@@ -432,6 +452,16 @@ export declare class HelixHeadlessDatePicker extends HelixHeadlessDatePicker_bas
|
|
|
432
452
|
* The validation message for a date that `step` skips.
|
|
433
453
|
*/
|
|
434
454
|
stepMismatchMessage: string;
|
|
455
|
+
/**
|
|
456
|
+
* The time zone today is read in, such as `America/New_York`, as React
|
|
457
|
+
* Aria's `today(timeZone)` reads it. Empty is the reader's own.
|
|
458
|
+
*
|
|
459
|
+
* Dates are plain `YYYY-MM-DD` and carry no zone, so this moves only today:
|
|
460
|
+
* the day marked `aria-current` and `day-today`, and the month a picker
|
|
461
|
+
* with no value opens on. A desk in Tokyo booking for an office in New York
|
|
462
|
+
* sets `America/New_York`, and today is the office's.
|
|
463
|
+
*/
|
|
464
|
+
timeZone: string;
|
|
435
465
|
/**
|
|
436
466
|
* The validation message for a date that `disable-dates` or `disable-days`
|
|
437
467
|
* bars.
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { addDays, addMonths, valueAsDate as asDate, barredBy, calendarLocale, customElement, formatWords, dateAsValue as fromDate, HelixFormElement, HelixNavigateEvent, handedLocale, hostAria, inlineStep, commaList as list,
|
|
7
|
+
import { addDays, addMonths, valueAsDate as asDate, barredBy, calendarLocale, customElement, formatWords, dateAsValue as fromDate, HelixFormElement, HelixNavigateEvent, handedLocale, hostAria, inlineStep, commaList as list, MixinControllerValue, MixinPickerFeedback, MONTH_CALENDARS, monthOf, monthOut, monthSystem, periodCells, periodKey, reportValues, requestChange, todayIn, weekendOf, weekStartOf, words, wordsLocale, YEARS_SHOWN, yearOut, yearPageOf, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { caretLeft, caretRight } from '@fusion.dev/helix-icons';
|
|
9
9
|
import { html, nothing } from 'lit';
|
|
10
10
|
import { property, state } from 'lit/decorators.js';
|
|
@@ -46,7 +46,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
46
46
|
this.focused = '';
|
|
47
47
|
this.choosing = false;
|
|
48
48
|
this.handleKeydown = (event) => {
|
|
49
|
-
if (this.view !== 'day') {
|
|
49
|
+
if (this.view !== 'day' && !this.ownMonths) {
|
|
50
50
|
this.handlePeriodKeydown(event);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -80,7 +80,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
82
|
const step = event.key === 'PageUp' ? -1 : 1;
|
|
83
|
-
this.moveTo(
|
|
83
|
+
this.moveTo(this.system.add(from, event.shiftKey ? step * 12 : step));
|
|
84
84
|
}
|
|
85
85
|
event.preventDefault();
|
|
86
86
|
};
|
|
@@ -105,6 +105,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
105
105
|
this.required = false;
|
|
106
106
|
this.step = 1;
|
|
107
107
|
this.stepMismatchMessage = 'Choose one of the dates the calendar offers.';
|
|
108
|
+
this.timeZone = '';
|
|
108
109
|
this.unavailableMessage = 'Choose a date that is available.';
|
|
109
110
|
this.valueMissingMessage = 'Choose a date.';
|
|
110
111
|
this.view = 'day';
|
|
@@ -115,7 +116,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
115
116
|
return wordsLocale(this);
|
|
116
117
|
}
|
|
117
118
|
get month() {
|
|
118
|
-
return this.monthState ?? (this.defaultMonth ||
|
|
119
|
+
return this.monthState ?? (this.defaultMonth || this.system.key(this.derivedMonth));
|
|
119
120
|
}
|
|
120
121
|
set month(next) {
|
|
121
122
|
const previous = this.month;
|
|
@@ -125,6 +126,9 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
125
126
|
get selected() {
|
|
126
127
|
return list(this.value);
|
|
127
128
|
}
|
|
129
|
+
get weekend() {
|
|
130
|
+
return handedLocale(this) === '' ? [0, 6] : weekendOf(this.language);
|
|
131
|
+
}
|
|
128
132
|
get weekStart() {
|
|
129
133
|
if (this.firstDayOfWeek !== undefined && Number.isFinite(this.firstDayOfWeek)) {
|
|
130
134
|
return ((Math.floor(this.firstDayOfWeek) % 7) + 7) % 7;
|
|
@@ -147,24 +151,31 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
147
151
|
return this.selected.includes(iso);
|
|
148
152
|
}
|
|
149
153
|
get shown() {
|
|
150
|
-
const explicit = /^(\d{4})-(\d{2})
|
|
154
|
+
const explicit = /^(\d{4})-(\d{2})(?:-(\d{2}))?$/.exec(this.monthState ?? this.defaultMonth);
|
|
151
155
|
if (explicit) {
|
|
152
|
-
|
|
156
|
+
const first = firstOf(Number(explicit[1]), Number(explicit[2]) - 1);
|
|
157
|
+
return this.system.start(explicit[3] ? addDays(first, Number(explicit[3]) - 1) : first);
|
|
153
158
|
}
|
|
154
159
|
return this.derivedMonth;
|
|
155
160
|
}
|
|
161
|
+
get system() {
|
|
162
|
+
return monthSystem(this.calendar);
|
|
163
|
+
}
|
|
164
|
+
get ownMonths() {
|
|
165
|
+
return MONTH_CALENDARS.includes(this.calendar ?? '');
|
|
166
|
+
}
|
|
156
167
|
get derivedMonth() {
|
|
157
|
-
const from = asDate(this.selected[0] ?? '') ?? asDate(
|
|
158
|
-
return
|
|
168
|
+
const from = asDate(this.selected[0] ?? '') ?? asDate(todayIn(this.timeZone)) ?? new Date();
|
|
169
|
+
return this.system.start(from);
|
|
159
170
|
}
|
|
160
171
|
get anchor() {
|
|
161
172
|
const shown = this.shown;
|
|
162
173
|
for (const candidate of [
|
|
163
174
|
asDate(this.focused),
|
|
164
175
|
asDate(this.selected[0] ?? ''),
|
|
165
|
-
asDate(
|
|
176
|
+
asDate(todayIn(this.timeZone)),
|
|
166
177
|
]) {
|
|
167
|
-
if (candidate &&
|
|
178
|
+
if (candidate && this.system.same(candidate, shown)) {
|
|
168
179
|
return candidate;
|
|
169
180
|
}
|
|
170
181
|
}
|
|
@@ -198,17 +209,17 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
198
209
|
return date;
|
|
199
210
|
}
|
|
200
211
|
get atStart() {
|
|
201
|
-
return asDate(this.min) !== null &&
|
|
212
|
+
return asDate(this.min) !== null && fromDate(addDays(this.shown, -1)) < this.min;
|
|
202
213
|
}
|
|
203
214
|
get atEnd() {
|
|
204
215
|
return (asDate(this.max) !== null &&
|
|
205
|
-
|
|
216
|
+
fromDate(this.system.start(this.system.add(this.shown, this.monthCount))) > this.max);
|
|
206
217
|
}
|
|
207
218
|
show(date) {
|
|
208
219
|
if (this.isDisabled) {
|
|
209
220
|
return;
|
|
210
221
|
}
|
|
211
|
-
const next =
|
|
222
|
+
const next = this.system.key(date);
|
|
212
223
|
if (next === this.month) {
|
|
213
224
|
return;
|
|
214
225
|
}
|
|
@@ -437,7 +448,9 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
437
448
|
return Math.max(1, Math.floor(this.months) || 1);
|
|
438
449
|
}
|
|
439
450
|
get formats() {
|
|
440
|
-
const language =
|
|
451
|
+
const language = this.ownMonths
|
|
452
|
+
? `${new Intl.Locale(this.language || new Intl.DateTimeFormat().resolvedOptions().locale, { calendar: this.calendar ?? 'gregory' })}`
|
|
453
|
+
: calendarLocale(this.language, this.calendar);
|
|
441
454
|
if (this.cachedFormats?.locale === language) {
|
|
442
455
|
return this.cachedFormats;
|
|
443
456
|
}
|
|
@@ -450,6 +463,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
450
463
|
monthName: utc({ month: 'short' }),
|
|
451
464
|
monthYear: utc({ month: 'short', year: 'numeric' }),
|
|
452
465
|
weekday: utc({ weekday: 'short' }),
|
|
466
|
+
weekdayName: utc({ weekday: 'long' }),
|
|
453
467
|
year: utc({ year: 'numeric' }),
|
|
454
468
|
};
|
|
455
469
|
this.cachedFormats = built;
|
|
@@ -470,12 +484,13 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
470
484
|
</slot>`;
|
|
471
485
|
}
|
|
472
486
|
renderMonth(month, index) {
|
|
473
|
-
const { full, heading: named, weekday } = this.formats;
|
|
487
|
+
const { full, heading: named, weekday, weekdayName } = this.formats;
|
|
474
488
|
const heading = named.format(month);
|
|
475
489
|
const weeks = this.weeksOf(month);
|
|
476
490
|
const anchor = fromDate(this.anchor);
|
|
477
|
-
const today =
|
|
491
|
+
const today = todayIn(this.timeZone);
|
|
478
492
|
const range = this.range;
|
|
493
|
+
const weekend = this.weekend;
|
|
479
494
|
const first = index === 0;
|
|
480
495
|
const last = index === this.monthCount - 1;
|
|
481
496
|
return html `<div part="month">
|
|
@@ -486,7 +501,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
486
501
|
type="button"
|
|
487
502
|
aria-label=${this.previousLabel}
|
|
488
503
|
?disabled=${this.isDisabled || this.atStart}
|
|
489
|
-
@click=${() => this.show(
|
|
504
|
+
@click=${() => this.show(this.system.add(this.shown, -1))}
|
|
490
505
|
>
|
|
491
506
|
${this.renderPreviousMark()}
|
|
492
507
|
</button>`
|
|
@@ -501,7 +516,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
501
516
|
type="button"
|
|
502
517
|
aria-label=${this.nextLabel}
|
|
503
518
|
?disabled=${this.isDisabled || this.atEnd}
|
|
504
|
-
@click=${() => this.show(
|
|
519
|
+
@click=${() => this.show(this.system.add(this.shown, 1))}
|
|
505
520
|
>
|
|
506
521
|
${this.renderNextMark()}
|
|
507
522
|
</button>`
|
|
@@ -515,14 +530,16 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
515
530
|
data-unset=${this.value === '' ? '' : nothing}
|
|
516
531
|
>
|
|
517
532
|
<div part="week" role="row">
|
|
518
|
-
${weeks[0]?.map((date) => html `<span part="weekday" role="columnheader"
|
|
533
|
+
${weeks[0]?.map((date) => html `<span part="weekday" role="columnheader" aria-label=${weekdayName.format(date)}
|
|
534
|
+
>${weekday.format(date)}</span
|
|
535
|
+
>`)}
|
|
519
536
|
</div>
|
|
520
537
|
${weeks.map((week) => html `<div part="week" role="row">
|
|
521
538
|
${week.map((date) => {
|
|
522
539
|
const iso = fromDate(date);
|
|
523
540
|
const disabled = this.barred(date);
|
|
524
541
|
const selected = this.isSelected(iso);
|
|
525
|
-
const outside = !
|
|
542
|
+
const outside = !this.system.same(date, month);
|
|
526
543
|
const start = !outside && range !== null && iso === range[0];
|
|
527
544
|
const end = !outside && range !== null && iso === range[1];
|
|
528
545
|
const middle = !outside && range !== null && iso > range[0] && iso < range[1];
|
|
@@ -538,10 +555,11 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
538
555
|
data-range-middle=${middle ? '' : nothing}
|
|
539
556
|
data-range-start=${start ? '' : nothing}
|
|
540
557
|
data-today=${iso === today ? '' : nothing}
|
|
558
|
+
data-weekend=${weekend.includes(date.getUTCDay()) ? '' : nothing}
|
|
541
559
|
tabindex=${!outside && iso === anchor && !this.isDisabled ? '0' : '-1'}
|
|
542
560
|
@click=${outside ? nothing : () => this.select(date)}
|
|
543
561
|
><span
|
|
544
|
-
part="day${!outside && selected && !middle ? ' day-selected' : ''}${iso === today ? ' day-today' : ''}${outside ? ' day-outside' : ''}${disabled ? ' day-disabled' : ''}"
|
|
562
|
+
part="day${!outside && selected && !middle ? ' day-selected' : ''}${iso === today ? ' day-today' : ''}${outside ? ' day-outside' : ''}${disabled ? ' day-disabled' : ''}${weekend.includes(date.getUTCDay()) ? ' day-weekend' : ''}"
|
|
545
563
|
>${this.renderDay(date, outside)}</span
|
|
546
564
|
></span
|
|
547
565
|
>`;
|
|
@@ -551,10 +569,11 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
551
569
|
</div>`;
|
|
552
570
|
}
|
|
553
571
|
renderDay(date, outside) {
|
|
554
|
-
return this.dayContent && !outside ? this.dayContent(fromDate(date)) :
|
|
572
|
+
return this.dayContent && !outside ? this.dayContent(fromDate(date)) : this.system.day(date);
|
|
555
573
|
}
|
|
556
574
|
renderHeadingText(text, label) {
|
|
557
575
|
const steps = this.maxView !== undefined &&
|
|
576
|
+
!this.ownMonths &&
|
|
558
577
|
(this.view === 'day' || (this.view === 'month' && this.maxView === 'year'));
|
|
559
578
|
if (!steps) {
|
|
560
579
|
return text;
|
|
@@ -580,7 +599,7 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
580
599
|
min: this.min,
|
|
581
600
|
page: this.periodYear,
|
|
582
601
|
shown: this.shown,
|
|
583
|
-
today:
|
|
602
|
+
today: todayIn(this.timeZone),
|
|
584
603
|
view: years ? 'year' : 'month',
|
|
585
604
|
}).map(({ at, chosen, current, first, out }) => {
|
|
586
605
|
const words = years ? yearName.format(first) : monthName.format(first);
|
|
@@ -625,17 +644,18 @@ let HelixHeadlessDatePicker = class HelixHeadlessDatePicker extends MixinPickerF
|
|
|
625
644
|
</div>`;
|
|
626
645
|
}
|
|
627
646
|
render() {
|
|
628
|
-
if (this.view !== 'day') {
|
|
629
|
-
return html `<
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
${this.renderPickerFeedback()}`;
|
|
647
|
+
if (this.view !== 'day' && !this.ownMonths) {
|
|
648
|
+
return html `<slot name="header"></slot>
|
|
649
|
+
<div part="months" style="--date-picker-column-count: 1">${this.renderPeriods()}</div>
|
|
650
|
+
<slot name="footer"></slot>${this.renderPickerFeedback()}`;
|
|
633
651
|
}
|
|
634
652
|
const shown = this.shown;
|
|
635
653
|
const count = this.monthCount;
|
|
636
|
-
return html `<
|
|
637
|
-
|
|
638
|
-
|
|
654
|
+
return html `<slot name="header"></slot>
|
|
655
|
+
<div part="months" style="--date-picker-column-count: ${Math.min(count, 2)}">
|
|
656
|
+
${Array.from({ length: count }, (_, index) => this.renderMonth(this.system.add(shown, index), index))}
|
|
657
|
+
</div>
|
|
658
|
+
<slot name="footer"></slot>${this.renderPickerFeedback()}`;
|
|
639
659
|
}
|
|
640
660
|
get valueAsDate() {
|
|
641
661
|
return asDate(this.value);
|
|
@@ -758,6 +778,9 @@ __decorate([
|
|
|
758
778
|
words,
|
|
759
779
|
property({ attribute: 'step-mismatch-message' })
|
|
760
780
|
], HelixHeadlessDatePicker.prototype, "stepMismatchMessage", void 0);
|
|
781
|
+
__decorate([
|
|
782
|
+
property({ attribute: 'time-zone' })
|
|
783
|
+
], HelixHeadlessDatePicker.prototype, "timeZone", void 0);
|
|
761
784
|
__decorate([
|
|
762
785
|
words,
|
|
763
786
|
property({ attribute: 'unavailable-message' })
|
|
@@ -6,6 +6,7 @@ registerElementEvents({
|
|
|
6
6
|
'helix-headless-area-chart': ['helix-reading-change', 'helix-reading-press'],
|
|
7
7
|
'helix-headless-avatar': ['error', 'load'],
|
|
8
8
|
'helix-headless-bar-chart': ['helix-reading-change', 'helix-reading-press'],
|
|
9
|
+
'helix-headless-breadcrumb': ['helix-select'],
|
|
9
10
|
'helix-headless-button': ['helix-press'],
|
|
10
11
|
'helix-headless-button-group': ['change', 'helix-before-change'],
|
|
11
12
|
'helix-headless-callout': ['helix-dismiss'],
|
|
@@ -241,7 +242,7 @@ registerElementEvents({
|
|
|
241
242
|
'helix-headless-step': ['helix-select'],
|
|
242
243
|
'helix-headless-steps': ['helix-activate', 'helix-before-activate', 'helix-select'],
|
|
243
244
|
'helix-headless-switch': ['change', 'helix-before-toggle', 'input'],
|
|
244
|
-
'helix-headless-tab': ['helix-select'],
|
|
245
|
+
'helix-headless-tab': ['helix-dismiss', 'helix-select'],
|
|
245
246
|
'helix-headless-table': [
|
|
246
247
|
'helix-before-reorder',
|
|
247
248
|
'helix-reorder',
|
|
@@ -36,6 +36,15 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
36
36
|
* links and not a single control, and the keys across the other axis are
|
|
37
37
|
* left to the page and to an open panel.
|
|
38
38
|
*
|
|
39
|
+
* While a `Megamenu`, or another disclosure among the destinations, is open,
|
|
40
|
+
* the navigation is `:state(open)`, so a page can dim what lies under the
|
|
41
|
+
* panel, as Radix's navigation menu marks its open state.
|
|
42
|
+
*
|
|
43
|
+
* A screen reader lists the page's navigation landmarks by name, so two named
|
|
44
|
+
* alike cannot be told apart. Where another navigation in the same document
|
|
45
|
+
* has the same name, "Main" for two with no `label`, the later one warns once
|
|
46
|
+
* with the kind `duplicate-name`.
|
|
47
|
+
*
|
|
39
48
|
* @since 0.1.0
|
|
40
49
|
* @status stable
|
|
41
50
|
* @category navigation
|
|
@@ -47,6 +56,8 @@ import { type PropertyValues, type TemplateResult } from 'lit';
|
|
|
47
56
|
*
|
|
48
57
|
* @csspart indicator - The marker that moves to the current destination. It carries the destination's place and size as `--indicator-x`, `--indicator-y`, `--indicator-inline-size` and `--indicator-block-size`, and `data-placed` once it has been placed.
|
|
49
58
|
* @csspart nav - The navigation landmark.
|
|
59
|
+
*
|
|
60
|
+
* @cssstate open - While a megamenu or another disclosure among the destinations is open.
|
|
50
61
|
*/
|
|
51
62
|
export declare class HelixHeadlessNavigation extends HelixElement {
|
|
52
63
|
/**
|
|
@@ -80,6 +91,21 @@ export declare class HelixHeadlessNavigation extends HelixElement {
|
|
|
80
91
|
*/
|
|
81
92
|
orientation?: 'vertical';
|
|
82
93
|
private current;
|
|
94
|
+
/** The disclosures among the destinations that are open. */
|
|
95
|
+
private readonly opened;
|
|
96
|
+
/**
|
|
97
|
+
* Hears a disclosure among the destinations open or close. In capture,
|
|
98
|
+
* because `toggle` does not bubble.
|
|
99
|
+
*/
|
|
100
|
+
private readonly handleToggle;
|
|
101
|
+
/** The landmark's name as a screen reader lists it. */
|
|
102
|
+
private get landmarkName();
|
|
103
|
+
/**
|
|
104
|
+
* Warns once where another navigation in the same document has the same
|
|
105
|
+
* name, a task after the first render, so the page's other landmarks have
|
|
106
|
+
* rendered too.
|
|
107
|
+
*/
|
|
108
|
+
private auditTwin;
|
|
83
109
|
/**
|
|
84
110
|
* The destinations the consumer slotted, and the items of a slotted list in
|
|
85
111
|
* place of the list.
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { AriaForwardController, customElement, focusableElements, focusItemOf, HelixElement, IndicatorController, KeyboardNavigationController, words, } from '@fusion.dev/helix-core';
|
|
7
|
+
import { AriaForwardController, customElement, focusableElements, focusItemOf, HelixElement, IndicatorController, KeyboardNavigationController, reportRuntime, words, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
10
|
const FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
@@ -23,6 +23,8 @@ const navigable = (item) => {
|
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
+
const connected = new Set();
|
|
27
|
+
const warned = new WeakSet();
|
|
26
28
|
let HelixHeadlessNavigation = class HelixHeadlessNavigation extends HelixElement {
|
|
27
29
|
constructor() {
|
|
28
30
|
super(...arguments);
|
|
@@ -53,8 +55,56 @@ let HelixHeadlessNavigation = class HelixHeadlessNavigation extends HelixElement
|
|
|
53
55
|
label: true,
|
|
54
56
|
target: () => this.partNamed('nav'),
|
|
55
57
|
});
|
|
58
|
+
this.opened = new Set();
|
|
59
|
+
this.handleToggle = (event) => {
|
|
60
|
+
const target = event.target;
|
|
61
|
+
if (target === this || target === null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (event.newState === 'open') {
|
|
65
|
+
this.opened.add(target);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.opened.delete(target);
|
|
69
|
+
}
|
|
70
|
+
this.toggleState('open', this.opened.size > 0);
|
|
71
|
+
};
|
|
56
72
|
}
|
|
57
73
|
static { this.words = 'helix-navigation'; }
|
|
74
|
+
get landmarkName() {
|
|
75
|
+
const labeled = this.getAttribute('aria-labelledby');
|
|
76
|
+
if (labeled) {
|
|
77
|
+
const root = this.getRootNode();
|
|
78
|
+
return labeled
|
|
79
|
+
.split(/\s+/)
|
|
80
|
+
.map((id) => root.getElementById?.(id)?.textContent?.trim() ?? '')
|
|
81
|
+
.join(' ')
|
|
82
|
+
.trim();
|
|
83
|
+
}
|
|
84
|
+
return (this.getAttribute('aria-label') ?? this.label).trim();
|
|
85
|
+
}
|
|
86
|
+
auditTwin() {
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
if (!this.isConnected || warned.has(this)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const name = this.landmarkName;
|
|
92
|
+
const root = this.getRootNode();
|
|
93
|
+
const twin = [...connected].some((other) => other !== this &&
|
|
94
|
+
other.isConnected &&
|
|
95
|
+
(other.compareDocumentPosition(this) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 &&
|
|
96
|
+
other.getRootNode() === root &&
|
|
97
|
+
other.landmarkName === name);
|
|
98
|
+
if (twin) {
|
|
99
|
+
warned.add(this);
|
|
100
|
+
reportRuntime({
|
|
101
|
+
kind: 'duplicate-name',
|
|
102
|
+
message: `<${this.localName}> has the name "${name}", which another navigation on the page has too, so a screen reader lists the two alike. Give each a \`label\` that says what it holds, such as "Footer".`,
|
|
103
|
+
tag: this.localName,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
58
108
|
get items() {
|
|
59
109
|
const slot = this.renderRoot.querySelector('slot:not([name])');
|
|
60
110
|
return (slot?.assignedElements() ?? []).flatMap((one) => isList(one) ? [...one.children] : [one]);
|
|
@@ -69,17 +119,24 @@ let HelixHeadlessNavigation = class HelixHeadlessNavigation extends HelixElement
|
|
|
69
119
|
}
|
|
70
120
|
connectedCallback() {
|
|
71
121
|
super.connectedCallback();
|
|
122
|
+
connected.add(this);
|
|
123
|
+
this.addEventListener('toggle', this.handleToggle, true);
|
|
72
124
|
if (this.hasUpdated) {
|
|
73
125
|
this.watch();
|
|
74
126
|
}
|
|
75
127
|
}
|
|
76
128
|
disconnectedCallback() {
|
|
77
129
|
super.disconnectedCallback();
|
|
130
|
+
connected.delete(this);
|
|
131
|
+
this.removeEventListener('toggle', this.handleToggle, true);
|
|
132
|
+
this.opened.clear();
|
|
133
|
+
this.toggleState('open', false);
|
|
78
134
|
this.current?.disconnect();
|
|
79
135
|
}
|
|
80
136
|
firstUpdated(changed) {
|
|
81
137
|
super.firstUpdated(changed);
|
|
82
138
|
this.watch();
|
|
139
|
+
this.auditTwin();
|
|
83
140
|
}
|
|
84
141
|
render() {
|
|
85
142
|
return html `<nav part="nav" aria-label=${this.label}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AriaForwardController, HelixFormElement, PopoverController } from '@fusion.dev/helix-core';
|
|
1
|
+
import { AriaForwardController, type DataOptionItem, HelixFormElement, PopoverController } from '@fusion.dev/helix-core';
|
|
2
2
|
import { type PropertyValues, type TemplateResult } from 'lit';
|
|
3
3
|
import { type HelixHeadlessOption } from '../../option/root/option-root.js';
|
|
4
4
|
import '../../listbox/index.js';
|
|
@@ -13,7 +13,10 @@ declare const HelixHeadlessSelect_base: (new (...args: any[]) => import("@fusion
|
|
|
13
13
|
* place for focus to return to when the list closes.
|
|
14
14
|
*
|
|
15
15
|
* Your options stay in your light DOM and are slotted through into the listbox,
|
|
16
|
-
* so the listbox looks through slots to find them.
|
|
16
|
+
* so the listbox looks through slots to find them. For a list too long to draw
|
|
17
|
+
* whole, set `items` instead: the list draws only the options in sight, as
|
|
18
|
+
* Listbox's `items` does, and the trigger, its keys and the form read the
|
|
19
|
+
* whole set.
|
|
17
20
|
*
|
|
18
21
|
* `Select` owns the value, passes it down to the listbox, and takes changes
|
|
19
22
|
* back, so the value lives in one place.
|
|
@@ -102,6 +105,8 @@ declare const HelixHeadlessSelect_base: (new (...args: any[]) => import("@fusion
|
|
|
102
105
|
*
|
|
103
106
|
* @cssstate invalid - The control has an error to show, from the browser's validation or from your `feedback`.
|
|
104
107
|
* @cssstate open - While the list is open.
|
|
108
|
+
* @cssstate placed-bottom - While the open list sits below the trigger.
|
|
109
|
+
* @cssstate placed-top - While the open list sits above the trigger, where there was no room below.
|
|
105
110
|
*/
|
|
106
111
|
export declare class HelixHeadlessSelect extends HelixHeadlessSelect_base {
|
|
107
112
|
/**
|
|
@@ -145,6 +150,20 @@ export declare class HelixHeadlessSelect extends HelixHeadlessSelect_base {
|
|
|
145
150
|
* anything a consumer sets.
|
|
146
151
|
*/
|
|
147
152
|
focusable: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* The options as data, for a list too long to draw whole: each a value,
|
|
155
|
+
* which is also its words, or a record with a `value`, a `label` and
|
|
156
|
+
* `disabled`. Passed to the list, which draws only the options in sight,
|
|
157
|
+
* as Listbox's `items` does. Set, the options you write as children are
|
|
158
|
+
* not read.
|
|
159
|
+
*
|
|
160
|
+
* The trigger shows the chosen options' labels, the letters and the Left
|
|
161
|
+
* and Right keys on the closed trigger choose over the whole set, and a
|
|
162
|
+
* chosen value whose option leaves `items` drops out of `value`.
|
|
163
|
+
* `value-content` is not called for `items`. Import the Option family as
|
|
164
|
+
* well, whose elements are drawn.
|
|
165
|
+
*/
|
|
166
|
+
items: readonly DataOptionItem[] | undefined;
|
|
148
167
|
/**
|
|
149
168
|
* The open list's name where nothing names the Select, read by screen
|
|
150
169
|
* readers. The list has no visible name.
|
|
@@ -270,8 +289,15 @@ export declare class HelixHeadlessSelect extends HelixHeadlessSelect_base {
|
|
|
270
289
|
* the commit creates the text node it needs.
|
|
271
290
|
*/
|
|
272
291
|
private get display();
|
|
273
|
-
/** The chosen options, in the order they appear. None on a server or while hydrating
|
|
292
|
+
/** The chosen options, in the order they appear. None on a server or while hydrating, and none for `items`. */
|
|
274
293
|
private get chosenOptions();
|
|
294
|
+
/** `items` as the list reads them, built once per array. */
|
|
295
|
+
private data;
|
|
296
|
+
/**
|
|
297
|
+
* Every option the select reads, in order: the records of `items`, or the
|
|
298
|
+
* option elements among its children.
|
|
299
|
+
*/
|
|
300
|
+
private get entries();
|
|
275
301
|
/**
|
|
276
302
|
* What the trigger shows, behind a seam: what `value-content` draws for the
|
|
277
303
|
* chosen options, or their words, or the placeholder.
|