@cypress-design/vue-checkbox 0.4.6 → 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.
- package/.turbo/turbo-build.log +14 -0
- package/CHANGELOG.md +94 -0
- package/Checkbox.vue +40 -22
- package/CheckboxVue.cy.tsx +61 -6
- package/ReadMe.md +19 -0
- package/dist/Checkbox.vue.d.ts +59 -170
- package/dist/Checkbox.vue.d.ts.map +1 -1
- package/dist/index.es.mjs +68 -78
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -4
- package/tsconfig.build.json +3 -2
- package/Checkbox.stories.mdx +0 -75
- package/tsconfig.json +0 -4
package/dist/index.es.mjs
CHANGED
|
@@ -1,102 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, j = (o) => {
|
|
22
|
-
const { sizeWithDefault: t, compiledClasses: e } = w.getComponentAttributes({ ...o, availableSizes: ["16"] }), l = {
|
|
23
|
-
16: '<path d="M5 8.5 7.5 11 11 5" stroke="currentColor" class="icon-dark" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'
|
|
24
|
-
}[t];
|
|
25
|
-
if (!l)
|
|
26
|
-
throw Error(`Icon "checkmark-small" is not available in size ${t}`);
|
|
27
|
-
return k("svg", S({
|
|
28
|
-
...o,
|
|
29
|
-
size: t,
|
|
30
|
-
body: l,
|
|
31
|
-
compiledClasses: e
|
|
32
|
-
}));
|
|
33
|
-
}, z = { class: "block relative flex items-center" }, O = ["id", "name", "disabled", "checked"], V = ["for"];
|
|
34
|
-
function N() {
|
|
35
|
-
return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
|
|
1
|
+
import { defineComponent as f, ref as k, computed as y, openBlock as s, createElementBlock as u, createElementVNode as i, normalizeClass as t, unref as o, createBlock as x, createCommentVNode as m, renderSlot as C, toDisplayString as v } from "vue";
|
|
2
|
+
import { IconCheckmarkSmall as V } from "@cypress-design/vue-icon";
|
|
3
|
+
const r = {
|
|
4
|
+
wrapper: "relative flex items-center",
|
|
5
|
+
hiddenInput: "absolute inset-0 w-0 h-0 opacity-0",
|
|
6
|
+
labelTag: "flex items-center",
|
|
7
|
+
visibleCheckbox: "border border-solid rounded h-[16px] w-[16px] flex flex-shrink-0 items-center text-white",
|
|
8
|
+
trueLabel: "block ml-[8px] text-[16px] leading-[24px] font-light select-none"
|
|
9
|
+
}, c = {
|
|
10
|
+
indigo: "border-indigo-500 bg-indigo-400",
|
|
11
|
+
jade: "border-jade-500 bg-jade-400",
|
|
12
|
+
red: "border-red-500 bg-red-400",
|
|
13
|
+
disabled: "border-gray-200 bg-gray-100",
|
|
14
|
+
empty: "border-gray-200 bg-white"
|
|
15
|
+
}, w = { class: "relative flex items-center" }, B = ["id", "name", "disabled", "checked"], S = ["for"];
|
|
16
|
+
function A() {
|
|
17
|
+
return String(Date.now().toString(32) + Math.random().toString(16)).replace(
|
|
18
|
+
/\./g,
|
|
19
|
+
""
|
|
20
|
+
);
|
|
36
21
|
}
|
|
37
|
-
const
|
|
22
|
+
const I = /* @__PURE__ */ f({
|
|
38
23
|
__name: "Checkbox",
|
|
39
24
|
props: {
|
|
40
|
-
id: { default: () =>
|
|
41
|
-
name:
|
|
25
|
+
id: { default: () => A() },
|
|
26
|
+
name: {},
|
|
42
27
|
checked: { type: Boolean },
|
|
43
28
|
color: { default: "indigo" },
|
|
44
29
|
disabled: { type: Boolean },
|
|
45
|
-
modelValue: { type: Boolean },
|
|
46
|
-
label:
|
|
30
|
+
modelValue: { type: [Boolean, Array] },
|
|
31
|
+
label: {}
|
|
47
32
|
},
|
|
48
|
-
emits: ["update:modelValue"],
|
|
49
|
-
setup(
|
|
50
|
-
const e =
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
emits: ["update:modelValue", "change"],
|
|
34
|
+
setup(b, { emit: p }) {
|
|
35
|
+
const e = b, l = k(
|
|
36
|
+
(Array.isArray(e.modelValue) ? e.name ? e.modelValue.includes(e.name) : !1 : e.modelValue) || e.checked
|
|
37
|
+
), d = p;
|
|
38
|
+
function h() {
|
|
39
|
+
if (l.value = !l.value, Array.isArray(e.modelValue)) {
|
|
40
|
+
const a = [...e.modelValue];
|
|
41
|
+
if (!e.name)
|
|
42
|
+
return;
|
|
43
|
+
const n = a.indexOf(e.name);
|
|
44
|
+
n === -1 ? a.push(e.name) : a.splice(n, 1), d("update:modelValue", a);
|
|
45
|
+
} else
|
|
46
|
+
d("update:modelValue", l.value);
|
|
47
|
+
d("change", l.value);
|
|
53
48
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return (n, r) => (i(), b("span", z, [
|
|
63
|
-
d("input", {
|
|
64
|
-
id: o.id,
|
|
65
|
-
class: "absolute inset-0 w-0 h-0 opacity-0",
|
|
66
|
-
name: o.name || o.id,
|
|
49
|
+
const g = y(
|
|
50
|
+
() => e.disabled ? c.disabled : l.value ? c[e.color] : c.empty
|
|
51
|
+
);
|
|
52
|
+
return (a, n) => (s(), u("span", w, [
|
|
53
|
+
i("input", {
|
|
54
|
+
id: a.id,
|
|
55
|
+
class: t(o(r).hiddenInput),
|
|
56
|
+
name: a.name || a.id,
|
|
67
57
|
type: "checkbox",
|
|
68
|
-
onChange: c,
|
|
69
58
|
disabled: e.disabled,
|
|
70
|
-
checked: l.value
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
checked: l.value,
|
|
60
|
+
onChange: h
|
|
61
|
+
}, null, 42, B),
|
|
62
|
+
i("label", {
|
|
63
|
+
class: t(o(r).labelTag),
|
|
64
|
+
for: a.id
|
|
75
65
|
}, [
|
|
76
|
-
l.value ? (
|
|
66
|
+
l.value ? (s(), x(o(V), {
|
|
77
67
|
key: 0,
|
|
78
68
|
strokeColor: "white",
|
|
79
69
|
class: "absolute"
|
|
80
|
-
})) :
|
|
81
|
-
|
|
82
|
-
class: g(
|
|
70
|
+
})) : m("", !0),
|
|
71
|
+
i("span", {
|
|
72
|
+
class: t([g.value, o(r).visibleCheckbox])
|
|
83
73
|
}, null, 2),
|
|
84
|
-
C(
|
|
85
|
-
|
|
74
|
+
C(a.$slots, "label", {}, () => [
|
|
75
|
+
a.label ? (s(), u("span", {
|
|
86
76
|
key: 0,
|
|
87
|
-
class:
|
|
88
|
-
|
|
89
|
-
|
|
77
|
+
class: t([
|
|
78
|
+
o(r).trueLabel,
|
|
79
|
+
a.disabled ? "text-gray-500" : "text-gray-800"
|
|
90
80
|
])
|
|
91
|
-
}, v(
|
|
81
|
+
}, v(a.label), 3)) : m("", !0)
|
|
92
82
|
])
|
|
93
|
-
],
|
|
83
|
+
], 10, S)
|
|
94
84
|
]));
|
|
95
85
|
}
|
|
96
86
|
});
|
|
97
87
|
export {
|
|
98
|
-
|
|
88
|
+
I as default
|
|
99
89
|
};
|
|
100
|
-
|
|
101
|
-
/* <windicss-keep class="block border-1 border-solid rounded h-16px w-16px flex-shrink-0 border-gray-200 bg-gray-100 border-indigo-500 bg-indigo-400 border-jade-500 bg-jade-400 border-red-500 bg-red-400 bg-white relative flex items-center absolute inset-0 w-0 h-0 opacity-0 ml-8px text-16px leading-24px font-light select-none text-gray-500 text-gray-800 icon-dark-white"> */
|
|
102
90
|
//# sourceMappingURL=index.es.mjs.map
|
|
91
|
+
|
|
92
|
+
/* <wind-keep class="relative flex items-center absolute text-gray-500 text-gray-800 icon-dark-white inset-0 w-0 h-0 opacity-0 border border-solid rounded h-[16px] w-[16px] flex-shrink-0 text-white block ml-[8px] text-[16px] leading-[24px] font-light select-none border-indigo-500 bg-indigo-400 border-jade-500 bg-jade-400 border-red-500 bg-red-400 border-gray-200 bg-gray-100 bg-white"> */
|