@fiscozen/checkbox 0.1.1 → 0.1.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fiscozen/checkbox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Design System Checkbox and Checkbox Group component",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -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",
|
|
37
38
|
"@fiscozen/eslint-config": "^0.1.0",
|
|
38
39
|
"@fiscozen/icons": "^0.1.4",
|
|
39
|
-
"@fiscozen/prettier-config": "^0.1.0"
|
|
40
|
-
"@fiscozen/tsconfig": "^0.1.0"
|
|
40
|
+
"@fiscozen/prettier-config": "^0.1.0"
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"scripts": {
|
package/src/FzCheckbox.vue
CHANGED
|
@@ -13,10 +13,7 @@
|
|
|
13
13
|
:indeterminate="indeterminate"
|
|
14
14
|
ref="refCheckbox"
|
|
15
15
|
/>
|
|
16
|
-
<label
|
|
17
|
-
:for="id"
|
|
18
|
-
:class="[staticLabelClass, computedLabelClass]"
|
|
19
|
-
>
|
|
16
|
+
<label :for="id" :class="[staticLabelClass, computedLabelClass]">
|
|
20
17
|
<FzIcon
|
|
21
18
|
:name="computedName"
|
|
22
19
|
:size="size"
|
|
@@ -46,9 +43,9 @@ const props = withDefaults(defineProps<FzCheckboxProps>(), {
|
|
|
46
43
|
|
|
47
44
|
const currentValue = computed(() => props.value ?? props.label);
|
|
48
45
|
|
|
49
|
-
const id = computed(
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
const id = computed(
|
|
47
|
+
() => `fz-checkbox-${Math.random().toString(36).slice(2, 9)}`,
|
|
48
|
+
);
|
|
52
49
|
|
|
53
50
|
const model = defineModel<boolean | (string | number | boolean)[]>({
|
|
54
51
|
required: true,
|
package/src/FzCheckboxGroup.vue
CHANGED
|
@@ -32,8 +32,8 @@ import { mapSizeToClasses } from "./common";
|
|
|
32
32
|
import FzCheckboxGroupOption from "./components/FzCheckboxGroupOption.vue";
|
|
33
33
|
|
|
34
34
|
FzCheckboxGroupOption.compatConfig = {
|
|
35
|
-
MODE:3
|
|
36
|
-
}
|
|
35
|
+
MODE: 3,
|
|
36
|
+
};
|
|
37
37
|
|
|
38
38
|
const props = defineProps<FzCheckboxGroupProps>();
|
|
39
39
|
const id = `fz-checkbox-group-${generateRandomId()}`;
|
|
@@ -3,6 +3,8 @@ import { mount } from "@vue/test-utils";
|
|
|
3
3
|
import { describe, it, expect } from "vitest";
|
|
4
4
|
import FzCheckbox from "../FzCheckbox.vue";
|
|
5
5
|
|
|
6
|
+
const MAX_CHECKBOX = 200;
|
|
7
|
+
|
|
6
8
|
describe("FzCheckbox", () => {
|
|
7
9
|
it("renders correctly", async () => {
|
|
8
10
|
const wrapper = mount(FzCheckbox, {
|
|
@@ -16,7 +18,6 @@ describe("FzCheckbox", () => {
|
|
|
16
18
|
|
|
17
19
|
await wrapper.vm.$nextTick();
|
|
18
20
|
expect(wrapper.html()).toContain("Test Checkbox");
|
|
19
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
it("emits an update event when clicked", async () => {
|
|
@@ -85,4 +86,23 @@ describe("FzCheckbox", () => {
|
|
|
85
86
|
await wrapper.vm.$nextTick();
|
|
86
87
|
expect(wrapper.find("input").element.disabled).toBe(true);
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
it(`should render ${MAX_CHECKBOX} checkbox all with different ids`, async () => {
|
|
91
|
+
const checkboxes = Array.from({ length: MAX_CHECKBOX }).map((_) => {
|
|
92
|
+
return mount(FzCheckbox, {
|
|
93
|
+
props: {
|
|
94
|
+
label: "Test Checkbox",
|
|
95
|
+
value: "test",
|
|
96
|
+
size: "md",
|
|
97
|
+
modelValue: false,
|
|
98
|
+
disabled: true,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
await Promise.all(checkboxes.map((c) => c.vm.$nextTick()));
|
|
103
|
+
const ids = checkboxes.map((c) => c.find("input").attributes("id"));
|
|
104
|
+
const labelFor = checkboxes.map((c) => c.find("label").attributes("for"));
|
|
105
|
+
expect(new Set(ids).size).toBe(MAX_CHECKBOX);
|
|
106
|
+
expect(new Set(labelFor).size).toBe(MAX_CHECKBOX);
|
|
107
|
+
});
|
|
88
108
|
});
|
|
@@ -71,9 +71,7 @@ function handleCheckboxParentChange() {
|
|
|
71
71
|
} else {
|
|
72
72
|
// remove parent value from model if it exists
|
|
73
73
|
if (model.value.includes(currentValue.value))
|
|
74
|
-
model.value = model.value.filter(
|
|
75
|
-
(value) => value !== currentValue.value,
|
|
76
|
-
);
|
|
74
|
+
model.value = model.value.filter((value) => value !== currentValue.value);
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`FzCheckbox > renders correctly 1`] = `
|
|
4
|
-
"<div class="flex justify-center flex-col w-fit"><input type="checkbox" id="test" class="w-0 h-0 peer" value="test"><label for="test" class="flex items-start gap-4 hover:cursor-pointer
|
|
5
|
-
peer-focus:[&_div]:after:border-1
|
|
6
|
-
peer-focus:[&_div]:after:border-solid
|
|
7
|
-
peer-focus:[&_div]:after:rounded-[3px]
|
|
8
|
-
peer-focus:[&_div]:after:border-blue-500
|
|
9
|
-
peer-focus:[&_div]:after:content-['']
|
|
10
|
-
peer-focus:[&_div]:after:top-0
|
|
11
|
-
peer-focus:[&_div]:after:left-0
|
|
12
|
-
peer-focus:[&_div]:after:right-0
|
|
13
|
-
peer-focus:[&_div]:after:bottom-0
|
|
14
|
-
peer-focus:[&_div]:after:absolute text-md text-grey-500">
|
|
15
|
-
<div class="flex items-center justify-center w-[20px] h-[20px] relative mt-2 text-grey-500"><svg class="svg-inline--fa fa-square h-[16px]" aria-hidden="true" focusable="false" data-prefix="far" data-icon="square" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
|
|
16
|
-
<path class="" fill="currentColor" d="M384 80c8.8 0 16 7.2 16 16V416c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V96c0-8.8 7.2-16 16-16H384zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"></path>
|
|
17
|
-
</svg></div><span class="w-fit">Test Checkbox</span>
|
|
18
|
-
</label>
|
|
19
|
-
<!--v-if-->
|
|
20
|
-
</div>"
|
|
21
|
-
`;
|