@mintplayer/web-components 2.2.0 → 2.3.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 (107) hide show
  1. package/a11y/index.mjs +26 -2
  2. package/a11y/src/dismiss-stack.d.ts +25 -0
  3. package/a11y/src/error-text.d.ts +41 -0
  4. package/a11y/src/focus-restore.d.ts +116 -0
  5. package/a11y/src/focus-trap.d.ts +69 -0
  6. package/a11y/src/form-associated.d.ts +48 -0
  7. package/a11y/src/host-aria.d.ts +154 -0
  8. package/a11y/src/index.d.ts +16 -0
  9. package/a11y/src/inert-regions.d.ts +52 -0
  10. package/a11y/src/live-announcer.d.ts +8 -0
  11. package/a11y/src/roving-focus.d.ts +118 -0
  12. package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
  13. package/a11y/src/testing/index.d.ts +1 -0
  14. package/accordion/index.mjs +180 -174
  15. package/accordion/src/components/mp-accordion.d.ts +18 -13
  16. package/calendar/index.mjs +1 -1
  17. package/calendar/src/mp-calendar.element.d.ts +2 -0
  18. package/carousel/index.mjs +211 -164
  19. package/carousel/src/components/mp-carousel.d.ts +1 -0
  20. package/checkbox/index.mjs +1 -1
  21. package/checkbox/src/components/mp-checkbox.d.ts +59 -1
  22. package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
  23. package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
  24. package/chunks/form-associated-axmc5sY0.mjs +58 -0
  25. package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
  26. package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
  27. package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
  28. package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
  29. package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
  30. package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
  31. package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
  32. package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
  33. package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
  34. package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
  35. package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
  36. package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
  37. package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
  38. package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
  39. package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
  40. package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
  41. package/chunks/roving-focus-CrL9982a.mjs +129 -0
  42. package/code-snippet/index.mjs +21 -13
  43. package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
  44. package/datatable/index.mjs +1 -1
  45. package/datatable/src/components/mp-datatable.d.ts +50 -0
  46. package/datatable/src/types/index.d.ts +2 -0
  47. package/datatable/src/types/labels.d.ts +30 -0
  48. package/datepicker/index.mjs +45 -22
  49. package/datepicker/src/mp-datepicker.element.d.ts +30 -0
  50. package/datetime-picker/index.mjs +15 -9
  51. package/dock/index.mjs +365 -209
  52. package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
  53. package/dropdown-menu/index.mjs +135 -90
  54. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
  55. package/file-manager/index.mjs +279 -214
  56. package/file-manager/src/components/mp-file-manager.d.ts +22 -0
  57. package/file-manager/src/types/messages.d.ts +9 -0
  58. package/multi-range/index.mjs +26 -10
  59. package/multi-range/src/mint-multi-range.element.d.ts +7 -0
  60. package/navbar/index.mjs +53 -39
  61. package/navbar/src/components/mp-navbar.d.ts +1 -0
  62. package/otp-input/index.mjs +82 -48
  63. package/otp-input/src/mint-otp-input.element.d.ts +31 -3
  64. package/overlay/index.mjs +2 -258
  65. package/overlay/src/overlay-controller.d.ts +64 -4
  66. package/package.json +9 -1
  67. package/pagination/index.mjs +1 -1
  68. package/query-builder/index.mjs +117 -87
  69. package/query-builder/src/model/messages.d.ts +9 -0
  70. package/radio/index.mjs +2 -160
  71. package/radio/src/components/mp-radio.d.ts +58 -3
  72. package/radio-group/index.d.ts +1 -0
  73. package/radio-group/index.mjs +145 -0
  74. package/radio-group/src/components/mp-radio-group.d.ts +52 -0
  75. package/radio-group/src/index.d.ts +1 -0
  76. package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
  77. package/ribbon/index.mjs +316 -304
  78. package/ribbon/src/mp-ribbon.element.d.ts +16 -0
  79. package/scheduler/index.mjs +219 -132
  80. package/scheduler/src/components/mp-scheduler.d.ts +3 -0
  81. package/scheduler/src/views/base-view.d.ts +23 -0
  82. package/select/index.mjs +1 -1
  83. package/select/src/components/mp-select.d.ts +60 -3
  84. package/shell/index.mjs +142 -31
  85. package/shell/src/components/mp-shell.d.ts +1 -0
  86. package/signature-pad/index.d.ts +1 -0
  87. package/signature-pad/index.mjs +230 -0
  88. package/signature-pad/src/index.d.ts +2 -0
  89. package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
  90. package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
  91. package/signature-pad/src/types/signature.d.ts +12 -0
  92. package/splitter/index.mjs +1 -1
  93. package/splitter/src/components/mp-splitter.d.ts +7 -0
  94. package/tab-control/index.mjs +1 -1
  95. package/tile-manager/index.mjs +110 -93
  96. package/timeline/index.mjs +138 -54
  97. package/timeline/src/components/mp-timeline.d.ts +15 -0
  98. package/timepicker/index.mjs +1 -1
  99. package/timepicker/src/mp-time-list.element.d.ts +13 -4
  100. package/timepicker/src/mp-timepicker.element.d.ts +29 -0
  101. package/toggle-button/index.mjs +1 -1
  102. package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
  103. package/tree-select/index.mjs +233 -121
  104. package/tree-select/src/components/mp-tree-select.d.ts +37 -0
  105. package/treeview/index.mjs +1 -1
  106. package/treeview/src/components/mp-treeview.d.ts +10 -1
  107. package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
