@cypress-design/vue-checkbox 0.4.5 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @cypress-design/vue-checkbox
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#151](https://github.com/cypress-io/cypress-design/pull/151) [`8b0e735`](https://github.com/cypress-io/cypress-design/commit/8b0e7356eb64a6b3583d3486dda8ecbb11c34cca) Thanks [@elevatebart](https://github.com/elevatebart)! - refactor: use clases compatible with both windi and tailwind
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`106b61a`](https://github.com/cypress-io/cypress-design/commit/106b61a97888f956a4c9d235fde5efb4243e1445), [`7b4f416`](https://github.com/cypress-io/cypress-design/commit/7b4f4162a0d150aa8cab7ec239faebb58c39464d)]:
12
+ - @cypress-design/vue-icon@0.18.0
13
+
14
+ ## 0.4.6
15
+
16
+ ### Patch Changes
17
+
18
+ - [#112](https://github.com/cypress-io/cypress-design/pull/112) [`d229b48`](https://github.com/cypress-io/cypress-design/commit/d229b48a3806a882abe83c9ebf9c32ed18d2c47f) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: when label is too big avoid checkbox shrinking
19
+
3
20
  ## 0.4.5
4
21
 
5
22
  ### Patch Changes
package/Checkbox.vue CHANGED
@@ -60,7 +60,6 @@ function updated() {
60
60
  }
61
61
 
62
62
  const checkboxClasses = computed(() => [
63
- 'block border-1 border-solid rounded h-16px w-16px',
64
63
  props.disabled
65
64
  ? 'border-gray-200 bg-gray-100'
66
65
  : localChecked.value
@@ -90,12 +89,15 @@ const checkboxClasses = computed(() => [
90
89
  strokeColor="white"
91
90
  class="absolute"
92
91
  />
93
- <span :class="checkboxClasses" />
92
+ <span
93
+ :class="checkboxClasses"
94
+ class="block border border-solid rounded h-[16px] w-[16px] flex-shrink-0"
95
+ />
94
96
  <slot name="label">
95
97
  <span
96
98
  v-if="label"
97
99
  :class="[
98
- 'ml-2 text-16px leading-normal font-light select-none',
100
+ 'ml-[8px] text-[16px] leading-[24px] font-light select-none',
99
101
  disabled ? 'text-gray-500' : 'text-gray-800',
100
102
  ]"
101
103
  >
@@ -18,8 +18,10 @@ describe('<Checkbox />', () => {
18
18
  })
19
19
 
20
20
  cy.get('input[type="checkbox"]').should('be.checked')
21
+ cy.percySnapshot()
21
22
  cy.contains('Welcome guide settings').click()
22
23
  cy.get('input[type="checkbox"]').should('not.be.checked')
24
+ cy.percySnapshot()
23
25
  })
24
26
 
25
27
  it('changes when checkbox is clicked', () => {
@@ -39,6 +41,19 @@ describe('<Checkbox />', () => {
39
41
  cy.get('input[type="checkbox"]').should('not.be.checked')
40
42
  })
41
43
 
44
+ it('keeps its width when label is long', () => {
45
+ mount(() => {
46
+ return (
47
+ <Checkbox
48
+ label="lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
49
+ id="lorem-checkbox"
50
+ />
51
+ )
52
+ })
53
+
54
+ cy.get('label span:first-child').invoke('outerWidth').should('equal', 16)
55
+ })
56
+
42
57
  it('renders vModel', () => {
43
58
  const isChecked = ref(false)
44
59
  mount(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.vue.d.ts","sourceRoot":"","sources":["../Checkbox.vue.ts"],"names":[],"mappings":";;;;;gBAkFS,MAAM;mBAaH,KAAK,GAAG,QAAQ,GAAG,MAAM;;YAjBjC;;;eAGG;;YAEH;;eAEG;;YAEH;;eAEG;;YAEH;;;eAGG;;YAEH;;eAEG;;;YAGH;;;eAGG;;;;;;;;;;;;;;;;;;;;;;YA1BH;;;eA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,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;QACzD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,GAAG,CAAC,CAAC,CAAC,CAAC;CACR,CAAC"}
package/dist/index.es.mjs CHANGED
@@ -1,39 +1,40 @@
1
- import { h as k, defineComponent as p, ref as f, computed as y, openBlock as d, createElementBlock as b, createElementVNode as i, createBlock as C, unref as m, createCommentVNode as h, normalizeClass as g, renderSlot as v, toDisplayString as x } from "vue";
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
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 = ({
5
- body: e,
3
+ import { ICON_COLOR_PROP_NAMES as B } from "@cypress-design/icon-registry";
4
+ const S = ({
5
+ body: o,
6
6
  compiledClasses: t,
7
- size: o,
7
+ size: e,
8
8
  class: l,
9
9
  interactiveColorsOnGroup: c,
10
10
  ...a
11
11
  }) => {
12
- const n = Object.keys(a).reduce((u, s) => (S.includes(s) || (u[s] = a[s]), u), {}), r = {
13
- width: o,
14
- height: o,
12
+ const r = Object.keys(a).reduce((u, n) => (!B.includes(n) && n !== "name" && (u[n] = a[n]), u), {}), s = {
13
+ width: e,
14
+ height: e,
15
+ viewBox: `0 0 ${e} ${e}`,
15
16
  fill: "none",
16
- innerHTML: e,
17
- ...n
17
+ innerHTML: o,
18
+ ...r
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
+ return t.length && (s.class = t.join(" ")), s;
21
+ }, j = (o) => {
22
+ const { sizeWithDefault: t, compiledClasses: e } = w.getComponentAttributes({ ...o, availableSizes: ["16"] }), l = {
22
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"/>'
23
24
  }[t];
24
25
  if (!l)
25
26
  throw Error(`Icon "checkmark-small" is not available in size ${t}`);
26
- return k("svg", j({
27
- ...e,
27
+ return k("svg", S({
28
+ ...o,
28
29
  size: t,
29
30
  body: l,
30
- compiledClasses: o
31
+ compiledClasses: e
31
32
  }));
32
- }, B = { class: "block relative flex items-center" }, O = ["id", "name", "disabled", "checked"], V = ["for"];
33
+ }, z = { class: "block relative flex items-center" }, O = ["id", "name", "disabled", "checked"], V = ["for"];
33
34
  function N() {
34
35
  return String(Date.now().toString(32) + Math.random().toString(16)).replace(/\./g, "");
35
36
  }
36
- const D = /* @__PURE__ */ p({
37
+ const $ = /* @__PURE__ */ p({
37
38
  __name: "Checkbox",
38
39
  props: {
39
40
  id: { default: () => N() },
@@ -45,57 +46,56 @@ const D = /* @__PURE__ */ p({
45
46
  label: null
46
47
  },
47
48
  emits: ["update:modelValue"],
48
- setup(e, { emit: t }) {
49
- const o = e, l = f(o.modelValue || o.checked);
49
+ setup(o, { emit: t }) {
50
+ const e = o, l = f(e.modelValue || e.checked);
50
51
  function c() {
51
52
  l.value = !l.value, t("update:modelValue", l.value);
52
53
  }
53
- const a = y(() => [
54
- "block border-1 border-solid rounded h-16px w-16px",
55
- o.disabled ? "border-gray-200 bg-gray-100" : l.value ? {
56
- "border-indigo-500 bg-indigo-400": o.color === "indigo",
57
- "border-jade-500 bg-jade-400": o.color === "jade",
58
- "border-red-500 bg-red-400": o.color === "red"
54
+ const a = x(() => [
55
+ e.disabled ? "border-gray-200 bg-gray-100" : l.value ? {
56
+ "border-indigo-500 bg-indigo-400": e.color === "indigo",
57
+ "border-jade-500 bg-jade-400": e.color === "jade",
58
+ "border-red-500 bg-red-400": e.color === "red"
59
59
  } : "border-gray-200 bg-white"
60
60
  ]);
61
- return (n, r) => (d(), b("span", B, [
62
- i("input", {
63
- id: e.id,
61
+ return (r, s) => (i(), b("span", z, [
62
+ d("input", {
63
+ id: o.id,
64
64
  class: "absolute inset-0 w-0 h-0 opacity-0",
65
- name: e.name || e.id,
65
+ name: o.name || o.id,
66
66
  type: "checkbox",
67
67
  onChange: c,
68
- disabled: o.disabled,
68
+ disabled: e.disabled,
69
69
  checked: l.value
70
70
  }, null, 40, O),
71
- i("label", {
71
+ d("label", {
72
72
  className: "flex items-center",
73
- for: e.id
73
+ for: o.id
74
74
  }, [
75
- l.value ? (d(), C(m(z), {
75
+ l.value ? (i(), y(m(j), {
76
76
  key: 0,
77
77
  strokeColor: "white",
78
78
  class: "absolute"
79
79
  })) : h("", !0),
80
- i("span", {
81
- class: g(m(a))
80
+ d("span", {
81
+ class: g([m(a), "block border border-solid rounded h-[16px] w-[16px] flex-shrink-0"])
82
82
  }, null, 2),
83
- v(n.$slots, "label", {}, () => [
84
- e.label ? (d(), b("span", {
83
+ C(r.$slots, "label", {}, () => [
84
+ o.label ? (i(), b("span", {
85
85
  key: 0,
86
86
  class: g([
87
- "ml-2 text-16px leading-normal font-light select-none",
88
- e.disabled ? "text-gray-500" : "text-gray-800"
87
+ "ml-[8px] text-[16px] leading-[24px] font-light select-none",
88
+ o.disabled ? "text-gray-500" : "text-gray-800"
89
89
  ])
90
- }, x(e.label), 3)) : h("", !0)
90
+ }, v(o.label), 3)) : h("", !0)
91
91
  ])
92
92
  ], 8, V)
93
93
  ]));
94
94
  }
95
95
  });
96
96
  export {
97
- D as default
97
+ $ as default
98
98
  };
99
99
 
100
- /* <windicss-keep class="block border-1 border-solid 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"> */
100
+ /* <windicss-keep class="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 block relative flex items-center absolute inset-0 w-0 h-0 opacity-0 border border-solid rounded h-[16px] w-[16px] flex-shrink-0 ml-[8px] text-[16px] leading-[24px] font-light select-none text-gray-500 text-gray-800 icon-dark-white"> */
101
101
  //# sourceMappingURL=index.es.mjs.map