@m3e/button 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 +193 -0
- package/cem.config.mjs +16 -0
- package/demo/index.html +105 -0
- package/dist/css-custom-data.json +1582 -0
- package/dist/custom-elements.json +1753 -0
- package/dist/html-custom-data.json +83 -0
- package/dist/index.js +1781 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +468 -0
- package/dist/index.min.js.map +1 -0
- package/dist/src/ButtonElement.d.ts +429 -0
- package/dist/src/ButtonElement.d.ts.map +1 -0
- package/dist/src/ButtonShape.d.ts +3 -0
- package/dist/src/ButtonShape.d.ts.map +1 -0
- package/dist/src/ButtonSize.d.ts +3 -0
- package/dist/src/ButtonSize.d.ts.map +1 -0
- package/dist/src/ButtonVariant.d.ts +3 -0
- package/dist/src/ButtonVariant.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/styles/ButtonSizeStyle.d.ts +7 -0
- package/dist/src/styles/ButtonSizeStyle.d.ts.map +1 -0
- package/dist/src/styles/ButtonSizeToken.d.ts +27 -0
- package/dist/src/styles/ButtonSizeToken.d.ts.map +1 -0
- package/dist/src/styles/ButtonStyle.d.ts +7 -0
- package/dist/src/styles/ButtonStyle.d.ts.map +1 -0
- package/dist/src/styles/ButtonVariantStyle.d.ts +7 -0
- package/dist/src/styles/ButtonVariantStyle.d.ts.map +1 -0
- package/dist/src/styles/ButtonVariantToken.d.ts +75 -0
- package/dist/src/styles/ButtonVariantToken.d.ts.map +1 -0
- package/dist/src/styles/index.d.ts +4 -0
- package/dist/src/styles/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/ButtonElement.ts +629 -0
- package/src/ButtonShape.ts +2 -0
- package/src/ButtonSize.ts +2 -0
- package/src/ButtonVariant.ts +2 -0
- package/src/index.ts +4 -0
- package/src/styles/ButtonSizeStyle.ts +102 -0
- package/src/styles/ButtonSizeToken.ts +180 -0
- package/src/styles/ButtonStyle.ts +191 -0
- package/src/styles/ButtonVariantStyle.ts +170 -0
- package/src/styles/ButtonVariantToken.ts +1165 -0
- package/src/styles/index.ts +3 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { CSSResultGroup, html, LitElement, nothing, PropertyValues } from "lit";
|
|
2
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
renderPseudoLink,
|
|
6
|
+
AttachInternals,
|
|
7
|
+
Disabled,
|
|
8
|
+
DisabledInteractive,
|
|
9
|
+
Focusable,
|
|
10
|
+
FocusController,
|
|
11
|
+
FormSubmitter,
|
|
12
|
+
LinkButton,
|
|
13
|
+
M3eElevationElement,
|
|
14
|
+
M3eFocusRingElement,
|
|
15
|
+
M3eRippleElement,
|
|
16
|
+
M3eStateLayerElement,
|
|
17
|
+
PressedController,
|
|
18
|
+
Role,
|
|
19
|
+
KeyboardClick,
|
|
20
|
+
hasAssignedNodes,
|
|
21
|
+
ResizeController,
|
|
22
|
+
debounce,
|
|
23
|
+
} from "@m3e/core";
|
|
24
|
+
|
|
25
|
+
import { ButtonShape } from "./ButtonShape";
|
|
26
|
+
import { ButtonSize } from "./ButtonSize";
|
|
27
|
+
import { ButtonVariant } from "./ButtonVariant";
|
|
28
|
+
|
|
29
|
+
import { ButtonSizeStyle, ButtonStyle, ButtonVariantStyle } from "./styles";
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @summary
|
|
33
|
+
* A button users interact with to perform an action.
|
|
34
|
+
*
|
|
35
|
+
* @description
|
|
36
|
+
* The `m3e-button` component is a semantic, expressive UI primitive users interact with to perform an action.
|
|
37
|
+
* Designed according to Material Design 3 guidelines, it supports five visual variants, specified using the
|
|
38
|
+
* `variant` attribute—`filled`, `tonal`, `elevated`, `outlined`, and `text`—each with dynamic elevation,
|
|
39
|
+
* shape morphing, and adaptive color theming. The component responds to interaction states (hover, focus, press, disabled)
|
|
40
|
+
* with smooth motion transitions, ensuring emotional clarity and visual hierarchy.
|
|
41
|
+
*
|
|
42
|
+
* The component is accessible by default, with ARIA roles, contrast-safe color tokens, and strong focus indicators.
|
|
43
|
+
* It supports optional icons and states for binary actions. When using `m3e-icon` for icons, `filled` is automatically
|
|
44
|
+
* set based on the selected state of a toggle button. It can also function as a link or be used to submit form data.
|
|
45
|
+
*
|
|
46
|
+
* Native disabled `<button>` elements cannot receive focus. This can be problematic in some cases because it can prevent you
|
|
47
|
+
* from telling the user why the button is disabled. You can use the `disabled-interactive` attribute to style a `m3e-button`
|
|
48
|
+
* as disabled but allow for it to receive focus. The button will have `aria-disabled="true"` for assistive technology.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* The following example illustrates changing the appearance from `text` (default), to `tonal` using the `variant` attribute.
|
|
52
|
+
* ```html
|
|
53
|
+
* <m3e-button variant="tonal">Tonal Button</m3e-button>
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @tag m3e-button
|
|
57
|
+
*
|
|
58
|
+
* @slot - Renders the label of the button.
|
|
59
|
+
* @slot icon - Renders an icon before the button's label.
|
|
60
|
+
* @slot selected - Renders the label of the button, when selected.
|
|
61
|
+
* @slot selected-icon - Renders an icon before the button's label, when selected.
|
|
62
|
+
* @slot trailing-icon - Renders an icon after the button's label.
|
|
63
|
+
*
|
|
64
|
+
* @attr disabled - Whether the element is disabled.
|
|
65
|
+
* @attr disabled-interactive - Whether the element is disabled and interactive.
|
|
66
|
+
* @attr download - A value indicating whether the `target` of the link button will be downloaded, optionally specifying the new name of the file.
|
|
67
|
+
* @attr href - The URL to which the link button points.
|
|
68
|
+
* @attr name - The name of the element, submitted as a pair with the element's `value` as part of form data, when the element is used to submit a form.
|
|
69
|
+
* @attr rel - The relationship between the `target` of the link button and the document.
|
|
70
|
+
* @attr selected - Whether the toggle button is selected.
|
|
71
|
+
* @attr shape - The shape of the button.
|
|
72
|
+
* @attr size - The size of the button.
|
|
73
|
+
* @attr target - The target of the link button.
|
|
74
|
+
* @attr toggle - Whether the button will toggle between selected and unselected states.
|
|
75
|
+
* @attr type - The type of the element.
|
|
76
|
+
* @attr value - The value associated with the element's name when it's submitted with form data.
|
|
77
|
+
* @attr variant - The appearance variant of the button.
|
|
78
|
+
*
|
|
79
|
+
* @fires input - Dispatched when a toggle button's selected state changes.
|
|
80
|
+
* @fires change - Dispatched when a toggle button's selected state changes.
|
|
81
|
+
*
|
|
82
|
+
* @cssprop --m3e-button-extra-small-container-height - Height of the button container, for the extra-small size variant.
|
|
83
|
+
* @cssprop --m3e-button-extra-small-outline-thickness - Thickness of the button outline, for the extra-small size variant.
|
|
84
|
+
* @cssprop --m3e-button-extra-small-label-text-font-size - Font size for the label text, for the extra-small size variant.
|
|
85
|
+
* @cssprop --m3e-button-extra-small-label-text-font-weight - Font weight for the label text, for the extra-small size variant.
|
|
86
|
+
* @cssprop --m3e-button-extra-small-label-text-line-height - Line height for the label text, for the extra-small size variant.
|
|
87
|
+
* @cssprop --m3e-button-extra-small-label-text-tracking - Letter tracking for the label text, for the extra-small size variant.
|
|
88
|
+
* @cssprop --m3e-button-extra-small-icon-size - Size of the icon, for the extra-small size variant.
|
|
89
|
+
* @cssprop --m3e-button-extra-small-shape-round - Corner radius for round shape, for the extra-small size variant.
|
|
90
|
+
* @cssprop --m3e-button-extra-small-shape-square - Corner radius for square shape, for the extra-small size variant.
|
|
91
|
+
* @cssprop --m3e-button-extra-small-selected-shape-round - Corner radius when selected (round), for the extra-small size variant.
|
|
92
|
+
* @cssprop --m3e-button-extra-small-selected-shape-square - Corner radius when selected (square), for the extra-small size variant.
|
|
93
|
+
* @cssprop --m3e-button-extra-small-shape-pressed-morph - Corner radius when pressed, for the extra-small size variant.
|
|
94
|
+
* @cssprop --m3e-button-extra-small-leading-space - Space before icon or label, for the extra-small size variant.
|
|
95
|
+
* @cssprop --m3e-button-extra-small-trailing-space - Space after icon or label, for the extra-small size variant.
|
|
96
|
+
* @cssprop --m3e-button-extra-small-icon-label-space - Space between icon and label, for the extra-small size variant.
|
|
97
|
+
* @cssprop --m3e-button-small-container-height - Height of the button container, for the small size variant.
|
|
98
|
+
* @cssprop --m3e-button-small-outline-thickness - Thickness of the button outline, for the small size variant.
|
|
99
|
+
* @cssprop --m3e-button-small-label-text-font-size - Font size for the label text, for the small size variant.
|
|
100
|
+
* @cssprop --m3e-button-small-label-text-font-weight - Font weight for the label text, for the small size variant.
|
|
101
|
+
* @cssprop --m3e-button-small-label-text-line-height - Line height for the label text, for the small size variant.
|
|
102
|
+
* @cssprop --m3e-button-small-label-text-tracking - Letter tracking for the label text, for the small size variant.
|
|
103
|
+
* @cssprop --m3e-button-small-icon-size - Size of the icon, for the small size variant.
|
|
104
|
+
* @cssprop --m3e-button-small-shape-round - Corner radius for round shape, for the small size variant.
|
|
105
|
+
* @cssprop --m3e-button-small-shape-square - Corner radius for square shape, for the small size variant.
|
|
106
|
+
* @cssprop --m3e-button-small-selected-shape-round - Corner radius when selected (round), for the small size variant.
|
|
107
|
+
* @cssprop --m3e-button-small-selected-shape-square - Corner radius when selected (square), for the small size variant.
|
|
108
|
+
* @cssprop --m3e-button-small-shape-pressed-morph - Corner radius when pressed, for the small size variant.
|
|
109
|
+
* @cssprop --m3e-button-small-leading-space - Space before icon or label, for the small size variant.
|
|
110
|
+
* @cssprop --m3e-button-small-trailing-space - Space after icon or label, for the small size variant.
|
|
111
|
+
* @cssprop --m3e-button-small-icon-label-space - Space between icon and label, for the small size variant.
|
|
112
|
+
* @cssprop --m3e-button-medium-container-height - Height of the button container, for the medium size variant.
|
|
113
|
+
* @cssprop --m3e-button-medium-outline-thickness - Thickness of the button outline, for the medium size variant.
|
|
114
|
+
* @cssprop --m3e-button-medium-label-text-font-size - Font size for the label text, for the medium size variant.
|
|
115
|
+
* @cssprop --m3e-button-medium-label-text-font-weight - Font weight for the label text, for the medium size variant.
|
|
116
|
+
* @cssprop --m3e-button-medium-label-text-line-height - Line height for the label text, for the medium size variant.
|
|
117
|
+
* @cssprop --m3e-button-medium-label-text-tracking - Letter tracking for the label text, for the medium size variant.
|
|
118
|
+
* @cssprop --m3e-button-medium-icon-size - Size of the icon, for the medium size variant.
|
|
119
|
+
* @cssprop --m3e-button-medium-shape-round - Corner radius for round shape, for the medium size variant.
|
|
120
|
+
* @cssprop --m3e-button-medium-shape-square - Corner radius for square shape, for the medium size variant.
|
|
121
|
+
* @cssprop --m3e-button-medium-selected-shape-round - Corner radius when selected (round), for the medium size variant.
|
|
122
|
+
* @cssprop --m3e-button-medium-selected-shape-square - Corner radius when selected (square), for the medium size variant.
|
|
123
|
+
* @cssprop --m3e-button-medium-shape-pressed-morph - Corner radius when pressed, for the medium size variant.
|
|
124
|
+
* @cssprop --m3e-button-medium-leading-space - Space before icon or label, for the medium size variant.
|
|
125
|
+
* @cssprop --m3e-button-medium-trailing-space - Space after icon or label, for the medium size variant.
|
|
126
|
+
* @cssprop --m3e-button-medium-icon-label-space - Space between icon and label, for the medium size variant.
|
|
127
|
+
* @cssprop --m3e-button-large-container-height - Height of the button container, for the large size variant.
|
|
128
|
+
* @cssprop --m3e-button-large-outline-thickness - Thickness of the button outline, for the large size variant.
|
|
129
|
+
* @cssprop --m3e-button-large-label-text-font-size - Font size for the label text, for the large size variant.
|
|
130
|
+
* @cssprop --m3e-button-large-label-text-font-weight - Font weight for the label text, for the large size variant.
|
|
131
|
+
* @cssprop --m3e-button-large-label-text-line-height - Line height for the label text, for the large size variant.
|
|
132
|
+
* @cssprop --m3e-button-large-label-text-tracking - Letter tracking for the label text, for the large size variant.
|
|
133
|
+
* @cssprop --m3e-button-large-icon-size - Size of the icon, for the large size variant.
|
|
134
|
+
* @cssprop --m3e-button-large-shape-round - Corner radius for round shape, for the large size variant.
|
|
135
|
+
* @cssprop --m3e-button-large-shape-square - Corner radius for square shape, for the large size variant.
|
|
136
|
+
* @cssprop --m3e-button-large-selected-shape-round - Corner radius when selected (round), for the large size variant.
|
|
137
|
+
* @cssprop --m3e-button-large-selected-shape-square - Corner radius when selected (square), for the large size variant.
|
|
138
|
+
* @cssprop --m3e-button-large-shape-pressed-morph - Corner radius when pressed, for the large size variant.
|
|
139
|
+
* @cssprop --m3e-button-large-leading-space - Space before icon or label, for the large size variant.
|
|
140
|
+
* @cssprop --m3e-button-large-trailing-space - Space after icon or label, for the large size variant.
|
|
141
|
+
* @cssprop --m3e-button-large-icon-label-space - Space between icon and label, for the large size variant.
|
|
142
|
+
* @cssprop --m3e-button-extra-large-container-height - Height of the button container, for the extra-large size variant.
|
|
143
|
+
* @cssprop --m3e-button-extra-large-outline-thickness - Thickness of the button outline, for the extra-large size variant.
|
|
144
|
+
* @cssprop --m3e-button-extra-large-label-text-font-size - Font size for the label text, for the extra-large size variant.
|
|
145
|
+
* @cssprop --m3e-button-extra-large-label-text-font-weight - Font weight for the label text, for the extra-large size variant.
|
|
146
|
+
* @cssprop --m3e-button-extra-large-label-text-line-height - Line height for the label text, for the extra-large size variant.
|
|
147
|
+
* @cssprop --m3e-button-extra-large-label-text-tracking - Letter tracking for the label text, for the extra-large size variant.
|
|
148
|
+
* @cssprop --m3e-button-extra-large-icon-size - Size of the icon, for the extra-large size variant.
|
|
149
|
+
* @cssprop --m3e-button-extra-large-shape-round - Corner radius for round shape, for the extra-large size variant.
|
|
150
|
+
* @cssprop --m3e-button-extra-large-shape-square - Corner radius for square shape, for the extra-large size variant.
|
|
151
|
+
* @cssprop --m3e-button-extra-large-selected-shape-round - Corner radius when selected (round), for the extra-large size variant.
|
|
152
|
+
* @cssprop --m3e-button-extra-large-selected-shape-square - Corner radius when selected (square), for the extra-large size variant.
|
|
153
|
+
* @cssprop --m3e-button-extra-large-shape-pressed-morph - Corner radius when pressed, for the extra-large size variant.
|
|
154
|
+
* @cssprop --m3e-button-extra-large-leading-space - Space before icon or label, for the extra-large size variant.
|
|
155
|
+
* @cssprop --m3e-button-extra-large-trailing-space - Space after icon or label, for the extra-large size variant.
|
|
156
|
+
* @cssprop --m3e-button-extra-large-icon-label-space - Space between icon and label, for the extra-large size variant.
|
|
157
|
+
* @cssprop --m3e-elevated-button-label-text-color - Label color, for the elevated variant.
|
|
158
|
+
* @cssprop --m3e-elevated-button-icon-color - Icon color, for the elevated variant.
|
|
159
|
+
* @cssprop --m3e-elevated-button-container-color - Container background color, for the elevated variant.
|
|
160
|
+
* @cssprop --m3e-elevated-button-container-elevation - Elevation, for the elevated variant.
|
|
161
|
+
* @cssprop --m3e-elevated-button-unselected-label-text-color - Unselected label color, for the elevated variant.
|
|
162
|
+
* @cssprop --m3e-elevated-button-unselected-icon-color - Unselected icon color, for the elevated variant.
|
|
163
|
+
* @cssprop --m3e-elevated-button-unselected-container-color - Unselected container color, for the elevated variant.
|
|
164
|
+
* @cssprop --m3e-elevated-button-selected-label-text-color - Selected label color, for the elevated variant.
|
|
165
|
+
* @cssprop --m3e-elevated-button-selected-icon-color - Selected icon color, for the elevated variant.
|
|
166
|
+
* @cssprop --m3e-elevated-button-selected-container-color - Selected container color, for the elevated variant.
|
|
167
|
+
* @cssprop --m3e-elevated-button-disabled-container-color - Disabled container color, for the elevated variant.
|
|
168
|
+
* @cssprop --m3e-elevated-button-disabled-container-opacity - Disabled container opacity, for the elevated variant.
|
|
169
|
+
* @cssprop --m3e-elevated-button-disabled-icon-color - Disabled icon color, for the elevated variant.
|
|
170
|
+
* @cssprop --m3e-elevated-button-disabled-icon-opacity - Disabled icon opacity, for the elevated variant.
|
|
171
|
+
* @cssprop --m3e-elevated-button-disabled-label-text-color - Disabled label color, for the elevated variant.
|
|
172
|
+
* @cssprop --m3e-elevated-button-disabled-label-text-opacity - Disabled label opacity, for the elevated variant.
|
|
173
|
+
* @cssprop --m3e-elevated-button-disabled-container-elevation - Disabled elevation, for the elevated variant.
|
|
174
|
+
* @cssprop --m3e-elevated-button-hover-icon-color - Hover icon color, for the elevated variant.
|
|
175
|
+
* @cssprop --m3e-elevated-button-hover-label-text-color - Hover label color, for the elevated variant.
|
|
176
|
+
* @cssprop --m3e-elevated-button-hover-state-layer-color - Hover state layer color, for the elevated variant.
|
|
177
|
+
* @cssprop --m3e-elevated-button-hover-state-layer-opacity - Hover state layer opacity, for the elevated variant.
|
|
178
|
+
* @cssprop --m3e-elevated-button-hover-container-elevation - Hover elevation, for the elevated variant.
|
|
179
|
+
* @cssprop --m3e-elevated-button-hover-unselected-icon-color - Hover unselected icon color, for the elevated variant.
|
|
180
|
+
* @cssprop --m3e-elevated-button-hover-unselected-label-text-color - Hover unselected label color, for the elevated variant.
|
|
181
|
+
* @cssprop --m3e-elevated-button-hover-unselected-state-layer-color - Hover unselected state layer color, for the elevated variant.
|
|
182
|
+
* @cssprop --m3e-elevated-button-hover-selected-icon-color - Hover selected icon color, for the elevated variant.
|
|
183
|
+
* @cssprop --m3e-elevated-button-hover-selected-label-text-color - Hover selected label color, for the elevated variant.
|
|
184
|
+
* @cssprop --m3e-elevated-button-hover-selected-state-layer-color - Hover selected state layer color, for the elevated variant.
|
|
185
|
+
* @cssprop --m3e-elevated-button-focus-icon-color - Focus icon color, for the elevated variant.
|
|
186
|
+
* @cssprop --m3e-elevated-button-focus-label-text-color - Focus label color, for the elevated variant.
|
|
187
|
+
* @cssprop --m3e-elevated-button-focus-state-layer-color - Focus state layer color, for the elevated variant.
|
|
188
|
+
* @cssprop --m3e-elevated-button-focus-state-layer-opacity - Focus state layer opacity, for the elevated variant.
|
|
189
|
+
* @cssprop --m3e-elevated-button-focus-container-elevation - Focus elevation, for the elevated variant.
|
|
190
|
+
* @cssprop --m3e-elevated-button-focus-unselected-label-text-color - Focus unselected label color, for the elevated variant.
|
|
191
|
+
* @cssprop --m3e-elevated-button-focus-unselected-icon-color - Focus unselected icon color, for the elevated variant.
|
|
192
|
+
* @cssprop --m3e-elevated-button-focus-unselected-state-layer-color - Focus unselected state layer color, for the elevated variant.
|
|
193
|
+
* @cssprop --m3e-elevated-button-focus-selected-icon-color - Focus selected icon color, for the elevated variant.
|
|
194
|
+
* @cssprop --m3e-elevated-button-focus-selected-label-text-color - Focus selected label color, for the elevated variant.
|
|
195
|
+
* @cssprop --m3e-elevated-button-focus-selected-state-layer-color - Focus selected state layer color, for the elevated variant.
|
|
196
|
+
* @cssprop --m3e-elevated-button-pressed-icon-color - Pressed icon color, for the elevated variant.
|
|
197
|
+
* @cssprop --m3e-elevated-button-pressed-label-text-color - Pressed label color, for the elevated variant.
|
|
198
|
+
* @cssprop --m3e-elevated-button-pressed-state-layer-color - Pressed state layer color, for the elevated variant.
|
|
199
|
+
* @cssprop --m3e-elevated-button-pressed-state-layer-opacity - Pressed state layer opacity, for the elevated variant.
|
|
200
|
+
* @cssprop --m3e-elevated-button-pressed-container-elevation - Pressed elevation, for the elevated variant.
|
|
201
|
+
* @cssprop --m3e-elevated-button-pressed-unselected-label-text-color - Pressed unselected label color, for the elevated variant.
|
|
202
|
+
* @cssprop --m3e-elevated-button-pressed-unselected-icon-color - Pressed unselected icon color, for the elevated variant.
|
|
203
|
+
* @cssprop --m3e-elevated-button-pressed-unselected-state-layer-color - Pressed unselected state layer color, for the elevated variant.
|
|
204
|
+
* @cssprop --m3e-elevated-button-pressed-selected-icon-color - Pressed selected icon color, for the elevated variant.
|
|
205
|
+
* @cssprop --m3e-elevated-button-pressed-selected-label-text-color - Pressed selected label color, for the elevated variant.
|
|
206
|
+
* @cssprop --m3e-elevated-button-pressed-selected-state-layer-color - Pressed selected state layer color, for the elevated variant.
|
|
207
|
+
* @cssprop --m3e-outlined-button-label-text-color - Label color, for the outlined variant.
|
|
208
|
+
* @cssprop --m3e-outlined-button-icon-color - Icon color, for the outlined variant.
|
|
209
|
+
* @cssprop --m3e-outlined-button-outline-color - Outline color, for the outlined variant.
|
|
210
|
+
* @cssprop --m3e-outlined-button-unselected-label-text-color - Unselected label color, for the outlined variant.
|
|
211
|
+
* @cssprop --m3e-outlined-button-unselected-icon-color - Unselected icon color, for the outlined variant.
|
|
212
|
+
* @cssprop --m3e-outlined-button-selected-label-text-color - Selected label color, for the outlined variant.
|
|
213
|
+
* @cssprop --m3e-outlined-button-selected-icon-color - Selected icon color, for the outlined variant.
|
|
214
|
+
* @cssprop --m3e-outlined-button-selected-container-color - Selected container color, for the outlined variant.
|
|
215
|
+
* @cssprop --m3e-outlined-button-disabled-container-color - Disabled container color, for the outlined variant.
|
|
216
|
+
* @cssprop --m3e-outlined-button-disabled-container-opacity - Disabled container opacity, for the outlined variant.
|
|
217
|
+
* @cssprop --m3e-outlined-button-disabled-icon-color - Disabled icon color, for the outlined variant.
|
|
218
|
+
* @cssprop --m3e-outlined-button-disabled-icon-opacity - Disabled icon opacity, for the outlined variant.
|
|
219
|
+
* @cssprop --m3e-outlined-button-disabled-label-text-color - Disabled label color, for the outlined variant.
|
|
220
|
+
* @cssprop --m3e-outlined-button-disabled-label-text-opacity - Disabled label opacity, for the outlined variant.
|
|
221
|
+
* @cssprop --m3e-outlined-button-disabled-outline-color - Disabled outline color, for the outlined variant.
|
|
222
|
+
* @cssprop --m3e-outlined-button-hover-icon-color - Hover icon color, for the outlined variant.
|
|
223
|
+
* @cssprop --m3e-outlined-button-hover-label-text-color - Hover label color, for the outlined variant.
|
|
224
|
+
* @cssprop --m3e-outlined-button-hover-outline-color - Hover outline color, for the outlined variant.
|
|
225
|
+
* @cssprop --m3e-outlined-button-hover-state-layer-color - Hover state layer color, for the outlined variant.
|
|
226
|
+
* @cssprop --m3e-outlined-button-hover-state-layer-opacity - Hover state layer opacity, for the outlined variant.
|
|
227
|
+
* @cssprop --m3e-outlined-button-hover-unselected-icon-color - Hover unselected icon color, for the outlined variant.
|
|
228
|
+
* @cssprop --m3e-outlined-button-hover-unselected-label-text-color - Hover unselected label color, for the outlined variant.
|
|
229
|
+
* @cssprop --m3e-outlined-button-hover-unselected-state-layer-color - Hover unselected state layer color, for the outlined variant.
|
|
230
|
+
* @cssprop --m3e-outlined-button-hover-selected-icon-color - Hover selected icon color, for the outlined variant.
|
|
231
|
+
* @cssprop --m3e-outlined-button-hover-selected-label-text-color - Hover selected label color, for the outlined variant.
|
|
232
|
+
* @cssprop --m3e-outlined-button-hover-selected-state-layer-color - Hover selected state layer color, for the outlined variant.
|
|
233
|
+
* @cssprop --m3e-outlined-button-focus-icon-color - Focus icon color, for the outlined variant.
|
|
234
|
+
* @cssprop --m3e-outlined-button-focus-label-text-color - Focus label color, for the outlined variant.
|
|
235
|
+
* @cssprop --m3e-outlined-button-focus-outline-color - Focus outline color, for the outlined variant.
|
|
236
|
+
* @cssprop --m3e-outlined-button-focus-state-layer-color - Focus state layer color, for the outlined variant.
|
|
237
|
+
* @cssprop --m3e-outlined-button-focus-state-layer-opacity - Focus state layer opacity, for the outlined variant.
|
|
238
|
+
* @cssprop --m3e-outlined-button-focus-unselected-icon-color - Focus unselected icon color, for the outlined variant.
|
|
239
|
+
* @cssprop --m3e-outlined-button-focus-unselected-label-text-color - Focus unselected label color, for the outlined variant.
|
|
240
|
+
* @cssprop --m3e-outlined-button-focus-unselected-state-layer-color - Focus unselected state layer color, for the outlined variant.
|
|
241
|
+
* @cssprop --m3e-outlined-button-focus-selected-icon-color - Focus selected icon color, for the outlined variant.
|
|
242
|
+
* @cssprop --m3e-outlined-button-focus-selected-label-text-color - Focus selected label color, for the outlined variant.
|
|
243
|
+
* @cssprop --m3e-outlined-button-focus-selected-state-layer-color - Focus selected state layer color, for the outlined variant.
|
|
244
|
+
* @cssprop --m3e-outlined-button-pressed-icon-color - Pressed icon color, for the outlined variant.
|
|
245
|
+
* @cssprop --m3e-outlined-button-pressed-label-text-color - Pressed label color, for the outlined variant.
|
|
246
|
+
* @cssprop --m3e-outlined-button-pressed-outline-color - Pressed outline color, for the outlined variant.
|
|
247
|
+
* @cssprop --m3e-outlined-button-pressed-state-layer-color - Pressed state layer color, for the outlined variant.
|
|
248
|
+
* @cssprop --m3e-outlined-button-pressed-state-layer-opacity - Pressed state layer opacity, for the outlined variant.
|
|
249
|
+
* @cssprop --m3e-outlined-button-pressed-unselected-icon-color - Pressed unselected icon color, for the outlined variant.
|
|
250
|
+
* @cssprop --m3e-outlined-button-pressed-unselected-label-text-color - Pressed unselected label color, for the outlined variant.
|
|
251
|
+
* @cssprop --m3e-outlined-button-pressed-unselected-state-layer-color - Pressed unselected state layer color, for the outlined variant.
|
|
252
|
+
* @cssprop --m3e-outlined-button-pressed-selected-icon-color - Pressed selected icon color, for the outlined variant.
|
|
253
|
+
* @cssprop --m3e-outlined-button-pressed-selected-label-text-color - Pressed selected label color, for the outlined variant.
|
|
254
|
+
* @cssprop --m3e-outlined-button-pressed-selected-state-layer-color - Pressed selected state layer color, for the outlined variant.
|
|
255
|
+
* @cssprop --m3e-filled-button-label-text-color - Label color, for the filled variant.
|
|
256
|
+
* @cssprop --m3e-filled-button-icon-color - Icon color, for the filled variant.
|
|
257
|
+
* @cssprop --m3e-filled-button-container-color - Container background color, for the filled variant.
|
|
258
|
+
* @cssprop --m3e-filled-button-container-elevation - Elevation, for the filled variant.
|
|
259
|
+
* @cssprop --m3e-filled-button-unselected-label-text-color - Unselected label color, for the filled variant.
|
|
260
|
+
* @cssprop --m3e-filled-button-unselected-icon-color - Unselected icon color, for the filled variant.
|
|
261
|
+
* @cssprop --m3e-filled-button-unselected-container-color - Unselected container color, for the filled variant.
|
|
262
|
+
* @cssprop --m3e-filled-button-selected-label-text-color - Selected label color, for the filled variant.
|
|
263
|
+
* @cssprop --m3e-filled-button-selected-icon-color - Selected icon color, for the filled variant.
|
|
264
|
+
* @cssprop --m3e-filled-button-selected-container-color - Selected container color, for the filled variant.
|
|
265
|
+
* @cssprop --m3e-filled-button-disabled-container-color - Disabled container color, for the filled variant.
|
|
266
|
+
* @cssprop --m3e-filled-button-disabled-container-opacity - Disabled container opacity, for the filled variant.
|
|
267
|
+
* @cssprop --m3e-filled-button-disabled-icon-color - Disabled icon color, for the filled variant.
|
|
268
|
+
* @cssprop --m3e-filled-button-disabled-icon-opacity - Disabled icon opacity, for the filled variant.
|
|
269
|
+
* @cssprop --m3e-filled-button-disabled-label-text-color - Disabled label color, for the filled variant.
|
|
270
|
+
* @cssprop --m3e-filled-button-disabled-label-text-opacity - Disabled label opacity, for the filled variant.
|
|
271
|
+
* @cssprop --m3e-filled-button-disabled-container-elevation - Disabled elevation, for the filled variant.
|
|
272
|
+
* @cssprop --m3e-filled-button-hover-icon-color - Hover icon color, for the filled variant.
|
|
273
|
+
* @cssprop --m3e-filled-button-hover-label-text-color - Hover label color, for the filled variant.
|
|
274
|
+
* @cssprop --m3e-filled-button-hover-state-layer-color - Hover state layer color, for the filled variant.
|
|
275
|
+
* @cssprop --m3e-filled-button-hover-state-layer-opacity - Hover state layer opacity, for the filled variant.
|
|
276
|
+
* @cssprop --m3e-filled-button-hover-container-elevation - Hover elevation, for the filled variant.
|
|
277
|
+
* @cssprop --m3e-filled-button-hover-unselected-icon-color - Hover unselected icon color, for the filled variant.
|
|
278
|
+
* @cssprop --m3e-filled-button-hover-unselected-label-text-color - Hover unselected label color, for the filled variant.
|
|
279
|
+
* @cssprop --m3e-filled-button-hover-unselected-state-layer-color - Hover unselected state layer color, for the filled variant.
|
|
280
|
+
* @cssprop --m3e-filled-button-hover-selected-icon-color - Hover selected icon color, for the filled variant.
|
|
281
|
+
* @cssprop --m3e-filled-button-hover-selected-label-text-color - Hover selected label color, for the filled variant.
|
|
282
|
+
* @cssprop --m3e-filled-button-hover-selected-state-layer-color - Hover selected state layer color, for the filled variant.
|
|
283
|
+
* @cssprop --m3e-filled-button-focus-icon-color - Focus icon color, for the filled variant.
|
|
284
|
+
* @cssprop --m3e-filled-button-focus-label-text-color - Focus label color, for the filled variant.
|
|
285
|
+
* @cssprop --m3e-filled-button-focus-state-layer-color - Focus state layer color, for the filled variant.
|
|
286
|
+
* @cssprop --m3e-filled-button-focus-state-layer-opacity - Focus state layer opacity, for the filled variant.
|
|
287
|
+
* @cssprop --m3e-filled-button-focus-container-elevation - Focus elevation, for the filled variant.
|
|
288
|
+
* @cssprop --m3e-filled-button-focus-unselected-icon-color - Focus unselected icon color, for the filled variant.
|
|
289
|
+
* @cssprop --m3e-filled-button-focus-unselected-label-text-color - Focus unselected label color, for the filled variant.
|
|
290
|
+
* @cssprop --m3e-filled-button-focus-unselected-state-layer-color - Focus unselected state layer color, for the filled variant.
|
|
291
|
+
* @cssprop --m3e-filled-button-focus-selected-icon-color - Focus selected icon color, for the filled variant.
|
|
292
|
+
* @cssprop --m3e-filled-button-focus-selected-label-text-color - Focus selected label color, for the filled variant.
|
|
293
|
+
* @cssprop --m3e-filled-button-focus-selected-state-layer-color - Focus selected state layer color, for the filled variant.
|
|
294
|
+
* @cssprop --m3e-filled-button-pressed-icon-color - Pressed icon color, for the filled variant.
|
|
295
|
+
* @cssprop --m3e-filled-button-pressed-label-text-color - Pressed label color, for the filled variant.
|
|
296
|
+
* @cssprop --m3e-filled-button-pressed-state-layer-color - Pressed state layer color, for the filled variant.
|
|
297
|
+
* @cssprop --m3e-filled-button-pressed-state-layer-opacity - Pressed state layer opacity, for the filled variant.
|
|
298
|
+
* @cssprop --m3e-filled-button-pressed-container-elevation - Pressed elevation, for the filled variant.
|
|
299
|
+
* @cssprop --m3e-filled-button-pressed-unselected-icon-color - Pressed unselected icon color, for the filled variant.
|
|
300
|
+
* @cssprop --m3e-filled-button-pressed-unselected-label-text-color - Pressed unselected label color, for the filled variant.
|
|
301
|
+
* @cssprop --m3e-filled-button-pressed-unselected-state-layer-color - Pressed unselected state layer color, for the filled variant.
|
|
302
|
+
* @cssprop --m3e-filled-button-pressed-selected-icon-color - Pressed selected icon color, for the filled variant.
|
|
303
|
+
* @cssprop --m3e-filled-button-pressed-selected-label-text-color - Pressed selected label color, for the filled variant.
|
|
304
|
+
* @cssprop --m3e-filled-button-pressed-selected-state-layer-color - Pressed selected state layer color, for the filled variant.
|
|
305
|
+
* @cssprop --m3e-tonal-button-label-text-color - Label color, for the tonal variant.
|
|
306
|
+
* @cssprop --m3e-tonal-button-icon-color - Icon color, for the tonal variant.
|
|
307
|
+
* @cssprop --m3e-tonal-button-container-color - Container background color, for the tonal variant.
|
|
308
|
+
* @cssprop --m3e-tonal-button-container-elevation - Elevation, for the tonal variant.
|
|
309
|
+
* @cssprop --m3e-tonal-button-unselected-label-text-color - Unselected label color, for the tonal variant.
|
|
310
|
+
* @cssprop --m3e-tonal-button-unselected-icon-color - Unselected icon color, for the tonal variant.
|
|
311
|
+
* @cssprop --m3e-tonal-button-unselected-container-color - Unselected container color, for the tonal variant.
|
|
312
|
+
* @cssprop --m3e-tonal-button-selected-label-text-color - Selected label color, for the tonal variant.
|
|
313
|
+
* @cssprop --m3e-tonal-button-selected-icon-color - Selected icon color, for the tonal variant.
|
|
314
|
+
* @cssprop --m3e-tonal-button-selected-container-color - Selected container color, for the tonal variant.
|
|
315
|
+
* @cssprop --m3e-tonal-button-disabled-container-color - Disabled container color, for the tonal variant.
|
|
316
|
+
* @cssprop --m3e-tonal-button-disabled-container-opacity - Disabled container opacity, for the tonal variant.
|
|
317
|
+
* @cssprop --m3e-tonal-button-disabled-icon-color - Disabled icon color, for the tonal variant.
|
|
318
|
+
* @cssprop --m3e-tonal-button-disabled-icon-opacity - Disabled icon opacity, for the tonal variant.
|
|
319
|
+
* @cssprop --m3e-tonal-button-disabled-label-text-color - Disabled label color, for the tonal variant.
|
|
320
|
+
* @cssprop --m3e-tonal-button-disabled-label-text-opacity - Disabled label opacity, for the tonal variant.
|
|
321
|
+
* @cssprop --m3e-tonal-button-disabled-container-elevation - Disabled elevation, for the tonal variant.
|
|
322
|
+
* @cssprop --m3e-tonal-button-hover-icon-color - Hover icon color, for the tonal variant.
|
|
323
|
+
* @cssprop --m3e-tonal-button-hover-label-text-color - Hover label color, for the tonal variant.
|
|
324
|
+
* @cssprop --m3e-tonal-button-hover-state-layer-color - Hover state layer color, for the tonal variant.
|
|
325
|
+
* @cssprop --m3e-tonal-button-hover-state-layer-opacity - Hover state layer opacity, for the tonal variant.
|
|
326
|
+
* @cssprop --m3e-tonal-button-hover-container-elevation - Hover elevation, for the tonal variant.
|
|
327
|
+
* @cssprop --m3e-tonal-button-hover-unselected-icon-color - Hover unselected icon color, for the tonal variant.
|
|
328
|
+
* @cssprop --m3e-tonal-button-hover-unselected-label-text-color - Hover unselected label color, for the tonal variant.
|
|
329
|
+
* @cssprop --m3e-tonal-button-hover-unselected-state-layer-color - Hover unselected state layer color, for the tonal variant.
|
|
330
|
+
* @cssprop --m3e-tonal-button-hover-selected-icon-color - Hover selected icon color, for the tonal variant.
|
|
331
|
+
* @cssprop --m3e-tonal-button-hover-selected-label-text-color - Hover selected label color, for the tonal variant.
|
|
332
|
+
* @cssprop --m3e-tonal-button-hover-selected-state-layer-color - Hover selected state layer color, for the tonal variant.
|
|
333
|
+
* @cssprop --m3e-tonal-button-focus-icon-color - Focus icon color, for the tonal variant.
|
|
334
|
+
* @cssprop --m3e-tonal-button-focus-label-text-color - Focus label color, for the tonal variant.
|
|
335
|
+
* @cssprop --m3e-tonal-button-focus-state-layer-color - Focus state layer color, for the tonal variant.
|
|
336
|
+
* @cssprop --m3e-tonal-button-focus-state-layer-opacity - Focus state layer opacity, for the tonal variant.
|
|
337
|
+
* @cssprop --m3e-tonal-button-focus-container-elevation - Focus elevation, for the tonal variant.
|
|
338
|
+
* @cssprop --m3e-tonal-button-focus-unselected-icon-color - Focus unselected icon color, for the tonal variant.
|
|
339
|
+
* @cssprop --m3e-tonal-button-focus-unselected-label-text-color - Focus unselected label color, for the tonal variant.
|
|
340
|
+
* @cssprop --m3e-tonal-button-focus-unselected-state-layer-color - Focus unselected state layer color, for the tonal variant.
|
|
341
|
+
* @cssprop --m3e-tonal-button-focus-selected-icon-color - Focus selected icon color, for the tonal variant.
|
|
342
|
+
* @cssprop --m3e-tonal-button-focus-selected-label-text-color - Focus selected label color, for the tonal variant.
|
|
343
|
+
* @cssprop --m3e-tonal-button-focus-selected-state-layer-color - Focus selected state layer color, for the tonal variant.
|
|
344
|
+
* @cssprop --m3e-tonal-button-pressed-icon-color - Pressed icon color, for the tonal variant.
|
|
345
|
+
* @cssprop --m3e-tonal-button-pressed-label-text-color - Pressed label color, for the tonal variant.
|
|
346
|
+
* @cssprop --m3e-tonal-button-pressed-state-layer-color - Pressed state layer color, for the tonal variant.
|
|
347
|
+
* @cssprop --m3e-tonal-button-pressed-state-layer-opacity - Pressed state layer opacity, for the tonal variant.
|
|
348
|
+
* @cssprop --m3e-tonal-button-pressed-container-elevation - Pressed elevation, for the tonal variant.
|
|
349
|
+
* @cssprop --m3e-tonal-button-pressed-unselected-icon-color - Pressed unselected icon color, for the tonal variant.
|
|
350
|
+
* @cssprop --m3e-tonal-button-pressed-unselected-label-text-color - Pressed unselected label color, for the tonal variant.
|
|
351
|
+
* @cssprop --m3e-tonal-button-pressed-unselected-state-layer-color - Pressed unselected state layer color, for the tonal variant.
|
|
352
|
+
* @cssprop --m3e-tonal-button-pressed-selected-icon-color - Pressed selected icon color, for the tonal variant.
|
|
353
|
+
* @cssprop --m3e-tonal-button-pressed-selected-label-text-color - Pressed selected label color, for the tonal variant.
|
|
354
|
+
* @cssprop --m3e-tonal-button-pressed-selected-state-layer-color - Pressed selected state layer color, for the tonal variant.
|
|
355
|
+
* @cssprop --m3e-text-button-label-text-color - Label color, for the text variant.
|
|
356
|
+
* @cssprop --m3e-text-button-icon-color - Icon color, for the text variant.
|
|
357
|
+
* @cssprop --m3e-text-button-unselected-label-text-color - Unselected label color, for the text variant.
|
|
358
|
+
* @cssprop --m3e-text-button-unselected-icon-color - Unselected icon color, for the text variant.
|
|
359
|
+
* @cssprop --m3e-text-button-selected-label-text-color - Selected label color, for the text variant.
|
|
360
|
+
* @cssprop --m3e-text-button-selected-icon-color - Selected icon color, for the text variant.
|
|
361
|
+
* @cssprop --m3e-text-button-disabled-container-color - Disabled container color, for the text variant.
|
|
362
|
+
* @cssprop --m3e-text-button-disabled-container-opacity - Disabled container opacity, for the text variant.
|
|
363
|
+
* @cssprop --m3e-text-button-disabled-icon-color - Disabled icon color, for the text variant.
|
|
364
|
+
* @cssprop --m3e-text-button-disabled-icon-opacity - Disabled icon opacity, for the text variant.
|
|
365
|
+
* @cssprop --m3e-text-button-disabled-label-text-color - Disabled label color, for the text variant.
|
|
366
|
+
* @cssprop --m3e-text-button-disabled-label-text-opacity - Disabled label opacity, for the text variant.
|
|
367
|
+
* @cssprop --m3e-text-button-hover-icon-color - Hover icon color, for the text variant.
|
|
368
|
+
* @cssprop --m3e-text-button-hover-label-text-color - Hover label color, for the text variant.
|
|
369
|
+
* @cssprop --m3e-text-button-hover-state-layer-color - Hover state layer color, for the text variant.
|
|
370
|
+
* @cssprop --m3e-text-button-hover-state-layer-opacity - Hover state layer opacity, for the text variant.
|
|
371
|
+
* @cssprop --m3e-text-button-hover-unselected-icon-color - Hover unselected icon color, for the text variant.
|
|
372
|
+
* @cssprop --m3e-text-button-hover-unselected-label-text-color - Hover unselected label color, for the text variant.
|
|
373
|
+
* @cssprop --m3e-text-button-hover-unselected-state-layer-color - Hover unselected state layer color, for the text variant.
|
|
374
|
+
* @cssprop --m3e-text-button-hover-selected-icon-color - Hover selected icon color, for the text variant.
|
|
375
|
+
* @cssprop --m3e-text-button-hover-selected-label-text-color - Hover selected label color, for the text variant.
|
|
376
|
+
* @cssprop --m3e-text-button-hover-selected-state-layer-color - Hover selected state layer color, for the text variant.
|
|
377
|
+
* @cssprop --m3e-text-button-focus-icon-color - Focus icon color, for the text variant.
|
|
378
|
+
* @cssprop --m3e-text-button-focus-label-text-color - Focus label color, for the text variant.
|
|
379
|
+
* @cssprop --m3e-text-button-focus-state-layer-color - Focus state layer color, for the text variant.
|
|
380
|
+
* @cssprop --m3e-text-button-focus-state-layer-opacity - Focus state layer opacity, for the text variant.
|
|
381
|
+
* @cssprop --m3e-text-button-focus-unselected-icon-color - Focus unselected icon color, for the text variant.
|
|
382
|
+
* @cssprop --m3e-text-button-focus-unselected-label-text-color - Focus unselected label color, for the text variant.
|
|
383
|
+
* @cssprop --m3e-text-button-focus-unselected-state-layer-color - Focus unselected state layer color, for the text variant.
|
|
384
|
+
* @cssprop --m3e-text-button-focus-selected-icon-color - Focus selected icon color, for the text variant.
|
|
385
|
+
* @cssprop --m3e-text-button-focus-selected-label-text-color - Focus selected label color, for the text variant.
|
|
386
|
+
* @cssprop --m3e-text-button-focus-selected-state-layer-color - Focus selected state layer color, for the text variant.
|
|
387
|
+
* @cssprop --m3e-text-button-pressed-icon-color - Pressed icon color, for the text variant.
|
|
388
|
+
* @cssprop --m3e-text-button-pressed-label-text-color - Pressed label color, for the text variant.
|
|
389
|
+
* @cssprop --m3e-text-button-pressed-state-layer-color - Pressed state layer color, for the text variant.
|
|
390
|
+
* @cssprop --m3e-text-button-pressed-state-layer-opacity - Pressed state layer opacity, for the text variant.
|
|
391
|
+
* @cssprop --m3e-text-button-pressed-unselected-icon-color - Pressed unselected icon color, for the text variant.
|
|
392
|
+
* @cssprop --m3e-text-button-pressed-unselected-label-text-color - Pressed unselected label color, for the text variant.
|
|
393
|
+
* @cssprop --m3e-text-button-pressed-unselected-state-layer-color - Pressed unselected state layer color, for the text variant.
|
|
394
|
+
* @cssprop --m3e-text-button-pressed-selected-icon-color - Pressed selected icon color, for the text variant.
|
|
395
|
+
* @cssprop --m3e-text-button-pressed-selected-label-text-color - Pressed selected label color, for the text variant.
|
|
396
|
+
* @cssprop --m3e-text-button-pressed-selected-state-layer-color - Pressed selected state layer color, for the text variant.
|
|
397
|
+
*/
|
|
398
|
+
@customElement("m3e-button")
|
|
399
|
+
export class M3eButtonElement extends KeyboardClick(
|
|
400
|
+
LinkButton(FormSubmitter(Focusable(DisabledInteractive(Disabled(AttachInternals(Role(LitElement, "button"), true))))))
|
|
401
|
+
) {
|
|
402
|
+
/** The styles of the element. */
|
|
403
|
+
static override styles: CSSResultGroup = [ButtonSizeStyle, ButtonVariantStyle, ButtonStyle];
|
|
404
|
+
|
|
405
|
+
/** @private */ @query(".base") private readonly _base?: HTMLElement;
|
|
406
|
+
/** @private */ @query(".elevation") private readonly _elevation?: M3eElevationElement;
|
|
407
|
+
/** @private */ @query(".focus-ring") private readonly _focusRing?: M3eFocusRingElement;
|
|
408
|
+
/** @private */ @query(".state-layer") private readonly _stateLayer?: M3eStateLayerElement;
|
|
409
|
+
/** @private */ @query(".ripple") private readonly _ripple?: M3eRippleElement;
|
|
410
|
+
|
|
411
|
+
/** @private */ readonly #clickHandler = (e: Event) => this.#handleClick(e);
|
|
412
|
+
|
|
413
|
+
constructor() {
|
|
414
|
+
super();
|
|
415
|
+
|
|
416
|
+
new ResizeController(this, {
|
|
417
|
+
callback: () => {
|
|
418
|
+
if (this.grouped) {
|
|
419
|
+
this._handleResize();
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
new FocusController(this, {
|
|
425
|
+
callback: (focused) => {
|
|
426
|
+
if (!this.disabledInteractive && this._base) {
|
|
427
|
+
if (focused) {
|
|
428
|
+
this.#updateButtonShape();
|
|
429
|
+
} else if (!this.grouped) {
|
|
430
|
+
this._base?.style.removeProperty("--_button-shape");
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
new PressedController(this, {
|
|
437
|
+
isPressedKey: (key) => key === " " || key === "Enter",
|
|
438
|
+
callback: (pressed) => {
|
|
439
|
+
if (!this.disabled && !this.disabledInteractive) {
|
|
440
|
+
this.classList.toggle("-pressed", pressed);
|
|
441
|
+
this.classList.toggle("-resting", !pressed);
|
|
442
|
+
|
|
443
|
+
const group = this.closest("m3e-button-group");
|
|
444
|
+
if (group) {
|
|
445
|
+
const clientWidth = this.getBoundingClientRect().width;
|
|
446
|
+
const buttons = [...group.querySelectorAll<HTMLElement>("m3e-button,m3e-icon-button")];
|
|
447
|
+
const index = buttons.indexOf(this);
|
|
448
|
+
|
|
449
|
+
for (let i = 0; i < buttons.length; i++) {
|
|
450
|
+
const button = buttons[i];
|
|
451
|
+
if (i === index - 1) {
|
|
452
|
+
button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
|
|
453
|
+
button.classList.toggle("-adjacent-pressed", pressed);
|
|
454
|
+
} else if (i === index + 1) {
|
|
455
|
+
button.style.setProperty("--_adjacent-button-width", `${clientWidth}px`);
|
|
456
|
+
button.classList.toggle("-adjacent-pressed", pressed);
|
|
457
|
+
} else {
|
|
458
|
+
button.style.removeProperty("--_adjacent-button-width");
|
|
459
|
+
button.classList.remove("-adjacent-pressed");
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The appearance variant of the button.
|
|
470
|
+
* @default "text"
|
|
471
|
+
*/
|
|
472
|
+
@property({ reflect: true }) variant: ButtonVariant = "text";
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* The shape of the button.
|
|
476
|
+
* @default "rounded"
|
|
477
|
+
*/
|
|
478
|
+
@property({ reflect: true }) shape: ButtonShape = "rounded";
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* The size of the button.
|
|
482
|
+
* @default "small"
|
|
483
|
+
*/
|
|
484
|
+
@property({ reflect: true }) size: ButtonSize = "small";
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Whether the button will toggle between selected and unselected states.
|
|
488
|
+
* @default false
|
|
489
|
+
*/
|
|
490
|
+
@property({ type: Boolean, reflect: true }) toggle = false;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Whether the toggle button is selected.
|
|
494
|
+
* @default false
|
|
495
|
+
*/
|
|
496
|
+
@property({ type: Boolean, reflect: true }) selected = false;
|
|
497
|
+
|
|
498
|
+
/** Whether the button is contained by a button group. */
|
|
499
|
+
get grouped() {
|
|
500
|
+
return this.classList.contains("-grouped");
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** @inheritdoc */
|
|
504
|
+
override render(): unknown {
|
|
505
|
+
return html`<div class="base">
|
|
506
|
+
<m3e-elevation class="elevation" ?disabled="${this.disabled || this.disabledInteractive}"></m3e-elevation>
|
|
507
|
+
<m3e-state-layer class="state-layer" ?disabled="${this.disabled || this.disabledInteractive}"></m3e-state-layer>
|
|
508
|
+
<m3e-focus-ring class="focus-ring" ?disabled="${this.disabled}"></m3e-focus-ring>
|
|
509
|
+
<m3e-ripple class="ripple" ?disabled="${this.disabled || this.disabledInteractive}"></m3e-ripple>
|
|
510
|
+
<div class="touch" aria-hidden="true"></div>
|
|
511
|
+
${this[renderPseudoLink]()}
|
|
512
|
+
<div class="wrapper">
|
|
513
|
+
${this.toggle
|
|
514
|
+
? html`<slot
|
|
515
|
+
class="icon"
|
|
516
|
+
name="selected-icon"
|
|
517
|
+
aria-hidden="true"
|
|
518
|
+
@slotchange="${this.#handleSelectedIconSlotChange}"
|
|
519
|
+
></slot>`
|
|
520
|
+
: nothing}
|
|
521
|
+
<slot class="icon" name="icon" aria-hidden="true"></slot>
|
|
522
|
+
<div class="label">
|
|
523
|
+
${this.toggle && this.selected ? html`<slot name="selected"><slot></slot></slot>` : html`<slot></slot>`}
|
|
524
|
+
</div>
|
|
525
|
+
<slot class="icon" name="trailing-icon" aria-hidden="true"></slot>
|
|
526
|
+
</div>
|
|
527
|
+
</div>`;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** @inheritdoc */
|
|
531
|
+
override connectedCallback(): void {
|
|
532
|
+
super.connectedCallback();
|
|
533
|
+
this.addEventListener("click", this.#clickHandler);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** @inheritdoc */
|
|
537
|
+
override disconnectedCallback(): void {
|
|
538
|
+
super.disconnectedCallback();
|
|
539
|
+
|
|
540
|
+
["-pressed", "-resting", "-grouped", "-connected"].forEach((x) => this.classList.remove(x));
|
|
541
|
+
this._base?.style.removeProperty("--_button-shape");
|
|
542
|
+
this.style.removeProperty("--_button-width");
|
|
543
|
+
this.style.removeProperty("--_adjacent-button-width");
|
|
544
|
+
this.classList.remove("-adjacent-pressed");
|
|
545
|
+
|
|
546
|
+
this.removeEventListener("click", this.#clickHandler);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/** @inheritdoc */
|
|
550
|
+
protected override firstUpdated(_changedProperties: PropertyValues<this>): void {
|
|
551
|
+
super.firstUpdated(_changedProperties);
|
|
552
|
+
[this._elevation, this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** @inheritdoc */
|
|
556
|
+
protected override updated(_changedProperties: PropertyValues<this>): void {
|
|
557
|
+
super.updated(_changedProperties);
|
|
558
|
+
|
|
559
|
+
if (
|
|
560
|
+
(_changedProperties.has("disabled") && this.disabled) ||
|
|
561
|
+
(_changedProperties.has("disabledInteractive") && this.disabledInteractive)
|
|
562
|
+
) {
|
|
563
|
+
this.classList.toggle("-pressed", false);
|
|
564
|
+
this.classList.toggle("-resting", false);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (_changedProperties.has("toggle") || _changedProperties.has("selected")) {
|
|
568
|
+
this.ariaPressed = this.toggle ? `${this.selected}` : null;
|
|
569
|
+
if (this.toggle) {
|
|
570
|
+
for (const icon of this.querySelectorAll("m3e-icon")) {
|
|
571
|
+
icon.toggleAttribute("filled", this.selected);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** @private */
|
|
578
|
+
#handleClick(e: Event): void {
|
|
579
|
+
if (this.disabled || this.disabledInteractive) {
|
|
580
|
+
e.preventDefault();
|
|
581
|
+
e.stopImmediatePropagation();
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (this.toggle && !e.defaultPrevented) {
|
|
585
|
+
this.selected = !this.selected;
|
|
586
|
+
|
|
587
|
+
// Dispatch an input event and if not prevented, dispatch a change event.
|
|
588
|
+
// Otherwise, reset the selected state.
|
|
589
|
+
|
|
590
|
+
if (this.dispatchEvent(new Event("input", { bubbles: true, composed: true, cancelable: true }))) {
|
|
591
|
+
this.dispatchEvent(new Event("change", { bubbles: true }));
|
|
592
|
+
} else {
|
|
593
|
+
this.selected = !this.selected;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/** @private */
|
|
599
|
+
#handleSelectedIconSlotChange(e: Event): void {
|
|
600
|
+
this._base?.classList.toggle("with-selected-icon", hasAssignedNodes(<HTMLSlotElement>e.target));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/** @private */
|
|
604
|
+
@debounce(40)
|
|
605
|
+
private _handleResize(): void {
|
|
606
|
+
if (this.grouped && !this.classList.contains("-pressed")) {
|
|
607
|
+
this.style.setProperty("--_button-width", `${this.clientWidth}px`);
|
|
608
|
+
this.#updateButtonShape(true);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** @private */
|
|
613
|
+
#updateButtonShape(force = false): void {
|
|
614
|
+
if (!this._base) return;
|
|
615
|
+
const shape = parseFloat(getComputedStyle(this._base).borderRadius);
|
|
616
|
+
if (!isNaN(shape) || force) {
|
|
617
|
+
const adjustedShape = this.clientHeight / 2;
|
|
618
|
+
if (adjustedShape < shape || force) {
|
|
619
|
+
this._base?.style.setProperty("--_button-shape", `${adjustedShape}px`);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
declare global {
|
|
626
|
+
interface HTMLElementTagNameMap {
|
|
627
|
+
"m3e-button": M3eButtonElement;
|
|
628
|
+
}
|
|
629
|
+
}
|