@a-drowned-fish/rox-v 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +255 -27
  2. package/dist/es/_virtual/_plugin-vue_export-helper.js +8 -0
  3. package/dist/es/_virtual/_rolldown/runtime.js +11 -0
  4. package/dist/es/components.js +10 -0
  5. package/dist/es/index.js +11 -0
  6. package/dist/es/input-otp/index.js +7 -0
  7. package/dist/es/input-otp/input-otp.js +7 -0
  8. package/dist/es/input-otp/input-otp.vue_vue_type_script_setup_true_lang.js +89 -0
  9. package/dist/es/input-otp/style.css +1 -0
  10. package/dist/es/popup/index.js +7 -0
  11. package/dist/es/popup/popup.js +7 -0
  12. package/dist/es/popup/popup.vue_vue_type_script_setup_true_lang.js +51 -0
  13. package/dist/es/popup/style.css +1 -0
  14. package/dist/index.js +1 -75
  15. package/dist/lib/_virtual/_plugin-vue_export-helper.js +1 -0
  16. package/dist/lib/_virtual/_rolldown/runtime.js +1 -0
  17. package/dist/lib/components.js +1 -0
  18. package/dist/lib/index.js +1 -0
  19. package/dist/lib/input-otp/index.js +1 -0
  20. package/dist/lib/input-otp/input-otp.js +1 -0
  21. package/dist/lib/input-otp/input-otp.vue_vue_type_script_setup_true_lang.js +1 -0
  22. package/dist/lib/input-otp/style.css +1 -0
  23. package/dist/lib/popup/index.js +1 -0
  24. package/dist/lib/popup/popup.js +1 -0
  25. package/dist/lib/popup/popup.vue_vue_type_script_setup_true_lang.js +1 -0
  26. package/dist/lib/popup/style.css +1 -0
  27. package/dist/style.css +2 -1
  28. package/dist/types/components/components.d.ts +4 -0
  29. package/dist/types/components/index.d.ts +7 -0
  30. package/dist/types/components/input-otp/index.d.ts +5 -0
  31. package/{es → dist/types/components}/input-otp/input-otp.vue.d.ts +5 -10
  32. package/dist/types/components/input-otp/style.css.d.ts +1 -0
  33. package/dist/types/components/input-otp/types.d.ts +8 -0
  34. package/dist/types/components/popup/index.d.ts +5 -0
  35. package/dist/types/components/popup/popup.vue.d.ts +33 -0
  36. package/dist/types/components/popup/style.css.d.ts +1 -0
  37. package/dist/types/components/popup/types.d.ts +8 -0
  38. package/dist/types/components/style.css.d.ts +1 -0
  39. package/package.json +48 -57
  40. package/dist/index.iife.js +0 -1
  41. package/dist/index.umd.cjs +0 -1
  42. package/es/components.d.ts +0 -1
  43. package/es/components.js +0 -69
  44. package/es/index.d.ts +0 -9
  45. package/es/index.js +0 -75
  46. package/es/input-otp/index.css +0 -28
  47. package/es/input-otp/index.d.ts +0 -3
  48. package/es/input-otp/index.js +0 -89
  49. package/lib/components.d.ts +0 -1
  50. package/lib/components.js +0 -1
  51. package/lib/index.d.ts +0 -9
  52. package/lib/index.js +0 -1
  53. package/lib/input-otp/index.css +0 -28
  54. package/lib/input-otp/index.d.ts +0 -3
  55. package/lib/input-otp/index.js +0 -89
  56. package/lib/input-otp/input-otp.vue.d.ts +0 -23
  57. package/resolver/resolver.cjs +0 -25
  58. package/resolver/resolver.d.ts +0 -13
  59. package/resolver/resolver.js +0 -25
package/README.md CHANGED
@@ -1,51 +1,279 @@
1
- # @a-drowned-fish/rox-v
1
+ # Rox V
2
2
 
3
- ## Usage
3
+ 一个基于 Vue 3 的组件库,支持按需引入和自动导入。
4
4
 
5
- ### Install
5
+ ## 安装
6
6
 
7
7
  ```bash
8
- npm add @a-drowned-fish/rox-v
8
+ npm install @a-drowned-fish/rox-v
9
+ # 或
10
+ yarn add @a-drowned-fish/rox-v
11
+ # 或
12
+ pnpm add @a-drowned-fish/rox-v
9
13
  ```
10
14
 
11
- ### Import all components
15
+ ## 使用方式
16
+
17
+ ### 1. 完整引入
12
18
 
13
19
  ```ts
14
20
  import { createApp } from "vue";
15
21
  import RoxV from "@a-drowned-fish/rox-v";
16
- import "@a-drowned-fish/rox-v/dist/style.css";
22
+ import "@a-drowned-fish/rox-v/dist/style.css"; // 如果需要样式
17
23
 
18
24
  const app = createApp(App);
19
25
  app.use(RoxV);
20
26
  ```
