@fiscozen/input 0.1.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/LICENSE +21 -0
- package/README.md +3 -0
- package/eslintrc.cjs +18 -0
- package/package.json +41 -0
- package/prettierrc.js +5 -0
- package/src/FzInput.vue +95 -0
- package/src/__tests__/FzInput.spec.ts +153 -0
- package/src/index.ts +2 -0
- package/src/types.ts +58 -0
- package/src/useInputStyle.ts +64 -0
- package/tsconfig.json +4 -0
- package/vite.config.ts +34 -0
- package/vitest.config.ts +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Fiscozen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
require('@rushstack/eslint-patch/modern-module-resolution')
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
root: true,
|
|
6
|
+
'extends': ['@fiscozen/eslint-config', 'plugin:storybook/recommended'],
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
files: [
|
|
10
|
+
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
|
|
11
|
+
'cypress/support/**/*.{js,ts,jsx,tsx}'
|
|
12
|
+
],
|
|
13
|
+
'extends': [
|
|
14
|
+
'plugin:cypress/recommended'
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fiscozen/input",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Design System Input component",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"author": "Cristian Barraco",
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"tailwindcss": "^3.4.1",
|
|
11
|
+
"vue": "^3.4.13",
|
|
12
|
+
"@fiscozen/icons": "^0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@rushstack/eslint-patch": "^1.3.3",
|
|
16
|
+
"@types/jsdom": "^21.1.6",
|
|
17
|
+
"@types/node": "^18.19.3",
|
|
18
|
+
"@vitejs/plugin-vue": "^4.5.2",
|
|
19
|
+
"@vitest/coverage-v8": "^1.2.1",
|
|
20
|
+
"@vue/test-utils": "^2.4.3",
|
|
21
|
+
"@vue/tsconfig": "^0.5.0",
|
|
22
|
+
"eslint": "^8.49.0",
|
|
23
|
+
"jsdom": "^23.0.1",
|
|
24
|
+
"prettier": "^3.0.3",
|
|
25
|
+
"typescript": "~5.3.0",
|
|
26
|
+
"vite": "^5.0.10",
|
|
27
|
+
"vite-plugin-dts": "^3.8.3",
|
|
28
|
+
"vitest": "^1.2.0",
|
|
29
|
+
"vue-tsc": "^1.8.25",
|
|
30
|
+
"@fiscozen/tsconfig": "^0.1.0",
|
|
31
|
+
"@fiscozen/prettier-config": "^0.1.0",
|
|
32
|
+
"@fiscozen/eslint-config": "^0.1.0"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"coverage": "vitest run --coverage",
|
|
37
|
+
"format": "prettier --write src/",
|
|
38
|
+
"test:unit": "vitest run",
|
|
39
|
+
"build": "vue-tsc && vite build"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/prettierrc.js
ADDED
package/src/FzInput.vue
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-full flex flex-col gap-8">
|
|
3
|
+
<label :class="['text-sm', computedLabelClass]" :for="uniqueId">
|
|
4
|
+
{{ label }}{{ required ? " *" : "" }}
|
|
5
|
+
</label>
|
|
6
|
+
<div
|
|
7
|
+
:class="[staticContainerClass, computedContainerClass]"
|
|
8
|
+
ref="containerRef"
|
|
9
|
+
@click="inputRef?.focus()"
|
|
10
|
+
>
|
|
11
|
+
<FzIcon
|
|
12
|
+
v-if="leftIcon"
|
|
13
|
+
:name="leftIcon"
|
|
14
|
+
:size="size"
|
|
15
|
+
:variant="leftIconVariant"
|
|
16
|
+
/>
|
|
17
|
+
<input
|
|
18
|
+
:type="type"
|
|
19
|
+
:required="required ? required : false"
|
|
20
|
+
:disabled="disabled"
|
|
21
|
+
:placeholder="placeholder"
|
|
22
|
+
v-model="model"
|
|
23
|
+
:id="uniqueId"
|
|
24
|
+
ref="inputRef"
|
|
25
|
+
:class="[staticInputClass]"
|
|
26
|
+
:pattern="pattern"
|
|
27
|
+
/>
|
|
28
|
+
<FzIcon
|
|
29
|
+
v-if="valid"
|
|
30
|
+
name="check"
|
|
31
|
+
:size="size"
|
|
32
|
+
class="text-semantic-success"
|
|
33
|
+
/>
|
|
34
|
+
<FzIcon
|
|
35
|
+
v-if="rightIcon"
|
|
36
|
+
:name="rightIcon"
|
|
37
|
+
:size="size"
|
|
38
|
+
:variant="rightIconVariant"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
<div
|
|
42
|
+
v-if="error && $slots.errorMessage"
|
|
43
|
+
class="flex gap-4"
|
|
44
|
+
:style="{ width: containerWidth }"
|
|
45
|
+
>
|
|
46
|
+
<FzIcon
|
|
47
|
+
name="triangle-exclamation"
|
|
48
|
+
class="text-semantic-error"
|
|
49
|
+
:size="size"
|
|
50
|
+
/>
|
|
51
|
+
<div :class="['mt-1', computedErrorClass]">
|
|
52
|
+
<slot name="errorMessage"></slot>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<span
|
|
56
|
+
v-else-if="$slots.helpText"
|
|
57
|
+
:class="[computedHelpClass]"
|
|
58
|
+
:style="{ width: containerWidth }"
|
|
59
|
+
>
|
|
60
|
+
<slot name="helpText"></slot>
|
|
61
|
+
</span>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import { Ref, ref } from "vue";
|
|
67
|
+
import { FzInputProps } from "./types";
|
|
68
|
+
import { FzIcon } from "@fiscozen/icons";
|
|
69
|
+
import useInputStyle from "./useInputStyle";
|
|
70
|
+
|
|
71
|
+
const props = withDefaults(defineProps<FzInputProps>(), {
|
|
72
|
+
size: "md",
|
|
73
|
+
error: false,
|
|
74
|
+
type: "text",
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const model = defineModel();
|
|
78
|
+
const containerRef: Ref<HTMLElement | null> = ref(null);
|
|
79
|
+
const inputRef: Ref<HTMLInputElement | null> = ref(null);
|
|
80
|
+
const uniqueId = `fz-input-${Math.random().toString(36).slice(2, 9)}`;
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
staticContainerClass,
|
|
84
|
+
computedContainerClass,
|
|
85
|
+
computedLabelClass,
|
|
86
|
+
staticInputClass,
|
|
87
|
+
computedHelpClass,
|
|
88
|
+
computedErrorClass,
|
|
89
|
+
containerWidth,
|
|
90
|
+
} = useInputStyle(props, containerRef);
|
|
91
|
+
|
|
92
|
+
const emit = defineEmits([]);
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<style scoped></style>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { describe, it } from "vitest";
|
|
2
|
+
import { mount } from "@vue/test-utils";
|
|
3
|
+
import { FzInput } from "..";
|
|
4
|
+
|
|
5
|
+
const NUMBER_OF_INPUTS = 1000;
|
|
6
|
+
|
|
7
|
+
describe.concurrent("FzInput", () => {
|
|
8
|
+
it("renders label", async ({ expect }) => {
|
|
9
|
+
const wrapper = mount(FzInput, {
|
|
10
|
+
props: {
|
|
11
|
+
label: "Label",
|
|
12
|
+
},
|
|
13
|
+
slots: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(wrapper.text()).toContain("Label");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("renders leftIcon", async ({ expect }) => {
|
|
20
|
+
const wrapper = mount(FzInput, {
|
|
21
|
+
props: {
|
|
22
|
+
label: "Label",
|
|
23
|
+
leftIcon: "calendar-lines",
|
|
24
|
+
},
|
|
25
|
+
slots: {},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expect(wrapper.find(".fa-calendar-lines")).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("renders rightIcon", async ({ expect }) => {
|
|
32
|
+
const wrapper = mount(FzInput, {
|
|
33
|
+
props: {
|
|
34
|
+
label: "Label",
|
|
35
|
+
rightIcon: "credit-card",
|
|
36
|
+
},
|
|
37
|
+
slots: {},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(wrapper.find(".fa-credit-card")).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("renders helpText", async ({ expect }) => {
|
|
44
|
+
const wrapper = mount(FzInput, {
|
|
45
|
+
props: {
|
|
46
|
+
label: "Label",
|
|
47
|
+
},
|
|
48
|
+
slots: {
|
|
49
|
+
helpText: "This is a helper text",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await wrapper.vm.$nextTick();
|
|
54
|
+
expect(wrapper.text()).toContain("This is a helper text");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("renders errorMessage", async ({ expect }) => {
|
|
58
|
+
const wrapper = mount(FzInput, {
|
|
59
|
+
props: {
|
|
60
|
+
label: "Label",
|
|
61
|
+
error: true,
|
|
62
|
+
},
|
|
63
|
+
slots: {
|
|
64
|
+
errorMessage: "This is an error message",
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await wrapper.vm.$nextTick();
|
|
69
|
+
expect(wrapper.text()).toContain("This is an error message");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("renders disabled", async ({ expect }) => {
|
|
73
|
+
const wrapper = mount(FzInput, {
|
|
74
|
+
props: {
|
|
75
|
+
label: "Label",
|
|
76
|
+
disabled: true,
|
|
77
|
+
},
|
|
78
|
+
slots: {},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
expect(wrapper.find("input").attributes("disabled")).toBe("");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("renders required", async ({ expect }) => {
|
|
85
|
+
const wrapper = mount(FzInput, {
|
|
86
|
+
props: {
|
|
87
|
+
label: "Label",
|
|
88
|
+
required: true,
|
|
89
|
+
},
|
|
90
|
+
slots: {},
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
await wrapper.vm.$nextTick();
|
|
94
|
+
|
|
95
|
+
expect(wrapper.find("input").attributes("required")).toBe("");
|
|
96
|
+
expect(wrapper.text()).toContain("*");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("renders email type", async ({ expect }) => {
|
|
100
|
+
const wrapper = mount(FzInput, {
|
|
101
|
+
props: {
|
|
102
|
+
label: "Label",
|
|
103
|
+
type: "email",
|
|
104
|
+
},
|
|
105
|
+
slots: {},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(wrapper.find("input").attributes("type")).toBe("email");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("renders tel type", async ({ expect }) => {
|
|
112
|
+
const wrapper = mount(FzInput, {
|
|
113
|
+
props: {
|
|
114
|
+
label: "Label",
|
|
115
|
+
type: "tel",
|
|
116
|
+
},
|
|
117
|
+
slots: {},
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
expect(wrapper.find("input").attributes("type")).toBe("tel");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("renders password type", async ({ expect }) => {
|
|
124
|
+
const wrapper = mount(FzInput, {
|
|
125
|
+
props: {
|
|
126
|
+
label: "Label",
|
|
127
|
+
type: "password",
|
|
128
|
+
},
|
|
129
|
+
slots: {},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect(wrapper.find("input").attributes("type")).toBe("password");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it(`renders ${NUMBER_OF_INPUTS} input with different ids`, async ({
|
|
136
|
+
expect,
|
|
137
|
+
}) => {
|
|
138
|
+
const wrapperList = Array.from({ length: NUMBER_OF_INPUTS }).map((_, i) =>
|
|
139
|
+
mount(FzInput, {
|
|
140
|
+
props: {
|
|
141
|
+
label: `Label ${i}`,
|
|
142
|
+
},
|
|
143
|
+
slots: {},
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
await Promise.all(wrapperList.map((w) => w.vm.$nextTick()));
|
|
148
|
+
|
|
149
|
+
const ids = wrapperList.map((w) => w.find("input").attributes("id"));
|
|
150
|
+
|
|
151
|
+
expect(new Set(ids).size).toBe(NUMBER_OF_INPUTS);
|
|
152
|
+
});
|
|
153
|
+
});
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { IconVariant } from "@fiscozen/icons";
|
|
2
|
+
|
|
3
|
+
type FzInputProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The label displayed on top of the input
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* The size of the input
|
|
10
|
+
*/
|
|
11
|
+
size?: "sm" | "md" | "lg";
|
|
12
|
+
/**
|
|
13
|
+
* The placeholder displayed in the input
|
|
14
|
+
*/
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
/**
|
|
17
|
+
* If set to true, the input is required
|
|
18
|
+
*/
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If set to true, the input is disabled
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If set to true, the input is in error state
|
|
26
|
+
*/
|
|
27
|
+
error?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Left icon name
|
|
30
|
+
*/
|
|
31
|
+
leftIcon?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Left icon variant
|
|
34
|
+
*/
|
|
35
|
+
leftIconVariant?: IconVariant;
|
|
36
|
+
/**
|
|
37
|
+
* Right icon name
|
|
38
|
+
*/
|
|
39
|
+
rightIcon?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Right icon variant
|
|
42
|
+
*/
|
|
43
|
+
rightIconVariant?: IconVariant;
|
|
44
|
+
/**
|
|
45
|
+
* The input type
|
|
46
|
+
*/
|
|
47
|
+
type?: "text" | "password" | "email" | "number" | "tel" | "url";
|
|
48
|
+
/**
|
|
49
|
+
* If set to true, the input is valid
|
|
50
|
+
*/
|
|
51
|
+
valid?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Pattern to validate the input
|
|
54
|
+
*/
|
|
55
|
+
pattern?: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { FzInputProps };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { computed, Ref } from "vue";
|
|
2
|
+
import { FzInputProps } from "./types";
|
|
3
|
+
|
|
4
|
+
export default function useInputStyle(
|
|
5
|
+
props: FzInputProps,
|
|
6
|
+
container: Ref<HTMLElement | null>,
|
|
7
|
+
) {
|
|
8
|
+
const containerWidth = computed(() =>
|
|
9
|
+
container.value ? `${container.value.clientWidth}px` : "auto",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const mapContainerClass = {
|
|
13
|
+
sm: "h-28 text-sm",
|
|
14
|
+
md: "h-32 text-base",
|
|
15
|
+
lg: "h-40 text-lg",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const staticContainerClass = `flex justify-between w-full items-center px-10 border-1 rounded gap-8 text-left has-[:focus]:border-blue-600`;
|
|
19
|
+
|
|
20
|
+
const computedContainerClass = computed(() => [
|
|
21
|
+
mapContainerClass[props.size!],
|
|
22
|
+
evaluateProps(),
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const computedLabelClass = computed(() => [
|
|
26
|
+
props.disabled ? "text-grey-300" : "text-core-black",
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const staticInputClass = `peer w-full bg-transparent border-0 focus:outline-none cursor-[inherit] focus:ring-0 truncate`;
|
|
30
|
+
|
|
31
|
+
const computedHelpClass = computed(() => [
|
|
32
|
+
props.size === "sm" ? "text-xs" : "",
|
|
33
|
+
props.size === "md" ? "text-sm" : "",
|
|
34
|
+
props.size === "lg" ? "text-base" : "",
|
|
35
|
+
props.disabled ? "text-grey-300" : "text-grey-500",
|
|
36
|
+
]);
|
|
37
|
+
const computedErrorClass = computed(() => [
|
|
38
|
+
props.size === "sm" ? "text-xs" : "",
|
|
39
|
+
props.size === "md" ? "text-sm" : "",
|
|
40
|
+
props.size === "lg" ? "text-base" : "",
|
|
41
|
+
props.disabled ? "text-grey-300" : "text-core-black",
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const evaluateProps = () => {
|
|
45
|
+
switch (true) {
|
|
46
|
+
case props.disabled:
|
|
47
|
+
return "bg-grey-100 border-grey-100 text-grey-300 cursor-not-allowed";
|
|
48
|
+
case props.error:
|
|
49
|
+
return "border-semantic-error bg-white text-core-black cursor-text";
|
|
50
|
+
default:
|
|
51
|
+
return "border-grey-300 bg-white text-core-black cursor-text";
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
staticContainerClass,
|
|
57
|
+
computedContainerClass,
|
|
58
|
+
computedLabelClass,
|
|
59
|
+
staticInputClass,
|
|
60
|
+
computedHelpClass,
|
|
61
|
+
computedErrorClass,
|
|
62
|
+
containerWidth,
|
|
63
|
+
};
|
|
64
|
+
}
|
package/tsconfig.json
ADDED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { defineConfig } from 'vite'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import dts from 'vite-plugin-dts'
|
|
6
|
+
|
|
7
|
+
// https://vitejs.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
vue(),
|
|
11
|
+
dts({
|
|
12
|
+
insertTypesEntry: true,
|
|
13
|
+
})
|
|
14
|
+
],
|
|
15
|
+
resolve: {
|
|
16
|
+
alias: {
|
|
17
|
+
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
build: {
|
|
21
|
+
lib: {
|
|
22
|
+
entry: resolve(__dirname, './src/index.ts'),
|
|
23
|
+
name: 'FzInput',
|
|
24
|
+
},
|
|
25
|
+
rollupOptions: {
|
|
26
|
+
external: ['vue'],
|
|
27
|
+
output: {
|
|
28
|
+
globals: {
|
|
29
|
+
vue: 'Vue',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
|
|
3
|
+
import viteConfig from './vite.config'
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
viteConfig,
|
|
7
|
+
defineConfig({
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'jsdom',
|
|
10
|
+
exclude: [...configDefaults.exclude, 'e2e/*'],
|
|
11
|
+
root: fileURLToPath(new URL('./', import.meta.url)),
|
|
12
|
+
coverage: {
|
|
13
|
+
provider: 'v8',
|
|
14
|
+
include: ['**/src/**'],
|
|
15
|
+
exclude: ['**/index.ts']
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
)
|