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