@api-client/ui 0.2.9 → 0.2.11
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/build/src/md/UiElement.d.ts +5 -0
- package/build/src/md/UiElement.d.ts.map +1 -1
- package/build/src/md/UiElement.js +7 -0
- package/build/src/md/UiElement.js.map +1 -1
- package/build/src/md/button/ui-elevated-button.d.ts +1 -1
- package/build/src/md/button/ui-elevated-button.js +1 -1
- package/build/src/md/button/ui-elevated-button.js.map +1 -1
- package/build/src/md/button/ui-filled-button.d.ts +1 -1
- package/build/src/md/button/ui-filled-button.js +1 -1
- package/build/src/md/button/ui-filled-button.js.map +1 -1
- package/build/src/md/button/ui-filled-tonal-button.d.ts +3 -3
- package/build/src/md/button/ui-filled-tonal-button.d.ts.map +1 -1
- package/build/src/md/button/ui-filled-tonal-button.js +6 -6
- package/build/src/md/button/ui-filled-tonal-button.js.map +1 -1
- package/build/src/md/button/ui-outlined-button.d.ts +1 -1
- package/build/src/md/button/ui-outlined-button.js +1 -1
- package/build/src/md/button/ui-outlined-button.js.map +1 -1
- package/build/src/md/button/ui-text-button.d.ts +1 -1
- package/build/src/md/button/ui-text-button.js +1 -1
- package/build/src/md/button/ui-text-button.js.map +1 -1
- package/build/src/md/checkbox/internals/Checkbox.styles.d.ts.map +1 -1
- package/build/src/md/checkbox/internals/Checkbox.styles.js +55 -216
- package/build/src/md/checkbox/internals/Checkbox.styles.js.map +1 -1
- package/build/src/md/checkbox/internals/CheckboxElement.d.ts +10 -7
- package/build/src/md/checkbox/internals/CheckboxElement.d.ts.map +1 -1
- package/build/src/md/checkbox/internals/CheckboxElement.js +39 -32
- package/build/src/md/checkbox/internals/CheckboxElement.js.map +1 -1
- package/build/src/md/checkbox/internals/CheckedElement.d.ts.map +1 -1
- package/build/src/md/checkbox/internals/CheckedElement.js +1 -0
- package/build/src/md/checkbox/internals/CheckedElement.js.map +1 -1
- package/build/src/md/dropdown-list/internals/UiDropdownList.d.ts +13 -2
- package/build/src/md/dropdown-list/internals/UiDropdownList.d.ts.map +1 -1
- package/build/src/md/dropdown-list/internals/UiDropdownList.js +59 -20
- package/build/src/md/dropdown-list/internals/UiDropdownList.js.map +1 -1
- package/build/src/md/icon-button/internals/IconButton.d.ts +8 -24
- package/build/src/md/icon-button/internals/IconButton.d.ts.map +1 -1
- package/build/src/md/icon-button/internals/IconButton.js +35 -63
- package/build/src/md/icon-button/internals/IconButton.js.map +1 -1
- package/build/src/md/icon-button/internals/{IconButton.styles.d.ts → base.styles.d.ts} +1 -1
- package/build/src/md/icon-button/internals/base.styles.d.ts.map +1 -0
- package/build/src/md/icon-button/internals/base.styles.js +93 -0
- package/build/src/md/icon-button/internals/base.styles.js.map +1 -0
- package/build/src/md/icon-button/internals/filled-tonal.styles.d.ts +3 -0
- package/build/src/md/icon-button/internals/filled-tonal.styles.d.ts.map +1 -0
- package/build/src/md/icon-button/internals/filled-tonal.styles.js +30 -0
- package/build/src/md/icon-button/internals/filled-tonal.styles.js.map +1 -0
- package/build/src/md/icon-button/internals/filled.styles.d.ts +3 -0
- package/build/src/md/icon-button/internals/filled.styles.d.ts.map +1 -0
- package/build/src/md/icon-button/internals/filled.styles.js +36 -0
- package/build/src/md/icon-button/internals/filled.styles.js.map +1 -0
- package/build/src/md/icon-button/internals/outlined.styles.d.ts +3 -0
- package/build/src/md/icon-button/internals/outlined.styles.d.ts.map +1 -0
- package/build/src/md/icon-button/internals/outlined.styles.js +31 -0
- package/build/src/md/icon-button/internals/outlined.styles.js.map +1 -0
- package/build/src/md/icon-button/internals/standard.styles.d.ts +3 -0
- package/build/src/md/icon-button/internals/standard.styles.d.ts.map +1 -0
- package/build/src/md/icon-button/internals/standard.styles.js +18 -0
- package/build/src/md/icon-button/internals/standard.styles.js.map +1 -0
- package/build/src/md/icon-button/ui-filled-icon-button.d.ts +11 -0
- package/build/src/md/icon-button/ui-filled-icon-button.d.ts.map +1 -0
- package/build/src/md/icon-button/ui-filled-icon-button.js +28 -0
- package/build/src/md/icon-button/ui-filled-icon-button.js.map +1 -0
- package/build/src/md/icon-button/ui-filled-tonal-icon-button.d.ts +11 -0
- package/build/src/md/icon-button/ui-filled-tonal-icon-button.d.ts.map +1 -0
- package/build/src/md/icon-button/ui-filled-tonal-icon-button.js +28 -0
- package/build/src/md/icon-button/ui-filled-tonal-icon-button.js.map +1 -0
- package/build/src/md/icon-button/ui-icon-button.d.ts.map +1 -1
- package/build/src/md/icon-button/ui-icon-button.js +3 -2
- package/build/src/md/icon-button/ui-icon-button.js.map +1 -1
- package/build/src/md/icon-button/ui-outlined-icon-button.d.ts +11 -0
- package/build/src/md/icon-button/ui-outlined-icon-button.d.ts.map +1 -0
- package/build/src/md/icon-button/ui-outlined-icon-button.js +28 -0
- package/build/src/md/icon-button/ui-outlined-icon-button.js.map +1 -0
- package/build/src/md/icons/internals/Icon.d.ts +1 -0
- package/build/src/md/icons/internals/Icon.d.ts.map +1 -1
- package/build/src/md/icons/internals/Icon.js +13 -0
- package/build/src/md/icons/internals/Icon.js.map +1 -1
- package/build/src/md/icons/internals/Icon.styles.d.ts.map +1 -1
- package/build/src/md/icons/internals/Icon.styles.js +31 -2
- package/build/src/md/icons/internals/Icon.styles.js.map +1 -1
- package/build/src/md/list/internals/ListItem.d.ts +4 -3
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +55 -15
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +6 -2
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/ripple/internals/ripple.d.ts +2 -1
- package/build/src/md/ripple/internals/ripple.d.ts.map +1 -1
- package/build/src/md/ripple/internals/ripple.js +42 -12
- package/build/src/md/ripple/internals/ripple.js.map +1 -1
- package/build/src/md/segmented-button/internals/SegmentedButton.d.ts +1 -1
- package/build/src/md/segmented-button/internals/SegmentedButton.d.ts.map +1 -1
- package/build/src/md/segmented-button/internals/SegmentedButton.js +1 -1
- package/build/src/md/segmented-button/internals/SegmentedButton.js.map +1 -1
- package/demo/md/buttons/{button.html → index.html} +1 -1
- package/demo/md/{inputs/checkbox.html → checkbox/index.html} +1 -1
- package/demo/md/{list/dropdown-list.html → dropdown-list/index.html} +1 -1
- package/demo/md/{buttons/icon-button.html → icon-button/index.html} +5 -1
- package/demo/md/icon-button/index.ts +236 -0
- package/demo/md/index.html +36 -29
- package/demo/md/listbox/listbox.html +31 -0
- package/demo/md/listbox/listbox.ts +27 -0
- package/demo/md/{buttons/segmented-buttons.html → segmented-button/index.html} +1 -1
- package/package.json +1 -1
- package/src/md/UiElement.ts +8 -0
- package/src/md/button/ui-elevated-button.ts +1 -1
- package/src/md/button/ui-filled-button.ts +1 -1
- package/src/md/button/ui-filled-tonal-button.ts +3 -3
- package/src/md/button/ui-outlined-button.ts +1 -1
- package/src/md/button/ui-text-button.ts +1 -1
- package/src/md/checkbox/internals/Checkbox.styles.ts +55 -216
- package/src/md/checkbox/internals/CheckboxElement.ts +39 -26
- package/src/md/checkbox/internals/CheckedElement.ts +1 -0
- package/src/md/dropdown-list/internals/UiDropdownList.ts +60 -21
- package/src/md/icon-button/internals/IconButton.ts +29 -46
- package/src/md/icon-button/internals/base.styles.ts +93 -0
- package/src/md/icon-button/internals/filled-tonal.styles.ts +30 -0
- package/src/md/icon-button/internals/filled.styles.ts +36 -0
- package/src/md/icon-button/internals/outlined.styles.ts +31 -0
- package/src/md/icon-button/internals/standard.styles.ts +18 -0
- package/src/md/icon-button/ui-filled-icon-button.ts +16 -0
- package/src/md/icon-button/ui-filled-tonal-icon-button.ts +16 -0
- package/src/md/icon-button/ui-icon-button.ts +3 -2
- package/src/md/icon-button/ui-outlined-icon-button.ts +16 -0
- package/src/md/icons/internals/Icon.styles.ts +31 -2
- package/src/md/icons/internals/Icon.ts +14 -0
- package/src/md/list/internals/ListItem.styles.ts +6 -2
- package/src/md/list/internals/ListItem.ts +51 -18
- package/src/md/ripple/internals/ripple.ts +47 -13
- package/src/md/segmented-button/internals/SegmentedButton.ts +2 -2
- package/test/ui/button/UiIconButton.test.ts +1 -8
- package/build/src/md/icon-button/internals/IconButton.styles.d.ts.map +0 -1
- package/build/src/md/icon-button/internals/IconButton.styles.js +0 -614
- package/build/src/md/icon-button/internals/IconButton.styles.js.map +0 -1
- package/demo/md/buttons/icon-button.ts +0 -184
- package/src/md/icon-button/internals/IconButton.styles.ts +0 -614
- /package/demo/md/buttons/{button.ts → index.ts} +0 -0
- /package/demo/md/{inputs/checkbox.ts → checkbox/index.ts} +0 -0
- /package/demo/md/{list/dropdown-list.ts → dropdown-list/index.ts} +0 -0
- /package/demo/md/{buttons/segmented-buttons.ts → segmented-button/index.ts} +0 -0
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { SVGTemplateResult, TemplateResult, nothing } from 'lit';
|
|
2
2
|
import CheckedElement from './CheckedElement.js';
|
|
3
|
-
import UiRipple from '../../ripple/internals/ripple.js';
|
|
3
|
+
import type UiRipple from '../../ripple/internals/ripple.js';
|
|
4
|
+
import type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js';
|
|
4
5
|
import '../../ripple/ui-ripple.js';
|
|
6
|
+
import '@material/web/focus/md-focus-ring.js';
|
|
5
7
|
export default class CheckboxElement extends CheckedElement {
|
|
6
8
|
protected get _icon(): SVGTemplateResult | typeof nothing;
|
|
7
|
-
protected accessor ripple:
|
|
8
|
-
protected
|
|
9
|
-
protected
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
protected accessor ripple: UiRipple | null;
|
|
10
|
+
protected pressRipple(options: BeginPressConfig): void;
|
|
11
|
+
protected endRipple(): void;
|
|
12
|
+
beginPress(options: BeginPressConfig): void;
|
|
13
|
+
endPress(config: EndPressConfig): void;
|
|
12
14
|
handleKeyDown(e: KeyboardEvent): Promise<void>;
|
|
13
15
|
handleKeyUp(e: KeyboardEvent): Promise<void>;
|
|
16
|
+
handlePointerEnter(e: PointerEvent): void;
|
|
17
|
+
handlePointerLeave(e: PointerEvent): void;
|
|
14
18
|
protected render(): TemplateResult;
|
|
15
|
-
protected renderRipple: () => TemplateResult;
|
|
16
19
|
}
|
|
17
20
|
//# sourceMappingURL=CheckboxElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxElement.d.ts","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckboxElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"CheckboxElement.d.ts","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckboxElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAGtE,OAAO,cAAc,MAAM,qBAAqB,CAAA;AAEhD,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAEhG,OAAO,2BAA2B,CAAA;AAClC,OAAO,sCAAsC,CAAA;AAE7C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,cAAc;IACzD,SAAS,KAAK,KAAK,IAAI,iBAAiB,GAAG,OAAO,OAAO,CASxD;IAEmB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAG,QAAQ,GAAG,IAAI,CAAA;IAE/D,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAOtD,SAAS,CAAC,SAAS,IAAI,IAAI;IAIlB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAK3C,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAKhC,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9C,WAAW,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlD,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAOzC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;cAO/B,MAAM,IAAI,cAAc;CAgB5C"}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
2
|
import { html, nothing } from 'lit';
|
|
3
|
-
import {
|
|
3
|
+
import { query } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
-
import { when } from 'lit/directives/when.js';
|
|
6
5
|
import CheckedElement from './CheckedElement.js';
|
|
7
6
|
import { check, checkIndeterminate } from '../../icons/Icons.js';
|
|
8
|
-
import { ripple } from '../../effects/rippleDirective.js';
|
|
9
7
|
import '../../ripple/ui-ripple.js';
|
|
8
|
+
import '@material/web/focus/md-focus-ring.js';
|
|
10
9
|
let CheckboxElement = (() => {
|
|
11
10
|
let _classSuper = CheckedElement;
|
|
12
11
|
let _ripple_decorators;
|
|
13
12
|
let _ripple_initializers = [];
|
|
14
13
|
let _ripple_extraInitializers = [];
|
|
15
|
-
let _showRipple_decorators;
|
|
16
|
-
let _showRipple_initializers = [];
|
|
17
|
-
let _showRipple_extraInitializers = [];
|
|
18
14
|
return class CheckboxElement extends _classSuper {
|
|
19
15
|
static {
|
|
20
16
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
21
|
-
_ripple_decorators = [
|
|
22
|
-
_showRipple_decorators = [state()];
|
|
17
|
+
_ripple_decorators = [query('ui-ripple')];
|
|
23
18
|
__esDecorate(this, null, _ripple_decorators, { kind: "accessor", name: "ripple", static: false, private: false, access: { has: obj => "ripple" in obj, get: obj => obj.ripple, set: (obj, value) => { obj.ripple = value; } }, metadata: _metadata }, _ripple_initializers, _ripple_extraInitializers);
|
|
24
|
-
__esDecorate(this, null, _showRipple_decorators, { kind: "accessor", name: "showRipple", static: false, private: false, access: { has: obj => "showRipple" in obj, get: obj => obj.showRipple, set: (obj, value) => { obj.showRipple = value; } }, metadata: _metadata }, _showRipple_initializers, _showRipple_extraInitializers);
|
|
25
19
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
26
20
|
}
|
|
27
21
|
get _icon() {
|
|
@@ -37,33 +31,45 @@ let CheckboxElement = (() => {
|
|
|
37
31
|
#ripple_accessor_storage = __runInitializers(this, _ripple_initializers, void 0);
|
|
38
32
|
get ripple() { return this.#ripple_accessor_storage; }
|
|
39
33
|
set ripple(value) { this.#ripple_accessor_storage = value; }
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const _ripple = await this.getRipple();
|
|
49
|
-
_ripple?.beginFocus();
|
|
34
|
+
pressRipple(options) {
|
|
35
|
+
const element = this.ripple;
|
|
36
|
+
if (element && !element.isPressed) {
|
|
37
|
+
element.beginPress(options.positionEvent);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
endRipple() {
|
|
41
|
+
this.ripple?.endPress();
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
beginPress(options) {
|
|
44
|
+
super.beginPress(options);
|
|
45
|
+
this.pressRipple(options);
|
|
46
|
+
}
|
|
47
|
+
endPress(config) {
|
|
48
|
+
super.endPress(config);
|
|
49
|
+
this.endRipple();
|
|
54
50
|
}
|
|
55
51
|
async handleKeyDown(e) {
|
|
56
52
|
super.handleKeyDown(e);
|
|
57
53
|
if (['Space'].includes(e.code)) {
|
|
58
|
-
|
|
59
|
-
_ripple?.beginPress();
|
|
54
|
+
this.ripple?.beginPress();
|
|
60
55
|
}
|
|
61
56
|
}
|
|
62
57
|
async handleKeyUp(e) {
|
|
63
58
|
super.handleKeyUp(e);
|
|
64
59
|
if (['Space'].includes(e.code)) {
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
this.ripple?.endPress();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
handlePointerEnter(e) {
|
|
64
|
+
super.handlePointerEnter(e);
|
|
65
|
+
if (this.ripple) {
|
|
66
|
+
this.ripple.beginHover(e);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
handlePointerLeave(e) {
|
|
70
|
+
super.handlePointerLeave(e);
|
|
71
|
+
if (this.ripple) {
|
|
72
|
+
this.ripple.endHover();
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
render() {
|
|
@@ -73,18 +79,19 @@ let CheckboxElement = (() => {
|
|
|
73
79
|
pressed,
|
|
74
80
|
});
|
|
75
81
|
return html `
|
|
76
|
-
<
|
|
82
|
+
<md-focus-ring part="focus-ring" .control="${this}"></md-focus-ring>
|
|
83
|
+
<div class="${containerClasses}">
|
|
77
84
|
<div class="container"></div>
|
|
78
85
|
<div class="state"></div>
|
|
79
|
-
${
|
|
86
|
+
<ui-ripple class="ripple" unbounded ?disabled="${this.disabled}"></ui-ripple>
|
|
80
87
|
<div class="icon">${this._icon}</div>
|
|
81
88
|
</div>
|
|
82
89
|
`;
|
|
83
90
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
91
|
+
constructor() {
|
|
92
|
+
super(...arguments);
|
|
93
|
+
__runInitializers(this, _ripple_extraInitializers);
|
|
94
|
+
}
|
|
88
95
|
};
|
|
89
96
|
})();
|
|
90
97
|
export default CheckboxElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxElement.js","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckboxElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAqC,OAAO,EAAE,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,
|
|
1
|
+
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ACR,CAAC,CAAA;YACF,OAAO,IAAI,CAAA;mDACoC,IAAmB;oBAClD,gBAAgB;;;yDAGqB,IAAI,CAAC,QAAQ;4BAC1C,IAAI,CAAC,KAAK;;KAEjC,CAAA;QACH,CAAC;;;;;;;AA9EH,+BA+EC","sourcesContent":["import { html, SVGTemplateResult, TemplateResult, nothing } from 'lit'\nimport { query } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport CheckedElement from './CheckedElement.js'\nimport { check, checkIndeterminate } from '../../icons/Icons.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '@material/web/focus/md-focus-ring.js'\n\nexport default class CheckboxElement extends CheckedElement {\n protected get _icon(): SVGTemplateResult | typeof nothing {\n const { indeterminate, checked } = this\n if (indeterminate) {\n return checkIndeterminate\n }\n if (checked) {\n return check\n }\n return nothing\n }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n protected pressRipple(options: BeginPressConfig): void {\n const element = this.ripple\n if (element && !element.isPressed) {\n element.beginPress(options.positionEvent as PointerEvent)\n }\n }\n\n protected endRipple(): void {\n this.ripple?.endPress()\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.pressRipple(options)\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.endRipple()\n }\n\n override async handleKeyDown(e: KeyboardEvent): Promise<void> {\n super.handleKeyDown(e)\n if (['Space'].includes(e.code)) {\n this.ripple?.beginPress()\n }\n }\n\n override async handleKeyUp(e: KeyboardEvent): Promise<void> {\n super.handleKeyUp(e)\n if (['Space'].includes(e.code)) {\n this.ripple?.endPress()\n }\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n if (this.ripple) {\n this.ripple.beginHover(e)\n }\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n if (this.ripple) {\n this.ripple.endHover()\n }\n }\n\n protected override render(): TemplateResult {\n const { pressed = false } = this\n const containerClasses = classMap({\n surface: true,\n pressed,\n })\n return html`\n <md-focus-ring part=\"focus-ring\" .control=\"${this as HTMLElement}\"></md-focus-ring>\n <div class=\"${containerClasses}\">\n <div class=\"container\"></div>\n <div class=\"state\"></div>\n <ui-ripple class=\"ripple\" unbounded ?disabled=\"${this.disabled}\"></ui-ripple>\n <div class=\"icon\">${this._icon}</div>\n </div>\n `\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckedElement.d.ts","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckedElement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAA;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAAS;;IAGnD,MAAM,CAAC,QAAQ,CAAC,cAAc,QAAO;IAIrC,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,CAEjC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACH,IACI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAK1B;IAED;;;OAGG;IACyB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IAE7D;;;;;OAKG;IACyB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IAE9D;;;;;;;OAOG;IACyC,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAA;IAEjF;;;;;;;OAOG;IACyC,QAAQ,CAAC,aAAa,EAAE,OAAO,GAAG,SAAS,CAAA;IAEvF;;;OAGG;IACyC,QAAQ,CAAC,QAAQ,EAAE,OAAO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AWf,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAoB1D;;;OAGG;IACH,iBAAiB,IAAI,IAAI;IAKzB;;;;;OAKG;IACH,wBAAwB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAOzC,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAKhC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAW/C,SAAS,CAAC,WAAW,IAAI,IAAI;IAI7B,SAAS,CAAC,UAAU,IAAI,IAAI;IAI5B,SAAS,CAAC,WAAW,CAAC,KAAK,UAAQ,GAAG,IAAI;IAQ1C,SAAS,CAAC,gBAAgB,IAAI,IAAI;IAoBzB,YAAY,IAAI,IAAI;IAM7B,SAAS,CAAC,eAAe,IAAI,IAAI;IAOjC,MAAM,IAAI,IAAI;IAWd,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAKpC;;;OAGG;IACH,aAAa,IAAI,OAAO;IAKxB;;;;OAIG;IACH,cAAc,IAAI,OAAO;CAI1B"}
|
|
@@ -133,6 +133,7 @@ let CheckedElement = (() => {
|
|
|
133
133
|
this.addEventListener('pointerdown', this.handlePointerDown.bind(this));
|
|
134
134
|
this.addEventListener('pointerup', this.handlePointerUp.bind(this));
|
|
135
135
|
this.addEventListener('pointercancel', this.handlePointerCancel.bind(this));
|
|
136
|
+
this.addEventListener('pointerenter', this.handlePointerEnter.bind(this));
|
|
136
137
|
this.addEventListener('pointerleave', this.handlePointerLeave.bind(this));
|
|
137
138
|
this.addEventListener('contextmenu', this.handleContextMenu.bind(this));
|
|
138
139
|
this.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckedElement.js","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckedElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,E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G,IAAI,CAAA;YAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAA;QACzC,CAAC;QAED;;;;WAIG;QACH,cAAc;YACZ,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;YAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAA;QAC1C,CAAC;;;AAnQH;;;;;GAKG;AACH","sourcesContent":["import { property } from 'lit/decorators.js'\nimport { UiElement } from '../../UiElement.js'\nimport { EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport { PropertyValues } from 'lit'\n\n/**\n * A base class for UI elements that can be checked (as in a form: checkbox, switch, radio).\n *\n * @fires change - when the checked element changes it's checked state\n * @fires input - when the checked element changes it's checked state\n */\nexport default class CheckedElement extends UiElement {\n #_userInteracted: boolean\n\n static readonly formAssociated = true\n\n #_internals = this.attachInternals()\n\n get form(): HTMLFormElement | null {\n return this.#_internals && this.#_internals.form\n }\n\n get type(): string {\n return this.localName\n }\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n this._updateFormValue()\n }\n\n /**\n * The name of the form control, submitted as a pair with the control's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n /**\n * When a form is submitted, only checkboxes which are currently checked are submitted to the server,\n * and the reported value is the `value` of the value attribute.\n * If the `value` is not otherwise specified, it is the string `on` by default.\n * @attribute\n */\n @property({ type: String }) accessor value: string | undefined\n\n /**\n * A Boolean attribute indicating whether this checkbox is checked.\n *\n * A checkbox's value is only included in the submitted data\n * if the checkbox is currently `checked`. If it is, then the value\n * of the checkbox's `value` attribute is reported as the input's value.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor checked: boolean | undefined\n\n /**\n * In addition to the checked and unchecked states, there is a third state a checkbox can be in: indeterminate.\n * This is a state in which it's impossible to say whether the item is toggled on or off.\n *\n * If you submit a form with an indeterminate checkbox, the same thing happens as\n * if the checkbox were unchecked — no data is submitted to represent the checkbox.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor indeterminate: boolean | undefined\n\n /**\n * Set to true to mark the checked element as required.\n * @attribute\n */\n @property({ reflect: true, type: Boolean }) accessor required: boolean | undefined\n\n /**\n * While the element can be easily styled with the `:valid` and `:invalid` pseudo classes\n * it also exposes an attribute to style the element as invalid. This attribute changes\n * when the element validation is performed.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor invalid: boolean | undefined\n\n protected readonly _validationError: string = 'Please check this box if you want to proceed.'\n\n constructor() {\n super()\n // The default value for the `<input type=\"checkbox\"/>\n this.value = 'on'\n this.checked = false\n this.indeterminate = false\n this.#_userInteracted = false\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('invalid', this._invalidHandler.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('focus', this.handleFocus.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'checkbox')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n this._setChecked(this.checked)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n if (cp.has('required')) {\n const value = cp.get('required')\n if (value) {\n // this.setAttribute('aria-required', 'true');\n this.#_internals.ariaRequired = 'true'\n } else {\n // this.removeAttribute('aria-required');\n this.#_internals.ariaRequired = null\n }\n this._updateFormValue()\n }\n if (cp.has('indeterminate') || cp.has('value')) {\n this._updateFormValue()\n }\n if (cp.has('checked')) {\n this._setChecked(this.checked)\n }\n }\n\n /**\n * When form-associated custom elements are supported in the browser it\n * is called when the form has been reset\n */\n formResetCallback(): void {\n this.checked = false\n this._postCheckedChange()\n }\n\n /**\n * When form-associated custom elements are supported in the browser it\n * is called when the form state has been restored\n *\n * @param formState Restored value\n */\n formStateRestoreCallback(formState?: string): void {\n if (this.value === formState) {\n this.checked = true\n this._postCheckedChange()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n this.toggle()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n if (reason === 'enter' || reason === 'space') {\n this.toggle()\n }\n }\n\n protected handleFocus(): void {\n //\n }\n\n protected handleBlur(): void {\n //\n }\n\n protected _setChecked(value = false): void {\n const { indeterminate } = this\n const attrValue = indeterminate ? 'mixed' : String(value)\n this.setAttribute('aria-checked', attrValue)\n this.#_internals.ariaChecked = attrValue\n this._updateFormValue()\n }\n\n protected _updateFormValue(): void {\n const { value = null, checked, indeterminate, disabled, required } = this\n if (!checked || indeterminate || disabled) {\n this.#_internals.setFormValue(null)\n } else {\n this.#_internals.setFormValue(value)\n }\n\n if (required && !checked) {\n this.#_internals.setValidity(\n {\n valueMissing: true,\n },\n this._validationError\n )\n } else if (this.#_internals.validity.valueMissing) {\n this.#_internals.setValidity({})\n }\n }\n\n override notifyChange(): void {\n // The <input type=\"checkbox\"/> dispatches both events.\n this.dispatchEvent(new Event('input'))\n super.notifyChange()\n }\n\n protected _invalidHandler(): void {\n if (!this.#_userInteracted) {\n return\n }\n this.invalid = true\n }\n\n toggle(): void {\n if (this.disabled) {\n return\n }\n this.#_userInteracted = true\n this.invalid = false\n this.checked = !this.checked\n this._updateFormValue()\n this._postCheckedChange()\n }\n\n protected _postCheckedChange(): void {\n this.notifyChange()\n this.#_internals.checkValidity()\n }\n\n /**\n * Returns true if the element's value has no validity problems; false otherwise.\n * Fires an invalid event at the element in the latter case.\n */\n checkValidity(): boolean {\n this.#_userInteracted = true\n return this.#_internals.checkValidity()\n }\n\n /**\n * Returns `true` if internals's target element has no validity problems; otherwise, returns false,\n * fires an invalid event at the element, and (if the event isn't canceled) reports\n * the problem to the user.\n */\n reportValidity(): boolean {\n this.#_userInteracted = true\n return this.#_internals.reportValidity()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CheckedElement.js","sourceRoot":"","sources":["../../../../../src/md/checkbox/internals/CheckedElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;;sBAStB,SAAS;;;;;;;;;;;;;;;;;;;;;iBAAhC,cAAe,SAAQ,WAAS;;;wCAuBlD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gCAY1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iCAQ1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCAU1B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAU1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAM1C,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mCAQ1C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YArD3C,0LAAI,QAAQ,wEAKX;YA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;YACvB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC3B,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACrB,CAAC;QAED,MAAM;YACJ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAM;YACR,CAAC;YACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;YAC5B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;YACpB,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAA;YAC5B,IAAI,CAAC,gBAAgB,EAAE,CAAA;YACvB,IAAI,CAAC,kBAAkB,EAAE,CAAA;QAC3B,CAAC;QAES,kBAAkB;YAC1B,IAAI,CAAC,YAAY,EAAE,CAAA;YACnB,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAA;QAClC,CAAC;QAED;;;WAGG;QACH,aAAa;YACX,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;YAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAA;QACzC,CAAC;QAED;;;;WAIG;QACH,cAAc;YACZ,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;YAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAA;QAC1C,CAAC;;;AApQH;;;;;GAKG;AACH","sourcesContent":["import { property } from 'lit/decorators.js'\nimport { UiElement } from '../../UiElement.js'\nimport { EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport { PropertyValues } from 'lit'\n\n/**\n * A base class for UI elements that can be checked (as in a form: checkbox, switch, radio).\n *\n * @fires change - when the checked element changes it's checked state\n * @fires input - when the checked element changes it's checked state\n */\nexport default class CheckedElement extends UiElement {\n #_userInteracted: boolean\n\n static readonly formAssociated = true\n\n #_internals = this.attachInternals()\n\n get form(): HTMLFormElement | null {\n return this.#_internals && this.#_internals.form\n }\n\n get type(): string {\n return this.localName\n }\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n this._updateFormValue()\n }\n\n /**\n * The name of the form control, submitted as a pair with the control's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n /**\n * When a form is submitted, only checkboxes which are currently checked are submitted to the server,\n * and the reported value is the `value` of the value attribute.\n * If the `value` is not otherwise specified, it is the string `on` by default.\n * @attribute\n */\n @property({ type: String }) accessor value: string | undefined\n\n /**\n * A Boolean attribute indicating whether this checkbox is checked.\n *\n * A checkbox's value is only included in the submitted data\n * if the checkbox is currently `checked`. If it is, then the value\n * of the checkbox's `value` attribute is reported as the input's value.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor checked: boolean | undefined\n\n /**\n * In addition to the checked and unchecked states, there is a third state a checkbox can be in: indeterminate.\n * This is a state in which it's impossible to say whether the item is toggled on or off.\n *\n * If you submit a form with an indeterminate checkbox, the same thing happens as\n * if the checkbox were unchecked — no data is submitted to represent the checkbox.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor indeterminate: boolean | undefined\n\n /**\n * Set to true to mark the checked element as required.\n * @attribute\n */\n @property({ reflect: true, type: Boolean }) accessor required: boolean | undefined\n\n /**\n * While the element can be easily styled with the `:valid` and `:invalid` pseudo classes\n * it also exposes an attribute to style the element as invalid. This attribute changes\n * when the element validation is performed.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor invalid: boolean | undefined\n\n protected readonly _validationError: string = 'Please check this box if you want to proceed.'\n\n constructor() {\n super()\n // The default value for the `<input type=\"checkbox\"/>\n this.value = 'on'\n this.checked = false\n this.indeterminate = false\n this.#_userInteracted = false\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('invalid', this._invalidHandler.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('focus', this.handleFocus.bind(this))\n this.addEventListener('blur', this.handleBlur.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'checkbox')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n this._setChecked(this.checked)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n if (cp.has('required')) {\n const value = cp.get('required')\n if (value) {\n // this.setAttribute('aria-required', 'true');\n this.#_internals.ariaRequired = 'true'\n } else {\n // this.removeAttribute('aria-required');\n this.#_internals.ariaRequired = null\n }\n this._updateFormValue()\n }\n if (cp.has('indeterminate') || cp.has('value')) {\n this._updateFormValue()\n }\n if (cp.has('checked')) {\n this._setChecked(this.checked)\n }\n }\n\n /**\n * When form-associated custom elements are supported in the browser it\n * is called when the form has been reset\n */\n formResetCallback(): void {\n this.checked = false\n this._postCheckedChange()\n }\n\n /**\n * When form-associated custom elements are supported in the browser it\n * is called when the form state has been restored\n *\n * @param formState Restored value\n */\n formStateRestoreCallback(formState?: string): void {\n if (this.value === formState) {\n this.checked = true\n this._postCheckedChange()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n this.toggle()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n if (reason === 'enter' || reason === 'space') {\n this.toggle()\n }\n }\n\n protected handleFocus(): void {\n //\n }\n\n protected handleBlur(): void {\n //\n }\n\n protected _setChecked(value = false): void {\n const { indeterminate } = this\n const attrValue = indeterminate ? 'mixed' : String(value)\n this.setAttribute('aria-checked', attrValue)\n this.#_internals.ariaChecked = attrValue\n this._updateFormValue()\n }\n\n protected _updateFormValue(): void {\n const { value = null, checked, indeterminate, disabled, required } = this\n if (!checked || indeterminate || disabled) {\n this.#_internals.setFormValue(null)\n } else {\n this.#_internals.setFormValue(value)\n }\n\n if (required && !checked) {\n this.#_internals.setValidity(\n {\n valueMissing: true,\n },\n this._validationError\n )\n } else if (this.#_internals.validity.valueMissing) {\n this.#_internals.setValidity({})\n }\n }\n\n override notifyChange(): void {\n // The <input type=\"checkbox\"/> dispatches both events.\n this.dispatchEvent(new Event('input'))\n super.notifyChange()\n }\n\n protected _invalidHandler(): void {\n if (!this.#_userInteracted) {\n return\n }\n this.invalid = true\n }\n\n toggle(): void {\n if (this.disabled) {\n return\n }\n this.#_userInteracted = true\n this.invalid = false\n this.checked = !this.checked\n this._updateFormValue()\n this._postCheckedChange()\n }\n\n protected _postCheckedChange(): void {\n this.notifyChange()\n this.#_internals.checkValidity()\n }\n\n /**\n * Returns true if the element's value has no validity problems; false otherwise.\n * Fires an invalid event at the element in the latter case.\n */\n checkValidity(): boolean {\n this.#_userInteracted = true\n return this.#_internals.checkValidity()\n }\n\n /**\n * Returns `true` if internals's target element has no validity problems; otherwise, returns false,\n * fires an invalid event at the element, and (if the event isn't canceled) reports\n * the problem to the user.\n */\n reportValidity(): boolean {\n this.#_userInteracted = true\n return this.#_internals.reportValidity()\n }\n}\n"]}
|
|
@@ -91,6 +91,8 @@ export default class UiDropdownList extends LitElement {
|
|
|
91
91
|
connectedCallback(): void;
|
|
92
92
|
disconnectedCallback(): void;
|
|
93
93
|
protected dropdownOpenHandler(e: Event): void;
|
|
94
|
+
protected willUpdate(cp: PropertyValues<this>): void;
|
|
95
|
+
protected updated(cp: PropertyValues<this>): void;
|
|
94
96
|
protected updateExpanded(): void;
|
|
95
97
|
protected triggerChanged(): void;
|
|
96
98
|
protected dropdownChanged(): void;
|
|
@@ -105,8 +107,6 @@ export default class UiDropdownList extends LitElement {
|
|
|
105
107
|
protected contentClickHandler(e: PointerEvent): void;
|
|
106
108
|
close(): void;
|
|
107
109
|
protected contentCloseHandler(e: Event): void;
|
|
108
|
-
protected willUpdate(cp: PropertyValues<this>): void;
|
|
109
|
-
protected updated(cp: PropertyValues<this>): void;
|
|
110
110
|
/**
|
|
111
111
|
* Since the container for the dropdown content is positioned as fixed
|
|
112
112
|
* we need to position the dropdown according to the configured rules.
|
|
@@ -115,6 +115,17 @@ export default class UiDropdownList extends LitElement {
|
|
|
115
115
|
protected scrollHandler(): void;
|
|
116
116
|
protected clickHandler(e: Event): void;
|
|
117
117
|
protected toggleOpened(): void;
|
|
118
|
+
/**
|
|
119
|
+
* When set, it is the last active child of the dropdown
|
|
120
|
+
* before the tabindex was removed from it. It is used to restore focus
|
|
121
|
+
* when the dropdown is re-opened.
|
|
122
|
+
*/
|
|
123
|
+
lastActiveChild?: HTMLElement;
|
|
124
|
+
/**
|
|
125
|
+
* When the list is closed, the tabindex of the dropdown is removed to prevent
|
|
126
|
+
* it from being focused while invisible.
|
|
127
|
+
*/
|
|
128
|
+
protected manageTabindex(): void;
|
|
118
129
|
protected handleOpened(): void;
|
|
119
130
|
protected handleClosed(): void;
|
|
120
131
|
protected activate(e: Event): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiDropdownList.d.ts","sourceRoot":"","sources":["../../../../../src/md/dropdown-list/internals/UiDropdownList.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAGtE,OAAO,EAAE,SAAS,EAAY,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAmB,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAKtH,MAAM,WAAW,uBAAuB;I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AI;IAe9B,SAAS,CAAC,YAAY,IAAI,IAAI;IAgB9B,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAmClC,SAAS,CAAC,UAAU,IAAI,IAAI;cAaT,MAAM,IAAI,cAAc;IAS3C,SAAS,CAAC,aAAa,IAAI,cAAc;IAQzC,SAAS,CAAC,aAAa,IAAI,cAAc;CAc1C"}
|
|
@@ -191,7 +191,6 @@ let UiDropdownList = (() => {
|
|
|
191
191
|
set overlayPositioning(value) { this.#overlayPositioning_accessor_storage = value; }
|
|
192
192
|
constructor() {
|
|
193
193
|
super();
|
|
194
|
-
__runInitializers(this, _overlayPositioning_extraInitializers);
|
|
195
194
|
this.dropdownOpenHandler = this.dropdownOpenHandler.bind(this);
|
|
196
195
|
this.scrollHandler = this.scrollHandler.bind(this);
|
|
197
196
|
this.clickHandler = this.clickHandler.bind(this);
|
|
@@ -216,6 +215,20 @@ let UiDropdownList = (() => {
|
|
|
216
215
|
}
|
|
217
216
|
this.close();
|
|
218
217
|
}
|
|
218
|
+
willUpdate(cp) {
|
|
219
|
+
super.willUpdate(cp);
|
|
220
|
+
if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {
|
|
221
|
+
this.computePositioning();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
updated(cp) {
|
|
225
|
+
super.updated(cp);
|
|
226
|
+
if (cp.has('open')) {
|
|
227
|
+
this.toggleOpened();
|
|
228
|
+
this.updateExpanded();
|
|
229
|
+
// this.manageTabindex()
|
|
230
|
+
}
|
|
231
|
+
}
|
|
219
232
|
updateExpanded() {
|
|
220
233
|
this.setAttribute('aria-expanded', String(this.open));
|
|
221
234
|
}
|
|
@@ -258,14 +271,12 @@ let UiDropdownList = (() => {
|
|
|
258
271
|
}
|
|
259
272
|
triggerClickHandler() {
|
|
260
273
|
this.open = !this.open;
|
|
261
|
-
this.updateExpanded();
|
|
262
274
|
this.notifyOpen();
|
|
263
275
|
}
|
|
264
276
|
triggerKeyDownHandler(e) {
|
|
265
277
|
if (['Enter', 'Space', 'ArrowDown', 'ArrowUp'].includes(e.code)) {
|
|
266
278
|
e.preventDefault();
|
|
267
279
|
this.open = true;
|
|
268
|
-
this.updateExpanded();
|
|
269
280
|
this.notifyOpen();
|
|
270
281
|
}
|
|
271
282
|
}
|
|
@@ -290,25 +301,12 @@ let UiDropdownList = (() => {
|
|
|
290
301
|
}
|
|
291
302
|
close() {
|
|
292
303
|
this.open = false;
|
|
293
|
-
this.updateExpanded();
|
|
294
304
|
this.notifyOpen();
|
|
295
305
|
}
|
|
296
306
|
contentCloseHandler(e) {
|
|
297
307
|
e.stopPropagation();
|
|
298
308
|
this.close();
|
|
299
309
|
}
|
|
300
|
-
willUpdate(cp) {
|
|
301
|
-
super.willUpdate(cp);
|
|
302
|
-
if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {
|
|
303
|
-
this.computePositioning();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
updated(cp) {
|
|
307
|
-
super.updated(cp);
|
|
308
|
-
if (cp.has('open')) {
|
|
309
|
-
this.toggleOpened();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
310
|
/**
|
|
313
311
|
* Since the container for the dropdown content is positioned as fixed
|
|
314
312
|
* we need to position the dropdown according to the configured rules.
|
|
@@ -351,12 +349,50 @@ let UiDropdownList = (() => {
|
|
|
351
349
|
this.handleClosed();
|
|
352
350
|
}
|
|
353
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* When set, it is the last active child of the dropdown
|
|
354
|
+
* before the tabindex was removed from it. It is used to restore focus
|
|
355
|
+
* when the dropdown is re-opened.
|
|
356
|
+
*/
|
|
357
|
+
lastActiveChild = __runInitializers(this, _overlayPositioning_extraInitializers);
|
|
358
|
+
/**
|
|
359
|
+
* When the list is closed, the tabindex of the dropdown is removed to prevent
|
|
360
|
+
* it from being focused while invisible.
|
|
361
|
+
*/
|
|
362
|
+
manageTabindex() {
|
|
363
|
+
const { dropdown } = this;
|
|
364
|
+
if (!dropdown) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (this.open) {
|
|
368
|
+
if (this.lastActiveChild) {
|
|
369
|
+
this.lastActiveChild.setAttribute('tabindex', '0');
|
|
370
|
+
this.lastActiveChild.focus();
|
|
371
|
+
this.lastActiveChild = undefined;
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
// If no last active child, focus the dropdown itself
|
|
375
|
+
dropdown.setAttribute('tabindex', '0');
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
// const activeChild = dropdown.querySelector(':focus') || dropdown
|
|
380
|
+
// this.lastActiveChild = activeChild as HTMLElement
|
|
381
|
+
// activeChild.removeAttribute('tabindex')
|
|
382
|
+
// this.trigger?.focus()
|
|
383
|
+
}
|
|
384
|
+
}
|
|
354
385
|
handleOpened() {
|
|
355
386
|
const { trigger, dropdown } = this;
|
|
356
387
|
if (trigger) {
|
|
357
388
|
trigger.removeAttribute('tabindex');
|
|
358
389
|
}
|
|
359
|
-
if (
|
|
390
|
+
if (this.lastActiveChild) {
|
|
391
|
+
this.lastActiveChild.setAttribute('tabindex', '0');
|
|
392
|
+
this.lastActiveChild.focus();
|
|
393
|
+
this.lastActiveChild = undefined;
|
|
394
|
+
}
|
|
395
|
+
else if (dropdown) {
|
|
360
396
|
dropdown.setAttribute('tabindex', '0');
|
|
361
397
|
dropdown.focus();
|
|
362
398
|
}
|
|
@@ -365,11 +401,14 @@ let UiDropdownList = (() => {
|
|
|
365
401
|
const { trigger, dropdown } = this;
|
|
366
402
|
if (trigger) {
|
|
367
403
|
trigger.setAttribute('tabindex', '0');
|
|
368
|
-
|
|
369
|
-
trigger.focus();
|
|
370
|
-
}
|
|
404
|
+
trigger.focus();
|
|
371
405
|
}
|
|
372
406
|
if (dropdown) {
|
|
407
|
+
const activeChild = dropdown.querySelector('[tabindex="0"]');
|
|
408
|
+
if (activeChild) {
|
|
409
|
+
this.lastActiveChild = activeChild;
|
|
410
|
+
activeChild.removeAttribute('tabindex');
|
|
411
|
+
}
|
|
373
412
|
dropdown.removeAttribute('tabindex');
|
|
374
413
|
}
|
|
375
414
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiDropdownList.js","sourceRoot":"","sources":["../../../../../src/md/dropdown-list/internals/UiDropdownList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAoD,MAAM,oCAAoC,CAAA;AACtH,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAE5D,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAA;;sBA0BtB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAjC,cAAe,SAAQ,WAAU;;;oCACnD,qBAAqB,EAAE;qCAGvB,qBAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;qCAG3C,KAAK,EAAE;kCAEP,KAAK,EAAE;gCAMP,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAW1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAWzC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCAQz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AI,CAAC,aAAa,CAChB,IAAI,KAAK,CAAC,cAAc,EAAE;oBACxB,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,IAAI;iBACjB,CAAC,CACH,CAAA;YACH,CAAC;QACH,CAAC;QAEkB,MAAM;YACvB,MAAM,OAAO,GAAc;gBACzB,SAAS,EAAE,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAA;YAED,OAAO,IAAI,CAAA,gBAAgB,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,SAAS,CAAA;QACxG,CAAC;QAES,aAAa;YACrB,OAAO,IAAI,CAAA;qCACsB,IAAI,CAAC,mBAAmB,eAAe,IAAI,CAAC,qBAAqB;6BACzE,IAAI,CAAC,cAAc;;KAE3C,CAAA;QACH,CAAC;QAES,aAAa;YACrB,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAA;YACnD,OAAO,IAAI,CAAA;oCACqB,QAAQ,CAAC,aAAa,CAAC;;;yBAGlC,IAAI,CAAC,eAAe;sBACvB,IAAI,CAAC,qBAAqB;oBAC5B,IAAI,CAAC,mBAAmB;oBACxB,IAAI,CAAC,mBAAmB;;;KAGvC,CAAA;QACH,CAAC;;;AA1YH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8BAuXC","sourcesContent":["import { randomString } from '@api-client/core/lib/math/Random.js'\nimport { html, LitElement, PropertyValues, TemplateResult } from 'lit'\nimport { property, queryAssignedElements, state } from 'lit/decorators.js'\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { StyleInfo, styleMap } from 'lit/directives/style-map.js'\nimport { positionOverlay, type HorizontalAlignment, type VerticalAlignment } from '../../../lib/ElementPositioning.js'\nimport * as ScrollHelper from '../../../lib/ScrollHelper.js'\n\nconst itemRole = ['menuitem', 'menuitemcheckbox', 'menuitemradio']\n\nexport interface UiDropdownListSelection {\n item: HTMLElement\n}\n\n/**\n * An overlay list rendered over a button.\n *\n * Examples:\n *\n * <ui-dropdown-list>\n * <ui-filled-button>Click me</ui-filled-button>\n * <ui-list slot=\"dropdown\" role=\"menu\">\n * <ui-list-item role=\"menuitem\">Item 1</ui-list-item>\n * <ui-list-item role=\"menuitem\">Item 2</ui-list-item>\n * </ui-list>\n * </ui-dropdown-list>\n *\n * @slot - The default slot for the dropdown trigger (button)\n * @slot dropdown - The slot for the list.\n * @fires select - Custom event with the selected item on the `detail.item` when the user selected an item.\n * When the event is cancelled then there's no side effects (closing the dropdown)\n * @fires dropdownopen - An event informing other dropdowns that this one was opened and other should close.\n * @fires open - An event dispatched when the open state change through a user interaction\n */\nexport default class UiDropdownList extends LitElement {\n @queryAssignedElements()\n protected accessor triggers!: HTMLElement[]\n\n @queryAssignedElements({ slot: 'dropdown' })\n protected accessor dropdowns!: HTMLElement[]\n\n @state() protected accessor triggerId = `ui-trigger-${randomString(4)}`\n\n @state() protected accessor menuId = `ui-menu-${randomString(4)}`\n\n /**\n * Whether the menu is opened.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n /**\n * The vertical (y-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n *\n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor verticalAlign: VerticalAlignment | undefined\n\n /**\n * The horizontal (x-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n *\n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor horizontalAlign: HorizontalAlignment | undefined\n\n /**\n * Affects the `horizontal` and `vertical` positioning so that the target element does not overlap with the anchor.\n * For example, when the `vertical` align is `top`, the top edge of the target will be rendered at the bottom\n * of the anchor down to the edge of the viewport.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor noOverlap: boolean | undefined\n\n /**\n * When set it closes the opened list when registering a click outside the list.\n * @attribute\n */\n @property({ type: Boolean }) accessor closeOnOutsideClick: boolean | undefined\n\n /**\n * When set it makes the drop-down to match the width of the trigger.\n * Be careful as this may crop the content when the trigger is not wide enough.\n * @attribute\n */\n @property({ type: Boolean }) accessor matchTriggerWidth: boolean | undefined\n\n /**\n * When set it closes the drop-down when `tab` button is pressed.\n * This is not a default behavior since the drop-down content can have its own logic\n * related to tab index.\n */\n @property({ type: Boolean }) accessor closeOnTab: boolean | undefined\n\n /**\n * The first element located in the default slot.\n */\n protected get trigger(): HTMLElement | null {\n const { triggers } = this\n if (!triggers || !triggers.length) {\n return null\n }\n const [button] = triggers\n return button\n }\n\n /**\n * The first element located in the \"dropdown\" slot.\n */\n protected get dropdown(): HTMLElement | null {\n const { dropdowns } = this\n if (!dropdowns || !dropdowns.length) {\n return null\n }\n const [content] = dropdowns\n return content\n }\n\n @state() protected accessor overlayPositioning: StyleInfo | undefined\n\n constructor() {\n super()\n this.dropdownOpenHandler = this.dropdownOpenHandler.bind(this)\n this.scrollHandler = this.scrollHandler.bind(this)\n this.clickHandler = this.clickHandler.bind(this)\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n window.addEventListener('dropdownopen', this.dropdownOpenHandler)\n window.addEventListener('click', this.clickHandler, { capture: true })\n ScrollHelper.addListeners(this, this.scrollHandler)\n\n this.setAttribute('aria-haspopup', 'menu')\n this.setAttribute('aria-expanded', 'false')\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n window.removeEventListener('dropdownopen', this.dropdownOpenHandler)\n window.removeEventListener('click', this.clickHandler, { capture: true })\n ScrollHelper.removeListeners(this)\n }\n\n protected dropdownOpenHandler(e: Event): void {\n if (e.composedPath()[0] === this) {\n return\n }\n this.close()\n }\n\n protected updateExpanded(): void {\n this.setAttribute('aria-expanded', String(this.open))\n }\n\n protected triggerChanged(): void {\n const { trigger } = this\n if (!trigger) {\n return\n }\n this.decorateTrigger(trigger)\n }\n\n protected dropdownChanged(): void {\n const { dropdown } = this\n if (!dropdown) {\n return\n }\n this.decorateDropdown(dropdown)\n }\n\n /**\n * Decorates the trigger with aria attributes.\n */\n protected decorateTrigger(button: HTMLElement): void {\n button.setAttribute('aria-controls', this.menuId)\n button.setAttribute('tabindex', '0')\n if (button.id) {\n this.triggerId = button.id\n } else {\n button.id = this.triggerId\n }\n }\n\n protected decorateDropdown(list: HTMLElement): void {\n if (!list.hasAttribute('role')) {\n list.setAttribute('role', 'menu')\n }\n if (!list.hasAttribute('aria-labelledby')) {\n list.setAttribute('aria-labelledby', this.triggerId)\n }\n list.setAttribute('tabindex', '-1')\n list.id = this.menuId\n }\n\n protected triggerClickHandler(): void {\n this.open = !this.open\n this.updateExpanded()\n this.notifyOpen()\n }\n\n protected triggerKeyDownHandler(e: KeyboardEvent): void {\n if (['Enter', 'Space', 'ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault()\n this.open = true\n this.updateExpanded()\n this.notifyOpen()\n }\n }\n\n protected contentKeyDownHandler(e: KeyboardEvent): void {\n if (e.defaultPrevented) {\n return\n }\n if (e.code === 'Escape') {\n this.close()\n } else if (e.code === 'Tab') {\n if (this.closeOnTab) {\n this.close()\n }\n } else if (['Enter', 'Space'].includes(e.code)) {\n this.activate(e)\n }\n }\n\n protected contentClickHandler(e: PointerEvent): void {\n this.activate(e)\n }\n\n close(): void {\n this.open = false\n this.updateExpanded()\n this.notifyOpen()\n }\n\n protected contentCloseHandler(e: Event): void {\n e.stopPropagation()\n this.close()\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n super.willUpdate(cp)\n if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {\n this.computePositioning()\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n if (cp.has('open')) {\n this.toggleOpened()\n }\n }\n\n /**\n * Since the container for the dropdown content is positioned as fixed\n * we need to position the dropdown according to the configured rules.\n */\n protected computePositioning(): void {\n const { trigger, dropdown } = this\n if (!trigger || !dropdown) {\n return\n }\n this.overlayPositioning = positionOverlay(dropdown, trigger, {\n horizontal: this.horizontalAlign,\n vertical: this.verticalAlign,\n noOverlap: this.noOverlap,\n constrain: true,\n constrainPaddingY: 20,\n matchAnchorWidth: this.matchTriggerWidth,\n })\n }\n\n protected scrollHandler(): void {\n if (this.open) {\n this.computePositioning()\n }\n }\n\n protected clickHandler(e: Event): void {\n if (!this.open || !this.closeOnOutsideClick) {\n return\n }\n const inside = e.composedPath().some((i) => i === this)\n if (inside) {\n return\n }\n this.close()\n }\n\n protected toggleOpened(): void {\n const { open } = this\n if (open) {\n this.handleOpened()\n } else {\n this.handleClosed()\n }\n }\n\n protected handleOpened(): void {\n const { trigger, dropdown } = this\n if (trigger) {\n trigger.removeAttribute('tabindex')\n }\n if (dropdown) {\n dropdown.setAttribute('tabindex', '0')\n dropdown.focus()\n }\n }\n\n protected handleClosed(): void {\n const { trigger, dropdown } = this\n if (trigger) {\n trigger.setAttribute('tabindex', '0')\n if (this.matches(':focus-within')) {\n trigger.focus()\n }\n }\n if (dropdown) {\n dropdown.removeAttribute('tabindex')\n }\n }\n\n protected activate(e: Event): void {\n if (e.defaultPrevented) {\n return\n }\n const path = e.composedPath()\n let item: HTMLElement | undefined\n while (!item) {\n const next = path.shift() as Element\n if (next === this) {\n break\n }\n if (next.nodeType !== Node.ELEMENT_NODE) {\n continue\n }\n if (itemRole.includes(next.getAttribute('role') || '')) {\n item = next as HTMLElement\n }\n }\n if (!item) {\n return\n }\n const event = new CustomEvent<UiDropdownListSelection>('select', {\n cancelable: true,\n // composed: true,\n detail: {\n item,\n },\n })\n this.dispatchEvent(event)\n if (event.defaultPrevented) {\n return\n }\n this.close()\n }\n\n protected notifyOpen(): void {\n this.dispatchEvent(new Event('open'))\n if (this.open) {\n this.dispatchEvent(\n new Event('dropdownopen', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n )\n }\n }\n\n protected override render(): TemplateResult {\n const classes: ClassInfo = {\n container: true,\n open: this.open,\n }\n\n return html` <div class=\"${classMap(classes)}\">${this.renderTrigger()} ${this.renderContent()}</div> `\n }\n\n protected renderTrigger(): TemplateResult {\n return html`\n <div class=\"trigger\" @click=\"${this.triggerClickHandler}\" @keydown=\"${this.triggerKeyDownHandler}\">\n <slot @slotchange=\"${this.triggerChanged}\"></slot>\n </div>\n `\n }\n\n protected renderContent(): TemplateResult {\n const contentStyles = this.overlayPositioning || {}\n return html`\n <div class=\"content\" style=\"${styleMap(contentStyles)}\">\n <slot\n name=\"dropdown\"\n @slotchange=\"${this.dropdownChanged}\"\n @keydown=\"${this.contentKeyDownHandler}\"\n @click=\"${this.contentClickHandler}\"\n @close=\"${this.contentCloseHandler}\"\n ></slot>\n </div>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UiDropdownList.js","sourceRoot":"","sources":["../../../../../src/md/dropdown-list/internals/UiDropdownList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAkC,MAAM,KAAK,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,eAAe,EAAoD,MAAM,oCAAoC,CAAA;AACtH,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAA;AAE5D,MAAM,QAAQ,GAAG,CAAC,UAAU,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAA;;sBA0BtB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAjC,cAAe,SAAQ,WAAU;;;oCACnD,qBAAqB,EAAE;qCAGvB,qBAAqB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;qCAG3C,KAAK,EAAE;kCAEP,KAAK,EAAE;gCAMP,QA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AC,cAAc,EAAE;oBACxB,OAAO,EAAE,IAAI;oBACb,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,IAAI;iBACjB,CAAC,CACH,CAAA;YACH,CAAC;QACH,CAAC;QAEkB,MAAM;YACvB,MAAM,OAAO,GAAc;gBACzB,SAAS,EAAE,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAA;YAED,OAAO,IAAI,CAAA,gBAAgB,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,SAAS,CAAA;QACxG,CAAC;QAES,aAAa;YACrB,OAAO,IAAI,CAAA;qCACsB,IAAI,CAAC,mBAAmB,eAAe,IAAI,CAAC,qBAAqB;6BACzE,IAAI,CAAC,cAAc;;KAE3C,CAAA;QACH,CAAC;QAES,aAAa;YACrB,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,IAAI,EAAE,CAAA;YACnD,OAAO,IAAI,CAAA;oCACqB,QAAQ,CAAC,aAAa,CAAC;;;yBAGlC,IAAI,CAAC,eAAe;sBACvB,IAAI,CAAC,qBAAqB;oBAC5B,IAAI,CAAC,mBAAmB;oBACxB,IAAI,CAAC,mBAAmB;;;KAGvC,CAAA;QACH,CAAC;;;AAjbH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8BA8ZC","sourcesContent":["import { randomString } from '@api-client/core/lib/math/Random.js'\nimport { html, LitElement, PropertyValues, TemplateResult } from 'lit'\nimport { property, queryAssignedElements, state } from 'lit/decorators.js'\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js'\nimport { StyleInfo, styleMap } from 'lit/directives/style-map.js'\nimport { positionOverlay, type HorizontalAlignment, type VerticalAlignment } from '../../../lib/ElementPositioning.js'\nimport * as ScrollHelper from '../../../lib/ScrollHelper.js'\n\nconst itemRole = ['menuitem', 'menuitemcheckbox', 'menuitemradio']\n\nexport interface UiDropdownListSelection {\n item: HTMLElement\n}\n\n/**\n * An overlay list rendered over a button.\n *\n * Examples:\n *\n * <ui-dropdown-list>\n * <ui-filled-button>Click me</ui-filled-button>\n * <ui-list slot=\"dropdown\" role=\"menu\">\n * <ui-list-item role=\"menuitem\">Item 1</ui-list-item>\n * <ui-list-item role=\"menuitem\">Item 2</ui-list-item>\n * </ui-list>\n * </ui-dropdown-list>\n *\n * @slot - The default slot for the dropdown trigger (button)\n * @slot dropdown - The slot for the list.\n * @fires select - Custom event with the selected item on the `detail.item` when the user selected an item.\n * When the event is cancelled then there's no side effects (closing the dropdown)\n * @fires dropdownopen - An event informing other dropdowns that this one was opened and other should close.\n * @fires open - An event dispatched when the open state change through a user interaction\n */\nexport default class UiDropdownList extends LitElement {\n @queryAssignedElements()\n protected accessor triggers!: HTMLElement[]\n\n @queryAssignedElements({ slot: 'dropdown' })\n protected accessor dropdowns!: HTMLElement[]\n\n @state() protected accessor triggerId = `ui-trigger-${randomString(4)}`\n\n @state() protected accessor menuId = `ui-menu-${randomString(4)}`\n\n /**\n * Whether the menu is opened.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor open = false\n\n /**\n * The vertical (y-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n *\n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor verticalAlign: VerticalAlignment | undefined\n\n /**\n * The horizontal (x-axis) alignment of the dropdown content.\n * - top\n * - bottom\n * - middle\n *\n * No value means the natural position according to the box model.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor horizontalAlign: HorizontalAlignment | undefined\n\n /**\n * Affects the `horizontal` and `vertical` positioning so that the target element does not overlap with the anchor.\n * For example, when the `vertical` align is `top`, the top edge of the target will be rendered at the bottom\n * of the anchor down to the edge of the viewport.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor noOverlap: boolean | undefined\n\n /**\n * When set it closes the opened list when registering a click outside the list.\n * @attribute\n */\n @property({ type: Boolean }) accessor closeOnOutsideClick: boolean | undefined\n\n /**\n * When set it makes the drop-down to match the width of the trigger.\n * Be careful as this may crop the content when the trigger is not wide enough.\n * @attribute\n */\n @property({ type: Boolean }) accessor matchTriggerWidth: boolean | undefined\n\n /**\n * When set it closes the drop-down when `tab` button is pressed.\n * This is not a default behavior since the drop-down content can have its own logic\n * related to tab index.\n */\n @property({ type: Boolean }) accessor closeOnTab: boolean | undefined\n\n /**\n * The first element located in the default slot.\n */\n protected get trigger(): HTMLElement | null {\n const { triggers } = this\n if (!triggers || !triggers.length) {\n return null\n }\n const [button] = triggers\n return button\n }\n\n /**\n * The first element located in the \"dropdown\" slot.\n */\n protected get dropdown(): HTMLElement | null {\n const { dropdowns } = this\n if (!dropdowns || !dropdowns.length) {\n return null\n }\n const [content] = dropdowns\n return content\n }\n\n @state() protected accessor overlayPositioning: StyleInfo | undefined\n\n constructor() {\n super()\n this.dropdownOpenHandler = this.dropdownOpenHandler.bind(this)\n this.scrollHandler = this.scrollHandler.bind(this)\n this.clickHandler = this.clickHandler.bind(this)\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n window.addEventListener('dropdownopen', this.dropdownOpenHandler)\n window.addEventListener('click', this.clickHandler, { capture: true })\n ScrollHelper.addListeners(this, this.scrollHandler)\n\n this.setAttribute('aria-haspopup', 'menu')\n this.setAttribute('aria-expanded', 'false')\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n window.removeEventListener('dropdownopen', this.dropdownOpenHandler)\n window.removeEventListener('click', this.clickHandler, { capture: true })\n ScrollHelper.removeListeners(this)\n }\n\n protected dropdownOpenHandler(e: Event): void {\n if (e.composedPath()[0] === this) {\n return\n }\n this.close()\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n super.willUpdate(cp)\n if ((cp.has('noOverlap') || cp.has('verticalAlign') || cp.has('horizontalAlign') || cp.has('open')) && this.open) {\n this.computePositioning()\n }\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n if (cp.has('open')) {\n this.toggleOpened()\n this.updateExpanded()\n // this.manageTabindex()\n }\n }\n\n protected updateExpanded(): void {\n this.setAttribute('aria-expanded', String(this.open))\n }\n\n protected triggerChanged(): void {\n const { trigger } = this\n if (!trigger) {\n return\n }\n this.decorateTrigger(trigger)\n }\n\n protected dropdownChanged(): void {\n const { dropdown } = this\n if (!dropdown) {\n return\n }\n this.decorateDropdown(dropdown)\n }\n\n /**\n * Decorates the trigger with aria attributes.\n */\n protected decorateTrigger(button: HTMLElement): void {\n button.setAttribute('aria-controls', this.menuId)\n button.setAttribute('tabindex', '0')\n if (button.id) {\n this.triggerId = button.id\n } else {\n button.id = this.triggerId\n }\n }\n\n protected decorateDropdown(list: HTMLElement): void {\n if (!list.hasAttribute('role')) {\n list.setAttribute('role', 'menu')\n }\n if (!list.hasAttribute('aria-labelledby')) {\n list.setAttribute('aria-labelledby', this.triggerId)\n }\n list.setAttribute('tabindex', '-1')\n list.id = this.menuId\n }\n\n protected triggerClickHandler(): void {\n this.open = !this.open\n this.notifyOpen()\n }\n\n protected triggerKeyDownHandler(e: KeyboardEvent): void {\n if (['Enter', 'Space', 'ArrowDown', 'ArrowUp'].includes(e.code)) {\n e.preventDefault()\n this.open = true\n this.notifyOpen()\n }\n }\n\n protected contentKeyDownHandler(e: KeyboardEvent): void {\n if (e.defaultPrevented) {\n return\n }\n if (e.code === 'Escape') {\n this.close()\n } else if (e.code === 'Tab') {\n if (this.closeOnTab) {\n this.close()\n }\n } else if (['Enter', 'Space'].includes(e.code)) {\n this.activate(e)\n }\n }\n\n protected contentClickHandler(e: PointerEvent): void {\n this.activate(e)\n }\n\n close(): void {\n this.open = false\n this.notifyOpen()\n }\n\n protected contentCloseHandler(e: Event): void {\n e.stopPropagation()\n this.close()\n }\n\n /**\n * Since the container for the dropdown content is positioned as fixed\n * we need to position the dropdown according to the configured rules.\n */\n protected computePositioning(): void {\n const { trigger, dropdown } = this\n if (!trigger || !dropdown) {\n return\n }\n this.overlayPositioning = positionOverlay(dropdown, trigger, {\n horizontal: this.horizontalAlign,\n vertical: this.verticalAlign,\n noOverlap: this.noOverlap,\n constrain: true,\n constrainPaddingY: 20,\n matchAnchorWidth: this.matchTriggerWidth,\n })\n }\n\n protected scrollHandler(): void {\n if (this.open) {\n this.computePositioning()\n }\n }\n\n protected clickHandler(e: Event): void {\n if (!this.open || !this.closeOnOutsideClick) {\n return\n }\n const inside = e.composedPath().some((i) => i === this)\n if (inside) {\n return\n }\n this.close()\n }\n\n protected toggleOpened(): void {\n const { open } = this\n if (open) {\n this.handleOpened()\n } else {\n this.handleClosed()\n }\n }\n\n /**\n * When set, it is the last active child of the dropdown\n * before the tabindex was removed from it. It is used to restore focus\n * when the dropdown is re-opened.\n */\n lastActiveChild?: HTMLElement\n\n /**\n * When the list is closed, the tabindex of the dropdown is removed to prevent\n * it from being focused while invisible.\n */\n protected manageTabindex(): void {\n const { dropdown } = this\n if (!dropdown) {\n return\n }\n if (this.open) {\n if (this.lastActiveChild) {\n this.lastActiveChild.setAttribute('tabindex', '0')\n this.lastActiveChild.focus()\n this.lastActiveChild = undefined\n } else {\n // If no last active child, focus the dropdown itself\n dropdown.setAttribute('tabindex', '0')\n }\n } else {\n // const activeChild = dropdown.querySelector(':focus') || dropdown\n // this.lastActiveChild = activeChild as HTMLElement\n // activeChild.removeAttribute('tabindex')\n // this.trigger?.focus()\n }\n }\n\n protected handleOpened(): void {\n const { trigger, dropdown } = this\n if (trigger) {\n trigger.removeAttribute('tabindex')\n }\n if (this.lastActiveChild) {\n this.lastActiveChild.setAttribute('tabindex', '0')\n this.lastActiveChild.focus()\n this.lastActiveChild = undefined\n } else if (dropdown) {\n dropdown.setAttribute('tabindex', '0')\n dropdown.focus()\n }\n }\n\n protected handleClosed(): void {\n const { trigger, dropdown } = this\n if (trigger) {\n trigger.setAttribute('tabindex', '0')\n trigger.focus()\n }\n if (dropdown) {\n const activeChild = dropdown.querySelector('[tabindex=\"0\"]')\n if (activeChild) {\n this.lastActiveChild = activeChild as HTMLElement\n activeChild.removeAttribute('tabindex')\n }\n dropdown.removeAttribute('tabindex')\n }\n }\n\n protected activate(e: Event): void {\n if (e.defaultPrevented) {\n return\n }\n const path = e.composedPath()\n let item: HTMLElement | undefined\n while (!item) {\n const next = path.shift() as Element\n if (next === this) {\n break\n }\n if (next.nodeType !== Node.ELEMENT_NODE) {\n continue\n }\n if (itemRole.includes(next.getAttribute('role') || '')) {\n item = next as HTMLElement\n }\n }\n if (!item) {\n return\n }\n const event = new CustomEvent<UiDropdownListSelection>('select', {\n cancelable: true,\n // composed: true,\n detail: {\n item,\n },\n })\n this.dispatchEvent(event)\n if (event.defaultPrevented) {\n return\n }\n this.close()\n }\n\n protected notifyOpen(): void {\n this.dispatchEvent(new Event('open'))\n if (this.open) {\n this.dispatchEvent(\n new Event('dropdownopen', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n )\n }\n }\n\n protected override render(): TemplateResult {\n const classes: ClassInfo = {\n container: true,\n open: this.open,\n }\n\n return html` <div class=\"${classMap(classes)}\">${this.renderTrigger()} ${this.renderContent()}</div> `\n }\n\n protected renderTrigger(): TemplateResult {\n return html`\n <div class=\"trigger\" @click=\"${this.triggerClickHandler}\" @keydown=\"${this.triggerKeyDownHandler}\">\n <slot @slotchange=\"${this.triggerChanged}\"></slot>\n </div>\n `\n }\n\n protected renderContent(): TemplateResult {\n const contentStyles = this.overlayPositioning || {}\n return html`\n <div class=\"content\" style=\"${styleMap(contentStyles)}\">\n <slot\n name=\"dropdown\"\n @slotchange=\"${this.dropdownChanged}\"\n @keydown=\"${this.contentKeyDownHandler}\"\n @click=\"${this.contentClickHandler}\"\n @close=\"${this.contentCloseHandler}\"\n ></slot>\n </div>\n `\n }\n}\n"]}
|