@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
@@ -1,4 +1,4 @@
1
- class p extends HTMLElement {
1
+ class f extends HTMLElement {
2
2
  static get observedAttributes() {
3
3
  return [
4
4
  "name",
@@ -18,57 +18,70 @@ class p extends HTMLElement {
18
18
  constructor() {
19
19
  super(), this.attachShadow({ mode: "open" });
20
20
  }
21
+ get value() {
22
+ var t;
23
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("textarea");
24
+ return (e == null ? void 0 : e.value) ?? this.getAttribute("value") ?? "";
25
+ }
26
+ set value(e) {
27
+ this.setAttribute("value", e ?? "");
28
+ }
29
+ focus(e) {
30
+ var r;
31
+ const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector("textarea");
32
+ t ? t.focus(e) : super.focus(e);
33
+ }
21
34
  connectedCallback() {
22
35
  this.hasAttribute("size") || this.setAttribute("size", "medium"), this.render(), this.setupListener();
23
36
  }
24
37
  disconnectedCallback() {
25
38
  this.cleanupListeners();
26
39
  }
27
- attributeChangedCallback(e, a, r) {
40
+ attributeChangedCallback(e, t, r) {
28
41
  var o;
29
- const t = (o = this.shadowRoot) == null ? void 0 : o.querySelector("textarea");
30
- if (t) {
42
+ const a = (o = this.shadowRoot) == null ? void 0 : o.querySelector("textarea");
43
+ if (a) {
31
44
  if (e === "value") {
32
- t.value = r ?? "", this.updateCharacterCount();
45
+ a.value = r ?? "", this.updateCharacterCount();
33
46
  return;
34
47
  }
35
48
  if (e === "disabled") {
36
- r === null || r === "false" ? t.removeAttribute("disabled") : t.setAttribute("disabled", "");
49
+ r === null || r === "false" ? a.removeAttribute("disabled") : a.setAttribute("disabled", "");
37
50
  return;
38
51
  }
39
52
  if (e === "rows") {
40
- r && t.setAttribute("rows", r);
53
+ r && a.setAttribute("rows", r);
41
54
  return;
42
55
  }
43
56
  ["placeholder", "label", "hide-label", "variant", "optional", "max-length", "size"].includes(e) && (this.render(), this.setupListener());
44
57
  }
45
58
  }
46
59
  cleanupListeners() {
47
- var a;
48
- const e = (a = this.shadowRoot) == null ? void 0 : a.querySelector("textarea");
60
+ var t;
61
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("textarea");
49
62
  e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
50
63
  }
51
64
  setupListener() {
52
65
  if (!this.shadowRoot) return;
53
66
  const e = this.shadowRoot.querySelector("textarea");
54
- e && (this.cleanupListeners(), this._changeHandler = (a) => {
55
- const r = a.target;
67
+ e && (this.cleanupListeners(), this._changeHandler = (t) => {
68
+ const r = t.target;
56
69
  this.setAttribute("value", r.value);
57
- const t = {
70
+ const a = {
58
71
  detail: { value: r.value },
59
72
  bubbles: !0,
60
73
  composed: !0
61
74
  };
62
- this.dispatchEvent(new CustomEvent("change", t)), this.dispatchEvent(new CustomEvent("input", t)), this.updateCharacterCount();
75
+ this.dispatchEvent(new CustomEvent("change", a)), this.dispatchEvent(new CustomEvent("input", a)), this.updateCharacterCount();
63
76
  }, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler), this.updateCharacterCount());
64
77
  }
65
78
  updateCharacterCount() {
66
- var r, t;
67
- const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("textarea"), a = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".char-count");
68
- !e || !a || e.maxLength <= 0 || (a.textContent = `${e.value.length}/${e.maxLength}`);
79
+ var r, a;
80
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("textarea"), t = (a = this.shadowRoot) == null ? void 0 : a.querySelector(".char-count");
81
+ !e || !t || e.maxLength <= 0 || (t.textContent = `${e.value.length}/${e.maxLength}`);
69
82
  }
70
83
  render() {
71
- const e = this.getAttribute("name") || "", a = this.getAttribute("value") || "", r = this.getAttribute("placeholder") || "", t = this.getAttribute("id") || `mui-textarea-${Math.random().toString(36).substr(2, 9)}`, o = this.getAttribute("label") || "", d = this.hasAttribute("optional"), n = this.hasAttribute("hide-label"), x = this.hasAttribute("disabled"), l = this.getAttribute("rows") || "4", i = this.getAttribute("max-length"), s = i && Number(i) > 0 ? String(Number(i)) : "", c = this.getAttribute("size") || "medium", u = ["x-small", "small", "medium", "large"].includes(c) ? c : "medium", v = n && o ? `aria-label="${o}"` : "", h = this.getAttribute("variant") || "", g = h || "", b = (
84
+ const e = this.getAttribute("name") || "", t = this.getAttribute("value") || "", r = this.getAttribute("placeholder") || "", a = this.getAttribute("id") || `mui-textarea-${Math.random().toString(36).substr(2, 9)}`, o = this.getAttribute("label") || "", d = this.hasAttribute("optional"), l = this.hasAttribute("hide-label"), u = this.hasAttribute("disabled"), n = this.getAttribute("rows") || "4", i = this.getAttribute("max-length"), s = i && Number(i) > 0 ? String(Number(i)) : "", c = this.getAttribute("size") || "medium", x = ["x-small", "small", "medium", "large"].includes(c) ? c : "medium", v = l && o ? `aria-label="${o}"` : "", h = this.getAttribute("variant") || "", g = h || "", b = (
72
85
  /*html*/
73
86
  `
74
87
  <style>
@@ -114,7 +127,7 @@ class p extends HTMLElement {
114
127
  padding-inline: var(--textarea-padding-inline-current);
115
128
  box-sizing: border-box;
116
129
  font-size: var(--textarea-font-size-current);
117
- border-radius: var(--radius-100);
130
+ border-radius: var(--form-radius-medium);
118
131
  border: var(--border-thin);
119
132
  border-color: var(--form-default-border-color);
120
133
  color: var(--form-default-text-color);
@@ -131,24 +144,28 @@ class p extends HTMLElement {
131
144
  --textarea-line-height-current: var(--text-line-height-xs);
132
145
  --textarea-padding-block-current: var(--space-050);
133
146
  --textarea-padding-inline-current: var(--space-200);
147
+ border-radius: var(--form-radius-x-small);
134
148
  }
135
149
  textarea.size-small {
136
150
  --textarea-font-size-current: var(--text-font-size-s);
137
151
  --textarea-line-height-current: var(--text-line-height-s);
138
152
  --textarea-padding-block-current: calc(var(--space-100) - (var(--stroke-size-100) / 2));
139
153
  --textarea-padding-inline-current: var(--space-300);
154
+ border-radius: var(--form-radius-small);
140
155
  }
141
156
  textarea.size-medium {
142
157
  --textarea-font-size-current: var(--text-font-size);
143
158
  --textarea-line-height-current: var(--text-line-height);
144
159
  --textarea-padding-block-current: var(--space-200);
145
160
  --textarea-padding-inline-current: var(--space-300);
161
+ border-radius: var(--form-radius-medium);
146
162
  }
147
163
  textarea.size-large {
148
164
  --textarea-font-size-current: var(--text-font-size-l);
149
165
  --textarea-line-height-current: var(--text-line-height-l);
150
166
  --textarea-padding-block-current: var(--space-300);
151
167
  --textarea-padding-inline-current: var(--space-400);
168
+ border-radius: var(--form-radius-large);
152
169
  }
153
170
 
154
171
  textarea:hover {
@@ -278,23 +295,23 @@ class p extends HTMLElement {
278
295
  }
279
296
  </style>
280
297
 
281
- ${o ? `<label for="${t}" class="${n ? "vh" : ""}">${o}${d ? ' <span class="optional"><span class="optional-dot" aria-hidden="true">•</span><span class="optional-text">Optional</span></span>' : ""}</label>` : ""}
298
+ ${o ? `<label for="${a}" class="${l ? "vh" : ""}">${o}${d ? ' <span class="optional"><span class="optional-dot" aria-hidden="true">•</span><span class="optional-text">Optional</span></span>' : ""}</label>` : ""}
282
299
 
283
300
  <textarea
284
- id="${t}"
301
+ id="${a}"
285
302
  name="${e}"
286
- class="${[g, `size-${u}`].filter(Boolean).join(" ")}"
287
- style="--textarea-rows: ${l};"
288
- rows="${l}"
303
+ class="${[g, `size-${x}`].filter(Boolean).join(" ")}"
304
+ style="--textarea-rows: ${n};"
305
+ rows="${n}"
289
306
  placeholder="${r}"
290
307
  ${s ? `maxlength="${s}"` : ""}
291
- ${x ? "disabled" : ""}
308
+ ${u ? "disabled" : ""}
292
309
  ${v}
293
- >${a}</textarea>
310
+ >${t}</textarea>
294
311
  ${s ? '<div class="meta"><span class="char-count"></span></div>' : ""}
295
312
  `
296
313
  );
297
314
  this.shadowRoot.innerHTML = b, o || console.warn("mui-textarea: Missing required 'label' attribute for accessibility.");
298
315
  }
299
316
  }
300
- customElements.get("mui-textarea") || customElements.define("mui-textarea", p);
317
+ customElements.get("mui-textarea") || customElements.define("mui-textarea", f);
@@ -0,0 +1,336 @@
1
+ class x extends HTMLElement {
2
+ constructor() {
3
+ super(), this.hour = 12, this.minute = 0, this.ampm = "PM", this.attachShadow({ mode: "open" });
4
+ const r = /* @__PURE__ */ new Date();
5
+ this.hour = r.getHours(), this.minute = r.getMinutes();
6
+ }
7
+ static get observedAttributes() {
8
+ return ["value", "format", "step", "start", "end", "variant"];
9
+ }
10
+ get value() {
11
+ return this.getAttribute("value") || "";
12
+ }
13
+ set value(r) {
14
+ this.setAttribute("value", r ?? "");
15
+ }
16
+ focus(r) {
17
+ var i;
18
+ const s = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".selected, .slot-btn, .column");
19
+ s && typeof s.focus == "function" ? s.focus(r) : super.focus(r);
20
+ }
21
+ connectedCallback() {
22
+ this.syncAttributes(), this.render();
23
+ }
24
+ attributeChangedCallback(r, s, i) {
25
+ var v, d;
26
+ s !== i && (this.syncAttributes(), r === "value" && ((v = this.shadowRoot) != null && v.querySelector(".time-picker-container") || (d = this.shadowRoot) != null && d.querySelector(".slots-container")) ? this.updateDOMForValue() : this.render());
27
+ }
28
+ updateDOMForValue() {
29
+ var s, i, v, d;
30
+ if ((this.getAttribute("variant") || "dial") === "slots") {
31
+ const g = (s = this.shadowRoot) == null ? void 0 : s.querySelectorAll(".slot-btn");
32
+ g && g.forEach((c) => {
33
+ c.getAttribute("data-value") === this.getAttribute("value") ? (c.classList.add("selected"), c.setAttribute("variant", "primary"), c.setAttribute("aria-selected", "true")) : (c.classList.remove("selected"), c.removeAttribute("variant"), c.setAttribute("aria-selected", "false"));
34
+ });
35
+ } else {
36
+ const g = (this.getAttribute("format") || "12h") === "12h", c = this.hour % 12 || 12, b = (i = this.shadowRoot) == null ? void 0 : i.getElementById("col-hours"), m = (v = this.shadowRoot) == null ? void 0 : v.getElementById("col-minutes"), y = (d = this.shadowRoot) == null ? void 0 : d.getElementById("col-ampm");
37
+ b && this.scrollToValue(b, g ? c : this.hour), m && this.scrollToValue(m, this.minute), y && this.scrollToValue(y, this.ampm);
38
+ }
39
+ }
40
+ scrollToValue(r, s) {
41
+ const i = r.querySelector(`[data-value="${s}"]`);
42
+ if (i) {
43
+ const v = i.offsetTop + i.offsetHeight / 2, d = r.offsetHeight / 2;
44
+ r.scrollTop = v - d;
45
+ }
46
+ }
47
+ syncAttributes() {
48
+ const r = this.getAttribute("value");
49
+ if (r) {
50
+ const s = r.trim().split(" "), i = s[0].split(":");
51
+ i.length === 2 && (this.hour = parseInt(i[0], 10) || 0, this.minute = parseInt(i[1], 10) || 0), s[1] && (s[1].toUpperCase() === "AM" || s[1].toUpperCase() === "PM") ? this.ampm = s[1].toUpperCase() : this.ampm = this.hour >= 12 ? "PM" : "AM";
52
+ }
53
+ }
54
+ updateTime() {
55
+ const r = this.getAttribute("format") || "12h";
56
+ let s = "";
57
+ if (r === "12h") {
58
+ let i = this.hour % 12;
59
+ i === 0 && (i = 12), s = `${String(i).padStart(2, "0")}:${String(this.minute).padStart(2, "0")} ${this.ampm}`;
60
+ } else {
61
+ let i = this.hour;
62
+ s = `${String(i).padStart(2, "0")}:${String(this.minute).padStart(2, "0")}`;
63
+ }
64
+ this.setAttribute("value", s), this.dispatchEvent(new CustomEvent("change", { detail: { value: s }, bubbles: !0, composed: !0 }));
65
+ }
66
+ render() {
67
+ if (!this.shadowRoot) return;
68
+ (this.getAttribute("variant") || "dial") === "slots" ? this.renderSlots() : this.renderDial();
69
+ }
70
+ renderSlots() {
71
+ const r = parseInt(this.getAttribute("start") || "9", 10), s = parseInt(this.getAttribute("end") || "17", 10), i = parseInt(this.getAttribute("step") || "60", 10), d = (this.getAttribute("format") || "12h") === "12h", g = [];
72
+ for (let e = r; e <= s; e++)
73
+ for (let n = 0; n < 60 && !(e === s && n > 0); n += i) {
74
+ let u = "", t = `${String(e).padStart(2, "0")}:${String(n).padStart(2, "0")}`;
75
+ if (d) {
76
+ const o = e >= 12 ? "PM" : "AM";
77
+ u = `${e % 12 === 0 ? 12 : e % 12}:${String(n).padStart(2, "0")} ${o}`;
78
+ } else
79
+ u = t;
80
+ g.push({ label: u, val: d ? u : t, h: e, m: n });
81
+ }
82
+ const c = this.getAttribute("value") || "", b = (
83
+ /*html*/
84
+ `
85
+ <style>
86
+ :host {
87
+ display: flex;
88
+ flex-direction: column;
89
+ width: 100%;
90
+ height: var(--time-picker-height);
91
+ font-family: inherit;
92
+ --time-picker-height: 24rem;
93
+ }
94
+ .slots-container {
95
+ display: flex;
96
+ flex-direction: column;
97
+ height: 100%;
98
+ background: transparent;
99
+ }
100
+ .slots-scroll {
101
+ flex: 1 1 auto;
102
+ overflow-y: auto;
103
+ overflow-x: hidden;
104
+ margin: var(--stroke-size-200);
105
+ display: flex;
106
+ flex-direction: column;
107
+ gap: var(--space-100);
108
+ scrollbar-width: none; /* Firefox */
109
+ }
110
+ .slots-scroll::-webkit-scrollbar {
111
+ display: none; /* Chrome/Safari */
112
+ }
113
+ .slot-btn {
114
+ width: 100%;
115
+ font-variant-numeric: tabular-nums;
116
+ }
117
+ :host([slotted]) .slot-btn {
118
+ --action-radius-small: var(--stroke-size-200);
119
+ }
120
+ </style>
121
+ <div class="slots-container">
122
+ <div class="slots-scroll">
123
+ ${g.map(
124
+ (e) => `
125
+ <mui-button variant="${c === e.val ? "primary" : "tertiary"}" size="small" class="slot-btn" data-value="${e.val}" data-h="${e.h}" data-m="${e.m}">
126
+ ${e.label}
127
+ </mui-button>
128
+ `
129
+ ).join("")}
130
+ </div>
131
+ </div>
132
+ `
133
+ );
134
+ if (!this.shadowRoot) return;
135
+ this.shadowRoot.innerHTML = b, this.shadowRoot.querySelectorAll(".slot-btn").forEach((e) => {
136
+ e.addEventListener("click", () => {
137
+ const n = e.getAttribute("data-value"), u = parseInt(e.getAttribute("data-h"), 10), t = parseInt(e.getAttribute("data-m"), 10);
138
+ this.hour = u, this.minute = t, d && (this.ampm = u >= 12 ? "PM" : "AM"), this.setAttribute("value", n), this.dispatchEvent(new CustomEvent("change", { detail: { value: n }, bubbles: !0, composed: !0 })), this.renderSlots();
139
+ });
140
+ });
141
+ const y = this.shadowRoot.querySelector(".slots-scroll");
142
+ y == null || y.addEventListener("keydown", (e) => {
143
+ var u, t, o;
144
+ const n = e;
145
+ if (n.key === "ArrowDown" || n.key === "ArrowUp") {
146
+ n.preventDefault();
147
+ const a = this.shadowRoot ? this.shadowRoot.activeElement : null;
148
+ let p = a != null && a.classList.contains("slot-btn") ? a : null;
149
+ if (!p) {
150
+ p = ((u = this.shadowRoot) == null ? void 0 : u.querySelector(".slot-btn[variant='primary']")) || ((t = this.shadowRoot) == null ? void 0 : t.querySelector(".slot-btn")), p == null || p.focus();
151
+ return;
152
+ }
153
+ const f = Array.from(((o = this.shadowRoot) == null ? void 0 : o.querySelectorAll(".slot-btn")) || []), A = f.indexOf(p);
154
+ if (A === -1) return;
155
+ let l = n.key === "ArrowDown" ? A + 1 : A - 1;
156
+ l < 0 && (l = 0), l >= f.length && (l = f.length - 1), f[l].focus();
157
+ }
158
+ }), requestAnimationFrame(() => {
159
+ var n;
160
+ const e = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".slot-btn.selected");
161
+ e && e.scrollIntoView({ behavior: "auto", block: "center" });
162
+ });
163
+ }
164
+ renderDial() {
165
+ const r = this.getAttribute("format") || "12h", s = parseInt(this.getAttribute("step") || "1", 10), i = r === "12h", v = i ? Array.from({ length: 12 }, (t, o) => o === 0 ? 12 : o) : Array.from({ length: 24 }, (t, o) => o), d = Array.from({ length: Math.floor(60 / s) }, (t, o) => o * s), g = (
166
+ /*html*/
167
+ `
168
+ <style>
169
+ :host {
170
+ display: inline-block;
171
+ font-family: inherit;
172
+ --time-picker-height: 24rem;
173
+ --time-item-height: 4rem;
174
+ }
175
+ .time-picker-container {
176
+ display: flex;
177
+ height: var(--time-picker-height);
178
+ background: var(--input-background);
179
+ border-radius: var(--time-picker-radius, var(--radius-200));
180
+ position: relative;
181
+ overflow: hidden;
182
+ padding: 0 var(--space-200);
183
+ gap: var(--space-100);
184
+ }
185
+ .time-picker-container::before {
186
+ content: "";
187
+ position: absolute;
188
+ top: 50%;
189
+ left: var(--space-200);
190
+ right: var(--space-200);
191
+ height: var(--time-item-height);
192
+ transform: translateY(-50%);
193
+ background: var(--action-tertiary-background-hover);
194
+ border-radius: var(--radius-100);
195
+ pointer-events: none;
196
+ z-index: 1;
197
+ }
198
+ /* Top and Bottom faded masks */
199
+ .time-picker-container::after {
200
+ content: "";
201
+ position: absolute;
202
+ top: 0;
203
+ bottom: 0;
204
+ left: 0;
205
+ right: 0;
206
+ background: linear-gradient(
207
+ to bottom,
208
+ var(--input-background) 0%,
209
+ transparent 30%,
210
+ transparent 70%,
211
+ var(--input-background) 100%
212
+ );
213
+ pointer-events: none;
214
+ z-index: 2;
215
+ }
216
+ .column {
217
+ flex: 1;
218
+ display: flex;
219
+ flex-direction: column;
220
+ overflow-y: scroll;
221
+ scroll-snap-type: y mandatory;
222
+ scrollbar-width: none;
223
+ z-index: 2;
224
+ border-radius: var(--radius-100);
225
+ }
226
+ .column:focus-visible {
227
+ outline: 2px solid var(--action-primary-background);
228
+ outline-offset: -2px;
229
+ }
230
+ .column::-webkit-scrollbar {
231
+ display: none; /* Chrome/Safari */
232
+ }
233
+ /* Add padding to allow first and last items to reach the center */
234
+ .column::before,
235
+ .column::after {
236
+ content: "";
237
+ display: block;
238
+ flex: 0 0 calc(50% - (var(--time-item-height) / 2));
239
+ }
240
+ .item {
241
+ flex: 0 0 var(--time-item-height);
242
+ display: flex;
243
+ align-items: center;
244
+ justify-content: center;
245
+ font-size: var(--text-font-size-l);
246
+ color: var(--text-color);
247
+ scroll-snap-align: center;
248
+ cursor: pointer;
249
+ user-select: none;
250
+ z-index: 3;
251
+ position: relative;
252
+ font-variant-numeric: tabular-nums;
253
+ }
254
+ </style>
255
+ <div class="time-picker-container">
256
+ <!-- Hours -->
257
+ <div class="column" id="col-hours">
258
+ ${v.map((t) => `<div class="item" data-value="${t}">${String(t).padStart(2, "0")}</div>`).join("")}
259
+ </div>
260
+ <!-- Minutes -->
261
+ <div class="column" id="col-minutes">
262
+ ${d.map((t) => `<div class="item" data-value="${t}">${String(t).padStart(2, "0")}</div>`).join("")}
263
+ </div>
264
+ <!-- AM/PM -->
265
+ ${i ? `
266
+ <div class="column" id="col-ampm">
267
+ <div class="item" data-value="AM">AM</div>
268
+ <div class="item" data-value="PM">PM</div>
269
+ </div>
270
+ ` : ""}
271
+ </div>
272
+ `
273
+ );
274
+ if (!this.shadowRoot) return;
275
+ this.shadowRoot.innerHTML = g;
276
+ const c = this.shadowRoot.getElementById("col-hours"), b = this.shadowRoot.getElementById("col-minutes"), m = this.shadowRoot.getElementById("col-ampm");
277
+ let y;
278
+ const e = (t, o) => {
279
+ clearTimeout(y), y = setTimeout(() => {
280
+ const a = t.scrollTop + t.offsetHeight / 2, p = Array.from(t.querySelectorAll(".item"));
281
+ let f = p[0], A = 1 / 0;
282
+ if (p.forEach((l) => {
283
+ const h = l.offsetTop + l.offsetHeight / 2, w = Math.abs(a - h);
284
+ w < A && (A = w, f = l);
285
+ }), f) {
286
+ const l = f.getAttribute("data-value");
287
+ if (o === "hour") {
288
+ const h = parseInt(l, 10);
289
+ this.getAttribute("format") === "12h" ? this.hour = h === 12 && this.ampm === "AM" ? 0 : h === 12 && this.ampm === "PM" ? 12 : this.ampm === "PM" ? h + 12 : h : this.hour = h;
290
+ } else if (o === "minute")
291
+ this.minute = parseInt(l, 10);
292
+ else if (o === "ampm") {
293
+ this.ampm = l;
294
+ const h = this.hour % 12 || 12;
295
+ this.hour = l === "AM" ? h === 12 ? 0 : h : h === 12 ? 12 : h + 12;
296
+ }
297
+ this.updateTime();
298
+ }
299
+ }, 150);
300
+ };
301
+ c.addEventListener("scroll", () => e(c, "hour")), b.addEventListener("scroll", () => e(b, "minute")), m && m.addEventListener("scroll", () => e(m, "ampm"));
302
+ const n = (t) => {
303
+ t.addEventListener("click", (o) => {
304
+ const a = o.target.closest(".item");
305
+ a && a.scrollIntoView({ behavior: "smooth", block: "center" });
306
+ });
307
+ }, u = (t) => {
308
+ t.setAttribute("tabindex", "0"), t.addEventListener("keydown", (o) => {
309
+ if (o.key === "ArrowUp" || o.key === "ArrowDown") {
310
+ o.preventDefault();
311
+ const a = Array.from(t.querySelectorAll(".item")), p = t.scrollTop + t.offsetHeight / 2;
312
+ let f = 0, A = 1 / 0;
313
+ a.forEach((h, w) => {
314
+ const S = h.offsetTop + h.offsetHeight / 2, k = Math.abs(p - S);
315
+ k < A && (A = k, f = w);
316
+ });
317
+ let l = o.key === "ArrowUp" ? f - 1 : f + 1;
318
+ l < 0 && (l = 0), l >= a.length && (l = a.length - 1), a[l].scrollIntoView({ behavior: "smooth", block: "center" });
319
+ } else if (o.key === "ArrowLeft") {
320
+ o.preventDefault();
321
+ const a = t.previousElementSibling;
322
+ a && a.classList.contains("column") && a.focus();
323
+ } else if (o.key === "ArrowRight") {
324
+ o.preventDefault();
325
+ const a = t.nextElementSibling;
326
+ a && a.classList.contains("column") && a.focus();
327
+ }
328
+ });
329
+ };
330
+ n(c), n(b), m && n(m), u(c), u(b), m && u(m), requestAnimationFrame(() => {
331
+ const t = this.hour % 12 || 12;
332
+ this.scrollToValue(c, i ? t : this.hour), this.scrollToValue(b, this.minute), m && this.scrollToValue(m, this.ampm);
333
+ });
334
+ }
335
+ }
336
+ customElements.get("mui-time") || customElements.define("mui-time", x);
@@ -0,0 +1,126 @@
1
+ import "../mui-dropdown/index.js";
2
+ import "../mui-input/index.js";
3
+ import "../mui-time/index/index.js";
4
+ import "../mui-icons/timer/index.js";
5
+ class c extends HTMLElement {
6
+ constructor() {
7
+ super(), this.attachShadow({ mode: "open" });
8
+ }
9
+ get value() {
10
+ return this.getAttribute("value") || "";
11
+ }
12
+ set value(t) {
13
+ this.setAttribute("value", t ?? "");
14
+ }
15
+ focus(t) {
16
+ var i;
17
+ const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("mui-input");
18
+ e && typeof e.focus == "function" ? e.focus(t) : super.focus(t);
19
+ }
20
+ connectedCallback() {
21
+ this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
22
+ `
23
+ <style>
24
+ :host {
25
+ display: flex;
26
+ box-sizing: border-box;
27
+ }
28
+ ::slotted(.time-pane) {
29
+ flex: 1 1 auto;
30
+ min-width: 160px;
31
+ display: flex;
32
+ flex-direction: column;
33
+ min-height: 0;
34
+ }
35
+ </style>
36
+ <slot></slot>
37
+ `);
38
+ }
39
+ }
40
+ customElements.get("mui-time-picker-popover") || customElements.define("mui-time-picker-popover", c);
41
+ class m extends HTMLElement {
42
+ constructor() {
43
+ super(), this.selectedTime = "", this.initialized = !1, this.attachShadow({ mode: "open" });
44
+ }
45
+ static get observedAttributes() {
46
+ return ["value", "type", "label", "hide-label", "optional", "size", "variant"];
47
+ }
48
+ connectedCallback() {
49
+ this.syncAttributes(), this.render(), this.setupListeners(), this.initialized = !0;
50
+ }
51
+ attributeChangedCallback(t, e, i) {
52
+ var n, s;
53
+ if (e !== i)
54
+ if (t === "value") {
55
+ if (this.syncAttributes(), this.initialized) {
56
+ const o = (n = this.shadowRoot) == null ? void 0 : n.querySelector("mui-input"), u = (s = this.shadowRoot) == null ? void 0 : s.querySelector("mui-time");
57
+ o && o.setAttribute("value", this.getAttribute("value") || ""), u && this.selectedTime && u.setAttribute("value", this.selectedTime);
58
+ }
59
+ } else
60
+ this.render(), this.setupListeners();
61
+ }
62
+ syncAttributes() {
63
+ this.selectedTime = this.getAttribute("value") || "";
64
+ }
65
+ setupListeners() {
66
+ if (!this.shadowRoot) return;
67
+ const t = this.shadowRoot.querySelector("mui-time"), e = this.shadowRoot.querySelector("mui-input"), i = () => {
68
+ this.setAttribute("value", this.selectedTime), e && e.setAttribute("value", this.selectedTime), this.dispatchEvent(new CustomEvent("change", { detail: { value: this.selectedTime }, bubbles: !0, composed: !0 }));
69
+ };
70
+ t && t.addEventListener("change", (s) => {
71
+ const o = s.detail;
72
+ o && o.value && (this.selectedTime = o.value, i(), (this.getAttribute("type") || "time") === "timeslot" && requestAnimationFrame(() => {
73
+ var a;
74
+ const r = (a = this.shadowRoot) == null ? void 0 : a.querySelector("mui-dropdown");
75
+ r && typeof r.close == "function" && r.close();
76
+ }));
77
+ });
78
+ const n = this.shadowRoot.querySelector("mui-time-picker-popover");
79
+ n && n.addEventListener("click", (s) => {
80
+ s.stopPropagation();
81
+ });
82
+ }
83
+ render() {
84
+ if (!this.shadowRoot) return;
85
+ const t = this.getAttribute("value") || "", e = this.getAttribute("type") || "time", i = this.getAttribute("label") || "", n = this.hasAttribute("hide-label") ? "hide-label" : "", s = this.hasAttribute("optional") ? "optional" : "", o = this.getAttribute("size") || "medium", u = this.getAttribute("variant") || "", a = (
86
+ /*html*/
87
+ `
88
+ <style>
89
+ :host {
90
+ display: inline-block;
91
+ width: 100%;
92
+ }
93
+ .time-pane {
94
+ padding: var(--space-200);
95
+ height: 310px;
96
+ }
97
+ mui-dropdown {
98
+ width: 100%;
99
+ --dropdown-min-width: auto;
100
+ }
101
+ </style>
102
+ <mui-dropdown persistent>
103
+ <mui-input
104
+ slot="action"
105
+ value="${t}"
106
+ label="${i}"
107
+ size="${o}"
108
+ variant="${u}"
109
+ ${n}
110
+ ${s}
111
+ readonly>
112
+ <mui-button slot="after"><mui-icon-timer></mui-icon-timer></mui-button>
113
+ </mui-input>
114
+
115
+ <mui-time-picker-popover>
116
+ <div class="time-pane">
117
+ <mui-time variant="${e === "timeslot" ? "slots" : "wheels"}" value="${this.selectedTime}" slotted style="--time-picker-radius: var(--stroke-size-200);"></mui-time>
118
+ </div>
119
+ </mui-time-picker-popover>
120
+ </mui-dropdown>
121
+ `
122
+ );
123
+ this.shadowRoot.innerHTML = a;
124
+ }
125
+ }
126
+ customElements.get("mui-time-picker") || customElements.define("mui-time-picker", m);