@melodicdev/components 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +4 -4
  2. package/assets/fonts/phosphor/phosphor.css +5 -25
  3. package/assets/melodic-components.css +50 -25
  4. package/assets/melodic-components.js +5370 -4233
  5. package/assets/melodic-components.js.map +1 -1
  6. package/assets/melodic-components.min.css +1 -21
  7. package/assets/melodic-components.min.js +1808 -26662
  8. package/lib/components/data-display/calendar-view/calendar-view.styles.d.ts.map +1 -1
  9. package/lib/components/data-display/calendar-view/calendar-view.styles.js +14 -0
  10. package/lib/components/data-display/data-grid/data-grid.component.d.ts +43 -2
  11. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  12. package/lib/components/data-display/data-grid/data-grid.component.js +94 -8
  13. package/lib/components/data-display/data-grid/data-grid.styles.d.ts.map +1 -1
  14. package/lib/components/data-display/data-grid/data-grid.styles.js +17 -0
  15. package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
  16. package/lib/components/data-display/data-grid/data-grid.template.js +19 -10
  17. package/lib/components/data-display/data-grid/index.d.ts +1 -0
  18. package/lib/components/data-display/data-grid/index.d.ts.map +1 -1
  19. package/lib/components/data-display/list/list-item.styles.js +1 -1
  20. package/lib/components/data-display/table/index.d.ts +1 -0
  21. package/lib/components/data-display/table/index.d.ts.map +1 -1
  22. package/lib/components/data-display/table/table.component.d.ts +16 -0
  23. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  24. package/lib/components/data-display/table/table.component.js +28 -3
  25. package/lib/components/data-display/table/table.styles.d.ts.map +1 -1
  26. package/lib/components/data-display/table/table.styles.js +7 -1
  27. package/lib/components/data-display/table/table.template.d.ts.map +1 -1
  28. package/lib/components/data-display/table/table.template.js +8 -6
  29. package/lib/components/data-display/table-core/index.d.ts +2 -2
  30. package/lib/components/data-display/table-core/index.d.ts.map +1 -1
  31. package/lib/components/data-display/table-core/index.js +1 -1
  32. package/lib/components/data-display/table-core/table-core.d.ts +16 -2
  33. package/lib/components/data-display/table-core/table-core.d.ts.map +1 -1
  34. package/lib/components/data-display/table-core/table-core.js +32 -5
  35. package/lib/components/data-display/tag/tag.styles.d.ts.map +1 -1
  36. package/lib/components/data-display/tag/tag.styles.js +11 -4
  37. package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
  38. package/lib/components/feedback/alert/alert.styles.js +11 -0
  39. package/lib/components/feedback/toast/index.d.ts +1 -0
  40. package/lib/components/feedback/toast/index.d.ts.map +1 -1
  41. package/lib/components/feedback/toast/toast-container.styles.d.ts.map +1 -1
  42. package/lib/components/feedback/toast/toast-container.styles.js +20 -0
  43. package/lib/components/feedback/toast/toast.component.d.ts +16 -0
  44. package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
  45. package/lib/components/feedback/toast/toast.component.js +63 -5
  46. package/lib/components/feedback/toast/toast.service.d.ts +14 -0
  47. package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
  48. package/lib/components/feedback/toast/toast.service.js +41 -0
  49. package/lib/components/feedback/toast/toast.styles.d.ts.map +1 -1
  50. package/lib/components/feedback/toast/toast.styles.js +6 -0
  51. package/lib/components/feedback/toast/toast.template.js +1 -1
  52. package/lib/components/forms/autocomplete/autocomplete.component.d.ts +14 -4
  53. package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
  54. package/lib/components/forms/autocomplete/autocomplete.component.js +40 -96
  55. package/lib/components/forms/autocomplete/autocomplete.styles.d.ts.map +1 -1
  56. package/lib/components/forms/autocomplete/autocomplete.styles.js +22 -6
  57. package/lib/components/forms/autocomplete/autocomplete.template.js +7 -1
  58. package/lib/components/forms/button/button.styles.d.ts.map +1 -1
  59. package/lib/components/forms/button/button.styles.js +11 -0
  60. package/lib/components/forms/button-group/button-group-item.styles.d.ts.map +1 -1
  61. package/lib/components/forms/button-group/button-group-item.styles.js +11 -0
  62. package/lib/components/forms/button-group/button-group.styles.js +2 -2
  63. package/lib/components/forms/checkbox/checkbox.styles.d.ts.map +1 -1
  64. package/lib/components/forms/checkbox/checkbox.styles.js +13 -2
  65. package/lib/components/forms/date-picker/calendar.component.d.ts +20 -7
  66. package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
  67. package/lib/components/forms/date-picker/calendar.component.js +88 -13
  68. package/lib/components/forms/date-picker/calendar.styles.d.ts.map +1 -1
  69. package/lib/components/forms/date-picker/calendar.styles.js +19 -0
  70. package/lib/components/forms/date-picker/date-picker.component.d.ts +2 -3
  71. package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
  72. package/lib/components/forms/date-picker/date-picker.component.js +70 -18
  73. package/lib/components/forms/date-picker/date-picker.styles.d.ts.map +1 -1
  74. package/lib/components/forms/date-picker/date-picker.styles.js +12 -1
  75. package/lib/components/forms/date-time-picker/date-time-picker.styles.d.ts.map +1 -1
  76. package/lib/components/forms/date-time-picker/date-time-picker.styles.js +12 -1
  77. package/lib/components/forms/date-time-picker/tz-utils.d.ts.map +1 -1
  78. package/lib/components/forms/date-time-picker/tz-utils.js +24 -3
  79. package/lib/components/forms/file-upload/file-upload-item.styles.d.ts.map +1 -1
  80. package/lib/components/forms/file-upload/file-upload-item.styles.js +13 -1
  81. package/lib/components/forms/file-upload/file-upload.styles.d.ts.map +1 -1
  82. package/lib/components/forms/file-upload/file-upload.styles.js +11 -0
  83. package/lib/components/forms/form-field/form-field.component.d.ts +18 -1
  84. package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
  85. package/lib/components/forms/form-field/form-field.component.js +55 -16
  86. package/lib/components/forms/form-field/form-field.styles.d.ts.map +1 -1
  87. package/lib/components/forms/form-field/form-field.styles.js +15 -2
  88. package/lib/components/forms/input/input.styles.d.ts.map +1 -1
  89. package/lib/components/forms/input/input.styles.js +12 -1
  90. package/lib/components/forms/listbox-core/index.d.ts +3 -0
  91. package/lib/components/forms/listbox-core/index.d.ts.map +1 -0
  92. package/lib/components/forms/listbox-core/index.js +2 -0
  93. package/lib/components/forms/listbox-core/listbox-core.d.ts +57 -0
  94. package/lib/components/forms/listbox-core/listbox-core.d.ts.map +1 -0
  95. package/lib/components/forms/listbox-core/listbox-core.js +168 -0
  96. package/lib/components/forms/radio/radio-group.styles.js +1 -1
  97. package/lib/components/forms/radio/radio.styles.d.ts.map +1 -1
  98. package/lib/components/forms/radio/radio.styles.js +12 -1
  99. package/lib/components/forms/radio-card-group/radio-card-group.styles.js +1 -1
  100. package/lib/components/forms/radio-card-group/radio-card.styles.d.ts.map +1 -1
  101. package/lib/components/forms/radio-card-group/radio-card.styles.js +11 -0
  102. package/lib/components/forms/select/select.component.d.ts +12 -4
  103. package/lib/components/forms/select/select.component.d.ts.map +1 -1
  104. package/lib/components/forms/select/select.component.js +41 -110
  105. package/lib/components/forms/select/select.styles.d.ts.map +1 -1
  106. package/lib/components/forms/select/select.styles.js +23 -6
  107. package/lib/components/forms/select/select.template.d.ts.map +1 -1
  108. package/lib/components/forms/select/select.template.js +25 -9
  109. package/lib/components/forms/slider/slider.component.js +1 -1
  110. package/lib/components/forms/slider/slider.styles.d.ts.map +1 -1
  111. package/lib/components/forms/slider/slider.styles.js +11 -0
  112. package/lib/components/forms/slider/slider.template.d.ts.map +1 -1
  113. package/lib/components/forms/slider/slider.template.js +5 -1
  114. package/lib/components/forms/textarea/textarea.styles.d.ts.map +1 -1
  115. package/lib/components/forms/textarea/textarea.styles.js +13 -2
  116. package/lib/components/forms/time-picker/time-picker.component.d.ts +1 -2
  117. package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
  118. package/lib/components/forms/time-picker/time-picker.component.js +8 -17
  119. package/lib/components/forms/time-picker/time-picker.styles.d.ts.map +1 -1
  120. package/lib/components/forms/time-picker/time-picker.styles.js +23 -3
  121. package/lib/components/forms/toggle/toggle.styles.d.ts.map +1 -1
  122. package/lib/components/forms/toggle/toggle.styles.js +13 -2
  123. package/lib/components/foundation/card/card.styles.d.ts.map +1 -1
  124. package/lib/components/foundation/card/card.styles.js +11 -0
  125. package/lib/components/foundation/container/container.styles.js +4 -4
  126. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
  127. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +5 -3
  128. package/lib/components/navigation/sidebar/sidebar-item.styles.js +4 -4
  129. package/lib/components/navigation/sidebar/sidebar-item.template.js +2 -2
  130. package/lib/components/navigation/sidebar/sidebar.styles.js +5 -5
  131. package/lib/components/navigation/sidebar/sidebar.template.js +2 -2
  132. package/lib/components/navigation/steps/step.styles.js +3 -3
  133. package/lib/components/navigation/steps/steps.styles.js +3 -3
  134. package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
  135. package/lib/components/navigation/tabs/tabs.component.js +4 -1
  136. package/lib/components/navigation/tabs/tabs.styles.js +8 -8
  137. package/lib/components/overlays/dialog/dialog.component.d.ts +15 -2
  138. package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
  139. package/lib/components/overlays/dialog/dialog.component.js +33 -1
  140. package/lib/components/overlays/dialog/dialog.service.d.ts +8 -2
  141. package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
  142. package/lib/components/overlays/dialog/dialog.service.js +1 -0
  143. package/lib/components/overlays/dialog/index.d.ts +1 -0
  144. package/lib/components/overlays/dialog/index.d.ts.map +1 -1
  145. package/lib/components/overlays/drawer/drawer.component.d.ts +18 -3
  146. package/lib/components/overlays/drawer/drawer.component.d.ts.map +1 -1
  147. package/lib/components/overlays/drawer/drawer.component.js +59 -16
  148. package/lib/components/overlays/dropdown/dropdown-item.styles.d.ts.map +1 -1
  149. package/lib/components/overlays/dropdown/dropdown-item.styles.js +12 -0
  150. package/lib/components/overlays/popover/popover.component.d.ts +12 -0
  151. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  152. package/lib/components/overlays/popover/popover.component.js +28 -1
  153. package/lib/components/overlays/popover/popover.template.d.ts.map +1 -1
  154. package/lib/components/overlays/popover/popover.template.js +2 -0
  155. package/lib/components/overlays/tooltip/tooltip.component.d.ts +8 -5
  156. package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
  157. package/lib/components/overlays/tooltip/tooltip.component.js +10 -3
  158. package/lib/components/sections/app-shell/app-shell.styles.js +1 -1
  159. package/lib/directives/tooltip.directive.d.ts.map +1 -1
  160. package/lib/directives/tooltip.directive.js +22 -3
  161. package/lib/theme/presets/base.preset.d.ts.map +1 -1
  162. package/lib/theme/presets/base.preset.js +17 -0
  163. package/lib/theme/presets/dark.preset.d.ts +8 -0
  164. package/lib/theme/presets/dark.preset.d.ts.map +1 -1
  165. package/lib/theme/presets/dark.preset.js +9 -0
  166. package/lib/theme/presets/light.preset.d.ts +6 -0
  167. package/lib/theme/presets/light.preset.d.ts.map +1 -1
  168. package/lib/theme/presets/light.preset.js +7 -0
  169. package/lib/theme/tokens/all-tokens.d.ts +10 -0
  170. package/lib/theme/tokens/all-tokens.d.ts.map +1 -1
  171. package/lib/theme/tokens/colors.tokens.d.ts +8 -0
  172. package/lib/theme/tokens/colors.tokens.d.ts.map +1 -1
  173. package/lib/theme/tokens/colors.tokens.js +11 -0
  174. package/lib/theme/tokens/transitions.tokens.d.ts +1 -0
  175. package/lib/theme/tokens/transitions.tokens.d.ts.map +1 -1
  176. package/lib/theme/tokens/transitions.tokens.js +3 -0
  177. package/lib/theme/tokens/typography.tokens.d.ts +1 -0
  178. package/lib/theme/tokens/typography.tokens.d.ts.map +1 -1
  179. package/lib/theme/tokens/typography.tokens.js +1 -0
  180. package/lib/utils/accessibility/cross-root-aria.d.ts +16 -8
  181. package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -1
  182. package/lib/utils/accessibility/cross-root-aria.js +58 -22
  183. package/lib/utils/accessibility/focus-trap.d.ts.map +1 -1
  184. package/lib/utils/accessibility/focus-trap.js +9 -19
  185. package/lib/utils/accessibility/focus-utils.d.ts +10 -1
  186. package/lib/utils/accessibility/focus-utils.d.ts.map +1 -1
  187. package/lib/utils/accessibility/focus-utils.js +48 -14
  188. package/lib/utils/accessibility/index.d.ts +2 -1
  189. package/lib/utils/accessibility/index.d.ts.map +1 -1
  190. package/lib/utils/accessibility/index.js +1 -1
  191. package/lib/utils/positioning/compute-position.d.ts +6 -1
  192. package/lib/utils/positioning/compute-position.d.ts.map +1 -1
  193. package/lib/utils/positioning/compute-position.js +3 -2
  194. package/lib/utils/positioning/middlewares/flip.middleware.js +2 -51
  195. package/package.json +8 -5
  196. package/assets/fonts/phosphor/Phosphor-Bold.svg +0 -3057
  197. package/assets/fonts/phosphor/Phosphor-Bold.ttf +0 -0
  198. package/assets/fonts/phosphor/Phosphor-Bold.woff +0 -0
  199. package/assets/fonts/phosphor/Phosphor-Fill.svg +0 -3057
  200. package/assets/fonts/phosphor/Phosphor-Fill.ttf +0 -0
  201. package/assets/fonts/phosphor/Phosphor-Fill.woff +0 -0
  202. package/assets/fonts/phosphor/Phosphor-Light.svg +0 -3057
  203. package/assets/fonts/phosphor/Phosphor-Light.ttf +0 -0
  204. package/assets/fonts/phosphor/Phosphor-Light.woff +0 -0
  205. package/assets/fonts/phosphor/Phosphor-Thin.svg +0 -3057
  206. package/assets/fonts/phosphor/Phosphor-Thin.ttf +0 -0
  207. package/assets/fonts/phosphor/Phosphor-Thin.woff +0 -0
  208. package/assets/fonts/phosphor/Phosphor.svg +0 -3056
  209. package/assets/fonts/phosphor/Phosphor.ttf +0 -0
  210. package/assets/fonts/phosphor/Phosphor.woff +0 -0
