@fiscozen/checkbox 0.1.4 → 0.1.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.
Files changed (37) hide show
  1. package/coverage/.tmp/coverage-0.json +1 -0
  2. package/coverage/.tmp/coverage-1.json +1 -0
  3. package/coverage/base.css +224 -0
  4. package/coverage/block-navigation.js +87 -0
  5. package/coverage/clover.xml +457 -0
  6. package/coverage/coverage-final.json +7 -0
  7. package/coverage/favicon.png +0 -0
  8. package/coverage/index.html +131 -0
  9. package/coverage/prettify.css +1 -0
  10. package/coverage/prettify.js +2 -0
  11. package/coverage/sort-arrow-sprite.png +0 -0
  12. package/coverage/sorter.js +196 -0
  13. package/coverage/src/FzCheckbox.vue.html +541 -0
  14. package/coverage/src/FzCheckboxGroup.vue.html +319 -0
  15. package/coverage/src/common.ts.html +97 -0
  16. package/coverage/src/components/FzCheckboxErrorText.vue.html +145 -0
  17. package/coverage/src/components/FzCheckboxGroupOption.vue.html +379 -0
  18. package/coverage/src/components/index.html +131 -0
  19. package/coverage/src/index.html +161 -0
  20. package/coverage/src/types.ts.html +310 -0
  21. package/dist/checkbox.js +301 -0
  22. package/dist/checkbox.umd.cjs +1 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/src/FzCheckbox.vue.d.ts +95 -0
  25. package/dist/src/FzCheckboxGroup.vue.d.ts +70 -0
  26. package/dist/src/__test__/FzCheckbox.test.d.ts +1 -0
  27. package/dist/src/__test__/FzCheckboxGroup.test.d.ts +1 -0
  28. package/dist/src/common.d.ts +4 -0
  29. package/dist/src/components/FzCheckboxErrorText.vue.d.ts +24 -0
  30. package/dist/src/components/FzCheckboxGroupOption.vue.d.ts +82 -0
  31. package/dist/src/index.d.ts +3 -0
  32. package/dist/src/types.d.ts +76 -0
  33. package/dist/style.css +1 -0
  34. package/package.json +7 -7
  35. package/src/FzCheckbox.vue +13 -9
  36. package/src/__test__/FzCheckbox.test.ts +26 -0
  37. package/src/common.ts +1 -1
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ input[type=checkbox][data-v-7bafffef]{width:0;height:0}input[type=checkbox]+label[data-v-7bafffef]{cursor:pointer}input[type=checkbox]+label[data-v-7bafffef]:hover{cursor:pointer}input[type=checkbox]:focus+label div[data-v-7bafffef]:after{border-radius:3px;content:"";border-style:solid;border-width:1px;@apply border-blue-500;top:0;left:0;right:0;bottom:0;position:absolute}.checkbox--small:focus+label div[data-v-7bafffef]:after{transform:translate(-.2px,.4px)}.checkbox-group--child-container__small[data-v-c563830e]{margin-top:5px;padding-left:24px}.checkbox-group--child-container__medium[data-v-c563830e]{margin-top:6px;padding-left:24px}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@fiscozen/checkbox",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Design System Checkbox and Checkbox Group component",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
7
7
  "keywords": [],
8
8
  "author": "Cristian Barraco",
9
9
  "dependencies": {
10
- "@fiscozen/composables": "^0.1.24",
11
- "@fiscozen/badge": "^0.1.0"
10
+ "@fiscozen/composables": "^0.1.33",
11
+ "@fiscozen/badge": "^0.1.2"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "tailwindcss": "^3.4.1",
15
15
  "vue": "^3.4.13",
16
- "@fiscozen/icons": "^0.1.9"
16
+ "@fiscozen/icons": "^0.1.14"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rushstack/eslint-patch": "^1.3.3",
@@ -34,10 +34,10 @@
34
34
  "@awesome.me/kit-8137893ad3": "^1.0.65",
35
35
  "@fortawesome/fontawesome-svg-core": "^6.5.1",
36
36
  "@fortawesome/vue-fontawesome": "^3.0.6",
37
- "@fiscozen/tsconfig": "^0.1.0",
38
- "@fiscozen/icons": "^0.1.9",
37
+ "@fiscozen/eslint-config": "^0.1.0",
38
+ "@fiscozen/icons": "^0.1.14",
39
39
  "@fiscozen/prettier-config": "^0.1.0",
40
- "@fiscozen/eslint-config": "^0.1.0"
40
+ "@fiscozen/tsconfig": "^0.1.0"
41
41
  },
42
42
  "license": "MIT",
