@api-client/ui 0.5.52 → 0.5.54
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/build/src/md/menu/internal/Menu.d.ts.map +1 -1
- package/build/src/md/menu/internal/Menu.js +16 -5
- package/build/src/md/menu/internal/Menu.js.map +1 -1
- package/build/src/md/menu/internal/Menu.styles.d.ts.map +1 -1
- package/build/src/md/menu/internal/Menu.styles.js +5 -1
- package/build/src/md/menu/internal/Menu.styles.js.map +1 -1
- package/build/src/md/menu/internal/SubMenu.styles.d.ts.map +1 -1
- package/build/src/md/menu/internal/SubMenu.styles.js +22 -1
- package/build/src/md/menu/internal/SubMenu.styles.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +62 -7
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +248 -32
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/md/menu/internal/Menu.styles.ts +5 -1
- package/src/md/menu/internal/Menu.ts +17 -6
- package/src/md/menu/internal/SubMenu.styles.ts +22 -1
- package/src/md/select/internals/Select.ts +283 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAI1D,OAAO,MAAM,MAAM,8BAA8B,CAAA;AACjD,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,OAAO,UAAU,MAAM,kCAAkC,CAAA;AAGzD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,MAAM;IACtC;;;OAGG;IACyC,QAAQ,CAAC,IAAI,UAAQ;IAEjE;;;OAGG;IACyC,QAAQ,CAAC,QAAQ,UAAQ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EG;IACH,SAAS,CAAC,kBAAkB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAQ5C;;OAEG;IACM,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI;IAuB9C,mBAAmB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;IAIzC;;OAEG;IACH,SAAS,CAAC,WAAW,IAAI,IAAI;IAO7B;;OAEG;IACH,YAAY,IAAI,IAAI;IAQpB;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAKxC,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAUzF;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAOhC;;OAEG;IACH,IAAI,YAAY,IAAI,UAAU,GAAG,IAAI,CAGpC;IAED;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI;IAO9C;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI;IAKjD;;OAEG;IACH,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAKzB,MAAM,IAAI,cAAc;CAWlC"}
|
|
@@ -113,12 +113,14 @@ let Menu = (() => {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
togglePopover(force) {
|
|
116
|
+
if (!this.open && !this.disabled) {
|
|
117
|
+
this.positionMenu();
|
|
118
|
+
}
|
|
116
119
|
this.open = !this.open;
|
|
117
120
|
this.ariaExpanded = String(this.open);
|
|
118
121
|
this.tabIndex = this.open ? 0 : -1;
|
|
119
122
|
const result = super.togglePopover(force);
|
|
120
123
|
if (this.open) {
|
|
121
|
-
this.positionMenu();
|
|
122
124
|
this.focus();
|
|
123
125
|
}
|
|
124
126
|
return result;
|
|
@@ -142,9 +144,9 @@ let Menu = (() => {
|
|
|
142
144
|
showPopover() {
|
|
143
145
|
this.tabIndex = 0; // Make menu focusable
|
|
144
146
|
this.ariaExpanded = 'true';
|
|
147
|
+
this.positionMenu();
|
|
145
148
|
super.showPopover();
|
|
146
149
|
this.open = true;
|
|
147
|
-
this.positionMenu();
|
|
148
150
|
this.focus();
|
|
149
151
|
this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }));
|
|
150
152
|
}
|
|
@@ -160,13 +162,17 @@ let Menu = (() => {
|
|
|
160
162
|
this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }));
|
|
161
163
|
}
|
|
162
164
|
positionMenu() {
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
|
|
165
|
+
// for the frame, make the element visible (without animations)
|
|
166
|
+
// to take measurements correctly.
|
|
167
|
+
this.classList.add('measurements');
|
|
166
168
|
// Reset any previous manual positioning to let CSS anchor positioning work
|
|
167
169
|
this.style.removeProperty('position-area');
|
|
168
170
|
this.style.removeProperty('max-height');
|
|
169
171
|
this.style.removeProperty('max-width');
|
|
172
|
+
// Let CSS anchor positioning handle the positioning automatically
|
|
173
|
+
// Only intervene if we need to set max-height for overflow cases
|
|
174
|
+
const box = this.getBoundingClientRect();
|
|
175
|
+
this.classList.remove('measurements');
|
|
170
176
|
// Check if the menu content is being clipped
|
|
171
177
|
const isVerticallyClipped = this.scrollHeight > this.clientHeight;
|
|
172
178
|
const isHorizontallyClipped = this.scrollWidth > this.clientWidth;
|
|
@@ -177,6 +183,11 @@ let Menu = (() => {
|
|
|
177
183
|
// by checking if the menu is in the upper or lower half of the viewport
|
|
178
184
|
const viewportMiddle = innerHeight / 2;
|
|
179
185
|
const isMenuInUpperHalf = box.top < viewportMiddle;
|
|
186
|
+
// console.log(`Menu positioned at: top=${box.top}, left=${box.left}, bottom=${menuBottom}, right=${menuRight}`)
|
|
187
|
+
// console.log(
|
|
188
|
+
// eslint-disable-next-line max-len
|
|
189
|
+
// `Menu is in upper half: ${isMenuInUpperHalf}, Vertically clipped: ${isVerticallyClipped}, Horizontally clipped: ${isHorizontallyClipped}`
|
|
190
|
+
// )
|
|
180
191
|
// Add CSS class to control animation direction
|
|
181
192
|
if (isMenuInUpperHalf) {
|
|
182
193
|
this.classList.add('menu-positioned-above');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkC,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,MAAM,MAAM,8BAA8B,CAAA;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;;sBAUlB,MAAM;;;;;;;;;;;;;;;iBAAnB,IAAK,SAAQ,WAAM;;;gCAKrC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAM1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAW1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAK3B,KAAK,EAAE;+CA6KP,KAAK;YAnMsC,iKAAS,IAAI,6BAAJ,IAAI,mFAAQ;YAMrB,6KAAS,QAAQ,6BAAR,QAAQ,2FAAQ;YAWxC,qMAAS,gBAAgB,6BAAhB,gBAAgB,2GAAQ;YAKrD,4LAAS,aAAa,6BAAb,aAAa,qGAAyB;YA8KxD,4MAAA,mBAAmB,6DAElB;;;QAtM2C,0BALzB,mDAAI,8CAKqC,KAAK;QAEjE;;;WAGG;WAL8D;QAJjE;;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T,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YACtB,CAAC;QACH,CAAC;QAED;;WAEG;QACO,iBAAiB,CAAC,CAAc;YACxC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;YAChC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;QAED;;WAEG;QACO,gBAAgB;YACxB,kDAAkD;YAClD,IAAI,CAAC,WAAW,EAAE,CAAA;QACpB,CAAC;QAEQ,MAAM;YACb,MAAM,OAAO,GAAG,QAAQ,CAAC;gBACvB,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAA;YAEF,OAAO,IAAI,CAAA;mBACI,OAAO;4BACE,IAAI,CAAC,gBAAgB;;KAE5C,CAAA;QACH,CAAC;;;AAlTH;;;;;;;GAOG;AACH,oBA2SC","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { nanoid } from 'nanoid'\nimport UiList from '../../list/internals/List.js'\nimport UiMenuItem from './MenuItem.js'\nimport UiSubMenu from './SubMenu.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport UiListItem from '../../list/internals/ListItem.js'\nimport { bound } from '../../../decorators/bound.js'\n\n/**\n * Material Design 3 Menu component with sub-menu support.\n * Uses Popover API and Anchor Positioning API for modern positioning.\n *\n * @fires select - Dispatched when a menu item is selected\n * @fires close - Dispatched when the menu is closed\n * @fires open - Dispatched when the menu is opened\n */\nexport default class Menu extends UiList {\n /**\n * Whether the menu is currently open\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n /**\n * Whether the menu is disabled\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * Whether to select menu items when they are activated.\n * When true, clicking or pressing Enter/Space on a menu item will mark it as selected.\n * When false (default), menu items will not be marked as selected when activated.\n *\n * Note, this is different than `selectActive` as this property controls the class names\n * set on the menu item.\n * @attribute\n */\n @property({ type: Boolean }) accessor selectOnActivate = false\n\n /**\n * Currently active sub-menu\n */\n @state() accessor activeSubMenu: UiSubMenu | null = null\n\n constructor() {\n super()\n this.selector = 'ui-menu-item'\n this.ariaExpanded = 'false'\n this.addEventListener('beforetoggle', this.handleBeforeToggle.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.setAttribute('role', 'menu')\n this.setAttribute('tabindex', '-1')\n if (!this.hasAttribute('popover')) {\n this.setAttribute('popover', 'auto')\n }\n if (!this.id) {\n this.id = nanoid()\n }\n }\n\n protected override updated(changedProperties: PropertyValues<this>): void {\n super.updated(changedProperties)\n\n if (changedProperties.has('disabled')) {\n setDisabled(this, this.disabled)\n }\n }\n\n override togglePopover(force?: boolean): boolean {\n this.open = !this.open\n this.ariaExpanded = String(this.open)\n this.tabIndex = this.open ? 0 : -1\n const result = super.togglePopover(force)\n if (this.open) {\n this.positionMenu()\n this.focus()\n }\n return result\n }\n\n protected queryMenuItems(): UiMenuItem[] {\n const slot = this.shadowRoot?.querySelector('slot')\n if (!slot) return []\n const { selector } = this\n return Array.from(slot.assignedElements({ flatten: true })).filter((el) => el.matches(selector)) as UiMenuItem[]\n }\n\n show(): void {\n this.showPopover()\n }\n\n hide(): void {\n this.hidePopover()\n }\n\n /**\n * Shows the menu\n */\n override showPopover(): void {\n this.tabIndex = 0 // Make menu focusable\n this.ariaExpanded = 'true'\n super.showPopover()\n this.open = true\n this.positionMenu()\n this.focus()\n this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }))\n }\n\n /**\n * Hides the menu\n */\n override hidePopover(): void {\n this.tabIndex = -1\n this.ariaExpanded = 'false'\n super.hidePopover()\n this.open = false\n this.closeSubMenu()\n this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }))\n }\n\n positionMenu(): void {\n // Let CSS anchor positioning handle the positioning automatically\n // Only intervene if we need to set max-height for overflow cases\n const box = this.getBoundingClientRect()\n\n // Reset any previous manual positioning to let CSS anchor positioning work\n this.style.removeProperty('position-area')\n this.style.removeProperty('max-height')\n this.style.removeProperty('max-width')\n\n // Check if the menu content is being clipped\n const isVerticallyClipped = this.scrollHeight > this.clientHeight\n const isHorizontallyClipped = this.scrollWidth > this.clientWidth\n\n // Get the actual bottom and right edges of the menu\n const menuBottom = box.top + box.height\n const menuRight = box.left + box.width\n\n // Detect if menu is positioned above or below the anchor\n // by checking if the menu is in the upper or lower half of the viewport\n const viewportMiddle = innerHeight / 2\n const isMenuInUpperHalf = box.top < viewportMiddle\n\n // Add CSS class to control animation direction\n if (isMenuInUpperHalf) {\n this.classList.add('menu-positioned-above')\n this.classList.remove('menu-positioned-below')\n } else {\n this.classList.add('menu-positioned-below')\n this.classList.remove('menu-positioned-above')\n }\n\n // Only set max-height if the menu would overflow the viewport OR is already clipped\n if (menuBottom > innerHeight || isVerticallyClipped) {\n let availableHeight: number\n\n if (isMenuInUpperHalf) {\n // Menu is positioned below the anchor - available space is from top to bottom of viewport\n availableHeight = innerHeight - box.top\n } else {\n // Menu is positioned above the anchor - available space is from top of viewport to bottom of menu\n availableHeight = box.top + box.height\n }\n\n this.style.maxHeight = `${Math.max(200, availableHeight - 20)}px`\n }\n\n // Only set max-width if the menu would overflow the viewport OR is already clipped\n if (menuRight > innerWidth || isHorizontallyClipped) {\n const availableWidth = innerWidth - box.left\n if (availableWidth < 200) {\n this.style.maxWidth = `${Math.max(180, availableWidth - 20)}px`\n }\n }\n }\n\n /**\n * Handles beforetoggle event from popover\n */\n protected handleBeforeToggle(e: Event): void {\n const toggleEvent = e as ToggleEvent\n if (toggleEvent.newState === 'closed') {\n this.open = false\n this.closeSubMenu()\n }\n }\n\n /**\n * Handles keyboard navigation for the menu\n */\n override handleKeydown(e: KeyboardEvent): void {\n if (!this.open || e.defaultPrevented) return\n\n switch (e.key) {\n case 'Escape':\n e.preventDefault()\n this.hide()\n break\n case 'ArrowRight':\n e.preventDefault()\n this.openSubMenu()\n break\n case 'ArrowLeft':\n e.preventDefault()\n this.closeSubMenu()\n break\n default:\n // Let the parent UiList handle other keys\n super.handleKeydown(e)\n }\n }\n\n @bound\n handleSubMenuSelect(e: CustomEvent): void {\n super.notifySelect(e.detail.item, e.detail.index)\n }\n\n /**\n * Opens the sub-menu for the currently active item\n */\n protected openSubMenu(): void {\n const activeItem = this.activeListItem as UiMenuItem\n if (activeItem?.hasSubMenu) {\n activeItem.openSubMenu()\n }\n }\n\n /**\n * Closes the currently open sub-menu\n */\n closeSubMenu(): void {\n if (this.activeSubMenu) {\n this.activeSubMenu.removeEventListener('select', this.handleSubMenuSelect as EventListener)\n this.activeSubMenu.hide()\n this.activeSubMenu = null\n }\n }\n\n /**\n * Sets the active sub-menu\n */\n setActiveSubMenu(subMenu: UiSubMenu | null): void {\n this.activeSubMenu = subMenu\n subMenu?.addEventListener('select', this.handleSubMenuSelect as EventListener)\n }\n\n override notifySelect(item: UiListItem & { selected?: boolean }, index?: number): boolean {\n // Only handle selection if selectOnActivate is enabled\n if (this.selectOnActivate) {\n this.clearSelection()\n item.selected = true\n }\n this.hide()\n return super.notifySelect(item, index)\n }\n\n /**\n * Clears selection from all menu items\n */\n protected clearSelection(): void {\n const items = this.queryMenuItems()\n items.forEach((menuItem) => {\n menuItem.selected = false\n })\n }\n\n /**\n * Gets the currently selected menu item\n */\n get selectedItem(): UiMenuItem | null {\n const items = this.queryMenuItems()\n return items.find((item) => item.selected) || null\n }\n\n /**\n * Sets the selected menu item\n */\n setSelectedItem(item: UiMenuItem | null): void {\n this.clearSelection()\n if (item) {\n item.selected = true\n }\n }\n\n /**\n * Handles sub-menu opening\n */\n protected handleSubMenuOpen(e: CustomEvent): void {\n const subMenu = e.detail.subMenu\n this.setActiveSubMenu(subMenu)\n }\n\n /**\n * Handles slot changes to update menu items\n */\n protected handleSlotChange(): void {\n // Update the items list when slot content changes\n this.updateItems()\n }\n\n override render(): TemplateResult {\n const classes = classMap({\n 'menu-container': true,\n })\n\n return html`\n <div class=${classes}>\n <slot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AAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAA;QACpD,CAAC;QAED;;WAEG;QACH,eAAe,CAAC,IAAuB;YACrC,IAAI,CAAC,cAAc,EAAE,CAAA;YACrB,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YACtB,CAAC;QACH,CAAC;QAED;;WAEG;QACO,iBAAiB,CAAC,CAAc;YACxC,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAA;YAChC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;QAED;;WAEG;QACO,gBAAgB;YACxB,kDAAkD;YAClD,IAAI,CAAC,WAAW,EAAE,CAAA;QACpB,CAAC;QAEQ,MAAM;YACb,MAAM,OAAO,GAAG,QAAQ,CAAC;gBACvB,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAA;YAEF,OAAO,IAAI,CAAA;mBACI,OAAO;4BACE,IAAI,CAAC,gBAAgB;;KAE5C,CAAA;QACH,CAAC;;;AA7TH;;;;;;;GAOG;AACH,oBAsTC","sourcesContent":["import { html, PropertyValues, TemplateResult } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { nanoid } from 'nanoid'\nimport UiList from '../../list/internals/List.js'\nimport UiMenuItem from './MenuItem.js'\nimport UiSubMenu from './SubMenu.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport UiListItem from '../../list/internals/ListItem.js'\nimport { bound } from '../../../decorators/bound.js'\n\n/**\n * Material Design 3 Menu component with sub-menu support.\n * Uses Popover API and Anchor Positioning API for modern positioning.\n *\n * @fires select - Dispatched when a menu item is selected\n * @fires close - Dispatched when the menu is closed\n * @fires open - Dispatched when the menu is opened\n */\nexport default class Menu extends UiList {\n /**\n * Whether the menu is currently open\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n /**\n * Whether the menu is disabled\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n\n /**\n * Whether to select menu items when they are activated.\n * When true, clicking or pressing Enter/Space on a menu item will mark it as selected.\n * When false (default), menu items will not be marked as selected when activated.\n *\n * Note, this is different than `selectActive` as this property controls the class names\n * set on the menu item.\n * @attribute\n */\n @property({ type: Boolean }) accessor selectOnActivate = false\n\n /**\n * Currently active sub-menu\n */\n @state() accessor activeSubMenu: UiSubMenu | null = null\n\n constructor() {\n super()\n this.selector = 'ui-menu-item'\n this.ariaExpanded = 'false'\n this.addEventListener('beforetoggle', this.handleBeforeToggle.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.setAttribute('role', 'menu')\n this.setAttribute('tabindex', '-1')\n if (!this.hasAttribute('popover')) {\n this.setAttribute('popover', 'auto')\n }\n if (!this.id) {\n this.id = nanoid()\n }\n }\n\n protected override updated(changedProperties: PropertyValues<this>): void {\n super.updated(changedProperties)\n\n if (changedProperties.has('disabled')) {\n setDisabled(this, this.disabled)\n }\n }\n\n override togglePopover(force?: boolean): boolean {\n if (!this.open && !this.disabled) {\n this.positionMenu()\n }\n this.open = !this.open\n this.ariaExpanded = String(this.open)\n this.tabIndex = this.open ? 0 : -1\n const result = super.togglePopover(force)\n if (this.open) {\n this.focus()\n }\n return result\n }\n\n protected queryMenuItems(): UiMenuItem[] {\n const slot = this.shadowRoot?.querySelector('slot')\n if (!slot) return []\n const { selector } = this\n return Array.from(slot.assignedElements({ flatten: true })).filter((el) => el.matches(selector)) as UiMenuItem[]\n }\n\n show(): void {\n this.showPopover()\n }\n\n hide(): void {\n this.hidePopover()\n }\n\n /**\n * Shows the menu\n */\n override showPopover(): void {\n this.tabIndex = 0 // Make menu focusable\n this.ariaExpanded = 'true'\n this.positionMenu()\n super.showPopover()\n this.open = true\n this.focus()\n this.dispatchEvent(new CustomEvent('open', { bubbles: false, composed: true }))\n }\n\n /**\n * Hides the menu\n */\n override hidePopover(): void {\n this.tabIndex = -1\n this.ariaExpanded = 'false'\n super.hidePopover()\n this.open = false\n this.closeSubMenu()\n this.dispatchEvent(new CustomEvent('close', { bubbles: false, composed: true }))\n }\n\n positionMenu(): void {\n // for the frame, make the element visible (without animations)\n // to take measurements correctly.\n this.classList.add('measurements')\n\n // Reset any previous manual positioning to let CSS anchor positioning work\n this.style.removeProperty('position-area')\n this.style.removeProperty('max-height')\n this.style.removeProperty('max-width')\n\n // Let CSS anchor positioning handle the positioning automatically\n // Only intervene if we need to set max-height for overflow cases\n const box = this.getBoundingClientRect()\n this.classList.remove('measurements')\n\n // Check if the menu content is being clipped\n const isVerticallyClipped = this.scrollHeight > this.clientHeight\n const isHorizontallyClipped = this.scrollWidth > this.clientWidth\n\n // Get the actual bottom and right edges of the menu\n const menuBottom = box.top + box.height\n const menuRight = box.left + box.width\n\n // Detect if menu is positioned above or below the anchor\n // by checking if the menu is in the upper or lower half of the viewport\n const viewportMiddle = innerHeight / 2\n const isMenuInUpperHalf = box.top < viewportMiddle\n\n // console.log(`Menu positioned at: top=${box.top}, left=${box.left}, bottom=${menuBottom}, right=${menuRight}`)\n // console.log(\n // eslint-disable-next-line max-len\n // `Menu is in upper half: ${isMenuInUpperHalf}, Vertically clipped: ${isVerticallyClipped}, Horizontally clipped: ${isHorizontallyClipped}`\n // )\n // Add CSS class to control animation direction\n if (isMenuInUpperHalf) {\n this.classList.add('menu-positioned-above')\n this.classList.remove('menu-positioned-below')\n } else {\n this.classList.add('menu-positioned-below')\n this.classList.remove('menu-positioned-above')\n }\n // Only set max-height if the menu would overflow the viewport OR is already clipped\n if (menuBottom > innerHeight || isVerticallyClipped) {\n let availableHeight: number\n\n if (isMenuInUpperHalf) {\n // Menu is positioned below the anchor - available space is from top to bottom of viewport\n availableHeight = innerHeight - box.top\n } else {\n // Menu is positioned above the anchor - available space is from top of viewport to bottom of menu\n availableHeight = box.top + box.height\n }\n\n this.style.maxHeight = `${Math.max(200, availableHeight - 20)}px`\n }\n\n // Only set max-width if the menu would overflow the viewport OR is already clipped\n if (menuRight > innerWidth || isHorizontallyClipped) {\n const availableWidth = innerWidth - box.left\n if (availableWidth < 200) {\n this.style.maxWidth = `${Math.max(180, availableWidth - 20)}px`\n }\n }\n }\n\n /**\n * Handles beforetoggle event from popover\n */\n protected handleBeforeToggle(e: Event): void {\n const toggleEvent = e as ToggleEvent\n if (toggleEvent.newState === 'closed') {\n this.open = false\n this.closeSubMenu()\n }\n }\n\n /**\n * Handles keyboard navigation for the menu\n */\n override handleKeydown(e: KeyboardEvent): void {\n if (!this.open || e.defaultPrevented) return\n\n switch (e.key) {\n case 'Escape':\n e.preventDefault()\n this.hide()\n break\n case 'ArrowRight':\n e.preventDefault()\n this.openSubMenu()\n break\n case 'ArrowLeft':\n e.preventDefault()\n this.closeSubMenu()\n break\n default:\n // Let the parent UiList handle other keys\n super.handleKeydown(e)\n }\n }\n\n @bound\n handleSubMenuSelect(e: CustomEvent): void {\n super.notifySelect(e.detail.item, e.detail.index)\n }\n\n /**\n * Opens the sub-menu for the currently active item\n */\n protected openSubMenu(): void {\n const activeItem = this.activeListItem as UiMenuItem\n if (activeItem?.hasSubMenu) {\n activeItem.openSubMenu()\n }\n }\n\n /**\n * Closes the currently open sub-menu\n */\n closeSubMenu(): void {\n if (this.activeSubMenu) {\n this.activeSubMenu.removeEventListener('select', this.handleSubMenuSelect as EventListener)\n this.activeSubMenu.hide()\n this.activeSubMenu = null\n }\n }\n\n /**\n * Sets the active sub-menu\n */\n setActiveSubMenu(subMenu: UiSubMenu | null): void {\n this.activeSubMenu = subMenu\n subMenu?.addEventListener('select', this.handleSubMenuSelect as EventListener)\n }\n\n override notifySelect(item: UiListItem & { selected?: boolean }, index?: number): boolean {\n // Only handle selection if selectOnActivate is enabled\n if (this.selectOnActivate) {\n this.clearSelection()\n item.selected = true\n }\n this.hide()\n return super.notifySelect(item, index)\n }\n\n /**\n * Clears selection from all menu items\n */\n protected clearSelection(): void {\n const items = this.queryMenuItems()\n items.forEach((menuItem) => {\n menuItem.selected = false\n })\n }\n\n /**\n * Gets the currently selected menu item\n */\n get selectedItem(): UiMenuItem | null {\n const items = this.queryMenuItems()\n return items.find((item) => item.selected) || null\n }\n\n /**\n * Sets the selected menu item\n */\n setSelectedItem(item: UiMenuItem | null): void {\n this.clearSelection()\n if (item) {\n item.selected = true\n }\n }\n\n /**\n * Handles sub-menu opening\n */\n protected handleSubMenuOpen(e: CustomEvent): void {\n const subMenu = e.detail.subMenu\n this.setActiveSubMenu(subMenu)\n }\n\n /**\n * Handles slot changes to update menu items\n */\n protected handleSlotChange(): void {\n // Update the items list when slot content changes\n this.updateItems()\n }\n\n override render(): TemplateResult {\n const classes = classMap({\n 'menu-container': true,\n })\n\n return html`\n <div class=${classes}>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"Menu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.styles.ts"],"names":[],"mappings":";AAEA,wBA2QC"}
|
|
@@ -8,7 +8,6 @@ export default css `
|
|
|
8
8
|
margin: 0;
|
|
9
9
|
padding: 0;
|
|
10
10
|
border: none;
|
|
11
|
-
overflow: hidden;
|
|
12
11
|
/* in most cases the max-height won't matter as this assumes the whole screen to be available, which is rarely the truth. */
|
|
13
12
|
max-height: 90vh;
|
|
14
13
|
overflow: auto;
|
|
@@ -26,6 +25,11 @@ export default css `
|
|
|
26
25
|
position-area: top span-left;
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
/* Special class set on the element to render the menu to take measurements */
|
|
29
|
+
:host(.measurements) {
|
|
30
|
+
display: block;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
:host(:popover-open) {
|
|
30
34
|
display: block;
|
|
31
35
|
background-color: var(--md-sys-color-surface-container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"Menu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/Menu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2QjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: none;\n position-area: bottom span-right;\n position-try: --menu-fallback-bottom-left, --menu-fallback-top-right, --menu-fallback-top-left, flip-block;\n position: fixed;\n margin: 0;\n padding: 0;\n border: none;\n /* in most cases the max-height won't matter as this assumes the whole screen to be available, which is rarely the truth. */\n max-height: 90vh;\n overflow: auto;\n }\n\n @position-try --menu-fallback-bottom-left {\n position-area: bottom span-left;\n }\n\n @position-try --menu-fallback-top-right {\n position-area: top span-right;\n }\n\n @position-try --menu-fallback-top-left {\n position-area: top span-left;\n }\n\n /* Special class set on the element to render the menu to take measurements */\n :host(.measurements) {\n display: block;\n }\n\n :host(:popover-open) {\n display: block;\n background-color: var(--md-sys-color-surface-container);\n border-radius: var(--md-sys-shape-corner-extra-small);\n box-shadow: var(--md-sys-elevation-3);\n animation: menu-scale-in 0.15s cubic-bezier(0.4, 0, 0.2, 1) forwards;\n }\n\n /* Scale animation for menus positioned below the anchor */\n @keyframes menu-scale-in {\n 0% {\n transform: scaleY(0);\n transform-origin: top center;\n opacity: 0;\n }\n 100% {\n transform: scaleY(1);\n transform-origin: top center;\n opacity: 1;\n }\n }\n\n /* Scale animation for menus positioned above the anchor */\n @keyframes menu-scale-in-up {\n 0% {\n transform: scaleY(0);\n transform-origin: bottom center;\n opacity: 0;\n }\n 100% {\n transform: scaleY(1);\n transform-origin: bottom center;\n opacity: 1;\n }\n }\n\n /* Position-specific animations using JavaScript-detected classes */\n :host(.menu-positioned-above):popover-open {\n animation: menu-scale-in-up 0.15s var(--md-sys-motion-easing-standard-accelerate) forwards;\n }\n\n :host(.menu-positioned-below):popover-open {\n animation: menu-scale-in 0.15s var(--md-sys-motion-easing-standard-accelerate) forwards;\n }\n\n .menu-container {\n min-width: 200px;\n padding: 8px 0;\n outline: none;\n }\n\n .menu-divider {\n height: 1px;\n background-color: var(--md-sys-color-outline-variant);\n margin: 8px 0;\n }\n\n /* Menu Item Styles */\n .menu-item {\n position: relative;\n display: flex;\n align-items: center;\n min-height: 48px;\n padding: 0 16px;\n cursor: pointer;\n outline: none;\n transition: background-color 0.2s ease;\n }\n\n .menu-item:hover {\n background-color: var(--md-sys-color-surface-variant);\n }\n\n .menu-item:focus {\n background-color: var(--md-sys-color-surface-variant);\n }\n\n .menu-item[disabled] {\n opacity: 0.38;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n .menu-item-content {\n display: flex;\n align-items: center;\n width: 100%;\n gap: 12px;\n }\n\n .menu-item-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n color: var(--md-sys-color-on-surface);\n font-size: 20px;\n }\n\n .menu-item-label {\n flex: 1;\n color: var(--md-sys-color-on-surface);\n font-family: var(--md-sys-typescale-label-large-font-family-name);\n font-size: var(--md-sys-typescale-label-large-font-size);\n font-weight: var(--md-sys-typescale-label-large-font-weight);\n line-height: var(--md-sys-typescale-label-large-line-height);\n letter-spacing: var(--md-sys-typescale-label-large-letter-spacing);\n }\n\n .menu-item-arrow {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 24px;\n height: 24px;\n color: var(--md-sys-color-on-surface);\n font-size: 18px;\n font-weight: 500;\n }\n\n .menu-item-with-submenu {\n position: relative;\n }\n\n .menu-item-with-submenu:hover .menu-item-arrow {\n color: var(--md-sys-color-primary);\n }\n\n /* Sub-menu Styles */\n .submenu-container {\n min-width: 200px;\n max-width: 320px;\n background-color: var(--md-sys-color-surface);\n border-radius: var(--md-sys-shape-corner-extra-small);\n box-shadow: var(--md-sys-elevation-level3);\n padding: 8px 0;\n }\n\n /* Submenu positioning with Anchor API */\n ui-sub-menu {\n display: none;\n }\n\n ui-sub-menu:popover-open {\n display: block;\n background-color: var(--md-sys-color-surface);\n border-radius: var(--md-sys-shape-corner-extra-small);\n box-shadow: var(--md-sys-elevation-level3);\n min-width: 200px;\n max-width: 320px;\n padding: 8px 0;\n z-index: 1000;\n animation: submenu-scale-in 0.12s cubic-bezier(0.4, 0, 0.2, 1) forwards;\n }\n\n /* Submenu scale animation */\n @keyframes submenu-scale-in {\n 0% {\n transform: scaleY(0) scaleX(0.8);\n transform-origin: left top;\n opacity: 0;\n }\n 100% {\n transform: scaleY(1) scaleX(1);\n transform-origin: left top;\n opacity: 1;\n }\n }\n\n /* Fallback positioning for browsers without anchor positioning */\n @supports not (anchor-name: --test) {\n ui-sub-menu:popover-open {\n position: fixed;\n transform: translateX(200px);\n }\n }\n\n /* Focus Ring */\n md-focus-ring {\n --md-focus-ring-color: var(--md-sys-color-primary);\n --md-focus-ring-width: 2px;\n }\n\n /* Ripple Effect */\n ui-ripple {\n --md-ripple-color: var(--md-sys-color-primary);\n --md-ripple-opacity: 0.12;\n }\n\n /* Responsive Design */\n @media (max-width: 600px) {\n .menu-container {\n min-width: 180px;\n max-width: 280px;\n }\n\n .submenu-container {\n min-width: 180px;\n max-width: 280px;\n }\n }\n\n /* High Contrast Mode */\n @media (prefers-contrast: high) {\n .menu-container {\n border: 1px solid var(--md-sys-color-outline);\n }\n\n .submenu-container {\n border: 1px solid var(--md-sys-color-outline);\n }\n\n .menu-divider {\n background-color: var(--md-sys-color-outline);\n }\n }\n\n /* Reduced Motion */\n @media (prefers-reduced-motion: reduce) {\n .menu-item {\n transition: none;\n }\n\n :host(:popover-open) {\n animation: none;\n opacity: 1;\n transform: none;\n }\n\n ui-sub-menu:popover-open {\n animation: none;\n opacity: 1;\n transform: none;\n }\n }\n`\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubMenu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"SubMenu.styles.d.ts","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":";AAEA,wBA0BC"}
|
|
@@ -2,7 +2,28 @@ import { css } from 'lit';
|
|
|
2
2
|
export default css `
|
|
3
3
|
:host {
|
|
4
4
|
position-area: span-bottom right;
|
|
5
|
-
position-try
|
|
5
|
+
position-try:
|
|
6
|
+
--submenu-fallback-left,
|
|
7
|
+
--submenu-fallback-top-right,
|
|
8
|
+
--submenu-fallback-top-left,
|
|
9
|
+
--submenu-fallback-bottom-left,
|
|
10
|
+
flip-block flip-inline;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@position-try --submenu-fallback-left {
|
|
14
|
+
position-area: span-bottom left;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@position-try --submenu-fallback-top-right {
|
|
18
|
+
position-area: span-top right;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@position-try --submenu-fallback-top-left {
|
|
22
|
+
position-area: span-top left;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@position-try --submenu-fallback-bottom-left {
|
|
26
|
+
position-area: span-bottom left;
|
|
6
27
|
}
|
|
7
28
|
`;
|
|
8
29
|
//# sourceMappingURL=SubMenu.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubMenu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"SubMenu.styles.js","sourceRoot":"","sources":["../../../../../src/md/menu/internal/SubMenu.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n position-area: span-bottom right;\n position-try:\n --submenu-fallback-left,\n --submenu-fallback-top-right,\n --submenu-fallback-top-left,\n --submenu-fallback-bottom-left,\n flip-block flip-inline;\n }\n\n @position-try --submenu-fallback-left {\n position-area: span-bottom left;\n }\n\n @position-try --submenu-fallback-top-right {\n position-area: span-top right;\n }\n\n @position-try --submenu-fallback-top-left {\n position-area: span-top left;\n }\n\n @position-try --submenu-fallback-bottom-left {\n position-area: span-bottom left;\n }\n`\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { UiElement } from '../../UiElement.js';
|
|
2
3
|
import type UiOption from './Option.js';
|
|
3
4
|
import type { UiMenuElement } from '../../menu/ui-menu.js';
|
|
4
5
|
import '../../text-field/ui-outlined-text-field.js';
|
|
@@ -17,9 +18,13 @@ export interface UiSelectChangeEvent {
|
|
|
17
18
|
* @fires open - Dispatched when the dropdown opens
|
|
18
19
|
* @fires close - Dispatched when the dropdown closes
|
|
19
20
|
*/
|
|
20
|
-
export default class UiSelect extends
|
|
21
|
+
export default class UiSelect extends UiElement {
|
|
21
22
|
#private;
|
|
22
23
|
static readonly formAssociated = true;
|
|
24
|
+
/**
|
|
25
|
+
* Timeout duration for type-ahead reset (in milliseconds)
|
|
26
|
+
*/
|
|
27
|
+
static readonly TYPE_AHEAD_TIMEOUT = 1000;
|
|
23
28
|
/**
|
|
24
29
|
* The currently selected value. Corresponds to the `value` attribute of the selected `ui-option`.
|
|
25
30
|
* When set programmatically, it will update the selected option if a matching option exists.
|
|
@@ -134,7 +139,6 @@ export default class UiSelect extends LitElement {
|
|
|
134
139
|
*/
|
|
135
140
|
accessor open: boolean;
|
|
136
141
|
accessor selectedOption: UiOption | null;
|
|
137
|
-
accessor ariaActiveDescendant: string | undefined;
|
|
138
142
|
accessor menu: UiMenuElement;
|
|
139
143
|
/**
|
|
140
144
|
* Returns the currently selected option element. This provides access to the
|
|
@@ -207,6 +211,7 @@ export default class UiSelect extends LitElement {
|
|
|
207
211
|
checkValidity(): boolean;
|
|
208
212
|
constructor();
|
|
209
213
|
connectedCallback(): void;
|
|
214
|
+
disconnectedCallback(): void;
|
|
210
215
|
/**
|
|
211
216
|
* Resets the select to its initial state. Called automatically when the parent
|
|
212
217
|
* form is reset. Part of the form-associated custom element API.
|
|
@@ -244,15 +249,65 @@ export default class UiSelect extends LitElement {
|
|
|
244
249
|
protected setCurrentOption(): void;
|
|
245
250
|
protected handleKeydown(e: KeyboardEvent): void;
|
|
246
251
|
protected handleBlur(e: FocusEvent): void;
|
|
247
|
-
|
|
252
|
+
handleClick(e: Event): void;
|
|
248
253
|
protected handleOpenChange(): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Focus the next menu item in the dropdown, skipping disabled options
|
|
256
|
+
*/
|
|
257
|
+
focusNextMenuItem(): void;
|
|
258
|
+
/**
|
|
259
|
+
* Focus the previous menu item in the dropdown, skipping disabled options
|
|
260
|
+
*/
|
|
261
|
+
focusPreviousMenuItem(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Focus the first menu item in the dropdown, skipping disabled options
|
|
264
|
+
*/
|
|
265
|
+
focusFirstMenuItem(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Focus the last menu item in the dropdown, skipping disabled options
|
|
268
|
+
*/
|
|
269
|
+
focusLastMenuItem(): void;
|
|
270
|
+
/**
|
|
271
|
+
* Gets the first selectable (non-disabled) option
|
|
272
|
+
*/
|
|
273
|
+
getFirstSelectableOption(): UiOption | null;
|
|
274
|
+
/**
|
|
275
|
+
* Gets the last selectable (non-disabled) option
|
|
276
|
+
*/
|
|
277
|
+
getLastSelectableOption(): UiOption | null;
|
|
278
|
+
/**
|
|
279
|
+
* Gets the next selectable option after the current one, wrapping around if needed
|
|
280
|
+
*/
|
|
281
|
+
protected getNextSelectableOption(currentOption: UiOption): UiOption | null;
|
|
282
|
+
/**
|
|
283
|
+
* Gets the previous selectable option before the current one, wrapping around if needed
|
|
284
|
+
*/
|
|
285
|
+
protected getPreviousSelectableOption(currentOption: UiOption): UiOption | null;
|
|
286
|
+
/**
|
|
287
|
+
* Checks if an option is selectable (not disabled and not hidden)
|
|
288
|
+
*/
|
|
289
|
+
protected isOptionSelectable(option: UiOption): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Handles type-ahead functionality for keyboard navigation
|
|
292
|
+
*/
|
|
293
|
+
protected handleTypeAhead(char: string): void;
|
|
294
|
+
/**
|
|
295
|
+
* Finds an option that matches the type-ahead search string
|
|
296
|
+
*/
|
|
297
|
+
protected findOptionByTypeAhead(searchString: string): UiOption | null;
|
|
298
|
+
/**
|
|
299
|
+
* Gets the display text for an option (either textContent or renderValue)
|
|
300
|
+
*/
|
|
301
|
+
protected getOptionDisplayText(option: UiOption): string;
|
|
302
|
+
/**
|
|
303
|
+
* Selects an option and updates the component state
|
|
304
|
+
*/
|
|
305
|
+
protected selectOption(option: UiOption): void;
|
|
249
306
|
handleSelect(e: CustomEvent<{
|
|
250
307
|
item: UiOption;
|
|
251
308
|
}>): void;
|
|
252
|
-
handleHighlightChange(e: CustomEvent<{
|
|
253
|
-
item: UiOption | null;
|
|
254
|
-
}>): void;
|
|
255
309
|
handleMenuClose(): void;
|
|
310
|
+
handleMenuToggle(e: ToggleEvent): void;
|
|
256
311
|
protected renderInput(): TemplateResult;
|
|
257
312
|
protected renderMenu(): TemplateResult;
|
|
258
313
|
protected handleSlotChange(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/md/select/internals/Select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAK1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,4CAA4C,CAAA;AACnD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,wBAAwB,CAAA;AAC/B,OAAO,mCAAmC,CAAA;AAE1C,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,SAAS;;IAC7C,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAO;IAmBrC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,QAAO;IAEzC;;;;;;;;;;;;OAYG;IACH,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IACI,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAKrC;IAED;;;;;;;;;;;OAWG;IACyB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IAE7D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