@duskmoon-dev/el-otp-input 1.0.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.
@@ -0,0 +1,113 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+
39
+ // src/index.ts
40
+ var exports_src = {};
41
+ __export(exports_src, {
42
+ register: () => register,
43
+ ElDmOtpInput: () => ElDmOtpInput
44
+ });
45
+ module.exports = __toCommonJS(exports_src);
46
+
47
+ // src/el-dm-otp-input.ts
48
+ var import_el_base = require("@duskmoon-dev/el-base");
49
+ var import_otp_input = require("@duskmoon-dev/core/components/otp-input");
50
+ var coreStyles = import_otp_input.css.replace(/@layer\s+components\s*\{/, "").replace(/\}\s*$/, "");
51
+ var styles = import_el_base.css`
52
+ :host {
53
+ display: inline-flex;
54
+ vertical-align: middle;
55
+ }
56
+ :host([hidden]) {
57
+ display: none !important;
58
+ }
59
+ ${coreStyles}
60
+ `;
61
+
62
+ class ElDmOtpInput extends import_el_base.BaseElement {
63
+ static properties = {
64
+ length: { type: Number, reflect: true, default: 6 },
65
+ color: { type: String, reflect: true, default: "primary" },
66
+ disabled: { type: Boolean, reflect: true }
67
+ };
68
+ #listening = false;
69
+ constructor() {
70
+ super();
71
+ this.attachStyles(styles);
72
+ }
73
+ update() {
74
+ super.update();
75
+ if (!this.#listening && this.shadowRoot) {
76
+ this.#listening = true;
77
+ this.shadowRoot.addEventListener("input", this.#onInput.bind(this));
78
+ this.shadowRoot.addEventListener("keydown", this.#onKeydown.bind(this));
79
+ }
80
+ }
81
+ #onInput(e) {
82
+ const input = e.target;
83
+ if (!input.classList.contains("otp-input-field"))
84
+ return;
85
+ if (input.value.length === 1) {
86
+ const next = input.nextElementSibling;
87
+ next?.focus();
88
+ }
89
+ }
90
+ #onKeydown(e) {
91
+ const input = e.target;
92
+ if (!input.classList.contains("otp-input-field"))
93
+ return;
94
+ if (e.key === "Backspace" && input.value === "") {
95
+ const prev = input.previousElementSibling;
96
+ prev?.focus();
97
+ }
98
+ }
99
+ render() {
100
+ const len = this.length || 6;
101
+ const colorClass = `otp-input-${this.color || "primary"}`;
102
+ const fields = Array.from({ length: len }, () => `<input type="text" maxlength="1" class="otp-input-field" ${this.disabled ? "disabled" : ""} />`).join("");
103
+ return `<div class="otp-input ${colorClass}">${fields}</div>`;
104
+ }
105
+ }
106
+ function register() {
107
+ if (!customElements.get("el-dm-otp-input")) {
108
+ customElements.define("el-dm-otp-input", ElDmOtpInput);
109
+ }
110
+ }
111
+
112
+ //# debugId=42AEFA4DFE38378D64756E2164756E21
113
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/el-dm-otp-input.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @duskmoon-dev/el-otp-input\n *\n * A one-time password (OTP) input component for verification codes.\n */\n\nimport { BaseElement, css } from '@duskmoon-dev/el-base';\nimport { css as otpInputCSS } from '@duskmoon-dev/core/components/otp-input';\n\nconst coreStyles = otpInputCSS\n .replace(/@layer\\s+components\\s*\\{/, '')\n .replace(/\\}\\s*$/, '');\n\nexport type OtpInputColor =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'error';\n\nconst styles = css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none !important;\n }\n ${coreStyles}\n`;\n\nexport class ElDmOtpInput extends BaseElement {\n static properties = {\n length: { type: Number, reflect: true, default: 6 },\n color: { type: String, reflect: true, default: 'primary' },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare length: number;\n declare color: OtpInputColor;\n declare disabled: boolean;\n\n #listening = false;\n\n constructor() {\n super();\n this.attachStyles(styles);\n }\n\n override update(): void {\n super.update();\n if (!this.#listening && this.shadowRoot) {\n this.#listening = true;\n this.shadowRoot.addEventListener('input', this.#onInput.bind(this));\n this.shadowRoot.addEventListener('keydown', this.#onKeydown.bind(this) as EventListener);\n }\n }\n\n #onInput(e: Event): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (input.value.length === 1) {\n const next = input.nextElementSibling as HTMLInputElement | null;\n next?.focus();\n }\n }\n\n #onKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (e.key === 'Backspace' && input.value === '') {\n const prev = input.previousElementSibling as HTMLInputElement | null;\n prev?.focus();\n }\n }\n\n render(): string {\n const len = this.length || 6;\n const colorClass = `otp-input-${this.color || 'primary'}`;\n const fields = Array.from(\n { length: len },\n () =>\n `<input type=\"text\" maxlength=\"1\" class=\"otp-input-field\" ${this.disabled ? 'disabled' : ''} />`\n ).join('');\n return `<div class=\"otp-input ${colorClass}\">${fields}</div>`;\n }\n}\n\nexport function register(): void {\n if (!customElements.get('el-dm-otp-input')) {\n customElements.define('el-dm-otp-input', ElDmOtpInput);\n }\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMiC,IAAjC;AACmC,IAAnC;AAEA,IAAM,aAAa,qBAChB,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,UAAU,EAAE;AAUvB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQX;AAAA;AAAA;AAGG,MAAM,qBAAqB,2BAAY;AAAA,SACrC,aAAa;AAAA,IAClB,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,EAAE;AAAA,IAClD,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,UAAU;AAAA,IACzD,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,EAC3C;AAAA,EAMA,aAAa;AAAA,EAEb,WAAW,GAAG;AAAA,IACZ,MAAM;AAAA,IACN,KAAK,aAAa,MAAM;AAAA;AAAA,EAGjB,MAAM,GAAS;AAAA,IACtB,MAAM,OAAO;AAAA,IACb,IAAI,CAAC,KAAK,cAAc,KAAK,YAAY;AAAA,MACvC,KAAK,aAAa;AAAA,MAClB,KAAK,WAAW,iBAAiB,SAAS,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MAClE,KAAK,WAAW,iBAAiB,WAAW,KAAK,WAAW,KAAK,IAAI,CAAkB;AAAA,IACzF;AAAA;AAAA,EAGF,QAAQ,CAAC,GAAgB;AAAA,IACvB,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,MAAM,MAAM,WAAW,GAAG;AAAA,MAC5B,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,UAAU,CAAC,GAAwB;AAAA,IACjC,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,EAAE,QAAQ,eAAe,MAAM,UAAU,IAAI;AAAA,MAC/C,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,MAAM,MAAM,KAAK,UAAU;AAAA,IAC3B,MAAM,aAAa,aAAa,KAAK,SAAS;AAAA,IAC9C,MAAM,SAAS,MAAM,KACnB,EAAE,QAAQ,IAAI,GACd,MACE,4DAA4D,KAAK,WAAW,aAAa,OAC7F,EAAE,KAAK,EAAE;AAAA,IACT,OAAO,yBAAyB,eAAe;AAAA;AAEnD;AAEO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAAA,IAC1C,eAAe,OAAO,mBAAmB,YAAY;AAAA,EACvD;AAAA;",
8
+ "debugId": "42AEFA4DFE38378D64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,108 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+
39
+ // src/el-dm-otp-input.ts
40
+ var import_el_base = require("@duskmoon-dev/el-base");
41
+ var import_otp_input = require("@duskmoon-dev/core/components/otp-input");
42
+ var coreStyles = import_otp_input.css.replace(/@layer\s+components\s*\{/, "").replace(/\}\s*$/, "");
43
+ var styles = import_el_base.css`
44
+ :host {
45
+ display: inline-flex;
46
+ vertical-align: middle;
47
+ }
48
+ :host([hidden]) {
49
+ display: none !important;
50
+ }
51
+ ${coreStyles}
52
+ `;
53
+
54
+ class ElDmOtpInput extends import_el_base.BaseElement {
55
+ static properties = {
56
+ length: { type: Number, reflect: true, default: 6 },
57
+ color: { type: String, reflect: true, default: "primary" },
58
+ disabled: { type: Boolean, reflect: true }
59
+ };
60
+ #listening = false;
61
+ constructor() {
62
+ super();
63
+ this.attachStyles(styles);
64
+ }
65
+ update() {
66
+ super.update();
67
+ if (!this.#listening && this.shadowRoot) {
68
+ this.#listening = true;
69
+ this.shadowRoot.addEventListener("input", this.#onInput.bind(this));
70
+ this.shadowRoot.addEventListener("keydown", this.#onKeydown.bind(this));
71
+ }
72
+ }
73
+ #onInput(e) {
74
+ const input = e.target;
75
+ if (!input.classList.contains("otp-input-field"))
76
+ return;
77
+ if (input.value.length === 1) {
78
+ const next = input.nextElementSibling;
79
+ next?.focus();
80
+ }
81
+ }
82
+ #onKeydown(e) {
83
+ const input = e.target;
84
+ if (!input.classList.contains("otp-input-field"))
85
+ return;
86
+ if (e.key === "Backspace" && input.value === "") {
87
+ const prev = input.previousElementSibling;
88
+ prev?.focus();
89
+ }
90
+ }
91
+ render() {
92
+ const len = this.length || 6;
93
+ const colorClass = `otp-input-${this.color || "primary"}`;
94
+ const fields = Array.from({ length: len }, () => `<input type="text" maxlength="1" class="otp-input-field" ${this.disabled ? "disabled" : ""} />`).join("");
95
+ return `<div class="otp-input ${colorClass}">${fields}</div>`;
96
+ }
97
+ }
98
+ function register() {
99
+ if (!customElements.get("el-dm-otp-input")) {
100
+ customElements.define("el-dm-otp-input", ElDmOtpInput);
101
+ }
102
+ }
103
+
104
+ // src/register.ts
105
+ register();
106
+
107
+ //# debugId=DD51C0DCBEF5511E64756E2164756E21
108
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/el-dm-otp-input.ts", "../../src/register.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @duskmoon-dev/el-otp-input\n *\n * A one-time password (OTP) input component for verification codes.\n */\n\nimport { BaseElement, css } from '@duskmoon-dev/el-base';\nimport { css as otpInputCSS } from '@duskmoon-dev/core/components/otp-input';\n\nconst coreStyles = otpInputCSS\n .replace(/@layer\\s+components\\s*\\{/, '')\n .replace(/\\}\\s*$/, '');\n\nexport type OtpInputColor =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'error';\n\nconst styles = css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none !important;\n }\n ${coreStyles}\n`;\n\nexport class ElDmOtpInput extends BaseElement {\n static properties = {\n length: { type: Number, reflect: true, default: 6 },\n color: { type: String, reflect: true, default: 'primary' },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare length: number;\n declare color: OtpInputColor;\n declare disabled: boolean;\n\n #listening = false;\n\n constructor() {\n super();\n this.attachStyles(styles);\n }\n\n override update(): void {\n super.update();\n if (!this.#listening && this.shadowRoot) {\n this.#listening = true;\n this.shadowRoot.addEventListener('input', this.#onInput.bind(this));\n this.shadowRoot.addEventListener('keydown', this.#onKeydown.bind(this) as EventListener);\n }\n }\n\n #onInput(e: Event): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (input.value.length === 1) {\n const next = input.nextElementSibling as HTMLInputElement | null;\n next?.focus();\n }\n }\n\n #onKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (e.key === 'Backspace' && input.value === '') {\n const prev = input.previousElementSibling as HTMLInputElement | null;\n prev?.focus();\n }\n }\n\n render(): string {\n const len = this.length || 6;\n const colorClass = `otp-input-${this.color || 'primary'}`;\n const fields = Array.from(\n { length: len },\n () =>\n `<input type=\"text\" maxlength=\"1\" class=\"otp-input-field\" ${this.disabled ? 'disabled' : ''} />`\n ).join('');\n return `<div class=\"otp-input ${colorClass}\">${fields}</div>`;\n }\n}\n\nexport function register(): void {\n if (!customElements.get('el-dm-otp-input')) {\n customElements.define('el-dm-otp-input', ElDmOtpInput);\n }\n}\n",
6
+ "/**\n * Auto-registration entry point for el-dm-otp-input\n *\n * Import this module to automatically register the custom element:\n * import '@duskmoon-dev/el-otp-input/register';\n */\n\nimport { register } from './el-dm-otp-input.js';\n\nregister();\n"
7
+ ],
8
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMiC,IAAjC;AACmC,IAAnC;AAEA,IAAM,aAAa,qBAChB,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,UAAU,EAAE;AAUvB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQX;AAAA;AAAA;AAGG,MAAM,qBAAqB,2BAAY;AAAA,SACrC,aAAa;AAAA,IAClB,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,EAAE;AAAA,IAClD,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,UAAU;AAAA,IACzD,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,EAC3C;AAAA,EAMA,aAAa;AAAA,EAEb,WAAW,GAAG;AAAA,IACZ,MAAM;AAAA,IACN,KAAK,aAAa,MAAM;AAAA;AAAA,EAGjB,MAAM,GAAS;AAAA,IACtB,MAAM,OAAO;AAAA,IACb,IAAI,CAAC,KAAK,cAAc,KAAK,YAAY;AAAA,MACvC,KAAK,aAAa;AAAA,MAClB,KAAK,WAAW,iBAAiB,SAAS,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MAClE,KAAK,WAAW,iBAAiB,WAAW,KAAK,WAAW,KAAK,IAAI,CAAkB;AAAA,IACzF;AAAA;AAAA,EAGF,QAAQ,CAAC,GAAgB;AAAA,IACvB,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,MAAM,MAAM,WAAW,GAAG;AAAA,MAC5B,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,UAAU,CAAC,GAAwB;AAAA,IACjC,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,EAAE,QAAQ,eAAe,MAAM,UAAU,IAAI;AAAA,MAC/C,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,MAAM,MAAM,KAAK,UAAU;AAAA,IAC3B,MAAM,aAAa,aAAa,KAAK,SAAS;AAAA,IAC9C,MAAM,SAAS,MAAM,KACnB,EAAE,QAAQ,IAAI,GACd,MACE,4DAA4D,KAAK,WAAW,aAAa,OAC7F,EAAE,KAAK,EAAE;AAAA,IACT,OAAO,yBAAyB,eAAe;AAAA;AAEnD;AAEO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAAA,IAC1C,eAAe,OAAO,mBAAmB,YAAY;AAAA,EACvD;AAAA;;;ACnFF,SAAS;",
9
+ "debugId": "DD51C0DCBEF5511E64756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1,71 @@
1
+ // src/el-dm-otp-input.ts
2
+ import { BaseElement, css } from "@duskmoon-dev/el-base";
3
+ import { css as otpInputCSS } from "@duskmoon-dev/core/components/otp-input";
4
+ var coreStyles = otpInputCSS.replace(/@layer\s+components\s*\{/, "").replace(/\}\s*$/, "");
5
+ var styles = css`
6
+ :host {
7
+ display: inline-flex;
8
+ vertical-align: middle;
9
+ }
10
+ :host([hidden]) {
11
+ display: none !important;
12
+ }
13
+ ${coreStyles}
14
+ `;
15
+
16
+ class ElDmOtpInput extends BaseElement {
17
+ static properties = {
18
+ length: { type: Number, reflect: true, default: 6 },
19
+ color: { type: String, reflect: true, default: "primary" },
20
+ disabled: { type: Boolean, reflect: true }
21
+ };
22
+ #listening = false;
23
+ constructor() {
24
+ super();
25
+ this.attachStyles(styles);
26
+ }
27
+ update() {
28
+ super.update();
29
+ if (!this.#listening && this.shadowRoot) {
30
+ this.#listening = true;
31
+ this.shadowRoot.addEventListener("input", this.#onInput.bind(this));
32
+ this.shadowRoot.addEventListener("keydown", this.#onKeydown.bind(this));
33
+ }
34
+ }
35
+ #onInput(e) {
36
+ const input = e.target;
37
+ if (!input.classList.contains("otp-input-field"))
38
+ return;
39
+ if (input.value.length === 1) {
40
+ const next = input.nextElementSibling;
41
+ next?.focus();
42
+ }
43
+ }
44
+ #onKeydown(e) {
45
+ const input = e.target;
46
+ if (!input.classList.contains("otp-input-field"))
47
+ return;
48
+ if (e.key === "Backspace" && input.value === "") {
49
+ const prev = input.previousElementSibling;
50
+ prev?.focus();
51
+ }
52
+ }
53
+ render() {
54
+ const len = this.length || 6;
55
+ const colorClass = `otp-input-${this.color || "primary"}`;
56
+ const fields = Array.from({ length: len }, () => `<input type="text" maxlength="1" class="otp-input-field" ${this.disabled ? "disabled" : ""} />`).join("");
57
+ return `<div class="otp-input ${colorClass}">${fields}</div>`;
58
+ }
59
+ }
60
+ function register() {
61
+ if (!customElements.get("el-dm-otp-input")) {
62
+ customElements.define("el-dm-otp-input", ElDmOtpInput);
63
+ }
64
+ }
65
+ export {
66
+ register,
67
+ ElDmOtpInput
68
+ };
69
+
70
+ //# debugId=80E0F0D8C86B0F3A64756E2164756E21
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/el-dm-otp-input.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @duskmoon-dev/el-otp-input\n *\n * A one-time password (OTP) input component for verification codes.\n */\n\nimport { BaseElement, css } from '@duskmoon-dev/el-base';\nimport { css as otpInputCSS } from '@duskmoon-dev/core/components/otp-input';\n\nconst coreStyles = otpInputCSS\n .replace(/@layer\\s+components\\s*\\{/, '')\n .replace(/\\}\\s*$/, '');\n\nexport type OtpInputColor =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'error';\n\nconst styles = css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none !important;\n }\n ${coreStyles}\n`;\n\nexport class ElDmOtpInput extends BaseElement {\n static properties = {\n length: { type: Number, reflect: true, default: 6 },\n color: { type: String, reflect: true, default: 'primary' },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare length: number;\n declare color: OtpInputColor;\n declare disabled: boolean;\n\n #listening = false;\n\n constructor() {\n super();\n this.attachStyles(styles);\n }\n\n override update(): void {\n super.update();\n if (!this.#listening && this.shadowRoot) {\n this.#listening = true;\n this.shadowRoot.addEventListener('input', this.#onInput.bind(this));\n this.shadowRoot.addEventListener('keydown', this.#onKeydown.bind(this) as EventListener);\n }\n }\n\n #onInput(e: Event): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (input.value.length === 1) {\n const next = input.nextElementSibling as HTMLInputElement | null;\n next?.focus();\n }\n }\n\n #onKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (e.key === 'Backspace' && input.value === '') {\n const prev = input.previousElementSibling as HTMLInputElement | null;\n prev?.focus();\n }\n }\n\n render(): string {\n const len = this.length || 6;\n const colorClass = `otp-input-${this.color || 'primary'}`;\n const fields = Array.from(\n { length: len },\n () =>\n `<input type=\"text\" maxlength=\"1\" class=\"otp-input-field\" ${this.disabled ? 'disabled' : ''} />`\n ).join('');\n return `<div class=\"otp-input ${colorClass}\">${fields}</div>`;\n }\n}\n\nexport function register(): void {\n if (!customElements.get('el-dm-otp-input')) {\n customElements.define('el-dm-otp-input', ElDmOtpInput);\n }\n}\n"
6
+ ],
7
+ "mappings": ";AAMA;AACA,gBAAS;AAET,IAAM,aAAa,YAChB,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,UAAU,EAAE;AAUvB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQX;AAAA;AAAA;AAGG,MAAM,qBAAqB,YAAY;AAAA,SACrC,aAAa;AAAA,IAClB,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,EAAE;AAAA,IAClD,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,UAAU;AAAA,IACzD,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,EAC3C;AAAA,EAMA,aAAa;AAAA,EAEb,WAAW,GAAG;AAAA,IACZ,MAAM;AAAA,IACN,KAAK,aAAa,MAAM;AAAA;AAAA,EAGjB,MAAM,GAAS;AAAA,IACtB,MAAM,OAAO;AAAA,IACb,IAAI,CAAC,KAAK,cAAc,KAAK,YAAY;AAAA,MACvC,KAAK,aAAa;AAAA,MAClB,KAAK,WAAW,iBAAiB,SAAS,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MAClE,KAAK,WAAW,iBAAiB,WAAW,KAAK,WAAW,KAAK,IAAI,CAAkB;AAAA,IACzF;AAAA;AAAA,EAGF,QAAQ,CAAC,GAAgB;AAAA,IACvB,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,MAAM,MAAM,WAAW,GAAG;AAAA,MAC5B,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,UAAU,CAAC,GAAwB;AAAA,IACjC,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,EAAE,QAAQ,eAAe,MAAM,UAAU,IAAI;AAAA,MAC/C,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,MAAM,MAAM,KAAK,UAAU;AAAA,IAC3B,MAAM,aAAa,aAAa,KAAK,SAAS;AAAA,IAC9C,MAAM,SAAS,MAAM,KACnB,EAAE,QAAQ,IAAI,GACd,MACE,4DAA4D,KAAK,WAAW,aAAa,OAC7F,EAAE,KAAK,EAAE;AAAA,IACT,OAAO,yBAAyB,eAAe;AAAA;AAEnD;AAEO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAAA,IAC1C,eAAe,OAAO,mBAAmB,YAAY;AAAA,EACvD;AAAA;",
8
+ "debugId": "80E0F0D8C86B0F3A64756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,70 @@
1
+ // src/el-dm-otp-input.ts
2
+ import { BaseElement, css } from "@duskmoon-dev/el-base";
3
+ import { css as otpInputCSS } from "@duskmoon-dev/core/components/otp-input";
4
+ var coreStyles = otpInputCSS.replace(/@layer\s+components\s*\{/, "").replace(/\}\s*$/, "");
5
+ var styles = css`
6
+ :host {
7
+ display: inline-flex;
8
+ vertical-align: middle;
9
+ }
10
+ :host([hidden]) {
11
+ display: none !important;
12
+ }
13
+ ${coreStyles}
14
+ `;
15
+
16
+ class ElDmOtpInput extends BaseElement {
17
+ static properties = {
18
+ length: { type: Number, reflect: true, default: 6 },
19
+ color: { type: String, reflect: true, default: "primary" },
20
+ disabled: { type: Boolean, reflect: true }
21
+ };
22
+ #listening = false;
23
+ constructor() {
24
+ super();
25
+ this.attachStyles(styles);
26
+ }
27
+ update() {
28
+ super.update();
29
+ if (!this.#listening && this.shadowRoot) {
30
+ this.#listening = true;
31
+ this.shadowRoot.addEventListener("input", this.#onInput.bind(this));
32
+ this.shadowRoot.addEventListener("keydown", this.#onKeydown.bind(this));
33
+ }
34
+ }
35
+ #onInput(e) {
36
+ const input = e.target;
37
+ if (!input.classList.contains("otp-input-field"))
38
+ return;
39
+ if (input.value.length === 1) {
40
+ const next = input.nextElementSibling;
41
+ next?.focus();
42
+ }
43
+ }
44
+ #onKeydown(e) {
45
+ const input = e.target;
46
+ if (!input.classList.contains("otp-input-field"))
47
+ return;
48
+ if (e.key === "Backspace" && input.value === "") {
49
+ const prev = input.previousElementSibling;
50
+ prev?.focus();
51
+ }
52
+ }
53
+ render() {
54
+ const len = this.length || 6;
55
+ const colorClass = `otp-input-${this.color || "primary"}`;
56
+ const fields = Array.from({ length: len }, () => `<input type="text" maxlength="1" class="otp-input-field" ${this.disabled ? "disabled" : ""} />`).join("");
57
+ return `<div class="otp-input ${colorClass}">${fields}</div>`;
58
+ }
59
+ }
60
+ function register() {
61
+ if (!customElements.get("el-dm-otp-input")) {
62
+ customElements.define("el-dm-otp-input", ElDmOtpInput);
63
+ }
64
+ }
65
+
66
+ // src/register.ts
67
+ register();
68
+
69
+ //# debugId=24C60C7D67CF80E164756E2164756E21
70
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/el-dm-otp-input.ts", "../../src/register.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @duskmoon-dev/el-otp-input\n *\n * A one-time password (OTP) input component for verification codes.\n */\n\nimport { BaseElement, css } from '@duskmoon-dev/el-base';\nimport { css as otpInputCSS } from '@duskmoon-dev/core/components/otp-input';\n\nconst coreStyles = otpInputCSS\n .replace(/@layer\\s+components\\s*\\{/, '')\n .replace(/\\}\\s*$/, '');\n\nexport type OtpInputColor =\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'error';\n\nconst styles = css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n }\n :host([hidden]) {\n display: none !important;\n }\n ${coreStyles}\n`;\n\nexport class ElDmOtpInput extends BaseElement {\n static properties = {\n length: { type: Number, reflect: true, default: 6 },\n color: { type: String, reflect: true, default: 'primary' },\n disabled: { type: Boolean, reflect: true },\n };\n\n declare length: number;\n declare color: OtpInputColor;\n declare disabled: boolean;\n\n #listening = false;\n\n constructor() {\n super();\n this.attachStyles(styles);\n }\n\n override update(): void {\n super.update();\n if (!this.#listening && this.shadowRoot) {\n this.#listening = true;\n this.shadowRoot.addEventListener('input', this.#onInput.bind(this));\n this.shadowRoot.addEventListener('keydown', this.#onKeydown.bind(this) as EventListener);\n }\n }\n\n #onInput(e: Event): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (input.value.length === 1) {\n const next = input.nextElementSibling as HTMLInputElement | null;\n next?.focus();\n }\n }\n\n #onKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n if (!input.classList.contains('otp-input-field')) return;\n if (e.key === 'Backspace' && input.value === '') {\n const prev = input.previousElementSibling as HTMLInputElement | null;\n prev?.focus();\n }\n }\n\n render(): string {\n const len = this.length || 6;\n const colorClass = `otp-input-${this.color || 'primary'}`;\n const fields = Array.from(\n { length: len },\n () =>\n `<input type=\"text\" maxlength=\"1\" class=\"otp-input-field\" ${this.disabled ? 'disabled' : ''} />`\n ).join('');\n return `<div class=\"otp-input ${colorClass}\">${fields}</div>`;\n }\n}\n\nexport function register(): void {\n if (!customElements.get('el-dm-otp-input')) {\n customElements.define('el-dm-otp-input', ElDmOtpInput);\n }\n}\n",
6
+ "/**\n * Auto-registration entry point for el-dm-otp-input\n *\n * Import this module to automatically register the custom element:\n * import '@duskmoon-dev/el-otp-input/register';\n */\n\nimport { register } from './el-dm-otp-input.js';\n\nregister();\n"
7
+ ],
8
+ "mappings": ";AAMA;AACA,gBAAS;AAET,IAAM,aAAa,YAChB,QAAQ,4BAA4B,EAAE,EACtC,QAAQ,UAAU,EAAE;AAUvB,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQX;AAAA;AAAA;AAGG,MAAM,qBAAqB,YAAY;AAAA,SACrC,aAAa;AAAA,IAClB,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,EAAE;AAAA,IAClD,OAAO,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,UAAU;AAAA,IACzD,UAAU,EAAE,MAAM,SAAS,SAAS,KAAK;AAAA,EAC3C;AAAA,EAMA,aAAa;AAAA,EAEb,WAAW,GAAG;AAAA,IACZ,MAAM;AAAA,IACN,KAAK,aAAa,MAAM;AAAA;AAAA,EAGjB,MAAM,GAAS;AAAA,IACtB,MAAM,OAAO;AAAA,IACb,IAAI,CAAC,KAAK,cAAc,KAAK,YAAY;AAAA,MACvC,KAAK,aAAa;AAAA,MAClB,KAAK,WAAW,iBAAiB,SAAS,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,MAClE,KAAK,WAAW,iBAAiB,WAAW,KAAK,WAAW,KAAK,IAAI,CAAkB;AAAA,IACzF;AAAA;AAAA,EAGF,QAAQ,CAAC,GAAgB;AAAA,IACvB,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,MAAM,MAAM,WAAW,GAAG;AAAA,MAC5B,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,UAAU,CAAC,GAAwB;AAAA,IACjC,MAAM,QAAQ,EAAE;AAAA,IAChB,IAAI,CAAC,MAAM,UAAU,SAAS,iBAAiB;AAAA,MAAG;AAAA,IAClD,IAAI,EAAE,QAAQ,eAAe,MAAM,UAAU,IAAI;AAAA,MAC/C,MAAM,OAAO,MAAM;AAAA,MACnB,MAAM,MAAM;AAAA,IACd;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,MAAM,MAAM,KAAK,UAAU;AAAA,IAC3B,MAAM,aAAa,aAAa,KAAK,SAAS;AAAA,IAC9C,MAAM,SAAS,MAAM,KACnB,EAAE,QAAQ,IAAI,GACd,MACE,4DAA4D,KAAK,WAAW,aAAa,OAC7F,EAAE,KAAK,EAAE;AAAA,IACT,OAAO,yBAAyB,eAAe;AAAA;AAEnD;AAEO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,iBAAiB,GAAG;AAAA,IAC1C,eAAe,OAAO,mBAAmB,YAAY;AAAA,EACvD;AAAA;;;ACnFF,SAAS;",
9
+ "debugId": "24C60C7D67CF80E164756E2164756E21",
10
+ "names": []
11
+ }
@@ -0,0 +1 @@
1
+ {"fileNames":["../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.bun/typescript@6.0.2/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/duskmoon-core.d.ts","../../../packages/base/dist/types/base-element.d.ts","../../../packages/base/dist/types/styles.d.ts","../../../packages/base/dist/types/animations.d.ts","../../../packages/base/dist/types/themes.d.ts","../../../packages/base/dist/types/mixins.d.ts","../../../packages/base/dist/types/types.d.ts","../../../packages/base/dist/types/validation.d.ts","../../../packages/base/dist/types/performance.d.ts","../../../packages/base/dist/types/index.d.ts","../src/el-dm-otp-input.ts","../src/index.ts","../src/register.ts"],"fileIdsList":[[60,69],[70],[61,62,63,64,65,66,67,68],[61],[66]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},"5b0dacca53c101359676a52c36ef942d4586c8be521dc431383e781da8cde399","42526b6de804c10fd86f1cf55a6c660a74ee448e381f0f78356f223b75982280","28914adcfb92fa94199e1c887da7d67a7d9d736d9571627d6b02e55ff82f577b","b0a69607a92876948c2a42e3aa6703b0d724699468ed7e3c6e2a237d119a9db9","cdacb8e4ac607a46494d1187e073382c43e7269e8bf698502a285a8ccb470925","f5091ebbd718ea236a7f503df569deb07aff0621aa8f73ed90e419de88f006aa","d3a328c0eccf652bc8b6c14515a8b848a558b9d684e15a7c0c2e15de5016df57","1b5193795ee478857bf1115fed004151284dd4da883a5a4f22e62631c3b414ad","3be01044afc63501423c361deb531d3e95f5c2677f1f7a628802bd346988d62c","78d8d1ca7d54a437702c8a8c08764b6a49f2cf2ca357d0e459bfe89a06abf50a",{"version":"cdad34f58edc0a2be6e3f82216bb7d6fc7d93f42c3b8318695de40c82666e3be","signature":"e883cdc30058a7a68694cbfcfab68c860fc5558cfd1360755b30555dca7ff623"},{"version":"f95f96a9cc6342a766885997f033c4ca82cb2f00e4d9b2e47d44aedc47681970","signature":"850aa139cbaed89e23759987f6a10773785c4771eca76d8aeee6b2ac7ce56a2f"},{"version":"03b75abe2f2ec750195b4c564dc849044a5e06f0c44a5b9a9de89414cbe6101f","signature":"74f79c0a7da3ac81e60d3e7199834416328d19a5d35e2f6f483b2e494238efcf"}],"root":[60,[70,72]],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":99,"outDir":"./types","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[70,1],[71,2],[72,2],[69,3],[65,4],[67,5]],"latestChangedDtsFile":"./types/register.d.ts","version":"6.0.2"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @duskmoon-dev/el-otp-input
3
+ *
4
+ * A one-time password (OTP) input component for verification codes.
5
+ */
6
+ import { BaseElement } from '@duskmoon-dev/el-base';
7
+ export type OtpInputColor = 'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'error';
8
+ export declare class ElDmOtpInput extends BaseElement {
9
+ #private;
10
+ static properties: {
11
+ length: {
12
+ type: NumberConstructor;
13
+ reflect: boolean;
14
+ default: number;
15
+ };
16
+ color: {
17
+ type: StringConstructor;
18
+ reflect: boolean;
19
+ default: string;
20
+ };
21
+ disabled: {
22
+ type: BooleanConstructor;
23
+ reflect: boolean;
24
+ };
25
+ };
26
+ length: number;
27
+ color: OtpInputColor;
28
+ disabled: boolean;
29
+ constructor();
30
+ update(): void;
31
+ render(): string;
32
+ }
33
+ export declare function register(): void;
34
+ //# sourceMappingURL=el-dm-otp-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"el-dm-otp-input.d.ts","sourceRoot":"","sources":["../../src/el-dm-otp-input.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAO,MAAM,uBAAuB,CAAC;AAOzD,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,WAAW,GACX,UAAU,GACV,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAaZ,qBAAa,YAAa,SAAQ,WAAW;;IAC3C,MAAM,CAAC,UAAU;;;;;;;;;;;;;;;MAIf;IAEM,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;;IASjB,MAAM,IAAI,IAAI;IA2BvB,MAAM,IAAI,MAAM;CAUjB;AAED,wBAAgB,QAAQ,IAAI,IAAI,CAI/B"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @duskmoon-dev/el-otp-input
3
+ *
4
+ * A one-time password (OTP) input component for verification codes.
5
+ */
6
+ export { ElDmOtpInput, register, type OtpInputColor } from './el-dm-otp-input.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Auto-registration entry point for el-dm-otp-input
3
+ *
4
+ * Import this module to automatically register the custom element:
5
+ * import '@duskmoon-dev/el-otp-input/register';
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@duskmoon-dev/el-otp-input",
3
+ "version": "1.0.0",
4
+ "description": "DuskMoon OTP Input custom element for one-time password entry",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.js"
14
+ },
15
+ "./register": {
16
+ "types": "./dist/types/register.d.ts",
17
+ "import": "./dist/esm/register.js",
18
+ "require": "./dist/cjs/register.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "scripts": {
26
+ "prebuild": "bun run clean",
27
+ "build": "bun run build:esm && bun run build:cjs && bun run build:types",
28
+ "build:esm": "bun build ./src/index.ts ./src/register.ts --outdir ./dist/esm --format esm --sourcemap --external @duskmoon-dev/el-base --external @duskmoon-dev/core",
29
+ "build:cjs": "bun build ./src/index.ts ./src/register.ts --outdir ./dist/cjs --format cjs --sourcemap --external @duskmoon-dev/el-base --external @duskmoon-dev/core",
30
+ "build:types": "tsc --emitDeclarationOnly --outDir ./dist/types",
31
+ "dev": "bun build ./src/index.ts --outdir ./dist/esm --format esm --sourcemap --external @duskmoon-dev/el-base --external @duskmoon-dev/core --watch",
32
+ "clean": "rm -rf dist",
33
+ "test": "bun test",
34
+ "typecheck": "tsc --noEmit"
35
+ },
36
+ "dependencies": {
37
+ "@duskmoon-dev/el-base": "0.11.2",
38
+ "@duskmoon-dev/core": "^1.15.0"
39
+ },
40
+ "devDependencies": {
41
+ "typescript": "^6.0.2"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/AkaraChen/duskmoon-elements.git",
49
+ "directory": "elements/otp-input"
50
+ },
51
+ "keywords": [
52
+ "web-components",
53
+ "custom-elements",
54
+ "otp",
55
+ "otp-input",
56
+ "one-time-password",
57
+ "verification",
58
+ "duskmoon"
59
+ ],
60
+ "author": "AkaraChen",
61
+ "license": "MIT"
62
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Type declarations for @duskmoon-dev/core otp-input component export
3
+ */
4
+
5
+ declare module '@duskmoon-dev/core/components/otp-input' {
6
+ export const css: string;
7
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @duskmoon-dev/el-otp-input
3
+ *
4
+ * A one-time password (OTP) input component for verification codes.
5
+ */
6
+
7
+ import { BaseElement, css } from '@duskmoon-dev/el-base';
8
+ import { css as otpInputCSS } from '@duskmoon-dev/core/components/otp-input';
9
+
10
+ const coreStyles = otpInputCSS
11
+ .replace(/@layer\s+components\s*\{/, '')
12
+ .replace(/\}\s*$/, '');
13
+
14
+ export type OtpInputColor =
15
+ | 'primary'
16
+ | 'secondary'
17
+ | 'tertiary'
18
+ | 'success'
19
+ | 'warning'
20
+ | 'error';
21
+
22
+ const styles = css`
23
+ :host {
24
+ display: inline-flex;
25
+ vertical-align: middle;
26
+ }
27
+ :host([hidden]) {
28
+ display: none !important;
29
+ }
30
+ ${coreStyles}
31
+ `;
32
+
33
+ export class ElDmOtpInput extends BaseElement {
34
+ static properties = {
35
+ length: { type: Number, reflect: true, default: 6 },
36
+ color: { type: String, reflect: true, default: 'primary' },
37
+ disabled: { type: Boolean, reflect: true },
38
+ };
39
+
40
+ declare length: number;
41
+ declare color: OtpInputColor;
42
+ declare disabled: boolean;
43
+
44
+ #listening = false;
45
+
46
+ constructor() {
47
+ super();
48
+ this.attachStyles(styles);
49
+ }
50
+
51
+ override update(): void {
52
+ super.update();
53
+ if (!this.#listening && this.shadowRoot) {
54
+ this.#listening = true;
55
+ this.shadowRoot.addEventListener('input', this.#onInput.bind(this));
56
+ this.shadowRoot.addEventListener('keydown', this.#onKeydown.bind(this) as EventListener);
57
+ }
58
+ }
59
+
60
+ #onInput(e: Event): void {
61
+ const input = e.target as HTMLInputElement;
62
+ if (!input.classList.contains('otp-input-field')) return;
63
+ if (input.value.length === 1) {
64
+ const next = input.nextElementSibling as HTMLInputElement | null;
65
+ next?.focus();
66
+ }
67
+ }
68
+
69
+ #onKeydown(e: KeyboardEvent): void {
70
+ const input = e.target as HTMLInputElement;
71
+ if (!input.classList.contains('otp-input-field')) return;
72
+ if (e.key === 'Backspace' && input.value === '') {
73
+ const prev = input.previousElementSibling as HTMLInputElement | null;
74
+ prev?.focus();
75
+ }
76
+ }
77
+
78
+ render(): string {
79
+ const len = this.length || 6;
80
+ const colorClass = `otp-input-${this.color || 'primary'}`;
81
+ const fields = Array.from(
82
+ { length: len },
83
+ () =>
84
+ `<input type="text" maxlength="1" class="otp-input-field" ${this.disabled ? 'disabled' : ''} />`
85
+ ).join('');
86
+ return `<div class="otp-input ${colorClass}">${fields}</div>`;
87
+ }
88
+ }
89
+
90
+ export function register(): void {
91
+ if (!customElements.get('el-dm-otp-input')) {
92
+ customElements.define('el-dm-otp-input', ElDmOtpInput);
93
+ }
94
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @duskmoon-dev/el-otp-input
3
+ *
4
+ * A one-time password (OTP) input component for verification codes.
5
+ */
6
+
7
+ export { ElDmOtpInput, register, type OtpInputColor } from './el-dm-otp-input.js';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Auto-registration entry point for el-dm-otp-input
3
+ *
4
+ * Import this module to automatically register the custom element:
5
+ * import '@duskmoon-dev/el-otp-input/register';
6
+ */
7
+
8
+ import { register } from './el-dm-otp-input.js';
9
+
10
+ register();