@kiva/kv-components 6.37.0 → 6.38.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.
- package/dist/vue/KvCheckbox.css +1 -0
- package/dist/vue/KvCheckbox.js +100 -55
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[data-v-9958a4b0] .check-icon svg{transform:scale(1.2)}
|
package/dist/vue/KvCheckbox.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { nanoid as
|
|
2
|
-
import { toRefs as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { nanoid as k } from "nanoid";
|
|
2
|
+
import { toRefs as L, ref as v, watch as M, onMounted as I, resolveComponent as K, openBlock as r, createElementBlock as s, normalizeClass as c, normalizeStyle as S, createElementVNode as d, mergeProps as q, toHandlers as R, withModifiers as j, createCommentVNode as b, createBlock as z, renderSlot as D } from "vue";
|
|
3
|
+
import { mdiCheckCircle as E } from "@mdi/js";
|
|
4
|
+
import N from "./KvMaterialIcon.js";
|
|
5
|
+
import { useAttrs as O } from "../utils/attrs.js";
|
|
6
|
+
import "./KvCheckbox.css";
|
|
7
|
+
import H from "../_virtual/_plugin-vue_export-helper.js";
|
|
8
|
+
const C = [
|
|
6
9
|
"change",
|
|
7
10
|
"update:modelValue"
|
|
8
11
|
], P = {
|
|
12
|
+
components: {
|
|
13
|
+
KvMaterialIcon: N
|
|
14
|
+
},
|
|
9
15
|
inheritAttrs: !1,
|
|
10
16
|
model: {
|
|
11
17
|
prop: "modelValue",
|
|
@@ -40,62 +46,77 @@ const k = [
|
|
|
40
46
|
valid: {
|
|
41
47
|
type: Boolean,
|
|
42
48
|
default: !0
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Variant of the checkbox: 'square' (default) or 'round'
|
|
52
|
+
*/
|
|
53
|
+
variant: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "square",
|
|
56
|
+
validator: (i) => ["square", "round"].includes(i)
|
|
57
|
+
},
|
|
58
|
+
blurOnDisabled: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: !0
|
|
43
61
|
}
|
|
44
62
|
},
|
|
45
|
-
emits:
|
|
63
|
+
emits: C,
|
|
46
64
|
setup(i, l) {
|
|
47
65
|
const {
|
|
48
66
|
modelValue: t,
|
|
49
67
|
value: e
|
|
50
|
-
} =
|
|
51
|
-
classes:
|
|
52
|
-
styles:
|
|
53
|
-
inputAttrs:
|
|
54
|
-
inputListeners:
|
|
55
|
-
} =
|
|
56
|
-
const
|
|
57
|
-
let
|
|
58
|
-
Array.isArray(t.value) ?
|
|
59
|
-
},
|
|
60
|
-
Array.isArray(t.value) ?
|
|
61
|
-
}, _ = () => {
|
|
62
|
-
d.focus();
|
|
68
|
+
} = L(i), { emit: u } = l, w = v(`kvc-${k(10)}`), a = v(!1), o = v(null), {
|
|
69
|
+
classes: g,
|
|
70
|
+
styles: y,
|
|
71
|
+
inputAttrs: x,
|
|
72
|
+
inputListeners: _
|
|
73
|
+
} = O(l, C), p = (h) => {
|
|
74
|
+
const m = h.target.checked;
|
|
75
|
+
let n;
|
|
76
|
+
Array.isArray(t.value) ? m ? n = [...t.value, h.target.value] : n = t.value.filter((V) => V !== e.value) : n = m, u("change", n), u("update:modelValue", n);
|
|
77
|
+
}, f = () => {
|
|
78
|
+
Array.isArray(t.value) ? a.value = t.value.includes(e.value) : a.value = t.value;
|
|
63
79
|
}, A = () => {
|
|
64
|
-
|
|
80
|
+
o.focus();
|
|
81
|
+
}, B = () => {
|
|
82
|
+
o.blur();
|
|
65
83
|
};
|
|
66
|
-
return
|
|
67
|
-
|
|
84
|
+
return f(), M(t, () => f()), I(() => {
|
|
85
|
+
w.value = `kvc-${k(10)}`;
|
|
68
86
|
}), {
|
|
69
|
-
uuid:
|
|
70
|
-
isChecked:
|
|
71
|
-
checkboxRef:
|
|
72
|
-
onChange:
|
|
73
|
-
setChecked:
|
|
74
|
-
focus:
|
|
75
|
-
blur:
|
|
76
|
-
classes:
|
|
77
|
-
styles:
|
|
78
|
-
inputAttrs:
|
|
79
|
-
inputListeners:
|
|
87
|
+
uuid: w,
|
|
88
|
+
isChecked: a,
|
|
89
|
+
checkboxRef: o,
|
|
90
|
+
onChange: p,
|
|
91
|
+
setChecked: f,
|
|
92
|
+
focus: A,
|
|
93
|
+
blur: B,
|
|
94
|
+
classes: g,
|
|
95
|
+
styles: y,
|
|
96
|
+
inputAttrs: x,
|
|
97
|
+
inputListeners: _,
|
|
98
|
+
iconCheckCircle: E
|
|
99
|
+
// <-- just return the value
|
|
80
100
|
};
|
|
81
101
|
}
|
|
82
|
-
}, Z = ["for"],
|
|
102
|
+
}, Z = ["for"], F = ["id", "checked", "value", "disabled"], G = {
|
|
83
103
|
key: 0,
|
|
84
104
|
class: "tw-w-1.5 tw-h-auto",
|
|
85
105
|
viewBox: "0 0 12 9",
|
|
86
106
|
fill: "none",
|
|
87
107
|
xmlns: "http://www.w3.org/2000/svg"
|
|
88
|
-
},
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
}, J = { class: "tw-flex-1 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action" };
|
|
109
|
+
function Q(i, l, t, e, u, w) {
|
|
110
|
+
const a = K("KvMaterialIcon");
|
|
111
|
+
return r(), s("div", {
|
|
112
|
+
class: c(e.classes),
|
|
113
|
+
style: S(e.styles)
|
|
93
114
|
}, [
|
|
94
|
-
|
|
95
|
-
class:
|
|
115
|
+
d("label", {
|
|
116
|
+
class: c(["tw-inline-flex tw-items-center", { "tw-opacity-low": t.disabled && t.blurOnDisabled }]),
|
|
96
117
|
for: e.uuid
|
|
97
118
|
}, [
|
|
98
|
-
|
|
119
|
+
d("input", q(e.inputAttrs, {
|
|
99
120
|
id: e.uuid,
|
|
100
121
|
ref: "checkboxRef",
|
|
101
122
|
class: "tw-peer tw-appearance-none tw-w-max",
|
|
@@ -103,11 +124,12 @@ function G(i, l, t, e, n, r) {
|
|
|
103
124
|
checked: e.isChecked,
|
|
104
125
|
value: t.value,
|
|
105
126
|
disabled: t.disabled
|
|
106
|
-
},
|
|
107
|
-
onChange: l[0] || (l[0] =
|
|
108
|
-
}), null, 16,
|
|
109
|
-
s("div", {
|
|
110
|
-
|
|
127
|
+
}, R(e.inputListeners, !0), {
|
|
128
|
+
onChange: l[0] || (l[0] = j((...o) => e.onChange && e.onChange(...o), ["prevent"]))
|
|
129
|
+
}), null, 16, F),
|
|
130
|
+
t.variant === "square" ? (r(), s("div", {
|
|
131
|
+
key: 0,
|
|
132
|
+
class: c(["tw-w-3 tw-h-3 tw-mr-2 tw-flex-shrink-0 tw-rounded-sm tw-border tw-flex tw-justify-center tw-items-center tw-overflow-hidden tw-transition-all tw-duration-100 peer-focus-visible:tw-ring-2 peer-focus-visible:tw-ring-action", {
|
|
111
133
|
"tw-bg-white": !e.isChecked,
|
|
112
134
|
"tw-bg-action": e.isChecked,
|
|
113
135
|
"tw-border-secondary": !e.isChecked && t.valid,
|
|
@@ -115,20 +137,43 @@ function G(i, l, t, e, n, r) {
|
|
|
115
137
|
"tw-border-danger": !t.valid
|
|
116
138
|
}])
|
|
117
139
|
}, [
|
|
118
|
-
e.isChecked ? (
|
|
119
|
-
|
|
140
|
+
e.isChecked ? (r(), s("svg", G, l[1] || (l[1] = [
|
|
141
|
+
d("path", {
|
|
120
142
|
d: "M3.99975 6.79988L1.66642 4.46655C1.40642 4.20655 0.993086 4.20655 0.733086 4.46655C0.473086 4.72655 0.473086 5.13988 0.733086 5.39988L3.52642 8.19322C3.78642 8.45322 4.20642 8.45322 4.46642 8.19322L11.5331 1.13322C11.7931 0.873216 11.7931 0.459883 11.5331 0.199883C11.2731 -0.0601172 10.8598 -0.0601172 10.5998 0.199883L3.99975 6.79988Z",
|
|
121
143
|
fill: "white"
|
|
122
144
|
}, null, -1)
|
|
123
|
-
]))) :
|
|
124
|
-
], 2),
|
|
125
|
-
|
|
126
|
-
|
|
145
|
+
]))) : b("", !0)
|
|
146
|
+
], 2)) : (r(), s("div", {
|
|
147
|
+
key: 1,
|
|
148
|
+
class: c([
|
|
149
|
+
"tw-w-3 tw-h-3 tw-mr-2",
|
|
150
|
+
"tw-flex-shrink-0",
|
|
151
|
+
"tw-rounded-full",
|
|
152
|
+
"tw-flex tw-justify-center tw-items-center",
|
|
153
|
+
"tw-overflow-hidden",
|
|
154
|
+
"tw-transition-all tw-duration-100",
|
|
155
|
+
"peer-focus-visible:tw-ring-2",
|
|
156
|
+
"peer-focus-visible:tw-ring-action",
|
|
157
|
+
e.isChecked ? "tw-text-brand-550 tw-bg-white" : "tw-bg-gray-200",
|
|
158
|
+
// Only show border if checked or invalid
|
|
159
|
+
!e.isChecked && !t.valid ? "tw-border-danger" : "",
|
|
160
|
+
e.isChecked && t.valid ? "tw-border-action" : "",
|
|
161
|
+
(!e.isChecked && t.valid, "")
|
|
162
|
+
])
|
|
163
|
+
}, [
|
|
164
|
+
e.isChecked ? (r(), z(a, {
|
|
165
|
+
key: 0,
|
|
166
|
+
icon: e.iconCheckCircle,
|
|
167
|
+
class: "check-icon"
|
|
168
|
+
}, null, 8, ["icon"])) : b("", !0)
|
|
169
|
+
], 2)),
|
|
170
|
+
d("div", J, [
|
|
171
|
+
D(i.$slots, "default", {}, void 0, !0)
|
|
127
172
|
])
|
|
128
173
|
], 10, Z)
|
|
129
174
|
], 6);
|
|
130
175
|
}
|
|
131
|
-
const
|
|
176
|
+
const te = /* @__PURE__ */ H(P, [["render", Q], ["__scopeId", "data-v-9958a4b0"]]);
|
|
132
177
|
export {
|
|
133
|
-
|
|
178
|
+
te as default
|
|
134
179
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiva/kv-components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.38.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"embla-carousel-fade",
|
|
112
112
|
"popper.js"
|
|
113
113
|
],
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "664b7df4d6a1ac8608eefcbf5e3b2387ea84052b"
|
|
115
115
|
}
|