@@ -1,9 +1,13 @@
1
- import { html as b, unsafeCSS as m, LitElement as f } from "lit";
1
+ import { html as b, unsafeCSS as v, LitElement as f } from "lit";
2
+ import "lit/directives/ref.js";
3
+ import { F as x, e as _ } from "../chunks/form-associated-axmc5sY0.mjs";
4
+ import { i as y } from "../chunks/invalid-feedback.styles-he0JYrJm.mjs";
2
5
  b`<!-- Hidden input + boxes are rendered dynamically by render(). This file exists
3
6
  so the codegen-wc target produces a \`styles\` export from the sibling .scss;
4
7
  the \`template\` export it generates here is intentionally unused. -->`;
5
- const x = m(`:host {
8
+ const w = v(`:host {
6
9
  display: inline-flex;
10
+ flex-wrap: wrap;
7
11
  position: relative;
8
12
  box-sizing: border-box;
9
13
  --bs-otp-input-box-bg: var(--bs-body-bg, #fff);
@@ -124,16 +128,17 @@ const x = m(`:host {
124
128
  transition: none;
125
129
  }
126
130
  }`);
127
- class o extends f {
131
+ let A = 0;
132
+ class o extends x(f) {
128
133
  constructor() {
129
- super(...arguments), this.type = "numeric", this.case = "upper", this.size = "md", this.disabled = !1, this.label = null, this.invalid = !1, this._value = "", this._groups = [...o.DEFAULT_GROUPS], this._revealedIndex = null, this._revealedUntil = 0, this._revealTimer = null, this._inputEl = null, this._isFocused = !1, this.onInput = (e) => {
130
- const t = e.target, s = t.value, i = this._value, a = i.length === this.totalLength() && i.length > 0, r = this.normaliseValue(s), n = r.length - i.length;
131
- this.type === "password" && n === 1 ? this.scheduleReveal(r.length - 1) : n !== 1 && this.clearReveal(), this._value = r, t.value !== r && (t.value = r), this.requestUpdate(), this.dispatchValueChange(), r.length === this.totalLength() && !a && (this.clearReveal(), this.dispatchComplete());
134
+ super(...arguments), this.type = "numeric", this.case = "upper", this.size = "md", this.disabled = !1, this.inputLabel = null, this.ariaLabelForRender = null, this.invalid = !1, this.errorText = null, this._value = "", this._groups = [...o.DEFAULT_GROUPS], this._revealedIndex = null, this._revealedUntil = 0, this._revealTimer = null, this._inputEl = null, this._isFocused = !1, this._errorId = `mp-otp-input-${++A}-error`, this.onInput = (e) => {
135
+ const t = e.target, i = t.value, s = this._value, a = s.length === this.totalLength() && s.length > 0, r = this.normaliseValue(i), l = r.length - s.length;
136
+ this.type === "password" && l === 1 ? this.scheduleReveal(r.length - 1) : l !== 1 && this.clearReveal(), this._value = r, t.value !== r && (t.value = r), this.requestUpdate(), this.dispatchValueChange(), r.length === this.totalLength() && !a && (this.clearReveal(), this.dispatchComplete());
132
137
  }, this.onPaste = (e) => {
133
138
  if (this.disabled) return;
134
139
  e.preventDefault();
135
- const t = e.clipboardData?.getData("text") ?? "", s = this._value, i = s.length === this.totalLength() && s.length > 0, a = this.normaliseValue(t);
136
- this._value = a, this._inputEl && (this._inputEl.value = a), this.clearReveal(), this.requestUpdate(), this.dispatchValueChange(), a.length === this.totalLength() && !i && this.dispatchComplete();
140
+ const t = e.clipboardData?.getData("text") ?? "", i = this._value, s = i.length === this.totalLength() && i.length > 0, a = this.normaliseValue(t);
141
+ this._value = a, this._inputEl && (this._inputEl.value = a), this.clearReveal(), this.requestUpdate(), this.dispatchValueChange(), a.length === this.totalLength() && !s && this.dispatchComplete();
137
142
  }, this.onFocus = () => {
138
143
  this._isFocused = !0, this.requestUpdate();
139
144
  }, this.onBlur = () => {
@@ -143,7 +148,7 @@ class o extends f {
143
148
  };
144
149
  }
145
150
  static {
146
- this.styles = [x];
151
+ this.styles = [w, y];
147
152
  }
148
153
  static get observedAttributes() {
149
154
  return [
@@ -152,8 +157,16 @@ class o extends f {
152
157
  "case",
153
158
  "size",
154
159
  "disabled",
155
- "label",
160
+ // Renamed from 'label' (breaking, decision D3): the library-wide name for
161
+ // "accessible name of the control inside the shadow root" is input-label,
162
+ // and a second spelling on one component is precisely the inconsistency
163
+ // the rename removes. Optional — the WC defaults to 'One-time code'.
164
+ "input-label",
165
+ "aria-label",
156
166
  "invalid",
167
+ // Validation message rendered inside the shadow root and referenced by the
168
+ // hidden <input>; shown only while `invalid` is also set.
169
+ "error-text",
157
170
  "groups"
158
171
  ];
159
172
  }
@@ -165,7 +178,7 @@ class o extends f {
165
178
  converter: {
166
179
  fromAttribute: (e) => {
167
180
  if (!e) return [...o.DEFAULT_GROUPS];
168
- const t = e.split(",").map((s) => Number(s.trim())).filter((s) => Number.isFinite(s));
181
+ const t = e.split(",").map((i) => Number(i.trim())).filter((i) => Number.isFinite(i));
169
182
  return t.length > 0 ? t : [...o.DEFAULT_GROUPS];
170
183
  },
171
184
  toAttribute: (e) => Array.isArray(e) ? e.join(",") : null
@@ -176,8 +189,13 @@ class o extends f {
176
189
  case: { attribute: "case", type: String, reflect: !0 },
177
190
  size: { attribute: "size", type: String, reflect: !0 },
178
191
  disabled: { attribute: "disabled", type: Boolean, reflect: !0 },
179
- label: { attribute: "label", type: String, reflect: !1 },
180
- invalid: { attribute: "invalid", type: Boolean, reflect: !0 }
192
+ inputLabel: { attribute: "input-label", type: String, reflect: !1 },
193
+ // Not a real property; listed so a host aria-label change re-renders. The
194
+ // consumer's aria-label wins over inputLabel, same precedence as every other
195
+ // form control in the library.
196
+ ariaLabelForRender: { attribute: "aria-label", type: String, reflect: !1 },
197
+ invalid: { attribute: "invalid", type: Boolean, reflect: !0 },
198
+ errorText: { attribute: "error-text", type: String, reflect: !1 }
181
199
  };
182
200
  }
183
201
  static {
@@ -199,19 +217,19 @@ class o extends f {
199
217
  return this._value;
200
218
  }
201
219
  set value(e) {
202
- const t = this._value, s = this.normaliseValue(e ?? "");
203
- t !== s && (this._value = s, this.clearReveal(), this.requestUpdate("value", t));
220
+ const t = this._value, i = this.normaliseValue(e ?? "");
221
+ t !== i && (this._value = i, this.clearReveal(), this.requestUpdate("value", t));
204
222
  }
205
223
  get groups() {
206
224
  return this._groups;
207
225
  }
208
226
  set groups(e) {
209
- const t = this._groups, s = this.normaliseGroups(e);
210
- if (this.arraysEqual(t, s)) return;
211
- this._groups = s;
212
- const i = this.totalLength();
227
+ const t = this._groups, i = this.normaliseGroups(e);
228
+ if (this.arraysEqual(t, i)) return;
229
+ this._groups = i;
230
+ const s = this.totalLength();
213
231
  let a = !1;
214
- this._value.length > i && (this._value = this._value.slice(0, i), a = !0), this.requestUpdate("groups", t), a && this.dispatchValueChange();
232
+ this._value.length > s && (this._value = this._value.slice(0, s), a = !0), this.requestUpdate("groups", t), a && this.dispatchValueChange();
215
233
  }
216
234
  disconnectedCallback() {
217
235
  super.disconnectedCallback(), this._revealTimer && (clearTimeout(this._revealTimer), this._revealTimer = null);
@@ -244,17 +262,17 @@ class o extends f {
244
262
  if (!e || !Array.isArray(e) || e.length === 0)
245
263
  return console.warn("[mp-otp-input] groups must be a non-empty array; falling back to default."), [...o.DEFAULT_GROUPS];
246
264
  let t = !1;
247
- const s = e.map((a) => {
265
+ const i = e.map((a) => {
248
266
  const r = Math.round(Number(a));
249
267
  return !Number.isFinite(r) || r < 1 ? (t = !0, 1) : r > o.MAX_GROUP_SIZE ? (t = !0, o.MAX_GROUP_SIZE) : r;
250
268
  });
251
- let i = s.reduce((a, r) => a + r, 0);
252
- for (; i > o.MAX_TOTAL && s.length > 1; )
253
- i -= s.pop(), t = !0;
254
- return s.length === 1 && s[0] > o.MAX_TOTAL && (s[0] = o.MAX_TOTAL, t = !0), t && console.warn(`[mp-otp-input] groups clamped to ${JSON.stringify(s)} (per-element max ${o.MAX_GROUP_SIZE}, total max ${o.MAX_TOTAL}).`), s;
269
+ let s = i.reduce((a, r) => a + r, 0);
270
+ for (; s > o.MAX_TOTAL && i.length > 1; )
271
+ s -= i.pop(), t = !0;
272
+ return i.length === 1 && i[0] > o.MAX_TOTAL && (i[0] = o.MAX_TOTAL, t = !0), t && console.warn(`[mp-otp-input] groups clamped to ${JSON.stringify(i)} (per-element max ${o.MAX_GROUP_SIZE}, total max ${o.MAX_TOTAL}).`), i;
255
273
  }
256
274
  arraysEqual(e, t) {
257
- return e === t ? !0 : e.length !== t.length ? !1 : e.every((s, i) => s === t[i]);
275
+ return e === t ? !0 : e.length !== t.length ? !1 : e.every((i, s) => i === t[s]);
258
276
  }
259
277
  /** Filter to allowed chars per `type`, normalise per `case`, truncate. */
260
278
  normaliseValue(e) {
@@ -271,8 +289,21 @@ class o extends f {
271
289
  this._revealTimer && (clearTimeout(this._revealTimer), this._revealTimer = null), this._revealedIndex = null, this._revealedUntil = 0;
272
290
  }
273
291
  // ------- event dispatch -------
292
+ // ---- form association (FormAssociatedHost, Phase F) ----
293
+ formValue() {
294
+ return this._value || null;
295
+ }
296
+ formReset() {
297
+ this.clear();
298
+ }
299
+ formRestore(e) {
300
+ typeof e == "string" && (this.value = e);
301
+ }
302
+ formValidityAnchor() {
303
+ return this._inputEl;
304
+ }
274
305
  dispatchValueChange() {
275
- this.dispatchEvent(new CustomEvent("value-change", {
306
+ this.syncFormValue(), this.dispatchEvent(new CustomEvent("value-change", {
276
307
  detail: this._value,
277
308
  bubbles: !0,
278
309
  composed: !0
@@ -287,22 +318,24 @@ class o extends f {
287
318
  }
288
319
  // ------- render -------
289
320
  render() {
290
- const e = this._groups, t = this._value, s = this.boundaries(), i = s[s.length - 1], a = this._inputEl?.selectionEnd ?? t.length, r = this._isFocused ? this.activeBoxIndex(a, t.length, s) : null, l = this.type === "numeric" && e.every((u) => u === 1) ? "one-time-code" : "off", h = this.type === "numeric" ? "numeric" : "text", c = this.label ?? "One-time code";
321
+ const e = this._groups, t = this._value, i = this.boundaries(), s = i[i.length - 1], a = this._inputEl?.selectionEnd ?? t.length, r = this._isFocused ? this.activeBoxIndex(a, t.length, i) : null, u = this.type === "numeric" && e.every((h) => h === 1) ? "one-time-code" : "off", c = this.type === "numeric" ? "numeric" : "text", d = this.getAttribute("aria-label") ?? this.inputLabel ?? "One-time code", p = _(this._errorId, this.errorText, this.invalid);
291
322
  return b`
292
323
  <div class="container" part="container">
293
324
  <input
294
325
  class="hidden-input"
295
326
  part="input"
296
327
  .value=${t}
297
- autocomplete=${l}
328
+ autocomplete=${u}
298
329
  autocorrect="off"
299
330
  autocapitalize="off"
300
331
  spellcheck="false"
301
- inputmode=${h}
302
- maxlength=${i}
332
+ inputmode=${c}
333
+ maxlength=${s}
303
334
  ?disabled=${this.disabled}
304
- aria-label=${c}
335
+ aria-label=${d}
305
336
  aria-invalid=${this.invalid ? "true" : "false"}
337
+ aria-errormessage=${p.id}
338
+ aria-describedby=${p.id}
306
339
  @input=${this.onInput}
307
340
  @paste=${this.onPaste}
308
341
  @focus=${this.onFocus}
@@ -311,30 +344,31 @@ class o extends f {
311
344
  @click=${this.onCaretMove}
312
345
  />
313
346
  ${e.map(
314
- (u, d) => this.renderBox(d, u, s, t, r)
347
+ (h, n) => this.renderBox(n, h, i, t, r)
315
348
  )}
316
349
  </div>
350
+ ${p.node}
317
351
  `;
318
352
  }
319
- renderBox(e, t, s, i, a) {
320
- const r = s[e], n = s[e + 1], l = i.slice(r, Math.min(n, i.length)), h = i.length >= n, c = !h && l.length > 0, u = a === e, d = this.renderSliceContent(l, r), p = ["box"];
321
- (h || c) && p.push("box-filled"), u && p.push("box-active"), this.invalid && p.push("box-invalid");
322
- const v = p.join(" "), g = "M".repeat(t);
353
+ renderBox(e, t, i, s, a) {
354
+ const r = i[e], l = i[e + 1], u = s.slice(r, Math.min(l, s.length)), c = s.length >= l, d = !c && u.length > 0, p = a === e, h = this.renderSliceContent(u, r), n = ["box"];
355
+ (c || d) && n.push("box-filled"), p && n.push("box-active"), this.invalid && n.push("box-invalid");
356
+ const m = n.join(" "), g = "M".repeat(t);
323
357
  return b`
324
- <span class=${v} part=${p.join(" ")} aria-hidden="true">
358
+ <span class=${m} part=${n.join(" ")} aria-hidden="true">
325
359
  <span class="box-spacer">${g}</span>
326
- <span class="box-content">${d}</span>
360
+ <span class="box-content">${h}</span>
327
361
  </span>
328
362
  `;
329
363
  }
330
364
  /** Build the displayed string for a slice, applying password reveal. */
331
365
  renderSliceContent(e, t) {
332
366
  if (this.type !== "password" || e.length === 0) return e;
333
- const s = performance.now();
334
- let i = "";
367
+ const i = performance.now();
368
+ let s = "";
335
369
  for (let a = 0; a < e.length; a++)
336
- t + a === this._revealedIndex && s < this._revealedUntil ? i += e[a] : i += o.MASK_CHAR;
337
- return i;
370
+ t + a === this._revealedIndex && i < this._revealedUntil ? s += e[a] : s += o.MASK_CHAR;
371
+ return s;
338
372
  }
339
373
  /**
340
374
  * Returns the index of the visual box that should be highlighted as "active"
@@ -347,12 +381,12 @@ class o extends f {
347
381
  * - Caret at totalLength (everything filled): last box.
348
382
  * - Otherwise: the box whose [start, end) range contains caretPos.
349
383
  */
350
- activeBoxIndex(e, t, s) {
384
+ activeBoxIndex(e, t, i) {
351
385
  if (this._groups.length === 0) return null;
352
- const i = s[s.length - 1], a = Math.min(e, i);
353
- if (a >= i) return this._groups.length - 1;
354
- for (let r = 0; r < s.length - 1; r++)
355
- if (a >= s[r] && a < s[r + 1]) return r;
386
+ const s = i[i.length - 1], a = Math.min(e, s);
387
+ if (a >= s) return this._groups.length - 1;
388
+ for (let r = 0; r < i.length - 1; r++)
389
+ if (a >= i[r] && a < i[r + 1]) return r;
356
390
  return this._groups.length - 1;
357
391
  }
358
392
  }
@@ -2,6 +2,7 @@ import { LitElement, TemplateResult } from 'lit';
2
2
  import { OtpInputType } from './types/otp-input-type';
3
3
  import { OtpInputCase } from './types/otp-input-case';
4
4
  import { OtpInputSize } from './types/otp-input-size';
5
+ declare const MintOtpInputElement_base: typeof LitElement & (new (...args: any[]) => import('@mintplayer/web-components/a11y').FormAssociatedElement);
5
6
  /**
6
7
  * Bootstrap-flavoured OTP / segmented-code input.
7
8
  *
@@ -22,7 +23,7 @@ import { OtpInputSize } from './types/otp-input-size';
22
23
  *
23
24
  * Both bubble and compose so an Angular wrapper's host listeners pick them up.
24
25
  */
25
- export declare class MintOtpInputElement extends LitElement {
26
+ export declare class MintOtpInputElement extends MintOtpInputElement_base {
26
27
  static styles: import('lit').CSSResult[];
27
28
  static get observedAttributes(): string[];
28
29
  static properties: {
@@ -57,7 +58,12 @@ export declare class MintOtpInputElement extends LitElement {
57
58
  type: BooleanConstructor;
58
59
  reflect: boolean;
59
60
  };
60
- label: {
61
+ inputLabel: {
62
+ attribute: string;
63
+ type: StringConstructor;
64
+ reflect: boolean;
65
+ };
66
+ ariaLabelForRender: {
61
67
  attribute: string;
62
68
  type: StringConstructor;
63
69
  reflect: boolean;
@@ -67,13 +73,29 @@ export declare class MintOtpInputElement extends LitElement {
67
73
  type: BooleanConstructor;
68
74
  reflect: boolean;
69
75
  };
76
+ errorText: {
77
+ attribute: string;
78
+ type: StringConstructor;
79
+ reflect: boolean;
80
+ };
70
81
  };
71
82
  type: OtpInputType;
72
83
  case: OtpInputCase;
73
84
  size: OtpInputSize;
74
85
  disabled: boolean;
75
- label: string | null;
86
+ inputLabel: string | null;
87
+ /** Mirror of the host aria-label attribute; exists only to trigger re-renders. */
88
+ ariaLabelForRender: string | null;
76
89
  invalid: boolean;
90
+ /**
91
+ * Validation message, as `errorText` / `error-text`. Rendered as a
92
+ * `.invalid-feedback` node inside the shadow root and referenced from the hidden
93
+ * `<input>` by `aria-errormessage` **and** `aria-describedby`, but only while
94
+ * `invalid` is true — `aria-errormessage` is meaningless on a control that is
95
+ * not `aria-invalid`. Text rather than a node, because a consumer's own element
96
+ * lives outside this shadow root where an IDREF from the input cannot reach it.
97
+ */
98
+ errorText: string | null;
77
99
  static readonly MAX_GROUP_SIZE = 10;
78
100
  static readonly MAX_TOTAL = 40;
79
101
  static readonly DEFAULT_GROUPS: readonly number[];
@@ -86,6 +108,7 @@ export declare class MintOtpInputElement extends LitElement {
86
108
  private _revealTimer;
87
109
  private _inputEl;
88
110
  private _isFocused;
111
+ private readonly _errorId;
89
112
  get value(): string;
90
113
  set value(next: string | null | undefined);
91
114
  get groups(): number[];
@@ -108,6 +131,10 @@ export declare class MintOtpInputElement extends LitElement {
108
131
  private onCaretMove;
109
132
  private scheduleReveal;
110
133
  private clearReveal;
134
+ formValue(): string | null;
135
+ formReset(): void;
136
+ formRestore(state: string | FormData | File | null): void;
137
+ formValidityAnchor(): HTMLElement | null;
111
138
  private dispatchValueChange;
112
139
  private dispatchComplete;
113
140
  protected render(): TemplateResult;
@@ -132,3 +159,4 @@ declare global {
132
159
  'mp-otp-input': MintOtpInputElement;
133
160
  }
134
161
  }
162
+ export {};
package/overlay/index.mjs CHANGED
@@ -1,260 +1,4 @@
1
- const k = [
2
- { originX: "start", originY: "bottom", overlayX: "start", overlayY: "top" },
3
- { originX: "start", originY: "top", overlayX: "start", overlayY: "bottom" }
4
- ];
5
- class r {
6
- constructor(t, e) {
7
- this._open = !1, this.mouseDownAttached = !1, this.stackToken = null, this.activeAnchor = null, this.positionFrame = 0, this.scrollListenersAttached = !1, this.blockedScroll = null, this.blockedBodyPaddingRight = null, this.onScroll = () => {
8
- if (!this._open) return;
9
- const o = this.currentStrategy();
10
- if (o === "close") {
11
- this.close(!1);
12
- return;
13
- }
14
- o === "reposition" && this.schedulePosition();
15
- }, this.onResize = () => {
16
- this._open && this.schedulePosition();
17
- }, this.onKeyDown = (o) => {
18
- o.key === "Escape" && this._open && this.isTopOfStack() && (this.close(), o.preventDefault());
19
- }, this.onMouseDown = (o) => {
20
- this._open && (o.composedPath().includes(this.host) || this.close(!1));
21
- }, this.host = t, this.options = e, t.addController(this);
22
- }
23
- static {
24
- this.openStack = [];
25
- }
26
- /**
27
- * Allocate a frame on top of the shared overlay stack. Use this from code
28
- * paths that don't own a full `OverlayController` instance. Pair every
29
- * `pushFrame()` with a `releaseFrame(token)`.
30
- */
31
- static pushFrame() {
32
- const t = Symbol("overlay-frame-external");
33
- return r.openStack.push(t), t;
34
- }
35
- static releaseFrame(t) {
36
- const e = r.openStack.lastIndexOf(t);
37
- e >= 0 && r.openStack.splice(e, 1);
38
- }
39
- static isFrameTop(t) {
40
- return r.openStack.length > 0 && r.openStack[r.openStack.length - 1] === t;
41
- }
42
- hostConnected() {
43
- document.addEventListener("keydown", this.onKeyDown);
44
- }
45
- hostDisconnected() {
46
- document.removeEventListener("keydown", this.onKeyDown), this.detachMouseDown(), this.stackToken && this.releaseStackToken();
47
- }
48
- get isOpen() {
49
- return this._open;
50
- }
51
- async open() {
52
- this._open || (this._open = !0, this.stackToken = r.pushFrame(), this.host.setAttribute("data-menu-open", ""), this.host.requestUpdate(), await this.host.updateComplete, this.position(), this.attachScrollListeners(), setTimeout(() => this.attachMouseDown(), 0), this.options.onOpen?.());
53
- }
54
- close(t = !0) {
55
- this._open && (this._open = !1, this.releaseStackToken(), this.host.removeAttribute("data-menu-open"), this.host.requestUpdate(), this.detachMouseDown(), this.detachScrollListeners(), this.positionFrame && (cancelAnimationFrame(this.positionFrame), this.positionFrame = 0), t && (this.options.trigger?.() ?? this.activeAnchor)?.focus(), this.activeAnchor = null, this.options.onClose?.());
56
- }
57
- async toggle() {
58
- this._open ? this.close() : await this.open();
59
- }
60
- /**
61
- * Resolve the list of candidate anchors from `anchor()`. Single-element
62
- * returns become a one-item array; null returns become an empty array.
63
- * Nulls inside arrays are filtered out.
64
- */
65
- resolveAnchors() {
66
- const t = this.options.anchor();
67
- if (t === null) return [];
68
- if (Array.isArray(t)) {
69
- const e = t.filter((o) => o != null);
70
- return e.length === 0 && t.length > 0 && console.warn("[OverlayController] anchor() returned an array of all-null elements."), e;
71
- }
72
- return [t];
73
- }
74
- /**
75
- * Resolve the *active* anchor — the one used in the most recent positioning
76
- * pass, or the first available one if none has been picked yet.
77
- */
78
- resolveAnchor() {
79
- return this.activeAnchor ? this.activeAnchor : this.resolveAnchors()[0] ?? null;
80
- }
81
- /**
82
- * Walk the configured `positions` and pick the first candidate whose panel
83
- * rect fully fits inside the viewport (minus `viewportMargin`). If none fit,
84
- * the last candidate is applied and clamped to viewport edges (push behaviour).
85
- *
86
- * `start`/`end` are direction-aware: in RTL contexts they swap to match
87
- * visual layout.
88
- *
89
- * Sticky-offscreen behaviour: when `stickyOnAnchorOffscreen` is true and the
90
- * anchor's bounding rect is entirely outside the viewport, the panel is
91
- * pinned to its last in-viewport position (clamped to viewport edges) rather
92
- * than disappearing with the anchor. Normal positioning resumes when the
93
- * anchor re-enters the viewport.
94
- */
95
- position() {
96
- const t = this.resolveAnchors(), e = this.options.panel();
97
- if (t.length === 0 || !e) return;
98
- this.applyPanelWidth(e, t[0]);
99
- const o = this.options.viewportMargin ?? 8, i = e.getBoundingClientRect(), s = window.innerWidth, n = window.innerHeight, h = t[0].getBoundingClientRect();
100
- if (this.options.stickyOnAnchorOffscreen && this.isAnchorOffscreen(h, s, n)) {
101
- const l = parseFloat(e.style.left) || i.left, d = parseFloat(e.style.top) || i.top, c = this.clampToViewport({ left: l, top: d }, i, s, n, o);
102
- e.style.left = `${c.left}px`, e.style.top = `${c.top}px`;
103
- return;
104
- }
105
- const a = this.options.positions ?? k, m = this.isRtl();
106
- let p = null, u = null;
107
- t: for (const l of t) {
108
- const d = l.getBoundingClientRect();
109
- for (const c of a) {
110
- const y = this.placeFor(c, d, i, m);
111
- if (p = l, u = y, this.fitsInViewport(y, i, s, n, o)) break t;
112
- }
113
- }
114
- if (!u || !p) return;
115
- this.activeAnchor = p;
116
- const f = this.clampToViewport(u, i, s, n, o);
117
- e.style.left = `${f.left}px`, e.style.top = `${f.top}px`;
118
- }
119
- /** True when the anchor's bounding rect lies entirely outside the viewport. */
120
- isAnchorOffscreen(t, e, o) {
121
- return t.right < 0 || t.bottom < 0 || t.left > e || t.top > o;
122
- }
123
- /**
124
- * Apply the configured `panelWidth` strategy to the panel element. Called
125
- * from `position()` before measurement so the position-pair fit check
126
- * sees the post-resize panel dimensions.
127
- *
128
- * For `'anchor'` and `'anchor-min'` the anchor's `offsetWidth` is used
129
- * (not `getBoundingClientRect().width`) so transforms / zoom on ancestors
130
- * don't skew the result.
131
- */
132
- applyPanelWidth(t, e) {
133
- const o = this.options.panelWidth;
134
- if (o != null) {
135
- if (o === "anchor") {
136
- t.style.width = `${e.offsetWidth}px`, t.style.minWidth = "";
137
- return;
138
- }
139
- if (o === "anchor-min") {
140
- t.style.minWidth = `${e.offsetWidth}px`, t.style.width = "";
141
- return;
142
- }
143
- if (typeof o == "number") {
144
- t.style.width = `${o}px`, t.style.minWidth = "";
145
- return;
146
- }
147
- t.style.width = o, t.style.minWidth = "";
148
- }
149
- }
150
- isRtl() {
151
- return getComputedStyle(this.host).direction === "rtl";
152
- }
153
- /**
154
- * Compute the (left, top) at which `panel` should be placed for a single
155
- * position candidate. The candidate identifies which corner of the anchor
156
- * to align which corner of the panel to, plus optional pixel offsets.
157
- */
158
- placeFor(t, e, o, i) {
159
- const s = this.anchorXFor(t.originX, e, i), n = this.anchorYFor(t.originY, e), h = this.panelXOffsetFor(t.overlayX, o.width, i), a = this.panelYOffsetFor(t.overlayY, o.height);
160
- return {
161
- left: s + h + (t.offsetX ?? 0),
162
- top: n + a + (t.offsetY ?? 0)
163
- };
164
- }
165
- anchorXFor(t, e, o) {
166
- const i = o ? e.right : e.left, s = o ? e.left : e.right;
167
- return t === "start" ? i : t === "end" ? s : e.left + e.width / 2;
168
- }
169
- anchorYFor(t, e) {
170
- return t === "top" ? e.top : t === "bottom" ? e.bottom : e.top + e.height / 2;
171
- }
172
- panelXOffsetFor(t, e, o) {
173
- return t === "start" ? o ? -e : 0 : t === "end" ? o ? 0 : -e : -e / 2;
174
- }
175
- panelYOffsetFor(t, e) {
176
- return t === "top" ? 0 : t === "bottom" ? -e : -e / 2;
177
- }
178
- fitsInViewport(t, e, o, i, s) {
179
- return t.left >= s && t.top >= s && t.left + e.width <= o - s && t.top + e.height <= i - s;
180
- }
181
- clampToViewport(t, e, o, i, s) {
182
- let { left: n, top: h } = t;
183
- return n + e.width > o - s && (n = o - e.width - s), n < s && (n = s), h + e.height > i - s && (h = i - e.height - s), h < s && (h = s), { left: n, top: h };
184
- }
185
- /* ---- Scroll + resize tracking ---- */
186
- currentStrategy() {
187
- return this.options.scrollStrategy ?? "reposition";
188
- }
189
- /**
190
- * Wire scroll + resize listeners according to the active strategy. Called
191
- * from open(); paired with detachScrollListeners() in close().
192
- *
193
- * The capture-phase listener on document catches scroll events from any
194
- * scrollable ancestor without us having to walk the DOM — scroll events
195
- * don't bubble, but capture-phase listeners receive every dispatch.
196
- */
197
- attachScrollListeners() {
198
- if (this.scrollListenersAttached) return;
199
- this.scrollListenersAttached = !0;
200
- const t = this.currentStrategy();
201
- if (t !== "noop") {
202
- if (window.addEventListener("resize", this.onResize, { passive: !0 }), t === "block") {
203
- this.applyBlockScroll();
204
- return;
205
- }
206
- document.addEventListener("scroll", this.onScroll, {
207
- passive: !0,
208
- capture: !0
209
- });
210
- }
211
- }
212
- detachScrollListeners() {
213
- this.scrollListenersAttached && (this.scrollListenersAttached = !1, window.removeEventListener("resize", this.onResize), document.removeEventListener("scroll", this.onScroll, !0), this.releaseBlockScroll());
214
- }
215
- schedulePosition() {
216
- this.positionFrame || (this.positionFrame = requestAnimationFrame(() => {
217
- this.positionFrame = 0, this.position();
218
- }));
219
- }
220
- /**
221
- * 'block' strategy: lock the document scroll position while the overlay is
222
- * open. Mirrors CDK's BlockScrollStrategy — sets position: fixed on the html
223
- * element with the saved offset, then restores on close. Cheap; no event
224
- * preventDefault dance required.
225
- */
226
- applyBlockScroll() {
227
- if (this.blockedScroll) return;
228
- const t = document.documentElement, e = t.scrollTop || window.scrollY, o = t.scrollLeft || window.scrollX, i = Math.max(0, window.innerWidth - t.clientWidth);
229
- if (this.blockedScroll = { top: e, left: o }, i > 0) {
230
- const s = document.body;
231
- this.blockedBodyPaddingRight = s.style.paddingRight;
232
- const n = parseFloat(getComputedStyle(s).paddingRight) || 0;
233
- s.style.paddingRight = `${n + i}px`;
234
- }
235
- t.style.setProperty("--overlay-blocked-top", `-${e}px`), t.style.setProperty("--overlay-blocked-left", `-${o}px`), t.style.position = "fixed", t.style.top = `-${e}px`, t.style.left = `-${o}px`, t.style.width = "100%";
236
- }
237
- releaseBlockScroll() {
238
- if (!this.blockedScroll) return;
239
- const { top: t, left: e } = this.blockedScroll;
240
- this.blockedScroll = null;
241
- const o = document.documentElement;
242
- o.style.position = "", o.style.top = "", o.style.left = "", o.style.width = "", o.style.removeProperty("--overlay-blocked-top"), o.style.removeProperty("--overlay-blocked-left"), this.blockedBodyPaddingRight !== null && (document.body.style.paddingRight = this.blockedBodyPaddingRight, this.blockedBodyPaddingRight = null), window.scrollTo(e, t);
243
- }
244
- /* ---- Esc-stack ---- */
245
- releaseStackToken() {
246
- this.stackToken && (r.releaseFrame(this.stackToken), this.stackToken = null);
247
- }
248
- isTopOfStack() {
249
- return this.stackToken !== null && r.isFrameTop(this.stackToken);
250
- }
251
- attachMouseDown() {
252
- this.mouseDownAttached || (document.addEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !0);
253
- }
254
- detachMouseDown() {
255
- this.mouseDownAttached && (document.removeEventListener("mousedown", this.onMouseDown, !0), this.mouseDownAttached = !1);
256
- }
257
- }
1
+ import { O as e } from "../chunks/overlay-controller-DPt13i8p.mjs";
258
2
  export {
259
- r as OverlayController
3
+ e as OverlayController
260
4
  };