@vollowx/seele 0.7.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/LICENSE +21 -0
- package/README.md +79 -0
- package/package.json +62 -0
- package/src/all.js +19 -0
- package/src/base/button.js +61 -0
- package/src/base/checkbox.js +118 -0
- package/src/base/controllers/list-controller.js +96 -0
- package/src/base/controllers/popover-controller.js +163 -0
- package/src/base/field.js +3 -0
- package/src/base/hidden-styles.css.js +2 -0
- package/src/base/input.js +182 -0
- package/src/base/item.js +7 -0
- package/src/base/list-item.js +54 -0
- package/src/base/menu-item.js +12 -0
- package/src/base/menu-utils.js +111 -0
- package/src/base/menu.js +244 -0
- package/src/base/mixins/attachable.js +71 -0
- package/src/base/mixins/form-associated.js +69 -0
- package/src/base/mixins/internals-attached.js +13 -0
- package/src/base/option.js +17 -0
- package/src/base/select.js +285 -0
- package/src/base/switch.js +86 -0
- package/src/base/tooltip.js +139 -0
- package/src/core/focus-visible.js +13 -0
- package/src/core/shared.d.ts +1 -0
- package/src/core/unique-id.js +11 -0
- package/src/m3/button/common-button-styles.css.js +2 -0
- package/src/m3/button/common-button-toggle-styles.css.js +2 -0
- package/src/m3/button/common-button-toggle.js +69 -0
- package/src/m3/button/common-button.js +65 -0
- package/src/m3/button/icon-button-styles.css.js +2 -0
- package/src/m3/button/icon-button-toggle-styles.css.js +2 -0
- package/src/m3/button/icon-button-toggle.js +57 -0
- package/src/m3/button/icon-button.js +51 -0
- package/src/m3/button/shared-button-styles.css.js +2 -0
- package/src/m3/checkbox-styles.css.js +2 -0
- package/src/m3/checkbox.js +46 -0
- package/src/m3/fab-styles.css.js +2 -0
- package/src/m3/fab.js +48 -0
- package/src/m3/field/field-styles.css.js +2 -0
- package/src/m3/field/field.js +93 -0
- package/src/m3/field/filled-field-styles.css.js +2 -0
- package/src/m3/field/filled-field.js +30 -0
- package/src/m3/field/outlined-field-styles.css.js +2 -0
- package/src/m3/field/outlined-field.js +34 -0
- package/src/m3/focus-ring-styles.css.js +2 -0
- package/src/m3/focus-ring.js +72 -0
- package/src/m3/item-styles.css.js +2 -0
- package/src/m3/item.js +46 -0
- package/src/m3/list-item-styles.css.js +2 -0
- package/src/m3/list-item.js +52 -0
- package/src/m3/list-styles.css.js +2 -0
- package/src/m3/list.js +16 -0
- package/src/m3/menu-item.js +15 -0
- package/src/m3/menu-part-styles.css.js +2 -0
- package/src/m3/menu-styles.css.js +2 -0
- package/src/m3/menu.js +30 -0
- package/src/m3/option.js +15 -0
- package/src/m3/ripple-styles.css.js +2 -0
- package/src/m3/ripple.js +199 -0
- package/src/m3/select/filled-select.js +41 -0
- package/src/m3/select/outlined-select.js +41 -0
- package/src/m3/select/select-styles.css.js +2 -0
- package/src/m3/select/select.js +34 -0
- package/src/m3/switch-styles.css.js +2 -0
- package/src/m3/switch.js +129 -0
- package/src/m3/target-styles.css.js +2 -0
- package/src/m3/text-field/filled-text-field.js +38 -0
- package/src/m3/text-field/outlined-text-field.js +40 -0
- package/src/m3/text-field/text-field-styles.css.js +2 -0
- package/src/m3/toolbar-styles.css.js +2 -0
- package/src/m3/toolbar.js +53 -0
- package/src/m3/tooltip-styles.css.js +2 -0
- package/src/m3/tooltip.js +18 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Switch } from '../../base/switch.js';
|
|
5
|
+
import { internals } from '../../base/mixins/internals-attached.js';
|
|
6
|
+
import '../focus-ring.js';
|
|
7
|
+
import '../ripple.js';
|
|
8
|
+
import { targetStyles } from '../target-styles.css.js';
|
|
9
|
+
import { sharedButtonStyles } from './shared-button-styles.css.js';
|
|
10
|
+
import { commonButtonStyles } from './common-button-styles.css.js';
|
|
11
|
+
import { commonButtonToggleStyles } from './common-button-toggle-styles.css.js';
|
|
12
|
+
/**
|
|
13
|
+
* @tag md-button-toggle
|
|
14
|
+
*
|
|
15
|
+
* @csspart label
|
|
16
|
+
* @csspart label checked
|
|
17
|
+
* @csspart icon
|
|
18
|
+
* @csspart icon checked
|
|
19
|
+
*
|
|
20
|
+
* @slot - label
|
|
21
|
+
* @slot icon - leading icon
|
|
22
|
+
*/
|
|
23
|
+
let M3ButtonToggle = class M3ButtonToggle extends Switch {
|
|
24
|
+
static { this.styles = [
|
|
25
|
+
...super.styles,
|
|
26
|
+
targetStyles,
|
|
27
|
+
sharedButtonStyles,
|
|
28
|
+
commonButtonStyles,
|
|
29
|
+
commonButtonToggleStyles,
|
|
30
|
+
]; }
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.size = 'small';
|
|
34
|
+
this.shape = 'rounded';
|
|
35
|
+
this.variant = 'filled';
|
|
36
|
+
/**
|
|
37
|
+
* Whether to show the icon at the end of the button.
|
|
38
|
+
*/
|
|
39
|
+
this.trailingIcon = false;
|
|
40
|
+
this[internals].role = 'button';
|
|
41
|
+
}
|
|
42
|
+
render() {
|
|
43
|
+
return html `
|
|
44
|
+
<md-focus-ring></md-focus-ring>
|
|
45
|
+
<md-ripple></md-ripple>
|
|
46
|
+
<span part="target"></span>
|
|
47
|
+
<slot part="icon unchecked" name="icon" aria-hidden="true"></slot>
|
|
48
|
+
<slot part="icon checked" name="icon-checked" aria-hidden="true"></slot>
|
|
49
|
+
<slot part="label unchecked"></slot>
|
|
50
|
+
<slot part="label checked" name="checked"></slot>
|
|
51
|
+
`;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
__decorate([
|
|
55
|
+
property({ reflect: true })
|
|
56
|
+
], M3ButtonToggle.prototype, "size", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
property({ reflect: true })
|
|
59
|
+
], M3ButtonToggle.prototype, "shape", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
property({ reflect: true })
|
|
62
|
+
], M3ButtonToggle.prototype, "variant", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
property({ type: Boolean, reflect: true })
|
|
65
|
+
], M3ButtonToggle.prototype, "trailingIcon", void 0);
|
|
66
|
+
M3ButtonToggle = __decorate([
|
|
67
|
+
customElement('md-button-toggle')
|
|
68
|
+
], M3ButtonToggle);
|
|
69
|
+
export { M3ButtonToggle };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Button } from '../../base/button.js';
|
|
5
|
+
import '../focus-ring.js';
|
|
6
|
+
import '../ripple.js';
|
|
7
|
+
import { targetStyles } from '../target-styles.css.js';
|
|
8
|
+
import { sharedButtonStyles } from './shared-button-styles.css.js';
|
|
9
|
+
import { commonButtonStyles } from './common-button-styles.css.js';
|
|
10
|
+
/**
|
|
11
|
+
* @tag md-button
|
|
12
|
+
*
|
|
13
|
+
* @csspart label
|
|
14
|
+
* @csspart icon
|
|
15
|
+
*
|
|
16
|
+
* @slot - label
|
|
17
|
+
* @slot icon - leading icon
|
|
18
|
+
*/
|
|
19
|
+
let M3Button = class M3Button extends Button {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.size = 'small';
|
|
23
|
+
this.shape = 'rounded';
|
|
24
|
+
this.color = 'primary';
|
|
25
|
+
this.variant = 'filled';
|
|
26
|
+
/**
|
|
27
|
+
* Whether to show the icon at the end of the button.
|
|
28
|
+
*/
|
|
29
|
+
this.trailingIcon = false;
|
|
30
|
+
}
|
|
31
|
+
static { this.styles = [
|
|
32
|
+
...super.styles,
|
|
33
|
+
targetStyles,
|
|
34
|
+
sharedButtonStyles,
|
|
35
|
+
commonButtonStyles,
|
|
36
|
+
]; }
|
|
37
|
+
render() {
|
|
38
|
+
return html `
|
|
39
|
+
<md-focus-ring></md-focus-ring>
|
|
40
|
+
<md-ripple></md-ripple>
|
|
41
|
+
<span part="target"></span>
|
|
42
|
+
<slot part="icon" name="icon" aria-hidden="true"></slot>
|
|
43
|
+
<slot part="label"></slot>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ reflect: true })
|
|
49
|
+
], M3Button.prototype, "size", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
property({ reflect: true })
|
|
52
|
+
], M3Button.prototype, "shape", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
property({ reflect: true })
|
|
55
|
+
], M3Button.prototype, "color", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
property({ reflect: true })
|
|
58
|
+
], M3Button.prototype, "variant", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
property({ type: Boolean, reflect: true })
|
|
61
|
+
], M3Button.prototype, "trailingIcon", void 0);
|
|
62
|
+
M3Button = __decorate([
|
|
63
|
+
customElement('md-button')
|
|
64
|
+
], M3Button);
|
|
65
|
+
export { M3Button };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const iconButtonStyles = css `:host{--_icon-size:24px;background-color:color-mix(in srgb,var(--_background-color)var(--_background-opacity,100%),transparent);border-radius:calc(var(--_h)/2);color:color-mix(in srgb,var(--_text-color)var(--_text-opacity,100%),transparent);height:var(--_h);transition:border-radius var(--md-sys-motion-std-effects-slow-duration)var(--md-sys-motion-std-effects-slow);width:var(--_h)}:host([variant=text]){--_text-color:var(--md-sys-color-on-surface-variant)}:host([width=narrow]){width:var(--_w_narrow)}:host([width=wide]){width:var(--_w_wide)}:host(:disabled){--_text-opacity:38%;cursor:default;pointer-events:none;--_text-color:var(--md-sys-color-on-surface)!important}:host([variant=filled]:disabled),:host([variant=tonal]:disabled){--_background-color:var(--md-sys-color-on-surface);--_background-opacity:10%}:host([variant=outlined]:disabled){--_outline-color:var(--md-sys-color-on-surface);--_outline-opacity:10%}::slotted(*){fill:currentColor;block-size:1em;font-size:var(--_icon-size);inline-size:1em}`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const iconButtonToggleStyles = css `:host([variant=text]:state(checked)){--_text-color:var(--md-sys-color-primary)}:host([variant=filled]:not(:state(checked))){--_background-color:var(--md-sys-color-surface-container);--_text-color:var(--md-sys-color-on-surface-variant)}:host([variant=tonal]:not(:state(checked))){--_background-color:var(--md-sys-color-surface-container-highest);--_text-color:var(--md-sys-color-on-surface-variant)}:host([variant=outlined]:state(checked)){--_background-color:var(--md-sys-color-inverse-surface);--_outline-color:var(--md-sys-color-inverse-surface);--_text-color:var(--md-sys-color-inverse-on-surface)}:host([variant=outlined]:state(checked):disabled){--_background-color:var(--md-sys-color-on-surface);--_background-opacity:10%;--_text-color:var(--md-sys-color-on-surface);--_text-opacity:38%;border-width:0}`;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Switch } from '../../base/switch.js';
|
|
5
|
+
import { internals } from '../../base/mixins/internals-attached.js';
|
|
6
|
+
import '../focus-ring.js';
|
|
7
|
+
import '../ripple.js';
|
|
8
|
+
import { targetStyles } from '../target-styles.css.js';
|
|
9
|
+
import { sharedButtonStyles } from './shared-button-styles.css.js';
|
|
10
|
+
import { iconButtonStyles } from './icon-button-styles.css.js';
|
|
11
|
+
import { iconButtonToggleStyles } from './icon-button-toggle-styles.css.js';
|
|
12
|
+
/**
|
|
13
|
+
* @tag md-icon-button-toggle
|
|
14
|
+
*
|
|
15
|
+
* @csspart icon
|
|
16
|
+
*
|
|
17
|
+
* @slot - icon
|
|
18
|
+
* @slot checked - icon when checked
|
|
19
|
+
*/
|
|
20
|
+
let M3IconButtonToggle = class M3IconButtonToggle extends Switch {
|
|
21
|
+
static { this.styles = [
|
|
22
|
+
...super.styles,
|
|
23
|
+
targetStyles,
|
|
24
|
+
sharedButtonStyles,
|
|
25
|
+
iconButtonStyles,
|
|
26
|
+
iconButtonToggleStyles,
|
|
27
|
+
]; }
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.size = 'small';
|
|
31
|
+
this.variant = 'text';
|
|
32
|
+
this.width = 'standard';
|
|
33
|
+
this[internals].role = 'button';
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
return html `
|
|
37
|
+
<md-focus-ring></md-focus-ring>
|
|
38
|
+
<md-ripple enterbehavior="always"></md-ripple>
|
|
39
|
+
<span part="target"></span>
|
|
40
|
+
<slot part="icon unchecked"></slot>
|
|
41
|
+
<slot part="icon checked" name="checked"></slot>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ reflect: true })
|
|
47
|
+
], M3IconButtonToggle.prototype, "size", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ reflect: true })
|
|
50
|
+
], M3IconButtonToggle.prototype, "variant", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
property({ reflect: true })
|
|
53
|
+
], M3IconButtonToggle.prototype, "width", void 0);
|
|
54
|
+
M3IconButtonToggle = __decorate([
|
|
55
|
+
customElement('md-icon-button-toggle')
|
|
56
|
+
], M3IconButtonToggle);
|
|
57
|
+
export { M3IconButtonToggle };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Button } from '../../base/button.js';
|
|
5
|
+
import '../focus-ring.js';
|
|
6
|
+
import '../ripple.js';
|
|
7
|
+
import { targetStyles } from '../target-styles.css.js';
|
|
8
|
+
import { sharedButtonStyles } from './shared-button-styles.css.js';
|
|
9
|
+
import { iconButtonStyles } from './icon-button-styles.css.js';
|
|
10
|
+
/**
|
|
11
|
+
* @tag md-icon-button
|
|
12
|
+
*
|
|
13
|
+
* @csspart icon
|
|
14
|
+
*
|
|
15
|
+
* @slot - icon
|
|
16
|
+
*/
|
|
17
|
+
let M3IconButton = class M3IconButton extends Button {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.size = 'small';
|
|
21
|
+
this.variant = 'text';
|
|
22
|
+
this.width = 'standard';
|
|
23
|
+
}
|
|
24
|
+
static { this.styles = [
|
|
25
|
+
...super.styles,
|
|
26
|
+
targetStyles,
|
|
27
|
+
sharedButtonStyles,
|
|
28
|
+
iconButtonStyles,
|
|
29
|
+
]; }
|
|
30
|
+
render() {
|
|
31
|
+
return html `
|
|
32
|
+
<md-focus-ring></md-focus-ring>
|
|
33
|
+
<md-ripple></md-ripple>
|
|
34
|
+
<span part="target"></span>
|
|
35
|
+
<slot part="icon"></slot>
|
|
36
|
+
`;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ reflect: true })
|
|
41
|
+
], M3IconButton.prototype, "size", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
property({ reflect: true })
|
|
44
|
+
], M3IconButton.prototype, "variant", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ reflect: true })
|
|
47
|
+
], M3IconButton.prototype, "width", void 0);
|
|
48
|
+
M3IconButton = __decorate([
|
|
49
|
+
customElement('md-icon-button')
|
|
50
|
+
], M3IconButton);
|
|
51
|
+
export { M3IconButton };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const sharedButtonStyles = css `:host{--_on-color:var(--md-sys-color-on-primary);--_color:var(--md-sys-color-primary);--_h:40px;--_w_narrow:32px;--_w_wide:52px;--_icon-size:20px;--_pad:16px;--_gap:8px;--_rad-sq:12px;--_rad-pr:8px;--_text-color:var(--_on-color);--_background-color:var(--_color);--_outline-color:var(--md-sys-color-outline-variant);box-sizing:border-box;cursor:pointer;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;vertical-align:top;outline:0;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([size=xsmall]){--_h:32px;--_w_narrow:28px;--_w_wide:40px;--_pad:12px;--_gap:4px}:host([size=medium]){--_h:56px;--_w_narrow:48px;--_w_wide:72px;--_icon-size:24px;--_pad:24px;--_gap:8px;--_rad-sq:16px;--_rad-pr:12px;font:var(--md-sys-typography-title-medium)}:host([size=large]){--_h:96px;--_w_narrow:64px;--_w_wide:128px;--_icon-size:32px;--_pad:48px;--_gap:12px;--_rad-sq:28px;--_rad-pr:16px;font:var(--md-sys-typography-headline-small)}:host([size=xlarge]){--_h:136px;--_w_narrow:104px;--_w_wide:184px;--_icon-size:40px;--_pad:64px;--_gap:16px;--_rad-sq:28px;--_rad-pr:16px;font:var(--md-sys-typography-headline-medium)}:host([color=secondary]){--_on-color:var(--md-sys-color-on-secondary);--_color:var(--md-sys-color-secondary)}:host([color=tertiary]){--_on-color:var(--md-sys-color-on-tertiary);--_color:var(--md-sys-color-tertiary)}:host([variant=tonal]){--_background-color:var(--md-sys-color-secondary-container);--_text-color:var(--md-sys-color-on-secondary-container)}:host([variant=outlined]){--_background-color:transparent;--_text-color:var(--md-sys-color-on-surface-variant);--md-focus-ring-offset:3px;border-color:color-mix(in srgb,var(--_outline-color)var(--_outline-opacity,100%),transparent);box-shadow:none;border-style:solid;border-width:1px}:host([variant=text]){--_background-color:transparent;--_text-color:var(--_color)}:host([shape=square]),:host(:state(checked)){--md-focus-ring-shape:var(--_rad-sq);border-radius:var(--_rad-sq)}:host(:active){--md-focus-ring-shape:var(--_rad-pr);border-radius:var(--_rad-pr)}:host(:state(checked)) [part~=unchecked],:host(:not(:state(checked))) [part~=checked]{display:none}`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const checkboxStyles = css `:host{--md-focus-ring-radius:9999px;--_container-color:transparent;--_outline-color:var(--md-sys-color-on-surface-variant);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-on-surface);--_checkbox-size:18px;background-color:color-mix(in srgb,var(--_container-color)var(--_container-opacity,100%),transparent);border-color:color-mix(in srgb,var(--_outline-color)var(--_outline-opacity,100%),transparent);border-style:solid;border-width:var(--md-checkbox-outline-width,2px);box-sizing:border-box;cursor:pointer;height:var(--_checkbox-size);-webkit-tap-highlight-color:transparent;transition:background-color var(--md-sys-motion-exp-effects-fast-duration)var(--md-sys-motion-exp-effects-fast),border-color var(--md-sys-motion-exp-effects-fast-duration)var(--md-sys-motion-exp-effects-fast);-webkit-user-select:none;user-select:none;vertical-align:top;width:var(--_checkbox-size);border-radius:2px;outline:0;place-content:center;place-items:center;margin:15px;display:inline-grid;position:relative}:host(:state(checked)),:host(:state(indeterminate)){--_container-color:var(--md-sys-color-primary);--_outline-color:var(--md-sys-color-primary);--_mark-color:var(--md-sys-color-on-primary);--_mark-opacity:100%;--_ripple-color:var(--md-sys-color-primary)}:host([error]){--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-surface-container-highest);--_ripple-color:var(--md-sys-color-error)}:host([error]:state(checked)),:host([error]:state(indeterminate)){--_container-color:var(--md-sys-color-error);--_outline-color:var(--md-sys-color-error);--_mark-color:var(--md-sys-color-on-error);--_ripple-color:var(--md-sys-color-error)}:host(:disabled){--_outline-color:var(--md-sys-color-on-surface);--_outline-opacity:38%;--_mark-color:var(--md-sys-color-surface-container-highest);cursor:default;pointer-events:none}:host(:disabled:state(checked)),:host(:disabled:state(indeterminate)){--_container-color:var(--md-sys-color-on-surface);--_container-opacity:38%;--_outline-color:var(--md-sys-color-surface);--_outline-opacity:0%;--_mark-color:var(--md-sys-color-surface)}@media (hover:hover) and (pointer:fine){:host(:hover){--_unchecked-outline-color:var(--md-sys-color-on-surface)}}@media (forced-colors:active){:host{forced-color-adjust:none}}:host(:disabled){--_unchecked-container-opacity:38%}[part~=icon]{fill:color-mix(in srgb,var(--_mark-color)var(--_mark-opacity,0%),transparent);height:18px;transition:fill var(--md-sys-motion-exp-effects-fast-duration)var(--md-sys-motion-exp-effects-fast);width:18px;position:absolute;inset:-2px}[part~=mark]{transition-duration:var(--md-sys-motion-exp-effects-fast-duration);transition-timing-function:var(--md-sys-motion-exp-effects-fast);transform:scaleY(-1)translate(7px,-14px)rotate(45deg)}:host(:state(indeterminate)) [part~=mark]{transform:scaleY(-1)translate(4px,-10px)rotate(0)}:host(:state(checked)) [part~=mark],:host(:state(indeterminate)) [part~=mark]{transition-duration:var(--md-sys-motion-exp-effects-slow-duration);transition-timing-function:var(--md-sys-motion-exp-effects-slow)}[part~=mark-short]{width:2px;height:0;transition-property:transform,height}[part~=mark-long]{width:0;height:2px;transition-property:transform,width}:host(:not(:state(checked)):not(:state(indeterminate)):state(was-checked)) [part~=mark],:host(:not(:state(checked)):not(:state(indeterminate)):state(was-indeterminate)) [part~=mark]{transition-delay:var(--md-sys-motion-exp-effects-fast-duration)}:host(:state(checked)) [part~=mark-short]{height:5.65685px}:host(:state(checked)) [part~=mark-long]{width:11.3137px}:host(:state(checked):state(was-unchecked)) [part~=mark-short]{transition-property:none}:host(:state(indeterminate)) [part~=mark-short]{height:2px}:host(:state(indeterminate)) [part~=mark-long]{width:10px}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-short]{transition-property:height}:host(:state(indeterminate):state(was-unchecked)) [part~=mark-long]{transition-property:width}md-focus-ring{height:44px;inset:unset;width:44px}md-ripple{--md-ripple-color:var(--_ripple-color);height:40px;inset:unset;border-radius:9999px;width:40px}`;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Checkbox } from '../base/checkbox.js';
|
|
5
|
+
import './focus-ring.js';
|
|
6
|
+
import './ripple.js';
|
|
7
|
+
import { checkboxStyles } from './checkbox-styles.css.js';
|
|
8
|
+
import { targetStyles } from './target-styles.css.js';
|
|
9
|
+
/**
|
|
10
|
+
* @tag md-checkbox
|
|
11
|
+
*
|
|
12
|
+
* @csspart icon
|
|
13
|
+
* @csspart mark
|
|
14
|
+
* @csspart mark-short
|
|
15
|
+
* @csspart mark-long
|
|
16
|
+
*/
|
|
17
|
+
let M3Checkbox = class M3Checkbox extends Checkbox {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.error = false;
|
|
21
|
+
}
|
|
22
|
+
static { this.styles = [...super.styles, targetStyles, checkboxStyles]; }
|
|
23
|
+
render() {
|
|
24
|
+
return html `
|
|
25
|
+
<md-focus-ring></md-focus-ring>
|
|
26
|
+
<md-ripple enterbehavior="none"></md-ripple>
|
|
27
|
+
<span part="target"></span>
|
|
28
|
+
${this.renderIcon()}
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
renderIcon() {
|
|
32
|
+
return html `
|
|
33
|
+
<svg part="icon" viewBox="0 0 18 18" aria-hidden="true">
|
|
34
|
+
<rect part="mark mark-short"></rect>
|
|
35
|
+
<rect part="mark mark-long"></rect>
|
|
36
|
+
</svg>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
property({ type: Boolean, reflect: true })
|
|
42
|
+
], M3Checkbox.prototype, "error", void 0);
|
|
43
|
+
M3Checkbox = __decorate([
|
|
44
|
+
customElement('md-checkbox')
|
|
45
|
+
], M3Checkbox);
|
|
46
|
+
export { M3Checkbox };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const fabStyles = css `:host{--_text-color:var(--md-sys-color-primary);--_background-color:var(--md-sys-color-surface-container-high);--_size:56px;--_border-radius:16px;--_icon-size:24px;background-color:color-mix(in srgb,var(--_background-color)var(--_background-opacity,100%),transparent);border-radius:var(--_border-radius);box-shadow:var(--md-sys-elevation-shadow-3);box-sizing:border-box;color:color-mix(in srgb,var(--_text-color)var(--_text-opacity,100%),transparent);cursor:pointer;font:var(--md-sys-typography-label-large);height:var(--_size);min-width:var(--_size);padding-inline:calc((var(--_size) - var(--_icon-size))/2);-webkit-tap-highlight-color:transparent;transition:box-shadow var(--md-sys-motion-std-effects-slow-duration)var(--md-sys-motion-std-effects-slow);-webkit-user-select:none;user-select:none;vertical-align:middle;outline:0;justify-content:center;align-items:center;gap:8px;display:inline-flex;position:relative}:host([lowered]){--_background-color:var(--md-sys-color-surface-container-low);box-shadow:var(--md-sys-elevation-shadow-1)}:host([size=small]){--_size:40px;--_border-radius:12px}:host([size=large]){--_size:96px;--_border-radius:28px;--_icon-size:36px}:host([color=primary]){--_text-color:var(--md-sys-color-on-primary);--_background-color:var(--md-sys-color-primary)}:host([color=secondary]){--_text-color:var(--md-sys-color-on-secondary);--_background-color:var(--md-sys-color-secondary)}:host([color=tertiary]){--_text-color:var(--md-sys-color-on-tertiary);--_background-color:var(--md-sys-color-tertiary)}:host(:disabled){--_background-color:var(--md-sys-color-on-surface);--_background-opacity:12%;--_text-color:var(--md-sys-color-on-surface);--_text-opacity:38%;box-shadow:none;cursor:default;pointer-events:none}@media (hover:hover) and (pointer:fine){:host(:hover:not(:active)){box-shadow:var(--md-sys-elevation-shadow-4)}:host([lowered]:hover:not(:active)){box-shadow:var(--md-sys-elevation-shadow-2)}}md-focus-ring{--md-focus-ring-shape:var(--_border-radius)}::slotted(:not([slot=label])){fill:currentColor;block-size:1em;font-size:var(--_icon-size);inline-size:1em;display:inline-flex}::slotted([slot=label]){margin-inline:4px}`;
|
package/src/m3/fab.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { Button } from '../base/button.js';
|
|
5
|
+
import './focus-ring.js';
|
|
6
|
+
import './ripple.js';
|
|
7
|
+
import { fabStyles } from './fab-styles.css.js';
|
|
8
|
+
import { targetStyles } from './target-styles.css.js';
|
|
9
|
+
/**
|
|
10
|
+
* @tag md-fab
|
|
11
|
+
*
|
|
12
|
+
* @csspart icon
|
|
13
|
+
* @csspart label
|
|
14
|
+
*
|
|
15
|
+
* @slot - icon
|
|
16
|
+
* @slot label - label
|
|
17
|
+
*/
|
|
18
|
+
let M3FAB = class M3FAB extends Button {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.size = 'medium';
|
|
22
|
+
this.color = 'surface';
|
|
23
|
+
this.lowered = false;
|
|
24
|
+
}
|
|
25
|
+
static { this.styles = [...super.styles, targetStyles, fabStyles]; }
|
|
26
|
+
render() {
|
|
27
|
+
return html `
|
|
28
|
+
<md-focus-ring></md-focus-ring>
|
|
29
|
+
<md-ripple></md-ripple>
|
|
30
|
+
<span part="target"></span>
|
|
31
|
+
<slot part="icon" aria-hidden="true"></slot>
|
|
32
|
+
<slot part="label" name="label"></slot>
|
|
33
|
+
`;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
__decorate([
|
|
37
|
+
property({ reflect: true })
|
|
38
|
+
], M3FAB.prototype, "size", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
property({ reflect: true })
|
|
41
|
+
], M3FAB.prototype, "color", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
property({ type: Boolean, reflect: true })
|
|
44
|
+
], M3FAB.prototype, "lowered", void 0);
|
|
45
|
+
M3FAB = __decorate([
|
|
46
|
+
customElement('md-fab')
|
|
47
|
+
], M3FAB);
|
|
48
|
+
export { M3FAB };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const fieldStyles = css `:host{cursor:text;-webkit-user-select:none;user-select:none;vertical-align:top;flex-direction:column;display:inline-flex;position:relative}.container{box-sizing:border-box;flex:1;align-items:center;min-height:56px;padding-block:16px;display:flex;position:relative}:host([disabled]){opacity:.38;pointer-events:none}.start,.end{color:var(--md-sys-color-on-surface-variant);justify-content:center;align-items:center;min-width:48px;display:flex}.start[hidden],.end[hidden]{display:none}.middle{flex-direction:column;flex:1;justify-content:center;height:100%;display:flex;position:relative;overflow:hidden}.label{font:var(--md-sys-typography-body-large);pointer-events:none;text-overflow:ellipsis;transform-origin:0 0;max-width:calc(100% - 24px);transition:margin-top var(--md-sys-motion-exp-effects-default-duration)var(--md-sys-motion-exp-effects-default),font-size var(--md-sys-motion-exp-effects-default-duration)var(--md-sys-motion-exp-effects-default);white-space:nowrap}.input-wrapper{flex:1;align-items:center;display:flex}:host([haslabel]:not([focused]):not([populated])) ::slotted(input)::placeholder,:host([haslabel]:not([focused]):not([populated])) ::slotted(textarea)::placeholder{opacity:0}::slotted(*){caret-color:var(--md-sys-color-primary);font:var(--md-sys-typography-body-large)}.supporting-text{color:var(--md-sys-color-on-surface-variant);font:var(--md-sys-typography-body-small);padding-inline:16px;padding-top:4px}:host([error]) ::slotted(*){caret-color:var(--md-sys-color-error)}:host([error]) .supporting-text{color:var(--md-sys-color-error)}`;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property, state } from 'lit/decorators.js';
|
|
4
|
+
import { Field } from '../../base/field.js';
|
|
5
|
+
import { fieldStyles } from './field-styles.css.js';
|
|
6
|
+
/**
|
|
7
|
+
* @fires {Event} change - Fired when the selected value has changed.
|
|
8
|
+
* @fires {Event} input - Fired when the selected value has changed.
|
|
9
|
+
*/
|
|
10
|
+
export class M3Field extends Field {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.label = '';
|
|
14
|
+
this.supportingText = '';
|
|
15
|
+
this.disabled = false;
|
|
16
|
+
this.error = false;
|
|
17
|
+
this.focused = false;
|
|
18
|
+
this.populated = false;
|
|
19
|
+
this.hasLabel = false;
|
|
20
|
+
this.hasStart = false;
|
|
21
|
+
this.hasEnd = false;
|
|
22
|
+
}
|
|
23
|
+
static { this.styles = [fieldStyles]; }
|
|
24
|
+
update(changedProperties) {
|
|
25
|
+
if (changedProperties.has('label')) {
|
|
26
|
+
this.hasLabel = !!this.label;
|
|
27
|
+
}
|
|
28
|
+
super.update(changedProperties);
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
return html `
|
|
32
|
+
<div class="container">${this.renderContainerContent()}</div>
|
|
33
|
+
${this.renderSupportingText()}
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
renderSupportingText() {
|
|
37
|
+
if (!this.supportingText) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
return html `<div class="supporting-text">${this.supportingText}</div>`;
|
|
41
|
+
}
|
|
42
|
+
renderStart() {
|
|
43
|
+
return html `<slot
|
|
44
|
+
name="start"
|
|
45
|
+
class="start"
|
|
46
|
+
?hidden=${!this.hasStart}
|
|
47
|
+
@slotchange=${this.handleSlotChange}
|
|
48
|
+
></slot>`;
|
|
49
|
+
}
|
|
50
|
+
renderEnd() {
|
|
51
|
+
return html `<slot
|
|
52
|
+
name="end"
|
|
53
|
+
class="end"
|
|
54
|
+
?hidden=${!this.hasEnd}
|
|
55
|
+
@slotchange=${this.handleSlotChange}
|
|
56
|
+
></slot>`;
|
|
57
|
+
}
|
|
58
|
+
handleSlotChange(e) {
|
|
59
|
+
const slot = e.target;
|
|
60
|
+
const hasContent = slot.assignedNodes({ flatten: true }).length > 0;
|
|
61
|
+
if (slot.name === 'start')
|
|
62
|
+
this.hasStart = hasContent;
|
|
63
|
+
if (slot.name === 'end')
|
|
64
|
+
this.hasEnd = hasContent;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__decorate([
|
|
68
|
+
property({ type: String, reflect: true })
|
|
69
|
+
], M3Field.prototype, "label", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
property({ type: String, reflect: true })
|
|
72
|
+
], M3Field.prototype, "supportingText", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
property({ type: Boolean, reflect: true })
|
|
75
|
+
], M3Field.prototype, "disabled", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
property({ type: Boolean, reflect: true })
|
|
78
|
+
], M3Field.prototype, "error", void 0);
|
|
79
|
+
__decorate([
|
|
80
|
+
property({ type: Boolean, reflect: true })
|
|
81
|
+
], M3Field.prototype, "focused", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
property({ type: Boolean, reflect: true })
|
|
84
|
+
], M3Field.prototype, "populated", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
property({ type: Boolean, reflect: true })
|
|
87
|
+
], M3Field.prototype, "hasLabel", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
state()
|
|
90
|
+
], M3Field.prototype, "hasStart", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
state()
|
|
93
|
+
], M3Field.prototype, "hasEnd", void 0);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const filledFieldStyles = css `.container{--_indicator-height:1px;--_indicator-color:var(--md-sys-color-on-surface-variant);background-color:var(--md-sys-color-surface-container-highest);box-shadow:inset 0 calc(var(--_indicator-height)*-1)0 0 var(--_indicator-color);transition:box-shadow var(--md-sys-motion-exp-effects-default-duration)var(--md-sys-motion-exp-effects-default);border-radius:4px 4px 0 0;padding:0 16px}:host([haslabel]) .input-wrapper{padding-top:24px;padding-bottom:8px}.label{color:var(--md-sys-color-on-surface-variant);margin-top:15px;position:absolute;top:0;left:0}:host([focused]) .label{color:var(--md-sys-color-primary)}:host([error]) .label{color:var(--md-sys-color-error)}:host([populated]) .label,:host([focused]) .label{margin-top:4px;font-size:.75rem}:host([focused]) .container{--_indicator-height:3px;--_indicator-color:var(--md-sys-color-primary)}:host([error]) .container,:host([error][focused]) .container{--_indicator-color:var(--md-sys-color-error)}`;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import { M3Field } from './field.js';
|
|
5
|
+
import '../ripple.js';
|
|
6
|
+
import { filledFieldStyles } from './filled-field-styles.css.js';
|
|
7
|
+
let M3FilledField = class M3FilledField extends M3Field {
|
|
8
|
+
static { this.styles = [...super.styles, filledFieldStyles]; }
|
|
9
|
+
renderContainerContent() {
|
|
10
|
+
return html `
|
|
11
|
+
<md-ripple
|
|
12
|
+
clickbehavior="none"
|
|
13
|
+
enterbehavior="none"
|
|
14
|
+
spacebehavior="none"
|
|
15
|
+
></md-ripple>
|
|
16
|
+
${this.renderStart()}
|
|
17
|
+
<div class="middle">
|
|
18
|
+
<span class="label">${this.label}</span>
|
|
19
|
+
<div class="input-wrapper">
|
|
20
|
+
<slot></slot>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
${this.renderEnd()}
|
|
24
|
+
`;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
M3FilledField = __decorate([
|
|
28
|
+
customElement('md-filled-field')
|
|
29
|
+
], M3FilledField);
|
|
30
|
+
export { M3FilledField };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const outlinedFieldStyles = css `:host{--_outline-width:1px}.container{border-radius:4px;padding-inline:16px}.outline{border-radius:inherit;color:var(--md-sys-color-outline);pointer-events:none;display:flex;position:absolute;inset:0}.outline-start,.outline-notch,.outline-end{border:var(--_outline-width)solid currentColor;box-sizing:border-box;transition:border-width var(--md-sys-motion-exp-effects-default-duration)var(--md-sys-motion-exp-effects-default),border-top-color var(--md-sys-motion-exp-effects-default-duration)var(--md-sys-motion-exp-effects-default)}.outline-start{border-radius:inherit;border-right:none;border-top-right-radius:0;border-bottom-right-radius:0;width:12px}.outline-end{border-radius:inherit;border-left:none;border-top-left-radius:0;border-bottom-left-radius:0;flex:1}.outline-notch{border-left:none;border-right:none;align-items:flex-start;max-width:calc(100% - 24px);margin-top:0;padding:0 4px;display:flex}:host(:not([haslabel])) .outline-notch{display:none}.label{margin-top:15px}:host(:hover) .label,:host(:hover) .outline{color:var(--md-sys-color-on-surface)}:host([focused]){--_outline-width:3px}:host([focused]) .label,:host([focused]) .outline{color:var(--md-sys-color-primary)}:host([error]) .label,:host([error]) .outline{color:var(--md-sys-color-error)}:host([populated]) .outline-notch,:host([focused]) .outline-notch{border-top-width:0;border-top-color:#0000}:host([populated]) .label,:host([focused]) .label{margin-top:-12px;font-size:.75rem}:host([disabled]) .outline{color:var(--md-sys-color-outline-variant)}:host([disabled]) .label{color:var(--md-sys-color-on-surface-variant)}`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import { M3Field } from './field.js';
|
|
5
|
+
import { outlinedFieldStyles } from './outlined-field-styles.css.js';
|
|
6
|
+
let M3OutlinedField = class M3OutlinedField extends M3Field {
|
|
7
|
+
static { this.styles = [...super.styles, outlinedFieldStyles]; }
|
|
8
|
+
renderContainerContent() {
|
|
9
|
+
return html `
|
|
10
|
+
${this.renderOutline()} ${this.renderStart()}
|
|
11
|
+
<div class="middle">
|
|
12
|
+
<div class="input-wrapper">
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
${this.renderEnd()}
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
renderOutline() {
|
|
20
|
+
return html `
|
|
21
|
+
<div class="outline">
|
|
22
|
+
<div class="outline-start"></div>
|
|
23
|
+
<div class="outline-notch">
|
|
24
|
+
<span class="label">${this.label}</span>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="outline-end"></div>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
M3OutlinedField = __decorate([
|
|
32
|
+
customElement('md-outlined-field')
|
|
33
|
+
], M3OutlinedField);
|
|
34
|
+
export { M3OutlinedField };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const focusRingStyles = css `:host{animation-delay:0s,calc(var(--md-focus-ring-duration,.6s)*.25);animation-duration:calc(var(--md-focus-ring-duration,.6s)*.25),calc(var(--md-focus-ring-duration,.6s)*.75);animation-timing-function:var(--md-sys-motion-exp-spatial-slow);box-sizing:border-box;color:var(--md-focus-ring-color,var(--md-sys-color-secondary));pointer-events:none;display:none;position:absolute}:host(:state(visible)){display:flex}:host(:not([inward])){inset:calc(-1*var(--md-focus-ring-outward-offset,2px));outline:var(--md-focus-ring-width,3px)solid currentColor;border-start-start-radius:calc(var(--md-focus-ring-shape-start-start,var(--md-focus-ring-shape,9999px)) + var(--md-focus-ring-outward-offset,2px));border-start-end-radius:calc(var(--md-focus-ring-shape-start-end,var(--md-focus-ring-shape,9999px)) + var(--md-focus-ring-outward-offset,2px));border-end-end-radius:calc(var(--md-focus-ring-shape-end-end,var(--md-focus-ring-shape,9999px)) + var(--md-focus-ring-outward-offset,2px));border-end-start-radius:calc(var(--md-focus-ring-shape-end-start,var(--md-focus-ring-shape,9999px)) + var(--md-focus-ring-outward-offset,2px));animation-name:outward-grow,outward-shrink}:host([inward]){border:var(--md-focus-ring-width,3px)solid currentColor;inset:var(--md-focus-ring-inward-offset,0px);border-start-start-radius:calc(var(--md-focus-ring-shape-start-start,var(--md-focus-ring-shape,9999px)) - var(--md-focus-ring-inward-offset,0px));border-start-end-radius:calc(var(--md-focus-ring-shape-start-end,var(--md-focus-ring-shape,9999px)) - var(--md-focus-ring-inward-offset,0px));border-end-end-radius:calc(var(--md-focus-ring-shape-end-end,var(--md-focus-ring-shape,9999px)) - var(--md-focus-ring-inward-offset,0px));border-end-start-radius:calc(var(--md-focus-ring-shape-end-start,var(--md-focus-ring-shape,9999px)) - var(--md-focus-ring-inward-offset,0px));animation-name:inward-grow,inward-shrink}@keyframes outward-grow{0%{outline-width:0}to{outline-width:var(--md-focus-ring-active-width,8px)}}@keyframes outward-shrink{0%{outline-width:var(--md-focus-ring-active-width,8px)}}@keyframes inward-grow{0%{border-width:0}to{border-width:var(--md-focus-ring-active-width,8px)}}@keyframes inward-shrink{0%{border-width:var(--md-focus-ring-active-width,8px)}}@media (prefers-reduced-motion){:host{animation:none}}`;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { focusVisible } from '../core/focus-visible.js';
|
|
5
|
+
import { Attachable } from '../base/mixins/attachable.js';
|
|
6
|
+
import { InternalsAttached, internals, } from '../base/mixins/internals-attached.js';
|
|
7
|
+
import { focusRingStyles } from './focus-ring-styles.css.js';
|
|
8
|
+
/**
|
|
9
|
+
* @tag md-focus-ring
|
|
10
|
+
*
|
|
11
|
+
* @cssprop --md-focus-ring-active-width
|
|
12
|
+
* @cssprop --md-focus-ring-color
|
|
13
|
+
* @cssprop --md-focus-ring-duration
|
|
14
|
+
* @cssprop --md-focus-ring-inward-offset
|
|
15
|
+
* @cssprop --md-focus-ring-outward-offset
|
|
16
|
+
* @cssprop --md-focus-ring-shape
|
|
17
|
+
* @cssprop --md-focus-ring-shape-end-end
|
|
18
|
+
* @cssprop --md-focus-ring-shape-end-start
|
|
19
|
+
* @cssprop --md-focus-ring-shape-start-end
|
|
20
|
+
* @cssprop --md-focus-ring-shape-start-start
|
|
21
|
+
* @cssprop --md-focus-ring-width
|
|
22
|
+
*/
|
|
23
|
+
let M3FocusRing = class M3FocusRing extends Attachable(InternalsAttached(LitElement)) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.inward = false;
|
|
27
|
+
this.#boundFocusIn = this.#handleFocusIn.bind(this);
|
|
28
|
+
this.#boundFocusOut = this.#handleFocusOut.bind(this);
|
|
29
|
+
this.#boundPointerDown = this.#handlePointerDown.bind(this);
|
|
30
|
+
this[internals].ariaHidden = 'true';
|
|
31
|
+
}
|
|
32
|
+
static { this.styles = [focusRingStyles]; }
|
|
33
|
+
#boundFocusIn;
|
|
34
|
+
#boundFocusOut;
|
|
35
|
+
#boundPointerDown;
|
|
36
|
+
#handleFocusIn() {
|
|
37
|
+
if (focusVisible)
|
|
38
|
+
this[internals].states.add('visible');
|
|
39
|
+
else
|
|
40
|
+
this[internals].states.delete('visible');
|
|
41
|
+
}
|
|
42
|
+
#handleFocusOut() {
|
|
43
|
+
this[internals].states.delete('visible');
|
|
44
|
+
}
|
|
45
|
+
#handlePointerDown() {
|
|
46
|
+
this[internals].states.delete('visible');
|
|
47
|
+
}
|
|
48
|
+
visualFocus() {
|
|
49
|
+
this.#handleFocusIn();
|
|
50
|
+
}
|
|
51
|
+
visualBlur() {
|
|
52
|
+
this.#handleFocusOut();
|
|
53
|
+
}
|
|
54
|
+
handleControlChange(prev = null, next = null) {
|
|
55
|
+
const eventHandlers = {
|
|
56
|
+
focusin: this.#boundFocusIn,
|
|
57
|
+
focusout: this.#boundFocusOut,
|
|
58
|
+
pointerdown: this.#boundPointerDown,
|
|
59
|
+
};
|
|
60
|
+
Object.keys(eventHandlers).forEach((eventName) => {
|
|
61
|
+
prev?.removeEventListener(eventName, eventHandlers[eventName]);
|
|
62
|
+
next?.addEventListener(eventName, eventHandlers[eventName]);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
__decorate([
|
|
67
|
+
property({ type: Boolean, reflect: true })
|
|
68
|
+
], M3FocusRing.prototype, "inward", void 0);
|
|
69
|
+
M3FocusRing = __decorate([
|
|
70
|
+
customElement('md-focus-ring')
|
|
71
|
+
], M3FocusRing);
|
|
72
|
+
export { M3FocusRing };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const itemStyles = css `:host{border-radius:inherit;box-sizing:border-box;font:var(--md-sys-typography-body-large);-webkit-user-select:none;user-select:none;flex:1;align-items:center;gap:8px;min-height:48px;padding:0 12px;display:flex;position:relative}[name=container]{border-radius:inherit}[name=container]::slotted(*){position:absolute;inset:0}`;
|