21
27
 
22
- ### Tree-shakable import
28
+ ### 2. 按需引入(无需手动引入css)
23
29
 
24
- ```ts
25
- import { InputOtp } from "@a-drowned-fish/rox-v";
26
- import "@a-drowned-fish/rox-v/es/input-otp/index.css";
30
+ ```vue
31
+ <template>
32
+ <Button>点击我</Button>
33
+ <InputOtp />
34
+ </template>
35
+ <script setup lang="ts">
36
+ import { Button, InputOtp } from "@a-drowned-fish/rox-v";
37
+ </script>
27
38
  ```
28
39
 
29
- ### Auto Import
40
+ ## 可用组件
30
41
 
31
- ```ts
32
- // vite.config.ts
33
- import { defineConfig } from "vite";
34
- import vue from "@vitejs/plugin-vue";
35
- import Components from "unplugin-vue-components/vite";
36
- import { RoxVResolver } from "@a-drowned-fish/rox-v/resolver";
37
-
38
- // https://vitejs.dev/config/
39
- export default defineConfig({
40
- plugins: [
41
- vue(),
42
- Components({
43
- resolvers: [RoxVResolver()],
44
- }),
45
- ],
46
- });
42
+ ### InputOtp - OTP 输入组件
43
+
44
+ 一个用于输入一次性密码(OTP)的组件,支持自定义长度、样式和间距。
45
+
46
+ #### 基础用法
47
+
48
+ ```vue
49
+ <template>
50
+ <InputOtp v-model="code" />
51
+ </template>
52
+
53
+ <script setup lang="ts">
54
+ import { ref } from "vue";
55
+
56
+ const code = ref("");
57
+ </script>
58
+ ```
59
+
60
+ #### 自定义长度
61
+
62
+ ```vue
63
+ <template>
64
+ <!-- 4位验证码 -->
65
+ <InputOtp v-model="code" :length="4" />
66
+
67
+ <!-- 8位验证码 -->
68
+ <InputOtp v-model="code" :length="8" />
69
+ </template>
70
+
71
+ <script setup lang="ts">
72
+ import { ref } from "vue";
73
+
74
+ const code = ref("");
75
+ </script>
76
+ ```
77
+
78
+ #### 自定义样式
79
+
80
+ ```vue
81
+ <template>
82
+ <InputOtp v-model="code" item-class="custom-item" active-item-class="custom-active" gap="15px" />
83
+ </template>
84
+
85
+ <script setup lang="ts">
86
+ import { ref } from "vue";
87
+
88
+ const code = ref("");
89
+ </script>
90
+
91
+ <style scoped>
92
+ .custom-item {
93
+ width: 50px;
94
+ height: 60px;
95
+ border: 2px solid #ddd;
96
+ border-radius: 12px;
97
+ font-size: 24px;
98
+ }
99
+
100
+ .custom-active {
101
+ border-color: #67c23a;
102
+ box-shadow: 0 0 0 3px rgba(103, 194, 58, 0.2);
103
+ }
104
+ </style>
105
+ ```
106
+
107
+ #### 监听完成事件
108
+
109
+ ```vue
110
+ <template>
111
+ <InputOtp v-model="code" @complete="handleComplete" />
112
+ </template>
113
+
114
+ <script setup lang="ts">
115
+ import { ref } from "vue";
116
+
117
+ const code = ref("");
118
+
119
+ const handleComplete = (value: string) => {
120
+ console.log("验证码输入完成:", value);
121
+ // 在这里执行验证逻辑
122
+ };
123
+ </script>
124
+ ```
125
+
126
+ #### Props
127
+
128
+ | 属性 | 说明 | 类型 | 默认值 |
129
+ | ------------------ | -------------------------------------------- | -------- | ---------- |
130
+ | length | 输入框数量 | `number` | `6` |
131
+ | itemClass | 每个输入项的自定义类名 | `string` | `''` |
132
+ | activeItemClass | 激活状态输入项的自定义类名 | `string` | `''` |
133
+ | gap | 输入项之间的间距 | `string` | `'10px'` |
134
+ | hasFilledItemClass | 具有内容的输入项的类名[active前面选项的类名] | `string` | `'active'` |
135
+
136
+ #### Events
137
+
138
+ | 事件名 | 说明 | 回调参数 |
139
+ | -------- | ------------------------------ | ----------------- |
140
+ | complete | 输入完成时触发(达到指定长度) | `(value: string)` |
141
+
142
+ ### Popup - 弹出层组件
143
+
144
+ 一个灵活的弹出层组件,支持从不同方向滑入,带有遮罩层和过渡动画效果。
145
+
146
+ #### 基础用法
147
+
148
+ ``vue
149
+ <template>
150
+ <Button @click="show = true">打开弹窗</Button>
151
+
152
+ <Popup v-model="show">
153
+ <div class="popup-content">
154
+ <h3>标题</h3>
155
+ <p>这是弹窗内容</p>
156
+ <Button @click="show = false">关闭</Button>
157
+ </div>
158
+ </Popup>
159
+
160
+ </template>
161
+
162
+ <script setup lang="ts">
163
+ import { ref } from "vue";
164
+ import { Button, Popup } from "@a-drowned-fish/rox-v";
165
+
166
+ const show = ref(false);
167
+ </script>
168
+
169
+ <style scoped>
170
+ .popup-content {
171
+ padding: 20px;
172
+ background: white;
173
+ border-radius: 12px 12px 0 0;
174
+ }
175
+ </style>
176
+
177
+ ```
178
+
179
+ #### 不同位置
180
+
181
+ ``vue
182
+ <template>
183
+ <!-- 底部弹出(默认) -->
184
+ <Popup v-model="showBottom" position="bottom">
185
+ <div class="content">底部弹窗</div>
186
+ </Popup>
187
+
188
+ <!-- 顶部弹出 -->
189
+ <Popup v-model="showTop" position="top">
190
+ <div class="content">顶部弹窗</div>
191
+ </Popup>
192
+
193
+ <!-- 左侧弹出 -->
194
+ <Popup v-model="showLeft" position="left">
195
+ <div class="content">左侧弹窗</div>
196
+ </Popup>
197
+
198
+ <!-- 右侧弹出 -->
199
+ <Popup v-model="showRight" position="right">
200
+ <div class="content">右侧弹窗</div>
201
+ </Popup>
202
+ </template>
203
+
204
+ <script setup lang="ts">
205
+ import { ref } from "vue";
206
+ import { Popup } from "@a-drowned-fish/rox-v";
207
+
208
+ const showBottom = ref(false);
209
+ const showTop = ref(false);
210
+ const showLeft = ref(false);
211
+ const showRight = ref(false);
212
+ </script>
47
213
  ```
