@muibook/components 10.0.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -11
- package/README.md +4 -0
- package/dist/esm/components/mui-accordion/block/index.js +9 -5
- package/dist/esm/components/mui-alert/index.js +88 -52
- package/dist/esm/components/mui-badge/index.js +61 -16
- package/dist/esm/components/mui-body/index.js +76 -10
- package/dist/esm/components/mui-button/index.js +152 -32
- package/dist/esm/components/mui-card/card/index.js +13 -8
- package/dist/esm/components/mui-checkbox/index.js +64 -30
- package/dist/esm/components/mui-chip/index.js +153 -33
- package/dist/esm/components/mui-chip-input/index.js +407 -0
- package/dist/esm/components/mui-code/index.js +11 -9
- package/dist/esm/components/mui-dialog/index.js +17 -8
- package/dist/esm/components/mui-dropdown/index.js +44 -44
- package/dist/esm/components/mui-field/index.js +56 -21
- package/dist/esm/components/mui-form-group/index.js +88 -0
- package/dist/esm/components/mui-form-hint/index.js +1 -0
- package/dist/esm/components/mui-form-message/index.js +72 -0
- package/dist/esm/components/mui-form-section/index.js +108 -0
- package/dist/esm/components/mui-form-section-footer/index.js +46 -0
- package/dist/esm/components/mui-hint/index.js +146 -0
- package/dist/esm/components/mui-icons/accessibility/index.js +5 -4
- package/dist/esm/components/mui-icons/add/index.js +1 -0
- package/dist/esm/components/mui-icons/ai/index.js +5 -4
- package/dist/esm/components/mui-icons/attention/index.js +1 -0
- package/dist/esm/components/mui-icons/calendar/index.js +5 -4
- package/dist/esm/components/mui-icons/check/index.js +6 -5
- package/dist/esm/components/mui-icons/checkmark/index.js +9 -8
- package/dist/esm/components/mui-icons/close/index.js +6 -5
- package/dist/esm/components/mui-icons/down-arrow-circle/index.js +9 -8
- package/dist/esm/components/mui-icons/down-chevron/index.js +8 -7
- package/dist/esm/components/mui-icons/ellipsis/index.js +1 -0
- package/dist/esm/components/mui-icons/exclamationmark/index.js +49 -0
- package/dist/esm/components/mui-icons/game-controller/index.js +8 -7
- package/dist/esm/components/mui-icons/gear/index.js +5 -4
- package/dist/esm/components/mui-icons/globe/index.js +8 -7
- package/dist/esm/components/mui-icons/grid/index.js +1 -0
- package/dist/esm/components/mui-icons/home/index.js +9 -8
- package/dist/esm/components/mui-icons/index.js +3 -0
- package/dist/esm/components/mui-icons/info/index.js +3 -2
- package/dist/esm/components/mui-icons/left-arrow/index.js +1 -0
- package/dist/esm/components/mui-icons/left-chevron/index.js +6 -5
- package/dist/esm/components/mui-icons/left-sidebar/index.js +6 -5
- package/dist/esm/components/mui-icons/list-and-film/index.js +1 -0
- package/dist/esm/components/mui-icons/menu/index.js +8 -7
- package/dist/esm/components/mui-icons/message/index.js +5 -4
- package/dist/esm/components/mui-icons/moon/index.js +3 -2
- package/dist/esm/components/mui-icons/movie-clapper/index.js +5 -4
- package/dist/esm/components/mui-icons/music-microphone/index.js +6 -5
- package/dist/esm/components/mui-icons/music-quarter-note/index.js +1 -0
- package/dist/esm/components/mui-icons/notification/index.js +5 -4
- package/dist/esm/components/mui-icons/pin/index.js +3 -2
- package/dist/esm/components/mui-icons/pin-slash/index.js +6 -5
- package/dist/esm/components/mui-icons/play-rectangle/index.js +9 -8
- package/dist/esm/components/mui-icons/play-stack/index.js +5 -4
- package/dist/esm/components/mui-icons/rectangle/index.js +6 -5
- package/dist/esm/components/mui-icons/rectangle-bottom-panel/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-dashed/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-left-drawer/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-media-text/index.js +6 -5
- package/dist/esm/components/mui-icons/right-chevron/index.js +1 -0
- package/dist/esm/components/mui-icons/search/index.js +6 -5
- package/dist/esm/components/mui-icons/spinner/index.js +56 -0
- package/dist/esm/components/mui-icons/stop/index.js +3 -2
- package/dist/esm/components/mui-icons/subtract/index.js +1 -0
- package/dist/esm/components/mui-icons/sun/index.js +1 -0
- package/dist/esm/components/mui-icons/text-below-folder/index.js +55 -0
- package/dist/esm/components/mui-icons/toggle/index.js +8 -6
- package/dist/esm/components/mui-icons/translate/index.js +5 -4
- package/dist/esm/components/mui-icons/up-arrow/index.js +5 -4
- package/dist/esm/components/mui-icons/up-chevron/index.js +6 -5
- package/dist/esm/components/mui-icons/warning/index.js +7 -6
- package/dist/esm/components/mui-input/index.js +298 -47
- package/dist/esm/components/mui-link/index.js +187 -59
- package/dist/esm/components/mui-list/item/index.js +3 -0
- package/dist/esm/components/mui-markdown/index.js +149 -0
- package/dist/esm/components/mui-media-player/index.js +184 -0
- package/dist/esm/components/mui-message/index.js +50 -20
- package/dist/esm/components/mui-progress/index.js +15 -15
- package/dist/esm/components/mui-prompt/index.js +1461 -0
- package/dist/esm/components/mui-prompt-message/index.js +114 -0
- package/dist/esm/components/mui-prompt-preview/index.js +497 -0
- package/dist/esm/components/mui-prompt-toggle/index.js +48 -0
- package/dist/esm/components/mui-radio/index.js +155 -0
- package/dist/esm/components/mui-radio-group/index.js +104 -0
- package/dist/esm/components/mui-range-input/index.js +122 -0
- package/dist/esm/components/mui-rule/index.js +11 -3
- package/dist/esm/components/mui-select/index.js +89 -30
- package/dist/esm/components/mui-spinner/index.js +70 -0
- package/dist/esm/components/mui-stepper/step/index.js +255 -18
- package/dist/esm/components/mui-stepper/stepper/index.js +68 -72
- package/dist/esm/components/mui-table/row/index.js +16 -3
- package/dist/esm/components/mui-tabs/controller/index.js +21 -14
- package/dist/esm/components/mui-tabs/item/index.js +285 -29
- package/dist/esm/components/mui-tabs/panel/index.js +3 -0
- package/dist/esm/components/mui-tabs/tab-bar/index.js +85 -34
- package/dist/esm/components/mui-textarea/index.js +257 -0
- package/dist/esm/css/mui-base.css +27 -0
- package/dist/esm/css/mui-brand.css +3 -1
- package/dist/esm/css/mui-tokens.css +234 -7
- package/dist/esm/custom-elements.json +5113 -1702
- package/dist/esm/index.js +24 -4
- package/dist/esm/tokens/js/index.js +107 -105
- package/dist/types/components/mui-agent-bubble/doc.d.ts +2 -0
- package/dist/types/components/mui-agent-bubble/index.d.ts +1 -0
- package/dist/types/components/mui-agent-prompt/doc.d.ts +2 -0
- package/dist/types/components/mui-agent-prompt/index.d.ts +1 -0
- package/dist/types/components/mui-chip-input/doc.d.ts +2 -0
- package/dist/types/components/mui-chip-input/index.d.ts +3 -0
- package/dist/types/components/mui-form-group/doc.d.ts +2 -0
- package/dist/types/components/mui-form-group/index.d.ts +2 -0
- package/dist/types/components/mui-form-group-horizontal/index.d.ts +1 -0
- package/dist/types/components/mui-form-hint/doc.d.ts +2 -0
- package/dist/types/components/mui-form-hint/index.d.ts +1 -0
- package/dist/types/components/mui-form-message/index.d.ts +2 -0
- package/dist/types/components/mui-form-section/doc.d.ts +2 -0
- package/dist/types/components/mui-form-section/index.d.ts +1 -0
- package/dist/types/components/mui-form-section-footer/doc.d.ts +2 -0
- package/dist/types/components/mui-form-section-footer/index.d.ts +1 -0
- package/dist/types/components/mui-hint/doc.d.ts +2 -0
- package/dist/types/components/mui-hint/index.d.ts +1 -0
- package/dist/types/components/mui-icons/exclamationmark.d.ts +1 -0
- package/dist/types/components/mui-icons/index.d.ts +3 -0
- package/dist/types/components/mui-icons/spinner.d.ts +1 -0
- package/dist/types/components/mui-icons/text-below-folder.d.ts +1 -0
- package/dist/types/components/mui-markdown/doc.d.ts +2 -0
- package/dist/types/components/mui-markdown/index.d.ts +1 -0
- package/dist/types/components/mui-media-player/doc.d.ts +2 -0
- package/dist/types/components/mui-media-player/index.d.ts +8 -0
- package/dist/types/components/mui-prompt/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt/index.d.ts +18 -0
- package/dist/types/components/mui-prompt-chip/index.d.ts +1 -0
- package/dist/types/components/mui-prompt-message/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt-message/index.d.ts +1 -0
- package/dist/types/components/mui-prompt-preview/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt-preview/index.d.ts +7 -0
- package/dist/types/components/mui-prompt-toggle/index.d.ts +1 -0
- package/dist/types/components/mui-radio/doc.d.ts +2 -0
- package/dist/types/components/mui-radio/index.d.ts +1 -0
- package/dist/types/components/mui-radio-group/index.d.ts +1 -0
- package/dist/types/components/mui-range-input/doc.d.ts +2 -0
- package/dist/types/components/mui-range-input/index.d.ts +1 -0
- package/dist/types/components/mui-spinner/doc.d.ts +2 -0
- package/dist/types/components/mui-spinner/index.d.ts +1 -0
- package/dist/types/components/mui-stepper/step/index.d.ts +4 -1
- package/dist/types/components/mui-textarea/doc.d.ts +2 -0
- package/dist/types/components/mui-textarea/index.d.ts +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/tokens/js/index.d.ts +2 -0
- package/package.json +88 -1
|
@@ -1,45 +1,259 @@
|
|
|
1
|
-
class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
class i extends HTMLElement {
|
|
2
|
+
getIconSizeFromTabSize() {
|
|
3
|
+
const t = this.getAttribute("size") || "medium";
|
|
4
|
+
return t === "x-small" || t === "small" ? "x-small" : t === "large" ? "medium" : "small";
|
|
5
|
+
}
|
|
6
|
+
getBadgeSizeFromTabSize() {
|
|
7
|
+
const t = this.getAttribute("size") || "medium";
|
|
8
|
+
return t === "x-small" ? "x-small" : t === "small" ? "small" : t === "large" ? "large" : "medium";
|
|
9
|
+
}
|
|
10
|
+
hasAssignedContent(t) {
|
|
11
|
+
return t ? t.assignedNodes({ flatten: !0 }).some(
|
|
12
|
+
(a) => {
|
|
13
|
+
var e;
|
|
14
|
+
return a.nodeType === Node.ELEMENT_NODE || a.nodeType === Node.TEXT_NODE && !!((e = a.textContent) != null && e.trim());
|
|
15
|
+
}
|
|
16
|
+
) : !1;
|
|
17
|
+
}
|
|
18
|
+
syncSlottedAffordances(t) {
|
|
19
|
+
if (!t) return;
|
|
20
|
+
t.assignedElements({ flatten: !0 }).forEach((e) => {
|
|
21
|
+
const s = e.tagName.toLowerCase();
|
|
22
|
+
s.startsWith("mui-icon-") && (e.setAttribute("size", this.getIconSizeFromTabSize()), e.setAttribute("color", this.hasAttribute("active") ? "var(--tab-icon-active)" : "var(--tab-icon)")), s === "mui-badge" && e.setAttribute("size", this.getBadgeSizeFromTabSize());
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
updateSlotState() {
|
|
26
|
+
const t = this.hasAssignedContent(this.beforeSlot), a = this.hasAssignedContent(this.afterSlot);
|
|
27
|
+
this.toggleAttribute("has-before", t), this.toggleAttribute("has-after", a), this.syncSlottedAffordances(this.beforeSlot), this.syncSlottedAffordances(this.afterSlot);
|
|
7
28
|
}
|
|
8
29
|
constructor() {
|
|
9
30
|
super(), this.attachShadow({ mode: "open" });
|
|
10
31
|
}
|
|
11
32
|
static get observedAttributes() {
|
|
12
|
-
return ["active", "
|
|
33
|
+
return ["active", "size", "variant"];
|
|
13
34
|
}
|
|
14
|
-
attributeChangedCallback(t
|
|
15
|
-
t === "active" ? this.updateActiveState() : t === "
|
|
35
|
+
attributeChangedCallback(t) {
|
|
36
|
+
t === "active" ? this.updateActiveState() : (t === "size" || t === "variant") && this.updateSlotState();
|
|
16
37
|
}
|
|
17
38
|
connectedCallback() {
|
|
39
|
+
var a, e;
|
|
18
40
|
if (!this.shadowRoot) return;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (e.textContent = /*css*/
|
|
41
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.setAttribute("tabindex", this.hasAttribute("active") ? "0" : "-1"), this.shadowRoot.innerHTML = "";
|
|
42
|
+
const t = document.createElement("style");
|
|
43
|
+
t.textContent = /*css*/
|
|
23
44
|
`
|
|
24
45
|
:host {
|
|
25
46
|
user-select: none;
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: center;
|
|
28
|
-
gap: var(--space-100);
|
|
47
|
+
display: inline-flex;
|
|
29
48
|
align-items: center;
|
|
30
|
-
|
|
49
|
+
justify-content: center;
|
|
50
|
+
padding: var(--action-padding);
|
|
31
51
|
font-size: var(--text-font-size-m);
|
|
32
52
|
line-height: var(--text-line-height-m);
|
|
33
|
-
font-weight: var(--font-weight-bold);
|
|
53
|
+
font-weight: var(--font-weight-semi-bold);
|
|
34
54
|
color: var(--tab-text-color);
|
|
35
55
|
background: transparent;
|
|
36
56
|
white-space: nowrap;
|
|
37
57
|
cursor: pointer;
|
|
38
|
-
min-height:
|
|
58
|
+
min-height: var(--action-icon-only-size);
|
|
39
59
|
box-sizing: border-box;
|
|
40
60
|
border-radius: calc(var(--tab-radius) - 0.2rem);
|
|
41
61
|
}
|
|
42
62
|
|
|
63
|
+
.inner {
|
|
64
|
+
display: grid;
|
|
65
|
+
width: 100%;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: stretch;
|
|
69
|
+
gap: var(--space-100);
|
|
70
|
+
grid-template-columns: auto;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host([has-before]) .inner {
|
|
74
|
+
grid-template-columns: auto 1fr;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:host([has-after]) .inner {
|
|
78
|
+
grid-template-columns: 1fr auto;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:host([has-before][has-after]) .inner {
|
|
82
|
+
grid-template-columns: auto 1fr auto;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.label {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
justify-self: center;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
slot[name="before"] {
|
|
92
|
+
justify-self: start;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
slot[name="after"] {
|
|
96
|
+
justify-self: end;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([has-after]) {
|
|
100
|
+
padding-right: var(--action-after-slot-padding);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([has-before]) {
|
|
104
|
+
padding-left: var(--action-before-slot-padding);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([has-after][has-before]) {
|
|
108
|
+
padding-right: var(--action-after-slot-padding);
|
|
109
|
+
padding-left: var(--action-before-slot-padding);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
::slotted([slot="before"]),
|
|
113
|
+
::slotted([slot="after"]) {
|
|
114
|
+
display: inline-flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
line-height: 1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host([has-before]) ::slotted(mui-badge[slot="before"]) {
|
|
120
|
+
margin-right: var(--tab-badge-offset);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:host([has-after]) ::slotted(mui-badge[slot="after"]) {
|
|
124
|
+
margin-left: var(--tab-badge-offset);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([size="x-small"][has-before]) ::slotted(mui-badge[slot="before"]) {
|
|
128
|
+
margin-right: var(--tab-badge-offset);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([size="x-small"][has-after]) ::slotted(mui-badge[slot="after"]) {
|
|
132
|
+
margin-left: var(--tab-badge-offset);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host([size="large"][has-before]) ::slotted(mui-badge[slot="before"]) {
|
|
136
|
+
margin-right: var(--tab-badge-offset-large);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host([size="large"][has-after]) ::slotted(mui-badge[slot="after"]) {
|
|
140
|
+
margin-left: var(--tab-badge-offset-large);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:host([size="x-small"]) {
|
|
144
|
+
font-size: var(--text-font-size-xs);
|
|
145
|
+
line-height: var(--text-line-height-xs);
|
|
146
|
+
font-weight: var(--font-weight-semi-bold);
|
|
147
|
+
padding: var(--action-padding-x-small);
|
|
148
|
+
min-height: var(--action-icon-only-size-x-small);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:host([size="x-small"][has-after]) {
|
|
152
|
+
padding-right: var(--action-after-slot-padding-x-small);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host([size="x-small"][has-before]) {
|
|
156
|
+
padding-left: var(--action-before-slot-padding-x-small);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
:host([size="x-small"][has-after][has-before]) {
|
|
160
|
+
padding-right: var(--action-after-slot-padding-x-small);
|
|
161
|
+
padding-left: var(--action-before-slot-padding-x-small);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
:host([size="x-small"]) .inner {
|
|
165
|
+
gap: var(--space-050);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
:host([size="small"]) {
|
|
169
|
+
font-size: var(--text-font-size-s);
|
|
170
|
+
line-height: var(--text-line-height-s);
|
|
171
|
+
padding: var(--action-padding-small);
|
|
172
|
+
min-height: var(--action-icon-only-size-small);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:host([size="small"][has-after]) {
|
|
176
|
+
padding-right: var(--action-after-slot-padding-small);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
:host([size="small"][has-before]) {
|
|
180
|
+
padding-left: var(--action-before-slot-padding-small);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host([size="small"][has-after][has-before]) {
|
|
184
|
+
padding-right: var(--action-after-slot-padding-small);
|
|
185
|
+
padding-left: var(--action-before-slot-padding-small);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
:host([size="small"]) .inner {
|
|
189
|
+
gap: var(--space-100);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:host([size="large"]) {
|
|
193
|
+
font-size: var(--text-font-size-l);
|
|
194
|
+
line-height: var(--text-line-height-l);
|
|
195
|
+
padding: var(--action-padding-large);
|
|
196
|
+
min-height: var(--action-icon-only-size-large);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:host([size="large"][has-after]) {
|
|
200
|
+
padding-right: var(--action-after-slot-padding-large);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
:host([size="large"][has-before]) {
|
|
204
|
+
padding-left: var(--action-before-slot-padding-large);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
:host([size="large"][has-after][has-before]) {
|
|
208
|
+
padding-right: var(--action-after-slot-padding-large);
|
|
209
|
+
padding-left: var(--action-before-slot-padding-large);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
:host([size="large"]) .inner {
|
|
213
|
+
gap: var(--space-200);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Outer-edge padding for slot affordances */
|
|
217
|
+
:host([has-before]),
|
|
218
|
+
:host([has-after][has-before]) {
|
|
219
|
+
padding-left: calc(var(--action-before-slot-padding) + var(--tab-edge-padding-extra));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
:host([has-after]),
|
|
223
|
+
:host([has-after][has-before]) {
|
|
224
|
+
padding-right: calc(var(--action-after-slot-padding) + var(--tab-edge-padding-extra));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
:host([size="x-small"][has-before]),
|
|
228
|
+
:host([size="x-small"][has-after][has-before]) {
|
|
229
|
+
padding-left: calc(var(--action-before-slot-padding-x-small) + var(--tab-edge-padding-extra-x-small));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
:host([size="x-small"][has-after]),
|
|
233
|
+
:host([size="x-small"][has-after][has-before]) {
|
|
234
|
+
padding-right: calc(var(--action-after-slot-padding-x-small) + var(--tab-edge-padding-extra-x-small));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
:host([size="small"][has-before]),
|
|
238
|
+
:host([size="small"][has-after][has-before]) {
|
|
239
|
+
padding-left: calc(var(--action-before-slot-padding-small) + var(--tab-edge-padding-extra-small));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
:host([size="small"][has-after]),
|
|
243
|
+
:host([size="small"][has-after][has-before]) {
|
|
244
|
+
padding-right: calc(var(--action-after-slot-padding-small) + var(--tab-edge-padding-extra-small));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
:host([size="large"][has-before]),
|
|
248
|
+
:host([size="large"][has-after][has-before]) {
|
|
249
|
+
padding-left: calc(var(--action-before-slot-padding-large) + var(--tab-edge-padding-extra-large));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
:host([size="large"][has-after]),
|
|
253
|
+
:host([size="large"][has-after][has-before]) {
|
|
254
|
+
padding-right: calc(var(--action-after-slot-padding-large) + var(--tab-edge-padding-extra-large));
|
|
255
|
+
}
|
|
256
|
+
|
|
43
257
|
:host([active]) {
|
|
44
258
|
color: var(--tab-text-color-active);
|
|
45
259
|
}
|
|
@@ -49,19 +263,61 @@ class s extends HTMLElement {
|
|
|
49
263
|
outline-offset: -5px;
|
|
50
264
|
}
|
|
51
265
|
|
|
52
|
-
|
|
53
|
-
|
|
266
|
+
:host([variant="dots"]:focus-visible) {
|
|
267
|
+
outline: var(--outline-medium);
|
|
268
|
+
outline-offset: var(--stroke-size-200);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
:host([variant="dots"]) {
|
|
272
|
+
width: var(--tab-dot-size);
|
|
273
|
+
height: var(--tab-dot-size);
|
|
274
|
+
min-height: var(--tab-dot-size);
|
|
275
|
+
min-width: var(--tab-dot-size);
|
|
276
|
+
border-radius: 999px;
|
|
277
|
+
padding: var(--space-000);
|
|
278
|
+
background: var(--tab-dot-color);
|
|
54
279
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
280
|
+
|
|
281
|
+
:host([variant="dots"]) .inner {
|
|
282
|
+
width: 100%;
|
|
283
|
+
height: 100%;
|
|
284
|
+
gap: var(--space-000);
|
|
285
|
+
display: block;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
:host([variant="dots"]) .label {
|
|
289
|
+
position: absolute;
|
|
290
|
+
width: 1px;
|
|
291
|
+
height: 1px;
|
|
292
|
+
margin: -1px;
|
|
293
|
+
padding: 0;
|
|
294
|
+
overflow: hidden;
|
|
295
|
+
clip: rect(0 0 0 0);
|
|
296
|
+
white-space: nowrap;
|
|
297
|
+
border: 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
:host([variant="dots"]) slot[name="before"],
|
|
301
|
+
:host([variant="dots"]) slot[name="after"] {
|
|
302
|
+
display: none;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
:host([variant="dots"][active]) {
|
|
306
|
+
background: var(--tab-dot-color-active);
|
|
307
|
+
}
|
|
308
|
+
`, this.shadowRoot.innerHTML = /*html*/
|
|
309
|
+
`
|
|
310
|
+
<style>${t.textContent}</style>
|
|
311
|
+
<div class="inner">
|
|
312
|
+
<slot name="before"></slot>
|
|
313
|
+
<span class="label"><slot></slot></span>
|
|
314
|
+
<slot name="after"></slot>
|
|
315
|
+
</div>
|
|
316
|
+
`, this.beforeSlot = this.shadowRoot.querySelector('slot[name="before"]'), this.afterSlot = this.shadowRoot.querySelector('slot[name="after"]'), (a = this.beforeSlot) == null || a.addEventListener("slotchange", () => this.updateSlotState()), (e = this.afterSlot) == null || e.addEventListener("slotchange", () => this.updateSlotState()), this.updateSlotState(), this.updateActiveState();
|
|
61
317
|
}
|
|
62
318
|
updateActiveState() {
|
|
63
319
|
const t = this.hasAttribute("active");
|
|
64
|
-
this.setAttribute("role", "tab"), this.setAttribute("aria-selected", t ? "true" : "false"), this.setAttribute("tabindex", t ? "0" : "-1"), this.
|
|
320
|
+
this.setAttribute("role", "tab"), this.setAttribute("aria-selected", t ? "true" : "false"), this.setAttribute("tabindex", t ? "0" : "-1"), this.syncSlottedAffordances(this.beforeSlot), this.syncSlottedAffordances(this.afterSlot);
|
|
65
321
|
}
|
|
66
322
|
}
|
|
67
|
-
customElements.get("mui-tab-item") || customElements.define("mui-tab-item",
|
|
323
|
+
customElements.get("mui-tab-item") || customElements.define("mui-tab-item", i);
|
|
@@ -4,45 +4,52 @@ class l extends HTMLElement {
|
|
|
4
4
|
this._activeTab && this._updateHighlight(this._activeTab);
|
|
5
5
|
});
|
|
6
6
|
}
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return ["size", "variant"];
|
|
9
|
+
}
|
|
10
|
+
attributeChangedCallback(e, s, a) {
|
|
11
|
+
(e === "size" || e === "variant") && s !== a && (this._applySizeToChildren(), this._applyVariantToChildren(), this._activeTab && this._updateHighlight(this._activeTab));
|
|
12
|
+
}
|
|
7
13
|
connectedCallback() {
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium");
|
|
15
|
+
const e = this.getAttribute("speed") || "200";
|
|
16
|
+
this._animationSpeed = parseInt(e, 10);
|
|
10
17
|
const s = Array.from(this.children);
|
|
11
|
-
this.setAttribute("role", "tablist");
|
|
18
|
+
this._applySizeToChildren(s), this._applyVariantToChildren(s), this.setAttribute("role", "tablist");
|
|
12
19
|
const a = this.getAttribute("orientation") || "horizontal";
|
|
13
|
-
this.setAttribute("aria-orientation", a), this.addEventListener("keydown", (
|
|
14
|
-
const
|
|
20
|
+
this.setAttribute("aria-orientation", a), this.addEventListener("keydown", (t) => {
|
|
21
|
+
const i = Array.from(this.children), r = i.findIndex((d) => d.hasAttribute("active")), n = this.getAttribute("aria-orientation") || "horizontal";
|
|
15
22
|
let o = r;
|
|
16
|
-
switch (
|
|
23
|
+
switch (t.key) {
|
|
17
24
|
case "ArrowRight":
|
|
18
|
-
n === "horizontal" && (o = (r + 1) %
|
|
25
|
+
n === "horizontal" && (o = (r + 1) % i.length, t.preventDefault());
|
|
19
26
|
break;
|
|
20
27
|
case "ArrowLeft":
|
|
21
|
-
n === "horizontal" && (o = (r - 1 +
|
|
28
|
+
n === "horizontal" && (o = (r - 1 + i.length) % i.length, t.preventDefault());
|
|
22
29
|
break;
|
|
23
30
|
case "ArrowDown":
|
|
24
|
-
n === "vertical" && (o = (r + 1) %
|
|
31
|
+
n === "vertical" && (o = (r + 1) % i.length, t.preventDefault());
|
|
25
32
|
break;
|
|
26
33
|
case "ArrowUp":
|
|
27
|
-
n === "vertical" && (o = (r - 1 +
|
|
34
|
+
n === "vertical" && (o = (r - 1 + i.length) % i.length, t.preventDefault());
|
|
28
35
|
break;
|
|
29
36
|
case "Home":
|
|
30
|
-
o = 0,
|
|
37
|
+
o = 0, t.preventDefault();
|
|
31
38
|
break;
|
|
32
39
|
case "End":
|
|
33
|
-
o =
|
|
40
|
+
o = i.length - 1, t.preventDefault();
|
|
34
41
|
break;
|
|
35
42
|
default:
|
|
36
43
|
return;
|
|
37
44
|
}
|
|
38
|
-
const h =
|
|
45
|
+
const h = i[o];
|
|
39
46
|
h && (this.setActiveTab(h), h.focus());
|
|
40
|
-
}), s.forEach((
|
|
41
|
-
|
|
42
|
-
}), s.forEach((
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
this.setActiveTab(
|
|
47
|
+
}), s.forEach((t, i) => {
|
|
48
|
+
t.classList.remove("first", "middle", "last", "only"), s.length === 1 ? t.classList.add("only") : i === 0 ? t.classList.add("first") : i === s.length - 1 ? t.classList.add("last") : t.classList.add("middle");
|
|
49
|
+
}), s.forEach((t) => {
|
|
50
|
+
const i = t;
|
|
51
|
+
i.addEventListener("click", () => {
|
|
52
|
+
this.setActiveTab(i);
|
|
46
53
|
});
|
|
47
54
|
}), this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
|
|
48
55
|
`
|
|
@@ -66,6 +73,29 @@ class l extends HTMLElement {
|
|
|
66
73
|
width: 100%;
|
|
67
74
|
}
|
|
68
75
|
|
|
76
|
+
:host([variant="dots"]) {
|
|
77
|
+
border: none;
|
|
78
|
+
border-radius: var(--radius-000);
|
|
79
|
+
background: transparent;
|
|
80
|
+
gap: var(--tab-dot-gap);
|
|
81
|
+
overflow: visible;
|
|
82
|
+
align-items: center;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:host([variant="ghost"]) {
|
|
86
|
+
border: none;
|
|
87
|
+
background: transparent;
|
|
88
|
+
box-shadow: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host([variant="ghost"]) .highlight {
|
|
92
|
+
box-shadow: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([variant="dots"][full-width]) {
|
|
96
|
+
justify-content: center;
|
|
97
|
+
}
|
|
98
|
+
|
|
69
99
|
.highlight {
|
|
70
100
|
border-radius: calc(var(--tab-radius) - 0.2rem);
|
|
71
101
|
position: absolute;
|
|
@@ -82,6 +112,10 @@ class l extends HTMLElement {
|
|
|
82
112
|
width: 0;
|
|
83
113
|
}
|
|
84
114
|
|
|
115
|
+
:host([variant="dots"]) .highlight {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
85
119
|
::slotted(mui-tab-item) {
|
|
86
120
|
position: relative;
|
|
87
121
|
z-index: 1;
|
|
@@ -89,18 +123,34 @@ class l extends HTMLElement {
|
|
|
89
123
|
contain: content; /* Performance optimization */
|
|
90
124
|
transform: translateZ(0);
|
|
91
125
|
}
|
|
126
|
+
|
|
127
|
+
:host([variant="dots"]) ::slotted(mui-tab-item) {
|
|
128
|
+
flex: 0;
|
|
129
|
+
}
|
|
92
130
|
</style>
|
|
93
131
|
<div class="highlight"></div>
|
|
94
132
|
<slot></slot>
|
|
95
133
|
`, window.addEventListener("resize", this._handleResize), this._resizeObserver.observe(this), requestAnimationFrame(() => {
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
134
|
+
const t = this.shadowRoot.querySelector(".highlight");
|
|
135
|
+
t.style.transition = "none";
|
|
136
|
+
const i = s.find((r) => r.hasAttribute("active")) || s[0];
|
|
137
|
+
i && (this._activeTab = i, i.setAttribute("active", ""), this._updateHighlight(i), this._observedTab = i, this._resizeObserver.observe(i)), t.offsetWidth, requestAnimationFrame(() => {
|
|
138
|
+
t.style.transition = "", this._hasInitialized = !0;
|
|
101
139
|
});
|
|
102
140
|
}));
|
|
103
141
|
}
|
|
142
|
+
_applySizeToChildren(e) {
|
|
143
|
+
const s = this.getAttribute("size") || "medium";
|
|
144
|
+
(e || Array.from(this.children)).forEach((t) => {
|
|
145
|
+
t.tagName.toLowerCase() === "mui-tab-item" && t.setAttribute("size", s);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
_applyVariantToChildren(e) {
|
|
149
|
+
const s = this.getAttribute("variant") || "default";
|
|
150
|
+
(e || Array.from(this.children)).forEach((t) => {
|
|
151
|
+
t.tagName.toLowerCase() === "mui-tab-item" && t.setAttribute("variant", s);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
104
154
|
disconnectedCallback() {
|
|
105
155
|
window.removeEventListener("resize", this._handleResize), this._observedTab && this._resizeObserver.unobserve(this._observedTab), this._resizeObserver.unobserve(this), this._resizeTimeout && clearTimeout(this._resizeTimeout), this._resizeObserver.disconnect();
|
|
106
156
|
}
|
|
@@ -109,27 +159,28 @@ class l extends HTMLElement {
|
|
|
109
159
|
this._resizeTimeout && clearTimeout(this._resizeTimeout), this._activeTab && Array.from(this.children).forEach((s) => {
|
|
110
160
|
s === this._activeTab ? s.setAttribute("active", "") : s.removeAttribute("active");
|
|
111
161
|
});
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
162
|
+
const e = this.shadowRoot.querySelector(".highlight");
|
|
163
|
+
e && (e.style.transition = "none", this._updateHighlight(this._activeTab), e.offsetWidth, this._resizeTimeout = window.setTimeout(() => {
|
|
164
|
+
e.style.transition = "", this._updateHighlight(this._activeTab);
|
|
115
165
|
}, 100));
|
|
116
166
|
}
|
|
117
|
-
_updateHighlight(
|
|
118
|
-
|
|
167
|
+
_updateHighlight(e) {
|
|
168
|
+
if (this.getAttribute("variant") === "dots") return;
|
|
169
|
+
const s = this.shadowRoot.querySelector(".highlight"), a = e.getBoundingClientRect(), t = this.getBoundingClientRect(), i = parseFloat(getComputedStyle(this).borderWidth) || 0, r = a.left - t.left - i;
|
|
119
170
|
s.style.transform = `translateX(${r}px) translateZ(0)`, s.style.width = `${a.width}px`;
|
|
120
171
|
}
|
|
121
|
-
setActiveTab(
|
|
122
|
-
if (Array.from(this.children).forEach((a) => a.removeAttribute("active")),
|
|
123
|
-
this._updateHighlight(
|
|
172
|
+
setActiveTab(e) {
|
|
173
|
+
if (Array.from(this.children).forEach((a) => a.removeAttribute("active")), e.setAttribute("active", ""), this._activeTab = e, this._observedTab && this._observedTab !== e && this._resizeObserver.unobserve(this._observedTab), this._observedTab = e, this._resizeObserver.observe(e), this._hasInitialized)
|
|
174
|
+
this._updateHighlight(e);
|
|
124
175
|
else {
|
|
125
176
|
const a = this.shadowRoot.querySelector(".highlight");
|
|
126
|
-
a.style.transition = "none", this._updateHighlight(
|
|
177
|
+
a.style.transition = "none", this._updateHighlight(e), a.offsetWidth, a.style.transition = "", this._hasInitialized = !0;
|
|
127
178
|
}
|
|
128
179
|
this.dispatchEvent(
|
|
129
180
|
new CustomEvent("tab-change", {
|
|
130
181
|
bubbles: !0,
|
|
131
182
|
composed: !0,
|
|
132
|
-
detail: { activeId:
|
|
183
|
+
detail: { activeId: e.id }
|
|
133
184
|
})
|
|
134
185
|
);
|
|
135
186
|
}
|