@aurodesignsystem/auro-formkit 5.8.1 → 5.9.1
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/CHANGELOG.md +4 -15
- package/README.md +4 -4
- package/components/bibtemplate/dist/iconVersion.d.ts +1 -1
- package/components/bibtemplate/dist/index.js +2 -2
- package/components/bibtemplate/dist/registered.js +2 -2
- package/components/checkbox/demo/api.min.js +1 -1
- package/components/checkbox/demo/index.min.js +1 -1
- package/components/checkbox/dist/index.js +1 -1
- package/components/checkbox/dist/registered.js +1 -1
- package/components/combobox/demo/api.md +7 -6
- package/components/combobox/demo/api.min.js +1698 -1038
- package/components/combobox/demo/index.min.js +1698 -1038
- package/components/combobox/dist/auro-combobox.d.ts +10 -8
- package/components/combobox/dist/index.js +128 -149
- package/components/combobox/dist/registered.js +128 -149
- package/components/counter/demo/api.min.js +37 -61
- package/components/counter/demo/index.min.js +37 -61
- package/components/counter/dist/index.js +37 -61
- package/components/counter/dist/registered.js +37 -61
- package/components/datepicker/demo/api.min.js +55 -148
- package/components/datepicker/demo/index.min.js +55 -148
- package/components/datepicker/dist/auro-datepicker.d.ts +1 -1
- package/components/datepicker/dist/iconVersion.d.ts +1 -1
- package/components/datepicker/dist/index.js +55 -148
- package/components/datepicker/dist/popoverVersion.d.ts +1 -1
- package/components/datepicker/dist/registered.js +55 -148
- package/components/dropdown/demo/api.min.js +33 -57
- package/components/dropdown/demo/index.min.js +33 -57
- package/components/dropdown/dist/iconVersion.d.ts +1 -1
- package/components/dropdown/dist/index.js +33 -57
- package/components/dropdown/dist/registered.js +33 -57
- package/components/form/demo/working.html +1 -1
- package/components/input/demo/api.min.js +5 -4
- package/components/input/demo/index.min.js +5 -4
- package/components/input/dist/base-input.d.ts +1 -1
- package/components/input/dist/iconVersion.d.ts +1 -1
- package/components/input/dist/index.js +5 -4
- package/components/input/dist/registered.js +5 -4
- package/components/menu/demo/api.js +4 -0
- package/components/menu/demo/api.md +271 -31
- package/components/menu/demo/api.min.js +1609 -863
- package/components/menu/demo/index.html +1 -0
- package/components/menu/demo/index.js +2 -0
- package/components/menu/demo/index.md +95 -1
- package/components/menu/demo/index.min.js +1544 -812
- package/components/menu/dist/auro-menu.context.d.ts +227 -0
- package/components/menu/dist/auro-menu.d.ts +98 -53
- package/components/menu/dist/auro-menuoption.d.ts +116 -14
- package/components/menu/dist/index.js +1457 -796
- package/components/menu/dist/registered.js +1456 -807
- package/components/radio/demo/api.min.js +1 -1
- package/components/radio/demo/index.min.js +1 -1
- package/components/radio/dist/index.js +1 -1
- package/components/radio/dist/registered.js +1 -1
- package/components/select/demo/api.md +8 -7
- package/components/select/demo/api.min.js +1617 -1056
- package/components/select/demo/index.min.js +1617 -1056
- package/components/select/dist/auro-select.d.ts +11 -35
- package/components/select/dist/index.js +98 -218
- package/components/select/dist/registered.js +98 -218
- package/package.json +8 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css, LitElement, html } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { ContextConsumer, createContext, ContextProvider } from '@lit/context';
|
|
3
3
|
import { unsafeStatic, literal, html as html$1 } from 'lit/static-html.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
|
|
6
7
|
var styleCss$1 = css`:focus:not(:focus-visible){outline:3px solid transparent}.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-font-size, 0.625rem);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);font-weight:var(--wcss-display-2xl-weight, 300);line-height:var(--wcss-display-2xl-line-height, 1.3);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem))}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);font-weight:var(--wcss-display-xl-weight, 300);line-height:var(--wcss-display-xl-line-height, 1.3);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem))}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);font-weight:var(--wcss-display-lg-weight, 300);line-height:var(--wcss-display-lg-line-height, 1.3);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem))}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-md-letter-spacing, 0);font-weight:var(--wcss-display-md-weight, 300);line-height:var(--wcss-display-md-line-height, 1.3);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem))}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);font-weight:var(--wcss-display-sm-weight, 300);line-height:var(--wcss-display-sm-line-height, 1.3);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem))}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);font-weight:var(--wcss-display-xs-weight, 300);line-height:var(--wcss-display-xs-line-height, 1.3);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem))}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);font-weight:var(--wcss-heading-xl-weight, 300);line-height:var(--wcss-heading-xl-line-height, 1.3);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem))}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);font-weight:var(--wcss-heading-lg-weight, 300);line-height:var(--wcss-heading-lg-line-height, 1.3);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem))}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);font-weight:var(--wcss-heading-md-weight, 300);line-height:var(--wcss-heading-md-line-height, 1.3);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem))}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);font-weight:var(--wcss-heading-sm-weight, 300);line-height:var(--wcss-heading-sm-line-height, 1.3);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem))}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);font-weight:var(--wcss-heading-xs-weight, 450);line-height:var(--wcss-heading-xs-line-height, 1.3);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem))}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);font-weight:var(--wcss-heading-2xs-weight, 450);line-height:var(--wcss-heading-2xs-line-height, 1.3);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem))}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-2xl-weight, 450);line-height:var(--wcss-accent-2xl-line-height, 1);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-xl-weight, 450);line-height:var(--wcss-accent-xl-line-height, 1.3);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));text-transform:uppercase}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);font-weight:var(--wcss-accent-lg-weight, 450);line-height:var(--wcss-accent-lg-line-height, 1.3);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);font-weight:var(--wcss-accent-md-weight, 500);line-height:var(--wcss-accent-md-line-height, 1.3);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));text-transform:uppercase}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);font-weight:var(--wcss-accent-sm-weight, 500);line-height:var(--wcss-accent-sm-line-height, 1.3);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-xs-weight, 500);line-height:var(--wcss-accent-xs-line-height, 1.3);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));text-transform:uppercase}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-2xs-weight, 450);line-height:var(--wcss-accent-2xs-line-height, 1.3);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));text-transform:uppercase}:host{display:block;vertical-align:middle;line-height:0}:host .menuWrapper{box-sizing:border-box;display:flex;flex-direction:column;width:100%;margin:0;padding:0}:host ::slotted(hr){box-sizing:content-box !important;height:0 !important;overflow:visible !important;margin:var(--ds-size-100, 0.5rem) 0 !important;border-width:0 !important;border-top-width:1px !important;border-top-style:solid !important}:host [loadingplaceholder].empty{opacity:0;position:absolute}:host [loadingplaceholder] slot[name=loadingIcon]{vertical-align:middle;display:inline-block;margin-bottom:var(--ds-size-25, 0.125rem)}:host [loadingplaceholder] slot[name=loadingIcon]::slotted(*){margin-right:var(--ds-size-150, 0.75rem)}:host([root]){overflow-y:auto}:host([root]) .menuWrapper.lg{padding:var(--ds-size-150, 0.75rem);gap:var(--ds-size-50, 0.25rem)}:host([root]) .menuWrapper.xl{padding:var(--ds-size-200, 1rem);gap:var(--ds-size-100, 0.5rem)}`;
|
|
@@ -113,6 +114,10 @@ class AuroElement extends LitElement {
|
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
var styleCss = css`.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-font-size, 0.625rem);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);font-weight:var(--wcss-display-2xl-weight, 300);line-height:var(--wcss-display-2xl-line-height, 1.3);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem))}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);font-weight:var(--wcss-display-xl-weight, 300);line-height:var(--wcss-display-xl-line-height, 1.3);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem))}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);font-weight:var(--wcss-display-lg-weight, 300);line-height:var(--wcss-display-lg-line-height, 1.3);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem))}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-md-letter-spacing, 0);font-weight:var(--wcss-display-md-weight, 300);line-height:var(--wcss-display-md-line-height, 1.3);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem))}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);font-weight:var(--wcss-display-sm-weight, 300);line-height:var(--wcss-display-sm-line-height, 1.3);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem))}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);font-weight:var(--wcss-display-xs-weight, 300);line-height:var(--wcss-display-xs-line-height, 1.3);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem))}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);font-weight:var(--wcss-heading-xl-weight, 300);line-height:var(--wcss-heading-xl-line-height, 1.3);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem))}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);font-weight:var(--wcss-heading-lg-weight, 300);line-height:var(--wcss-heading-lg-line-height, 1.3);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem))}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);font-weight:var(--wcss-heading-md-weight, 300);line-height:var(--wcss-heading-md-line-height, 1.3);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem))}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);font-weight:var(--wcss-heading-sm-weight, 300);line-height:var(--wcss-heading-sm-line-height, 1.3);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem))}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);font-weight:var(--wcss-heading-xs-weight, 450);line-height:var(--wcss-heading-xs-line-height, 1.3);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem))}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);font-weight:var(--wcss-heading-2xs-weight, 450);line-height:var(--wcss-heading-2xs-line-height, 1.3);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem))}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-2xl-weight, 450);line-height:var(--wcss-accent-2xl-line-height, 1);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-xl-weight, 450);line-height:var(--wcss-accent-xl-line-height, 1.3);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));text-transform:uppercase}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);font-weight:var(--wcss-accent-lg-weight, 450);line-height:var(--wcss-accent-lg-line-height, 1.3);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);font-weight:var(--wcss-accent-md-weight, 500);line-height:var(--wcss-accent-md-line-height, 1.3);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));text-transform:uppercase}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);font-weight:var(--wcss-accent-sm-weight, 500);line-height:var(--wcss-accent-sm-line-height, 1.3);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-xs-weight, 500);line-height:var(--wcss-accent-xs-line-height, 1.3);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));text-transform:uppercase}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-2xs-weight, 450);line-height:var(--wcss-accent-2xs-line-height, 1.3);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));text-transform:uppercase}:host{cursor:pointer;user-select:none;text-overflow:ellipsis;max-width:100dvw}:host .wrapper{display:flex;align-items:center;padding-right:var(--ds-size-200, 1rem);padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem));padding-top:var(--ds-size-50, 0.25rem);padding-bottom:var(--ds-size-50, 0.25rem);border-radius:var(--ds-size-100, 0.5rem);-webkit-tap-highlight-color:transparent}:host .wrapper[class*=shape-box]{border-radius:unset}:host .wrapper[class*=shape-snowflake]{border-radius:unset;line-height:24px}:host .wrapper[class*=shape-pill]{border-radius:30px}:host .wrapper[class*=-lg]{padding-top:var(--ds-size-75, 0.375rem);padding-bottom:var(--ds-size-75, 0.375rem);padding-right:var(--ds-size-150, 0.75rem);line-height:26px}:host .wrapper[class*=-xl]{padding-top:var(--ds-size-100, 0.5rem);padding-bottom:var(--ds-size-100, 0.5rem);padding-right:var(--ds-size-200, 1rem);line-height:26px}:host slot{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host [auro-icon]{--ds-auro-icon-size: var(--ds-size-300, 1.5rem);margin-right:var(--ds-size-150, 0.75rem);margin-left:var(--ds-size-100, 0.5rem)}:host ::slotted(.nestingSpacer){display:inline-block;width:var(--ds-size-300, 1.5rem)}[slot=displayValue]{display:none}:host([loadingplaceholder]) .wrapper{padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem))}:host([selected]) .wrapper{padding-left:0}:host([nocheckmark]) .wrapper{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-lg]{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-xl]{padding-left:var(--ds-size-200, 1rem)}:host([hidden]){display:none}:host([static]){pointer-events:none}:host([disabled]:hover){cursor:auto}:host([disabled]){user-select:none;pointer-events:none}`;
|
|
118
|
+
|
|
119
|
+
var colorCss = css`:host .wrapper{background-color:var(--ds-auro-menuoption-container-color, transparent);box-shadow:inset 0 0 0 1px var(--ds-auro-menuoption-container-border-color, transparent);color:var(--ds-auro-menuoption-text-color)}:host svg{fill:var(--ds-auro-menuoption-icon-color)}:host([disabled]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:hover),:host(.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}:host(:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host([selected]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([selected]:hover),:host([selected].active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}:host([selected]:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host(:focus:hover),:host(:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host([selected]:focus:hover),:host([selected]:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}`;
|
|
120
|
+
|
|
116
121
|
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
117
122
|
// See LICENSE in the project root for license information.
|
|
118
123
|
|
|
@@ -196,22 +201,78 @@ class AuroLibraryRuntimeUtils {
|
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
|
|
199
|
-
// Copyright (c)
|
|
204
|
+
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
200
205
|
// See LICENSE in the project root for license information.
|
|
201
206
|
|
|
202
207
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
class AuroDependencyVersioning {
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Generates a unique string to be used for child auro element naming.
|
|
212
|
+
* @private
|
|
213
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
214
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
215
|
+
* @returns {string} - Unique string to be used for naming.
|
|
216
|
+
*/
|
|
217
|
+
generateElementName(baseName, version) {
|
|
218
|
+
let result = baseName;
|
|
219
|
+
|
|
220
|
+
result += '-';
|
|
221
|
+
result += version.replace(/[.]/g, '_');
|
|
222
|
+
|
|
223
|
+
return result;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Generates a unique string to be used for child auro element naming.
|
|
228
|
+
* @param {string} baseName - Defines the first part of the unique element name.
|
|
229
|
+
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
230
|
+
* @returns {string} - Unique string to be used for naming.
|
|
231
|
+
*/
|
|
232
|
+
generateTag(baseName, version, tagClass) {
|
|
233
|
+
const elementName = this.generateElementName(baseName, version);
|
|
234
|
+
const tag = literal`${unsafeStatic(elementName)}`;
|
|
235
|
+
|
|
236
|
+
if (!customElements.get(elementName)) {
|
|
237
|
+
customElements.define(elementName, class extends tagClass {});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return tag;
|
|
241
|
+
}
|
|
213
242
|
}
|
|
214
243
|
|
|
244
|
+
class p{registerComponent(t,a){customElements.get(t)||customElements.define(t,class extends a{});}closestElement(t,a=this,e=(a,s=a&&a.closest(t))=>a&&a!==document&&a!==window?s||e(a.getRootNode().host):null){return e(a)}handleComponentTagRename(t,a){const e=a.toLowerCase();t.tagName.toLowerCase()!==e&&t.setAttribute(e,true);}elementMatch(t,a){const e=a.toLowerCase();return t.tagName.toLowerCase()===e||t.hasAttribute(e)}}var u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error__desc" class="ico_squareLarge" data-deprecated="true" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error__desc">Error alert indicator.</desc><path d="m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583"/></svg>';class m extends LitElement{static get properties(){return {hidden:{type:Boolean,reflect:true},hiddenVisually:{type:Boolean,reflect:true},hiddenAudible:{type:Boolean,reflect:true}}}hideAudible(t){return t?"true":"false"}}const g=new Map,f=(t,a={})=>{const e=a.responseParser||(t=>t.text());return g.has(t)||g.set(t,fetch(t).then(e)),g.get(t)};var w=css`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, .75rem))}:host{color:currentColor;vertical-align:middle;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem)!important;width:var(--ds-auro-icon-size, 1.5rem)!important;height:var(--ds-auro-icon-size, 1.5rem)!important}.componentWrapper{display:flex;line-height:var(--ds-auro-icon-size)}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.svgWrapper [part=svg]{display:flex}.labelWrapper{margin-left:var(--ds-size-50, .25rem)}.labelWrapper ::slotted(*){line-height:inherit!important}
|
|
245
|
+
`;class z extends m{constructor(){super(),this.onDark=false,this.appearance="default";}static get properties(){return {...m.properties,onDark:{type:Boolean,reflect:true},appearance:{type:String,reflect:true},svg:{attribute:false,reflect:true}}}static get styles(){return w}async fetchIcon(t,a){let e="";e="logos"===t?await f(`${this.uri}/${t}/${a}.svg`):await f(`${this.uri}/icons/${t}/${a}.svg`);return (new DOMParser).parseFromString(e,"text/html").body.querySelector("svg")}async firstUpdated(){try{if(!this.customSvg){const t=await this.fetchIcon(this.category,this.name);if(t)this.svg=t;else if(!t){const t=(new DOMParser).parseFromString(u,"text/html");this.svg=t.body.firstChild;}}}catch(t){this.svg=void 0;}}}css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}:host{display:inline-block;--ds-auro-icon-size: 100%;width:100%;height:100%}:host .logo{color:var(--ds-auro-alaska-color)}:host([onDark]),:host([appearance=inverse]){--ds-auro-alaska-color: #FFF}
|
|
246
|
+
`;var y=css`:host{--ds-auro-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color: #02426D;--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}
|
|
247
|
+
`;var k=css`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]),:host(:not([appearance=inverse])[variant=accent1]){--ds-auro-icon-color: var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]),:host(:not([appearance=inverse])[variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]),:host(:not([appearance=inverse])[variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]),:host(:not([appearance=inverse])[variant=statusDefault]){--ds-auro-icon-color: var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]),:host(:not([appearance=inverse])[variant=statusInfo]){--ds-auro-icon-color: var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]),:host(:not([appearance=inverse])[variant=statusSuccess]){--ds-auro-icon-color: var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]),:host(:not([appearance=inverse])[variant=statusWarning]){--ds-auro-icon-color: var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]),:host(:not([appearance=inverse])[variant=statusError]){--ds-auro-icon-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]),:host(:not([appearance=inverse])[variant=statusInfoSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]),:host(:not([appearance=inverse])[variant=statusSuccessSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]),:host(:not([appearance=inverse])[variant=statusWarningSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]),:host(:not([appearance=inverse])[variant=statusErrorSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]),:host(:not([appearance=inverse])[variant=fareBasicEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]),:host(:not([appearance=inverse])[variant=fareBusiness]){--ds-auro-icon-color: var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]),:host(:not([appearance=inverse])[variant=fareEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]),:host(:not([appearance=inverse])[variant=fareFirst]){--ds-auro-icon-color: var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]),:host(:not([appearance=inverse])[variant=farePremiumEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]),:host(:not([appearance=inverse])[variant=tierOneWorldEmerald]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]),:host(:not([appearance=inverse])[variant=tierOneWorldSapphire]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]),:host(:not([appearance=inverse])[variant=tierOneWorldRuby]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]),:host([appearance=inverse]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]),:host([appearance=inverse][variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]),:host([appearance=inverse][variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]),:host([appearance=inverse][variant=statusError]){--ds-auro-icon-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}
|
|
248
|
+
`;class x extends z{constructor(){super(),this.variant=void 0,this.privateDefaults();}privateDefaults(){this.uri="https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist",this.runtimeUtils=new p;}static get properties(){return {...z.properties,ariaHidden:{type:String,reflect:true},category:{type:String,reflect:true},customColor:{type:Boolean,reflect:true},customSvg:{type:Boolean},label:{type:Boolean,reflect:true},name:{type:String,reflect:true},variant:{type:String,reflect:true}}}static get styles(){return [z.styles,y,w,k]}static register(t="auro-icon"){p.prototype.registerComponent(t,x);}connectedCallback(){super.connectedCallback(),this.runtimeUtils.handleComponentTagRename(this,"auro-icon");}exposeCssParts(){this.setAttribute("exportparts","svg:iconSvg");}async firstUpdated(){if(await super.firstUpdated(),this.hasAttribute("ariaHidden")&&this.svg){const t=this.svg.querySelector("desc");t&&(t.remove(),this.svg.removeAttribute("aria-labelledby"));}}render(){const t={labelWrapper:true,util_displayHiddenVisually:!this.label};return html`
|
|
249
|
+
<div class="componentWrapper">
|
|
250
|
+
<div
|
|
251
|
+
class="${classMap({svgWrapper:true})}"
|
|
252
|
+
title="${ifDefined(this.title||void 0)}">
|
|
253
|
+
<span aria-hidden="${ifDefined(this.ariaHidden||true)}" part="svg">
|
|
254
|
+
${this.customSvg?html`
|
|
255
|
+
<slot name="svg"></slot>
|
|
256
|
+
`:html`
|
|
257
|
+
${this.svg}
|
|
258
|
+
`}
|
|
259
|
+
</span>
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
<div class="${classMap(t)}" part="label">
|
|
263
|
+
<slot></slot>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
`}}
|
|
267
|
+
|
|
268
|
+
var iconVersion = '9.1.0';
|
|
269
|
+
|
|
270
|
+
var checkmarkIcon = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"checkmark-sm__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"checkmark-sm__desc\">a small check mark.</desc><path d=\"M8.461 11.84a.625.625 0 1 0-.922.844l2.504 2.738c.247.27.674.27.922 0l5.496-6a.625.625 0 1 0-.922-.844l-5.035 5.496z\"/></svg>"};
|
|
271
|
+
|
|
272
|
+
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
273
|
+
// See LICENSE in the project root for license information.
|
|
274
|
+
|
|
275
|
+
|
|
215
276
|
/**
|
|
216
277
|
* Helper method to dispatch custom events.
|
|
217
278
|
* @param {HTMLElement} element - Element to dispatch event from.
|
|
@@ -232,755 +293,1590 @@ function dispatchMenuEvent(element, eventName, detail = null) {
|
|
|
232
293
|
element.dispatchEvent(new CustomEvent(eventName, eventConfig));
|
|
233
294
|
}
|
|
234
295
|
|
|
235
|
-
// Copyright (c)
|
|
296
|
+
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
236
297
|
// See LICENSE in the project root for license information.
|
|
237
298
|
|
|
238
299
|
|
|
239
|
-
|
|
240
|
-
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
241
300
|
/**
|
|
242
|
-
* The auro-menu element provides users a way to
|
|
243
|
-
*
|
|
244
|
-
* @attr {
|
|
245
|
-
* @attr {
|
|
246
|
-
* @attr {
|
|
247
|
-
* @attr {
|
|
248
|
-
* @
|
|
249
|
-
* @
|
|
250
|
-
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
251
|
-
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
252
|
-
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
253
|
-
* @event {CustomEvent<{ loading: boolean; hasLoadingPlaceholder: boolean; }>} auroMenu-loadingChange - Notifies when the loading attribute is changed.
|
|
254
|
-
* @event {CustomEvent<any>} auroMenu-selectValueFailure - Notifies that an attempt to select a menuoption by matching a value has failed.
|
|
255
|
-
* @event {CustomEvent<any>} auroMenu-selectValueReset - Notifies that the component value has been reset.
|
|
256
|
-
* @event {CustomEvent<any>} auroMenu-selectedOption - Notifies that a new menuoption selection has been made.
|
|
257
|
-
* @slot loadingText - Text to show while loading attribute is set
|
|
258
|
-
* @slot loadingIcon - Icon to show while loading attribute is set
|
|
259
|
-
* @slot - Slot for insertion of menu options.
|
|
301
|
+
* The auro-menu element provides users a way to define a menu option.
|
|
302
|
+
*
|
|
303
|
+
* @attr {String} value - Specifies the value to be sent to a server.
|
|
304
|
+
* @attr {String} noCheckmark - When true, selected option will not show the checkmark.
|
|
305
|
+
* @attr {Boolean} disabled - When true specifies that the menuoption is disabled.
|
|
306
|
+
* @attr {Boolean} selected - Specifies that an option is selected.
|
|
307
|
+
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
308
|
+
* @slot - Specifies text for an option, but is not the value.
|
|
260
309
|
*/
|
|
310
|
+
class AuroMenuOption extends AuroElement {
|
|
261
311
|
|
|
262
|
-
|
|
312
|
+
/**
|
|
313
|
+
* This will register this element with the browser.
|
|
314
|
+
* @param {string} [name="auro-menuoption"] - The name of element that you want to register to.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* AuroMenuOption.register("custom-menuoption") // this will register this element to <custom-menuoption/>
|
|
318
|
+
*
|
|
319
|
+
*/
|
|
320
|
+
static register(name = "auro-menuoption") {
|
|
321
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenuOption);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Returns whether the menu option is currently active and selectable.
|
|
326
|
+
* An option is considered active if it is not hidden, not disabled, and not static.
|
|
327
|
+
* @returns {boolean} True if the option is active, false otherwise.
|
|
328
|
+
*/
|
|
329
|
+
get isActive() {
|
|
330
|
+
return !this.hasAttribute('hidden') &&
|
|
331
|
+
!this.disabled &&
|
|
332
|
+
!this.hasAttribute('static');
|
|
333
|
+
}
|
|
263
334
|
|
|
264
|
-
class AuroMenu extends AuroElement {
|
|
265
335
|
constructor() {
|
|
266
336
|
super();
|
|
267
337
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* @private
|
|
272
|
-
*/
|
|
273
|
-
this.shape = "box";
|
|
338
|
+
this.bindEvents();
|
|
274
339
|
|
|
275
340
|
/**
|
|
276
341
|
* @private
|
|
277
342
|
*/
|
|
278
|
-
this.
|
|
279
|
-
|
|
280
|
-
// Value of the selected options
|
|
281
|
-
this.value = undefined;
|
|
282
|
-
// Currently selected option
|
|
283
|
-
this.optionSelected = undefined;
|
|
284
|
-
// String used for highlighting/filtering
|
|
285
|
-
this.matchWord = undefined;
|
|
286
|
-
// Hide the checkmark icon on selected options
|
|
287
|
-
this.noCheckmark = false;
|
|
288
|
-
// Currently active option
|
|
289
|
-
this.optionActive = undefined;
|
|
290
|
-
// Loading state
|
|
291
|
-
this.loading = false;
|
|
292
|
-
// Multi-select mode
|
|
293
|
-
this.multiSelect = false;
|
|
294
|
-
|
|
295
|
-
// Event Bindings
|
|
343
|
+
this.shape = undefined;
|
|
296
344
|
|
|
297
345
|
/**
|
|
298
346
|
* @private
|
|
299
347
|
*/
|
|
300
|
-
this.
|
|
348
|
+
this.size = undefined;
|
|
301
349
|
|
|
302
350
|
/**
|
|
303
|
-
*
|
|
351
|
+
* Generate unique names for dependency components.
|
|
304
352
|
*/
|
|
305
|
-
|
|
353
|
+
const versioning = new AuroDependencyVersioning();
|
|
354
|
+
this.iconTag = versioning.generateTag('auro-formkit-menuoption-icon', iconVersion, x);
|
|
306
355
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
this.handleOptionHover = this.handleOptionHover.bind(this);
|
|
356
|
+
this.selected = false;
|
|
357
|
+
this.noCheckmark = false;
|
|
358
|
+
this.disabled = false;
|
|
311
359
|
|
|
312
360
|
/**
|
|
313
361
|
* @private
|
|
314
362
|
*/
|
|
315
|
-
this.
|
|
363
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
316
364
|
|
|
317
|
-
//
|
|
365
|
+
// Initialize context-related properties
|
|
366
|
+
this.menuService = null;
|
|
367
|
+
this.unsubscribe = null;
|
|
318
368
|
|
|
319
369
|
/**
|
|
320
370
|
* @private
|
|
321
371
|
*/
|
|
322
|
-
|
|
323
|
-
// Root-level menu (true) or a nested submenu (false)
|
|
324
|
-
rootMenu: true,
|
|
325
|
-
// Currently focused/active menu item index
|
|
326
|
-
index: -1,
|
|
327
|
-
// Nested menu spacer
|
|
328
|
-
nestingSpacer: '<span class="nestingSpacer"></span>',
|
|
329
|
-
// Loading indicator for slot elements
|
|
330
|
-
loadingSlots: null,
|
|
331
|
-
// Store for menu items
|
|
332
|
-
items: [],
|
|
333
|
-
});
|
|
372
|
+
this.handleMenuChange = this.handleMenuChange.bind(this);
|
|
334
373
|
}
|
|
335
374
|
|
|
336
375
|
static get properties() {
|
|
337
376
|
return {
|
|
338
377
|
...super.properties,
|
|
339
|
-
noCheckmark: {
|
|
340
|
-
type: Boolean,
|
|
341
|
-
reflect: true,
|
|
342
|
-
attribute: 'nocheckmark'
|
|
343
|
-
},
|
|
344
378
|
disabled: {
|
|
345
379
|
type: Boolean,
|
|
346
380
|
reflect: true
|
|
347
381
|
},
|
|
348
|
-
|
|
349
|
-
type:
|
|
382
|
+
event: {
|
|
383
|
+
type: String,
|
|
350
384
|
reflect: true
|
|
351
385
|
},
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
386
|
+
key: {
|
|
387
|
+
type: String,
|
|
388
|
+
reflect: true
|
|
355
389
|
},
|
|
356
|
-
|
|
390
|
+
menuService: {
|
|
357
391
|
type: Object,
|
|
358
|
-
|
|
392
|
+
state: true
|
|
359
393
|
},
|
|
360
394
|
matchWord: {
|
|
361
395
|
type: String,
|
|
362
|
-
|
|
396
|
+
state: true
|
|
363
397
|
},
|
|
364
|
-
|
|
398
|
+
noCheckmark: {
|
|
365
399
|
type: Boolean,
|
|
366
|
-
reflect: true
|
|
367
|
-
|
|
400
|
+
reflect: true
|
|
401
|
+
},
|
|
402
|
+
selected: {
|
|
403
|
+
type: Boolean,
|
|
404
|
+
reflect: true
|
|
405
|
+
},
|
|
406
|
+
tabIndex: {
|
|
407
|
+
type: Number,
|
|
408
|
+
reflect: true
|
|
368
409
|
},
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Value selected for the component.
|
|
372
|
-
*/
|
|
373
410
|
value: {
|
|
374
411
|
type: String,
|
|
375
|
-
reflect: true
|
|
376
|
-
attribute: 'value'
|
|
412
|
+
reflect: true
|
|
377
413
|
},
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Indent level for submenus.
|
|
381
|
-
* @private
|
|
382
|
-
*/
|
|
383
|
-
level: {
|
|
384
|
-
type: Number,
|
|
385
|
-
reflect: false,
|
|
386
|
-
attribute: false
|
|
387
|
-
}
|
|
388
414
|
};
|
|
389
415
|
}
|
|
390
416
|
|
|
391
417
|
static get styles() {
|
|
392
418
|
return [
|
|
393
|
-
styleCss
|
|
394
|
-
colorCss
|
|
419
|
+
styleCss,
|
|
420
|
+
colorCss,
|
|
395
421
|
tokensCss
|
|
396
422
|
];
|
|
397
423
|
}
|
|
398
424
|
|
|
399
|
-
/**
|
|
400
|
-
* This will register this element with the browser.
|
|
401
|
-
* @param {string} [name="auro-menu"] - The name of element that you want to register to.
|
|
402
|
-
*
|
|
403
|
-
* @example
|
|
404
|
-
* AuroMenu.register("custom-menu") // this will register this element to <custom-menu/>
|
|
405
|
-
*
|
|
406
|
-
*/
|
|
407
|
-
static register(name = "auro-menu") {
|
|
408
|
-
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenu);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Formatted value based on `multiSelect` state.
|
|
413
|
-
* Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
414
|
-
* @private
|
|
415
|
-
* @returns {String|Array<String>}
|
|
416
|
-
*/
|
|
417
|
-
get formattedValue() {
|
|
418
|
-
if (this.multiSelect) {
|
|
419
|
-
if (!this.value) {
|
|
420
|
-
return undefined;
|
|
421
|
-
}
|
|
422
|
-
if (this.value.startsWith("[")) {
|
|
423
|
-
return JSON.parse(this.value);
|
|
424
|
-
}
|
|
425
|
-
return [this.value];
|
|
426
|
-
}
|
|
427
|
-
return this.value;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Lifecycle Methods
|
|
431
|
-
|
|
432
425
|
connectedCallback() {
|
|
433
426
|
super.connectedCallback();
|
|
434
427
|
|
|
435
|
-
|
|
436
|
-
this
|
|
437
|
-
this.
|
|
438
|
-
this.addEventListener('slotchange', this.handleSlotChange);
|
|
439
|
-
this.setTagAttribute("auro-menu");
|
|
440
|
-
}
|
|
428
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
429
|
+
// Add this step soon as this node gets attached to the DOM to avoid racing condition with menu's value setting logic.
|
|
430
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-menuoption');
|
|
441
431
|
|
|
442
|
-
|
|
443
|
-
this.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
432
|
+
// Set up context consumption in connectedCallback
|
|
433
|
+
this._contextConsumer = new ContextConsumer(this, {
|
|
434
|
+
context: MenuContext,
|
|
435
|
+
callback: this.attachTo.bind(this),
|
|
436
|
+
subscribe: true
|
|
437
|
+
});
|
|
447
438
|
|
|
448
|
-
|
|
439
|
+
// Establish the key property as early as possible
|
|
440
|
+
const valueAttr = this.getAttribute('value');
|
|
441
|
+
const keyAttr = this.getAttribute('key');
|
|
442
|
+
this.key = keyAttr !== null ? keyAttr : valueAttr;
|
|
449
443
|
}
|
|
450
444
|
|
|
451
445
|
firstUpdated() {
|
|
452
|
-
|
|
446
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
447
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-menuoption');
|
|
453
448
|
|
|
454
|
-
this.
|
|
455
|
-
this.
|
|
456
|
-
}
|
|
449
|
+
this.setAttribute('role', 'option');
|
|
450
|
+
this.setAttribute('aria-selected', 'false');
|
|
457
451
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
452
|
+
this.addEventListener('mouseover', () => {
|
|
453
|
+
this.dispatchEvent(new CustomEvent('auroMenuOption-mouseover', {
|
|
454
|
+
bubbles: true,
|
|
455
|
+
cancelable: false,
|
|
456
|
+
composed: true,
|
|
457
|
+
detail: this
|
|
458
|
+
}));
|
|
459
|
+
});
|
|
467
460
|
}
|
|
468
461
|
|
|
469
|
-
// eslint-disable-next-line complexity
|
|
470
462
|
updated(changedProperties) {
|
|
471
463
|
super.updated(changedProperties);
|
|
472
464
|
|
|
473
|
-
if
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
465
|
+
// Update aria-selected attribute if selected changed
|
|
466
|
+
if (changedProperties.has('selected')) {
|
|
467
|
+
|
|
468
|
+
// Update aria-selected attribute
|
|
469
|
+
this.setAttribute('aria-selected', this.selected.toString());
|
|
470
|
+
|
|
471
|
+
// Update menu service selection state if this isn't an internal update
|
|
472
|
+
if (this.internalUpdateInProgress !== true) {
|
|
473
|
+
this.menuService[this.selected ? 'selectOption' : 'deselectOption'](this);
|
|
479
474
|
}
|
|
480
475
|
}
|
|
481
476
|
|
|
482
|
-
if (changedProperties.has('
|
|
483
|
-
|
|
484
|
-
this.clearSelection();
|
|
477
|
+
if (changedProperties.has('active')) {
|
|
478
|
+
this.updateActiveClasses();
|
|
485
479
|
}
|
|
486
480
|
|
|
481
|
+
// Update text highlight if matchWord changed
|
|
482
|
+
if (changedProperties.has('matchWord')) {
|
|
483
|
+
this.updateTextHighlight();
|
|
484
|
+
}
|
|
487
485
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
if (this.multiSelect) {
|
|
494
|
-
// In multiselect mode, this.value should be an array of strings
|
|
495
|
-
const valueArray = this.formattedValue;
|
|
496
|
-
const matchingOptions = this.items.filter((item) => valueArray.includes(item.value));
|
|
497
|
-
|
|
498
|
-
this.optionSelected = matchingOptions.length > 0 ? matchingOptions : undefined;
|
|
499
|
-
} else {
|
|
500
|
-
// In single-select mode, this.value should be a string
|
|
501
|
-
const matchingOptions = this.items.find((item) => item.value === this.value);
|
|
502
|
-
|
|
503
|
-
if (matchingOptions) {
|
|
504
|
-
this.optionSelected = matchingOptions;
|
|
505
|
-
this.index = this.items.indexOf(matchingOptions);
|
|
506
|
-
} else {
|
|
507
|
-
// If no matching option found, reset selection
|
|
508
|
-
this.optionSelected = undefined;
|
|
509
|
-
this.index = -1;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// If no matching options were found in either mode
|
|
514
|
-
if (!this.optionSelected || (Array.isArray(this.optionSelected) && this.optionSelected.length === 0)) {
|
|
515
|
-
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
516
|
-
this.optionSelected = undefined;
|
|
517
|
-
this.index = -1;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
486
|
+
// Set the key to be the passed value if no key is provided
|
|
487
|
+
if (changedProperties.has('value') && this.key === undefined) {
|
|
488
|
+
this.key = this.value;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
520
491
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
true
|
|
526
|
-
]
|
|
527
|
-
]));
|
|
528
|
-
|
|
529
|
-
// Notify of changes
|
|
530
|
-
if (this.optionSelected !== undefined) {
|
|
531
|
-
this.notifySelectionChange();
|
|
532
|
-
}
|
|
492
|
+
disconnectedCallback() {
|
|
493
|
+
if (this.menuService) {
|
|
494
|
+
this.menuService.unsubscribe(this.handleMenuChange);
|
|
495
|
+
this.menuService.removeMenuOption(this);
|
|
533
496
|
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Sets up event listeners for user interaction with the menu option.
|
|
501
|
+
* This function enables click and mouse enter events to trigger selection and highlighting logic.
|
|
502
|
+
*/
|
|
503
|
+
bindEvents() {
|
|
504
|
+
this.addEventListener('click', this.handleClick.bind(this));
|
|
505
|
+
this.addEventListener('mouseenter', this.handleMouseEnter.bind(this));
|
|
506
|
+
}
|
|
534
507
|
|
|
535
|
-
|
|
536
|
-
|
|
508
|
+
/**
|
|
509
|
+
* Attaches this menu option to a menu service and subscribes to its events.
|
|
510
|
+
* This method enables the option to participate in menu selection and highlighting logic.
|
|
511
|
+
* @param {Object} service - The menu service instance to attach to.
|
|
512
|
+
*/
|
|
513
|
+
attachTo(service) {
|
|
514
|
+
if (!service) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
this.menuService = service;
|
|
518
|
+
this.menuService.addMenuOption(this);
|
|
519
|
+
this.menuService.subscribe(this.handleMenuChange);
|
|
537
520
|
}
|
|
538
521
|
|
|
539
522
|
/**
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* @param {
|
|
523
|
+
* Handles changes from the menu service and updates the option's state.
|
|
524
|
+
* This function synchronizes the option's properties and selection/highlight state with menu events.
|
|
525
|
+
* @param {Object} event - The event object from the menu service.
|
|
543
526
|
*/
|
|
544
|
-
|
|
545
|
-
|
|
527
|
+
handleMenuChange(event) {
|
|
528
|
+
|
|
529
|
+
// Ignore events without a type or property
|
|
530
|
+
if (!event || (!event.type && !event.property)) {
|
|
546
531
|
return;
|
|
547
532
|
}
|
|
548
533
|
|
|
549
|
-
//
|
|
550
|
-
if (
|
|
551
|
-
|
|
552
|
-
this.querySelectorAll('auro-menu, [auro-menu], auro-menuoption, [auro-menuoption]').forEach((element) => element.setAttribute('noCheckmark', ''));
|
|
534
|
+
// Update reactive properties based on event type
|
|
535
|
+
if (event.property && Object.keys(AuroMenuOption.properties).includes(event.property)) {
|
|
536
|
+
this[event.property] = event.value;
|
|
553
537
|
}
|
|
554
538
|
|
|
555
|
-
// Handle
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
539
|
+
// Handle highlight changes
|
|
540
|
+
if (event.type === 'highlightChange') {
|
|
541
|
+
const isActive = event.option === this;
|
|
542
|
+
this.active = isActive;
|
|
543
|
+
this.updateActiveClasses();
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (event.type === 'stateChange') {
|
|
547
|
+
const isSelected = event.selectedOptions.includes(this);
|
|
548
|
+
this.setInternalSelected(isSelected);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Updates the internal selected state of the menu option bypassing 'updated' and triggers custom events if selected.
|
|
554
|
+
* This function ensures the option's selection state is synchronized with menu logic and notifies listeners.
|
|
555
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
556
|
+
*/
|
|
557
|
+
setInternalSelected(isSelected) {
|
|
558
|
+
this.internalUpdateInProgress = true;
|
|
559
|
+
this.selected = isSelected;
|
|
560
|
+
|
|
561
|
+
// Fire custom event if selected
|
|
562
|
+
if (isSelected) {
|
|
563
|
+
this.handleCustomEvent();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
setTimeout(() => {
|
|
567
|
+
this.internalUpdateInProgress = false;
|
|
568
|
+
}, 0);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Sets the selected state of the menu option.
|
|
573
|
+
* This function updates whether the option is currently selected.
|
|
574
|
+
* @param {boolean} isSelected - Whether the option should be marked as selected.
|
|
575
|
+
* @deprecated Simply modify the `selected` property directly instead.
|
|
576
|
+
*/
|
|
577
|
+
setSelected(isSelected) {
|
|
578
|
+
this.selected = isSelected;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Updates the active state and visual highlighting of the menu option.
|
|
583
|
+
* This function toggles the option's active status and applies or removes the active CSS class.
|
|
584
|
+
* @param {boolean} isActive - Whether the option should be marked as active.
|
|
585
|
+
* @deprecated Simply modify the `active` property directly instead.
|
|
586
|
+
*/
|
|
587
|
+
updateActive(isActive) {
|
|
588
|
+
|
|
589
|
+
// Set active state
|
|
590
|
+
this.active = isActive;
|
|
591
|
+
this.updateActiveClasses();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Updates the CSS class for the menu option based on its active state.
|
|
596
|
+
* This function adds or removes the 'active' class to visually indicate the option's active status.
|
|
597
|
+
* @private
|
|
598
|
+
*/
|
|
599
|
+
updateActiveClasses() {
|
|
600
|
+
// Update class based on active state
|
|
601
|
+
if (this.active) this.classList.add('active');
|
|
602
|
+
else this.classList.remove('active');
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Updates the visual highlighting of text within the menu option based on the current match word.
|
|
608
|
+
* This function highlights matching text segments and manages nested spacers for display formatting.
|
|
609
|
+
* @private
|
|
610
|
+
*/
|
|
611
|
+
updateTextHighlight() {
|
|
567
612
|
|
|
568
613
|
// Regex for matchWord if needed
|
|
569
614
|
let regexWord = null;
|
|
570
615
|
|
|
571
|
-
if (
|
|
616
|
+
if (this.matchWord && this.matchWord.length) {
|
|
572
617
|
const escapedWord = this.matchWord.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
573
618
|
regexWord = new RegExp(escapedWord, 'giu');
|
|
574
619
|
}
|
|
575
620
|
|
|
576
|
-
//
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
const isSelected = this.isOptionSelected(option);
|
|
581
|
-
option.setAttribute('aria-selected', isSelected ? 'true' : 'false');
|
|
582
|
-
|
|
583
|
-
// Add/remove selected attribute based on state
|
|
584
|
-
if (isSelected) {
|
|
585
|
-
option.setAttribute('selected', '');
|
|
586
|
-
} else {
|
|
587
|
-
option.removeAttribute('selected');
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
// Update text highlighting if matchWord changed
|
|
592
|
-
if (changedProperties.has('matchWord') && regexWord &&
|
|
593
|
-
isOptionInteractive(option) && !option.hasAttribute('persistent')) {
|
|
594
|
-
const nested = option.querySelectorAll('.nestingSpacer');
|
|
621
|
+
// Update text highlighting if matchWord changed
|
|
622
|
+
if (regexWord &&
|
|
623
|
+
this.isActive && !this.hasAttribute('persistent')) {
|
|
624
|
+
const nested = this.querySelectorAll('.nestingSpacer');
|
|
595
625
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// Create nested spacers
|
|
602
|
-
const nestingSpacerBundle = [...nested].map(() => this.nestingSpacer).join('');
|
|
603
|
-
|
|
604
|
-
// Update with spacers and matchWord
|
|
605
|
-
option.innerHTML = nestingSpacerBundle +
|
|
606
|
-
option.textContent.replace(
|
|
607
|
-
regexWord,
|
|
608
|
-
(match) => `<strong>${match}</strong>`
|
|
609
|
-
);
|
|
610
|
-
if (displayValueEl) {
|
|
611
|
-
option.append(displayValueEl);
|
|
612
|
-
}
|
|
626
|
+
const displayValueEl = this.querySelector('[slot="displayValue"]');
|
|
627
|
+
if (displayValueEl) {
|
|
628
|
+
this.removeChild(displayValueEl);
|
|
613
629
|
}
|
|
614
630
|
|
|
615
|
-
//
|
|
616
|
-
|
|
617
|
-
|
|
631
|
+
// Create nested spacers
|
|
632
|
+
const nestingSpacerBundle = [...nested].map(() => this.nestingSpacer).join('');
|
|
633
|
+
|
|
634
|
+
// Update with spacers and matchWord
|
|
635
|
+
this.innerHTML = nestingSpacerBundle +
|
|
636
|
+
this.textContent.replace(
|
|
637
|
+
regexWord,
|
|
638
|
+
(match) => `<strong>${match}</strong>`
|
|
639
|
+
);
|
|
640
|
+
if (displayValueEl) {
|
|
641
|
+
this.append(displayValueEl);
|
|
618
642
|
}
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
// Handle loading state changes
|
|
622
|
-
if (changedProperties.has('loading')) {
|
|
623
|
-
this.setAttribute("aria-busy", this.loading);
|
|
624
|
-
dispatchMenuEvent(this, "auroMenu-loadingChange", {
|
|
625
|
-
loading: this.loading,
|
|
626
|
-
hasLoadingPlaceholder: this.hasLoadingPlaceholder
|
|
627
|
-
});
|
|
628
643
|
}
|
|
629
644
|
}
|
|
630
645
|
|
|
631
|
-
// Init Methods
|
|
632
|
-
|
|
633
646
|
/**
|
|
634
|
-
*
|
|
647
|
+
* Handles click events on the menu option, toggling its selected state.
|
|
648
|
+
* This function dispatches a click event and updates selection if the option is not disabled.
|
|
635
649
|
* @private
|
|
636
650
|
*/
|
|
637
|
-
|
|
638
|
-
this.
|
|
639
|
-
|
|
640
|
-
this.
|
|
641
|
-
this.setAttribute('root', '');
|
|
642
|
-
this.handleNestedMenus(this);
|
|
651
|
+
handleClick() {
|
|
652
|
+
if (!this.disabled) {
|
|
653
|
+
this.dispatchClickEvent();
|
|
654
|
+
this.selected = !this.selected;
|
|
643
655
|
}
|
|
644
656
|
}
|
|
645
657
|
|
|
646
658
|
/**
|
|
647
|
-
*
|
|
659
|
+
* Handles mouse enter events to highlight the menu option.
|
|
660
|
+
* This function updates the menu service to set this option as the currently highlighted item if not disabled.
|
|
648
661
|
* @private
|
|
649
662
|
*/
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
this.updateItemsState(new Map([
|
|
654
|
-
[
|
|
655
|
-
'noCheckmark',
|
|
656
|
-
true
|
|
657
|
-
]
|
|
658
|
-
]));
|
|
663
|
+
handleMouseEnter() {
|
|
664
|
+
if (!this.disabled) {
|
|
665
|
+
this.menuService.setHighlightedOption(this);
|
|
659
666
|
}
|
|
660
667
|
}
|
|
661
668
|
|
|
662
|
-
// Logic Methods
|
|
663
|
-
|
|
664
669
|
/**
|
|
665
|
-
*
|
|
670
|
+
* Dispatches custom events defined for this menu option.
|
|
671
|
+
* This function notifies listeners when a custom event is triggered by the option.
|
|
666
672
|
* @private
|
|
667
|
-
* @param {HTMLElement} option - The option element to select.
|
|
668
673
|
*/
|
|
669
|
-
|
|
670
|
-
if (this.
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (!currentValue.includes(option.value)) {
|
|
675
|
-
this.value = JSON.stringify([
|
|
676
|
-
...currentValue,
|
|
677
|
-
option.value
|
|
678
|
-
]);
|
|
679
|
-
}
|
|
680
|
-
if (!currentSelected.includes(option)) {
|
|
681
|
-
this.optionSelected = [
|
|
682
|
-
...currentSelected,
|
|
683
|
-
option
|
|
684
|
-
];
|
|
685
|
-
}
|
|
686
|
-
} else {
|
|
687
|
-
// Single select - use arrays with single values
|
|
688
|
-
this.value = option.value;
|
|
689
|
-
this.optionSelected = option;
|
|
674
|
+
handleCustomEvent() {
|
|
675
|
+
if (this.event) {
|
|
676
|
+
dispatchMenuEvent(this, this.event, { option: this });
|
|
677
|
+
dispatchMenuEvent(this, 'auroMenu-customEventFired', { option: this });
|
|
690
678
|
}
|
|
679
|
+
}
|
|
691
680
|
|
|
692
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Dispatches a click event for this menu option.
|
|
683
|
+
* This function notifies listeners that the option has been clicked.
|
|
684
|
+
* @private
|
|
685
|
+
*/
|
|
686
|
+
dispatchClickEvent() {
|
|
687
|
+
this.dispatchEvent(new CustomEvent('auroMenuOption-click', {
|
|
688
|
+
bubbles: true,
|
|
689
|
+
cancelable: false,
|
|
690
|
+
composed: true,
|
|
691
|
+
detail: this
|
|
692
|
+
}));
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
/**
|
|
696
|
-
*
|
|
696
|
+
* Generates an HTML element containing an SVG icon based on the provided `svgContent`.
|
|
697
|
+
*
|
|
697
698
|
* @private
|
|
698
|
-
* @param {
|
|
699
|
+
* @param {string} svgContent - The SVG content to be embedded.
|
|
700
|
+
* @returns {Element} The HTML element containing the SVG icon.
|
|
699
701
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
const newFormattedValue = (this.formattedValue || []).filter((val) => val !== option.value);
|
|
702
|
+
generateIconHtml(svgContent) {
|
|
703
|
+
const dom = new DOMParser().parseFromString(svgContent, 'text/html');
|
|
704
|
+
const svg = dom.body.firstChild;
|
|
704
705
|
|
|
705
|
-
|
|
706
|
-
if (newFormattedValue && newFormattedValue.length === 0) {
|
|
707
|
-
this.value = undefined;
|
|
708
|
-
} else {
|
|
709
|
-
this.value = JSON.stringify(newFormattedValue);
|
|
710
|
-
}
|
|
706
|
+
svg.setAttribute('slot', 'svg');
|
|
711
707
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
708
|
+
return html$1`<${this.iconTag} customColor customSvg>${svg}</${this.iconTag}>`;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Logic to determine the layout of the component.
|
|
713
|
+
* @protected
|
|
714
|
+
* @returns {void}
|
|
715
|
+
*/
|
|
716
|
+
renderLayout() {
|
|
721
717
|
|
|
722
|
-
|
|
723
|
-
|
|
718
|
+
const fontClassMap = {
|
|
719
|
+
xs: 'body-sm',
|
|
720
|
+
sm: 'body-default',
|
|
721
|
+
md: 'body-default',
|
|
722
|
+
lg: 'body-lg',
|
|
723
|
+
xl: 'body-lg'
|
|
724
|
+
};
|
|
724
725
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
[
|
|
728
|
-
|
|
729
|
-
true
|
|
730
|
-
]
|
|
731
|
-
]));
|
|
726
|
+
const classes = classMap({
|
|
727
|
+
'wrapper': true,
|
|
728
|
+
[this.size ? fontClassMap[this.size] : 'body-sm']: true,
|
|
729
|
+
});
|
|
732
730
|
|
|
733
|
-
|
|
734
|
-
|
|
731
|
+
return html$1`
|
|
732
|
+
<div class="${classes}">
|
|
733
|
+
${this.selected && !this.noCheckmark
|
|
734
|
+
? this.generateIconHtml(checkmarkIcon.svg)
|
|
735
|
+
: undefined}
|
|
736
|
+
<slot></slot>
|
|
737
|
+
</div>
|
|
738
|
+
`;
|
|
735
739
|
}
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/* eslint-disable */
|
|
743
|
+
|
|
744
|
+
class MenuService {
|
|
736
745
|
|
|
737
746
|
/**
|
|
738
|
-
*
|
|
739
|
-
* @private
|
|
747
|
+
* PROPERTIES AND GETTERS
|
|
740
748
|
*/
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Gets the list of registered menu options.
|
|
752
|
+
* @returns {AuroMenuOption[]}
|
|
753
|
+
*/
|
|
754
|
+
get menuOptions() {
|
|
755
|
+
return this._menuOptions;
|
|
745
756
|
}
|
|
746
757
|
|
|
747
758
|
/**
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* @public
|
|
759
|
+
* Gets the currently highlighted option.
|
|
760
|
+
* @returns {AuroMenuOption|null}
|
|
751
761
|
*/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
this.optionSelected = undefined;
|
|
756
|
-
this.index = -1;
|
|
762
|
+
get highlightedOption() {
|
|
763
|
+
return this._menuOptions[this.highlightedIndex] || null;
|
|
764
|
+
}
|
|
757
765
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
]
|
|
766
|
+
/**
|
|
767
|
+
* Gets the current value(s) of the selected option(s).
|
|
768
|
+
* @returns {string|string[]|undefined}
|
|
769
|
+
*/
|
|
770
|
+
get currentValue() {
|
|
771
|
+
const values = (this.selectedOptions || []).map(option => option.value);
|
|
772
|
+
return this.multiSelect ? values : values[0];
|
|
773
|
+
}
|
|
765
774
|
|
|
766
|
-
|
|
767
|
-
|
|
775
|
+
/**
|
|
776
|
+
* Gets the label(s) of the currently selected option(s).
|
|
777
|
+
* @returns {string}
|
|
778
|
+
*/
|
|
779
|
+
get currentLabel() {
|
|
780
|
+
const labels = (this.selectedOptions || []).map(option => option.textContent);
|
|
781
|
+
return this.multiSelect ? labels.join(", ") : labels[0] || '';
|
|
768
782
|
}
|
|
769
783
|
|
|
770
784
|
/**
|
|
771
|
-
*
|
|
772
|
-
*
|
|
773
|
-
* @
|
|
785
|
+
* Gets the string representation of the current value(s).
|
|
786
|
+
* For multi-select, this is a JSON stringified array.
|
|
787
|
+
* @returns {string|undefined}
|
|
774
788
|
*/
|
|
775
|
-
|
|
776
|
-
|
|
789
|
+
get stringValue() {
|
|
790
|
+
const { currentValue } = this;
|
|
777
791
|
|
|
778
|
-
if (
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
if (!menu.hasAttribute('aria-label')) {
|
|
782
|
-
menu.setAttribute('aria-label', 'submenu');
|
|
792
|
+
if (Array.isArray(currentValue)) {
|
|
793
|
+
if (currentValue.length > 0) {
|
|
794
|
+
return JSON.stringify(currentValue);
|
|
783
795
|
}
|
|
796
|
+
return undefined;
|
|
784
797
|
}
|
|
785
798
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
799
|
+
if (typeof currentValue === 'string') {
|
|
800
|
+
if (currentValue.length > 0) {
|
|
801
|
+
return currentValue;
|
|
802
|
+
}
|
|
803
|
+
return undefined;
|
|
804
|
+
}
|
|
792
805
|
|
|
793
|
-
|
|
806
|
+
// Future: handle other types here (e.g., number, object, etc.)
|
|
807
|
+
return undefined;
|
|
808
|
+
}
|
|
794
809
|
|
|
795
810
|
/**
|
|
796
|
-
*
|
|
797
|
-
* @
|
|
798
|
-
* @param {KeyboardEvent} event - Event object from the browser.
|
|
811
|
+
* Gets the key(s) of the currently selected option(s).
|
|
812
|
+
* @returns {string|string[]|undefined}
|
|
799
813
|
*/
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
case "ArrowDown":
|
|
804
|
-
this.navigateOptions('down');
|
|
805
|
-
break;
|
|
806
|
-
case "ArrowUp":
|
|
807
|
-
this.navigateOptions('up');
|
|
808
|
-
break;
|
|
809
|
-
case "Tab":
|
|
810
|
-
this.makeSelection();
|
|
811
|
-
break;
|
|
812
|
-
case "Enter":
|
|
813
|
-
this.makeSelection();
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
814
|
+
get currentKeys() {
|
|
815
|
+
const keys = (this.selectedOptions || []).map(option => option.key);
|
|
816
|
+
return this.multiSelect ? keys : keys[0];
|
|
816
817
|
}
|
|
817
818
|
|
|
818
819
|
/**
|
|
819
|
-
*
|
|
820
|
-
* @private
|
|
820
|
+
* CONSTRUCTOR
|
|
821
821
|
*/
|
|
822
|
-
makeSelection() {
|
|
823
|
-
if (!this.items) {
|
|
824
|
-
this.initItems();
|
|
825
|
-
}
|
|
826
822
|
|
|
827
|
-
|
|
828
|
-
|
|
823
|
+
/**
|
|
824
|
+
* Creates a new MenuService instance.
|
|
825
|
+
* @param {Object} options - The options object.
|
|
826
|
+
* @param {AuroMenu} options.host - The host element that this service will control. Required.
|
|
827
|
+
* @throws {Error} If the host is not provided.
|
|
828
|
+
*/
|
|
829
|
+
constructor({ host } = {}) {
|
|
829
830
|
|
|
830
|
-
//
|
|
831
|
-
if (!
|
|
832
|
-
|
|
831
|
+
// Ensure a host was passed
|
|
832
|
+
if (!host) {
|
|
833
|
+
throw new Error("MenuService requires a host element.");
|
|
833
834
|
}
|
|
834
835
|
|
|
835
|
-
//
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
836
|
+
// Attach the service to the host
|
|
837
|
+
this.host = host;
|
|
838
|
+
this.host.addController(this);
|
|
840
839
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
840
|
+
// Set default properties
|
|
841
|
+
this.size = undefined;
|
|
842
|
+
this.shape = undefined;
|
|
843
|
+
this.noCheckmark = undefined;
|
|
844
|
+
this.disabled = undefined;
|
|
845
|
+
this.matchWord = undefined;
|
|
846
|
+
this.multiSelect = undefined;
|
|
847
|
+
this.allowDeselect = undefined;
|
|
848
|
+
this.selectAllMatchingOptions = undefined;
|
|
849
|
+
|
|
850
|
+
this.highlightedIndex = -1;
|
|
849
851
|
|
|
850
|
-
this.
|
|
852
|
+
this._menuOptions = [];
|
|
853
|
+
this._subscribers = [];
|
|
854
|
+
this.internalUpdateInProgress = false;
|
|
855
|
+
this.selectedOptions = [];
|
|
851
856
|
}
|
|
852
857
|
|
|
853
858
|
/**
|
|
854
|
-
*
|
|
855
|
-
* @private
|
|
856
|
-
* @param {HTMLElement} option - The menuoption to toggle.
|
|
859
|
+
* PROPERTY SYNCING
|
|
857
860
|
*/
|
|
858
|
-
toggleOption(option) {
|
|
859
|
-
const isCurrentlySelected = this.isOptionSelected(option);
|
|
860
|
-
|
|
861
|
-
if (isCurrentlySelected) {
|
|
862
|
-
this.handleDeselectState(option);
|
|
863
|
-
} else if (option.value === undefined || option.value === '') {
|
|
864
|
-
dispatchMenuEvent(this, 'auroMenu-selectValueFailure');
|
|
865
|
-
} else {
|
|
866
|
-
this.handleSelectState(option);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
861
|
|
|
870
862
|
/**
|
|
871
|
-
* Handles
|
|
872
|
-
*
|
|
873
|
-
*
|
|
863
|
+
* Handles host updates.
|
|
864
|
+
* This is a lit reactive lifecycle method.
|
|
865
|
+
* This comes from the Lit controller interface provided by adding this service as a controller to the host.
|
|
866
|
+
* See constructor for `this.host.addController(this)`
|
|
867
|
+
* You can read more about Lit reactive controllers here: https://lit.dev/docs/composition/controllers/
|
|
874
868
|
*/
|
|
875
|
-
|
|
876
|
-
if (!this.rootMenu || event.target === this) {
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
869
|
+
hostUpdated() {
|
|
879
870
|
|
|
880
|
-
|
|
881
|
-
if (
|
|
882
|
-
this.
|
|
883
|
-
this.makeSelection();
|
|
871
|
+
// Reset selection if multiSelect mode changes
|
|
872
|
+
if (this.host.multiSelect !== this.multiSelect) {
|
|
873
|
+
this.selectedOptions = [];
|
|
884
874
|
}
|
|
875
|
+
|
|
876
|
+
// Update properties on host update
|
|
877
|
+
this.setProperties({
|
|
878
|
+
size: this.host.size,
|
|
879
|
+
shape: this.host.shape,
|
|
880
|
+
noCheckmark: this.host.noCheckmark,
|
|
881
|
+
disabled: this.host.disabled,
|
|
882
|
+
matchWord: this.host.matchWord,
|
|
883
|
+
multiSelect: this.host.multiSelect,
|
|
884
|
+
allowDeselect: this.host.allowDeselect,
|
|
885
|
+
selectAllMatchingOptions: this.host.selectAllMatchingOptions
|
|
886
|
+
});
|
|
885
887
|
}
|
|
886
888
|
|
|
887
889
|
/**
|
|
888
|
-
* Handles
|
|
889
|
-
* @private
|
|
890
|
-
* @param {CustomEvent} event - Event object from the browser.
|
|
890
|
+
* Handles host disconnection and memory cleanup.
|
|
891
891
|
*/
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
this.
|
|
895
|
-
this.updateActiveOption(this.index);
|
|
892
|
+
hostDisconnected() {
|
|
893
|
+
this._subscribers = [];
|
|
894
|
+
this._menuOptions = [];
|
|
896
895
|
}
|
|
897
896
|
|
|
898
897
|
/**
|
|
899
|
-
*
|
|
900
|
-
* @
|
|
898
|
+
* Sets a property value if it exists on the instance and the value has changed.
|
|
899
|
+
* @param {string} property
|
|
900
|
+
* @param {any} value
|
|
901
901
|
*/
|
|
902
|
-
|
|
903
|
-
if (this.parentElement && this.parentElement.closest('auro-menu, [auro-menu]')) {
|
|
904
|
-
this.rootMenu = false;
|
|
905
|
-
}
|
|
902
|
+
setProperty(property, value) {
|
|
906
903
|
|
|
907
|
-
if
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
904
|
+
// Only update if we are tracking the property in this service
|
|
905
|
+
if (this.hasOwnProperty(property)) {
|
|
906
|
+
|
|
907
|
+
// Check if the value has changed
|
|
908
|
+
const valueChanged = this[property] !== value;
|
|
909
|
+
|
|
910
|
+
// Update and notify if changed
|
|
911
|
+
if (valueChanged) {
|
|
912
|
+
this[property] = value;
|
|
913
|
+
this.notify({ property, value });
|
|
914
|
+
}
|
|
916
915
|
}
|
|
917
916
|
}
|
|
918
917
|
|
|
919
918
|
/**
|
|
920
|
-
*
|
|
921
|
-
* @
|
|
922
|
-
* @param {string} direction - 'up' or 'down'.
|
|
919
|
+
* Sets multiple properties on the instance.
|
|
920
|
+
* @param {Object} properties - Key-value pairs of properties to set.
|
|
923
921
|
*/
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
return;
|
|
922
|
+
setProperties(properties) {
|
|
923
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
924
|
+
this.setProperty(key, value);
|
|
928
925
|
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* MENU OPTION HIGHLIGHTING
|
|
930
|
+
*/
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Highlights the next active option in the menu.
|
|
934
|
+
*/
|
|
935
|
+
highlightNext() {
|
|
936
|
+
this.moveHighlightedOption("next");
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Highlights the previous active option in the menu.
|
|
941
|
+
*/
|
|
942
|
+
highlightPrevious() {
|
|
943
|
+
this.moveHighlightedOption("previous");
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Moves the highlighted option in the specified direction.
|
|
948
|
+
* @param {string} direction - The direction to move the highlight ("next" or "previous").
|
|
949
|
+
*/
|
|
950
|
+
moveHighlightedOption(direction) {
|
|
951
|
+
|
|
952
|
+
// Get the active options
|
|
953
|
+
const activeOptions = this._menuOptions.filter(option => option.isActive);
|
|
954
|
+
|
|
955
|
+
// Get the currently active option
|
|
956
|
+
const currentActiveOption = activeOptions[activeOptions.indexOf(this.highlightedOption)];
|
|
957
|
+
|
|
958
|
+
// Determine the new index based on the currently active option and direction
|
|
959
|
+
let newIndex = currentActiveOption
|
|
960
|
+
? direction === "previous"
|
|
961
|
+
? activeOptions.indexOf(currentActiveOption) - 1
|
|
962
|
+
: activeOptions.indexOf(currentActiveOption) + 1
|
|
963
|
+
: direction === "previous"
|
|
964
|
+
? activeOptions.length - 1
|
|
965
|
+
: 0;
|
|
966
|
+
|
|
967
|
+
// Wrap around the index if needed
|
|
968
|
+
newIndex = newIndex < 0 ? activeOptions.length - 1 : newIndex >= activeOptions.length ? 0 : newIndex;
|
|
969
|
+
|
|
970
|
+
// Get the new active option and set it as highlighted
|
|
971
|
+
const newActiveOption = activeOptions[newIndex];
|
|
972
|
+
this.setHighlightedOption(newActiveOption);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Sets the highlighted index to the specified option.
|
|
977
|
+
* @param {AuroMenuOption} option - The option to highlight.
|
|
978
|
+
*/
|
|
979
|
+
setHighlightedOption(option) {
|
|
980
|
+
|
|
981
|
+
if (!option) return;
|
|
982
|
+
|
|
983
|
+
// Get the index of the option to highlight
|
|
984
|
+
const index = this._menuOptions.indexOf(option);
|
|
985
|
+
|
|
986
|
+
// Update highlighted index
|
|
987
|
+
this.highlightedIndex = index;
|
|
988
|
+
|
|
989
|
+
// Notify subscribers of highlight change
|
|
990
|
+
this.notify({ type: 'highlightChange', option, index: this.highlightedIndex });
|
|
991
|
+
|
|
992
|
+
// Dispatch the change event
|
|
993
|
+
this.dispatchChangeEvent('auroMenu-activatedOption', option);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Sets the highlighted option to the option at the specified index if it exists.
|
|
998
|
+
* @param {number} index
|
|
999
|
+
*/
|
|
1000
|
+
setHighlightedIndex(index) {
|
|
1001
|
+
const option = this._menuOptions[index] || null;
|
|
1002
|
+
this.setHighlightedOption(option);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Selects the currently highlighted option.
|
|
1007
|
+
*/
|
|
1008
|
+
selectHighlightedOption() {
|
|
1009
|
+
if (this.highlightedOption) {
|
|
1010
|
+
this.toggleOption(this.highlightedOption);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* SELECTION AND DESELECTION METHODS
|
|
1016
|
+
*/
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Selects one or more options in a batch operation
|
|
1020
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to select
|
|
1021
|
+
*/
|
|
1022
|
+
selectOptions(options) {
|
|
1023
|
+
let optionsToSelect = Array.isArray(options) ? options : [options];
|
|
1024
|
+
|
|
1025
|
+
// Filter out options that are inactive
|
|
1026
|
+
optionsToSelect = optionsToSelect.filter(option => option.isActive);
|
|
1027
|
+
|
|
1028
|
+
if (!optionsToSelect.length) return;
|
|
1029
|
+
|
|
1030
|
+
if (this.multiSelect) {
|
|
1031
|
+
this.selectedOptions = [...(this.selectedOptions || []), ...optionsToSelect];
|
|
1032
|
+
} else {
|
|
1033
|
+
// In single select mode, only take the last option
|
|
1034
|
+
this.selectedOptions = [optionsToSelect[optionsToSelect.length - 1]];
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
this.stageUpdate();
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Deselects one or more options in a batch operation
|
|
1042
|
+
* @param {AuroMenuOption|AuroMenuOption[]} options - Single option or array of options to deselect
|
|
1043
|
+
*/
|
|
1044
|
+
deselectOptions(options) {
|
|
1045
|
+
const optionsToDeselect = Array.isArray(options) ? options : [options];
|
|
1046
|
+
|
|
1047
|
+
if (!optionsToDeselect.length) return;
|
|
1048
|
+
|
|
1049
|
+
// Check if deselection should be prevented
|
|
1050
|
+
const shouldPreventDeselect = !this.allowDeselect && !this.multiSelect;
|
|
1051
|
+
const isOnlySelectedOption = this.selectedOptions.length === 1 && optionsToDeselect.includes(this.selectedOptions[0]);
|
|
1052
|
+
|
|
1053
|
+
// Prevent deselecting the only selected option if not allowed
|
|
1054
|
+
if (shouldPreventDeselect && isOnlySelectedOption) return;
|
|
1055
|
+
|
|
1056
|
+
const optionsSet = new Set(optionsToDeselect);
|
|
1057
|
+
this.selectedOptions = (this.selectedOptions || [])
|
|
1058
|
+
.filter(opt => !optionsSet.has(opt));
|
|
1059
|
+
|
|
1060
|
+
this.stageUpdate();
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Selects a single option.
|
|
1065
|
+
* @param {AuroMenuOption} option
|
|
1066
|
+
*/
|
|
1067
|
+
selectOption(option) {
|
|
1068
|
+
this.selectOptions(option);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Deselects a single option.
|
|
1073
|
+
* @param {AuroMenuOption} option
|
|
1074
|
+
*/
|
|
1075
|
+
deselectOption(option) {
|
|
1076
|
+
this.deselectOptions(option);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Toggles the selection state of a single option.
|
|
1081
|
+
* @param {AuroMenuOption} option
|
|
1082
|
+
*/
|
|
1083
|
+
toggleOption(option) {
|
|
1084
|
+
if (option.selected) {
|
|
1085
|
+
this.deselectOption(option);
|
|
1086
|
+
} else {
|
|
1087
|
+
this.selectOption(option);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Selects options based on their value(s) when compared to a passed value or values.
|
|
1093
|
+
* Value or values are normalized to an array of strings that can be matched to option keys.
|
|
1094
|
+
* @param {string|number|Array<string|number>} value - The value(s) to select.
|
|
1095
|
+
*/
|
|
1096
|
+
selectByValue(value) {
|
|
1097
|
+
// Early exit for invalid/empty values or internal updates
|
|
1098
|
+
if (this.internalUpdateInProgress ||
|
|
1099
|
+
this.host.internalUpdateInProgress ||
|
|
1100
|
+
value === undefined ||
|
|
1101
|
+
value === null ||
|
|
1102
|
+
(Array.isArray(value) && value.length === 0) ||
|
|
1103
|
+
(typeof value === 'string' && value.trim() === '')) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
this.reset();
|
|
1108
|
+
|
|
1109
|
+
// Normalize values to array of strings
|
|
1110
|
+
const normalizedValues = this._getNormalizedValues(value);
|
|
1111
|
+
|
|
1112
|
+
// Validate for single-select mode
|
|
1113
|
+
let validatedValues = normalizedValues;
|
|
1114
|
+
if (normalizedValues.length > 1 && !this.multiSelect) {
|
|
1115
|
+
console.warn("MenuService - Multiple values provided for single-select menu. Only the first value will be selected.");
|
|
1116
|
+
validatedValues = [normalizedValues[0]];
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
// Find matching options by comparing available options to validated values
|
|
1120
|
+
const trackedKeys = new Set();
|
|
1121
|
+
const optionsToSelect = this._menuOptions.filter(option => {
|
|
1122
|
+
const passesFilter = validatedValues.includes(option.key);
|
|
1123
|
+
const alreadyTracked = trackedKeys.has(option.key);
|
|
1124
|
+
|
|
1125
|
+
trackedKeys.add(option.key);
|
|
1126
|
+
|
|
1127
|
+
// Include the option in the options to be selected if it passes the filter check and
|
|
1128
|
+
// either hasn't been tracked yet or selectAllMatchingOptions is true
|
|
1129
|
+
return passesFilter && (!alreadyTracked || (alreadyTracked && this.selectAllMatchingOptions));
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// Handle selection result
|
|
1133
|
+
if (optionsToSelect.length && !this.optionsArraysMatch(optionsToSelect, this.selectedOptions)) {
|
|
1134
|
+
this.selectOptions(optionsToSelect);
|
|
1135
|
+
} else {
|
|
1136
|
+
this.stageUpdate();
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// Dispatch failure event if no matches found
|
|
1140
|
+
if (!optionsToSelect.length && validatedValues.length) {
|
|
1141
|
+
this.dispatchChangeEvent('auroMenu-selectValueFailure', {
|
|
1142
|
+
message: 'No matching options found for the provided value(s).',
|
|
1143
|
+
values: validatedValues
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Resets the selected options to an empty array.
|
|
1150
|
+
*/
|
|
1151
|
+
reset() {
|
|
1152
|
+
const previousOptions = [...this.selectedOptions];
|
|
1153
|
+
this.selectedOptions = [];
|
|
1154
|
+
|
|
1155
|
+
// Single update after clearing all
|
|
1156
|
+
if (previousOptions.length) {
|
|
1157
|
+
this.stageUpdate();
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* SUBSCRIPTION, NOTIFICATION AND EVENT DISPATCH METHODS
|
|
1163
|
+
*/
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Subscribes a callback to menu service events.
|
|
1167
|
+
* @param {Function} callback - The callback to invoke on events.
|
|
1168
|
+
*/
|
|
1169
|
+
subscribe(callback) {
|
|
1170
|
+
this._subscribers.push(callback);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Remove a previously subscribed callback from menu service events.
|
|
1175
|
+
* @param {Function} callback
|
|
1176
|
+
*/
|
|
1177
|
+
unsubscribe(callback) {
|
|
1178
|
+
this._subscribers = this._subscribers.filter(cb => cb !== callback);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Stages an update to notify subscribers of state and value changes.
|
|
1183
|
+
*/
|
|
1184
|
+
stageUpdate() {
|
|
1185
|
+
this.notifyStateChange();
|
|
1186
|
+
this.notifyValueChange();
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Notifies subscribers of a menu service event.
|
|
1191
|
+
* All notifications are sent to all subscribers.
|
|
1192
|
+
* @param {string} event - The event to send to subscribers.
|
|
1193
|
+
*/
|
|
1194
|
+
notify(event) {
|
|
1195
|
+
this._subscribers.forEach(callback => callback(event));
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* Notifies subscribers of a state change (selected options has changed).
|
|
1200
|
+
*/
|
|
1201
|
+
notifyStateChange() {
|
|
1202
|
+
this.notify({ type: 'stateChange', selectedOptions: this.selectedOptions });
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/**
|
|
1206
|
+
* Notifies subscribers of a value change (current value has changed).
|
|
1207
|
+
*/
|
|
1208
|
+
notifyValueChange() {
|
|
1209
|
+
|
|
1210
|
+
// Prepare details for the event
|
|
1211
|
+
const details = {
|
|
1212
|
+
value: this.currentValue,
|
|
1213
|
+
stringValue: this.stringValue,
|
|
1214
|
+
keys: this.currentKeys,
|
|
1215
|
+
options: this.selectedOptions,
|
|
1216
|
+
label: this.currentLabel
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
// If only one option is selected, include its index
|
|
1220
|
+
if (this.selectedOptions.length === 1) details.index = this._menuOptions.indexOf(this.selectedOptions[0]);
|
|
1221
|
+
|
|
1222
|
+
this.notify({
|
|
1223
|
+
type: 'valueChange',
|
|
1224
|
+
...details
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
this.dispatchChangeEvent('auroMenu-selectedOption', details);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Dispatches a custom event from the host element.
|
|
1232
|
+
* @param {string} eventName
|
|
1233
|
+
* @param {any} detail
|
|
1234
|
+
*/
|
|
1235
|
+
dispatchChangeEvent(eventName, detail) {
|
|
1236
|
+
this.host.dispatchEvent(new CustomEvent(eventName, {
|
|
1237
|
+
bubbles: true,
|
|
1238
|
+
cancelable: false,
|
|
1239
|
+
composed: true,
|
|
1240
|
+
detail
|
|
1241
|
+
}));
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* MENU OPTION MANAGEMENT METHODS
|
|
1246
|
+
*/
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Adds a menu option to the service's list.
|
|
1250
|
+
* @param {AuroMenuOption} option - the option to track
|
|
1251
|
+
*/
|
|
1252
|
+
addMenuOption(option) {
|
|
1253
|
+
this._menuOptions.push(option);
|
|
1254
|
+
this.notify({ type: 'optionsChange', options: this._menuOptions });
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Removes a menu option from the service's list.
|
|
1259
|
+
* @param {AuroMenuOption} option - the option to remove
|
|
1260
|
+
*/
|
|
1261
|
+
removeMenuOption(option) {
|
|
1262
|
+
this._menuOptions = this._menuOptions.filter(opt => opt !== option);
|
|
1263
|
+
this.notify({ type: 'optionsChange', options: this._menuOptions });
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* UTILITIES
|
|
1268
|
+
*/
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Normalizes a value or array of values into an array of strings for option selection.
|
|
1272
|
+
* This function ensures that input values are consistently formatted for matching menu options.
|
|
1273
|
+
*
|
|
1274
|
+
* @param {string|number|Array<string|number>} value - The value(s) to normalize.
|
|
1275
|
+
* @returns {Array<string>} An array of string values suitable for option matching.
|
|
1276
|
+
* @throws {Error} If any value is not a string or number.
|
|
1277
|
+
*/
|
|
1278
|
+
_getNormalizedValues(value) {
|
|
1279
|
+
let values = value;
|
|
1280
|
+
|
|
1281
|
+
// Handle JSON string and single value string input
|
|
1282
|
+
if (!Array.isArray(values) && typeof values === 'string') {
|
|
1283
|
+
|
|
1284
|
+
// Attempt to parse as JSON array
|
|
1285
|
+
try {
|
|
1286
|
+
|
|
1287
|
+
// Normalize single quotes to double quotes for JSON parsing
|
|
1288
|
+
// This will not handle complex cases but will cover basic usage
|
|
1289
|
+
const parseValue = values.replace(/'([^']*?)'/g, '"$1"');
|
|
1290
|
+
|
|
1291
|
+
// Attempt parse
|
|
1292
|
+
const parsed = JSON.parse(parseValue);
|
|
1293
|
+
|
|
1294
|
+
// Ensure parsed value is an array
|
|
1295
|
+
if (!Array.isArray(parsed)) throw new Error('Not an array');
|
|
1296
|
+
|
|
1297
|
+
// Set values to parsed array
|
|
1298
|
+
values = parsed;
|
|
1299
|
+
} catch (err) {
|
|
1300
|
+
|
|
1301
|
+
// If parsing fails, treat as single value
|
|
1302
|
+
values = [value];
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
// Handle a single number being passed
|
|
1307
|
+
if (typeof values === 'number') {
|
|
1308
|
+
values = [String(values)];
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// Coerce each value to string and validate types
|
|
1312
|
+
values.forEach((val, index) => {
|
|
1313
|
+
|
|
1314
|
+
// Throw an error for invalid value types
|
|
1315
|
+
if (typeof val !== 'string' && typeof val !== 'number') {
|
|
1316
|
+
throw new Error('Value contains invalid value type. Supported types are string and number.');
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
// Convert numbers to strings for consistency
|
|
1320
|
+
if (typeof val === 'number') {
|
|
1321
|
+
values[index] = String(val);
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
|
|
1325
|
+
// Return the resulting array of string values
|
|
1326
|
+
return values;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* Returns whether two arrays of options contain the same elements.
|
|
1331
|
+
* @param {AuroMenuOption[]} arr1 - First array of options.
|
|
1332
|
+
* @param {AuroMenuOption[]} arr2 - Second array of options.
|
|
1333
|
+
* @returns {boolean} True if arrays match, false otherwise.
|
|
1334
|
+
*/
|
|
1335
|
+
optionsArraysMatch(arr1, arr2) {
|
|
1336
|
+
if (arr1.length !== arr2.length) return false;
|
|
1337
|
+
|
|
1338
|
+
const set1 = new Set(arr1);
|
|
1339
|
+
const set2 = new Set(arr2);
|
|
1340
|
+
|
|
1341
|
+
for (let item of set1) {
|
|
1342
|
+
if (!set2.has(item)) {
|
|
1343
|
+
return false;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
return true;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
const MenuContext = createContext('menu-context');
|
|
1352
|
+
|
|
1353
|
+
/* eslint-disable no-underscore-dangle, curly */
|
|
1354
|
+
// Copyright (c) 2025 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1355
|
+
// See LICENSE in the project root for license information.
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* The auro-menu element provides users a way to select from a list of options.
|
|
1361
|
+
* @attr {HTMLElement|Array<HTMLElement>} optionSelected - An array of currently selected menu options, type `HTMLElement` by default. In multi-select mode, `optionSelected` is an array of HTML elements.
|
|
1362
|
+
* @attr {object} optionactive - Specifies the current active menuOption.
|
|
1363
|
+
* @attr {string} matchword - Specifies a string used to highlight matched string parts in options.
|
|
1364
|
+
* @attr {boolean} disabled - When true, the entire menu and all options are disabled;
|
|
1365
|
+
* @attr {boolean} nocheckmark - When true, selected option will not show the checkmark.
|
|
1366
|
+
* @attr {boolean} loading - When true, displays a loading state using the loadingIcon and loadingText slots if provided.
|
|
1367
|
+
* @attr {boolean} multiselect - When true, the selected option can be multiple options.
|
|
1368
|
+
* @attr {boolean} selectAllMatchingOptions - When true, selects all options that match the provided value/key when setting value and multiselect is enabled.
|
|
1369
|
+
* @attr {string} value - The value of the selected option. In multi-select mode, this is a JSON stringified array of selected option values.
|
|
1370
|
+
* @prop {string} size - Sets the size of the menu. Accepted values are 'sm' and 'md'. Default is 'sm'.
|
|
1371
|
+
* @prop {string} shape - Sets the shape of the menu options. Accepted values are 'box' and 'round'. Default is 'box'.
|
|
1372
|
+
* @prop {boolean} hasLoadingPlaceholder - Indicates whether the menu has a loadingIcon or loadingText to render when in a loading state.
|
|
1373
|
+
* @event {CustomEvent<Element>} auroMenu-activatedOption - Notifies that a menuoption has been made `active`.
|
|
1374
|
+
* @event {CustomEvent<any>} auroMenu-customEventFired - Notifies that a custom event has been fired.
|
|
1375
|
+
* @event {CustomEvent<{ loading: boolean; hasLoadingPlaceholder: boolean; }>} auroMenu-loadingChange - Notifies when the loading attribute is changed.
|
|
1376
|
+
* @event {CustomEvent<any>} auroMenu-selectValueFailure - Notifies that an attempt to select a menuoption by matching a value has failed.
|
|
1377
|
+
* @event {CustomEvent<any>} auroMenu-selectValueReset - Notifies that the component value has been reset.
|
|
1378
|
+
* @event {CustomEvent<any>} auroMenu-selectedOption - Notifies that a new menuoption selection has been made.
|
|
1379
|
+
* @slot loadingText - Text to show while loading attribute is set
|
|
1380
|
+
* @slot loadingIcon - Icon to show while loading attribute is set
|
|
1381
|
+
* @slot - Slot for insertion of menu options.
|
|
1382
|
+
*/
|
|
1383
|
+
|
|
1384
|
+
/* eslint-disable no-magic-numbers, max-lines, no-extra-parens */
|
|
1385
|
+
|
|
1386
|
+
class AuroMenu extends AuroElement {
|
|
1387
|
+
|
|
1388
|
+
constructor() {
|
|
1389
|
+
super();
|
|
1390
|
+
|
|
1391
|
+
// State properties (reactive)
|
|
1392
|
+
|
|
1393
|
+
/**
|
|
1394
|
+
* @private
|
|
1395
|
+
*/
|
|
1396
|
+
this.shape = "box";
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @private
|
|
1400
|
+
*/
|
|
1401
|
+
this.size = "sm";
|
|
1402
|
+
|
|
1403
|
+
// Value of the selected options
|
|
1404
|
+
this.value = undefined;
|
|
1405
|
+
// Currently selected option
|
|
1406
|
+
this.optionSelected = undefined;
|
|
1407
|
+
// String used for highlighting/filtering
|
|
1408
|
+
this.matchWord = undefined;
|
|
1409
|
+
// Hide the checkmark icon on selected options
|
|
1410
|
+
this.noCheckmark = false;
|
|
1411
|
+
// Currently active option
|
|
1412
|
+
this.optionActive = undefined;
|
|
1413
|
+
// Loading state
|
|
1414
|
+
this.loading = false;
|
|
1415
|
+
// Multi-select mode
|
|
1416
|
+
this.multiSelect = false;
|
|
1417
|
+
// Allow deselecting of menu options
|
|
1418
|
+
this.allowDeselect = false;
|
|
1419
|
+
// Select all matching options when setting value in multi-select mode
|
|
1420
|
+
this.selectAllMatchingOptions = false;
|
|
1421
|
+
|
|
1422
|
+
// Event Bindings
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* @private
|
|
1426
|
+
*/
|
|
1427
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
1428
|
+
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* @private
|
|
1432
|
+
*/
|
|
1433
|
+
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
1434
|
+
|
|
1435
|
+
// Instance properties (non-reactive)
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* @private
|
|
1439
|
+
*/
|
|
1440
|
+
Object.assign(this, {
|
|
1441
|
+
// Root-level menu (true) or a nested submenu (false)
|
|
1442
|
+
rootMenu: true,
|
|
1443
|
+
// Currently focused/active menu item index
|
|
1444
|
+
_index: -1,
|
|
1445
|
+
// Nested menu spacer
|
|
1446
|
+
nestingSpacer: '<span class="nestingSpacer"></span>',
|
|
1447
|
+
// Loading indicator for slot elements
|
|
1448
|
+
loadingSlots: null,
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
static get properties() {
|
|
1453
|
+
return {
|
|
1454
|
+
...super.properties,
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Allows deselecting an already selected option when clicked again in single-select mode.
|
|
1458
|
+
*/
|
|
1459
|
+
allowDeselect: {
|
|
1460
|
+
type: Boolean,
|
|
1461
|
+
reflect: true,
|
|
1462
|
+
},
|
|
1463
|
+
noCheckmark: {
|
|
1464
|
+
type: Boolean,
|
|
1465
|
+
reflect: true,
|
|
1466
|
+
attribute: 'nocheckmark'
|
|
1467
|
+
},
|
|
1468
|
+
disabled: {
|
|
1469
|
+
type: Boolean,
|
|
1470
|
+
reflect: true
|
|
1471
|
+
},
|
|
1472
|
+
loading: {
|
|
1473
|
+
type: Boolean,
|
|
1474
|
+
reflect: true
|
|
1475
|
+
},
|
|
1476
|
+
optionSelected: {
|
|
1477
|
+
// Allow HTMLElement, HTMLElement[] arrays and undefined
|
|
1478
|
+
type: Object
|
|
1479
|
+
},
|
|
1480
|
+
optionActive: {
|
|
1481
|
+
type: Object,
|
|
1482
|
+
attribute: 'optionactive'
|
|
1483
|
+
},
|
|
1484
|
+
matchWord: {
|
|
1485
|
+
type: String,
|
|
1486
|
+
attribute: 'matchword'
|
|
1487
|
+
},
|
|
1488
|
+
multiSelect: {
|
|
1489
|
+
type: Boolean,
|
|
1490
|
+
reflect: true,
|
|
1491
|
+
attribute: 'multiselect'
|
|
1492
|
+
},
|
|
1493
|
+
selectAllMatchingOptions: {
|
|
1494
|
+
type: Boolean,
|
|
1495
|
+
reflect: true,
|
|
1496
|
+
},
|
|
929
1497
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1498
|
+
/**
|
|
1499
|
+
* Value selected for the component.
|
|
1500
|
+
*/
|
|
1501
|
+
value: {
|
|
1502
|
+
type: String,
|
|
1503
|
+
reflect: true,
|
|
1504
|
+
attribute: 'value'
|
|
1505
|
+
},
|
|
935
1506
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1507
|
+
/**
|
|
1508
|
+
* Indent level for submenus.
|
|
1509
|
+
* @private
|
|
1510
|
+
*/
|
|
1511
|
+
level: {
|
|
1512
|
+
type: Number,
|
|
1513
|
+
reflect: false,
|
|
1514
|
+
attribute: false
|
|
1515
|
+
},
|
|
939
1516
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1517
|
+
/**
|
|
1518
|
+
* Available menu options
|
|
1519
|
+
* @readonly
|
|
1520
|
+
*/
|
|
1521
|
+
options: {
|
|
1522
|
+
type: Array,
|
|
1523
|
+
reflect: false,
|
|
1524
|
+
attribute: false
|
|
945
1525
|
}
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
946
1528
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1529
|
+
static get styles() {
|
|
1530
|
+
return [
|
|
1531
|
+
styleCss$1,
|
|
1532
|
+
colorCss$1,
|
|
1533
|
+
tokensCss
|
|
1534
|
+
];
|
|
1535
|
+
}
|
|
952
1536
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1537
|
+
/**
|
|
1538
|
+
* @readonly
|
|
1539
|
+
* @returns {string} - Returns the label of the currently selected option(s).
|
|
1540
|
+
*/
|
|
1541
|
+
get currentLabel() {
|
|
1542
|
+
return this.menuService.currentLabel;
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* @readonly
|
|
1547
|
+
* @returns {Array<HTMLElement>} - Returns the array of available menu options.
|
|
1548
|
+
* @deprecated use `options` property instead.
|
|
1549
|
+
*/
|
|
1550
|
+
get items() {
|
|
1551
|
+
return this.options;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* @returns {number} - Returns the index of the currently active option.
|
|
1556
|
+
*/
|
|
1557
|
+
get index() {
|
|
1558
|
+
return this._index;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* @param {number} value - Sets the index of the currently active option.
|
|
1563
|
+
*/
|
|
1564
|
+
set index(value) {
|
|
1565
|
+
this.menuService.setHighlightedIndex(value);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* This will register this element with the browser.
|
|
1570
|
+
* @param {string} [name="auro-menu"] - The name of element that you want to register to.
|
|
1571
|
+
*
|
|
1572
|
+
* @example
|
|
1573
|
+
* AuroMenu.register("custom-menu") // this will register this element to <custom-menu/>
|
|
1574
|
+
*
|
|
1575
|
+
*/
|
|
1576
|
+
static register(name = "auro-menu") {
|
|
1577
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenu);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
/**
|
|
1581
|
+
* Formatted value based on `multiSelect` state.
|
|
1582
|
+
* Default type is `String`, changing to `Array<String>` when `multiSelect` is true.
|
|
1583
|
+
* @private
|
|
1584
|
+
* @returns {String|Array<String>}
|
|
1585
|
+
*/
|
|
1586
|
+
get formattedValue() {
|
|
1587
|
+
return this.menuService.currentValue;
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
/**
|
|
1591
|
+
* Gets the current property values for the menu service.
|
|
1592
|
+
* @private
|
|
1593
|
+
* @returns {Object}
|
|
1594
|
+
*/
|
|
1595
|
+
get propertyValues() {
|
|
1596
|
+
return {
|
|
1597
|
+
size: this.size,
|
|
1598
|
+
shape: this.shape,
|
|
1599
|
+
noCheckmark: this.nocheckmark,
|
|
1600
|
+
disabled: this.disabled
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
/**
|
|
1605
|
+
* Provides the menu context to child components.
|
|
1606
|
+
* Initializes the MenuService and subscribes to menu changes.
|
|
1607
|
+
* @protected
|
|
1608
|
+
*/
|
|
1609
|
+
provideContext() {
|
|
1610
|
+
this.menuService = new MenuService({host: this});
|
|
1611
|
+
this.menuService.setProperties(this.propertyValues);
|
|
1612
|
+
this.menuService.subscribe(this.handleMenuChange.bind(this));
|
|
1613
|
+
this._contextProvider = new ContextProvider(this, {
|
|
1614
|
+
context: MenuContext,
|
|
1615
|
+
initialValue: this.menuService
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* Updates the currently active option in the menu.
|
|
1621
|
+
* @param {HTMLElement} option - The option to set as active.
|
|
1622
|
+
*/
|
|
1623
|
+
updateActiveOption(option) {
|
|
1624
|
+
this.menuService.setHighlightedOption(option);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
/**
|
|
1628
|
+
* Sets the internal value and manages update state.
|
|
1629
|
+
* @param {String|Array<String>} value - The value to set.
|
|
1630
|
+
* @protected
|
|
1631
|
+
*/
|
|
1632
|
+
setInternalValue(value) {
|
|
1633
|
+
if (this.value !== value) {
|
|
1634
|
+
this.internalUpdateInProgress = true;
|
|
1635
|
+
this.value = value;
|
|
1636
|
+
|
|
1637
|
+
setTimeout(() => {
|
|
1638
|
+
this.internalUpdateInProgress = false;
|
|
965
1639
|
});
|
|
966
1640
|
}
|
|
967
1641
|
}
|
|
968
1642
|
|
|
969
1643
|
/**
|
|
970
|
-
*
|
|
971
|
-
* @param {
|
|
1644
|
+
* Handles changes from the menu service and updates component state.
|
|
1645
|
+
* @param {Object} event - The event object from the menu service.
|
|
1646
|
+
* @protected
|
|
1647
|
+
*/
|
|
1648
|
+
handleMenuChange(event) {
|
|
1649
|
+
if (event.type === 'valueChange') {
|
|
1650
|
+
|
|
1651
|
+
// New option is array value or first option with fallback to undefined for empty array in all cases
|
|
1652
|
+
const newOption = this.multiSelect && event.options.length ? event.options : event.options[0] || undefined;
|
|
1653
|
+
const newValue = event.stringValue;
|
|
1654
|
+
|
|
1655
|
+
// Check if the option or value has actually changed
|
|
1656
|
+
if (newValue === undefined || (this.optionSelected !== newOption || this.stringValue !== newValue)) {
|
|
1657
|
+
this.optionSelected = newOption;
|
|
1658
|
+
this.setInternalValue(newValue);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// Notify components of selection change
|
|
1662
|
+
this.notifySelectionChange(event);
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
if (event.type === 'highlightChange') {
|
|
1666
|
+
this.optionActive = event.option;
|
|
1667
|
+
this._index = event.index;
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
if (event.type === 'optionsChange') {
|
|
1671
|
+
this.options = event.options;
|
|
1672
|
+
this.dispatchEvent(new CustomEvent('auroMenu-optionsChange', {
|
|
1673
|
+
detail: {
|
|
1674
|
+
options: event.options
|
|
1675
|
+
}
|
|
1676
|
+
}));
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Gets the currently selected options.
|
|
1682
|
+
* @returns {Array<HTMLElement>}
|
|
1683
|
+
*/
|
|
1684
|
+
get selectedOptions() {
|
|
1685
|
+
return this.menuService ? this.menuService.selectedOptions : [];
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Gets the first selected option, or null if none.
|
|
1690
|
+
* @returns {HTMLElement|null}
|
|
1691
|
+
*/
|
|
1692
|
+
get selectedOption() {
|
|
1693
|
+
return this.menuService ? this.menuService.selectedOptions[0] : null;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
// Lifecycle Methods
|
|
1697
|
+
|
|
1698
|
+
connectedCallback() {
|
|
1699
|
+
super.connectedCallback();
|
|
1700
|
+
|
|
1701
|
+
this.provideContext();
|
|
1702
|
+
|
|
1703
|
+
this.addEventListener('keydown', this.handleKeyDown);
|
|
1704
|
+
this.addEventListener('auroMenuOption-click', this.handleMouseSelect);
|
|
1705
|
+
this.addEventListener('auroMenuOption-mouseover', this.handleOptionHover);
|
|
1706
|
+
this.addEventListener('slotchange', this.handleSlotChange);
|
|
1707
|
+
this.setTagAttribute("auro-menu");
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
disconnectedCallback() {
|
|
1711
|
+
this.removeEventListener('keydown', this.handleKeyDown);
|
|
1712
|
+
this.removeEventListener('auroMenuOption-click', this.handleMouseSelect);
|
|
1713
|
+
this.removeEventListener('auroMenuOption-mouseover', this.handleOptionHover);
|
|
1714
|
+
this.removeEventListener('slotchange', this.handleSlotChange);
|
|
1715
|
+
|
|
1716
|
+
super.disconnectedCallback();
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
firstUpdated() {
|
|
1720
|
+
AuroLibraryRuntimeUtils.prototype.handleComponentTagRename(this, 'auro-menu');
|
|
1721
|
+
|
|
1722
|
+
this.loadingSlots = this.querySelectorAll("[slot='loadingText'], [slot='loadingIcon']");
|
|
1723
|
+
this.initializeMenu();
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
updated(changedProperties) {
|
|
1728
|
+
super.updated(changedProperties);
|
|
1729
|
+
|
|
1730
|
+
// Update menu service properties on host update
|
|
1731
|
+
if (changedProperties.has('value')) {
|
|
1732
|
+
this.menuService.selectByValue(this.value);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// Handle loading state changes
|
|
1736
|
+
if (changedProperties.has('loading')) {
|
|
1737
|
+
this.setLoadingState(this.loading);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* Sets an attribute that matches the default tag name if the tag name is not the default.
|
|
1743
|
+
* @param {string} tagName - The tag name to set as an attribute.
|
|
1744
|
+
* @private
|
|
1745
|
+
*/
|
|
1746
|
+
setTagAttribute(tagName) {
|
|
1747
|
+
if (this.tagName.toLowerCase() !== tagName) {
|
|
1748
|
+
this.setAttribute(tagName, true);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Sets the loading state and dispatches a loading change event.
|
|
1754
|
+
* @param {boolean} isLoading - Whether the menu is loading.
|
|
1755
|
+
* @protected
|
|
1756
|
+
*/
|
|
1757
|
+
setLoadingState(isLoading) {
|
|
1758
|
+
this.setAttribute("aria-busy", isLoading);
|
|
1759
|
+
dispatchMenuEvent(this, "auroMenu-loadingChange", {
|
|
1760
|
+
loading: isLoading,
|
|
1761
|
+
hasLoadingPlaceholder: this.hasLoadingPlaceholder
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
// Init Methods
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* Initializes the menu's state and structure.
|
|
1769
|
+
* @private
|
|
1770
|
+
*/
|
|
1771
|
+
initializeMenu() {
|
|
1772
|
+
if (this.rootMenu) {
|
|
1773
|
+
this.setAttribute('role', 'listbox');
|
|
1774
|
+
this.setAttribute('root', '');
|
|
1775
|
+
this.handleNestedMenus(this);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* Selects the currently highlighted option.
|
|
1781
|
+
* @protected
|
|
1782
|
+
*/
|
|
1783
|
+
makeSelection() {
|
|
1784
|
+
this.menuService.selectHighlightedOption();
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Resets all options to their default state.
|
|
1789
|
+
* @private
|
|
1790
|
+
*/
|
|
1791
|
+
clearSelection() {
|
|
1792
|
+
this.optionSelected = undefined;
|
|
1793
|
+
this.value = undefined;
|
|
1794
|
+
this._index = -1;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* Resets the menu to its initial state.
|
|
1799
|
+
* This is the only way to return value to undefined.
|
|
1800
|
+
* @public
|
|
1801
|
+
*/
|
|
1802
|
+
reset() {
|
|
1803
|
+
this.menuService.reset();
|
|
1804
|
+
|
|
1805
|
+
// Dispatch reset event
|
|
1806
|
+
dispatchMenuEvent(this, 'auroMenu-selectValueReset');
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* Handles nested menu structure.
|
|
1811
|
+
* @private
|
|
1812
|
+
* @param {HTMLElement} menu - Root menu element.
|
|
1813
|
+
*/
|
|
1814
|
+
handleNestedMenus(menu) {
|
|
1815
|
+
menu.level = menu.parentElement.level >= 0 ? menu.parentElement.level + 1 : 0;
|
|
1816
|
+
|
|
1817
|
+
if (menu.level > 0) {
|
|
1818
|
+
menu.setAttribute('role', 'group');
|
|
1819
|
+
menu.removeAttribute("root");
|
|
1820
|
+
if (!menu.hasAttribute('aria-label')) {
|
|
1821
|
+
menu.setAttribute('aria-label', 'submenu');
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1825
|
+
const options = menu.querySelectorAll(':scope > auro-menuoption, :scope > [auro-menuoption]');
|
|
1826
|
+
options.forEach((option) => {
|
|
1827
|
+
const regex = new RegExp(this.nestingSpacer, "gu");
|
|
1828
|
+
option.innerHTML = this.nestingSpacer.repeat(menu.level) + option.innerHTML.replace(regex, '');
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// Event Handlers
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* Handles keyboard navigation.
|
|
1836
|
+
* @private
|
|
1837
|
+
* @param {KeyboardEvent} event - Event object from the browser.
|
|
1838
|
+
*/
|
|
1839
|
+
handleKeyDown(event) {
|
|
1840
|
+
event.preventDefault();
|
|
1841
|
+
switch (event.key) {
|
|
1842
|
+
case "ArrowDown":
|
|
1843
|
+
this.menuService.highlightNext();
|
|
1844
|
+
break;
|
|
1845
|
+
case "ArrowUp":
|
|
1846
|
+
this.menuService.highlightPrevious();
|
|
1847
|
+
break;
|
|
1848
|
+
case "Tab":
|
|
1849
|
+
case "Enter":
|
|
1850
|
+
this.menuService.selectHighlightedOption();
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Navigates the menu options in the specified direction.
|
|
1857
|
+
* @param {'up'|'down'} direction - The direction to navigate.
|
|
1858
|
+
* @protected
|
|
972
1859
|
*/
|
|
973
|
-
|
|
974
|
-
if (
|
|
975
|
-
|
|
1860
|
+
navigateOptions(direction) {
|
|
1861
|
+
if (direction === 'up') {
|
|
1862
|
+
this.menuService.highlightPrevious();
|
|
1863
|
+
} else if (direction === 'down') {
|
|
1864
|
+
this.menuService.highlightNext();
|
|
976
1865
|
}
|
|
1866
|
+
}
|
|
977
1867
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1868
|
+
/**
|
|
1869
|
+
* Handles slot change events.
|
|
1870
|
+
* @private
|
|
1871
|
+
*/
|
|
1872
|
+
handleSlotChange() {
|
|
1873
|
+
if (this.parentElement && this.parentElement.closest('auro-menu, [auro-menu]')) {
|
|
1874
|
+
this.rootMenu = false;
|
|
1875
|
+
}
|
|
982
1876
|
|
|
983
|
-
|
|
1877
|
+
if (this.rootMenu) {
|
|
1878
|
+
this.initializeMenu();
|
|
1879
|
+
}
|
|
984
1880
|
}
|
|
985
1881
|
|
|
986
1882
|
/**
|
|
@@ -999,8 +1895,13 @@ class AuroMenu extends AuroElement {
|
|
|
999
1895
|
* @param {any} source - The source that triggers this event.
|
|
1000
1896
|
* @private
|
|
1001
1897
|
*/
|
|
1002
|
-
notifySelectionChange(
|
|
1003
|
-
dispatchMenuEvent(this, 'auroMenu-selectedOption', {
|
|
1898
|
+
notifySelectionChange({value, stringValue, keys, options} = {}) {
|
|
1899
|
+
dispatchMenuEvent(this, 'auroMenu-selectedOption', {
|
|
1900
|
+
value,
|
|
1901
|
+
stringValue,
|
|
1902
|
+
keys,
|
|
1903
|
+
options
|
|
1904
|
+
});
|
|
1004
1905
|
}
|
|
1005
1906
|
|
|
1006
1907
|
/**
|
|
@@ -1073,257 +1974,5 @@ class AuroMenu extends AuroElement {
|
|
|
1073
1974
|
}
|
|
1074
1975
|
}
|
|
1075
1976
|
|
|
1076
|
-
var styleCss = css`.body-default{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-default-font-size, 1rem);line-height:var(--wcss-body-default-line-height, 1.5rem)}.body-lg{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-lg-font-size, 1.125rem);line-height:var(--wcss-body-lg-line-height, 1.625rem)}.body-sm{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-sm-font-size, 0.875rem);line-height:var(--wcss-body-sm-line-height, 1.25rem)}.body-xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-xs-font-size, 0.75rem);line-height:var(--wcss-body-xs-line-height, 1rem)}.body-2xs{font-family:var(--wcss-body-family, "AS Circular"),system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-weight:var(--wcss-body-weight, 450);letter-spacing:var(--wcss-body-letter-spacing, 0);font-size:var(--wcss-body-2xs-font-size, 0.625rem);line-height:var(--wcss-body-2xs-line-height, 0.875rem)}.display-2xl{font-family:var(--wcss-display-2xl-family, "AS Circular"),var(--wcss-display-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-2xl-letter-spacing, 0);font-weight:var(--wcss-display-2xl-weight, 300);line-height:var(--wcss-display-2xl-line-height, 1.3);font-size:var(--wcss-display-2xl-font-size, clamp(3.5rem, 6vw, 5.375rem))}.display-xl{font-family:var(--wcss-display-xl-family, "AS Circular"),var(--wcss-display-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xl-letter-spacing, 0);font-weight:var(--wcss-display-xl-weight, 300);line-height:var(--wcss-display-xl-line-height, 1.3);font-size:var(--wcss-display-xl-font-size, clamp(3rem, 5.3333333333vw, 4.5rem))}.display-lg{font-family:var(--wcss-display-lg-family, "AS Circular"),var(--wcss-display-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-lg-letter-spacing, 0);font-weight:var(--wcss-display-lg-weight, 300);line-height:var(--wcss-display-lg-line-height, 1.3);font-size:var(--wcss-display-lg-font-size, clamp(2.75rem, 4.6666666667vw, 4rem))}.display-md{font-family:var(--wcss-display-md-family, "AS Circular"),var(--wcss-display-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-md-letter-spacing, 0);font-weight:var(--wcss-display-md-weight, 300);line-height:var(--wcss-display-md-line-height, 1.3);font-size:var(--wcss-display-md-font-size, clamp(2.5rem, 4vw, 3.5rem))}.display-sm{font-family:var(--wcss-display-sm-family, "AS Circular"),var(--wcss-display-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-sm-letter-spacing, 0);font-weight:var(--wcss-display-sm-weight, 300);line-height:var(--wcss-display-sm-line-height, 1.3);font-size:var(--wcss-display-sm-font-size, clamp(2rem, 3.6666666667vw, 3rem))}.display-xs{font-family:var(--wcss-display-xs-family, "AS Circular"),var(--wcss-display-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-display-xs-letter-spacing, 0);font-weight:var(--wcss-display-xs-weight, 300);line-height:var(--wcss-display-xs-line-height, 1.3);font-size:var(--wcss-display-xs-font-size, clamp(1.75rem, 3vw, 2.375rem))}.heading-xl{font-family:var(--wcss-heading-xl-family, "AS Circular"),var(--wcss-heading-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xl-letter-spacing, 0);font-weight:var(--wcss-heading-xl-weight, 300);line-height:var(--wcss-heading-xl-line-height, 1.3);font-size:var(--wcss-heading-xl-font-size, clamp(2rem, 3vw, 2.5rem))}.heading-lg{font-family:var(--wcss-heading-lg-family, "AS Circular"),var(--wcss-heading-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-lg-letter-spacing, 0);font-weight:var(--wcss-heading-lg-weight, 300);line-height:var(--wcss-heading-lg-line-height, 1.3);font-size:var(--wcss-heading-lg-font-size, clamp(1.75rem, 2.6666666667vw, 2.25rem))}.heading-md{font-family:var(--wcss-heading-md-family, "AS Circular"),var(--wcss-heading-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-md-letter-spacing, 0);font-weight:var(--wcss-heading-md-weight, 300);line-height:var(--wcss-heading-md-line-height, 1.3);font-size:var(--wcss-heading-md-font-size, clamp(1.625rem, 2.3333333333vw, 1.75rem))}.heading-sm{font-family:var(--wcss-heading-sm-family, "AS Circular"),var(--wcss-heading-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-sm-letter-spacing, 0);font-weight:var(--wcss-heading-sm-weight, 300);line-height:var(--wcss-heading-sm-line-height, 1.3);font-size:var(--wcss-heading-sm-font-size, clamp(1.375rem, 2vw, 1.5rem))}.heading-xs{font-family:var(--wcss-heading-xs-family, "AS Circular"),var(--wcss-heading-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-xs-letter-spacing, 0);font-weight:var(--wcss-heading-xs-weight, 450);line-height:var(--wcss-heading-xs-line-height, 1.3);font-size:var(--wcss-heading-xs-font-size, clamp(1.25rem, 1.6666666667vw, 1.25rem))}.heading-2xs{font-family:var(--wcss-heading-2xs-family, "AS Circular"),var(--wcss-heading-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-heading-2xs-letter-spacing, 0);font-weight:var(--wcss-heading-2xs-weight, 450);line-height:var(--wcss-heading-2xs-line-height, 1.3);font-size:var(--wcss-heading-2xs-font-size, clamp(1.125rem, 1.5vw, 1.125rem))}.accent-2xl{font-family:var(--wcss-accent-2xl-family, "Good OT"),var(--wcss-accent-2xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-2xl-weight, 450);line-height:var(--wcss-accent-2xl-line-height, 1);font-size:var(--wcss-accent-2xl-font-size, clamp(2rem, 3.1666666667vw, 2.375rem));text-transform:uppercase}.accent-xl{font-family:var(--wcss-accent-xl-family, "Good OT"),var(--wcss-accent-xl-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xl-letter-spacing, 0.05em);font-weight:var(--wcss-accent-xl-weight, 450);line-height:var(--wcss-accent-xl-line-height, 1.3);font-size:var(--wcss-accent-xl-font-size, clamp(1.625rem, 2.3333333333vw, 2rem));text-transform:uppercase}.accent-lg{font-family:var(--wcss-accent-lg-family, "Good OT"),var(--wcss-accent-lg-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-lg-letter-spacing, 0.05em);font-weight:var(--wcss-accent-lg-weight, 450);line-height:var(--wcss-accent-lg-line-height, 1.3);font-size:var(--wcss-accent-lg-font-size, clamp(1.5rem, 2.1666666667vw, 1.75rem));text-transform:uppercase}.accent-md{font-family:var(--wcss-accent-md-family, "Good OT"),var(--wcss-accent-md-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-md-letter-spacing, 0.05em);font-weight:var(--wcss-accent-md-weight, 500);line-height:var(--wcss-accent-md-line-height, 1.3);font-size:var(--wcss-accent-md-font-size, clamp(1.375rem, 1.8333333333vw, 1.5rem));text-transform:uppercase}.accent-sm{font-family:var(--wcss-accent-sm-family, "Good OT"),var(--wcss-accent-sm-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-sm-letter-spacing, 0.05em);font-weight:var(--wcss-accent-sm-weight, 500);line-height:var(--wcss-accent-sm-line-height, 1.3);font-size:var(--wcss-accent-sm-font-size, clamp(1.125rem, 1.5vw, 1.25rem));text-transform:uppercase}.accent-xs{font-family:var(--wcss-accent-xs-family, "Good OT"),var(--wcss-accent-xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-xs-weight, 500);line-height:var(--wcss-accent-xs-line-height, 1.3);font-size:var(--wcss-accent-xs-font-size, clamp(1rem, 1.3333333333vw, 1rem));text-transform:uppercase}.accent-2xs{font-family:var(--wcss-accent-2xs-family, "Good OT"),var(--wcss-accent-2xs-family-fallback, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);letter-spacing:var(--wcss-accent-2xs-letter-spacing, 0.1em);font-weight:var(--wcss-accent-2xs-weight, 450);line-height:var(--wcss-accent-2xs-line-height, 1.3);font-size:var(--wcss-accent-2xs-font-size, clamp(0.875rem, 1.1666666667vw, 0.875rem));text-transform:uppercase}:host{cursor:pointer;user-select:none;text-overflow:ellipsis;max-width:100dvw}:host .wrapper{display:flex;align-items:center;padding-right:var(--ds-size-200, 1rem);padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem));padding-top:var(--ds-size-50, 0.25rem);padding-bottom:var(--ds-size-50, 0.25rem);border-radius:var(--ds-size-100, 0.5rem);-webkit-tap-highlight-color:transparent}:host .wrapper[class*=shape-box]{border-radius:unset}:host .wrapper[class*=shape-snowflake]{border-radius:unset;line-height:24px}:host .wrapper[class*=shape-pill]{border-radius:30px}:host .wrapper[class*=-lg]{padding-top:var(--ds-size-75, 0.375rem);padding-bottom:var(--ds-size-75, 0.375rem);padding-right:var(--ds-size-150, 0.75rem);line-height:26px}:host .wrapper[class*=-xl]{padding-top:var(--ds-size-100, 0.5rem);padding-bottom:var(--ds-size-100, 0.5rem);padding-right:var(--ds-size-200, 1rem);line-height:26px}:host slot{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host [auro-icon]{--ds-auro-icon-size: var(--ds-size-300, 1.5rem);margin-right:var(--ds-size-150, 0.75rem);margin-left:var(--ds-size-100, 0.5rem)}:host ::slotted(.nestingSpacer){display:inline-block;width:var(--ds-size-300, 1.5rem)}[slot=displayValue]{display:none}:host([loadingplaceholder]) .wrapper{padding-left:calc(var(--ds-size-150, 0.75rem) + var(--ds-size-300, 1.5rem) + var(--ds-size-100, 0.5rem))}:host([selected]) .wrapper{padding-left:0}:host([nocheckmark]) .wrapper{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-lg]{padding-left:var(--ds-size-150, 0.75rem)}:host([nocheckmark]) .wrapper[class*=-xl]{padding-left:var(--ds-size-200, 1rem)}:host([hidden]){display:none}:host([static]){pointer-events:none}:host([disabled]:hover){cursor:auto}:host([disabled]){user-select:none;pointer-events:none}`;
|
|
1077
|
-
|
|
1078
|
-
var colorCss = css`:host .wrapper{background-color:var(--ds-auro-menuoption-container-color, transparent);box-shadow:inset 0 0 0 1px var(--ds-auro-menuoption-container-border-color, transparent);color:var(--ds-auro-menuoption-text-color)}:host svg{fill:var(--ds-auro-menuoption-icon-color)}:host([disabled]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-disabled, #d0d0d0);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:hover),:host(.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}:host(:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-default, #ffffff);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host([selected]){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-text-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-menuoption-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a)}:host([selected]:hover),:host([selected].active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd)}:host([selected]:focus){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-subtle, #b4eff9);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host(:focus:hover),:host(:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}:host([selected]:focus:hover),:host([selected]:focus.active){--ds-auro-menuoption-container-color: var(--ds-basic-color-surface-accent1-muted, #ebfafd);--ds-auro-menuoption-container-border-color: var(--ds-basic-color-border-brand, #00274a)}`;
|
|
1079
|
-
|
|
1080
|
-
// Copyright (c) Alaska Air. All right reserved. Licensed under the Apache-2.0 license
|
|
1081
|
-
// See LICENSE in the project root for license information.
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
class AuroDependencyVersioning {
|
|
1085
|
-
|
|
1086
|
-
/**
|
|
1087
|
-
* Generates a unique string to be used for child auro element naming.
|
|
1088
|
-
* @private
|
|
1089
|
-
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1090
|
-
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1091
|
-
* @returns {string} - Unique string to be used for naming.
|
|
1092
|
-
*/
|
|
1093
|
-
generateElementName(baseName, version) {
|
|
1094
|
-
let result = baseName;
|
|
1095
|
-
|
|
1096
|
-
result += '-';
|
|
1097
|
-
result += version.replace(/[.]/g, '_');
|
|
1098
|
-
|
|
1099
|
-
return result;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
/**
|
|
1103
|
-
* Generates a unique string to be used for child auro element naming.
|
|
1104
|
-
* @param {string} baseName - Defines the first part of the unique element name.
|
|
1105
|
-
* @param {string} version - Version of the component that will be appended to the baseName.
|
|
1106
|
-
* @returns {string} - Unique string to be used for naming.
|
|
1107
|
-
*/
|
|
1108
|
-
generateTag(baseName, version, tagClass) {
|
|
1109
|
-
const elementName = this.generateElementName(baseName, version);
|
|
1110
|
-
const tag = literal`${unsafeStatic(elementName)}`;
|
|
1111
|
-
|
|
1112
|
-
if (!customElements.get(elementName)) {
|
|
1113
|
-
customElements.define(elementName, class extends tagClass {});
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
return tag;
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
class p{registerComponent(t,a){customElements.get(t)||customElements.define(t,class extends a{});}closestElement(t,a=this,e=(a,s=a&&a.closest(t))=>a&&a!==document&&a!==window?s||e(a.getRootNode().host):null){return e(a)}handleComponentTagRename(t,a){const e=a.toLowerCase();t.tagName.toLowerCase()!==e&&t.setAttribute(e,true);}elementMatch(t,a){const e=a.toLowerCase();return t.tagName.toLowerCase()===e||t.hasAttribute(e)}}var u='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="error__desc" class="ico_squareLarge" data-deprecated="true" role="img" style="min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor" viewBox="0 0 24 24" part="svg"><title/><desc id="error__desc">Error alert indicator.</desc><path d="m13.047 5.599 6.786 11.586A1.207 1.207 0 0 1 18.786 19H5.214a1.207 1.207 0 0 1-1.047-1.815l6.786-11.586a1.214 1.214 0 0 1 2.094 0m-1.165.87a.23.23 0 0 0-.085.085L5.419 17.442a.232.232 0 0 0 .203.35h12.756a.234.234 0 0 0 .203-.35L12.203 6.554a.236.236 0 0 0-.321-.084M12 15.5a.75.75 0 1 1 0 1.5.75.75 0 0 1 0-1.5m-.024-6.22c.325 0 .589.261.589.583v4.434a.586.586 0 0 1-.589.583.586.586 0 0 1-.588-.583V9.863c0-.322.264-.583.588-.583"/></svg>';class m extends LitElement{static get properties(){return {hidden:{type:Boolean,reflect:true},hiddenVisually:{type:Boolean,reflect:true},hiddenAudible:{type:Boolean,reflect:true}}}hideAudible(t){return t?"true":"false"}}const g=new Map,f=(t,a={})=>{const e=a.responseParser||(t=>t.text());return g.has(t)||g.set(t,fetch(t).then(e)),g.get(t)};var w=css`:focus:not(:focus-visible){outline:3px solid transparent}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}.ico_squareLarge{fill:currentColor;height:var(--auro-size-lg, var(--ds-size-300, 1.5rem))}.ico_squareSmall{fill:currentColor;height:.6rem}.ico_squareMed{fill:currentColor;height:var(--auro-size-md, var(--ds-size-200, 1rem))}.ico_squareSml{fill:currentColor;height:var(--auro-size-sm, var(--ds-size-150, .75rem))}:host{color:currentColor;vertical-align:middle;line-height:1;display:inline-block}svg{min-width:var(--ds-auro-icon-size, 1.5rem)!important;width:var(--ds-auro-icon-size, 1.5rem)!important;height:var(--ds-auro-icon-size, 1.5rem)!important}.componentWrapper{display:flex}.svgWrapper{height:var(--ds-auro-icon-size);width:var(--ds-auro-icon-size)}.labelWrapper{margin-left:var(--ds-size-50, .25rem);line-height:1.8}
|
|
1121
|
-
`;class z extends m{constructor(){super(),this.onDark=false,this.appearance="default";}static get properties(){return {...m.properties,onDark:{type:Boolean,reflect:true},appearance:{type:String,reflect:true},svg:{attribute:false,reflect:true}}}static get styles(){return w}async fetchIcon(t,a){let e="";e="logos"===t?await f(`${this.uri}/${t}/${a}.svg`):await f(`${this.uri}/icons/${t}/${a}.svg`);return (new DOMParser).parseFromString(e,"text/html").body.querySelector("svg")}async firstUpdated(){try{if(!this.customSvg){const t=await this.fetchIcon(this.category,this.name);if(t)this.svg=t;else if(!t){const t=(new DOMParser).parseFromString(u,"text/html");this.svg=t.body.firstChild;}}}catch(t){this.svg=void 0;}}}css`.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock,:host{display:block}.util_displayFlex{display:flex}.util_displayHidden,:host([hidden]:not(:focus):not(:active)){display:none}.util_displayHiddenVisually,:host([hiddenVisually]:not(:focus):not(:active)){position:absolute;overflow:hidden;clip:rect(1px,1px,1px,1px);width:1px;height:1px;padding:0;border:0}:host{display:inline-block;--ds-auro-icon-size: 100%;width:100%;height:100%}:host .logo{color:var(--ds-auro-alaska-color)}:host([onDark]),:host([appearance=inverse]){--ds-auro-alaska-color: #FFF}
|
|
1122
|
-
`;var y=css`:host{--ds-auro-icon-color: var(--ds-basic-color-texticon-default, #2a2a2a);--ds-auro-alaska-color: #02426D;--ds-auro-icon-size: var(--ds-size-300, 1.5rem)}
|
|
1123
|
-
`;var k=css`:host{color:var(--ds-auro-icon-color)}:host([customColor]){color:inherit}:host(:not([onDark])[variant=accent1]),:host(:not([appearance=inverse])[variant=accent1]){--ds-auro-icon-color: var(--ds-basic-color-texticon-accent1, #265688)}:host(:not([onDark])[variant=disabled]),:host(:not([appearance=inverse])[variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-disabled, #d0d0d0)}:host(:not([onDark])[variant=muted]),:host(:not([appearance=inverse])[variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-muted, #676767)}:host(:not([onDark])[variant=statusDefault]),:host(:not([appearance=inverse])[variant=statusDefault]){--ds-auro-icon-color: var(--ds-basic-color-status-default, #afb9c6)}:host(:not([onDark])[variant=statusInfo]),:host(:not([appearance=inverse])[variant=statusInfo]){--ds-auro-icon-color: var(--ds-basic-color-status-info, #01426a)}:host(:not([onDark])[variant=statusSuccess]),:host(:not([appearance=inverse])[variant=statusSuccess]){--ds-auro-icon-color: var(--ds-basic-color-status-success, #447a1f)}:host(:not([onDark])[variant=statusWarning]),:host(:not([appearance=inverse])[variant=statusWarning]){--ds-auro-icon-color: var(--ds-basic-color-status-warning, #fac200)}:host(:not([onDark])[variant=statusError]),:host(:not([appearance=inverse])[variant=statusError]){--ds-auro-icon-color: var(--ds-basic-color-status-error, #e31f26)}:host(:not([onDark])[variant=statusInfoSubtle]),:host(:not([appearance=inverse])[variant=statusInfoSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-info-subtle, #ebf3f9)}:host(:not([onDark])[variant=statusSuccessSubtle]),:host(:not([appearance=inverse])[variant=statusSuccessSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-success-subtle, #d6eac7)}:host(:not([onDark])[variant=statusWarningSubtle]),:host(:not([appearance=inverse])[variant=statusWarningSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-warning-subtle, #fff0b2)}:host(:not([onDark])[variant=statusErrorSubtle]),:host(:not([appearance=inverse])[variant=statusErrorSubtle]){--ds-auro-icon-color: var(--ds-basic-color-status-error-subtle, #fbc6c6)}:host(:not([onDark])[variant=fareBasicEconomy]),:host(:not([appearance=inverse])[variant=fareBasicEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-basiceconomy, #97eaf8)}:host(:not([onDark])[variant=fareBusiness]),:host(:not([appearance=inverse])[variant=fareBusiness]){--ds-auro-icon-color: var(--ds-basic-color-fare-business, #01426a)}:host(:not([onDark])[variant=fareEconomy]),:host(:not([appearance=inverse])[variant=fareEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-economy, #0074ca)}:host(:not([onDark])[variant=fareFirst]),:host(:not([appearance=inverse])[variant=fareFirst]){--ds-auro-icon-color: var(--ds-basic-color-fare-first, #00274a)}:host(:not([onDark])[variant=farePremiumEconomy]),:host(:not([appearance=inverse])[variant=farePremiumEconomy]){--ds-auro-icon-color: var(--ds-basic-color-fare-premiumeconomy, #005154)}:host(:not([onDark])[variant=tierOneWorldEmerald]),:host(:not([appearance=inverse])[variant=tierOneWorldEmerald]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-emerald, #139142)}:host(:not([onDark])[variant=tierOneWorldSapphire]),:host(:not([appearance=inverse])[variant=tierOneWorldSapphire]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-sapphire, #015daa)}:host(:not([onDark])[variant=tierOneWorldRuby]),:host(:not([appearance=inverse])[variant=tierOneWorldRuby]){--ds-auro-icon-color: var(--ds-basic-color-tier-program-oneworld-ruby, #a41d4a)}:host([onDark]),:host([appearance=inverse]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse, #ffffff)}:host([onDark][variant=disabled]),:host([appearance=inverse][variant=disabled]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-disabled, #7e8894)}:host([onDark][variant=muted]),:host([appearance=inverse][variant=muted]){--ds-auro-icon-color: var(--ds-basic-color-texticon-inverse-muted, #ccd2db)}:host([onDark][variant=statusError]),:host([appearance=inverse][variant=statusError]){--ds-auro-icon-color: var(--ds-advanced-color-state-error-inverse, #f9a4a8)}
|
|
1124
|
-
`;class x extends z{constructor(){super(),this.variant=void 0,this.privateDefaults();}privateDefaults(){this.uri="https://cdn.jsdelivr.net/npm/@alaskaairux/icons@latest/dist",this.runtimeUtils=new p;}static get properties(){return {...z.properties,ariaHidden:{type:String,reflect:true},category:{type:String,reflect:true},customColor:{type:Boolean,reflect:true},customSvg:{type:Boolean},label:{type:Boolean,reflect:true},name:{type:String,reflect:true},variant:{type:String,reflect:true}}}static get styles(){return [z.styles,y,w,k]}static register(t="auro-icon"){p.prototype.registerComponent(t,x);}connectedCallback(){super.connectedCallback(),this.runtimeUtils.handleComponentTagRename(this,"auro-icon");}exposeCssParts(){this.setAttribute("exportparts","svg:iconSvg");}async firstUpdated(){if(await super.firstUpdated(),this.hasAttribute("ariaHidden")&&this.svg){const t=this.svg.querySelector("desc");t&&(t.remove(),this.svg.removeAttribute("aria-labelledby"));}}render(){const t={labelWrapper:true,util_displayHiddenVisually:!this.label};return html`
|
|
1125
|
-
<div class="componentWrapper">
|
|
1126
|
-
<div
|
|
1127
|
-
class="${classMap({svgWrapper:true})}"
|
|
1128
|
-
title="${ifDefined(this.title||void 0)}">
|
|
1129
|
-
<span aria-hidden="${ifDefined(this.ariaHidden||true)}" part="svg">
|
|
1130
|
-
${this.customSvg?html`
|
|
1131
|
-
<slot name="svg"></slot>
|
|
1132
|
-
`:html`
|
|
1133
|
-
${this.svg}
|
|
1134
|
-
`}
|
|
1135
|
-
</span>
|
|
1136
|
-
</div>
|
|
1137
|
-
|
|
1138
|
-
<div class="${classMap(t)}" part="label">
|
|
1139
|
-
<slot></slot>
|
|
1140
|
-
</div>
|
|
1141
|
-
</div>
|
|
1142
|
-
`}}
|
|
1143
|
-
|
|
1144
|
-
var iconVersion = '9.1.0';
|
|
1145
|
-
|
|
1146
|
-
var checkmarkIcon = {"svg":"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" aria-labelledby=\"checkmark-sm__desc\" class=\"ico_squareLarge\" role=\"img\" style=\"min-width:var(--auro-size-lg, var(--ds-size-300, 1.5rem));height:var(--auro-size-lg, var(--ds-size-300, 1.5rem));fill:currentColor\" viewBox=\"0 0 24 24\" part=\"svg\"><title/><desc id=\"checkmark-sm__desc\">a small check mark.</desc><path d=\"M8.461 11.84a.625.625 0 1 0-.922.844l2.504 2.738c.247.27.674.27.922 0l5.496-6a.625.625 0 1 0-.922-.844l-5.035 5.496z\"/></svg>"};
|
|
1147
|
-
|
|
1148
|
-
// Copyright (c) 2021 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
1149
|
-
// See LICENSE in the project root for license information.
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
/**
|
|
1153
|
-
* The auro-menu element provides users a way to define a menu option.
|
|
1154
|
-
*
|
|
1155
|
-
* @attr {String} value - Specifies the value to be sent to a server.
|
|
1156
|
-
* @attr {String} noCheckmark - When true, selected option will not show the checkmark.
|
|
1157
|
-
* @attr {Boolean} disabled - When true specifies that the menuoption is disabled.
|
|
1158
|
-
* @attr {Boolean} selected - Specifies that an option is selected.
|
|
1159
|
-
* @event auroMenuOption-mouseover - Notifies that this option has been hovered over.
|
|
1160
|
-
* @slot - Specifies text for an option, but is not the value.
|
|
1161
|
-
*/
|
|
1162
|
-
class AuroMenuOption extends AuroElement {
|
|
1163
|
-
constructor() {
|
|
1164
|
-
super();
|
|
1165
|
-
|
|
1166
|
-
/**
|
|
1167
|
-
* @private
|
|
1168
|
-
*/
|
|
1169
|
-
this.shape = undefined;
|
|
1170
|
-
|
|
1171
|
-
/**
|
|
1172
|
-
* @private
|
|
1173
|
-
*/
|
|
1174
|
-
this.size = undefined;
|
|
1175
|
-
|
|
1176
|
-
/**
|
|
1177
|
-
* Generate unique names for dependency components.
|
|
1178
|
-
*/
|
|
1179
|
-
const versioning = new AuroDependencyVersioning();
|
|
1180
|
-
this.iconTag = versioning.generateTag('auro-formkit-menuoption-icon', iconVersion, x);
|
|
1181
|
-
|
|
1182
|
-
this.selected = false;
|
|
1183
|
-
this.nocheckmark = false;
|
|
1184
|
-
this.disabled = false;
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
* @private
|
|
1188
|
-
*/
|
|
1189
|
-
this.tabIndex = -1;
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* @private
|
|
1193
|
-
*/
|
|
1194
|
-
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
static get properties() {
|
|
1198
|
-
return {
|
|
1199
|
-
...super.properties,
|
|
1200
|
-
nocheckmark: {
|
|
1201
|
-
type: Boolean,
|
|
1202
|
-
reflect: true
|
|
1203
|
-
},
|
|
1204
|
-
selected: {
|
|
1205
|
-
type: Boolean,
|
|
1206
|
-
reflect: true
|
|
1207
|
-
},
|
|
1208
|
-
disabled: {
|
|
1209
|
-
type: Boolean,
|
|
1210
|
-
reflect: true
|
|
1211
|
-
},
|
|
1212
|
-
value: {
|
|
1213
|
-
type: String,
|
|
1214
|
-
reflect: true
|
|
1215
|
-
},
|
|
1216
|
-
tabIndex: {
|
|
1217
|
-
type: Number,
|
|
1218
|
-
reflect: true
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
static get styles() {
|
|
1224
|
-
return [
|
|
1225
|
-
styleCss,
|
|
1226
|
-
colorCss,
|
|
1227
|
-
tokensCss
|
|
1228
|
-
];
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
/**
|
|
1232
|
-
* This will register this element with the browser.
|
|
1233
|
-
* @param {string} [name="auro-menuoption"] - The name of element that you want to register to.
|
|
1234
|
-
*
|
|
1235
|
-
* @example
|
|
1236
|
-
* AuroMenuOption.register("custom-menuoption") // this will register this element to <custom-menuoption/>
|
|
1237
|
-
*
|
|
1238
|
-
*/
|
|
1239
|
-
static register(name = "auro-menuoption") {
|
|
1240
|
-
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroMenuOption);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
connectedCallback() {
|
|
1244
|
-
super.connectedCallback();
|
|
1245
|
-
|
|
1246
|
-
// Add the tag name as an attribute if it is different than the component name
|
|
1247
|
-
// Add this step soon as this node gets attached to the DOM to avoid racing condition with menu's value setting logic.
|
|
1248
|
-
this.runtimeUtils.handleComponentTagRename(this, 'auro-menuoption');
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
firstUpdated() {
|
|
1252
|
-
if (!this.hasAttribute('size')) {
|
|
1253
|
-
this.size = this.parentElement.getAttribute('size') || 'sm';
|
|
1254
|
-
}
|
|
1255
|
-
if (!this.hasAttribute('shape')) {
|
|
1256
|
-
this.shape = this.parentElement.getAttribute('shape') || 'box';
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
this.setAttribute('role', 'option');
|
|
1260
|
-
this.setAttribute('aria-selected', 'false');
|
|
1261
|
-
|
|
1262
|
-
this.addEventListener('mouseover', () => {
|
|
1263
|
-
this.dispatchEvent(new CustomEvent('auroMenuOption-mouseover', {
|
|
1264
|
-
bubbles: true,
|
|
1265
|
-
cancelable: false,
|
|
1266
|
-
composed: true,
|
|
1267
|
-
detail: this
|
|
1268
|
-
}));
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
// observer for selected property changes
|
|
1273
|
-
updated(changedProperties) {
|
|
1274
|
-
super.updated(changedProperties);
|
|
1275
|
-
|
|
1276
|
-
if (changedProperties.has('selected')) {
|
|
1277
|
-
this.setAttribute('aria-selected', this.selected.toString());
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
* Generates an HTML element containing an SVG icon based on the provided `svgContent`.
|
|
1283
|
-
*
|
|
1284
|
-
* @private
|
|
1285
|
-
* @param {string} svgContent - The SVG content to be embedded.
|
|
1286
|
-
* @returns {Element} The HTML element containing the SVG icon.
|
|
1287
|
-
*/
|
|
1288
|
-
generateIconHtml(svgContent) {
|
|
1289
|
-
const dom = new DOMParser().parseFromString(svgContent, 'text/html');
|
|
1290
|
-
const svg = dom.body.firstChild;
|
|
1291
|
-
|
|
1292
|
-
svg.setAttribute('slot', 'svg');
|
|
1293
|
-
|
|
1294
|
-
return html$1`<${this.iconTag} customColor customSvg>${svg}</${this.iconTag}>`;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
/**
|
|
1298
|
-
* Logic to determine the layout of the component.
|
|
1299
|
-
* @protected
|
|
1300
|
-
* @returns {void}
|
|
1301
|
-
*/
|
|
1302
|
-
renderLayout() {
|
|
1303
|
-
|
|
1304
|
-
const fontClassMap = {
|
|
1305
|
-
xs: 'body-sm',
|
|
1306
|
-
sm: 'body-default',
|
|
1307
|
-
md: 'body-default',
|
|
1308
|
-
lg: 'body-lg',
|
|
1309
|
-
xl: 'body-lg'
|
|
1310
|
-
};
|
|
1311
|
-
|
|
1312
|
-
const classes = classMap({
|
|
1313
|
-
'wrapper': true,
|
|
1314
|
-
[this.size ? fontClassMap[this.size] : 'body-sm']: true,
|
|
1315
|
-
});
|
|
1316
|
-
|
|
1317
|
-
return html$1`
|
|
1318
|
-
<div class="${classes}">
|
|
1319
|
-
${this.selected && !this.nocheckmark
|
|
1320
|
-
? this.generateIconHtml(checkmarkIcon.svg)
|
|
1321
|
-
: undefined}
|
|
1322
|
-
<slot></slot>
|
|
1323
|
-
</div>
|
|
1324
|
-
`;
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
1977
|
AuroMenu.register();
|
|
1329
1978
|
AuroMenuOption.register();
|