adverich-kun-ui 0.1.37 → 0.1.38

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,157 @@
1
+ import { computed as b, createElementBlock as o, openBlock as n, normalizeClass as r, createCommentVNode as d, createElementVNode as c, toDisplayString as h, withKeys as m, withModifiers as f, renderSlot as u, mergeProps as w } from "vue";
2
+ const k = {
3
+ key: 0,
4
+ class: "flex flex-col items-center gap-1 cursor-pointer"
5
+ }, C = {
6
+ key: 0,
7
+ class: "text-sm text-gray-900"
8
+ }, S = ["aria-checked", "aria-disabled", "onKeydown"], V = {
9
+ key: 1,
10
+ class: "text-sm text-gray-900"
11
+ }, B = ["aria-checked", "aria-disabled", "onKeydown"], P = {
12
+ key: 0,
13
+ class: "text-sm text-gray-900"
14
+ }, z = {
15
+ __name: "KunSwitch",
16
+ props: {
17
+ modelValue: { type: [Boolean, String, Number], default: !1 },
18
+ trueValue: { type: [Boolean, String, Number], default: !0 },
19
+ falseValue: { type: [Boolean, String, Number], default: !1 },
20
+ label: String,
21
+ labelPosition: { type: String, default: "right" },
22
+ // 'top', 'bottom', 'left', 'right'
23
+ disabled: Boolean,
24
+ onColor: { type: String, default: "bg-green-600" },
25
+ offColor: { type: String, default: "bg-gray-300" },
26
+ iconColor: { type: String, default: "bg-white" },
27
+ inset: Boolean,
28
+ hideDetails: { type: Boolean, default: !1 },
29
+ size: {
30
+ type: String,
31
+ default: "md",
32
+ validator: (e) => ["xxs", "xs", "sm", "md", "lg", "xl", "xxl"].includes(e)
33
+ }
34
+ },
35
+ emits: ["update:modelValue"],
36
+ setup(e, { emit: v }) {
37
+ const l = e, y = v, t = b(() => l.modelValue === l.trueValue), s = () => {
38
+ l.disabled || y(
39
+ "update:modelValue",
40
+ t.value ? l.falseValue : l.trueValue
41
+ );
42
+ }, g = b(
43
+ () => l.labelPosition === "top" || l.labelPosition === "bottom"
44
+ ), x = {
45
+ xxs: {
46
+ outer: "w-6 h-3",
47
+ thumb: "w-3 h-3",
48
+ icon: "text-[10px]",
49
+ translate: "translate-x-3"
50
+ },
51
+ xs: {
52
+ outer: "w-8 h-4",
53
+ thumb: "w-4 h-4",
54
+ icon: "text-xs",
55
+ translate: "translate-x-4"
56
+ },
57
+ sm: {
58
+ outer: "w-9 h-5",
59
+ thumb: "w-4 h-4",
60
+ icon: "text-sm",
61
+ translate: "translate-x-4.5"
62
+ },
63
+ md: {
64
+ outer: "w-10 h-6",
65
+ thumb: "w-6 h-6",
66
+ icon: "text-base",
67
+ translate: "translate-x-4.25"
68
+ },
69
+ lg: {
70
+ outer: "w-12 h-7",
71
+ thumb: "w-7 h-7",
72
+ icon: "text-lg",
73
+ translate: "translate-x-5"
74
+ },
75
+ xl: {
76
+ outer: "w-14 h-8",
77
+ thumb: "w-8 h-8",
78
+ icon: "text-xl",
79
+ translate: "translate-x-6"
80
+ },
81
+ xxl: {
82
+ outer: "w-16 h-9",
83
+ thumb: "w-9 h-9",
84
+ icon: "text-2xl",
85
+ translate: "translate-x-7"
86
+ }
87
+ }, a = b(() => x[l.size] || x.md);
88
+ return (i, K) => (n(), o("div", {
89
+ class: r(["select-none", { "opacity-50 cursor-not-allowed": e.disabled, "pl-6": e.inset }])
90
+ }, [
91
+ g.value ? (n(), o("label", k, [
92
+ e.label && e.labelPosition === "top" ? (n(), o("span", C, h(e.label), 1)) : d("", !0),
93
+ c("div", {
94
+ class: r(["relative rounded-full transition-colors duration-200 cursor-pointer", [a.value.outer, t.value ? e.onColor : e.offColor]]),
95
+ role: "switch",
96
+ "aria-checked": t.value,
97
+ "aria-disabled": e.disabled,
98
+ tabindex: "0",
99
+ onClick: s,
100
+ onKeydown: [
101
+ m(f(s, ["prevent"]), ["space"]),
102
+ m(f(s, ["prevent"]), ["enter"])
103
+ ]
104
+ }, [
105
+ c("div", {
106
+ class: r(["absolute top-0 left-0 rounded-full shadow-md transform transition-transform duration-200 flex items-center justify-center", [
107
+ e.iconColor,
108
+ a.value.thumb,
109
+ a.value.icon,
110
+ t.value ? a.value.translate : "translate-x-0"
111
+ ]])
112
+ }, [
113
+ t.value ? u(i.$slots, "on-icon", { key: 0 }) : u(i.$slots, "off-icon", { key: 1 })
114
+ ], 2)
115
+ ], 42, S),
116
+ e.label && e.labelPosition === "bottom" ? (n(), o("span", V, h(e.label), 1)) : d("", !0)
117
+ ])) : (n(), o("label", {
118
+ key: 1,
119
+ class: r(["flex items-center gap-3 cursor-pointer", { "flex-row-reverse": e.labelPosition === "left" }])
120
+ }, [
121
+ c("div", {
122
+ class: r(["relative rounded-full transition-colors duration-200", [a.value.outer, t.value ? e.onColor : e.offColor]]),
123
+ role: "switch",
124
+ "aria-checked": t.value,
125
+ "aria-disabled": e.disabled,
126
+ tabindex: "0",
127
+ onClick: s,
128
+ onKeydown: [
129
+ m(f(s, ["prevent"]), ["space"]),
130
+ m(f(s, ["prevent"]), ["enter"])
131
+ ]
132
+ }, [
133
+ c("div", {
134
+ class: r(["absolute top-0 left-0 rounded-full shadow-md transform transition-transform duration-200 flex items-center justify-center", [
135
+ e.iconColor,
136
+ a.value.thumb,
137
+ a.value.icon,
138
+ t.value ? a.value.translate : "translate-x-0"
139
+ ]])
140
+ }, [
141
+ t.value ? u(i.$slots, "on-icon", { key: 0 }) : u(i.$slots, "off-icon", { key: 1 })
142
+ ], 2)
143
+ ], 42, B),
144
+ e.label ? (n(), o("div", P, h(e.label), 1)) : d("", !0)
145
+ ], 2)),
146
+ e.hideDetails ? d("", !0) : (n(), o("div", w({
147
+ key: 2,
148
+ class: "text-xs text-gray-500 mt-1 ml-14"
149
+ }, i.$attrs), [
150
+ u(i.$slots, "details")
151
+ ], 16))
152
+ ], 2));
153
+ }
154
+ };
155
+ export {
156
+ z as default
157
+ };
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  import m from "./components/KunAlert/src/components/KunAlert.vue.js";
3
3
  import t from "./components/KunAppbar/src/components/KunAppbar.vue.js";
