magneto365.ui 2.40.2 → 2.40.4
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/dist/cjs/css/magneto.ui.lib.min.css +1 -1
- package/dist/cjs/index.js +72 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/date/dateInput.util.d.ts +14 -0
- package/dist/esm/css/magneto.ui.lib.min.css +1 -1
- package/dist/esm/index.js +72 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/date/dateInput.util.d.ts +14 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -3474,7 +3474,60 @@ var Component$V = function (_a) {
|
|
|
3474
3474
|
*/
|
|
3475
3475
|
var Breadcrumb = Component$V;
|
|
3476
3476
|
|
|
3477
|
-
var
|
|
3477
|
+
var DateArray = /** @class */ (function () {
|
|
3478
|
+
function DateArray(array) {
|
|
3479
|
+
this.day = NaN;
|
|
3480
|
+
this.month = NaN;
|
|
3481
|
+
this.year = NaN;
|
|
3482
|
+
this.raw = {
|
|
3483
|
+
day: ['', ''],
|
|
3484
|
+
month: ['', ''],
|
|
3485
|
+
year: ['', '', '', '']
|
|
3486
|
+
};
|
|
3487
|
+
if (!array)
|
|
3488
|
+
return;
|
|
3489
|
+
this.fromArray(array);
|
|
3490
|
+
}
|
|
3491
|
+
DateArray.prototype.fromArray = function (array) {
|
|
3492
|
+
var _a = array.map(function (x) { return (x === '' ? NaN : Number(x)); }), d1 = _a[0], d2 = _a[1], m1 = _a[2], m2 = _a[3], y1 = _a[4], y2 = _a[5], y3 = _a[6], y4 = _a[7];
|
|
3493
|
+
this.day = d1 * 10 + d2;
|
|
3494
|
+
this.month = m1 * 10 + m2;
|
|
3495
|
+
this.year = y1 * 1000 + y2 * 100 + y3 * 10 + y4;
|
|
3496
|
+
this.setRaw(array);
|
|
3497
|
+
};
|
|
3498
|
+
DateArray.prototype.setRaw = function (array) {
|
|
3499
|
+
var _a = array[0], d1 = _a === void 0 ? '' : _a, _b = array[1], d2 = _b === void 0 ? '' : _b, _c = array[2], m1 = _c === void 0 ? '' : _c, _d = array[3], m2 = _d === void 0 ? '' : _d, year = array.slice(4);
|
|
3500
|
+
this.raw.day = [d1, d2];
|
|
3501
|
+
this.raw.month = [m1, m2];
|
|
3502
|
+
this.raw.year = year;
|
|
3503
|
+
};
|
|
3504
|
+
DateArray.prototype.getMonth = function () {
|
|
3505
|
+
if (isNaN(this.month)) {
|
|
3506
|
+
return this.raw.month;
|
|
3507
|
+
}
|
|
3508
|
+
return [Math.floor(this.month / 10), this.month % 10];
|
|
3509
|
+
};
|
|
3510
|
+
DateArray.prototype.getArray = function () {
|
|
3511
|
+
return __spreadArray(__spreadArray(__spreadArray([], this.raw.day, true), this.getMonth(), true), this.raw.year, true);
|
|
3512
|
+
};
|
|
3513
|
+
DateArray.prototype.setArray = function (array) {
|
|
3514
|
+
this.fromArray(array);
|
|
3515
|
+
return this;
|
|
3516
|
+
};
|
|
3517
|
+
DateArray.prototype.fixMonth = function () {
|
|
3518
|
+
if (!isNaN(this.month) && this.month > 12) {
|
|
3519
|
+
this.month = 12;
|
|
3520
|
+
}
|
|
3521
|
+
return this;
|
|
3522
|
+
};
|
|
3523
|
+
return DateArray;
|
|
3524
|
+
}());
|
|
3525
|
+
var dateArray = new DateArray();
|
|
3526
|
+
var fixArrayDate = function (array) {
|
|
3527
|
+
return dateArray.setArray(array).fixMonth().getArray();
|
|
3528
|
+
};
|
|
3529
|
+
|
|
3530
|
+
var styles$M = {"date-input":"mg_date_input_date-input_1hkg2","date-input__input":"mg_date_input_date-input_input_1hkg2","date-input__separator":"mg_date_input_date-input_separator_1hkg2","date-input__separator--filled":"mg_date_input_date-input_separator--filled_1hkg2","date-input--fit":"mg_date_input_date-input--fit_1hkg2","date-input--error":"mg_date_input_date-input--error_1hkg2","date-input__left":"mg_date_input_date-input_left_1hkg2","date-input__right":"mg_date_input_date-input_right_1hkg2"};
|
|
3478
3531
|
|
|
3479
3532
|
// placeholder to every input.
|
|
3480
3533
|
var placeholder = ['D', 'D', 'M', 'M', 'A', 'A', 'A', 'A'];
|
|
@@ -3505,7 +3558,7 @@ var Component$U = function (_a) {
|
|
|
3505
3558
|
var newValues = __spreadArray([], internalValues, true);
|
|
3506
3559
|
var numberValue = value.slice(-1).replace(notNumberRegex, '');
|
|
3507
3560
|
newValues[index] = numberValue;
|
|
3508
|
-
setInternalValues(newValues);
|
|
3561
|
+
setInternalValues(fixArrayDate(newValues));
|
|
3509
3562
|
// Focus the next input
|
|
3510
3563
|
if (numberValue && index < internalValues.length - 1) {
|
|
3511
3564
|
(_a = inputsRef.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -3575,11 +3628,20 @@ var Component$U = function (_a) {
|
|
|
3575
3628
|
className,
|
|
3576
3629
|
fit ? styles$M['date-input--fit'] : '',
|
|
3577
3630
|
hasError ? styles$M['date-input--error'] : ''
|
|
3578
|
-
].join(' ') },
|
|
3579
|
-
[
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3631
|
+
].join(' ') },
|
|
3632
|
+
React.createElement("div", { className: styles$M['date-input__left'], onClick: function () {
|
|
3633
|
+
var _a;
|
|
3634
|
+
(_a = inputsRef.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3635
|
+
} }),
|
|
3636
|
+
internalValues.map(function (value, index) { return (React.createElement(React.Fragment, { key: index },
|
|
3637
|
+
[2, 4].includes(index) ? (
|
|
3638
|
+
// include / separator in date (DD / MM / YYYY)
|
|
3639
|
+
React.createElement("span", { className: [styles$M['date-input__separator'], value ? styles$M['date-input__separator--filled'] : ''].join(' ') }, "/")) : null,
|
|
3640
|
+
React.createElement("input", { className: styles$M['date-input__input'], type: "text", maxLength: 1, value: value, placeholder: placeholder[index], onChange: function (e) { return handleChange(index, e.target.value); }, onKeyDown: function (e) { return handleKeyDown(index, e.key); }, onPaste: function (e) { return handlePaste(index, e); }, ref: function (el) { return (inputsRef.current[index] = el); }, inputMode: "numeric" }))); }),
|
|
3641
|
+
React.createElement("div", { className: styles$M['date-input__right'], onClick: function () {
|
|
3642
|
+
var _a;
|
|
3643
|
+
(_a = inputsRef.current[inputsRef.current.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3644
|
+
} })));
|
|
3583
3645
|
};
|
|
3584
3646
|
var DateInput = Component$U;
|
|
3585
3647
|
|
|
@@ -5971,8 +6033,10 @@ var useSelect2 = function (_a) {
|
|
|
5971
6033
|
}
|
|
5972
6034
|
}, [searchValue, setTerm]);
|
|
5973
6035
|
useEffect(function () {
|
|
5974
|
-
if (!currentFields || !currentFields.length)
|
|
6036
|
+
if (!currentFields || !currentFields.length) {
|
|
6037
|
+
setValueSelected([]);
|
|
5975
6038
|
return;
|
|
6039
|
+
}
|
|
5976
6040
|
setValueSelected(function (prev) {
|
|
5977
6041
|
if (currentFields.map(function (field) { return field.id; }).join() === prev.map(function (p) { return p.id; }).join()) {
|
|
5978
6042
|
return prev;
|