@@ -5,27 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
- import { registerAdapter } from '@melodicdev/core/forms';
9
8
  import { OverlayPositioner } from '../../../utils/overlay/index.js';
10
9
  import { newID } from '../../../functions/index.js';
10
+ import { ListboxValueSync, registerListboxAdapter, findNextEnabledIndex, findPreviousEnabledIndex, findFirstEnabledIndex as firstEnabledIndex, scrollOptionIntoView } from '../listbox-core/index.js';
11
11
  import { autocompleteTemplate } from './autocomplete.template.js';
12
12
  import { autocompleteStyles } from './autocomplete.styles.js';
13
- registerAdapter((el) => el.tagName === 'ML-AUTOCOMPLETE', {
14
- inputEvent: 'ml:change',
15
- blurEvent: 'focusout',
16
- getValue: (el) => {
17
- const e = el;
18
- return e.multiple ? (e.values ?? []) : (e.value ?? '');
19
- },
20
- setValue: (el, value) => {
21
- const e = el;
22
- if (Array.isArray(value))
23
- e.values = value;
24
- else
25
- e.value = value !== null && value !== undefined ? String(value) : '';
26
- },
27
- setDisabled: (el, disabled) => { el.disabled = disabled; }
28
- });
13
+ registerListboxAdapter('ML-AUTOCOMPLETE');
29
14
  /**
30
15
  * ml-autocomplete - Typeahead/autocomplete form component
31
16
  *
@@ -110,7 +95,8 @@ let AutocompleteComponent = class AutocompleteComponent {
110
95
  }));
111
96
  this._debounceTimer = null;
112
97
  this._searchGeneration = 0;
113
- this._syncingValues = false;
98
+ /** Keeps value / values / multiple consistent (shared with ml-select). */
99
+ this._valueSync = new ListboxValueSync(this);
114
100
  /** Unique id for the option at the given display index */
