@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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import "../mui-body/index.js";
|
|
2
|
+
class c extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ["checked", "disabled", "id", "name", "value", "aria-label", "size"];
|
|
5
|
+
}
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), this.attachShadow({ mode: "open" });
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.render(), this.setupListener();
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
this.cleanupListeners();
|
|
14
|
+
}
|
|
15
|
+
attributeChangedCallback(e, i, a) {
|
|
16
|
+
var r;
|
|
17
|
+
const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
18
|
+
if (e === "checked") {
|
|
19
|
+
t && (t.checked = a !== null);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (e === "disabled") {
|
|
23
|
+
t && (t.disabled = a !== null);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
["id", "name", "value", "aria-label", "size"].includes(e) && (this.render(), this.setupListener());
|
|
27
|
+
}
|
|
28
|
+
cleanupListeners() {
|
|
29
|
+
var i;
|
|
30
|
+
const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("input");
|
|
31
|
+
e && this._changeHandler && e.removeEventListener("change", this._changeHandler);
|
|
32
|
+
}
|
|
33
|
+
setupListener() {
|
|
34
|
+
var i;
|
|
35
|
+
const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("input");
|
|
36
|
+
e && (this.cleanupListeners(), this._changeHandler = (a) => {
|
|
37
|
+
const t = a.target;
|
|
38
|
+
t.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.dispatchEvent(
|
|
39
|
+
new CustomEvent("change", {
|
|
40
|
+
detail: {
|
|
41
|
+
checked: t.checked,
|
|
42
|
+
value: t.value,
|
|
43
|
+
name: t.name
|
|
44
|
+
},
|
|
45
|
+
bubbles: !0,
|
|
46
|
+
composed: !0
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
}, e.addEventListener("change", this._changeHandler));
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
const e = this.getAttribute("id") || `mui-radio-${Math.random().toString(36).substr(2, 9)}`, i = this.getAttribute("name") || "", a = this.getAttribute("value") || "", t = this.hasAttribute("checked"), r = this.hasAttribute("disabled"), o = this.getAttribute("aria-label") || "", s = this.getAttribute("size") || "medium", d = ["x-small", "small", "medium", "large"].includes(s) ? s : "medium", l = this.innerHTML.trim().length > 0;
|
|
53
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
54
|
+
`
|
|
55
|
+
<style>
|
|
56
|
+
:host {
|
|
57
|
+
display: flex;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
label {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: var(--space-200);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
:host([disabled]) label {
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
69
|
+
:host([disabled]) mui-body {
|
|
70
|
+
cursor: not-allowed;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
input[type="radio"] {
|
|
74
|
+
all: unset;
|
|
75
|
+
width: var(--radio-size);
|
|
76
|
+
height: var(--radio-size);
|
|
77
|
+
border: var(--border-thin);
|
|
78
|
+
border-color: var(--radio-border-color);
|
|
79
|
+
border-radius: var(--radius-500);
|
|
80
|
+
display: inline-block;
|
|
81
|
+
vertical-align: middle;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
background: var(--radio-background);
|
|
84
|
+
position: relative;
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
}
|
|
87
|
+
:host([size="x-small"]) input[type="radio"] {
|
|
88
|
+
width: calc(var(--radio-size) - var(--space-100));
|
|
89
|
+
height: calc(var(--radio-size) - var(--space-100));
|
|
90
|
+
}
|
|
91
|
+
:host([size="small"]) input[type="radio"] {
|
|
92
|
+
width: calc(var(--radio-size) - var(--space-050));
|
|
93
|
+
height: calc(var(--radio-size) - var(--space-050));
|
|
94
|
+
}
|
|
95
|
+
:host([size="large"]) input[type="radio"] {
|
|
96
|
+
width: calc(var(--radio-size) + var(--space-100));
|
|
97
|
+
height: calc(var(--radio-size) + var(--space-100));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
input[type="radio"]:hover {
|
|
101
|
+
border-color: var(--radio-border-color-hover);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
input[type="radio"]:focus {
|
|
105
|
+
outline: var(--outline-medium);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
input[type="radio"]::after {
|
|
109
|
+
content: "";
|
|
110
|
+
position: absolute;
|
|
111
|
+
inset: 50%;
|
|
112
|
+
width: 55%;
|
|
113
|
+
height: 55%;
|
|
114
|
+
transform: translate(-50%, -50%);
|
|
115
|
+
border-radius: var(--radius-500);
|
|
116
|
+
background: var(--radio-dot-color-checked);
|
|
117
|
+
opacity: 0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
input[type="radio"]:checked {
|
|
121
|
+
border-color: var(--radio-border-color-checked);
|
|
122
|
+
background: var(--radio-background);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
input[type="radio"]:checked::after {
|
|
126
|
+
opacity: 1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
input:disabled {
|
|
130
|
+
background: var(--radio-background-disabled);
|
|
131
|
+
border-color: var(--radio-border-color-disabled);
|
|
132
|
+
cursor: not-allowed;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
input[type="radio"]:disabled::after {
|
|
136
|
+
background: var(--radio-dot-color-checked-disabled);
|
|
137
|
+
}
|
|
138
|
+
</style>
|
|
139
|
+
|
|
140
|
+
<label>
|
|
141
|
+
<input
|
|
142
|
+
type="radio"
|
|
143
|
+
id="${e}"
|
|
144
|
+
name="${i}"
|
|
145
|
+
value="${a}"
|
|
146
|
+
${t ? "checked" : ""}
|
|
147
|
+
${r ? "disabled" : ""}
|
|
148
|
+
${o ? `aria-label="${o}"` : ""}
|
|
149
|
+
/>
|
|
150
|
+
${l ? `<mui-body size="${d === "x-small" || d === "small" ? "x-small" : "small"}"><slot></slot></mui-body>` : ""}
|
|
151
|
+
</label>
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
customElements.get("mui-radio") || customElements.define("mui-radio", c);
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
class r extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(), this._groupName = "", this.onRadioChange = (e) => {
|
|
4
|
+
const t = e.target;
|
|
5
|
+
if (t.tagName.toLowerCase() !== "mui-radio" || !t.hasAttribute("checked")) return;
|
|
6
|
+
const a = t.getAttribute("value") || "";
|
|
7
|
+
this.setAttribute("value", a), this.getRadios().forEach((s) => {
|
|
8
|
+
s !== t && s.removeAttribute("checked");
|
|
9
|
+
}), this.dispatchEvent(
|
|
10
|
+
new CustomEvent("change", {
|
|
11
|
+
detail: { value: a, name: this._groupName },
|
|
12
|
+
bubbles: !0,
|
|
13
|
+
composed: !0
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}, this.attachShadow({ mode: "open" });
|
|
17
|
+
}
|
|
18
|
+
static get observedAttributes() {
|
|
19
|
+
return ["name", "value", "disabled", "size", "label", "hide-label", "optional"];
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
var e, t;
|
|
23
|
+
this.hasAttribute("role") || this.setAttribute("role", "radiogroup"), this.hasAttribute("size") || this.setAttribute("size", "medium"), this._groupName = this.getAttribute("name") || this.generateGroupName(), this.render(), this.syncRadios(), (t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("slot")) == null || t.addEventListener("slotchange", () => this.syncRadios()), this.addEventListener("change", this.onRadioChange);
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
this.removeEventListener("change", this.onRadioChange);
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e, t, a) {
|
|
29
|
+
e === "name" && a && (this._groupName = a), this.syncRadios();
|
|
30
|
+
}
|
|
31
|
+
generateGroupName() {
|
|
32
|
+
return `mui-radio-group-${Math.random().toString(36).substr(2, 9)}`;
|
|
33
|
+
}
|
|
34
|
+
getRadios() {
|
|
35
|
+
return Array.from(this.querySelectorAll("mui-radio"));
|
|
36
|
+
}
|
|
37
|
+
syncRadios() {
|
|
38
|
+
const e = this.hasAttribute("disabled"), t = this.getAttribute("value") || "", a = this.getAttribute("size") || "medium";
|
|
39
|
+
this.getRadios().forEach((i) => {
|
|
40
|
+
i.setAttribute("name", this._groupName), i.setAttribute("size", a), e ? (i.setAttribute("disabled", ""), i.setAttribute("data-group-disabled", "")) : i.hasAttribute("data-group-disabled") && (i.removeAttribute("disabled"), i.removeAttribute("data-group-disabled"));
|
|
41
|
+
const o = i.getAttribute("value") || "";
|
|
42
|
+
t && o === t ? i.setAttribute("checked", "") : t && i.removeAttribute("checked");
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
if (!this.shadowRoot) return;
|
|
47
|
+
const e = this.getAttribute("label") || "", t = this.hasAttribute("hide-label"), a = this.hasAttribute("optional"), s = `mui-radio-group-label-${this._groupName}`, i = a ? '<span class="optional"><span class="optional-dot">•</span><span class="optional-text">Optional</span></span>' : "";
|
|
48
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
49
|
+
`
|
|
50
|
+
<style>
|
|
51
|
+
:host {
|
|
52
|
+
display: grid;
|
|
53
|
+
gap: var(--space-200);
|
|
54
|
+
}
|
|
55
|
+
label {
|
|
56
|
+
font-size: var(--text-font-size);
|
|
57
|
+
font-weight: var(--font-weight-medium);
|
|
58
|
+
margin-bottom: var(--space-100);
|
|
59
|
+
color: var(--text-color);
|
|
60
|
+
display: block;
|
|
61
|
+
}
|
|
62
|
+
.label-with-optional {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
gap: var(--space-100);
|
|
66
|
+
}
|
|
67
|
+
.vh {
|
|
68
|
+
position: absolute;
|
|
69
|
+
width: 1px;
|
|
70
|
+
height: 1px;
|
|
71
|
+
margin: -1px;
|
|
72
|
+
padding: 0;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
clip: rect(0 0 0 0);
|
|
75
|
+
white-space: nowrap;
|
|
76
|
+
border: 0;
|
|
77
|
+
}
|
|
78
|
+
.optional {
|
|
79
|
+
color: var(--text-color-optional);
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
gap: var(--space-050);
|
|
83
|
+
font-size: var(--text-font-size-xs);
|
|
84
|
+
line-height: var(--text-line-height-xs);
|
|
85
|
+
text-transform: uppercase;
|
|
86
|
+
font-weight: var(--font-weight-medium);
|
|
87
|
+
}
|
|
88
|
+
.optional-dot {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
line-height: 1;
|
|
92
|
+
}
|
|
93
|
+
.optional-text {
|
|
94
|
+
transform: translateY(calc(var(--stroke-size-100) * -1));
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
97
|
+
${e ? `<label id="${s}" class="${t ? "vh" : ""}">
|
|
98
|
+
<span class="label-with-optional">${e}${i}</span>
|
|
99
|
+
</label>` : ""}
|
|
100
|
+
<slot></slot>
|
|
101
|
+
`, e ? this.setAttribute("aria-labelledby", s) : this.removeAttribute("aria-labelledby");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
customElements.get("mui-radio-group") || customElements.define("mui-radio-group", r);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import "../mui-body/index.js";
|
|
2
|
+
class u extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ["min", "max", "value", "step", "disabled", "bubble", "bubble-format"];
|
|
5
|
+
}
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), this.attachShadow({ mode: "open" });
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.render(), this.bind();
|
|
11
|
+
}
|
|
12
|
+
attributeChangedCallback(e, t) {
|
|
13
|
+
e !== t && (this.render(), this.bind());
|
|
14
|
+
}
|
|
15
|
+
get value() {
|
|
16
|
+
return Number(this.getAttribute("value") || "0");
|
|
17
|
+
}
|
|
18
|
+
set value(e) {
|
|
19
|
+
this.setAttribute("value", String(Number.isFinite(e) ? e : 0));
|
|
20
|
+
}
|
|
21
|
+
getThumbSize() {
|
|
22
|
+
return Number(this.getAttribute("thumb-size") || "16");
|
|
23
|
+
}
|
|
24
|
+
formatTime(e) {
|
|
25
|
+
const t = Number.isFinite(e) ? Math.max(0, Math.floor(e)) : 0, r = Math.floor(t / 60), a = t % 60;
|
|
26
|
+
return `${r}:${String(a).padStart(2, "0")}`;
|
|
27
|
+
}
|
|
28
|
+
formatBubble(e) {
|
|
29
|
+
return (this.getAttribute("bubble-format") || "number").toLowerCase() === "time" ? this.formatTime(e) : String(Math.round(e * 100) / 100);
|
|
30
|
+
}
|
|
31
|
+
updateBubble() {
|
|
32
|
+
if (!this.shadowRoot) return;
|
|
33
|
+
const e = this.shadowRoot.querySelector("input"), t = this.shadowRoot.querySelector('[data-role="bubble"]');
|
|
34
|
+
if (!e || !t) return;
|
|
35
|
+
const r = Number(e.min || "0"), a = Number(e.max || "0"), i = Number(e.value || "0"), o = Math.max(0, a - r), s = o > 0 ? Math.max(0, Math.min(1, (i - r) / o)) : 0, n = this.getThumbSize();
|
|
36
|
+
t.textContent = this.formatBubble(i), t.style.left = `calc(${s * 100}% - ${(s - 0.5) * n}px)`;
|
|
37
|
+
}
|
|
38
|
+
bind() {
|
|
39
|
+
if (!this.shadowRoot) return;
|
|
40
|
+
const e = this.shadowRoot.querySelector(".range-wrap"), t = this.shadowRoot.querySelector("input");
|
|
41
|
+
if (!e || !t) return;
|
|
42
|
+
const r = () => {
|
|
43
|
+
this.hasAttribute("bubble") && (e.classList.add("show-bubble"), this.updateBubble());
|
|
44
|
+
}, a = () => e.classList.remove("show-bubble");
|
|
45
|
+
t.oninput = () => {
|
|
46
|
+
this.setAttribute("value", t.value), r(), this.dispatchEvent(
|
|
47
|
+
new CustomEvent("input", {
|
|
48
|
+
detail: { value: Number(t.value || "0") },
|
|
49
|
+
bubbles: !0,
|
|
50
|
+
composed: !0
|
|
51
|
+
})
|
|
52
|
+
), this.updateBubble();
|
|
53
|
+
}, t.onchange = () => {
|
|
54
|
+
this.dispatchEvent(
|
|
55
|
+
new CustomEvent("change", {
|
|
56
|
+
detail: { value: Number(t.value || "0") },
|
|
57
|
+
bubbles: !0,
|
|
58
|
+
composed: !0
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
}, t.onpointerdown = r, t.onpointerup = a, t.onfocus = r, t.onblur = a, t.onmouseenter = r, t.onmouseleave = a, t.onmousemove = () => {
|
|
62
|
+
e.classList.contains("show-bubble") && this.updateBubble();
|
|
63
|
+
}, this.updateBubble();
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
if (!this.shadowRoot) return;
|
|
67
|
+
const e = this.getAttribute("min") || "0", t = this.getAttribute("max") || "100", r = this.getAttribute("value") || "0", a = this.getAttribute("step") || "1", i = this.hasAttribute("disabled"), o = this.getAttribute("label") || "Range input";
|
|
68
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
69
|
+
`
|
|
70
|
+
<style>
|
|
71
|
+
:host {
|
|
72
|
+
display: inline-flex;
|
|
73
|
+
width: 100%;
|
|
74
|
+
}
|
|
75
|
+
.range-wrap {
|
|
76
|
+
position: relative;
|
|
77
|
+
width: 100%;
|
|
78
|
+
min-width: 0;
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
}
|
|
82
|
+
input[type="range"] {
|
|
83
|
+
width: 100%;
|
|
84
|
+
margin: 0;
|
|
85
|
+
accent-color: var(--range-input-accent-color, var(--grey-1200));
|
|
86
|
+
}
|
|
87
|
+
[data-role="bubble"] {
|
|
88
|
+
position: absolute;
|
|
89
|
+
bottom: calc(100% + var(--space-100));
|
|
90
|
+
left: 0;
|
|
91
|
+
transform: translateX(-50%);
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
opacity: 0;
|
|
95
|
+
transition: opacity var(--speed-200) ease;
|
|
96
|
+
border: var(--border-thin);
|
|
97
|
+
border-color: var(--range-input-bubble-border-color, var(--border-color));
|
|
98
|
+
border-radius: var(--radius-100);
|
|
99
|
+
background: var(--range-input-bubble-background, var(--surface-elevated-100));
|
|
100
|
+
padding: var(--space-025) var(--space-100);
|
|
101
|
+
z-index: 2;
|
|
102
|
+
}
|
|
103
|
+
.range-wrap.show-bubble [data-role="bubble"] {
|
|
104
|
+
opacity: 1;
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
107
|
+
<div class="range-wrap">
|
|
108
|
+
<input
|
|
109
|
+
type="range"
|
|
110
|
+
min="${e}"
|
|
111
|
+
max="${t}"
|
|
112
|
+
value="${r}"
|
|
113
|
+
step="${a}"
|
|
114
|
+
aria-label="${o.replace(/"/g, """)}"
|
|
115
|
+
${i ? "disabled" : ""}
|
|
116
|
+
/>
|
|
117
|
+
<mui-body data-role="bubble" size="x-small" variant="optional" aria-hidden="true">0</mui-body>
|
|
118
|
+
</div>
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
customElements.get("mui-range-input") || customElements.define("mui-range-input", u);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class o extends HTMLElement {
|
|
2
2
|
static get observedAttributes() {
|
|
3
3
|
return ["length", "weight", "direction"];
|
|
4
4
|
}
|
|
@@ -6,11 +6,15 @@ class s extends HTMLElement {
|
|
|
6
6
|
super(), this.attachShadow({ mode: "open" });
|
|
7
7
|
}
|
|
8
8
|
connectedCallback() {
|
|
9
|
-
this.shadowRoot && (this.hasAttribute("direction") || this.setAttribute("direction", "horizontal"), this.setAttribute("role", "presentation"), this.updateStyles());
|
|
9
|
+
this.shadowRoot && (this.hasAttribute("direction") || this.setAttribute("direction", "horizontal"), this.setAttribute("role", "presentation"), this.syncContextAttributes(), this.updateStyles());
|
|
10
10
|
}
|
|
11
11
|
attributeChangedCallback() {
|
|
12
12
|
this.updateStyles();
|
|
13
13
|
}
|
|
14
|
+
syncContextAttributes() {
|
|
15
|
+
const t = !!this.closest("mui-card"), e = !!this.closest("mui-form-section");
|
|
16
|
+
this.toggleAttribute("in-card", t), this.toggleAttribute("in-form-section", e);
|
|
17
|
+
}
|
|
14
18
|
updateStyles() {
|
|
15
19
|
const t = this.getAttribute("length") || "100%", e = this.getAttribute("weight") || "1px", i = (
|
|
16
20
|
/*css*/
|
|
@@ -19,6 +23,10 @@ class s extends HTMLElement {
|
|
|
19
23
|
display: block;
|
|
20
24
|
background: var(--border-color);
|
|
21
25
|
}
|
|
26
|
+
:host([in-card]),
|
|
27
|
+
:host([in-form-section]) {
|
|
28
|
+
background: color-mix(in srgb, var(--border-color) 50%, transparent);
|
|
29
|
+
}
|
|
22
30
|
:host([direction="horizontal"]) {
|
|
23
31
|
width: ${t};
|
|
24
32
|
height: ${e};
|
|
@@ -32,4 +40,4 @@ class s extends HTMLElement {
|
|
|
32
40
|
this.shadowRoot.innerHTML = `<style>${i}</style>`;
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
|
-
customElements.get("mui-rule") || customElements.define("mui-rule",
|
|
43
|
+
customElements.get("mui-rule") || customElements.define("mui-rule", o);
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { getPartMap as s } from "../../utils/part-map/index.js";
|
|
2
2
|
import "../mui-icons/down-chevron/index.js";
|
|
3
|
-
class
|
|
3
|
+
class x extends HTMLElement {
|
|
4
4
|
constructor() {
|
|
5
5
|
super(), this.partMap = "", this.attachShadow({ mode: "open" });
|
|
6
6
|
}
|
|
7
7
|
static get observedAttributes() {
|
|
8
|
-
return ["name", "value", "id", "label", "options", "disabled", "hide-label", "variant"];
|
|
8
|
+
return ["name", "value", "id", "label", "options", "disabled", "hide-label", "variant", "optional", "size"];
|
|
9
9
|
}
|
|
10
10
|
async connectedCallback() {
|
|
11
|
-
await this.waitForPartMap(), this.partMap = s("text", "visual"), this.render(), this.setupListener();
|
|
11
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), await this.waitForPartMap(), this.partMap = s("text", "visual"), this.render(), this.setupListener();
|
|
12
12
|
}
|
|
13
13
|
disconnectedCallback() {
|
|
14
14
|
this.cleanupListeners();
|
|
15
15
|
}
|
|
16
|
-
attributeChangedCallback(e,
|
|
17
|
-
if (!this.shadowRoot ||
|
|
16
|
+
attributeChangedCallback(e, t, r) {
|
|
17
|
+
if (!this.shadowRoot || t === r) return;
|
|
18
18
|
const o = this.shadowRoot.querySelector("select");
|
|
19
19
|
if (e === "value" && o) {
|
|
20
|
-
o.value =
|
|
20
|
+
o.value = r || "";
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
if (e === "disabled" && o) {
|
|
24
|
-
|
|
24
|
+
r === null || r === "false" ? o.removeAttribute("disabled") : o.setAttribute("disabled", "");
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
["options", "label", "hide-label", "variant"].includes(e) && (this.render(), this.setupListener());
|
|
27
|
+
["options", "label", "hide-label", "variant", "optional", "size"].includes(e) && (this.render(), this.setupListener());
|
|
28
28
|
}
|
|
29
29
|
cleanupListeners() {
|
|
30
|
-
var
|
|
31
|
-
const e = (
|
|
30
|
+
var t;
|
|
31
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("select");
|
|
32
32
|
e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
|
|
33
33
|
}
|
|
34
34
|
setupListener() {
|
|
35
35
|
if (!this.shadowRoot) return;
|
|
36
36
|
const e = this.shadowRoot.querySelector("select");
|
|
37
|
-
e && (this.cleanupListeners(), this._changeHandler = (
|
|
38
|
-
const
|
|
39
|
-
this.setAttribute("value",
|
|
37
|
+
e && (this.cleanupListeners(), this._changeHandler = (t) => {
|
|
38
|
+
const r = t.target;
|
|
39
|
+
this.setAttribute("value", r.value);
|
|
40
40
|
const o = {
|
|
41
|
-
detail: { value:
|
|
41
|
+
detail: { value: r.value },
|
|
42
42
|
bubbles: !0,
|
|
43
43
|
composed: !0
|
|
44
44
|
};
|
|
@@ -47,16 +47,21 @@ class p extends HTMLElement {
|
|
|
47
47
|
}
|
|
48
48
|
render() {
|
|
49
49
|
if (!this.shadowRoot) return;
|
|
50
|
-
const e = this.getAttribute("name") || "",
|
|
51
|
-
|
|
50
|
+
const e = this.getAttribute("name") || "", t = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, r = this.getAttribute("label") || "", o = this.getAttribute("value") || "", i = this.hasAttribute("hide-label"), h = this.hasAttribute("optional"), v = this.hasAttribute("disabled"), p = this.getAttribute("options") || "[]", n = this.getAttribute("size") || "medium", l = ["x-small", "small", "medium", "large"].includes(n) ? n : "medium", u = {
|
|
51
|
+
"x-small": "xx-small",
|
|
52
|
+
small: "x-small",
|
|
53
|
+
medium: "x-small",
|
|
54
|
+
large: "small"
|
|
55
|
+
}[l] || "x-small", c = this.getAttribute("variant") || "", b = c || "", m = i && r ? `aria-label="${r}"` : "";
|
|
56
|
+
let d = [];
|
|
52
57
|
try {
|
|
53
|
-
|
|
58
|
+
d = JSON.parse(p);
|
|
54
59
|
} catch (a) {
|
|
55
60
|
console.error("Invalid JSON in options attribute", a);
|
|
56
61
|
}
|
|
57
|
-
const
|
|
62
|
+
const g = d.map(
|
|
58
63
|
(a) => `<option value="${a.value}" ${a.value === o ? "selected" : ""} ${a.disabled ? "disabled" : ""}>${a.label}</option>`
|
|
59
|
-
).join(""),
|
|
64
|
+
).join(""), f = (
|
|
60
65
|
/*html*/
|
|
61
66
|
`
|
|
62
67
|
<style>
|
|
@@ -85,6 +90,30 @@ class p extends HTMLElement {
|
|
|
85
90
|
box-sizing: border-box;
|
|
86
91
|
appearance: none;
|
|
87
92
|
}
|
|
93
|
+
select.size-x-small {
|
|
94
|
+
min-height: var(--action-icon-only-size-x-small);
|
|
95
|
+
padding: var(--action-padding-x-small);
|
|
96
|
+
font-size: var(--text-font-size-xs);
|
|
97
|
+
line-height: var(--text-line-height-xs);
|
|
98
|
+
}
|
|
99
|
+
select.size-small {
|
|
100
|
+
min-height: var(--action-icon-only-size-small);
|
|
101
|
+
padding: var(--action-padding-small);
|
|
102
|
+
font-size: var(--text-font-size-s);
|
|
103
|
+
line-height: var(--text-line-height-s);
|
|
104
|
+
}
|
|
105
|
+
select.size-medium {
|
|
106
|
+
min-height: 4.4rem;
|
|
107
|
+
padding: var(--space-200) var(--space-300);
|
|
108
|
+
font-size: var(--text-font-size);
|
|
109
|
+
line-height: var(--text-line-height);
|
|
110
|
+
}
|
|
111
|
+
select.size-large {
|
|
112
|
+
min-height: var(--action-icon-only-size-large);
|
|
113
|
+
padding: var(--space-300) var(--space-400);
|
|
114
|
+
font-size: var(--text-font-size-l);
|
|
115
|
+
line-height: var(--text-line-height-l);
|
|
116
|
+
}
|
|
88
117
|
select:hover {
|
|
89
118
|
border-color: var(--form-default-border-color-hover);
|
|
90
119
|
color: var(--form-default-text-color-hover);
|
|
@@ -138,6 +167,24 @@ class p extends HTMLElement {
|
|
|
138
167
|
white-space: nowrap;
|
|
139
168
|
border: 0;
|
|
140
169
|
}
|
|
170
|
+
.optional {
|
|
171
|
+
color: var(--text-color-optional);
|
|
172
|
+
display: inline-flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
gap: var(--space-050);
|
|
175
|
+
font-size: var(--text-font-size-xs);
|
|
176
|
+
line-height: var(--text-line-height-xs);
|
|
177
|
+
text-transform: uppercase;
|
|
178
|
+
font-weight: var(--font-weight-medium);
|
|
179
|
+
}
|
|
180
|
+
.optional-dot {
|
|
181
|
+
display: inline-flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
line-height: 1;
|
|
184
|
+
}
|
|
185
|
+
.optional-text {
|
|
186
|
+
transform: translateY(calc(var(--stroke-size-100) * -1));
|
|
187
|
+
}
|
|
141
188
|
.chevron {
|
|
142
189
|
position: absolute;
|
|
143
190
|
right: var(--space-300);
|
|
@@ -150,6 +197,18 @@ class p extends HTMLElement {
|
|
|
150
197
|
box-shadow: -4px 0 4px 0 var(--input-background);
|
|
151
198
|
pointer-events: none;
|
|
152
199
|
}
|
|
200
|
+
:host([size="x-small"]) .chevron,
|
|
201
|
+
:host([size="small"]) .chevron {
|
|
202
|
+
right: var(--space-200);
|
|
203
|
+
padding: var(--space-000);
|
|
204
|
+
box-shadow: none;
|
|
205
|
+
}
|
|
206
|
+
:host([size="large"]) .chevron {
|
|
207
|
+
right: var(--space-400);
|
|
208
|
+
padding: var(--space-300);
|
|
209
|
+
padding-left: var(--space-000);
|
|
210
|
+
padding-right: var(--space-000);
|
|
211
|
+
}
|
|
153
212
|
|
|
154
213
|
select:disabled + .chevron {
|
|
155
214
|
background: transparent;
|
|
@@ -192,29 +251,29 @@ class p extends HTMLElement {
|
|
|
192
251
|
/* ========================================================================== */
|
|
193
252
|
|
|
194
253
|
</style>
|
|
195
|
-
${
|
|
254
|
+
${r ? (
|
|
196
255
|
/*html*/
|
|
197
|
-
`<label for="${
|
|
256
|
+
`<label for="${t}" class="${i ? "vh" : ""}">${r}${h ? ' <span class="optional"><span class="optional-dot" aria-hidden="true">•</span><span class="optional-text">Optional</span></span>' : ""}</label>`
|
|
198
257
|
) : ""}
|
|
199
258
|
<div style="position: relative;">
|
|
200
|
-
<select class="${
|
|
201
|
-
${
|
|
202
|
-
${
|
|
259
|
+
<select class="${[b, `size-${l}`].filter(Boolean).join(" ")}" part="${this.partMap || ""}" name="${e}" id="${t}" ${m}
|
|
260
|
+
${v ? "disabled" : ""}>
|
|
261
|
+
${g}
|
|
203
262
|
</select>
|
|
204
|
-
<mui-icon-down-chevron class="chevron" size="
|
|
263
|
+
<mui-icon-down-chevron class="chevron" size="${u}"></mui-icon-down-chevron>
|
|
205
264
|
</div>
|
|
206
265
|
`
|
|
207
266
|
);
|
|
208
|
-
this.shadowRoot.innerHTML =
|
|
267
|
+
this.shadowRoot.innerHTML = f;
|
|
209
268
|
}
|
|
210
269
|
waitForPartMap() {
|
|
211
270
|
return new Promise((e) => {
|
|
212
271
|
if (typeof s == "function") return e();
|
|
213
|
-
const
|
|
214
|
-
typeof s == "function" ? e() : requestAnimationFrame(
|
|
272
|
+
const t = () => {
|
|
273
|
+
typeof s == "function" ? e() : requestAnimationFrame(t);
|
|
215
274
|
};
|
|
216
|
-
|
|
275
|
+
t();
|
|
217
276
|
});
|
|
218
277
|
}
|
|
219
278
|
}
|
|
220
|
-
customElements.get("mui-select") || customElements.define("mui-select",
|
|
279
|
+
customElements.get("mui-select") || customElements.define("mui-select", x);
|