@vollowx/seele 0.13.4 → 0.13.6
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/custom-elements.json +1256 -115
- package/package.json +22 -14
- package/src/all.d.ts +34 -0
- package/src/all.js +1 -0
- package/src/base/autocomplete.d.ts +56 -0
- package/src/base/autocomplete.js +82 -87
- package/src/base/button.d.ts +13 -0
- package/src/base/button.js +26 -22
- package/src/base/checkbox.d.ts +18 -0
- package/src/base/checkbox.js +39 -34
- package/src/base/controllers/list-controller.d.ts +37 -0
- package/src/base/controllers/list-controller.js +23 -15
- package/src/base/controllers/popover-controller.d.ts +35 -0
- package/src/base/controllers/popover-controller.js +37 -29
- package/src/base/dialog.d.ts +20 -0
- package/src/base/dialog.js +11 -9
- package/src/base/field.d.ts +3 -0
- package/src/base/input.d.ts +44 -0
- package/src/base/input.js +57 -65
- package/src/base/item.d.ts +7 -0
- package/src/base/item.js +2 -1
- package/src/base/list-item.d.ts +15 -0
- package/src/base/list-item.js +22 -22
- package/src/base/list.d.ts +54 -0
- package/src/base/list.js +69 -55
- package/src/base/menu-item.d.ts +6 -0
- package/src/base/menu-item.js +4 -3
- package/src/base/menu.d.ts +76 -0
- package/src/base/menu.js +135 -143
- package/src/base/mixins/attachable.d.ts +9 -0
- package/src/base/mixins/attachable.js +22 -18
- package/src/base/mixins/focus-delegated.d.ts +5 -0
- package/src/base/mixins/focus-delegated.js +6 -8
- package/src/base/mixins/form-associated.d.ts +15 -0
- package/src/base/mixins/form-associated.js +11 -18
- package/src/base/mixins/internals-attached.d.ts +6 -0
- package/src/base/mixins/internals-attached.js +1 -1
- package/src/base/option.d.ts +9 -0
- package/src/base/option.js +7 -8
- package/src/base/radio.d.ts +13 -0
- package/src/base/radio.js +169 -0
- package/src/base/select.d.ts +116 -0
- package/src/base/select.js +130 -128
- package/src/base/slider.d.ts +75 -0
- package/src/base/slider.js +115 -118
- package/src/base/tab-panel.d.ts +9 -0
- package/src/base/tab-panel.js +11 -11
- package/src/base/tab.d.ts +18 -0
- package/src/base/tab.js +25 -24
- package/src/base/tabs.d.ts +19 -0
- package/src/base/tabs.js +84 -81
- package/src/base/toggle-button.d.ts +47 -0
- package/src/base/toggle-button.js +57 -53
- package/src/base/tooltip.d.ts +37 -0
- package/src/base/tooltip.js +70 -65
- package/src/core/decorators.d.ts +2 -0
- package/src/core/decorators.js +5 -4
- package/src/core/focus-visible.d.ts +2 -0
- package/src/core/focus-visible.js +4 -4
- package/src/core/shared.d.ts +1 -0
- package/src/core/unique-id.d.ts +4 -0
- package/src/core/unique-id.js +2 -1
- package/src/m3/autocomplete/autocomplete.d.ts +8 -0
- package/src/m3/autocomplete/autocomplete.js +10 -10
- package/src/m3/badge/badge.d.ts +12 -0
- package/src/m3/badge/badge.js +24 -37
- package/src/m3/button/common-button-toggle.d.ts +31 -0
- package/src/m3/button/common-button-toggle.js +44 -41
- package/src/m3/button/common-button.d.ts +29 -0
- package/src/m3/button/common-button.js +40 -40
- package/src/m3/button/icon-button-toggle.d.ts +24 -0
- package/src/m3/button/icon-button-toggle.js +35 -32
- package/src/m3/button/icon-button.d.ts +23 -0
- package/src/m3/button/icon-button.js +33 -31
- package/src/m3/button-group/connected-button-group.d.ts +19 -0
- package/src/m3/button-group/connected-button-group.js +30 -28
- package/src/m3/button-group/standard-button-group.d.ts +24 -0
- package/src/m3/button-group/standard-button-group.js +72 -66
- package/src/m3/checkbox/checkbox.d.ts +25 -0
- package/src/m3/checkbox/checkbox.js +24 -22
- package/src/m3/dialog/dialog-spring.d.ts +45 -0
- package/src/m3/dialog/dialog-spring.js +83 -86
- package/src/m3/dialog/dialog.d.ts +46 -0
- package/src/m3/dialog/dialog.js +90 -117
- package/src/m3/divider/divider.d.ts +13 -0
- package/src/m3/divider/divider.js +20 -33
- package/src/m3/fab/fab.d.ts +23 -0
- package/src/m3/fab/fab.js +24 -23
- package/src/m3/field/field.d.ts +28 -0
- package/src/m3/field/field.js +40 -55
- package/src/m3/field/filled-field.d.ts +11 -0
- package/src/m3/field/filled-field.js +7 -11
- package/src/m3/field/outlined-field.d.ts +11 -0
- package/src/m3/field/outlined-field.js +8 -12
- package/src/m3/focus-ring/focus-ring.d.ts +32 -0
- package/src/m3/focus-ring/focus-ring.js +38 -23
- package/src/m3/item/item.d.ts +31 -0
- package/src/m3/item/item.js +32 -17
- package/src/m3/list/list-item.d.ts +22 -0
- package/src/m3/list/list-item.js +18 -16
- package/src/m3/list/list.d.ts +15 -0
- package/src/m3/list/list.js +16 -15
- package/src/m3/loading-indicator/loading-indicator.d.ts +26 -0
- package/src/m3/loading-indicator/loading-indicator.js +113 -161
- package/src/m3/menu/menu-item.d.ts +15 -0
- package/src/m3/menu/menu-item.js +10 -4
- package/src/m3/menu/menu.d.ts +22 -0
- package/src/m3/menu/menu.js +20 -18
- package/src/m3/radio/radio-styles.css.js +2 -0
- package/src/m3/radio/radio.d.ts +17 -0
- package/src/m3/radio/radio.js +33 -0
- package/src/m3/ripple/ripple.d.ts +43 -0
- package/src/m3/ripple/ripple.js +82 -89
- package/src/m3/select/filled-select.d.ts +16 -0
- package/src/m3/select/filled-select.js +12 -10
- package/src/m3/select/option.d.ts +15 -0
- package/src/m3/select/option.js +10 -4
- package/src/m3/select/outlined-select.d.ts +16 -0
- package/src/m3/select/outlined-select.js +12 -10
- package/src/m3/select/select.d.ts +13 -0
- package/src/m3/select/select.js +16 -16
- package/src/m3/slider/slider.d.ts +20 -0
- package/src/m3/slider/slider.js +32 -26
- package/src/m3/switch/switch.d.ts +27 -0
- package/src/m3/switch/switch.js +62 -53
- package/src/m3/system/motion.d.ts +12 -0
- package/src/m3/system/motion.js +16 -9
- package/src/m3/tab/tab-panel.d.ts +9 -0
- package/src/m3/tab/tab-panel.js +6 -9
- package/src/m3/tab/tab.d.ts +19 -0
- package/src/m3/tab/tab.js +14 -12
- package/src/m3/tab/tabs.d.ts +25 -0
- package/src/m3/tab/tabs.js +34 -30
- package/src/m3/text-field/filled-text-field.d.ts +13 -0
- package/src/m3/text-field/filled-text-field.js +15 -20
- package/src/m3/text-field/outlined-text-field.d.ts +13 -0
- package/src/m3/text-field/outlined-text-field.js +15 -20
- package/src/m3/toolbar/toolbar.d.ts +26 -0
- package/src/m3/toolbar/toolbar.js +28 -25
- package/src/m3/tooltip/tooltip.d.ts +19 -0
- package/src/m3/tooltip/tooltip.js +15 -14
- package/src/win98/button/button.d.ts +13 -0
- package/src/win98/button/button.js +13 -11
- package/src/win98/button/radio.d.ts +3 -0
- package/src/win98/button/radio.js +9 -0
- package/src/win98/radio/radio.d.ts +3 -0
- package/src/win98/radio/radio.js +9 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const M3Ripple_base: Constructor<import("../../base/mixins/attachable.js").AttachableInterface> & Constructor<import("../../base/mixins/internals-attached.js").InternalsAttachedInterface> & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-ripple
|
|
5
|
+
*
|
|
6
|
+
* @cssprop --md-ripple-color
|
|
7
|
+
*/
|
|
8
|
+
export declare class M3Ripple extends M3Ripple_base {
|
|
9
|
+
#private;
|
|
10
|
+
clickBehavior: 'always' | 'none';
|
|
11
|
+
enterBehavior: 'always' | 'none';
|
|
12
|
+
spaceBehavior: 'always' | 'once' | 'none';
|
|
13
|
+
$ripples: HTMLSpanElement[];
|
|
14
|
+
static styles: any[];
|
|
15
|
+
constructor();
|
|
16
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
17
|
+
handleKeyUp: (e: KeyboardEvent) => void;
|
|
18
|
+
handlePointerEnter: (e: PointerEvent) => void;
|
|
19
|
+
handlePointerLeave: () => void;
|
|
20
|
+
handlePointerDown: (e: PointerEvent) => void;
|
|
21
|
+
handlePointerUp: () => void;
|
|
22
|
+
handleControlChange(prev?: HTMLElement | null, next?: HTMLElement | HTMLInputElement | null): void;
|
|
23
|
+
calculateRipple(e?: MouseEvent | null): {
|
|
24
|
+
startCenter: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
};
|
|
28
|
+
endCenter: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
};
|
|
32
|
+
radius: number;
|
|
33
|
+
};
|
|
34
|
+
addRipple(e?: MouseEvent | null): void;
|
|
35
|
+
removeRipple(ripple: HTMLSpanElement): void;
|
|
36
|
+
removeRippleAll(): void;
|
|
37
|
+
}
|
|
38
|
+
declare global {
|
|
39
|
+
interface HTMLElementTagNameMap {
|
|
40
|
+
'md-ripple': M3Ripple;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export {};
|
package/src/m3/ripple/ripple.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement } from 'lit';
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from '../../core/decorators.js';
|
|
5
5
|
import { Attachable } from '../../base/mixins/attachable.js';
|
|
6
|
-
import { InternalsAttached, internals } from '../../base/mixins/internals-attached.js';
|
|
6
|
+
import { InternalsAttached, internals, } from '../../base/mixins/internals-attached.js';
|
|
7
7
|
import { rippleStyles } from './ripple-styles.css.js';
|
|
8
8
|
const PRESS_GROW_MS = 450;
|
|
9
9
|
const MINIMUM_PRESS_MS = 225;
|
|
@@ -12,42 +12,65 @@ const OPACITY_OUT_MS = 375;
|
|
|
12
12
|
function distance({ x: ax, y: ay }, { x: bx, y: by }) {
|
|
13
13
|
return Math.sqrt((ax - bx) ** 2 + (ay - by) ** 2);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @tag md-ripple
|
|
17
|
+
*
|
|
18
|
+
* @cssprop --md-ripple-color
|
|
19
|
+
*/
|
|
20
|
+
let M3Ripple = class M3Ripple extends Attachable(InternalsAttached(LitElement)) {
|
|
21
|
+
static { this.styles = [rippleStyles]; }
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.clickBehavior = 'always';
|
|
25
|
+
this.enterBehavior = 'always';
|
|
26
|
+
this.spaceBehavior = 'once';
|
|
27
|
+
this.$ripples = [];
|
|
28
|
+
this.#spaceKeyDown = false;
|
|
29
|
+
this.#pointerDown = false;
|
|
30
|
+
this.#lastTime = 0;
|
|
31
|
+
this.handleKeyDown = (e) => {
|
|
32
|
+
if ((e.key === 'Enter' && this.enterBehavior === 'always') ||
|
|
33
|
+
(e.key === ' ' && this.spaceBehavior === 'always')) {
|
|
24
34
|
this.addRipple();
|
|
25
35
|
this.removeRippleAll();
|
|
26
|
-
}
|
|
27
|
-
|
|
36
|
+
}
|
|
37
|
+
else if (e.key === ' ' && this.spaceBehavior === 'once') {
|
|
38
|
+
if (!this.#spaceKeyDown)
|
|
39
|
+
this.addRipple();
|
|
28
40
|
this.#spaceKeyDown = true;
|
|
29
41
|
}
|
|
30
|
-
}
|
|
42
|
+
};
|
|
43
|
+
this.handleKeyUp = (e) => {
|
|
31
44
|
if (e.key === ' ' && this.spaceBehavior === 'once') {
|
|
32
45
|
this.#spaceKeyDown = false;
|
|
33
46
|
this.removeRippleAll();
|
|
34
47
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
48
|
+
};
|
|
49
|
+
this.handlePointerEnter = (e) => {
|
|
50
|
+
if (e.pointerType === 'touch')
|
|
51
|
+
return;
|
|
37
52
|
this[internals].states.add('hover');
|
|
38
|
-
if (this.#pointerDown && this.clickBehavior === 'always')
|
|
39
|
-
|
|
53
|
+
if (this.#pointerDown && this.clickBehavior === 'always')
|
|
54
|
+
this.addRipple(e);
|
|
55
|
+
};
|
|
56
|
+
this.handlePointerLeave = () => {
|
|
40
57
|
this[internals].states.delete('hover');
|
|
41
|
-
if (this.#pointerDown && this.clickBehavior === 'always')
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
if (this.#pointerDown && this.clickBehavior === 'always')
|
|
59
|
+
this.removeRippleAll();
|
|
60
|
+
};
|
|
61
|
+
this.handlePointerDown = (e) => {
|
|
62
|
+
if (e.pointerType === 'mouse')
|
|
63
|
+
this.#pointerDown = true;
|
|
44
64
|
document.addEventListener('pointerup', this.handlePointerUp);
|
|
45
65
|
document.addEventListener('touchcancel', this.handlePointerUp);
|
|
46
66
|
document.addEventListener('touchend', this.handlePointerUp);
|
|
47
67
|
document.addEventListener('touchmove', this.handlePointerUp);
|
|
48
|
-
if (e.button === 2)
|
|
49
|
-
|
|
50
|
-
|
|
68
|
+
if (e.button === 2)
|
|
69
|
+
return;
|
|
70
|
+
if (this.clickBehavior === 'always')
|
|
71
|
+
this.addRipple(e);
|
|
72
|
+
};
|
|
73
|
+
this.handlePointerUp = () => {
|
|
51
74
|
this.#pointerDown = false;
|
|
52
75
|
document.removeEventListener('pointerup', this.handlePointerUp);
|
|
53
76
|
document.removeEventListener('touchcancel', this.handlePointerUp);
|
|
@@ -66,22 +89,24 @@ export class M3Ripple extends Attachable(InternalsAttached(LitElement)) {
|
|
|
66
89
|
keyup: this.handleKeyUp,
|
|
67
90
|
pointerenter: this.handlePointerEnter,
|
|
68
91
|
pointerleave: this.handlePointerLeave,
|
|
69
|
-
pointerdown: this.handlePointerDown
|
|
92
|
+
pointerdown: this.handlePointerDown,
|
|
70
93
|
};
|
|
71
|
-
Object.keys(eventHandlers).forEach((eventName)=>{
|
|
94
|
+
Object.keys(eventHandlers).forEach((eventName) => {
|
|
72
95
|
// @ts-ignore
|
|
73
|
-
prev?.labels?.forEach((label)=>label.removeEventListener(eventName, eventHandlers[eventName]));
|
|
96
|
+
prev?.labels?.forEach((label) => label.removeEventListener(eventName, eventHandlers[eventName]));
|
|
74
97
|
prev?.removeEventListener(eventName, eventHandlers[eventName]);
|
|
75
98
|
// Check if control is nested in label, if so, only bind to label
|
|
76
99
|
let isNestedInLabel = false;
|
|
77
100
|
// @ts-ignore
|
|
78
|
-
next?.labels?.forEach((label)=>{
|
|
79
|
-
if (label.contains(next))
|
|
101
|
+
next?.labels?.forEach((label) => {
|
|
102
|
+
if (label.contains(next))
|
|
103
|
+
isNestedInLabel = true;
|
|
80
104
|
});
|
|
81
105
|
if (isNestedInLabel) {
|
|
82
106
|
// @ts-ignore
|
|
83
|
-
next.labels?.forEach((label)=>label.addEventListener(eventName, eventHandlers[eventName]));
|
|
84
|
-
}
|
|
107
|
+
next.labels?.forEach((label) => label.addEventListener(eventName, eventHandlers[eventName]));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
85
110
|
next?.addEventListener(eventName, eventHandlers[eventName]);
|
|
86
111
|
}
|
|
87
112
|
});
|
|
@@ -90,7 +115,7 @@ export class M3Ripple extends Attachable(InternalsAttached(LitElement)) {
|
|
|
90
115
|
const containerRect = this.getBoundingClientRect();
|
|
91
116
|
const containerMiddle = {
|
|
92
117
|
x: containerRect.width / 2,
|
|
93
|
-
y: containerRect.height / 2
|
|
118
|
+
y: containerRect.height / 2,
|
|
94
119
|
};
|
|
95
120
|
const centered = !e;
|
|
96
121
|
const endCenter = containerMiddle;
|
|
@@ -100,29 +125,13 @@ export class M3Ripple extends Attachable(InternalsAttached(LitElement)) {
|
|
|
100
125
|
startCenter.y = e.clientY - containerRect.top;
|
|
101
126
|
}
|
|
102
127
|
const corners = [
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
x: containerRect.width,
|
|
109
|
-
y: 0
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
x: 0,
|
|
113
|
-
y: containerRect.height
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
x: containerRect.width,
|
|
117
|
-
y: containerRect.height
|
|
118
|
-
}
|
|
128
|
+
{ x: 0, y: 0 },
|
|
129
|
+
{ x: containerRect.width, y: 0 },
|
|
130
|
+
{ x: 0, y: containerRect.height },
|
|
131
|
+
{ x: containerRect.width, y: containerRect.height },
|
|
119
132
|
];
|
|
120
|
-
const radius = Math.max(...corners.map((corner)=>distance(endCenter, corner)));
|
|
121
|
-
return {
|
|
122
|
-
startCenter,
|
|
123
|
-
endCenter,
|
|
124
|
-
radius
|
|
125
|
-
};
|
|
133
|
+
const radius = Math.max(...corners.map((corner) => distance(endCenter, corner)));
|
|
134
|
+
return { startCenter, endCenter, radius };
|
|
126
135
|
}
|
|
127
136
|
addRipple(e = null) {
|
|
128
137
|
const { startCenter, endCenter, radius } = this.calculateRipple(e);
|
|
@@ -134,68 +143,52 @@ export class M3Ripple extends Attachable(InternalsAttached(LitElement)) {
|
|
|
134
143
|
this.renderRoot.append(ripple);
|
|
135
144
|
this.$ripples.push(ripple);
|
|
136
145
|
ripple.animate({
|
|
137
|
-
opacity: [
|
|
138
|
-
0,
|
|
139
|
-
0.1
|
|
140
|
-
]
|
|
146
|
+
opacity: [0, 0.1],
|
|
141
147
|
}, {
|
|
142
148
|
duration: OPACITY_IN_MS,
|
|
143
149
|
easing: 'linear',
|
|
144
|
-
fill: 'forwards'
|
|
150
|
+
fill: 'forwards',
|
|
145
151
|
});
|
|
146
152
|
ripple.animate({
|
|
147
|
-
height: [
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
],
|
|
151
|
-
width: [
|
|
152
|
-
diameter,
|
|
153
|
-
diameter
|
|
154
|
-
],
|
|
155
|
-
translate: [
|
|
156
|
-
translateStart,
|
|
157
|
-
translateEnd
|
|
158
|
-
],
|
|
159
|
-
scale: [
|
|
160
|
-
0.2,
|
|
161
|
-
1.35
|
|
162
|
-
]
|
|
153
|
+
height: [diameter, diameter],
|
|
154
|
+
width: [diameter, diameter],
|
|
155
|
+
translate: [translateStart, translateEnd],
|
|
156
|
+
scale: [0.2, 1.35],
|
|
163
157
|
}, {
|
|
164
158
|
duration: PRESS_GROW_MS,
|
|
165
159
|
// TODO: Control by global variables
|
|
166
160
|
easing: 'cubic-bezier(0.2, 0, 0, 1)',
|
|
167
|
-
fill: 'forwards'
|
|
161
|
+
fill: 'forwards',
|
|
168
162
|
});
|
|
169
163
|
this.#lastTime = Date.now();
|
|
170
164
|
}
|
|
171
165
|
removeRipple(ripple) {
|
|
172
|
-
setTimeout(()=>{
|
|
166
|
+
setTimeout(() => {
|
|
173
167
|
const animation = ripple.animate({
|
|
174
|
-
opacity: [
|
|
175
|
-
getComputedStyle(ripple).opacity,
|
|
176
|
-
'0'
|
|
177
|
-
]
|
|
168
|
+
opacity: [getComputedStyle(ripple).opacity, '0'],
|
|
178
169
|
}, {
|
|
179
170
|
duration: OPACITY_OUT_MS,
|
|
180
171
|
fill: 'forwards',
|
|
181
|
-
easing: 'linear'
|
|
172
|
+
easing: 'linear',
|
|
182
173
|
});
|
|
183
|
-
animation.onfinish = animation.oncancel = ()=>ripple.remove();
|
|
174
|
+
animation.onfinish = animation.oncancel = () => ripple.remove();
|
|
184
175
|
}, Math.max(MINIMUM_PRESS_MS - (Date.now() - this.#lastTime), 0));
|
|
185
176
|
}
|
|
186
177
|
removeRippleAll() {
|
|
187
|
-
for (const ripple of this.$ripples.splice(0))
|
|
178
|
+
for (const ripple of this.$ripples.splice(0))
|
|
179
|
+
this.removeRipple(ripple);
|
|
188
180
|
}
|
|
189
|
-
}
|
|
190
|
-
|
|
181
|
+
};
|
|
182
|
+
__decorate([
|
|
191
183
|
property()
|
|
192
184
|
], M3Ripple.prototype, "clickBehavior", void 0);
|
|
193
|
-
|
|
185
|
+
__decorate([
|
|
194
186
|
property()
|
|
195
187
|
], M3Ripple.prototype, "enterBehavior", void 0);
|
|
196
|
-
|
|
188
|
+
__decorate([
|
|
197
189
|
property()
|
|
198
190
|
], M3Ripple.prototype, "spaceBehavior", void 0);
|
|
199
|
-
M3Ripple =
|
|
191
|
+
M3Ripple = __decorate([
|
|
200
192
|
customElement('md-ripple', false)
|
|
201
193
|
], M3Ripple);
|
|
194
|
+
export { M3Ripple };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { M3Select } from './select.js';
|
|
2
|
+
import '../field/filled-field.js';
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-filled-select
|
|
5
|
+
*
|
|
6
|
+
* @slot - options
|
|
7
|
+
*/
|
|
8
|
+
export declare class MdFilledSelect extends M3Select {
|
|
9
|
+
static styles: any[];
|
|
10
|
+
protected renderField(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'md-filled-select': MdFilledSelect;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { M3Select } from './select.js';
|
|
5
5
|
import '../field/filled-field.js';
|
|
6
6
|
import { selectStyles } from './select-styles.css.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @tag md-filled-select
|
|
9
|
+
*
|
|
10
|
+
* @slot - options
|
|
11
|
+
*/
|
|
12
|
+
let MdFilledSelect = class MdFilledSelect extends M3Select {
|
|
13
|
+
static { this.styles = [selectStyles]; }
|
|
13
14
|
renderField() {
|
|
14
|
-
return html`<md-filled-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${()=>this.focused = true}" @blur="${()=>this.focused = false}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-filled-field>`;
|
|
15
|
+
return html `<md-filled-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${() => (this.focused = true)}" @blur="${() => (this.focused = false)}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-filled-field>`;
|
|
15
16
|
}
|
|
16
|
-
}
|
|
17
|
-
MdFilledSelect =
|
|
17
|
+
};
|
|
18
|
+
MdFilledSelect = __decorate([
|
|
18
19
|
customElement('md-filled-select')
|
|
19
20
|
], MdFilledSelect);
|
|
21
|
+
export { MdFilledSelect };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { M3ListItem } from '../list/list-item.js';
|
|
2
|
+
declare const M3Option_base: Constructor<import("../../base/option.js").OptionInterface> & typeof M3ListItem;
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-option
|
|
5
|
+
*
|
|
6
|
+
* @slot - contents in md-menu-item
|
|
7
|
+
*/
|
|
8
|
+
export declare class M3Option extends M3Option_base {
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
'md-option': M3Option;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/src/m3/select/option.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { customElement } from 'lit/decorators.js';
|
|
3
3
|
import { OptionMixin } from '../../base/option.js';
|
|
4
4
|
import { M3ListItem } from '../list/list-item.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @tag md-option
|
|
7
|
+
*
|
|
8
|
+
* @slot - contents in md-menu-item
|
|
9
|
+
*/
|
|
10
|
+
let M3Option = class M3Option extends OptionMixin(M3ListItem) {
|
|
11
|
+
};
|
|
12
|
+
M3Option = __decorate([
|
|
8
13
|
customElement('md-option')
|
|
9
14
|
], M3Option);
|
|
15
|
+
export { M3Option };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { M3Select } from './select.js';
|
|
2
|
+
import '../field/outlined-field.js';
|
|
3
|
+
/**
|
|
4
|
+
* @tag md-outlined-select
|
|
5
|
+
*
|
|
6
|
+
* @slot - options
|
|
7
|
+
*/
|
|
8
|
+
export declare class MdOutlinedSelect extends M3Select {
|
|
9
|
+
static styles: any[];
|
|
10
|
+
protected renderField(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'md-outlined-select': MdOutlinedSelect;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { M3Select } from './select.js';
|
|
5
5
|
import '../field/outlined-field.js';
|
|
6
6
|
import { selectStyles } from './select-styles.css.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @tag md-outlined-select
|
|
9
|
+
*
|
|
10
|
+
* @slot - options
|
|
11
|
+
*/
|
|
12
|
+
let MdOutlinedSelect = class MdOutlinedSelect extends M3Select {
|
|
13
|
+
static { this.styles = [selectStyles]; }
|
|
13
14
|
renderField() {
|
|
14
|
-
return html`<md-outlined-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${()=>this.focused = true}" @blur="${()=>this.focused = false}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-outlined-field>`;
|
|
15
|
+
return html `<md-outlined-field id="field" part="field" .label="${this.label}" .populated="${!!this.value}" .disabled="${this.disabled}" .required="${this.required}" .error="${this.error}" .focused="${this.open || this.focused}" supportingtext="${this.supportingText}" @click="${this.toggle}" @keydown="${this._handleFieldKeydown}" @focus="${() => (this.focused = true)}" @blur="${() => (this.focused = false)}" tabindex="${this.disabled ? '-1' : '0'}" role="combobox" aria-haspopup="listbox" aria-expanded="${this.open}" aria-controls="menu" aria-disabled="${this.disabled}" aria-required="${this.required}">${this.renderFieldContent()}</md-outlined-field>`;
|
|
15
16
|
}
|
|
16
|
-
}
|
|
17
|
-
MdOutlinedSelect =
|
|
17
|
+
};
|
|
18
|
+
MdOutlinedSelect = __decorate([
|
|
18
19
|
customElement('md-outlined-select')
|
|
19
20
|
], MdOutlinedSelect);
|
|
21
|
+
export { MdOutlinedSelect };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Select } from '../../base/select.js';
|
|
2
|
+
import { M3Field } from '../field/field.js';
|
|
3
|
+
/**
|
|
4
|
+
* @fires {Event} change - Fired when the selected value has changed.
|
|
5
|
+
* @fires {Event} input - Fired when the selected value has changed.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class M3Select extends Select {
|
|
8
|
+
label: string;
|
|
9
|
+
supportingText: string;
|
|
10
|
+
protected focused: boolean;
|
|
11
|
+
protected field: M3Field;
|
|
12
|
+
protected renderMenu(): import("lit-html").TemplateResult<1>;
|
|
13
|
+
}
|
package/src/m3/select/select.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { html } from 'lit';
|
|
3
3
|
import { property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { Select } from '../../base/select.js';
|
|
5
5
|
/**
|
|
6
6
|
* @fires {Event} change - Fired when the selected value has changed.
|
|
7
7
|
* @fires {Event} input - Fired when the selected value has changed.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
*/
|
|
9
|
+
export class M3Select extends Select {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.label = '';
|
|
13
|
+
this.supportingText = '';
|
|
14
|
+
this.focused = false;
|
|
11
15
|
}
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
renderMenu() {
|
|
17
|
+
return html `<md-menu part="menu" id="menu" for="field" type="listbox" data-tabindex="-1" ?quick="${this.quick}" offset="${this.offset}" align="${this.align}" align-strategy="${this.alignStrategy}" keep-open-blur no-focus-control ?open="${this.open}" @open="${() => (this.open = true)}" @close="${() => (this.open = false)}" @item-focus="${this._handleMenuItemFocus}" @select="${this._handleMenuSelect}"><slot part="items" @slotchange="${this._handleSlotChange}"></slot></md-menu>`;
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
property({
|
|
18
|
-
type: String
|
|
19
|
-
})
|
|
20
|
+
__decorate([
|
|
21
|
+
property({ type: String })
|
|
20
22
|
], M3Select.prototype, "label", void 0);
|
|
21
|
-
|
|
22
|
-
property({
|
|
23
|
-
type: String
|
|
24
|
-
})
|
|
23
|
+
__decorate([
|
|
24
|
+
property({ type: String })
|
|
25
25
|
], M3Select.prototype, "supportingText", void 0);
|
|
26
|
-
|
|
26
|
+
__decorate([
|
|
27
27
|
state()
|
|
28
28
|
], M3Select.prototype, "focused", void 0);
|
|
29
|
-
|
|
29
|
+
__decorate([
|
|
30
30
|
query('md-filled-field, md-outlined-field')
|
|
31
31
|
], M3Select.prototype, "field", void 0);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Slider } from '../../base/slider.js';
|
|
2
|
+
import '../focus-ring/focus-ring.js';
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Add size variants
|
|
5
|
+
* TODO: Add orientation: vertical
|
|
6
|
+
*
|
|
7
|
+
* @tag md-slider
|
|
8
|
+
*/
|
|
9
|
+
export declare class M3Slider extends Slider {
|
|
10
|
+
static styles: any[];
|
|
11
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
private renderTrack;
|
|
13
|
+
private renderLabel;
|
|
14
|
+
private renderHandle;
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'md-slider': M3Slider;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/m3/slider/slider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
2
|
import { html, nothing } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
@@ -7,70 +7,76 @@ import { when } from 'lit/directives/when.js';
|
|
|
7
7
|
import { Slider } from '../../base/slider.js';
|
|
8
8
|
import '../focus-ring/focus-ring.js';
|
|
9
9
|
import { sliderStyles } from './slider-styles.css.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
/**
|
|
11
|
+
* TODO: Add size variants
|
|
12
|
+
* TODO: Add orientation: vertical
|
|
13
|
+
*
|
|
14
|
+
* @tag md-slider
|
|
15
|
+
*/
|
|
16
|
+
let M3Slider = class M3Slider extends Slider {
|
|
17
|
+
static { this.styles = [sliderStyles]; }
|
|
16
18
|
render() {
|
|
17
19
|
const step = this.step === 0 ? 1 : this.step;
|
|
18
20
|
const range = Math.max(this.max - this.min, step);
|
|
19
|
-
const startFraction = this.range
|
|
21
|
+
const startFraction = this.range
|
|
22
|
+
? ((this.renderValueStart ?? this.min) - this.min) / range
|
|
23
|
+
: 0;
|
|
20
24
|
const endFraction = ((this.renderValueEnd ?? this.min) - this.min) / range;
|
|
21
25
|
const containerStyles = {
|
|
22
26
|
'--_start': String(startFraction),
|
|
23
27
|
'--_end': String(endFraction),
|
|
24
|
-
'--_ticks': String(range / step)
|
|
25
|
-
};
|
|
26
|
-
const containerClasses = {
|
|
27
|
-
ranged: this.range
|
|
28
|
+
'--_ticks': String(range / step),
|
|
28
29
|
};
|
|
30
|
+
const containerClasses = { ranged: this.range };
|
|
29
31
|
const labelStart = this.valueLabelStart || String(this.renderValueStart);
|
|
30
|
-
const labelEnd = (this.range ? this.valueLabelEnd : this.valueLabel) ||
|
|
32
|
+
const labelEnd = (this.range ? this.valueLabelEnd : this.valueLabel) ||
|
|
33
|
+
String(this.renderValueEnd);
|
|
31
34
|
const inputStartProps = {
|
|
32
35
|
start: true,
|
|
33
36
|
value: this.renderValueStart,
|
|
34
37
|
ariaLabel: this.renderAriaLabelStart,
|
|
35
38
|
ariaValueText: this.renderAriaValueTextStart,
|
|
36
39
|
ariaMin: this.min,
|
|
37
|
-
ariaMax: this.valueEnd ?? this.max
|
|
40
|
+
ariaMax: this.valueEnd ?? this.max,
|
|
38
41
|
};
|
|
39
42
|
const inputEndProps = {
|
|
40
43
|
start: false,
|
|
41
44
|
value: this.renderValueEnd,
|
|
42
45
|
ariaLabel: this.renderAriaLabelEnd,
|
|
43
46
|
ariaValueText: this.renderAriaValueTextEnd,
|
|
44
|
-
ariaMin: this.range ? this.valueStart ?? this.min : this.min,
|
|
45
|
-
ariaMax: this.max
|
|
47
|
+
ariaMin: this.range ? (this.valueStart ?? this.min) : this.min,
|
|
48
|
+
ariaMax: this.max,
|
|
46
49
|
};
|
|
47
50
|
const handleStartProps = {
|
|
48
51
|
start: true,
|
|
49
|
-
label: labelStart
|
|
52
|
+
label: labelStart,
|
|
50
53
|
};
|
|
51
54
|
const handleEndProps = {
|
|
52
55
|
start: false,
|
|
53
|
-
label: labelEnd
|
|
56
|
+
label: labelEnd,
|
|
54
57
|
};
|
|
55
|
-
return html`<div class="container ${classMap(containerClasses)}" style="${styleMap(containerStyles)}">${when(this.range, ()=>this.renderInput(inputStartProps))} ${this.renderInput(inputEndProps)} ${this.renderTrack()}<div class="handles-padded"><div class="handles">${when(this.range, ()=>this.renderHandle(handleStartProps))} ${this.renderHandle(handleEndProps)}</div></div></div>`;
|
|
58
|
+
return html `<div class="container ${classMap(containerClasses)}" style="${styleMap(containerStyles)}">${when(this.range, () => this.renderInput(inputStartProps))} ${this.renderInput(inputEndProps)} ${this.renderTrack()}<div class="handles-padded"><div class="handles">${when(this.range, () => this.renderHandle(handleStartProps))} ${this.renderHandle(handleEndProps)}</div></div></div>`;
|
|
56
59
|
}
|
|
57
60
|
renderTrack() {
|
|
58
|
-
return html`<div class="track"><div class="inactive-before"></div><div class="active"></div><div class="inactive-after"></div></div>${this.ticks
|
|
61
|
+
return html `<div class="track"><div class="inactive-before"></div><div class="active"></div><div class="inactive-after"></div></div>${this.ticks
|
|
62
|
+
? html `<div class="tickmarks"><div class="inactive-before"></div><div class="active"></div><div class="inactive-after"></div></div>`
|
|
63
|
+
: nothing}`;
|
|
59
64
|
}
|
|
60
65
|
renderLabel(value) {
|
|
61
|
-
return html`<div class="label" aria-hidden="true"><span part="label">${value}</span></div>`;
|
|
66
|
+
return html `<div class="label" aria-hidden="true"><span part="label">${value}</span></div>`;
|
|
62
67
|
}
|
|
63
68
|
renderHandle({ start, label }) {
|
|
64
69
|
const onTop = !this.disabled && start === this.startOnTop;
|
|
65
70
|
const isOverlapping = !this.disabled && this.handlesOverlapping;
|
|
66
71
|
const name = start ? 'start' : 'end';
|
|
67
|
-
return html`<div class="handle ${classMap({
|
|
72
|
+
return html `<div class="handle ${classMap({
|
|
68
73
|
[name]: true,
|
|
69
74
|
onTop,
|
|
70
|
-
isOverlapping
|
|
71
|
-
})}"><md-focus-ring part="focus-ring" for="${name}"></md-focus-ring><div class="nub"></div>${when(this.labeled, ()=>this.renderLabel(label))}</div>`;
|
|
75
|
+
isOverlapping,
|
|
76
|
+
})}"><md-focus-ring part="focus-ring" for="${name}"></md-focus-ring><div class="nub"></div>${when(this.labeled, () => this.renderLabel(label))}</div>`;
|
|
72
77
|
}
|
|
73
|
-
}
|
|
74
|
-
M3Slider =
|
|
78
|
+
};
|
|
79
|
+
M3Slider = __decorate([
|
|
75
80
|
customElement('md-slider')
|
|
76
81
|
], M3Slider);
|
|
82
|
+
export { M3Slider };
|