awing-library 2.1.2-dev.582 → 2.1.2-dev.583
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.
|
@@ -6,7 +6,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
|
|
|
6
6
|
import { Constants } from "../../Commons/Constant.js";
|
|
7
7
|
import container from "./container.js";
|
|
8
8
|
var __webpack_modules__ = {
|
|
9
|
-
"
|
|
9
|
+
"AWING/DataInput": function(module) {
|
|
10
10
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
11
11
|
},
|
|
12
12
|
"../helper": function(module) {
|
|
@@ -23,7 +23,7 @@ function __webpack_require__(moduleId) {
|
|
|
23
23
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
24
|
return module.exports;
|
|
25
25
|
}
|
|
26
|
-
var index_js_ = __webpack_require__("
|
|
26
|
+
var index_js_ = __webpack_require__("AWING/DataInput");
|
|
27
27
|
jest.mock('../DataInput', ()=>({
|
|
28
28
|
__esModule: true,
|
|
29
29
|
default: jest.fn(),
|
|
@@ -91,7 +91,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
91
91
|
children: children
|
|
92
92
|
})
|
|
93
93
|
}));
|
|
94
|
-
const mockInputFactory = __webpack_require__("
|
|
94
|
+
const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
|
|
95
95
|
const mockCalculateValue = __webpack_require__("../helper").calculateValue;
|
|
96
96
|
const mockConvertFormulaToBinaryTree = __webpack_require__("../helper").convertFormulaToBinaryTree;
|
|
97
97
|
const mockReplaceFieldsValue = __webpack_require__("../helper").replaceFieldsValue;
|
|
@@ -5,7 +5,7 @@ import { act, fireEvent, render, screen, waitFor } from "@testing-library/react"
|
|
|
5
5
|
import containerOptimized from "./containerOptimized.js";
|
|
6
6
|
import { createFormStateManager } from "./formStateManager.js";
|
|
7
7
|
var __webpack_modules__ = {
|
|
8
|
-
"
|
|
8
|
+
"AWING/DataInput": function(module) {
|
|
9
9
|
module.exports = __WEBPACK_EXTERNAL_MODULE__DataInput_index_js_c7933a4f__;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
@@ -98,7 +98,7 @@ jest.mock('@mui/material', ()=>({
|
|
|
98
98
|
children: children
|
|
99
99
|
})
|
|
100
100
|
}));
|
|
101
|
-
const mockInputFactory = __webpack_require__("
|
|
101
|
+
const mockInputFactory = __webpack_require__("AWING/DataInput")["default"];
|
|
102
102
|
describe('DataForm Optimized - Performance Tests', ()=>{
|
|
103
103
|
let inputRenderCounts = {};
|
|
104
104
|
const mockFields = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeField.d.ts","sourceRoot":"","sources":["../../../src/AWING/DateRangePicker/DateRangeField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAyB,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMxC,UAAU,mBAAoB,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACxF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,WAA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AAO,EAAE,IAAI,CAAC;KACjB,CAAC;IACF,oBAAoB,CAAC,EAAE;QACnB,SAAS,EAAE,IAAI,CAAC;QAChB,OAAO,EAAE,IAAI,CAAC;KACjB,CAAC;CACL;AAyBD,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAogBjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -153,22 +153,29 @@ const DateRangeField_DateRangeField = ({ label = 'Khoảng thời gian', dateFor
|
|
|
153
153
|
oldValueRef.current.startMonth = 'MM';
|
|
154
154
|
} else {
|
|
155
155
|
const monthNum = parseInt(cleanInput);
|
|
156
|
-
const
|
|
157
|
-
|
|
156
|
+
const isFirstDigit = 'MM' === oldValueRef.current.startMonth;
|
|
157
|
+
const prevFirstDigit = oldValueRef.current.startMonth;
|
|
158
|
+
if (monthNum >= 2 && monthNum <= 9 && isFirstDigit) {
|
|
158
159
|
startMonth = `0${monthNum}`;
|
|
159
160
|
oldValueRef.current.startMonth = startMonth;
|
|
160
161
|
setTimeout(()=>{
|
|
161
162
|
input.setSelectionRange(startYearPos, startYearPos + 4);
|
|
162
163
|
oldValueRef.current.startMonth = 'MM';
|
|
163
164
|
}, 0);
|
|
164
|
-
} else if (1 === cleanInput.length && 1 === monthNum &&
|
|
165
|
+
} else if (1 === cleanInput.length && 1 === monthNum && isFirstDigit) {
|
|
165
166
|
startMonth = '01';
|
|
166
|
-
oldValueRef.current.startMonth =
|
|
167
|
+
oldValueRef.current.startMonth = '1';
|
|
167
168
|
setTimeout(()=>{
|
|
168
169
|
input.setSelectionRange(startMonthPos, startMonthPos + 2);
|
|
169
170
|
}, 0);
|
|
170
|
-
} else if (1 === cleanInput.length &&
|
|
171
|
-
|
|
171
|
+
} else if (1 === cleanInput.length && 0 === monthNum && isFirstDigit) {
|
|
172
|
+
startMonth = '01';
|
|
173
|
+
oldValueRef.current.startMonth = '0';
|
|
174
|
+
setTimeout(()=>{
|
|
175
|
+
input.setSelectionRange(startMonthPos, startMonthPos + 2);
|
|
176
|
+
}, 0);
|
|
177
|
+
} else if (1 === cleanInput.length && '1' === prevFirstDigit) {
|
|
178
|
+
const newMonthNum = parseInt(`1${cleanInput}`);
|
|
172
179
|
if (newMonthNum >= 10 && newMonthNum <= 12) {
|
|
173
180
|
startMonth = `${newMonthNum}`;
|
|
174
181
|
oldValueRef.current.startMonth = startMonth;
|
|
@@ -180,10 +187,21 @@ const DateRangeField_DateRangeField = ({ label = 'Khoảng thời gian', dateFor
|
|
|
180
187
|
startMonth = 'MM';
|
|
181
188
|
oldValueRef.current.startMonth = 'MM';
|
|
182
189
|
}
|
|
190
|
+
} else if (1 === cleanInput.length && '0' === prevFirstDigit) if (monthNum >= 1 && monthNum <= 9) {
|
|
191
|
+
startMonth = `0${monthNum}`;
|
|
192
|
+
oldValueRef.current.startMonth = startMonth;
|
|
193
|
+
setTimeout(()=>{
|
|
194
|
+
input.setSelectionRange(startYearPos, startYearPos + 4);
|
|
195
|
+
oldValueRef.current.startMonth = 'MM';
|
|
196
|
+
}, 0);
|
|
183
197
|
} else {
|
|
184
198
|
startMonth = 'MM';
|
|
185
199
|
oldValueRef.current.startMonth = 'MM';
|
|
186
200
|
}
|
|
201
|
+
else {
|
|
202
|
+
startMonth = 'MM';
|
|
203
|
+
oldValueRef.current.startMonth = 'MM';
|
|
204
|
+
}
|
|
187
205
|
}
|
|
188
206
|
} else if (cursorPosition >= startYearPos && cursorPosition <= startYearPos + 4) {
|
|
189
207
|
const cleanInput = inputValue.slice(startYearPos, startYearPos + 4).replace(/[^0-9]/g, '');
|
|
@@ -244,22 +262,29 @@ const DateRangeField_DateRangeField = ({ label = 'Khoảng thời gian', dateFor
|
|
|
244
262
|
oldValueRef.current.endMonth = 'MM';
|
|
245
263
|
} else {
|
|
246
264
|
const monthNum = parseInt(cleanInput);
|
|
247
|
-
const
|
|
248
|
-
|
|
265
|
+
const isFirstDigit = 'MM' === oldValueRef.current.endMonth;
|
|
266
|
+
const prevFirstDigit = oldValueRef.current.endMonth;
|
|
267
|
+
if (monthNum >= 2 && monthNum <= 9 && isFirstDigit) {
|
|
249
268
|
endMonth = `0${monthNum}`;
|
|
250
269
|
oldValueRef.current.endMonth = endMonth;
|
|
251
270
|
setTimeout(()=>{
|
|
252
271
|
input.setSelectionRange(endYearPos, endYearPos + 4);
|
|
253
272
|
oldValueRef.current.endMonth = 'MM';
|
|
254
273
|
}, 0);
|
|
255
|
-
} else if (1 === cleanInput.length && 1 === monthNum &&
|
|
274
|
+
} else if (1 === cleanInput.length && 1 === monthNum && isFirstDigit) {
|
|
256
275
|
endMonth = '01';
|
|
257
|
-
oldValueRef.current.endMonth =
|
|
276
|
+
oldValueRef.current.endMonth = '1';
|
|
258
277
|
setTimeout(()=>{
|
|
259
278
|
input.setSelectionRange(endMonthPos, endMonthPos + 2);
|
|
260
279
|
}, 0);
|
|
261
|
-
} else if (1 === cleanInput.length &&
|
|
262
|
-
|
|
280
|
+
} else if (1 === cleanInput.length && 0 === monthNum && isFirstDigit) {
|
|
281
|
+
endMonth = '01';
|
|
282
|
+
oldValueRef.current.endMonth = '0';
|
|
283
|
+
setTimeout(()=>{
|
|
284
|
+
input.setSelectionRange(endMonthPos, endMonthPos + 2);
|
|
285
|
+
}, 0);
|
|
286
|
+
} else if (1 === cleanInput.length && '1' === prevFirstDigit) {
|
|
287
|
+
const newMonthNum = parseInt(`1${cleanInput}`);
|
|
263
288
|
if (newMonthNum >= 10 && newMonthNum <= 12) {
|
|
264
289
|
endMonth = `${newMonthNum}`;
|
|
265
290
|
oldValueRef.current.endMonth = endMonth;
|
|
@@ -271,10 +296,21 @@ const DateRangeField_DateRangeField = ({ label = 'Khoảng thời gian', dateFor
|
|
|
271
296
|
endMonth = 'MM';
|
|
272
297
|
oldValueRef.current.endMonth = 'MM';
|
|
273
298
|
}
|
|
299
|
+
} else if (1 === cleanInput.length && '0' === prevFirstDigit) if (monthNum >= 1 && monthNum <= 9) {
|
|
300
|
+
endMonth = `0${monthNum}`;
|
|
301
|
+
oldValueRef.current.endMonth = endMonth;
|
|
302
|
+
setTimeout(()=>{
|
|
303
|
+
input.setSelectionRange(endYearPos, endYearPos + 4);
|
|
304
|
+
oldValueRef.current.endMonth = 'MM';
|
|
305
|
+
}, 0);
|
|
274
306
|
} else {
|
|
275
307
|
endMonth = 'MM';
|
|
276
308
|
oldValueRef.current.endMonth = 'MM';
|
|
277
309
|
}
|
|
310
|
+
else {
|
|
311
|
+
endMonth = 'MM';
|
|
312
|
+
oldValueRef.current.endMonth = 'MM';
|
|
313
|
+
}
|
|
278
314
|
}
|
|
279
315
|
} else if (cursorPosition >= endYearPos) {
|
|
280
316
|
const cleanInput = inputValue.slice(endYearPos, endYearPos + 4).replace(/[^0-9]/g, '');
|