@muibook/components 19.6.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.
Files changed (172) hide show
  1. package/AGENTS.md +67 -0
  2. package/DESIGN.md +358 -0
  3. package/README.md +53 -2
  4. package/dist/esm/agent/keywords/index.js +2 -173
  5. package/dist/esm/agent/prompts/index.js +6 -432
  6. package/dist/esm/components/mui-accordion/core/index.js +25 -17
  7. package/dist/esm/components/mui-addon/index.js +14 -14
  8. package/dist/esm/components/mui-avatar/index.js +103 -43
  9. package/dist/esm/components/mui-avatar-chip/index.js +158 -0
  10. package/dist/esm/components/mui-avatar-group/index.js +88 -0
  11. package/dist/esm/components/mui-badge/index.js +37 -20
  12. package/dist/esm/components/mui-body/index.js +20 -11
  13. package/dist/esm/components/mui-button/index.js +265 -78
  14. package/dist/esm/components/mui-calendar/index.js +199 -0
  15. package/dist/esm/components/mui-card/body/index.js +33 -18
  16. package/dist/esm/components/mui-card/footer/index.js +11 -9
  17. package/dist/esm/components/mui-carousel/controller/index.js +1 -1
  18. package/dist/esm/components/mui-checkbox/index.js +23 -18
  19. package/dist/esm/components/mui-chip/index.js +219 -73
  20. package/dist/esm/components/mui-chip-input/index.js +146 -137
  21. package/dist/esm/components/mui-chip-rail/index.js +342 -0
  22. package/dist/esm/components/mui-code/index.js +26 -7
  23. package/dist/esm/components/mui-container/index.js +68 -45
  24. package/dist/esm/components/mui-date-picker/index.js +169 -0
  25. package/dist/esm/components/mui-drawer/index.js +968 -100
  26. package/dist/esm/components/mui-dropdown/index.js +255 -59
  27. package/dist/esm/components/mui-field/index.js +1 -1
  28. package/dist/esm/components/mui-file-upload/index.js +14 -4
  29. package/dist/esm/components/mui-form-group/index.js +1 -2
  30. package/dist/esm/components/mui-form-message/index.js +4 -9
  31. package/dist/esm/components/mui-heading/index.js +3 -2
  32. package/dist/esm/components/mui-hint/index.js +178 -72
  33. package/dist/esm/components/mui-icons/copy/index.js +54 -0
  34. package/dist/esm/components/mui-icons/fullscreen/index.js +5 -0
  35. package/dist/esm/components/mui-icons/icon-helper/index.js +56 -0
  36. package/dist/esm/components/mui-icons/index.js +14 -1
  37. package/dist/esm/components/mui-icons/moon/index.js +3 -1
  38. package/dist/esm/components/mui-icons/{rectangle-bottom-panel → panel}/index.js +6 -6
  39. package/dist/esm/components/mui-icons/pause/index.js +5 -0
  40. package/dist/esm/components/mui-icons/picture-in-picture/index.js +5 -0
  41. package/dist/esm/components/mui-icons/play-fill/index.js +5 -0
  42. package/dist/esm/components/mui-icons/rectangle-right-drawer/index.js +56 -0
  43. package/dist/esm/components/mui-icons/reload/index.js +5 -0
  44. package/dist/esm/components/mui-icons/speaker-mute/index.js +5 -0
  45. package/dist/esm/components/mui-icons/speaker-one-wave/index.js +5 -0
  46. package/dist/esm/components/mui-icons/speaker-two-wave/index.js +5 -0
  47. package/dist/esm/components/mui-icons/spinner/index.js +7 -5
  48. package/dist/esm/components/mui-icons/stop-fill/index.js +5 -0
  49. package/dist/esm/components/mui-icons/sun/index.js +5 -5
  50. package/dist/esm/components/mui-icons/timer/index.js +54 -0
  51. package/dist/esm/components/mui-icons/toggle/index.js +16 -6
  52. package/dist/esm/components/mui-icons/vertical-ellipsis/index.js +5 -0
  53. package/dist/esm/components/mui-illustrations/trash/index.js +6 -5
  54. package/dist/esm/components/mui-input/index.js +96 -67
  55. package/dist/esm/components/mui-link/index.js +352 -96
  56. package/dist/esm/components/mui-media-player/index.js +1577 -83
  57. package/dist/esm/components/mui-message/index.js +7 -6
  58. package/dist/esm/components/mui-model-viewer/index.js +258 -0
  59. package/dist/esm/components/mui-progress-ring/index.js +349 -0
  60. package/dist/esm/components/mui-prompt/index.js +143 -115
  61. package/dist/esm/components/mui-prompt-preview/index.js +11 -23
  62. package/dist/esm/components/mui-radio/index.js +38 -17
  63. package/dist/esm/components/mui-range-input/index.js +9 -4
  64. package/dist/esm/components/mui-responsive/index.js +60 -27
  65. package/dist/esm/components/mui-search-input/index.js +300 -0
  66. package/dist/esm/components/mui-select/index.js +235 -46
  67. package/dist/esm/components/mui-slat/slat/index.js +40 -12
  68. package/dist/esm/components/mui-spinner/index.js +11 -9
  69. package/dist/esm/components/mui-stack/hstack/index.js +10 -5
  70. package/dist/esm/components/mui-status/index.js +239 -0
  71. package/dist/esm/components/mui-stepper/step/index.js +46 -32
  72. package/dist/esm/components/mui-switch/index.js +37 -26
  73. package/dist/esm/components/mui-table/row/index.js +2 -6
  74. package/dist/esm/components/mui-table/table/index.js +157 -14
  75. package/dist/esm/components/mui-tabs/controller/index.js +17 -6
  76. package/dist/esm/components/mui-tabs/item/index.js +17 -5
  77. package/dist/esm/components/mui-tabs/tab-bar/index.js +93 -39
  78. package/dist/esm/components/mui-textarea/index.js +43 -26
  79. package/dist/esm/components/mui-time/index/index.js +336 -0
  80. package/dist/esm/components/mui-time-picker/index.js +126 -0
  81. package/dist/esm/components/mui-video-thumbnail/index.js +205 -0
  82. package/dist/esm/css/mui-brand.css +12 -8
  83. package/dist/esm/css/mui-tokens.css +646 -344
  84. package/dist/esm/css/readme.md +2 -2
  85. package/dist/esm/custom-elements.json +4506 -1707
  86. package/dist/esm/dynamic-attrs.json +271 -54
  87. package/dist/esm/index.js +33 -6
  88. package/dist/esm/knowledge/compositions/index.js +1560 -0
  89. package/dist/esm/knowledge/index.js +28 -0
  90. package/dist/esm/knowledge/keywords/index.js +306 -0
  91. package/dist/esm/knowledge/rules/index.js +199 -0
  92. package/dist/esm/tokens/js/index.js +143 -139
  93. package/dist/types/agent/keywords/index.d.ts +1 -1
  94. package/dist/types/components/mui-avatar-chip/api.d.ts +28 -0
  95. package/dist/types/components/mui-avatar-chip/index.d.ts +18 -0
  96. package/dist/types/components/mui-avatar-group/api.d.ts +28 -0
  97. package/dist/types/components/mui-avatar-group/doc.d.ts +2 -0
  98. package/dist/types/components/mui-avatar-group/index.d.ts +1 -0
  99. package/dist/types/components/mui-button/api.d.ts +6 -2
  100. package/dist/types/components/mui-calendar/api.d.ts +41 -0
  101. package/dist/types/components/mui-calendar/doc.d.ts +2 -0
  102. package/dist/types/components/mui-calendar/index.d.ts +3 -0
  103. package/dist/types/components/mui-checkbox/api.d.ts +4 -0
  104. package/dist/types/components/mui-chip/api.d.ts +4 -0
  105. package/dist/types/components/mui-chip-input/api.d.ts +4 -0
  106. package/dist/types/components/mui-chip-rail/api.d.ts +21 -0
  107. package/dist/types/components/mui-chip-rail/doc.d.ts +2 -0
  108. package/dist/types/components/mui-chip-rail/index.d.ts +4 -0
  109. package/dist/types/components/mui-date-picker/api.d.ts +38 -0
  110. package/dist/types/components/mui-date-picker/doc.d.ts +2 -0
  111. package/dist/types/components/mui-date-picker/index.d.ts +6 -0
  112. package/dist/types/components/mui-drawer/api.d.ts +4 -0
  113. package/dist/types/components/mui-drawer/index.d.ts +2 -0
  114. package/dist/types/components/mui-file-upload/api.d.ts +4 -0
  115. package/dist/types/components/mui-icons/fullscreen.d.ts +1 -0
  116. package/dist/types/components/mui-icons/icon-helper.d.ts +1 -0
  117. package/dist/types/components/mui-icons/index.d.ts +14 -1
  118. package/dist/types/components/mui-icons/panel.d.ts +1 -0
  119. package/dist/types/components/mui-icons/pause.d.ts +1 -0
  120. package/dist/types/components/mui-icons/picture-in-picture.d.ts +1 -0
  121. package/dist/types/components/mui-icons/play-fill.d.ts +1 -0
  122. package/dist/types/components/mui-icons/rectangle-right-drawer.d.ts +1 -0
  123. package/dist/types/components/mui-icons/reload.d.ts +1 -0
  124. package/dist/types/components/mui-icons/speaker-mute.d.ts +1 -0
  125. package/dist/types/components/mui-icons/speaker-one-wave.d.ts +1 -0
  126. package/dist/types/components/mui-icons/speaker-two-wave.d.ts +1 -0
  127. package/dist/types/components/mui-icons/stop-fill.d.ts +1 -0
  128. package/dist/types/components/mui-icons/timer.d.ts +1 -0
  129. package/dist/types/components/mui-icons/vertical-ellipsis.d.ts +1 -0
  130. package/dist/types/components/mui-input/api.d.ts +12 -0
  131. package/dist/types/components/mui-link/api.d.ts +4 -0
  132. package/dist/types/components/mui-media-player/api.d.ts +4 -0
  133. package/dist/types/components/mui-media-player/index.d.ts +13 -4
  134. package/dist/types/components/mui-model-viewer/api.d.ts +28 -0
  135. package/dist/types/components/mui-model-viewer/doc.d.ts +2 -0
  136. package/dist/types/components/mui-model-viewer/index.d.ts +17 -0
  137. package/dist/types/components/mui-progress-ring/api.d.ts +24 -0
  138. package/dist/types/components/mui-progress-ring/doc.d.ts +2 -0
  139. package/dist/types/components/mui-progress-ring/index.d.ts +1 -0
  140. package/dist/types/components/mui-radio/api.d.ts +12 -0
  141. package/dist/types/components/mui-range-input/api.d.ts +4 -0
  142. package/dist/types/components/mui-responsive/api.d.ts +10 -2
  143. package/dist/types/components/mui-search-input/api.d.ts +40 -0
  144. package/dist/types/components/mui-search-input/doc.d.ts +2 -0
  145. package/dist/types/components/mui-search-input/index.d.ts +3 -0
  146. package/dist/types/components/mui-select/api.d.ts +12 -0
  147. package/dist/types/components/mui-status/api.d.ts +24 -0
  148. package/dist/types/components/mui-status/doc.d.ts +2 -0
  149. package/dist/types/components/mui-status/index.d.ts +1 -0
  150. package/dist/types/components/mui-switch/api.d.ts +4 -0
  151. package/dist/types/components/mui-table/api.d.ts +15 -0
  152. package/dist/types/components/mui-textarea/api.d.ts +12 -0
  153. package/dist/types/components/mui-time/api.d.ts +41 -0
  154. package/dist/types/components/mui-time/doc.d.ts +2 -0
  155. package/dist/types/components/mui-time/index.d.ts +1 -0
  156. package/dist/types/components/mui-time-picker/api.d.ts +38 -0
  157. package/dist/types/components/mui-time-picker/doc.d.ts +2 -0
  158. package/dist/types/components/mui-time-picker/index.d.ts +4 -0
  159. package/dist/types/components/mui-video-thumbnail/api.d.ts +28 -0
  160. package/dist/types/components/mui-video-thumbnail/doc.d.ts +2 -0
  161. package/dist/types/components/mui-video-thumbnail/index.d.ts +1 -0
  162. package/dist/types/index.d.ts +27 -2
  163. package/dist/types/knowledge/compositions.d.ts +4644 -0
  164. package/dist/types/knowledge/index.d.ts +4657 -0
  165. package/dist/types/knowledge/keywords.d.ts +4 -0
  166. package/dist/types/knowledge/rules.d.ts +1 -0
  167. package/dist/types/tokens/js/index.d.ts +11 -7
  168. package/package.json +131 -12
  169. package/dist/esm/components/mui-form-hint/index.js +0 -1
  170. package/dist/types/components/mui-form-hint/index.d.ts +0 -1
  171. /package/dist/types/components/{mui-form-hint → mui-avatar-chip}/doc.d.ts +0 -0
  172. /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((t) => ({ ...t }));
