@m3e/web 2.5.3 → 2.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.js +394 -348
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +56 -56
- package/dist/all.min.js.map +1 -1
- package/dist/autocomplete.js +14 -14
- package/dist/autocomplete.js.map +1 -1
- package/dist/autocomplete.min.js +1 -1
- package/dist/autocomplete.min.js.map +1 -1
- package/dist/bottom-sheet.js +11 -14
- package/dist/bottom-sheet.js.map +1 -1
- package/dist/bottom-sheet.min.js +1 -1
- package/dist/bottom-sheet.min.js.map +1 -1
- package/dist/breadcrumb.js +4 -4
- package/dist/breadcrumb.js.map +1 -1
- package/dist/breadcrumb.min.js +1 -1
- package/dist/breadcrumb.min.js.map +1 -1
- package/dist/button-group.js +5 -5
- package/dist/button-group.js.map +1 -1
- package/dist/button-group.min.js +1 -1
- package/dist/button-group.min.js.map +1 -1
- package/dist/button.js +15 -15
- package/dist/button.js.map +1 -1
- package/dist/button.min.js +1 -1
- package/dist/button.min.js.map +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.js.map +1 -1
- package/dist/checkbox.min.js +1 -1
- package/dist/checkbox.min.js.map +1 -1
- package/dist/chips.js +11 -11
- package/dist/chips.js.map +1 -1
- package/dist/chips.min.js +1 -1
- package/dist/chips.min.js.map +1 -1
- package/dist/core-a11y.js +5 -3
- package/dist/core-a11y.js.map +1 -1
- package/dist/core-a11y.min.js +4 -4
- package/dist/core-a11y.min.js.map +1 -1
- package/dist/core-anchoring.js +4 -4
- package/dist/core-anchoring.js.map +1 -1
- package/dist/core-anchoring.min.js +1 -1
- package/dist/core-anchoring.min.js.map +1 -1
- package/dist/core.js +78 -64
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +200 -185
- package/dist/custom-elements.json +1598 -1524
- package/dist/datepicker.js +12 -12
- package/dist/datepicker.js.map +1 -1
- package/dist/datepicker.min.js +1 -1
- package/dist/datepicker.min.js.map +1 -1
- package/dist/dialog.js +4 -4
- package/dist/dialog.js.map +1 -1
- package/dist/dialog.min.js +1 -1
- package/dist/dialog.min.js.map +1 -1
- package/dist/drawer-container.js +14 -14
- package/dist/drawer-container.js.map +1 -1
- package/dist/drawer-container.min.js +1 -1
- package/dist/drawer-container.min.js.map +1 -1
- package/dist/expansion-panel.js +4 -4
- package/dist/expansion-panel.js.map +1 -1
- package/dist/expansion-panel.min.js +1 -1
- package/dist/expansion-panel.min.js.map +1 -1
- package/dist/fab-menu.js +4 -4
- package/dist/fab-menu.js.map +1 -1
- package/dist/fab-menu.min.js +1 -1
- package/dist/fab-menu.min.js.map +1 -1
- package/dist/fab.js +2 -2
- package/dist/fab.js.map +1 -1
- package/dist/fab.min.js +1 -1
- package/dist/fab.min.js.map +1 -1
- package/dist/form-field.js +19 -19
- package/dist/form-field.js.map +1 -1
- package/dist/form-field.min.js +2 -2
- package/dist/form-field.min.js.map +1 -1
- package/dist/html-custom-data.json +54 -44
- package/dist/icon-button.js +15 -15
- package/dist/icon-button.js.map +1 -1
- package/dist/icon-button.min.js +1 -1
- package/dist/icon-button.min.js.map +1 -1
- package/dist/icon.js +1 -1
- package/dist/icon.js.map +1 -1
- package/dist/icon.min.js +1 -1
- package/dist/icon.min.js.map +1 -1
- package/dist/list.js +16 -16
- package/dist/list.js.map +1 -1
- package/dist/list.min.js +1 -1
- package/dist/list.min.js.map +1 -1
- package/dist/menu.js +20 -20
- package/dist/menu.js.map +1 -1
- package/dist/menu.min.js +1 -1
- package/dist/menu.min.js.map +1 -1
- package/dist/nav-bar.js +40 -10
- package/dist/nav-bar.js.map +1 -1
- package/dist/nav-bar.min.js +1 -1
- package/dist/nav-bar.min.js.map +1 -1
- package/dist/nav-menu.js +10 -10
- package/dist/nav-menu.js.map +1 -1
- package/dist/nav-menu.min.js +1 -1
- package/dist/nav-menu.min.js.map +1 -1
- package/dist/nav-rail.js +15 -11
- package/dist/nav-rail.js.map +1 -1
- package/dist/nav-rail.min.js +1 -1
- package/dist/nav-rail.min.js.map +1 -1
- package/dist/option.js +13 -13
- package/dist/option.js.map +1 -1
- package/dist/option.min.js +1 -1
- package/dist/option.min.js.map +1 -1
- package/dist/paginator.js +2 -2
- package/dist/paginator.js.map +1 -1
- package/dist/paginator.min.js +2 -2
- package/dist/paginator.min.js.map +1 -1
- package/dist/radio-group.js +2 -2
- package/dist/radio-group.js.map +1 -1
- package/dist/radio-group.min.js +1 -1
- package/dist/radio-group.min.js.map +1 -1
- package/dist/search.js +15 -15
- package/dist/search.js.map +1 -1
- package/dist/search.min.js +1 -1
- package/dist/search.min.js.map +1 -1
- package/dist/segmented-button.js +7 -7
- package/dist/segmented-button.js.map +1 -1
- package/dist/segmented-button.min.js +1 -1
- package/dist/segmented-button.min.js.map +1 -1
- package/dist/select.js +6 -6
- package/dist/select.js.map +1 -1
- package/dist/select.min.js +1 -1
- package/dist/select.min.js.map +1 -1
- package/dist/slider.js +5 -5
- package/dist/slider.js.map +1 -1
- package/dist/slider.min.js +1 -1
- package/dist/slider.min.js.map +1 -1
- package/dist/split-pane.js +10 -10
- package/dist/split-pane.js.map +1 -1
- package/dist/split-pane.min.js +1 -1
- package/dist/split-pane.min.js.map +1 -1
- package/dist/src/autocomplete/AutocompleteElement.d.ts.map +1 -1
- package/dist/src/bottom-sheet/BottomSheetElement.d.ts +1 -1
- package/dist/src/bottom-sheet/BottomSheetElement.d.ts.map +1 -1
- package/dist/src/button/styles/ButtonSizeStyle.d.ts.map +1 -1
- package/dist/src/button/styles/ButtonStyle.d.ts.map +1 -1
- package/dist/src/button/styles/ButtonVariantStyle.d.ts.map +1 -1
- package/dist/src/button-group/ButtonGroupElement.d.ts.map +1 -1
- package/dist/src/checkbox/CheckboxElement.d.ts.map +1 -1
- package/dist/src/chips/InputChipElement.d.ts.map +1 -1
- package/dist/src/core/a11y/InteractivityChecker.d.ts +2 -1
- package/dist/src/core/a11y/InteractivityChecker.d.ts.map +1 -1
- package/dist/src/core/anchoring/FloatingPanelElement.d.ts +1 -1
- package/dist/src/core/shared/mixins/SuppressInitialAnimation.d.ts +9 -2
- package/dist/src/core/shared/mixins/SuppressInitialAnimation.d.ts.map +1 -1
- package/dist/src/core/shared/mixins/index.d.ts +0 -1
- package/dist/src/core/shared/mixins/index.d.ts.map +1 -1
- package/dist/src/core/shared/primitives/CollapsibleElement.d.ts +13 -0
- package/dist/src/core/shared/primitives/CollapsibleElement.d.ts.map +1 -1
- package/dist/src/core/shared/primitives/CollapsibleOrientation.d.ts +3 -0
- package/dist/src/core/shared/primitives/CollapsibleOrientation.d.ts.map +1 -0
- package/dist/src/core/shared/primitives/index.d.ts +1 -0
- package/dist/src/core/shared/primitives/index.d.ts.map +1 -1
- package/dist/src/datepicker/DatepickerElement.d.ts +1 -1
- package/dist/src/dialog/DialogElement.d.ts.map +1 -1
- package/dist/src/drawer-container/styles/DrawerContainerStyle.d.ts.map +1 -1
- package/dist/src/expansion-panel/ExpansionPanelElement.d.ts.map +1 -1
- package/dist/src/fab/FabElement.d.ts.map +1 -1
- package/dist/src/fab/styles/FabStyle.d.ts.map +1 -1
- package/dist/src/fab-menu/FabMenuElement.d.ts +1 -1
- package/dist/src/form-field/FormFieldElement.d.ts.map +1 -1
- package/dist/src/icon/IconElement.d.ts.map +1 -1
- package/dist/src/icon-button/styles/IconButtonSizeStyle.d.ts.map +1 -1
- package/dist/src/icon-button/styles/IconButtonStyle.d.ts.map +1 -1
- package/dist/src/icon-button/styles/IconButtonVariantStyle.d.ts.map +1 -1
- package/dist/src/menu/MenuElement.d.ts +1 -1
- package/dist/src/nav-bar/NavItemElement.d.ts +7 -1
- package/dist/src/nav-bar/NavItemElement.d.ts.map +1 -1
- package/dist/src/nav-menu/NavMenuItemElement.d.ts.map +1 -1
- package/dist/src/nav-rail/NavRailElement.d.ts +10 -5
- package/dist/src/nav-rail/NavRailElement.d.ts.map +1 -1
- package/dist/src/paginator/PaginatorElement.d.ts.map +1 -1
- package/dist/src/search/SearchBarElement.d.ts.map +1 -1
- package/dist/src/search/SearchViewElement.d.ts.map +1 -1
- package/dist/src/search/styles/SearchBarStyle.d.ts.map +1 -1
- package/dist/src/split-pane/SplitPaneElement.d.ts.map +1 -1
- package/dist/src/stepper/StepperElement.d.ts.map +1 -1
- package/dist/src/toolbar/ToolbarElement.d.ts.map +1 -1
- package/dist/src/tree/TreeItemElement.d.ts.map +1 -1
- package/dist/stepper.js +6 -6
- package/dist/stepper.js.map +1 -1
- package/dist/stepper.min.js +1 -1
- package/dist/stepper.min.js.map +1 -1
- package/dist/tabs.js +5 -5
- package/dist/tabs.js.map +1 -1
- package/dist/tabs.min.js +1 -1
- package/dist/tabs.min.js.map +1 -1
- package/dist/toc.js +7 -7
- package/dist/toc.js.map +1 -1
- package/dist/toc.min.js +1 -1
- package/dist/toc.min.js.map +1 -1
- package/dist/toolbar.js +2 -1
- package/dist/toolbar.js.map +1 -1
- package/dist/toolbar.min.js +1 -1
- package/dist/toolbar.min.js.map +1 -1
- package/dist/tooltip.js +3 -3
- package/dist/tooltip.js.map +1 -1
- package/dist/tooltip.min.js +1 -1
- package/dist/tooltip.min.js.map +1 -1
- package/dist/tree.js +9 -9
- package/dist/tree.js.map +1 -1
- package/dist/tree.min.js +1 -1
- package/dist/tree.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/core/shared/mixins/EventAttribute.d.ts +0 -11
- package/dist/src/core/shared/mixins/EventAttribute.d.ts.map +0 -1
package/dist/icon.js
CHANGED
|
@@ -232,7 +232,7 @@ let M3eIconElement = class M3eIconElement extends Role(LitElement, "img") {
|
|
|
232
232
|
};
|
|
233
233
|
_M3eIconElement_iconRegistryUnobserve = new WeakMap();
|
|
234
234
|
/** The styles of the element. */
|
|
235
|
-
M3eIconElement.styles = css`: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 { font-size: inherit; width: 1em; height: 1em; }`;
|
|
235
|
+
M3eIconElement.styles = css`: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; }`;
|
|
236
236
|
__decorate([query(".icon")], M3eIconElement.prototype, "_icon", void 0);
|
|
237
237
|
__decorate([property()], M3eIconElement.prototype, "name", void 0);
|
|
238
238
|
__decorate([property({
|
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 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\">${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,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,QAAQ,EAAE;MACxCF,OAAO,CAACE,QAAQ,GAAG;AACjBG,QAAAA,OAAO,EAAE,gBAAgB;QACzBC,IAAI,EAAEN,OAAO,CAACE;OACf;AACH,IAAA;AACA,IAAA,IAAI,OAAOF,OAAO,CAACI,MAAM,KAAK,QAAQ,EAAE;MACtCJ,OAAO,CAACI,MAAM,GAAG;AACfC,QAAAA,OAAO,EAAE,gBAAgB;QACzBC,IAAI,EAAEN,OAAO,CAACI;OACf;AACH,IAAA;IAEAG,sBAAA,CAAA,IAAI,EAAAC,EAAA,EAAA,GAAA,EAAAC,iCAAA,CAAqB,CAAAC,IAAA,CAAzB,IAAI,EAAsBZ,IAAI,EAAEC,OAAO,EAAEC,OAAO,CAACE,QAAQ,EAAED,oBAAoB,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AA3CG,QAAQ,CAAC;AAAEE,EAAAA,IAAI,EAAEC,OAAO;AAAEF,EAAAA,OAAO,EAAE;AAAI,CAAE,CAAC,CAAgB,EAAA5B,cAAA,CAAA0B,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAM/CF,UAAA,CAAA,CAAXG,QAAQ,EAAE,CAA6B,EAAA3B,cAAA,CAAA0B,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAMZF,UAAA,CAAA,CAA3BG,QAAQ,CAAC;AAAEE,EAAAA,IAAI,EAAEE;CAAQ,CAAC,CAA0B,EAAA/B,cAAA,CAAA0B,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAMEF,UAAA,CAAA,CAAtDG,QAAQ,CAAC;AAAEK,EAAAA,SAAS,EAAE,cAAc;AAAEH,EAAAA,IAAI,EAAEE;AAAM,CAAE,CAAC,CAAkB,EAAA/B,cAAA,CAAA0B,SAAA,EAAA,aAAA,EAAA,MAAA,CAAA;AAlF7D1B,cAAc,GAAAwB,UAAA,CAAA,CAD1BS,aAAa,CAAC,UAAU,CAAC,CACb,EAAAjC,cAAc,CAgJ1B;;ACxLD;;;;;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 (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\">${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,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,QAAQ,EAAE;MACxCF,OAAO,CAACE,QAAQ,GAAG;AACjBG,QAAAA,OAAO,EAAE,gBAAgB;QACzBC,IAAI,EAAEN,OAAO,CAACE;OACf;AACH,IAAA;AACA,IAAA,IAAI,OAAOF,OAAO,CAACI,MAAM,KAAK,QAAQ,EAAE;MACtCJ,OAAO,CAACI,MAAM,GAAG;AACfC,QAAAA,OAAO,EAAE,gBAAgB;QACzBC,IAAI,EAAEN,OAAO,CAACI;OACf;AACH,IAAA;IAEAG,sBAAA,CAAA,IAAI,EAAAC,EAAA,EAAA,GAAA,EAAAC,iCAAA,CAAqB,CAAAC,IAAA,CAAzB,IAAI,EAAsBZ,IAAI,EAAEC,OAAO,EAAEC,OAAO,CAACE,QAAQ,EAAED,oBAAoB,CAAC;IAChFM,sBAAA,CAAA,IAAI,EAAAC,EAAA,EAAA,GAAA,EAAAC,iCAAA,CAAqB,CAAAC,IAAA,CAAzB,IAAI,EAAsBZ,IAAI,EAAEC,OAAO,EAAEC,OAAO,CAACI,MAAM,EAAED,kBAAkB,CA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AA,CAAA,CAAXG,QAAQ,EAAE,CAA6B,EAAA3B,cAAA,CAAA0B,SAAA,EAAA,OAAA,EAAA,MAAA,CAAA;AAMZF,UAAA,CAAA,CAA3BG,QAAQ,CAAC;AAAEE,EAAAA,IAAI,EAAEE;CAAQ,CAAC,CAA0B,EAAA/B,cAAA,CAAA0B,SAAA,EAAA,QAAA,EAAA,MAAA,CAAA;AAMEF,UAAA,CAAA,CAAtDG,QAAQ,CAAC;AAAEK,EAAAA,SAAS,EAAE,cAAc;AAAEH,EAAAA,IAAI,EAAEE;AAAM,CAAE,CAAC,CAAkB,EAAA/B,cAAA,CAAA0B,SAAA,EAAA,aAAA,EAAA,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;;;;"}
|
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,p,
|
|
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">${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
|
package/dist/icon.min.js.map
CHANGED
|
@@ -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 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\">${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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{"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\">${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,EAA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AAOC,MAAMC,YAChB,gBACe,QAAftD,KAAKuC,MAAkB,MAAuB,SAAfvC,KAAKuC,MAAmB,MAAQ,KAG/DS,EAAmBhC,IAAI,WACzBhB,KAAKoD,OAAOC,MAAMC,YAAY,iBAAkB,GAAGtD,KAAKwC,UAEtDQ,EAAmBhC,IAAI,gBACzBhB,KAAKoD,OAAOC,MAAMC,YAAY,uBAAwB,GAAGtD,KAAKyC,cAElE,CAGmBc,MAAAA,GACjB,OAAOnE,EAAa2B,iBAAiBf,KAAKV,KAAMU,KAAKT,SACjDH,EAAa6B,WAAWjB,KAAKV,KAAMU,KAAKT,QAASS,KAAKJ,QACtD4D,CAAI,wCAAwCxD,KAAKV,YACvD,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"}
|
package/dist/list.js
CHANGED
|
@@ -138,7 +138,7 @@ let M3eListItemElement = class M3eListItemElement extends ReconnectedCallback(At
|
|
|
138
138
|
_handleLeadingSlotChange(e) {
|
|
139
139
|
const contentType = __classPrivateFieldGet(this, _M3eListItemElement_leadingContentType, "f");
|
|
140
140
|
__classPrivateFieldSet(this, _M3eListItemElement_leadingContentType, __classPrivateFieldGet(this, _M3eListItemElement_instances, "m", _M3eListItemElement_getSlotContentType).call(this, e.target), "f");
|
|
141
|
-
setCustomState(this, "
|
|
141
|
+
setCustomState(this, "--has-leading", __classPrivateFieldGet(this, _M3eListItemElement_leadingContentType, "f") !== undefined);
|
|
142
142
|
if (contentType !== __classPrivateFieldGet(this, _M3eListItemElement_leadingContentType, "f")) {
|
|
143
143
|
this.closest("m3e-list,m3e-action-list,m3e-selection-list")?.notifyLeadingContentTypeChange(contentType, __classPrivateFieldGet(this, _M3eListItemElement_leadingContentType, "f"));
|
|
144
144
|
}
|
|
@@ -147,7 +147,7 @@ let M3eListItemElement = class M3eListItemElement extends ReconnectedCallback(At
|
|
|
147
147
|
_handleTrailingSlotChange(e) {
|
|
148
148
|
const contentType = __classPrivateFieldGet(this, _M3eListItemElement_trailingContentType, "f");
|
|
149
149
|
__classPrivateFieldSet(this, _M3eListItemElement_trailingContentType, __classPrivateFieldGet(this, _M3eListItemElement_instances, "m", _M3eListItemElement_getSlotContentType).call(this, e.target), "f");
|
|
150
|
-
setCustomState(this, "
|
|
150
|
+
setCustomState(this, "--has-trailing", __classPrivateFieldGet(this, _M3eListItemElement_trailingContentType, "f") !== undefined);
|
|
151
151
|
if (contentType !== __classPrivateFieldGet(this, _M3eListItemElement_trailingContentType, "f")) {
|
|
152
152
|
this.closest("m3e-list,m3e-action-list,m3e-selection-list")?.notifyTrailingContentTypeChange(contentType, __classPrivateFieldGet(this, _M3eListItemElement_trailingContentType, "f"));
|
|
153
153
|
}
|
|
@@ -166,9 +166,9 @@ _M3eListItemElement_initialize = function _M3eListItemElement_initialize() {
|
|
|
166
166
|
_M3eListItemElement_updateMultiline = function _M3eListItemElement_updateMultiline() {
|
|
167
167
|
const content = this.shadowRoot?.querySelector(".content") ?? null;
|
|
168
168
|
const lines = content === null ? 0 : computeLineCount(content);
|
|
169
|
-
setCustomState(this, "
|
|
170
|
-
setCustomState(this, "
|
|
171
|
-
setCustomState(this, "
|
|
169
|
+
setCustomState(this, "--one-line", lines <= 1);
|
|
170
|
+
setCustomState(this, "--two-line", lines == 2);
|
|
171
|
+
setCustomState(this, "--three-line", lines > 2);
|
|
172
172
|
};
|
|
173
173
|
_M3eListItemElement_getSlotContentType = function _M3eListItemElement_getSlotContentType(slot) {
|
|
174
174
|
const elements = slot.assignedElements({
|
|
@@ -181,7 +181,7 @@ _M3eListItemElement_getSlotContentType = function _M3eListItemElement_getSlotCon
|
|
|
181
181
|
return elements.length > 0 ? "text" : undefined;
|
|
182
182
|
};
|
|
183
183
|
/** The styles of the element. */
|
|
184
|
-
M3eListItemElement.styles = css`:host { display: block; } .base { display: flex; min-height: inherit; width: 100%; box-sizing: border-box; column-gap: var(--m3e-list-item-between-space, 1rem); padding-inline-start: var(--m3e-list-item-leading-space, 1rem); padding-inline-end: var(--m3e-list-item-trailing-space, 1rem); border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); transition: ${unsafeCSS(`border-radius ${DesignToken.motion.spring.fastEffects}, background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)}; } :host(:state(-one-line)) { min-height: calc(var(--m3e-list-item-one-line-height, 3.5rem) + ${DesignToken.density.calc(-3)}); } :host(:state(-one-line)) .base { padding-block-start: var(--m3e-list-item-one-line-top-space, 0.5rem); padding-block-end: var(--m3e-list-item-one-line-bottom-space, 0.5rem); } :host(:state(-two-line)) { min-height: calc(var(--m3e-list-item-two-line-height, 4.5rem) + ${DesignToken.density.calc(-3)}); } :host(:state(-two-line)) .base { padding-block-start: var(--m3e-list-item-two-line-top-space, 0.5rem); padding-block-end: var(--m3e-list-item-two-line-bottom-space, 0.5rem); } :host(:state(-three-line)) { min-height: calc(var(--m3e-list-item-three-line-height, 5.5rem) + ${DesignToken.density.calc(-3)}); } :host(:state(-three-line)) .base { padding-block-start: var(--m3e-list-item-three-line-top-space, 0.75rem); padding-block-end: var(--m3e-list-item-three-line-bottom-space, 0.75rem); } :host(:not(:state(-three-line))) .base { align-items: center; } :host(:state(-three-line)) .base { align-items: flex-start; } :host(:not(:disabled):not([selected])) .base:not(.hover).focus-visible:not(.pressed) { border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); } :host(:not(:disabled):not([selected])) .base.hover, :host(:not(:disabled):not([selected])) .base.pressed { border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); } .content { flex: 1 1 auto; display: flex; flex-direction: column; align-items: unset; justify-content: unset; } ::slotted([slot="overline"]) { font-size: var(--m3e-list-item-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-list-item-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-list-item-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-list-item-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking}); } ::slotted([slot="supporting-text"]) { font-size: var(--m3e-list-item-supporting-text-font-size, ${DesignToken.typescale.standard.body.medium.fontSize}); font-weight: var( --m3e-list-item-supporting-text-font-weight, ${DesignToken.typescale.standard.body.medium.fontWeight} ); line-height: var( --m3e-list-item-supporting-text-line-height, ${DesignToken.typescale.standard.body.medium.lineHeight} ); letter-spacing: var( --m3e-list-item-supporting-text-tracking, ${DesignToken.typescale.standard.body.medium.tracking} ); } ::slotted(:not([slot])) { font-size: var(--m3e-list-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize}); font-weight: var(--m3e-list-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight}); line-height: var(--m3e-list-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight}); letter-spacing: var(--m3e-list-item-tracking, ${DesignToken.typescale.standard.body.large.tracking}); } :host(:state(-has-leading)) slot[name="leading"], :host(:state(-has-trailing)) slot[name="trailing"] { display: flex; justify-content: center; } :host(:not(:state(-has-leading))) slot[name="leading"] { display: var(--_list-item-leading-reserved-display, contents); } :host(:not(:state(-has-trailing))) slot[name="trailing"] { display: var(--_list-item-trailing-reserved-display, contents); } slot[name="leading"] { min-width: var(--_list-item-leading-reserved-space, 0px); margin-inline-start: calc(0px - var(--_list-item-leading-reserved-outset, 0px)); } slot[name="trailing"] { min-width: var(--_list-item-trailing-reserved-space, 0px); margin-inline-end: calc(0px - var(--_list-item-trailing-reserved-outset, 0px)); } ::slotted(span[slot="trailing"]), ::slotted([slot="trailing-supporting-text"]) { white-space: nowrap; font-size: var(--m3e-list-item-trailing-text-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var( --m3e-list-item-trailing-text-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight} ); line-height: var( --m3e-list-item-trailing-text-line-height, ${DesignToken.typescale.standard.label.small.lineHeight} ); letter-spacing: var( --m3e-list-item-trailing-text-tracking, ${DesignToken.typescale.standard.label.small.tracking} ); } ::slotted(video[slot="leading"]), ::slotted(video[slot="trailing"]), ::slotted(img[slot="leading"]), ::slotted(img[slot="trailing"]) { display: block; margin: 0 auto; overflow: hidden; object-fit: cover; } ::slotted(video) { width: var(--m3e-list-item-video-width, 6.25rem); height: var(--m3e-list-item-video-height, 3.5rem); } ::slotted(video[slot="leading"]), ::slotted(video[slot="trailing"]) { border-radius: var(--m3e-list-item-video-shape, ${DesignToken.shape.corner.none}); } ::slotted(video[slot="leading"]) { margin-inline-start: calc(0px - var(--_list-item-leading-video-outset, 0px)); } ::slotted(video[slot="trailing"]) { margin-inline-end: calc(0px - var(--_list-item-trailing-video-outset, 0px)); } ::slotted(img) { user-drag: none; user-select: none; pointer-events: none; width: var(--m3e-list-item-image-width, 3.5rem); height: var(--m3e-list-item-image-height, 3.5rem); } ::slotted(img[slot="leading"]), ::slotted(img[slot="trailing"]) { border-radius: var(--m3e-list-item-image-shape, ${DesignToken.shape.corner.none}); } ::slotted(m3e-icon[slot="leading"]), ::slotted(m3e-icon[slot="leading-icon"]), ::slotted(m3e-icon[slot="trailing"]), ::slotted(m3e-icon[slot="trailing-icon"]) { --m3e-icon-size: var(--m3e-list-item-icon-size, 1.5rem); } :host(:not(:disabled)) ::slotted(m3e-icon[slot="leading"]), :host(:not(:disabled)) ::slotted(m3e-icon[slot="leading-icon"]) { color: var(--m3e-list-item-leading-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) .content { color: var(--m3e-list-item-label-text-color, ${DesignToken.color.onSurface}); } :host(:not(:disabled)) ::slotted([slot="overline"]) { color: var(--m3e-list-item-overline-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) ::slotted([slot="supporting-text"]) { color: var(--m3e-list-item-supporting-text-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) ::slotted([slot="trailing"]), :host(:not(:disabled)) ::slotted([slot="trailing-supporting-text"]), :host(:not(:disabled)) ::slotted([slot="trailing-icon"]) { color: var(--m3e-list-item-trailing-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) .base { background-color: var(--_list-item-container-color, var(--m3e-list-item-container-color, transparent)); } :host(:disabled) .base { background-color: var(--m3e-list-item-disabled-container-color, transparent); } :host(:disabled) ::slotted(video), :host(:disabled) ::slotted(img), :host(:disabled) ::slotted(m3e-avatar) { opacity: var(--m3e-list-item-disabled-media-opacity, 38%); } :host(:disabled) .content { color: color-mix( in srgb, var(--m3e-list-item-disabled-label-text-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-label-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="overline"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-overline-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-overline-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="supporting-text"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-supporting-text-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-supporting-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="leading"]), :host(:disabled) ::slotted([slot="leading-icon"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-leading-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-leading-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="trailing"]), :host(:disabled) ::slotted([slot="trailing-supporting-text"]), :host(:disabled) ::slotted([slot="trailing-icon"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-trailing-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-trailing-opacity, 38%), transparent ); } :host(:not(:disabled)) .state-layer { --m3e-state-layer-hover-color: var(--m3e-list-item-hover-state-layer-color, ${DesignToken.color.onSurface}); --m3e-state-layer-hover-opacity: var( --m3e-list-item-hover-state-layer-opacity, ${DesignToken.state.hoverStateLayerOpacity} ); --m3e-state-layer-focus-color: var(--m3e-list-item-focus-state-layer-color, ${DesignToken.color.onSurface}); --m3e-state-layer-focus-opacity: var( --m3e-list-item-focus-state-layer-opacity, ${DesignToken.state.focusStateLayerOpacity} ); } :host(:not(:disabled)) .ripple { --m3e-ripple-color: var(--m3e-list-item-pressed-state-layer-color, ${DesignToken.color.onSurface}); --m3e-ripple-opacity: var( --m3e-list-item-pressed-state-layer-opacity, ${DesignToken.state.pressedStateLayerOpacity} ); } @media (forced-colors: active) { .base { transition: none; } :host(:disabled) ::slotted([slot="leading"]), :host(:disabled) ::slotted([slot="leading-icon"]), :host(:disabled) .content, :host(:disabled) ::slotted([slot="overline"]), :host(:disabled) ::slotted([slot="supporting-text"]), :host(:disabled) ::slotted([slot="trailing"]), :host(:disabled) ::slotted([slot="trailing-supporting-text"]), :host(:disabled) ::slotted([slot="trailing-icon"]) { color: GrayText; } } @media (prefers-reduced-motion) { .base { transition: none; } }`;
|
|
184
|
+
M3eListItemElement.styles = css`:host { display: block; } .base { display: flex; min-height: inherit; width: 100%; box-sizing: border-box; column-gap: var(--m3e-list-item-between-space, 1rem); padding-inline-start: var(--m3e-list-item-leading-space, 1rem); padding-inline-end: var(--m3e-list-item-trailing-space, 1rem); border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-container-shape, ${DesignToken.shape.corner.none}) ); transition: ${unsafeCSS(`border-radius ${DesignToken.motion.spring.fastEffects}, background-color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)}; } :host(:is(:state(--one-line), :--one-line)) { min-height: calc(var(--m3e-list-item-one-line-height, 3.5rem) + ${DesignToken.density.calc(-3)}); } :host(:is(:state(--one-line), :--one-line)) .base { padding-block-start: var(--m3e-list-item-one-line-top-space, 0.5rem); padding-block-end: var(--m3e-list-item-one-line-bottom-space, 0.5rem); } :host(:is(:state(--two-line), :--two-line)) { min-height: calc(var(--m3e-list-item-two-line-height, 4.5rem) + ${DesignToken.density.calc(-3)}); } :host(:is(:state(--two-line), :--two-line)) .base { padding-block-start: var(--m3e-list-item-two-line-top-space, 0.5rem); padding-block-end: var(--m3e-list-item-two-line-bottom-space, 0.5rem); } :host(:is(:state(--three-line), :--three-line)) { min-height: calc(var(--m3e-list-item-three-line-height, 5.5rem) + ${DesignToken.density.calc(-3)}); } :host(:is(:state(--three-line), :--three-line)) .base { padding-block-start: var(--m3e-list-item-three-line-top-space, 0.75rem); padding-block-end: var(--m3e-list-item-three-line-bottom-space, 0.75rem); } :host(:not(:is(:state(--three-line), :--three-line))) .base { align-items: center; } :host(:is(:state(--three-line), :--three-line)) .base { align-items: flex-start; } :host(:not(:disabled):not([selected])) .base:not(.hover).focus-visible:not(.pressed) { border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-focus-container-shape, ${DesignToken.shape.corner.large}) ); } :host(:not(:disabled):not([selected])) .base.hover, :host(:not(:disabled):not([selected])) .base.pressed { border-top-left-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-top-right-radius: var( --_list-item-top-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-bottom-left-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); border-bottom-right-radius: var( --_list-item-bottom-container-shape, var(--m3e-list-item-hover-container-shape, ${DesignToken.shape.corner.medium}) ); } .content { flex: 1 1 auto; display: flex; flex-direction: column; align-items: unset; justify-content: unset; } ::slotted([slot="overline"]) { font-size: var(--m3e-list-item-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-list-item-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-list-item-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-list-item-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking}); } ::slotted([slot="supporting-text"]) { font-size: var(--m3e-list-item-supporting-text-font-size, ${DesignToken.typescale.standard.body.medium.fontSize}); font-weight: var( --m3e-list-item-supporting-text-font-weight, ${DesignToken.typescale.standard.body.medium.fontWeight} ); line-height: var( --m3e-list-item-supporting-text-line-height, ${DesignToken.typescale.standard.body.medium.lineHeight} ); letter-spacing: var( --m3e-list-item-supporting-text-tracking, ${DesignToken.typescale.standard.body.medium.tracking} ); } ::slotted(:not([slot])) { font-size: var(--m3e-list-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize}); font-weight: var(--m3e-list-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight}); line-height: var(--m3e-list-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight}); letter-spacing: var(--m3e-list-item-tracking, ${DesignToken.typescale.standard.body.large.tracking}); } :host(:is(:state(--has-leading), :--has-leading)) slot[name="leading"], :host(:is(:state(--has-trailing), :--has-trailing)) slot[name="trailing"] { display: flex; justify-content: center; } :host(:not(:is(:state(--has-leading), :--has-leading))) slot[name="leading"] { display: var(--_list-item-leading-reserved-display, contents); } :host(:not(:is(:state(--has-trailing), :--has-trailing))) slot[name="trailing"] { display: var(--_list-item-trailing-reserved-display, contents); } slot[name="leading"] { min-width: var(--_list-item-leading-reserved-space, 0px); margin-inline-start: calc(0px - var(--_list-item-leading-reserved-outset, 0px)); } slot[name="trailing"] { min-width: var(--_list-item-trailing-reserved-space, 0px); margin-inline-end: calc(0px - var(--_list-item-trailing-reserved-outset, 0px)); } ::slotted(span[slot="trailing"]), ::slotted([slot="trailing-supporting-text"]) { white-space: nowrap; font-size: var(--m3e-list-item-trailing-text-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var( --m3e-list-item-trailing-text-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight} ); line-height: var( --m3e-list-item-trailing-text-line-height, ${DesignToken.typescale.standard.label.small.lineHeight} ); letter-spacing: var( --m3e-list-item-trailing-text-tracking, ${DesignToken.typescale.standard.label.small.tracking} ); } ::slotted(video[slot="leading"]), ::slotted(video[slot="trailing"]), ::slotted(img[slot="leading"]), ::slotted(img[slot="trailing"]) { display: block; margin: 0 auto; overflow: hidden; object-fit: cover; } ::slotted(video) { width: var(--m3e-list-item-video-width, 6.25rem); height: var(--m3e-list-item-video-height, 3.5rem); } ::slotted(video[slot="leading"]), ::slotted(video[slot="trailing"]) { border-radius: var(--m3e-list-item-video-shape, ${DesignToken.shape.corner.none}); } ::slotted(video[slot="leading"]) { margin-inline-start: calc(0px - var(--_list-item-leading-video-outset, 0px)); } ::slotted(video[slot="trailing"]) { margin-inline-end: calc(0px - var(--_list-item-trailing-video-outset, 0px)); } ::slotted(img) { user-drag: none; user-select: none; pointer-events: none; width: var(--m3e-list-item-image-width, 3.5rem); height: var(--m3e-list-item-image-height, 3.5rem); } ::slotted(img[slot="leading"]), ::slotted(img[slot="trailing"]) { border-radius: var(--m3e-list-item-image-shape, ${DesignToken.shape.corner.none}); } ::slotted(m3e-icon[slot="leading"]), ::slotted(m3e-icon[slot="leading-icon"]), ::slotted(m3e-icon[slot="trailing"]), ::slotted(m3e-icon[slot="trailing-icon"]) { --m3e-icon-size: var(--m3e-list-item-icon-size, 1.5rem); } :host(:not(:disabled)) ::slotted(m3e-icon[slot="leading"]), :host(:not(:disabled)) ::slotted(m3e-icon[slot="leading-icon"]) { color: var(--m3e-list-item-leading-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) .content { color: var(--m3e-list-item-label-text-color, ${DesignToken.color.onSurface}); } :host(:not(:disabled)) ::slotted([slot="overline"]) { color: var(--m3e-list-item-overline-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) ::slotted([slot="supporting-text"]) { color: var(--m3e-list-item-supporting-text-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) ::slotted([slot="trailing"]), :host(:not(:disabled)) ::slotted([slot="trailing-supporting-text"]), :host(:not(:disabled)) ::slotted([slot="trailing-icon"]) { color: var(--m3e-list-item-trailing-color, ${DesignToken.color.onSurfaceVariant}); } :host(:not(:disabled)) .base { background-color: var(--_list-item-container-color, var(--m3e-list-item-container-color, transparent)); } :host(:disabled) .base { background-color: var(--m3e-list-item-disabled-container-color, transparent); } :host(:disabled) ::slotted(video), :host(:disabled) ::slotted(img), :host(:disabled) ::slotted(m3e-avatar) { opacity: var(--m3e-list-item-disabled-media-opacity, 38%); } :host(:disabled) .content { color: color-mix( in srgb, var(--m3e-list-item-disabled-label-text-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-label-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="overline"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-overline-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-overline-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="supporting-text"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-supporting-text-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-supporting-text-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="leading"]), :host(:disabled) ::slotted([slot="leading-icon"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-leading-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-leading-opacity, 38%), transparent ); } :host(:disabled) ::slotted([slot="trailing"]), :host(:disabled) ::slotted([slot="trailing-supporting-text"]), :host(:disabled) ::slotted([slot="trailing-icon"]) { color: color-mix( in srgb, var(--m3e-list-item-disabled-trailing-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-disabled-trailing-opacity, 38%), transparent ); } :host(:not(:disabled)) .state-layer { --m3e-state-layer-hover-color: var(--m3e-list-item-hover-state-layer-color, ${DesignToken.color.onSurface}); --m3e-state-layer-hover-opacity: var( --m3e-list-item-hover-state-layer-opacity, ${DesignToken.state.hoverStateLayerOpacity} ); --m3e-state-layer-focus-color: var(--m3e-list-item-focus-state-layer-color, ${DesignToken.color.onSurface}); --m3e-state-layer-focus-opacity: var( --m3e-list-item-focus-state-layer-opacity, ${DesignToken.state.focusStateLayerOpacity} ); } :host(:not(:disabled)) .ripple { --m3e-ripple-color: var(--m3e-list-item-pressed-state-layer-color, ${DesignToken.color.onSurface}); --m3e-ripple-opacity: var( --m3e-list-item-pressed-state-layer-opacity, ${DesignToken.state.pressedStateLayerOpacity} ); } @media (forced-colors: active) { .base { transition: none; } :host(:disabled) ::slotted([slot="leading"]), :host(:disabled) ::slotted([slot="leading-icon"]), :host(:disabled) .content, :host(:disabled) ::slotted([slot="overline"]), :host(:disabled) ::slotted([slot="supporting-text"]), :host(:disabled) ::slotted([slot="trailing"]), :host(:disabled) ::slotted([slot="trailing-supporting-text"]), :host(:disabled) ::slotted([slot="trailing-icon"]) { color: GrayText; } } @media (prefers-reduced-motion) { .base { transition: none; } }`;
|
|
185
185
|
M3eListItemElement = __decorate([customElement("m3e-list-item")], M3eListItemElement);
|
|
186
186
|
|
|
187
187
|
var _M3eListElement_instances, _M3eListElement_items, _M3eListElement_leadingContentTypes, _M3eListElement_trailingContentTypes, _M3eListElement_handleSlotChange;
|
|
@@ -290,7 +290,7 @@ let M3eListElement = class M3eListElement extends AttachInternals(Role(LitElemen
|
|
|
290
290
|
__classPrivateFieldGet(this, _M3eListElement_leadingContentTypes, "f")[newType]++;
|
|
291
291
|
}
|
|
292
292
|
["video", "image", "avatar", "icon"].forEach(x => {
|
|
293
|
-
setCustomState(this,
|
|
293
|
+
setCustomState(this, `--has-leading-${x}`, this.leadingContentType === x);
|
|
294
294
|
});
|
|
295
295
|
}
|
|
296
296
|
/**
|
|
@@ -305,7 +305,7 @@ let M3eListElement = class M3eListElement extends AttachInternals(Role(LitElemen
|
|
|
305
305
|
__classPrivateFieldGet(this, _M3eListElement_trailingContentTypes, "f")[newType]--;
|
|
306
306
|
}
|
|
307
307
|
["video", "image", "avatar", "icon"].forEach(x => {
|
|
308
|
-
setCustomState(this,
|
|
308
|
+
setCustomState(this, `--has-trailing-${x}`, this.trailingContentType === x);
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
};
|
|
@@ -318,13 +318,13 @@ _M3eListElement_handleSlotChange = function _M3eListElement_handleSlotChange(e)
|
|
|
318
318
|
flatten: true
|
|
319
319
|
}).filter(x => x instanceof M3eListItemElement), "f");
|
|
320
320
|
__classPrivateFieldGet(this, _M3eListElement_items, "f").forEach((x, i) => {
|
|
321
|
-
setCustomState(x, "
|
|
322
|
-
setCustomState(x, "
|
|
321
|
+
setCustomState(x, "--first", i === 0);
|
|
322
|
+
setCustomState(x, "--last", i === __classPrivateFieldGet(this, _M3eListElement_items, "f").length - 1);
|
|
323
323
|
});
|
|
324
324
|
this.notifyItemsChange();
|
|
325
325
|
};
|
|
326
326
|
/** The styles of the element. */
|
|
327
|
-
M3eListElement.styles = css`:host { display: flex; flex-direction: column; overflow-y: auto; box-sizing: border-box; padding-block: var(--m3e-list-block-padding, 0px); --m3e-divider-inset-start-size: var(--m3e-list-divider-inset-start-size, 1rem); --m3e-divider-inset-end-size: var(--m3e-list-divider-inset-end-size, 1.5rem); } :host([variant="standard"]) { --_list-item-leading-video-outset: var(--m3e-list-item-leading-space, 1rem); --_list-item-trailing-video-outset: var(--m3e-list-item-trailing-space, 1rem); --_expandable-list-item-expanded-toggle-icon-container-color: transparent; } :host([variant="segmented"]) { row-gap: var(--m3e-segmented-list-segment-gap, 0.125rem); } :host([variant="segmented"]) { --m3e-list-item-container-color: var(--m3e-segmented-list-item-container-color, ${DesignToken.color.surface}); --m3e-list-item-disabled-container-color: var( --m3e-segmented-list-item-disabled-container-color, ${DesignToken.color.surface} ); --m3e-list-item-container-shape: var( --m3e-segmented-list-item-container-shape, ${DesignToken.shape.corner.extraSmall} ); --m3e-list-item-hover-container-shape: var( --m3e-segmented-list-item-hover-container-shape, ${DesignToken.shape.corner.medium} ); --m3e-list-item-focus-container-shape: var( --m3e-segmented-list-item-focus-container-shape, ${DesignToken.shape.corner.large} ); --m3e-list-item-selected-container-shape: var( --m3e-segmented-list-item-selected-container-shape, ${DesignToken.shape.corner.large} ); --m3e-list-item-video-shape: var(--m3e-segmented-list-item-video-shape, ${DesignToken.shape.corner.small}); --m3e-list-item-image-shape: var(--m3e-segmented-list-item-image-shape, ${DesignToken.shape.corner.small}); --m3e-list-item-between-space: var(--m3e-segmented-list-item-spacing, 0.75rem); --_expandable-list-item-items-segment-gap: var(--m3e-segmented-list-segment-gap, 0.125rem); --_expandable-list-item-expanded-top-shape: var( --m3e-segmented-list-container-shape, ${DesignToken.shape.corner.large} ); } :host([variant="segmented"]) ::slotted(:state(
|
|
327
|
+
M3eListElement.styles = css`:host { display: flex; flex-direction: column; overflow-y: auto; box-sizing: border-box; padding-block: var(--m3e-list-block-padding, 0px); --m3e-divider-inset-start-size: var(--m3e-list-divider-inset-start-size, 1rem); --m3e-divider-inset-end-size: var(--m3e-list-divider-inset-end-size, 1.5rem); } :host([variant="standard"]) { --_list-item-leading-video-outset: var(--m3e-list-item-leading-space, 1rem); --_list-item-trailing-video-outset: var(--m3e-list-item-trailing-space, 1rem); --_expandable-list-item-expanded-toggle-icon-container-color: transparent; } :host([variant="segmented"]) { row-gap: var(--m3e-segmented-list-segment-gap, 0.125rem); } :host([variant="segmented"]) { --m3e-list-item-container-color: var(--m3e-segmented-list-item-container-color, ${DesignToken.color.surface}); --m3e-list-item-disabled-container-color: var( --m3e-segmented-list-item-disabled-container-color, ${DesignToken.color.surface} ); --m3e-list-item-container-shape: var( --m3e-segmented-list-item-container-shape, ${DesignToken.shape.corner.extraSmall} ); --m3e-list-item-hover-container-shape: var( --m3e-segmented-list-item-hover-container-shape, ${DesignToken.shape.corner.medium} ); --m3e-list-item-focus-container-shape: var( --m3e-segmented-list-item-focus-container-shape, ${DesignToken.shape.corner.large} ); --m3e-list-item-selected-container-shape: var( --m3e-segmented-list-item-selected-container-shape, ${DesignToken.shape.corner.large} ); --m3e-list-item-video-shape: var(--m3e-segmented-list-item-video-shape, ${DesignToken.shape.corner.small}); --m3e-list-item-image-shape: var(--m3e-segmented-list-item-image-shape, ${DesignToken.shape.corner.small}); --m3e-list-item-between-space: var(--m3e-segmented-list-item-spacing, 0.75rem); --_expandable-list-item-items-segment-gap: var(--m3e-segmented-list-segment-gap, 0.125rem); --_expandable-list-item-expanded-top-shape: var( --m3e-segmented-list-container-shape, ${DesignToken.shape.corner.large} ); } :host([variant="segmented"]) ::slotted(:is(:state(--first), :--first)), :host([variant="segmented"]) ::slotted(:is(:state(--has-previous-open), :--has-previous-open):not([open])) { --_list-item-top-container-shape: var(--m3e-segmented-list-container-shape, ${DesignToken.shape.corner.large}); } :host([variant="segmented"]) ::slotted(:is(:state(--has-next-open), :--has-next-open):not([open])), :host([variant="segmented"]) ::slotted(:is(:state(--last), :--last)) { --_list-item-bottom-container-shape: var(--m3e-segmented-list-container-shape, ${DesignToken.shape.corner.large}); } :host([variant="segmented"]) ::slotted(m3e-divider) { display: none; } :host(:is(:state(--has-leading-video), :--has-leading-video)) { --_list-item-leading-reserved-display: block; --_list-item-leading-reserved-space: var(--m3e-list-item-video-width, 6.25rem); } :host([variant="standard"]:is(:state(--has-leading-video), :--has-leading-video)) { --_list-item-leading-reserved-outset: var(--m3e-list-item-leading-space, 1rem); --_list-item-trailing-reserved-outset: var(--m3e-list-item-trailing-space, 1rem); } :host(:is(:state(--has-leading-image), :--has-leading-image)) { --_list-item-leading-reserved-display: block; --_list-item-leading-reserved-space: var(--m3e-list-item-image-width, 3.5rem); } :host(:is(:state(--has-leading-avatar), :--has-leading-avatar)) { --_list-item-leading-reserved-display: block; --_list-item-leading-reserved-space: var(--m3e-avatar-size, 2.5rem); } :host(:is(:state(--has-leading-icon), :--has-leading-icon)) { --_list-item-leading-reserved-display: block; --_list-item-leading-reserved-space: var(--m3e-list-item-icon-size, 1.5rem); }`;
|
|
328
328
|
__decorate([property({
|
|
329
329
|
reflect: true
|
|
330
330
|
})], M3eListElement.prototype, "variant", void 0);
|
|
@@ -490,13 +490,13 @@ let M3eExpandableListItemElement = M3eExpandableListItemElement_1 = class M3eExp
|
|
|
490
490
|
if (_changedProperties.has("open")) {
|
|
491
491
|
for (let sibling = this.previousElementSibling; sibling; sibling = sibling.previousElementSibling) {
|
|
492
492
|
if (sibling instanceof M3eListItemElement) {
|
|
493
|
-
setCustomState(sibling, "
|
|
493
|
+
setCustomState(sibling, "--has-next-open", this.open);
|
|
494
494
|
break;
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
for (let sibling = this.nextElementSibling; sibling; sibling = sibling.nextElementSibling) {
|
|
498
498
|
if (sibling instanceof M3eListItemElement) {
|
|
499
|
-
setCustomState(sibling, "
|
|
499
|
+
setCustomState(sibling, "--has-previous-open", this.open);
|
|
500
500
|
break;
|
|
501
501
|
}
|
|
502
502
|
}
|
|
@@ -982,7 +982,7 @@ _M3eListOptionElement_handleClick = function _M3eListOptionElement_handleClick(e
|
|
|
982
982
|
}
|
|
983
983
|
};
|
|
984
984
|
/** The styles of the element. */
|
|
985
|
-
M3eListOptionElement.styles = [M3eListItemElement.styles, css`:host { outline: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .base { position: relative; } .indicator { min-width: 1.5rem; min-height: 1.5rem; display: flex; align-items: center; justify-content: center; } :host(:not(:disabled)) { cursor: pointer; } :host(:state(-three-line)) .indicator { align-self: flex-start; margin-top: var(--m3e-list-item-three-line-top-offset, 0.25rem); } :host([selected]) .base, :host([selected]) .state-layer, :host([selected]) .ripple, :host([selected]) .focus-ring { border-radius: var(--m3e-list-item-selected-container-shape, ${DesignToken.shape.corner.large}); } :host([selected]:not(:disabled)) .content { color: var(--m3e-list-item-selected-label-text-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="overline"]) { color: var(--m3e-list-item-selected-overline-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="supporting-text"]) { color: var(--m3e-list-item-selected-supporting-text-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="leading"]) { color: var(--m3e-list-item-selected-leading-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="trailing"]) { color: var(--m3e-list-item-selected-trailing-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) .base { background-color: var(--m3e-list-item-selected-container-color, ${DesignToken.color.secondaryContainer}); } :host([selected]:disabled) .base { background-color: color-mix( in srgb, var(--m3e-list-item-selected-disabled-container-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-selected-disabled-container-opacity, 10%), transparent ); } :host([selected]:not(:disabled)) .state-layer { --m3e-state-layer-hover-color: var( --m3e-list-item-selected-hover-state-layer-color, ${DesignToken.color.onSurface} ); --m3e-state-layer-hover-opacity: var( --m3e-list-item-selected-hover-state-layer-opacity, ${DesignToken.state.hoverStateLayerOpacity} ); --m3e-state-layer-focus-color: var( --m3e-list-item-selected-focus-state-layer-color, ${DesignToken.color.onSurface} ); --m3e-state-layer-focus-opacity: var( --m3e-list-item-selected-focus-state-layer-opacity, ${DesignToken.state.focusStateLayerOpacity} ); } :host([selected]:not(:disabled)) .ripple { --m3e-ripple-color: var(--m3e-list-item-selected-pressed-state-layer-color, ${DesignToken.color.onSurface}); --m3e-ripple-opacity: var( --m3e-list-item-selected-pressed-state-layer-opacity, ${DesignToken.state.pressedStateLayerOpacity} ); } :host(:state(-hide-selection)) .indicator, :host(:not(:state(-hide-selection))) ::slotted([slot="trailing"]) { display: none; } @media (forced-colors: active) { :host([selected]:not(:disabled)) .content, :host([selected]:not(:disabled)) ::slotted([slot="overline"]), :host([selected]:not(:disabled)) ::slotted([slot="supporting-text"]), :host([selected]:not(:disabled)) ::slotted([slot="leading"]), :host([selected]:not(:disabled)) ::slotted([slot="trailing"]) { color: HighlightText; forced-color-adjust: none; } :host([selected]:not(:disabled)) .base { background-color: Highlight; } }`];
|
|
985
|
+
M3eListOptionElement.styles = [M3eListItemElement.styles, css`:host { outline: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } .base { position: relative; } .indicator { min-width: 1.5rem; min-height: 1.5rem; display: flex; align-items: center; justify-content: center; } :host(:not(:disabled)) { cursor: pointer; } :host(:is(:state(--three-line), :--three-line)) .indicator { align-self: flex-start; margin-top: var(--m3e-list-item-three-line-top-offset, 0.25rem); } :host([selected]) .base, :host([selected]) .state-layer, :host([selected]) .ripple, :host([selected]) .focus-ring { border-radius: var(--m3e-list-item-selected-container-shape, ${DesignToken.shape.corner.large}); } :host([selected]:not(:disabled)) .content { color: var(--m3e-list-item-selected-label-text-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="overline"]) { color: var(--m3e-list-item-selected-overline-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="supporting-text"]) { color: var(--m3e-list-item-selected-supporting-text-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="leading"]) { color: var(--m3e-list-item-selected-leading-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) ::slotted([slot="trailing"]) { color: var(--m3e-list-item-selected-trailing-color, ${DesignToken.color.onSecondaryContainer}); } :host([selected]:not(:disabled)) .base { background-color: var(--m3e-list-item-selected-container-color, ${DesignToken.color.secondaryContainer}); } :host([selected]:disabled) .base { background-color: color-mix( in srgb, var(--m3e-list-item-selected-disabled-container-color, ${DesignToken.color.onSurface}) var(--m3e-list-item-selected-disabled-container-opacity, 10%), transparent ); } :host([selected]:not(:disabled)) .state-layer { --m3e-state-layer-hover-color: var( --m3e-list-item-selected-hover-state-layer-color, ${DesignToken.color.onSurface} ); --m3e-state-layer-hover-opacity: var( --m3e-list-item-selected-hover-state-layer-opacity, ${DesignToken.state.hoverStateLayerOpacity} ); --m3e-state-layer-focus-color: var( --m3e-list-item-selected-focus-state-layer-color, ${DesignToken.color.onSurface} ); --m3e-state-layer-focus-opacity: var( --m3e-list-item-selected-focus-state-layer-opacity, ${DesignToken.state.focusStateLayerOpacity} ); } :host([selected]:not(:disabled)) .ripple { --m3e-ripple-color: var(--m3e-list-item-selected-pressed-state-layer-color, ${DesignToken.color.onSurface}); --m3e-ripple-opacity: var( --m3e-list-item-selected-pressed-state-layer-opacity, ${DesignToken.state.pressedStateLayerOpacity} ); } :host(:is(:state(--hide-selection), :--hide-selection)) .indicator, :host(:not(:is(:state(--hide-selection), :--hide-selection))) ::slotted([slot="trailing"]) { display: none; } @media (forced-colors: active) { :host([selected]:not(:disabled)) .content, :host([selected]:not(:disabled)) ::slotted([slot="overline"]), :host([selected]:not(:disabled)) ::slotted([slot="supporting-text"]), :host([selected]:not(:disabled)) ::slotted([slot="leading"]), :host([selected]:not(:disabled)) ::slotted([slot="trailing"]) { color: HighlightText; forced-color-adjust: none; } :host([selected]:not(:disabled)) .base { background-color: Highlight; } }`];
|
|
986
986
|
__decorate([query(".focus-ring")], M3eListOptionElement.prototype, "_focusRing", void 0);
|
|
987
987
|
__decorate([query(".state-layer")], M3eListOptionElement.prototype, "_stateLayer", void 0);
|
|
988
988
|
__decorate([query(".ripple")], M3eListOptionElement.prototype, "_ripple", void 0);
|
|
@@ -1104,7 +1104,7 @@ let M3eSelectionListElement = class M3eSelectionListElement extends Labelled(Dir
|
|
|
1104
1104
|
this[selectionManager].items.forEach(x => x.requestUpdate());
|
|
1105
1105
|
}
|
|
1106
1106
|
if (changedProperties.has("hideSelectionIndicator")) {
|
|
1107
|
-
this[selectionManager].items.forEach(x => setCustomState(x, "
|
|
1107
|
+
this[selectionManager].items.forEach(x => setCustomState(x, "--hide-selection", this.hideSelectionIndicator));
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
1110
|
/** @inheritdoc */
|
|
@@ -1112,7 +1112,7 @@ let M3eSelectionListElement = class M3eSelectionListElement extends Labelled(Dir
|
|
|
1112
1112
|
const {
|
|
1113
1113
|
added
|
|
1114
1114
|
} = this[selectionManager].setItems(this.items.filter(x => x instanceof M3eListOptionElement));
|
|
1115
|
-
added.forEach(x => setCustomState(x, "
|
|
1115
|
+
added.forEach(x => setCustomState(x, "--hide-selection", this.hideSelectionIndicator));
|
|
1116
1116
|
if (!this[selectionManager].activeItem) {
|
|
1117
1117
|
this[selectionManager].updateActiveItem(added.find(x => !x.disabled));
|
|
1118
1118
|
}
|