48
214
 
215
+ #### 自定义遮罩层
216
+
217
+ ``vue
218
+ <template>
219
+ <Popup
220
+ v-model="show"
221
+ :bg="'rgba(0, 0, 0, 0.7)'"
222
+ :duration="500"
223
+ :mask-closable="false"
224
+ >
225
+
226
+ <div class="content">
227
+ <p>点击遮罩层不会关闭</p>
228
+ <Button @click="show = false">手动关闭</Button>
229
+ </div>
230
+ </Popup>
231
+ </template>
232
+
233
+ <script setup lang="ts">
234
+ import { ref } from "vue";
235
+ import { Popup, Button } from "@a-drowned-fish/rox-v";
236
+
237
+ const show = ref(false);
238
+ </script>
239
+
240
+ ```
241
+
242
+ #### 自定义挂载节点
243
+
244
+ ``vue
245
+ <template>
246
+ <div id="custom-container">
247
+ <Popup v-model="show" to="#custom-container">
248
+ <div class="content">挂载到指定容器</div>
249
+ </Popup>
250
+ </div>
251
+ </template>
252
+
253
+ <script setup lang="ts">
254
+ import { ref } from "vue";
255
+ import { Popup } from "@a-drowned-fish/rox-v";
256
+
257
+ const show = ref(false);
258
+ </script>
259
+ ```
260
+
261
+ #### Props
262
+
263
+ | 属性 | 说明 | 类型 | 默认值 |
264
+ | ------------ | -------------------- | ---------------------------------------- | --------------------- |
265
+ | position | 弹出位置 | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` |
266
+ | bg | 遮罩层背景色 | `string` | `'rgba(0, 0, 0, .5)'` |
267
+ | duration | 动画持续时间(毫秒) | `number` | `300` |
268
+ | maskClosable | 点击遮罩层是否关闭 | `boolean` | `true` |
269
+ | to | teleport 的目标节点 | `string` | `'body'` |
270
+
271
+ #### Slots
272
+
273
+ | 插槽名 | 说明 |
274
+ | ------- | ------------ |
275
+ | default | 弹窗内容区域 |
276
+
49
277
  ## License
50
278
 
51
279
  MIT
@@ -0,0 +1,8 @@
1
+ //#region \0plugin-vue:export-helper
2
+ var e = (e, t) => {
3
+ let n = e.__vccOpts || e;
4
+ for (let [e, r] of t) n[e] = r;
5
+ return n;
6
+ };
7
+ //#endregion
8
+ export { e as default };
@@ -0,0 +1,11 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = (t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ };
10
+ //#endregion
11
+ export { t as __exportAll };
@@ -0,0 +1,10 @@
1
+ import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
2
+ import t from "./input-otp/index.js";
3
+ import n from "./popup/index.js";
4
+ //#region components/components.ts
5
+ var r = /* @__PURE__ */ e({
6
+ InputOtp: () => t,
7
+ Popup: () => n
8
+ });
9
+ //#endregion
10
+ export { r as components_exports };
@@ -0,0 +1,11 @@
1
+ import e from "./input-otp/index.js";
2
+ import t from "./popup/index.js";
3
+ import { components_exports as n } from "./components.js";
4
+ import "./style.css";
5
+ //#region components/index.ts
6
+ var r = (e) => (Object.keys(n).forEach((t) => {
7
+ let r = n[t];
8
+ r.install && e.use(r);
9
+ }), e), i = { install: r };
10
+ //#endregion
11
+ export { e as InputOtp, t as Popup, i as default, r as install };
@@ -0,0 +1,7 @@
1
+ import e from "./input-otp.js";
2
+ import "./style.css";
3
+ //#region components/input-otp/index.ts
4
+ e.install = (t) => (e.name && t.component(e.name, e), t);
5
+ var t = e;
6
+ //#endregion
7
+ export { t as default };
@@ -0,0 +1,7 @@
1
+ import e from "./input-otp.vue_vue_type_script_setup_true_lang.js";
2
+ /* empty css */
3
+ import t from "../_virtual/_plugin-vue_export-helper.js";
4
+ //#region components/input-otp/input-otp.vue
5
+ var n = /* @__PURE__ */ t(e, [["__scopeId", "data-v-0e246228"]]);
6
+ //#endregion
7
+ export { n as default };
@@ -0,0 +1,89 @@
1
+ import { Fragment as e, createElementBlock as t, createElementVNode as n, defineComponent as r, nextTick as i, normalizeClass as a, normalizeStyle as o, openBlock as s, ref as c, renderList as l, toDisplayString as u, vModelText as d, watch as f, withDirectives as p } from "vue";
2
+ //#region components/input-otp/input-otp.vue?vue&type=script&setup=true&lang.ts
3
+ var m = ["maxlength"], h = /* @__PURE__ */ r({
4
+ name: "InputOtp",
5
+ __name: "input-otp",
6
+ props: {
7
+ modelValue: { default: "" },
8
+ length: { default: 6 },
9
+ itemClass: { default: "" },
10
+ activeItemClass: { default: "" },
11
+ gap: { default: "10px" },
12
+ hasFilledItemClass: { default: "active" }
13
+ },
14
+ emits: ["update:modelValue", "complete"],
15
+ setup(r, { emit: h }) {
16
+ let g = [
17
+ "ArrowLeft",
18
+ "ArrowRight",
19
+ "Home",
20
+ "End"
21
+ ], _ = r, v = h, y = c(null), b = c(_.modelValue);
22
+ f(() => _.modelValue, (e) => {
23
+ e !== b.value && (b.value = e);
24
+ });
25
+ function x(e) {
26
+ let t = e.target.value;
27
+ t = t.replace(/\D/g, ""), t = t.slice(0, _.length), b.value = t, v("update:modelValue", t), t.length === _.length && v("complete", t);
28
+ }
29
+ function S() {
30
+ i(() => {
31
+ if (y.value) {
32
+ let e = b.value.length;
33
+ y.value.setSelectionRange?.(e, e);
34
+ }
35
+ });
36
+ }
37
+ function C(e) {
38
+ let t = b.value, n = e.key;
39
+ if (n === "Backspace" || n === "Delete") {
40
+ if (e.preventDefault(), t.length > 0) {
41
+ let e = t.slice(0, -1);
42
+ b.value = e, v("update:modelValue", e), S();
43
+ }
44
+ } else g.includes(n) && e.preventDefault();
45
+ }
46
+ function w() {
47
+ y.value?.focus();
48
+ }
49
+ function T(e) {
50
+ return e === b.value.length;
51
+ }
52
+ function E(e) {
53
+ return e < b.value.length;
54
+ }
55
+ return (i, c) => (s(), t("div", {
56
+ class: "otp-wrapper",
57
+ onClick: w
58
+ }, [p(n("input", {
59
+ inputmode: "numeric",
60
+ autocomplete: "one-time-code",
61
+ ref_key: "inputRef",
62
+ ref: y,
63
+ "onUpdate:modelValue": c[0] ||= (e) => b.value = e,
64
+ maxlength: r.length,
65
+ onInput: x,
66
+ onKeydown: C,
67
+ onFocus: S,
68
+ style: {
69
+ position: "absolute",
70
+ opacity: "0",
71
+ "pointer-events": "none",
72
+ width: "1px",
73
+ height: "1px"
74
+ }
75
+ }, null, 40, m), [[d, b.value]]), n("div", {
76
+ class: "otp-box",
77
+ style: o({ gap: _.gap })
78
+ }, [(s(!0), t(e, null, l(r.length, (e, n) => (s(), t("div", {
79
+ key: n,
80
+ class: a(["otp-item", [
81
+ { [_.activeItemClass]: T(n) },
82
+ { [_.hasFilledItemClass]: E(n) },
83
+ _.itemClass
84
+ ]])
85
+ }, u(b.value[n] || ""), 3))), 128))], 4)]));
86
+ }
87
+ });
88
+ //#endregion
89
+ export { h as default };
@@ -0,0 +1 @@
1
+ .otp-wrapper[data-v-0e246228]{cursor:pointer;width:max-content;position:relative}.otp-box[data-v-0e246228]{display:flex}.otp-item[data-v-0e246228]{border-bottom:1px solid #00000029;justify-content:center;align-items:center;width:60px;height:60px;transition:all .2s;display:flex}.otp-item.active[data-v-0e246228]{border-bottom:1px solid #000}
@@ -0,0 +1,7 @@
1
+ import e from "./popup.js";
2
+ import "./style.css";
3
+ //#region components/popup/index.ts
4
+ e.install = (t) => (e.name && t.component(e.name, e), t);
5
+ var t = e;
6
+ //#endregion
7
+ export { t as default };
@@ -0,0 +1,7 @@
1
+ import e from "../_virtual/_plugin-vue_export-helper.js";
2
+ import t from "./popup.vue_vue_type_script_setup_true_lang.js";
3
+ /* empty css */
4
+ //#region components/popup/popup.vue
5
+ var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-00d0e4c1"]]);
6
+ //#endregion
7
+ export { n as default };
@@ -0,0 +1,51 @@
1
+ import { Teleport as e, Transition as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, mergeModels as c, normalizeClass as l, normalizeStyle as u, openBlock as d, renderSlot as f, useModel as p, withCtx as m, withModifiers as h } from "vue";
2
+ //#region components/popup/popup.vue?vue&type=script&setup=true&lang.ts
3
+ var g = /* @__PURE__ */ s({
4
+ name: "Popup",
5
+ __name: "popup",
6
+ props: /* @__PURE__ */ c({
7
+ to: { default: "body" },
8
+ bg: { default: "rgba(0, 0, 0, .5)" },
9
+ duration: { default: 300 },
10
+ position: { default: "bottom" },
11
+ maskClosable: {
12
+ type: Boolean,
13
+ default: !0
14
+ }
15
+ }, {
16
+ modelValue: {
17
+ type: Boolean,
18
+ default: !1
19
+ },
20
+ modelModifiers: {}
21
+ }),
22
+ emits: ["update:modelValue"],
23
+ setup(s) {
24
+ let c = [
25
+ "bottom",
26
+ "left",
27
+ "right",
28
+ "top"
29
+ ], g = p(s, "modelValue"), _ = s;
30
+ function v() {
31
+ _.maskClosable && (g.value = !1);
32
+ }
33
+ return (s, p) => (d(), n(e, { to: _.to }, [o(t, { name: "fade" }, {
34
+ default: m(() => [g.value ? (d(), i("div", {
35
+ key: 0,
36
+ style: u({
37
+ "background-color": _.bg,
38
+ "--duration": `${_.duration}ms`
39
+ }),
40
+ class: l(["popup-container", [`popup-container-${_.position}`, { "popup-container-bottom": !c.includes(_.position) }]]),
41
+ onClick: v
42
+ }, [a("div", {
43
+ class: "popup-content",
44
+ onClick: p[0] ||= h(() => {}, ["stop"])
45
+ }, [f(s.$slots, "default", {}, void 0, !0)])], 6)) : r("", !0)]),
46
+ _: 3
47
+ })], 8, ["to"]));
48
+ }
49
+ });
50
+ //#endregion
51
+ export { g as default };
@@ -0,0 +1 @@
1
+ .fade-enter-from[data-v-00d0e4c1],.fade-leave-to[data-v-00d0e4c1]{opacity:0}.popup-container[data-v-00d0e4c1]{z-index:50;transition:opacity var(--duration) ease-in-out;will-change:opacity;position:fixed;inset:0}.popup-content[data-v-00d0e4c1]{transition:transform var(--duration) ease-in-out;will-change:transform;position:absolute}.popup-container-top .popup-content[data-v-00d0e4c1]{top:0;left:0;right:0}.fade-enter-from.popup-container-top .popup-content[data-v-00d0e4c1],.fade-leave-to.popup-container-top .popup-content[data-v-00d0e4c1]{transform:translateY(-100%)}.popup-container-bottom .popup-content[data-v-00d0e4c1]{bottom:0;left:0;right:0}.fade-enter-from.popup-container-bottom .popup-content[data-v-00d0e4c1],.fade-leave-to.popup-container-bottom .popup-content[data-v-00d0e4c1]{transform:translateY(100%)}.popup-container-left .popup-content[data-v-00d0e4c1]{top:0;bottom:0;left:0}.fade-enter-from.popup-container-left .popup-content[data-v-00d0e4c1],.fade-leave-to.popup-container-left .popup-content[data-v-00d0e4c1]{transform:translate(-100%)}.popup-container-right .popup-content[data-v-00d0e4c1]{top:0;bottom:0;right:0}.fade-enter-from.popup-container-right .popup-content[data-v-00d0e4c1],.fade-leave-to.popup-container-right .popup-content[data-v-00d0e4c1]{transform:translate(100%)}
package/dist/index.js CHANGED
@@ -1,75 +1 @@
1
- import { defineComponent as h, ref as d, watch as _, openBlock as i, createElementBlock as p, withDirectives as I, createElementVNode as f, vModelText as V, normalizeStyle as C, Fragment as k, renderList as x, normalizeClass as y, toDisplayString as b } from "vue";
2
- const w = ["maxlength"], D = /* @__PURE__ */ h({
3
- __name: "input-otp",
4
- props: {
5
- modelValue: { default: "" },
6
- length: { default: 6 },
7
- itemClass: { default: "" },
8
- activeItemClass: { default: "" },
9
- gap: { default: "10px" }
10
- },
11
- emits: ["update:modelValue", "complete"],
12
- setup(n, { emit: c }) {
13
- const t = n, o = c, u = d(null), a = d(t.modelValue);
14
- _(
15
- () => t.modelValue,
16
- (l) => {
17
- l !== a.value && (a.value = l);
18
- }
19
- );
20
- function v(l) {
21
- let e = l.target.value;
22
- e = e.replace(/\D/g, ""), e = e.slice(0, t.length), a.value = e, o("update:modelValue", e), e.length === t.length && o("complete", e);
23
- }
24
- function g() {
25
- var l;
26
- (l = u.value) == null || l.focus();
27
- }
28
- function r(l) {
29
- return l === a.value.length;
30
- }
31
- return (l, e) => (i(), p("div", {
32
- class: "otp-wrapper",
33
- onClick: g
34
- }, [
35
- I(f("input", {
36
- inputmode: "numeric",
37
- autocomplete: "one-time-code",
38
- ref_key: "inputRef",
39
- ref: u,
40
- "onUpdate:modelValue": e[0] || (e[0] = (m) => a.value = m),
41
- maxlength: n.length,
42
- onInput: v,
43
- class: "otp-input"
44
- }, null, 40, w), [
45
- [V, a.value]
46
- ]),
47
- f("div", {
48
- class: "otp-box",
49
- style: C({ gap: t.gap })
50
- }, [
51
- (i(!0), p(k, null, x(n.length, (m, s) => (i(), p("div", {
52
- key: s,
53
- class: y(["otp-item", [
54
- { active: r(s), [t.activeItemClass]: r(s) },
55
- t.itemClass
56
- ]])
57
- }, b(a.value[s] || ""), 3))), 128))
58
- ], 4)
59
- ]));
60
- }
61
- }), O = (n, c) => {
62
- const t = n.__vccOpts || n;
63
- for (const [o, u] of c)
64
- t[o] = u;
65
- return t;
66
- }, R = /* @__PURE__ */ O(D, [["__scopeId", "data-v-14ecb7bd"]]), z = "1.0.0", B = (n) => {
67
- n.component("RInputOtp", R);
68
- }, S = {
69
- version: z,
70
- install: B
71
- };
72
- export {
73
- R as InputOtp,
74
- S as default
75
- };
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`rox-v`]={},e.Vue))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var n=Object.defineProperty,r=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},i=[`maxlength`],a=(0,t.defineComponent)({name:`InputOtp`,__name:`input-otp`,props:{modelValue:{default:``},length:{default:6},itemClass:{default:``},activeItemClass:{default:``},gap:{default:`10px`},hasFilledItemClass:{default:`active`}},emits:[`update:modelValue`,`complete`],setup(e,{emit:n}){let r=[`ArrowLeft`,`ArrowRight`,`Home`,`End`],a=e,o=n,s=(0,t.ref)(null),c=(0,t.ref)(a.modelValue);(0,t.watch)(()=>a.modelValue,e=>{e!==c.value&&(c.value=e)});function l(e){let t=e.target.value;t=t.replace(/\D/g,``),t=t.slice(0,a.length),c.value=t,o(`update:modelValue`,t),t.length===a.length&&o(`complete`,t)}function u(){(0,t.nextTick)(()=>{if(s.value){let e=c.value.length;s.value.setSelectionRange?.(e,e)}})}function d(e){let t=c.value,n=e.key;if(n===`Backspace`||n===`Delete`){if(e.preventDefault(),t.length>0){let e=t.slice(0,-1);c.value=e,o(`update:modelValue`,e),u()}}else r.includes(n)&&e.preventDefault()}function f(){s.value?.focus()}function p(e){return e===c.value.length}function m(e){return e<c.value.length}return(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:`otp-wrapper`,onClick:f},[(0,t.withDirectives)((0,t.createElementVNode)(`input`,{inputmode:`numeric`,autocomplete:`one-time-code`,ref_key:`inputRef`,ref:s,"onUpdate:modelValue":r[0]||=e=>c.value=e,maxlength:e.length,onInput:l,onKeydown:d,onFocus:u,style:{position:`absolute`,opacity:`0`,"pointer-events":`none`,width:`1px`,height:`1px`}},null,40,i),[[t.vModelText,c.value]]),(0,t.createElementVNode)(`div`,{class:`otp-box`,style:(0,t.normalizeStyle)({gap:a.gap})},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.length,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([`otp-item`,[{[a.activeItemClass]:p(n)},{[a.hasFilledItemClass]:m(n)},a.itemClass]])},(0,t.toDisplayString)(c.value[n]||``),3))),128))],4)]))}}),o=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},s=o(a,[[`__scopeId`,`data-v-0e246228`]]);s.install=e=>(s.name&&e.component(s.name,s),e);var c=s,l=o((0,t.defineComponent)({name:`Popup`,__name:`popup`,props:(0,t.mergeModels)({to:{default:`body`},bg:{default:`rgba(0, 0, 0, .5)`},duration:{default:300},position:{default:`bottom`},maskClosable:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let n=[`bottom`,`left`,`right`,`top`],r=(0,t.useModel)(e,`modelValue`),i=e;function a(){i.maskClosable&&(r.value=!1)}return(e,o)=>((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:i.to},[(0,t.createVNode)(t.Transition,{name:`fade`},{default:(0,t.withCtx)(()=>[r.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,style:(0,t.normalizeStyle)({"background-color":i.bg,"--duration":`${i.duration}ms`}),class:(0,t.normalizeClass)([`popup-container`,[`popup-container-${i.position}`,{"popup-container-bottom":!n.includes(i.position)}]]),onClick:a},[(0,t.createElementVNode)(`div`,{class:`popup-content`,onClick:o[0]||=(0,t.withModifiers)(()=>{},[`stop`])},[(0,t.renderSlot)(e.$slots,`default`,{},void 0,!0)])],6)):(0,t.createCommentVNode)(``,!0)]),_:3})],8,[`to`]))}}),[[`__scopeId`,`data-v-00d0e4c1`]]);l.install=e=>(l.name&&e.component(l.name,l),e);var u=l,d=r({InputOtp:()=>c,Popup:()=>u}),f=e=>(Object.keys(d).forEach(t=>{let n=d[t];n.install&&e.use(n)}),e),p={install:f};e.InputOtp=c,e.Popup=u,e.default=p,e.install=f});
@@ -0,0 +1 @@
1
+ var e=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n};exports.default=e;
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};exports.__exportAll=t;
@@ -0,0 +1 @@
1
+ const e=require(`./_virtual/_rolldown/runtime.js`),t=require(`./input-otp/index.js`),n=require(`./popup/index.js`);var r=e.__exportAll({InputOtp:()=>t.default,Popup:()=>n.default});Object.defineProperty(exports,`components_exports`,{enumerable:!0,get:function(){return r}});
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./input-otp/index.js`),t=require(`./popup/index.js`),n=require(`./components.js`);require(`./style.css.js`);var r=e=>(Object.keys(n.components_exports).forEach(t=>{let r=n.components_exports[t];r.install&&e.use(r)}),e),i={install:r};exports.InputOtp=e.default,exports.Popup=t.default,exports.default=i,exports.install=r;
@@ -0,0 +1 @@
1
+ const e=require(`./input-otp.js`);require(`./style.css.js`),e.default.install=t=>(e.default.name&&t.component(e.default.name,e.default),t);var t=e.default;exports.default=t;
@@ -0,0 +1 @@
1
+ const e=require(`./input-otp.vue_vue_type_script_setup_true_lang.js`);;/* empty css */var t=require(`../_virtual/_plugin-vue_export-helper.js`).default(e.default,[[`__scopeId`,`data-v-0e246228`]]);exports.default=t;
@@ -0,0 +1 @@
1
+ let e=require(`vue`);var t=[`maxlength`],n=(0,e.defineComponent)({name:`InputOtp`,__name:`input-otp`,props:{modelValue:{default:``},length:{default:6},itemClass:{default:``},activeItemClass:{default:``},gap:{default:`10px`},hasFilledItemClass:{default:`active`}},emits:[`update:modelValue`,`complete`],setup(n,{emit:r}){let i=[`ArrowLeft`,`ArrowRight`,`Home`,`End`],a=n,o=r,s=(0,e.ref)(null),c=(0,e.ref)(a.modelValue);(0,e.watch)(()=>a.modelValue,e=>{e!==c.value&&(c.value=e)});function l(e){let t=e.target.value;t=t.replace(/\D/g,``),t=t.slice(0,a.length),c.value=t,o(`update:modelValue`,t),t.length===a.length&&o(`complete`,t)}function u(){(0,e.nextTick)(()=>{if(s.value){let e=c.value.length;s.value.setSelectionRange?.(e,e)}})}function d(e){let t=c.value,n=e.key;if(n===`Backspace`||n===`Delete`){if(e.preventDefault(),t.length>0){let e=t.slice(0,-1);c.value=e,o(`update:modelValue`,e),u()}}else i.includes(n)&&e.preventDefault()}function f(){s.value?.focus()}function p(e){return e===c.value.length}function m(e){return e<c.value.length}return(r,i)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:`otp-wrapper`,onClick:f},[(0,e.withDirectives)((0,e.createElementVNode)(`input`,{inputmode:`numeric`,autocomplete:`one-time-code`,ref_key:`inputRef`,ref:s,"onUpdate:modelValue":i[0]||=e=>c.value=e,maxlength:n.length,onInput:l,onKeydown:d,onFocus:u,style:{position:`absolute`,opacity:`0`,"pointer-events":`none`,width:`1px`,height:`1px`}},null,40,t),[[e.vModelText,c.value]]),(0,e.createElementVNode)(`div`,{class:`otp-box`,style:(0,e.normalizeStyle)({gap:a.gap})},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(n.length,(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:n,class:(0,e.normalizeClass)([`otp-item`,[{[a.activeItemClass]:p(n)},{[a.hasFilledItemClass]:m(n)},a.itemClass]])},(0,e.toDisplayString)(c.value[n]||``),3))),128))],4)]))}});exports.default=n;
@@ -0,0 +1 @@
1
+ .otp-wrapper[data-v-0e246228]{cursor:pointer;width:max-content;position:relative}.otp-box[data-v-0e246228]{display:flex}.otp-item[data-v-0e246228]{border-bottom:1px solid #00000029;justify-content:center;align-items:center;width:60px;height:60px;transition:all .2s;display:flex}.otp-item.active[data-v-0e246228]{border-bottom:1px solid #000}
@@ -0,0 +1 @@
1
+ const e=require(`./popup.js`);require(`./style.css.js`),e.default.install=t=>(e.default.name&&t.component(e.default.name,e.default),t);var t=e.default;exports.default=t;
@@ -0,0 +1 @@
1
+ const e=require(`../_virtual/_plugin-vue_export-helper.js`),t=require(`./popup.vue_vue_type_script_setup_true_lang.js`);;/* empty css */var n=e.default(t.default,[[`__scopeId`,`data-v-00d0e4c1`]]);exports.default=n;
@@ -0,0 +1 @@
1
+ let e=require(`vue`);var t=(0,e.defineComponent)({name:`Popup`,__name:`popup`,props:(0,e.mergeModels)({to:{default:`body`},bg:{default:`rgba(0, 0, 0, .5)`},duration:{default:300},position:{default:`bottom`},maskClosable:{type:Boolean,default:!0}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(t){let n=[`bottom`,`left`,`right`,`top`],r=(0,e.useModel)(t,`modelValue`),i=t;function a(){i.maskClosable&&(r.value=!1)}return(t,o)=>((0,e.openBlock)(),(0,e.createBlock)(e.Teleport,{to:i.to},[(0,e.createVNode)(e.Transition,{name:`fade`},{default:(0,e.withCtx)(()=>[r.value?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,style:(0,e.normalizeStyle)({"background-color":i.bg,"--duration":`${i.duration}ms`}),class:(0,e.normalizeClass)([`popup-container`,[`popup-container-${i.position}`,{"popup-container-bottom":!n.includes(i.position)}]]),onClick:a},[(0,e.createElementVNode)(`div`,{class:`popup-content`,onClick:o[0]||=(0,e.withModifiers)(()=>{},[`stop`])},[(0,e.renderSlot)(t.$slots,`default`,{},void 0,!0)])],6)):(0,e.createCommentVNode)(``,!0)]),_:3})],8,[`to`]))}});exports.default=t;