43
43
  "scripts": {
@@ -20,7 +20,7 @@
20
20
  :class="[staticIconClass, computedIconClasses]"
21
21
  :variant="computedVariant"
22
22
  />
23
- <span class="w-fit">{{ standalone ? "" : label }}</span>
23
+ {{ standalone ? "" : label }}
24
24
  </label>
25
25
  <FzRadioErrorText :size="size" v-if="error && $slots.error">
26
26
  <slot name="error" />
@@ -47,7 +47,9 @@ const id = computed(
47
47
  () => `fz-checkbox-${Math.random().toString(36).slice(2, 9)}`,
48
48
  );
49
49
 
50
- const model = defineModel<boolean | (string | number | boolean)[]>({
50
+ const model = defineModel<
51
+ null | undefined | boolean | (string | number | boolean)[]
52
+ >({
51
53
  required: true,
52
54
  });
53
55
 
@@ -56,7 +58,7 @@ const refCheckbox = ref<HTMLInputElement | null>(null);
56
58
 
57
59
  const staticInputClass = "w-0 h-0 peer fz-hidden-input";
58
60
  const staticLabelClass = `
59
- flex items-start gap-4 hover:cursor-pointer
61
+ flex gap-4 hover:cursor-pointer
60
62
  peer-focus:[&_div]:after:border-1
61
63
  peer-focus:[&_div]:after:border-solid
62
64
  peer-focus:[&_div]:after:rounded-[3px]
@@ -77,7 +79,6 @@ const computedLabelClass = computed(() => [
77
79
 
78
80
  const computedIconClasses = computed(() => [
79
81
  props.size === "sm" ? "mt-1" : "",
80
- props.size === "md" ? "mt-2" : "",
81
82
  getTextClassForIcon(),
82
83
  ]);
83
84
 
@@ -94,6 +95,8 @@ const computedVariant = computed(() => {
94
95
  });
95
96
 
96
97
  const checkValueIsInModel = () => {
98
+ if (model.value == null) return false;
99
+
97
100
  if (typeof model.value === "boolean") {
98
101
  return model.value;
99
102
  } else {
@@ -108,9 +111,9 @@ const getTextClassForLabel = () => {
108
111
  case props.error:
109
112
  return "text-semantic-error";
110
113
  case props.emphasis:
111
- return "text-grey-500 peer-checked:[&_div]:text-blue-500 peer-indeterminate:[&_div]:text-blue-500";
114
+ return "text-core-black peer-checked:[&_div]:text-blue-500 peer-indeterminate:[&_div]:text-blue-500";
112
115
  default:
113
- return "text-grey-500";
116
+ return "text-core-black";
114
117
  }
115
118
  };
116
119
 
@@ -127,6 +130,7 @@ const getTextClassForIcon = () => {
127
130
  };
128
131
 
129
132
  onMounted(() => {
133
+ if (model.value == null) return;
130
134
  if (typeof model.value === "boolean") {
131
135
  if (model.value) refCheckbox.value?.dispatchEvent(new Event("change"));
132
136
  else if (props.checked !== undefined) model.value = props.checked;
@@ -140,9 +144,9 @@ onMounted(() => {
140
144
  <style scoped>
141
145
  .fz-hidden-input {
142
146
  opacity: 0;
143
- margin:0;
144
- height:0;
145
- border:0 none;
147
+ margin: 0;
148
+ height: 0;
149
+ border: 0 none;
146
150
  appearance: none;
147
151
  }
148
152
  </style>
@@ -105,4 +105,30 @@ describe("FzCheckbox", () => {
105
105
  expect(new Set(ids).size).toBe(MAX_CHECKBOX);
106
106
  expect(new Set(labelFor).size).toBe(MAX_CHECKBOX);
107
107
  });
108
+
109
+ it("should not throw error when modelValue is undefined", async () => {
110
+ const wrapper = mount(FzCheckbox, {
111
+ props: {
112
+ label: "Test Checkbox",
113
+ value: "test",
114
+ size: "md",
115
+ modelValue: undefined,
116
+ },
117
+ });
118
+ await wrapper.vm.$nextTick();
119
+ expect(wrapper.find("input").element.checked).toBe(false);
120
+ });
121
+
122
+ it("should not throw error when modelValue is null", async () => {
123
+ const wrapper = mount(FzCheckbox, {
124
+ props: {
125
+ label: "Test Checkbox",
126
+ value: "test",
127
+ size: "md",
128
+ modelValue: null,
129
+ },
130
+ });
131
+ await wrapper.vm.$nextTick();
132
+ expect(wrapper.find("input").element.checked).toBe(false);
133
+ });
108
134
  });
package/src/common.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export const mapSizeToClasses = {
2
2
  sm: "text-sm",
3
- md: "text-md",
3
+ md: "text-base",
4
4
  };