@cypress-design/vue-checkbox 0.4.0 → 0.4.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cypress-design/vue-checkbox
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2afa4d5`](https://github.com/cypress-io/cypress-design/commit/2afa4d54a2373692f82bee35ae40446bc9bb3f91) Thanks [@elevatebart](https://github.com/elevatebart)! - avoid duplicate ids in checkboxes
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  ### Minor Changes
package/Checkbox.vue CHANGED
@@ -43,7 +43,7 @@ const props = withDefaults(
43
43
  label?: string
44
44
  }>(),
45
45
  {
46
- id: uid(),
46
+ id: () => uid(),
47
47
  color: 'indigo',
48
48
  }
49
49
  )
@@ -28,7 +28,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
28
28
  */
29
29
  label?: string | undefined;
30
30
  }>, {
31
- id: string;
31
+ id: () => string;
32
32
  color: string;
33
33
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
34
34
  "update:modelValue": (value: boolean) => void;
@@ -62,7 +62,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
62
62
  */
63
63
  label?: string | undefined;
64
64
  }>, {
65
- id: string;
65
+ id: () => string;
66
66
  color: string;
67
67
  }>>> & {
68
68
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { h as k, defineComponent as p, ref as f, computed as y, openBlock as i, createElementBlock as b, createElementVNode as s, createBlock as C, unref as m, createCommentVNode as h, normalizeClass as g, renderSlot as v, toDisplayString as x } from "vue";
2
- import * as w from "@cypress-design/icon-registry";
3
- import { ICON_COLOR_PROP_NAMES as S } from "@cypress-design/icon-registry";
4
- const j = ({
1
+ import { defineComponent as k, h as p, ref as y, computed as C, openBlock as i, createElementBlock as b, createElementVNode as d, createBlock as v, unref as m, createCommentVNode as h, normalizeClass as g, renderSlot as x, toDisplayString as w } from "vue";
2
+ import * as S from "@cypress-design/icon-registry";
3
+ import { compileIcon as j, ICON_COLOR_PROP_NAMES as z } from "@cypress-design/icon-registry";
4
+ const f = ({
5
5
  body: e,
6
6
  compiledClasses: t,
7
7
  size: o,
@@ -9,7 +9,7 @@ const j = ({
9
9
  interactiveColorsOnGroup: c,
10
10
  ...a
11
11
  }) => {
12
- const n = Object.keys(a).reduce((u, d) => (S.includes(d) || (u[d] = a[d]), u), {}), r = {
12
+ const n = Object.keys(a).reduce((u, s) => (z.includes(s) || (u[s] = a[s]), u), {}), r = {
13
13
  width: o,
14
14
  height: o,
15
15
  fill: "none",
@@ -17,26 +17,28 @@ const j = ({
17
17
  ...n
18
18
  };
19
19
  return t.length && (r.class = t.join(" ")), r;
20
- }, z = (e) => {
21
- const { sizeWithDefault: t, compiledClasses: o } = w.getComponentAttributes({ ...e, availableSizes: ["16"] }), l = {
20
+ };
21
+ k((e) => p("svg", f(j(e))));
22
+ const B = (e) => {
23
+ const { sizeWithDefault: t, compiledClasses: o } = S.getComponentAttributes({ ...e, availableSizes: ["16"] }), l = {
22
24
  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"/>'
23
25
  }[t];
24
26
  if (!l)
25
27
  throw Error(`Icon "checkmark-small" is not available in size ${t}`);
26
- return k("svg", j({
28
+ return p("svg", f({
27
29
  ...e,
28
30
  size: t,
29
31
  body: l,
30
32
  compiledClasses: o
31
33
  }));
32
- }, B = { class: "relative flex items-center" }, O = ["id", "name", "disabled", "checked"], V = ["for"];
33
- function E() {
34
+ }, O = { class: "relative flex items-center" }, V = ["id", "name", "disabled", "checked"], E = ["for"];
35
+ function M() {
34
36
  return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
35
37
  }
36
- const D = /* @__PURE__ */ p({
38
+ const I = /* @__PURE__ */ k({
37
39
  __name: "Checkbox",
38
40
  props: {
39
- id: { default: E() },
41
+ id: { default: () => M() },
40
42
  name: null,
41
43
  checked: { type: Boolean },
42
44
  color: { default: "indigo" },
@@ -46,11 +48,11 @@ const D = /* @__PURE__ */ p({
46
48
  },
47
49
  emits: ["update:modelValue"],
48
50
  setup(e, { emit: t }) {
49
- const o = e, l = f(o.modelValue || o.checked);
51
+ const o = e, l = y(o.modelValue || o.checked);
50
52
  function c() {
51
53
  l.value = !l.value, t("update:modelValue", l.value);
52
54
  }
53
- const a = y(() => [
55
+ const a = C(() => [
54
56
  "block border-1 rounded h-16px w-16px",
55
57
  o.disabled ? "border-gray-200 bg-gray-100" : l.value ? {
56
58
  "border-indigo-500 bg-indigo-400": o.color === "indigo",
@@ -58,8 +60,8 @@ const D = /* @__PURE__ */ p({
58
60
  "border-red-500 bg-red-400": o.color === "red"
59
61
  } : "border-gray-200 bg-white"
60
62
  ]);
61
- return (n, r) => (i(), b("div", B, [
62
- s("input", {
63
+ return (n, r) => (i(), b("div", O, [
64
+ d("input", {
63
65
  id: e.id,
64
66
  class: "absolute inset-0 w-0 h-0 opacity-0",
65
67
  name: e.name || e.id,
@@ -67,31 +69,31 @@ const D = /* @__PURE__ */ p({
67
69
  onChange: c,
68
70
  disabled: o.disabled,
69
71
  checked: l.value
70
- }, null, 40, O),
71
- l.value ? (i(), C(m(z), {
72
+ }, null, 40, V),
73
+ l.value ? (i(), v(m(B), {
72
74
  key: 0,
73
75
  strokeColor: "white",
74
76
  class: "absolute"
75
77
  })) : h("", !0),
76
- s("span", {
78
+ d("span", {
77
79
  class: g(m(a))
78
80
  }, null, 2),
79
- s("label", {
81
+ d("label", {
80
82
  class: "block",
81
83
  for: e.id
82
84
  }, [
83
- v(n.$slots, "label", {}, () => [
85
+ x(n.$slots, "label", {}, () => [
84
86
  e.label ? (i(), b("span", {
85
87
  key: 0,
86
88
  class: g(["ml-2 text-16px leading-normal font-light select-none", e.disabled ? "text-gray-500" : "text-gray-800"])
87
- }, x(e.label), 3)) : h("", !0)
89
+ }, w(e.label), 3)) : h("", !0)
88
90
  ])
89
- ], 8, V)
91
+ ], 8, E)
90
92
  ]));
91
93
  }
92
94
  });
93
95
  export {
94
- D as default
96
+ I as default
95
97
  };
96
98
  /* <windicss-keep class="block border-1 rounded h-16px w-16px 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-2 text-16px leading-normal font-light select-none text-gray-500 text-gray-800 icon-dark-white"> */
97
99