@mono-lit/helper 0.0.9 → 0.0.10

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 (161) hide show
  1. package/dist/accordion-core-DaNyPWRr.js +277 -0
  2. package/dist/alert-core-DWtHbX_-.js +134 -0
  3. package/dist/breadcrumb-list-core-Dh68T8Cf.js +747 -0
  4. package/dist/{mono-button-CLkHg3WW.js → button-core-DerXg84Q.js} +3 -276
  5. package/dist/button-dropdown-core-DKYEOyjy.js +654 -0
  6. package/dist/button-utils-D5-66M02.js +63 -0
  7. package/dist/card-utils-l80qAmrN.js +312 -0
  8. package/dist/chart-core-DV7hD3ZY.js +801 -0
  9. package/dist/checkbox-utils-DKdrhAzF.js +337 -0
  10. package/dist/chip-utils-DpRrd7Zj.js +403 -0
  11. package/dist/{data-source-controller-C6C4ej_M.js → data-source-controller-DS_JLrmS.js} +1 -1
  12. package/dist/{data-source-options-fxT5QIX4.js → data-source-options-DJUNU26C.js} +6 -6
  13. package/dist/{data-source-read-BL266IW0.js → data-source-read-uKJpRAzx.js} +2 -2
  14. package/dist/date-core-CyuSyvvG.js +734 -0
  15. package/dist/drawer-core-DbFWvNln.js +759 -0
  16. package/dist/dropdown-core-BCH1pK14.js +511 -0
  17. package/dist/dropdown-table-core-SfHUJVFq.js +1342 -0
  18. package/dist/export.js +1 -1
  19. package/dist/{field-path-BabiMrrA.js → field-path-DK2VBWHl.js} +1 -1
  20. package/dist/field-tooltip.css_raw-DVblekCl.js +5 -0
  21. package/dist/{field-validation.css_raw-Cx6SGrfP.js → field-validation.css_raw-BU7C6173.js} +1 -170
  22. package/dist/file-upload-core-Cz_dBQMx.js +624 -0
  23. package/dist/filter-builder-core-DyWjbBP7.js +381 -0
  24. package/dist/{filter-builder-B6Y2mmbM.js → filter-builder-vbqIuPhX.js} +1 -1
  25. package/dist/{filter-eval-ChDSaAUH.js → filter-eval-CqeBnMYh.js} +1 -1
  26. package/dist/{filter-odata-Bi27XUpQ.js → filter-odata-GsczYKNC.js} +1 -1
  27. package/dist/{hydration-flush-BaE9gN3C.js → hydration-flush-Volt9X7Q.js} +2 -1071
  28. package/dist/index.js +11 -11
  29. package/dist/{index.node-DTqDBca7.js → index.node-Csy9zrr1.js} +4 -4
  30. package/dist/index.node.js +11 -11
  31. package/dist/input-utils-BglY-k0H.js +1145 -0
  32. package/dist/menu-core-DkAYuCZ2.js +831 -0
  33. package/dist/modal-core-CSBSPN_m.js +844 -0
  34. package/dist/mono-button-DVvZ03P-.js +280 -0
  35. package/dist/{mono-button.shadow-DqZMpcqY.js → mono-button.shadow-BANxMGln.js} +6 -594
  36. package/dist/{mono-data-chart-NKPdAgVq.js → mono-data-chart-ChF4J9RT.js} +6 -6
  37. package/dist/{mono-data-dropdown-B2iRpJuI.js → mono-data-dropdown-Bgj2PDfm.js} +1 -1
  38. package/dist/{mono-data-grid-llJCX9MC.js → mono-data-grid-DJkp96N-.js} +144 -46
  39. package/dist/{mono-event-BPku9HpS.js → mono-event-CAZf0F_k.js} +14 -9
  40. package/dist/{mono-form-controller-BrA10erm.js → mono-form-controller-DxZLvyg6.js} +2 -1
  41. package/dist/mono-table-checkbox-core-BKOMx8R5.js +5288 -0
  42. package/dist/nav-core-B5qU2dzn.js +225 -0
  43. package/dist/{normalize-error-D93O4q8g.js → normalize-error-BEcd1tmS.js} +2 -2
  44. package/dist/otp-core-DXg3vFLh.js +758 -0
  45. package/dist/radio-utils-Dk9Tl1jz.js +319 -0
  46. package/dist/rich-text-editor-core-Ddd_QaLn.js +1280 -0
  47. package/dist/select-utils-BgArYHk8.js +2140 -0
  48. package/dist/sidebar-core-CD6txDo3.js +583 -0
  49. package/dist/slider-core-vcWr321-.js +1014 -0
  50. package/dist/src/components/dropdown-table/dropdown-table-core.d.ts +2 -2
  51. package/dist/src/components/dropdown-table/dropdown-table-types.d.ts +1 -1
  52. package/dist/src/components/dropdown-table/index.d.ts +1 -1
  53. package/dist/src/components/dropdown-table/index.shadow.d.ts +1 -1
  54. package/dist/src/components/dropdown-table/mono-data-dropdown.d.ts +1 -1
  55. package/dist/src/components/form/form-types.d.ts +9 -3
  56. package/dist/src/components/input/input-core.d.ts +1 -1
  57. package/dist/src/components/input/input-types.d.ts +1 -1
  58. package/dist/src/components/otp/otp-core.d.ts +1 -1
  59. package/dist/src/components/select/select-core.d.ts +1 -1
  60. package/dist/src/components/select/select-types.d.ts +1 -1
  61. package/dist/src/components/slider/slider-core.d.ts +1 -1
  62. package/dist/src/components/slider/slider-types.d.ts +1 -1
  63. package/dist/src/components/table/filter-suggestion.d.ts +171 -0
  64. package/dist/src/components/table/index.d.ts +5 -4
  65. package/dist/src/components/table/index.shadow.d.ts +5 -4
  66. package/dist/src/components/table/mono-data-grid.d.ts +22 -3
  67. package/dist/src/components/table/mono-table-empty-core.d.ts +37 -0
  68. package/dist/src/components/table/mono-table-search-core.d.ts +22 -3
  69. package/dist/src/components/table/table-types.d.ts +74 -4
  70. package/dist/src/components/tag-input/tag-input-core.d.ts +1 -1
  71. package/dist/src/components/tag-input/tag-input-types.d.ts +1 -1
  72. package/dist/src/components/textarea/textarea-core.d.ts +1 -1
  73. package/dist/src/composables/mono-event.d.ts +7 -1
  74. package/dist/src/entries/index.d.ts +8 -6
  75. package/dist/src/entries/index.node.d.ts +8 -6
  76. package/dist/src/search/index.d.ts +1 -1
  77. package/dist/src/utils/group-count.d.ts +36 -0
  78. package/dist/switch-utils-CTZ4id2V.js +338 -0
  79. package/dist/tabs-core-r5-B8k_N.js +317 -0
  80. package/dist/tag-input-utils-D2JA90DQ.js +3060 -0
  81. package/dist/textarea-utils-VU1KeXm8.js +821 -0
  82. package/dist/ui/accordion.js +2 -274
  83. package/dist/ui/alert.js +2 -131
  84. package/dist/ui/breadcrumb.js +4 -745
  85. package/dist/ui/button-dropdown.js +4 -652
  86. package/dist/ui/button.js +2 -63
  87. package/dist/ui/card.js +2 -310
  88. package/dist/ui/chart.js +4 -800
  89. package/dist/ui/checkbox.js +4 -335
  90. package/dist/ui/chip.js +4 -402
  91. package/dist/ui/date.js +3 -732
  92. package/dist/ui/drawer.js +3 -757
  93. package/dist/ui/dropdown-table.js +5 -1341
  94. package/dist/ui/dropdown.js +4 -509
  95. package/dist/ui/file-upload.js +3 -622
  96. package/dist/ui/filter.js +5 -380
  97. package/dist/ui/form.js +1 -1
  98. package/dist/ui/index.css +118 -1
  99. package/dist/ui/input.js +3 -1141
  100. package/dist/ui/menu.js +4 -828
  101. package/dist/ui/modal.js +4 -843
  102. package/dist/ui/nav.js +4 -223
  103. package/dist/ui/otp.js +4 -756
  104. package/dist/ui/radio.js +4 -317
  105. package/dist/ui/rich-text-editor.js +4 -1278
  106. package/dist/ui/select.js +5 -2138
  107. package/dist/ui/shadow/accordion.js +4 -273
  108. package/dist/ui/shadow/alert.js +4 -130
  109. package/dist/ui/shadow/breadcrumb.js +5 -744
  110. package/dist/ui/shadow/button-dropdown.js +6 -652
  111. package/dist/ui/shadow/button.js +3 -63
  112. package/dist/ui/shadow/card.js +4 -309
  113. package/dist/ui/shadow/chart.js +6 -1576
  114. package/dist/ui/shadow/checkbox.js +4 -334
  115. package/dist/ui/shadow/chip.js +4 -396
  116. package/dist/ui/shadow/date.js +7 -731
  117. package/dist/ui/shadow/drawer.js +4 -756
  118. package/dist/ui/shadow/dropdown-table.js +8 -1762
  119. package/dist/ui/shadow/dropdown.js +4 -508
  120. package/dist/ui/shadow/file-upload.js +4 -620
  121. package/dist/ui/shadow/filter.js +7 -379
  122. package/dist/ui/shadow/input.js +6 -1140
  123. package/dist/ui/shadow/menu.js +5 -828
  124. package/dist/ui/shadow/modal.js +6 -1063
  125. package/dist/ui/shadow/nav.js +5 -223
  126. package/dist/ui/shadow/otp.js +6 -754
  127. package/dist/ui/shadow/radio.js +4 -316
  128. package/dist/ui/shadow/rich-text-editor.js +4 -1276
  129. package/dist/ui/shadow/select.js +6 -2136
  130. package/dist/ui/shadow/sidebar.js +5 -581
  131. package/dist/ui/shadow/slider.js +5 -1010
  132. package/dist/ui/shadow/switch.js +4 -335
  133. package/dist/ui/shadow/table.js +10 -4501
  134. package/dist/ui/shadow/tabs.js +6 -315
  135. package/dist/ui/shadow/tag-input.js +7 -3057
  136. package/dist/ui/shadow/textarea.js +6 -817
  137. package/dist/ui/sidebar.js +3 -581
  138. package/dist/ui/slider.js +4 -1012
  139. package/dist/ui/switch.js +4 -336
  140. package/dist/ui/table.js +9 -4502
  141. package/dist/ui/tabs.js +4 -315
  142. package/dist/ui/tag-input.js +5 -3058
  143. package/dist/ui/textarea.js +4 -819
  144. package/dist/vue.d.ts +3 -2
  145. package/package.json +3 -3
  146. package/dist/chip-strip-bNfLn52Z.js +0 -215
  147. package/dist/data-source-controller-Dx6IQ2CN.js +0 -243
  148. package/dist/data-source-options-BM4r4PRw.js +0 -558
  149. package/dist/data-source-read-HyBCRg1t.js +0 -242
  150. package/dist/excel-BXzr3uI1.js +0 -784
  151. package/dist/export-ixRdCS2y.js +0 -2388
  152. package/dist/field-tooltip-addon-CWCp19mJ.js +0 -702
  153. package/dist/field-tooltip.css_raw-U5UeTa2d.js +0 -269
  154. package/dist/filter-builder-C0T3pMx2.js +0 -208
  155. package/dist/form-control-core-BbiACMtL.js +0 -226
  156. package/dist/icon-ClxnYhBG.js +0 -19
  157. package/dist/import-Dc4eXC02.js +0 -612
  158. package/dist/light-slots-_no0r2Z-.js +0 -246
  159. package/dist/markdown-uGlE_OfJ.js +0 -20191
  160. package/dist/mono-data-grid-e9ZVBlNN.js +0 -4240
  161. package/dist/normalize-error-BmLbgANw.js +0 -1048
