@m3e/web 2.5.13 → 2.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/all.js +344 -154
  2. package/dist/all.js.map +1 -1
  3. package/dist/all.min.js +64 -64
  4. package/dist/all.min.js.map +1 -1
  5. package/dist/avatar.js +1 -1
  6. package/dist/avatar.js.map +1 -1
  7. package/dist/avatar.min.js +1 -1
  8. package/dist/avatar.min.js.map +1 -1
  9. package/dist/badge.js +29 -8
  10. package/dist/badge.js.map +1 -1
  11. package/dist/badge.min.js +1 -1
  12. package/dist/badge.min.js.map +1 -1
  13. package/dist/bottom-sheet.js +1 -1
  14. package/dist/bottom-sheet.js.map +1 -1
  15. package/dist/bottom-sheet.min.js +1 -1
  16. package/dist/bottom-sheet.min.js.map +1 -1
  17. package/dist/calendar.js +1 -1
  18. package/dist/calendar.js.map +1 -1
  19. package/dist/calendar.min.js +1 -1
  20. package/dist/calendar.min.js.map +1 -1
  21. package/dist/checkbox.js +1 -1
  22. package/dist/checkbox.js.map +1 -1
  23. package/dist/checkbox.min.js +1 -1
  24. package/dist/checkbox.min.js.map +1 -1
  25. package/dist/core-anchoring.js +40 -10
  26. package/dist/core-anchoring.js.map +1 -1
  27. package/dist/core-anchoring.min.js +1 -1
  28. package/dist/core-anchoring.min.js.map +1 -1
  29. package/dist/core.js +10 -6
  30. package/dist/core.js.map +1 -1
  31. package/dist/core.min.js +1 -1
  32. package/dist/core.min.js.map +1 -1
  33. package/dist/custom-elements.json +227 -42
  34. package/dist/datepicker.js +23 -8
  35. package/dist/datepicker.js.map +1 -1
  36. package/dist/datepicker.min.js +1 -1
  37. package/dist/datepicker.min.js.map +1 -1
  38. package/dist/dialog.js +1 -1
  39. package/dist/dialog.js.map +1 -1
  40. package/dist/dialog.min.js +1 -1
  41. package/dist/dialog.min.js.map +1 -1
  42. package/dist/divider.js +1 -1
  43. package/dist/divider.js.map +1 -1
  44. package/dist/divider.min.js +1 -1
  45. package/dist/divider.min.js.map +1 -1
  46. package/dist/drawer-container.js +2 -2
  47. package/dist/drawer-container.js.map +1 -1
  48. package/dist/drawer-container.min.js +1 -1
  49. package/dist/drawer-container.min.js.map +1 -1
  50. package/dist/expansion-panel.js +6 -3
  51. package/dist/expansion-panel.js.map +1 -1
  52. package/dist/expansion-panel.min.js +1 -1
  53. package/dist/expansion-panel.min.js.map +1 -1
  54. package/dist/fab-menu.js +1 -1
  55. package/dist/fab-menu.js.map +1 -1
  56. package/dist/fab-menu.min.js +1 -1
  57. package/dist/fab-menu.min.js.map +1 -1
  58. package/dist/html-custom-data.json +1 -1
  59. package/dist/icon.js +7 -8
  60. package/dist/icon.js.map +1 -1
  61. package/dist/icon.min.js +1 -1
  62. package/dist/icon.min.js.map +1 -1
  63. package/dist/menu.js +20 -7
  64. package/dist/menu.js.map +1 -1
  65. package/dist/menu.min.js +1 -1
  66. package/dist/menu.min.js.map +1 -1
  67. package/dist/nav-bar.js +2 -2
  68. package/dist/nav-bar.js.map +1 -1
  69. package/dist/nav-bar.min.js +1 -1
  70. package/dist/nav-bar.min.js.map +1 -1
  71. package/dist/nav-menu.js +2 -2
  72. package/dist/nav-menu.js.map +1 -1
  73. package/dist/nav-menu.min.js +1 -1
  74. package/dist/nav-menu.min.js.map +1 -1
  75. package/dist/nav-rail.js +1 -1
  76. package/dist/nav-rail.js.map +1 -1
  77. package/dist/nav-rail.min.js +1 -1
  78. package/dist/nav-rail.min.js.map +1 -1
  79. package/dist/radio-group.js +1 -1
  80. package/dist/radio-group.js.map +1 -1
  81. package/dist/radio-group.min.js +1 -1
  82. package/dist/radio-group.min.js.map +1 -1
  83. package/dist/search.js +31 -11
  84. package/dist/search.js.map +1 -1
  85. package/dist/search.min.js +1 -1
  86. package/dist/search.min.js.map +1 -1
  87. package/dist/skeleton.js +89 -44
  88. package/dist/skeleton.js.map +1 -1
  89. package/dist/skeleton.min.js +1 -1
  90. package/dist/skeleton.min.js.map +1 -1
  91. package/dist/slide-group.js +1 -1
  92. package/dist/slide-group.js.map +1 -1
  93. package/dist/slide-group.min.js +1 -1
  94. package/dist/slide-group.min.js.map +1 -1
  95. package/dist/slider.js +2 -2
  96. package/dist/slider.js.map +1 -1
  97. package/dist/slider.min.js +1 -1
  98. package/dist/slider.min.js.map +1 -1
  99. package/dist/snackbar.js +1 -1
  100. package/dist/snackbar.js.map +1 -1
  101. package/dist/snackbar.min.js +1 -1
  102. package/dist/snackbar.min.js.map +1 -1
  103. package/dist/split-pane.js +1 -1
  104. package/dist/split-pane.js.map +1 -1
  105. package/dist/split-pane.min.js +1 -1
  106. package/dist/split-pane.min.js.map +1 -1
  107. package/dist/src/avatar/AvatarElement.d.ts.map +1 -1
  108. package/dist/src/badge/BadgeElement.d.ts +1 -0
  109. package/dist/src/badge/BadgeElement.d.ts.map +1 -1
  110. package/dist/src/bottom-sheet/BottomSheetElement.d.ts.map +1 -1
  111. package/dist/src/calendar/CalendarElement.d.ts.map +1 -1
  112. package/dist/src/checkbox/CheckboxElement.d.ts.map +1 -1
  113. package/dist/src/core/anchoring/FloatingPanelElement.d.ts.map +1 -1
  114. package/dist/src/core/anchoring/positionAnchor.d.ts.map +1 -1
  115. package/dist/src/core/shared/mixins/AttachInternals.d.ts.map +1 -1
  116. package/dist/src/core/shared/primitives/FocusRingElement.d.ts.map +1 -1
  117. package/dist/src/core/shared/primitives/PseudoCheckboxElement.d.ts.map +1 -1
  118. package/dist/src/core/shared/primitives/PseudoRadioElement.d.ts.map +1 -1
  119. package/dist/src/core/shared/primitives/RippleElement.d.ts.map +1 -1
  120. package/dist/src/core/shared/primitives/StateLayerElement.d.ts.map +1 -1
  121. package/dist/src/datepicker/DatepickerElement.d.ts.map +1 -1
  122. package/dist/src/dialog/DialogElement.d.ts.map +1 -1
  123. package/dist/src/divider/DividerElement.d.ts.map +1 -1
  124. package/dist/src/drawer-container/styles/DrawerContainerStyle.d.ts.map +1 -1
  125. package/dist/src/expansion-panel/ExpansionPanelElement.d.ts.map +1 -1
  126. package/dist/src/expansion-panel/styles/ExpansionHeaderStyle.d.ts.map +1 -1
  127. package/dist/src/expansion-panel/styles/ExpansionPanelStyle.d.ts.map +1 -1
  128. package/dist/src/fab-menu/FabMenuElement.d.ts.map +1 -1
  129. package/dist/src/menu/MenuElement.d.ts.map +1 -1
  130. package/dist/src/nav-bar/NavBarElement.d.ts.map +1 -1
  131. package/dist/src/nav-bar/NavItemElement.d.ts.map +1 -1
  132. package/dist/src/nav-menu/NavMenuElement.d.ts.map +1 -1
  133. package/dist/src/nav-menu/NavMenuItemElement.d.ts.map +1 -1
  134. package/dist/src/nav-rail/NavRailElement.d.ts.map +1 -1
  135. package/dist/src/radio-group/RadioElement.d.ts.map +1 -1
  136. package/dist/src/search/SearchViewElement.d.ts.map +1 -1
  137. package/dist/src/search/styles/SearchBarStyle.d.ts.map +1 -1
  138. package/dist/src/search/styles/SearchViewStyle.d.ts.map +1 -1
  139. package/dist/src/skeleton/SkeletonElement.d.ts +11 -1
  140. package/dist/src/skeleton/SkeletonElement.d.ts.map +1 -1
  141. package/dist/src/slide-group/SlideGroupElement.d.ts.map +1 -1
  142. package/dist/src/slider/SliderElement.d.ts.map +1 -1
  143. package/dist/src/slider/SliderThumbElement.d.ts.map +1 -1
  144. package/dist/src/snackbar/SnackbarElement.d.ts.map +1 -1
  145. package/dist/src/split-pane/SplitPaneElement.d.ts.map +1 -1
  146. package/dist/src/stepper/StepElement.d.ts.map +1 -1
  147. package/dist/src/stepper/StepPanelElement.d.ts.map +1 -1
  148. package/dist/src/stepper/StepperElement.d.ts.map +1 -1
  149. package/dist/src/switch/styles/SwitchStyle.d.ts.map +1 -1
  150. package/dist/src/switch/styles/SwitchTrackStyle.d.ts.map +1 -1
  151. package/dist/src/tabs/TabElement.d.ts.map +1 -1
  152. package/dist/src/tabs/TabPanelElement.d.ts.map +1 -1
  153. package/dist/src/tabs/TabsElement.d.ts.map +1 -1
  154. package/dist/src/toc/TocElement.d.ts.map +1 -1
  155. package/dist/src/toc/TocItemElement.d.ts.map +1 -1
  156. package/dist/src/tooltip/RichTooltipElement.d.ts +2 -0
  157. package/dist/src/tooltip/RichTooltipElement.d.ts.map +1 -1
  158. package/dist/src/tooltip/TooltipElement.d.ts +4 -0
  159. package/dist/src/tooltip/TooltipElement.d.ts.map +1 -1
  160. package/dist/src/tree/TreeElement.d.ts.map +1 -1
  161. package/dist/src/tree/TreeItemElement.d.ts.map +1 -1
  162. package/dist/stepper.js +3 -3
  163. package/dist/stepper.js.map +1 -1
  164. package/dist/stepper.min.js +1 -1
  165. package/dist/stepper.min.js.map +1 -1
  166. package/dist/switch.js +2 -2
  167. package/dist/switch.js.map +1 -1
  168. package/dist/switch.min.js +1 -1
  169. package/dist/switch.min.js.map +1 -1
  170. package/dist/tabs.js +3 -3
  171. package/dist/tabs.js.map +1 -1
  172. package/dist/tabs.min.js +1 -1
  173. package/dist/tabs.min.js.map +1 -1
  174. package/dist/toc.js +2 -2
  175. package/dist/toc.js.map +1 -1
  176. package/dist/toc.min.js +1 -1
  177. package/dist/toc.min.js.map +1 -1
  178. package/dist/tooltip.js +58 -18
  179. package/dist/tooltip.js.map +1 -1
  180. package/dist/tooltip.min.js +1 -1
  181. package/dist/tooltip.min.js.map +1 -1
  182. package/dist/tree.js +2 -2
  183. package/dist/tree.js.map +1 -1
  184. package/dist/tree.min.js +1 -1
  185. package/dist/tree.min.js.map +1 -1
  186. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fab-menu.min.js","sources":["../../src/fab-menu/FabMenuElement.ts","../../src/fab-menu/FabMenuItemElement.ts","../../src/fab-menu/FabMenuTriggerElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\r\nimport { css, CSSResultGroup, html, LitElement, unsafeCSS } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n ClickOutsideController,\r\n customElement,\r\n DesignToken,\r\n DisabledMixin,\r\n Role,\r\n ScrollController,\r\n setCustomState,\r\n SuppressInitialAnimation,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { RovingTabIndexManager } from \"@m3e/web/core/a11y\";\r\nimport { M3eDirectionality } from \"@m3e/web/core/bidi\";\r\nimport { positionAnchor } from \"@m3e/web/core/anchoring\";\r\n\r\nimport { M3eFabElement } from \"@m3e/web/fab\";\r\n\r\nimport { FabMenuVariant } from \"./FabMenuVariant\";\r\n\r\n/**\r\n * A menu, opened from a floating action button (FAB), used to display multiple related actions.\r\n *\r\n * @description\r\n * The `m3e-fab-menu` component presents a dynamic menu of related actions, elegantly revealed from a\r\n * floating action button (FAB). Designed using expressive, adaptive surfaces, it enables seamless access\r\n * to contextual actions in modern, visually rich interfaces.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-fab-menu\r\n *\r\n * @slot - Renders the contents of the menu.\r\n *\r\n * @attr variant - The appearance variant of the menu.\r\n *\r\n * @fires beforetoggle - Dispatched before the toggle state changes.\r\n * @fires toggle - Dispatched after the toggle state has changed.\r\n *\r\n * @cssprop --m3e-fab-menu-spacing - Vertical gap between menu items.\r\n * @cssprop --m3e-fab-menu-max-width - Maximum width of the menu.\r\n * @cssprop --m3e-primary-fab-color - Foreground color for primary variant items.\r\n * @cssprop --m3e-primary-fab-container-color - Container color for primary variant items.\r\n * @cssprop --m3e-primary-fab-hover-color - Hover background color for primary variant items.\r\n * @cssprop --m3e-primary-fab-focus-color - Focus background color for primary variant items.\r\n * @cssprop --m3e-primary-fab-ripple-color - Ripple color for primary variant items.\r\n * @cssprop --m3e-secondary-fab-color - Foreground color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-container-color - Container color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-hover-color - Hover background color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-focus-color - Focus background color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-ripple-color - Ripple color for secondary variant items.\r\n * @cssprop --m3e-tertiary-fab-color - Foreground color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-container-color - Container color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-hover-color - Hover background color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-focus-color - Focus background color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-ripple-color - Ripple color for tertiary variant items.\r\n */\r\n@customElement(\"m3e-fab-menu\")\r\nexport class M3eFabMenuElement extends SuppressInitialAnimation(AttachInternals(Role(LitElement, \"menu\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n position: absolute;\r\n flex-direction: column;\r\n row-gap: var(--m3e-fab-menu-spacing, 0.25rem);\r\n padding: unset;\r\n margin: unset;\r\n border: unset;\r\n overflow: visible;\r\n max-width: var(--m3e-fab-menu-max-width, 17.5rem);\r\n opacity: 0;\r\n background-color: transparent;\r\n display: none;\r\n }\r\n :host(:not(:is(:state(--no-animate), :--no-animate))) {\r\n transition: ${unsafeCSS(\r\n `opacity ${DesignToken.motion.spring.fastEffects}, \r\n transform ${DesignToken.motion.spring.fastSpatial},\r\n overlay ${DesignToken.motion.spring.fastEffects} allow-discrete,\r\n display ${DesignToken.motion.spring.fastEffects} allow-discrete`,\r\n )};\r\n }\r\n .base {\r\n display: contents;\r\n }\r\n :host([variant=\"primary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-primary-fab-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-item-container-color: var(--m3e-primary-fab-container-color, ${DesignToken.color.primaryContainer});\r\n --_fab-menu-background-hover-color: var(--m3e-primary-fab-hover-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-background-focus-color: var(--m3e-primary-fab-focus-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-ripple-color: var(--m3e-primary-fab-ripple-color, ${DesignToken.color.onPrimaryContainer});\r\n }\r\n :host([variant=\"secondary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-secondary-fab-color, ${DesignToken.color.onSecondaryContainer});\r\n --_fab-menu-item-container-color: var(\r\n --m3e-secondary-fab-container-color,\r\n ${DesignToken.color.secondaryContainer}\r\n );\r\n --_fab-menu-background-hover-color: var(\r\n --m3e-secondary-fab-hover-color,\r\n ${DesignToken.color.onSecondaryContainer}\r\n );\r\n --_fab-menu-background-focus-color: var(\r\n --m3e-secondary-fab-focus-color,\r\n ${DesignToken.color.onSecondaryContainer}\r\n );\r\n --_fab-menu-ripple-color: var(--m3e-secondary-fab-ripple-color, ${DesignToken.color.onSecondaryContainer});\r\n }\r\n :host([variant=\"tertiary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-tertiary-fab-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-item-container-color: var(--m3e-tertiary-fab-container-color, ${DesignToken.color.tertiaryContainer});\r\n --_fab-menu-background-hover-color: var(--m3e-tertiary-fab-hover-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-background-focus-color: var(--m3e-tertiary-fab-focus-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-ripple-color: var(--m3e-tertiary-fab-ripple-color, ${DesignToken.color.onTertiaryContainer});\r\n }\r\n :host {\r\n transform: scaleX(0.8);\r\n }\r\n :host(:is(:state(--left), :--left)) {\r\n align-items: flex-start;\r\n transform-origin: left;\r\n }\r\n :host(:is(:state(--right), :--right)) {\r\n align-items: flex-end;\r\n transform-origin: right;\r\n }\r\n :host(:popover-open) {\r\n transform: scaleX(1);\r\n display: inline-flex;\r\n opacity: 1;\r\n }\r\n :host::backdrop {\r\n background-color: transparent;\r\n }\r\n @starting-style {\r\n :host(:popover-open) {\r\n opacity: 0;\r\n }\r\n :host(:popover-open) {\r\n transform: scaleX(0.8);\r\n }\r\n }\r\n @media (prefers-reduced-motion) {\r\n :host(:not(:is(:state(--no-animate), :--no-animate))) {\r\n transition: none;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n :host {\r\n border-radius: ${DesignToken.shape.corner.medium};\r\n outline: 1px solid MenuText;\r\n background-color: Menu;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ #fabTabIndex?: number;\r\n /** @private */ #trigger?: HTMLElement;\r\n /** @private */ #anchoringCleanup?: () => void;\r\n\r\n /** @private */\r\n readonly #listManager = new RovingTabIndexManager<LitElement & DisabledMixin>()\r\n .withWrap()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation();\r\n\r\n /** @private */ readonly #keyDownHandler = (e: KeyboardEvent) => this.#handleKeyDown(e);\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, { target: null, callback: () => this.hide() });\r\n\r\n /** @private */ readonly #clickOutsideController = new ClickOutsideController(this, {\r\n target: null,\r\n callback: () => this.hide(),\r\n });\r\n\r\n /** @private */\r\n readonly #toggleHandler = (e: ToggleEvent) => {\r\n switch (e.newState) {\r\n case \"open\":\r\n this.#clickOutsideController.observe(this);\r\n if (this.#trigger) {\r\n this.#clickOutsideController.observe(this.#trigger);\r\n }\r\n setTimeout(() => this.#listManager.setActiveItem(this.#listManager.items.find((x) => !x.disabled)), 40);\r\n break;\r\n\r\n case \"closed\":\r\n this.#clickOutsideController.unobserveAll();\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = undefined;\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * The appearance variant of the menu.\r\n * @default \"primary\"\r\n */\r\n @property({ reflect: true }) variant: FabMenuVariant = \"primary\";\r\n\r\n /** Whether the menu is open. */\r\n get isOpen() {\r\n return this.#trigger !== undefined;\r\n }\r\n\r\n /**\r\n * Opens the menu.\r\n * @param {HTMLElement} trigger The element that triggered the menu.\r\n * @returns {Promise<void>} A `Promise` that resolves when the menu is opened.\r\n */\r\n async show(trigger: HTMLElement): Promise<void> {\r\n if (this.#trigger && this.#trigger !== trigger) {\r\n this.hide();\r\n }\r\n\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = await positionAnchor(\r\n this,\r\n trigger,\r\n {\r\n position: \"top-end\",\r\n inline: true,\r\n shift: \"main\",\r\n flip: true,\r\n offset: 8,\r\n },\r\n (x, y, position) => {\r\n setCustomState(this, \"--right\", position.includes(\"end\"));\r\n setCustomState(this, \"--left\", position.includes(\"start\"));\r\n if (M3eDirectionality.current === \"rtl\") {\r\n this.style.right = `${window.innerWidth - x - this.clientWidth}px`;\r\n this.style.left = \"\";\r\n } else {\r\n this.style.left = `${x}px`;\r\n this.style.right = \"\";\r\n }\r\n this.style.top = `${y}px`;\r\n },\r\n );\r\n\r\n this.showPopover();\r\n\r\n this.#trigger = trigger;\r\n this.#trigger.ariaExpanded = \"true\";\r\n this.#scrollController.observe(this.#trigger);\r\n\r\n this.#attachFab();\r\n }\r\n\r\n /**\r\n * Hides the menu.\r\n * @param {boolean} [restoreFocus=false] A value indicating whether to restore focus to the menu's trigger.\r\n */\r\n hide(restoreFocus: boolean = false): void {\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = undefined;\r\n\r\n if (this.#trigger) {\r\n this.#trigger.ariaExpanded = \"false\";\r\n if (restoreFocus) {\r\n this.#trigger.focus();\r\n }\r\n\r\n this.#detachFab();\r\n\r\n this.#scrollController.unobserve(this.#trigger);\r\n this.#trigger = undefined;\r\n }\r\n this.hidePopover();\r\n }\r\n\r\n /**\r\n * Toggles the menu.\r\n * @param {HTMLElement} trigger The element that triggered the menu.\r\n * @returns {Promise<void>} A `Promise` that resolves when the menu is opened or closed.\r\n */\r\n async toggle(trigger: HTMLElement): Promise<void> {\r\n if (this.#trigger) {\r\n this.hide();\r\n } else {\r\n await this.show(trigger);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n\r\n this.tabIndex = -1;\r\n this.setAttribute(\"popover\", \"manual\");\r\n this.addEventListener(\"keydown\", this.#keyDownHandler);\r\n this.addEventListener(\"toggle\", this.#toggleHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.removeEventListener(\"toggle\", this.#toggleHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"base\"><slot @slotchange=\"${this.#handleSlotChange}\"></slot></div>`;\r\n }\r\n\r\n /** @private */\r\n #handleSlotChange(): void {\r\n const { added } = this.#listManager.setItems([...this.querySelectorAll(\"m3e-fab-menu-item\")]);\r\n if (!this.#listManager.activeItem) {\r\n this.#listManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleKeyDown(e: KeyboardEvent): void {\r\n switch (e.key) {\r\n case \"Tab\":\r\n this.hide();\r\n break;\r\n\r\n case \"Escape\":\r\n if (!e.shiftKey && !e.ctrlKey) {\r\n this.hide(true);\r\n }\r\n break;\r\n\r\n default:\r\n this.#listManager.onKeyDown(e);\r\n break;\r\n }\r\n }\r\n\r\n /** @private */\r\n #attachFab(): void {\r\n const fab = this.#trigger?.closest<M3eFabElement>(\"m3e-fab\");\r\n if (fab) {\r\n this.#fabTabIndex = fab.tabIndex;\r\n fab.addEventListener(\"keydown\", this.#keyDownHandler);\r\n this.#listManager.setItems([...this.#listManager.items, fab]);\r\n }\r\n }\r\n\r\n /** @private */\r\n #detachFab(): void {\r\n const fab = this.#trigger?.closest<M3eFabElement>(\"m3e-fab\");\r\n if (fab) {\r\n if (this.#fabTabIndex !== undefined) {\r\n fab.tabIndex = this.#fabTabIndex;\r\n }\r\n fab.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.#listManager.setItems([...this.#listManager.items.filter((x) => x !== fab)]);\r\n }\r\n }\r\n}\r\n\r\ninterface M3eFabMenuElementEventMap extends HTMLElementEventMap {\r\n beforetoggle: ToggleEvent;\r\n toggle: ToggleEvent;\r\n}\r\n\r\nexport interface M3eFabMenuElement {\r\n addEventListener<K extends keyof M3eFabMenuElementEventMap>(\r\n type: K,\r\n listener: (this: M3eFabMenuElement, ev: M3eFabMenuElementEventMap[K]) => void,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n addEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener<K extends keyof M3eFabMenuElementEventMap>(\r\n type: K,\r\n listener: (this: M3eFabMenuElement, ev: M3eFabMenuElementEventMap[K]) => void,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu\": M3eFabMenuElement;\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n KeyboardClick,\r\n LinkButton,\r\n M3eElevationElement,\r\n M3eFocusRingElement,\r\n M3eRippleElement,\r\n M3eStateLayerElement,\r\n renderPseudoLink,\r\n Role,\r\n} from \"@m3e/web/core\";\r\n\r\nimport type { M3eFabMenuElement } from \"./FabMenuElement\";\r\n\r\n/**\r\n * An item of a floating action button (FAB) menu.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-menu-item\r\n *\r\n * @slot - Renders the label of the item.\r\n * @slot icon - Renders an icon before the items's label.\r\n *\r\n * @attr disabled - Whether the element is disabled.\r\n * @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.\r\n * @attr href - The URL to which the link button points.\r\n * @attr rel - The relationship between the `target` of the link button and the document.\r\n * @attr target - The target of the link button.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-fab-menu-item-height - Height of the menu item.\r\n * @cssprop --m3e-fab-menu-item-font-size - Font size of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-font-weight - Font weight of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-line-height - Line height of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-tracking - Letter spacing of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-shape - Border radius of the menu item.\r\n * @cssprop --m3e-fab-menu-item-leading-space - Padding at the start of the menu item.\r\n * @cssprop --m3e-fab-menu-item-trailing-space - Padding at the end of the menu item.\r\n * @cssprop --m3e-fab-menu-item-spacing - Gap between icon and label.\r\n * @cssprop --m3e-fab-menu-item-icon-size - Size of the icon in the menu item.\r\n */\r\n@customElement(\"m3e-fab-menu-item\")\r\nexport class M3eFabMenuItemElement extends KeyboardClick(\r\n LinkButton(Disabled(AttachInternals(Role(LitElement, \"menuitem\"), true))),\r\n) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n outline: none;\r\n user-select: none;\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n .base {\r\n box-sizing: border-box;\r\n vertical-align: middle;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n position: relative;\r\n width: 100%;\r\n transition: ${unsafeCSS(\r\n `background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`,\r\n )};\r\n height: var(--m3e-fab-menu-item-height, 3.5rem);\r\n font-size: var(--m3e-fab-menu-item-font-size, ${DesignToken.typescale.standard.label.large.fontSize});\r\n font-weight: var(--m3e-fab-menu-item-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});\r\n line-height: var(--m3e-fab-menu-item-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});\r\n letter-spacing: var(--m3e-fab-menu-item-tracking, ${DesignToken.typescale.standard.label.large.tracking});\r\n border-radius: var(--m3e-fab-menu-item-shape, ${DesignToken.shape.corner.full});\r\n }\r\n :host(:not(:disabled)) .label,\r\n :host(:not(:disabled)) .icon {\r\n color: var(--_fab-menu-item-color);\r\n }\r\n :host(:not(:disabled)) .base {\r\n background-color: var(--_fab-menu-item-container-color);\r\n --m3e-state-layer-hover-color: var(--_fab-menu-background-hover-color);\r\n --m3e-state-layer-focus-color: var(--_fab-menu-background-focus-color);\r\n --m3e-ripple-color: var(--_fab-menu-ripple-color);\r\n }\r\n :host(:disabled) .base {\r\n background-color: color-mix(\r\n in srgb,\r\n var(--m3e-fab-menu-item-disabled-container-color, ${DesignToken.color.onSurface})\r\n var(--m3e-fab-menu-item-disabled-container-opacity, 10%),\r\n transparent\r\n );\r\n }\r\n :host(:disabled) .label,\r\n :host(:disabled) .icon {\r\n color: color-mix(\r\n in srgb,\r\n var(--m3e-fab-menu-item-disabled-color, ${DesignToken.color.onSurface})\r\n var(--m3e-fab-menu-item-disabled-opacity, 38%),\r\n transparent\r\n );\r\n }\r\n .touch {\r\n position: absolute;\r\n height: 3rem;\r\n left: 0;\r\n right: 0;\r\n }\r\n .wrapper {\r\n width: 100%;\r\n overflow: hidden;\r\n display: inline-flex;\r\n align-items: center;\r\n padding-inline-start: var(--m3e-fab-menu-item-leading-space, 1.5rem);\r\n padding-inline-end: var(--m3e-fab-menu-item-trailing-space, 1.5rem);\r\n column-gap: var(--m3e-fab-menu-item-spacing, 0.5rem);\r\n }\r\n .label {\r\n justify-self: center;\r\n flex: 1 1 auto;\r\n text-align: center;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .icon {\r\n font-size: var(--m3e-fab-menu-item-icon-size, 1.5rem);\r\n transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n ::slotted([slot=\"icon\"]) {\r\n font-size: inherit !important;\r\n flex: none;\r\n }\r\n ::slotted(svg[slot=\"icon\"]) {\r\n width: 1em;\r\n height: 1em;\r\n }\r\n a {\r\n all: unset;\r\n display: block;\r\n position: absolute;\r\n top: 0px;\r\n left: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n z-index: 1;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base,\r\n .label,\r\n .icon {\r\n transition: none;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n .base,\r\n .label,\r\n .icon {\r\n transition: none;\r\n }\r\n :host(:not(:disabled)) .base {\r\n background-color: Menu;\r\n }\r\n :host(:not(:disabled)) .label,\r\n :host(:not(:disabled)) .icon {\r\n color: MenuText;\r\n }\r\n :host(:disabled) .label,\r\n :host(:disabled) .icon {\r\n color: GrayText;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".elevation\") private readonly _elevation?: M3eElevationElement;\r\n /** @private */ @query(\".focus-ring\") private readonly _focusRing?: M3eFocusRingElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @private */ @query(\".ripple\") private readonly _ripple?: M3eRippleElement;\r\n\r\n /** @private */ readonly #clickHandler = (e: Event) => this.#handleClick(e);\r\n\r\n /** The floating action button (FAB) menu to which this item belongs. */\r\n get menu(): M3eFabMenuElement | null {\r\n return this.closest(\"m3e-fab-menu\");\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n this.addEventListener(\"click\", this.#clickHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n this.removeEventListener(\"click\", this.#clickHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n [this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<div class=\"base\">\r\n <m3e-elevation class=\"elevation\" ?disabled=\"${this.disabled}\"></m3e-elevation>\r\n <m3e-state-layer class=\"state-layer\" ?disabled=\"${this.disabled}\"></m3e-state-layer>\r\n <m3e-focus-ring class=\"focus-ring\" ?disabled=\"${this.disabled}\"></m3e-focus-ring>\r\n <m3e-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></m3e-ripple>\r\n <div class=\"touch\" aria-hidden=\"true\"></div>\r\n ${this[renderPseudoLink]()}\r\n <div class=\"wrapper\">\r\n <slot class=\"icon\" name=\"icon\" aria-hidden=\"true\"></slot>\r\n <div class=\"label\"><slot></slot></div>\r\n </div>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (!e.defaultPrevented) {\r\n this.menu?.hide(true);\r\n }\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu-item\": M3eFabMenuItemElement;\r\n }\r\n}\r\n","import { ActionElementBase, customElement, HtmlFor } from \"@m3e/web/core\";\r\nimport { addAriaReferencedId, removeAriaReferencedId } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eFabMenuElement } from \"./FabMenuElement\";\r\n\r\n/**\r\n * An element, nested within a clickable element, used to open a floating action button (FAB) menu.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-fab-menu-trigger\r\n */\r\n@customElement(\"m3e-fab-menu-trigger\")\r\nexport class M3eFabMenuTriggerElement extends HtmlFor(ActionElementBase) {\r\n /** The menu triggered by the element. */\r\n get menu(): M3eFabMenuElement | null {\r\n return this.control instanceof M3eFabMenuElement ? this.control : null;\r\n }\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n\r\n if (this.parentElement && control instanceof M3eFabMenuElement) {\r\n this.parentElement.ariaHasPopup = \"menu\";\r\n this.parentElement.ariaExpanded = \"false\";\r\n if (control.id) {\r\n addAriaReferencedId(this.parentElement, \"aria-controls\", control.id);\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.parentElement) {\r\n this.parentElement.ariaHasPopup = null;\r\n this.parentElement.ariaExpanded = null;\r\n if (this.control?.id) {\r\n removeAriaReferencedId(this.parentElement, \"aria-controls\", this.control.id);\r\n }\r\n }\r\n\r\n super.detach();\r\n }\r\n\r\n /** @inheritdoc */\r\n override _onClick(): void {\r\n if (this.parentElement) {\r\n this.menu?.toggle(this.parentElement);\r\n }\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu-trigger\": M3eFabMenuTriggerElement;\r\n }\r\n}\r\n"],"names":["M3eFabMenuElement","SuppressInitialAnimation","AttachInternals","Role","LitElement","constructor","_M3eFabMenuElement_fabTabIndex","set","this","_M3eFabMenuElement_trigger","_M3eFabMenuElement_anchoringCleanup","_M3eFabMenuElement_listManager","RovingTabIndexManager","withWrap","withHomeAndEnd","withVerticalOrientation","_M3eFabMenuElement_keyDownHandler","e","__classPrivateFieldGet","call","_M3eFabMenuElement_scrollController","ScrollController","target","callback","hide","_M3eFabMenuElement_clickOutsideController","ClickOutsideController","_M3eFabMenuElement_toggleHandler","newState","observe","setTimeout","setActiveItem","items","find","x","disabled","unobserveAll","__classPrivateFieldSet","undefined","variant","isOpen","show","trigger","positionAnchor","position","inline","shift","flip","offset","y","setCustomState","includes","M3eDirectionality","current","style","right","window","innerWidth","clientWidth","left","top","showPopover","ariaExpanded","_M3eFabMenuElement_instances","_M3eFabMenuElement_attachFab","restoreFocus","focus","_M3eFabMenuElement_detachFab","unobserve","hidePopover","toggle","connectedCallback","super","tabIndex","setAttribute","addEventListener","disconnectedCallback","removeEventListener","render","html","_M3eFabMenuElement_handleSlotChange","added","setItems","querySelectorAll","activeItem","updateActiveItem","key","shiftKey","ctrlKey","onKeyDown","fab","closest","filter","styles","css","unsafeCSS","DesignToken","motion","spring","fastEffects","fastSpatial","color","onPrimaryContainer","primaryContainer","onSecondaryContainer","secondaryContainer","onTertiaryContainer","tertiaryContainer","shape","corner","medium","__decorate","property","reflect","prototype","customElement","M3eFabMenuItemElement","KeyboardClick","LinkButton","Disabled","_M3eFabMenuItemElement_clickHandler","menu","firstUpdated","_changedProperties","_elevation","_focusRing","_stateLayer","_ripple","forEach","attach","renderPseudoLink","defaultPrevented","duration","short4","easing","standard","typescale","label","large","fontSize","fontWeight","lineHeight","tracking","full","onSurface","query","M3eFabMenuTriggerElement","HtmlFor","ActionElementBase","control","parentElement","ariaHasPopup","id","addAriaReferencedId","detach","removeAriaReferencedId","_onClick"],"mappings":";;;;;iwBA8EO,IAAMA,EAAN,cAAgCC,EAAyBC,EAAgBC,EAAKC,EAAY,WAA1FC,WAAAA,mCAkGWC,EAAAC,IAAAC,aACAC,EAAAF,IAAAC,aACAE,EAAAH,IAAAC,aAGPG,EAAAJ,IAAAC,MAAe,IAAII,GACzBC,WACAC,iBACAC,2BAEsBC,EAAAT,IAAAC,KAAmBS,GAAqBC,EAAAV,cAAmBW,KAAnBX,KAAoBS,IAG5EG,EAAAb,IAAAC,KAAoB,IAAIa,EAAiBb,KAAM,CAAEc,OAAQ,KAAMC,SAAUA,IAAMf,KAAKgB,UAEpEC,EAAAlB,IAAAC,KAA0B,IAAIkB,EAAuBlB,KAAM,CAClFc,OAAQ,KACRC,SAAUA,IAAMf,KAAKgB,UAIdG,EAAApB,IAAAC,KAAkBS,IACzB,OAAQA,EAAEW,UACR,IAAK,OACHV,EAAAV,KAAIiB,EAAA,KAAyBI,QAAQrB,MACjCU,EAAAV,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D,EAAU,SAASC,EAAYC,OAAOmC,SAASC,UAAUrC,EAAYC,OAAOqC,OAAOC,6FAInFxC,EAAU,SAASC,EAAYC,OAAOmC,SAASC,UAAUrC,EAAYC,OAAOqC,OAAOC,0pBAkD/CxB,EAAA,CAArCkC,EAAM,eAAgE7B,EAAAF,UAAA,qBAChCH,EAAA,CAAtCkC,EAAM,gBAAiE7B,EAAAF,UAAA,qBAChCH,EAAA,CAAvCkC,EAAM,iBAAoE7B,EAAAF,UAAA,sBACxCH,EAAA,CAAlCkC,EAAM,YAAuD7B,EAAAF,UAAA,kBAvInEE,EAAqBL,EAAA,CADjCI,EAAc,sBACFC,GCrCN,IAAM8B,EAAN,cAAuCC,EAAQC,IAEpD,QAAI3B,GACF,OAAOjH,KAAK6I,mBAAmBrJ,EAAoBQ,KAAK6I,QAAU,IACpE,CAGSpB,MAAAA,CAAOoB,GACd7E,MAAMyD,OAAOoB,GAET7I,KAAK8I,eAAiBD,aAAmBrJ,IAC3CQ,KAAK8I,cAAcC,aAAe,OAClC/I,KAAK8I,cAAcxF,aAAe,QAC9BuF,EAAQG,IACVC,EAAoBjJ,KAAK8I,cAAe,gBAAiBD,EAAQG,IAGvE,CAGSE,MAAAA,GACHlJ,KAAK8I,gBACP9I,KAAK8I,cAAcC,aAAe,KAClC/I,KAAK8I,cAAcxF,aAAe,KAC9BtD,KAAK6I,SAASG,IAChBG,EAAuBnJ,KAAK8I,cAAe,gBAAiB9I,KAAK6I,QAAQG,KAI7EhF,MAAMkF,QACR,CAGSE,QAAAA,GACHpJ,KAAK8I,eACP9I,KAAKiH,MAAMnD,OAAO9D,KAAK8I,cAE3B,GArCWJ,EAAwBnC,EAAA,CADpCI,EAAc,yBACF+B"}
