@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/dist/index.es.mjs CHANGED
@@ -1,102 +1,92 @@
1
- import { h as k, defineComponent as p, ref as f, computed as x, openBlock as i, createElementBlock as b, createElementVNode as d, createBlock as y, unref as m, createCommentVNode as h, normalizeClass as g, renderSlot as C, toDisplayString as v } from "vue";
2
- import * as w from "@cypress-design/icon-registry";
3
- import { ICON_COLOR_PROP_NAMES as B } from "@cypress-design/icon-registry";
4
- const S = ({
5
- body: o,
6
- compiledClasses: t,
7
- size: e,
8
- class: l,
9
- interactiveColorsOnGroup: c,
10
- ...a
11
- }) => {
12
- const n = Object.keys(a).reduce((u, s) => (B.includes(s) || (u[s] = a[s]), u), {}), r = {
13
- width: e,
14
- height: e,
15
- viewBox: `0 0 ${e} ${e}`,
16
- fill: "none",
17
- innerHTML: o,
18
- ...n
19
- };
20
- return t.length && (r.class = t.join(" ")), r;
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 $ = /* @__PURE__ */ p({
22
+ const I = /* @__PURE__ */ f({
38
23
  __name: "Checkbox",
39
24
  props: {
40
- id: { default: () => N() },
41
- name: null,
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: null
30
+ modelValue: { type: [Boolean, Array] },
31
+ label: {}
47
32
  },
48
- emits: ["update:modelValue"],
49
- setup(o, { emit: t }) {
50
- const e = o, l = f(e.modelValue || e.checked);
51
- function c() {
52
- l.value = !l.value, t("update:modelValue", l.value);
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 a = x(() => [
55
- "block border-1 border-solid rounded h-16px w-16px flex-shrink-0",
56
- e.disabled ? "border-gray-200 bg-gray-100" : l.value ? {
57
- "border-indigo-500 bg-indigo-400": e.color === "indigo",
58
- "border-jade-500 bg-jade-400": e.color === "jade",
59
- "border-red-500 bg-red-400": e.color === "red"
60
- } : "border-gray-200 bg-white"
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
- }, null, 40, O),
72
- d("label", {
73
- className: "flex items-center",
74
- for: o.id
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 ? (i(), y(m(j), {
66
+ l.value ? (s(), x(o(V), {
77
67
  key: 0,
78
68
  strokeColor: "white",
79
69
  class: "absolute"
80
- })) : h("", !0),
81
- d("span", {
82
- class: g(m(a))
70
+ })) : m("", !0),
71
+ i("span", {
72
+ class: t([g.value, o(r).visibleCheckbox])
83
73
  }, null, 2),
84
- C(n.$slots, "label", {}, () => [
85
- o.label ? (i(), b("span", {
74
+ C(a.$slots, "label", {}, () => [
75
+ a.label ? (s(), u("span", {
86
76
  key: 0,
87
- class: g([
88
- "ml-8px text-16px leading-24px font-light select-none",
89
- o.disabled ? "text-gray-500" : "text-gray-800"
77
+ class: t([
78
+ o(r).trueLabel,
79
+ a.disabled ? "text-gray-500" : "text-gray-800"
90
80
  ])
91
- }, v(o.label), 3)) : h("", !0)
81
+ }, v(a.label), 3)) : m("", !0)
92
82
  ])
93
- ], 8, V)
83
+ ], 10, S)
94
84
  ]));
95
85
  }
96
86
  });
97
87
  export {
98
- $ as default
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"> */