@dmsi/wedgekit-react 0.0.854 → 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/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
|
@@ -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
|
}
|
|
@@ -4774,6 +4754,60 @@ function CalendarPane({
|
|
|
4774
4754
|
] }, month.name + month.year);
|
|
4775
4755
|
}
|
|
4776
4756
|
|
|
4757
|
+
// src/utils/date-patch-dashes.ts
|
|
4758
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4759
|
+
const digits = value.replace(/\D/g, "");
|
|
4760
|
+
if (dateInDashes) {
|
|
4761
|
+
if (digits.length <= 4) return digits;
|
|
4762
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4763
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4764
|
+
} else {
|
|
4765
|
+
if (digits.length <= 2) return digits;
|
|
4766
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4767
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4771
|
+
if (!value) return "";
|
|
4772
|
+
let year = "", month = "", day = "";
|
|
4773
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4774
|
+
[year, month, day] = value.split("-");
|
|
4775
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4776
|
+
[month, day, year] = value.split("-");
|
|
4777
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4778
|
+
[month, day, year] = value.split("/");
|
|
4779
|
+
} else {
|
|
4780
|
+
return value;
|
|
4781
|
+
}
|
|
4782
|
+
if (!year || !month || !day) return value;
|
|
4783
|
+
if (dateInDashes) {
|
|
4784
|
+
return `${month}-${day}-${year}`;
|
|
4785
|
+
}
|
|
4786
|
+
return `${month}/${day}/${year}`;
|
|
4787
|
+
}
|
|
4788
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4789
|
+
if (!value) return "";
|
|
4790
|
+
let year = "", month = "", day = "";
|
|
4791
|
+
if (dateInDashes) {
|
|
4792
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4793
|
+
if (match) {
|
|
4794
|
+
[, month, day, year] = match;
|
|
4795
|
+
} else {
|
|
4796
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4797
|
+
if (match) {
|
|
4798
|
+
[, year, month, day] = match;
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4801
|
+
} else {
|
|
4802
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4803
|
+
if (match) {
|
|
4804
|
+
[, month, day, year] = match;
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
if (!year || !month || !day) return "";
|
|
4808
|
+
return `${month}-${day}-${year}`;
|
|
4809
|
+
}
|
|
4810
|
+
|
|
4777
4811
|
// src/components/DateInput.tsx
|
|
4778
4812
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4779
4813
|
var DateInput = (_a) => {
|
|
@@ -4787,7 +4821,8 @@ var DateInput = (_a) => {
|
|
|
4787
4821
|
readOnly = false,
|
|
4788
4822
|
label,
|
|
4789
4823
|
isDateAvailable,
|
|
4790
|
-
disableManualInput
|
|
4824
|
+
disableManualInput,
|
|
4825
|
+
dateInDashes = false
|
|
4791
4826
|
} = _b, props = __objRest(_b, [
|
|
4792
4827
|
"id",
|
|
4793
4828
|
"testid",
|
|
@@ -4798,7 +4833,8 @@ var DateInput = (_a) => {
|
|
|
4798
4833
|
"readOnly",
|
|
4799
4834
|
"label",
|
|
4800
4835
|
"isDateAvailable",
|
|
4801
|
-
"disableManualInput"
|
|
4836
|
+
"disableManualInput",
|
|
4837
|
+
"dateInDashes"
|
|
4802
4838
|
]);
|
|
4803
4839
|
const [visible, setVisible] = (0, import_react19.useState)(false);
|
|
4804
4840
|
const [inputValue, setInputValue] = (0, import_react19.useState)("");
|
|
@@ -4814,9 +4850,9 @@ var DateInput = (_a) => {
|
|
|
4814
4850
|
const [from, to] = [value, ""];
|
|
4815
4851
|
(0, import_react19.useEffect)(() => {
|
|
4816
4852
|
if (!isTyping) {
|
|
4817
|
-
setInputValue(formatDisplayValue(from));
|
|
4853
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4818
4854
|
}
|
|
4819
|
-
}, [from, isTyping]);
|
|
4855
|
+
}, [from, isTyping, dateInDashes]);
|
|
4820
4856
|
(0, import_react19.useLayoutEffect)(() => {
|
|
4821
4857
|
if (visible) {
|
|
4822
4858
|
updatePosition();
|
|
@@ -4879,7 +4915,7 @@ var DateInput = (_a) => {
|
|
|
4879
4915
|
const rawValue = event.target.value;
|
|
4880
4916
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4881
4917
|
setIsTyping(true);
|
|
4882
|
-
const formattedValue =
|
|
4918
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4883
4919
|
setInputValue(formattedValue);
|
|
4884
4920
|
requestAnimationFrame(() => {
|
|
4885
4921
|
if (triggerRef.current) {
|
|
@@ -4891,16 +4927,16 @@ var DateInput = (_a) => {
|
|
|
4891
4927
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4892
4928
|
}
|
|
4893
4929
|
});
|
|
4894
|
-
const parsedDate =
|
|
4930
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4895
4931
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4896
4932
|
onChange(parsedDate);
|
|
4897
4933
|
}
|
|
4898
4934
|
};
|
|
4899
4935
|
const handleBlur = () => {
|
|
4900
4936
|
setIsTyping(false);
|
|
4901
|
-
const parsedDate =
|
|
4937
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4902
4938
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4903
|
-
setInputValue(formatDisplayValue(from));
|
|
4939
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4904
4940
|
}
|
|
4905
4941
|
};
|
|
4906
4942
|
const handleKeyDown = (event) => {
|
|
@@ -4908,10 +4944,11 @@ var DateInput = (_a) => {
|
|
|
4908
4944
|
const input = event.target;
|
|
4909
4945
|
const cursorPosition = input.selectionStart || 0;
|
|
4910
4946
|
const value2 = input.value;
|
|
4911
|
-
|
|
4947
|
+
const sep = dateInDashes ? "-" : "/";
|
|
4948
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4912
4949
|
event.preventDefault();
|
|
4913
4950
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4914
|
-
const formattedValue =
|
|
4951
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4915
4952
|
setInputValue(formattedValue);
|
|
4916
4953
|
requestAnimationFrame(() => {
|
|
4917
4954
|
if (triggerRef.current) {
|
|
@@ -4924,7 +4961,7 @@ var DateInput = (_a) => {
|
|
|
4924
4961
|
}
|
|
4925
4962
|
}
|
|
4926
4963
|
if (event.key === "Enter") {
|
|
4927
|
-
const parsedDate =
|
|
4964
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4928
4965
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4929
4966
|
onChange(parsedDate);
|
|
4930
4967
|
setVisible(false);
|
|
@@ -5013,14 +5050,14 @@ var DateInput = (_a) => {
|
|
|
5013
5050
|
] });
|
|
5014
5051
|
};
|
|
5015
5052
|
DateInput.displayName = "DateInput";
|
|
5016
|
-
function formatDisplayValue(from) {
|
|
5053
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5017
5054
|
if (!from) {
|
|
5018
5055
|
return "";
|
|
5019
5056
|
}
|
|
5020
5057
|
if (!isValidDate(from)) {
|
|
5021
5058
|
return "";
|
|
5022
5059
|
}
|
|
5023
|
-
return
|
|
5060
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5024
5061
|
}
|
|
5025
5062
|
|
|
5026
5063
|
// 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
|
}
|
|
@@ -4619,6 +4599,60 @@ function CalendarPane({
|
|
|
4619
4599
|
] }, month.name + month.year);
|
|
4620
4600
|
}
|
|
4621
4601
|
|
|
4602
|
+
// src/utils/date-patch-dashes.ts
|
|
4603
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4604
|
+
const digits = value.replace(/\D/g, "");
|
|
4605
|
+
if (dateInDashes) {
|
|
4606
|
+
if (digits.length <= 4) return digits;
|
|
4607
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4608
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4609
|
+
} else {
|
|
4610
|
+
if (digits.length <= 2) return digits;
|
|
4611
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4612
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4616
|
+
if (!value) return "";
|
|
4617
|
+
let year = "", month = "", day = "";
|
|
4618
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4619
|
+
[year, month, day] = value.split("-");
|
|
4620
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4621
|
+
[month, day, year] = value.split("-");
|
|
4622
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4623
|
+
[month, day, year] = value.split("/");
|
|
4624
|
+
} else {
|
|
4625
|
+
return value;
|
|
4626
|
+
}
|
|
4627
|
+
if (!year || !month || !day) return value;
|
|
4628
|
+
if (dateInDashes) {
|
|
4629
|
+
return `${month}-${day}-${year}`;
|
|
4630
|
+
}
|
|
4631
|
+
return `${month}/${day}/${year}`;
|
|
4632
|
+
}
|
|
4633
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4634
|
+
if (!value) return "";
|
|
4635
|
+
let year = "", month = "", day = "";
|
|
4636
|
+
if (dateInDashes) {
|
|
4637
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4638
|
+
if (match) {
|
|
4639
|
+
[, month, day, year] = match;
|
|
4640
|
+
} else {
|
|
4641
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4642
|
+
if (match) {
|
|
4643
|
+
[, year, month, day] = match;
|
|
4644
|
+
}
|
|
4645
|
+
}
|
|
4646
|
+
} else {
|
|
4647
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4648
|
+
if (match) {
|
|
4649
|
+
[, month, day, year] = match;
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
if (!year || !month || !day) return "";
|
|
4653
|
+
return `${month}-${day}-${year}`;
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4622
4656
|
// src/components/DateInput.tsx
|
|
4623
4657
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
4624
4658
|
var DateInput = (_a) => {
|
|
@@ -4632,7 +4666,8 @@ var DateInput = (_a) => {
|
|
|
4632
4666
|
readOnly = false,
|
|
4633
4667
|
label,
|
|
4634
4668
|
isDateAvailable,
|
|
4635
|
-
disableManualInput
|
|
4669
|
+
disableManualInput,
|
|
4670
|
+
dateInDashes = false
|
|
4636
4671
|
} = _b, props = __objRest(_b, [
|
|
4637
4672
|
"id",
|
|
4638
4673
|
"testid",
|
|
@@ -4643,7 +4678,8 @@ var DateInput = (_a) => {
|
|
|
4643
4678
|
"readOnly",
|
|
4644
4679
|
"label",
|
|
4645
4680
|
"isDateAvailable",
|
|
4646
|
-
"disableManualInput"
|
|
4681
|
+
"disableManualInput",
|
|
4682
|
+
"dateInDashes"
|
|
4647
4683
|
]);
|
|
4648
4684
|
const [visible, setVisible] = (0, import_react18.useState)(false);
|
|
4649
4685
|
const [inputValue, setInputValue] = (0, import_react18.useState)("");
|
|
@@ -4659,9 +4695,9 @@ var DateInput = (_a) => {
|
|
|
4659
4695
|
const [from, to] = [value, ""];
|
|
4660
4696
|
(0, import_react18.useEffect)(() => {
|
|
4661
4697
|
if (!isTyping) {
|
|
4662
|
-
setInputValue(formatDisplayValue(from));
|
|
4698
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4663
4699
|
}
|
|
4664
|
-
}, [from, isTyping]);
|
|
4700
|
+
}, [from, isTyping, dateInDashes]);
|
|
4665
4701
|
(0, import_react18.useLayoutEffect)(() => {
|
|
4666
4702
|
if (visible) {
|
|
4667
4703
|
updatePosition();
|
|
@@ -4724,7 +4760,7 @@ var DateInput = (_a) => {
|
|
|
4724
4760
|
const rawValue = event.target.value;
|
|
4725
4761
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4726
4762
|
setIsTyping(true);
|
|
4727
|
-
const formattedValue =
|
|
4763
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4728
4764
|
setInputValue(formattedValue);
|
|
4729
4765
|
requestAnimationFrame(() => {
|
|
4730
4766
|
if (triggerRef.current) {
|
|
@@ -4736,16 +4772,16 @@ var DateInput = (_a) => {
|
|
|
4736
4772
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4737
4773
|
}
|
|
4738
4774
|
});
|
|
4739
|
-
const parsedDate =
|
|
4775
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4740
4776
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4741
4777
|
onChange(parsedDate);
|
|
4742
4778
|
}
|
|
4743
4779
|
};
|
|
4744
4780
|
const handleBlur = () => {
|
|
4745
4781
|
setIsTyping(false);
|
|
4746
|
-
const parsedDate =
|
|
4782
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4747
4783
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4748
|
-
setInputValue(formatDisplayValue(from));
|
|
4784
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4749
4785
|
}
|
|
4750
4786
|
};
|
|
4751
4787
|
const handleKeyDown = (event) => {
|
|
@@ -4753,10 +4789,11 @@ var DateInput = (_a) => {
|
|
|
4753
4789
|
const input = event.target;
|
|
4754
4790
|
const cursorPosition = input.selectionStart || 0;
|
|
4755
4791
|
const value2 = input.value;
|
|
4756
|
-
|
|
4792
|
+
const sep = dateInDashes ? "-" : "/";
|
|
4793
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4757
4794
|
event.preventDefault();
|
|
4758
4795
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4759
|
-
const formattedValue =
|
|
4796
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4760
4797
|
setInputValue(formattedValue);
|
|
4761
4798
|
requestAnimationFrame(() => {
|
|
4762
4799
|
if (triggerRef.current) {
|
|
@@ -4769,7 +4806,7 @@ var DateInput = (_a) => {
|
|
|
4769
4806
|
}
|
|
4770
4807
|
}
|
|
4771
4808
|
if (event.key === "Enter") {
|
|
4772
|
-
const parsedDate =
|
|
4809
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4773
4810
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4774
4811
|
onChange(parsedDate);
|
|
4775
4812
|
setVisible(false);
|
|
@@ -4858,14 +4895,14 @@ var DateInput = (_a) => {
|
|
|
4858
4895
|
] });
|
|
4859
4896
|
};
|
|
4860
4897
|
DateInput.displayName = "DateInput";
|
|
4861
|
-
function formatDisplayValue(from) {
|
|
4898
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
4862
4899
|
if (!from) {
|
|
4863
4900
|
return "";
|
|
4864
4901
|
}
|
|
4865
4902
|
if (!isValidDate(from)) {
|
|
4866
4903
|
return "";
|
|
4867
4904
|
}
|
|
4868
|
-
return
|
|
4905
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
4869
4906
|
}
|
|
4870
4907
|
|
|
4871
4908
|
// src/components/Accordion.tsx
|
|
@@ -475,30 +475,10 @@ function formatCurrencyDisplay(value) {
|
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
// src/utils/date.ts
|
|
478
|
-
function parseInputDate(input) {
|
|
479
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
480
|
-
if (!match) {
|
|
481
|
-
return null;
|
|
482
|
-
}
|
|
483
|
-
const [, month, day, year] = match;
|
|
484
|
-
const paddedMonth = month.padStart(2, "0");
|
|
485
|
-
const paddedDay = day.padStart(2, "0");
|
|
486
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
487
|
-
}
|
|
488
478
|
function isValidDate(dateString) {
|
|
489
479
|
const date = new Date(dateString);
|
|
490
480
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
491
481
|
}
|
|
492
|
-
function formatInputValue(value) {
|
|
493
|
-
const digits = value.replace(/\D/g, "");
|
|
494
|
-
if (digits.length < 2) {
|
|
495
|
-
return digits;
|
|
496
|
-
}
|
|
497
|
-
if (digits.length >= 4) {
|
|
498
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
499
|
-
}
|
|
500
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
501
|
-
}
|
|
502
482
|
function isDigit(character) {
|
|
503
483
|
return /\d/.test(character);
|
|
504
484
|
}
|
|
@@ -4844,6 +4824,60 @@ function CalendarPane({
|
|
|
4844
4824
|
] }, month.name + month.year);
|
|
4845
4825
|
}
|
|
4846
4826
|
|
|
4827
|
+
// src/utils/date-patch-dashes.ts
|
|
4828
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4829
|
+
const digits = value.replace(/\D/g, "");
|
|
4830
|
+
if (dateInDashes) {
|
|
4831
|
+
if (digits.length <= 4) return digits;
|
|
4832
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4833
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4834
|
+
} else {
|
|
4835
|
+
if (digits.length <= 2) return digits;
|
|
4836
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4837
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4838
|
+
}
|
|
4839
|
+
}
|
|
4840
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4841
|
+
if (!value) return "";
|
|
4842
|
+
let year = "", month = "", day = "";
|
|
4843
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4844
|
+
[year, month, day] = value.split("-");
|
|
4845
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4846
|
+
[month, day, year] = value.split("-");
|
|
4847
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4848
|
+
[month, day, year] = value.split("/");
|
|
4849
|
+
} else {
|
|
4850
|
+
return value;
|
|
4851
|
+
}
|
|
4852
|
+
if (!year || !month || !day) return value;
|
|
4853
|
+
if (dateInDashes) {
|
|
4854
|
+
return `${month}-${day}-${year}`;
|
|
4855
|
+
}
|
|
4856
|
+
return `${month}/${day}/${year}`;
|
|
4857
|
+
}
|
|
4858
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4859
|
+
if (!value) return "";
|
|
4860
|
+
let year = "", month = "", day = "";
|
|
4861
|
+
if (dateInDashes) {
|
|
4862
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4863
|
+
if (match) {
|
|
4864
|
+
[, month, day, year] = match;
|
|
4865
|
+
} else {
|
|
4866
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4867
|
+
if (match) {
|
|
4868
|
+
[, year, month, day] = match;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
} else {
|
|
4872
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4873
|
+
if (match) {
|
|
4874
|
+
[, month, day, year] = match;
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
if (!year || !month || !day) return "";
|
|
4878
|
+
return `${month}-${day}-${year}`;
|
|
4879
|
+
}
|
|
4880
|
+
|
|
4847
4881
|
// src/components/DateInput.tsx
|
|
4848
4882
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4849
4883
|
var DateInput = (_a) => {
|
|
@@ -4857,7 +4891,8 @@ var DateInput = (_a) => {
|
|
|
4857
4891
|
readOnly = false,
|
|
4858
4892
|
label,
|
|
4859
4893
|
isDateAvailable,
|
|
4860
|
-
disableManualInput
|
|
4894
|
+
disableManualInput,
|
|
4895
|
+
dateInDashes = false
|
|
4861
4896
|
} = _b, props = __objRest(_b, [
|
|
4862
4897
|
"id",
|
|
4863
4898
|
"testid",
|
|
@@ -4868,7 +4903,8 @@ var DateInput = (_a) => {
|
|
|
4868
4903
|
"readOnly",
|
|
4869
4904
|
"label",
|
|
4870
4905
|
"isDateAvailable",
|
|
4871
|
-
"disableManualInput"
|
|
4906
|
+
"disableManualInput",
|
|
4907
|
+
"dateInDashes"
|
|
4872
4908
|
]);
|
|
4873
4909
|
const [visible, setVisible] = (0, import_react21.useState)(false);
|
|
4874
4910
|
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
@@ -4884,9 +4920,9 @@ var DateInput = (_a) => {
|
|
|
4884
4920
|
const [from, to] = [value, ""];
|
|
4885
4921
|
(0, import_react21.useEffect)(() => {
|
|
4886
4922
|
if (!isTyping) {
|
|
4887
|
-
setInputValue(formatDisplayValue(from));
|
|
4923
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4888
4924
|
}
|
|
4889
|
-
}, [from, isTyping]);
|
|
4925
|
+
}, [from, isTyping, dateInDashes]);
|
|
4890
4926
|
(0, import_react21.useLayoutEffect)(() => {
|
|
4891
4927
|
if (visible) {
|
|
4892
4928
|
updatePosition();
|
|
@@ -4949,7 +4985,7 @@ var DateInput = (_a) => {
|
|
|
4949
4985
|
const rawValue = event.target.value;
|
|
4950
4986
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4951
4987
|
setIsTyping(true);
|
|
4952
|
-
const formattedValue =
|
|
4988
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4953
4989
|
setInputValue(formattedValue);
|
|
4954
4990
|
requestAnimationFrame(() => {
|
|
4955
4991
|
if (triggerRef.current) {
|
|
@@ -4961,16 +4997,16 @@ var DateInput = (_a) => {
|
|
|
4961
4997
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4962
4998
|
}
|
|
4963
4999
|
});
|
|
4964
|
-
const parsedDate =
|
|
5000
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4965
5001
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4966
5002
|
onChange(parsedDate);
|
|
4967
5003
|
}
|
|
4968
5004
|
};
|
|
4969
5005
|
const handleBlur = () => {
|
|
4970
5006
|
setIsTyping(false);
|
|
4971
|
-
const parsedDate =
|
|
5007
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4972
5008
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4973
|
-
setInputValue(formatDisplayValue(from));
|
|
5009
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4974
5010
|
}
|
|
4975
5011
|
};
|
|
4976
5012
|
const handleKeyDown = (event) => {
|
|
@@ -4978,10 +5014,11 @@ var DateInput = (_a) => {
|
|
|
4978
5014
|
const input = event.target;
|
|
4979
5015
|
const cursorPosition = input.selectionStart || 0;
|
|
4980
5016
|
const value2 = input.value;
|
|
4981
|
-
|
|
5017
|
+
const sep = dateInDashes ? "-" : "/";
|
|
5018
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4982
5019
|
event.preventDefault();
|
|
4983
5020
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4984
|
-
const formattedValue =
|
|
5021
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4985
5022
|
setInputValue(formattedValue);
|
|
4986
5023
|
requestAnimationFrame(() => {
|
|
4987
5024
|
if (triggerRef.current) {
|
|
@@ -4994,7 +5031,7 @@ var DateInput = (_a) => {
|
|
|
4994
5031
|
}
|
|
4995
5032
|
}
|
|
4996
5033
|
if (event.key === "Enter") {
|
|
4997
|
-
const parsedDate =
|
|
5034
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4998
5035
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4999
5036
|
onChange(parsedDate);
|
|
5000
5037
|
setVisible(false);
|
|
@@ -5083,14 +5120,14 @@ var DateInput = (_a) => {
|
|
|
5083
5120
|
] });
|
|
5084
5121
|
};
|
|
5085
5122
|
DateInput.displayName = "DateInput";
|
|
5086
|
-
function formatDisplayValue(from) {
|
|
5123
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5087
5124
|
if (!from) {
|
|
5088
5125
|
return "";
|
|
5089
5126
|
}
|
|
5090
5127
|
if (!isValidDate(from)) {
|
|
5091
5128
|
return "";
|
|
5092
5129
|
}
|
|
5093
|
-
return
|
|
5130
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5094
5131
|
}
|
|
5095
5132
|
|
|
5096
5133
|
// src/components/Accordion.tsx
|