@melodicdev/components 3.1.0 → 4.0.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/assets/melodic-components.js +4269 -2377
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +5477 -3831
- package/lib/components/data-display/calendar-view/calendar-view-month.template.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view-month.template.js +17 -0
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts +23 -3
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.component.js +76 -21
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +9 -0
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.js +68 -19
- package/lib/components/data-display/data-grid/data-grid.component.d.ts +24 -0
- package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.component.js +104 -31
- package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.template.js +3 -0
- package/lib/components/data-display/table/table.component.d.ts +7 -0
- package/lib/components/data-display/table/table.component.d.ts.map +1 -1
- package/lib/components/data-display/table/table.component.js +20 -5
- package/lib/components/data-display/table/table.template.d.ts.map +1 -1
- package/lib/components/data-display/table/table.template.js +3 -0
- package/lib/components/data-display/table-core/index.d.ts +1 -0
- package/lib/components/data-display/table-core/index.d.ts.map +1 -1
- package/lib/components/data-display/table-core/index.js +1 -0
- package/lib/components/data-display/table-core/memo.d.ts +10 -0
- package/lib/components/data-display/table-core/memo.d.ts.map +1 -0
- package/lib/components/data-display/table-core/memo.js +20 -0
- package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.styles.js +25 -0
- package/lib/components/feedback/progress/progress.styles.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.styles.js +8 -3
- package/lib/components/feedback/spinner/spinner.styles.d.ts.map +1 -1
- package/lib/components/feedback/spinner/spinner.styles.js +2 -11
- package/lib/components/feedback/toast/toast-container.template.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast-container.template.js +4 -0
- package/lib/components/feedback/toast/toast.component.d.ts +3 -2
- package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.component.js +10 -0
- package/lib/components/feedback/toast/toast.service.d.ts +26 -6
- package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.service.js +53 -18
- package/lib/components/feedback/toast/toast.template.js +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts +7 -0
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +39 -0
- package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.template.js +5 -1
- package/lib/components/forms/button-group/button-group.component.d.ts +3 -2
- package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.js +11 -1
- package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -0
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +5 -1
- package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.template.js +2 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts +21 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.component.js +69 -2
- package/lib/components/forms/date-picker/calendar.template.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.template.js +6 -3
- package/lib/components/forms/date-picker/date-picker.component.d.ts +6 -0
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +41 -12
- package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload.component.js +15 -5
- package/lib/components/forms/form-field/form-field.component.d.ts +8 -0
- package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
- package/lib/components/forms/form-field/form-field.component.js +41 -6
- package/lib/components/forms/form-field/form-field.template.js +1 -1
- package/lib/components/forms/input/input.component.d.ts +26 -3
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/input/input.component.js +46 -6
- package/lib/components/forms/input/input.template.d.ts.map +1 -1
- package/lib/components/forms/input/input.template.js +9 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card-group.component.js +34 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card.component.js +7 -1
- package/lib/components/forms/radio-card-group/radio-card.template.js +1 -1
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +13 -1
- package/lib/components/forms/select/select.template.d.ts.map +1 -1
- package/lib/components/forms/select/select.template.js +5 -1
- package/lib/components/forms/textarea/textarea.component.d.ts +10 -3
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.component.js +10 -5
- package/lib/components/forms/textarea/textarea.template.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.template.js +2 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts +16 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/time-picker/time-picker.component.js +43 -3
- package/lib/components/foundation/container/container.component.js +5 -5
- package/lib/components/foundation/container/container.styles.d.ts.map +1 -1
- package/lib/components/foundation/container/container.styles.js +10 -0
- package/lib/components/foundation/stack/stack.component.d.ts +6 -0
- package/lib/components/foundation/stack/stack.component.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.component.js +11 -5
- package/lib/components/foundation/stack/stack.styles.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.styles.js +14 -0
- package/lib/components/general/icon/icon.template.d.ts.map +1 -1
- package/lib/components/general/icon/icon.template.js +7 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +2 -1
- package/lib/components/navigation/functions/match-by-route.function.d.ts +16 -0
- package/lib/components/navigation/functions/match-by-route.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/match-by-route.function.js +34 -0
- package/lib/components/navigation/functions/route-link.function.d.ts +20 -0
- package/lib/components/navigation/functions/route-link.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/route-link.function.js +34 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts +8 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.component.js +12 -2
- package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.styles.js +10 -0
- package/lib/components/navigation/pagination/pagination.template.js +2 -2
- package/lib/components/navigation/sidebar/sidebar-item.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar-item.template.js +5 -1
- package/lib/components/navigation/sidebar/sidebar.component.d.ts +12 -6
- package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.component.js +20 -12
- package/lib/components/navigation/sidebar/sidebar.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.template.js +5 -1
- package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.component.js +19 -1
- package/lib/components/navigation/steps/step.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.template.js +6 -0
- package/lib/components/navigation/steps/steps.component.d.ts +10 -0
- package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.component.js +42 -9
- package/lib/components/navigation/steps/steps.template.js +9 -0
- package/lib/components/navigation/tabs/tab-panel.styles.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.styles.js +7 -2
- package/lib/components/navigation/tabs/tabs.component.d.ts +10 -0
- package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.component.js +36 -7
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts +19 -9
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog-ref.class.js +37 -5
- package/lib/components/overlays/dropdown/dropdown.component.d.ts +7 -0
- package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown.component.js +26 -11
- package/lib/components/overlays/popover/popover.component.d.ts +8 -0
- package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
- package/lib/components/overlays/popover/popover.component.js +17 -0
- package/lib/components/overlays/tooltip/tooltip.component.d.ts +6 -5
- package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.component.js +14 -10
- package/lib/components/sections/app-shell/app-shell.component.d.ts +13 -0
- package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.component.js +45 -1
- package/lib/components/sections/app-shell/app-shell.styles.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.styles.js +15 -0
- package/lib/components/sections/app-shell/app-shell.template.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.template.js +5 -0
- package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.template.js +6 -1
- package/lib/directives/tooltip.directive.d.ts.map +1 -1
- package/lib/directives/tooltip.directive.js +39 -6
- package/lib/theme/functions/apply-theme.function.d.ts +4 -1
- package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
- package/lib/theme/functions/apply-theme.function.js +20 -4
- package/lib/theme/functions/create-theme.function.js +0 -1
- package/lib/utils/accessibility/cross-root-aria.d.ts +40 -0
- package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -0
- package/lib/utils/accessibility/cross-root-aria.js +97 -0
- package/lib/utils/accessibility/index.d.ts +1 -0
- package/lib/utils/accessibility/index.d.ts.map +1 -1
- package/lib/utils/accessibility/index.js +1 -0
- package/lib/utils/directives/index.d.ts +1 -0
- package/lib/utils/directives/index.d.ts.map +1 -1
- package/lib/utils/directives/index.js +1 -0
- package/lib/utils/directives/watch-light-slots.d.ts +20 -0
- package/lib/utils/directives/watch-light-slots.d.ts.map +1 -0
- package/lib/utils/directives/watch-light-slots.js +36 -0
- package/package.json +2 -2
|
@@ -17,18 +17,31 @@ registerAdapter((el) => el.tagName === 'ML-DATE-PICKER', {
|
|
|
17
17
|
setValue: (el, value) => { el.value = value !== null && value !== undefined ? String(value) : ''; },
|
|
18
18
|
setDisabled: (el, disabled) => { el.disabled = disabled; }
|
|
19
19
|
});
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Format an ISO date (YYYY-MM-DD) for display in `locale`.
|
|
22
|
+
*
|
|
23
|
+
* The display format used to be hardcoded MM/DD/YYYY, which is wrong almost
|
|
24
|
+
* everywhere outside the US. `Intl` picks the locale's own numeric order.
|
|
25
|
+
*/
|
|
26
|
+
function formatDisplayDate(iso, locale) {
|
|
22
27
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso ?? '');
|
|
23
28
|
if (!match)
|
|
24
29
|
return iso ?? '';
|
|
25
|
-
|
|
30
|
+
const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
|
|
31
|
+
return new Intl.DateTimeFormat(locale || undefined, { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date);
|
|
32
|
+
}
|
|
33
|
+
/** Order of the numeric parts in `locale`'s short date format. */
|
|
34
|
+
function localeDateOrder(locale) {
|
|
35
|
+
const parts = new Intl.DateTimeFormat(locale || undefined, { year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(new Date(2001, 1, 3));
|
|
36
|
+
return parts
|
|
37
|
+
.filter((part) => part.type === 'year' || part.type === 'month' || part.type === 'day')
|
|
38
|
+
.map((part) => part.type);
|
|
26
39
|
}
|
|
27
40
|
/**
|
|
28
41
|
* Parse typed text into an ISO date (YYYY-MM-DD).
|
|
29
42
|
* Accepts `YYYY-MM-DD`, `MM/DD/YYYY`, and `M/D/YYYY`. Returns null when invalid.
|
|
30
43
|
*/
|
|
31
|
-
function parseDateInput(text) {
|
|
44
|
+
function parseDateInput(text, locale) {
|
|
32
45
|
const trimmed = text.trim();
|
|
33
46
|
let year;
|
|
34
47
|
let month;
|
|
@@ -40,12 +53,22 @@ function parseDateInput(text) {
|
|
|
40
53
|
day = Number(match[3]);
|
|
41
54
|
}
|
|
42
55
|
else {
|
|
43
|
-
|
|
56
|
+
// Accept the locale's own part order rather than assuming MM/DD/YYYY —
|
|
57
|
+
// a user typing 03/02/2001 in en-GB means 3 February.
|
|
58
|
+
match = /^(\d{1,4})[/.-](\d{1,2})[/.-](\d{1,4})$/.exec(trimmed);
|
|
44
59
|
if (!match)
|
|
45
60
|
return null;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
const order = localeDateOrder(locale);
|
|
62
|
+
const values = { year: 0, month: 0, day: 0 };
|
|
63
|
+
order.forEach((part, index) => {
|
|
64
|
+
values[part] = Number(match[index + 1]);
|
|
65
|
+
});
|
|
66
|
+
year = values.year;
|
|
67
|
+
month = values.month;
|
|
68
|
+
day = values.day;
|
|
69
|
+
if (year < 100) {
|
|
70
|
+
year += year < 50 ? 2000 : 1900;
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
73
|
if (month < 1 || month > 12)
|
|
51
74
|
return null;
|
|
@@ -88,6 +111,12 @@ let DatePickerComponent = class DatePickerComponent {
|
|
|
88
111
|
this.disabled = false;
|
|
89
112
|
/** Required state */
|
|
90
113
|
this.required = false;
|
|
114
|
+
/**
|
|
115
|
+
* BCP 47 locale for the displayed and accepted date format. Defaults to
|
|
116
|
+
* the document's `lang`, then the browser's — the format used to be
|
|
117
|
+
* hardcoded MM/DD/YYYY.
|
|
118
|
+
*/
|
|
119
|
+
this.locale = '';
|
|
91
120
|
/** Minimum selectable date (YYYY-MM-DD) */
|
|
92
121
|
this.min = '';
|
|
93
122
|
/** Maximum selectable date (YYYY-MM-DD) */
|
|
@@ -122,12 +151,12 @@ let DatePickerComponent = class DatePickerComponent {
|
|
|
122
151
|
input.value = '';
|
|
123
152
|
return;
|
|
124
153
|
}
|
|
125
|
-
const iso = parseDateInput(text);
|
|
154
|
+
const iso = parseDateInput(text, this.locale);
|
|
126
155
|
if (iso && this.isWithinRange(iso)) {
|
|
127
156
|
this.commitValue(iso);
|
|
128
157
|
// Normalize the display immediately (re-render may be skipped when the
|
|
129
158
|
// committed value is unchanged).
|
|
130
|
-
input.value = formatDisplayDate(iso);
|
|
159
|
+
input.value = formatDisplayDate(iso, this.locale);
|
|
131
160
|
}
|
|
132
161
|
else {
|
|
133
162
|
// Invalid or out-of-range input: revert to the last committed value,
|
|
@@ -185,7 +214,7 @@ let DatePickerComponent = class DatePickerComponent {
|
|
|
185
214
|
}
|
|
186
215
|
/** The formatted text shown in the input (MM/DD/YYYY) */
|
|
187
216
|
get displayValue() {
|
|
188
|
-
return formatDisplayDate(this.value);
|
|
217
|
+
return formatDisplayDate(this.value, this.locale);
|
|
189
218
|
}
|
|
190
219
|
onCreate() {
|
|
191
220
|
const popoverEl = this.getPopoverEl();
|
|
@@ -251,7 +280,7 @@ DatePickerComponent = __decorate([
|
|
|
251
280
|
selector: 'ml-date-picker',
|
|
252
281
|
template: datePickerTemplate,
|
|
253
282
|
styles: datePickerStyles,
|
|
254
|
-
attributes: ['value', 'placeholder', 'label', 'hint', 'error', 'size', 'disabled', 'required', 'min', 'max', 'min-year', 'max-year']
|
|
283
|
+
attributes: ['value', 'placeholder', 'label', 'hint', 'error', 'size', 'disabled', 'required', 'min', 'max', 'min-year', 'max-year', 'locale']
|
|
255
284
|
})
|
|
256
285
|
], DatePickerComponent);
|
|
257
286
|
export { DatePickerComponent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/file-upload/file-upload.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgCpD;;;;;GAKG;AACH,qBAMa,mBAAoB,YAAW,WAAW;IAC/C,UAAU,EAAG,WAAW,CAAC;IAEzB,MAAM,SAAM;IACZ,QAAQ,UAAS;IACjB,OAAO,SAAK;IACZ,QAAQ,SAAK;IACb,QAAQ,UAAS;IACjB,KAAK,SAAqB;IAC1B,QAAQ,SAAsB;IAC9B,IAAI,SAAM;IACV,KAAK,SAAM;IACX,IAAI,SAAoB;IAExB,QAAQ,UAAS;IACxB,OAAO,CAAC,YAAY,CAAK;IAEzB;;;;;OAKG;IACI,KAAK,EAAE,IAAI,EAAE,CAAM;IAE1B,6EAA6E;IACtE,UAAU,GAAI,MAAM,IAAI,KAAG,IAAI,CAUpC;IAEK,WAAW,QAAO,IAAI,CAI3B;IAEK,eAAe,GAAI,OAAO,KAAK,KAAG,IAAI,CAK3C;IAEK,eAAe,GAAI,OAAO,SAAS,KAAG,IAAI,CAQ/C;IAEK,cAAc,GAAI,OAAO,SAAS,KAAG,IAAI,CAG9C;IAEK,eAAe,GAAI,OAAO,SAAS,KAAG,IAAI,CAO/C;IAEK,UAAU,GAAI,OAAO,SAAS,KAAG,IAAI,CAS1C;IAEK,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"file-upload.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/file-upload/file-upload.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgCpD;;;;;GAKG;AACH,qBAMa,mBAAoB,YAAW,WAAW;IAC/C,UAAU,EAAG,WAAW,CAAC;IAEzB,MAAM,SAAM;IACZ,QAAQ,UAAS;IACjB,OAAO,SAAK;IACZ,QAAQ,SAAK;IACb,QAAQ,UAAS;IACjB,KAAK,SAAqB;IAC1B,QAAQ,SAAsB;IAC9B,IAAI,SAAM;IACV,KAAK,SAAM;IACX,IAAI,SAAoB;IAExB,QAAQ,UAAS;IACxB,OAAO,CAAC,YAAY,CAAK;IAEzB;;;;;OAKG;IACI,KAAK,EAAE,IAAI,EAAE,CAAM;IAE1B,6EAA6E;IACtE,UAAU,GAAI,MAAM,IAAI,KAAG,IAAI,CAUpC;IAEK,WAAW,QAAO,IAAI,CAI3B;IAEK,eAAe,GAAI,OAAO,KAAK,KAAG,IAAI,CAK3C;IAEK,eAAe,GAAI,OAAO,SAAS,KAAG,IAAI,CAQ/C;IAEK,cAAc,GAAI,OAAO,SAAS,KAAG,IAAI,CAG9C;IAEK,eAAe,GAAI,OAAO,SAAS,KAAG,IAAI,CAO/C;IAEK,UAAU,GAAI,OAAO,SAAS,KAAG,IAAI,CAS1C;IAEK,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;CAuExC"}
|
|
@@ -71,7 +71,7 @@ let FileUploadComponent = class FileUploadComponent {
|
|
|
71
71
|
this.elementRef.dispatchEvent(new CustomEvent('ml:change', {
|
|
72
72
|
bubbles: true,
|
|
73
73
|
composed: true,
|
|
74
|
-
detail: { files: this.files }
|
|
74
|
+
detail: { files: this.files, removed: [file] }
|
|
75
75
|
}));
|
|
76
76
|
};
|
|
77
77
|
this.handleClick = () => {
|
|
@@ -152,9 +152,16 @@ let FileUploadComponent = class FileUploadComponent {
|
|
|
152
152
|
return true;
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
if (this.maxFiles > 0
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
if (this.maxFiles > 0) {
|
|
156
|
+
// `maxFiles` is a limit on the SELECTION, not on one batch. Counting
|
|
157
|
+
// per batch let three drops of two files each end up with six files
|
|
158
|
+
// under `max-files="2"`.
|
|
159
|
+
const alreadySelected = this.multiple ? this.files.length : 0;
|
|
160
|
+
const remaining = Math.max(0, this.maxFiles - alreadySelected);
|
|
161
|
+
if (validFiles.length > remaining) {
|
|
162
|
+
errors.push({ type: 'max-files', message: `Maximum ${this.maxFiles} files allowed` });
|
|
163
|
+
validFiles = validFiles.slice(0, remaining);
|
|
164
|
+
}
|
|
158
165
|
}
|
|
159
166
|
if (errors.length > 0) {
|
|
160
167
|
this.elementRef.dispatchEvent(new CustomEvent('ml:error', {
|
|
@@ -167,10 +174,13 @@ let FileUploadComponent = class FileUploadComponent {
|
|
|
167
174
|
// Track selection state (backs the forms adapter): accumulate in
|
|
168
175
|
// multiple mode, replace in single mode.
|
|
169
176
|
this.files = this.multiple ? [...this.files, ...validFiles] : validFiles.slice(0, 1);
|
|
177
|
+
// Report the full selection, as removeFile does. The two paths used
|
|
178
|
+
// to disagree — one sent the newly added files, the other the whole
|
|
179
|
+
// list — so a consumer could not read `detail.files` uniformly.
|
|
170
180
|
this.elementRef.dispatchEvent(new CustomEvent('ml:change', {
|
|
171
181
|
bubbles: true,
|
|
172
182
|
composed: true,
|
|
173
|
-
detail: { files: validFiles }
|
|
183
|
+
detail: { files: this.files, added: validFiles }
|
|
174
184
|
}));
|
|
175
185
|
}
|
|
176
186
|
}
|
|
@@ -53,6 +53,14 @@ export declare class FormFieldComponent implements IElementRef, OnCreate, OnRend
|
|
|
53
53
|
private _control;
|
|
54
54
|
private _controlResolved;
|
|
55
55
|
private connectSlottedControl;
|
|
56
|
+
/** Point the control at the hint/error elements across the shadow boundary. */
|
|
57
|
+
private syncDescription;
|
|
58
|
+
/**
|
|
59
|
+
* Focus the slotted control when the label is clicked. `<label for=…>` can
|
|
60
|
+
* only target an element in the same tree, so the label's `for` never
|
|
61
|
+
* resolved to the light-DOM control.
|
|
62
|
+
*/
|
|
63
|
+
handleLabelClick: (event: Event) => void;
|
|
56
64
|
private syncAttribute;
|
|
57
65
|
private findFormControl;
|
|
58
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/form-field/form-field.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAMa,kBAAmB,YAAW,WAAW,EAAE,QAAQ,EAAE,QAAQ;IAClE,UAAU,EAAG,WAAW,CAAC;IAEhC,iBAAiB;IACV,KAAK,SAAM;IAElB,wCAAwC;IACjC,IAAI,SAAM;IAEjB,iDAAiD;IAC1C,KAAK,SAAM;IAElB,iBAAiB;IACV,IAAI,EAAE,WAAW,CAAQ;IAEhC,yBAAyB;IAClB,WAAW,EAAE,oBAAoB,CAAc;IAEtD,qBAAqB;IACd,QAAQ,UAAS;IAExB,+BAA+B;IACxB,QAAQ,UAAS;IAExB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6D;IAEtF,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,WAAW,IAAI,MAAM,CAM/B;IAEM,QAAQ,IAAI,IAAI;IAIhB,QAAQ,IAAI,IAAI;IAOhB,gBAAgB,QAAO,IAAI,CAGhC;IAEF;;;sCAGkC;IAClC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,qBAAqB;
|
|
1
|
+
{"version":3,"file":"form-field.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/form-field/form-field.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAMa,kBAAmB,YAAW,WAAW,EAAE,QAAQ,EAAE,QAAQ;IAClE,UAAU,EAAG,WAAW,CAAC;IAEhC,iBAAiB;IACV,KAAK,SAAM;IAElB,wCAAwC;IACjC,IAAI,SAAM;IAEjB,iDAAiD;IAC1C,KAAK,SAAM;IAElB,iBAAiB;IACV,IAAI,EAAE,WAAW,CAAQ;IAEhC,yBAAyB;IAClB,WAAW,EAAE,oBAAoB,CAAc;IAEtD,qBAAqB;IACd,QAAQ,UAAS;IAExB,+BAA+B;IACxB,QAAQ,UAAS;IAExB,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6D;IAEtF,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,WAAW,IAAI,MAAM,CAM/B;IAEM,QAAQ,IAAI,IAAI;IAIhB,QAAQ,IAAI,IAAI;IAOhB,gBAAgB,QAAO,IAAI,CAGhC;IAEF;;;sCAGkC;IAClC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,qBAAqB;IAwC7B,+EAA+E;IAC/E,OAAO,CAAC,eAAe;IAwBvB;;;;OAIG;IACI,gBAAgB,GAAI,OAAO,KAAK,KAAG,IAAI,CAG5C;IAEF,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,eAAe;CAqCvB"}
|
|
@@ -55,6 +55,15 @@ let FormFieldComponent = class FormFieldComponent {
|
|
|
55
55
|
* doesn't re-assign the slot). */
|
|
56
56
|
this._control = null;
|
|
57
57
|
this._controlResolved = false;
|
|
58
|
+
/**
|
|
59
|
+
* Focus the slotted control when the label is clicked. `<label for=…>` can
|
|
60
|
+
* only target an element in the same tree, so the label's `for` never
|
|
61
|
+
* resolved to the light-DOM control.
|
|
62
|
+
*/
|
|
63
|
+
this.handleLabelClick = (event) => {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
this._control?.focus();
|
|
66
|
+
};
|
|
58
67
|
}
|
|
59
68
|
get fieldId() {
|
|
60
69
|
return this._fieldId;
|
|
@@ -101,15 +110,41 @@ let FormFieldComponent = class FormFieldComponent {
|
|
|
101
110
|
if (!control.id) {
|
|
102
111
|
control.id = this.fieldId;
|
|
103
112
|
}
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
|
|
113
|
+
// The hint and error live in THIS component's shadow root while the
|
|
114
|
+
// control is in the light DOM, so an `aria-describedby` IDREF between
|
|
115
|
+
// them never resolves. Element references do cross the boundary, so use
|
|
116
|
+
// `ariaDescribedByElements` where the browser supports it and fall back
|
|
117
|
+
// to copying the text into `aria-description`.
|
|
118
|
+
this.syncDescription(control);
|
|
107
119
|
this.syncAttribute(control, 'aria-invalid', this.error ? 'true' : null);
|
|
108
120
|
this.syncAttribute(control, 'aria-required', this.required ? 'true' : null);
|
|
109
|
-
//
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
// Mirror the field's disabled state onto the control, in BOTH
|
|
122
|
+
// directions — it used to be set to true and never cleared, so a field
|
|
123
|
+
// that started disabled could never be re-enabled.
|
|
124
|
+
if ('disabled' in control) {
|
|
125
|
+
control.disabled = this.disabled;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this.syncAttribute(control, 'aria-disabled', this.disabled ? 'true' : null);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Point the control at the hint/error elements across the shadow boundary. */
|
|
132
|
+
syncDescription(control) {
|
|
133
|
+
const root = this.elementRef.shadowRoot;
|
|
134
|
+
const describers = [this.error ? root?.getElementById(this.errorId) : null, this.hint ? root?.getElementById(this.hintId) : null].filter((element) => element !== null && element !== undefined);
|
|
135
|
+
const reflected = control;
|
|
136
|
+
if ('ariaDescribedByElements' in reflected) {
|
|
137
|
+
reflected.ariaDescribedByElements = describers.length > 0 ? describers : null;
|
|
138
|
+
this.syncAttribute(control, 'aria-description', null);
|
|
139
|
+
return;
|
|
112
140
|
}
|
|
141
|
+
// No element-reference support: carry the text itself. An IDREF here
|
|
142
|
+
// would point at nothing.
|
|
143
|
+
const description = describers
|
|
144
|
+
.map((element) => element.textContent?.trim() ?? '')
|
|
145
|
+
.filter(Boolean)
|
|
146
|
+
.join('. ');
|
|
147
|
+
this.syncAttribute(control, 'aria-description', description || null);
|
|
113
148
|
}
|
|
114
149
|
syncAttribute(el, name, value) {
|
|
115
150
|
if (value === null) {
|
|
@@ -11,7 +11,7 @@ export function formFieldTemplate(c) {
|
|
|
11
11
|
})}
|
|
12
12
|
>
|
|
13
13
|
${when(!!c.label, () => html `
|
|
14
|
-
<label class="ml-form-field__label"
|
|
14
|
+
<label class="ml-form-field__label" @click=${c.handleLabelClick}>
|
|
15
15
|
${c.label}
|
|
16
16
|
${when(c.required, () => html `<span class="ml-form-field__required">*</span>`)}
|
|
17
17
|
</label>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IElementRef
|
|
1
|
+
import type { IElementRef } from '@melodicdev/core';
|
|
2
2
|
import type { ControlSize } from '../../../types/index.js';
|
|
3
3
|
import type { InputType } from './input.types.js';
|
|
4
4
|
/**
|
|
@@ -20,7 +20,7 @@ import type { InputType } from './input.types.js';
|
|
|
20
20
|
* @fires ml:focus - Emitted on focus
|
|
21
21
|
* @fires ml:blur - Emitted on blur
|
|
22
22
|
*/
|
|
23
|
-
export declare class InputComponent implements IElementRef
|
|
23
|
+
export declare class InputComponent implements IElementRef {
|
|
24
24
|
elementRef: HTMLElement;
|
|
25
25
|
/** Input type */
|
|
26
26
|
type: InputType;
|
|
@@ -46,7 +46,30 @@ export declare class InputComponent implements IElementRef, OnInit {
|
|
|
46
46
|
autocomplete: string;
|
|
47
47
|
/** Internal focus state */
|
|
48
48
|
focused: boolean;
|
|
49
|
-
|
|
49
|
+
/** Form field name, forwarded to the inner input. */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Maximum input length. */
|
|
52
|
+
maxlength: number | null;
|
|
53
|
+
/** Minimum input length. */
|
|
54
|
+
minlength: number | null;
|
|
55
|
+
/** Minimum value (number/date types). */
|
|
56
|
+
min: string;
|
|
57
|
+
/** Maximum value (number/date types). */
|
|
58
|
+
max: string;
|
|
59
|
+
/** Step (number/date types). */
|
|
60
|
+
step: string;
|
|
61
|
+
/** Validation pattern. */
|
|
62
|
+
pattern: string;
|
|
63
|
+
/** Virtual-keyboard hint. */
|
|
64
|
+
inputmode: string;
|
|
65
|
+
/**
|
|
66
|
+
* Accessible name for the inner control when there is no visible label.
|
|
67
|
+
*
|
|
68
|
+
* An `aria-label` set on the HOST names the custom element, not the
|
|
69
|
+
* `<input>` inside its shadow root — which is the node a screen reader
|
|
70
|
+
* actually reaches — so an unlabelled field announced nothing useful.
|
|
71
|
+
*/
|
|
72
|
+
get fieldLabel(): string;
|
|
50
73
|
handleInput: (event: Event) => void;
|
|
51
74
|
handleChange: (event: Event) => void;
|
|
52
75
|
handleFocus: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/input/input.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"input.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/input/input.component.ts"],"names":[],"mappings":"AACA,OAA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AAU,QAAO,IAAI,CAQ1B;CACF"}
|
|
@@ -60,6 +60,22 @@ let InputComponent = class InputComponent {
|
|
|
60
60
|
this.autocomplete = 'off';
|
|
61
61
|
/** Internal focus state */
|
|
62
62
|
this.focused = false;
|
|
63
|
+
/** Form field name, forwarded to the inner input. */
|
|
64
|
+
this.name = '';
|
|
65
|
+
/** Maximum input length. */
|
|
66
|
+
this.maxlength = null;
|
|
67
|
+
/** Minimum input length. */
|
|
68
|
+
this.minlength = null;
|
|
69
|
+
/** Minimum value (number/date types). */
|
|
70
|
+
this.min = '';
|
|
71
|
+
/** Maximum value (number/date types). */
|
|
72
|
+
this.max = '';
|
|
73
|
+
/** Step (number/date types). */
|
|
74
|
+
this.step = '';
|
|
75
|
+
/** Validation pattern. */
|
|
76
|
+
this.pattern = '';
|
|
77
|
+
/** Virtual-keyboard hint. */
|
|
78
|
+
this.inputmode = '';
|
|
63
79
|
this.handleInput = (event) => {
|
|
64
80
|
const target = event.target;
|
|
65
81
|
this.value = target.value;
|
|
@@ -93,11 +109,15 @@ let InputComponent = class InputComponent {
|
|
|
93
109
|
}));
|
|
94
110
|
};
|
|
95
111
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Accessible name for the inner control when there is no visible label.
|
|
114
|
+
*
|
|
115
|
+
* An `aria-label` set on the HOST names the custom element, not the
|
|
116
|
+
* `<input>` inside its shadow root — which is the node a screen reader
|
|
117
|
+
* actually reaches — so an unlabelled field announced nothing useful.
|
|
118
|
+
*/
|
|
119
|
+
get fieldLabel() {
|
|
120
|
+
return this.label || this.elementRef?.getAttribute('aria-label') || this.placeholder || '';
|
|
101
121
|
}
|
|
102
122
|
};
|
|
103
123
|
InputComponent = __decorate([
|
|
@@ -105,7 +125,27 @@ InputComponent = __decorate([
|
|
|
105
125
|
selector: 'ml-input',
|
|
106
126
|
template: inputTemplate,
|
|
107
127
|
styles: inputStyles,
|
|
108
|
-
attributes: [
|
|
128
|
+
attributes: [
|
|
129
|
+
'type',
|
|
130
|
+
'value',
|
|
131
|
+
'placeholder',
|
|
132
|
+
'label',
|
|
133
|
+
'hint',
|
|
134
|
+
'error',
|
|
135
|
+
'size',
|
|
136
|
+
'disabled',
|
|
137
|
+
'readonly',
|
|
138
|
+
'required',
|
|
139
|
+
'autocomplete',
|
|
140
|
+
'name',
|
|
141
|
+
'maxlength',
|
|
142
|
+
'minlength',
|
|
143
|
+
'min',
|
|
144
|
+
'max',
|
|
145
|
+
'step',
|
|
146
|
+
'pattern',
|
|
147
|
+
'inputmode'
|
|
148
|
+
]
|
|
109
149
|
})
|
|
110
150
|
], InputComponent);
|
|
111
151
|
export { InputComponent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/input/input.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"input.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/input/input.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,aAAa,CAAC,CAAC,EAAE,cAAc,6CA4D9C"}
|
|
@@ -30,6 +30,15 @@ export function inputTemplate(c) {
|
|
|
30
30
|
?readonly=${c.readonly}
|
|
31
31
|
?required=${c.required}
|
|
32
32
|
autocomplete="${c.autocomplete}"
|
|
33
|
+
name="${c.name}"
|
|
34
|
+
maxlength=${c.maxlength ?? ''}
|
|
35
|
+
minlength=${c.minlength ?? ''}
|
|
36
|
+
min="${c.min}"
|
|
37
|
+
max="${c.max}"
|
|
38
|
+
step="${c.step}"
|
|
39
|
+
pattern="${c.pattern}"
|
|
40
|
+
inputmode="${c.inputmode}"
|
|
41
|
+
aria-label=${c.label ? '' : c.fieldLabel}
|
|
33
42
|
aria-invalid=${c.error ? 'true' : 'false'}
|
|
34
43
|
aria-describedby=${c.error ? 'error' : c.hint ? 'hint' : ''}
|
|
35
44
|
@input=${c.handleInput}
|
|
@@ -31,6 +31,12 @@ export declare class RadioCardGroupComponent implements IElementRef, OnCreate, O
|
|
|
31
31
|
onCreate(): void;
|
|
32
32
|
onRender(): void;
|
|
33
33
|
onDestroy(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Arrow-key navigation across the group, as the radio pattern requires.
|
|
36
|
+
* Cards live in their own shadow roots, so native radio grouping does not
|
|
37
|
+
* apply and this has to be done by hand (mirrors ml-radio-group).
|
|
38
|
+
*/
|
|
39
|
+
private readonly handleGroupKeyDown;
|
|
34
40
|
handleSlotChange: () => void;
|
|
35
41
|
private readonly _handleCardSelect;
|
|
36
42
|
private syncCards;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-card-group.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/radio-card-group/radio-card-group.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAazE;;;;;;;;;;;;GAYG;AACH,qBAMa,uBAAwB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACxE,UAAU,EAAG,WAAW,CAAC;IAEhC,+BAA+B;IACxB,KAAK,SAAM;IAElB,kBAAkB;IACX,KAAK,SAAM;IAElB,gBAAgB;IACT,IAAI,SAAM;IAEjB,oBAAoB;IACb,KAAK,SAAM;IAElB,yBAAyB;IAClB,WAAW,EAAE,UAAU,GAAG,YAAY,CAAc;IAE3D,qBAAqB;IACd,QAAQ,UAAS;IAExB,qBAAqB;IACd,QAAQ,UAAS;IAEjB,QAAQ,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"radio-card-group.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/radio-card-group/radio-card-group.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAazE;;;;;;;;;;;;GAYG;AACH,qBAMa,uBAAwB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACxE,UAAU,EAAG,WAAW,CAAC;IAEhC,+BAA+B;IACxB,KAAK,SAAM;IAElB,kBAAkB;IACX,KAAK,SAAM;IAElB,gBAAgB;IACT,IAAI,SAAM;IAEjB,oBAAoB;IACb,KAAK,SAAM;IAElB,yBAAyB;IAClB,WAAW,EAAE,UAAU,GAAG,YAAY,CAAc;IAE3D,qBAAqB;IACd,QAAQ,UAAS;IAExB,qBAAqB;IACd,QAAQ,UAAS;IAEjB,QAAQ,IAAI,IAAI;IAOhB,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAKxB;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAgCjC;IAEK,gBAAgB,QAAO,IAAI,CAEhC;IAEF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAYhC;IAEF,OAAO,CAAC,SAAS;CA0BjB"}
|
|
@@ -44,6 +44,33 @@ let RadioCardGroupComponent = class RadioCardGroupComponent {
|
|
|
44
44
|
this.disabled = false;
|
|
45
45
|
/** Required state */
|
|
46
46
|
this.required = false;
|
|
47
|
+
/**
|
|
48
|
+
* Arrow-key navigation across the group, as the radio pattern requires.
|
|
49
|
+
* Cards live in their own shadow roots, so native radio grouping does not
|
|
50
|
+
* apply and this has to be done by hand (mirrors ml-radio-group).
|
|
51
|
+
*/
|
|
52
|
+
this.handleGroupKeyDown = (event) => {
|
|
53
|
+
const keys = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'];
|
|
54
|
+
if (!keys.includes(event.key)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const cards = [...this.elementRef.querySelectorAll('ml-radio-card')].filter((card) => !card.hasAttribute('disabled') && !card.hasAttribute('group-disabled'));
|
|
58
|
+
if (cards.length === 0) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const currentIndex = Math.max(0, cards.findIndex((card) => (card.getAttribute('value') ?? '') === this.value));
|
|
62
|
+
const forward = event.key === 'ArrowDown' || event.key === 'ArrowRight';
|
|
63
|
+
const next = cards[(currentIndex + (forward ? 1 : -1) + cards.length) % cards.length];
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
this.value = next.getAttribute('value') ?? '';
|
|
66
|
+
this.syncCards();
|
|
67
|
+
next.focus();
|
|
68
|
+
this.elementRef.dispatchEvent(new CustomEvent('ml:change', {
|
|
69
|
+
bubbles: true,
|
|
70
|
+
composed: true,
|
|
71
|
+
detail: { value: this.value }
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
47
74
|
this.handleSlotChange = () => {
|
|
48
75
|
this.syncCards();
|
|
49
76
|
};
|
|
@@ -60,6 +87,7 @@ let RadioCardGroupComponent = class RadioCardGroupComponent {
|
|
|
60
87
|
}
|
|
61
88
|
onCreate() {
|
|
62
89
|
this.elementRef.addEventListener('ml:card-select', this._handleCardSelect);
|
|
90
|
+
this.elementRef.addEventListener('keydown', this.handleGroupKeyDown);
|
|
63
91
|
// Re-sync when slotted cards are added/removed.
|
|
64
92
|
this.elementRef.shadowRoot?.querySelector('slot')?.addEventListener('slotchange', this.handleSlotChange);
|
|
65
93
|
}
|
|
@@ -71,6 +99,7 @@ let RadioCardGroupComponent = class RadioCardGroupComponent {
|
|
|
71
99
|
}
|
|
72
100
|
onDestroy() {
|
|
73
101
|
this.elementRef.removeEventListener('ml:card-select', this._handleCardSelect);
|
|
102
|
+
this.elementRef.removeEventListener('keydown', this.handleGroupKeyDown);
|
|
74
103
|
}
|
|
75
104
|
syncCards() {
|
|
76
105
|
const cards = this.elementRef.querySelectorAll('ml-radio-card');
|
|
@@ -83,11 +112,16 @@ let RadioCardGroupComponent = class RadioCardGroupComponent {
|
|
|
83
112
|
}
|
|
84
113
|
}
|
|
85
114
|
}
|
|
115
|
+
// The tab stop is the selected card, or the first enabled one when
|
|
116
|
+
// nothing is selected yet — one stop for the whole group.
|
|
117
|
+
const enabled = [...cards].filter((card) => !card.hasAttribute('disabled'));
|
|
118
|
+
const tabStopCard = enabled.find((card) => (card.getAttribute('value') ?? '') === this.value) ?? enabled[0];
|
|
86
119
|
cards.forEach((card) => {
|
|
87
120
|
const cardValue = card.getAttribute('value') ?? '';
|
|
88
121
|
const isSelected = cardValue === this.value;
|
|
89
122
|
card.toggleAttribute('selected', isSelected);
|
|
90
123
|
card.toggleAttribute('group-disabled', this.disabled);
|
|
124
|
+
card.toggleAttribute('tab-stop', card === tabStopCard);
|
|
91
125
|
});
|
|
92
126
|
}
|
|
93
127
|
};
|
|
@@ -27,6 +27,12 @@ export declare class RadioCardComponent implements IElementRef {
|
|
|
27
27
|
disabled: boolean;
|
|
28
28
|
/** Disabled state from parent group */
|
|
29
29
|
groupDisabled: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether this card is the group's single tab stop. A radio group is ONE
|
|
32
|
+
* tab stop — every card being `tabindex="0"` made a five-option group five
|
|
33
|
+
* stops instead of one, and broke the expected arrow-key navigation.
|
|
34
|
+
*/
|
|
35
|
+
tabStop: boolean;
|
|
30
36
|
get isDisabled(): boolean;
|
|
31
37
|
handleClick: () => void;
|
|
32
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-card.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/radio-card-group/radio-card.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD;;;;;;;;;GASG;AACH,qBAMa,kBAAmB,YAAW,WAAW;IAC9C,UAAU,EAAG,WAAW,CAAC;IAEhC,4BAA4B;IACrB,KAAK,SAAM;IAElB,oBAAoB;IACb,KAAK,SAAM;IAElB,mCAAmC;IAC5B,WAAW,SAAM;IAExB,6DAA6D;IACtD,MAAM,SAAM;IAEnB,yBAAyB;IAClB,IAAI,SAAM;IAEjB,uDAAuD;IAChD,QAAQ,UAAS;IAExB,kCAAkC;IAC3B,QAAQ,UAAS;IAExB,uCAAuC;IAChC,aAAa,UAAS;IAE7B,IAAW,UAAU,IAAI,OAAO,CAE/B;IAEM,WAAW,QAAO,IAAI,CAS3B;CACF"}
|
|
1
|
+
{"version":3,"file":"radio-card.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/radio-card-group/radio-card.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD;;;;;;;;;GASG;AACH,qBAMa,kBAAmB,YAAW,WAAW;IAC9C,UAAU,EAAG,WAAW,CAAC;IAEhC,4BAA4B;IACrB,KAAK,SAAM;IAElB,oBAAoB;IACb,KAAK,SAAM;IAElB,mCAAmC;IAC5B,WAAW,SAAM;IAExB,6DAA6D;IACtD,MAAM,SAAM;IAEnB,yBAAyB;IAClB,IAAI,SAAM;IAEjB,uDAAuD;IAChD,QAAQ,UAAS;IAExB,kCAAkC;IAC3B,QAAQ,UAAS;IAExB,uCAAuC;IAChC,aAAa,UAAS;IAE7B;;;;OAIG;IACI,OAAO,UAAS;IAEvB,IAAW,UAAU,IAAI,OAAO,CAE/B;IAEM,WAAW,QAAO,IAAI,CAS3B;CACF"}
|
|
@@ -35,6 +35,12 @@ let RadioCardComponent = class RadioCardComponent {
|
|
|
35
35
|
this.disabled = false;
|
|
36
36
|
/** Disabled state from parent group */
|
|
37
37
|
this.groupDisabled = false;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this card is the group's single tab stop. A radio group is ONE
|
|
40
|
+
* tab stop — every card being `tabindex="0"` made a five-option group five
|
|
41
|
+
* stops instead of one, and broke the expected arrow-key navigation.
|
|
42
|
+
*/
|
|
43
|
+
this.tabStop = false;
|
|
38
44
|
this.handleClick = () => {
|
|
39
45
|
if (this.isDisabled)
|
|
40
46
|
return;
|
|
@@ -54,7 +60,7 @@ RadioCardComponent = __decorate([
|
|
|
54
60
|
selector: 'ml-radio-card',
|
|
55
61
|
template: radioCardTemplate,
|
|
56
62
|
styles: radioCardStyles,
|
|
57
|
-
attributes: ['value', 'label', 'description', 'detail', 'icon', 'selected', 'disabled', 'group-disabled']
|
|
63
|
+
attributes: ['value', 'label', 'description', 'detail', 'icon', 'selected', 'disabled', 'group-disabled', 'tab-stop']
|
|
58
64
|
})
|
|
59
65
|
], RadioCardComponent);
|
|
60
66
|
export { RadioCardComponent };
|
|
@@ -10,7 +10,7 @@ export function radioCardTemplate(c) {
|
|
|
10
10
|
role="radio"
|
|
11
11
|
aria-checked=${c.selected ? 'true' : 'false'}
|
|
12
12
|
aria-disabled=${c.isDisabled ? 'true' : 'false'}
|
|
13
|
-
tabindex=${c.isDisabled ? '-1' : '0'}
|
|
13
|
+
tabindex=${c.isDisabled || !c.tabStop ? '-1' : '0'}
|
|
14
14
|
@click=${c.handleClick}
|
|
15
15
|
@keydown=${(e) => { if (e.key === ' ' || e.key === 'Enter') {
|
|
16
16
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/select.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwBtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAEhC,iBAAiB;IACV,KAAK,SAAM;IAElB,yCAAyC;IAClC,WAAW,SAAsB;IAExC,mCAAmC;IAC5B,IAAI,SAAM;IAEjB,iDAAiD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AAG,MAAM,CAEvC;IAEF,sFAAsF;IACtF,IAAW,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAEhD;IAED,iCAAiC;IAC1B,MAAM,QAAO,IAAI,CAQtB;IAEF,wBAAwB;IACjB,IAAI,QAAO,IAAI,CAGpB;IAEF,yBAAyB;IAClB,KAAK,QAAO,IAAI,CAGrB;IAEF,uBAAuB;IAChB,YAAY,GAAI,QAAQ,YAAY,KAAG,IAAI,CAkBhD;IAEF,0CAA0C;IAC1C,OAAO,CAAC,YAAY;IAapB,6BAA6B;IACtB,iBAAiB,GAAI,OAAO,KAAK,EAAE,QAAQ,YAAY,KAAG,IAAI,CAGnE;IAEK,eAAe,GAAI,OAAO,KAAK,EAAE,OAAO,MAAM,KAAG,IAAI,CAY1D;IAEK,iBAAiB,GAAI,OAAO,KAAK,KAAG,IAAI,CAQ7C;IAEK,iBAAiB,GAAI,OAAO,KAAK,KAAG,IAAI,CAK7C;IAEF,gEAAgE;IAChE,OAAO,CAAC,eAAe;IAuBvB,8EAA8E;IAC9E,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,aAAa;IAIrB,iCAAiC;IACjC,OAAO,CAAC,SAAS;
|
|
1
|
+
{"version":3,"file":"select.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/select.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAwBtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAEhC,iBAAiB;IACV,KAAK,SAAM;IAElB,yCAAyC;IACl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|
|
@@ -332,8 +332,13 @@ let SelectComponent = class SelectComponent {
|
|
|
332
332
|
switch (event.key) {
|
|
333
333
|
case 'Enter':
|
|
334
334
|
case ' ':
|
|
335
|
-
|
|
335
|
+
// Space types a space in the search box, but Enter must commit
|
|
336
|
+
// the focused option from there too — in multiple mode the
|
|
337
|
+
// search input holds focus for the whole interaction, so Enter
|
|
338
|
+
// could not select anything at all.
|
|
339
|
+
if (isSearchInput && (event.key === ' ' || !this.isOpen || this.focusedIndex < 0)) {
|
|
336
340
|
return;
|
|
341
|
+
}
|
|
337
342
|
event.preventDefault();
|
|
338
343
|
if (this.isOpen && this.focusedIndex >= 0) {
|
|
339
344
|
const option = this.getActiveOptions()[this.focusedIndex];
|
|
@@ -346,6 +351,13 @@ let SelectComponent = class SelectComponent {
|
|
|
346
351
|
}
|
|
347
352
|
break;
|
|
348
353
|
case 'Escape':
|
|
354
|
+
// Only claim Escape while the listbox is actually open.
|
|
355
|
+
// preventDefault() on a closed control cancelled the platform's
|
|
356
|
+
// close-watcher, so an enclosing dialog or drawer could not be
|
|
357
|
+
// dismissed with Escape while focus sat on this field.
|
|
358
|
+
if (!this.isOpen) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
349
361
|
event.preventDefault();
|
|
350
362
|
this.close();
|
|
351
363
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/select.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"select.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/select/select.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG7D,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,6CAwEhD"}
|
|
@@ -45,7 +45,11 @@ export function selectTemplate(c) {
|
|
|
45
45
|
aria-multiselectable=${c.multiple || false}
|
|
46
46
|
>
|
|
47
47
|
${c.filteredOptions.length
|
|
48
|
-
? repeat(c.filteredOptions,
|
|
48
|
+
? repeat(c.filteredOptions,
|
|
49
|
+
// Key by identity only. Embedding the selection state in the
|
|
50
|
+
// key made every toggle destroy and rebuild the option's
|
|
51
|
+
// DOM — losing hover, focus and any in-flight click.
|
|
52
|
+
(option) => option.value, (option, index) => renderOption(c, option, index))
|
|
49
53
|
: html `<div class="ml-select__empty">No results found</div>`}
|
|
50
54
|
</div>
|
|
51
55
|
</div>
|