1
+ {"version":3,"file":"fab-menu.min.js","sources":["../../src/fab-menu/FabMenuElement.ts","../../src/fab-menu/FabMenuItemElement.ts","../../src/fab-menu/FabMenuTriggerElement.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */\r\nimport { css, CSSResultGroup, html, LitElement, unsafeCSS } from \"lit\";\r\nimport { property } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n ClickOutsideController,\r\n customElement,\r\n DesignToken,\r\n DisabledMixin,\r\n Role,\r\n ScrollController,\r\n setCustomState,\r\n SuppressInitialAnimation,\r\n} from \"@m3e/web/core\";\r\n\r\nimport { RovingTabIndexManager } from \"@m3e/web/core/a11y\";\r\nimport { M3eDirectionality } from \"@m3e/web/core/bidi\";\r\nimport { positionAnchor } from \"@m3e/web/core/anchoring\";\r\n\r\nimport { M3eFabElement } from \"@m3e/web/fab\";\r\n\r\nimport { FabMenuVariant } from \"./FabMenuVariant\";\r\n\r\n/**\r\n * A menu, opened from a floating action button (FAB), used to display multiple related actions.\r\n *\r\n * @description\r\n * The `m3e-fab-menu` component presents a dynamic menu of related actions, elegantly revealed from a\r\n * floating action button (FAB). Designed using expressive, adaptive surfaces, it enables seamless access\r\n * to contextual actions in modern, visually rich interfaces.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-fab-menu\r\n *\r\n * @slot - Renders the contents of the menu.\r\n *\r\n * @attr variant - The appearance variant of the menu.\r\n *\r\n * @fires beforetoggle - Dispatched before the toggle state changes.\r\n * @fires toggle - Dispatched after the toggle state has changed.\r\n *\r\n * @cssprop --m3e-fab-menu-spacing - Vertical gap between menu items.\r\n * @cssprop --m3e-fab-menu-max-width - Maximum width of the menu.\r\n * @cssprop --m3e-primary-fab-color - Foreground color for primary variant items.\r\n * @cssprop --m3e-primary-fab-container-color - Container color for primary variant items.\r\n * @cssprop --m3e-primary-fab-hover-color - Hover background color for primary variant items.\r\n * @cssprop --m3e-primary-fab-focus-color - Focus background color for primary variant items.\r\n * @cssprop --m3e-primary-fab-ripple-color - Ripple color for primary variant items.\r\n * @cssprop --m3e-secondary-fab-color - Foreground color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-container-color - Container color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-hover-color - Hover background color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-focus-color - Focus background color for secondary variant items.\r\n * @cssprop --m3e-secondary-fab-ripple-color - Ripple color for secondary variant items.\r\n * @cssprop --m3e-tertiary-fab-color - Foreground color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-container-color - Container color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-hover-color - Hover background color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-focus-color - Focus background color for tertiary variant items.\r\n * @cssprop --m3e-tertiary-fab-ripple-color - Ripple color for tertiary variant items.\r\n */\r\n@customElement(\"m3e-fab-menu\")\r\nexport class M3eFabMenuElement extends SuppressInitialAnimation(AttachInternals(Role(LitElement, \"menu\"))) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n contain: layout style;\r\n position: absolute;\r\n flex-direction: column;\r\n row-gap: var(--m3e-fab-menu-spacing, 0.25rem);\r\n padding: unset;\r\n margin: unset;\r\n border: unset;\r\n overflow: visible;\r\n max-width: var(--m3e-fab-menu-max-width, 17.5rem);\r\n opacity: 0;\r\n background-color: transparent;\r\n display: none;\r\n }\r\n :host(:not(:is(:state(--no-animate), :--no-animate))) {\r\n transition: ${unsafeCSS(\r\n `opacity ${DesignToken.motion.spring.fastEffects}, \r\n transform ${DesignToken.motion.spring.fastSpatial},\r\n overlay ${DesignToken.motion.spring.fastEffects} allow-discrete,\r\n display ${DesignToken.motion.spring.fastEffects} allow-discrete`,\r\n )};\r\n }\r\n .base {\r\n display: contents;\r\n }\r\n :host([variant=\"primary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-primary-fab-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-item-container-color: var(--m3e-primary-fab-container-color, ${DesignToken.color.primaryContainer});\r\n --_fab-menu-background-hover-color: var(--m3e-primary-fab-hover-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-background-focus-color: var(--m3e-primary-fab-focus-color, ${DesignToken.color.onPrimaryContainer});\r\n --_fab-menu-ripple-color: var(--m3e-primary-fab-ripple-color, ${DesignToken.color.onPrimaryContainer});\r\n }\r\n :host([variant=\"secondary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-secondary-fab-color, ${DesignToken.color.onSecondaryContainer});\r\n --_fab-menu-item-container-color: var(\r\n --m3e-secondary-fab-container-color,\r\n ${DesignToken.color.secondaryContainer}\r\n );\r\n --_fab-menu-background-hover-color: var(\r\n --m3e-secondary-fab-hover-color,\r\n ${DesignToken.color.onSecondaryContainer}\r\n );\r\n --_fab-menu-background-focus-color: var(\r\n --m3e-secondary-fab-focus-color,\r\n ${DesignToken.color.onSecondaryContainer}\r\n );\r\n --_fab-menu-ripple-color: var(--m3e-secondary-fab-ripple-color, ${DesignToken.color.onSecondaryContainer});\r\n }\r\n :host([variant=\"tertiary\"]) .base {\r\n --_fab-menu-item-color: var(--m3e-tertiary-fab-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-item-container-color: var(--m3e-tertiary-fab-container-color, ${DesignToken.color.tertiaryContainer});\r\n --_fab-menu-background-hover-color: var(--m3e-tertiary-fab-hover-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-background-focus-color: var(--m3e-tertiary-fab-focus-color, ${DesignToken.color.onTertiaryContainer});\r\n --_fab-menu-ripple-color: var(--m3e-tertiary-fab-ripple-color, ${DesignToken.color.onTertiaryContainer});\r\n }\r\n :host {\r\n transform: scaleX(0.8);\r\n }\r\n :host(:is(:state(--left), :--left)) {\r\n align-items: flex-start;\r\n transform-origin: left;\r\n }\r\n :host(:is(:state(--right), :--right)) {\r\n align-items: flex-end;\r\n transform-origin: right;\r\n }\r\n :host(:popover-open) {\r\n transform: scaleX(1);\r\n display: inline-flex;\r\n opacity: 1;\r\n }\r\n :host::backdrop {\r\n background-color: transparent;\r\n }\r\n @starting-style {\r\n :host(:popover-open) {\r\n opacity: 0;\r\n }\r\n :host(:popover-open) {\r\n transform: scaleX(0.8);\r\n }\r\n }\r\n @media (prefers-reduced-motion) {\r\n :host(:not(:is(:state(--no-animate), :--no-animate))) {\r\n transition: none;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n :host {\r\n border-radius: ${DesignToken.shape.corner.medium};\r\n outline: 1px solid MenuText;\r\n background-color: Menu;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ #fabTabIndex?: number;\r\n /** @private */ #trigger?: HTMLElement;\r\n /** @private */ #anchoringCleanup?: () => void;\r\n\r\n /** @private */\r\n readonly #listManager = new RovingTabIndexManager<LitElement & DisabledMixin>()\r\n .withWrap()\r\n .withHomeAndEnd()\r\n .withVerticalOrientation();\r\n\r\n /** @private */ readonly #keyDownHandler = (e: KeyboardEvent) => this.#handleKeyDown(e);\r\n\r\n /** @private */\r\n readonly #scrollController = new ScrollController(this, { target: null, callback: () => this.hide() });\r\n\r\n /** @private */ readonly #clickOutsideController = new ClickOutsideController(this, {\r\n target: null,\r\n callback: () => this.hide(),\r\n });\r\n\r\n /** @private */\r\n readonly #toggleHandler = (e: ToggleEvent) => {\r\n switch (e.newState) {\r\n case \"open\":\r\n this.#clickOutsideController.observe(this);\r\n if (this.#trigger) {\r\n this.#clickOutsideController.observe(this.#trigger);\r\n }\r\n setTimeout(() => this.#listManager.setActiveItem(this.#listManager.items.find((x) => !x.disabled)), 40);\r\n break;\r\n\r\n case \"closed\":\r\n this.#clickOutsideController.unobserveAll();\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = undefined;\r\n break;\r\n }\r\n };\r\n\r\n /**\r\n * The appearance variant of the menu.\r\n * @default \"primary\"\r\n */\r\n @property({ reflect: true }) variant: FabMenuVariant = \"primary\";\r\n\r\n /** Whether the menu is open. */\r\n get isOpen() {\r\n return this.#trigger !== undefined;\r\n }\r\n\r\n /**\r\n * Opens the menu.\r\n * @param {HTMLElement} trigger The element that triggered the menu.\r\n * @returns {Promise<void>} A `Promise` that resolves when the menu is opened.\r\n */\r\n async show(trigger: HTMLElement): Promise<void> {\r\n if (this.#trigger && this.#trigger !== trigger) {\r\n this.hide();\r\n }\r\n\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = await positionAnchor(\r\n this,\r\n trigger,\r\n {\r\n position: \"top-end\",\r\n inline: true,\r\n shift: \"main\",\r\n flip: true,\r\n offset: 8,\r\n },\r\n (x, y, position) => {\r\n setCustomState(this, \"--right\", position.includes(\"end\"));\r\n setCustomState(this, \"--left\", position.includes(\"start\"));\r\n if (M3eDirectionality.current === \"rtl\") {\r\n this.style.right = `${window.innerWidth - x - this.clientWidth}px`;\r\n this.style.left = \"\";\r\n } else {\r\n this.style.left = `${x}px`;\r\n this.style.right = \"\";\r\n }\r\n this.style.top = `${y}px`;\r\n },\r\n );\r\n\r\n this.showPopover();\r\n\r\n this.#trigger = trigger;\r\n this.#trigger.ariaExpanded = \"true\";\r\n this.#scrollController.observe(this.#trigger);\r\n\r\n this.#attachFab();\r\n }\r\n\r\n /**\r\n * Hides the menu.\r\n * @param {boolean} [restoreFocus=false] A value indicating whether to restore focus to the menu's trigger.\r\n */\r\n hide(restoreFocus: boolean = false): void {\r\n this.#anchoringCleanup?.();\r\n this.#anchoringCleanup = undefined;\r\n\r\n if (this.#trigger) {\r\n this.#trigger.ariaExpanded = \"false\";\r\n if (restoreFocus) {\r\n this.#trigger.focus();\r\n }\r\n\r\n this.#detachFab();\r\n\r\n this.#scrollController.unobserve(this.#trigger);\r\n this.#trigger = undefined;\r\n }\r\n this.hidePopover();\r\n }\r\n\r\n /**\r\n * Toggles the menu.\r\n * @param {HTMLElement} trigger The element that triggered the menu.\r\n * @returns {Promise<void>} A `Promise` that resolves when the menu is opened or closed.\r\n */\r\n async toggle(trigger: HTMLElement): Promise<void> {\r\n if (this.#trigger) {\r\n this.hide();\r\n } else {\r\n await this.show(trigger);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n\r\n this.tabIndex = -1;\r\n this.setAttribute(\"popover\", \"manual\");\r\n this.addEventListener(\"keydown\", this.#keyDownHandler);\r\n this.addEventListener(\"toggle\", this.#toggleHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.removeEventListener(\"toggle\", this.#toggleHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return html`<div class=\"base\"><slot @slotchange=\"${this.#handleSlotChange}\"></slot></div>`;\r\n }\r\n\r\n /** @private */\r\n #handleSlotChange(): void {\r\n const { added } = this.#listManager.setItems([...this.querySelectorAll(\"m3e-fab-menu-item\")]);\r\n if (!this.#listManager.activeItem) {\r\n this.#listManager.updateActiveItem(added.find((x) => !x.disabled));\r\n }\r\n }\r\n\r\n /** @private */\r\n #handleKeyDown(e: KeyboardEvent): void {\r\n switch (e.key) {\r\n case \"Tab\":\r\n this.hide();\r\n break;\r\n\r\n case \"Escape\":\r\n if (!e.shiftKey && !e.ctrlKey) {\r\n this.hide(true);\r\n }\r\n break;\r\n\r\n default:\r\n this.#listManager.onKeyDown(e);\r\n break;\r\n }\r\n }\r\n\r\n /** @private */\r\n #attachFab(): void {\r\n const fab = this.#trigger?.closest<M3eFabElement>(\"m3e-fab\");\r\n if (fab) {\r\n this.#fabTabIndex = fab.tabIndex;\r\n fab.addEventListener(\"keydown\", this.#keyDownHandler);\r\n this.#listManager.setItems([...this.#listManager.items, fab]);\r\n }\r\n }\r\n\r\n /** @private */\r\n #detachFab(): void {\r\n const fab = this.#trigger?.closest<M3eFabElement>(\"m3e-fab\");\r\n if (fab) {\r\n if (this.#fabTabIndex !== undefined) {\r\n fab.tabIndex = this.#fabTabIndex;\r\n }\r\n fab.removeEventListener(\"keydown\", this.#keyDownHandler);\r\n this.#listManager.setItems([...this.#listManager.items.filter((x) => x !== fab)]);\r\n }\r\n }\r\n}\r\n\r\ninterface M3eFabMenuElementEventMap extends HTMLElementEventMap {\r\n beforetoggle: ToggleEvent;\r\n toggle: ToggleEvent;\r\n}\r\n\r\nexport interface M3eFabMenuElement {\r\n addEventListener<K extends keyof M3eFabMenuElementEventMap>(\r\n type: K,\r\n listener: (this: M3eFabMenuElement, ev: M3eFabMenuElementEventMap[K]) => void,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n addEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | AddEventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener<K extends keyof M3eFabMenuElementEventMap>(\r\n type: K,\r\n listener: (this: M3eFabMenuElement, ev: M3eFabMenuElementEventMap[K]) => void,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n\r\n removeEventListener(\r\n type: string,\r\n listener: EventListenerOrEventListenerObject,\r\n options?: boolean | EventListenerOptions,\r\n ): void;\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu\": M3eFabMenuElement;\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues, unsafeCSS } from \"lit\";\r\nimport { query } from \"lit/decorators.js\";\r\n\r\nimport {\r\n AttachInternals,\r\n customElement,\r\n DesignToken,\r\n Disabled,\r\n KeyboardClick,\r\n LinkButton,\r\n M3eElevationElement,\r\n M3eFocusRingElement,\r\n M3eRippleElement,\r\n M3eStateLayerElement,\r\n renderPseudoLink,\r\n Role,\r\n} from \"@m3e/web/core\";\r\n\r\nimport type { M3eFabMenuElement } from \"./FabMenuElement\";\r\n\r\n/**\r\n * An item of a floating action button (FAB) menu.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-menu-item\r\n *\r\n * @slot - Renders the label of the item.\r\n * @slot icon - Renders an icon before the items's label.\r\n *\r\n * @attr disabled - Whether the element is disabled.\r\n * @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.\r\n * @attr href - The URL to which the link button points.\r\n * @attr rel - The relationship between the `target` of the link button and the document.\r\n * @attr target - The target of the link button.\r\n *\r\n * @fires click - Dispatched when the element is clicked.\r\n *\r\n * @cssprop --m3e-fab-menu-item-height - Height of the menu item.\r\n * @cssprop --m3e-fab-menu-item-font-size - Font size of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-font-weight - Font weight of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-line-height - Line height of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-tracking - Letter spacing of the menu item label.\r\n * @cssprop --m3e-fab-menu-item-shape - Border radius of the menu item.\r\n * @cssprop --m3e-fab-menu-item-leading-space - Padding at the start of the menu item.\r\n * @cssprop --m3e-fab-menu-item-trailing-space - Padding at the end of the menu item.\r\n * @cssprop --m3e-fab-menu-item-spacing - Gap between icon and label.\r\n * @cssprop --m3e-fab-menu-item-icon-size - Size of the icon in the menu item.\r\n */\r\n@customElement(\"m3e-fab-menu-item\")\r\nexport class M3eFabMenuItemElement extends KeyboardClick(\r\n LinkButton(Disabled(AttachInternals(Role(LitElement, \"menuitem\"), true))),\r\n) {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n outline: none;\r\n user-select: none;\r\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\r\n }\r\n .base {\r\n box-sizing: border-box;\r\n vertical-align: middle;\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n position: relative;\r\n width: 100%;\r\n transition: ${unsafeCSS(\r\n `background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`,\r\n )};\r\n height: var(--m3e-fab-menu-item-height, 3.5rem);\r\n font-size: var(--m3e-fab-menu-item-font-size, ${DesignToken.typescale.standard.label.large.fontSize});\r\n font-weight: var(--m3e-fab-menu-item-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight});\r\n line-height: var(--m3e-fab-menu-item-line-height, ${DesignToken.typescale.standard.label.large.lineHeight});\r\n letter-spacing: var(--m3e-fab-menu-item-tracking, ${DesignToken.typescale.standard.label.large.tracking});\r\n border-radius: var(--m3e-fab-menu-item-shape, ${DesignToken.shape.corner.full});\r\n }\r\n :host(:not(:disabled)) .label,\r\n :host(:not(:disabled)) .icon {\r\n color: var(--_fab-menu-item-color);\r\n }\r\n :host(:not(:disabled)) .base {\r\n background-color: var(--_fab-menu-item-container-color);\r\n --m3e-state-layer-hover-color: var(--_fab-menu-background-hover-color);\r\n --m3e-state-layer-focus-color: var(--_fab-menu-background-focus-color);\r\n --m3e-ripple-color: var(--_fab-menu-ripple-color);\r\n }\r\n :host(:disabled) .base {\r\n background-color: color-mix(\r\n in srgb,\r\n var(--m3e-fab-menu-item-disabled-container-color, ${DesignToken.color.onSurface})\r\n var(--m3e-fab-menu-item-disabled-container-opacity, 10%),\r\n transparent\r\n );\r\n }\r\n :host(:disabled) .label,\r\n :host(:disabled) .icon {\r\n color: color-mix(\r\n in srgb,\r\n var(--m3e-fab-menu-item-disabled-color, ${DesignToken.color.onSurface})\r\n var(--m3e-fab-menu-item-disabled-opacity, 38%),\r\n transparent\r\n );\r\n }\r\n .touch {\r\n position: absolute;\r\n height: 3rem;\r\n left: 0;\r\n right: 0;\r\n }\r\n .wrapper {\r\n width: 100%;\r\n overflow: hidden;\r\n display: inline-flex;\r\n align-items: center;\r\n padding-inline-start: var(--m3e-fab-menu-item-leading-space, 1.5rem);\r\n padding-inline-end: var(--m3e-fab-menu-item-trailing-space, 1.5rem);\r\n column-gap: var(--m3e-fab-menu-item-spacing, 0.5rem);\r\n }\r\n .label {\r\n justify-self: center;\r\n flex: 1 1 auto;\r\n text-align: center;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n .icon {\r\n font-size: var(--m3e-fab-menu-item-icon-size, 1.5rem);\r\n transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)};\r\n }\r\n :host(:not(:disabled)) {\r\n cursor: pointer;\r\n }\r\n ::slotted([slot=\"icon\"]) {\r\n font-size: inherit !important;\r\n flex: none;\r\n }\r\n ::slotted(svg[slot=\"icon\"]) {\r\n width: 1em;\r\n height: 1em;\r\n }\r\n a {\r\n all: unset;\r\n display: block;\r\n position: absolute;\r\n top: 0px;\r\n left: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n z-index: 1;\r\n }\r\n @media (prefers-reduced-motion) {\r\n .base,\r\n .label,\r\n .icon {\r\n transition: none;\r\n }\r\n }\r\n @media (forced-colors: active) {\r\n .base,\r\n .label,\r\n .icon {\r\n transition: none;\r\n }\r\n :host(:not(:disabled)) .base {\r\n background-color: Menu;\r\n }\r\n :host(:not(:disabled)) .label,\r\n :host(:not(:disabled)) .icon {\r\n color: MenuText;\r\n }\r\n :host(:disabled) .label,\r\n :host(:disabled) .icon {\r\n color: GrayText;\r\n }\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".elevation\") private readonly _elevation?: M3eElevationElement;\r\n /** @private */ @query(\".focus-ring\") private readonly _focusRing?: M3eFocusRingElement;\r\n /** @private */ @query(\".state-layer\") private readonly _stateLayer?: M3eStateLayerElement;\r\n /** @private */ @query(\".ripple\") private readonly _ripple?: M3eRippleElement;\r\n\r\n /** @private */ readonly #clickHandler = (e: Event) => this.#handleClick(e);\r\n\r\n /** The floating action button (FAB) menu to which this item belongs. */\r\n get menu(): M3eFabMenuElement | null {\r\n return this.closest(\"m3e-fab-menu\");\r\n }\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n super.connectedCallback();\r\n this.addEventListener(\"click\", this.#clickHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n this.removeEventListener(\"click\", this.#clickHandler);\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override firstUpdated(_changedProperties: PropertyValues<this>): void {\r\n super.firstUpdated(_changedProperties);\r\n [this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));\r\n }\r\n\r\n /** @inheritdoc */\r\n override render(): unknown {\r\n return html`<div class=\"base\">\r\n <m3e-elevation class=\"elevation\" ?disabled=\"${this.disabled}\"></m3e-elevation>\r\n <m3e-state-layer class=\"state-layer\" ?disabled=\"${this.disabled}\"></m3e-state-layer>\r\n <m3e-focus-ring class=\"focus-ring\" ?disabled=\"${this.disabled}\"></m3e-focus-ring>\r\n <m3e-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></m3e-ripple>\r\n <div class=\"touch\" aria-hidden=\"true\"></div>\r\n ${this[renderPseudoLink]()}\r\n <div class=\"wrapper\">\r\n <slot class=\"icon\" name=\"icon\" aria-hidden=\"true\"></slot>\r\n <div class=\"label\"><slot></slot></div>\r\n </div>\r\n </div>`;\r\n }\r\n\r\n /** @private */\r\n #handleClick(e: Event): void {\r\n if (!e.defaultPrevented) {\r\n this.menu?.hide(true);\r\n }\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu-item\": M3eFabMenuItemElement;\r\n }\r\n}\r\n","import { ActionElementBase, customElement, HtmlFor } from \"@m3e/web/core\";\r\nimport { addAriaReferencedId, removeAriaReferencedId } from \"@m3e/web/core/a11y\";\r\n\r\nimport { M3eFabMenuElement } from \"./FabMenuElement\";\r\n\r\n/**\r\n * An element, nested within a clickable element, used to open a floating action button (FAB) menu.\r\n *\r\n * @example\r\n * The following example illustrates triggering a `m3e-fab-menu` from an `m3e-fab` using a `m3e-fab-menu-trigger`.\r\n * ```html\r\n * <m3e-fab variant=\"primary\" size=\"large\">\r\n * <m3e-fab-menu-trigger for=\"fabmenu\">\r\n * <m3e-icon name=\"edit\"></m3e-icon>\r\n * </m3e-fab-menu-trigger>\r\n * </m3e-fab>\r\n * <m3e-fab-menu id=\"fabmenu\" variant=\"secondary\">\r\n * <m3e-fab-menu-item>First</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Second</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Third</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Forth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Fifth</m3e-fab-menu-item>\r\n * <m3e-fab-menu-item>Sixth</m3e-fab-menu-item>\r\n * </m3e-fab-menu>\r\n * ```\r\n *\r\n * @tag m3e-fab-menu-trigger\r\n */\r\n@customElement(\"m3e-fab-menu-trigger\")\r\nexport class M3eFabMenuTriggerElement extends HtmlFor(ActionElementBase) {\r\n /** The menu triggered by the element. */\r\n get menu(): M3eFabMenuElement | null {\r\n return this.control instanceof M3eFabMenuElement ? this.control : null;\r\n }\r\n\r\n /** @inheritdoc */\r\n override attach(control: HTMLElement): void {\r\n super.attach(control);\r\n\r\n if (this.parentElement && control instanceof M3eFabMenuElement) {\r\n this.parentElement.ariaHasPopup = \"menu\";\r\n this.parentElement.ariaExpanded = \"false\";\r\n if (control.id) {\r\n addAriaReferencedId(this.parentElement, \"aria-controls\", control.id);\r\n }\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n override detach(): void {\r\n if (this.parentElement) {\r\n this.parentElement.ariaHasPopup = null;\r\n this.parentElement.ariaExpanded = null;\r\n if (this.control?.id) {\r\n removeAriaReferencedId(this.parentElement, \"aria-controls\", this.control.id);\r\n }\r\n }\r\n\r\n super.detach();\r\n }\r\n\r\n /** @inheritdoc */\r\n override _onClick(): void {\r\n if (this.parentElement) {\r\n this.menu?.toggle(this.parentElement);\r\n }\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-fab-menu-trigger\": M3eFabMenuTriggerElement;\r\n }\r\n}\r\n"],"names":["M3eFabMenuElement","SuppressInitialAnimation","AttachInternals","Role","LitElement","constructor","_M3eFabMenuElement_fabTabIndex","set","this","_M3eFabMenuElement_trigger","_M3eFabMenuElement_anchoringCleanup","_M3eFabMenuElement_listManager","RovingTabIndexManager","withWrap","withHomeAndEnd","withVerticalOrientation","_M3eFabMenuElement_keyDownHandler","e","__classPrivateFieldGet","call","_M3eFabMenuElement_scrollController","ScrollController","target","callback","hide","_M3eFabMenuElement_clickOutsideController","ClickOutsideController","_M3eFabMenuElement_toggleHandler","newState","observe","setTimeout","setActiveItem","items","find","x","disabled","unobserveAll","__classPrivateFieldSet","undefined","variant","isOpen","show","trigger","positionAnchor","position","inline","shift","flip","offset","y","setCustomState","includes","M3eDirectionality","current","style","right","window","innerWidth","clientWidth","left","top","showPopover","ariaExpanded","_M3eFabMenuElement_instances","_M3eFabMenuElement_attachFab","restoreFocus","focus","_M3eFabMenuElement_detachFab","unobserve","hidePopover","toggle","connectedCallback","super","tabIndex","setAttribute","addEventListener","disconnectedCallback","removeEventListener","render","html","_M3eFabMenuElement_handleSlotChange","added","setItems","querySelectorAll","activeItem","updateActiveItem","key","shiftKey","ctrlKey","onKeyDown","fab","closest","filter","styles","css","unsafeCSS","DesignToken","motion","spring","fastEffects","fastSpatial","color","onPrimaryContainer","primaryContainer","onSecondaryContainer","secondaryContainer","onTertiaryContainer","tertiaryContainer","shape","corner","medium","__decorate","property","reflect","prototype","customElement","M3eFabMenuItemElement","KeyboardClick","LinkButton","Disabled","_M3eFabMenuItemElement_clickHandler","menu","firstUpdated","_changedProperties","_elevation","_focusRing","_stateLayer","_ripple","forEach","attach","renderPseudoLink","defaultPrevented","duration","short4","easing","standard","typescale","label","large","fontSize","fontWeight","lineHeight","tracking","full","onSurface","query","M3eFabMenuTriggerElement","HtmlFor","ActionElementBase","control","parentElement","ariaHasPopup","id","addAriaReferencedId","detach","removeAriaReferencedId","_onClick"],"mappings":";;;;;iwBA8EO,IAAMA,EAAN,cAAgCC,EAAyBC,EAAgBC,EAAKC,EAAY,WAA1FC,WAAAA,mCAmGWC,EAAAC,IAAAC,aACAC,EAAAF,IAAAC,aACAE,EAAAH,IAAAC,aAGPG,EAAAJ,IAAAC,MAAe,IAAII,GACzBC,WACAC,iBACAC,2BAEsBC,EAAAT,IAAAC,KAAmBS,GAAqBC,EAAAV,cAAmBW,KAAnBX,KAAoBS,IAG5EG,EAAAb,IAAAC,KAAoB,IAAIa,EAAiBb,KAAM,CAAEc,OAAQ,KAAMC,SAAUA,IAAMf,KAAKgB,UAEpEC,EAAAlB,IAAAC,KAA0B,IAAIkB,EAAuBlB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B"}
@@ -845,7 +845,7 @@
845
845
  },