115
101
  this.optionId = (index) => {
116
102
  return `${this.listboxId}-option-${index}`;
@@ -278,53 +264,8 @@ let AutocompleteComponent = class AutocompleteComponent {
278
264
  clearTimeout(this._debounceTimer);
279
265
  }
280
266
  }
281
- onPropertyChange(name) {
282
- if (this._syncingValues)
283
- return;
284
- if (name === 'multiple') {
285
- if (this.multiple) {
286
- if (!this.values.length && this.value) {
287
- this.updateValues([this.value]);
288
- }
289
- return;
290
- }
291
- if (this.values.length) {
292
- this.value = this.values[0] ?? '';
293
- }
294
- this.updateValues([]);
295
- this.search = '';
296
- return;
297
- }
298
- if (name === 'values') {
299
- const rawValues = this.values;
300
- let normalized = [];
301
- if (typeof rawValues === 'string') {
302
- normalized = rawValues
303
- .split(',')
304
- .map((v) => v.trim())
305
- .filter((v) => v.length > 0);
306
- }
307
- else if (Array.isArray(rawValues)) {
308
- normalized = rawValues.filter((v) => typeof v === 'string');
309
- }
310
- normalized = Array.from(new Set(normalized));
311
- if (!this.areValuesEqual(this.values, normalized)) {
312
- this.updateValues(normalized);
313
- }
314
- if (!this.multiple) {
315
- this.value = normalized[0] ?? '';
316
- this.updateValues([]);
317
- }
318
- return;
319
- }
320
- if (name === 'value' && this.multiple) {
321
- if (this.value) {
322
- const nextValues = Array.from(new Set([...this.values, this.value]));
323
- if (!this.areValuesEqual(this.values, nextValues)) {
324
- this.updateValues(nextValues);
325
- }
326
- }
327
- }
267
+ onPropertyChange(name, _, newValue) {
268
+ this._valueSync.handlePropertyChange(name, newValue);
328
269
  }
329
270
  /** Get the selected option (single mode) */
330
271
  get selectedOption() {
@@ -366,6 +307,22 @@ let AutocompleteComponent = class AutocompleteComponent {
366
307
  get hasValue() {
367
308
  return this.multiple ? this.values.length > 0 : !!this.value;
368
309
  }
310
+ /** Unique id of the error element (for aria-describedby) */
311
+ get errorId() {
312
+ return `ml-autocomplete-error-${this._uid}`;
313
+ }
314
+ /** Unique id of the hint element (for aria-describedby) */
315
+ get hintId() {
316
+ return `ml-autocomplete-hint-${this._uid}`;
317
+ }
318
+ /** Id of the message that describes the input, or undefined when there is none. */
319
+ get describedBy() {
320
+ if (this.error)
321
+ return this.errorId;
322
+ if (this.hint)
323
+ return this.hintId;
324
+ return undefined;
325
+ }
369
326
  /** Unique id of the listbox element (for aria-controls) */
370
327
  get listboxId() {
371
328
  return `ml-autocomplete-listbox-${this._uid}`;
@@ -520,44 +477,31 @@ let AutocompleteComponent = class AutocompleteComponent {
520
477
  break;
521
478
  }
522
479
  }
480
+ /**
481
+ * Keep the keyboard-focused option visible. Arrowing past the visible
482
+ * part of a long list used to move the highlight out of view.
483
+ */
484
+ scrollFocusedOptionIntoView() {
485
+ if (this.focusedIndex < 0)
486
+ return;
487
+ scrollOptionIntoView(this.elementRef.shadowRoot, this.optionId(this.focusedIndex));
488
+ }
523
489
  focusNextOption() {
524
- const options = this.filteredOptions;
525
- let index = this.focusedIndex + 1;
526
- while (index < options.length) {
527
- if (!options[index].disabled) {
528
- this.focusedIndex = index;
529
- return;
530
- }
531
- index++;
490
+ const index = findNextEnabledIndex(this.filteredOptions, this.focusedIndex);
491
+ if (index >= 0) {
492
+ this.focusedIndex = index;
493
+ this.scrollFocusedOptionIntoView();
532
494
  }
533
495
  }
534
496
  focusPreviousOption() {
535
- const options = this.filteredOptions;
536
- let index = this.focusedIndex - 1;
537
- while (index >= 0) {
538
- if (!options[index].disabled) {
539
- this.focusedIndex = index;
540
- return;
541
- }
542
- index--;
497
+ const index = findPreviousEnabledIndex(this.filteredOptions, this.focusedIndex);
498
+ if (index >= 0) {
499
+ this.focusedIndex = index;
500
+ this.scrollFocusedOptionIntoView();
543
501
  }
544
502
  }
545
503
  findFirstEnabledIndex() {
546
- return this.filteredOptions.findIndex((opt) => !opt.disabled);
547
- }
548
- updateValues(values) {
549
- this._syncingValues = true;
550
- this.values = values;
551
- this._syncingValues = false;
552
- }
553
- areValuesEqual(left, right) {
554
- if (left.length !== right.length)
555
- return false;
556
- for (let i = 0; i < left.length; i++) {
557
- if (left[i] !== right[i])
558
- return false;
559
- }
560
- return true;
504
+ return firstEnabledIndex(this.filteredOptions);
561
505
  }
562
506
  };
563
507
  AutocompleteComponent = __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/autocomplete/autocomplete.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDA6b9B,CAAC"}
1
+ {"version":3,"file":"autocomplete.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/autocomplete/autocomplete.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDA6c9B,CAAC"}
@@ -125,7 +125,7 @@ export const autocompleteStyles = () => css `
125
125
 
126
126
  .ml-autocomplete__required {
127
127
  color: var(--ml-autocomplete-required-color, var(--ml-color-danger));
128
- margin-left: var(--ml-space-0-5);
128
+ margin-inline-start: var(--ml-space-0-5);
129
129
  }
130
130
 
131
131
  .ml-autocomplete__trigger {
@@ -144,7 +144,7 @@ export const autocompleteStyles = () => css `
144
144
  font-family: var(--ml-autocomplete-font-family, var(--ml-font-sans));
145
145
  font-size: var(--ml-autocomplete-font-size, var(--ml-text-sm));
146
146
  cursor: text;
147
- text-align: left;
147
+ text-align: start;
148
148
  transition:
149
149
  border-color var(--ml-autocomplete-transition-duration, var(--ml-duration-150)) var(--ml-autocomplete-transition-easing, var(--ml-ease-in-out)),
150
150
  box-shadow var(--ml-autocomplete-transition-duration, var(--ml-duration-150)) var(--ml-autocomplete-transition-easing, var(--ml-ease-in-out));
@@ -257,15 +257,15 @@ export const autocompleteStyles = () => css `
257
257
  height: 14px;
258
258
  border-radius: var(--ml-autocomplete-tag-border-radius, var(--ml-radius-full));
259
259
  object-fit: cover;
260
- margin-left: -2px;
260
+ margin-inline-start: -2px;
261
261
  }
262
262
 
263
263
  .ml-autocomplete__tag-remove {
264
264
  border: none;
265
265
  background: transparent;
266
266
  padding: 2px;
267
- margin-left: var(--ml-space-0-5);
268
- margin-right: -4px;
267
+ margin-inline-start: var(--ml-space-0-5);
268
+ margin-inline-end: -4px;
269
269
  color: var(--ml-autocomplete-tag-remove-color, var(--ml-color-text-secondary));
270
270
  cursor: pointer;
271
271
  display: inline-flex;
@@ -398,7 +398,7 @@ export const autocompleteStyles = () => css `
398
398
  .ml-autocomplete__option-check {
399
399
  flex-shrink: 0;
400
400
  color: var(--ml-autocomplete-option-check-color, var(--ml-color-primary));
401
- margin-left: auto;
401
+ margin-inline-start: auto;
402
402
  }
403
403
 
404
404
  /* Hint / Error */
@@ -444,4 +444,20 @@ export const autocompleteStyles = () => css `
444
444
  .ml-autocomplete--disabled {
445
445
  pointer-events: none;
446
446
  }
447
+
448
+ /*
449
+ * Forced colors (Windows High Contrast): box-shadow rings and background
450
+ * highlights are not painted there, so focus falls back to a real outline.
451
+ */
452
+ @media (forced-colors: active) {
453
+ .ml-autocomplete__trigger:focus-within {
454
+ outline: 2px solid Highlight;
455
+ outline-offset: 2px;
456
+ }
457
+
458
+ .ml-autocomplete__option--focused {
459
+ outline: 2px solid Highlight;
460
+ outline-offset: -2px;
461
+ }
462
+ }
447
463
  `;
@@ -48,7 +48,7 @@ export function autocompleteTemplate(c) {
48
48
  </div>
49
49
  </div>
50
50
 
51
- ${when(!!c.error, () => html `<span class="ml-autocomplete__error">${c.error}</span>`, () => html `${when(!!c.hint, () => html `<span class="ml-autocomplete__hint">${c.hint}</span>`)}`)}
51
+ ${when(!!c.error, () => html `<span id=${c.errorId} class="ml-autocomplete__error">${c.error}</span>`, () => html `${when(!!c.hint, () => html `<span id=${c.hintId} class="ml-autocomplete__hint">${c.hint}</span>`)}`)}
52
52
  </div>
53
53
  `;
54
54
  }
@@ -65,6 +65,9 @@ function renderSingleValue(c) {
65
65
  aria-autocomplete="list"
66
66
  aria-haspopup="listbox"
67
67
  aria-activedescendant=${c.activeDescendant}
68
+ aria-describedby=${c.describedBy}
69
+ aria-invalid=${c.error ? 'true' : undefined}
70
+ aria-required=${c.required ? 'true' : undefined}
68
71
  placeholder=${c.hasValue ? c.displayText : c.placeholder}
69
72
  aria-label=${c.label || c.placeholder || 'Search'}
70
73
  .value=${c.hasValue && !c.search ? c.displayText : c.search}
@@ -106,6 +109,9 @@ function renderMultiValue(c) {
106
109
  aria-autocomplete="list"
107
110
  aria-haspopup="listbox"
108
111
  aria-activedescendant=${c.activeDescendant}
112
+ aria-describedby=${c.describedBy}
113
+ aria-invalid=${c.error ? 'true' : undefined}
114
+ aria-required=${c.required ? 'true' : undefined}
109
115
  placeholder=${c.values.length ? '' : c.placeholder}
110
116
  aria-label=${c.label || c.placeholder || 'Search'}
111
117
  .value=${c.search}
@@ -1 +1 @@
1
- {"version":3,"file":"button.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iDAiQxB,CAAC"}
1
+ {"version":3,"file":"button.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,iDA4QxB,CAAC"}
@@ -256,4 +256,15 @@ export const buttonStyles = () => css `
256
256
  ::slotted(ml-icon) {
257
257
  --ml-icon-size: 1.125em;
258
258
  }
259
+
260
+ /*
261
+ * Forced colors (Windows High Contrast): box-shadow rings and background
262
+ * highlights are not painted there, so focus falls back to a real outline.
263
+ */
264
+ @media (forced-colors: active) {
265
+ .ml-button:focus-visible {
266
+ outline: 2px solid Highlight;
267
+ outline-offset: 2px;
268
+ }
269
+ }
259
270
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"button-group-item.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button-group/button-group-item.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,iDA2GjC,CAAC"}
1
+ {"version":3,"file":"button-group-item.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button-group/button-group-item.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,iDAsHjC,CAAC"}
@@ -106,4 +106,15 @@ export const buttonGroupItemStyles = () => css `
106
106
  opacity: 0.5;
107
107
  cursor: not-allowed;
108
108
  }
109
+
110
+ /*
111
+ * Forced colors (Windows High Contrast): box-shadow rings and background
112
+ * highlights are not painted there, so focus falls back to a real outline.
113
+ */
114
+ @media (forced-colors: active) {
115
+ .ml-button-group-item:focus-visible {
116
+ outline: 2px solid Highlight;
117
+ outline-offset: 2px;
118
+ }
119
+ }
109
120
  `;
@@ -40,10 +40,10 @@ export const buttonGroupStyles = () => css `
40
40
  }
41
41
 
42
42
  ::slotted(ml-button-group-item) {
43
- margin-left: var(--ml-button-group-item-offset, -1px);
43
+ margin-inline-start: var(--ml-button-group-item-offset, -1px);
44
44
  }
45
45
 
46
46
  ::slotted(ml-button-group-item:first-child) {
47
- margin-left: 0;
47
+ margin-inline-start: 0;
48
48
  }
49
49
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/checkbox/checkbox.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDA4K1B,CAAC"}
1
+ {"version":3,"file":"checkbox.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/checkbox/checkbox.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAuL1B,CAAC"}
@@ -116,7 +116,7 @@ export const checkboxStyles = () => css `
116
116
  .ml-checkbox__hint {
117
117
  display: block;
118
118
  margin-top: var(--ml-space-0-5);
119
- margin-left: calc(var(--ml-checkbox-box-size, 1.25rem) + var(--ml-checkbox-gap, var(--ml-space-3)));
119
+ margin-inline-start: calc(var(--ml-checkbox-box-size, 1.25rem) + var(--ml-checkbox-gap, var(--ml-space-3)));
120
120
  font-size: var(--ml-checkbox-hint-font-size, var(--ml-text-sm));
121
121
  color: var(--ml-checkbox-hint-color, var(--ml-color-text-muted));
122
122
  line-height: var(--ml-leading-tight);
@@ -125,7 +125,7 @@ export const checkboxStyles = () => css `
125
125
  .ml-checkbox__error {
126
126
  display: block;
127
127
  margin-top: var(--ml-checkbox-error-margin-top, var(--ml-space-0-5));
128
- margin-left: calc(var(--ml-checkbox-box-size, 1.25rem) + var(--ml-checkbox-gap, var(--ml-space-3)));
128
+ margin-inline-start: calc(var(--ml-checkbox-box-size, 1.25rem) + var(--ml-checkbox-gap, var(--ml-space-3)));
129
129
  font-size: var(--ml-checkbox-hint-font-size, var(--ml-text-sm));
130
130
  color: var(--ml-checkbox-error-color, var(--ml-color-danger));
131
131
  line-height: var(--ml-checkbox-error-line-height, var(--ml-leading-tight));
@@ -171,4 +171,15 @@ export const checkboxStyles = () => css `
171
171
  --ml-checkbox-label-font-size: var(--ml-text-base);
172
172
  --ml-checkbox-label-line-height: 1.5rem;
173
173
  }
174
+
175
+ /*
176
+ * Forced colors (Windows High Contrast): box-shadow rings and background
177
+ * highlights are not painted there, so focus falls back to a real outline.
178
+ */
179
+ @media (forced-colors: active) {
180
+ .ml-checkbox__input:focus-visible + .ml-checkbox__box {
181
+ outline: 2px solid Highlight;
182
+ outline-offset: 2px;
183
+ }
184
+ }
174
185
  `;
@@ -1,4 +1,4 @@
1
- import type { IElementRef, OnInit, OnAttributeChange } from '@melodicdev/core';
1
+ import type { IElementRef, OnInit, OnRender } from '@melodicdev/core';
2
2
  export interface CalendarDay {
3
3
  date: number;
4
4
  month: number;
@@ -36,7 +36,7 @@ export type CalendarView = 'day' | 'month' | 'year';
36
36
  *
37
37
  * @fires ml:select - Emitted when a date is selected. Detail: { value: string }
38
38
  */
39
- export declare class CalendarComponent implements IElementRef, OnInit, OnAttributeChange {
39
+ export declare class CalendarComponent implements IElementRef, OnInit, OnRender {
40
40
  elementRef: HTMLElement;
41
41
  /** Selected date in ISO format (YYYY-MM-DD) */
42
42
  value: string;
@@ -57,12 +57,10 @@ export declare class CalendarComponent implements IElementRef, OnInit, OnAttribu
57
57
  /** First year shown on the current page of the year grid */
58
58
  yearPageStart: number;
59
59
  onInit(): void;
60
- onAttributeChange(name: string, _: unknown, newVal: unknown): void;
61
60
  /**
62
- * `.value=${iso}` never writes an attribute, so navigating to a
63
- * programmatically set date only worked when the consumer happened to use
64
- * `setAttribute`. The property hook covers both, since an observed
65
- * attribute write also lands on the property.
61
+ * Navigate to a newly set date. This is the only hook needed: an observed
62
+ * attribute write lands on the property too, while `.value=${iso}` never
63
+ * writes an attribute (so an attribute hook alone missed it).
66
64
  */
67
65
  onPropertyChange(name: string, _: unknown, newValue: unknown): void;
68
66
  private navigateToValue;
@@ -108,6 +106,21 @@ export declare class CalendarComponent implements IElementRef, OnInit, OnAttribu
108
106
  get monthTabStop(): number;
109
107
  /** Year cell that carries the tab stop. */
110
108
  get yearTabStop(): number;
109
+ /** Cell to focus once the next render has produced it (month changed by keyboard). */
110
+ private _pendingFocusKey;
111
+ onRender(): void;
112
+ /**
113
+ * Day-grid keyboard navigation (WAI-ARIA date picker pattern).
114
+ *
115
+ * Arrows move by a day / a week and cross month boundaries, PageUp /
116
+ * PageDown move by a month (with Shift: a year), Home / End go to the
117
+ * start / end of the week. Movement used to be index arithmetic over the
118
+ * enabled buttons of the visible month, so it stopped dead at the month's
119
+ * edges and jumped unevenly around disabled dates.
120
+ *
121
+ * Returns true when the key was handled.
122
+ */
123
+ private handleDayGridKey;
111
124
  handleGridKeyDown: (event: KeyboardEvent) => void;
112
125
  private computeYearPageStart;
113
126
  private selectedMonthForYear;
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/date-picker/calendar.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI/E,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AA8BpD;;;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EK,QAAQ,QAAO,IAAI,CAExB;IAEK,SAAS,QAAO,IAAI,CAOzB;IAEK,SAAS,QAAO,IAAI,CAOzB;IAEK,UAAU,QAAO,IAAI,CAI1B;IAEK,UAAU,QAAO,IAAI,CAI1B;IAEK,aAAa,QAAO,IAAI,CAG7B;IAEK,aAAa,QAAO,IAAI,CAG7B;IAEK,YAAY,QAAO,IAAI,CAI5B;IAEK,YAAY,QAAO,IAAI,CAI5B;IAIK,aAAa,QAAO,IAAI,CAE7B;IAEK,YAAY,QAAO,IAAI,CAO5B;IAEK,eAAe,GAAI,OAAO,aAAa,KAAG,IAAI,CAInD;IAEK,cAAc,GAAI,MAAM,YAAY,KAAG,IAAI,CAIhD;IAIK,SAAS,GAAI,KAAK,WAAW,KAAG,IAAI,CAYzC;IAEK,SAAS,QAAO,IAAI,CAgBzB;IAIF;;;;;;OAMG;IACI,SAAS,SAAM;IAEtB,0CAA0C;IAC1C,IAAW,UAAU,IAAI,MAAM,CAW9B;IAED,4CAA4C;IAC5C,IAAW,YAAY,IAAI,MAAM,CAYhC;IAED,2CAA2C;IAC3C,IAAW,WAAW,IAAI,MAAM,CAY/B;IAEM,iBAAiB,GAAI,OAAO,aAAa,KAAG,IAAI,CAmCrD;IAIF,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,UAAU;CAKlB"}
1
+ {"version":3,"file":"calendar.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/date-picker/calendar.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,E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IAavB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,gBAAgB;IAiDjB,iBAAiB,GAAI,OAAO,aAAa,KAAG,IAAI,CAwCrD;IAIF,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,UAAU;CAKlB"}
@@ -186,14 +186,19 @@ let CalendarComponent = class CalendarComponent {
186
186
  * keys move within it.
187
187
  */
188
188
  this.rovingKey = '';
189
+ /** Cell to focus once the next render has produced it (month changed by keyboard). */
190
+ this._pendingFocusKey = '';
189
191
  this.handleGridKeyDown = (event) => {
190
192
  const key = event.key;
191
- if (key !== 'ArrowLeft' && key !== 'ArrowRight' && key !== 'ArrowUp' && key !== 'ArrowDown' && key !== 'Home' && key !== 'End') {
192
- return;
193
- }
194
193
  const target = event.target;
195
194
  if (!target || target.tagName !== 'BUTTON')
196
195
  return;
196
+ if (this.view === 'day' && this.handleDayGridKey(event, target.dataset.key ?? '')) {
197
+ return;
198
+ }
199
+ if (key !== 'ArrowLeft' && key !== 'ArrowRight' && key !== 'ArrowUp' && key !== 'ArrowDown' && key !== 'Home' && key !== 'End') {
200
+ return;
201
+ }
197
202
  const grid = target.closest('.ml-calendar__grid, .ml-calendar__cell-grid');
198
203
  if (!grid)
199
204
  return;
@@ -242,17 +247,10 @@ let CalendarComponent = class CalendarComponent {
242
247
  this.navigateToValue();
243
248
  this.yearPageStart = this.computeYearPageStart(this.viewYear);
244
249
  }
245
- onAttributeChange(name, _, newVal) {
246
- if (name === 'value' && newVal) {
247
- this.navigateToValue();
248
- this.yearPageStart = this.computeYearPageStart(this.viewYear);
249
- }
250
- }
251
250
  /**
252
- * `.value=${iso}` never writes an attribute, so navigating to a
253
- * programmatically set date only worked when the consumer happened to use
254
- * `setAttribute`. The property hook covers both, since an observed
255
- * attribute write also lands on the property.
251
+ * Navigate to a newly set date. This is the only hook needed: an observed
252
+ * attribute write lands on the property too, while `.value=${iso}` never
253
+ * writes an attribute (so an attribute hook alone missed it).
256
254
  */
257
255
  onPropertyChange(name, _, newValue) {
258
256
  if (name !== 'value' || !newValue) {
@@ -435,6 +433,83 @@ let CalendarComponent = class CalendarComponent {
435
433
  }
436
434
  return (candidates.find((year) => year.isSelected) ?? candidates.find((year) => year.isCurrent) ?? candidates[0]).year;
437
435
  }
436
+ onRender() {
437
+ if (!this._pendingFocusKey) {
438
+ return;
439
+ }
440
+ const key = this._pendingFocusKey;
441
+ this._pendingFocusKey = '';
442
+ const cell = this.elementRef.shadowRoot?.querySelector(`.ml-calendar__grid button[data-key="${key}"]`);
443
+ if (cell && !cell.disabled) {
444
+ cell.focus();
445
+ }
446
+ }
447
+ /**
448
+ * Day-grid keyboard navigation (WAI-ARIA date picker pattern).
449
+ *
450
+ * Arrows move by a day / a week and cross month boundaries, PageUp /
451
+ * PageDown move by a month (with Shift: a year), Home / End go to the
452
+ * start / end of the week. Movement used to be index arithmetic over the
453
+ * enabled buttons of the visible month, so it stopped dead at the month's
454
+ * edges and jumped unevenly around disabled dates.
455
+ *
456
+ * Returns true when the key was handled.
457
+ */
458
+ handleDayGridKey(event, fromIso) {
459
+ const parts = fromIso.split('-').map((part) => Number.parseInt(part, 10));
460
+ if (parts.length !== 3 || parts.some((part) => Number.isNaN(part))) {
461
+ return false;
462
+ }
463
+ const [year, month, day] = parts;
464
+ const from = new Date(year, month - 1, day);
465
+ let target;
466
+ switch (event.key) {
467
+ case 'ArrowLeft':
468
+ target = new Date(year, month - 1, day - 1);
469
+ break;
470
+ case 'ArrowRight':
471
+ target = new Date(year, month - 1, day + 1);
472
+ break;
473
+ case 'ArrowUp':
474
+ target = new Date(year, month - 1, day - 7);
475
+ break;
476
+ case 'ArrowDown':
477
+ target = new Date(year, month - 1, day + 7);
478
+ break;
479
+ case 'Home':
480
+ target = new Date(year, month - 1, day - from.getDay());
481
+ break;
482
+ case 'End':
483
+ target = new Date(year, month - 1, day + (6 - from.getDay()));
484
+ break;
485
+ case 'PageUp':
486
+ case 'PageDown': {
487
+ const step = (event.key === 'PageUp' ? -1 : 1) * (event.shiftKey ? 12 : 1);
488
+ const first = new Date(year, month - 1 + step, 1);
489
+ const lastDay = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate();
490
+ target = new Date(first.getFullYear(), first.getMonth(), Math.min(day, lastDay));
491
+ break;
492
+ }
493
+ default:
494
+ return false;
495
+ }
496
+ event.preventDefault();
497
+ const iso = toIso(target.getFullYear(), target.getMonth(), target.getDate());
498
+ if (this.isDisabled(iso)) {
499
+ return true;
500
+ }
501
+ this.rovingKey = iso;
502
+ if (target.getMonth() !== this.viewMonth || target.getFullYear() !== this.viewYear) {
503
+ // The cell does not exist (or is an inert other-month cell) until
504
+ // the new month renders; focus it from onRender.
505
+ this.viewMonth = target.getMonth();
506
+ this.viewYear = target.getFullYear();
507
+ this._pendingFocusKey = iso;
508
+ return true;
509
+ }
510
+ this.elementRef.shadowRoot?.querySelector(`.ml-calendar__grid button[data-key="${iso}"]`)?.focus();
511
+ return true;
512
+ }
438
513
  // ── Helpers ─────────────────────────────────────────────────────────────
439
514
  computeYearPageStart(year) {
440
515
  const minY = this.resolvedMinYear;
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/date-picker/calendar.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAgW1B,CAAC"}
1
+ {"version":3,"file":"calendar.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/date-picker/calendar.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAmX1B,CAAC"}
@@ -351,4 +351,23 @@ export const calendarStyles = () => css `
351
351
  outline: none;
352
352
  box-shadow: var(--ml-calendar-focus-shadow, var(--ml-shadow-focus-ring));
353
353
  }
354
+
355
+ /*
356
+ * Forced colors (Windows High Contrast): box-shadow rings and background
357
+ * highlights are not painted there, so focus falls back to a real outline.
358
+ */
359
+ @media (forced-colors: active) {
360
+ .ml-calendar__title-btn:focus-visible,
361
+ .ml-calendar__nav:focus-visible,
362
+ .ml-calendar__today-btn:focus-visible {
363
+ outline: 2px solid Highlight;
364
+ outline-offset: 2px;
365
+ }
366
+
367
+ .ml-calendar__cell:focus-visible,
368
+ .ml-calendar__day:focus-visible {
369
+ outline: 2px solid Highlight;
370
+ outline-offset: -2px;
371
+ }
372
+ }
354
373
  `;
@@ -2,7 +2,7 @@ import type { IElementRef, OnCreate, OnDestroy } from '@melodicdev/core';
2
2
  /**
3
3
  * ml-date-picker - Date input with calendar dropdown
4
4
  *
5
- * Users can type a date directly into the input (`MM/DD/YYYY` or `YYYY-MM-DD`)
5
+ * Users can type a date directly into the input (the locale's short date or `YYYY-MM-DD`)
6
6
  * or pick from the custom calendar popover. The input is a plain text field so
7
7
  * the native browser date picker never competes with the custom calendar.
8
8
  * `value` is always the ISO date (`YYYY-MM-DD`).
@@ -35,8 +35,7 @@ export declare class DatePickerComponent implements IElementRef, OnCreate, OnDes
35
35
  required: boolean;
36
36
  /**
37
37
  * BCP 47 locale for the displayed and accepted date format. Defaults to
38
- * the document's `lang`, then the browser's — the format used to be
39
- * hardcoded MM/DD/YYYY.
38
+ * the browser's locale — the format used to be hardcoded MM/DD/YYYY.
40
39
  */
41
40
  locale: string;
42
41
  /** Minimum selectable date (YYYY-MM-DD) */
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/date-picker/date-picker.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAmFzE;;;;;;;;;;;;;;;GAeG;AACH,qBAMa,mBAAoB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACpE,UAAU,EAAG,WAAW,CAAC;IAEhC,+CAA+C;IACxC,KAAK,SAAM;IAElB,uBAAuB;IAChB,WAAW,SAAiB;IAEnC,kBA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