@nexub/elements 11.8.0 → 11.9.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type ValidityKind = 'valueMissing' | 'rangeUnderflow' | 'rangeOverflow' | 'badInput';
1
+ type ValidityKind = 'valueMissing' | 'rangeUnderflow' | 'rangeOverflow' | 'badInput' | 'typeMismatch';
2
2
 
3
3
  /** `HTMLElement`, or a stand-in where there is none (a server importing the classes), so the import doesn't throw. */
4
4
  declare const Base: typeof HTMLElement;
@@ -27,7 +27,7 @@ declare abstract class NxFieldElement extends Base {
27
27
  /** @internal */
28
28
  protected readonly root: ShadowRoot;
29
29
  /** @internal The focusable control: the validation anchor, named from the label. */
30
- protected abstract readonly control: HTMLInputElement;
30
+ protected abstract readonly control: HTMLInputElement | HTMLButtonElement;
31
31
  /** @internal The bordered box around the control. */
32
32
  protected readonly box: HTMLDivElement;
33
33
  static get observedAttributes(): string[];
@@ -54,6 +54,9 @@ declare abstract class NxFieldElement extends Base {
54
54
  set disabled(v: boolean);
55
55
  get readOnly(): boolean;
56
56
  set readOnly(v: boolean);
57
+ /** Shows the field as invalid (`aria-invalid`, the error border) whatever its validity, as `@nexub/react`'s `invalid`. */
58
+ get invalid(): boolean;
59
+ set invalid(v: boolean);
57
60
  /** `sm`, `md` (default) or `lg`. */
58
61
  get size(): NxFieldSize;
59
62
  set size(v: NxFieldSize);
@@ -70,6 +73,10 @@ declare abstract class NxFieldElement extends Base {
70
73
  formResetCallback(): void;
71
74
  formDisabledCallback(disabled: boolean): void;
72
75
  formStateRestoreCallback(state: File | string | FormData | null): void;
76
+ /** @internal The value the field starts with and resets to: the `value` attribute. */
77
+ protected initial(): string;
78
+ /** @internal A property set on the element before its class was defined goes through the setter. */
79
+ protected upgrade(...names: string[]): void;
73
80
  /** @internal Clears typing state on reset. */
74
81
  protected reset(): void;
75
82
  /** @internal Runs `sanitize` again after an attribute it reads changed (the default when untouched). */
@@ -135,6 +142,9 @@ declare class NxNumberInput extends NxFieldElement {
135
142
  protected update(): void;
136
143
  }
137
144
 
145
+ /** ISO 3166-1 alpha-2 code, upper case ("IN"). */
146
+ type CountryCode = string;
147
+
138
148
  /**
139
149
  * Date values as strings, shared by `@nexub/react`'s DatePicker (`granularity="month" | "year"`)
140
150
  * and `@nexub/elements`' `<nx-date-picker>`. A value is `YYYY-MM-DD` (day), `YYYY-MM` (month) or
@@ -196,7 +206,256 @@ declare class NxDatePicker extends NxFieldElement {
196
206
  protected check(): FieldError;
197
207
  /** @internal */
198
208
  protected update(): void;
209
+ /** @internal */
210
+ protected nameControl(): void;
211
+ }
212
+
213
+ /** One choice in `<nx-select>` or `<nx-combobox>`: the shape of `@nexub/react`'s `ComboboxOption`. */
214
+ interface NxOption {
215
+ value: string;
216
+ label: string;
217
+ /** A second line under the label (an email, a code). Also searched. */
218
+ description?: string;
219
+ /** More text the option is found by (type-ahead and filtering). */
220
+ keywords?: string[];
221
+ disabled?: boolean;
222
+ /** A heading the option is listed under; consecutive options with the same group share it. */
223
+ group?: string;
224
+ }
225
+ /**
226
+ * The popup listbox of the three list fields. Focus never moves into it: the field keeps focus
227
+ * and points at the active option with `aria-activedescendant` (WAI-ARIA combobox pattern).
228
+ * The popup is a `popover="manual"` (the top layer) where the browser has it, placed under the
229
+ * field (above it without room), and a bottom sheet below 48rem.
230
+ *
231
+ * @internal
232
+ */
233
+ declare class ListPopup {
234
+ #private;
235
+ readonly host: HTMLElement;
236
+ readonly anchor: HTMLElement;
237
+ readonly control: HTMLElement;
238
+ readonly pick: (option: NxOption) => void;
239
+ /** Draws the options; runs before the popup opens. */
240
+ readonly refresh: () => void;
241
+ readonly popup: HTMLDivElement;
242
+ readonly status: HTMLDivElement;
243
+ readonly list: HTMLDivElement;
244
+ options: NxOption[];
245
+ /** The highlighted option's index, `-1` for none. */
246
+ active: number;
247
+ constructor(host: HTMLElement, anchor: HTMLElement, control: HTMLElement, pick: (option: NxOption) => void,
248
+ /** Draws the options; runs before the popup opens. */
249
+ refresh: () => void);
250
+ get open(): boolean;
251
+ /** Draws `options`; `selected` (the field's value) is `aria-selected` with a check. */
252
+ render(options: NxOption[], selected: string, label: string): void;
253
+ /** Highlights option `i` (`-1`: none) and scrolls it into view. */
254
+ setActive(i: number, scroll?: boolean): void;
255
+ /** The enabled option `count` steps from `from` in `dir`, stopping at the ends. */
256
+ step(from: number, dir: 1 | -1, count?: number): number;
257
+ first(): number;
258
+ last(): number;
259
+ indexOf(value: string): number;
260
+ show(): void;
261
+ hide(): void;
262
+ /** Under the field, the field's width (above it without room below); the sheet layout ignores this. */
263
+ place: () => void;
264
+ /** `true` while a type-ahead search is running (a space then adds to it). */
265
+ get typing(): boolean;
266
+ /**
267
+ * Type-ahead: the next enabled option whose label (or a keyword) starts with the keys typed in
268
+ * the last half second; one key pressed again cycles through the options starting with it.
269
+ * `-1` when none matches.
270
+ */
271
+ typeahead(key: string): number;
272
+ /**
273
+ * The select-only combobox keys (WAI-ARIA APG), for a button that opens this list. Closed:
274
+ * Arrow Down / Up, Enter, Space, Home, End open it; a printable key picks by type-ahead (as a
275
+ * native select). Open: arrows, Home / End, Page Up / Down (ten) and type-ahead move; Enter,
276
+ * Space and Alt+Arrow Up pick; Tab picks and moves on; Escape closes.
277
+ */
278
+ selectKey(e: KeyboardEvent): void;
279
+ }
280
+ /**
281
+ * What `<nx-select>` and `<nx-combobox>` share: options from child `<option>` / `<optgroup>`
282
+ * elements (watched for changes) or the `options` property, the placeholder, and the popup.
283
+ *
284
+ * @alpha
285
+ */
286
+ declare abstract class NxChoiceElement extends NxFieldElement {
287
+ #private;
288
+ static get observedAttributes(): string[];
289
+ /** @internal */
290
+ protected abstract readonly list: ListPopup;
291
+ /** The options: the `options` property when set, else the child `<option>` elements. */
292
+ get options(): NxOption[];
293
+ /** Replaces the child `<option>`s as the source; `null` goes back to them. */
294
+ set options(v: NxOption[] | null);
295
+ get placeholder(): string;
296
+ set placeholder(v: string);
297
+ /** `true` while the list is open. */
298
+ get open(): boolean;
299
+ /** Closes the list. */
300
+ close(): void;
301
+ connectedCallback(): void;
302
+ disconnectedCallback(): void;
303
+ /** @internal The `value` attribute, else the child `<option selected>`. */
304
+ protected initial(): string;
305
+ /** @internal The options changed: the value is checked against them again. */
306
+ protected optionsChanged(): void;
307
+ /** @internal Read-only or disabled: the list can't open and the value can't change. */
308
+ protected get locked(): boolean;
309
+ /** @internal The text the list is named by: the field's own name. */
310
+ protected get listLabel(): string;
311
+ }
312
+
313
+ /**
314
+ * `<nx-select>`: a form-associated single choice, the `@nexub/react` `Select`: a field-styled
315
+ * button (`role="combobox"`) that opens a listbox, the WAI-ARIA select-only combobox pattern.
316
+ * Options come from child `<option>` / `<optgroup>` elements (as in a native `<select>`) or the
317
+ * `options` property (`{ value, label, description?, disabled?, group? }[]`).
318
+ *
319
+ * Keyboard: closed, Arrow Down / Up, Enter, Space, Home and End open the list, and typing picks
320
+ * the option it starts (type-ahead, as a native select); open, arrows, Home / End and Page Up /
321
+ * Down move, typing jumps, Enter / Space pick, Escape closes, Tab picks and moves on.
322
+ *
323
+ * Attributes (reflected as properties): `name`, `value` (the default; else the child
324
+ * `<option selected>`), `placeholder`, `required`, `disabled`, `readonly`, `invalid`, `size`.
325
+ * A value that is none of the options is no value. Events: `input` and `change` when the user
326
+ * picks another option.
327
+ *
328
+ * @alpha
329
+ */
330
+ declare class NxSelect extends NxChoiceElement {
331
+ #private;
332
+ /** @internal */
333
+ protected readonly control: HTMLButtonElement;
334
+ /** @internal */
335
+ protected readonly list: ListPopup;
336
+ constructor();
337
+ /** The picked option, if any. */
338
+ get selectedOption(): NxOption | undefined;
339
+ /** Opens the list on the picked option (or the first). */
340
+ show(): void;
341
+ /** @internal Any of the option values; anything else is no value (kept while there are no options yet). */
342
+ protected sanitize(v: string): string;
343
+ /** @internal */
344
+ protected check(): FieldError;
345
+ /** @internal */
346
+ protected reset(): void;
347
+ /** @internal */
348
+ protected update(): void;
349
+ }
350
+
351
+ /** `<nx-combobox>`'s async search: the options for `query`; `signal` aborts when a newer search starts. */
352
+ type NxSearch = (query: string, signal: AbortSignal) => Promise<NxOption[]>;
353
+ /**
354
+ * `<nx-combobox>`: a form-associated editable combobox, the `@nexub/react` `ComboboxField`: a
355
+ * text field that filters a listbox as you type (WAI-ARIA combobox pattern, list autocomplete,
356
+ * `aria-activedescendant`). Options come from child `<option>` / `<optgroup>` elements or the
357
+ * `options` property, or from the server through `onsearch`.
358
+ *
359
+ * Without `allow-custom` the value is an option's value: text that names no option goes back
360
+ * to the picked option's label on blur (typing an option's label exactly picks it). With
361
+ * `allow-custom` the typed text is the value.
362
+ *
363
+ * Async search: set `onsearch` to `(query, signal) => Promise<options>`. It runs on every edit
364
+ * (debounce on your side) and when the list opens; only the latest search's answer is shown
365
+ * (older ones are dropped and their `signal` aborted). "Searching…", "No results found." and a
366
+ * failed search are announced in a live region.
367
+ *
368
+ * Keyboard: Arrow Down / Up open the list and move (Alt+Arrow Down opens without moving,
369
+ * Alt+Arrow Up closes), Enter picks (or, closed, submits the form), Escape closes, then clears.
370
+ *
371
+ * Attributes (reflected as properties): `name`, `value` (the default), `placeholder`,
372
+ * `allow-custom`, `required`, `disabled`, `readonly`, `invalid`, `size`. Events: `input` when
373
+ * the value changes, `change` when it was committed (a pick, blur, Enter).
374
+ *
375
+ * @alpha
376
+ */
377
+ declare class NxCombobox extends NxChoiceElement {
378
+ #private;
379
+ static get observedAttributes(): string[];
380
+ /** @internal */
381
+ protected readonly control: HTMLInputElement;
382
+ /** @internal */
383
+ protected readonly list: ListPopup;
384
+ constructor();
385
+ /** Free text: the typed text is the value when it names no option. */
386
+ get allowCustom(): boolean;
387
+ set allowCustom(v: boolean);
388
+ /** The async search (see the class docs); `null` filters the options here. */
389
+ get onsearch(): NxSearch | null;
390
+ set onsearch(fn: NxSearch | null);
391
+ /** The picked option, if it is known (an option, a search result or the last pick). */
392
+ get selectedOption(): NxOption | undefined;
393
+ /** Opens the list (and runs the search when there is none yet). */
394
+ show(): void;
395
+ attributeChangedCallback(name: string, old: string | null, next: string | null): void;
396
+ /** @internal Without free text or a search, a value that is none of the options is no value. */
397
+ protected sanitize(v: string): string;
398
+ /** @internal */
399
+ protected check(): FieldError;
400
+ /** @internal */
401
+ protected reset(): void;
402
+ /** @internal */
403
+ protected update(): void;
404
+ }
405
+
406
+ /**
407
+ * `<nx-phone-input>`: a form-associated phone field, the `@nexub/react` `PhoneInput`: a country
408
+ * picker (a select-only combobox listing every country, or the `countries` given) and the
409
+ * national number, grouped as you type, with the `@nexub/core` phone rules. A full
410
+ * international number (`+44 20…`, `0044…`) typed or pasted picks its country.
411
+ *
412
+ * The value (what the form posts) is E.164 (`+919847012345`), `''` when empty. A number with
413
+ * the wrong length for its country is `typeMismatch`; an international prefix left unfinished
414
+ * (`+4`) is `badInput`. Formatting and length checks only: confirm the number on the server.
415
+ *
416
+ * Attributes (reflected as properties): `name`, `value` (the default, E.164), `country` (the
417
+ * picked country; set it to change it), `default-country` (else the region of the nearest
418
+ * `lang`, else `US`), `countries` (a list, in this order; one shows as text), `locale` (country
419
+ * names), `placeholder`, `required`, `disabled`, `readonly`, `invalid`, `size`. Events: `input`
420
+ * on every change of the value, `change` when it was committed (blur, Enter, a country pick),
421
+ * and `countrychange` when the user changes the country.
422
+ *
423
+ * @alpha
424
+ */
425
+ declare class NxPhoneInput extends NxFieldElement {
426
+ #private;
427
+ static get observedAttributes(): string[];
428
+ /** @internal */
429
+ protected readonly control: HTMLInputElement;
430
+ constructor();
431
+ /** The country the number is in (ISO 3166-1 alpha-2). Setting it keeps the national digits. */
432
+ get country(): CountryCode;
433
+ set country(v: CountryCode);
434
+ /** The country an empty field starts on, and goes back to on `form.reset()`. */
435
+ get defaultCountry(): string;
436
+ set defaultCountry(v: string);
437
+ /** The countries to pick from, in order (`"IN AE US"`); empty for every country. */
438
+ get countries(): string;
439
+ set countries(v: string);
440
+ get locale(): string;
441
+ set locale(v: string);
442
+ get placeholder(): string;
443
+ set placeholder(v: string);
444
+ /** `true` while the country list is open. */
445
+ get open(): boolean;
446
+ /** Closes the country list. */
447
+ close(): void;
448
+ disconnectedCallback(): void;
449
+ attributeChangedCallback(name: string, old: string | null, next: string | null): void;
450
+ /** @internal Any typed form to E.164 (a number from a country the field doesn't allow is no value); its country becomes the field's. */
451
+ protected sanitize(v: string): string;
452
+ /** @internal */
453
+ protected reset(): void;
454
+ /** @internal */
455
+ protected check(): FieldError;
456
+ /** @internal */
457
+ protected update(): void;
199
458
  }
200
459
 
201
- export { NxDatePicker, NxFieldElement, NxNumberInput };
202
- export type { NxDateGranularity, NxFieldSize };
460
+ export { NxChoiceElement, NxCombobox, NxDatePicker, NxFieldElement, NxNumberInput, NxPhoneInput, NxSelect };
461
+ export type { NxDateGranularity, NxFieldSize, NxOption, NxSearch };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c}from"./chunk-N4ME7GWE.js";export{c as NxDatePicker,a as NxFieldElement,b as NxNumberInput};
1
+ import{a as e,b as o,c as r,d as t,e as x,f as p,g as m}from"./chunk-NG5UPH5U.js";export{t as NxChoiceElement,p as NxCombobox,r as NxDatePicker,e as NxFieldElement,o as NxNumberInput,m as NxPhoneInput,x as NxSelect};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexub/elements",
3
- "version": "11.8.0",
4
- "description": "Web components for Nexub Design System: form-associated <nx-number-input> and <nx-date-picker> for server-rendered pages, with no framework.",
3
+ "version": "11.9.0",
4
+ "description": "Web components for Nexub Design System: form-associated <nx-number-input>, <nx-date-picker>, <nx-select>, <nx-combobox> and <nx-phone-input> for server-rendered pages, with no framework.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/Nexub-AI/nexub-ds#readme",
@@ -25,7 +25,9 @@
25
25
  ],
