@material/web 2.5.0 → 2.5.1-nightly.efaa189.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +2220 -838
- package/labs/gb/components/appbar/_app-bar-tokens.scss +136 -0
- package/labs/gb/components/appbar/app-bar-element.d.ts +53 -0
- package/labs/gb/components/appbar/app-bar-element.js +144 -0
- package/labs/gb/components/appbar/app-bar-element.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.css +4 -0
- package/labs/gb/components/appbar/app-bar.css.map +1 -0
- package/labs/gb/components/appbar/app-bar.cssresult.d.ts +3 -0
- package/labs/gb/components/appbar/app-bar.cssresult.js +14 -0
- package/labs/gb/components/appbar/app-bar.cssresult.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.d.ts +71 -0
- package/labs/gb/components/appbar/app-bar.js +96 -0
- package/labs/gb/components/appbar/app-bar.js.map +1 -0
- package/labs/gb/components/appbar/app-bar.scss +167 -0
- package/labs/gb/components/appbar/md-gb-app-bar.d.ts +12 -0
- package/labs/gb/components/appbar/md-gb-app-bar.js +8 -0
- package/labs/gb/components/appbar/md-gb-app-bar.js.map +1 -0
- package/labs/gb/components/chip/_chip-tokens.scss +167 -0
- package/labs/gb/components/chip/chip-element.d.ts +73 -0
- package/labs/gb/components/chip/chip-element.js +233 -0
- package/labs/gb/components/chip/chip-element.js.map +1 -0
- package/labs/gb/components/chip/chip.css +4 -0
- package/labs/gb/components/chip/chip.css.map +1 -0
- package/labs/gb/components/chip/chip.cssresult.d.ts +3 -0
- package/labs/gb/components/chip/chip.cssresult.js +14 -0
- package/labs/gb/components/chip/chip.cssresult.js.map +1 -0
- package/labs/gb/components/chip/chip.d.ts +77 -0
- package/labs/gb/components/chip/chip.js +99 -0
- package/labs/gb/components/chip/chip.js.map +1 -0
- package/labs/gb/components/chip/chip.scss +97 -0
- package/labs/gb/components/chip/md-gb-chip.d.ts +13 -0
- package/labs/gb/components/chip/md-gb-chip.js +9 -0
- package/labs/gb/components/chip/md-gb-chip.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2026 Google LLC
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// go/keep-sorted start by_regex='(.+) prefix_order=sass:
|
|
7
|
+
@use 'app-bar-tokens';
|
|
8
|
+
// go/keep-sorted end
|
|
9
|
+
|
|
10
|
+
@layer md.sys;
|
|
11
|
+
@layer md.comp.app-bar {
|
|
12
|
+
// Component tokens
|
|
13
|
+
.app-bar {
|
|
14
|
+
@include app-bar-tokens.root;
|
|
15
|
+
}
|
|
16
|
+
.app-bar-md {
|
|
17
|
+
@include app-bar-tokens.medium;
|
|
18
|
+
}
|
|
19
|
+
.app-bar-lg {
|
|
20
|
+
@include app-bar-tokens.large;
|
|
21
|
+
}
|
|
22
|
+
.app-bar-with-subtitle {
|
|
23
|
+
@include app-bar-tokens.with-subtitle;
|
|
24
|
+
}
|
|
25
|
+
.app-bar-with-subtitle.app-bar-lg {
|
|
26
|
+
@include app-bar-tokens.with-subtitle-large;
|
|
27
|
+
}
|
|
28
|
+
.app-bar-search {
|
|
29
|
+
@include app-bar-tokens.search;
|
|
30
|
+
}
|
|
31
|
+
.app-bar-scrolled {
|
|
32
|
+
@include app-bar-tokens.on-scroll;
|
|
33
|
+
}
|
|
34
|
+
.app-bar-scrolled.app-bar-search {
|
|
35
|
+
@include app-bar-tokens.on-scroll-search;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Component styles
|
|
39
|
+
.app-bar {
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
display: flex;
|
|
42
|
+
position: relative;
|
|
43
|
+
width: 100%;
|
|
44
|
+
min-height: var(--container-height);
|
|
45
|
+
background-color: var(--container-color);
|
|
46
|
+
border-radius: var(--container-shape);
|
|
47
|
+
box-shadow: var(--container-elevation);
|
|
48
|
+
color: var(--title-color);
|
|
49
|
+
transition:
|
|
50
|
+
background-color 200ms ease,
|
|
51
|
+
box-shadow 200ms ease,
|
|
52
|
+
min-height 200ms ease;
|
|
53
|
+
padding-inline: var(--leading-space) var(--trailing-space);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Small and Search layouts (single row)
|
|
57
|
+
.app-bar-sm,
|
|
58
|
+
.app-bar-search {
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Medium and Large layouts (two rows)
|
|
65
|
+
.app-bar-md,
|
|
66
|
+
.app-bar-lg {
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
align-items: stretch;
|
|
70
|
+
|
|
71
|
+
.app-bar-top-row {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: row;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
min-height: 64px;
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.app-bar-bottom-row {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
justify-content: flex-end;
|
|
84
|
+
padding-bottom: 24px;
|
|
85
|
+
padding-inline: 12px;
|
|
86
|
+
flex: 1 1 auto;
|
|
87
|
+
min-height: 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Slot containers
|
|
92
|
+
.app-bar-leading,
|
|
93
|
+
.app-bar-trailing {
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: var(--icon-button-space);
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.app-bar-leading {
|
|
101
|
+
color: var(--leading-icon-color);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.app-bar-trailing {
|
|
105
|
+
color: var(--trailing-icon-color);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.app-bar-title-wrapper {
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
flex: 1 1 auto;
|
|
113
|
+
min-width: 0;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.app-bar-sm .app-bar-title-wrapper {
|
|
118
|
+
margin-inline: 4px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.app-bar-title {
|
|
122
|
+
margin: 0;
|
|
123
|
+
font: var(--title);
|
|
124
|
+
font-variation-settings: var(--title-axes);
|
|
125
|
+
letter-spacing: var(--title-tracking);
|
|
126
|
+
color: var(--title-color);
|
|
127
|
+
white-space: nowrap;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
text-overflow: ellipsis;
|
|
130
|
+
|
|
131
|
+
::slotted(*) {
|
|
132
|
+
margin: 0;
|
|
133
|
+
font: inherit;
|
|
134
|
+
font-variation-settings: inherit;
|
|
135
|
+
letter-spacing: inherit;
|
|
136
|
+
color: inherit;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.app-bar-subtitle {
|
|
141
|
+
margin: 0;
|
|
142
|
+
margin-top: 2px;
|
|
143
|
+
font: var(--subtitle);
|
|
144
|
+
font-variation-settings: var(--subtitle-axes);
|
|
145
|
+
letter-spacing: var(--subtitle-tracking);
|
|
146
|
+
color: var(--subtitle-color);
|
|
147
|
+
white-space: nowrap;
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
|
|
151
|
+
::slotted(*) {
|
|
152
|
+
margin: 0;
|
|
153
|
+
font: inherit;
|
|
154
|
+
font-variation-settings: inherit;
|
|
155
|
+
letter-spacing: inherit;
|
|
156
|
+
color: inherit;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.app-bar-search-container {
|
|
161
|
+
display: flex;
|
|
162
|
+
flex: 1 1 auto;
|
|
163
|
+
align-items: center;
|
|
164
|
+
min-width: 0;
|
|
165
|
+
margin-inline: 8px;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AppBarElement } from './app-bar-element.js';
|
|
7
|
+
declare global {
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
/** A Material Design app bar component. */
|
|
10
|
+
'md-gb-app-bar': AppBarElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md-gb-app-bar.js","sourceRoot":"","sources":["md-gb-app-bar.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AASnD,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {AppBarElement} from './app-bar-element.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n /** A Material Design app bar component. */\n 'md-gb-app-bar': AppBarElement;\n }\n}\n\ncustomElements.define('md-gb-app-bar', AppBarElement);\n"]}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 Google LLC
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
// Auto-generated by cascade_tokens
|
|
7
|
+
// Add `// EDIT:` comments for manual adjustments.
|
|
8
|
+
//
|
|
9
|
+
// --prefix=md.comp.chip
|
|
10
|
+
// --states="hovered|focused|pressed|dragged,:unselected|selected,:filter|input,with-leading-icon|with-avatar,with-trailing-icon,disabled"
|
|
11
|
+
// --exclude=motion,state-layer,indicator
|
|
12
|
+
|
|
13
|
+
@mixin root {
|
|
14
|
+
// LINT.IfChange
|
|
15
|
+
--avatar-opacity: unset;
|
|
16
|
+
// md.comp.chip.avatar.shape
|
|
17
|
+
--avatar-shape: var(--md-sys-shape-corner-full);
|
|
18
|
+
// md.comp.chip.avatar.size
|
|
19
|
+
--avatar-size: 24px;
|
|
20
|
+
--container-color: unset;
|
|
21
|
+
// md.comp.chip.container.elevation
|
|
22
|
+
--container-elevation: var(--md-sys-elevation-shadow-0);
|
|
23
|
+
// --container-opacity: unset; // EDIT: unused
|
|
24
|
+
// md.comp.chip.gap.horizontal
|
|
25
|
+
--gap-horizontal: var(--md-sys-space-50);
|
|
26
|
+
// md.comp.chip.height
|
|
27
|
+
--height: 32px;
|
|
28
|
+
// md.comp.chip.label-text
|
|
29
|
+
--label-text: var(--md-sys-typescale-label-lg);
|
|
30
|
+
// ┌┄ md.comp.chip.label-text
|
|
31
|
+
--label-text-axes: var(--md-sys-typescale-label-lg-axes);
|
|
32
|
+
// md.comp.chip.unselected.label-text.color
|
|
33
|
+
--label-text-color: var(--md-sys-color-on-surface-variant);
|
|
34
|
+
// --label-text-opacity: unset; // EDIT: unused
|
|
35
|
+
// ┌┄ md.comp.chip.label-text
|
|
36
|
+
--label-text-tracking: var(--md-sys-typescale-label-lg-tracking);
|
|
37
|
+
// md.comp.chip.unselected.leading-icon.color
|
|
38
|
+
--leading-icon-color: var(--md-sys-color-on-surface-variant);
|
|
39
|
+
// --leading-icon-opacity: unset; // EDIT: unused
|
|
40
|
+
// md.comp.chip.leading-icon.size
|
|
41
|
+
--leading-icon-size: 18px;
|
|
42
|
+
// md.comp.chip.unselected.outline.color
|
|
43
|
+
--outline-color: var(--md-sys-color-outline-variant);
|
|
44
|
+
// --outline-opacity: unset; // EDIT: unused
|
|
45
|
+
// md.comp.chip.unselected.outline.width
|
|
46
|
+
--outline-width: 1px;
|
|
47
|
+
// md.comp.chip.padding.bottom
|
|
48
|
+
--padding-bottom: var(--md-sys-space-75);
|
|
49
|
+
// ┌ md.comp.chip.filter.padding.leading
|
|
50
|
+
--padding-leading: var(--md-sys-space-200);
|
|
51
|
+
// md.comp.chip.padding.top
|
|
52
|
+
--padding-top: var(--md-sys-space-75);
|
|
53
|
+
// ┌ md.comp.chip.filter.padding.trailing
|
|
54
|
+
--padding-trailing: var(--md-sys-space-200);
|
|
55
|
+
// md.comp.chip.unselected.shape
|
|
56
|
+
--shape: var(--md-sys-shape-corner-md);
|
|
57
|
+
// md.comp.chip.unselected.trailing-icon.color
|
|
58
|
+
--trailing-icon-color: var(--md-sys-color-on-surface-variant);
|
|
59
|
+
// --trailing-icon-opacity: unset; // EDIT: unused
|
|
60
|
+
// md.comp.chip.trailing-icon.size
|
|
61
|
+
--trailing-icon-size: 18px;
|
|
62
|
+
// LINT.ThenChange(md-gb-chip.ts) sync with `@cssprop` jsdoc tags
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@mixin pressed {
|
|
66
|
+
// md.comp.chip.pressed.shape
|
|
67
|
+
--shape: var(--md-sys-shape-corner-sm);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@mixin dragged {
|
|
71
|
+
// md.comp.chip.dragged.container.elevation
|
|
72
|
+
--container-elevation: var(--md-sys-elevation-shadow-4);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@mixin selected {
|
|
76
|
+
// md.comp.chip.selected.container.color
|
|
77
|
+
--container-color: var(--md-sys-color-secondary-container);
|
|
78
|
+
// md.comp.chip.selected.label-text.color
|
|
79
|
+
--label-text-color: var(--md-sys-color-on-secondary-container);
|
|
80
|
+
// md.comp.chip.selected.leading-icon.color
|
|
81
|
+
--leading-icon-color: var(--md-sys-color-on-secondary-container);
|
|
82
|
+
// md.comp.chip.selected.outline.width
|
|
83
|
+
--outline-width: 0px;
|
|
84
|
+
// md.comp.chip.selected.shape
|
|
85
|
+
--shape: var(--md-sys-shape-corner-full);
|
|
86
|
+
// md.comp.chip.selected.trailing-icon.color
|
|
87
|
+
--trailing-icon-color: var(--md-sys-color-on-secondary-container);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@mixin input {
|
|
91
|
+
// md.comp.chip.input.padding.leading
|
|
92
|
+
--padding-leading: var(--md-sys-space-150);
|
|
93
|
+
// md.comp.chip.input.padding.trailing
|
|
94
|
+
--padding-trailing: var(--md-sys-space-150);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@mixin with-leading-icon {
|
|
98
|
+
// md.comp.chip.with-leading-icon.padding.leading
|
|
99
|
+
--padding-leading: var(--md-sys-space-100);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@mixin with-avatar {
|
|
103
|
+
// md.comp.chip.with-avatar.padding.leading
|
|
104
|
+
--padding-leading: var(--md-sys-space-50);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@mixin with-trailing-icon {
|
|
108
|
+
// md.comp.chip.with-trailing-icon.padding.trailing
|
|
109
|
+
--padding-trailing: var(--md-sys-space-100);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@mixin disabled {
|
|
113
|
+
// md.comp.chip.disabled.avatar.opacity
|
|
114
|
+
--avatar-opacity: 0.38;
|
|
115
|
+
// ┌ md.comp.chip.disabled.label-text.opacity
|
|
116
|
+
// md.comp.chip.disabled.label-text.color
|
|
117
|
+
--label-text-color: hsl(from var(--md-sys-color-on-surface) h s l / 0.38);
|
|
118
|
+
// ┌ md.comp.chip.disabled.leading-icon.opacity
|
|
119
|
+
// md.comp.chip.disabled.leading-icon.color
|
|
120
|
+
--leading-icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 0.38);
|
|
121
|
+
// ┌ md.comp.chip.unselected.disabled.outline.opacity
|
|
122
|
+
// md.comp.chip.unselected.disabled.outline.color
|
|
123
|
+
--outline-color: hsl(from var(--md-sys-color-on-surface) h s l / 0.1);
|
|
124
|
+
// ┌ md.comp.chip.disabled.trailing-icon.opacity
|
|
125
|
+
// md.comp.chip.disabled.trailing-icon.color
|
|
126
|
+
--trailing-icon-color: hsl(from var(--md-sys-color-on-surface) h s l / 0.38);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@mixin disabled-selected {
|
|
130
|
+
// ┌ md.comp.chip.selected.disabled.container.opacity
|
|
131
|
+
// md.comp.chip.selected.disabled.container.color
|
|
132
|
+
--container-color: hsl(from var(--md-sys-color-on-surface) h s l / 0.12);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// EDIT: Manual adjustments
|
|
136
|
+
@mixin filter {
|
|
137
|
+
// Hoisted to root, so empty here to satisfy chip.scss mapping
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@mixin elevated {
|
|
141
|
+
--container-color: var(--md-sys-color-surface-container-low);
|
|
142
|
+
--container-elevation: var(--md-sys-elevation-shadow-1);
|
|
143
|
+
--label-text-color: var(--md-sys-color-on-surface);
|
|
144
|
+
--outline-width: 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@mixin filled {
|
|
148
|
+
--container-color: var(--md-sys-color-surface-container);
|
|
149
|
+
--container-elevation: var(--md-sys-elevation-shadow-0);
|
|
150
|
+
--label-text-color: var(--md-sys-color-on-surface);
|
|
151
|
+
--outline-width: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@mixin tonal {
|
|
155
|
+
--container-color: var(--md-sys-color-secondary-container);
|
|
156
|
+
--container-elevation: var(--md-sys-elevation-shadow-0);
|
|
157
|
+
--label-text-color: var(--md-sys-color-on-secondary-container);
|
|
158
|
+
--outline-width: 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@mixin outlined {
|
|
162
|
+
--container-color: transparent;
|
|
163
|
+
--container-elevation: var(--md-sys-elevation-shadow-0);
|
|
164
|
+
--label-text-color: var(--md-sys-color-on-surface);
|
|
165
|
+
--outline-color: var(--md-sys-color-outline);
|
|
166
|
+
--outline-width: 1px;
|
|
167
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CSSResultOrNative, LitElement } from 'lit';
|
|
7
|
+
import { type ChipColor, type ChipType } from './chip.js';
|
|
8
|
+
/**
|
|
9
|
+
* A Material Design Expressive Chip component (`md-gb-chip`).
|
|
10
|
+
*
|
|
11
|
+
* @slot - Used to display the chip label text.
|
|
12
|
+
* @slot icon - Used to display an optional leading icon, checkmark, or avatar.
|
|
13
|
+
* @slot remove-icon - Used to display the trailing remove button icon when `removable="true"`.
|
|
14
|
+
* @fires {Event} remove - Fired when the remove action is triggered on a removable chip. --bubbles --composed
|
|
15
|
+
* @fires {Event} change - Fired when a filter/toggle chip's selection state changes. --bubbles
|
|
16
|
+
* @fires {InputEvent} input - Fired when a filter/toggle chip's selection state changes. --bubbles --composed
|
|
17
|
+
* @csspart chip - The root container element.
|
|
18
|
+
* @cssprop --avatar-opacity
|
|
19
|
+
* @cssprop --avatar-shape
|
|
20
|
+
* @cssprop --avatar-size
|
|
21
|
+
* @cssprop --container-color
|
|
22
|
+
* @cssprop --container-elevation
|
|
23
|
+
* @cssprop --container-opacity
|
|
24
|
+
* @cssprop --gap-horizontal
|
|
25
|
+
* @cssprop --height
|
|
26
|
+
* @cssprop --label-text
|
|
27
|
+
* @cssprop --label-text-color
|
|
28
|
+
* @cssprop --label-text-opacity
|
|
29
|
+
* @cssprop --leading-icon-color
|
|
30
|
+
* @cssprop --leading-icon-opacity
|
|
31
|
+
* @cssprop --leading-icon-size
|
|
32
|
+
* @cssprop --outline-color
|
|
33
|
+
* @cssprop --outline-opacity
|
|
34
|
+
* @cssprop --outline-width
|
|
35
|
+
* @cssprop --padding-bottom
|
|
36
|
+
* @cssprop --padding-leading
|
|
37
|
+
* @cssprop --padding-top
|
|
38
|
+
* @cssprop --padding-trailing
|
|
39
|
+
* @cssprop --shape
|
|
40
|
+
* @cssprop --trailing-icon-color
|
|
41
|
+
* @cssprop --trailing-icon-opacity
|
|
42
|
+
* @cssprop --trailing-icon-size
|
|
43
|
+
*/
|
|
44
|
+
export declare class ChipElement extends LitElement {
|
|
45
|
+
static styles: CSSResultOrNative[];
|
|
46
|
+
/** The color emphasis of the chip. Defaults to `outlined`. */
|
|
47
|
+
color: ChipColor;
|
|
48
|
+
/** The functional behavior type of the chip (`action`, `filter`, `toggle`, `link`). */
|
|
49
|
+
type: ChipType;
|
|
50
|
+
/** Whether the filter or toggle chip is selected. */
|
|
51
|
+
selected: boolean;
|
|
52
|
+
/** Whether the chip is removable. */
|
|
53
|
+
removable: boolean;
|
|
54
|
+
/** Whether the chip is disabled. */
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
/** Whether the chip is soft-disabled (`aria-disabled="true"` while preserving focusability). */
|
|
57
|
+
softDisabled: boolean;
|
|
58
|
+
/** The URL destination if `type="link"` or if `href` is set. */
|
|
59
|
+
href: string;
|
|
60
|
+
/** Where to display the linked `href` URL for a link chip. */
|
|
61
|
+
target: '_blank' | '_parent' | '_self' | '_top' | '';
|
|
62
|
+
private hasLeadingIcon;
|
|
63
|
+
private hasAvatar;
|
|
64
|
+
private hasRemoveIcon;
|
|
65
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
66
|
+
private renderContent;
|
|
67
|
+
private renderLeadingIcon;
|
|
68
|
+
private renderRemoveButton;
|
|
69
|
+
private handleIconSlotChange;
|
|
70
|
+
private handleRemoveIconSlotChange;
|
|
71
|
+
private handleChange;
|
|
72
|
+
private handleRemove;
|
|
73
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate } from "tslib";
|
|
7
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { redispatchEvent } from '../../../../internal/events/redispatch-event.js';
|
|
10
|
+
import focusRingStyles from '../focus/focus-ring.cssresult.js';
|
|
11
|
+
import rippleStyles from '../ripple/ripple.cssresult.js';
|
|
12
|
+
import { chip } from './chip.js';
|
|
13
|
+
import { styles as chipStyles } from './chip.cssresult.js';
|
|
14
|
+
/**
|
|
15
|
+
* A Material Design Expressive Chip component (`md-gb-chip`).
|
|
16
|
+
*
|
|
17
|
+
* @slot - Used to display the chip label text.
|
|
18
|
+
* @slot icon - Used to display an optional leading icon, checkmark, or avatar.
|
|
19
|
+
* @slot remove-icon - Used to display the trailing remove button icon when `removable="true"`.
|
|
20
|
+
* @fires {Event} remove - Fired when the remove action is triggered on a removable chip. --bubbles --composed
|
|
21
|
+
* @fires {Event} change - Fired when a filter/toggle chip's selection state changes. --bubbles
|
|
22
|
+
* @fires {InputEvent} input - Fired when a filter/toggle chip's selection state changes. --bubbles --composed
|
|
23
|
+
* @csspart chip - The root container element.
|
|
24
|
+
* @cssprop --avatar-opacity
|
|
25
|
+
* @cssprop --avatar-shape
|
|
26
|
+
* @cssprop --avatar-size
|
|
27
|
+
* @cssprop --container-color
|
|
28
|
+
* @cssprop --container-elevation
|
|
29
|
+
* @cssprop --container-opacity
|
|
30
|
+
* @cssprop --gap-horizontal
|
|
31
|
+
* @cssprop --height
|
|
32
|
+
* @cssprop --label-text
|
|
33
|
+
* @cssprop --label-text-color
|
|
34
|
+
* @cssprop --label-text-opacity
|
|
35
|
+
* @cssprop --leading-icon-color
|
|
36
|
+
* @cssprop --leading-icon-opacity
|
|
37
|
+
* @cssprop --leading-icon-size
|
|
38
|
+
* @cssprop --outline-color
|
|
39
|
+
* @cssprop --outline-opacity
|
|
40
|
+
* @cssprop --outline-width
|
|
41
|
+
* @cssprop --padding-bottom
|
|
42
|
+
* @cssprop --padding-leading
|
|
43
|
+
* @cssprop --padding-top
|
|
44
|
+
* @cssprop --padding-trailing
|
|
45
|
+
* @cssprop --shape
|
|
46
|
+
* @cssprop --trailing-icon-color
|
|
47
|
+
* @cssprop --trailing-icon-opacity
|
|
48
|
+
* @cssprop --trailing-icon-size
|
|
49
|
+
*/
|
|
50
|
+
export class ChipElement extends LitElement {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
/** The color emphasis of the chip. Defaults to `outlined`. */
|
|
54
|
+
this.color = 'outlined';
|
|
55
|
+
/** The functional behavior type of the chip (`action`, `filter`, `toggle`, `link`). */
|
|
56
|
+
this.type = 'action';
|
|
57
|
+
/** Whether the filter or toggle chip is selected. */
|
|
58
|
+
this.selected = false;
|
|
59
|
+
/** Whether the chip is removable. */
|
|
60
|
+
this.removable = false;
|
|
61
|
+
/** Whether the chip is disabled. */
|
|
62
|
+
this.disabled = false;
|
|
63
|
+
/** Whether the chip is soft-disabled (`aria-disabled="true"` while preserving focusability). */
|
|
64
|
+
this.softDisabled = false;
|
|
65
|
+
/** The URL destination if `type="link"` or if `href` is set. */
|
|
66
|
+
this.href = '';
|
|
67
|
+
/** Where to display the linked `href` URL for a link chip. */
|
|
68
|
+
this.target = '';
|
|
69
|
+
this.hasLeadingIcon = false;
|
|
70
|
+
this.hasAvatar = false;
|
|
71
|
+
this.hasRemoveIcon = false;
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
const isFilterSelected = (this.type === 'filter' || this.type === 'toggle') && this.selected;
|
|
75
|
+
const withLeadingIcon = this.hasLeadingIcon || isFilterSelected;
|
|
76
|
+
const withAvatar = this.hasAvatar;
|
|
77
|
+
const chipClasses = chip({
|
|
78
|
+
color: this.color,
|
|
79
|
+
type: this.href ? 'link' : this.type,
|
|
80
|
+
selected: this.selected,
|
|
81
|
+
removable: this.removable,
|
|
82
|
+
disabled: this.softDisabled || this.disabled,
|
|
83
|
+
withLeadingIcon: withLeadingIcon && !withAvatar,
|
|
84
|
+
withAvatar,
|
|
85
|
+
withTrailingIcon: this.removable || this.hasRemoveIcon,
|
|
86
|
+
});
|
|
87
|
+
if (this.href || this.type === 'link') {
|
|
88
|
+
return html `<a
|
|
89
|
+
part="chip"
|
|
90
|
+
class="${chipClasses}"
|
|
91
|
+
href=${this.href}
|
|
92
|
+
target=${this.target ||
|
|
93
|
+
nothing}
|
|
94
|
+
aria-disabled=${this.disabled || this.softDisabled ? 'true' : nothing}
|
|
95
|
+
tabindex=${this.disabled && !this.softDisabled ? -1 : nothing}>
|
|
96
|
+
${this.renderContent(withLeadingIcon, isFilterSelected)}
|
|
97
|
+
</a>`;
|
|
98
|
+
}
|
|
99
|
+
if (this.removable) {
|
|
100
|
+
return html `<div
|
|
101
|
+
part="chip"
|
|
102
|
+
class="${chipClasses}"
|
|
103
|
+
role="row"
|
|
104
|
+
aria-pressed=${this.type === 'filter' || this.type === 'toggle'
|
|
105
|
+
? (this.selected ? 'true' : 'false')
|
|
106
|
+
: nothing}
|
|
107
|
+
@change=${this.handleChange}>
|
|
108
|
+
<button
|
|
109
|
+
class="chip-action focus-ring-target"
|
|
110
|
+
type="button"
|
|
111
|
+
?disabled=${this.disabled}
|
|
112
|
+
aria-disabled=${this.softDisabled ? 'true' : nothing}>
|
|
113
|
+
${this.renderContent(withLeadingIcon, isFilterSelected)}
|
|
114
|
+
</button>
|
|
115
|
+
${this.renderRemoveButton()}
|
|
116
|
+
</div>`;
|
|
117
|
+
}
|
|
118
|
+
return html `<button
|
|
119
|
+
part="chip"
|
|
120
|
+
class="${chipClasses}"
|
|
121
|
+
type="button"
|
|
122
|
+
?disabled=${this.disabled}
|
|
123
|
+
aria-disabled=${this.softDisabled ? 'true' : nothing}
|
|
124
|
+
aria-pressed=${this.type === 'filter' || this.type === 'toggle'
|
|
125
|
+
? (this.selected ? 'true' : 'false')
|
|
126
|
+
: nothing}
|
|
127
|
+
@change=${this.handleChange}>
|
|
128
|
+
${this.renderContent(withLeadingIcon, isFilterSelected)}
|
|
129
|
+
</button>`;
|
|
130
|
+
}
|
|
131
|
+
renderContent(withLeadingIcon, isFilterSelected) {
|
|
132
|
+
return html `
|
|
133
|
+
${this.renderLeadingIcon(withLeadingIcon, isFilterSelected)}
|
|
134
|
+
<slot></slot>
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
renderLeadingIcon(withLeadingIcon, isFilterSelected) {
|
|
138
|
+
return html `<span
|
|
139
|
+
class="chip-icon"
|
|
140
|
+
style="${withLeadingIcon ? '' : 'display: none;'}">
|
|
141
|
+
<slot name="icon" @slotchange=${this.handleIconSlotChange}>
|
|
142
|
+
${isFilterSelected ? html `✓` : nothing}
|
|
143
|
+
</slot>
|
|
144
|
+
</span>`;
|
|
145
|
+
}
|
|
146
|
+
renderRemoveButton() {
|
|
147
|
+
return html `<button
|
|
148
|
+
class="chip-remove focus-ring-outer"
|
|
149
|
+
type="button"
|
|
150
|
+
aria-label="Remove"
|
|
151
|
+
?disabled=${this.disabled}
|
|
152
|
+
aria-disabled=${this.softDisabled ? 'true' : nothing}
|
|
153
|
+
@click=${this.handleRemove}>
|
|
154
|
+
<slot
|
|
155
|
+
name="remove-icon"
|
|
156
|
+
@slotchange=${this.handleRemoveIconSlotChange}
|
|
157
|
+
>✕</slot
|
|
158
|
+
>
|
|
159
|
+
</button>`;
|
|
160
|
+
}
|
|
161
|
+
handleIconSlotChange(event) {
|
|
162
|
+
const slot = event.target;
|
|
163
|
+
const elements = slot.assignedElements({ flatten: true });
|
|
164
|
+
this.hasLeadingIcon = elements.length > 0;
|
|
165
|
+
this.hasAvatar = elements.some((el) => el.classList.contains('chip-avatar'));
|
|
166
|
+
}
|
|
167
|
+
handleRemoveIconSlotChange(event) {
|
|
168
|
+
const slot = event.target;
|
|
169
|
+
this.hasRemoveIcon = slot.assignedNodes({ flatten: true }).length > 0;
|
|
170
|
+
}
|
|
171
|
+
handleChange(event) {
|
|
172
|
+
this.selected = event.target.ariaPressed === 'true';
|
|
173
|
+
redispatchEvent(this, event);
|
|
174
|
+
}
|
|
175
|
+
handleRemove(event) {
|
|
176
|
+
event.stopPropagation();
|
|
177
|
+
if (this.disabled || this.softDisabled)
|
|
178
|
+
return;
|
|
179
|
+
this.dispatchEvent(new Event('remove', { bubbles: true, composed: true }));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
ChipElement.styles = [
|
|
183
|
+
focusRingStyles,
|
|
184
|
+
rippleStyles,
|
|
185
|
+
chipStyles,
|
|
186
|
+
css `
|
|
187
|
+
:host {
|
|
188
|
+
display: inline-flex;
|
|
189
|
+
vertical-align: middle;
|
|
190
|
+
}
|
|
191
|
+
.chip {
|
|
192
|
+
flex: 1;
|
|
193
|
+
}
|
|
194
|
+
.chip-icon {
|
|
195
|
+
display: inline-flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
}
|
|
198
|
+
`,
|
|
199
|
+
];
|
|
200
|
+
__decorate([
|
|
201
|
+
property()
|
|
202
|
+
], ChipElement.prototype, "color", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
property()
|
|
205
|
+
], ChipElement.prototype, "type", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
property({ type: Boolean, reflect: true })
|
|
208
|
+
], ChipElement.prototype, "selected", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
property({ type: Boolean, reflect: true })
|
|
211
|
+
], ChipElement.prototype, "removable", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
property({ type: Boolean, reflect: true })
|
|
214
|
+
], ChipElement.prototype, "disabled", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ type: Boolean, attribute: 'soft-disabled', reflect: true })
|
|
217
|
+
], ChipElement.prototype, "softDisabled", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property()
|
|
220
|
+
], ChipElement.prototype, "href", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property()
|
|
223
|
+
], ChipElement.prototype, "target", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
state()
|
|
226
|
+
], ChipElement.prototype, "hasLeadingIcon", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
state()
|
|
229
|
+
], ChipElement.prototype, "hasAvatar", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
state()
|
|
232
|
+
], ChipElement.prototype, "hasRemoveIcon", void 0);
|
|
233
|
+
//# sourceMappingURL=chip-element.js.map
|