@muibook/components 20.0.0 → 20.1.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/AGENTS.md +67 -0
- package/DESIGN.md +358 -0
- package/README.md +52 -1
- package/dist/esm/agent/keywords/index.js +2 -204
- package/dist/esm/agent/prompts/index.js +6 -434
- package/dist/esm/components/mui-accordion/core/index.js +25 -17
- package/dist/esm/components/mui-avatar/index.js +99 -42
- package/dist/esm/components/mui-avatar-chip/index.js +158 -0
- package/dist/esm/components/mui-avatar-group/index.js +88 -0
- package/dist/esm/components/mui-badge/index.js +2 -2
- package/dist/esm/components/mui-body/index.js +20 -11
- package/dist/esm/components/mui-button/index.js +117 -65
- package/dist/esm/components/mui-calendar/index.js +199 -0
- package/dist/esm/components/mui-card/body/index.js +32 -17
- package/dist/esm/components/mui-card/footer/index.js +11 -9
- package/dist/esm/components/mui-carousel/controller/index.js +1 -1
- package/dist/esm/components/mui-checkbox/index.js +23 -18
- package/dist/esm/components/mui-chip/index.js +184 -68
- package/dist/esm/components/mui-chip-input/index.js +146 -137
- package/dist/esm/components/mui-chip-rail/index.js +154 -51
- package/dist/esm/components/mui-code/index.js +27 -8
- package/dist/esm/components/mui-container/index.js +68 -45
- package/dist/esm/components/mui-date-picker/index.js +169 -0
- package/dist/esm/components/mui-drawer/index.js +968 -100
- package/dist/esm/components/mui-dropdown/index.js +250 -63
- package/dist/esm/components/mui-field/index.js +1 -1
- package/dist/esm/components/mui-file-upload/index.js +13 -4
- package/dist/esm/components/mui-form-group/index.js +1 -2
- package/dist/esm/components/mui-form-message/index.js +4 -9
- package/dist/esm/components/mui-hint/index.js +178 -72
- package/dist/esm/components/mui-icons/copy/index.js +54 -0
- package/dist/esm/components/mui-icons/fullscreen/index.js +5 -0
- package/dist/esm/components/mui-icons/icon-helper/index.js +56 -0
- package/dist/esm/components/mui-icons/index.js +14 -1
- package/dist/esm/components/mui-icons/moon/index.js +3 -1
- package/dist/esm/components/mui-icons/{rectangle-bottom-panel → panel}/index.js +6 -6
- package/dist/esm/components/mui-icons/pause/index.js +5 -0
- package/dist/esm/components/mui-icons/picture-in-picture/index.js +5 -0
- package/dist/esm/components/mui-icons/play-fill/index.js +5 -0
- package/dist/esm/components/mui-icons/rectangle-right-drawer/index.js +56 -0
- package/dist/esm/components/mui-icons/reload/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-mute/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-one-wave/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-two-wave/index.js +5 -0
- package/dist/esm/components/mui-icons/spinner/index.js +7 -5
- package/dist/esm/components/mui-icons/stop-fill/index.js +5 -0
- package/dist/esm/components/mui-icons/sun/index.js +5 -5
- package/dist/esm/components/mui-icons/timer/index.js +54 -0
- package/dist/esm/components/mui-icons/toggle/index.js +16 -6
- package/dist/esm/components/mui-icons/vertical-ellipsis/index.js +5 -0
- package/dist/esm/components/mui-illustrations/trash/index.js +6 -5
- package/dist/esm/components/mui-input/index.js +87 -62
- package/dist/esm/components/mui-link/index.js +195 -83
- package/dist/esm/components/mui-media-player/index.js +1577 -83
- package/dist/esm/components/mui-model-viewer/index.js +258 -0
- package/dist/esm/components/mui-progress-ring/index.js +349 -0
- package/dist/esm/components/mui-prompt/index.js +99 -71
- package/dist/esm/components/mui-prompt-preview/index.js +11 -23
- package/dist/esm/components/mui-radio/index.js +38 -17
- package/dist/esm/components/mui-range-input/index.js +9 -4
- package/dist/esm/components/mui-responsive/index.js +60 -27
- package/dist/esm/components/mui-search-input/index.js +300 -0
- package/dist/esm/components/mui-select/index.js +231 -42
- package/dist/esm/components/mui-slat/slat/index.js +40 -12
- package/dist/esm/components/mui-spinner/index.js +11 -9
- package/dist/esm/components/mui-switch/index.js +23 -20
- package/dist/esm/components/mui-table/row/index.js +2 -6
- package/dist/esm/components/mui-table/table/index.js +157 -14
- package/dist/esm/components/mui-textarea/index.js +43 -26
- package/dist/esm/components/mui-time/index/index.js +336 -0
- package/dist/esm/components/mui-time-picker/index.js +126 -0
- package/dist/esm/components/mui-video-thumbnail/index.js +5 -5
- package/dist/esm/css/mui-brand.css +12 -8
- package/dist/esm/css/mui-tokens.css +417 -305
- package/dist/esm/css/readme.md +2 -2
- package/dist/esm/custom-elements.json +3678 -1553
- package/dist/esm/dynamic-attrs.json +263 -66
- package/dist/esm/index.js +30 -6
- package/dist/esm/knowledge/compositions/index.js +1560 -0
- package/dist/esm/knowledge/index.js +28 -0
- package/dist/esm/knowledge/keywords/index.js +306 -0
- package/dist/esm/knowledge/rules/index.js +199 -0
- package/dist/esm/tokens/js/index.js +143 -139
- package/dist/types/agent/keywords/index.d.ts +1 -1
- package/dist/types/components/mui-avatar-chip/api.d.ts +28 -0
- package/dist/types/components/mui-avatar-chip/index.d.ts +18 -0
- package/dist/types/components/mui-avatar-group/api.d.ts +28 -0
- package/dist/types/components/mui-avatar-group/doc.d.ts +2 -0
- package/dist/types/components/mui-avatar-group/index.d.ts +1 -0
- package/dist/types/components/mui-button/api.d.ts +2 -2
- package/dist/types/components/mui-calendar/api.d.ts +41 -0
- package/dist/types/components/mui-calendar/doc.d.ts +2 -0
- package/dist/types/components/mui-calendar/index.d.ts +3 -0
- package/dist/types/components/mui-checkbox/api.d.ts +4 -0
- package/dist/types/components/mui-chip-input/api.d.ts +4 -0
- package/dist/types/components/mui-chip-rail/index.d.ts +1 -0
- package/dist/types/components/mui-date-picker/api.d.ts +38 -0
- package/dist/types/components/mui-date-picker/doc.d.ts +2 -0
- package/dist/types/components/mui-date-picker/index.d.ts +6 -0
- package/dist/types/components/mui-drawer/api.d.ts +4 -0
- package/dist/types/components/mui-drawer/index.d.ts +2 -0
- package/dist/types/components/mui-file-upload/api.d.ts +4 -0
- package/dist/types/components/mui-icons/fullscreen.d.ts +1 -0
- package/dist/types/components/mui-icons/icon-helper.d.ts +1 -0
- package/dist/types/components/mui-icons/index.d.ts +14 -1
- package/dist/types/components/mui-icons/panel.d.ts +1 -0
- package/dist/types/components/mui-icons/pause.d.ts +1 -0
- package/dist/types/components/mui-icons/picture-in-picture.d.ts +1 -0
- package/dist/types/components/mui-icons/play-fill.d.ts +1 -0
- package/dist/types/components/mui-icons/rectangle-right-drawer.d.ts +1 -0
- package/dist/types/components/mui-icons/reload.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-mute.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-one-wave.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-two-wave.d.ts +1 -0
- package/dist/types/components/mui-icons/stop-fill.d.ts +1 -0
- package/dist/types/components/mui-icons/timer.d.ts +1 -0
- package/dist/types/components/mui-icons/vertical-ellipsis.d.ts +1 -0
- package/dist/types/components/mui-input/api.d.ts +12 -0
- package/dist/types/components/mui-media-player/api.d.ts +4 -0
- package/dist/types/components/mui-media-player/index.d.ts +13 -4
- package/dist/types/components/mui-model-viewer/api.d.ts +28 -0
- package/dist/types/components/mui-model-viewer/doc.d.ts +2 -0
- package/dist/types/components/mui-model-viewer/index.d.ts +17 -0
- package/dist/types/components/mui-progress-ring/api.d.ts +24 -0
- package/dist/types/components/mui-progress-ring/doc.d.ts +2 -0
- package/dist/types/components/mui-progress-ring/index.d.ts +1 -0
- package/dist/types/components/mui-radio/api.d.ts +12 -0
- package/dist/types/components/mui-range-input/api.d.ts +4 -0
- package/dist/types/components/mui-responsive/api.d.ts +10 -2
- package/dist/types/components/mui-search-input/api.d.ts +40 -0
- package/dist/types/components/mui-search-input/doc.d.ts +2 -0
- package/dist/types/components/mui-search-input/index.d.ts +3 -0
- package/dist/types/components/mui-select/api.d.ts +12 -0
- package/dist/types/components/mui-switch/api.d.ts +4 -0
- package/dist/types/components/mui-table/api.d.ts +15 -0
- package/dist/types/components/mui-textarea/api.d.ts +12 -0
- package/dist/types/components/mui-time/api.d.ts +41 -0
- package/dist/types/components/mui-time/doc.d.ts +2 -0
- package/dist/types/components/mui-time/index.d.ts +1 -0
- package/dist/types/components/mui-time-picker/api.d.ts +38 -0
- package/dist/types/components/mui-time-picker/doc.d.ts +2 -0
- package/dist/types/components/mui-time-picker/index.d.ts +4 -0
- package/dist/types/index.d.ts +24 -2
- package/dist/types/knowledge/compositions.d.ts +4644 -0
- package/dist/types/knowledge/index.d.ts +4657 -0
- package/dist/types/knowledge/keywords.d.ts +4 -0
- package/dist/types/knowledge/rules.d.ts +1 -0
- package/dist/types/tokens/js/index.d.ts +11 -7
- package/package.json +119 -12
- package/dist/esm/components/mui-form-hint/index.js +0 -1
- package/dist/types/components/mui-form-hint/index.d.ts +0 -1
- /package/dist/types/components/{mui-form-hint → mui-avatar-chip}/doc.d.ts +0 -0
- /package/dist/types/components/mui-icons/{rectangle-bottom-panel.d.ts → copy.d.ts} +0 -0
|
@@ -24,88 +24,89 @@ class w extends HTMLElement {
|
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
26
|
get value() {
|
|
27
|
-
return this.selectedItems.map((
|
|
27
|
+
return this.selectedItems.map((e) => ({ ...e }));
|
|
28
28
|
}
|
|
29
|
-
set value(
|
|
30
|
-
this.selectedItems = (Array.isArray(
|
|
29
|
+
set value(e) {
|
|
30
|
+
this.selectedItems = (Array.isArray(e) ? e : []).filter((t) => t && typeof t.value == "string").map((t) => ({ ...t, label: String(t.label ?? t.value), value: String(t.value) })), this.syncValueAttribute(), this.rerenderAndPreserveFocus(0, 0);
|
|
31
|
+
}
|
|
32
|
+
focus(e) {
|
|
33
|
+
const t = this.getInnerInput();
|
|
34
|
+
t ? t.focus(e) : super.focus(e);
|
|
31
35
|
}
|
|
32
36
|
connectedCallback() {
|
|
33
|
-
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.hasAttribute("id") || this.setAttribute(
|
|
34
|
-
"id",
|
|
35
|
-
`mui-chip-input-${Math.random().toString(36).slice(2, 9)}`
|
|
36
|
-
), this.syncSelectedFromAttribute(), this.setupBreakpointListener(), this.render(), this.setupListeners();
|
|
37
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.hasAttribute("id") || this.setAttribute("id", `mui-chip-input-${Math.random().toString(36).slice(2, 9)}`), this.syncSelectedFromAttribute(), this.setupBreakpointListener(), this.render(), this.setupListeners();
|
|
37
38
|
}
|
|
38
39
|
disconnectedCallback() {
|
|
39
40
|
this.cleanupBreakpointListener();
|
|
40
41
|
}
|
|
41
|
-
attributeChangedCallback(
|
|
42
|
-
|
|
42
|
+
attributeChangedCallback(e, t, i) {
|
|
43
|
+
t !== i && (e === "value" && this.syncSelectedFromAttribute(), (e === "breakpoint" || e === "mobile-stack") && this.setupBreakpointListener(), this.render(), this.setupListeners());
|
|
43
44
|
}
|
|
44
45
|
cleanupBreakpointListener() {
|
|
45
46
|
this.mql && this.mqlHandler && this.mql.removeEventListener("change", this.mqlHandler), this.mql = null, this.mqlHandler = null;
|
|
46
47
|
}
|
|
47
48
|
setupBreakpointListener() {
|
|
48
49
|
this.cleanupBreakpointListener();
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
Number.isNaN(
|
|
50
|
+
const e = this.getAttribute("breakpoint");
|
|
51
|
+
if (!e || this.hasAttribute("mobile-stack")) return;
|
|
52
|
+
const t = Number.parseInt(e, 10);
|
|
53
|
+
Number.isNaN(t) || t <= 0 || (this.mql = window.matchMedia(`(max-width: ${t}px)`), this.mqlHandler = () => {
|
|
53
54
|
this.render(), this.setupListeners();
|
|
54
55
|
}, this.mql.addEventListener("change", this.mqlHandler));
|
|
55
56
|
}
|
|
56
|
-
normalizeOption(
|
|
57
|
-
if (typeof
|
|
58
|
-
const
|
|
59
|
-
return
|
|
57
|
+
normalizeOption(e) {
|
|
58
|
+
if (typeof e == "string") {
|
|
59
|
+
const t = e.trim();
|
|
60
|
+
return t ? { value: t, label: t } : null;
|
|
60
61
|
}
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
62
|
+
if (e && typeof e == "object") {
|
|
63
|
+
const t = e, i = t.value, s = i == null ? "" : String(i).trim();
|
|
63
64
|
return s ? {
|
|
64
|
-
...
|
|
65
|
+
...t,
|
|
65
66
|
value: s,
|
|
66
|
-
label: String(
|
|
67
|
+
label: String(t.label ?? s).trim() || s
|
|
67
68
|
} : null;
|
|
68
69
|
}
|
|
69
70
|
return null;
|
|
70
71
|
}
|
|
71
72
|
parseOptions() {
|
|
72
|
-
const
|
|
73
|
-
let
|
|
73
|
+
const e = this.getAttribute("options") || "[]";
|
|
74
|
+
let t = [];
|
|
74
75
|
try {
|
|
75
|
-
|
|
76
|
+
t = JSON.parse(e);
|
|
76
77
|
} catch {
|
|
77
|
-
|
|
78
|
+
t = e.split(",").map((s) => s.trim()).filter(Boolean);
|
|
78
79
|
}
|
|
79
|
-
return Array.isArray(
|
|
80
|
+
return Array.isArray(t) ? t.map((i) => this.normalizeOption(i)).filter((i) => !!i) : [];
|
|
80
81
|
}
|
|
81
82
|
parseValueAttribute() {
|
|
82
|
-
const
|
|
83
|
-
let
|
|
83
|
+
const e = this.getAttribute("value") || "[]";
|
|
84
|
+
let t = [];
|
|
84
85
|
try {
|
|
85
|
-
|
|
86
|
+
t = JSON.parse(e);
|
|
86
87
|
} catch {
|
|
87
|
-
|
|
88
|
+
t = e.split(",").map((l) => l.trim()).filter(Boolean);
|
|
88
89
|
}
|
|
89
|
-
if (!Array.isArray(
|
|
90
|
-
const i = new Map(this.parseOptions().map((a) => [a.value.toLowerCase(), a])), s =
|
|
91
|
-
const
|
|
92
|
-
return
|
|
90
|
+
if (!Array.isArray(t)) return [];
|
|
91
|
+
const i = new Map(this.parseOptions().map((a) => [a.value.toLowerCase(), a])), s = t.map((a) => {
|
|
92
|
+
const l = this.normalizeOption(a);
|
|
93
|
+
return l ? i.get(l.value.toLowerCase()) || l : null;
|
|
93
94
|
}).filter((a) => !!a), r = /* @__PURE__ */ new Set();
|
|
94
95
|
return s.filter((a) => {
|
|
95
|
-
const
|
|
96
|
-
return r.has(
|
|
96
|
+
const l = a.value.toLowerCase();
|
|
97
|
+
return r.has(l) ? !1 : (r.add(l), !0);
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
syncSelectedFromAttribute() {
|
|
100
101
|
this.selectedItems = this.parseValueAttribute();
|
|
101
102
|
}
|
|
102
103
|
syncValueAttribute() {
|
|
103
|
-
const
|
|
104
|
-
this.getAttribute("value") !==
|
|
104
|
+
const e = JSON.stringify(this.selectedItems);
|
|
105
|
+
this.getAttribute("value") !== e && this.setAttribute("value", e);
|
|
105
106
|
}
|
|
106
107
|
get normalizedSize() {
|
|
107
|
-
const
|
|
108
|
-
return ["x-small", "small", "medium", "large"].includes(
|
|
108
|
+
const e = this.getAttribute("size") || "medium";
|
|
109
|
+
return ["x-small", "small", "medium", "large"].includes(e) ? e : "medium";
|
|
109
110
|
}
|
|
110
111
|
get allowCustom() {
|
|
111
112
|
return this.hasAttribute("allow-custom");
|
|
@@ -116,28 +117,28 @@ class w extends HTMLElement {
|
|
|
116
117
|
get placement() {
|
|
117
118
|
return this.getAttribute("placement") === "after" ? "after" : "before";
|
|
118
119
|
}
|
|
119
|
-
set placement(
|
|
120
|
-
const
|
|
121
|
-
this.setAttribute("placement",
|
|
120
|
+
set placement(e) {
|
|
121
|
+
const t = e === "after" ? "after" : "before";
|
|
122
|
+
this.setAttribute("placement", t);
|
|
122
123
|
}
|
|
123
124
|
get useStackLayout() {
|
|
124
125
|
if (this.hasAttribute("mobile-stack")) return !0;
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
const
|
|
128
|
-
return Number.isNaN(
|
|
126
|
+
const e = this.getAttribute("breakpoint");
|
|
127
|
+
if (!e) return !1;
|
|
128
|
+
const t = Number.parseInt(e, 10);
|
|
129
|
+
return Number.isNaN(t) || t <= 0 ? !1 : window.matchMedia(`(max-width: ${t}px)`).matches;
|
|
129
130
|
}
|
|
130
131
|
get selectedValues() {
|
|
131
|
-
return this.selectedItems.map((
|
|
132
|
+
return this.selectedItems.map((e) => e.value);
|
|
132
133
|
}
|
|
133
134
|
get filteredOptions() {
|
|
134
|
-
const
|
|
135
|
-
return this.parseOptions().filter((i) =>
|
|
135
|
+
const e = new Set(this.selectedValues.map((i) => i.toLowerCase())), t = this.inputValue.toLowerCase().trim();
|
|
136
|
+
return this.parseOptions().filter((i) => e.has(i.value.toLowerCase()) ? !1 : t ? i.label.toLowerCase().includes(t) : !0);
|
|
136
137
|
}
|
|
137
138
|
get showCreateOption() {
|
|
138
|
-
const
|
|
139
|
-
if (!this.allowCustom || !
|
|
140
|
-
const i = this.parseOptions().some((r) => r.value.toLowerCase() ===
|
|
139
|
+
const e = this.inputValue.trim();
|
|
140
|
+
if (!this.allowCustom || !e) return !1;
|
|
141
|
+
const i = this.parseOptions().some((r) => r.value.toLowerCase() === e.toLowerCase()), s = this.selectedValues.some((r) => r.toLowerCase() === e.toLowerCase());
|
|
141
142
|
return !i && !s;
|
|
142
143
|
}
|
|
143
144
|
emitQueryChange() {
|
|
@@ -149,76 +150,76 @@ class w extends HTMLElement {
|
|
|
149
150
|
})
|
|
150
151
|
);
|
|
151
152
|
}
|
|
152
|
-
emitChange(
|
|
153
|
+
emitChange(e, t, i) {
|
|
153
154
|
this.syncValueAttribute();
|
|
154
155
|
const s = {
|
|
155
|
-
action:
|
|
156
|
+
action: e,
|
|
156
157
|
values: this.selectedValues,
|
|
157
158
|
items: this.selectedItems.map((r) => ({ ...r })),
|
|
158
|
-
added:
|
|
159
|
+
added: t ? { ...t } : null,
|
|
159
160
|
removed: i ? { ...i } : null
|
|
160
161
|
};
|
|
161
162
|
this.dispatchEvent(new CustomEvent("chip-input-change", { detail: s, bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("change", { detail: s, bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("input", { detail: s, bubbles: !0, composed: !0 }));
|
|
162
163
|
}
|
|
163
|
-
setInputValue(
|
|
164
|
+
setInputValue(e) {
|
|
164
165
|
var i;
|
|
165
|
-
this.inputValue =
|
|
166
|
-
const
|
|
167
|
-
|
|
166
|
+
this.inputValue = e;
|
|
167
|
+
const t = (i = this.shadowRoot) == null ? void 0 : i.querySelector("mui-input");
|
|
168
|
+
t && t.setAttribute("value", e);
|
|
168
169
|
}
|
|
169
170
|
getInnerInput() {
|
|
170
|
-
var
|
|
171
|
-
const
|
|
172
|
-
return ((i =
|
|
171
|
+
var t, i;
|
|
172
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("mui-input");
|
|
173
|
+
return ((i = e == null ? void 0 : e.shadowRoot) == null ? void 0 : i.querySelector("input")) ?? null;
|
|
173
174
|
}
|
|
174
|
-
restoreInputFocus(
|
|
175
|
+
restoreInputFocus(e, t) {
|
|
175
176
|
requestAnimationFrame(() => {
|
|
176
177
|
const i = this.getInnerInput();
|
|
177
|
-
if (!(!i || this.disabled) && (i.focus({ preventScroll: !0 }), !(
|
|
178
|
+
if (!(!i || this.disabled) && (i.focus({ preventScroll: !0 }), !(e == null || t == null)))
|
|
178
179
|
try {
|
|
179
|
-
i.setSelectionRange(
|
|
180
|
+
i.setSelectionRange(e, t);
|
|
180
181
|
} catch {
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
}
|
|
184
|
-
rerenderAndPreserveFocus(
|
|
185
|
-
this.render(), this.setupListeners(), this.restoreInputFocus(
|
|
185
|
+
rerenderAndPreserveFocus(e, t) {
|
|
186
|
+
this.render(), this.setupListeners(), this.restoreInputFocus(e, t);
|
|
186
187
|
}
|
|
187
|
-
addValue(
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
190
|
-
const s = this.parseOptions().find((r) => r.value.toLowerCase() ===
|
|
188
|
+
addValue(e) {
|
|
189
|
+
const t = e.trim();
|
|
190
|
+
if (!t || this.selectedValues.some((r) => r.toLowerCase() === t.toLowerCase())) return;
|
|
191
|
+
const s = this.parseOptions().find((r) => r.value.toLowerCase() === t.toLowerCase()) || { value: t, label: t, custom: !0 };
|
|
191
192
|
this.selectedItems = [...this.selectedItems, s], this.highlightedIndex = -1, this.setInputValue(""), this.emitChange("add", s), this.rerenderAndPreserveFocus(0, 0);
|
|
192
193
|
}
|
|
193
|
-
removeValue(
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const i = this.selectedItems[
|
|
197
|
-
this.selectedItems = this.selectedItems.filter((r) => r.value !==
|
|
194
|
+
removeValue(e) {
|
|
195
|
+
const t = this.selectedItems.findIndex((r) => r.value === e);
|
|
196
|
+
if (t < 0) return;
|
|
197
|
+
const i = this.selectedItems[t];
|
|
198
|
+
this.selectedItems = this.selectedItems.filter((r) => r.value !== e), this.emitChange("remove", void 0, i);
|
|
198
199
|
const s = this.inputValue.length;
|
|
199
200
|
this.rerenderAndPreserveFocus(s, s);
|
|
200
201
|
}
|
|
201
|
-
handleKeyboard(
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
|
|
202
|
+
handleKeyboard(e) {
|
|
203
|
+
const t = this.filteredOptions, i = t.length + (this.showCreateOption ? 1 : 0);
|
|
204
|
+
if (e.key === "ArrowDown" && i > 0) {
|
|
205
|
+
e.preventDefault(), this.highlightedIndex = (this.highlightedIndex + 1 + i) % i, this.updateListbox();
|
|
205
206
|
return;
|
|
206
207
|
}
|
|
207
|
-
if (
|
|
208
|
-
|
|
208
|
+
if (e.key === "ArrowUp" && i > 0) {
|
|
209
|
+
e.preventDefault(), this.highlightedIndex = (this.highlightedIndex - 1 + i) % i, this.updateListbox();
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
|
-
if (
|
|
212
|
+
if (e.key === "Escape") {
|
|
212
213
|
this.highlightedIndex = -1, this.updateListbox();
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
|
-
if (
|
|
216
|
+
if (e.key === "Backspace" && !this.inputValue && this.selectedItems.length > 0) {
|
|
216
217
|
this.removeValue(this.selectedItems[this.selectedItems.length - 1].value);
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
219
|
-
if (
|
|
220
|
-
if (
|
|
221
|
-
this.addValue(
|
|
220
|
+
if (e.key === "Enter" || e.key === ",") {
|
|
221
|
+
if (e.preventDefault(), this.highlightedIndex >= 0 && this.highlightedIndex < t.length) {
|
|
222
|
+
this.addValue(t[this.highlightedIndex].value);
|
|
222
223
|
return;
|
|
223
224
|
}
|
|
224
225
|
this.showCreateOption && this.addValue(this.inputValue);
|
|
@@ -226,17 +227,17 @@ class w extends HTMLElement {
|
|
|
226
227
|
}
|
|
227
228
|
setupListeners() {
|
|
228
229
|
if (!this.shadowRoot) return;
|
|
229
|
-
const
|
|
230
|
-
if (!
|
|
231
|
-
|
|
230
|
+
const e = this.shadowRoot.querySelector("mui-input");
|
|
231
|
+
if (!e) return;
|
|
232
|
+
e.oninput = (i) => {
|
|
232
233
|
var a;
|
|
233
|
-
const s = (a = i.detail) == null ? void 0 : a.value, r =
|
|
234
|
+
const s = (a = i.detail) == null ? void 0 : a.value, r = e.getAttribute("value") || "";
|
|
234
235
|
this.inputValue = s ?? r, this.highlightedIndex = -1, this.emitQueryChange(), this.updateListbox();
|
|
235
|
-
},
|
|
236
|
+
}, e.onkeydown = (i) => {
|
|
236
237
|
this.handleKeyboard(i);
|
|
237
238
|
};
|
|
238
|
-
const
|
|
239
|
-
|
|
239
|
+
const t = this.shadowRoot.querySelector(".listbox");
|
|
240
|
+
t && (t.onmousedown = (i) => {
|
|
240
241
|
const s = i.target, r = s == null ? void 0 : s.closest("[data-option-value]");
|
|
241
242
|
if (!r) return;
|
|
242
243
|
i.preventDefault();
|
|
@@ -252,14 +253,14 @@ class w extends HTMLElement {
|
|
|
252
253
|
}
|
|
253
254
|
updateListbox() {
|
|
254
255
|
if (!this.shadowRoot) return;
|
|
255
|
-
const
|
|
256
|
-
if (!
|
|
257
|
-
const
|
|
258
|
-
if (!(!this.disabled && (
|
|
259
|
-
|
|
256
|
+
const e = this.shadowRoot.querySelector(".listbox");
|
|
257
|
+
if (!e) return;
|
|
258
|
+
const t = this.filteredOptions;
|
|
259
|
+
if (!(!this.disabled && (t.length > 0 || this.showCreateOption) && this.inputValue.trim().length > 0)) {
|
|
260
|
+
e.hidden = !0, e.innerHTML = "";
|
|
260
261
|
return;
|
|
261
262
|
}
|
|
262
|
-
const s =
|
|
263
|
+
const s = t.map((l, u) => {
|
|
263
264
|
const n = u === this.highlightedIndex;
|
|
264
265
|
return (
|
|
265
266
|
/*html*/
|
|
@@ -270,11 +271,11 @@ class w extends HTMLElement {
|
|
|
270
271
|
class="option ${n ? "active" : ""}"
|
|
271
272
|
role="option"
|
|
272
273
|
aria-selected="${n ? "true" : "false"}"
|
|
273
|
-
data-option-value="${
|
|
274
|
-
>${
|
|
274
|
+
data-option-value="${l.value}"
|
|
275
|
+
>${l.label}</mui-button>
|
|
275
276
|
`
|
|
276
277
|
);
|
|
277
|
-
}).join(""), r =
|
|
278
|
+
}).join(""), r = t.length, a = this.showCreateOption ? (
|
|
278
279
|
/*html*/
|
|
279
280
|
`
|
|
280
281
|
<mui-button
|
|
@@ -287,11 +288,11 @@ class w extends HTMLElement {
|
|
|
287
288
|
>Add "${this.inputValue.trim()}"</mui-button>
|
|
288
289
|
`
|
|
289
290
|
) : "";
|
|
290
|
-
|
|
291
|
+
e.hidden = !1, e.innerHTML = `${s}${a}`;
|
|
291
292
|
}
|
|
292
293
|
render() {
|
|
293
|
-
const
|
|
294
|
-
const d =
|
|
294
|
+
const e = this.getAttribute("id") || "", t = this.getAttribute("label") || "", i = this.getAttribute("placeholder") || "Type to add", s = this.hasAttribute("hide-label"), r = this.useStackLayout, a = this.getAttribute("name") || "", l = this.filteredOptions, u = `${e}-listbox`, n = !this.disabled && (l.length > 0 || this.showCreateOption) && this.inputValue.trim().length > 0, c = l.map((o, g) => {
|
|
295
|
+
const d = g === this.highlightedIndex;
|
|
295
296
|
return (
|
|
296
297
|
/*html*/
|
|
297
298
|
`
|
|
@@ -301,11 +302,11 @@ class w extends HTMLElement {
|
|
|
301
302
|
class="option ${d ? "active" : ""}"
|
|
302
303
|
role="option"
|
|
303
304
|
aria-selected="${d ? "true" : "false"}"
|
|
304
|
-
data-option-value="${
|
|
305
|
-
>${
|
|
305
|
+
data-option-value="${o.value}"
|
|
306
|
+
>${o.label}</mui-button>
|
|
306
307
|
`
|
|
307
308
|
);
|
|
308
|
-
}).join(""), h =
|
|
309
|
+
}).join(""), h = l.length, p = this.showCreateOption ? (
|
|
309
310
|
/*html*/
|
|
310
311
|
`
|
|
311
312
|
<mui-button
|
|
@@ -323,11 +324,11 @@ class w extends HTMLElement {
|
|
|
323
324
|
<mui-h-stack
|
|
324
325
|
slot="${m}"
|
|
325
326
|
class="${b} ${r ? "mobile-stack" : ""}"
|
|
326
|
-
space="var(--stroke-size-
|
|
327
|
+
space="var(--stroke-size-100)"
|
|
327
328
|
aligny="center"
|
|
328
329
|
>
|
|
329
330
|
${this.selectedItems.map(
|
|
330
|
-
(
|
|
331
|
+
(o) => (
|
|
331
332
|
/*html*/
|
|
332
333
|
`
|
|
333
334
|
<mui-chip
|
|
@@ -335,15 +336,15 @@ class w extends HTMLElement {
|
|
|
335
336
|
size="${this.normalizedSize}"
|
|
336
337
|
dismiss
|
|
337
338
|
${this.disabled ? "disabled" : ""}
|
|
338
|
-
data-remove-value="${
|
|
339
|
-
aria-label="Remove ${
|
|
340
|
-
>${
|
|
339
|
+
data-remove-value="${o.value}"
|
|
340
|
+
aria-label="Remove ${o.label}"
|
|
341
|
+
>${o.label}</mui-chip>
|
|
341
342
|
`
|
|
342
343
|
)
|
|
343
344
|
).join("")}
|
|
344
345
|
</mui-h-stack>
|
|
345
346
|
`
|
|
346
|
-
) : "",
|
|
347
|
+
) : "", v = a ? this.selectedValues.map((o) => `<input type="hidden" name="${a}" value="${o}" />`).join("") : "";
|
|
347
348
|
this.shadowRoot.innerHTML = /*html*/
|
|
348
349
|
`
|
|
349
350
|
<style>
|
|
@@ -359,18 +360,28 @@ class w extends HTMLElement {
|
|
|
359
360
|
.listbox {
|
|
360
361
|
border: var(--border-thin);
|
|
361
362
|
border-color: var(--form-default-border-color);
|
|
362
|
-
border-radius: var(--radius-
|
|
363
|
+
border-radius: var(--form-radius-medium);
|
|
363
364
|
background: var(--surface-elevated-100);
|
|
364
365
|
overflow: hidden;
|
|
365
366
|
}
|
|
367
|
+
:host([size="x-small"]) {
|
|
368
|
+
--chip-input-border-radius: var(--form-radius-x-small);
|
|
369
|
+
}
|
|
370
|
+
:host([size="small"]) {
|
|
371
|
+
--chip-input-border-radius: var(--form-radius-small);
|
|
372
|
+
}
|
|
373
|
+
:host([size="medium"]) {
|
|
374
|
+
--chip-input-border-radius: var(--form-radius-medium);
|
|
375
|
+
}
|
|
376
|
+
:host([size="large"]) {
|
|
377
|
+
--chip-input-border-radius: var(--form-radius-large);
|
|
378
|
+
}
|
|
366
379
|
mui-h-stack.chip-slot-shell {
|
|
367
380
|
background: var(--chip-input-background);
|
|
368
|
-
|
|
369
|
-
border: var(--chip-input-shell-border, 1px solid var(--form-default-border-color));
|
|
381
|
+
border: var(--chip-input-shell-border, var(--stroke-size-100) solid var(--form-default-border-color));
|
|
370
382
|
box-sizing: border-box;
|
|
371
383
|
width: 100%;
|
|
372
384
|
min-width: 0;
|
|
373
|
-
border-radius: var(--radius-100);
|
|
374
385
|
}
|
|
375
386
|
mui-h-stack.chip-slot-shell.mobile-stack {
|
|
376
387
|
overflow-x: auto;
|
|
@@ -379,29 +390,27 @@ class w extends HTMLElement {
|
|
|
379
390
|
}
|
|
380
391
|
mui-h-stack.chip-slot-shell.before-shell {
|
|
381
392
|
border-right: none;
|
|
382
|
-
border-top-
|
|
383
|
-
border-bottom-
|
|
393
|
+
border-top-left-radius: var(--chip-input-border-radius);
|
|
394
|
+
border-bottom-left-radius: var(--chip-input-border-radius);
|
|
384
395
|
}
|
|
385
396
|
mui-h-stack.chip-slot-shell.after-shell {
|
|
386
397
|
border-left: none;
|
|
387
|
-
border-top-
|
|
388
|
-
border-bottom-
|
|
398
|
+
border-top-right-radius: var(--chip-input-border-radius);
|
|
399
|
+
border-bottom-right-radius: var(--chip-input-border-radius);
|
|
389
400
|
}
|
|
390
401
|
mui-h-stack.chip-slot-shell.mobile-stack.before-shell {
|
|
391
|
-
border-right: var(--chip-input-shell-border,
|
|
402
|
+
border-right: var(--chip-input-shell-border, var(--stroke-size-100) solid var(--form-default-border-color));
|
|
392
403
|
border-bottom: none;
|
|
393
|
-
border-top-left-radius: var(--radius-100);
|
|
394
|
-
border-top-right-radius: var(--radius-100);
|
|
395
|
-
border-bottom-left-radius: 0;
|
|
396
|
-
border-bottom-right-radius: 0;
|
|
397
404
|
}
|
|
398
405
|
mui-h-stack.chip-slot-shell.mobile-stack.after-shell {
|
|
399
|
-
border-left: var(--chip-input-shell-border,
|
|
406
|
+
border-left: var(--chip-input-shell-border, var(--stroke-size-100) solid var(--form-default-border-color));
|
|
400
407
|
border-top: none;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
408
|
+
}
|
|
409
|
+
mui-h-stack.chip-slot-shell.before-shell mui-chip:first-child {
|
|
410
|
+
--chip-radius-left: calc(var(--chip-input-border-radius) + var(--stroke-size-200));
|
|
411
|
+
}
|
|
412
|
+
mui-h-stack.chip-slot-shell.after-shell mui-chip:last-child {
|
|
413
|
+
--chip-radius-right: calc(var(--chip-input-border-radius) + var(--stroke-size-200));
|
|
405
414
|
}
|
|
406
415
|
.option {
|
|
407
416
|
width: 100%;
|
|
@@ -418,8 +427,8 @@ class w extends HTMLElement {
|
|
|
418
427
|
--input-slot-wrap: wrap;
|
|
419
428
|
--input-slot-overflow-x: ${r ? "hidden" : "visible"};
|
|
420
429
|
"
|
|
421
|
-
id="${
|
|
422
|
-
label="${
|
|
430
|
+
id="${e}"
|
|
431
|
+
label="${t}"
|
|
423
432
|
${s ? "hide-label" : ""}
|
|
424
433
|
size="${this.normalizedSize}"
|
|
425
434
|
placeholder="${i}"
|
|
@@ -437,7 +446,7 @@ class w extends HTMLElement {
|
|
|
437
446
|
</div>
|
|
438
447
|
</div>
|
|
439
448
|
|
|
440
|
-
${
|
|
449
|
+
${v}
|
|
441
450
|
`;
|
|
442
451
|
}
|
|
443
452
|
}
|