@spectrum-web-components/number-field 0.3.13 → 0.4.1-devmode.7
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 +26 -13
- package/sp-number-field.dev.js +3 -0
- package/sp-number-field.dev.js.map +7 -0
- package/sp-number-field.js +3 -14
- package/sp-number-field.js.map +7 -1
- package/src/NumberField.dev.js +499 -0
- package/src/NumberField.dev.js.map +7 -0
- package/src/NumberField.js +452 -504
- package/src/NumberField.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/number-field.css.dev.js +147 -0
- package/src/number-field.css.dev.js.map +7 -0
- package/src/number-field.css.js +6 -15
- package/src/number-field.css.js.map +7 -1
- package/src/spectrum-number-field.css.dev.js +143 -0
- package/src/spectrum-number-field.css.dev.js.map +7 -0
- package/src/spectrum-number-field.css.js +3 -14
- package/src/spectrum-number-field.css.js.map +7 -1
- package/stories/number-field.stories.js +215 -229
- package/stories/number-field.stories.js.map +7 -1
- package/test/benchmark/basic-test.js +5 -16
- package/test/benchmark/basic-test.js.map +7 -1
- package/test/helpers.js +44 -55
- package/test/helpers.js.map +7 -1
- package/test/inputs.test.js +340 -350
- package/test/inputs.test.js.map +7 -1
- package/test/number-field.test-vrt.js +4 -15
- package/test/number-field.test-vrt.js.map +7 -1
- package/test/number-field.test.js +1135 -1135
- package/test/number-field.test.js.map +7 -1
package/test/inputs.test.js
CHANGED
|
@@ -1,385 +1,375 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
describe('keystroke prevention', () => {
|
|
31
|
-
it('converts 2 byte characters, default', async () => {
|
|
32
|
-
const el = await getElFrom(html `
|
|
1
|
+
import { html } from "@spectrum-web-components/base";
|
|
2
|
+
import { elementUpdated, expect } from "@open-wc/testing";
|
|
3
|
+
import { createLanguageContext, getElFrom } from "./helpers.js";
|
|
4
|
+
import polyfillCheck from "@formatjs/intl-numberformat/should-polyfill.js";
|
|
5
|
+
import "@spectrum-web-components/number-field/sp-number-field.js";
|
|
6
|
+
import { remapMultiByteCharacters } from "@spectrum-web-components/number-field";
|
|
7
|
+
import {
|
|
8
|
+
currency,
|
|
9
|
+
decimals,
|
|
10
|
+
Default,
|
|
11
|
+
minMax,
|
|
12
|
+
percents
|
|
13
|
+
} from "../stories/number-field.stories.js";
|
|
14
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
15
|
+
describe("NumberField - inputs", () => {
|
|
16
|
+
before(async () => {
|
|
17
|
+
if (polyfillCheck.shouldPolyfill()) {
|
|
18
|
+
await import("@formatjs/intl-numberformat/polyfill.js");
|
|
19
|
+
}
|
|
20
|
+
if (Intl.NumberFormat.polyfilled) {
|
|
21
|
+
await import("@formatjs/intl-numberformat/locale-data/en.js");
|
|
22
|
+
await import("@formatjs/intl-numberformat/locale-data/es.js");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
describe("keystroke prevention", () => {
|
|
26
|
+
it("converts 2 byte characters, default", async () => {
|
|
27
|
+
const el = await getElFrom(html`
|
|
33
28
|
${Default()}
|
|
34
29
|
`);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
await elementUpdated(el);
|
|
31
|
+
el.focus();
|
|
32
|
+
await sendKeys({
|
|
33
|
+
type: "\uFF13\u3001\uFF15\uFF16\uFF17\u3001\uFF18\uFF19\uFF10\u3002\uFF11"
|
|
34
|
+
});
|
|
35
|
+
await elementUpdated(el);
|
|
36
|
+
expect(el.formattedValue).to.equal("3,567,890.1");
|
|
37
|
+
});
|
|
38
|
+
it("converts 2 byte characters, percents", async () => {
|
|
39
|
+
const el = await getElFrom(html`
|
|
45
40
|
${percents()}
|
|
46
41
|
`);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
await elementUpdated(el);
|
|
43
|
+
el.focus();
|
|
44
|
+
await sendKeys({
|
|
45
|
+
type: "\uFF12\uFF14\uFF05"
|
|
46
|
+
});
|
|
47
|
+
await elementUpdated(el);
|
|
48
|
+
expect(el.formattedValue).to.equal("24%");
|
|
49
|
+
});
|
|
50
|
+
it('prevents second "." in EN', async () => {
|
|
51
|
+
const el = await getElFrom(html`
|
|
57
52
|
${Default()}
|
|
58
53
|
`);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
el.formatOptions = {
|
|
55
|
+
maximumFractionDigits: 2
|
|
56
|
+
};
|
|
57
|
+
await elementUpdated(el);
|
|
58
|
+
el.focus();
|
|
59
|
+
await sendKeys({
|
|
60
|
+
type: "1.1.1"
|
|
61
|
+
});
|
|
62
|
+
await elementUpdated(el);
|
|
63
|
+
expect(el.formattedValue).to.equal("1.11");
|
|
64
|
+
});
|
|
65
|
+
it("prevents text characters", async () => {
|
|
66
|
+
const el = await getElFrom(html`
|
|
72
67
|
${Default()}
|
|
73
68
|
`);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
el.formatOptions = {
|
|
70
|
+
maximumFractionDigits: 1
|
|
71
|
+
};
|
|
72
|
+
await elementUpdated(el);
|
|
73
|
+
el.focus();
|
|
74
|
+
await sendKeys({
|
|
75
|
+
type: "D2.2"
|
|
76
|
+
});
|
|
77
|
+
await elementUpdated(el);
|
|
78
|
+
expect(el.formattedValue).to.equal("2.2");
|
|
79
|
+
el.value = NaN;
|
|
80
|
+
await sendKeys({
|
|
81
|
+
type: "8u23.s7"
|
|
82
|
+
});
|
|
83
|
+
await elementUpdated(el);
|
|
84
|
+
expect(el.formattedValue).to.equal("823.7");
|
|
85
|
+
});
|
|
86
|
+
it('allows "-" to start', async () => {
|
|
87
|
+
const el = await getElFrom(html`
|
|
93
88
|
${Default()}
|
|
94
89
|
`);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
90
|
+
await elementUpdated(el);
|
|
91
|
+
el.focus();
|
|
92
|
+
await sendKeys({
|
|
93
|
+
type: "-54"
|
|
94
|
+
});
|
|
95
|
+
await elementUpdated(el);
|
|
96
|
+
expect(el.formattedValue).to.equal("-54");
|
|
97
|
+
});
|
|
98
|
+
it('prevents "-" not at the start', async () => {
|
|
99
|
+
const el = await getElFrom(html`
|
|
105
100
|
${Default()}
|
|
106
101
|
`);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
102
|
+
await elementUpdated(el);
|
|
103
|
+
el.focus();
|
|
104
|
+
await sendKeys({
|
|
105
|
+
type: "54-"
|
|
106
|
+
});
|
|
107
|
+
await elementUpdated(el);
|
|
108
|
+
expect(el.formattedValue).to.equal("54");
|
|
109
|
+
el.value = NaN;
|
|
110
|
+
await sendKeys({
|
|
111
|
+
type: "5-4"
|
|
112
|
+
});
|
|
113
|
+
await elementUpdated(el);
|
|
114
|
+
expect(el.formattedValue).to.equal("54");
|
|
115
|
+
});
|
|
116
|
+
it('prevent "+" to start, normally', async () => {
|
|
117
|
+
const el = await getElFrom(html`
|
|
123
118
|
${Default()}
|
|
124
119
|
`);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
120
|
+
await elementUpdated(el);
|
|
121
|
+
el.focus();
|
|
122
|
+
await sendKeys({
|
|
123
|
+
type: "+54"
|
|
124
|
+
});
|
|
125
|
+
await elementUpdated(el);
|
|
126
|
+
expect(el.formattedValue).to.equal("54");
|
|
127
|
+
});
|
|
128
|
+
it('allow "+" to start when "signDisplay: always"', async () => {
|
|
129
|
+
const el = await getElFrom(html`
|
|
135
130
|
${Default()}
|
|
136
131
|
`);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
await elementUpdated(el);
|
|
133
|
+
el.formatOptions = {
|
|
134
|
+
signDisplay: "always"
|
|
135
|
+
};
|
|
136
|
+
el.focus();
|
|
137
|
+
await sendKeys({
|
|
138
|
+
type: "+54"
|
|
139
|
+
});
|
|
140
|
+
await elementUpdated(el);
|
|
141
|
+
expect(el.formattedValue).to.equal("+54");
|
|
142
|
+
});
|
|
143
|
+
it('prevents "%" when when not percents', async () => {
|
|
144
|
+
const el = await getElFrom(html`
|
|
150
145
|
${Default()}
|
|
151
146
|
`);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
147
|
+
await elementUpdated(el);
|
|
148
|
+
el.focus();
|
|
149
|
+
await sendKeys({
|
|
150
|
+
type: "63%"
|
|
151
|
+
});
|
|
152
|
+
await elementUpdated(el);
|
|
153
|
+
expect(el.formattedValue).to.equal("63");
|
|
154
|
+
el.blur();
|
|
155
|
+
await elementUpdated(el);
|
|
156
|
+
expect(el.formattedValue).to.equal("63");
|
|
157
|
+
});
|
|
158
|
+
it('allows "%" when percents, and keeps "%" on blur', async () => {
|
|
159
|
+
const el = await getElFrom(html`
|
|
165
160
|
${percents()}
|
|
166
161
|
`);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
await elementUpdated(el);
|
|
163
|
+
el.focus();
|
|
164
|
+
await sendKeys({
|
|
165
|
+
type: "63%"
|
|
166
|
+
});
|
|
167
|
+
await elementUpdated(el);
|
|
168
|
+
expect(el.formattedValue).to.equal("63%");
|
|
169
|
+
el.blur();
|
|
170
|
+
await elementUpdated(el);
|
|
171
|
+
expect(el.formattedValue).to.equal("63%");
|
|
172
|
+
});
|
|
173
|
+
it('prevents "Backspace" on curreny value text, and keeps currency value text of blur', async () => {
|
|
174
|
+
const el = await getElFrom(html`
|
|
180
175
|
${currency({ value: 234.21 })}
|
|
181
176
|
`);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
it('prevents "." when `maximumFractionDigits: 0`', async () => {
|
|
198
|
-
const el = await getElFrom(html `
|
|
177
|
+
await elementUpdated(el);
|
|
178
|
+
expect(el.formattedValue).to.equal("EUR\xA0234.21");
|
|
179
|
+
el.focus();
|
|
180
|
+
el.inputElement.setSelectionRange(2, 2);
|
|
181
|
+
await sendKeys({
|
|
182
|
+
press: "Backspace"
|
|
183
|
+
});
|
|
184
|
+
await elementUpdated(el);
|
|
185
|
+
expect(el.inputElement.value).to.equal("EUR\xA0234.21");
|
|
186
|
+
el.blur();
|
|
187
|
+
await elementUpdated(el);
|
|
188
|
+
expect(el.inputElement.value).to.equal("EUR\xA0234.21");
|
|
189
|
+
});
|
|
190
|
+
it('prevents "." when `maximumFractionDigits: 0`', async () => {
|
|
191
|
+
const el = await getElFrom(html`
|
|
199
192
|
${Default()}
|
|
200
193
|
`);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const el = await getElFrom(html `
|
|
194
|
+
await elementUpdated(el);
|
|
195
|
+
el.formatOptions = {
|
|
196
|
+
maximumFractionDigits: 0
|
|
197
|
+
};
|
|
198
|
+
el.focus();
|
|
199
|
+
await elementUpdated(el);
|
|
200
|
+
await sendKeys({
|
|
201
|
+
type: "5.2"
|
|
202
|
+
});
|
|
203
|
+
await elementUpdated(el);
|
|
204
|
+
expect(el.formattedValue).to.equal("52");
|
|
205
|
+
await sendKeys({
|
|
206
|
+
press: "Enter"
|
|
207
|
+
});
|
|
208
|
+
await elementUpdated(el);
|
|
209
|
+
expect(el.value).to.equal(52);
|
|
210
|
+
});
|
|
211
|
+
xit("allow arabic numerals entered", async () => {
|
|
212
|
+
const el = await getElFrom(html`
|
|
221
213
|
${Default()}
|
|
222
214
|
`);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const el = await getElFrom(html `
|
|
215
|
+
await elementUpdated(el);
|
|
216
|
+
el.focus();
|
|
217
|
+
await elementUpdated(el);
|
|
218
|
+
await sendKeys({
|
|
219
|
+
type: "\u0662\u0661"
|
|
220
|
+
});
|
|
221
|
+
await elementUpdated(el);
|
|
222
|
+
expect(el.formattedValue).to.equal("21");
|
|
223
|
+
await sendKeys({
|
|
224
|
+
press: "Enter"
|
|
225
|
+
});
|
|
226
|
+
await elementUpdated(el);
|
|
227
|
+
expect(el.value).to.equal(21);
|
|
228
|
+
});
|
|
229
|
+
xit("allow hanidec numerals entered", async () => {
|
|
230
|
+
const el = await getElFrom(html`
|
|
240
231
|
${Default()}
|
|
241
232
|
`);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
233
|
+
await elementUpdated(el);
|
|
234
|
+
el.focus();
|
|
235
|
+
await elementUpdated(el);
|
|
236
|
+
await sendKeys({
|
|
237
|
+
type: "\u4E8C\u4E00"
|
|
238
|
+
});
|
|
239
|
+
await elementUpdated(el);
|
|
240
|
+
expect(el.formattedValue).to.equal("21");
|
|
241
|
+
await sendKeys({
|
|
242
|
+
press: "Enter"
|
|
243
|
+
});
|
|
244
|
+
await elementUpdated(el);
|
|
245
|
+
expect(el.value).to.equal(21);
|
|
256
246
|
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
247
|
+
});
|
|
248
|
+
describe("user suplied large numbers", () => {
|
|
249
|
+
it("do not crash the Number Field", async () => {
|
|
250
|
+
const el = await getElFrom(minMax(minMax.args));
|
|
251
|
+
await elementUpdated(el);
|
|
252
|
+
el.focus();
|
|
253
|
+
await sendKeys({
|
|
254
|
+
type: "12345678901234567890"
|
|
255
|
+
});
|
|
256
|
+
await elementUpdated(el);
|
|
257
|
+
expect(el.formattedValue).to.equal("255");
|
|
258
|
+
await sendKeys({
|
|
259
|
+
press: "Enter"
|
|
260
|
+
});
|
|
261
|
+
await elementUpdated(el);
|
|
262
|
+
expect(el.value).to.equal(255);
|
|
273
263
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
264
|
+
});
|
|
265
|
+
describe("locale specific", () => {
|
|
266
|
+
it("can determine the group symbol", async () => {
|
|
267
|
+
const languageContext = createLanguageContext("es-ES");
|
|
268
|
+
const el = await getElFrom(html`
|
|
278
269
|
<div @sp-language-context=${languageContext}>${Default()}</div>
|
|
279
270
|
`);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
271
|
+
await elementUpdated(el);
|
|
272
|
+
el.focus();
|
|
273
|
+
await sendKeys({
|
|
274
|
+
type: "123.456.789"
|
|
275
|
+
});
|
|
276
|
+
await elementUpdated(el);
|
|
277
|
+
expect(el.formattedValue).to.equal("123.456.789");
|
|
278
|
+
await sendKeys({
|
|
279
|
+
press: "Tab"
|
|
280
|
+
});
|
|
281
|
+
await elementUpdated(el);
|
|
282
|
+
expect(el.formattedValue).to.equal("123.456.789");
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
describe("2-byte characters", () => {
|
|
286
|
+
const numbers = Object.keys(remapMultiByteCharacters);
|
|
287
|
+
numbers.splice(10);
|
|
288
|
+
numbers.forEach((input) => {
|
|
289
|
+
const actual = remapMultiByteCharacters[input];
|
|
290
|
+
it(`accepts "${input}" as "${actual}"`, async () => {
|
|
291
|
+
const el = await getElFrom(Default());
|
|
292
|
+
el.focusElement.value = input;
|
|
293
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
294
|
+
bubbles: true,
|
|
295
|
+
cancelable: true,
|
|
296
|
+
composed: true
|
|
297
|
+
}));
|
|
298
|
+
await elementUpdated(el);
|
|
299
|
+
expect(el.formattedValue).to.equal(actual);
|
|
300
|
+
expect(el.value).to.equal(Number(actual));
|
|
301
|
+
});
|
|
302
|
+
});
|
|
303
|
+
it('accepts "\u3001" as "," and "\u3002" as "."', async () => {
|
|
304
|
+
const el = await getElFrom(Default(Default.args));
|
|
305
|
+
el.focusElement.value = "\uFF11\u3001\uFF12\uFF13\uFF14\u3002\uFF156";
|
|
306
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
307
|
+
bubbles: true,
|
|
308
|
+
cancelable: true,
|
|
309
|
+
composed: true
|
|
310
|
+
}));
|
|
311
|
+
await elementUpdated(el);
|
|
312
|
+
expect(el.formattedValue).to.equal("1,234.56");
|
|
313
|
+
expect(el.value).to.equal(Number(1234.56));
|
|
314
|
+
});
|
|
315
|
+
it('accepts misplaced "\u3001" and corrects them', async () => {
|
|
316
|
+
const el = await getElFrom(Default(Default.args));
|
|
317
|
+
const nextFocusableElement = document.createElement("input");
|
|
318
|
+
el.insertAdjacentElement("afterend", nextFocusableElement);
|
|
319
|
+
el.focus();
|
|
320
|
+
await elementUpdated(el);
|
|
321
|
+
el.focusElement.value = "\uFF11\uFF12\u3001\uFF13\uFF14\uFF15\uFF16\u3001\uFF17\u3002\uFF18\uFF19";
|
|
322
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
323
|
+
bubbles: true,
|
|
324
|
+
cancelable: true,
|
|
325
|
+
composed: true
|
|
326
|
+
}));
|
|
327
|
+
await elementUpdated(el);
|
|
328
|
+
expect(el.focusElement.value, "visible").to.equal("12,3456,7.89");
|
|
329
|
+
expect(el.formattedValue, "tracked").to.equal("1,234,567.89");
|
|
330
|
+
expect(el.value, "value").to.equal(Number(123456789e-2));
|
|
331
|
+
await sendKeys({
|
|
332
|
+
press: "Tab"
|
|
333
|
+
});
|
|
334
|
+
await elementUpdated(el);
|
|
335
|
+
expect(el.focusElement.value, "visible").to.equal("1,234,567.89");
|
|
336
|
+
expect(el.formattedValue, "tracked").to.equal("1,234,567.89");
|
|
337
|
+
expect(el.value, "value").to.equal(Number(123456789e-2));
|
|
338
|
+
nextFocusableElement.remove();
|
|
339
|
+
});
|
|
340
|
+
it('accepts "\uFF0B" as "+" and "\u30FC" as "-"', async () => {
|
|
341
|
+
const el = await getElFrom(decimals(decimals.args));
|
|
342
|
+
el.focusElement.value = "\uFF0B\uFF19\u3002\uFF18\uFF17";
|
|
343
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
344
|
+
bubbles: true,
|
|
345
|
+
cancelable: true,
|
|
346
|
+
composed: true
|
|
347
|
+
}));
|
|
348
|
+
await elementUpdated(el);
|
|
349
|
+
expect(el.formattedValue).to.equal("+9.87");
|
|
350
|
+
expect(el.value).to.equal(Number(9.87));
|
|
351
|
+
el.focusElement.value = "\u30FC\uFF19\uFF0E\uFF18\uFF17";
|
|
352
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
353
|
+
bubbles: true,
|
|
354
|
+
cancelable: true,
|
|
355
|
+
composed: true
|
|
356
|
+
}));
|
|
357
|
+
await elementUpdated(el);
|
|
358
|
+
expect(el.formattedValue).to.equal("-9.87");
|
|
359
|
+
expect(el.value).to.equal(Number(-9.87));
|
|
293
360
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
cancelable: true,
|
|
306
|
-
composed: true,
|
|
307
|
-
}));
|
|
308
|
-
await elementUpdated(el);
|
|
309
|
-
expect(el.formattedValue).to.equal(actual);
|
|
310
|
-
expect(el.value).to.equal(Number(actual));
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
it('accepts "、" as "," and "。" as "."', async () => {
|
|
314
|
-
const el = await getElFrom(Default(Default.args));
|
|
315
|
-
el.focusElement.value = '1、234。56';
|
|
316
|
-
el.focusElement.dispatchEvent(new Event('input', {
|
|
317
|
-
bubbles: true,
|
|
318
|
-
cancelable: true,
|
|
319
|
-
composed: true,
|
|
320
|
-
}));
|
|
321
|
-
await elementUpdated(el);
|
|
322
|
-
expect(el.formattedValue).to.equal('1,234.56');
|
|
323
|
-
expect(el.value).to.equal(Number(1234.56));
|
|
324
|
-
});
|
|
325
|
-
it('accepts misplaced "、" and corrects them', async () => {
|
|
326
|
-
const el = await getElFrom(Default(Default.args));
|
|
327
|
-
const nextFocusableElement = document.createElement('input');
|
|
328
|
-
el.insertAdjacentElement('afterend', nextFocusableElement);
|
|
329
|
-
el.focus();
|
|
330
|
-
await elementUpdated(el);
|
|
331
|
-
el.focusElement.value = '12、3456、7。89';
|
|
332
|
-
el.focusElement.dispatchEvent(new Event('input', {
|
|
333
|
-
bubbles: true,
|
|
334
|
-
cancelable: true,
|
|
335
|
-
composed: true,
|
|
336
|
-
}));
|
|
337
|
-
await elementUpdated(el);
|
|
338
|
-
expect(el.focusElement.value, 'visible').to.equal('12,3456,7.89');
|
|
339
|
-
expect(el.formattedValue, 'tracked').to.equal('1,234,567.89');
|
|
340
|
-
expect(el.value, 'value').to.equal(Number(1234567.89));
|
|
341
|
-
await sendKeys({
|
|
342
|
-
press: 'Tab',
|
|
343
|
-
});
|
|
344
|
-
await elementUpdated(el);
|
|
345
|
-
expect(el.focusElement.value, 'visible').to.equal('1,234,567.89');
|
|
346
|
-
expect(el.formattedValue, 'tracked').to.equal('1,234,567.89');
|
|
347
|
-
expect(el.value, 'value').to.equal(Number(1234567.89));
|
|
348
|
-
nextFocusableElement.remove();
|
|
349
|
-
});
|
|
350
|
-
it('accepts "+" as "+" and "ー" as "-"', async () => {
|
|
351
|
-
const el = await getElFrom(decimals(decimals.args));
|
|
352
|
-
el.focusElement.value = '+9。87';
|
|
353
|
-
el.focusElement.dispatchEvent(new Event('input', {
|
|
354
|
-
bubbles: true,
|
|
355
|
-
cancelable: true,
|
|
356
|
-
composed: true,
|
|
357
|
-
}));
|
|
358
|
-
await elementUpdated(el);
|
|
359
|
-
expect(el.formattedValue).to.equal('+9.87');
|
|
360
|
-
expect(el.value).to.equal(Number(9.87));
|
|
361
|
-
el.focusElement.value = 'ー9.87';
|
|
362
|
-
el.focusElement.dispatchEvent(new Event('input', {
|
|
363
|
-
bubbles: true,
|
|
364
|
-
cancelable: true,
|
|
365
|
-
composed: true,
|
|
366
|
-
}));
|
|
367
|
-
await elementUpdated(el);
|
|
368
|
-
expect(el.formattedValue).to.equal('-9.87');
|
|
369
|
-
expect(el.value).to.equal(Number(-9.87));
|
|
370
|
-
});
|
|
371
|
-
it('accepts "%" as "%"', async () => {
|
|
372
|
-
const el = await getElFrom(percents(percents.args));
|
|
373
|
-
el.focusElement.value = '10%';
|
|
374
|
-
el.focusElement.dispatchEvent(new Event('input', {
|
|
375
|
-
bubbles: true,
|
|
376
|
-
cancelable: true,
|
|
377
|
-
composed: true,
|
|
378
|
-
}));
|
|
379
|
-
await elementUpdated(el);
|
|
380
|
-
expect(el.formattedValue).to.equal('10%');
|
|
381
|
-
expect(el.value).to.equal(Number(0.1));
|
|
382
|
-
});
|
|
361
|
+
it('accepts "\uFF05" as "%"', async () => {
|
|
362
|
+
const el = await getElFrom(percents(percents.args));
|
|
363
|
+
el.focusElement.value = "\uFF11\uFF10\uFF05";
|
|
364
|
+
el.focusElement.dispatchEvent(new Event("input", {
|
|
365
|
+
bubbles: true,
|
|
366
|
+
cancelable: true,
|
|
367
|
+
composed: true
|
|
368
|
+
}));
|
|
369
|
+
await elementUpdated(el);
|
|
370
|
+
expect(el.formattedValue).to.equal("10%");
|
|
371
|
+
expect(el.value).to.equal(Number(0.1));
|
|
383
372
|
});
|
|
373
|
+
});
|
|
384
374
|
});
|
|
385
|
-
//# sourceMappingURL=inputs.test.js.map
|
|
375
|
+
//# sourceMappingURL=inputs.test.js.map
|