26
26
  "sideEffects": [
27
27
  "./dist/define.js",
28
- "./src/define.ts"
28
+ "./dist/define/*.js",
29
+ "./src/define.ts",
30
+ "./src/define/*.ts"
29
31
  ],
30
32
  "exports": {
31
33
  ".": {
@@ -40,13 +42,17 @@
40
42
  "types": "./dist/define.d.ts",
41
43
  "default": "./dist/define.js"
42
44
  },
45
+ "./define/*": {
46
+ "types": "./dist/define/*.d.ts",
47
+ "default": "./dist/define/*.js"
48
+ },
43
49
  "./package.json": "./package.json"
44
50
  },
45
51
  "main": "./dist/index.js",
46
52
  "types": "./dist/index.d.ts",
47
53
  "devDependencies": {
48
- "@nexub/core": "11.8.0",
49
- "@nexub/tokens": "11.8.0",
54
+ "@nexub/core": "11.9.0",
55
+ "@nexub/tokens": "11.9.0",
50
56
  "@testing-library/jest-dom": "^7.0.1",
51
57
  "@testing-library/user-event": "^14.6.8",
52
58
  "@vitest/coverage-v8": "5.1.0",
@@ -57,7 +63,7 @@
57
63
  "vitest": "^5.1.0"
58
64
  },