@@ -0,0 +1,758 @@
1
+ import { d as buildSizeStyle } from "./mono-ui-kvLVIf1V.js";
2
+ import { a as defineHybridPropAliases, i as defineHybridPropAlias, r as booleanStringConverter, t as __decorate } from "./decorate-DbYFpi8R.js";
3
+ import { t as dispatchMonoEvent } from "./mono-event-CAZf0F_k.js";
4
+ import { t as MonoFormControlCore } from "./form-control-core-CRZPZ1ru.js";
5
+ import { n as cssPart } from "./css-class-B6Tc_MAx.js";
6
+ import { t as FieldTooltipController } from "./field-tooltip-Csk4s2ve.js";
7
+ import { t as FieldValidationController } from "./field-validation-CFmUmuDx.js";
8
+ import { html, nothing } from "lit";
9
+ import { property, state } from "lit/decorators.js";
10
+ import { ifDefined } from "lit/directives/if-defined.js";
11
+ import { styleMap } from "lit/directives/style-map.js";
12
+ import { live } from "lit/directives/live.js";
13
+
14
+ //#region src/components/otp/otp-utils.ts
15
+ /**
16
+ * Pure helpers behind `mono-otp`. The value is always a CONTIGUOUS prefix of the boxes — box i
17
+ * holds `value[i]` — so every edit is a string operation and the boxes are just its characters.
18
+ */
19
+ const OTP_DEFAULT_LENGTH = 6;
20
+ /** One character cleaned for `type`; `''` when it is not accepted. */
21
+ function sanitizeOtpChar(ch, type = "numeric") {
22
+ if (!ch) return "";
23
+ if (type === "numeric") return /^[0-9]$/.test(ch) ? ch : "";
24
+ if (type === "alphanumeric") return /^[A-Za-z0-9]$/.test(ch) ? ch.toUpperCase() : "";
25
+ return /^\S$/u.test(ch) ? ch : "";
26
+ }
27
+ /** A whole string cleaned for `type` — rejected characters are dropped, not kept as holes. */
28
+ function sanitizeOtpText(text, type = "numeric") {
29
+ if (text == null) return "";
30
+ let out = "";
31
+ for (const ch of Array.from(String(text))) out += sanitizeOtpChar(ch, type);
32
+ return out;
33
+ }
34
+ /** `length` from a prop or attribute: a whole number ≥ 1, else the default. */
35
+ function resolveOtpLength(length) {
36
+ const n = Math.floor(Number(length));
37
+ return Number.isFinite(n) && n >= 1 ? n : 6;
38
+ }
39
+ /** The model for `length` boxes: cleaned and cut to fit. */
40
+ function normaliseOtpValue(value, length, type = "numeric") {
41
+ return Array.from(sanitizeOtpText(value, type)).slice(0, length).join("");
42
+ }
43
+ /**
44
+ * Group sizes → the box indexes a separator goes BEFORE. `3` repeats (6 boxes → 3-3, 8 → 3-3-2);
45
+ * a list is taken as given and any boxes past it form one last group.
46
+ */
47
+ function parseOtpGroups(groups, length) {
48
+ if (groups == null || groups === "") return [];
49
+ let sizes;
50
+ if (typeof groups === "number") sizes = [groups];
51
+ else if (Array.isArray(groups)) sizes = groups.map(Number);
52
+ else sizes = String(groups).replace(/[[\]\s]/g, "").split(/[,\-|]/).filter(Boolean).map(Number);
53
+ sizes = sizes.filter((n) => Number.isFinite(n) && n >= 1).map(Math.floor);
54
+ if (!sizes.length) return [];
55
+ const repeat = sizes.length === 1;
56
+ const breaks = [];
57
+ let at = 0;
58
+ for (let k = 0;; k++) {
59
+ const size = repeat ? sizes[0] : sizes[k];
60
+ if (size == null) break;
61
+ at += size;
62
+ if (at >= length) break;
63
+ breaks.push(at);
64
+ }
65
+ return breaks;
66
+ }
67
+ /**
68
+ * Put `text` at box `index`. One character replaces that box; several (a paste, an SMS
69
+ * autofill) overwrite from `index` onwards. Rejected characters are dropped first, so pasting
70
+ * `"123-456"` into a numeric field fills six boxes.
71
+ */
72
+ function spliceOtpValue(value, index, text, length, type = "numeric") {
73
+ const chars = Array.from(value);
74
+ const clean = Array.from(sanitizeOtpText(text, type));
75
+ if (!clean.length) return {
76
+ value,
77
+ caret: clampCaret(index, chars.length, length)
78
+ };
79
+ const at = Math.min(Math.max(0, index), chars.length);
80
+ let next;
81
+ if (clean.length === 1) {
82
+ next = chars.slice();
83
+ next[at] = clean[0];
84
+ } else next = chars.slice(0, at).concat(clean);
85
+ next = next.slice(0, length);
86
+ return {
87
+ value: next.join(""),
88
+ caret: clampCaret(at + clean.length, next.length, length)
89
+ };
90
+ }
91
+ /** Remove the character in box `index`; the boxes after it move left. */
92
+ function removeOtpChar(value, index, length) {
93
+ const chars = Array.from(value);
94
+ if (index < 0 || index >= chars.length) return {
95
+ value,
96
+ caret: clampCaret(index, chars.length, length)
97
+ };
98
+ chars.splice(index, 1);
99
+ return {
100
+ value: chars.join(""),
101
+ caret: clampCaret(index, chars.length, length)
102
+ };
103
+ }
104
+ /**
105
+ * Backspace in box `index`: clear it when it holds a character, otherwise step back and clear
106
+ * the one before.
107
+ */
108
+ function backspaceOtp(value, index, length) {
109
+ const filled = Array.from(value).length;
110
+ if (index < filled) return removeOtpChar(value, index, length);
111
+ if (filled === 0) return {
112
+ value,
113
+ caret: 0
114
+ };
115
+ return removeOtpChar(value, filled - 1, length);
116
+ }
117
+ /** The furthest box that can take focus: the first empty one, or the last box when full. */
118
+ function clampCaret(index, filled, length) {
119
+ return Math.max(0, Math.min(index, filled, length - 1));
120
+ }
121
+
122
+ //#endregion
123
+ //#region src/components/otp/otp-core.ts
124
+ /**
125
+ * `MonoOtpCore` — all render-mode-agnostic logic for `mono-otp`: N single-character boxes that
126
+ * behave as ONE field. The value is a contiguous prefix of the boxes (box i holds `value[i]`), so
127
+ * focus can never land past the first empty box, Backspace / Delete shift the rest left, and a
128
+ * paste or an SMS autofill overwrites from the focused box on (see `otp-utils.ts`).
129
+ *
130
+ * Same prop surface as mono-input (size / color / variant / label-position / validation-position
131
+ * / tooltip / messages / states / sizing), wired to `controlMonoForm` through
132
+ * `MonoFormControlCore`: `input` per edit (live rules), `change` when focus leaves the group
133
+ * (change rules, marks touched), plus `complete` once every box is filled.
134
+ *
135
+ * Each build supplies `createRenderRoot()`, the slot strategy (the `_render*` hooks below) and
136
+ * `renderIcon()` — light captures `slot="…"` children into `[data-mono-slot]` placeholders,
137
+ * shadow uses native `<slot>`s.
138
+ */
139
+ const MonoOtpCore = (superClass) => {
140
+ class MonoOtpCoreClass extends MonoFormControlCore(superClass) {
141
+ constructor(...args) {
142
+ super(...args);
143
+ this.cssClass = {};
144
+ this.cssClassName = "";
145
+ this.type = "numeric";
146
+ this.length = 6;
147
+ this.separator = "-";
148
+ this.mask = false;
149
+ this.size = "md";
150
+ this.color = "primary";
151
+ this.variant = "outlined";
152
+ this.labelPosition = "top";
153
+ this.validationPosition = "bottom";
154
+ this.modelValue = "";
155
+ this.value = "";
156
+ this.name = "";
157
+ this.placeholder = "";
158
+ this.label = "";
159
+ this.helperText = "";
160
+ this.tooltip = null;
161
+ this._tooltip = new FieldTooltipController(this, () => this.tooltip);
162
+ this._validation = new FieldValidationController(this, () => ({
163
+ position: this.validationPosition,
164
+ ...this._validationNotice ?? {
165
+ state: void 0,
166
+ text: void 0
167
+ }
168
+ }), () => this.renderRoot?.querySelector?.("[mono-otp] > [mono-field]"));
169
+ this.validationState = "default";
170
+ this.validationMessage = "";
171
+ this.error = false;
172
+ this.errorMessage = "";
173
+ this.success = false;
174
+ this.successMessage = "";
175
+ this.autocomplete = "one-time-code";
176
+ this.inputmode = "";
177
+ this.disabled = false;
178
+ this.readonly = false;
179
+ this.required = false;
180
+ this.clearable = false;
181
+ this.autofocus = false;
182
+ this._code = "";
183
+ this._focusIndex = -1;
184
+ this._hasPrefixSlotState = false;
185
+ this._hasSuffixSlotState = false;
186
+ this._hasLabelSlotState = false;
187
+ this._hasHelperSlotState = false;
188
+ this._committed = null;
189
+ this._otpId = `mono-otp-${Math.random().toString(36).slice(2)}`;
190
+ this._messageId = `${this._otpId}-message`;
191
+ this._onCellInput = (event) => {
192
+ const el = event.currentTarget;
193
+ const i = this._indexOf(event);
194
+ const old = Array.from(this._code)[i] ?? "";
195
+ const raw = el.value;
196
+ if (!this._editable) {
197
+ el.value = old;
198
+ event.stopPropagation();
199
+ return;
200
+ }
201
+ if (raw === "") {
202
+ el.value = old;
203
+ const edit = removeOtpChar(this._code, i, this._length);
204
+ if (edit.value === this._code) event.stopPropagation();
205
+ this._apply(edit, i, event);
206
+ return;
207
+ }
208
+ let text = raw;
209
+ if (old && Array.from(raw).length === 2 && raw.includes(old)) text = raw.startsWith(old) ? raw.slice(old.length) : raw.slice(0, raw.length - old.length);
210
+ const edit = spliceOtpValue(this._code, i, text, this._length, this.type);
211
+ el.value = Array.from(edit.value)[i] ?? "";
212
+ if (edit.value === this._code) event.stopPropagation();
213
+ this._apply(edit, i, event);
214
+ };
215
+ this._onCellKeydown = (event) => {
216
+ const i = this._indexOf(event);
217
+ const n = this._length;
218
+ const last = clampCaret(n, this._filled, n);
219
+ switch (event.key) {
220
+ case "Backspace":
221
+ event.preventDefault();
222
+ if (this._editable) this._apply(backspaceOtp(this._code, i, n), i, event);
223
+ return;
224
+ case "Delete":
225
+ event.preventDefault();
226
+ if (this._editable) this._apply(removeOtpChar(this._code, i, n), i, event);
227
+ return;
228
+ case "ArrowLeft":
229
+ case "ArrowUp":
230
+ event.preventDefault();
231
+ this._focusCell(Math.max(0, i - 1));
232
+ return;
233
+ case "ArrowRight":
234
+ case "ArrowDown":
235
+ event.preventDefault();
236
+ this._focusCell(Math.min(last, i + 1));
237
+ return;
238
+ case "Home":
239
+ event.preventDefault();
240
+ this._focusCell(0);
241
+ return;
242
+ case "End":
243
+ event.preventDefault();
244
+ this._focusCell(last);
245
+ return;
246
+ }
247
+ if (this._editable && event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
248
+ const edit = spliceOtpValue(this._code, i, event.key, n, this.type);
249
+ if (edit.value === this._code && i < this._filled && sanitizeOtpChar(event.key, this.type)) {
250
+ event.preventDefault();
251
+ this._focusCell(edit.caret);
252
+ }
253
+ }
254
+ };
255
+ this._onCellPaste = (event) => {
256
+ event.preventDefault();
257
+ if (!this._editable) return;
258
+ const text = event.clipboardData?.getData("text") ?? "";
259
+ this._apply(spliceOtpValue(this._code, this._indexOf(event), text, this._length, this.type), this._indexOf(event), event);
260
+ };
261
+ this._onCellFocus = (event) => {
262
+ const i = this._indexOf(event);
263
+ const allowed = clampCaret(i, this._filled, this._length);
264
+ if (allowed !== i) {
265
+ this._focusCell(allowed);
266
+ return;
267
+ }
268
+ this._focusIndex = i;
269
+ event.currentTarget.select?.();
270
+ };
271
+ this._onCellClick = (event) => {
272
+ event.currentTarget.select?.();
273
+ };
274
+ this._onFieldFocusIn = () => {
275
+ if (this._committed === null) this._committed = this._code;
276
+ };
277
+ this._onFieldFocusOut = (event) => {
278
+ const next = event.relatedTarget;
279
+ if (next && this.renderRoot.contains(next)) return;
280
+ this._focusIndex = -1;
281
+ const before = this._committed;
282
+ this._committed = null;
283
+ if (before !== null && before !== this._code) dispatchMonoEvent(this, "change", this._detail(before, -1, event));
284
+ };
285
+ this._swallow = (event) => {
286
+ event.stopPropagation();
287
+ };
288
+ this._onClear = () => {
289
+ if (!this._editable) return;
290
+ this.clear();
291
+ this._focusCell(0);
292
+ };
293
+ defineHybridPropAliases(this, [
294
+ "labelPosition",
295
+ "validationPosition",
296
+ "modelValue",
297
+ "helperText",
298
+ "validationState",
299
+ "validationMessage",
300
+ "errorMessage",
301
+ "successMessage",
302
+ "ariaLabelText",
303
+ "cssClass",
304
+ "minWidth",
305
+ "maxWidth",
306
+ "minHeight",
307
+ "maxHeight"
308
+ ]);
309
+ for (const alias of [
310
+ "ariaLabel",
311
+ "aria-label",
312
+ "arialabel"
313
+ ]) Object.defineProperty(this, alias, {
314
+ get: () => this.ariaLabelText,
315
+ set: (value) => {
316
+ this.ariaLabelText = value == null ? void 0 : String(value);
317
+ },
318
+ configurable: true,
319
+ enumerable: false
320
+ });
321
+ defineHybridPropAlias(this, "maxlength", "length");
322
+ }
323
+ static get observedAttributes() {
324
+ return [
325
+ ...super.observedAttributes ?? [],
326
+ "modelvalue",
327
+ "helpertext",
328
+ "validationstate",
329
+ "validationmessage",
330
+ "errormessage",
331
+ "successmessage",
332
+ "arialabeltext",
333
+ "arialabel",
334
+ "maxlength",
335
+ "css-class",
336
+ "cssclass"
337
+ ];
338
+ }
339
+ attributeChangedCallback(name, oldValue, newValue) {
340
+ super.attributeChangedCallback(name, oldValue, newValue);
341
+ if (oldValue === newValue) return;
342
+ switch (name) {
343
+ case "css-class":
344
+ case "cssclass":
345
+ this.cssClassName = newValue ?? "";
346
+ return;
347
+ case "modelvalue":
348
+ this.modelValue = newValue ?? "";
349
+ return;
350
+ case "helpertext":
351
+ this.helperText = newValue ?? "";
352
+ return;
353
+ case "validationstate":
354
+ this.validationState = newValue ?? "default";
355
+ return;
356
+ case "validationmessage":
357
+ this.validationMessage = newValue ?? "";
358
+ return;
359
+ case "errormessage":
360
+ this.errorMessage = newValue ?? "";
361
+ return;
362
+ case "successmessage":
363
+ this.successMessage = newValue ?? "";
364
+ return;
365
+ case "arialabeltext":
366
+ case "arialabel":
367
+ this.ariaLabelText = newValue ?? void 0;
368
+ return;
369
+ case "maxlength":
370
+ if (newValue != null) this.length = newValue;
371
+ return;
372
+ }
373
+ }
374
+ get complete() {
375
+ return Array.from(this._code).length === this._length;
376
+ }
377
+ get _length() {
378
+ return resolveOtpLength(this.length);
379
+ }
380
+ get _filled() {
381
+ return Array.from(this._code).length;
382
+ }
383
+ willUpdate(changed) {
384
+ if (changed.has("value") && !changed.has("modelValue") && String(this.value ?? "") !== this._code) this.modelValue = String(this.value ?? "");
385
+ if (changed.has("modelValue") || changed.has("length") || changed.has("type")) {
386
+ this._code = normaliseOtpValue(this.modelValue, this._length, this.type);
387
+ if (this.value !== this._code) this.value = this._code;
388
+ }
389
+ super.willUpdate?.(changed);
390
+ }
391
+ firstUpdated(changed) {
392
+ super.firstUpdated?.(changed);
393
+ if (this.autofocus) this.focus();
394
+ }
395
+ _cellEl(i) {
396
+ return this.renderRoot?.querySelector?.(`[mono-otp-cell][data-index="${i}"]`) ?? null;
397
+ }
398
+ _indexOf(event) {
399
+ return Number(event.currentTarget.dataset.index ?? 0);
400
+ }
401
+ get _editable() {
402
+ return !this.disabled && !this.readonly;
403
+ }
404
+ _focusCell(i) {
405
+ const el = this._cellEl(i);
406
+ if (!el) return;
407
+ el.focus();
408
+ el.select?.();
409
+ }
410
+ _detail(oldValue, index, sourceEvent) {
411
+ return {
412
+ modelValue: this._code,
413
+ currentValue: this._code,
414
+ oldValue,
415
+ value: this._code,
416
+ complete: this.complete,
417
+ index,
418
+ name: this.name,
419
+ sourceEvent
420
+ };
421
+ }
422
+ /** Commit an edit: write the model, fire `input` (+ `complete`), then move the caret. */
423
+ _apply(edit, index, event) {
424
+ const old = this._code;
425
+ if (edit.value !== old) {
426
+ this._code = edit.value;
427
+ this.value = edit.value;
428
+ this.modelValue = edit.value;
429
+ dispatchMonoEvent(this, "input", this._detail(old, index, event));
430
+ if (this.complete) dispatchMonoEvent(this, "complete", this._detail(old, index));
431
+ }
432
+ this._focusCell(edit.caret);
433
+ this.updateComplete.then(() => {
434
+ const el = this._cellEl(edit.caret);
435
+ if (el && this._focusIndex === edit.caret) el.select?.();
436
+ });
437
+ }
438
+ clear() {
439
+ if (!this._code) return;
440
+ const old = this._code;
441
+ this._code = "";
442
+ this.value = "";
443
+ this.modelValue = "";
444
+ const detail = this._detail(old, -1);
445
+ dispatchMonoEvent(this, "input", detail);
446
+ dispatchMonoEvent(this, "change", detail);
447
+ dispatchMonoEvent(this, "clear", detail);
448
+ if (this._committed !== null) this._committed = "";
449
+ }
450
+ focus(index) {
451
+ const i = typeof index === "number" ? index : clampCaret(this._length, this._filled, this._length);
452
+ this._focusCell(clampCaret(i, this._filled, this._length));
453
+ }
454
+ blur() {
455
+ this._cellEl(this._focusIndex)?.blur();
456
+ }
457
+ get _resolvedValidationState() {
458
+ if (this.validationState && this.validationState !== "default") return this.validationState;
459
+ if (this.error || this.errorMessage) return "invalid";
460
+ if (this.success || this.successMessage) return "valid";
461
+ return "default";
462
+ }
463
+ get _validationNotice() {
464
+ if (this.validationMessage) return {
465
+ state: this._resolvedValidationState,
466
+ text: this.validationMessage
467
+ };
468
+ if (this.errorMessage) return {
469
+ state: "invalid",
470
+ text: this.errorMessage
471
+ };
472
+ if (this.successMessage) return {
473
+ state: "valid",
474
+ text: this.successMessage
475
+ };
476
+ return null;
477
+ }
478
+ _cls(base, key) {
479
+ return cssPart(this.cssClass, base, key);
480
+ }
481
+ get _hasLabel() {
482
+ return !!(this.label || this._hasLabelSlotState);
483
+ }
484
+ get _describedBy() {
485
+ return this.validationMessage || this.errorMessage || this.successMessage || this.helperText || this._hasHelperSlotState ? this._messageId : void 0;
486
+ }
487
+ get _inputMode() {
488
+ return this.inputmode || (this.type === "numeric" ? "numeric" : "text");
489
+ }
490
+ _placeholderAt(i) {
491
+ const chars = Array.from(this.placeholder ?? "");
492
+ if (!chars.length) return void 0;
493
+ return chars.length === this._length ? chars[i] : chars[0];
494
+ }
495
+ _cellLabel(i) {
496
+ const base = this.ariaLabelText || this.label;
497
+ const own = `${this.type === "numeric" ? "Digit" : "Character"} ${i + 1} of ${this._length}`;
498
+ return base ? `${base} – ${own}` : own;
499
+ }
500
+ /** Label text — light: placeholder for the captured slot; shadow overrides with `<slot>`. */
501
+ _renderLabelText() {
502
+ return this._hasLabelSlotState ? html`<span data-mono-slot="label"></span>` : this.label;
503
+ }
504
+ _renderLabel() {
505
+ if (!this._hasLabel) return nothing;
506
+ return html`
507
+ <label class=${this._cls("mono-otp-label", "label")} mono-label id=${`${this._otpId}-label`} for=${`${this._otpId}-0`}>
508
+ ${this._renderLabelText()}
509
+ ${this.required ? html`<span class=${this._cls("mono-otp-required", "required")} mono-required-mark>*</span>` : nothing}
510
+ ${this._tooltip.render()}
511
+ </label>
512
+ `;
513
+ }
514
+ _renderHelperText(base) {
515
+ if (!this.helperText && !this._hasHelperSlotState) return nothing;
516
+ return html`<div class=${`${base} helper`} mono-message="helper">${this._hasHelperSlotState ? html`<span data-mono-slot="helper"></span>` : this.helperText}</div>`;
517
+ }
518
+ _renderMessage() {
519
+ const base = this._cls("mono-otp-message", "message");
520
+ if (this._validation.moved) {
521
+ const notice = this._validationNotice;
522
+ return html`${this._renderHelperText(base)}<div
523
+ class=${`${base} ${notice.state}`}
524
+ mono-message=${notice.state}
525
+ mono-sr-only
526
+ role=${notice.state === "invalid" ? "alert" : nothing}
527
+ >${notice.text}</div>`;
528
+ }
529
+ if (this.validationMessage) {
530
+ const s = this._resolvedValidationState;
531
+ return html`<div class=${`${base} ${s}`} mono-message=${s} role=${s === "invalid" ? "alert" : nothing}>${this.validationMessage}</div>`;
532
+ }
533
+ if (this.errorMessage) return html`<div class=${`${base} invalid`} mono-message="invalid" role="alert">${this.errorMessage}</div>`;
534
+ if (this.successMessage) return html`<div class=${`${base} valid`} mono-message="valid">${this.successMessage}</div>`;
535
+ return this._renderHelperText(base);
536
+ }
537
+ /** Prefix / suffix inside the row — light: captured-slot placeholder; shadow overrides with `<slot>`. */
538
+ _renderAffix(name) {
539
+ if (!(name === "prefix" ? this._hasPrefixSlotState : this._hasSuffixSlotState)) return nothing;
540
+ return html`<span class=${this._cls(`mono-otp-${name}`, name)} mono-otp-affix=${name}><span data-mono-slot=${name}></span></span>`;
541
+ }
542
+ _renderCell(i, chars, invalid) {
543
+ return html`<input
544
+ id=${`${this._otpId}-${i}`}
545
+ class=${this._cls("mono-otp-cell", "cell")}
546
+ mono-otp-cell
547
+ data-index=${i}
548
+ type=${this.mask ? "password" : "text"}
549
+ .value=${live(chars[i] ?? "")}
550
+ inputmode=${this._inputMode}
551
+ pattern=${ifDefined(this.type === "numeric" ? "[0-9]*" : void 0)}
552
+ autocomplete=${i === 0 ? this.autocomplete || "one-time-code" : "off"}
553
+ autocapitalize=${this.type === "alphanumeric" ? "characters" : "off"}
554
+ autocorrect="off"
555
+ spellcheck="false"
556
+ placeholder=${ifDefined(this._placeholderAt(i))}
557
+ ?disabled=${this.disabled}
558
+ ?readonly=${this.readonly}
559
+ ?mono-filled=${i < chars.length}
560
+ ?mono-active=${i === this._focusIndex}
561
+ aria-label=${this._cellLabel(i)}
562
+ aria-invalid=${invalid ? "true" : "false"}
563
+ aria-describedby=${ifDefined(this._describedBy)}
564
+ @input=${this._onCellInput}
565
+ @change=${this._swallow}
566
+ @keydown=${this._onCellKeydown}
567
+ @paste=${this._onCellPaste}
568
+ @focus=${this._onCellFocus}
569
+ @click=${this._onCellClick}
570
+ />`;
571
+ }
572
+ _renderCells() {
573
+ const n = this._length;
574
+ const chars = Array.from(this._code);
575
+ const breaks = new Set(parseOtpGroups(this.groups, n));
576
+ const invalid = this._resolvedValidationState === "invalid";
577
+ const groups = [[]];
578
+ for (let i = 0; i < n; i++) {
579
+ if (breaks.has(i)) groups.push([]);
580
+ groups[groups.length - 1].push(i);
581
+ }
582
+ return html`${groups.map((group, g) => html`${g > 0 ? html`<span class=${this._cls("mono-otp-separator", "separator")} mono-otp-separator aria-hidden="true">${this.separator}</span>` : nothing}<div class=${this._cls("mono-otp-group", "group")} mono-otp-group>${group.map((i) => this._renderCell(i, chars, invalid))}</div>`)}`;
583
+ }
584
+ _renderClear() {
585
+ if (!(this.clearable && this._code && this._editable)) return nothing;
586
+ return html`<button type="button" class=${this._cls("mono-otp-clear", "clear")} mono-clear aria-label="Clear code" @click=${this._onClear}>
587
+ ${this.renderIcon("close")}
588
+ </button>`;
589
+ }
590
+ /** Icon hook — light: UnoCSS `i-mdi-*`; shadow: inline SVG. */
591
+ renderIcon(_name) {
592
+ return html``;
593
+ }
594
+ render() {
595
+ const state = this._resolvedValidationState;
596
+ const lp = this.labelPosition === "left" || this.labelPosition === "right" ? this.labelPosition : nothing;
597
+ return html`<div
598
+ class=${[
599
+ "mono-otp",
600
+ this.size,
601
+ this.color,
602
+ this.variant,
603
+ this.disabled ? "disabled" : "",
604
+ this.cssClassName,
605
+ this.cssClass?.root
606
+ ].filter(Boolean).join(" ")}
607
+ style=${styleMap(buildSizeStyle(this))}
608
+ mono-otp
609
+ mono-size=${this.size === "md" ? nothing : this.size}
610
+ mono-color=${this.color === "primary" ? nothing : this.color}
611
+ mono-variant=${this.variant === "outlined" ? nothing : this.variant}
612
+ mono-label-position=${lp}
613
+ mono-validation-position=${this.validationPosition === "bottom" ? nothing : this.validationPosition}
614
+ mono-validation-state=${state === "default" ? nothing : state}
615
+ mono-type=${this.type === "numeric" ? nothing : this.type}
616
+ ?mono-mask=${this.mask}
617
+ ?mono-complete=${this.complete}
618
+ ?mono-disabled=${this.disabled}
619
+ ?mono-readonly=${this.readonly}
620
+ ?mono-required=${this.required}
621
+ ?mono-clearable=${this.clearable}
622
+ >
623
+ ${this._renderLabel()}
624
+ <div
625
+ class=${this._cls("mono-otp-field", "field")}
626
+ mono-field
627
+ role="group"
628
+ aria-labelledby=${ifDefined(!this.ariaLabelText && this._hasLabel ? `${this._otpId}-label` : void 0)}
629
+ aria-label=${ifDefined(this.ariaLabelText || (!this._hasLabel ? "One-time code" : void 0))}
630
+ aria-required=${ifDefined(this.required ? "true" : void 0)}
631
+ @focusin=${this._onFieldFocusIn}
632
+ @focusout=${this._onFieldFocusOut}
633
+ >
634
+ ${this._renderAffix("prefix")}
635
+ ${this._renderCells()}
636
+ ${this._validation.renderIcon()}
637
+ ${this._renderClear()}
638
+ ${this._renderAffix("suffix")}
639
+ </div>
640
+ ${this.name ? html`<input type="hidden" mono-otp-hidden name=${this.name} .value=${this._code} ?disabled=${this.disabled} />` : nothing}
641
+ <div id=${this._messageId} class=${this.cssClass?.messageWrap ?? ""} mono-message-wrap>${this._renderMessage()}</div>
642
+ ${this._validation.renderFloat()}
643
+ </div>`;
644
+ }
645
+ }
646
+ __decorate([property({ attribute: false })], MonoOtpCoreClass.prototype, "cssClass", void 0);
647
+ __decorate([property({
648
+ type: String,
649
+ attribute: "css-class"
650
+ })], MonoOtpCoreClass.prototype, "cssClassName", void 0);
651
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "type", void 0);
652
+ __decorate([property()], MonoOtpCoreClass.prototype, "length", void 0);
653
+ __decorate([property()], MonoOtpCoreClass.prototype, "groups", void 0);
654
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "separator", void 0);
655
+ __decorate([property({
656
+ reflect: true,
657
+ converter: booleanStringConverter
658
+ })], MonoOtpCoreClass.prototype, "mask", void 0);
659
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "size", void 0);
660
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "color", void 0);
661
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "variant", void 0);
662
+ __decorate([property({
663
+ type: String,
664
+ attribute: "label-position"
665
+ })], MonoOtpCoreClass.prototype, "labelPosition", void 0);
666
+ __decorate([property({
667
+ type: String,
668
+ attribute: "validation-position"
669
+ })], MonoOtpCoreClass.prototype, "validationPosition", void 0);
670
+ __decorate([property({ attribute: "model-value" })], MonoOtpCoreClass.prototype, "modelValue", void 0);
671
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "value", void 0);
672
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "name", void 0);
673
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "placeholder", void 0);
674
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "label", void 0);
675
+ __decorate([property({
676
+ type: String,
677
+ attribute: "helper-text"
678
+ })], MonoOtpCoreClass.prototype, "helperText", void 0);
679
+ __decorate([property()], MonoOtpCoreClass.prototype, "tooltip", void 0);
680
+ __decorate([property({
681
+ type: String,
682
+ attribute: "validation-state"
683
+ })], MonoOtpCoreClass.prototype, "validationState", void 0);
684
+ __decorate([property({
685
+ type: String,
686
+ attribute: "validation-message"
687
+ })], MonoOtpCoreClass.prototype, "validationMessage", void 0);
688
+ __decorate([property({
689
+ reflect: true,
690
+ converter: booleanStringConverter
691
+ })], MonoOtpCoreClass.prototype, "error", void 0);
692
+ __decorate([property({
693
+ type: String,
694
+ attribute: "error-message"
695
+ })], MonoOtpCoreClass.prototype, "errorMessage", void 0);
696
+ __decorate([property({
697
+ reflect: true,
698
+ converter: booleanStringConverter
699
+ })], MonoOtpCoreClass.prototype, "success", void 0);
700
+ __decorate([property({
701
+ type: String,
702
+ attribute: "success-message"
703
+ })], MonoOtpCoreClass.prototype, "successMessage", void 0);
704
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "autocomplete", void 0);
705
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "inputmode", void 0);
706
+ __decorate([property({
707
+ type: String,
708
+ attribute: "aria-label"
709
+ })], MonoOtpCoreClass.prototype, "ariaLabelText", void 0);
710
+ __decorate([property({
711
+ reflect: true,
712
+ converter: booleanStringConverter
713
+ })], MonoOtpCoreClass.prototype, "disabled", void 0);
714
+ __decorate([property({
715
+ reflect: true,
716
+ converter: booleanStringConverter
717
+ })], MonoOtpCoreClass.prototype, "readonly", void 0);
718
+ __decorate([property({
719
+ reflect: true,
720
+ converter: booleanStringConverter
721
+ })], MonoOtpCoreClass.prototype, "required", void 0);
722
+ __decorate([property({
723
+ reflect: true,
724
+ converter: booleanStringConverter
725
+ })], MonoOtpCoreClass.prototype, "clearable", void 0);
726
+ __decorate([property({
727
+ reflect: true,
728
+ converter: booleanStringConverter
729
+ })], MonoOtpCoreClass.prototype, "autofocus", void 0);
730
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "width", void 0);
731
+ __decorate([property({ type: String })], MonoOtpCoreClass.prototype, "height", void 0);
732
+ __decorate([property({
733
+ type: String,
734
+ attribute: "min-width"
735
+ })], MonoOtpCoreClass.prototype, "minWidth", void 0);
736
+ __decorate([property({
737
+ type: String,
738
+ attribute: "max-width"
739
+ })], MonoOtpCoreClass.prototype, "maxWidth", void 0);
740
+ __decorate([property({
741
+ type: String,
742
+ attribute: "min-height"
743
+ })], MonoOtpCoreClass.prototype, "minHeight", void 0);
744
+ __decorate([property({
745
+ type: String,
746
+ attribute: "max-height"
747
+ })], MonoOtpCoreClass.prototype, "maxHeight", void 0);
748
+ __decorate([state()], MonoOtpCoreClass.prototype, "_code", void 0);
749
+ __decorate([state()], MonoOtpCoreClass.prototype, "_focusIndex", void 0);
750
+ __decorate([state()], MonoOtpCoreClass.prototype, "_hasPrefixSlotState", void 0);
751
+ __decorate([state()], MonoOtpCoreClass.prototype, "_hasSuffixSlotState", void 0);
752
+ __decorate([state()], MonoOtpCoreClass.prototype, "_hasLabelSlotState", void 0);
753
+ __decorate([state()], MonoOtpCoreClass.prototype, "_hasHelperSlotState", void 0);
754
+ return MonoOtpCoreClass;
755
+ };
756
+
757
+ //#endregion
758
+ export { normaliseOtpValue as a, resolveOtpLength as c, spliceOtpValue as d, clampCaret as i, sanitizeOtpChar as l, OTP_DEFAULT_LENGTH as n, parseOtpGroups as o, backspaceOtp as r, removeOtpChar as s, MonoOtpCore as t, sanitizeOtpText as u };