@dmsi/wedgekit-react 0.0.853 → 0.0.855
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/{chunk-T7NSOCGM.js → chunk-IUJIB7Y2.js} +71 -16
- package/dist/components/CalendarRange.cjs +72 -33
- package/dist/components/CalendarRange.js +1 -1
- package/dist/components/ContentTabs.cjs +3 -3
- package/dist/components/ContentTabs.js +3 -3
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +70 -33
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +1 -1
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +70 -33
- package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +1 -1
- package/dist/components/DataGrid/PinnedColumns.cjs +70 -33
- package/dist/components/DataGrid/PinnedColumns.js +1 -1
- package/dist/components/DataGrid/TableBody/LoadingCell.cjs +70 -33
- package/dist/components/DataGrid/TableBody/LoadingCell.js +1 -1
- package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +70 -33
- package/dist/components/DataGrid/TableBody/TableBodyRow.js +1 -1
- package/dist/components/DataGrid/TableBody/index.cjs +70 -33
- package/dist/components/DataGrid/TableBody/index.js +1 -1
- package/dist/components/DataGrid/index.cjs +70 -33
- package/dist/components/DataGrid/index.js +1 -1
- package/dist/components/DataGrid/utils.cjs +70 -33
- package/dist/components/DataGrid/utils.js +1 -1
- package/dist/components/DateInput.cjs +70 -33
- package/dist/components/DateInput.js +1 -1
- package/dist/components/DateRangeInput.cjs +72 -13
- package/dist/components/DateRangeInput.js +1 -1
- package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +70 -33
- package/dist/components/MobileDataGrid/ColumnSelector/index.js +1 -1
- package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +70 -33
- package/dist/components/MobileDataGrid/MobileDataGridHeader.js +1 -1
- package/dist/components/MobileDataGrid/index.cjs +70 -33
- package/dist/components/MobileDataGrid/index.js +1 -1
- package/dist/components/index.cjs +70 -33
- package/dist/components/index.js +1 -1
- package/package.json +1 -1
|
@@ -478,30 +478,10 @@ function formatCurrencyDisplay(value) {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
// src/utils/date.ts
|
|
481
|
-
function parseInputDate(input) {
|
|
482
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
483
|
-
if (!match) {
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
const [, month, day, year] = match;
|
|
487
|
-
const paddedMonth = month.padStart(2, "0");
|
|
488
|
-
const paddedDay = day.padStart(2, "0");
|
|
489
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
490
|
-
}
|
|
491
481
|
function isValidDate(dateString) {
|
|
492
482
|
const date = new Date(dateString);
|
|
493
483
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
494
484
|
}
|
|
495
|
-
function formatInputValue(value) {
|
|
496
|
-
const digits = value.replace(/\D/g, "");
|
|
497
|
-
if (digits.length < 2) {
|
|
498
|
-
return digits;
|
|
499
|
-
}
|
|
500
|
-
if (digits.length >= 4) {
|
|
501
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
502
|
-
}
|
|
503
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
504
|
-
}
|
|
505
485
|
function isDigit(character) {
|
|
506
486
|
return /\d/.test(character);
|
|
507
487
|
}
|
|
@@ -4771,6 +4751,60 @@ function CalendarPane({
|
|
|
4771
4751
|
] }, month.name + month.year);
|
|
4772
4752
|
}
|
|
4773
4753
|
|
|
4754
|
+
// src/utils/date-patch-dashes.ts
|
|
4755
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4756
|
+
const digits = value.replace(/\D/g, "");
|
|
4757
|
+
if (dateInDashes) {
|
|
4758
|
+
if (digits.length <= 4) return digits;
|
|
4759
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4760
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4761
|
+
} else {
|
|
4762
|
+
if (digits.length <= 2) return digits;
|
|
4763
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4764
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4768
|
+
if (!value) return "";
|
|
4769
|
+
let year = "", month = "", day = "";
|
|
4770
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4771
|
+
[year, month, day] = value.split("-");
|
|
4772
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4773
|
+
[month, day, year] = value.split("-");
|
|
4774
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4775
|
+
[month, day, year] = value.split("/");
|
|
4776
|
+
} else {
|
|
4777
|
+
return value;
|
|
4778
|
+
}
|
|
4779
|
+
if (!year || !month || !day) return value;
|
|
4780
|
+
if (dateInDashes) {
|
|
4781
|
+
return `${month}-${day}-${year}`;
|
|
4782
|
+
}
|
|
4783
|
+
return `${month}/${day}/${year}`;
|
|
4784
|
+
}
|
|
4785
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4786
|
+
if (!value) return "";
|
|
4787
|
+
let year = "", month = "", day = "";
|
|
4788
|
+
if (dateInDashes) {
|
|
4789
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4790
|
+
if (match) {
|
|
4791
|
+
[, month, day, year] = match;
|
|
4792
|
+
} else {
|
|
4793
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4794
|
+
if (match) {
|
|
4795
|
+
[, year, month, day] = match;
|
|
4796
|
+
}
|
|
4797
|
+
}
|
|
4798
|
+
} else {
|
|
4799
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4800
|
+
if (match) {
|
|
4801
|
+
[, month, day, year] = match;
|
|
4802
|
+
}
|
|
4803
|
+
}
|
|
4804
|
+
if (!year || !month || !day) return "";
|
|
4805
|
+
return `${month}-${day}-${year}`;
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4774
4808
|
// src/components/DateInput.tsx
|
|
4775
4809
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4776
4810
|
var DateInput = (_a) => {
|
|
@@ -4784,7 +4818,8 @@ var DateInput = (_a) => {
|
|
|
4784
4818
|
readOnly = false,
|
|
4785
4819
|
label,
|
|
4786
4820
|
isDateAvailable,
|
|
4787
|
-
disableManualInput
|
|
4821
|
+
disableManualInput,
|
|
4822
|
+
dateInDashes = false
|
|
4788
4823
|
} = _b, props = __objRest(_b, [
|
|
4789
4824
|
"id",
|
|
4790
4825
|
"testid",
|
|
@@ -4795,7 +4830,8 @@ var DateInput = (_a) => {
|
|
|
4795
4830
|
"readOnly",
|
|
4796
4831
|
"label",
|
|
4797
4832
|
"isDateAvailable",
|
|
4798
|
-
"disableManualInput"
|
|
4833
|
+
"disableManualInput",
|
|
4834
|
+
"dateInDashes"
|
|
4799
4835
|
]);
|
|
4800
4836
|
const [visible, setVisible] = (0, import_react20.useState)(false);
|
|
4801
4837
|
const [inputValue, setInputValue] = (0, import_react20.useState)("");
|
|
@@ -4811,9 +4847,9 @@ var DateInput = (_a) => {
|
|
|
4811
4847
|
const [from, to] = [value, ""];
|
|
4812
4848
|
(0, import_react20.useEffect)(() => {
|
|
4813
4849
|
if (!isTyping) {
|
|
4814
|
-
setInputValue(formatDisplayValue(from));
|
|
4850
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4815
4851
|
}
|
|
4816
|
-
}, [from, isTyping]);
|
|
4852
|
+
}, [from, isTyping, dateInDashes]);
|
|
4817
4853
|
(0, import_react20.useLayoutEffect)(() => {
|
|
4818
4854
|
if (visible) {
|
|
4819
4855
|
updatePosition();
|
|
@@ -4876,7 +4912,7 @@ var DateInput = (_a) => {
|
|
|
4876
4912
|
const rawValue = event.target.value;
|
|
4877
4913
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4878
4914
|
setIsTyping(true);
|
|
4879
|
-
const formattedValue =
|
|
4915
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4880
4916
|
setInputValue(formattedValue);
|
|
4881
4917
|
requestAnimationFrame(() => {
|
|
4882
4918
|
if (triggerRef.current) {
|
|
@@ -4888,16 +4924,16 @@ var DateInput = (_a) => {
|
|
|
4888
4924
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4889
4925
|
}
|
|
4890
4926
|
});
|
|
4891
|
-
const parsedDate =
|
|
4927
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4892
4928
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4893
4929
|
onChange(parsedDate);
|
|
4894
4930
|
}
|
|
4895
4931
|
};
|
|
4896
4932
|
const handleBlur = () => {
|
|
4897
4933
|
setIsTyping(false);
|
|
4898
|
-
const parsedDate =
|
|
4934
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4899
4935
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4900
|
-
setInputValue(formatDisplayValue(from));
|
|
4936
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4901
4937
|
}
|
|
4902
4938
|
};
|
|
4903
4939
|
const handleKeyDown = (event) => {
|
|
@@ -4905,10 +4941,11 @@ var DateInput = (_a) => {
|
|
|
4905
4941
|
const input = event.target;
|
|
4906
4942
|
const cursorPosition = input.selectionStart || 0;
|
|
4907
4943
|
const value2 = input.value;
|
|
4908
|
-
|
|
4944
|
+
const sep = dateInDashes ? "-" : "/";
|
|
4945
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4909
4946
|
event.preventDefault();
|
|
4910
4947
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4911
|
-
const formattedValue =
|
|
4948
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4912
4949
|
setInputValue(formattedValue);
|
|
4913
4950
|
requestAnimationFrame(() => {
|
|
4914
4951
|
if (triggerRef.current) {
|
|
@@ -4921,7 +4958,7 @@ var DateInput = (_a) => {
|
|
|
4921
4958
|
}
|
|
4922
4959
|
}
|
|
4923
4960
|
if (event.key === "Enter") {
|
|
4924
|
-
const parsedDate =
|
|
4961
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4925
4962
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4926
4963
|
onChange(parsedDate);
|
|
4927
4964
|
setVisible(false);
|
|
@@ -5010,14 +5047,14 @@ var DateInput = (_a) => {
|
|
|
5010
5047
|
] });
|
|
5011
5048
|
};
|
|
5012
5049
|
DateInput.displayName = "DateInput";
|
|
5013
|
-
function formatDisplayValue(from) {
|
|
5050
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5014
5051
|
if (!from) {
|
|
5015
5052
|
return "";
|
|
5016
5053
|
}
|
|
5017
5054
|
if (!isValidDate(from)) {
|
|
5018
5055
|
return "";
|
|
5019
5056
|
}
|
|
5020
|
-
return
|
|
5057
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5021
5058
|
}
|
|
5022
5059
|
|
|
5023
5060
|
// src/components/Accordion.tsx
|
|
@@ -476,30 +476,10 @@ function formatCurrencyDisplay(value) {
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
// src/utils/date.ts
|
|
479
|
-
function parseInputDate(input) {
|
|
480
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
481
|
-
if (!match) {
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
const [, month, day, year] = match;
|
|
485
|
-
const paddedMonth = month.padStart(2, "0");
|
|
486
|
-
const paddedDay = day.padStart(2, "0");
|
|
487
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
488
|
-
}
|
|
489
479
|
function isValidDate(dateString) {
|
|
490
480
|
const date = new Date(dateString);
|
|
491
481
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
492
482
|
}
|
|
493
|
-
function formatInputValue(value) {
|
|
494
|
-
const digits = value.replace(/\D/g, "");
|
|
495
|
-
if (digits.length < 2) {
|
|
496
|
-
return digits;
|
|
497
|
-
}
|
|
498
|
-
if (digits.length >= 4) {
|
|
499
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
500
|
-
}
|
|
501
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
502
|
-
}
|
|
503
483
|
function isDigit(character) {
|
|
504
484
|
return /\d/.test(character);
|
|
505
485
|
}
|
|
@@ -4583,6 +4563,60 @@ function CalendarPane({
|
|
|
4583
4563
|
] }, month.name + month.year);
|
|
4584
4564
|
}
|
|
4585
4565
|
|
|
4566
|
+
// src/utils/date-patch-dashes.ts
|
|
4567
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4568
|
+
const digits = value.replace(/\D/g, "");
|
|
4569
|
+
if (dateInDashes) {
|
|
4570
|
+
if (digits.length <= 4) return digits;
|
|
4571
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4572
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4573
|
+
} else {
|
|
4574
|
+
if (digits.length <= 2) return digits;
|
|
4575
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4576
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4577
|
+
}
|
|
4578
|
+
}
|
|
4579
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4580
|
+
if (!value) return "";
|
|
4581
|
+
let year = "", month = "", day = "";
|
|
4582
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4583
|
+
[year, month, day] = value.split("-");
|
|
4584
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4585
|
+
[month, day, year] = value.split("-");
|
|
4586
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4587
|
+
[month, day, year] = value.split("/");
|
|
4588
|
+
} else {
|
|
4589
|
+
return value;
|
|
4590
|
+
}
|
|
4591
|
+
if (!year || !month || !day) return value;
|
|
4592
|
+
if (dateInDashes) {
|
|
4593
|
+
return `${month}-${day}-${year}`;
|
|
4594
|
+
}
|
|
4595
|
+
return `${month}/${day}/${year}`;
|
|
4596
|
+
}
|
|
4597
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4598
|
+
if (!value) return "";
|
|
4599
|
+
let year = "", month = "", day = "";
|
|
4600
|
+
if (dateInDashes) {
|
|
4601
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4602
|
+
if (match) {
|
|
4603
|
+
[, month, day, year] = match;
|
|
4604
|
+
} else {
|
|
4605
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4606
|
+
if (match) {
|
|
4607
|
+
[, year, month, day] = match;
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
} else {
|
|
4611
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4612
|
+
if (match) {
|
|
4613
|
+
[, month, day, year] = match;
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
if (!year || !month || !day) return "";
|
|
4617
|
+
return `${month}-${day}-${year}`;
|
|
4618
|
+
}
|
|
4619
|
+
|
|
4586
4620
|
// src/components/DateInput.tsx
|
|
4587
4621
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
4588
4622
|
var DateInput = (_a) => {
|
|
@@ -4596,7 +4630,8 @@ var DateInput = (_a) => {
|
|
|
4596
4630
|
readOnly = false,
|
|
4597
4631
|
label,
|
|
4598
4632
|
isDateAvailable,
|
|
4599
|
-
disableManualInput
|
|
4633
|
+
disableManualInput,
|
|
4634
|
+
dateInDashes = false
|
|
4600
4635
|
} = _b, props = __objRest(_b, [
|
|
4601
4636
|
"id",
|
|
4602
4637
|
"testid",
|
|
@@ -4607,7 +4642,8 @@ var DateInput = (_a) => {
|
|
|
4607
4642
|
"readOnly",
|
|
4608
4643
|
"label",
|
|
4609
4644
|
"isDateAvailable",
|
|
4610
|
-
"disableManualInput"
|
|
4645
|
+
"disableManualInput",
|
|
4646
|
+
"dateInDashes"
|
|
4611
4647
|
]);
|
|
4612
4648
|
const [visible, setVisible] = (0, import_react20.useState)(false);
|
|
4613
4649
|
const [inputValue, setInputValue] = (0, import_react20.useState)("");
|
|
@@ -4623,9 +4659,9 @@ var DateInput = (_a) => {
|
|
|
4623
4659
|
const [from, to] = [value, ""];
|
|
4624
4660
|
(0, import_react20.useEffect)(() => {
|
|
4625
4661
|
if (!isTyping) {
|
|
4626
|
-
setInputValue(formatDisplayValue(from));
|
|
4662
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4627
4663
|
}
|
|
4628
|
-
}, [from, isTyping]);
|
|
4664
|
+
}, [from, isTyping, dateInDashes]);
|
|
4629
4665
|
(0, import_react20.useLayoutEffect)(() => {
|
|
4630
4666
|
if (visible) {
|
|
4631
4667
|
updatePosition();
|
|
@@ -4688,7 +4724,7 @@ var DateInput = (_a) => {
|
|
|
4688
4724
|
const rawValue = event.target.value;
|
|
4689
4725
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4690
4726
|
setIsTyping(true);
|
|
4691
|
-
const formattedValue =
|
|
4727
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4692
4728
|
setInputValue(formattedValue);
|
|
4693
4729
|
requestAnimationFrame(() => {
|
|
4694
4730
|
if (triggerRef.current) {
|
|
@@ -4700,16 +4736,16 @@ var DateInput = (_a) => {
|
|
|
4700
4736
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4701
4737
|
}
|
|
4702
4738
|
});
|
|
4703
|
-
const parsedDate =
|
|
4739
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4704
4740
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4705
4741
|
onChange(parsedDate);
|
|
4706
4742
|
}
|
|
4707
4743
|
};
|
|
4708
4744
|
const handleBlur = () => {
|
|
4709
4745
|
setIsTyping(false);
|
|
4710
|
-
const parsedDate =
|
|
4746
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4711
4747
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4712
|
-
setInputValue(formatDisplayValue(from));
|
|
4748
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4713
4749
|
}
|
|
4714
4750
|
};
|
|
4715
4751
|
const handleKeyDown = (event) => {
|
|
@@ -4717,10 +4753,11 @@ var DateInput = (_a) => {
|
|
|
4717
4753
|
const input = event.target;
|
|
4718
4754
|
const cursorPosition = input.selectionStart || 0;
|
|
4719
4755
|
const value2 = input.value;
|
|
4720
|
-
|
|
4756
|
+
const sep = dateInDashes ? "-" : "/";
|
|
4757
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4721
4758
|
event.preventDefault();
|
|
4722
4759
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4723
|
-
const formattedValue =
|
|
4760
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4724
4761
|
setInputValue(formattedValue);
|
|
4725
4762
|
requestAnimationFrame(() => {
|
|
4726
4763
|
if (triggerRef.current) {
|
|
@@ -4733,7 +4770,7 @@ var DateInput = (_a) => {
|
|
|
4733
4770
|
}
|
|
4734
4771
|
}
|
|
4735
4772
|
if (event.key === "Enter") {
|
|
4736
|
-
const parsedDate =
|
|
4773
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4737
4774
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4738
4775
|
onChange(parsedDate);
|
|
4739
4776
|
setVisible(false);
|
|
@@ -4822,14 +4859,14 @@ var DateInput = (_a) => {
|
|
|
4822
4859
|
] });
|
|
4823
4860
|
};
|
|
4824
4861
|
DateInput.displayName = "DateInput";
|
|
4825
|
-
function formatDisplayValue(from) {
|
|
4862
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
4826
4863
|
if (!from) {
|
|
4827
4864
|
return "";
|
|
4828
4865
|
}
|
|
4829
4866
|
if (!isValidDate(from)) {
|
|
4830
4867
|
return "";
|
|
4831
4868
|
}
|
|
4832
|
-
return
|
|
4869
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
4833
4870
|
}
|
|
4834
4871
|
|
|
4835
4872
|
// src/components/Accordion.tsx
|
|
@@ -146,30 +146,10 @@ function formatCurrencyDisplay(value) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// src/utils/date.ts
|
|
149
|
-
function parseInputDate(input) {
|
|
150
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
151
|
-
if (!match) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
const [, month, day, year] = match;
|
|
155
|
-
const paddedMonth = month.padStart(2, "0");
|
|
156
|
-
const paddedDay = day.padStart(2, "0");
|
|
157
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
158
|
-
}
|
|
159
149
|
function isValidDate(dateString) {
|
|
160
150
|
const date = new Date(dateString);
|
|
161
151
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
162
152
|
}
|
|
163
|
-
function formatInputValue(value) {
|
|
164
|
-
const digits = value.replace(/\D/g, "");
|
|
165
|
-
if (digits.length < 2) {
|
|
166
|
-
return digits;
|
|
167
|
-
}
|
|
168
|
-
if (digits.length >= 4) {
|
|
169
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
170
|
-
}
|
|
171
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
172
|
-
}
|
|
173
153
|
function isDigit(character) {
|
|
174
154
|
return /\d/.test(character);
|
|
175
155
|
}
|
|
@@ -3715,6 +3695,60 @@ function CalendarPane({
|
|
|
3715
3695
|
] }, month.name + month.year);
|
|
3716
3696
|
}
|
|
3717
3697
|
|
|
3698
|
+
// src/utils/date-patch-dashes.ts
|
|
3699
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
3700
|
+
const digits = value.replace(/\D/g, "");
|
|
3701
|
+
if (dateInDashes) {
|
|
3702
|
+
if (digits.length <= 4) return digits;
|
|
3703
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
3704
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
3705
|
+
} else {
|
|
3706
|
+
if (digits.length <= 2) return digits;
|
|
3707
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
3708
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
3712
|
+
if (!value) return "";
|
|
3713
|
+
let year = "", month = "", day = "";
|
|
3714
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
3715
|
+
[year, month, day] = value.split("-");
|
|
3716
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
3717
|
+
[month, day, year] = value.split("-");
|
|
3718
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
3719
|
+
[month, day, year] = value.split("/");
|
|
3720
|
+
} else {
|
|
3721
|
+
return value;
|
|
3722
|
+
}
|
|
3723
|
+
if (!year || !month || !day) return value;
|
|
3724
|
+
if (dateInDashes) {
|
|
3725
|
+
return `${month}-${day}-${year}`;
|
|
3726
|
+
}
|
|
3727
|
+
return `${month}/${day}/${year}`;
|
|
3728
|
+
}
|
|
3729
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
3730
|
+
if (!value) return "";
|
|
3731
|
+
let year = "", month = "", day = "";
|
|
3732
|
+
if (dateInDashes) {
|
|
3733
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
3734
|
+
if (match) {
|
|
3735
|
+
[, month, day, year] = match;
|
|
3736
|
+
} else {
|
|
3737
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
3738
|
+
if (match) {
|
|
3739
|
+
[, year, month, day] = match;
|
|
3740
|
+
}
|
|
3741
|
+
}
|
|
3742
|
+
} else {
|
|
3743
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
3744
|
+
if (match) {
|
|
3745
|
+
[, month, day, year] = match;
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
if (!year || !month || !day) return "";
|
|
3749
|
+
return `${month}-${day}-${year}`;
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3718
3752
|
// src/components/DateInput.tsx
|
|
3719
3753
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3720
3754
|
var DateInput = (_a) => {
|
|
@@ -3728,7 +3762,8 @@ var DateInput = (_a) => {
|
|
|
3728
3762
|
readOnly = false,
|
|
3729
3763
|
label,
|
|
3730
3764
|
isDateAvailable,
|
|
3731
|
-
disableManualInput
|
|
3765
|
+
disableManualInput,
|
|
3766
|
+
dateInDashes = false
|
|
3732
3767
|
} = _b, props = __objRest(_b, [
|
|
3733
3768
|
"id",
|
|
3734
3769
|
"testid",
|
|
@@ -3739,7 +3774,8 @@ var DateInput = (_a) => {
|
|
|
3739
3774
|
"readOnly",
|
|
3740
3775
|
"label",
|
|
3741
3776
|
"isDateAvailable",
|
|
3742
|
-
"disableManualInput"
|
|
3777
|
+
"disableManualInput",
|
|
3778
|
+
"dateInDashes"
|
|
3743
3779
|
]);
|
|
3744
3780
|
const [visible, setVisible] = (0, import_react16.useState)(false);
|
|
3745
3781
|
const [inputValue, setInputValue] = (0, import_react16.useState)("");
|
|
@@ -3755,9 +3791,9 @@ var DateInput = (_a) => {
|
|
|
3755
3791
|
const [from, to] = [value, ""];
|
|
3756
3792
|
(0, import_react16.useEffect)(() => {
|
|
3757
3793
|
if (!isTyping) {
|
|
3758
|
-
setInputValue(formatDisplayValue(from));
|
|
3794
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
3759
3795
|
}
|
|
3760
|
-
}, [from, isTyping]);
|
|
3796
|
+
}, [from, isTyping, dateInDashes]);
|
|
3761
3797
|
(0, import_react16.useLayoutEffect)(() => {
|
|
3762
3798
|
if (visible) {
|
|
3763
3799
|
updatePosition();
|
|
@@ -3820,7 +3856,7 @@ var DateInput = (_a) => {
|
|
|
3820
3856
|
const rawValue = event.target.value;
|
|
3821
3857
|
const cursorPosition = event.target.selectionStart || 0;
|
|
3822
3858
|
setIsTyping(true);
|
|
3823
|
-
const formattedValue =
|
|
3859
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
3824
3860
|
setInputValue(formattedValue);
|
|
3825
3861
|
requestAnimationFrame(() => {
|
|
3826
3862
|
if (triggerRef.current) {
|
|
@@ -3832,16 +3868,16 @@ var DateInput = (_a) => {
|
|
|
3832
3868
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
3833
3869
|
}
|
|
3834
3870
|
});
|
|
3835
|
-
const parsedDate =
|
|
3871
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
3836
3872
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
3837
3873
|
onChange(parsedDate);
|
|
3838
3874
|
}
|
|
3839
3875
|
};
|
|
3840
3876
|
const handleBlur = () => {
|
|
3841
3877
|
setIsTyping(false);
|
|
3842
|
-
const parsedDate =
|
|
3878
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
3843
3879
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
3844
|
-
setInputValue(formatDisplayValue(from));
|
|
3880
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
3845
3881
|
}
|
|
3846
3882
|
};
|
|
3847
3883
|
const handleKeyDown = (event) => {
|
|
@@ -3849,10 +3885,11 @@ var DateInput = (_a) => {
|
|
|
3849
3885
|
const input = event.target;
|
|
3850
3886
|
const cursorPosition = input.selectionStart || 0;
|
|
3851
3887
|
const value2 = input.value;
|
|
3852
|
-
|
|
3888
|
+
const sep = dateInDashes ? "-" : "/";
|
|
3889
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
3853
3890
|
event.preventDefault();
|
|
3854
3891
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
3855
|
-
const formattedValue =
|
|
3892
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
3856
3893
|
setInputValue(formattedValue);
|
|
3857
3894
|
requestAnimationFrame(() => {
|
|
3858
3895
|
if (triggerRef.current) {
|
|
@@ -3865,7 +3902,7 @@ var DateInput = (_a) => {
|
|
|
3865
3902
|
}
|
|
3866
3903
|
}
|
|
3867
3904
|
if (event.key === "Enter") {
|
|
3868
|
-
const parsedDate =
|
|
3905
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
3869
3906
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
3870
3907
|
onChange(parsedDate);
|
|
3871
3908
|
setVisible(false);
|
|
@@ -3954,14 +3991,14 @@ var DateInput = (_a) => {
|
|
|
3954
3991
|
] });
|
|
3955
3992
|
};
|
|
3956
3993
|
DateInput.displayName = "DateInput";
|
|
3957
|
-
function formatDisplayValue(from) {
|
|
3994
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
3958
3995
|
if (!from) {
|
|
3959
3996
|
return "";
|
|
3960
3997
|
}
|
|
3961
3998
|
if (!isValidDate(from)) {
|
|
3962
3999
|
return "";
|
|
3963
4000
|
}
|
|
3964
|
-
return
|
|
4001
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
3965
4002
|
}
|
|
3966
4003
|
|
|
3967
4004
|
// src/components/Accordion.tsx
|