@mono-lit/helper 0.0.3 → 0.0.5
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.
- package/dist/control-tooltip-7vegYmq3.js +678 -0
- package/dist/{tooltip-FCMRUSLi.js → control-tooltip-C3rA_nSH.js} +12 -119
- package/dist/{data-source-controller-Cf_sMxEh.js → data-source-controller-C6C4ej_M.js} +1 -1
- package/dist/{data-source-options-Bk-UoaZV.js → data-source-options-Cz9fVLK8.js} +3 -2
- package/dist/{data-source-read-Cuqw3LcP.js → data-source-read-i6CYSUEl.js} +2 -1
- package/dist/{excel-DtRpxmxs.js → excel-BPdDt06G.js} +1 -1
- package/dist/{export-B91P6J1y.js → export-DgomqI_3.js} +2 -2
- package/dist/export.js +2 -2
- package/dist/{field-icons-FmyBWa0g.js → field-icons-t8rXRCKs.js} +50 -1
- package/dist/field-tooltip-FyMi9vNM.js +266 -0
- package/dist/field-tooltip.css_raw-DEctHXKm.js +270 -0
- package/dist/field-validation-CHHQi1zl.js +170 -0
- package/dist/field-validation.css_raw-B3Iu33rS.js +178 -0
- package/dist/index.js +4 -3
- package/dist/{index.node-dvrNviMx.js → index.node-DzCuvHLg.js} +1 -1
- package/dist/index.node.js +4 -3
- package/dist/input-format-GrRCJBqV.js +251 -0
- package/dist/input.css_raw-CQu2fAsU.js +5 -0
- package/dist/{mono-data-grid-BHlo1IgR.js → mono-data-grid-KDpu4d4_.js} +5 -4
- package/dist/{mono-form-controller-IYn0MuUQ.js → mono-form-controller-BkMR8g14.js} +18 -3
- package/dist/{reactive-DFCdZbH9.js → normalize-error-BmLbgANw.js} +1 -48
- package/dist/nuxt.js +36 -8
- package/dist/{popup-portal-HWhkd7oy.js → popup-portal-C8ttHDRX.js} +17 -1
- package/dist/{popup-stack-De05Y-mJ.js → popup-stack-C64WCuXq.js} +21 -1
- package/dist/src/components/accordion/accordion-core.d.ts +4 -1
- package/dist/src/components/accordion/mono-accordion.shadow.d.ts +4 -1
- package/dist/src/components/date/date-core.d.ts +3 -0
- package/dist/src/components/date/date-types.d.ts +36 -1
- package/dist/src/components/drawer/drawer-core.d.ts +1 -0
- package/dist/src/components/dropdown-table/dropdown-table-core.d.ts +3 -0
- package/dist/src/components/dropdown-table/dropdown-table-types.d.ts +31 -0
- package/dist/src/components/form/form-types.d.ts +23 -5
- package/dist/src/components/input/index.d.ts +2 -2
- package/dist/src/components/input/index.shadow.d.ts +2 -2
- package/dist/src/components/input/input-core.d.ts +23 -3
- package/dist/src/components/input/input-types.d.ts +84 -9
- package/dist/src/components/input/mono-input.d.ts +3 -2
- package/dist/src/components/input/mono-input.shadow.d.ts +3 -2
- package/dist/src/components/modal/modal-core.d.ts +1 -0
- package/dist/src/components/otp/index.d.ts +5 -0
- package/dist/src/components/otp/index.shadow.d.ts +6 -0
- package/dist/src/components/otp/mono-otp.d.ts +32 -0
- package/dist/src/components/otp/mono-otp.shadow.d.ts +30 -0
- package/dist/src/components/otp/otp-core.d.ts +91 -0
- package/dist/src/components/otp/otp-types.d.ts +161 -0
- package/dist/src/components/otp/otp-utils.d.ts +41 -0
- package/dist/src/components/select/select-core.d.ts +3 -0
- package/dist/src/components/select/select-types.d.ts +31 -0
- package/dist/src/components/slider/index.d.ts +5 -0
- package/dist/src/components/slider/index.shadow.d.ts +6 -0
- package/dist/src/components/slider/mono-slider.d.ts +33 -0
- package/dist/src/components/slider/mono-slider.shadow.d.ts +29 -0
- package/dist/src/components/slider/slider-core.d.ts +77 -0
- package/dist/src/components/slider/slider-math.d.ts +102 -0
- package/dist/src/components/slider/slider-types.d.ts +188 -0
- package/dist/src/components/tag-input/tag-input-core.d.ts +3 -0
- package/dist/src/components/tag-input/tag-input-types.d.ts +31 -0
- package/dist/src/components/textarea/textarea-core.d.ts +3 -0
- package/dist/src/components/textarea/textarea-types.d.ts +31 -0
- package/dist/src/composables/field-bubble.d.ts +34 -0
- package/dist/src/composables/field-icons.d.ts +10 -0
- package/dist/src/composables/field-tooltip.d.ts +52 -0
- package/dist/src/composables/field-validation.d.ts +58 -0
- package/dist/src/composables/popup-portal.d.ts +12 -0
- package/dist/src/composables/popup-stack.d.ts +21 -0
- package/dist/src/entries/index.d.ts +1 -1
- package/dist/src/entries/index.node.d.ts +1 -1
- package/dist/src/nuxt/index.d.ts +2 -2
- package/dist/src/nuxt/ssr-lit/index.d.ts +4 -0
- package/dist/ssr-lit/runtime/components/LitWrapper.vue +11 -0
- package/dist/ssr-lit/runtime/components/LitWrapperClient.vue +11 -0
- package/dist/ssr-lit/runtime/components/LitWrapperServer.vue +38 -0
- package/dist/ssr-lit/runtime/plugins/antiFouc.server.js +25 -0
- package/dist/ssr-lit/runtime/plugins/hydrateSupport.client.js +4 -0
- package/dist/ssr-lit/runtime/plugins/polyfill.client.js +9 -0
- package/dist/ssr-lit/runtime/utils/customElements.js +11 -0
- package/dist/ssr-lit/runtime/utils/litElementRenderer.js +28 -0
- package/dist/{styles-D-ergrfR.js → styles-BODNpZV1.js} +1 -1
- package/dist/tooltip-Drekihf5.js +102 -0
- package/dist/tooltip-loader-3U9FTOXj.js +20 -0
- package/dist/tooltip-loader-Dcp9AUZn.js +23 -0
- package/dist/tooltip.js +3 -1
- package/dist/ui/accordion.js +16 -3
- package/dist/ui/alert.js +2 -2
- package/dist/ui/breadcrumb.js +1 -1
- package/dist/ui/button-dropdown.js +1 -1
- package/dist/ui/chart.js +1 -1
- package/dist/ui/date.js +66 -5
- package/dist/ui/drawer.js +11 -2
- package/dist/ui/dropdown-table.js +60 -5
- package/dist/ui/dropdown.js +3 -2
- package/dist/ui/file-upload.js +1 -1
- package/dist/ui/form.js +1 -1
- package/dist/ui/index.css +8857 -3974
- package/dist/ui/input.js +362 -260
- package/dist/ui/menu.js +1 -1
- package/dist/ui/modal.js +11 -2
- package/dist/ui/otp.js +835 -0
- package/dist/ui/select.js +67 -3
- package/dist/ui/shadow/accordion.js +31 -4
- package/dist/ui/shadow/alert.js +1 -1
- package/dist/ui/shadow/button-dropdown.js +1 -1
- package/dist/ui/shadow/chart.js +4 -4
- package/dist/ui/shadow/date.js +67 -6
- package/dist/ui/shadow/drawer.js +11 -2
- package/dist/ui/shadow/dropdown-table.js +62 -7
- package/dist/ui/shadow/dropdown.js +3 -2
- package/dist/ui/shadow/input.js +367 -261
- package/dist/ui/shadow/modal.js +11 -2
- package/dist/ui/shadow/otp.js +842 -0
- package/dist/ui/shadow/select.js +71 -6
- package/dist/ui/shadow/sidebar.js +2 -2
- package/dist/ui/shadow/slider.js +1082 -0
- package/dist/ui/shadow/table.js +6 -6
- package/dist/ui/shadow/tag-input.js +72 -7
- package/dist/ui/shadow/textarea.js +63 -2
- package/dist/ui/sidebar.js +2 -2
- package/dist/ui/slider.js +1079 -0
- package/dist/ui/table.js +2 -2
- package/dist/ui/tag-input.js +67 -3
- package/dist/ui/textarea.js +62 -1
- package/dist/ui/theme/luma.css +505 -466
- package/dist/ui/theme/lyra.css +505 -466
- package/dist/ui/theme/maia.css +501 -466
- package/dist/ui/theme/mira.css +505 -466
- package/dist/ui/theme/nova.css +503 -466
- package/dist/ui/theme/one.css +742 -699
- package/dist/ui/theme/rhea.css +506 -466
- package/dist/ui/theme/sera.css +507 -466
- package/dist/ui/theme/vega.css +495 -466
- package/dist/{vite-DcyRlTTf.js → vite-CivRCJaf.js} +2 -0
- package/dist/vite.js +1 -1
- package/dist/vue.d.ts +10 -0
- package/package.json +30 -15
- package/dist/input.css_raw-CGESifay.js +0 -5
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
import { 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-DHrl4_KK.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 buildSizeStyle } from "../../css-size-DWAPgQdT.js";
|
|
5
|
+
import { t as MonoFormControlCore } from "../../form-control-core-CIdMLXMo.js";
|
|
6
|
+
import { n as FieldTooltipController, t as field_tooltip_css_raw_default } from "../../field-tooltip.css_raw-DEctHXKm.js";
|
|
7
|
+
import { n as label_position_css_raw_default, r as FieldValidationController, t as field_validation_css_raw_default } from "../../field-validation.css_raw-B3Iu33rS.js";
|
|
8
|
+
import { LitElement, html, isServer, nothing, unsafeCSS } 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
|
+
//#region \0raw:C:\Users\VCT-DEV\Desktop\libs\packages\helper\src\components\otp\otp.css?raw.js
|
|
759
|
+
var otp_css_raw_default = "/* =========================================================================\n mono-otp — a one-time-code field: N single-character boxes that act as one\n input. Same look as mono-input (Basecoat `.input-group`, vega) applied to\n EACH box, and the same attribute contract:\n\n <mono-otp length=\"6\" groups=\"3\" size=\"sm\" color=\"success\" label=\"Code\">\n <div mono-otp mono-size=\"sm\" mono-color=\"success\">\n <label mono-label>Code</label>\n <div mono-field>\n <div mono-otp-group><input mono-otp-cell>…</div>\n <span mono-otp-separator>-</span>\n <div mono-otp-group><input mono-otp-cell>…</div>\n </div>\n <div mono-message-wrap><div mono-message=\"helper\">…</div></div>\n </div>\n\n An absent attribute is the prop's default (md / primary / outlined /\n default state). Parts:\n [mono-field] the ROW (no border — every box is its own field)\n [mono-otp-group] one run of boxes\n [mono-otp-cell] a box (a native <input>); [mono-filled] holds a char,\n [mono-active] has focus (the element sets both;\n hand-written markup gets :focus / :placeholder-shown)\n [mono-otp-separator] the text between groups\n [mono-otp-affix] prefix / suffix (=\"prefix\" | \"suffix\")\n [mono-clear] the clear button\n\n Knobs — every one falls back to the matching mono-input knob, so a theme\n flavor that restyles the input restyles the code field too:\n --mono-otp-cell-size-<size> / --mono-otp-cell-width box height / width\n --mono-otp-font-<size>, --mono-otp-font-weight character type\n --mono-otp-gap, --mono-otp-group-gap spacing\n --mono-otp-radius, --mono-otp-bg, --mono-otp-border-color, --mono-otp-shadow\n --mono-otp-ring-color, --mono-otp-ring-width, --mono-otp-ring-alpha\n --mono-otp-filled-bg, --mono-otp-separator-color, --mono-otp-placeholder\n --mono-otp-<color> (primary … dark, valid, invalid)\n --mono-otp-label-width / -label-side-gap label-position left/right\n\n Specificity contract as input.css: a part's resting rule is\n `:where([mono-otp]) [mono-part]` (0,1,0) so `cssClass` utilities win;\n state rules stay heavier.\n ========================================================================= */\n\nmono-otp {\n display: block;\n}\n\n[mono-otp] {\n /* ── palette ── */\n --_mono-otp-text: var(--mono-otp-color, var(--mono-input-color, var(--mono-input-text, var(--foreground))));\n --_mono-otp-placeholder: var(--mono-otp-placeholder, var(--mono-input-placeholder, var(--muted-foreground)));\n --_mono-otp-muted: var(--mono-otp-muted, var(--mono-input-muted, var(--muted-foreground)));\n --_mono-otp-primary: var(--mono-otp-primary, var(--mono-input-primary, var(--ring)));\n --_mono-otp-secondary: var(--mono-otp-secondary, var(--mono-input-secondary, var(--muted-foreground)));\n --_mono-otp-success: var(--mono-otp-success, var(--mono-input-success, var(--success)));\n --_mono-otp-danger: var(--mono-otp-danger, var(--mono-input-danger, var(--destructive)));\n --_mono-otp-warning: var(--mono-otp-warning, var(--mono-input-warning, var(--warning)));\n --_mono-otp-info: var(--mono-otp-info, var(--mono-input-info, var(--info)));\n --_mono-otp-teal: var(--mono-otp-teal, var(--mono-input-teal, var(--teal)));\n --_mono-otp-purple: var(--mono-otp-purple, var(--mono-input-purple, var(--purple)));\n --_mono-otp-neutral: var(--mono-otp-neutral, var(--mono-input-neutral, var(--neutral)));\n --_mono-otp-dark: var(--mono-otp-dark, var(--mono-input-dark, var(--dark)));\n --_mono-otp-valid: var(--mono-otp-valid, var(--mono-input-valid, var(--success)));\n --_mono-otp-invalid: var(--mono-otp-invalid, var(--mono-input-invalid, var(--destructive)));\n\n /* ── the painted box — public knob → variant preset → input knob → token ── */\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))));\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))));\n --_mono-otp-ring-alpha: var(--mono-otp-ring-alpha, var(--mono-input-ring-alpha, var(--mono-ring-alpha)));\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)))));\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)))));\n --_mono-otp-shadow: var(--mono-otp-shadow, var(--_mono-otp-shadow-preset, 0 0 #0000));\n --_mono-otp-radius: var(--mono-otp-radius, var(--_mono-otp-radius-preset, var(--mono-input-radius, var(--mono-radius-md))));\n\n /* ── md metrics on the unqualified root (hand-written markup = md) ── */\n --_mono-otp-size: var(--mono-otp-cell-size-md, var(--mono-input-height-md, var(--mono-control-height-md)));\n --_mono-otp-font-size: var(--mono-otp-font-md, var(--mono-text-base));\n --_mono-otp-clear: calc(var(--mono-spacing) * 6);\n --_mono-otp-clear-glyph: calc(var(--mono-spacing) * 3.5);\n\n display: flex;\n flex-direction: column;\n gap: var(--mono-otp-label-gap, var(--mono-input-gap, calc(var(--mono-spacing) * 3)));\n width: 100%;\n font-family: inherit;\n color: var(--_mono-otp-text);\n}\n\n[mono-otp],\n:where([mono-otp]) *,\n:where([mono-otp]) *::before,\n:where([mono-otp]) *::after {\n box-sizing: border-box;\n}\n\n/* shadow build: unassigned slot wrappers carry `mono-empty` */\n:where([mono-otp]) :is([mono-label], [mono-otp-affix], [mono-message])[mono-empty] {\n display: none;\n}\n\n/* =========================================\n Sizes — box height IS the control token\n ========================================= */\n\n[mono-otp][mono-size=\"xs\"] {\n --_mono-otp-size: var(--mono-otp-cell-size-xs, var(--mono-input-height-xs, var(--mono-control-height-xs)));\n --_mono-otp-font-size: var(--mono-otp-font-xs, var(--mono-text-xs));\n --_mono-otp-clear: calc(var(--mono-spacing) * 4);\n --_mono-otp-clear-glyph: calc(var(--mono-spacing) * 3);\n}\n[mono-otp][mono-size=\"sm\"] {\n --_mono-otp-size: var(--mono-otp-cell-size-sm, var(--mono-input-height-sm, var(--mono-control-height-sm)));\n --_mono-otp-font-size: var(--mono-otp-font-sm, var(--mono-text-sm));\n --_mono-otp-clear: calc(var(--mono-spacing) * 5);\n}\n[mono-otp][mono-size=\"lg\"] {\n --_mono-otp-size: var(--mono-otp-cell-size-lg, var(--mono-input-height-lg, var(--mono-control-height-lg)));\n --_mono-otp-font-size: var(--mono-otp-font-lg, var(--mono-text-lg));\n}\n[mono-otp][mono-size=\"xl\"] {\n --_mono-otp-size: var(--mono-otp-cell-size-xl, var(--mono-input-height-xl, var(--mono-control-height-xl)));\n --_mono-otp-font-size: var(--mono-otp-font-xl, var(--mono-text-xl));\n --_mono-otp-clear: calc(var(--mono-spacing) * 7);\n --_mono-otp-clear-glyph: calc(var(--mono-spacing) * 4);\n}\n[mono-otp][mono-size=\"xxl\"] {\n --_mono-otp-size: var(--mono-otp-cell-size-xxl, var(--mono-input-height-xxl, var(--mono-control-height-xxl)));\n --_mono-otp-font-size: var(--mono-otp-font-xxl, calc(var(--mono-text-xl) * 1.25));\n --_mono-otp-clear: calc(var(--mono-spacing) * 8);\n --_mono-otp-clear-glyph: calc(var(--mono-spacing) * 4);\n}\n\n/* =========================================\n Variants — write `*-preset` slots only (same as input.css)\n ========================================= */\n\n[mono-otp]:is(:not([mono-variant]), [mono-variant=\"outlined\"]) {\n --_mono-otp-bg-preset: var(--mono-input-outline-bg);\n --_mono-otp-border-color-preset: var(--mono-input-outline-border-color);\n --_mono-otp-side-border-color-preset: var(--mono-input-outline-side-border-color);\n --_mono-otp-shadow-preset: var(--mono-input-outline-shadow, var(--mono-shadow-xs));\n --_mono-otp-ring-width-preset: var(--mono-input-outline-ring-width);\n --_mono-otp-radius-preset: var(--mono-input-outline-radius);\n}\n\n[mono-otp][mono-variant=\"filled\"] {\n --_mono-otp-bg-preset: var(--mono-otp-filled-bg, var(--mono-input-filled-bg, color-mix(in oklab, var(--input) 50%, transparent)));\n --_mono-otp-border-color-preset: transparent;\n --_mono-otp-shadow-preset: 0 0 #0000;\n}\n\n[mono-otp][mono-variant=\"underlined\"] {\n --_mono-otp-bg-preset: transparent;\n --_mono-otp-side-border-color-preset: transparent;\n --_mono-otp-shadow-preset: 0 0 #0000;\n --_mono-otp-ring-width-preset: 0px;\n --_mono-otp-radius-preset: 0;\n}\n\n/* =========================================\n Colours — the focus colour\n ========================================= */\n\n[mono-otp]:is(:not([mono-color]), [mono-color=\"primary\"]) { --_mono-otp-ring-color-preset: var(--_mono-otp-primary); }\n[mono-otp][mono-color=\"secondary\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-secondary); }\n[mono-otp][mono-color=\"success\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-success); }\n[mono-otp][mono-color=\"danger\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-danger); }\n[mono-otp][mono-color=\"warning\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-warning); }\n[mono-otp][mono-color=\"info\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-info); }\n[mono-otp][mono-color=\"teal\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-teal); }\n[mono-otp][mono-color=\"purple\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-purple); }\n[mono-otp][mono-color=\"neutral\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-neutral); }\n[mono-otp][mono-color=\"dark\"] { --_mono-otp-ring-color-preset: var(--_mono-otp-dark); }\n\n/* =========================================\n Label (same rules as input's)\n ========================================= */\n\n:where([mono-otp]) > [mono-label] {\n display: flex;\n align-items: center;\n width: fit-content;\n gap: var(--mono-otp-label-gap, var(--mono-input-label-gap, calc(var(--mono-spacing) * 2)));\n font-size: var(--mono-otp-label-font-size, var(--mono-input-label-font-size, var(--mono-text-sm)));\n line-height: var(--mono-otp-label-line-height, var(--mono-input-label-line-height, 1));\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))));\n text-transform: var(--mono-otp-label-text-transform, var(--mono-input-label-text-transform, none));\n letter-spacing: var(--mono-otp-label-letter-spacing, var(--mono-input-label-letter-spacing, normal));\n color: var(--_mono-otp-text);\n user-select: none;\n}\n\n[mono-otp][mono-disabled] > [mono-label] {\n opacity: 0.5;\n pointer-events: none;\n}\n\n[mono-otp][mono-validation-state=\"invalid\"] > [mono-label] {\n color: var(--_mono-otp-invalid);\n}\n\n:where([mono-otp]) [mono-required-mark] {\n color: var(--_mono-otp-danger);\n}\n\n:where([mono-otp]) > [mono-label] > [mono-label-tooltip] {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n font-size: var(--mono-otp-label-tooltip-size, var(--mono-input-label-tooltip-size, 1.1em));\n color: var(--mono-otp-label-tooltip-color, var(--mono-input-label-tooltip-color, currentColor));\n opacity: var(--mono-otp-label-tooltip-opacity, var(--mono-input-label-tooltip-opacity, 0.6));\n border-radius: 9999px;\n cursor: help;\n pointer-events: auto;\n outline: none;\n transition: opacity 150ms ease;\n}\n:where([mono-otp]) > [mono-label] > [mono-label-tooltip]:is(:hover, :focus-visible) {\n opacity: 1;\n}\n:where([mono-otp]) > [mono-label] > [mono-label-tooltip]:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 2px;\n}\n:where([mono-otp]) > [mono-label] > [mono-label-tooltip] > [mono-icon] {\n width: 1em;\n height: 1em;\n}\n\n/* =========================================\n The row, groups and separators\n ========================================= */\n\n:where([mono-otp]) > [mono-field] {\n position: relative;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--mono-otp-group-gap, calc(var(--mono-spacing) * 2));\n min-width: 0;\n}\n\n:where([mono-otp]) [mono-otp-group] {\n display: flex;\n align-items: center;\n gap: var(--mono-otp-gap, calc(var(--mono-spacing) * 2));\n}\n\n:where([mono-otp]) [mono-otp-separator] {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: var(--_mono-otp-font-size);\n line-height: 1;\n color: var(--mono-otp-separator-color, var(--_mono-otp-muted));\n user-select: none;\n}\n\n/* =========================================\n The box — input.css's [mono-field], per character\n ========================================= */\n\n:where([mono-otp]) [mono-otp-cell] {\n --_mono-otp-bc: var(--_mono-otp-border-color);\n --_mono-otp-side-bc: var(--mono-otp-side-border-color, var(--_mono-otp-side-border-color-preset, var(--_mono-otp-bc)));\n --_mono-otp-ring: 0 0 #0000;\n\n display: block;\n flex: none;\n width: var(--mono-otp-cell-width, var(--_mono-otp-size));\n height: var(--_mono-otp-size);\n min-width: 0;\n margin: 0;\n padding: 0;\n appearance: none;\n outline: none;\n border: var(--mono-border-width) solid var(--_mono-otp-bc);\n border-top-color: var(--_mono-otp-side-bc);\n border-inline-color: var(--_mono-otp-side-bc);\n border-radius: var(--_mono-otp-radius);\n background: var(--_mono-otp-bg);\n box-shadow: var(--_mono-otp-ring), var(--_mono-otp-shadow);\n color: var(--_mono-otp-text);\n caret-color: var(--_mono-otp-ring-color);\n font-family: inherit;\n font-size: var(--_mono-otp-font-size);\n font-weight: var(--mono-otp-font-weight, var(--mono-font-weight-semibold));\n font-variant-numeric: tabular-nums;\n line-height: 1;\n text-align: center;\n transition-property: color, box-shadow, border-color, background-color;\n transition-timing-function: var(--mono-ease);\n transition-duration: var(--mono-duration);\n\n &::placeholder {\n color: var(--_mono-otp-placeholder);\n font-weight: var(--mono-font-weight-normal);\n }\n\n /* The box is selected on focus so a keystroke replaces it; the ring already\n marks the active box, so the selection highlight would only be noise. */\n &::selection {\n background: transparent;\n color: inherit;\n }\n\n &:focus,\n &:focus-visible {\n outline: none !important;\n }\n\n /* focus:border-ring focus:ring-3 focus:ring-ring/50 — the box with the caret */\n &:focus,\n &[mono-active] {\n --_mono-otp-bc: var(--_mono-otp-ring-color);\n --_mono-otp-side-bc: var(--mono-otp-side-border-color, var(--_mono-otp-side-border-color-preset, var(--_mono-otp-ring-color)));\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);\n }\n\n &:disabled {\n cursor: not-allowed;\n }\n\n &:read-only {\n cursor: default;\n }\n}\n\n/* ── validation states (same tokens as input's box) ── */\n[mono-otp][mono-validation-state=\"invalid\"] [mono-otp-cell],\n:where([mono-otp]) [mono-otp-cell][aria-invalid=\"true\"] {\n --_mono-otp-bc: var(--mono-mode-invalid-border);\n --_mono-otp-ring: 0 0 0 var(--_mono-otp-ring-width) var(--mono-mode-invalid-ring);\n}\n[mono-otp][mono-validation-state=\"valid\"] [mono-otp-cell] {\n --_mono-otp-bc: color-mix(in oklab, var(--_mono-otp-valid) var(--mono-mode-state-border-alpha), transparent);\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);\n}\n[mono-otp][mono-validation-state=\"warning\"] [mono-otp-cell] {\n --_mono-otp-bc: color-mix(in oklab, var(--_mono-otp-warning) var(--mono-mode-state-border-alpha), transparent);\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);\n}\n\n/* ── readonly / disabled ── */\n[mono-otp][mono-readonly] [mono-otp-cell] {\n background: var(--mono-otp-readonly-bg, var(--mono-input-readonly-bg, var(--muted)));\n}\n\n[mono-otp][mono-disabled] > [mono-field],\n:where([mono-otp]) > [mono-field]:has([mono-otp-cell]:disabled) {\n opacity: 0.5;\n cursor: not-allowed;\n}\n[mono-otp][mono-disabled] [mono-otp-cell] {\n background: var(--mono-otp-disabled-bg, var(--mono-input-disabled-bg, var(--_mono-otp-bg)));\n}\n\n/* =========================================\n Prefix / suffix / clear\n ========================================= */\n\n:where([mono-otp]) [mono-otp-affix] {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n gap: calc(var(--mono-spacing) * 2);\n font-size: var(--mono-text-sm);\n font-weight: var(--mono-font-weight-medium);\n color: var(--_mono-otp-muted);\n user-select: none;\n}\n\n:where([mono-otp]) [mono-otp-affix] > [data-mono-slot] {\n display: inline-flex;\n align-items: center;\n gap: inherit;\n}\n\n:where([mono-otp]) [mono-otp-affix] :is(svg, .mono-icon, [mono-icon]),\n:where([mono-otp]) [mono-otp-affix] ::slotted(svg),\n:where([mono-otp]) [mono-otp-affix] ::slotted(.mono-icon),\n:where([mono-otp]) [mono-otp-affix] ::slotted([mono-icon]) {\n display: block;\n width: var(--mono-input-affix-icon-size, calc(var(--mono-spacing) * 4));\n height: var(--mono-input-affix-icon-size, calc(var(--mono-spacing) * 4));\n flex-shrink: 0;\n pointer-events: none;\n}\n\n:where([mono-otp]) [mono-clear] {\n flex: 0 0 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--_mono-otp-clear);\n height: var(--_mono-otp-clear);\n padding: 0;\n margin: 0;\n border: 0;\n border-radius: var(--mono-otp-clear-radius, var(--mono-input-clear-radius, calc(var(--radius) - 5px)));\n background: transparent;\n box-shadow: none;\n color: var(--_mono-otp-muted);\n font: inherit;\n line-height: 1;\n cursor: pointer;\n outline-style: none;\n transition-property: color, background-color, box-shadow;\n transition-timing-function: var(--mono-ease);\n transition-duration: var(--mono-duration);\n\n &:focus-visible {\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);\n }\n}\n\n@media (hover: hover) {\n :where([mono-otp]) [mono-clear]:hover {\n background: var(--mono-mode-ghost-hover);\n color: var(--_mono-otp-text);\n }\n}\n\n:where([mono-otp]) [mono-clear] > :is(svg, .mono-icon, [mono-icon]) {\n display: block;\n width: var(--_mono-otp-clear-glyph);\n height: var(--_mono-otp-clear-glyph);\n pointer-events: none;\n}\n\n/* =========================================\n Message\n ========================================= */\n\n:where([mono-otp]) > [mono-message-wrap] {\n display: block;\n}\n:where([mono-otp]) > [mono-message-wrap]:not(:has([mono-message]:not([mono-empty]))) {\n display: none;\n}\n\n:where([mono-otp]) [mono-message] {\n font-size: var(--mono-otp-message-font-size, var(--mono-input-message-font-size, var(--mono-text-sm)));\n line-height: var(--mono-otp-message-line-height, var(--mono-input-message-line-height, var(--mono-leading-normal)));\n font-weight: var(--mono-font-weight-normal);\n text-align: start;\n color: var(--_mono-otp-muted);\n}\n:where([mono-otp]) [mono-message=\"invalid\"] { color: var(--_mono-otp-invalid); }\n:where([mono-otp]) [mono-message=\"valid\"] { color: var(--_mono-otp-valid); }\n:where([mono-otp]) [mono-message=\"warning\"] { color: var(--_mono-otp-warning); }\n\n/* hidden form value */\n:where([mono-otp]) [mono-otp-hidden] {\n display: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n :where([mono-otp]) :is([mono-otp-cell], [mono-clear]) {\n transition: none;\n }\n}\n\n/* =========================================\n label-position — left / right (form/label-position.css).\n `notched` renders as top: there is no single box to notch.\n ========================================= */\n\n[mono-otp][mono-label-position] {\n --_mono-lp-width: var(--mono-otp-label-width, var(--mono-input-label-width, auto));\n --_mono-lp-gap: var(--mono-otp-label-side-gap, var(--mono-input-label-side-gap, calc(var(--mono-spacing) * 3)));\n --_mono-lp-height: var(--_mono-otp-size);\n --_mono-lp-box-min: var(--_mono-otp-size);\n --_mono-lp-padding-x: 0px;\n --_mono-lp-padding-y: 0px;\n --_mono-lp-font: var(--mono-text-xs);\n --_mono-lp-notch-bg: var(--background);\n --_mono-lp-field-bg: var(--_mono-otp-bg);\n}\n";
|
|
760
|
+
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/components/otp/mono-otp.shadow.ts
|
|
763
|
+
let MonoOtpShadow = class MonoOtpShadow extends withShadowUtilityStyles(MonoOtpCore(LitElement)) {
|
|
764
|
+
static {
|
|
765
|
+
this.disableWarning?.("change-in-update");
|
|
766
|
+
}
|
|
767
|
+
static {
|
|
768
|
+
this.styles = [unsafeCSS(toShadowCss(otp_css_raw_default + label_position_css_raw_default + field_tooltip_css_raw_default + field_validation_css_raw_default, { host: "mono-otp" }))];
|
|
769
|
+
}
|
|
770
|
+
connectedCallback() {
|
|
771
|
+
super.connectedCallback();
|
|
772
|
+
if (isServer) return;
|
|
773
|
+
flushSsrHydration(this);
|
|
774
|
+
}
|
|
775
|
+
firstUpdated(changed) {
|
|
776
|
+
super.firstUpdated(changed);
|
|
777
|
+
for (const name of [
|
|
778
|
+
"prefix",
|
|
779
|
+
"suffix",
|
|
780
|
+
"label",
|
|
781
|
+
"helper"
|
|
782
|
+
]) {
|
|
783
|
+
const slot = this.renderRoot.querySelector(`slot[name="${name}"]`);
|
|
784
|
+
this._setSlotState(name, this._slotHasContent(slot));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
_slotHasContent(slot) {
|
|
788
|
+
return !!slot && slot.assignedNodes({ flatten: true }).some((n) => n.nodeType === Node.ELEMENT_NODE || !!(n.textContent ?? "").trim());
|
|
789
|
+
}
|
|
790
|
+
_setSlotState(name, has) {
|
|
791
|
+
if (name === "prefix" && this._hasPrefixSlotState !== has) this._hasPrefixSlotState = has;
|
|
792
|
+
else if (name === "suffix" && this._hasSuffixSlotState !== has) this._hasSuffixSlotState = has;
|
|
793
|
+
else if (name === "label" && this._hasLabelSlotState !== has) this._hasLabelSlotState = has;
|
|
794
|
+
else if (name === "helper" && this._hasHelperSlotState !== has) this._hasHelperSlotState = has;
|
|
795
|
+
}
|
|
796
|
+
_onSlotChange(name, event) {
|
|
797
|
+
this._setSlotState(name, this._slotHasContent(event.target));
|
|
798
|
+
}
|
|
799
|
+
_renderLabelText() {
|
|
800
|
+
return html`<slot name="label" @slotchange=${(e) => this._onSlotChange("label", e)}>${this.label}</slot>`;
|
|
801
|
+
}
|
|
802
|
+
/** Always rendered (the slot must exist to be scanned); hidden with `mono-empty` when empty. */
|
|
803
|
+
_renderLabel() {
|
|
804
|
+
return html`
|
|
805
|
+
<label
|
|
806
|
+
class=${this._cls("mono-otp-label", "label")}
|
|
807
|
+
mono-label
|
|
808
|
+
id=${`${this._otpId}-label`}
|
|
809
|
+
for=${`${this._otpId}-0`}
|
|
810
|
+
?mono-empty=${!this.label && !this._hasLabelSlotState}
|
|
811
|
+
>
|
|
812
|
+
${this._renderLabelText()}
|
|
813
|
+
${this.required ? html`<span class=${this._cls("mono-otp-required", "required")} mono-required-mark>*</span>` : nothing}
|
|
814
|
+
${this._tooltip.render()}
|
|
815
|
+
</label>
|
|
816
|
+
`;
|
|
817
|
+
}
|
|
818
|
+
_renderHelperText(base) {
|
|
819
|
+
return html`
|
|
820
|
+
<div class=${`${base} helper`} mono-message="helper" ?mono-empty=${!this.helperText && !this._hasHelperSlotState}>
|
|
821
|
+
<slot name="helper" @slotchange=${(e) => this._onSlotChange("helper", e)}>${this.helperText}</slot>
|
|
822
|
+
</div>
|
|
823
|
+
`;
|
|
824
|
+
}
|
|
825
|
+
_renderAffix(name) {
|
|
826
|
+
const has = name === "prefix" ? this._hasPrefixSlotState : this._hasSuffixSlotState;
|
|
827
|
+
return html`<span class=${this._cls(`mono-otp-${name}`, name)} mono-otp-affix=${name} ?mono-empty=${!has}>
|
|
828
|
+
<slot name=${name} @slotchange=${(e) => this._onSlotChange(name, e)}></slot>
|
|
829
|
+
</span>`;
|
|
830
|
+
}
|
|
831
|
+
renderIcon(_name) {
|
|
832
|
+
return html`
|
|
833
|
+
<svg viewBox="0 0 24 24" mono-icon fill="currentColor" aria-hidden="true">
|
|
834
|
+
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
|
|
835
|
+
</svg>
|
|
836
|
+
`;
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
MonoOtpShadow = __decorate([customElement("mono-shadow-otp")], MonoOtpShadow);
|
|
840
|
+
|
|
841
|
+
//#endregion
|
|
842
|
+
export { MonoOtpCore, MonoOtpShadow, OTP_DEFAULT_LENGTH, backspaceOtp, clampCaret, normaliseOtpValue, parseOtpGroups, removeOtpChar, resolveOtpLength, sanitizeOtpChar, sanitizeOtpText, spliceOtpValue };
|