@fiscozen/checkbox 0.1.3 → 0.1.5
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/package.json +7 -7
- package/src/FzCheckbox.vue +10 -6
- package/src/__test__/FzCheckbox.test.ts +26 -0
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/checkbox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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/
|
|
11
|
-
"@fiscozen/
|
|
10
|
+
"@fiscozen/composables": "^0.1.24",
|
|
11
|
+
"@fiscozen/badge": "^0.1.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"tailwindcss": "^3.4.1",
|
|
15
15
|
"vue": "^3.4.13",
|
|
16
|
-
"@fiscozen/icons": "^0.1.
|
|
16
|
+
"@fiscozen/icons": "^0.1.9"
|
|
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/eslint-config": "^0.1.0",
|
|
38
|
-
"@fiscozen/prettier-config": "^0.1.0",
|
|
39
37
|
"@fiscozen/tsconfig": "^0.1.0",
|
|
40
|
-
"@fiscozen/
|
|
38
|
+
"@fiscozen/eslint-config": "^0.1.0",
|
|
39
|
+
"@fiscozen/icons": "^0.1.9",
|
|
40
|
+
"@fiscozen/prettier-config": "^0.1.0"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"scripts": {
|
package/src/FzCheckbox.vue
CHANGED
|
@@ -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<
|
|
50
|
+
const model = defineModel<
|
|
51
|
+
null | undefined | boolean | (string | number | boolean)[]
|
|
52
|
+
>({
|
|
51
53
|
required: true,
|
|
52
54
|
});
|
|
53
55
|
|
|
@@ -94,6 +96,8 @@ const computedVariant = computed(() => {
|
|
|
94
96
|
});
|
|
95
97
|
|
|
96
98
|
const checkValueIsInModel = () => {
|
|
99
|
+
if (model.value == null) return false;
|
|
100
|
+
|
|
97
101
|
if (typeof model.value === "boolean") {
|
|
98
102
|
return model.value;
|
|
99
103
|
} else {
|
|
@@ -127,6 +131,7 @@ const getTextClassForIcon = () => {
|
|
|
127
131
|
};
|
|
128
132
|
|
|
129
133
|
onMounted(() => {
|
|
134
|
+
if (model.value == null) return;
|
|
130
135
|
if (typeof model.value === "boolean") {
|
|
131
136
|
if (model.value) refCheckbox.value?.dispatchEvent(new Event("change"));
|
|
132
137
|
else if (props.checked !== undefined) model.value = props.checked;
|
|
@@ -140,10 +145,9 @@ onMounted(() => {
|
|
|
140
145
|
<style scoped>
|
|
141
146
|
.fz-hidden-input {
|
|
142
147
|
opacity: 0;
|
|
143
|
-
margin:0;
|
|
144
|
-
height:0;
|
|
145
|
-
border:none;
|
|
146
|
-
|
|
147
|
-
clip-path: inset(50%);
|
|
148
|
+
margin: 0;
|
|
149
|
+
height: 0;
|
|
150
|
+
border: 0 none;
|
|
151
|
+
appearance: none;
|
|
148
152
|
}
|
|
149
153
|
</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
|
});
|