59
65
  "scripts": {
60
- "build": "tsup",
66
+ "build": "tsup && tsup --config tsup.define.config.ts",
61
67
  "dev": "tsup --watch",
62
68
  "clean": "rm -rf dist",
63
69
  "typecheck": "tsc --noEmit",
@@ -1,119 +0,0 @@
1
- var Z="var(--motion-spring-effects-fast-duration) var(--motion-spring-effects-fast-easing)",ke="outline: 0.1875rem solid var(--color-ring-default, var(--color-primary)); outline-offset: 0.125rem;",Y=`
2
- :host { display: block; font-family: var(--font-family-sans, inherit); color: var(--color-on-surface); }
3
- :host([hidden]) { display: none; }
4
- /* The field draws focus itself; no second ring on the host. */
5
- :host(:focus-within) { outline: none !important; }
6
- * { box-sizing: border-box; }
7
- .field {
8
- display: flex; align-items: center; gap: 0.5rem; inline-size: 100%;
9
- block-size: var(--size-control-md, 2.5rem); padding-inline: 0.875rem;
10
- border: 1px solid var(--field-border, var(--color-outline));
11
- border-radius: var(--field-radius, var(--shape-field));
12
- background: var(--field-bg, var(--color-surface-container-lowest));
13
- color: var(--field-fg, var(--color-on-surface));
14
- font-size: var(--type-body-md-size, 1rem); line-height: var(--type-body-md-lineHeight, 1.5rem);
15
- }
16
- :host([size='sm']) .field {
17
- block-size: var(--size-control-sm, 2rem); padding-inline: 0.75rem; gap: 0.375rem;
18
- font-size: var(--type-body-sm-size, 0.875rem); line-height: var(--type-body-sm-lineHeight, 1.25rem);
19
- }
20
- :host([size='lg']) .field { block-size: var(--size-control-lg, 3rem); padding-inline: 1rem; }
21
- .field:hover { border-color: var(--color-on-surface-variant); }
22
- .field:focus-within, .field:focus-within:hover { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
23
- .field[data-invalid], .field[data-invalid]:hover { border-color: var(--color-error); }
24
- .field[data-invalid]:focus-within { border-color: var(--color-error); box-shadow: inset 0 0 0 1px var(--color-error); }
25
- .field[data-readonly], .field[data-readonly]:hover { border-color: var(--color-outline-variant); background: var(--color-surface-container-low); }
26
- .field[data-disabled], .field[data-disabled]:hover {
27
- cursor: not-allowed; border-color: var(--color-outline-variant);
28
- background: var(--color-surface-container-low); color: var(--color-text-disabled);
29
- }
30
- input {
31
- flex: 1; min-inline-size: 0; block-size: 100%; margin: 0; padding: 0; border: 0; outline: none;
32
- background: transparent; color: inherit; font: inherit; font-variant-numeric: tabular-nums;
33
- }
34
- input::placeholder { color: var(--color-on-surface-muted); opacity: 1; }
35
- input:disabled { cursor: not-allowed; color: var(--color-text-disabled); }
36
- @media (prefers-reduced-motion: no-preference) {
37
- .field { transition: border-color ${Z}, box-shadow ${Z}; }
38
- }
39
- @media (forced-colors: active) {
40
- .field { border-color: FieldText; }
41
- .field:focus-within { outline: 0.125rem solid Highlight; outline-offset: 0; }
42
- .field[data-invalid] { border-style: dashed; }
43
- .field[data-disabled] { border-color: GrayText; color: GrayText; }
44
- }
45
- `,me=`
46
- :host([size='sm']) .field { padding-inline-end: 0.125rem; }
47
- .field { padding-inline-end: 0.25rem; }
48
- :host([size='lg']) .field { padding-inline-end: 0.375rem; }
49
- button {
50
- position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center;
51
- margin: 0; padding: 0; border: 1px solid transparent; border-radius: var(--shape-control, 999rem);
52
- background: transparent; color: inherit; font: inherit; cursor: pointer;
53
- }
54
- /* The state layer (themes' .nx-state-layer): the text colour at the --state-* opacity. */
55
- button::before {
56
- content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
57
- background: currentColor; opacity: 0; pointer-events: none;
58
- }
59
- button:hover::before { opacity: var(--state-hover, 0.08); }
60
- button:focus-visible::before { opacity: var(--state-focus, 0.1); }
61
- button:active::before { opacity: var(--state-pressed, 0.1); }
62
- button:disabled { cursor: default; pointer-events: none; color: var(--color-text-disabled); }
63
- button:disabled::before { opacity: 0; }
64
- button:focus-visible { ${ke} }
65
- svg { inline-size: 1rem; block-size: 1rem; flex: none; }
66
- .open { flex: none; inline-size: 2rem; block-size: 2rem; border-radius: 999rem; }
67
- :host([size='sm']) .open { inline-size: 1.75rem; block-size: 1.75rem; }
68
- dialog {
69
- position: fixed; margin: 0; inset: auto;
70
- inset-block-start: var(--nx-top, 0); inset-inline-start: var(--nx-start, 0);
71
- inline-size: max-content; max-inline-size: calc(100vw - 1rem); max-block-size: calc(100dvh - 1rem); overflow: auto;
72
- padding: 0.75rem; border: 0; border-radius: var(--shape-container, 1rem);
73
- background: var(--color-surface-elevated, var(--color-surface)); color: var(--color-on-surface);
74
- box-shadow: var(--elevation-2); font-size: var(--type-body-sm-size, 0.875rem);
75
- }
76
- dialog::backdrop { background: transparent; }
77
- .head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-block-end: 0.5rem; }
78
- .title { font-size: var(--type-label-lg-size, 0.875rem); font-weight: var(--type-label-lg-weight, 600); }
79
- .nav { inline-size: 1.75rem; block-size: 1.75rem; border-radius: 999rem; }
80
- :host(:dir(rtl)) .nav svg { transform: scaleX(-1); }
81
- table { border-collapse: collapse; margin-inline: auto; }
82
- th { block-size: var(--day-cell, 2rem); padding: 0; font-weight: inherit; font-size: var(--type-label-sm-size, 0.75rem); color: var(--color-on-surface-muted); }
83
- td { padding: 0; padding-block-start: 0.25rem; text-align: center; }
84
- .day, .cell { font-variant-numeric: tabular-nums; border-radius: 999rem; }
85
- .day { inline-size: var(--day-cell, 2rem); block-size: var(--day-cell, 2rem); }
86
- .day[data-outside]:not([aria-pressed='true']):not(:disabled) { color: var(--color-on-surface-muted); }
87
- .cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; inline-size: 16.5rem; max-inline-size: 100%; }
88
- /* Long month names in some locales wrap to two lines rather than overflow. */
89
- .cell { block-size: 2.5rem; padding-inline: 0.25rem; line-height: 1.125; overflow-wrap: anywhere; }
90
- [aria-current='date'] { border-color: var(--color-primary); }
91
- [aria-pressed='true'], [aria-selected='true'] > button { background: var(--color-primary); color: var(--color-on-primary); }
92
- @media (max-width: 47.99rem) {
93
- dialog {
94
- inset-inline: 0; inset-block: auto 0; inline-size: 100%; max-inline-size: none; max-block-size: 85dvh;
95
- border-start-start-radius: var(--shape-overlay, 1.5rem); border-start-end-radius: var(--shape-overlay, 1.5rem);
96
- border-end-start-radius: 0; border-end-end-radius: 0;
97
- padding-block-end: max(0.75rem, env(safe-area-inset-bottom));
98
- }
99
- dialog::before {
100
- content: ''; display: block; inline-size: 2rem; block-size: 0.25rem; margin: 0 auto 0.5rem;
101
- border-radius: var(--shape-overlay, 1.5rem); background: var(--color-outline-variant);
102
- }
103
- dialog::backdrop { background: color-mix(in srgb, var(--color-scrim, CanvasText) 40%, transparent); }
104
- .cells { inline-size: 100%; }
105
- .day { inline-size: 2.75rem; block-size: 2.75rem; }
106
- }
107
- @media (prefers-reduced-motion: no-preference) {
108
- button::before { transition: opacity ${Z}; }
109
- dialog[open] { animation: nx-pop var(--motion-spring-effects-default-duration) var(--motion-spring-effects-default-easing); }
110
- @keyframes nx-pop { from { opacity: 0; scale: 0.96; } }
111
- }
112
- @media (forced-colors: active) {
113
- dialog { outline: 1px solid CanvasText; }
114
- button:focus-visible { outline-color: Highlight; }
115
- [aria-current='date'] { border-color: CanvasText; }
116
- [aria-pressed='true'], [aria-selected='true'] > button { forced-color-adjust: none; background: Highlight; color: HighlightText; }
117
- button:disabled { color: GrayText; }
118
- }
119
- `,he=new Map;function O(n){let e=he.get(n);return e||(e=new CSSStyleSheet,e.replaceSync(n),he.set(n,e)),e}var we=typeof HTMLElement>"u"?class{}:HTMLElement,N=class extends we{static formAssociated=!0;internals;root;box;#e="";#t=!1;#n=!1;#r=!1;static get observedAttributes(){return["value","required","disabled","readonly","size","aria-label"]}constructor(){super(),this.internals=this.attachInternals(),this.root=this.attachShadow({mode:"open",delegatesFocus:!0}),this.root.adoptedStyleSheets=[O(Y)],this.box=document.createElement("div"),this.box.className="field",this.box.setAttribute("part","field"),this.root.append(this.box),this.addEventListener("invalid",()=>{this.#r=!0,this.render()})}connectedCallback(){this.#t||(this.#e=this.sanitize(this.getAttribute("value")??"")),this.render(),queueMicrotask(()=>this.nameControl())}attributeChangedCallback(e,r,t){r!==t&&(e==="value"&&!this.#t&&(this.#e=this.sanitize(t??"")),e==="aria-label"&&this.nameControl(),this.render())}get value(){return this.#e}set value(e){this.#t=!0,this.#e=this.sanitize(String(e??"")),this.render()}get defaultValue(){return this.getAttribute("value")??""}set defaultValue(e){this.setAttribute("value",e)}get name(){return this.getAttribute("name")??""}set name(e){this.setAttribute("name",e)}get required(){return this.hasAttribute("required")}set required(e){this.toggleAttribute("required",!!e)}get disabled(){return this.hasAttribute("disabled")}set disabled(e){this.toggleAttribute("disabled",!!e)}get readOnly(){return this.hasAttribute("readonly")}set readOnly(e){this.toggleAttribute("readonly",!!e)}get size(){let e=this.getAttribute("size");return e==="sm"||e==="lg"?e:"md"}set size(e){this.setAttribute("size",e)}get form(){return this.internals.form}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}focus(e){this.control.focus(e)}blur(){this.control.blur()}formResetCallback(){this.#t=!1,this.#r=!1,this.reset(),this.#e=this.sanitize(this.getAttribute("value")??""),this.render()}formDisabledCallback(e){this.#n=e,this.render()}formStateRestoreCallback(e){typeof e=="string"&&(this.value=e)}reset(){}resanitize(){this.#e=this.sanitize(this.#t?this.#e:this.getAttribute("value")??"")}get isDisabled(){return this.disabled||this.#n}setValue(e){let r=this.sanitize(e),t=r!==this.#e;return this.#t=!0,this.#e=r,t}touch(){this.#r=!0}emit(e){this.dispatchEvent(new Event(e,{bubbles:!0,composed:e==="input"}))}render(){let e=this.check();this.internals.setFormValue(this.#e),e&&!this.readOnly&&!this.isDisabled?this.internals.setValidity({[e.kind]:!0},e.message,this.control):this.internals.setValidity({});let r=!!e&&this.#r&&!this.readOnly;this.box.toggleAttribute("data-invalid",r),this.box.toggleAttribute("data-disabled",this.isDisabled),this.box.toggleAttribute("data-readonly",this.readOnly),this.control.disabled=this.isDisabled,this.control.readOnly=this.readOnly,this.control.setAttribute("aria-required",String(this.required)),this.control.setAttribute("aria-invalid",String(r)),this.update()}nameControl(){let e=this.getAttribute("aria-label"),r=Array.from(this.internals.labels??[]);if(!r.length){let i=this.getRootNode(),a=this.id?Array.from(i.querySelectorAll("label[for]")).filter(s=>s.htmlFor===this.id):[],o=this.closest("label");r=o&&!a.includes(o)?[...a,o]:a}let t=e??r.map(i=>i.textContent?.trim()).filter(Boolean).join(" ");t?this.control.setAttribute("aria-label",t):this.control.removeAttribute("aria-label")}};var Q={pickDate:"Pick a date",pickMonth:"Pick a month",pickYear:"Pick a year",previousMonth:"Go to previous month",nextMonth:"Go to next month",previousYear:"Go to previous year",nextYear:"Go to next year",previousYears:"Go to previous years",nextYears:"Go to next years",todayDate:n=>`Today, ${n}`,selectedDate:n=>`${n}, selected`};var Ae=/^[-+]?\d*(?:[.,]\d*)?$/;function X(n){return Ae.test(n)}function U(n){let e=Number(n.trim().replace(",","."));return n.trim()!==""&&Number.isFinite(e)&&/\d/.test(n)?e:void 0}function M(n,e,r){let t=n;return e!==void 0&&t<e&&(t=e),r!==void 0&&t>r&&(t=r),t}function fe(n=1){return n==="any"?1:n}function R(n,e,r,t){return M(n===null?M(0,r,t):n+e,r,t)}function J(n,e,{min:r,max:t,step:i}={}){let a=fe(i);switch(n){case"ArrowUp":return R(e,a,r,t);case"ArrowDown":return R(e,-a,r,t);case"PageUp":return R(e,a*10,r,t);case"PageDown":return R(e,-a*10,r,t);case"Home":return r===void 0?void 0:M(r,r,t);case"End":return t===void 0?void 0:M(t,r,t);default:return}}var pe=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/,Se={year:0,month:1,day:2},W=(n,e=2)=>String(n).padStart(e,"0");function z(n,e){let r=new Date(0);return r.setUTCFullYear(n,e+1,0),r.getUTCDate()}function A(n){let e=n?pe.exec(n):null;if(!e)return;let r=e[3]?"day":e[2]?"month":"year";return c(n,r)?r:void 0}function c(n,e){let r=n?pe.exec(n):null;if(!r)return;let t=r[3]?"day":r[2]?"month":"year";if(e&&t!==e)return;let i=Number(r[1]),a=r[2]?Number(r[2])-1:0,o=r[3]?Number(r[3]):1;if(!(a<0||a>11||o<1||o>z(i,a)))return{year:i,month:a,day:o}}function v(n,e="day"){let r=W(n.year,4);return e==="year"?r:e==="month"?`${r}-${W(n.month+1)}`:`${r}-${W(n.month+1)}-${W(n.day)}`}function y(n,e,r="day"){let t=Se[r];return n.year!==e.year?n.year-e.year:t>=1&&n.month!==e.month?n.month-e.month:t>=2&&n.day!==e.day?n.day-e.day:0}function H(n,e,r,t="day"){let i=c(e),a=c(r),o=(s,d)=>d==="year"?{year:s.year,month:11,day:31}:d==="month"?{...s,day:z(s.year,s.month)}:s;if(i&&y(n,i,t)<0)return"under";if(a&&y(n,o(a,A(r)),t)>0)return"over"}function $({year:n,month:e,day:r}){let t=new Date(0);return t.setUTCFullYear(n,e,r),t.getUTCDay()}function C({year:n,month:e,day:r},t){let i=new Date(0);return i.setUTCFullYear(n,e,r+t),{year:i.getUTCFullYear(),month:i.getUTCMonth(),day:i.getUTCDate()}}function x({year:n,month:e,day:r},t){let i=n*12+e+t,a=Math.floor(i/12),o=i-a*12;return{year:a,month:o,day:Math.min(r,z(a,o))}}function K(n=new Date){return{year:n.getFullYear(),month:n.getMonth(),day:n.getDate()}}var Ee=new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" ")),Ne=new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));function j(n){let e;try{e=new Intl.Locale(n??new Intl.DateTimeFormat().resolvedOptions().locale)}catch{return 1}try{let t=typeof e.getWeekInfo=="function"?e.getWeekInfo():e.weekInfo;if(t&&typeof t.firstDay=="number")return t.firstDay%7}catch{}let r=e.maximize().region??"";return Ee.has(r)?0:Ne.has(r)?6:1}var h=Q;function D(n,e,r,t){if(n!=="badInput"&&typeof document<"u"){let i=document.createElement("input");if(n==="valueMissing"?i.required=!0:(i.type=e,i[n==="rangeUnderflow"?"min":"max"]=r,i.value=e==="number"?String(Number(r)+(n==="rangeUnderflow"?-1:1)):n==="rangeUnderflow"?"0001-01-01".slice(0,r.length):"9999-12-31".slice(0,r.length)),i.validationMessage)return i.validationMessage}return t}var ee=n=>{if(n===null||n.trim()==="")return;let e=Number(n);return Number.isFinite(e)?e:void 0},te=class extends N{static get observedAttributes(){return[...super.observedAttributes,"min","max","step","placeholder"]}control=document.createElement("input");#e=null;#t="";constructor(){super();let e=this.control;e.type="text",e.inputMode="decimal",e.autocomplete="off",e.setAttribute("role","spinbutton"),e.setAttribute("part","input"),this.box.append(e),e.addEventListener("focus",()=>{this.#e=this.value,this.#t=this.value}),e.addEventListener("input",this.#r),e.addEventListener("blur",this.#o),e.addEventListener("keydown",this.#i)}get min(){return this.getAttribute("min")??""}set min(e){this.setAttribute("min",e)}get max(){return this.getAttribute("max")??""}set max(e){this.setAttribute("max",e)}get step(){return this.getAttribute("step")??""}set step(e){this.setAttribute("step",e)}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(e){this.setAttribute("placeholder",e)}get valueAsNumber(){return this.value===""?NaN:Number(this.value)}set valueAsNumber(e){this.value=Number.isFinite(e)?String(e):""}get#n(){let e=this.getAttribute("step"),r=ee(e),t=e?.trim().toLowerCase()==="any"?"any":r!==void 0&&r>0?r:1;return{min:ee(this.getAttribute("min")),max:ee(this.getAttribute("max")),step:t}}sanitize(e){let r=U(e);return r===void 0?"":String(r)}reset(){this.#e=null,this.#t=this.sanitize(this.getAttribute("value")??"")}check(){let{min:e,max:r}=this.#n,t=this.#e;if(t!==null&&t.trim()!==""&&U(t)===void 0)return{kind:"badInput",message:D("badInput","number","","Enter a number.")};if(this.value==="")return this.required?{kind:"valueMissing",message:D("valueMissing","number","","Fill out this field.")}:void 0;let i=Number(this.value);if(e!==void 0&&i<e)return{kind:"rangeUnderflow",message:D("rangeUnderflow","number",String(e),`Value must be ${e} or more.`)};if(r!==void 0&&i>r)return{kind:"rangeOverflow",message:D("rangeOverflow","number",String(r),`Value must be ${r} or less.`)}}update(){let e=this.control,{min:r,max:t}=this.#n,i=this.#e??this.value;e.value!==i&&(e.value=i),e.placeholder=this.placeholder;let a=(o,s)=>s===void 0?e.removeAttribute(o):e.setAttribute(o,String(s));a("aria-valuenow",this.value===""?void 0:Number(this.value)),a("aria-valuemin",r),a("aria-valuemax",t)}#r=e=>{e.stopPropagation();let r=this.control,t=r.value;if(!X(t)){let o=this.#e??this.value,s=Math.max(0,(r.selectionStart??o.length)-(t.length-o.length));r.value=o,r.setSelectionRange?.(s,s);return}this.#e=t;let i=U(t),a=i!==void 0?this.setValue(String(i)):t.trim()===""?this.setValue(""):!1;this.render(),a&&this.emit("input")};#a(){this.#e=null;let{min:e,max:r}=this.#n,t=!1;this.value!==""&&!this.readOnly&&(t=this.setValue(String(M(Number(this.value),e,r)))),this.value!==this.#t&&this.touch(),this.render(),t&&this.emit("input"),this.value!==this.#t&&(this.#t=this.value,this.emit("change"))}#o=()=>this.#a();#i=e=>{if(e.key==="Enter"&&!e.isComposing){this.#a(),this.#e=this.value,this.form?.requestSubmit();return}if(this.readOnly){(e.key==="ArrowUp"||e.key==="ArrowDown")&&e.preventDefault();return}if(this.isDisabled)return;let r=this.value===""?null:Number(this.value),t=J(e.key,r,this.#n);if(t===void 0)return;e.preventDefault();let i=this.setValue(String(t));this.#e!==null&&(this.#e=this.value),this.touch(),this.render(),i&&(this.emit("input"),this.#t=this.value,this.emit("change"))}};var be={year:0,month:1,day:2};function k({year:n,month:e,day:r}){let t=new Date(0);return t.setUTCFullYear(n,e,r),t}var F=(n,e)=>new Intl.DateTimeFormat(n,{timeZone:"UTC",...e}),re={year:"numeric",month:"2-digit",day:"2-digit"};function B(n,e,r){return e==="year"?String(n.year):F(r,e==="month"?{year:"numeric",month:"long"}:re).format(k(n))}function Me(n){return F(n,re).formatToParts(k({year:2026,month:0,day:31})).map(e=>e.type).filter(e=>e==="year"||e==="month"||e==="day")}function ne(n,e){if(n==="year")return"yyyy";let r={year:"yyyy",month:"mm",day:"dd"};return F(e,n==="month"?{year:"numeric",month:"2-digit"}:re).formatToParts(k({year:2026,month:0,day:31})).map(i=>i.type==="year"||i.type==="month"||i.type==="day"?r[i.type]:i.type==="literal"?i.value:"").join("").trim()}function ze(n,e){let r=new Intl.NumberFormat(e,{useGrouping:!1}),t=n;for(let i=0;i<=9;i++){let a=r.format(i);a!==String(i)&&(t=t.split(a).join(String(i)))}return t}function Te(n,e){let r=t=>t.toLowerCase().replace(/\.$/,"");for(let t=0;t<12;t++){let i=k({year:2026,month:t,day:1});if([F(e,{month:"long"}).format(i),F(e,{month:"short"}).format(i),F(e,{day:"numeric",month:"long"}).formatToParts(i).find(o=>o.type==="month")?.value??""].map(r).some(o=>o===n||n.length>=3&&o.startsWith(n)))return t}}function ye(n,e,r){let t=ze(n.trim(),r);if(!t)return;let i=c(t);if(i)return be[A(t)]>=be[e]?i:void 0;let a,o=[];for(let m of t.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean))if(/^\d+$/.test(m))o.push(m);else{let S=Te(m,r);if(S===void 0||a!==void 0)return;a=S}let s=Me(r).filter(m=>m==="year"||m==="month"&&e!=="year"&&a===void 0||m==="day"&&e==="day");if(o.length!==s.length)return;let d=m=>o[s.indexOf(m)]??"",g=d("year"),L={year:g.length<=2?2e3+Number(g):Number(g),month:a??(e==="year"?0:Number(d("month"))-1),day:e==="day"?Number(d("day")):1};return c(v(L,e),e)}var q={year:0,month:1,day:2},T=12,ge="http://www.w3.org/2000/svg",ie=n=>{let e=document.createElementNS(ge,"svg"),r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"};for(let[t,i]of Object.entries(r))e.setAttribute(t,i);for(let[t,i]of n){let a=document.createElementNS(ge,t);for(let[o,s]of Object.entries(i))a.setAttribute(o,s);e.append(a)}return e},Pe=[["rect",{x:"3",y:"4",width:"18",height:"18",rx:"2"}],["path",{d:"M16 2v4M8 2v4M3 10h18"}]],Ce=[["path",{d:"m15 18-6-6 6-6"}]],Fe=[["path",{d:"m9 18 6-6-6-6"}]],Le="(max-width: 47.99rem)",l=(n,e={})=>{let r=document.createElement(n);for(let[t,i]of Object.entries(e))i!==void 0&&r.setAttribute(t,i);return r},ae=n=>n-(n%T+T)%T,oe=class extends N{static get observedAttributes(){return[...super.observedAttributes,"min","max","granularity","locale"]}control=l("input",{type:"text",part:"input",autocomplete:"off",spellcheck:"false"});#e=l("button",{type:"button",part:"button",class:"open","aria-haspopup":"dialog","aria-expanded":"false"});#t=l("dialog",{part:"calendar"});#n=l("span",{class:"title","aria-live":"polite"});#r=l("button",{type:"button",class:"nav"});#a=l("button",{type:"button",class:"nav"});#o=l("div");#i=null;#s;#d=K();constructor(){super(),this.root.adoptedStyleSheets=[O(Y),O(me)],this.#e.replaceChildren(ie(Pe)),this.#r.replaceChildren(ie(Ce)),this.#a.replaceChildren(ie(Fe));let e=l("div",{class:"head"});e.append(this.#r,this.#n,this.#a),this.#t.append(e,this.#o),this.box.append(this.control,this.#e),this.root.append(this.#t);let r=this.control;r.addEventListener("input",t=>{t.stopPropagation(),this.#i=r.value}),r.addEventListener("blur",()=>this.#b()),r.addEventListener("keydown",t=>{t.key!=="Enter"||t.isComposing||(this.#b(),this.form?.requestSubmit())}),this.#e.addEventListener("click",()=>this.show()),this.#r.addEventListener("click",()=>this.#y(-1)),this.#a.addEventListener("click",()=>this.#y(1)),this.#o.addEventListener("click",t=>{let i=t.target.closest("button[data-value]");i&&!i.disabled&&this.#g(i.dataset.value)}),this.#o.addEventListener("keydown",this.#v),this.#t.addEventListener("close",()=>{this.#e.setAttribute("aria-expanded","false"),window.removeEventListener("resize",this.#u),window.removeEventListener("scroll",this.#u,!0),this.control.focus()}),this.#t.addEventListener("click",t=>{if(t.target!==this.#t)return;let i=this.#t.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&this.close()})}get min(){return this.getAttribute("min")??""}set min(e){this.setAttribute("min",e)}get max(){return this.getAttribute("max")??""}set max(e){this.setAttribute("max",e)}get granularity(){let e=this.getAttribute("granularity");return e==="month"||e==="year"?e:"day"}set granularity(e){this.setAttribute("granularity",e)}get locale(){return this.getAttribute("locale")??""}set locale(e){this.setAttribute("locale",e)}get value(){return super.value}set value(e){this.#i=null,this.#s=void 0,super.value=e}get open(){return this.#t.open}show(){this.open||this.isDisabled||this.readOnly||(this.#d=this.#h(c(this.value)??K()),this.#c(),this.#t.showModal(),this.#e.setAttribute("aria-expanded","true"),this.#u(),window.addEventListener("resize",this.#u),window.addEventListener("scroll",this.#u,{capture:!0,passive:!0}),this.#m())}close(){this.open&&this.#t.close()}attributeChangedCallback(e,r,t){e==="granularity"&&r!==t&&this.resanitize(),super.attributeChangedCallback(e,r,t),this.open&&this.#c()}get#l(){let e=this.getAttribute("locale")||this.closest("[lang]")?.getAttribute("lang")||void 0;try{return e?Intl.getCanonicalLocales(e)[0]:void 0}catch{return}}get#f(){try{return this.matches(":dir(rtl)")}catch{return this.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}}sanitize(e){let r=c(e.trim()),t=A(e.trim());return r&&t&&q[t]>=q[this.granularity]?v(r,this.granularity):""}reset(){this.#i=null,this.#s=void 0,this.close()}#p(e){let r=H(e,this.min,this.max,this.granularity);if(!r)return;let t=r==="under",i=c(t?this.min:this.max),a=this.granularity,o=B(i,a,this.#l),s=t?"rangeUnderflow":"rangeOverflow";return{kind:s,message:D(s,a==="day"?"date":a==="month"?"month":"number",v(i,a),`Value must be ${o} or ${t?"later":"earlier"}.`)}}check(){if(this.#s)return this.#s;let e=c(this.value);return e?this.#p(e):this.required?{kind:"valueMissing",message:D("valueMissing","date","","Fill out this field.")}:void 0}update(){let e=this.granularity,r=c(this.value),t=this.#i??(r?B(r,e,this.#l):"");this.control.value!==t&&(this.control.value=t),this.control.placeholder=ne(e,this.#l),this.#e.disabled=this.isDisabled||this.readOnly,this.#e.setAttribute("aria-label",e==="day"?h.pickDate:e==="month"?h.pickMonth:h.pickYear)}#b(){let e=this.#i;if(e===null)return;let r=!1,t=e.trim()?ye(e,this.granularity,this.#l):void 0;this.#s=!e.trim()||!t?e.trim()?{kind:"badInput",message:D("badInput","date","",`Enter a date as ${ne(this.granularity,this.#l)}.`)}:void 0:this.#p(t),this.#s||(this.#i=null,r=this.setValue(t?v(t,this.granularity):"")),this.touch(),this.render(),r&&this.emit("change")}#g(e){this.#i=null,this.#s=void 0;let r=this.setValue(e);this.touch(),this.render(),this.close(),r&&this.emit("change")}#h(e){let r=this.granularity,t=H(e,this.min,this.max,r);if(!t)return e;let i=c(t==="under"?this.min:this.max);if(t==="under"||q[A(this.max)]>=q[r])return i;let a=A(this.max)==="year"?11:i.month;return{year:i.year,month:a,day:z(i.year,a)}}#y(e,r=!1){let t=this.granularity,i=this.#d;this.#d=this.#h(t==="day"?x(i,e):x(i,e*12*(t==="year"?T:1))),this.#c(),r&&this.#m()}#v=e=>{let r=this.granularity,t=this.#d,i=this.#f?-1:1,a=d=>r==="day"?C(t,d):x(t,d*(r==="year"?12:1)),o=()=>r==="day"?C(t,-(($(t)-j(this.#l)+7)%7)):r==="month"?{...t,month:0,day:1}:{year:ae(t.year),month:0,day:1},s;switch(e.key){case"ArrowLeft":s=a(-i);break;case"ArrowRight":s=a(i);break;case"ArrowUp":s=a(r==="day"?-7:-3);break;case"ArrowDown":s=a(r==="day"?7:3);break;case"PageUp":case"PageDown":{let d=e.key==="PageUp"?-1:1;s=r==="day"?x(t,d*(e.shiftKey?12:1)):x(t,d*12*(r==="year"?T:1));break}case"Home":s=o();break;case"End":s=r==="day"?C(o(),6):r==="month"?{...t,month:11,day:1}:{year:ae(t.year)+11,month:0,day:1};break;default:return}e.preventDefault(),this.#d=this.#h(s),this.#c(),this.#m()};#m(){this.#o.querySelector('[tabindex="0"]')?.focus()}#u=()=>{if(!this.open||window.matchMedia?.(Le).matches)return;let e=this.box.getBoundingClientRect(),{offsetWidth:r,offsetHeight:t}=this.#t,i=document.documentElement.clientWidth||innerWidth,a=document.documentElement.clientHeight||innerHeight,o=4,s=e.bottom+o;s+t>a-o&&e.top-o-t>=o&&(s=e.top-o-t);let d=Math.max(o,Math.min(this.#f?i-e.right:e.left,i-r-o));this.#t.style.setProperty("--nx-top",`${Math.max(o,s)}px`),this.#t.style.setProperty("--nx-start",`${d}px`)};#c(){let e=this.granularity,r=this.#l,t=this.#d,i=c(this.value),a=K(),o=(u,b)=>H(u,this.min,this.max,b),s=u=>new Intl.DateTimeFormat(r,{timeZone:"UTC",...u}),d=new Intl.NumberFormat(r,{useGrouping:!1}),g,L,m,S,G;if(e==="day"){let u={year:t.year,month:t.month,day:1};g=s({month:"long",year:"numeric"}).format(k(u)),[L,m,S]=[x(u,-1),x(u,1),"month"];let b=j(r),E=($(u)-b+7)%7,f=Math.ceil((E+z(t.year,t.month))/7)*7;G=l("table",{role:"grid","aria-label":g});let P=l("tr");for(let w=0;w<7;w++){let p=k({year:1970,month:0,day:4+(b+w)%7}),V=l("th",{scope:"col",abbr:s({weekday:"long"}).format(p)});V.textContent=s({weekday:"short"}).format(p),P.append(V)}let se=l("thead");se.append(P);let le=l("tbody");G.append(se,le);let De=s({dateStyle:"full"}),de;for(let w=0;w<f;w++){w%7===0&&le.append(de=l("tr"));let p=C(u,w-E),V=i!==void 0&&y(p,i)===0,ue=y(p,a)===0,I=De.format(k(p));ue&&(I=h.todayDate(I)),V&&(I=h.selectedDate(I));let ce=l("td",{role:"gridcell","aria-selected":V?"true":void 0}),_=l("button",{type:"button",class:"day","data-value":v(p),tabindex:y(p,t)===0?"0":"-1","aria-label":I,"aria-current":ue?"date":void 0,"data-outside":p.month!==t.month?"":void 0});_.disabled=o(p,"day")!==void 0,_.textContent=d.format(p.day),ce.append(_),de.append(ce)}}else{let u=e==="month",b=u?t.year:ae(t.year);g=u?String(t.year):`${b} \u2013 ${b+T-1}`,S="year",L={year:u?t.year-1:b-1,month:0,day:1},m={year:u?t.year+1:b+T,month:0,day:1},G=l("div",{role:"group",class:"cells","aria-label":g});for(let E=0;E<12;E++){let f=u?{year:t.year,month:E,day:1}:{year:b+E,month:0,day:1},P=l("button",{type:"button",class:"cell","data-value":v(f,e),tabindex:y(f,t,e)===0?"0":"-1","aria-pressed":String(i!==void 0&&y(f,i,e)===0),"aria-current":y(f,a,e)===0?"date":void 0,"aria-label":u?B(f,"month",r):String(f.year)});P.disabled=o(f,e)!==void 0,P.textContent=u?s({month:"long"}).format(k(f)):String(f.year),G.append(P)}}this.#r.disabled=o(L,S)==="under",this.#a.disabled=o(m,S)==="over";let[ve,xe]=e==="day"?[h.previousMonth,h.nextMonth]:e==="month"?[h.previousYear,h.nextYear]:[h.previousYears,h.nextYears];this.#r.setAttribute("aria-label",ve),this.#a.setAttribute("aria-label",xe),this.#n.textContent=g,this.#t.setAttribute("aria-label",e==="day"?h.pickDate:e==="month"?h.pickMonth:h.pickYear),this.#o.replaceChildren(G)}};export{N as a,te as b,oe as c};