@fiscozen/input 0.1.16 → 1.0.0-next.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/README.md +718 -1
- package/coverage/FzCurrencyInput.vue.html +640 -0
- package/coverage/FzInput.vue.html +709 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +494 -0
- package/coverage/coverage-final.json +4 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +146 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/useInputStyle.ts.html +343 -0
- package/dist/index.d.ts +1 -0
- package/dist/input.js +7950 -0
- package/dist/input.umd.cjs +561 -0
- package/dist/src/FzCurrencyInput.vue.d.ts +202 -0
- package/dist/src/FzInput.vue.d.ts +254 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/types.d.ts +247 -0
- package/dist/src/useInputStyle.d.ts +27 -0
- package/dist/src/utils.d.ts +21 -0
- package/dist/style.css +1 -0
- package/package.json +6 -6
- package/src/FzCurrencyInput.vue +746 -106
- package/src/FzInput.vue +467 -97
- package/src/__tests__/FzCurrencyInput.test.ts +1528 -0
- package/src/__tests__/FzInput.test.ts +1005 -0
- package/src/index.ts +3 -0
- package/src/types.ts +171 -46
- package/src/useInputStyle.ts +96 -38
- package/src/utils.ts +64 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/FzCurrencyInput.spec.ts +0 -204
- package/src/__tests__/FzInput.spec.ts +0 -181
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { mount } from "@vue/test-utils";
|
|
3
|
-
import { FzCurrencyInput } from "..";
|
|
4
|
-
|
|
5
|
-
describe.concurrent("FzCurrencyInput", () => {
|
|
6
|
-
it("renders floating numbers as currency", async () => {
|
|
7
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
8
|
-
props: {
|
|
9
|
-
label: "Label",
|
|
10
|
-
amount: 1234.56,
|
|
11
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const inputElement = wrapper.find("input");
|
|
16
|
-
await inputElement.trigger("blur");
|
|
17
|
-
// flushPromises doesn't seem to be enoughsince the implementation
|
|
18
|
-
// of the composable uses setTimeout itself
|
|
19
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
20
|
-
expect(inputElement.element.value).toBe("1234,56");
|
|
21
|
-
});
|
|
22
|
-
it("should not allow inputs other than digits and separators", async () => {
|
|
23
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
24
|
-
props: {
|
|
25
|
-
label: "Label",
|
|
26
|
-
amount: 0,
|
|
27
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const inputElement = wrapper.find("input");
|
|
32
|
-
await inputElement.setValue("as12.3");
|
|
33
|
-
await inputElement.trigger("input");
|
|
34
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
35
|
-
expect(inputElement.element.value).toBe("12.3");
|
|
36
|
-
await inputElement.trigger("blur");
|
|
37
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
38
|
-
expect(inputElement.element.value).toBe("12,30");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should allow to set value at 0", async () => {
|
|
42
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
43
|
-
props: {
|
|
44
|
-
label: "Label",
|
|
45
|
-
amount: 10,
|
|
46
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const inputElement = wrapper.find("input");
|
|
51
|
-
await inputElement.trigger("blur");
|
|
52
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
53
|
-
expect(inputElement.element.value).toBe("10,00");
|
|
54
|
-
wrapper.setProps({ amount: 0 });
|
|
55
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
56
|
-
expect(inputElement.element.value).toBe("0,00");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should handle pasted values using the best possible euristic to parse and render it correctly", async () => {
|
|
60
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
61
|
-
props: {
|
|
62
|
-
label: "Label",
|
|
63
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const inputElement = wrapper.find("input");
|
|
68
|
-
// we need to mock the paste event
|
|
69
|
-
await inputElement.trigger("paste", {
|
|
70
|
-
clipboardData: {
|
|
71
|
-
getData() {
|
|
72
|
-
return "1.233.222,43";
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
77
|
-
expect(inputElement.element.value).toBe("1233222,43");
|
|
78
|
-
|
|
79
|
-
await inputElement.trigger("paste", {
|
|
80
|
-
clipboardData: {
|
|
81
|
-
getData() {
|
|
82
|
-
return "1.23";
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
87
|
-
expect(inputElement.element.value).toBe("1,23");
|
|
88
|
-
|
|
89
|
-
await inputElement.trigger("paste", {
|
|
90
|
-
clipboardData: {
|
|
91
|
-
getData() {
|
|
92
|
-
return "1,23";
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
97
|
-
expect(inputElement.element.value).toBe("1,23");
|
|
98
|
-
|
|
99
|
-
await inputElement.trigger("paste", {
|
|
100
|
-
clipboardData: {
|
|
101
|
-
getData() {
|
|
102
|
-
return "1.232.111";
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
107
|
-
expect(inputElement.element.value).toBe("1232111,00");
|
|
108
|
-
|
|
109
|
-
await inputElement.trigger("paste", {
|
|
110
|
-
clipboardData: {
|
|
111
|
-
getData() {
|
|
112
|
-
return "1.232";
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
117
|
-
expect(inputElement.element.value).toBe("1,23");
|
|
118
|
-
|
|
119
|
-
await inputElement.trigger("paste", {
|
|
120
|
-
clipboardData: {
|
|
121
|
-
getData() {
|
|
122
|
-
return "1.232555";
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
127
|
-
expect(inputElement.element.value).toBe("1,23");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("should limit value according to min/max setting", async () => {
|
|
131
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
132
|
-
props: {
|
|
133
|
-
label: "Label",
|
|
134
|
-
amount: 10,
|
|
135
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
136
|
-
min: 2,
|
|
137
|
-
max: 20,
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const inputElement = wrapper.find("input");
|
|
142
|
-
await inputElement.trigger("blur");
|
|
143
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
144
|
-
expect(inputElement.element.value).toBe("10,00");
|
|
145
|
-
await wrapper.setProps({ amount: 1 });
|
|
146
|
-
await inputElement.trigger("blur");
|
|
147
|
-
expect(inputElement.element.value).toBe("2,00");
|
|
148
|
-
await wrapper.setProps({ amount: 23 });
|
|
149
|
-
await inputElement.trigger("blur");
|
|
150
|
-
expect(inputElement.element.value).toBe("20,00");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("should step correctly when using quantization via the 'step' prop", async () => {
|
|
154
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
155
|
-
props: {
|
|
156
|
-
label: "Label",
|
|
157
|
-
amount: 1,
|
|
158
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
159
|
-
step: 4,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const inputElement = wrapper.find("input");
|
|
164
|
-
const arrowUp = wrapper.find(".fz__currencyinput__arrowup");
|
|
165
|
-
const arrowDown = wrapper.find(".fz__currencyinput__arrowdown");
|
|
166
|
-
|
|
167
|
-
await inputElement.trigger("blur");
|
|
168
|
-
expect(inputElement.element.value).toBe("1,00");
|
|
169
|
-
await arrowUp.trigger("click");
|
|
170
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
171
|
-
expect(inputElement.element.value).toBe("5,00");
|
|
172
|
-
await arrowDown.trigger("click");
|
|
173
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
174
|
-
expect(inputElement.element.value).toBe("1,00");
|
|
175
|
-
await arrowDown.trigger("click");
|
|
176
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
177
|
-
expect(inputElement.element.value).toBe("-3,00");
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("should enforce quantization via the 'forcedStep' prop", async () => {
|
|
181
|
-
const wrapper = mount(FzCurrencyInput, {
|
|
182
|
-
props: {
|
|
183
|
-
label: "Label",
|
|
184
|
-
amount: 8,
|
|
185
|
-
"onUpdate:amount": (e) => wrapper.setProps({ amount: e }),
|
|
186
|
-
step: 4,
|
|
187
|
-
forceStep: true,
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const inputElement = wrapper.find("input");
|
|
192
|
-
await inputElement.trigger("blur");
|
|
193
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
194
|
-
expect(inputElement.element.value).toBe("8,00");
|
|
195
|
-
await wrapper.setProps({ amount: 5 });
|
|
196
|
-
await inputElement.trigger("blur");
|
|
197
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
198
|
-
expect(inputElement.element.value).toBe("4,00");
|
|
199
|
-
await wrapper.setProps({ amount: -7 });
|
|
200
|
-
await inputElement.trigger("blur");
|
|
201
|
-
await new Promise((resolve) => window.setTimeout(resolve, 100));
|
|
202
|
-
expect(inputElement.element.value).toBe("-8,00");
|
|
203
|
-
});
|
|
204
|
-
});
|
|
@@ -1,181 +0,0 @@
|
|
|
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
|
-
|
|
154
|
-
it("emits fzinput:right-icon-click event", async ({ expect }) => {
|
|
155
|
-
const wrapper = mount(FzInput, {
|
|
156
|
-
props: {
|
|
157
|
-
label: "Label",
|
|
158
|
-
rightIcon: "eye",
|
|
159
|
-
},
|
|
160
|
-
slots: {},
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
await wrapper.find(".fa-eye").trigger("click");
|
|
164
|
-
|
|
165
|
-
expect(wrapper.emitted("fzinput:right-icon-click")).toBeTruthy();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("emits fzinput:left-icon-click event", async ({ expect }) => {
|
|
169
|
-
const wrapper = mount(FzInput, {
|
|
170
|
-
props: {
|
|
171
|
-
label: "Label",
|
|
172
|
-
leftIcon: "eye",
|
|
173
|
-
},
|
|
174
|
-
slots: {},
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await wrapper.find(".fa-eye").trigger("click");
|
|
178
|
-
|
|
179
|
-
expect(wrapper.emitted("fzinput:left-icon-click")).toBeTruthy();
|
|
180
|
-
});
|
|
181
|
-
});
|