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/index.js CHANGED
@@ -3483,7 +3483,60 @@ var Component$V = function (_a) {
3483
3483
  */
3484
3484
  var Breadcrumb = Component$V;
3485
3485
 
3486
- var styles$M = {"date-input":"mg_date_input_date-input_1n1gi","date-input__input":"mg_date_input_date-input_input_1n1gi","date-input__separator":"mg_date_input_date-input_separator_1n1gi","date-input__separator--filled":"mg_date_input_date-input_separator--filled_1n1gi","date-input--fit":"mg_date_input_date-input--fit_1n1gi","date-input--error":"mg_date_input_date-input--error_1n1gi"};
3486
+ var DateArray = /** @class */ (function () {
3487
+ function DateArray(array) {
3488
+ this.day = NaN;
3489
+ this.month = NaN;
3490
+ this.year = NaN;
3491
+ this.raw = {
3492
+ day: ['', ''],
3493
+ month: ['', ''],
3494
+ year: ['', '', '', '']
3495
+ };
3496
+ if (!array)
3497
+ return;
3498
+ this.fromArray(array);
3499
+ }
3500
+ DateArray.prototype.fromArray = function (array) {
3501
+ 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];
3502
+ this.day = d1 * 10 + d2;
3503
+ this.month = m1 * 10 + m2;
3504
+ this.year = y1 * 1000 + y2 * 100 + y3 * 10 + y4;
3505
+ this.setRaw(array);
3506
+ };
3507
+ DateArray.prototype.setRaw = function (array) {
3508
+ 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);
3509
+ this.raw.day = [d1, d2];
3510
+ this.raw.month = [m1, m2];
3511
+ this.raw.year = year;
3512
+ };
3513
+ DateArray.prototype.getMonth = function () {
3514
+ if (isNaN(this.month)) {
3515
+ return this.raw.month;
3516
+ }
3517
+ return [Math.floor(this.month / 10), this.month % 10];
3518
+ };
3519
+ DateArray.prototype.getArray = function () {
3520
+ return __spreadArray(__spreadArray(__spreadArray([], this.raw.day, true), this.getMonth(), true), this.raw.year, true);
3521
+ };
3522
+ DateArray.prototype.setArray = function (array) {
3523
+ this.fromArray(array);
3524
+ return this;
3525
+ };
3526
+ DateArray.prototype.fixMonth = function () {
3527
+ if (!isNaN(this.month) && this.month > 12) {
3528
+ this.month = 12;
3529
+ }
3530
+ return this;
3531
+ };
3532
+ return DateArray;
3533
+ }());
3534
+ var dateArray = new DateArray();
3535
+ var fixArrayDate = function (array) {
3536
+ return dateArray.setArray(array).fixMonth().getArray();
3537
+ };
3538
+
3539
+ 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"};
3487
3540
 
3488
3541
  // placeholder to every input.
3489
3542
  var placeholder = ['D', 'D', 'M', 'M', 'A', 'A', 'A', 'A'];
@@ -3514,7 +3567,7 @@ var Component$U = function (_a) {
3514
3567
  var newValues = __spreadArray([], internalValues, true);
3515
3568
  var numberValue = value.slice(-1).replace(notNumberRegex, '');
3516
3569
  newValues[index] = numberValue;
3517
- setInternalValues(newValues);
3570
+ setInternalValues(fixArrayDate(newValues));
3518
3571
  // Focus the next input
3519
3572
  if (numberValue && index < internalValues.length - 1) {
3520
3573
  (_a = inputsRef.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
@@ -3584,11 +3637,20 @@ var Component$U = function (_a) {
3584
3637
  className,
3585
3638
  fit ? styles$M['date-input--fit'] : '',
3586
3639
  hasError ? styles$M['date-input--error'] : ''
3587
- ].join(' ') }, internalValues.map(function (value, index) { return (React__default["default"].createElement(React__default["default"].Fragment, { key: index },
3588
- [2, 4].includes(index) ? (
3589
- // include / separator in date (DD / MM / YYYY)
3590
- React__default["default"].createElement("span", { className: [styles$M['date-input__separator'], value ? styles$M['date-input__separator--filled'] : ''].join(' ') }, "/")) : null,
3591
- React__default["default"].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" }))); })));
3640
+ ].join(' ') },
3641
+ React__default["default"].createElement("div", { className: styles$M['date-input__left'], onClick: function () {
3642
+ var _a;
3643
+ (_a = inputsRef.current[0]) === null || _a === void 0 ? void 0 : _a.focus();
3644
+ } }),
3645
+ internalValues.map(function (value, index) { return (React__default["default"].createElement(React__default["default"].Fragment, { key: index },
3646
+ [2, 4].includes(index) ? (
3647
+ // include / separator in date (DD / MM / YYYY)
3648
+ React__default["default"].createElement("span", { className: [styles$M['date-input__separator'], value ? styles$M['date-input__separator--filled'] : ''].join(' ') }, "/")) : null,
3649
+ React__default["default"].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" }))); }),
3650
+ React__default["default"].createElement("div", { className: styles$M['date-input__right'], onClick: function () {
3651
+ var _a;
3652
+ (_a = inputsRef.current[inputsRef.current.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
3653
+ } })));
3592
3654
  };
3593
3655
  var DateInput = Component$U;
3594
3656
 
@@ -5980,8 +6042,10 @@ var useSelect2 = function (_a) {
5980
6042
  }
5981
6043
  }, [searchValue, setTerm]);
5982
6044
  React.useEffect(function () {
5983
- if (!currentFields || !currentFields.length)
6045
+ if (!currentFields || !currentFields.length) {
6046
+ setValueSelected([]);
5984
6047
  return;
6048
+ }
5985
6049
  setValueSelected(function (prev) {
5986
6050
  if (currentFields.map(function (field) { return field.id; }).join() === prev.map(function (p) { return p.id; }).join()) {
5987
6051
  return prev;