846
846
  {
847
847
  "name": "m3e-rich-tooltip",
848
- "description": "Provides contextual details for a control, such as explaining the value or purpose of a feature.\n---\n\n\n### **Events:**\n - **beforetoggle** - Dispatched before the toggle state changes.\n- **toggle** - Dispatched after the toggle state has changed.\n\n### **Methods:**\n - **hide(restoreFocus): _void_** - Manually hides the tooltip.\n- **attach(control: _HTMLElement_): _void_** - Attaches the element to an interactive control.\n- **detach(): _void_** - Detaches the element from its current interactive control.\n- **show(): _Promise<void>_** - Manually shows the tooltip.\n\n### **Slots:**\n - _default_ - The main supporting text of the tooltip.\n- **subhead** - Optional subhead text displayed above the supporting content.\n- **actions** - Optional action elements displayed at the bottom of the tooltip.\n\n### **CSS Properties:**\n - **--m3e-rich-tooltip-padding-top** - Top padding of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-padding-bottom** - Bottom padding of the tooltip container (when no actions are present). _(default: undefined)_\n- **--m3e-rich-tooltip-padding-inline** - Horizontal padding of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-max-width** - Maximum width of the tooltip surface. _(default: undefined)_\n- **--m3e-rich-tooltip-shape** - Border‑radius of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-container-color** - Background color of the tooltip surface. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-color** - Color of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-font-size** - Font size of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-font-weight** - Font weight of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-line-height** - Line height of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-tracking** - Letter‑spacing of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-bottom-space** - Space below the subhead before the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-color** - Color of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-font-size** - Font size of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-font-weight** - Font weight of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-line-height** - Line height of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-tracking** - Letter‑spacing of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-padding-inline** - Horizontal padding applied to the actions slot area. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-top-space** - Space above the actions slot. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-bottom-space** - Space below the actions slot. _(default: undefined)_",
848
+ "description": "Provides contextual details for a control, such as explaining the value or purpose of a feature.\n---\n\n\n### **Events:**\n - **beforetoggle** - Dispatched before the toggle state changes.\n- **toggle** - Dispatched after the toggle state has changed.\n\n### **Methods:**\n - **show(): _Promise<void>_** - Manually shows the tooltip.\n- **hide(restoreFocus): _void_** - Manually hides the tooltip.\n- **attach(control: _HTMLElement_): _void_** - Attaches the element to an interactive control.\n- **detach(): _void_** - Detaches the element from its current interactive control.\n\n### **Slots:**\n - _default_ - The main supporting text of the tooltip.\n- **subhead** - Optional subhead text displayed above the supporting content.\n- **actions** - Optional action elements displayed at the bottom of the tooltip.\n\n### **CSS Properties:**\n - **--m3e-rich-tooltip-padding-top** - Top padding of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-padding-bottom** - Bottom padding of the tooltip container (when no actions are present). _(default: undefined)_\n- **--m3e-rich-tooltip-padding-inline** - Horizontal padding of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-max-width** - Maximum width of the tooltip surface. _(default: undefined)_\n- **--m3e-rich-tooltip-shape** - Border‑radius of the tooltip container. _(default: undefined)_\n- **--m3e-rich-tooltip-container-color** - Background color of the tooltip surface. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-color** - Color of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-font-size** - Font size of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-font-weight** - Font weight of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-line-height** - Line height of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-tracking** - Letter‑spacing of the subhead text. _(default: undefined)_\n- **--m3e-rich-tooltip-subhead-bottom-space** - Space below the subhead before the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-color** - Color of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-font-size** - Font size of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-font-weight** - Font weight of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-line-height** - Line height of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-supporting-text-tracking** - Letter‑spacing of the supporting text. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-padding-inline** - Horizontal padding applied to the actions slot area. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-top-space** - Space above the actions slot. _(default: undefined)_\n- **--m3e-rich-tooltip-actions-bottom-space** - Space below the actions slot. _(default: undefined)_",
849
849
  "attributes": [
850
850
  {
851
851
  "name": "disabled",
package/dist/icon.js CHANGED
@@ -41,14 +41,13 @@ class IconRegistry {
41
41
  }
42
42
  __classPrivateFieldGet(this, _a, "m", _IconRegistry_validateSvgIconInfo).call(this, name, variant, fillSet.outlined, trustOutlinedViewBox);
43
43
  __classPrivateFieldGet(this, _a, "m", _IconRegistry_validateSvgIconInfo).call(this, name, variant, fillSet.filled, trustFilledViewBox);
44
- if (window !== undefined) {
45
- const key = __classPrivateFieldGet(this, _a, "m", _IconRegistry_createKey).call(this, name, variant);
46
- __classPrivateFieldGet(this, _a, "f", _IconRegistry_icons).set(key, {
47
- outlined: svg`<svg viewBox="${fillSet.outlined.viewBox}"><path d="${fillSet.outlined.path}"/></svg>`,
48
- filled: svg`<svg viewBox="${fillSet.filled.viewBox}"><path d="${fillSet.filled.path}"/></svg>`
49
- });
50
- __classPrivateFieldGet(this, _a, "f", _IconRegistry_observers).get(key)?.forEach(x => x());
51
- }
44
+ if (typeof window === "undefined") return;
45
+ const key = __classPrivateFieldGet(this, _a, "m", _IconRegistry_createKey).call(this, name, variant);
46
+ __classPrivateFieldGet(this, _a, "f", _IconRegistry_icons).set(key, {
47
+ outlined: svg`<svg viewBox="${fillSet.outlined.viewBox}"><path d="${fillSet.outlined.path}"/></svg>`,
48
+ filled: svg`<svg viewBox="${fillSet.filled.viewBox}"><path d="${fillSet.filled.path}"/></svg>`
49
+ });
50
+ __classPrivateFieldGet(this, _a, "f", _IconRegistry_observers).get(key)?.forEach(x => x());
52
51
  }
53
52
  /**
54
53
  * Determines whether an icon is registered for the given variant.
package/dist/icon.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"icon.js","sources":["../../src/icon/IconRegistry.ts","../../src/icon/IconElement.ts","../../src/icon/registerIcon.ts"],"sourcesContent":["import { svg, SVGTemplateResult } from \"lit\";\r\n\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\n/** @private */ const PATH_DATA_PATTERN = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$/;\r\n/** @private */ const VIEW_BOX_PATTERN = /^-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?$/;\r\n\r\n/** Encapsulates information used to construct an SVG. */\r\nexport type SvgIconInfo = {\r\n /** The viewbox of the SVG. */\r\n viewBox: string;\r\n\r\n /** The path of the SVG. */\r\n path: string;\r\n};\r\n\r\n/** Represents the fill-axis SVG data for a single icon. */\r\nexport type SvgIconFillSet = {\r\n /** The unfilled (FILL=0) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n outlined: SvgIconInfo | string;\r\n\r\n /** The filled (FILL=1) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n filled: SvgIconInfo | string;\r\n};\r\n\r\n/**\r\n * Service to register and display icons used by the `m3e-icon` component.\r\n * @internal\r\n */\r\nexport class IconRegistry {\r\n /** @private */\r\n static readonly #icons = new Map<string, { outlined: SVGTemplateResult; filled: SVGTemplateResult }>();\r\n\r\n /** @private */ static readonly #observers = new Map<string, Array<() => void>>();\r\n\r\n /**\r\n * Adds an icon to the registry for the given variant and weight.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {SvgIconFillSet} fillSet The SVG data for both fill states (outlined and filled) of the icon.\r\n */\r\n static addIcon(name: string, variant: IconVariant, fillSet: SvgIconFillSet): void {\r\n const trustOutlinedViewBox = typeof fillSet.outlined === \"string\";\r\n const trustFilledViewBox = typeof fillSet.filled === \"string\";\r\n\r\n if (typeof fillSet.outlined === \"string\") {\r\n fillSet.outlined = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.outlined,\r\n };\r\n }\r\n if (typeof fillSet.filled === \"string\") {\r\n fillSet.filled = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.filled,\r\n };\r\n }\r\n\r\n this.#validateSvgIconInfo(name, variant, fillSet.outlined, trustOutlinedViewBox);\r\n this.#validateSvgIconInfo(name, variant, fillSet.filled, trustFilledViewBox);\r\n\r\n if (window !== undefined) {\r\n const key = this.#createKey(name, variant);\r\n this.#icons.set(key, {\r\n outlined: svg`<svg viewBox=\"${fillSet.outlined.viewBox}\"><path d=\"${fillSet.outlined.path}\"/></svg>`,\r\n filled: svg`<svg viewBox=\"${fillSet.filled.viewBox}\"><path d=\"${fillSet.filled.path}\"/></svg>`,\r\n });\r\n\r\n this.#observers.get(key)?.forEach((x) => x());\r\n }\r\n }\r\n\r\n /**\r\n * Determines whether an icon is registered for the given variant.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @returns {boolean} Whether `icon` is registered for the given `variant`.\r\n */\r\n static isIconRegistered(name: string, variant: IconVariant): boolean {\r\n return window !== undefined && this.#icons.has(this.#createKey(name, variant));\r\n }\r\n\r\n /**\r\n * Renders an icon from the registry.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {boolean} filled Whether to render a filled variant of the icon.\r\n * @returns {SVGTemplateResult | undefined} A `SVGTemplateResult` used to render the icon.\r\n */\r\n static renderIcon(name: string, variant: IconVariant, filled: boolean): SVGTemplateResult | undefined {\r\n const data = this.#icons.get(this.#createKey(name, variant));\r\n return filled ? data?.filled : data?.outlined;\r\n }\r\n\r\n /**\r\n * Begins observing registration for the specified icon.\r\n * @param {string} name The name of the icon to observe.\r\n * @param {IconVariant} variant The variant of the icon to observe.\r\n * @param {() => void} callback Callback invoked when the specified icon is registered for the given variant.\r\n * @returns {() => void} Function used to stop observing.\r\n */\r\n static observe(name: string, variant: IconVariant, callback: () => void): () => void {\r\n if (window === undefined) return () => {};\r\n\r\n const key = this.#createKey(name, variant);\r\n if (!this.#observers.has(key)) {\r\n this.#observers.set(key, [callback]);\r\n } else {\r\n this.#observers.get(key)?.push(callback);\r\n }\r\n\r\n return () => {\r\n const callbacks = this.#observers.get(key);\r\n if (callbacks) {\r\n const index = callbacks.indexOf(callback);\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n }\r\n if (callbacks.length == 0) {\r\n this.#observers.delete(key);\r\n }\r\n }\r\n };\r\n }\r\n\r\n /** @private */\r\n static #createKey(name: string, variant: IconVariant): string {\r\n return `${variant}-${name}`;\r\n }\r\n\r\n /** @private */\r\n static #validateSvgIconInfo(name: string, variant: IconVariant, info: SvgIconInfo, trustViewBox = false): void {\r\n if (!trustViewBox && !VIEW_BOX_PATTERN.test(info.viewBox)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid viewbox data.`);\r\n }\r\n if (!PATH_DATA_PATTERN.test(info.path)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid path data.`);\r\n }\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property, query } from \"lit/decorators.js\";\r\n\r\nimport { customElement, Role } from \"@m3e/web/core\";\r\n\r\nimport { IconRegistry } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\nimport { IconGrade } from \"./IconGrade\";\r\nimport { IconWeight } from \"./IconWeight\";\r\n\r\n/**\r\n * A small symbol used to easily identify an action or category.\r\n *\r\n * @description\r\n * The `m3e-icon` component makes it easier to use Material Symbols in your application. Material Symbols are Google's newest icons supporting\r\n * a range of design variants. For more information, see:\r\n * - {@link https://developers.google.com/fonts/docs/material_symbols|Material Symbol Guide}\r\n * - {@link https://fonts.google.com/icons|Material Symbol Library}\r\n *\r\n * The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the\r\n * {@link https://developers.google.com/fonts/docs/css2#forming_api_urls|Fonts CSS API}, you can use variable fonts to optimize icon\r\n * usage within your application. See {@link https://caniuse.com/variable-fonts|Can I Use's Variable Fonts} to determine whether\r\n * your user's browser support variable fonts.\r\n *\r\n * @example\r\n * The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.\r\n * ```html\r\n * <m3e-icon name=\"home\"></m3e-icon>\r\n * ```\r\n * @example\r\n * The next example illustrates a link used to download a variable font for outlined icons with fill support.\r\n * ```html\r\n * <link href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0\" rel=\"stylesheet\"/>\r\n * ```\r\n *\r\n * @tag m3e-icon\r\n *\r\n * @attr filled - Whether the icon is filled.\r\n * @attr grade - The grade of the icon.\r\n * @attr optical-size - A value from 20 to 48 indicating the optical size of the icon.\r\n * @attr name - The name of the icon.\r\n * @attr variant - The appearance variant of the icon.\r\n * @attr weight - A value from 100 to 700 indicating the weight of the icon.\r\n */\r\n@customElement(\"m3e-icon\")\r\nexport class M3eIconElement extends Role(LitElement, \"img\") {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n user-select: none;\r\n font-size: var(--m3e-icon-size, 1.5rem);\r\n width: 1em;\r\n height: 1em;\r\n vertical-align: middle;\r\n overflow: hidden;\r\n }\r\n .icon {\r\n font-weight: normal;\r\n font-style: normal;\r\n line-height: 1;\r\n letter-spacing: normal;\r\n text-transform: none;\r\n white-space: nowrap;\r\n word-wrap: normal;\r\n direction: ltr;\r\n font-feature-settings: \"liga\";\r\n -webkit-font-smoothing: antialiased;\r\n width: inherit;\r\n height: inherit;\r\n vertical-align: inherit;\r\n font-variation-settings:\r\n \"FILL\" var(--_icon-fill, 0),\r\n \"wght\" var(--_icon-weight, 400),\r\n \"GRAD\" var(--_icon-grade, 0),\r\n \"opsz\" var(--_icon-optical-size, 24);\r\n }\r\n :host([variant=\"outlined\"]) .icon {\r\n font-family: \"Material Symbols Outlined\";\r\n }\r\n :host([variant=\"rounded\"]) .icon {\r\n font-family: \"Material Symbols Rounded\";\r\n }\r\n :host([variant=\"sharp\"]) .icon {\r\n font-family: \"Material Symbols Sharp\";\r\n }\r\n svg {\r\n fill: currentColor;\r\n font-size: inherit;\r\n width: 1em;\r\n height: 1em;\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".icon\") private readonly _icon?: HTMLSpanElement;\r\n /** @private */ #iconRegistryUnobserve?: () => void;\r\n\r\n /** The name of the icon. */\r\n @property() name: string = \"\";\r\n\r\n /**\r\n * The appearance variant of the icon.\r\n * @default \"outlined\"\r\n */\r\n @property({ reflect: true }) variant: IconVariant = \"outlined\";\r\n\r\n /**\r\n * Whether the icon is filled.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) filled = false;\r\n\r\n /**\r\n * The grade of the icon.\r\n * @default \"medium\"\r\n */\r\n @property() grade: IconGrade = \"medium\";\r\n\r\n /**\r\n * A value from 100 to 700 indicating the weight of the icon.\r\n * @default 400\r\n */\r\n @property({ type: Number }) weight: IconWeight = 400;\r\n\r\n /**\r\n * A value from 20 to 48 indicating the optical size of the icon.\r\n * @default 24\r\n */\r\n @property({ attribute: \"optical-size\", type: Number }) opticalSize = 24;\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n if (\r\n !this.hasAttribute(\"aria-label\") &&\r\n !this.hasAttribute(\"aria-labelledby\") &&\r\n !this.hasAttribute(\"aria-hidden\")\r\n ) {\r\n this.ariaHidden = \"true\";\r\n }\r\n\r\n super.connectedCallback();\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.#iconRegistryUnobserve?.();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(_changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(_changedProperties);\r\n\r\n if (_changedProperties.has(\"name\") && !IconRegistry.isIconRegistered(this.name, this.variant)) {\r\n this.#iconRegistryUnobserve = IconRegistry.observe(this.name, this.variant, () => {\r\n this.requestUpdate();\r\n this.#iconRegistryUnobserve?.();\r\n this.#iconRegistryUnobserve = undefined;\r\n });\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues<this>): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"filled\")) {\r\n this._icon?.style.setProperty(\"--_icon-fill\", this.filled ? \"1\" : \"0\");\r\n }\r\n if (_changedProperties.has(\"grade\")) {\r\n this._icon?.style.setProperty(\r\n \"--_icon-grade\",\r\n this.grade === \"low\" ? \"-25\" : this.grade === \"high\" ? \"200\" : \"0\",\r\n );\r\n }\r\n if (_changedProperties.has(\"weight\")) {\r\n this._icon?.style.setProperty(\"--_icon-weight\", `${this.weight}`);\r\n }\r\n if (_changedProperties.has(\"opticalSize\")) {\r\n this._icon?.style.setProperty(\"--_icon-optical-size\", `${this.opticalSize}`);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return IconRegistry.isIconRegistered(this.name, this.variant)\r\n ? IconRegistry.renderIcon(this.name, this.variant, this.filled)\r\n : html`<div class=\"icon\" aria-hidden=\"true\" translate=\"no\">${this.name}</div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-icon\": M3eIconElement;\r\n }\r\n}\r\n","import { IconRegistry, SvgIconInfo } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\nexport type { SvgIconInfo } from \"./IconRegistry\";\r\n\r\n/**\r\n * Registers an SVG icon to the internal icon registry used by `m3e-icon`.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param data The outlined and filled SVG information of the icon.\r\n */\r\nexport function registerIcon(\r\n name: string,\r\n variant: IconVariant,\r\n data: { outlined: SvgIconInfo; filled: SvgIconInfo },\r\n): void {\r\n IconRegistry.addIcon(name, variant, data);\r\n}\r\n"],"names":["PATH_DATA_PATTERN","VIEW_BOX_PATTERN","IconRegistry","addIcon","name","variant","fillSet","trustOutlinedViewBox","outlined","trustFilledViewBox","filled","viewBox","path","__classPrivateFieldGet","_a","_IconRegistry_validateSvgIconInfo","call","window","undefined","key","_IconRegistry_createKey","_IconRegistry_icons","set","svg","_IconRegistry_observers","get","forEach","x","isIconRegistered","has","renderIcon","data","observe","callback","push","callbacks","index","indexOf","splice","length","delete","info","trustViewBox","test","Error","value","Map","M3eIconElement","Role","LitElement","constructor","_M3eIconElement_iconRegistryUnobserve","grade","weight","opticalSize","connectedCallback","hasAttribute","ariaHidden","disconnectedCallback","willUpdate","_changedProperties","__classPrivateFieldSet","requestUpdate","updated","_icon","style","setProperty","render","html","styles","css","__decorate","query","prototype","property","reflect","type","Boolean","Number","attribute","customElement","registerIcon"],"mappings":";;;;;;;;;;;AAIA;AAAgB,MAAMA,iBAAiB,GAAG,mCAAmC;AAC7E;AAAgB,MAAMC,gBAAgB,GAAG,iEAAiE;AAoB1G;;;AAGG;MACUC,YAAY,CAAA;AAMvB;;;;;AAKG;AACH,EAAA,OAAOC,OAAOA,CAACC,IAAY,EAAEC,OAAoB,EAAEC,OAAuB,EAAA;AACxE,IAAA,MAAMC,oBAAoB,GAA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AA,MAAA,CAAA;AAnF7D1B,cAAc,GAAAwB,UAAA,CAAA,CAD1BS,aAAa,CAAC,UAAU,CAAC,CACb,EAAAjC,cAAc,CAiJ1B;;ACzLD;;;;;AAKG;SACakC,YAAYA,CAC1B7E,IAAY,EACZC,OAAoB,EACpB0B,IAAoD,EAAA;EAEpD7B,YAAY,CAACC,OAAO,CAACC,IAAI,EAAEC,OAAO,EAAE0B,IAAI,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"icon.js","sources":["../../src/icon/IconRegistry.ts","../../src/icon/IconElement.ts","../../src/icon/registerIcon.ts"],"sourcesContent":["import { svg, SVGTemplateResult } from \"lit\";\r\n\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\n/** @private */ const PATH_DATA_PATTERN = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$/;\r\n/** @private */ const VIEW_BOX_PATTERN = /^-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?$/;\r\n\r\n/** Encapsulates information used to construct an SVG. */\r\nexport type SvgIconInfo = {\r\n /** The viewbox of the SVG. */\r\n viewBox: string;\r\n\r\n /** The path of the SVG. */\r\n path: string;\r\n};\r\n\r\n/** Represents the fill-axis SVG data for a single icon. */\r\nexport type SvgIconFillSet = {\r\n /** The unfilled (FILL=0) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n outlined: SvgIconInfo | string;\r\n\r\n /** The filled (FILL=1) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n filled: SvgIconInfo | string;\r\n};\r\n\r\n/**\r\n * Service to register and display icons used by the `m3e-icon` component.\r\n * @internal\r\n */\r\nexport class IconRegistry {\r\n /** @private */\r\n static readonly #icons = new Map<string, { outlined: SVGTemplateResult; filled: SVGTemplateResult }>();\r\n\r\n /** @private */ static readonly #observers = new Map<string, Array<() => void>>();\r\n\r\n /**\r\n * Adds an icon to the registry for the given variant and weight.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {SvgIconFillSet} fillSet The SVG data for both fill states (outlined and filled) of the icon.\r\n */\r\n static addIcon(name: string, variant: IconVariant, fillSet: SvgIconFillSet): void {\r\n const trustOutlinedViewBox = typeof fillSet.outlined === \"string\";\r\n const trustFilledViewBox = typeof fillSet.filled === \"string\";\r\n\r\n if (typeof fillSet.outlined === \"string\") {\r\n fillSet.outlined = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.outlined,\r\n };\r\n }\r\n if (typeof fillSet.filled === \"string\") {\r\n fillSet.filled = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.filled,\r\n };\r\n }\r\n\r\n this.#validateSvgIconInfo(name, variant, fillSet.outlined, trustOutlinedViewBox);\r\n this.#validateSvgIconInfo(name, variant, fillSet.filled, trustFilledViewBox);\r\n\r\n if (typeof window === \"undefined\") return;\r\n\r\n const key = this.#createKey(name, variant);\r\n this.#icons.set(key, {\r\n outlined: svg`<svg viewBox=\"${fillSet.outlined.viewBox}\"><path d=\"${fillSet.outlined.path}\"/></svg>`,\r\n filled: svg`<svg viewBox=\"${fillSet.filled.viewBox}\"><path d=\"${fillSet.filled.path}\"/></svg>`,\r\n });\r\n\r\n this.#observers.get(key)?.forEach((x) => x());\r\n }\r\n\r\n /**\r\n * Determines whether an icon is registered for the given variant.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @returns {boolean} Whether `icon` is registered for the given `variant`.\r\n */\r\n static isIconRegistered(name: string, variant: IconVariant): boolean {\r\n return window !== undefined && this.#icons.has(this.#createKey(name, variant));\r\n }\r\n\r\n /**\r\n * Renders an icon from the registry.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {boolean} filled Whether to render a filled variant of the icon.\r\n * @returns {SVGTemplateResult | undefined} A `SVGTemplateResult` used to render the icon.\r\n */\r\n static renderIcon(name: string, variant: IconVariant, filled: boolean): SVGTemplateResult | undefined {\r\n const data = this.#icons.get(this.#createKey(name, variant));\r\n return filled ? data?.filled : data?.outlined;\r\n }\r\n\r\n /**\r\n * Begins observing registration for the specified icon.\r\n * @param {string} name The name of the icon to observe.\r\n * @param {IconVariant} variant The variant of the icon to observe.\r\n * @param {() => void} callback Callback invoked when the specified icon is registered for the given variant.\r\n * @returns {() => void} Function used to stop observing.\r\n */\r\n static observe(name: string, variant: IconVariant, callback: () => void): () => void {\r\n if (window === undefined) return () => {};\r\n\r\n const key = this.#createKey(name, variant);\r\n if (!this.#observers.has(key)) {\r\n this.#observers.set(key, [callback]);\r\n } else {\r\n this.#observers.get(key)?.push(callback);\r\n }\r\n\r\n return () => {\r\n const callbacks = this.#observers.get(key);\r\n if (callbacks) {\r\n const index = callbacks.indexOf(callback);\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n }\r\n if (callbacks.length == 0) {\r\n this.#observers.delete(key);\r\n }\r\n }\r\n };\r\n }\r\n\r\n /** @private */\r\n static #createKey(name: string, variant: IconVariant): string {\r\n return `${variant}-${name}`;\r\n }\r\n\r\n /** @private */\r\n static #validateSvgIconInfo(name: string, variant: IconVariant, info: SvgIconInfo, trustViewBox = false): void {\r\n if (!trustViewBox && !VIEW_BOX_PATTERN.test(info.viewBox)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid viewbox data.`);\r\n }\r\n if (!PATH_DATA_PATTERN.test(info.path)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid path data.`);\r\n }\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property, query } from \"lit/decorators.js\";\r\n\r\nimport { customElement, Role } from \"@m3e/web/core\";\r\n\r\nimport { IconRegistry } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\nimport { IconGrade } from \"./IconGrade\";\r\nimport { IconWeight } from \"./IconWeight\";\r\n\r\n/**\r\n * A small symbol used to easily identify an action or category.\r\n *\r\n * @description\r\n * The `m3e-icon` component makes it easier to use Material Symbols in your application. Material Symbols are Google's newest icons supporting\r\n * a range of design variants. For more information, see:\r\n * - {@link https://developers.google.com/fonts/docs/material_symbols|Material Symbol Guide}\r\n * - {@link https://fonts.google.com/icons|Material Symbol Library}\r\n *\r\n * The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the\r\n * {@link https://developers.google.com/fonts/docs/css2#forming_api_urls|Fonts CSS API}, you can use variable fonts to optimize icon\r\n * usage within your application. See {@link https://caniuse.com/variable-fonts|Can I Use's Variable Fonts} to determine whether\r\n * your user's browser support variable fonts.\r\n *\r\n * @example\r\n * The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.\r\n * ```html\r\n * <m3e-icon name=\"home\"></m3e-icon>\r\n * ```\r\n * @example\r\n * The next example illustrates a link used to download a variable font for outlined icons with fill support.\r\n * ```html\r\n * <link href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0\" rel=\"stylesheet\"/>\r\n * ```\r\n *\r\n * @tag m3e-icon\r\n *\r\n * @attr filled - Whether the icon is filled.\r\n * @attr grade - The grade of the icon.\r\n * @attr optical-size - A value from 20 to 48 indicating the optical size of the icon.\r\n * @attr name - The name of the icon.\r\n * @attr variant - The appearance variant of the icon.\r\n * @attr weight - A value from 100 to 700 indicating the weight of the icon.\r\n */\r\n@customElement(\"m3e-icon\")\r\nexport class M3eIconElement extends Role(LitElement, \"img\") {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n user-select: none;\r\n font-size: var(--m3e-icon-size, 1.5rem);\r\n width: 1em;\r\n height: 1em;\r\n vertical-align: middle;\r\n overflow: hidden;\r\n }\r\n .icon {\r\n font-weight: normal;\r\n font-style: normal;\r\n line-height: 1;\r\n letter-spacing: normal;\r\n text-transform: none;\r\n white-space: nowrap;\r\n word-wrap: normal;\r\n direction: ltr;\r\n font-feature-settings: \"liga\";\r\n -webkit-font-smoothing: antialiased;\r\n width: inherit;\r\n height: inherit;\r\n vertical-align: inherit;\r\n font-variation-settings:\r\n \"FILL\" var(--_icon-fill, 0),\r\n \"wght\" var(--_icon-weight, 400),\r\n \"GRAD\" var(--_icon-grade, 0),\r\n \"opsz\" var(--_icon-optical-size, 24);\r\n }\r\n :host([variant=\"outlined\"]) .icon {\r\n font-family: \"Material Symbols Outlined\";\r\n }\r\n :host([variant=\"rounded\"]) .icon {\r\n font-family: \"Material Symbols Rounded\";\r\n }\r\n :host([variant=\"sharp\"]) .icon {\r\n font-family: \"Material Symbols Sharp\";\r\n }\r\n svg {\r\n fill: currentColor;\r\n font-size: inherit;\r\n width: 1em;\r\n height: 1em;\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".icon\") private readonly _icon?: HTMLSpanElement;\r\n /** @private */ #iconRegistryUnobserve?: () => void;\r\n\r\n /** The name of the icon. */\r\n @property() name: string = \"\";\r\n\r\n /**\r\n * The appearance variant of the icon.\r\n * @default \"outlined\"\r\n */\r\n @property({ reflect: true }) variant: IconVariant = \"outlined\";\r\n\r\n /**\r\n * Whether the icon is filled.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) filled = false;\r\n\r\n /**\r\n * The grade of the icon.\r\n * @default \"medium\"\r\n */\r\n @property() grade: IconGrade = \"medium\";\r\n\r\n /**\r\n * A value from 100 to 700 indicating the weight of the icon.\r\n * @default 400\r\n */\r\n @property({ type: Number }) weight: IconWeight = 400;\r\n\r\n /**\r\n * A value from 20 to 48 indicating the optical size of the icon.\r\n * @default 24\r\n */\r\n @property({ attribute: \"optical-size\", type: Number }) opticalSize = 24;\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n if (\r\n !this.hasAttribute(\"aria-label\") &&\r\n !this.hasAttribute(\"aria-labelledby\") &&\r\n !this.hasAttribute(\"aria-hidden\")\r\n ) {\r\n this.ariaHidden = \"true\";\r\n }\r\n\r\n super.connectedCallback();\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.#iconRegistryUnobserve?.();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(_changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(_changedProperties);\r\n\r\n if (_changedProperties.has(\"name\") && !IconRegistry.isIconRegistered(this.name, this.variant)) {\r\n this.#iconRegistryUnobserve = IconRegistry.observe(this.name, this.variant, () => {\r\n this.requestUpdate();\r\n this.#iconRegistryUnobserve?.();\r\n this.#iconRegistryUnobserve = undefined;\r\n });\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues<this>): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"filled\")) {\r\n this._icon?.style.setProperty(\"--_icon-fill\", this.filled ? \"1\" : \"0\");\r\n }\r\n if (_changedProperties.has(\"grade\")) {\r\n this._icon?.style.setProperty(\r\n \"--_icon-grade\",\r\n this.grade === \"low\" ? \"-25\" : this.grade === \"high\" ? \"200\" : \"0\",\r\n );\r\n }\r\n if (_changedProperties.has(\"weight\")) {\r\n this._icon?.style.setProperty(\"--_icon-weight\", `${this.weight}`);\r\n }\r\n if (_changedProperties.has(\"opticalSize\")) {\r\n this._icon?.style.setProperty(\"--_icon-optical-size\", `${this.opticalSize}`);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return IconRegistry.isIconRegistered(this.name, this.variant)\r\n ? IconRegistry.renderIcon(this.name, this.variant, this.filled)\r\n : html`<div class=\"icon\" aria-hidden=\"true\" translate=\"no\">${this.name}</div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-icon\": M3eIconElement;\r\n }\r\n}\r\n","import { IconRegistry, SvgIconInfo } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\nexport type { SvgIconInfo } from \"./IconRegistry\";\r\n\r\n/**\r\n * Registers an SVG icon to the internal icon registry used by `m3e-icon`.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param data The outlined and filled SVG information of the icon.\r\n */\r\nexport function registerIcon(\r\n name: string,\r\n variant: IconVariant,\r\n data: { outlined: SvgIconInfo; filled: SvgIconInfo },\r\n): void {\r\n IconRegistry.addIcon(name, variant, data);\r\n}\r\n"],"names":["PATH_DATA_PATTERN","VIEW_BOX_PATTERN","IconRegistry","addIcon","name","variant","fillSet","trustOutlinedViewBox","outlined","trustFilledViewBox","filled","viewBox","path","__classPrivateFieldGet","_a","_IconRegistry_validateSvgIconInfo","call","window","key","_IconRegistry_createKey","_IconRegistry_icons","set","svg","_IconRegistry_observers","get","forEach","x","isIconRegistered","undefined","has","renderIcon","data","observe","callback","push","callbacks","index","indexOf","splice","length","delete","info","trustViewBox","test","Error","value","Map","M3eIconElement","Role","LitElement","constructor","_M3eIconElement_iconRegistryUnobserve","grade","weight","opticalSize","connectedCallback","hasAttribute","ariaHidden","disconnectedCallback","willUpdate","_changedProperties","__classPrivateFieldSet","requestUpdate","updated","_icon","style","setProperty","render","html","styles","css","__decorate","query","prototype","property","reflect","type","Boolean","Number","attribute","customElement","registerIcon"],"mappings":";;;;;;;;;;;AAIA;AAAgB,MAAMA,iBAAiB,GAAG,mCAAmC;AAC7E;AAAgB,MAAMC,gBAAgB,GAAG,iEAAiE;AAoB1G;;;AAGG;MACUC,YAAY,CAAA;AAMvB;;;;;AAKG;AACH,EAAA,OAAOC,OAAOA,CAACC,IAAY,EAAEC,OAAoB,EAAEC,OAAuB,EAAA;AACxE,IAAA,MAAMC,oBAAoB,GAAG,OAAOD,OAAO,CAACE,QAAQ,KAAK,QAAQ;AACjE,IAAA,MAAMC,kBAAkB,GAAG,OAAOH,OAAO,CAACI,MAAM,KAAK,QAAQ;AAE7D,IAAA,IAAI,OAAOJ,OAAO,CAACE,QAAQ,KAAK,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EACpB0B,IAAoD,EAAA;EAEpD7B,YAAY,CAACC,OAAO,CAACC,IAAI,EAAEC,OAAO,EAAE0B,IAAI,CAAC;AAC3C;;;;"}
package/dist/icon.min.js CHANGED
@@ -3,5 +3,5 @@
3
3
  * Copyright (c) 2025–2026 matraic
4
4
  * See LICENSE file in the project root for full license text.
5
5
  */
6
- import{__classPrivateFieldGet as t,__classPrivateFieldSet as i,__decorate as e}from"tslib";import{svg as o,LitElement as s,html as a,css as n}from"lit";import{query as r,property as l}from"lit/decorators.js";import{Role as h,customElement as d}from"@m3e/web/core";var c,f,p,v,m;const g=/^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/,u=/^-?\d+(\.\d+)?\s+-?\d+(\.\d+)?\s+-?\d+(\.\d+)?\s+-?\d+(\.\d+)?$/;class w{static addIcon(i,e,s){const a="string"==typeof s.outlined,n="string"==typeof s.filled;if("string"==typeof s.outlined&&(s.outlined={viewBox:"0 -960 960 960",path:s.outlined}),"string"==typeof s.filled&&(s.filled={viewBox:"0 -960 960 960",path:s.filled}),t(this,c,"m",m).call(this,i,e,s.outlined,a),t(this,c,"m",m).call(this,i,e,s.filled,n),void 0!==window){const a=t(this,c,"m",v).call(this,i,e);t(this,c,"f",f).set(a,{outlined:o`<svg viewBox="${s.outlined.viewBox}"><path d="${s.outlined.path}"/></svg>`,filled:o`<svg viewBox="${s.filled.viewBox}"><path d="${s.filled.path}"/></svg>`}),t(this,c,"f",p).get(a)?.forEach(t=>t())}}static isIconRegistered(i,e){return void 0!==window&&t(this,c,"f",f).has(t(this,c,"m",v).call(this,i,e))}static renderIcon(i,e,o){const s=t(this,c,"f",f).get(t(this,c,"m",v).call(this,i,e));return o?s?.filled:s?.outlined}static observe(i,e,o){if(void 0===window)return()=>{};const s=t(this,c,"m",v).call(this,i,e);return t(this,c,"f",p).has(s)?t(this,c,"f",p).get(s)?.push(o):t(this,c,"f",p).set(s,[o]),()=>{const i=t(this,c,"f",p).get(s);if(i){const e=i.indexOf(o);e>=0&&i.splice(e,1),0==i.length&&t(this,c,"f",p).delete(s)}}}}var y;c=w,v=function(t,i){return`${i}-${t}`},m=function(t,i,e,o=!1){if(!o&&!u.test(e.viewBox))throw new Error(`Unable to register icon '${t}' for variant '${i}'. Invalid viewbox data.`);if(!g.test(e.path))throw new Error(`Unable to register icon '${t}' for variant '${i}'. Invalid path data.`)},f={value:new Map},p={value:new Map};let b=class extends(h(s,"img")){constructor(){super(...arguments),y.set(this,void 0),this.name="",this.variant="outlined",this.filled=!1,this.grade="medium",this.weight=400,this.opticalSize=24}connectedCallback(){this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.hasAttribute("aria-hidden")||(this.ariaHidden="true"),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),t(this,y,"f")?.call(this)}willUpdate(e){super.willUpdate(e),e.has("name")&&!w.isIconRegistered(this.name,this.variant)&&i(this,y,w.observe(this.name,this.variant,()=>{this.requestUpdate(),t(this,y,"f")?.call(this),i(this,y,void 0,"f")}),"f")}updated(t){super.updated(t),t.has("filled")&&this._icon?.style.setProperty("--_icon-fill",this.filled?"1":"0"),t.has("grade")&&this._icon?.style.setProperty("--_icon-grade","low"===this.grade?"-25":"high"===this.grade?"200":"0"),t.has("weight")&&this._icon?.style.setProperty("--_icon-weight",`${this.weight}`),t.has("opticalSize")&&this._icon?.style.setProperty("--_icon-optical-size",`${this.opticalSize}`)}render(){return w.isIconRegistered(this.name,this.variant)?w.renderIcon(this.name,this.variant,this.filled):a`<div class="icon" aria-hidden="true" translate="no">${this.name}</div>`}};function $(t,i,e){w.addIcon(t,i,e)}y=new WeakMap,b.styles=n`:host { display: inline-block; user-select: none; font-size: var(--m3e-icon-size, 1.5rem); width: 1em; height: 1em; vertical-align: middle; overflow: hidden; } .icon { font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; word-wrap: normal; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; width: inherit; height: inherit; vertical-align: inherit; font-variation-settings: "FILL" var(--_icon-fill, 0), "wght" var(--_icon-weight, 400), "GRAD" var(--_icon-grade, 0), "opsz" var(--_icon-optical-size, 24); } :host([variant="outlined"]) .icon { font-family: "Material Symbols Outlined"; } :host([variant="rounded"]) .icon { font-family: "Material Symbols Rounded"; } :host([variant="sharp"]) .icon { font-family: "Material Symbols Sharp"; } svg { fill: currentColor; font-size: inherit; width: 1em; height: 1em; }`,e([r(".icon")],b.prototype,"_icon",void 0),e([l()],b.prototype,"name",void 0),e([l({reflect:!0})],b.prototype,"variant",void 0),e([l({type:Boolean,reflect:!0})],b.prototype,"filled",void 0),e([l()],b.prototype,"grade",void 0),e([l({type:Number})],b.prototype,"weight",void 0),e([l({attribute:"optical-size",type:Number})],b.prototype,"opticalSize",void 0),b=e([d("m3e-icon")],b);export{b as M3eIconElement,$ as registerIcon};
6
+ import{__classPrivateFieldGet as t,__classPrivateFieldSet as i,__decorate as e}from"tslib";import{svg as o,LitElement as s,html as a,css as n}from"lit";import{query as r,property as l}from"lit/decorators.js";import{Role as h,customElement as d}from"@m3e/web/core";var c,f,p,v,m;const u=/^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/,g=/^-?\d+(\.\d+)?\s+-?\d+(\.\d+)?\s+-?\d+(\.\d+)?\s+-?\d+(\.\d+)?$/;class w{static addIcon(i,e,s){const a="string"==typeof s.outlined,n="string"==typeof s.filled;if("string"==typeof s.outlined&&(s.outlined={viewBox:"0 -960 960 960",path:s.outlined}),"string"==typeof s.filled&&(s.filled={viewBox:"0 -960 960 960",path:s.filled}),t(this,c,"m",m).call(this,i,e,s.outlined,a),t(this,c,"m",m).call(this,i,e,s.filled,n),"undefined"==typeof window)return;const r=t(this,c,"m",v).call(this,i,e);t(this,c,"f",f).set(r,{outlined:o`<svg viewBox="${s.outlined.viewBox}"><path d="${s.outlined.path}"/></svg>`,filled:o`<svg viewBox="${s.filled.viewBox}"><path d="${s.filled.path}"/></svg>`}),t(this,c,"f",p).get(r)?.forEach(t=>t())}static isIconRegistered(i,e){return void 0!==window&&t(this,c,"f",f).has(t(this,c,"m",v).call(this,i,e))}static renderIcon(i,e,o){const s=t(this,c,"f",f).get(t(this,c,"m",v).call(this,i,e));return o?s?.filled:s?.outlined}static observe(i,e,o){if(void 0===window)return()=>{};const s=t(this,c,"m",v).call(this,i,e);return t(this,c,"f",p).has(s)?t(this,c,"f",p).get(s)?.push(o):t(this,c,"f",p).set(s,[o]),()=>{const i=t(this,c,"f",p).get(s);if(i){const e=i.indexOf(o);e>=0&&i.splice(e,1),0==i.length&&t(this,c,"f",p).delete(s)}}}}var y;c=w,v=function(t,i){return`${i}-${t}`},m=function(t,i,e,o=!1){if(!o&&!g.test(e.viewBox))throw new Error(`Unable to register icon '${t}' for variant '${i}'. Invalid viewbox data.`);if(!u.test(e.path))throw new Error(`Unable to register icon '${t}' for variant '${i}'. Invalid path data.`)},f={value:new Map},p={value:new Map};let b=class extends(h(s,"img")){constructor(){super(...arguments),y.set(this,void 0),this.name="",this.variant="outlined",this.filled=!1,this.grade="medium",this.weight=400,this.opticalSize=24}connectedCallback(){this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby")||this.hasAttribute("aria-hidden")||(this.ariaHidden="true"),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),t(this,y,"f")?.call(this)}willUpdate(e){super.willUpdate(e),e.has("name")&&!w.isIconRegistered(this.name,this.variant)&&i(this,y,w.observe(this.name,this.variant,()=>{this.requestUpdate(),t(this,y,"f")?.call(this),i(this,y,void 0,"f")}),"f")}updated(t){super.updated(t),t.has("filled")&&this._icon?.style.setProperty("--_icon-fill",this.filled?"1":"0"),t.has("grade")&&this._icon?.style.setProperty("--_icon-grade","low"===this.grade?"-25":"high"===this.grade?"200":"0"),t.has("weight")&&this._icon?.style.setProperty("--_icon-weight",`${this.weight}`),t.has("opticalSize")&&this._icon?.style.setProperty("--_icon-optical-size",`${this.opticalSize}`)}render(){return w.isIconRegistered(this.name,this.variant)?w.renderIcon(this.name,this.variant,this.filled):a`<div class="icon" aria-hidden="true" translate="no">${this.name}</div>`}};function $(t,i,e){w.addIcon(t,i,e)}y=new WeakMap,b.styles=n`:host { display: inline-block; user-select: none; font-size: var(--m3e-icon-size, 1.5rem); width: 1em; height: 1em; vertical-align: middle; overflow: hidden; } .icon { font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; white-space: nowrap; word-wrap: normal; direction: ltr; font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; width: inherit; height: inherit; vertical-align: inherit; font-variation-settings: "FILL" var(--_icon-fill, 0), "wght" var(--_icon-weight, 400), "GRAD" var(--_icon-grade, 0), "opsz" var(--_icon-optical-size, 24); } :host([variant="outlined"]) .icon { font-family: "Material Symbols Outlined"; } :host([variant="rounded"]) .icon { font-family: "Material Symbols Rounded"; } :host([variant="sharp"]) .icon { font-family: "Material Symbols Sharp"; } svg { fill: currentColor; font-size: inherit; width: 1em; height: 1em; }`,e([r(".icon")],b.prototype,"_icon",void 0),e([l()],b.prototype,"name",void 0),e([l({reflect:!0})],b.prototype,"variant",void 0),e([l({type:Boolean,reflect:!0})],b.prototype,"filled",void 0),e([l()],b.prototype,"grade",void 0),e([l({type:Number})],b.prototype,"weight",void 0),e([l({attribute:"optical-size",type:Number})],b.prototype,"opticalSize",void 0),b=e([d("m3e-icon")],b);export{b as M3eIconElement,$ as registerIcon};
7
7
  //# sourceMappingURL=icon.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.min.js","sources":["../../src/icon/IconRegistry.ts","../../src/icon/IconElement.ts","../../src/icon/registerIcon.ts"],"sourcesContent":["import { svg, SVGTemplateResult } from \"lit\";\r\n\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\n/** @private */ const PATH_DATA_PATTERN = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$/;\r\n/** @private */ const VIEW_BOX_PATTERN = /^-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?$/;\r\n\r\n/** Encapsulates information used to construct an SVG. */\r\nexport type SvgIconInfo = {\r\n /** The viewbox of the SVG. */\r\n viewBox: string;\r\n\r\n /** The path of the SVG. */\r\n path: string;\r\n};\r\n\r\n/** Represents the fill-axis SVG data for a single icon. */\r\nexport type SvgIconFillSet = {\r\n /** The unfilled (FILL=0) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n outlined: SvgIconInfo | string;\r\n\r\n /** The filled (FILL=1) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n filled: SvgIconInfo | string;\r\n};\r\n\r\n/**\r\n * Service to register and display icons used by the `m3e-icon` component.\r\n * @internal\r\n */\r\nexport class IconRegistry {\r\n /** @private */\r\n static readonly #icons = new Map<string, { outlined: SVGTemplateResult; filled: SVGTemplateResult }>();\r\n\r\n /** @private */ static readonly #observers = new Map<string, Array<() => void>>();\r\n\r\n /**\r\n * Adds an icon to the registry for the given variant and weight.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {SvgIconFillSet} fillSet The SVG data for both fill states (outlined and filled) of the icon.\r\n */\r\n static addIcon(name: string, variant: IconVariant, fillSet: SvgIconFillSet): void {\r\n const trustOutlinedViewBox = typeof fillSet.outlined === \"string\";\r\n const trustFilledViewBox = typeof fillSet.filled === \"string\";\r\n\r\n if (typeof fillSet.outlined === \"string\") {\r\n fillSet.outlined = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.outlined,\r\n };\r\n }\r\n if (typeof fillSet.filled === \"string\") {\r\n fillSet.filled = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.filled,\r\n };\r\n }\r\n\r\n this.#validateSvgIconInfo(name, variant, fillSet.outlined, trustOutlinedViewBox);\r\n this.#validateSvgIconInfo(name, variant, fillSet.filled, trustFilledViewBox);\r\n\r\n if (window !== undefined) {\r\n const key = this.#createKey(name, variant);\r\n this.#icons.set(key, {\r\n outlined: svg`<svg viewBox=\"${fillSet.outlined.viewBox}\"><path d=\"${fillSet.outlined.path}\"/></svg>`,\r\n filled: svg`<svg viewBox=\"${fillSet.filled.viewBox}\"><path d=\"${fillSet.filled.path}\"/></svg>`,\r\n });\r\n\r\n this.#observers.get(key)?.forEach((x) => x());\r\n }\r\n }\r\n\r\n /**\r\n * Determines whether an icon is registered for the given variant.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @returns {boolean} Whether `icon` is registered for the given `variant`.\r\n */\r\n static isIconRegistered(name: string, variant: IconVariant): boolean {\r\n return window !== undefined && this.#icons.has(this.#createKey(name, variant));\r\n }\r\n\r\n /**\r\n * Renders an icon from the registry.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {boolean} filled Whether to render a filled variant of the icon.\r\n * @returns {SVGTemplateResult | undefined} A `SVGTemplateResult` used to render the icon.\r\n */\r\n static renderIcon(name: string, variant: IconVariant, filled: boolean): SVGTemplateResult | undefined {\r\n const data = this.#icons.get(this.#createKey(name, variant));\r\n return filled ? data?.filled : data?.outlined;\r\n }\r\n\r\n /**\r\n * Begins observing registration for the specified icon.\r\n * @param {string} name The name of the icon to observe.\r\n * @param {IconVariant} variant The variant of the icon to observe.\r\n * @param {() => void} callback Callback invoked when the specified icon is registered for the given variant.\r\n * @returns {() => void} Function used to stop observing.\r\n */\r\n static observe(name: string, variant: IconVariant, callback: () => void): () => void {\r\n if (window === undefined) return () => {};\r\n\r\n const key = this.#createKey(name, variant);\r\n if (!this.#observers.has(key)) {\r\n this.#observers.set(key, [callback]);\r\n } else {\r\n this.#observers.get(key)?.push(callback);\r\n }\r\n\r\n return () => {\r\n const callbacks = this.#observers.get(key);\r\n if (callbacks) {\r\n const index = callbacks.indexOf(callback);\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n }\r\n if (callbacks.length == 0) {\r\n this.#observers.delete(key);\r\n }\r\n }\r\n };\r\n }\r\n\r\n /** @private */\r\n static #createKey(name: string, variant: IconVariant): string {\r\n return `${variant}-${name}`;\r\n }\r\n\r\n /** @private */\r\n static #validateSvgIconInfo(name: string, variant: IconVariant, info: SvgIconInfo, trustViewBox = false): void {\r\n if (!trustViewBox && !VIEW_BOX_PATTERN.test(info.viewBox)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid viewbox data.`);\r\n }\r\n if (!PATH_DATA_PATTERN.test(info.path)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid path data.`);\r\n }\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property, query } from \"lit/decorators.js\";\r\n\r\nimport { customElement, Role } from \"@m3e/web/core\";\r\n\r\nimport { IconRegistry } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\nimport { IconGrade } from \"./IconGrade\";\r\nimport { IconWeight } from \"./IconWeight\";\r\n\r\n/**\r\n * A small symbol used to easily identify an action or category.\r\n *\r\n * @description\r\n * The `m3e-icon` component makes it easier to use Material Symbols in your application. Material Symbols are Google's newest icons supporting\r\n * a range of design variants. For more information, see:\r\n * - {@link https://developers.google.com/fonts/docs/material_symbols|Material Symbol Guide}\r\n * - {@link https://fonts.google.com/icons|Material Symbol Library}\r\n *\r\n * The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the\r\n * {@link https://developers.google.com/fonts/docs/css2#forming_api_urls|Fonts CSS API}, you can use variable fonts to optimize icon\r\n * usage within your application. See {@link https://caniuse.com/variable-fonts|Can I Use's Variable Fonts} to determine whether\r\n * your user's browser support variable fonts.\r\n *\r\n * @example\r\n * The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.\r\n * ```html\r\n * <m3e-icon name=\"home\"></m3e-icon>\r\n * ```\r\n * @example\r\n * The next example illustrates a link used to download a variable font for outlined icons with fill support.\r\n * ```html\r\n * <link href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0\" rel=\"stylesheet\"/>\r\n * ```\r\n *\r\n * @tag m3e-icon\r\n *\r\n * @attr filled - Whether the icon is filled.\r\n * @attr grade - The grade of the icon.\r\n * @attr optical-size - A value from 20 to 48 indicating the optical size of the icon.\r\n * @attr name - The name of the icon.\r\n * @attr variant - The appearance variant of the icon.\r\n * @attr weight - A value from 100 to 700 indicating the weight of the icon.\r\n */\r\n@customElement(\"m3e-icon\")\r\nexport class M3eIconElement extends Role(LitElement, \"img\") {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n user-select: none;\r\n font-size: var(--m3e-icon-size, 1.5rem);\r\n width: 1em;\r\n height: 1em;\r\n vertical-align: middle;\r\n overflow: hidden;\r\n }\r\n .icon {\r\n font-weight: normal;\r\n font-style: normal;\r\n line-height: 1;\r\n letter-spacing: normal;\r\n text-transform: none;\r\n white-space: nowrap;\r\n word-wrap: normal;\r\n direction: ltr;\r\n font-feature-settings: \"liga\";\r\n -webkit-font-smoothing: antialiased;\r\n width: inherit;\r\n height: inherit;\r\n vertical-align: inherit;\r\n font-variation-settings:\r\n \"FILL\" var(--_icon-fill, 0),\r\n \"wght\" var(--_icon-weight, 400),\r\n \"GRAD\" var(--_icon-grade, 0),\r\n \"opsz\" var(--_icon-optical-size, 24);\r\n }\r\n :host([variant=\"outlined\"]) .icon {\r\n font-family: \"Material Symbols Outlined\";\r\n }\r\n :host([variant=\"rounded\"]) .icon {\r\n font-family: \"Material Symbols Rounded\";\r\n }\r\n :host([variant=\"sharp\"]) .icon {\r\n font-family: \"Material Symbols Sharp\";\r\n }\r\n svg {\r\n fill: currentColor;\r\n font-size: inherit;\r\n width: 1em;\r\n height: 1em;\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".icon\") private readonly _icon?: HTMLSpanElement;\r\n /** @private */ #iconRegistryUnobserve?: () => void;\r\n\r\n /** The name of the icon. */\r\n @property() name: string = \"\";\r\n\r\n /**\r\n * The appearance variant of the icon.\r\n * @default \"outlined\"\r\n */\r\n @property({ reflect: true }) variant: IconVariant = \"outlined\";\r\n\r\n /**\r\n * Whether the icon is filled.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) filled = false;\r\n\r\n /**\r\n * The grade of the icon.\r\n * @default \"medium\"\r\n */\r\n @property() grade: IconGrade = \"medium\";\r\n\r\n /**\r\n * A value from 100 to 700 indicating the weight of the icon.\r\n * @default 400\r\n */\r\n @property({ type: Number }) weight: IconWeight = 400;\r\n\r\n /**\r\n * A value from 20 to 48 indicating the optical size of the icon.\r\n * @default 24\r\n */\r\n @property({ attribute: \"optical-size\", type: Number }) opticalSize = 24;\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n if (\r\n !this.hasAttribute(\"aria-label\") &&\r\n !this.hasAttribute(\"aria-labelledby\") &&\r\n !this.hasAttribute(\"aria-hidden\")\r\n ) {\r\n this.ariaHidden = \"true\";\r\n }\r\n\r\n super.connectedCallback();\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.#iconRegistryUnobserve?.();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(_changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(_changedProperties);\r\n\r\n if (_changedProperties.has(\"name\") && !IconRegistry.isIconRegistered(this.name, this.variant)) {\r\n this.#iconRegistryUnobserve = IconRegistry.observe(this.name, this.variant, () => {\r\n this.requestUpdate();\r\n this.#iconRegistryUnobserve?.();\r\n this.#iconRegistryUnobserve = undefined;\r\n });\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues<this>): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"filled\")) {\r\n this._icon?.style.setProperty(\"--_icon-fill\", this.filled ? \"1\" : \"0\");\r\n }\r\n if (_changedProperties.has(\"grade\")) {\r\n this._icon?.style.setProperty(\r\n \"--_icon-grade\",\r\n this.grade === \"low\" ? \"-25\" : this.grade === \"high\" ? \"200\" : \"0\",\r\n );\r\n }\r\n if (_changedProperties.has(\"weight\")) {\r\n this._icon?.style.setProperty(\"--_icon-weight\", `${this.weight}`);\r\n }\r\n if (_changedProperties.has(\"opticalSize\")) {\r\n this._icon?.style.setProperty(\"--_icon-optical-size\", `${this.opticalSize}`);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return IconRegistry.isIconRegistered(this.name, this.variant)\r\n ? IconRegistry.renderIcon(this.name, this.variant, this.filled)\r\n : html`<div class=\"icon\" aria-hidden=\"true\" translate=\"no\">${this.name}</div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-icon\": M3eIconElement;\r\n }\r\n}\r\n","import { IconRegistry, SvgIconInfo } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\nexport type { SvgIconInfo } from \"./IconRegistry\";\r\n\r\n/**\r\n * Registers an SVG icon to the internal icon registry used by `m3e-icon`.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param data The outlined and filled SVG information of the icon.\r\n */\r\nexport function registerIcon(\r\n name: string,\r\n variant: IconVariant,\r\n data: { outlined: SvgIconInfo; filled: SvgIconInfo },\r\n): void {\r\n IconRegistry.addIcon(name, variant, data);\r\n}\r\n"],"names":["PATH_DATA_PATTERN","VIEW_BOX_PATTERN","IconRegistry","addIcon","name","variant","fillSet","trustOutlinedViewBox","outlined","trustFilledViewBox","filled","viewBox","path","__classPrivateFieldGet","this","_a","_IconRegistry_validateSvgIconInfo","call","undefined","window","key","_IconRegistry_createKey","_IconRegistry_icons","set","svg","_IconRegistry_observers","get","forEach","x","isIconRegistered","has","renderIcon","data","observe","callback","push","callbacks","index","indexOf","splice","length","delete","info","trustViewBox","test","Error","value","Map","M3eIconElement","Role","LitElement","constructor","_M3eIconElement_iconRegistryUnobserve","grade","weight","opticalSize","connectedCallback","hasAttribute","ariaHidden","super","disconnectedCallback","willUpdate","_changedProperties","__classPrivateFieldSet","requestUpdate","updated","_icon","style","setProperty","render","html","registerIcon","styles","css","__decorate","query","prototype","property","reflect","type","Boolean","Number","attribute","customElement"],"mappings":";;;;;sRAIgB,MAAMA,EAAoB,oCACpBC,EAAmB,wEAwB5BC,EAYX,cAAOC,CAAQC,EAAcC,EAAsBC,GACjD,MAAMC,EAAmD,iBAArBD,EAAQE,SACtCC,EAA+C,iBAAnBH,EAAQI,OAkB1C,GAhBgC,iBAArBJ,EAAQE,WACjBF,EAAQE,SAAW,CACjBG,QAAS,iBACTC,KAAMN,EAAQE,WAGY,iBAAnBF,EAAQI,SACjBJ,EAAQI,OAAS,CACfC,QAAS,iBACTC,KAAMN,EAAQI,SAIlBG,EAAAC,KAAIC,EAAA,IAAAC,GAAqBC,KAAzBH,KAA0BV,EAAMC,EAASC,EAAQE,SAAUD,GAC3DM,EAAAC,KAAIC,EAAA,IAAAC,GAAqBC,KAAzBH,KAA0BV,EAAMC,EAASC,EAAQI,OAAQD,QAE1CS,IAAXC,OAAsB,CACxB,MAAMC,EAAMP,EAAAC,KAAIC,EAAA,IAAAM,GAAWJ,KAAfH,KAAgBV,EAAMC,GAClCQ,EAAAC,KAAIC,EAAA,IAAAO,GAAQC,IAAIH,EAAK,CACnBZ,SAAUgB,CAAG,iBAAiBlB,EAAQE,SAASG,qBAAqBL,EAAQE,SAASI,gBACrFF,OAAQc,CAAG,iBAAiBlB,EAAQI,OAAOC,qBAAqBL,EAAQI,OAAOE,kBAGjFC,EAAAC,KAAIC,EAAA,IAAAU,GAAYC,IAAIN,IAAMO,QAASC,GAAMA,IAC3C,CACF,CAQA,uBAAOC,CAAiBzB,EAAcC,GACpC,YAAkBa,IAAXC,QAAwBN,EAAAC,KAAIC,EAAA,IAAAO,GAAQQ,IAAIjB,EAAAC,KAAIC,EAAA,IAAAM,QAAJP,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,iBAAiBf,KAAKV,KAAMU,KAAKT,SACjDH,EAAa6B,WAAWjB,KAAKV,KAAMU,KAAKT,QAASS,KAAKJ,QACtD4D,CAAI,uDAAuDxD,KAAKV,YACtE,YClLcmE,EACdnE,EACAC,EACA2B,GAEA9B,EAAaC,QAAQC,EAAMC,EAAS2B,EACtC,eD8BkBgB,EAAAwB,OAAyBC,CAAG,q5BA+CKC,EAAA,CAAhCC,EAAM,UAAkD3B,EAAA4B,UAAA,gBAI7DF,EAAA,CAAXG,KAA6B7B,EAAA4B,UAAA,eAMDF,EAAA,CAA5BG,EAAS,CAAEC,SAAS,KAA0C9B,EAAA4B,UAAA,eAAA,GAMnBF,EAAA,CAA3CG,EAAS,CAAEE,KAAMC,QAASF,SAAS,KAAuB9B,EAAA4B,UAAA,cAAA,GAM/CF,EAAA,CAAXG,KAAuC7B,EAAA4B,UAAA,gBAMZF,EAAA,CAA3BG,EAAS,CAAEE,KAAME,UAAmCjC,EAAA4B,UAAA,cAAA,GAMEF,EAAA,CAAtDG,EAAS,CAAEK,UAAW,eAAgBH,KAAME,UAA2BjC,EAAA4B,UAAA,mBAAA,GAnF7D5B,EAAc0B,EAAA,CAD1BS,EAAc,aACFnC"}
1
+ {"version":3,"file":"icon.min.js","sources":["../../src/icon/IconRegistry.ts","../../src/icon/IconElement.ts","../../src/icon/registerIcon.ts"],"sourcesContent":["import { svg, SVGTemplateResult } from \"lit\";\r\n\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\n/** @private */ const PATH_DATA_PATTERN = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\\s-]+$/;\r\n/** @private */ const VIEW_BOX_PATTERN = /^-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?\\s+-?\\d+(\\.\\d+)?$/;\r\n\r\n/** Encapsulates information used to construct an SVG. */\r\nexport type SvgIconInfo = {\r\n /** The viewbox of the SVG. */\r\n viewBox: string;\r\n\r\n /** The path of the SVG. */\r\n path: string;\r\n};\r\n\r\n/** Represents the fill-axis SVG data for a single icon. */\r\nexport type SvgIconFillSet = {\r\n /** The unfilled (FILL=0) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n outlined: SvgIconInfo | string;\r\n\r\n /** The filled (FILL=1) SVG representation (or path assuming viewBox=\"0 -960 960 960\") of the icon. */\r\n filled: SvgIconInfo | string;\r\n};\r\n\r\n/**\r\n * Service to register and display icons used by the `m3e-icon` component.\r\n * @internal\r\n */\r\nexport class IconRegistry {\r\n /** @private */\r\n static readonly #icons = new Map<string, { outlined: SVGTemplateResult; filled: SVGTemplateResult }>();\r\n\r\n /** @private */ static readonly #observers = new Map<string, Array<() => void>>();\r\n\r\n /**\r\n * Adds an icon to the registry for the given variant and weight.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {SvgIconFillSet} fillSet The SVG data for both fill states (outlined and filled) of the icon.\r\n */\r\n static addIcon(name: string, variant: IconVariant, fillSet: SvgIconFillSet): void {\r\n const trustOutlinedViewBox = typeof fillSet.outlined === \"string\";\r\n const trustFilledViewBox = typeof fillSet.filled === \"string\";\r\n\r\n if (typeof fillSet.outlined === \"string\") {\r\n fillSet.outlined = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.outlined,\r\n };\r\n }\r\n if (typeof fillSet.filled === \"string\") {\r\n fillSet.filled = {\r\n viewBox: \"0 -960 960 960\",\r\n path: fillSet.filled,\r\n };\r\n }\r\n\r\n this.#validateSvgIconInfo(name, variant, fillSet.outlined, trustOutlinedViewBox);\r\n this.#validateSvgIconInfo(name, variant, fillSet.filled, trustFilledViewBox);\r\n\r\n if (typeof window === \"undefined\") return;\r\n\r\n const key = this.#createKey(name, variant);\r\n this.#icons.set(key, {\r\n outlined: svg`<svg viewBox=\"${fillSet.outlined.viewBox}\"><path d=\"${fillSet.outlined.path}\"/></svg>`,\r\n filled: svg`<svg viewBox=\"${fillSet.filled.viewBox}\"><path d=\"${fillSet.filled.path}\"/></svg>`,\r\n });\r\n\r\n this.#observers.get(key)?.forEach((x) => x());\r\n }\r\n\r\n /**\r\n * Determines whether an icon is registered for the given variant.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @returns {boolean} Whether `icon` is registered for the given `variant`.\r\n */\r\n static isIconRegistered(name: string, variant: IconVariant): boolean {\r\n return window !== undefined && this.#icons.has(this.#createKey(name, variant));\r\n }\r\n\r\n /**\r\n * Renders an icon from the registry.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param {boolean} filled Whether to render a filled variant of the icon.\r\n * @returns {SVGTemplateResult | undefined} A `SVGTemplateResult` used to render the icon.\r\n */\r\n static renderIcon(name: string, variant: IconVariant, filled: boolean): SVGTemplateResult | undefined {\r\n const data = this.#icons.get(this.#createKey(name, variant));\r\n return filled ? data?.filled : data?.outlined;\r\n }\r\n\r\n /**\r\n * Begins observing registration for the specified icon.\r\n * @param {string} name The name of the icon to observe.\r\n * @param {IconVariant} variant The variant of the icon to observe.\r\n * @param {() => void} callback Callback invoked when the specified icon is registered for the given variant.\r\n * @returns {() => void} Function used to stop observing.\r\n */\r\n static observe(name: string, variant: IconVariant, callback: () => void): () => void {\r\n if (window === undefined) return () => {};\r\n\r\n const key = this.#createKey(name, variant);\r\n if (!this.#observers.has(key)) {\r\n this.#observers.set(key, [callback]);\r\n } else {\r\n this.#observers.get(key)?.push(callback);\r\n }\r\n\r\n return () => {\r\n const callbacks = this.#observers.get(key);\r\n if (callbacks) {\r\n const index = callbacks.indexOf(callback);\r\n if (index >= 0) {\r\n callbacks.splice(index, 1);\r\n }\r\n if (callbacks.length == 0) {\r\n this.#observers.delete(key);\r\n }\r\n }\r\n };\r\n }\r\n\r\n /** @private */\r\n static #createKey(name: string, variant: IconVariant): string {\r\n return `${variant}-${name}`;\r\n }\r\n\r\n /** @private */\r\n static #validateSvgIconInfo(name: string, variant: IconVariant, info: SvgIconInfo, trustViewBox = false): void {\r\n if (!trustViewBox && !VIEW_BOX_PATTERN.test(info.viewBox)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid viewbox data.`);\r\n }\r\n if (!PATH_DATA_PATTERN.test(info.path)) {\r\n throw new Error(`Unable to register icon '${name}' for variant '${variant}'. Invalid path data.`);\r\n }\r\n }\r\n}\r\n","import { css, CSSResultGroup, html, LitElement, PropertyValues } from \"lit\";\r\nimport { property, query } from \"lit/decorators.js\";\r\n\r\nimport { customElement, Role } from \"@m3e/web/core\";\r\n\r\nimport { IconRegistry } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\nimport { IconGrade } from \"./IconGrade\";\r\nimport { IconWeight } from \"./IconWeight\";\r\n\r\n/**\r\n * A small symbol used to easily identify an action or category.\r\n *\r\n * @description\r\n * The `m3e-icon` component makes it easier to use Material Symbols in your application. Material Symbols are Google's newest icons supporting\r\n * a range of design variants. For more information, see:\r\n * - {@link https://developers.google.com/fonts/docs/material_symbols|Material Symbol Guide}\r\n * - {@link https://fonts.google.com/icons|Material Symbol Library}\r\n *\r\n * The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the\r\n * {@link https://developers.google.com/fonts/docs/css2#forming_api_urls|Fonts CSS API}, you can use variable fonts to optimize icon\r\n * usage within your application. See {@link https://caniuse.com/variable-fonts|Can I Use's Variable Fonts} to determine whether\r\n * your user's browser support variable fonts.\r\n *\r\n * @example\r\n * The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.\r\n * ```html\r\n * <m3e-icon name=\"home\"></m3e-icon>\r\n * ```\r\n * @example\r\n * The next example illustrates a link used to download a variable font for outlined icons with fill support.\r\n * ```html\r\n * <link href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0\" rel=\"stylesheet\"/>\r\n * ```\r\n *\r\n * @tag m3e-icon\r\n *\r\n * @attr filled - Whether the icon is filled.\r\n * @attr grade - The grade of the icon.\r\n * @attr optical-size - A value from 20 to 48 indicating the optical size of the icon.\r\n * @attr name - The name of the icon.\r\n * @attr variant - The appearance variant of the icon.\r\n * @attr weight - A value from 100 to 700 indicating the weight of the icon.\r\n */\r\n@customElement(\"m3e-icon\")\r\nexport class M3eIconElement extends Role(LitElement, \"img\") {\r\n /** The styles of the element. */\r\n static override styles: CSSResultGroup = css`\r\n :host {\r\n display: inline-block;\r\n user-select: none;\r\n font-size: var(--m3e-icon-size, 1.5rem);\r\n width: 1em;\r\n height: 1em;\r\n vertical-align: middle;\r\n overflow: hidden;\r\n }\r\n .icon {\r\n font-weight: normal;\r\n font-style: normal;\r\n line-height: 1;\r\n letter-spacing: normal;\r\n text-transform: none;\r\n white-space: nowrap;\r\n word-wrap: normal;\r\n direction: ltr;\r\n font-feature-settings: \"liga\";\r\n -webkit-font-smoothing: antialiased;\r\n width: inherit;\r\n height: inherit;\r\n vertical-align: inherit;\r\n font-variation-settings:\r\n \"FILL\" var(--_icon-fill, 0),\r\n \"wght\" var(--_icon-weight, 400),\r\n \"GRAD\" var(--_icon-grade, 0),\r\n \"opsz\" var(--_icon-optical-size, 24);\r\n }\r\n :host([variant=\"outlined\"]) .icon {\r\n font-family: \"Material Symbols Outlined\";\r\n }\r\n :host([variant=\"rounded\"]) .icon {\r\n font-family: \"Material Symbols Rounded\";\r\n }\r\n :host([variant=\"sharp\"]) .icon {\r\n font-family: \"Material Symbols Sharp\";\r\n }\r\n svg {\r\n fill: currentColor;\r\n font-size: inherit;\r\n width: 1em;\r\n height: 1em;\r\n }\r\n `;\r\n\r\n /** @private */ @query(\".icon\") private readonly _icon?: HTMLSpanElement;\r\n /** @private */ #iconRegistryUnobserve?: () => void;\r\n\r\n /** The name of the icon. */\r\n @property() name: string = \"\";\r\n\r\n /**\r\n * The appearance variant of the icon.\r\n * @default \"outlined\"\r\n */\r\n @property({ reflect: true }) variant: IconVariant = \"outlined\";\r\n\r\n /**\r\n * Whether the icon is filled.\r\n * @default false\r\n */\r\n @property({ type: Boolean, reflect: true }) filled = false;\r\n\r\n /**\r\n * The grade of the icon.\r\n * @default \"medium\"\r\n */\r\n @property() grade: IconGrade = \"medium\";\r\n\r\n /**\r\n * A value from 100 to 700 indicating the weight of the icon.\r\n * @default 400\r\n */\r\n @property({ type: Number }) weight: IconWeight = 400;\r\n\r\n /**\r\n * A value from 20 to 48 indicating the optical size of the icon.\r\n * @default 24\r\n */\r\n @property({ attribute: \"optical-size\", type: Number }) opticalSize = 24;\r\n\r\n /** @inheritdoc */\r\n override connectedCallback(): void {\r\n if (\r\n !this.hasAttribute(\"aria-label\") &&\r\n !this.hasAttribute(\"aria-labelledby\") &&\r\n !this.hasAttribute(\"aria-hidden\")\r\n ) {\r\n this.ariaHidden = \"true\";\r\n }\r\n\r\n super.connectedCallback();\r\n }\r\n\r\n /** @inheritdoc */\r\n override disconnectedCallback(): void {\r\n super.disconnectedCallback();\r\n\r\n this.#iconRegistryUnobserve?.();\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override willUpdate(_changedProperties: PropertyValues<this>): void {\r\n super.willUpdate(_changedProperties);\r\n\r\n if (_changedProperties.has(\"name\") && !IconRegistry.isIconRegistered(this.name, this.variant)) {\r\n this.#iconRegistryUnobserve = IconRegistry.observe(this.name, this.variant, () => {\r\n this.requestUpdate();\r\n this.#iconRegistryUnobserve?.();\r\n this.#iconRegistryUnobserve = undefined;\r\n });\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override updated(_changedProperties: PropertyValues<this>): void {\r\n super.updated(_changedProperties);\r\n\r\n if (_changedProperties.has(\"filled\")) {\r\n this._icon?.style.setProperty(\"--_icon-fill\", this.filled ? \"1\" : \"0\");\r\n }\r\n if (_changedProperties.has(\"grade\")) {\r\n this._icon?.style.setProperty(\r\n \"--_icon-grade\",\r\n this.grade === \"low\" ? \"-25\" : this.grade === \"high\" ? \"200\" : \"0\",\r\n );\r\n }\r\n if (_changedProperties.has(\"weight\")) {\r\n this._icon?.style.setProperty(\"--_icon-weight\", `${this.weight}`);\r\n }\r\n if (_changedProperties.has(\"opticalSize\")) {\r\n this._icon?.style.setProperty(\"--_icon-optical-size\", `${this.opticalSize}`);\r\n }\r\n }\r\n\r\n /** @inheritdoc */\r\n protected override render(): unknown {\r\n return IconRegistry.isIconRegistered(this.name, this.variant)\r\n ? IconRegistry.renderIcon(this.name, this.variant, this.filled)\r\n : html`<div class=\"icon\" aria-hidden=\"true\" translate=\"no\">${this.name}</div>`;\r\n }\r\n}\r\n\r\ndeclare global {\r\n interface HTMLElementTagNameMap {\r\n \"m3e-icon\": M3eIconElement;\r\n }\r\n}\r\n","import { IconRegistry, SvgIconInfo } from \"./IconRegistry\";\r\nimport { IconVariant } from \"./IconVariant\";\r\n\r\nexport type { SvgIconInfo } from \"./IconRegistry\";\r\n\r\n/**\r\n * Registers an SVG icon to the internal icon registry used by `m3e-icon`.\r\n * @param {string} name The name of the icon.\r\n * @param {IconVariant} variant The variant of the icon.\r\n * @param data The outlined and filled SVG information of the icon.\r\n */\r\nexport function registerIcon(\r\n name: string,\r\n variant: IconVariant,\r\n data: { outlined: SvgIconInfo; filled: SvgIconInfo },\r\n): void {\r\n IconRegistry.addIcon(name, variant, data);\r\n}\r\n"],"names":["PATH_DATA_PATTERN","VIEW_BOX_PATTERN","IconRegistry","addIcon","name","variant","fillSet","trustOutlinedViewBox","outlined","trustFilledViewBox","filled","viewBox","path","__classPrivateFieldGet","this","_a","_IconRegistry_validateSvgIconInfo","call","window","key","_IconRegistry_createKey","_IconRegistry_icons","set","svg","_IconRegistry_observers","get","forEach","x","isIconRegistered","undefined","has","renderIcon","data","observe","callback","push","callbacks","index","indexOf","splice","length","delete","info","trustViewBox","test","Error","value","Map","M3eIconElement","Role","LitElement","constructor","_M3eIconElement_iconRegistryUnobserve","grade","weight","opticalSize","connectedCallback","hasAttribute","ariaHidden","super","disconnectedCallback","willUpdate","_changedProperties","__classPrivateFieldSet","requestUpdate","updated","_icon","style","setProperty","render","html","registerIcon","styles","css","__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AEA9B,EAAaC,QAAQC,EAAMC,EAAS2B,EACtC,eD8BkBgB,EAAAwB,OAAyBC,CAAG,q5BA+CKC,EAAA,CAAhCC,EAAM,UAAkD3B,EAAA4B,UAAA,gBAI7DF,EAAA,CAAXG,KAA6B7B,EAAA4B,UAAA,eAMDF,EAAA,CAA5BG,EAAS,CAAEC,SAAS,KAA0C9B,EAAA4B,UAAA,eAAA,GAMnBF,EAAA,CAA3CG,EAAS,CAAEE,KAAMC,QAASF,SAAS,KAAuB9B,EAAA4B,UAAA,cAAA,GAM/CF,EAAA,CAAXG,KAAuC7B,EAAA4B,UAAA,gBAMZF,EAAA,CAA3BG,EAAS,CAAEE,KAAME,UAAmCjC,EAAA4B,UAAA,cAAA,GAMEF,EAAA,CAAtDG,EAAS,CAAEK,UAAW,eAAgBH,KAAME,UAA2BjC,EAAA4B,UAAA,mBAAA,GAnF7D5B,EAAc0B,EAAA,CAD1BS,EAAc,aACFnC"}
package/dist/menu.js CHANGED
@@ -355,7 +355,7 @@ _M3eMenuItemElement_handleMouseEnter = function _M3eMenuItemElement_handleMouseE
355
355
  __decorate([state()], M3eMenuItemElement.prototype, "_hasSubmenu", void 0);
356
356
  M3eMenuItemElement = M3eMenuItemElement_1 = __decorate([customElement("m3e-menu-item")], M3eMenuItemElement);
357
357
 
358
- var _M3eMenuElement_instances, _M3eMenuElement_trigger, _M3eMenuElement_anchorCleanup, _M3eMenuElement_listManager, _M3eMenuElement_keyDownHandler, _M3eMenuElement_mouseEnterHandler, _M3eMenuElement_scrollController, _M3eMenuElement_clickOutsideController, _M3eMenuElement_toggleHandler, _M3eMenuElement_handleSlotChange, _M3eMenuElement_handleKeyDown, _M3eMenuElement_handleMouseEnter, _M3eMenuElement_getAbsolutePosition, _M3eMenuElement_deactivate;
358
+ var _M3eMenuElement_instances, _M3eMenuElement_trigger, _M3eMenuElement_anchorCleanup, _M3eMenuElement_anchorLastPosition, _M3eMenuElement_listManager, _M3eMenuElement_keyDownHandler, _M3eMenuElement_mouseEnterHandler, _M3eMenuElement_scrollController, _M3eMenuElement_clickOutsideController, _M3eMenuElement_toggleHandler, _M3eMenuElement_handleSlotChange, _M3eMenuElement_handleKeyDown, _M3eMenuElement_handleMouseEnter, _M3eMenuElement_getAbsolutePosition, _M3eMenuElement_deactivate;
359
359
  var M3eMenuElement_1;
360
360
  /**
361
361
  * Presents a list of choices on a temporary surface.
@@ -443,6 +443,8 @@ let M3eMenuElement = M3eMenuElement_1 = class M3eMenuElement extends SuppressIni
443
443
  /** @private */
444
444
  _M3eMenuElement_anchorCleanup.set(this, void 0);
445
445
  /** @private */
446
+ _M3eMenuElement_anchorLastPosition.set(this, void 0);
447
+ /** @private */
446
448
  _M3eMenuElement_listManager.set(this, new RovingTabIndexManager().withWrap().withHomeAndEnd().withVerticalOrientation());
447
449
  /** @private */
448
450
  _M3eMenuElement_keyDownHandler.set(this, e => __classPrivateFieldGet(this, _M3eMenuElement_instances, "m", _M3eMenuElement_handleKeyDown).call(this, e));
@@ -477,6 +479,7 @@ let M3eMenuElement = M3eMenuElement_1 = class M3eMenuElement extends SuppressIni
477
479
  __classPrivateFieldGet(this, _M3eMenuElement_clickOutsideController, "f").unobserveAll();
478
480
  __classPrivateFieldGet(this, _M3eMenuElement_anchorCleanup, "f")?.call(this);
479
481
  __classPrivateFieldSet(this, _M3eMenuElement_anchorCleanup, undefined, "f");
482
+ __classPrivateFieldSet(this, _M3eMenuElement_anchorLastPosition, undefined, "f");
480
483
  break;
481
484
  }
482
485
  });
@@ -552,12 +555,21 @@ let M3eMenuElement = M3eMenuElement_1 = class M3eMenuElement extends SuppressIni
552
555
  setCustomState(this, "--shift-up", false);
553
556
  setCustomState(this, Math.round(y) === Math.round(top) ? "--shift-down" : "--shift-up", true);
554
557
  }
555
- if (M3eDirectionality.current === "rtl") {
556
- this.style.right = `${window.innerWidth - x - this.clientWidth}px`;
557
- } else {
558
- this.style.left = `${x}px`;
558
+ if (__classPrivateFieldGet(this, _M3eMenuElement_anchorLastPosition, "f")?.dir !== M3eDirectionality.current || __classPrivateFieldGet(this, _M3eMenuElement_anchorLastPosition, "f")?.x !== x) {
559
+ if (M3eDirectionality.current === "rtl") {
560
+ this.style.right = `${window.innerWidth - x - this.clientWidth}px`;
561
+ } else {
562
+ this.style.left = `${x}px`;
563
+ }
564
+ }
565
+ if (__classPrivateFieldGet(this, _M3eMenuElement_anchorLastPosition, "f")?.y !== y) {
566
+ this.style.top = `${y}px`;
559
567
  }
560
- this.style.top = `${y}px`;
568
+ __classPrivateFieldSet(this, _M3eMenuElement_anchorLastPosition, {
569
+ x,
570
+ y,
571
+ dir: M3eDirectionality.current
572
+ }, "f");
561
573
  }), "f");
