@api-client/ui 0.5.47 → 0.5.48
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/elements/data-table/DataTable.d.ts +1 -1
- package/build/src/elements/data-table/DataTable.js +3 -3
- package/build/src/elements/data-table/DataTable.js.map +1 -1
- package/build/src/elements/file-system/internals/Breadcrumbs.d.ts +1 -1
- package/build/src/elements/file-system/internals/Breadcrumbs.d.ts.map +1 -1
- package/build/src/elements/file-system/internals/Breadcrumbs.js +3 -3
- package/build/src/elements/file-system/internals/Breadcrumbs.js.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.d.ts +2 -0
- package/build/src/elements/navigation/internals/NavigationItem.d.ts.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.js +4 -2
- package/build/src/elements/navigation/internals/NavigationItem.js.map +1 -1
- package/build/src/elements/user/internals/UserAvatar.d.ts +26 -4
- package/build/src/elements/user/internals/UserAvatar.d.ts.map +1 -1
- package/build/src/elements/user/internals/UserAvatar.js +125 -12
- package/build/src/elements/user/internals/UserAvatar.js.map +1 -1
- package/build/src/elements/user/internals/UserAvatar.styles.d.ts.map +1 -1
- package/build/src/elements/user/internals/UserAvatar.styles.js +6 -11
- package/build/src/elements/user/internals/UserAvatar.styles.js.map +1 -1
- package/build/src/md/button/internals/base.d.ts +1 -1
- package/build/src/md/button/internals/base.d.ts.map +1 -1
- package/build/src/md/button/internals/base.js +2 -2
- package/build/src/md/button/internals/base.js.map +1 -1
- package/build/src/md/checkbox/internals/CheckboxElement.d.ts +1 -1
- package/build/src/md/checkbox/internals/CheckboxElement.d.ts.map +1 -1
- package/build/src/md/checkbox/internals/CheckboxElement.js +2 -2
- package/build/src/md/checkbox/internals/CheckboxElement.js.map +1 -1
- package/build/src/md/focus-ring/internals/focus-ring.d.ts +87 -0
- package/build/src/md/focus-ring/internals/focus-ring.d.ts.map +1 -0
- package/build/src/md/focus-ring/internals/focus-ring.js +206 -0
- package/build/src/md/focus-ring/internals/focus-ring.js.map +1 -0
- package/build/src/md/focus-ring/internals/focus-ring.styles.d.ts +3 -0
- package/build/src/md/focus-ring/internals/focus-ring.styles.d.ts.map +1 -0
- package/build/src/md/focus-ring/internals/focus-ring.styles.js +109 -0
- package/build/src/md/focus-ring/internals/focus-ring.styles.js.map +1 -0
- package/build/src/md/focus-ring/ui-focus-ring.d.ts +42 -0
- package/build/src/md/focus-ring/ui-focus-ring.d.ts.map +1 -0
- package/build/src/md/focus-ring/ui-focus-ring.js +58 -0
- package/build/src/md/focus-ring/ui-focus-ring.js.map +1 -0
- package/build/src/md/list/internals/ListItem.d.ts +3 -3
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +7 -6
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/menu/internal/MenuItem.d.ts +0 -2
- package/build/src/md/menu/internal/MenuItem.d.ts.map +1 -1
- package/build/src/md/menu/internal/MenuItem.js +0 -2
- package/build/src/md/menu/internal/MenuItem.js.map +1 -1
- package/build/src/md/radio/internals/Radio.styles.js +1 -1
- package/build/src/md/radio/internals/Radio.styles.js.map +1 -1
- package/build/src/md/radio/internals/RadioElement.d.ts +1 -0
- package/build/src/md/radio/internals/RadioElement.d.ts.map +1 -1
- package/build/src/md/radio/internals/RadioElement.js +2 -0
- package/build/src/md/radio/internals/RadioElement.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +1 -1
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +2 -2
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/src/md/tabs/internals/Tab.d.ts +1 -0
- package/build/src/md/tabs/internals/Tab.d.ts.map +1 -1
- package/build/src/md/tabs/internals/Tab.js +3 -2
- package/build/src/md/tabs/internals/Tab.js.map +1 -1
- package/build/src/md/tabs/internals/Tabs.js +4 -4
- package/build/src/md/tabs/internals/Tabs.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/src/elements/data-table/DataTable.ts +3 -3
- package/src/elements/file-system/internals/Breadcrumbs.ts +3 -3
- package/src/elements/navigation/internals/NavigationItem.ts +4 -2
- package/src/elements/user/internals/UserAvatar.styles.ts +6 -11
- package/src/elements/user/internals/UserAvatar.ts +115 -8
- package/src/md/button/internals/base.ts +2 -2
- package/src/md/checkbox/internals/CheckboxElement.ts +2 -2
- package/src/md/focus-ring/internals/focus-ring.styles.ts +109 -0
- package/src/md/focus-ring/internals/focus-ring.ts +184 -0
- package/src/md/focus-ring/ui-focus-ring.ts +46 -0
- package/src/md/list/internals/ListItem.ts +5 -5
- package/src/md/menu/internal/MenuItem.ts +0 -2
- package/src/md/radio/internals/Radio.styles.ts +1 -1
- package/src/md/radio/internals/RadioElement.ts +2 -0
- package/src/md/select/internals/Select.ts +2 -2
- package/src/md/tabs/internals/Tab.ts +4 -2
- package/src/md/tabs/internals/Tabs.ts +4 -4
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { html,
|
|
3
|
-
import { property, state } from 'lit/decorators.js';
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
2
|
+
import { html, svg } from 'lit';
|
|
3
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { UiElement } from '../../../md/UiElement.js';
|
|
5
|
+
import { setDisabled } from '../../../lib/disabled.js';
|
|
6
|
+
import '../../../md/focus-ring/ui-focus-ring.js';
|
|
7
|
+
import '../../../md/ripple/ui-ripple.js';
|
|
6
8
|
let UserAvatar = (() => {
|
|
7
|
-
let _classSuper =
|
|
9
|
+
let _classSuper = UiElement;
|
|
10
|
+
let _ripple_decorators;
|
|
11
|
+
let _ripple_initializers = [];
|
|
12
|
+
let _ripple_extraInitializers = [];
|
|
13
|
+
let _disabled_decorators;
|
|
14
|
+
let _disabled_initializers = [];
|
|
15
|
+
let _disabled_extraInitializers = [];
|
|
8
16
|
let _userInitials_decorators;
|
|
9
17
|
let _userInitials_initializers = [];
|
|
10
18
|
let _userInitials_extraInitializers = [];
|
|
@@ -20,25 +28,51 @@ let UserAvatar = (() => {
|
|
|
20
28
|
return class UserAvatar extends _classSuper {
|
|
21
29
|
static {
|
|
22
30
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
31
|
+
_ripple_decorators = [query('ui-ripple')];
|
|
32
|
+
_disabled_decorators = [property({ type: Boolean, reflect: true })];
|
|
23
33
|
_userInitials_decorators = [state()];
|
|
24
34
|
_userPicture_decorators = [state()];
|
|
25
35
|
_user_decorators = [property({ type: Object })];
|
|
26
36
|
_type_decorators = [property({ type: String })];
|
|
37
|
+
__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);
|
|
38
|
+
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
27
39
|
__esDecorate(this, null, _userInitials_decorators, { kind: "accessor", name: "userInitials", static: false, private: false, access: { has: obj => "userInitials" in obj, get: obj => obj.userInitials, set: (obj, value) => { obj.userInitials = value; } }, metadata: _metadata }, _userInitials_initializers, _userInitials_extraInitializers);
|
|
28
40
|
__esDecorate(this, null, _userPicture_decorators, { kind: "accessor", name: "userPicture", static: false, private: false, access: { has: obj => "userPicture" in obj, get: obj => obj.userPicture, set: (obj, value) => { obj.userPicture = value; } }, metadata: _metadata }, _userPicture_initializers, _userPicture_extraInitializers);
|
|
29
41
|
__esDecorate(this, null, _user_decorators, { kind: "accessor", name: "user", static: false, private: false, access: { has: obj => "user" in obj, get: obj => obj.user, set: (obj, value) => { obj.user = value; } }, metadata: _metadata }, _user_initializers, _user_extraInitializers);
|
|
30
42
|
__esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
31
43
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
32
44
|
}
|
|
33
|
-
#
|
|
45
|
+
#ripple_accessor_storage = __runInitializers(this, _ripple_initializers, null
|
|
46
|
+
/**
|
|
47
|
+
* Whether the avatar is disabled.
|
|
48
|
+
* @attribute
|
|
49
|
+
*/
|
|
50
|
+
);
|
|
51
|
+
get ripple() { return this.#ripple_accessor_storage; }
|
|
52
|
+
set ripple(value) { this.#ripple_accessor_storage = value; }
|
|
53
|
+
#disabled_accessor_storage = (__runInitializers(this, _ripple_extraInitializers), __runInitializers(this, _disabled_initializers, false
|
|
34
54
|
/**
|
|
35
55
|
* Set with the user. The computed user initials.
|
|
56
|
+
* @attribute
|
|
57
|
+
*/
|
|
58
|
+
));
|
|
59
|
+
/**
|
|
60
|
+
* Whether the avatar is disabled.
|
|
61
|
+
* @attribute
|
|
62
|
+
*/
|
|
63
|
+
get disabled() { return this.#disabled_accessor_storage; }
|
|
64
|
+
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
65
|
+
#userInitials_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _userInitials_initializers, void 0));
|
|
66
|
+
/**
|
|
67
|
+
* Set with the user. The computed user initials.
|
|
68
|
+
* @attribute
|
|
36
69
|
*/
|
|
37
70
|
get userInitials() { return this.#userInitials_accessor_storage; }
|
|
38
71
|
set userInitials(value) { this.#userInitials_accessor_storage = value; }
|
|
39
72
|
#userPicture_accessor_storage = (__runInitializers(this, _userInitials_extraInitializers), __runInitializers(this, _userPicture_initializers, void 0));
|
|
40
73
|
/**
|
|
41
74
|
* The URL to the user picture.
|
|
75
|
+
* @attribute
|
|
42
76
|
*/
|
|
43
77
|
get userPicture() { return this.#userPicture_accessor_storage; }
|
|
44
78
|
set userPicture(value) { this.#userPicture_accessor_storage = value; }
|
|
@@ -55,12 +89,91 @@ let UserAvatar = (() => {
|
|
|
55
89
|
*/
|
|
56
90
|
get type() { return this.#type_accessor_storage; }
|
|
57
91
|
set type(value) { this.#type_accessor_storage = value; }
|
|
92
|
+
constructor() {
|
|
93
|
+
super();
|
|
94
|
+
__runInitializers(this, _type_extraInitializers);
|
|
95
|
+
this.addEventListener('keydown', this.handleKeyDown.bind(this));
|
|
96
|
+
this.addEventListener('keyup', this.handleKeyUp.bind(this));
|
|
97
|
+
this.addEventListener('pointerenter', this.handlePointerEnter.bind(this));
|
|
98
|
+
this.addEventListener('pointerleave', this.handlePointerLeave.bind(this));
|
|
99
|
+
this.addEventListener('click', this.handleClick.bind(this));
|
|
100
|
+
this.addEventListener('pointerdown', this.handlePointerDown.bind(this));
|
|
101
|
+
this.addEventListener('pointerup', this.handlePointerUp.bind(this));
|
|
102
|
+
this.addEventListener('pointercancel', this.handlePointerCancel.bind(this));
|
|
103
|
+
this.addEventListener('contextmenu', this.handleContextMenu.bind(this));
|
|
104
|
+
}
|
|
58
105
|
willUpdate(cp) {
|
|
59
106
|
if (cp.has('user')) {
|
|
60
107
|
this.handleUserChange(this.user);
|
|
61
108
|
}
|
|
109
|
+
if (cp.has('disabled')) {
|
|
110
|
+
setDisabled(this, cp.get('disabled'));
|
|
111
|
+
}
|
|
62
112
|
super.willUpdate(cp);
|
|
63
113
|
}
|
|
114
|
+
beginPress(options) {
|
|
115
|
+
if (!this.shouldHandleInteraction()) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
super.beginPress(options);
|
|
119
|
+
this.ripple?.beginPress(options.positionEvent);
|
|
120
|
+
}
|
|
121
|
+
endPress(options) {
|
|
122
|
+
if (!this.shouldHandleInteraction()) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
super.endPress(options);
|
|
126
|
+
this.ripple?.endPress();
|
|
127
|
+
}
|
|
128
|
+
handleKeyDown(e) {
|
|
129
|
+
if (!this.shouldHandleInteraction()) {
|
|
130
|
+
e.stopPropagation();
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (e.code === 'Tab' || e.shiftKey)
|
|
135
|
+
return;
|
|
136
|
+
// do not prevent default, so that parent elements can handle the key event
|
|
137
|
+
this.beginPress({ positionEvent: e });
|
|
138
|
+
}
|
|
139
|
+
handleKeyUp(e) {
|
|
140
|
+
if (!this.shouldHandleInteraction()) {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// do not prevent default, so that parent elements can handle the key event
|
|
146
|
+
this.endPress({ cancelled: false, actionData: { item: this } });
|
|
147
|
+
}
|
|
148
|
+
handlePointerEnter(e) {
|
|
149
|
+
if (!this.shouldHandleInteraction()) {
|
|
150
|
+
e.stopPropagation();
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.ripple?.beginHover(e);
|
|
155
|
+
}
|
|
156
|
+
handlePointerLeave(e) {
|
|
157
|
+
if (!this.shouldHandleInteraction()) {
|
|
158
|
+
e.stopPropagation();
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
super.handlePointerLeave(e);
|
|
163
|
+
this.ripple?.endHover();
|
|
164
|
+
}
|
|
165
|
+
handleClick(e) {
|
|
166
|
+
super.handleClick(e);
|
|
167
|
+
if (this.disabled) {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
e.stopPropagation();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
this.endPress({ cancelled: false, actionData: { event: e } });
|
|
173
|
+
}
|
|
174
|
+
shouldHandleInteraction() {
|
|
175
|
+
return !this.disabled && this.type === 'button';
|
|
176
|
+
}
|
|
64
177
|
/**
|
|
65
178
|
* Handles changes to the user property.
|
|
66
179
|
* @param user The user object
|
|
@@ -114,10 +227,8 @@ let UserAvatar = (() => {
|
|
|
114
227
|
renderButton(content) {
|
|
115
228
|
return html `
|
|
116
229
|
<button id="button" class="icon-button">
|
|
117
|
-
|
|
118
|
-
<md-ripple></md-ripple>
|
|
230
|
+
${this.renderFocusRing()} ${this.renderRipple()}
|
|
119
231
|
<span role="presentation" class="icon">${content}</span>
|
|
120
|
-
<span class="touch"></span>
|
|
121
232
|
</button>
|
|
122
233
|
`;
|
|
123
234
|
}
|
|
@@ -161,9 +272,11 @@ let UserAvatar = (() => {
|
|
|
161
272
|
</svg>
|
|
162
273
|
`;
|
|
163
274
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
275
|
+
renderRipple() {
|
|
276
|
+
return html `<ui-ripple class="ripple" ?disabled="${this.disabled}"></ui-ripple>`;
|
|
277
|
+
}
|
|
278
|
+
renderFocusRing() {
|
|
279
|
+
return html `<ui-focus-ring part="focus-ring" for="button"></ui-focus-ring>`;
|
|
167
280
|
}
|
|
168
281
|
};
|
|
169
282
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.js","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkB,UAAU,EAAqC,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9F,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,sCAAsC,CAAA;AAC7C,OAAO,gCAAgC,CAAA;;sBAIC,UAAU;;;;;;;;;;;;;iBAA7B,UAAW,SAAQ,WAAU;;;wCAI/C,KAAK,EAAE;uCAKP,KAAK,EAAE;gCAKP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE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O,SAAS,CAAA;QACvE,CAAC;QAES,eAAe,CAAC,GAAW;YACnC,OAAO,IAAI,CAAA;;eAEA,GAAG;eACH,IAAI,CAAC,YAAY,IAAI,OAAO;;kBAEzB,IAAI,CAAC,kBAAkB;;KAEpC,CAAA;QACH,CAAC;QAED;;;WAGG;QACO,YAAY,CAAC,QAAgB;YACrC,OAAO,IAAI,CAAA,4CAA4C,QAAQ,UAAU,CAAA;QAC3E,CAAC;QAES,mBAAmB;YAC3B,OAAO,IAAI,CAAA,sCAAsC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAA;QAC/E,CAAC;QAES,WAAW;YACnB,OAAO,GAAG,CAAA;;;;;;;;;;;;;;KAcT,CAAA;QACH,CAAC;;;;;;;AArIH,0BAsIC","sourcesContent":["import { html, TemplateResult, LitElement, PropertyValues, SVGTemplateResult, svg } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport type { IUser } from '@api-client/core/models/store/User.js'\nimport '@material/web/focus/md-focus-ring.js'\nimport '@material/web/ripple/ripple.js'\n\nexport type AvatarType = 'button' | 'icon'\n\nexport default class UserAvatar extends LitElement {\n /**\n * Set with the user. The computed user initials.\n */\n @state() protected accessor userInitials: string | undefined\n\n /**\n * The URL to the user picture.\n */\n @state() protected accessor userPicture: string | undefined\n\n /**\n * The user object to display the avatar for.\n */\n @property({ type: Object }) accessor user: IUser | undefined\n /**\n * The type of avatar to render, either 'button' or 'icon'.\n * @attribute\n */\n @property({ type: String }) accessor type: AvatarType = 'button'\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('user')) {\n this.handleUserChange(this.user)\n }\n super.willUpdate(cp)\n }\n\n /**\n * Handles changes to the user property.\n * @param user The user object\n */\n protected handleUserChange(user?: IUser): void {\n if (user) {\n this.userInitials = this.readUserInitials(user)\n this.userPicture = user.picture && user.picture.url\n } else {\n this.userInitials = undefined\n this.userPicture = undefined\n }\n }\n\n protected readUserInitials(user: IUser): string | undefined {\n const { name } = user\n if (!name) {\n return undefined\n }\n const max = 2\n const parts = name\n .split(/[\\s-]/)\n .slice(0, max)\n .filter((i) => !!i)\n .map((i) => i[0])\n return parts.join('')\n }\n\n protected handlePictureError(): void {\n this.userPicture = undefined\n }\n\n /**\n * @return Template result for an icon\n */\n override render(): TemplateResult {\n const { userPicture } = this\n let content: TemplateResult\n if (userPicture) {\n content = this.pictureTemplate(userPicture)\n } else if (this.userInitials) {\n content = this.nameTemplate(this.userInitials)\n } else {\n content = this.renderDefaultAvatar()\n }\n if (this.type === 'icon') {\n return this.renderIcon(content)\n }\n return this.renderButton(content)\n }\n\n protected renderButton(content: TemplateResult): TemplateResult {\n return html`\n <button id=\"button\" class=\"icon-button\">\n <md-focus-ring part=\"focus-ring\" for=\"button\"></md-focus-ring>\n <md-ripple></md-ripple>\n <span role=\"presentation\" class=\"icon\">${content}</span>\n <span class=\"touch\"></span>\n </button>\n `\n }\n\n protected renderIcon(content: TemplateResult): TemplateResult {\n return html`<span role=\"presentation\" class=\"icon\">${content}</span>`\n }\n\n protected pictureTemplate(url: string): TemplateResult {\n return html`\n <img\n src=\"${url}\"\n alt=\"${this.userInitials || 'Thumb'}\"\n class=\"user-picture user-icon\"\n @error=\"${this.handlePictureError}\"\n />\n `\n }\n\n /**\n * Renders a bubble with user initials\n * @param initials The user initials\n */\n protected nameTemplate(initials: string): TemplateResult {\n return html` <span class=\"avatar-initials user-icon\">${initials}</span> `\n }\n\n protected renderDefaultAvatar(): TemplateResult {\n return html`<span class=\"avatar-default icon\"> ${this.defaultIcon()} </span>`\n }\n\n protected defaultIcon(): SVGTemplateResult {\n return svg`\n <svg viewBox=\"0 0 120 120\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" class=\"icon\">\n <rect width=\"120\" height=\"120\" rx=\"60\" class=\"avatar-background\" />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M78.0007 48C78.0007 57.9411 69.9419 66 60.0007 66C50.0596 66 42.0007 57.9411 42.0007 48C42.0007 38.0589 50.0596 30 60.0007 30C69.9419 30 78.0007 38.0589 78.0007 48ZM72.0007 48C72.0007 54.6274 66.6282 60 60.0007 60C53.3733 60 48.0007 54.6274 48.0007 48C48.0007 41.3726 53.3733 36 60.0007 36C66.6282 36 72.0007 41.3726 72.0007 48Z\"\n class=\"avatar-lines\"\n />\n <path\n d=\"M60.0007 75C40.5776 75 24.0286 86.4852 17.7246 102.576C19.2603 104.101 20.878 105.543 22.5706 106.896C27.2648 92.1231 41.9909 81 60.0007 81C78.0106 81 92.7367 92.1231 97.4309 106.896C99.1235 105.544 100.741 104.101 102.277 102.576C95.973 86.4853 79.4239 75 60.0007 75Z\"\n class=\"avatar-lines\"\n />\n </svg>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserAvatar.js","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAqD,GAAG,EAAE,MAAM,KAAK,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAItD,OAAO,yCAAyC,CAAA;AAChD,OAAO,iCAAiC,CAAA;;sBAIA,SAAS;;;;;;;;;;;;;;;;;;;iBAA5B,UAAW,SAAQ,WAAS;;;kCAC9C,KAAK,CAAC,WAAW,CAAC;oCAKlB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAK1C,KAAK,EAAE;uCAMP,KAAK,EAAE;gCAKP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YA1BP,uKAAS,MAAM,6BAAN,MAAM,uFAAwB;YAKf,6KAAS,QAA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AI,OAAO;;kBAEzB,IAAI,CAAC,kBAAkB;;KAEpC,CAAA;QACH,CAAC;QAED;;;WAGG;QACO,YAAY,CAAC,QAAgB;YACrC,OAAO,IAAI,CAAA,4CAA4C,QAAQ,UAAU,CAAA;QAC3E,CAAC;QAES,mBAAmB;YAC3B,OAAO,IAAI,CAAA,sCAAsC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAA;QAC/E,CAAC;QAES,WAAW;YACnB,OAAO,GAAG,CAAA;;;;;;;;;;;;;;KAcT,CAAA;QACH,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,gEAAgE,CAAA;QAC7E,CAAC;;;AA5OH,0BA6OC","sourcesContent":["import { html, TemplateResult, PropertyValues, SVGTemplateResult, svg } from 'lit'\nimport { property, query, state } from 'lit/decorators.js'\nimport { UiElement } from '../../../md/UiElement.js'\nimport { setDisabled } from '../../../lib/disabled.js'\nimport type { IUser } from '@api-client/core/models/store/User.js'\nimport type UiRipple from '../../../md/ripple/internals/ripple.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport '../../../md/focus-ring/ui-focus-ring.js'\nimport '../../../md/ripple/ui-ripple.js'\n\nexport type AvatarType = 'button' | 'icon'\n\nexport default class UserAvatar extends UiElement {\n @query('ui-ripple') accessor ripple: UiRipple | null = null\n /**\n * Whether the avatar is disabled.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor disabled = false\n /**\n * Set with the user. The computed user initials.\n * @attribute\n */\n @state() protected accessor userInitials: string | undefined\n\n /**\n * The URL to the user picture.\n * @attribute\n */\n @state() protected accessor userPicture: string | undefined\n\n /**\n * The user object to display the avatar for.\n */\n @property({ type: Object }) accessor user: IUser | undefined\n /**\n * The type of avatar to render, either 'button' or 'icon'.\n * @attribute\n */\n @property({ type: String }) accessor type: AvatarType = 'button'\n\n constructor() {\n super()\n\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.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('contextmenu', this.handleContextMenu.bind(this))\n }\n\n protected override willUpdate(cp: PropertyValues<this>): void {\n if (cp.has('user')) {\n this.handleUserChange(this.user)\n }\n if (cp.has('disabled')) {\n setDisabled(this, cp.get('disabled'))\n }\n super.willUpdate(cp)\n }\n\n override beginPress(options: BeginPressConfig): void {\n if (!this.shouldHandleInteraction()) {\n return\n }\n super.beginPress(options)\n this.ripple?.beginPress(options.positionEvent)\n }\n\n override endPress(options: EndPressConfig): void {\n if (!this.shouldHandleInteraction()) {\n return\n }\n super.endPress(options)\n this.ripple?.endPress()\n }\n\n override handleKeyDown(e: KeyboardEvent): void {\n if (!this.shouldHandleInteraction()) {\n e.stopPropagation()\n e.preventDefault()\n return\n }\n if (e.code === 'Tab' || e.shiftKey) return\n // do not prevent default, so that parent elements can handle the key event\n this.beginPress({ positionEvent: e })\n }\n\n override handleKeyUp(e: KeyboardEvent): void {\n if (!this.shouldHandleInteraction()) {\n e.stopPropagation()\n e.preventDefault()\n return\n }\n\n // do not prevent default, so that parent elements can handle the key event\n this.endPress({ cancelled: false, actionData: { item: this } })\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n if (!this.shouldHandleInteraction()) {\n e.stopPropagation()\n e.preventDefault()\n return\n }\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n if (!this.shouldHandleInteraction()) {\n e.stopPropagation()\n e.preventDefault()\n return\n }\n super.handlePointerLeave(e)\n\n this.ripple?.endHover()\n }\n\n override handleClick(e: MouseEvent): void {\n super.handleClick(e)\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n this.endPress({ cancelled: false, actionData: { event: e } })\n }\n\n protected shouldHandleInteraction(): boolean {\n return !this.disabled && this.type === 'button'\n }\n\n /**\n * Handles changes to the user property.\n * @param user The user object\n */\n protected handleUserChange(user?: IUser): void {\n if (user) {\n this.userInitials = this.readUserInitials(user)\n this.userPicture = user.picture && user.picture.url\n } else {\n this.userInitials = undefined\n this.userPicture = undefined\n }\n }\n\n protected readUserInitials(user: IUser): string | undefined {\n const { name } = user\n if (!name) {\n return undefined\n }\n const max = 2\n const parts = name\n .split(/[\\s-]/)\n .slice(0, max)\n .filter((i) => !!i)\n .map((i) => i[0])\n return parts.join('')\n }\n\n protected handlePictureError(): void {\n this.userPicture = undefined\n }\n\n /**\n * @return Template result for an icon\n */\n override render(): TemplateResult {\n const { userPicture } = this\n let content: TemplateResult\n if (userPicture) {\n content = this.pictureTemplate(userPicture)\n } else if (this.userInitials) {\n content = this.nameTemplate(this.userInitials)\n } else {\n content = this.renderDefaultAvatar()\n }\n if (this.type === 'icon') {\n return this.renderIcon(content)\n }\n return this.renderButton(content)\n }\n\n protected renderButton(content: TemplateResult): TemplateResult {\n return html`\n <button id=\"button\" class=\"icon-button\">\n ${this.renderFocusRing()} ${this.renderRipple()}\n <span role=\"presentation\" class=\"icon\">${content}</span>\n </button>\n `\n }\n\n protected renderIcon(content: TemplateResult): TemplateResult {\n return html`<span role=\"presentation\" class=\"icon\">${content}</span>`\n }\n\n protected pictureTemplate(url: string): TemplateResult {\n return html`\n <img\n src=\"${url}\"\n alt=\"${this.userInitials || 'Thumb'}\"\n class=\"user-picture user-icon\"\n @error=\"${this.handlePictureError}\"\n />\n `\n }\n\n /**\n * Renders a bubble with user initials\n * @param initials The user initials\n */\n protected nameTemplate(initials: string): TemplateResult {\n return html` <span class=\"avatar-initials user-icon\">${initials}</span> `\n }\n\n protected renderDefaultAvatar(): TemplateResult {\n return html`<span class=\"avatar-default icon\"> ${this.defaultIcon()} </span>`\n }\n\n protected defaultIcon(): SVGTemplateResult {\n return svg`\n <svg viewBox=\"0 0 120 120\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" class=\"icon\">\n <rect width=\"120\" height=\"120\" rx=\"60\" class=\"avatar-background\" />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M78.0007 48C78.0007 57.9411 69.9419 66 60.0007 66C50.0596 66 42.0007 57.9411 42.0007 48C42.0007 38.0589 50.0596 30 60.0007 30C69.9419 30 78.0007 38.0589 78.0007 48ZM72.0007 48C72.0007 54.6274 66.6282 60 60.0007 60C53.3733 60 48.0007 54.6274 48.0007 48C48.0007 41.3726 53.3733 36 60.0007 36C66.6282 36 72.0007 41.3726 72.0007 48Z\"\n class=\"avatar-lines\"\n />\n <path\n d=\"M60.0007 75C40.5776 75 24.0286 86.4852 17.7246 102.576C19.2603 104.101 20.878 105.543 22.5706 106.896C27.2648 92.1231 41.9909 81 60.0007 81C78.0106 81 92.7367 92.1231 97.4309 106.896C99.1235 105.544 100.741 104.101 102.277 102.576C95.973 86.4853 79.4239 75 60.0007 75Z\"\n class=\"avatar-lines\"\n />\n </svg>\n `\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring part=\"focus-ring\" for=\"button\"></ui-focus-ring>`\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.styles.d.ts","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.styles.ts"],"names":[],"mappings":";AAEA,
|
|
1
|
+
{"version":3,"file":"UserAvatar.styles.d.ts","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.styles.ts"],"names":[],"mappings":";AAEA,wBA6GC"}
|
|
@@ -43,10 +43,10 @@ export default css `
|
|
|
43
43
|
z-index: 0;
|
|
44
44
|
flex: 1;
|
|
45
45
|
border-radius: var(--_state-layer-shape);
|
|
46
|
-
|
|
47
|
-
--md-ripple-hover-
|
|
48
|
-
--md-ripple-
|
|
49
|
-
--md-ripple-pressed-
|
|
46
|
+
|
|
47
|
+
--md-ripple-hover-state-layer-color: var(--md-sys-color-primary);
|
|
48
|
+
--md-ripple-focus-state-layer-color: var(--md-sys-color-primary);
|
|
49
|
+
--md-ripple-pressed-state-layer-color: var(--md-sys-color-on-surface);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
.icon-button:hover {
|
|
@@ -68,8 +68,9 @@ export default css `
|
|
|
68
68
|
--md-focus-ring-shape-end-start: var(--_state-layer-shape);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
.ripple {
|
|
72
72
|
border-radius: var(--_state-layer-shape);
|
|
73
|
+
z-index: 1;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
.icon {
|
|
@@ -78,12 +79,6 @@ export default css `
|
|
|
78
79
|
overflow: hidden;
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
.touch {
|
|
82
|
-
position: absolute;
|
|
83
|
-
height: max(48px, 100%);
|
|
84
|
-
width: max(48px, 100%);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
82
|
.user-icon,
|
|
88
83
|
.avatar-initials {
|
|
89
84
|
background-color: var(--md-sys-color-primary-container, #9eeffe);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.styles.js","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"UserAvatar.styles.js","sourceRoot":"","sources":["../../../../../src/elements/user/internals/UserAvatar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,eAAe,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6GjB,CAAA","sourcesContent":["import { css } from 'lit'\n\nexport default css`\n :host {\n display: inline-flex;\n outline: none;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n justify-content: center;\n height: 40px;\n width: 40px;\n\n --_focus-icon-color: var(--md-icon-button-focus-icon-color, var(--md-sys-color-on-surface-variant, #49454f));\n --_hover-icon-color: var(--md-icon-button-hover-icon-color, var(--md-sys-color-on-surface-variant, #49454f));\n --_hover-state-layer-color: var(\n --md-icon-button-hover-state-layer-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n );\n --_hover-state-layer-opacity: var(--md-icon-button-hover-state-layer-opacity, 0.08);\n --_icon-color: var(--md-icon-button-icon-color, var(--md-sys-color-on-surface-variant, #49454f));\n --_pressed-icon-color: var(--md-icon-button-pressed-icon-color, var(--md-sys-color-on-surface-variant, #49454f));\n --_pressed-state-layer-color: var(\n --md-icon-button-pressed-state-layer-color,\n var(--md-sys-color-on-surface-variant, #49454f)\n );\n --_pressed-state-layer-opacity: var(--md-icon-button-pressed-state-layer-opacity, 0.12);\n --_state-layer-shape: var(--md-icon-button-state-layer-shape, var(--md-sys-shape-corner-full, 9999px));\n }\n\n .icon-button {\n background-color: rgba(0, 0, 0, 0);\n color: var(--_icon-color);\n place-items: center;\n background: none;\n border: none;\n box-sizing: border-box;\n cursor: pointer;\n display: flex;\n place-content: center;\n outline: none;\n padding: 0;\n position: relative;\n text-decoration: none;\n user-select: none;\n z-index: 0;\n flex: 1;\n border-radius: var(--_state-layer-shape);\n\n --md-ripple-hover-state-layer-color: var(--md-sys-color-primary);\n --md-ripple-focus-state-layer-color: var(--md-sys-color-primary);\n --md-ripple-pressed-state-layer-color: var(--md-sys-color-on-surface);\n }\n\n .icon-button:hover {\n color: var(--_hover-icon-color);\n }\n\n .icon-button:focus {\n color: var(--_focus-icon-color);\n }\n\n .icon-button:active {\n color: var(--_pressed-icon-color);\n }\n\n md-focus-ring {\n --md-focus-ring-shape-start-start: var(--_state-layer-shape);\n --md-focus-ring-shape-start-end: var(--_state-layer-shape);\n --md-focus-ring-shape-end-end: var(--_state-layer-shape);\n --md-focus-ring-shape-end-start: var(--_state-layer-shape);\n }\n\n .ripple {\n border-radius: var(--_state-layer-shape);\n z-index: 1;\n }\n\n .icon {\n display: inline-flex;\n border-radius: var(--_state-layer-shape);\n overflow: hidden;\n }\n\n .user-icon,\n .avatar-initials {\n background-color: var(--md-sys-color-primary-container, #9eeffe);\n color: var(--md-sys-color-on-primary-container, #001f24);\n }\n\n .avatar-initials {\n text-transform: uppercase;\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .user-icon,\n .icon-button,\n .icon {\n height: inherit;\n width: inherit;\n }\n\n .avatar-background {\n fill: var(--md-sys-color-primary-container, #9eeffe);\n }\n\n .avatar-lines {\n fill: var(--md-sys-color-on-primary-container, #001f24);\n }\n`\n"]}
|
|
@@ -3,7 +3,7 @@ import { UiElement } from '../../UiElement.js';
|
|
|
3
3
|
import type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js';
|
|
4
4
|
import type UiRipple from '../../ripple/internals/ripple.js';
|
|
5
5
|
import '../../ripple/ui-ripple.js';
|
|
6
|
-
import '
|
|
6
|
+
import '../../focus-ring/ui-focus-ring.js';
|
|
7
7
|
export type ButtonType = 'submit' | 'reset' | 'button';
|
|
8
8
|
export type MdButtonShape = 'round' | 'square';
|
|
9
9
|
export type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,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rC,SAAS,CAAC,YAAY,IAAI,IAAI;IA6B9B,SAAS,CAAC,WAAW,IAAI,IAAI;IAKpB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKzC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;cAK/B,MAAM,IAAI,cAAc;IAW3C,SAAS,CAAC,UAAU,IAAI,cAAc;IAItC,SAAS,CAAC,eAAe,IAAI,cAAc;IAI3C,SAAS,CAAC,YAAY,IAAI,cAAc;CAGzC"}
|
|
@@ -6,7 +6,7 @@ import { UiElement } from '../../UiElement.js';
|
|
|
6
6
|
import { isDisabled, setDisabled } from '../../../lib/disabled.js';
|
|
7
7
|
import { findElementInShadowRoots } from '../../../lib/Dom.js';
|
|
8
8
|
import '../../ripple/ui-ripple.js';
|
|
9
|
-
import '
|
|
9
|
+
import '../../focus-ring/ui-focus-ring.js';
|
|
10
10
|
let BaseButton = (() => {
|
|
11
11
|
let _classSuper = UiElement;
|
|
12
12
|
let _instanceExtraInitializers = [];
|
|
@@ -423,7 +423,7 @@ let BaseButton = (() => {
|
|
|
423
423
|
return html `<slot name="icon"></slot>`;
|
|
424
424
|
}
|
|
425
425
|
renderFocusRing() {
|
|
426
|
-
return html `<
|
|
426
|
+
return html `<ui-focus-ring part="focus-ring" class="focus-ring" .control="${this}"></ui-focus-ring>`;
|
|
427
427
|
}
|
|
428
428
|
renderRipple() {
|
|
429
429
|
return html `<ui-ripple class="ripple" ?disabled="${this.disabled}"></ui-ripple>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE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IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,iEAAiE,IAAmB,oBAAoB,CAAA;QACrH,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AAzWH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { nanoid } from 'nanoid'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\nimport { findElementInShadowRoots } from '../../../lib/Dom.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '@material/web/focus/md-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in 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 }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n /**\n * Turns a `<ui-button>` element into a popover control button; takes the ID\n * of the popover element to control as its value.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor popoverTarget: string | undefined\n /**\n * Specifies the action to be performed on a popover element being controlled\n * by a control <ui-button>. Possible values are:\n *\n * - `hide` - The button will hide a shown popover. If you try to hide an already hidden popover,\n * no action will be taken.\n * - `show` - The button will show a hidden popover. If you try to show an already showing popover,\n * no action will be taken.\n * - `toggle` - The button will toggle a popover between showing and hidden. If the popover is hidden,\n * it will be shown; if the popover is showing, it will be hidden. If popoverTargetAction is omitted,\n * \"toggle\" is the default action that will be performed by the control button.\n */\n @property({ type: String, reflect: true }) accessor popoverTargetAction: string | undefined\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.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('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override update(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('popoverTarget')) {\n this.setupPopoverTarget()\n }\n super.update(changedProperties)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (this.type === 'reset' && (!reason || allowedReasons)) {\n this.handleReset()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n // Do not call super.handleClick() here, as it would call `endPress` again.\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.handlePopoverAction()\n this.endPress({ cancelled: false, actionData: { event: e } })\n }\n\n protected setupPopoverTarget(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n // A regular button first sets its value to the popover target ID,\n this.value = id\n // create an anchor association with the popover target\n if (!this.id) {\n this.id = nanoid()\n }\n const anchorName = `--anchor-${this.id}`\n this.style.setProperty('anchor-name', anchorName)\n element.style.setProperty('position-anchor', anchorName)\n this.setAttribute('aria-details', id)\n this.setAttribute('aria-controls', id)\n }\n\n /**\n * When the button has a popover target, this method toggles the popover\n * visibility by finding the element in the shadow roots and calling its\n * `togglePopover` method.\n */\n protected handlePopoverAction(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n const action = this.popoverTargetAction || 'toggle'\n if (action === 'hide') {\n element.hidePopover()\n } else if (action === 'show') {\n element.showPopover()\n } else {\n element.togglePopover()\n }\n element.focus()\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n protected handleReset(): void {\n const form = this.form as HTMLFormElement\n form?.reset()\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<md-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></md-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,MAAM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G,KAAK,EAAE,GAAG,IAAI,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA,iEAAiE,IAAmB,oBAAoB,CAAA;QACrH,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AAzWH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { nanoid } from 'nanoid'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\nimport { findElementInShadowRoots } from '../../../lib/Dom.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '../../focus-ring/ui-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in 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 }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n /**\n * Turns a `<ui-button>` element into a popover control button; takes the ID\n * of the popover element to control as its value.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor popoverTarget: string | undefined\n /**\n * Specifies the action to be performed on a popover element being controlled\n * by a control <ui-button>. Possible values are:\n *\n * - `hide` - The button will hide a shown popover. If you try to hide an already hidden popover,\n * no action will be taken.\n * - `show` - The button will show a hidden popover. If you try to show an already showing popover,\n * no action will be taken.\n * - `toggle` - The button will toggle a popover between showing and hidden. If the popover is hidden,\n * it will be shown; if the popover is showing, it will be hidden. If popoverTargetAction is omitted,\n * \"toggle\" is the default action that will be performed by the control button.\n */\n @property({ type: String, reflect: true }) accessor popoverTargetAction: string | undefined\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.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('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override update(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('popoverTarget')) {\n this.setupPopoverTarget()\n }\n super.update(changedProperties)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (this.type === 'reset' && (!reason || allowedReasons)) {\n this.handleReset()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n // Do not call super.handleClick() here, as it would call `endPress` again.\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.handlePopoverAction()\n this.endPress({ cancelled: false, actionData: { event: e } })\n }\n\n protected setupPopoverTarget(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n // A regular button first sets its value to the popover target ID,\n this.value = id\n // create an anchor association with the popover target\n if (!this.id) {\n this.id = nanoid()\n }\n const anchorName = `--anchor-${this.id}`\n this.style.setProperty('anchor-name', anchorName)\n element.style.setProperty('position-anchor', anchorName)\n this.setAttribute('aria-details', id)\n this.setAttribute('aria-controls', id)\n }\n\n /**\n * When the button has a popover target, this method toggles the popover\n * visibility by finding the element in the shadow roots and calling its\n * `togglePopover` method.\n */\n protected handlePopoverAction(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n const action = this.popoverTargetAction || 'toggle'\n if (action === 'hide') {\n element.hidePopover()\n } else if (action === 'show') {\n element.showPopover()\n } else {\n element.togglePopover()\n }\n element.focus()\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n protected handleReset(): void {\n const form = this.form as HTMLFormElement\n form?.reset()\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring part=\"focus-ring\" class=\"focus-ring\" .control=\"${this as HTMLElement}\"></ui-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import CheckedElement from './CheckedElement.js';
|
|
|
3
3
|
import type UiRipple from '../../ripple/internals/ripple.js';
|
|
4
4
|
import type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js';
|
|
5
5
|
import '../../ripple/ui-ripple.js';
|
|
6
|
-
import '
|
|
6
|
+
import '../../focus-ring/ui-focus-ring.js';
|
|
7
7
|
export default class CheckboxElement extends CheckedElement {
|
|
8
8
|
protected get _icon(): SVGTemplateResult | typeof nothing;
|
|
9
9
|
protected accessor ripple: UiRipple | null;
|
|
@@ -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;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,
|
|
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,mCAAmC,CAAA;AAE1C,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"}
|
|
@@ -5,7 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
5
5
|
import CheckedElement from './CheckedElement.js';
|
|
6
6
|
import { check, checkIndeterminate } from '../../icons/Icons.js';
|
|
7
7
|
import '../../ripple/ui-ripple.js';
|
|
8
|
-
import '
|
|
8
|
+
import '../../focus-ring/ui-focus-ring.js';
|
|
9
9
|
let CheckboxElement = (() => {
|
|
10
10
|
let _classSuper = CheckedElement;
|
|
11
11
|
let _ripple_decorators;
|
|
@@ -79,7 +79,7 @@ let CheckboxElement = (() => {
|
|
|
79
79
|
pressed,
|
|
80
80
|
});
|
|
81
81
|
return html `
|
|
82
|
-
<
|
|
82
|
+
<ui-focus-ring part="focus-ring" .control="${this}"></ui-focus-ring>
|
|
83
83
|
<div class="${containerClasses}">
|
|
84
84
|
<div class="container"></div>
|
|
85
85
|
<div class="state"></div>
|
|
@@ -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,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,cAAc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;YACvB,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;YAChC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;gBAChC,OAAO,EAAE,IAAI;gBACb,OAAO;aACR,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 '../../focus-ring/ui-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 <ui-focus-ring part=\"focus-ring\" .control=\"${this as HTMLElement}\"></ui-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"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* A focus ring component that provides a visible focus indicator.
|
|
4
|
+
* This component automatically manages the visibility of the focus ring
|
|
5
|
+
* based on the focus state of its control element.
|
|
6
|
+
*
|
|
7
|
+
* @fires visibility-changed - Dispatched when the focus ring visibility changes.
|
|
8
|
+
* - `detail`: An object with a `visible` property (boolean).
|
|
9
|
+
*/
|
|
10
|
+
export default class UiFocusRing extends LitElement {
|
|
11
|
+
/**
|
|
12
|
+
* The control element that this focus ring is associated with.
|
|
13
|
+
* When the control gains or loses focus, the focus ring will show or hide.
|
|
14
|
+
*/
|
|
15
|
+
accessor control: HTMLElement | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* An element to attach the focus ring to. Defaults to the parent element.
|
|
18
|
+
* This is typically used when the focus ring should be positioned relative
|
|
19
|
+
* to a different element than the control.
|
|
20
|
+
*/
|
|
21
|
+
accessor attach: HTMLElement | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* An ID of an element that this focus ring is for.
|
|
24
|
+
* Alternative to setting the `control` property directly.
|
|
25
|
+
* @attribute
|
|
26
|
+
*/
|
|
27
|
+
accessor for: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the focus ring should render inward instead of outward.
|
|
30
|
+
* When true, the focus ring will be positioned inside the control bounds.
|
|
31
|
+
* @attribute
|
|
32
|
+
*/
|
|
33
|
+
accessor inward: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The internal visibility state of the focus ring.
|
|
36
|
+
*/
|
|
37
|
+
accessor visible: boolean;
|
|
38
|
+
private abortController?;
|
|
39
|
+
constructor();
|
|
40
|
+
connectedCallback(): void;
|
|
41
|
+
disconnectedCallback(): void;
|
|
42
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
43
|
+
/**
|
|
44
|
+
* Sets up the control element and event listeners.
|
|
45
|
+
*/
|
|
46
|
+
private setupControl;
|
|
47
|
+
/**
|
|
48
|
+
* Cleans up event listeners.
|
|
49
|
+
*/
|
|
50
|
+
private cleanupListeners;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the control element from either the `control` property,
|
|
53
|
+
* the `for` attribute, or defaults to the parent element.
|
|
54
|
+
*/
|
|
55
|
+
private getControl;
|
|
56
|
+
/**
|
|
57
|
+
* Handles focus events from the control element.
|
|
58
|
+
*/
|
|
59
|
+
private handleFocus;
|
|
60
|
+
/**
|
|
61
|
+
* Handles blur events from the control element.
|
|
62
|
+
*/
|
|
63
|
+
private handleBlur;
|
|
64
|
+
/**
|
|
65
|
+
* Handles pointer down events to hide focus ring during mouse interaction.
|
|
66
|
+
*/
|
|
67
|
+
private handlePointerDown;
|
|
68
|
+
/**
|
|
69
|
+
* Determines if the focus ring should be shown based on the focus event.
|
|
70
|
+
* The focus ring should only show for keyboard navigation, not mouse clicks.
|
|
71
|
+
*/
|
|
72
|
+
private shouldShowFocusRing;
|
|
73
|
+
/**
|
|
74
|
+
* Shows the focus ring.
|
|
75
|
+
*/
|
|
76
|
+
show(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Hides the focus ring.
|
|
79
|
+
*/
|
|
80
|
+
hide(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Handles the visibility changed event.
|
|
83
|
+
*/
|
|
84
|
+
private onVisibilityChanged;
|
|
85
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=focus-ring.d.ts.map
|