4
4
  import i from "./components/KunAppbarTitle/src/components/KunAppbarTitle.vue.js";
5
- import p from "./components/KunAutocomplete/src/components/KunAutocomplete.vue.js";
6
- import a from "./components/KunBtn/src/components/KunBtn.vue.js";
5
+ import a from "./components/KunAutocomplete/src/components/KunAutocomplete.vue.js";
6
+ import p from "./components/KunBtn/src/components/KunBtn.vue.js";
7
7
  import u from "./components/KunBudge/src/components/KunBudge.vue.js";
8
8
  import f from "./components/KunCard/src/components/KunCard.vue.js";
9
9
  import K from "./components/KunCardText/src/components/KunCardText.vue.js";
@@ -11,14 +11,15 @@ import s from "./components/KunCurrency/src/components/KunCurrency.vue.js";
11
11
  import c from "./components/KunIcon/src/components/KunIcon.vue.js";
12
12
  import e from "./components/KunList/src/components/KunList.vue.js";
13
13
  import _ from "./components/KunSpacer/src/components/KunSpacer.vue.js";
14
- import l from "./components/KunTextField/src/components/KunTextField.vue.js";
14
+ import l from "./components/KunSwitch/src/components/KunSwitch.vue.js";
15
+ import $ from "./components/KunTextField/src/components/KunTextField.vue.js";
15
16
  import A from "./components/KunToolbar/src/components/KunToolbar.vue.js";
16
17
  const o = {
17
18
  KunAlert: m,
18
19
  KunAppbar: t,
19
20
  KunAppbarTitle: i,
20
- KunAutocomplete: p,
21
- KunBtn: a,
21
+ KunAutocomplete: a,
22
+ KunBtn: p,
22
23
  KunBudge: u,
23
24
  KunCard: f,
24
25
  KunCardText: K,
@@ -26,10 +27,11 @@ const o = {
26
27
  KunIcon: c,
27
28
  KunList: e,
28
29
  KunSpacer: _,
29
- KunTextField: l,
30
+ KunSwitch: l,
31
+ KunTextField: $,
30
32
  KunToolbar: A
31
33
  };
32
- function k(r) {
34
+ function q(r) {
33
35
  for (const n in o)
34
36
  r.component(n, o[n]);
35
37
  }
@@ -37,8 +39,8 @@ export {
37
39
  m as KunAlert,
38
40
  t as KunAppbar,
39
41
  i as KunAppbarTitle,
40
- p as KunAutocomplete,
41
- a as KunBtn,
42
+ a as KunAutocomplete,
43
+ p as KunBtn,
42
44
  u as KunBudge,
43
45
  f as KunCard,
44
46
  K as KunCardText,
@@ -46,7 +48,8 @@ export {
46
48
  c as KunIcon,
47
49
  e as KunList,
48
50
  _ as KunSpacer,
49
- l as KunTextField,
51
+ l as KunSwitch,
52
+ $ as KunTextField,
50
53
  A as KunToolbar,
51
- k as install
54
+ q as install
52
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",