562
574
  const parent = trigger.closest("m3e-menu");
563
575
  if (parent) {
@@ -637,6 +649,7 @@ let M3eMenuElement = M3eMenuElement_1 = class M3eMenuElement extends SuppressIni
637
649
  };
638
650
  _M3eMenuElement_trigger = new WeakMap();
639
651
  _M3eMenuElement_anchorCleanup = new WeakMap();
652
+ _M3eMenuElement_anchorLastPosition = new WeakMap();
640
653
  _M3eMenuElement_listManager = new WeakMap();
641
654
  _M3eMenuElement_keyDownHandler = new WeakMap();
642
655
  _M3eMenuElement_mouseEnterHandler = new WeakMap();
@@ -714,7 +727,7 @@ _M3eMenuElement_deactivate = function _M3eMenuElement_deactivate() {
714
727
  registerStyleSheet(css`m3e-menu > m3e-divider { margin-block: var(--m3e-menu-divider-spacing, 0.5rem); }`);
715
728
  })();
716
729
  /** The styles of the element. */
717
- M3eMenuElement.styles = css`:host { position: absolute; padding: unset; margin: unset; border: unset; overflow-y: auto; overflow-x: visible; scrollbar-width: ${DesignToken.scrollbar.thinWidth}; scrollbar-color: ${DesignToken.scrollbar.color}; scroll-padding-block: calc( var(--m3e-focus-ring-thickness, 3px) + var(--m3e-menu-container-padding-block, 0.25rem) ); min-width: var(--m3e-menu-container-min-width, 7rem); max-width: var(--m3e-menu-container-max-width, 17.5rem); max-height: var(--m3e-menu-container-max-height, 17.5rem); box-shadow: var(--m3e-menu-container-elevation, ${DesignToken.elevation.level3}); opacity: 0; display: none; } .base { display: flex; flex-direction: column; row-gap: var(--m3e-menu-gap, 0.125rem); min-width: inherit; max-width: inherit; padding-block: var(--m3e-menu-container-padding-block, 0.25rem); padding-inline: var(--m3e-menu-container-padding-inline, 0.25rem); --m3e-focus-ring-outward-offset: 0px; --m3e-focus-ring-growth-factor: 1.5; } :host(:not(:is(:state(--active), :--active))) { border-radius: var(--m3e-menu-container-shape, ${DesignToken.shape.corner.small}); } :host(:not(:is(:state(--active), :--active))) .base { --m3e-menu-item-first-child-shape: ${DesignToken.shape.corner.extraSmall}; --m3e-menu-item-last-child-shape: ${DesignToken.shape.corner.extraSmall}; } :host(:is(:state(--active), :--active)) { border-radius: var(--m3e-menu-active-container-shape, ${DesignToken.shape.corner.large}); } :host(:not(:is(:state(--no-animate), :--no-animate))) { transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
730
+ M3eMenuElement.styles = css`:host { position: absolute; padding: unset; margin: unset; border: unset; overflow-y: auto; overflow-x: visible; scrollbar-width: ${DesignToken.scrollbar.thinWidth}; scrollbar-color: ${DesignToken.scrollbar.color}; scroll-padding-block: calc( var(--m3e-focus-ring-thickness, 3px) + var(--m3e-menu-container-padding-block, 0.25rem) ); min-width: var(--m3e-menu-container-min-width, 7rem); max-width: var(--m3e-menu-container-max-width, 17.5rem); max-height: var(--m3e-menu-container-max-height, 17.5rem); box-shadow: var(--m3e-menu-container-elevation, ${DesignToken.elevation.level3}); opacity: 0; display: none; } .base { contain: layout style paint; display: flex; flex-direction: column; row-gap: var(--m3e-menu-gap, 0.125rem); min-width: inherit; max-width: inherit; padding-block: var(--m3e-menu-container-padding-block, 0.25rem); padding-inline: var(--m3e-menu-container-padding-inline, 0.25rem); --m3e-focus-ring-outward-offset: 0px; --m3e-focus-ring-growth-factor: 1.5; } :host(:not(:is(:state(--active), :--active))) { border-radius: var(--m3e-menu-container-shape, ${DesignToken.shape.corner.small}); } :host(:not(:is(:state(--active), :--active))) .base { --m3e-menu-item-first-child-shape: ${DesignToken.shape.corner.extraSmall}; --m3e-menu-item-last-child-shape: ${DesignToken.shape.corner.extraSmall}; } :host(:is(:state(--active), :--active)) { border-radius: var(--m3e-menu-active-container-shape, ${DesignToken.shape.corner.large}); } :host(:not(:is(:state(--no-animate), :--no-animate))) { transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
718
731
  transform ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
719
732
  overlay ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete,
720
733
  display ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete,