@cypress-design/vue-checkbox 0.4.5 → 0.4.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
3
9
  ## 0.4.5
4
10
 
5
11
  ### Patch Changes
package/Checkbox.vue CHANGED
@@ -60,7 +60,7 @@ function updated() {
60
60
  }
61
61
 
62
62
  const checkboxClasses = computed(() => [
63
- 'block border-1 border-solid rounded h-16px w-16px',
63
+ 'block border-1 border-solid rounded h-16px w-16px flex-shrink-0',
64
64
  props.disabled
65
65
  ? 'border-gray-200 bg-gray-100'
66
66
  : localChecked.value
@@ -95,7 +95,7 @@ const checkboxClasses = computed(() => [
95
95
  <span
96
96
  v-if="label"
97
97
  :class="[
98
- 'ml-2 text-16px leading-normal font-light select-none',
98
+ 'ml-8px text-16px leading-24px font-light select-none',
99
99
  disabled ? 'text-gray-500' : 'text-gray-800',
100
100
  ]"
101
101
  >
@@ -39,6 +39,19 @@ describe('<Checkbox />', () => {
39
39
  cy.get('input[type="checkbox"]').should('not.be.checked')
40
40
  })
41
41
 
42
+ it('keeps its width when label is long', () => {
43
+ mount(() => {
44
+ return (
45
+ <Checkbox
46
+ 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."
47
+ id="lorem-checkbox"
48
+ />
49
+ )
50
+ })
51
+
52
+ cy.get('label span:first-child').invoke('outerWidth').should('equal', 16)
53
+ })
54
+
42
55
  it('renders vModel', () => {
43
56
  const isChecked = ref(false)
44
57
  mount(() => {
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 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}`,
15
16
  fill: "none",
16
- innerHTML: e,
17
+ innerHTML: o,
17
18
  ...n
18
19
  };
19
20
  return t.length && (r.class = t.join(" ")), r;
20
- }, z = (e) => {
21
- const { sizeWithDefault: t, compiledClasses: o } = w.getComponentAttributes({ ...e, availableSizes: ["16"] }), l = {
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,57 @@ 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
+ "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"
59
60
  } : "border-gray-200 bg-white"
60
61
  ]);
61
- return (n, r) => (d(), b("span", B, [
62
- i("input", {
63
- id: e.id,
62
+ return (n, r) => (i(), b("span", z, [
63
+ d("input", {
64
+ id: o.id,
64
65
  class: "absolute inset-0 w-0 h-0 opacity-0",
65
- name: e.name || e.id,
66
+ name: o.name || o.id,
66
67
  type: "checkbox",
67
68
  onChange: c,
68
- disabled: o.disabled,
69
+ disabled: e.disabled,
69
70
  checked: l.value
70
71
  }, null, 40, O),
71
- i("label", {
72
+ d("label", {
72
73
  className: "flex items-center",
73
- for: e.id
74
+ for: o.id
74
75
  }, [
75
- l.value ? (d(), C(m(z), {
76
+ l.value ? (i(), y(m(j), {
76
77
  key: 0,
77
78
  strokeColor: "white",
78
79
  class: "absolute"
79
80
  })) : h("", !0),
80
- i("span", {
81
+ d("span", {
81
82
  class: g(m(a))
82
83
  }, null, 2),
83
- v(n.$slots, "label", {}, () => [
84
- e.label ? (d(), b("span", {
84
+ C(n.$slots, "label", {}, () => [
85
+ o.label ? (i(), b("span", {
85
86
  key: 0,
86
87
  class: g([
87
- "ml-2 text-16px leading-normal font-light select-none",
88
- e.disabled ? "text-gray-500" : "text-gray-800"
88
+ "ml-8px text-16px leading-24px font-light select-none",
89
+ o.disabled ? "text-gray-500" : "text-gray-800"
89
90
  ])
90
- }, x(e.label), 3)) : h("", !0)
91
+ }, v(o.label), 3)) : h("", !0)
91
92
  ])
92
93
  ], 8, V)
93
94
  ]));
94
95
  }
95
96
  });
96
97
  export {
97
- D as default
98
+ $ as default
98
99
  };
99
100
 
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"> */
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"> */
101
102
  //# sourceMappingURL=index.es.mjs.map