27
+ return this.selectedItems.map((e) => ({ ...e }));
28
28
  }
29
- set value(t) {
30
- this.selectedItems = (Array.isArray(t) ? t : []).filter((e) => e && typeof e.value == "string").map((e) => ({ ...e, label: String(e.label ?? e.value), value: String(e.value) })), this.syncValueAttribute(), this.rerenderAndPreserveFocus(0, 0);
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(t, e, i) {
42
- e !== i && (t === "value" && this.syncSelectedFromAttribute(), (t === "breakpoint" || t === "mobile-stack") && this.setupBreakpointListener(), this.render(), this.setupListeners());
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 t = this.getAttribute("breakpoint");
50
- if (!t || this.hasAttribute("mobile-stack")) return;
51
- const e = Number.parseInt(t, 10);
52
- Number.isNaN(e) || e <= 0 || (this.mql = window.matchMedia(`(max-width: ${e}px)`), this.mqlHandler = () => {
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(t) {
57
- if (typeof t == "string") {
58
- const e = t.trim();
59
- return e ? { value: e, label: e } : null;
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 (t && typeof t == "object") {
62
- const e = t, i = e.value, s = i == null ? "" : String(i).trim();
62
+ if (e && typeof e == "object") {
63
+ const t = e, i = t.value, s = i == null ? "" : String(i).trim();
63
64
  return s ? {
64
- ...e,
65
+ ...t,
65
66
  value: s,
66
- label: String(e.label ?? s).trim() || s
67
+ label: String(t.label ?? s).trim() || s
67
68
  } : null;
68
69
  }
69
70
  return null;
70
71
  }
71
72
  parseOptions() {
72
- const t = this.getAttribute("options") || "[]";
73
- let e = [];
73
+ const e = this.getAttribute("options") || "[]";
74
+ let t = [];
74
75
  try {
75
- e = JSON.parse(t);
76
+ t = JSON.parse(e);
76
77
  } catch {
77
- e = t.split(",").map((s) => s.trim()).filter(Boolean);
78
+ t = e.split(",").map((s) => s.trim()).filter(Boolean);
78
79
  }
79
- return Array.isArray(e) ? e.map((i) => this.normalizeOption(i)).filter((i) => !!i) : [];
80
+ return Array.isArray(t) ? t.map((i) => this.normalizeOption(i)).filter((i) => !!i) : [];
80
81
  }
81
82
  parseValueAttribute() {
82
- const t = this.getAttribute("value") || "[]";
83
- let e = [];
83
+ const e = this.getAttribute("value") || "[]";
84
+ let t = [];
84
85
  try {
85
- e = JSON.parse(t);
86
+ t = JSON.parse(e);
86
87
  } catch {
87
- e = t.split(",").map((o) => o.trim()).filter(Boolean);
88
+ t = e.split(",").map((l) => l.trim()).filter(Boolean);
88
89
  }
89
- if (!Array.isArray(e)) return [];
90
- const i = new Map(this.parseOptions().map((a) => [a.value.toLowerCase(), a])), s = e.map((a) => {
91
- const o = this.normalizeOption(a);
92
- return o ? i.get(o.value.toLowerCase()) || o : null;
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 o = a.value.toLowerCase();
96
- return r.has(o) ? !1 : (r.add(o), !0);
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 t = JSON.stringify(this.selectedItems);
104
- this.getAttribute("value") !== t && this.setAttribute("value", t);
104
+ const e = JSON.stringify(this.selectedItems);
105
+ this.getAttribute("value") !== e && this.setAttribute("value", e);
105
106
  }
106
107
  get normalizedSize() {
107
- const t = this.getAttribute("size") || "medium";
108
- return ["x-small", "small", "medium", "large"].includes(t) ? t : "medium";
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(t) {
120
- const e = t === "after" ? "after" : "before";
121
- this.setAttribute("placement", e);
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 t = this.getAttribute("breakpoint");
126
- if (!t) return !1;
127
- const e = Number.parseInt(t, 10);
128
- return Number.isNaN(e) || e <= 0 ? !1 : window.matchMedia(`(max-width: ${e}px)`).matches;
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((t) => t.value);
132
+ return this.selectedItems.map((e) => e.value);
132
133
  }
133
134
  get filteredOptions() {
134
- const t = new Set(this.selectedValues.map((i) => i.toLowerCase())), e = this.inputValue.toLowerCase().trim();
135
- return this.parseOptions().filter((i) => t.has(i.value.toLowerCase()) ? !1 : e ? i.label.toLowerCase().includes(e) : !0);
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 t = this.inputValue.trim();
139
- if (!this.allowCustom || !t) return !1;
140
- const i = this.parseOptions().some((r) => r.value.toLowerCase() === t.toLowerCase()), s = this.selectedValues.some((r) => r.toLowerCase() === t.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(t, e, i) {
153
+ emitChange(e, t, i) {
153
154
  this.syncValueAttribute();
154
155
  const s = {
155
- action: t,
156
+ action: e,
156
157
  values: this.selectedValues,
157
158
  items: this.selectedItems.map((r) => ({ ...r })),
158
- added: e ? { ...e } : null,
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(t) {
164
+ setInputValue(e) {
164
165
  var i;
165
- this.inputValue = t;
166
- const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("mui-input");
167
- e && e.setAttribute("value", t);
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 e, i;
171
- const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("mui-input");
172
- return ((i = t == null ? void 0 : t.shadowRoot) == null ? void 0 : i.querySelector("input")) ?? null;
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(t, e) {
175
+ restoreInputFocus(e, t) {
175
176
  requestAnimationFrame(() => {
176
177
  const i = this.getInnerInput();
177
- if (!(!i || this.disabled) && (i.focus({ preventScroll: !0 }), !(t == null || e == null)))
178
+ if (!(!i || this.disabled) && (i.focus({ preventScroll: !0 }), !(e == null || t == null)))
178
179
  try {
179
- i.setSelectionRange(t, e);
180
+ i.setSelectionRange(e, t);
180
181
  } catch {
181
182
  }
182
183
  });
183
184
  }
184
- rerenderAndPreserveFocus(t, e) {
185
- this.render(), this.setupListeners(), this.restoreInputFocus(t, e);
185
+ rerenderAndPreserveFocus(e, t) {
186
+ this.render(), this.setupListeners(), this.restoreInputFocus(e, t);
186
187
  }
187
- addValue(t) {
188
- const e = t.trim();
189
- if (!e || this.selectedValues.some((r) => r.toLowerCase() === e.toLowerCase())) return;
190
- const s = this.parseOptions().find((r) => r.value.toLowerCase() === e.toLowerCase()) || { value: e, label: e, custom: !0 };
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(t) {
194
- const e = this.selectedItems.findIndex((r) => r.value === t);
195
- if (e < 0) return;
196
- const i = this.selectedItems[e];
197
- this.selectedItems = this.selectedItems.filter((r) => r.value !== t), this.emitChange("remove", void 0, i);
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(t) {
202
- const e = this.filteredOptions, i = e.length + (this.showCreateOption ? 1 : 0);
203
- if (t.key === "ArrowDown" && i > 0) {
204
- t.preventDefault(), this.highlightedIndex = (this.highlightedIndex + 1 + i) % i, this.updateListbox();
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 (t.key === "ArrowUp" && i > 0) {
208
- t.preventDefault(), this.highlightedIndex = (this.highlightedIndex - 1 + i) % i, this.updateListbox();
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 (t.key === "Escape") {
212
+ if (e.key === "Escape") {
212
213
  this.highlightedIndex = -1, this.updateListbox();
213
214
  return;
214
215
  }
215
- if (t.key === "Backspace" && !this.inputValue && this.selectedItems.length > 0) {
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 (t.key === "Enter" || t.key === ",") {
220
- if (t.preventDefault(), this.highlightedIndex >= 0 && this.highlightedIndex < e.length) {
221
- this.addValue(e[this.highlightedIndex].value);
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 t = this.shadowRoot.querySelector("mui-input");
230
- if (!t) return;
231
- t.oninput = (i) => {
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 = t.getAttribute("value") || "";
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
- }, t.onkeydown = (i) => {
236
+ }, e.onkeydown = (i) => {
236
237
  this.handleKeyboard(i);
237
238
  };
238
- const e = this.shadowRoot.querySelector(".listbox");
239
- e && (e.onmousedown = (i) => {
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 t = this.shadowRoot.querySelector(".listbox");
256
- if (!t) return;
257
- const e = this.filteredOptions;
258
- if (!(!this.disabled && (e.length > 0 || this.showCreateOption) && this.inputValue.trim().length > 0)) {
259
- t.hidden = !0, t.innerHTML = "";
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 = e.map((o, u) => {
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="${o.value}"
274
- >${o.label}</mui-button>
274
+ data-option-value="${l.value}"
275
+ >${l.label}</mui-button>
275
276
  `
276
277
  );
277
- }).join(""), r = e.length, a = this.showCreateOption ? (
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
- t.hidden = !1, t.innerHTML = `${s}${a}`;
291
+ e.hidden = !1, e.innerHTML = `${s}${a}`;
291
292
  }
292
293
  render() {
293
- const t = this.getAttribute("id") || "", e = this.getAttribute("label") || "", i = this.getAttribute("placeholder") || "Type to add", s = this.hasAttribute("hide-label"), r = this.useStackLayout, a = this.getAttribute("name") || "", o = this.filteredOptions, u = `${t}-listbox`, n = !this.disabled && (o.length > 0 || this.showCreateOption) && this.inputValue.trim().length > 0, c = o.map((l, v) => {
294
- const d = v === this.highlightedIndex;
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="${l.value}"
305
- >${l.label}</mui-button>
305
+ data-option-value="${o.value}"
306
+ >${o.label}</mui-button>
306
307
  `
307
308
  );
308
- }).join(""), h = o.length, p = this.showCreateOption ? (
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-200)"
327
+ space="var(--stroke-size-100)"
327
328
  aligny="center"
328
329
  >
329
330
  ${this.selectedItems.map(
330
- (l) => (
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="${l.value}"
339
- aria-label="Remove ${l.label}"
340
- >${l.label}</mui-chip>
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
- ) : "", g = a ? this.selectedValues.map((l) => `<input type="hidden" name="${a}" value="${l}" />`).join("") : "";
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-100);
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
- padding: var(--space-025);
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-right-radius: 0;
383
- border-bottom-right-radius: 0;
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-left-radius: 0;
388
- border-bottom-left-radius: 0;
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, 1px solid var(--form-default-border-color));
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, 1px solid var(--form-default-border-color));
406
+ border-left: var(--chip-input-shell-border, var(--stroke-size-100) solid var(--form-default-border-color));
400
407
  border-top: none;
401
- border-top-left-radius: 0;
402
- border-top-right-radius: 0;
403
- border-bottom-left-radius: var(--radius-100);
404
- border-bottom-right-radius: var(--radius-100);
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="${t}"
422
- label="${e}"
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
- ${g}
449
+ ${v}
441
450
  `;
442
451
  }
443
452
  }