@momentum-design/components 0.15.2 → 0.15.3
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/browser/index.js +93 -55
- package/dist/browser/index.js.map +4 -4
- package/dist/components/button/button.component.d.ts +3 -91
- package/dist/components/button/button.component.js +4 -175
- package/dist/components/button/button.constants.d.ts +1 -5
- package/dist/components/button/button.constants.js +1 -5
- package/dist/components/button/button.styles.d.ts +2 -2
- package/dist/components/button/button.styles.js +4 -25
- package/dist/components/button/button.types.d.ts +2 -3
- package/dist/components/buttonsimple/buttonsimple.component.d.ts +126 -0
- package/dist/components/buttonsimple/buttonsimple.component.js +240 -0
- package/dist/components/buttonsimple/buttonsimple.constants.d.ts +25 -0
- package/dist/components/buttonsimple/buttonsimple.constants.js +26 -0
- package/dist/components/buttonsimple/buttonsimple.styles.d.ts +2 -0
- package/dist/components/buttonsimple/buttonsimple.styles.js +60 -0
- package/dist/components/buttonsimple/buttonsimple.types.d.ts +5 -0
- package/dist/components/buttonsimple/buttonsimple.types.js +1 -0
- package/dist/components/buttonsimple/index.d.ts +7 -0
- package/dist/components/buttonsimple/index.js +4 -0
- package/dist/custom-elements.json +456 -102
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/react/buttonsimple/index.d.ts +11 -0
- package/dist/react/buttonsimple/index.js +20 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CSSResult, PropertyValueMap } from 'lit';
|
2
|
-
import {
|
3
|
-
import
|
2
|
+
import type { ButtonColor, ButtonVariant, PillButtonSize, IconButtonSize } from './button.types';
|
3
|
+
import Buttonsimple from '../buttonsimple';
|
4
4
|
/**
|
5
5
|
* `mdc-button` is a component that can be configured in various ways to suit different use cases.
|
6
6
|
*
|
@@ -33,31 +33,7 @@ import type { ButtonColor, ButtonType, ButtonVariant, PillButtonSize, IconButton
|
|
33
33
|
*
|
34
34
|
* @slot - Text label of the button.
|
35
35
|
*/
|
36
|
-
declare class Button extends
|
37
|
-
/**
|
38
|
-
* The button's active state indicates whether it is currently toggled on (active) or off (inactive).
|
39
|
-
* When the active state is true, the button is considered to be in an active state, meaning it is toggled on.
|
40
|
-
* Conversely, when the active state is false, the button is in an inactive state, indicating it is toggled off.
|
41
|
-
* @default false
|
42
|
-
*/
|
43
|
-
active: boolean;
|
44
|
-
/**
|
45
|
-
* Indicates whether the button is disabled.
|
46
|
-
* The button is currently disabled for user interaction; it is not focusable or clickable.
|
47
|
-
* @default false
|
48
|
-
*/
|
49
|
-
disabled: boolean;
|
50
|
-
/**
|
51
|
-
* Indicates whether the button is soft disabled.
|
52
|
-
* When set to `true`, the button appears visually disabled but still allows
|
53
|
-
* focus, click, and keyboard actions to be passed through.
|
54
|
-
*
|
55
|
-
* **Important:** When using soft disabled, consumers must ensure that
|
56
|
-
* the button behaves like a disabled button, allowing only focus and
|
57
|
-
* preventing any interactions (clicks or keyboard actions) from triggering unintended actions.
|
58
|
-
* @default false
|
59
|
-
*/
|
60
|
-
softDisabled: boolean;
|
36
|
+
declare class Button extends Buttonsimple {
|
61
37
|
/**
|
62
38
|
* The name of the icon to display as a prefix.
|
63
39
|
* The icon is displayed on the left side of the button.
|
@@ -102,23 +78,10 @@ declare class Button extends Component {
|
|
102
78
|
* @default button
|
103
79
|
*/
|
104
80
|
role: string;
|
105
|
-
/**
|
106
|
-
* This property defines the type attribute for the button element.
|
107
|
-
* The type attribute specifies the behavior of the button when it is clicked.
|
108
|
-
* - **submit**: The button submits the form data to the server.
|
109
|
-
* - **reset**: The button resets the form data to its initial state.
|
110
|
-
* - **button**: The button does nothing when clicked.
|
111
|
-
* @default button
|
112
|
-
*/
|
113
|
-
type: ButtonType;
|
114
81
|
/** @internal */
|
115
82
|
private typeInternal;
|
116
83
|
/** @internal */
|
117
84
|
private iconSize;
|
118
|
-
/**
|
119
|
-
* @internal
|
120
|
-
*/
|
121
|
-
private prevTabindex;
|
122
85
|
/**
|
123
86
|
* @internal
|
124
87
|
*/
|
@@ -127,15 +90,7 @@ declare class Button extends Component {
|
|
127
90
|
* @internal
|
128
91
|
*/
|
129
92
|
private prevPostfixIcon?;
|
130
|
-
/** @internal */
|
131
|
-
static formAssociated: boolean;
|
132
|
-
/** @internal */
|
133
|
-
private internals;
|
134
|
-
/** @internal */
|
135
|
-
get form(): HTMLFormElement | null;
|
136
|
-
constructor();
|
137
93
|
update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
138
|
-
private executeAction;
|
139
94
|
/**
|
140
95
|
* Modifies the icon name based on the active state.
|
141
96
|
* If the button is active, the icon name is suffixed with '-filled'.
|
@@ -168,49 +123,6 @@ declare class Button extends Component {
|
|
168
123
|
* @param color - The color to set.
|
169
124
|
*/
|
170
125
|
private setColor;
|
171
|
-
/**
|
172
|
-
* Sets the aria-pressed attribute based on the active state.
|
173
|
-
*
|
174
|
-
* @param element - The target element.
|
175
|
-
* @param active - The active state.
|
176
|
-
*/
|
177
|
-
private setAriaPressed;
|
178
|
-
/**
|
179
|
-
* Sets the soft-disabled attribute for the button.
|
180
|
-
* When soft-disabled, the button looks to be disabled but remains focusable and clickable.
|
181
|
-
* Also sets/removes aria-disabled attribute.
|
182
|
-
*
|
183
|
-
* @param element - The button element.
|
184
|
-
* @param softDisabled - The soft-disabled state.
|
185
|
-
*/
|
186
|
-
private setSoftDisabled;
|
187
|
-
/**
|
188
|
-
* Sets the disabled attribute for the button.
|
189
|
-
* When disabled, the button is not focusable or clickable, and tabindex is set to -1.
|
190
|
-
* The previous tabindex is stored and restored when enabled.
|
191
|
-
* Also sets/removes aria-disabled attribute.
|
192
|
-
*
|
193
|
-
* @param element - The button element.
|
194
|
-
* @param disabled - The disabled state.
|
195
|
-
*/
|
196
|
-
private setDisabled;
|
197
|
-
private triggerClickEvent;
|
198
|
-
/**
|
199
|
-
* Handles the keydown event on the button.
|
200
|
-
* If the key is 'Enter' or 'Space', the button is pressed.
|
201
|
-
* If the key is 'Enter', the button is pressed. The native HTML button works in the same way.
|
202
|
-
*
|
203
|
-
* @param event - The keyboard event.
|
204
|
-
*/
|
205
|
-
private handleKeyDown;
|
206
|
-
/**
|
207
|
-
* Handles the keyup event on the button.
|
208
|
-
* If the key is 'Enter' or 'Space', the button is clicked.
|
209
|
-
* If the key is 'Space', the button is pressed. The native HTML button works in the same way.
|
210
|
-
*
|
211
|
-
* @param event - The keyboard event.
|
212
|
-
*/
|
213
|
-
private handleKeyUp;
|
214
126
|
/**
|
215
127
|
* Infers the type of button based on the presence of slot and/or prefix and postfix icons.
|
216
128
|
* @param slot - default slot of button
|
@@ -10,9 +10,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
import { html } from 'lit';
|
11
11
|
import { property, state } from 'lit/decorators.js';
|
12
12
|
import styles from './button.styles';
|
13
|
-
import { Component } from '../../models';
|
14
13
|
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './button.constants';
|
15
14
|
import { getIconNameWithoutStyle, getIconSize } from './button.utils';
|
15
|
+
import Buttonsimple from '../buttonsimple';
|
16
16
|
/**
|
17
17
|
* `mdc-button` is a component that can be configured in various ways to suit different use cases.
|
18
18
|
*
|
@@ -45,37 +45,9 @@ import { getIconNameWithoutStyle, getIconSize } from './button.utils';
|
|
45
45
|
*
|
46
46
|
* @slot - Text label of the button.
|
47
47
|
*/
|
48
|
-
class Button extends
|
49
|
-
/** @internal */
|
50
|
-
get form() {
|
51
|
-
return this.internals.form;
|
52
|
-
}
|
48
|
+
class Button extends Buttonsimple {
|
53
49
|
constructor() {
|
54
|
-
super();
|
55
|
-
/**
|
56
|
-
* The button's active state indicates whether it is currently toggled on (active) or off (inactive).
|
57
|
-
* When the active state is true, the button is considered to be in an active state, meaning it is toggled on.
|
58
|
-
* Conversely, when the active state is false, the button is in an inactive state, indicating it is toggled off.
|
59
|
-
* @default false
|
60
|
-
*/
|
61
|
-
this.active = false;
|
62
|
-
/**
|
63
|
-
* Indicates whether the button is disabled.
|
64
|
-
* The button is currently disabled for user interaction; it is not focusable or clickable.
|
65
|
-
* @default false
|
66
|
-
*/
|
67
|
-
this.disabled = false;
|
68
|
-
/**
|
69
|
-
* Indicates whether the button is soft disabled.
|
70
|
-
* When set to `true`, the button appears visually disabled but still allows
|
71
|
-
* focus, click, and keyboard actions to be passed through.
|
72
|
-
*
|
73
|
-
* **Important:** When using soft disabled, consumers must ensure that
|
74
|
-
* the button behaves like a disabled button, allowing only focus and
|
75
|
-
* preventing any interactions (clicks or keyboard actions) from triggering unintended actions.
|
76
|
-
* @default false
|
77
|
-
*/
|
78
|
-
this.softDisabled = false;
|
50
|
+
super(...arguments);
|
79
51
|
/**
|
80
52
|
* There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
|
81
53
|
* - **Primary**: Solid background color.
|
@@ -110,39 +82,14 @@ class Button extends Component {
|
|
110
82
|
* @default button
|
111
83
|
*/
|
112
84
|
this.role = 'button';
|
113
|
-
/**
|
114
|
-
* This property defines the type attribute for the button element.
|
115
|
-
* The type attribute specifies the behavior of the button when it is clicked.
|
116
|
-
* - **submit**: The button submits the form data to the server.
|
117
|
-
* - **reset**: The button resets the form data to its initial state.
|
118
|
-
* - **button**: The button does nothing when clicked.
|
119
|
-
* @default button
|
120
|
-
*/
|
121
|
-
this.type = DEFAULTS.TYPE;
|
122
85
|
/** @internal */
|
123
86
|
this.typeInternal = DEFAULTS.TYPE_INTERNAL;
|
124
87
|
/** @internal */
|
125
88
|
this.iconSize = 1;
|
126
|
-
/**
|
127
|
-
* @internal
|
128
|
-
*/
|
129
|
-
this.prevTabindex = 0;
|
130
|
-
this.addEventListener('click', this.executeAction.bind(this));
|
131
|
-
this.addEventListener('keydown', this.handleKeyDown.bind(this));
|
132
|
-
this.addEventListener('keyup', this.handleKeyUp.bind(this));
|
133
|
-
/** @internal */
|
134
|
-
this.internals = this.attachInternals();
|
135
89
|
}
|
136
90
|
update(changedProperties) {
|
137
91
|
super.update(changedProperties);
|
138
|
-
if (changedProperties.has('disabled')) {
|
139
|
-
this.setDisabled(this, this.disabled);
|
140
|
-
}
|
141
|
-
if (changedProperties.has('softDisabled')) {
|
142
|
-
this.setSoftDisabled(this, this.softDisabled);
|
143
|
-
}
|
144
92
|
if (changedProperties.has('active')) {
|
145
|
-
this.setAriaPressed(this, this.active);
|
146
93
|
this.modifyIconName(this.active);
|
147
94
|
}
|
148
95
|
if (changedProperties.has('size')) {
|
@@ -162,14 +109,6 @@ class Button extends Component {
|
|
162
109
|
this.inferButtonType();
|
163
110
|
}
|
164
111
|
}
|
165
|
-
executeAction() {
|
166
|
-
if (this.type === 'submit' && this.internals.form) {
|
167
|
-
this.internals.form.requestSubmit();
|
168
|
-
}
|
169
|
-
if (this.type === 'reset' && this.internals.form) {
|
170
|
-
this.internals.form.reset();
|
171
|
-
}
|
172
|
-
}
|
173
112
|
/**
|
174
113
|
* Modifies the icon name based on the active state.
|
175
114
|
* If the button is active, the icon name is suffixed with '-filled'.
|
@@ -238,95 +177,6 @@ class Button extends Component {
|
|
238
177
|
this.setAttribute('color', color);
|
239
178
|
}
|
240
179
|
}
|
241
|
-
/**
|
242
|
-
* Sets the aria-pressed attribute based on the active state.
|
243
|
-
*
|
244
|
-
* @param element - The target element.
|
245
|
-
* @param active - The active state.
|
246
|
-
*/
|
247
|
-
setAriaPressed(element, active) {
|
248
|
-
if (active) {
|
249
|
-
element.setAttribute('aria-pressed', 'true');
|
250
|
-
}
|
251
|
-
else {
|
252
|
-
element.setAttribute('aria-pressed', 'false');
|
253
|
-
}
|
254
|
-
}
|
255
|
-
/**
|
256
|
-
* Sets the soft-disabled attribute for the button.
|
257
|
-
* When soft-disabled, the button looks to be disabled but remains focusable and clickable.
|
258
|
-
* Also sets/removes aria-disabled attribute.
|
259
|
-
*
|
260
|
-
* @param element - The button element.
|
261
|
-
* @param softDisabled - The soft-disabled state.
|
262
|
-
*/
|
263
|
-
setSoftDisabled(element, softDisabled) {
|
264
|
-
if (softDisabled) {
|
265
|
-
element.setAttribute('aria-disabled', 'true');
|
266
|
-
}
|
267
|
-
else {
|
268
|
-
element.setAttribute('aria-disabled', 'false');
|
269
|
-
}
|
270
|
-
}
|
271
|
-
/**
|
272
|
-
* Sets the disabled attribute for the button.
|
273
|
-
* When disabled, the button is not focusable or clickable, and tabindex is set to -1.
|
274
|
-
* The previous tabindex is stored and restored when enabled.
|
275
|
-
* Also sets/removes aria-disabled attribute.
|
276
|
-
*
|
277
|
-
* @param element - The button element.
|
278
|
-
* @param disabled - The disabled state.
|
279
|
-
*/
|
280
|
-
setDisabled(element, disabled) {
|
281
|
-
if (disabled) {
|
282
|
-
element.setAttribute('aria-disabled', 'true');
|
283
|
-
this.prevTabindex = this.tabIndex;
|
284
|
-
this.tabIndex = -1;
|
285
|
-
}
|
286
|
-
else {
|
287
|
-
this.tabIndex = this.prevTabindex;
|
288
|
-
element.removeAttribute('aria-disabled');
|
289
|
-
}
|
290
|
-
}
|
291
|
-
triggerClickEvent() {
|
292
|
-
const clickEvent = new MouseEvent('click', {
|
293
|
-
bubbles: true,
|
294
|
-
cancelable: true,
|
295
|
-
view: window,
|
296
|
-
});
|
297
|
-
this.dispatchEvent(clickEvent);
|
298
|
-
this.executeAction();
|
299
|
-
}
|
300
|
-
/**
|
301
|
-
* Handles the keydown event on the button.
|
302
|
-
* If the key is 'Enter' or 'Space', the button is pressed.
|
303
|
-
* If the key is 'Enter', the button is pressed. The native HTML button works in the same way.
|
304
|
-
*
|
305
|
-
* @param event - The keyboard event.
|
306
|
-
*/
|
307
|
-
handleKeyDown(event) {
|
308
|
-
if (['Enter', ' '].includes(event.key)) {
|
309
|
-
this.classList.add('pressed');
|
310
|
-
if (event.key === 'Enter') {
|
311
|
-
this.triggerClickEvent();
|
312
|
-
}
|
313
|
-
}
|
314
|
-
}
|
315
|
-
/**
|
316
|
-
* Handles the keyup event on the button.
|
317
|
-
* If the key is 'Enter' or 'Space', the button is clicked.
|
318
|
-
* If the key is 'Space', the button is pressed. The native HTML button works in the same way.
|
319
|
-
*
|
320
|
-
* @param event - The keyboard event.
|
321
|
-
*/
|
322
|
-
handleKeyUp(event) {
|
323
|
-
if (['Enter', ' '].includes(event.key)) {
|
324
|
-
this.classList.remove('pressed');
|
325
|
-
if (event.key === ' ') {
|
326
|
-
this.triggerClickEvent();
|
327
|
-
}
|
328
|
-
}
|
329
|
-
}
|
330
180
|
/**
|
331
181
|
* Infers the type of button based on the presence of slot and/or prefix and postfix icons.
|
332
182
|
* @param slot - default slot of button
|
@@ -347,9 +197,6 @@ class Button extends Component {
|
|
347
197
|
this.setAttribute('data-btn-type', 'pill');
|
348
198
|
}
|
349
199
|
}
|
350
|
-
// Note: @click is attached to each of the children of the button.
|
351
|
-
// Adding click listener within the constructor will not work properly when button is disabled.
|
352
|
-
// https://discord.com/channels/1012791295170859069/1047015641225371718/threads/1309446072413720576
|
353
200
|
render() {
|
354
201
|
return html `
|
355
202
|
${this.prefixIcon ? html `
|
@@ -370,21 +217,7 @@ class Button extends Component {
|
|
370
217
|
`;
|
371
218
|
}
|
372
219
|
}
|
373
|
-
|
374
|
-
Button.formAssociated = true;
|
375
|
-
Button.styles = [...Component.styles, ...styles];
|
376
|
-
__decorate([
|
377
|
-
property({ type: Boolean }),
|
378
|
-
__metadata("design:type", Object)
|
379
|
-
], Button.prototype, "active", void 0);
|
380
|
-
__decorate([
|
381
|
-
property({ type: Boolean }),
|
382
|
-
__metadata("design:type", Object)
|
383
|
-
], Button.prototype, "disabled", void 0);
|
384
|
-
__decorate([
|
385
|
-
property({ type: Boolean, attribute: 'soft-disabled' }),
|
386
|
-
__metadata("design:type", Object)
|
387
|
-
], Button.prototype, "softDisabled", void 0);
|
220
|
+
Button.styles = [...Buttonsimple.styles, ...styles];
|
388
221
|
__decorate([
|
389
222
|
property({ type: String, attribute: 'prefix-icon', reflect: true }),
|
390
223
|
__metadata("design:type", String)
|
@@ -413,10 +246,6 @@ __decorate([
|
|
413
246
|
property({ type: String, reflect: true }),
|
414
247
|
__metadata("design:type", Object)
|
415
248
|
], Button.prototype, "role", void 0);
|
416
|
-
__decorate([
|
417
|
-
property({ reflect: true }),
|
418
|
-
__metadata("design:type", String)
|
419
|
-
], Button.prototype, "type", void 0);
|
420
249
|
__decorate([
|
421
250
|
state(),
|
422
251
|
__metadata("design:type", String)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { BUTTON_TYPE } from '../buttonsimple/buttonsimple.constants';
|
1
2
|
declare const TAG_NAME: "mdc-button";
|
2
3
|
declare const BUTTON_VARIANTS: {
|
3
4
|
readonly PRIMARY: "primary";
|
@@ -31,11 +32,6 @@ declare const BUTTON_TYPE_INTERNAL: {
|
|
31
32
|
readonly ICON: "icon";
|
32
33
|
readonly PILL_WITH_ICON: "pill-with-icon";
|
33
34
|
};
|
34
|
-
declare const BUTTON_TYPE: {
|
35
|
-
readonly BUTTON: "button";
|
36
|
-
readonly SUBMIT: "submit";
|
37
|
-
readonly RESET: "reset";
|
38
|
-
};
|
39
35
|
declare const DEFAULTS: {
|
40
36
|
VARIANT: "primary";
|
41
37
|
SIZE: 32;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
|
+
import { BUTTON_TYPE } from '../buttonsimple/buttonsimple.constants';
|
2
3
|
const TAG_NAME = utils.constructTagName('button');
|
3
4
|
const BUTTON_VARIANTS = {
|
4
5
|
PRIMARY: 'primary',
|
@@ -29,11 +30,6 @@ const BUTTON_TYPE_INTERNAL = {
|
|
29
30
|
ICON: 'icon',
|
30
31
|
PILL_WITH_ICON: 'pill-with-icon',
|
31
32
|
};
|
32
|
-
const BUTTON_TYPE = {
|
33
|
-
BUTTON: 'button',
|
34
|
-
SUBMIT: 'submit',
|
35
|
-
RESET: 'reset',
|
36
|
-
};
|
37
33
|
const DEFAULTS = {
|
38
34
|
VARIANT: BUTTON_VARIANTS.PRIMARY,
|
39
35
|
SIZE: PILL_BUTTON_SIZES[32],
|
@@ -1,2 +1,2 @@
|
|
1
|
-
declare const
|
2
|
-
export default
|
1
|
+
declare const _default: import("lit").CSSResult[];
|
2
|
+
export default _default;
|
@@ -1,12 +1,10 @@
|
|
1
1
|
import { css } from 'lit';
|
2
|
-
|
3
|
-
const styles = [hostFitContentStyles, css `
|
2
|
+
const styles = css `
|
4
3
|
:host {
|
5
|
-
|
4
|
+
background-color: transparent;
|
6
5
|
border-radius: 1.25rem;
|
7
6
|
font-weight: var(--mds-font-apps-body-large-medium-font-weight);
|
8
7
|
outline: none;
|
9
|
-
border: 0.0625rem solid transparent;
|
10
8
|
|
11
9
|
--mdc-button-primary-color: var(--mds-color-theme-inverted-text-primary-normal);
|
12
10
|
--mdc-button-primary-background-color: var(--mds-color-theme-button-primary-normal);
|
@@ -29,14 +27,6 @@ const styles = [hostFitContentStyles, css `
|
|
29
27
|
--mdc-button-tertiary-disabled-background-color: var(--mds-color-theme-button-secondary-disabled);
|
30
28
|
--mdc-button-tertiary-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
31
29
|
|
32
|
-
--mdc-button-height-size-64: 4rem;
|
33
|
-
--mdc-button-height-size-52: 3.25rem;
|
34
|
-
--mdc-button-height-size-40: 2.5rem;
|
35
|
-
--mdc-button-height-size-32: 2rem;
|
36
|
-
--mdc-button-height-size-28: 1.75rem;
|
37
|
-
--mdc-button-height-size-24: 1.5rem;
|
38
|
-
--mdc-button-height-size-20: 1.25rem;
|
39
|
-
|
40
30
|
--mdc-button-line-height-size-40: var(--mds-font-lineheight-body-large);
|
41
31
|
--mdc-button-line-height-size-32: var(--mds-font-lineheight-body-large);
|
42
32
|
--mdc-button-line-height-size-28: var(--mds-font-lineheight-body-midsize);
|
@@ -108,42 +98,31 @@ const styles = [hostFitContentStyles, css `
|
|
108
98
|
aspect-ratio: 1;
|
109
99
|
padding: unset;
|
110
100
|
}
|
111
|
-
:host([size="64"]){
|
112
|
-
height: var(--mdc-button-height-size-64);
|
113
|
-
}
|
114
|
-
:host([size="52"]){
|
115
|
-
height: var(--mdc-button-height-size-52);
|
116
|
-
}
|
117
101
|
:host([size="40"]){
|
118
|
-
height: var(--mdc-button-height-size-40);
|
119
102
|
font-size: var(--mds-font-size-body-large);
|
120
103
|
line-height: var(--mdc-button-line-height-size-40);
|
121
104
|
padding: 0 1rem;
|
122
105
|
gap: 0.5rem;
|
123
106
|
}
|
124
107
|
:host([size="32"]){
|
125
|
-
height: var(--mdc-button-height-size-32);
|
126
108
|
font-size: var(--mds-font-size-body-large);
|
127
109
|
line-height: var(--mdc-button-line-height-size-32);
|
128
110
|
padding: 0 0.75rem;
|
129
111
|
gap: 0.375rem;
|
130
112
|
}
|
131
113
|
:host([size="28"]){
|
132
|
-
height: var(--mdc-button-height-size-28);
|
133
114
|
font-size: var(--mds-font-size-body-midsize);
|
134
115
|
line-height: var(--mdc-button-line-height-size-28);
|
135
116
|
padding: 0 0.75rem;
|
136
117
|
gap: 0.375rem;
|
137
118
|
}
|
138
119
|
:host([size="24"]){
|
139
|
-
height: var(--mdc-button-height-size-24);
|
140
120
|
font-size: var(--mds-font-size-body-small);
|
141
121
|
line-height: var(--mdc-button-line-height-size-24);
|
142
122
|
padding: 0 0.625rem;
|
143
123
|
gap: 0.25rem;
|
144
124
|
}
|
145
125
|
:host([size="20"]){
|
146
|
-
height: var(--mdc-button-height-size-20);
|
147
126
|
padding: 0.0625rem;
|
148
127
|
}
|
149
128
|
|
@@ -191,5 +170,5 @@ const styles = [hostFitContentStyles, css `
|
|
191
170
|
--mdc-button-secondary-hover-background-color: var(--mds-color-theme-button-secondary-hover);
|
192
171
|
--mdc-button-secondary-pressed-background-color: var(--mds-color-theme-button-secondary-pressed);
|
193
172
|
}
|
194
|
-
|
195
|
-
export default styles;
|
173
|
+
`;
|
174
|
+
export default [styles];
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { ValueOf } from '../../utils/types';
|
2
|
-
import { BUTTON_COLORS,
|
2
|
+
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from './button.constants';
|
3
3
|
type ButtonVariant = ValueOf<typeof BUTTON_VARIANTS>;
|
4
4
|
type PillButtonSize = ValueOf<typeof PILL_BUTTON_SIZES>;
|
5
5
|
type IconButtonSize = ValueOf<typeof ICON_BUTTON_SIZES>;
|
6
6
|
type ButtonTypeInternal = ValueOf<typeof BUTTON_TYPE_INTERNAL>;
|
7
|
-
type ButtonType = ValueOf<typeof BUTTON_TYPE>;
|
8
7
|
type ButtonColor = ValueOf<typeof BUTTON_COLORS>;
|
9
|
-
export { ButtonVariant, PillButtonSize, IconButtonSize, ButtonTypeInternal,
|
8
|
+
export { ButtonVariant, PillButtonSize, IconButtonSize, ButtonTypeInternal, ButtonColor, };
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import { CSSResult, PropertyValueMap } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
import { ButtonSize, ButtonType } from './buttonsimple.types';
|
4
|
+
/**
|
5
|
+
* `mdc-buttonsimple` is a component that can be configured in various ways to suit different use cases.
|
6
|
+
* It is used as an internal component and is not intended to be used directly by consumers.
|
7
|
+
* Consumers should use the `mdc-button` component instead.
|
8
|
+
*
|
9
|
+
* @tagname mdc-buttonsimple
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
declare class Buttonsimple extends Component {
|
13
|
+
/**
|
14
|
+
* The button's active state indicates whether it is currently toggled on (active) or off (inactive).
|
15
|
+
* When the active state is true, the button is considered to be in an active state, meaning it is toggled on.
|
16
|
+
* Conversely, when the active state is false, the button is in an inactive state, indicating it is toggled off.
|
17
|
+
* @default false
|
18
|
+
*/
|
19
|
+
active: boolean;
|
20
|
+
/**
|
21
|
+
* Indicates whether the button is disabled.
|
22
|
+
* When the button is disabled for user interaction; it is not focusable or clickable.
|
23
|
+
* @default false
|
24
|
+
*/
|
25
|
+
disabled: boolean;
|
26
|
+
/**
|
27
|
+
* Indicates whether the button is soft disabled.
|
28
|
+
* When set to `true`, the button appears visually disabled but still allows
|
29
|
+
* focus, click, and keyboard actions to be passed through.
|
30
|
+
*
|
31
|
+
* **Important:** When using soft disabled, consumers must ensure that
|
32
|
+
* the button behaves like a disabled button, allowing only focus and
|
33
|
+
* preventing any interactions (clicks or keyboard actions) from triggering unintended actions.
|
34
|
+
* @default false
|
35
|
+
*/
|
36
|
+
softDisabled: boolean;
|
37
|
+
/**
|
38
|
+
* Button sizing is based on the button type.
|
39
|
+
* - **Pill button**: 40, 32, 28, 24.
|
40
|
+
* - **Icon button**: 64, 52, 40, 32, 28, 24.
|
41
|
+
* - Tertiary icon button cam also be 20.
|
42
|
+
* @default 32
|
43
|
+
*/
|
44
|
+
size: ButtonSize;
|
45
|
+
/**
|
46
|
+
* The tabindex of the button.
|
47
|
+
* @default 0
|
48
|
+
*/
|
49
|
+
tabIndex: number;
|
50
|
+
/**
|
51
|
+
* This property defines the ARIA role for the element. By default, it is set to 'button'.
|
52
|
+
* Consumers should override this role when:
|
53
|
+
* - The element is being used in a context where a different role is more appropriate.
|
54
|
+
* - Custom behaviors are implemented that require a specific ARIA role for accessibility purposes.
|
55
|
+
* @default button
|
56
|
+
*/
|
57
|
+
role: string;
|
58
|
+
/**
|
59
|
+
* This property defines the type attribute for the button element.
|
60
|
+
* The type attribute specifies the behavior of the button when it is clicked.
|
61
|
+
* - **submit**: The button submits the form data to the server.
|
62
|
+
* - **reset**: The button resets the form data to its initial state.
|
63
|
+
* - **button**: The button does nothing when clicked.
|
64
|
+
* @default button
|
65
|
+
*/
|
66
|
+
type: ButtonType;
|
67
|
+
/**
|
68
|
+
* @internal
|
69
|
+
*/
|
70
|
+
private prevTabindex;
|
71
|
+
/** @internal */
|
72
|
+
static formAssociated: boolean;
|
73
|
+
/** @internal */
|
74
|
+
private internals;
|
75
|
+
/** @internal */
|
76
|
+
get form(): HTMLFormElement | null;
|
77
|
+
constructor();
|
78
|
+
update(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
79
|
+
private executeAction;
|
80
|
+
/**
|
81
|
+
* Sets the aria-pressed attribute based on the active state.
|
82
|
+
*
|
83
|
+
* @param element - The target element.
|
84
|
+
* @param active - The active state.
|
85
|
+
*/
|
86
|
+
private setAriaPressed;
|
87
|
+
/**
|
88
|
+
* Sets the soft-disabled attribute for the button.
|
89
|
+
* When soft-disabled, the button looks to be disabled but remains focusable and clickable.
|
90
|
+
* Also sets/removes aria-disabled attribute.
|
91
|
+
*
|
92
|
+
* @param element - The button element.
|
93
|
+
* @param softDisabled - The soft-disabled state.
|
94
|
+
*/
|
95
|
+
private setSoftDisabled;
|
96
|
+
/**
|
97
|
+
* Sets the disabled attribute for the button.
|
98
|
+
* When disabled, the button is not focusable or clickable, and tabindex is set to -1.
|
99
|
+
* The previous tabindex is stored and restored when enabled.
|
100
|
+
* Also sets/removes aria-disabled attribute.
|
101
|
+
*
|
102
|
+
* @param element - The button element.
|
103
|
+
* @param disabled - The disabled state.
|
104
|
+
*/
|
105
|
+
private setDisabled;
|
106
|
+
private triggerClickEvent;
|
107
|
+
/**
|
108
|
+
* Handles the keydown event on the button.
|
109
|
+
* If the key is 'Enter' or 'Space', the button is pressed.
|
110
|
+
* If the key is 'Enter', the button is pressed. The native HTML button works in the same way.
|
111
|
+
*
|
112
|
+
* @param event - The keyboard event.
|
113
|
+
*/
|
114
|
+
private handleKeyDown;
|
115
|
+
/**
|
116
|
+
* Handles the keyup event on the button.
|
117
|
+
* If the key is 'Enter' or 'Space', the button is clicked.
|
118
|
+
* If the key is 'Space', the button is pressed. The native HTML button works in the same way.
|
119
|
+
*
|
120
|
+
* @param event - The keyboard event.
|
121
|
+
*/
|
122
|
+
private handleKeyUp;
|
123
|
+
render(): import("lit-html").TemplateResult<1>;
|
124
|
+
static styles: Array<CSSResult>;
|
125
|
+
}
|
126
|
+
export default Buttonsimple;
|