@momentum-design/components 0.56.2 → 0.58.0
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 +329 -294
- package/dist/browser/index.js.map +4 -4
- package/dist/components/link/link.component.d.ts +7 -59
- package/dist/components/link/link.component.js +7 -109
- package/dist/components/link/link.constants.d.ts +0 -2
- package/dist/components/link/link.constants.js +0 -2
- package/dist/components/link/link.styles.d.ts +2 -2
- package/dist/components/link/link.styles.js +4 -57
- package/dist/components/linksimple/index.d.ts +7 -0
- package/dist/components/linksimple/index.js +4 -0
- package/dist/components/linksimple/linksimple.component.d.ts +73 -0
- package/dist/components/linksimple/linksimple.component.js +141 -0
- package/dist/components/linksimple/linksimple.constants.d.ts +6 -0
- package/dist/components/linksimple/linksimple.constants.js +7 -0
- package/dist/components/linksimple/linksimple.styles.d.ts +2 -0
- package/dist/components/linksimple/linksimple.styles.js +72 -0
- package/dist/components/linksimple/linksimple.types.d.ts +7 -0
- package/dist/components/linksimple/linksimple.types.js +1 -0
- package/dist/components/statictoggle/index.d.ts +8 -0
- package/dist/components/statictoggle/index.js +5 -0
- package/dist/components/statictoggle/statictoggle.component.d.ts +48 -0
- package/dist/components/statictoggle/statictoggle.component.js +82 -0
- package/dist/components/statictoggle/statictoggle.constants.d.ts +17 -0
- package/dist/components/statictoggle/statictoggle.constants.js +18 -0
- package/dist/components/statictoggle/statictoggle.styles.d.ts +2 -0
- package/dist/components/statictoggle/statictoggle.styles.js +82 -0
- package/dist/components/statictoggle/statictoggle.types.d.ts +4 -0
- package/dist/components/statictoggle/statictoggle.types.js +1 -0
- package/dist/components/toggle/index.d.ts +2 -1
- package/dist/components/toggle/index.js +2 -1
- package/dist/components/toggle/toggle.component.d.ts +16 -20
- package/dist/components/toggle/toggle.component.js +27 -33
- package/dist/components/toggle/toggle.styles.js +26 -96
- package/dist/custom-elements.json +636 -118
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/link/index.d.ts +4 -16
- package/dist/react/link/index.js +4 -16
- package/dist/react/linksimple/index.d.ts +34 -0
- package/dist/react/linksimple/index.js +42 -0
- package/dist/react/statictoggle/index.d.ts +30 -0
- package/dist/react/statictoggle/index.js +39 -0
- package/dist/react/toggle/index.d.ts +14 -18
- package/dist/react/toggle/index.js +14 -18
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import type { CSSResult } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
import type { ToggleSize } from './statictoggle.types';
|
4
|
+
declare const StaticToggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
|
5
|
+
/**
|
6
|
+
* This is a decorative component that is styled to look as a toggle. <br/>
|
7
|
+
* It has 3 properties - checked, size and disabled. <br/>
|
8
|
+
* We are using the same styling that has been created for the `mdc-toggle` component.
|
9
|
+
*
|
10
|
+
* @dependency mdc-icon
|
11
|
+
*
|
12
|
+
* @tagname mdc-statictoggle
|
13
|
+
*
|
14
|
+
* @slot default - This is a default/unnamed slot
|
15
|
+
*
|
16
|
+
* @cssproperty --mdc-statictoggle-width - Width of the toggle
|
17
|
+
* @cssproperty --mdc-statictoggle-height - Height of the toggle
|
18
|
+
* @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
|
19
|
+
* @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
|
20
|
+
* @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
|
21
|
+
* @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
|
22
|
+
* @cssproperty --mdc-statictoggle-border - Border of the toggle
|
23
|
+
* @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
|
24
|
+
* @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
|
25
|
+
* @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
|
26
|
+
* @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
|
27
|
+
* @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
|
28
|
+
* @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
|
29
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
|
30
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
|
31
|
+
*/
|
32
|
+
declare class StaticToggle extends StaticToggle_base {
|
33
|
+
/**
|
34
|
+
* Determines whether the toggle is active or inactive.
|
35
|
+
* @default false
|
36
|
+
*/
|
37
|
+
checked: boolean;
|
38
|
+
/**
|
39
|
+
* Determines toggle size in rem (height is specified here).
|
40
|
+
* - **Default**: 1.5
|
41
|
+
* - **Compact**: 1
|
42
|
+
* @default default
|
43
|
+
*/
|
44
|
+
size: ToggleSize;
|
45
|
+
render(): import("lit-html").TemplateResult<1>;
|
46
|
+
static styles: Array<CSSResult>;
|
47
|
+
}
|
48
|
+
export default StaticToggle;
|
@@ -0,0 +1,82 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
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;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { Component } from '../../models';
|
13
|
+
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
14
|
+
import { DEFAULTS, ICON_NAME, ICON_SIZE_IN_REM } from './statictoggle.constants';
|
15
|
+
import styles from './statictoggle.styles';
|
16
|
+
/**
|
17
|
+
* This is a decorative component that is styled to look as a toggle. <br/>
|
18
|
+
* It has 3 properties - checked, size and disabled. <br/>
|
19
|
+
* We are using the same styling that has been created for the `mdc-toggle` component.
|
20
|
+
*
|
21
|
+
* @dependency mdc-icon
|
22
|
+
*
|
23
|
+
* @tagname mdc-statictoggle
|
24
|
+
*
|
25
|
+
* @slot default - This is a default/unnamed slot
|
26
|
+
*
|
27
|
+
* @cssproperty --mdc-statictoggle-width - Width of the toggle
|
28
|
+
* @cssproperty --mdc-statictoggle-height - Height of the toggle
|
29
|
+
* @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
|
30
|
+
* @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
|
31
|
+
* @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
|
32
|
+
* @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
|
33
|
+
* @cssproperty --mdc-statictoggle-border - Border of the toggle
|
34
|
+
* @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
|
35
|
+
* @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
|
36
|
+
* @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
|
37
|
+
* @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
|
38
|
+
* @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
|
39
|
+
* @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
|
40
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
|
41
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
|
42
|
+
*/
|
43
|
+
class StaticToggle extends DisabledMixin(Component) {
|
44
|
+
constructor() {
|
45
|
+
super(...arguments);
|
46
|
+
/**
|
47
|
+
* Determines whether the toggle is active or inactive.
|
48
|
+
* @default false
|
49
|
+
*/
|
50
|
+
this.checked = false;
|
51
|
+
/**
|
52
|
+
* Determines toggle size in rem (height is specified here).
|
53
|
+
* - **Default**: 1.5
|
54
|
+
* - **Compact**: 1
|
55
|
+
* @default default
|
56
|
+
*/
|
57
|
+
this.size = DEFAULTS.SIZE;
|
58
|
+
}
|
59
|
+
render() {
|
60
|
+
return html `
|
61
|
+
<slot></slot>
|
62
|
+
<div part="slider">
|
63
|
+
<mdc-icon
|
64
|
+
name="${this.checked ? ICON_NAME.CHECKED : ICON_NAME.UNCHECKED}"
|
65
|
+
class="icon"
|
66
|
+
length-unit="rem"
|
67
|
+
size="${ICON_SIZE_IN_REM[this.size]}"
|
68
|
+
></mdc-icon>
|
69
|
+
</div>
|
70
|
+
`;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
StaticToggle.styles = [...Component.styles, ...styles];
|
74
|
+
__decorate([
|
75
|
+
property({ type: Boolean, reflect: true }),
|
76
|
+
__metadata("design:type", Object)
|
77
|
+
], StaticToggle.prototype, "checked", void 0);
|
78
|
+
__decorate([
|
79
|
+
property({ type: String, reflect: true }),
|
80
|
+
__metadata("design:type", String)
|
81
|
+
], StaticToggle.prototype, "size", void 0);
|
82
|
+
export default StaticToggle;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-statictoggle";
|
2
|
+
declare const TOGGLE_SIZE: {
|
3
|
+
readonly DEFAULT: "default";
|
4
|
+
readonly COMPACT: "compact";
|
5
|
+
};
|
6
|
+
declare const ICON_NAME: {
|
7
|
+
readonly CHECKED: "check-bold";
|
8
|
+
readonly UNCHECKED: "cancel-bold";
|
9
|
+
};
|
10
|
+
declare const ICON_SIZE_IN_REM: {
|
11
|
+
readonly compact: 0.75;
|
12
|
+
readonly default: 1.25;
|
13
|
+
};
|
14
|
+
declare const DEFAULTS: {
|
15
|
+
SIZE: "default";
|
16
|
+
};
|
17
|
+
export { TAG_NAME, ICON_SIZE_IN_REM, DEFAULTS, TOGGLE_SIZE, ICON_NAME };
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
const TAG_NAME = utils.constructTagName('statictoggle');
|
3
|
+
const TOGGLE_SIZE = {
|
4
|
+
DEFAULT: 'default',
|
5
|
+
COMPACT: 'compact',
|
6
|
+
};
|
7
|
+
const ICON_NAME = {
|
8
|
+
CHECKED: 'check-bold',
|
9
|
+
UNCHECKED: 'cancel-bold',
|
10
|
+
};
|
11
|
+
const ICON_SIZE_IN_REM = {
|
12
|
+
compact: 0.75,
|
13
|
+
default: 1.25,
|
14
|
+
};
|
15
|
+
const DEFAULTS = {
|
16
|
+
SIZE: TOGGLE_SIZE.DEFAULT,
|
17
|
+
};
|
18
|
+
export { TAG_NAME, ICON_SIZE_IN_REM, DEFAULTS, TOGGLE_SIZE, ICON_NAME };
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = [css `
|
3
|
+
:host {
|
4
|
+
--mdc-statictoggle-width: 3rem;
|
5
|
+
--mdc-statictoggle-height: 1.5rem;
|
6
|
+
--mdc-statictoggle-width-compact: 2rem;
|
7
|
+
--mdc-statictoggle-height-compact: 1rem;
|
8
|
+
--mdc-statictoggle-border-radius: 0.75rem;
|
9
|
+
--mdc-statictoggle-border-radius-compact: 0.5rem;
|
10
|
+
--mdc-statictoggle-border: 1px solid var(--mds-color-theme-outline-input-normal);
|
11
|
+
|
12
|
+
--mdc-statictoggle-inactive-rest-color: var(--mds-color-theme-control-inactive-normal);
|
13
|
+
--mdc-statictoggle-inactive-disabled-color: var(--mds-color-theme-control-inactive-disabled);
|
14
|
+
--mdc-statictoggle-active-rest-color: var(--mds-color-theme-control-active-normal);
|
15
|
+
--mdc-statictoggle-active-disabled-color: var(--mds-color-theme-control-active-disabled);
|
16
|
+
|
17
|
+
--mdc-statictoggle-icon-color-normal: var(--mds-color-theme-common-inverted-text-primary-normal);
|
18
|
+
--mdc-statictoggle-icon-color-disabled: var(--mds-color-theme-common-inverted-text-primary-disabled);
|
19
|
+
--mdc-statictoggle-icon-background-color-normal: var(--mds-color-theme-common-text-primary-normal);
|
20
|
+
--mdc-statictoggle-icon-background-color-disabled: var(--mds-color-theme-common-text-primary-disabled);
|
21
|
+
|
22
|
+
border-radius: var(--mdc-statictoggle-border-radius);
|
23
|
+
}
|
24
|
+
|
25
|
+
:host::part(slider) {
|
26
|
+
width: var(--mdc-statictoggle-width);
|
27
|
+
height: var(--mdc-statictoggle-height);
|
28
|
+
background: var(--mdc-statictoggle-inactive-rest-color);
|
29
|
+
border-radius: var(--mdc-statictoggle-border-radius);
|
30
|
+
border: var(--mdc-statictoggle-border);
|
31
|
+
display: flex;
|
32
|
+
align-items: center;
|
33
|
+
justify-content: flex-start;
|
34
|
+
transition: background-color 0.3s ease;
|
35
|
+
outline: none;
|
36
|
+
padding: 1px;
|
37
|
+
}
|
38
|
+
|
39
|
+
:host([checked])::part(slider) {
|
40
|
+
background-color: var(--mdc-statictoggle-active-rest-color);
|
41
|
+
justify-content: flex-end;
|
42
|
+
border-color: transparent;
|
43
|
+
}
|
44
|
+
|
45
|
+
:host([size='compact'])::part(slider) {
|
46
|
+
width: var(--mdc-statictoggle-width-compact);
|
47
|
+
height: var(--mdc-statictoggle-height-compact);
|
48
|
+
border-radius: var(--mdc-statictoggle-border-radius-compact);
|
49
|
+
}
|
50
|
+
|
51
|
+
.icon {
|
52
|
+
padding: 0.25rem;
|
53
|
+
--mdc-icon-fill-color: var(--mdc-statictoggle-icon-color-normal);
|
54
|
+
background-color: var(--mdc-statictoggle-icon-background-color-normal);
|
55
|
+
border-radius: 50%;
|
56
|
+
}
|
57
|
+
|
58
|
+
:host([disabled]) .icon {
|
59
|
+
--mdc-icon-fill-color: var(--mdc-statictoggle-icon-color-disabled);
|
60
|
+
background-color: var(--mdc-statictoggle-icon-background-color-disabled);
|
61
|
+
}
|
62
|
+
|
63
|
+
:host([size='compact']) .icon {
|
64
|
+
padding: 0.125rem;
|
65
|
+
}
|
66
|
+
|
67
|
+
:host([disabled])::part(slider) {
|
68
|
+
background-color: var(--mdc-statictoggle-inactive-disabled-color);
|
69
|
+
}
|
70
|
+
|
71
|
+
:host([disabled][checked])::part(slider) {
|
72
|
+
background-color: var(--mdc-statictoggle-active-disabled-color);
|
73
|
+
}
|
74
|
+
|
75
|
+
/* High Contrast Mode */
|
76
|
+
@media (forced-colors: active) {
|
77
|
+
:host([checked])::part(slider), .icon {
|
78
|
+
border: var(--mdc-statictoggle-border);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
`];
|
82
|
+
export default styles;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { CSSResult, PropertyValueMap } from 'lit';
|
2
|
-
import FormfieldWrapper from '../formfieldwrapper';
|
3
|
-
import { ToggleSize } from './toggle.types';
|
4
2
|
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
3
|
+
import FormfieldWrapper from '../formfieldwrapper';
|
4
|
+
import type { ToggleSize } from './toggle.types';
|
5
5
|
declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
6
6
|
/**
|
7
7
|
* Toggle Component is an interactive control used to switch between two mutually exclusive options,
|
@@ -14,30 +14,26 @@ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<
|
|
14
14
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
15
15
|
*
|
16
16
|
* @dependency mdc-icon
|
17
|
+
* @dependency mdc-statictoggle
|
17
18
|
*
|
18
19
|
* @tagname mdc-toggle
|
19
20
|
*
|
20
21
|
* @event change - (React: onChange) Event that gets dispatched when the toggle state changes.
|
21
22
|
* @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.
|
22
23
|
*
|
23
|
-
* @cssproperty --mdc-toggle-width -
|
24
|
-
* @cssproperty --mdc-toggle-height -
|
25
|
-
* @cssproperty --mdc-toggle-width-compact -
|
26
|
-
* @cssproperty --mdc-toggle-height-compact -
|
27
|
-
* @cssproperty --mdc-toggle-
|
28
|
-
* @cssproperty --mdc-toggle-
|
29
|
-
* @cssproperty --mdc-toggle-
|
30
|
-
* @cssproperty --mdc-toggle-
|
31
|
-
* @cssproperty --mdc-toggle-
|
32
|
-
* @cssproperty --mdc-toggle-
|
33
|
-
* @cssproperty --mdc-toggle-
|
34
|
-
* @cssproperty --mdc-toggle-
|
35
|
-
* @cssproperty --mdc-toggle-
|
36
|
-
* @cssproperty --mdc-toggle-active-pressed-color - background color of the active toggle in pressed state
|
37
|
-
* @cssproperty --mdc-toggle-active-disabled-color - background color of the active toggle in disabled state
|
38
|
-
* @cssproperty --mdc-toggle-help-text-color - color of the help text label
|
39
|
-
* @cssproperty --mdc-toggle-label-color-disabled - color of the toggle label and help text in disabled state
|
40
|
-
*
|
24
|
+
* @cssproperty --mdc-toggle-width - Width of the toggle
|
25
|
+
* @cssproperty --mdc-toggle-height - Height of the toggle
|
26
|
+
* @cssproperty --mdc-toggle-width-compact - Width of the toggle when it's size is compact
|
27
|
+
* @cssproperty --mdc-toggle-height-compact - Height of the toggle when it's size is compact
|
28
|
+
* @cssproperty --mdc-toggle-label-lineheight - Line height of the toggle label
|
29
|
+
* @cssproperty --mdc-toggle-label-fontsize - Font size of the toggle label
|
30
|
+
* @cssproperty --mdc-toggle-label-fontweight - Font weight of the toggle label
|
31
|
+
* @cssproperty --mdc-toggle-label-color-disabled - Color of the toggle label and help text in disabled state
|
32
|
+
* @cssproperty --mdc-toggle-help-text-color - Color of the help text label
|
33
|
+
* @cssproperty --mdc-toggle-active-hover-color - Background color of the active toggle in hover state
|
34
|
+
* @cssproperty --mdc-toggle-active-pressed-color - Background color of the active toggle in pressed state
|
35
|
+
* @cssproperty --mdc-toggle-inactive-hover-color - Background color of the inactive toggle in hover state
|
36
|
+
* @cssproperty --mdc-toggle-inactive-pressed-color - Background color of the inactive toggle in pressed state
|
41
37
|
*/
|
42
38
|
declare class Toggle extends Toggle_base implements AssociatedFormControl {
|
43
39
|
/**
|
@@ -10,12 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
import { html } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
-
import styles from './toggle.styles';
|
14
|
-
import FormfieldWrapper from '../formfieldwrapper';
|
15
|
-
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
16
|
-
import { DEFAULTS, ICON_NAME, ICON_SIZE_IN_REM, TOGGLE_SIZE } from './toggle.constants';
|
17
13
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
18
14
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
15
|
+
import FormfieldWrapper from '../formfieldwrapper';
|
16
|
+
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
17
|
+
import { DEFAULTS, TOGGLE_SIZE } from './toggle.constants';
|
18
|
+
import styles from './toggle.styles';
|
19
19
|
/**
|
20
20
|
* Toggle Component is an interactive control used to switch between two mutually exclusive options,
|
21
21
|
* such as On/Off, Active/Inactive. These are commonly used in settings panels, forms, and preference selections
|
@@ -27,30 +27,26 @@ import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
|
27
27
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
28
28
|
*
|
29
29
|
* @dependency mdc-icon
|
30
|
+
* @dependency mdc-statictoggle
|
30
31
|
*
|
31
32
|
* @tagname mdc-toggle
|
32
33
|
*
|
33
34
|
* @event change - (React: onChange) Event that gets dispatched when the toggle state changes.
|
34
35
|
* @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.
|
35
36
|
*
|
36
|
-
* @cssproperty --mdc-toggle-width -
|
37
|
-
* @cssproperty --mdc-toggle-height -
|
38
|
-
* @cssproperty --mdc-toggle-width-compact -
|
39
|
-
* @cssproperty --mdc-toggle-height-compact -
|
40
|
-
* @cssproperty --mdc-toggle-
|
41
|
-
* @cssproperty --mdc-toggle-
|
42
|
-
* @cssproperty --mdc-toggle-
|
43
|
-
* @cssproperty --mdc-toggle-
|
44
|
-
* @cssproperty --mdc-toggle-
|
45
|
-
* @cssproperty --mdc-toggle-
|
46
|
-
* @cssproperty --mdc-toggle-
|
47
|
-
* @cssproperty --mdc-toggle-
|
48
|
-
* @cssproperty --mdc-toggle-
|
49
|
-
* @cssproperty --mdc-toggle-active-pressed-color - background color of the active toggle in pressed state
|
50
|
-
* @cssproperty --mdc-toggle-active-disabled-color - background color of the active toggle in disabled state
|
51
|
-
* @cssproperty --mdc-toggle-help-text-color - color of the help text label
|
52
|
-
* @cssproperty --mdc-toggle-label-color-disabled - color of the toggle label and help text in disabled state
|
53
|
-
*
|
37
|
+
* @cssproperty --mdc-toggle-width - Width of the toggle
|
38
|
+
* @cssproperty --mdc-toggle-height - Height of the toggle
|
39
|
+
* @cssproperty --mdc-toggle-width-compact - Width of the toggle when it's size is compact
|
40
|
+
* @cssproperty --mdc-toggle-height-compact - Height of the toggle when it's size is compact
|
41
|
+
* @cssproperty --mdc-toggle-label-lineheight - Line height of the toggle label
|
42
|
+
* @cssproperty --mdc-toggle-label-fontsize - Font size of the toggle label
|
43
|
+
* @cssproperty --mdc-toggle-label-fontweight - Font weight of the toggle label
|
44
|
+
* @cssproperty --mdc-toggle-label-color-disabled - Color of the toggle label and help text in disabled state
|
45
|
+
* @cssproperty --mdc-toggle-help-text-color - Color of the help text label
|
46
|
+
* @cssproperty --mdc-toggle-active-hover-color - Background color of the active toggle in hover state
|
47
|
+
* @cssproperty --mdc-toggle-active-pressed-color - Background color of the active toggle in pressed state
|
48
|
+
* @cssproperty --mdc-toggle-inactive-hover-color - Background color of the inactive toggle in hover state
|
49
|
+
* @cssproperty --mdc-toggle-inactive-pressed-color - Background color of the inactive toggle in pressed state
|
54
50
|
*/
|
55
51
|
class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
56
52
|
constructor() {
|
@@ -177,11 +173,17 @@ class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
177
173
|
render() {
|
178
174
|
var _a;
|
179
175
|
return html `
|
180
|
-
<
|
176
|
+
<mdc-statictoggle
|
177
|
+
?checked="${this.checked}"
|
178
|
+
?disabled="${this.disabled}"
|
179
|
+
size="${this.size}"
|
180
|
+
class="mdc-focus-ring"
|
181
|
+
part="container"
|
182
|
+
>
|
181
183
|
<input
|
182
184
|
id="${this.id}"
|
183
185
|
type="checkbox"
|
184
|
-
|
186
|
+
part="toggle-input"
|
185
187
|
role="switch"
|
186
188
|
?autofocus="${this.autofocus}"
|
187
189
|
?required="${!!this.requiredLabel}"
|
@@ -196,15 +198,7 @@ class Toggle extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
196
198
|
@change="${this.handleChange}"
|
197
199
|
@keydown="${this.handleKeyDown}"
|
198
200
|
/>
|
199
|
-
|
200
|
-
<mdc-icon
|
201
|
-
name="${this.checked ? ICON_NAME.CHECKED : ICON_NAME.UNCHECKED}"
|
202
|
-
class="mdc-toggle__icon"
|
203
|
-
length-unit="rem"
|
204
|
-
size="${ICON_SIZE_IN_REM[this.size]}"
|
205
|
-
></mdc-icon>
|
206
|
-
</div>
|
207
|
-
</div>
|
201
|
+
</mdc-statictoggle>
|
208
202
|
${this.renderLabel()}
|
209
203
|
${this.renderHelperText()}
|
210
204
|
`;
|
@@ -6,18 +6,6 @@ const styles = [hostFitContentStyles, css `
|
|
6
6
|
--mdc-toggle-height: 1.5rem;
|
7
7
|
--mdc-toggle-width-compact: 2rem;
|
8
8
|
--mdc-toggle-height-compact: 1rem;
|
9
|
-
--mdc-toggle-border-radius: 0.75rem;
|
10
|
-
--mdc-toggle-border-radius-compact: 0.5rem;
|
11
|
-
--mdc-toggle-border: 0.0625rem solid var(--mds-color-theme-outline-input-normal);
|
12
|
-
|
13
|
-
--mdc-toggle-inactive-rest-color: var(--mds-color-theme-control-inactive-normal);
|
14
|
-
--mdc-toggle-inactive-hover-color: var(--mds-color-theme-control-inactive-hover);
|
15
|
-
--mdc-toggle-inactive-pressed-color: var(--mds-color-theme-control-inactive-pressed);
|
16
|
-
--mdc-toggle-inactive-disabled-color: var(--mds-color-theme-control-inactive-disabled);
|
17
|
-
--mdc-toggle-active-rest-color: var(--mds-color-theme-control-active-normal);
|
18
|
-
--mdc-toggle-active-hover-color: var(--mds-color-theme-control-active-hover);
|
19
|
-
--mdc-toggle-active-pressed-color: var(--mds-color-theme-control-active-pressed);
|
20
|
-
--mdc-toggle-active-disabled-color: var(--mds-color-theme-control-active-disabled);
|
21
9
|
|
22
10
|
--mdc-toggle-label-lineheight: var(--mds-font-lineheight-body-midsize);
|
23
11
|
--mdc-toggle-label-fontsize: var(--mds-font-size-body-midsize);
|
@@ -25,10 +13,10 @@ const styles = [hostFitContentStyles, css `
|
|
25
13
|
--mdc-toggle-label-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
26
14
|
--mdc-toggle-help-text-color: var(--mds-color-theme-text-secondary-normal);
|
27
15
|
|
28
|
-
--mdc-toggle-
|
29
|
-
--mdc-toggle-
|
30
|
-
--mdc-toggle-
|
31
|
-
--mdc-toggle-
|
16
|
+
--mdc-toggle-active-hover-color: var(--mds-color-theme-control-active-hover);
|
17
|
+
--mdc-toggle-active-pressed-color: var(--mds-color-theme-control-active-pressed);
|
18
|
+
--mdc-toggle-inactive-hover-color: var(--mds-color-theme-control-inactive-hover);
|
19
|
+
--mdc-toggle-inactive-pressed-color: var(--mds-color-theme-control-inactive-pressed);
|
32
20
|
}
|
33
21
|
|
34
22
|
:host([label]), :host([help-text]){
|
@@ -44,113 +32,55 @@ const styles = [hostFitContentStyles, css `
|
|
44
32
|
row-gap: 0rem;
|
45
33
|
}
|
46
34
|
|
47
|
-
|
48
|
-
position: relative;
|
49
|
-
border-radius: var(--mdc-toggle-border-radius);
|
50
|
-
}
|
51
|
-
|
52
|
-
.mdc-toggle__input {
|
53
|
-
opacity: 0;
|
54
|
-
position: absolute;
|
55
|
-
cursor: pointer;
|
35
|
+
:host::part(toggle-input) {
|
56
36
|
margin: 0;
|
37
|
+
padding: 0;
|
38
|
+
position: absolute;
|
39
|
+
opacity: 0.1%;
|
40
|
+
overflow: visible;
|
41
|
+
z-index: 1;
|
57
42
|
width: var(--mdc-toggle-width);
|
58
43
|
height: var(--mdc-toggle-height);
|
59
44
|
}
|
60
45
|
|
61
|
-
.mdc-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
border: var(--mdc-toggle-border);
|
67
|
-
display: flex;
|
68
|
-
align-items: center;
|
69
|
-
justify-content: flex-start;
|
70
|
-
transition: background-color 0.3s ease;
|
71
|
-
outline: none;
|
72
|
-
padding: 0.0625rem;
|
73
|
-
}
|
74
|
-
|
75
|
-
:host([checked]) .mdc-toggle__slider {
|
76
|
-
background-color: var(--mdc-toggle-active-rest-color);
|
77
|
-
justify-content: flex-end;
|
78
|
-
border-color: transparent;
|
79
|
-
}
|
80
|
-
|
81
|
-
:host([size='compact']) .mdc-toggle__slider {
|
82
|
-
width: var(--mdc-toggle-width-compact);
|
83
|
-
height: var(--mdc-toggle-height-compact);
|
84
|
-
border-radius: var(--mdc-toggle-border-radius-compact);
|
85
|
-
}
|
86
|
-
:host([size='compact']) .mdc-toggle__input {
|
87
|
-
width: var(--mdc-toggle-width-compact);
|
88
|
-
height: var(--mdc-toggle-height-compact);
|
46
|
+
.mdc-label-text, .mdc-help-text {
|
47
|
+
font-size: var(--mdc-toggle-label-fontsize);
|
48
|
+
font-weight: var(--mdc-toggle-label-fontweight);
|
49
|
+
line-height: var(--mdc-toggle-label-lineheight);
|
50
|
+
grid-column: 2;
|
89
51
|
}
|
90
52
|
|
91
|
-
.mdc-
|
92
|
-
|
93
|
-
--mdc-icon-fill-color: var(--mdc-toggle-icon-color-normal);
|
94
|
-
background-color: var(--mdc-toggle-icon-background-color-normal);
|
95
|
-
border-radius: 50%;
|
53
|
+
.mdc-label, :host::part(toggle-input) {
|
54
|
+
cursor: pointer;
|
96
55
|
}
|
97
56
|
|
98
|
-
:host([disabled]) .mdc-
|
99
|
-
|
57
|
+
:host([disabled]) .mdc-label,
|
58
|
+
:host([disabled])::part(toggle-input) {
|
59
|
+
cursor: default;
|
100
60
|
}
|
101
61
|
|
102
|
-
|
103
|
-
|
62
|
+
.mdc-help-text {
|
63
|
+
color: var(--mdc-toggle-help-text-color);
|
104
64
|
}
|
105
65
|
|
106
|
-
:host(:not([disabled]))
|
66
|
+
:host(:hover:not([disabled]))::part(container) {
|
107
67
|
background-color: var(--mdc-toggle-inactive-hover-color);
|
108
68
|
}
|
109
69
|
|
110
|
-
:host(:not([disabled]))
|
70
|
+
:host(:active:not([disabled]))::part(container) {
|
111
71
|
background-color: var(--mdc-toggle-inactive-pressed-color);
|
112
72
|
}
|
113
73
|
|
114
|
-
:host(:not([disabled])[checked])
|
74
|
+
:host(:hover:not([disabled])[checked])::part(container) {
|
115
75
|
background-color: var(--mdc-toggle-active-hover-color);
|
116
76
|
}
|
117
77
|
|
118
|
-
:host(:not([disabled])[checked])
|
78
|
+
:host(:active:not([disabled])[checked])::part(container) {
|
119
79
|
background-color: var(--mdc-toggle-active-pressed-color);
|
120
80
|
}
|
121
81
|
|
122
|
-
:host([disabled]) .mdc-toggle__slider {
|
123
|
-
background-color: var(--mdc-toggle-inactive-disabled-color);
|
124
|
-
}
|
125
|
-
|
126
|
-
:host([disabled][checked]) .mdc-toggle__slider {
|
127
|
-
background-color: var(--mdc-toggle-active-disabled-color);
|
128
|
-
}
|
129
|
-
|
130
|
-
:host([disabled]) .mdc-toggle__icon {
|
131
|
-
background-color: var(--mdc-toggle-icon-background-color-disabled);
|
132
|
-
}
|
133
|
-
|
134
|
-
.mdc-label-text, .mdc-help-text {
|
135
|
-
font-size: var(--mdc-toggle-label-fontsize);
|
136
|
-
font-weight: var(--mdc-toggle-label-fontweight);
|
137
|
-
line-height: var(--mdc-toggle-label-lineheight);
|
138
|
-
grid-column: 2;
|
139
|
-
}
|
140
|
-
|
141
|
-
.mdc-help-text {
|
142
|
-
color: var(--mdc-toggle-help-text-color);
|
143
|
-
}
|
144
|
-
|
145
82
|
:host([disabled]) .mdc-label-text, :host([disabled]) .mdc-help-text {
|
146
83
|
color: var(--mdc-toggle-label-color-disabled);
|
147
84
|
}
|
148
|
-
|
149
|
-
/* High Contrast Mode */
|
150
|
-
@media (forced-colors: active) {
|
151
|
-
:host([checked]) .mdc-toggle__slider, .mdc-toggle__icon {
|
152
|
-
border: var(--mdc-toggle-border);
|
153
|
-
}
|
154
|
-
}
|
155
85
|
`, ...hostFocusRingStyles(true)];
|
156
86
|
export default styles;
|