adverich-kun-ui 0.1.108 → 0.1.109

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.
@@ -1,8 +1,8 @@
1
- import { createElementBlock as o, openBlock as l, normalizeStyle as m, normalizeClass as s, createCommentVNode as c, toDisplayString as b } from "vue";
2
- const d = ["aria-valuemin", "aria-valuemax", "aria-valuenow"], p = {
1
+ import { createElementBlock as n, openBlock as o, normalizeStyle as s, normalizeClass as c, createCommentVNode as d, toDisplayString as b } from "vue";
2
+ const y = ["aria-valuemin", "aria-valuemax", "aria-valuenow"], h = {
3
3
  key: 0,
4
4
  class: "absolute -top-10 left-1/2 -translate-x-1/2 bg-gray-200/40 dark:bg-gray-800/40 text-black dark:text-white text-xs px-3 py-2 rounded-full whitespace-nowrap select-none"
5
- }, y = {
5
+ }, f = {
6
6
  __name: "KunThumb",
7
7
  props: {
8
8
  value: Number,
@@ -12,34 +12,44 @@ const d = ["aria-valuemin", "aria-valuemax", "aria-valuenow"], p = {
12
12
  type: String,
13
13
  default: "bg-blue-500"
14
14
  },
15
- min: Number,
16
- max: Number
15
+ min: {
16
+ type: Number,
17
+ default: 0
18
+ },
19
+ max: {
20
+ type: Number,
21
+ default: 100
22
+ },
23
+ step: {
24
+ type: Number,
25
+ default: 1
26
+ }
17
27
  },
18
28
  emits: ["update"],
19
- setup(e, { emit: r }) {
20
- const n = r;
21
- function u(t) {
22
- let a = 0;
23
- if (t.key === "ArrowRight" || t.key === "ArrowUp") a = props.step;
24
- else if (t.key === "ArrowLeft" || t.key === "ArrowDown") a = -props.step;
29
+ setup(e, { emit: u }) {
30
+ const t = e, r = u;
31
+ function i(a) {
32
+ let l = 0;
33
+ if (a.key === "ArrowRight" || a.key === "ArrowUp") l = t.step;
34
+ else if (a.key === "ArrowLeft" || a.key === "ArrowDown") l = -t.step;
25
35
  else return;
26
- const i = Math.min(props.max, Math.max(props.min, props.value + a));
27
- n("update", i);
36
+ const m = Math.min(t.max, Math.max(t.min, t.value + l));
37
+ r("update", m);
28
38
  }
29
- return (t, a) => (l(), o("div", {
30
- class: s(["absolute z-40 -top-1 w-4 h-4 rounded-full cursor-pointer touch-none", [e.thumbColor]]),
31
- style: m([e.thumbStyle]),
39
+ return (a, l) => (o(), n("div", {
40
+ class: c(["absolute z-40 -top-1 w-4 h-4 rounded-full cursor-pointer touch-none", [e.thumbColor]]),
41
+ style: s([e.thumbStyle]),
32
42
  role: "slider",
33
43
  tabindex: "0",
34
44
  "aria-valuemin": e.min,
35
45
  "aria-valuemax": e.max,
36
46
  "aria-valuenow": e.value,
37
- onKeydown: u
47
+ onKeydown: i
38
48
  }, [
39
- e.thumbLabel ? (l(), o("div", p, b(e.value), 1)) : c("", !0)
40
- ], 46, d));
49
+ e.thumbLabel ? (o(), n("div", h, b(e.value), 1)) : d("", !0)
50
+ ], 46, y));
41
51
  }
42
52
  };
43
53
  export {
44
- y as default
54
+ f as default
45
55
  };
@@ -1,31 +1,46 @@
1
- import { computed as c } from "vue";
2
- function v(e, m, b) {
3
- const u = c({
1
+ import { computed as u, watch as x } from "vue";
2
+ function g(e, l, V) {
3
+ const m = u({
4
4
  get: () => e.range ? [...e.modelValue] : Number(e.modelValue),
5
- set: (t) => m("update:modelValue", e.range ? t : t[0])
6
- }), r = c(() => {
7
- const t = Number(e.min), a = Number(e.max), n = Number(e.step);
8
- return n > 0 ? Math.floor((a - t) / n) + 1 : 0;
9
- }), l = (t) => {
10
- const a = Number(e.min), n = Number(e.max);
11
- return (t - a) / (n - a) * 97;
12
- }, o = c(() => (e.range ? u.value : [u.value]).map((a) => ({
13
- [e.vertical ? "bottom" : "left"]: `${l(a)}%`
14
- }))), i = c(() => {
15
- const t = e.range ? u.value : [u.value], a = `${l(Math.min(...t))}%`, n = `${l(Math.max(...t))}%`;
16
- return e.vertical ? { bottom: a, top: `calc(100% - ${n})` } : { left: a, right: `calc(100% - ${n})` };
5
+ set: (t) => l("update:modelValue", e.range ? t : t[0])
17
6
  });
18
- function s(t) {
19
- m("update:modelValue", t);
7
+ x(
8
+ () => [e.min, e.max, e.modelValue],
9
+ () => {
10
+ const t = Number(e.min), n = Number(e.max);
11
+ if (e.range) {
12
+ const a = e.modelValue.map((f) => Math.min(n, Math.max(t, f)));
13
+ JSON.stringify(a) !== JSON.stringify(e.modelValue) && l("update:modelValue", a);
14
+ } else {
15
+ const a = Math.min(n, Math.max(t, e.modelValue));
16
+ a !== e.modelValue && l("update:modelValue", a);
17
+ }
18
+ },
19
+ { immediate: !0 }
20
+ );
21
+ const i = u(() => {
22
+ const t = Number(e.min), n = Number(e.max), a = Number(e.step);
23
+ return a > 0 ? Math.floor((n - t) / a) + 1 : 0;
24
+ }), c = (t) => {
25
+ const n = Number(e.min), a = Number(e.max);
26
+ return (t - n) / (a - n) * 97;
27
+ }, o = u(() => (e.range ? m.value : [m.value]).map((n) => ({
28
+ [e.vertical ? "bottom" : "left"]: `${c(n)}%`
29
+ }))), d = u(() => {
30
+ const t = e.range ? m.value : [m.value], n = `${c(Math.min(...t))}%`, a = `${c(Math.max(...t))}%`;
31
+ return e.vertical ? { bottom: n, top: `calc(100% - ${a})` } : { left: n, right: `calc(100% - ${a})` };
32
+ });
33
+ function r(t) {
34
+ l("update:modelValue", t);
20
35
  }
21
36
  return {
22
- val: u,
23
- updateValue: s,
37
+ val: m,
38
+ updateValue: r,
24
39
  thumbStyles: o,
25
- trackFillStyle: i,
26
- tickCount: r
40
+ trackFillStyle: d,
41
+ tickCount: i
27
42
  };
28
43
  }
29
44
  export {
30
- v as useSlider
45
+ g as useSlider
31
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",