@m3e/icon 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +106 -0
- package/cem.config.mjs +16 -0
- package/dist/css-custom-data.json +6 -0
- package/dist/custom-elements.json +220 -0
- package/dist/html-custom-data.json +43 -0
- package/dist/index.js +236 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +75 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/IconElement.d.ts +84 -0
- package/dist/src/IconElement.d.ts.map +1 -0
- package/dist/src/IconGrade.d.ts +3 -0
- package/dist/src/IconGrade.d.ts.map +1 -0
- package/dist/src/IconVariant.d.ts +3 -0
- package/dist/src/IconVariant.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/eslint.config.mjs +13 -0
- package/package.json +48 -0
- package/rollup.config.js +32 -0
- package/src/IconElement.ts +163 -0
- package/src/IconGrade.ts +2 -0
- package/src/IconVariant.ts +2 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 matraic
|
|
4
|
+
Contact: matraic@yahoo.com
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
your user's browser support variable fonts.
|
|
2
|
+
|
|
3
|
+
# @m3e/icon
|
|
4
|
+
|
|
5
|
+
The `m3e-icon` component makes it easy to use Material Symbols in your application. It supports outlined, rounded, and sharp variants, as well as variable font features like fill, weight, grade, and optical size. For more information, see the [Material Symbol Guide](https://developers.google.com/fonts/docs/material_symbols) and [Material Symbol Library](https://fonts.google.com/icons).
|
|
6
|
+
|
|
7
|
+
The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the [Fonts CSS API](https://developers.google.com/fonts/docs/css2#forming_api_urls), you can use variable fonts to optimize icon
|
|
8
|
+
usage within your application. See [Can I Use's Variable Fonts](https://caniuse.com/variable-fonts) to determine whether
|
|
9
|
+
your user's browser support variable fonts.
|
|
10
|
+
|
|
11
|
+
> **Part of the [M3E](../../README.md) monorepo**
|
|
12
|
+
> This package is maintained within the unified M3E repository, which provides a suite of Material 3 web components.
|
|
13
|
+
|
|
14
|
+
## ๐ฆ Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @m3e/icon
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## ๐ป Editor Integration
|
|
21
|
+
|
|
22
|
+
This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
|
|
23
|
+
|
|
24
|
+
### Visual Studio Code
|
|
25
|
+
|
|
26
|
+
To enable autocomplete and hover documentation for `@m3e/icon`, install the [Custom Elements Manifest Language Server](https://marketplace.visualstudio.com/items?itemName=pwrs.cem-language-server-vscode) extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.
|
|
27
|
+
|
|
28
|
+
Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"html.customData": ["./node_modules/@m3e/icon/dist/html-custom-data.json"],
|
|
33
|
+
"css.customData": ["./node_modules/@m3e/icon/dist/css-custom-data.json"]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## ๐ Browser Usage
|
|
38
|
+
|
|
39
|
+
This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script type="module" src="/node_modules/@m3e/icon/dist/index.js"></script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include dependencies.
|
|
46
|
+
|
|
47
|
+
```html
|
|
48
|
+
<script type="importmap">
|
|
49
|
+
{
|
|
50
|
+
"imports": {
|
|
51
|
+
"lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
|
|
52
|
+
"@m3e/core": "/node_modules/@m3e/core/dist/index.js"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> For production, use index.min.js for faster load times.
|
|
59
|
+
|
|
60
|
+
## ๐๏ธ Elements
|
|
61
|
+
|
|
62
|
+
- `m3e-icon` โ A small symbol used to easily identify an action or category.
|
|
63
|
+
|
|
64
|
+
## ๐งช Examples
|
|
65
|
+
|
|
66
|
+
The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<m3e-icon name="home"></m3e-icon>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The next example illustrates a link used to download a variable font for outlined icons with fill support.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<link
|
|
76
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0"
|
|
77
|
+
rel="stylesheet"
|
|
78
|
+
/>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## ๐ API Reference
|
|
82
|
+
|
|
83
|
+
### โ๏ธ Attributes
|
|
84
|
+
|
|
85
|
+
| Attribute | Type | Default | Description |
|
|
86
|
+
| -------------- | ------------------------------------ | ------------ | -------------------------------------------------------------- |
|
|
87
|
+
| `name` | `string` | | The name of the icon. |
|
|
88
|
+
| `variant` | `"outlined" \| "rounded" \| "sharp"` | `"outlined"` | The appearance variant of the icon. |
|
|
89
|
+
| `filled` | `boolean` | `false` | Whether the icon is filled. |
|
|
90
|
+
| `grade` | `"low" \| "medium" \| "high"` | `"medium"` | The grade of the icon. |
|
|
91
|
+
| `weight` | `number` | `400` | A value from 100 to 700 indicating the weight of the icon. |
|
|
92
|
+
| `optical-size` | `number` | `24` | A value from 20 to 48 indicating the optical size of the icon. |
|
|
93
|
+
|
|
94
|
+
### ๐๏ธ CSS Custom Properties
|
|
95
|
+
|
|
96
|
+
| Property | Description |
|
|
97
|
+
| ----------------- | ---------------------- |
|
|
98
|
+
| `--m3e-icon-size` | Font size of the icon. |
|
|
99
|
+
|
|
100
|
+
## ๐ค Contributing
|
|
101
|
+
|
|
102
|
+
See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
|
|
103
|
+
|
|
104
|
+
## ๐ License
|
|
105
|
+
|
|
106
|
+
This package is licensed under the MIT License.
|
package/cem.config.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { customElementVsCodePlugin } from "custom-element-vs-code-integration";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
globs: ["src/**/*.ts"],
|
|
5
|
+
exclude: ["src/**/*.spec.ts"],
|
|
6
|
+
packagejson: true,
|
|
7
|
+
outdir: "dist",
|
|
8
|
+
litelement: true,
|
|
9
|
+
plugins: [
|
|
10
|
+
customElementVsCodePlugin({
|
|
11
|
+
outdir: "dist",
|
|
12
|
+
htmlFileName: "html-custom-data.json",
|
|
13
|
+
cssFileName: "css-custom-data.json",
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/IconElement.ts",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "",
|
|
12
|
+
"name": "M3eIconElement",
|
|
13
|
+
"members": [
|
|
14
|
+
{
|
|
15
|
+
"kind": "field",
|
|
16
|
+
"name": "_icon",
|
|
17
|
+
"type": {
|
|
18
|
+
"text": "HTMLSpanElement | undefined"
|
|
19
|
+
},
|
|
20
|
+
"privacy": "private",
|
|
21
|
+
"readonly": true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"kind": "field",
|
|
25
|
+
"name": "name",
|
|
26
|
+
"type": {
|
|
27
|
+
"text": "string"
|
|
28
|
+
},
|
|
29
|
+
"default": "\"\"",
|
|
30
|
+
"description": "The name of the icon.",
|
|
31
|
+
"attribute": "name"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "field",
|
|
35
|
+
"name": "variant",
|
|
36
|
+
"type": {
|
|
37
|
+
"text": "IconVariant"
|
|
38
|
+
},
|
|
39
|
+
"default": "\"outlined\"",
|
|
40
|
+
"description": "The appearance variant of the icon.",
|
|
41
|
+
"attribute": "variant",
|
|
42
|
+
"reflects": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"kind": "field",
|
|
46
|
+
"name": "filled",
|
|
47
|
+
"type": {
|
|
48
|
+
"text": "boolean"
|
|
49
|
+
},
|
|
50
|
+
"default": "false",
|
|
51
|
+
"description": "Whether the icon is filled.",
|
|
52
|
+
"attribute": "filled",
|
|
53
|
+
"reflects": true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"kind": "field",
|
|
57
|
+
"name": "grade",
|
|
58
|
+
"type": {
|
|
59
|
+
"text": "IconGrade"
|
|
60
|
+
},
|
|
61
|
+
"default": "\"medium\"",
|
|
62
|
+
"description": "The grade of the icon.",
|
|
63
|
+
"attribute": "grade"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"kind": "field",
|
|
67
|
+
"name": "weight",
|
|
68
|
+
"type": {
|
|
69
|
+
"text": "number"
|
|
70
|
+
},
|
|
71
|
+
"default": "400",
|
|
72
|
+
"description": "A value from 100 to 700 indicating the weight of the icon.",
|
|
73
|
+
"attribute": "weight"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"kind": "field",
|
|
77
|
+
"name": "opticalSize",
|
|
78
|
+
"type": {
|
|
79
|
+
"text": "number"
|
|
80
|
+
},
|
|
81
|
+
"default": "24",
|
|
82
|
+
"description": "A value from 20 to 48 indicating the optical size of the icon.",
|
|
83
|
+
"attribute": "optical-size"
|
|
84
|
+
}
|
|
85
|
+
],
|
|
86
|
+
"attributes": [
|
|
87
|
+
{
|
|
88
|
+
"description": "Whether the icon is filled.",
|
|
89
|
+
"name": "filled",
|
|
90
|
+
"type": {
|
|
91
|
+
"text": "boolean"
|
|
92
|
+
},
|
|
93
|
+
"default": "false",
|
|
94
|
+
"fieldName": "filled"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"description": "The grade of the icon.",
|
|
98
|
+
"name": "grade",
|
|
99
|
+
"type": {
|
|
100
|
+
"text": "IconGrade"
|
|
101
|
+
},
|
|
102
|
+
"default": "\"medium\"",
|
|
103
|
+
"fieldName": "grade"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"description": "A value from 20 to 48 indicating the optical size of the icon.",
|
|
107
|
+
"name": "optical-size",
|
|
108
|
+
"type": {
|
|
109
|
+
"text": "number"
|
|
110
|
+
},
|
|
111
|
+
"default": "24",
|
|
112
|
+
"fieldName": "opticalSize"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"description": "The name of the icon.",
|
|
116
|
+
"name": "name",
|
|
117
|
+
"type": {
|
|
118
|
+
"text": "string"
|
|
119
|
+
},
|
|
120
|
+
"default": "\"\"",
|
|
121
|
+
"fieldName": "name"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"description": "The appearance variant of the icon.",
|
|
125
|
+
"name": "variant",
|
|
126
|
+
"type": {
|
|
127
|
+
"text": "IconVariant"
|
|
128
|
+
},
|
|
129
|
+
"default": "\"outlined\"",
|
|
130
|
+
"fieldName": "variant"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"description": "A value from 100 to 700 indicating the weight of the icon.",
|
|
134
|
+
"name": "weight",
|
|
135
|
+
"type": {
|
|
136
|
+
"text": "number"
|
|
137
|
+
},
|
|
138
|
+
"default": "400",
|
|
139
|
+
"fieldName": "weight"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"mixins": [
|
|
143
|
+
{
|
|
144
|
+
"name": "Role",
|
|
145
|
+
"package": "@m3e/core"
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"superclass": {
|
|
149
|
+
"name": "LitElement",
|
|
150
|
+
"package": "lit"
|
|
151
|
+
},
|
|
152
|
+
"tagName": "m3e-icon",
|
|
153
|
+
"customElement": true,
|
|
154
|
+
"summary": "A small symbol used to easily identify an action or category."
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"exports": [
|
|
158
|
+
{
|
|
159
|
+
"kind": "js",
|
|
160
|
+
"name": "M3eIconElement",
|
|
161
|
+
"declaration": {
|
|
162
|
+
"name": "M3eIconElement",
|
|
163
|
+
"module": "src/IconElement.ts"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"kind": "custom-element-definition",
|
|
168
|
+
"name": "m3e-icon",
|
|
169
|
+
"declaration": {
|
|
170
|
+
"name": "M3eIconElement",
|
|
171
|
+
"module": "src/IconElement.ts"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"kind": "javascript-module",
|
|
178
|
+
"path": "src/IconGrade.ts",
|
|
179
|
+
"declarations": [],
|
|
180
|
+
"exports": []
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"kind": "javascript-module",
|
|
184
|
+
"path": "src/IconVariant.ts",
|
|
185
|
+
"declarations": [],
|
|
186
|
+
"exports": []
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"kind": "javascript-module",
|
|
190
|
+
"path": "src/index.ts",
|
|
191
|
+
"declarations": [],
|
|
192
|
+
"exports": [
|
|
193
|
+
{
|
|
194
|
+
"kind": "js",
|
|
195
|
+
"name": "*",
|
|
196
|
+
"declaration": {
|
|
197
|
+
"name": "*",
|
|
198
|
+
"package": "\"./IconElement\""
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"kind": "js",
|
|
203
|
+
"name": "*",
|
|
204
|
+
"declaration": {
|
|
205
|
+
"name": "*",
|
|
206
|
+
"package": "\"./IconGrade\""
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"kind": "js",
|
|
211
|
+
"name": "*",
|
|
212
|
+
"declaration": {
|
|
213
|
+
"name": "*",
|
|
214
|
+
"package": "\"./IconVariant\""
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/microsoft/vscode-html-languageservice/main/docs/customData.schema.json",
|
|
3
|
+
"version": 1.1,
|
|
4
|
+
"tags": [
|
|
5
|
+
{
|
|
6
|
+
"name": "m3e-icon",
|
|
7
|
+
"description": "A small symbol used to easily identify an action or category.\n---\n",
|
|
8
|
+
"attributes": [
|
|
9
|
+
{
|
|
10
|
+
"name": "filled",
|
|
11
|
+
"description": "Whether the icon is filled.",
|
|
12
|
+
"values": []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "grade",
|
|
16
|
+
"description": "The grade of the icon.",
|
|
17
|
+
"values": [{ "name": "IconGrade" }]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "optical-size",
|
|
21
|
+
"description": "A value from 20 to 48 indicating the optical size of the icon.",
|
|
22
|
+
"values": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "name",
|
|
26
|
+
"description": "The name of the icon.",
|
|
27
|
+
"values": []
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "variant",
|
|
31
|
+
"description": "The appearance variant of the icon.",
|
|
32
|
+
"values": [{ "name": "IconVariant" }]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "weight",
|
|
36
|
+
"description": "A value from 100 to 700 indicating the weight of the icon.",
|
|
37
|
+
"values": []
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"references": []
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { LitElement, html, css } from 'lit';
|
|
7
|
+
import { Role } from '@m3e/core';
|
|
8
|
+
|
|
9
|
+
/******************************************************************************
|
|
10
|
+
Copyright (c) Microsoft Corporation.
|
|
11
|
+
|
|
12
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
+
purpose with or without fee is hereby granted.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
+
***************************************************************************** */
|
|
23
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function __decorate(decorators, target, key, desc) {
|
|
27
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
29
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
30
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
+
var e = new Error(message);
|
|
35
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @license
|
|
40
|
+
* Copyright 2017 Google LLC
|
|
41
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
42
|
+
*/
|
|
43
|
+
const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @license
|
|
47
|
+
* Copyright 2019 Google LLC
|
|
48
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
49
|
+
*/
|
|
50
|
+
const t=globalThis,e$3=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o$2=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$3&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$2=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$3)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$1=e$3?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$2(e)})(t):t;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @license
|
|
54
|
+
* Copyright 2017 Google LLC
|
|
55
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
56
|
+
*/const{is:i,defineProperty:e$2,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$1,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f=(t,s)=>!i(t,s),b={attribute:true,type:String,converter:u,reflect:false,useDefault:false,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$2(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r$1(t),...o$1(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$1(s));}else void 0!==s&&i.push(c$1(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.1");
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @license
|
|
60
|
+
* Copyright 2017 Google LLC
|
|
61
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
62
|
+
*/const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @license
|
|
66
|
+
* Copyright 2017 Google LLC
|
|
67
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
68
|
+
*/
|
|
69
|
+
const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @license
|
|
73
|
+
* Copyright 2017 Google LLC
|
|
74
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
75
|
+
*/function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$1(n,s,{get(){return o(this)}})}}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @summary
|
|
79
|
+
* A small symbol used to easily identify an action or category.
|
|
80
|
+
*
|
|
81
|
+
* @description
|
|
82
|
+
* The `m3e-icon` component makes it easier to use Material Symbols in your application. Material Symbols are Google's newest icons supporting
|
|
83
|
+
* a range of design variants. For more information, see:
|
|
84
|
+
* - {@link https://developers.google.com/fonts/docs/material_symbols|Material Symbol Guide}
|
|
85
|
+
* - {@link https://fonts.google.com/icons|Material Symbol Library}
|
|
86
|
+
*
|
|
87
|
+
* The Material Symbols font is the easiest way to incorporate Material Symbols into your application. Using the
|
|
88
|
+
* {@link https://developers.google.com/fonts/docs/css2#forming_api_urls|Fonts CSS API}, you can use variable fonts to optimize icon
|
|
89
|
+
* usage within your application. See {@link https://caniuse.com/variable-fonts|Can I Use's Variable Fonts} to determine whether
|
|
90
|
+
* your user's browser support variable fonts.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* The following example illustrates showing the `home` icon. The `name` attribute specifies the icon to present.
|
|
94
|
+
* ```html
|
|
95
|
+
* <m3e-icon name="home"></m3e-icon>
|
|
96
|
+
* ```
|
|
97
|
+
* @example
|
|
98
|
+
* The next example illustrates a link used to download a variable font for outlined icons with fill support.
|
|
99
|
+
* ```html
|
|
100
|
+
* <link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0" rel="stylesheet"/>
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @tag m3e-icon
|
|
104
|
+
*
|
|
105
|
+
* @attr filled - Whether the icon is filled.
|
|
106
|
+
* @attr grade - The grade of the icon.
|
|
107
|
+
* @attr optical-size - A value from 20 to 48 indicating the optical size of the icon.
|
|
108
|
+
* @attr name - The name of the icon.
|
|
109
|
+
* @attr variant - The appearance variant of the icon.
|
|
110
|
+
* @attr weight - A value from 100 to 700 indicating the weight of the icon.
|
|
111
|
+
*/
|
|
112
|
+
let M3eIconElement = class M3eIconElement extends Role(LitElement, "img") {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(...arguments);
|
|
115
|
+
/** The name of the icon. */
|
|
116
|
+
this.name = "";
|
|
117
|
+
/**
|
|
118
|
+
* The appearance variant of the icon.
|
|
119
|
+
* @default "outlined"
|
|
120
|
+
*/
|
|
121
|
+
this.variant = "outlined";
|
|
122
|
+
/**
|
|
123
|
+
* Whether the icon is filled.
|
|
124
|
+
* @default false
|
|
125
|
+
*/
|
|
126
|
+
this.filled = false;
|
|
127
|
+
/**
|
|
128
|
+
* The grade of the icon.
|
|
129
|
+
* @default "medium"
|
|
130
|
+
*/
|
|
131
|
+
this.grade = "medium";
|
|
132
|
+
/**
|
|
133
|
+
* A value from 100 to 700 indicating the weight of the icon.
|
|
134
|
+
* @default 400
|
|
135
|
+
*/
|
|
136
|
+
this.weight = 400;
|
|
137
|
+
/**
|
|
138
|
+
* A value from 20 to 48 indicating the optical size of the icon.
|
|
139
|
+
* @default 24
|
|
140
|
+
*/
|
|
141
|
+
this.opticalSize = 24;
|
|
142
|
+
}
|
|
143
|
+
/** @inheritdoc */
|
|
144
|
+
connectedCallback() {
|
|
145
|
+
if (!this.hasAttribute("aria-label") &&
|
|
146
|
+
!this.hasAttribute("aria-labelledby") &&
|
|
147
|
+
!this.hasAttribute("aria-hidden")) {
|
|
148
|
+
this.ariaHidden = "true";
|
|
149
|
+
}
|
|
150
|
+
super.connectedCallback();
|
|
151
|
+
}
|
|
152
|
+
/** @inheritdoc */
|
|
153
|
+
updated(_changedProperties) {
|
|
154
|
+
super.updated(_changedProperties);
|
|
155
|
+
if (_changedProperties.has("filled")) {
|
|
156
|
+
this._icon?.style.setProperty("--_icon-fill", this.filled ? "1" : "0");
|
|
157
|
+
}
|
|
158
|
+
if (_changedProperties.has("grade")) {
|
|
159
|
+
this._icon?.style.setProperty("--_icon-grade", this.grade === "low" ? "-25" : this.grade === "high" ? "200" : "0");
|
|
160
|
+
}
|
|
161
|
+
if (_changedProperties.has("weight")) {
|
|
162
|
+
this._icon?.style.setProperty("--_icon-weight", `${this.weight}`);
|
|
163
|
+
}
|
|
164
|
+
if (_changedProperties.has("opticalSize")) {
|
|
165
|
+
this._icon?.style.setProperty("--_icon-optical-size", `${this.opticalSize}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** @inheritdoc */
|
|
169
|
+
render() {
|
|
170
|
+
return html `<div class="icon" aria-hidden="true">${this.name}</div>`;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
/** The styles of the element. */
|
|
174
|
+
M3eIconElement.styles = css `
|
|
175
|
+
:host {
|
|
176
|
+
display: inline-block;
|
|
177
|
+
user-select: none;
|
|
178
|
+
font-size: var(--m3e-icon-size, 1.5rem);
|
|
179
|
+
width: 1em;
|
|
180
|
+
vertical-align: middle;
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
}
|
|
183
|
+
.icon {
|
|
184
|
+
font-weight: normal;
|
|
185
|
+
font-style: normal;
|
|
186
|
+
line-height: 1;
|
|
187
|
+
letter-spacing: normal;
|
|
188
|
+
text-transform: none;
|
|
189
|
+
white-space: nowrap;
|
|
190
|
+
word-wrap: normal;
|
|
191
|
+
direction: ltr;
|
|
192
|
+
font-feature-settings: "liga";
|
|
193
|
+
-webkit-font-smoothing: antialiased;
|
|
194
|
+
width: inherit;
|
|
195
|
+
height: inherit;
|
|
196
|
+
vertical-align: inherit;
|
|
197
|
+
font-variation-settings: "FILL" var(--_icon-fill, 0), "wght" var(--_icon-weight, 400),
|
|
198
|
+
"GRAD" var(--_icon-grade, 0), "opsz" var(--_icon-optical-size, 24);
|
|
199
|
+
}
|
|
200
|
+
:host([variant="outlined"]) .icon {
|
|
201
|
+
font-family: "Material Symbols Outlined";
|
|
202
|
+
}
|
|
203
|
+
:host([variant="rounded"]) .icon {
|
|
204
|
+
font-family: "Material Symbols Rounded";
|
|
205
|
+
}
|
|
206
|
+
:host([variant="sharp"]) .icon {
|
|
207
|
+
font-family: "Material Symbols Sharp";
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
210
|
+
__decorate([
|
|
211
|
+
e(".icon")
|
|
212
|
+
], M3eIconElement.prototype, "_icon", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
n()
|
|
215
|
+
], M3eIconElement.prototype, "name", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
n({ reflect: true })
|
|
218
|
+
], M3eIconElement.prototype, "variant", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
n({ type: Boolean, reflect: true })
|
|
221
|
+
], M3eIconElement.prototype, "filled", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
n()
|
|
224
|
+
], M3eIconElement.prototype, "grade", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
n({ type: Number })
|
|
227
|
+
], M3eIconElement.prototype, "weight", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
n({ attribute: "optical-size", type: Number })
|
|
230
|
+
], M3eIconElement.prototype, "opticalSize", void 0);
|
|
231
|
+
M3eIconElement = __decorate([
|
|
232
|
+
t$1("m3e-icon")
|
|
233
|
+
], M3eIconElement);
|
|
234
|
+
|
|
235
|
+
export { M3eIconElement };
|
|
236
|
+
//# sourceMappingURL=index.js.map
|