@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
|
@@ -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
|
}
|
|
@@ -4863,6 +4843,60 @@ function CalendarPane({
|
|
|
4863
4843
|
] }, month.name + month.year);
|
|
4864
4844
|
}
|
|
4865
4845
|
|
|
4846
|
+
// src/utils/date-patch-dashes.ts
|
|
4847
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4848
|
+
const digits = value.replace(/\D/g, "");
|
|
4849
|
+
if (dateInDashes) {
|
|
4850
|
+
if (digits.length <= 4) return digits;
|
|
4851
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4852
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4853
|
+
} else {
|
|
4854
|
+
if (digits.length <= 2) return digits;
|
|
4855
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4856
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4860
|
+
if (!value) return "";
|
|
4861
|
+
let year = "", month = "", day = "";
|
|
4862
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4863
|
+
[year, month, day] = value.split("-");
|
|
4864
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4865
|
+
[month, day, year] = value.split("-");
|
|
4866
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4867
|
+
[month, day, year] = value.split("/");
|
|
4868
|
+
} else {
|
|
4869
|
+
return value;
|
|
4870
|
+
}
|
|
4871
|
+
if (!year || !month || !day) return value;
|
|
4872
|
+
if (dateInDashes) {
|
|
4873
|
+
return `${month}-${day}-${year}`;
|
|
4874
|
+
}
|
|
4875
|
+
return `${month}/${day}/${year}`;
|
|
4876
|
+
}
|
|
4877
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4878
|
+
if (!value) return "";
|
|
4879
|
+
let year = "", month = "", day = "";
|
|
4880
|
+
if (dateInDashes) {
|
|
4881
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4882
|
+
if (match) {
|
|
4883
|
+
[, month, day, year] = match;
|
|
4884
|
+
} else {
|
|
4885
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4886
|
+
if (match) {
|
|
4887
|
+
[, year, month, day] = match;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
} else {
|
|
4891
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4892
|
+
if (match) {
|
|
4893
|
+
[, month, day, year] = match;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
if (!year || !month || !day) return "";
|
|
4897
|
+
return `${month}-${day}-${year}`;
|
|
4898
|
+
}
|
|
4899
|
+
|
|
4866
4900
|
// src/components/DateInput.tsx
|
|
4867
4901
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4868
4902
|
var DateInput = (_a) => {
|
|
@@ -4876,7 +4910,8 @@ var DateInput = (_a) => {
|
|
|
4876
4910
|
readOnly = false,
|
|
4877
4911
|
label,
|
|
4878
4912
|
isDateAvailable,
|
|
4879
|
-
disableManualInput
|
|
4913
|
+
disableManualInput,
|
|
4914
|
+
dateInDashes = false
|
|
4880
4915
|
} = _b, props = __objRest(_b, [
|
|
4881
4916
|
"id",
|
|
4882
4917
|
"testid",
|
|
@@ -4887,7 +4922,8 @@ var DateInput = (_a) => {
|
|
|
4887
4922
|
"readOnly",
|
|
4888
4923
|
"label",
|
|
4889
4924
|
"isDateAvailable",
|
|
4890
|
-
"disableManualInput"
|
|
4925
|
+
"disableManualInput",
|
|
4926
|
+
"dateInDashes"
|
|
4891
4927
|
]);
|
|
4892
4928
|
const [visible, setVisible] = (0, import_react21.useState)(false);
|
|
4893
4929
|
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
@@ -4903,9 +4939,9 @@ var DateInput = (_a) => {
|
|
|
4903
4939
|
const [from, to] = [value, ""];
|
|
4904
4940
|
(0, import_react21.useEffect)(() => {
|
|
4905
4941
|
if (!isTyping) {
|
|
4906
|
-
setInputValue(formatDisplayValue(from));
|
|
4942
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4907
4943
|
}
|
|
4908
|
-
}, [from, isTyping]);
|
|
4944
|
+
}, [from, isTyping, dateInDashes]);
|
|
4909
4945
|
(0, import_react21.useLayoutEffect)(() => {
|
|
4910
4946
|
if (visible) {
|
|
4911
4947
|
updatePosition();
|
|
@@ -4968,7 +5004,7 @@ var DateInput = (_a) => {
|
|
|
4968
5004
|
const rawValue = event.target.value;
|
|
4969
5005
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4970
5006
|
setIsTyping(true);
|
|
4971
|
-
const formattedValue =
|
|
5007
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4972
5008
|
setInputValue(formattedValue);
|
|
4973
5009
|
requestAnimationFrame(() => {
|
|
4974
5010
|
if (triggerRef.current) {
|
|
@@ -4980,16 +5016,16 @@ var DateInput = (_a) => {
|
|
|
4980
5016
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4981
5017
|
}
|
|
4982
5018
|
});
|
|
4983
|
-
const parsedDate =
|
|
5019
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4984
5020
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4985
5021
|
onChange(parsedDate);
|
|
4986
5022
|
}
|
|
4987
5023
|
};
|
|
4988
5024
|
const handleBlur = () => {
|
|
4989
5025
|
setIsTyping(false);
|
|
4990
|
-
const parsedDate =
|
|
5026
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4991
5027
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4992
|
-
setInputValue(formatDisplayValue(from));
|
|
5028
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4993
5029
|
}
|
|
4994
5030
|
};
|
|
4995
5031
|
const handleKeyDown = (event) => {
|
|
@@ -4997,10 +5033,11 @@ var DateInput = (_a) => {
|
|
|
4997
5033
|
const input = event.target;
|
|
4998
5034
|
const cursorPosition = input.selectionStart || 0;
|
|
4999
5035
|
const value2 = input.value;
|
|
5000
|
-
|
|
5036
|
+
const sep = dateInDashes ? "-" : "/";
|
|
5037
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
5001
5038
|
event.preventDefault();
|
|
5002
5039
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
5003
|
-
const formattedValue =
|
|
5040
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
5004
5041
|
setInputValue(formattedValue);
|
|
5005
5042
|
requestAnimationFrame(() => {
|
|
5006
5043
|
if (triggerRef.current) {
|
|
@@ -5013,7 +5050,7 @@ var DateInput = (_a) => {
|
|
|
5013
5050
|
}
|
|
5014
5051
|
}
|
|
5015
5052
|
if (event.key === "Enter") {
|
|
5016
|
-
const parsedDate =
|
|
5053
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5017
5054
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5018
5055
|
onChange(parsedDate);
|
|
5019
5056
|
setVisible(false);
|
|
@@ -5102,14 +5139,14 @@ var DateInput = (_a) => {
|
|
|
5102
5139
|
] });
|
|
5103
5140
|
};
|
|
5104
5141
|
DateInput.displayName = "DateInput";
|
|
5105
|
-
function formatDisplayValue(from) {
|
|
5142
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5106
5143
|
if (!from) {
|
|
5107
5144
|
return "";
|
|
5108
5145
|
}
|
|
5109
5146
|
if (!isValidDate(from)) {
|
|
5110
5147
|
return "";
|
|
5111
5148
|
}
|
|
5112
|
-
return
|
|
5149
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5113
5150
|
}
|
|
5114
5151
|
|
|
5115
5152
|
// src/components/Accordion.tsx
|
|
@@ -944,30 +944,10 @@ var useMatchesMedia = (query) => {
|
|
|
944
944
|
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
945
945
|
|
|
946
946
|
// src/utils/date.ts
|
|
947
|
-
function parseInputDate(input) {
|
|
948
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
949
|
-
if (!match) {
|
|
950
|
-
return null;
|
|
951
|
-
}
|
|
952
|
-
const [, month, day, year] = match;
|
|
953
|
-
const paddedMonth = month.padStart(2, "0");
|
|
954
|
-
const paddedDay = day.padStart(2, "0");
|
|
955
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
956
|
-
}
|
|
957
947
|
function isValidDate(dateString) {
|
|
958
948
|
const date = new Date(dateString);
|
|
959
949
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
960
950
|
}
|
|
961
|
-
function formatInputValue(value) {
|
|
962
|
-
const digits = value.replace(/\D/g, "");
|
|
963
|
-
if (digits.length < 2) {
|
|
964
|
-
return digits;
|
|
965
|
-
}
|
|
966
|
-
if (digits.length >= 4) {
|
|
967
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
968
|
-
}
|
|
969
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
970
|
-
}
|
|
971
951
|
function isDigit(character) {
|
|
972
952
|
return /\d/.test(character);
|
|
973
953
|
}
|
|
@@ -5829,6 +5809,60 @@ function CalendarPane({
|
|
|
5829
5809
|
] }, month.name + month.year);
|
|
5830
5810
|
}
|
|
5831
5811
|
|
|
5812
|
+
// src/utils/date-patch-dashes.ts
|
|
5813
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
5814
|
+
const digits = value.replace(/\D/g, "");
|
|
5815
|
+
if (dateInDashes) {
|
|
5816
|
+
if (digits.length <= 4) return digits;
|
|
5817
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
5818
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
5819
|
+
} else {
|
|
5820
|
+
if (digits.length <= 2) return digits;
|
|
5821
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
5822
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
5825
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
5826
|
+
if (!value) return "";
|
|
5827
|
+
let year = "", month = "", day = "";
|
|
5828
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
5829
|
+
[year, month, day] = value.split("-");
|
|
5830
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
5831
|
+
[month, day, year] = value.split("-");
|
|
5832
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
5833
|
+
[month, day, year] = value.split("/");
|
|
5834
|
+
} else {
|
|
5835
|
+
return value;
|
|
5836
|
+
}
|
|
5837
|
+
if (!year || !month || !day) return value;
|
|
5838
|
+
if (dateInDashes) {
|
|
5839
|
+
return `${month}-${day}-${year}`;
|
|
5840
|
+
}
|
|
5841
|
+
return `${month}/${day}/${year}`;
|
|
5842
|
+
}
|
|
5843
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
5844
|
+
if (!value) return "";
|
|
5845
|
+
let year = "", month = "", day = "";
|
|
5846
|
+
if (dateInDashes) {
|
|
5847
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
5848
|
+
if (match) {
|
|
5849
|
+
[, month, day, year] = match;
|
|
5850
|
+
} else {
|
|
5851
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
5852
|
+
if (match) {
|
|
5853
|
+
[, year, month, day] = match;
|
|
5854
|
+
}
|
|
5855
|
+
}
|
|
5856
|
+
} else {
|
|
5857
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
5858
|
+
if (match) {
|
|
5859
|
+
[, month, day, year] = match;
|
|
5860
|
+
}
|
|
5861
|
+
}
|
|
5862
|
+
if (!year || !month || !day) return "";
|
|
5863
|
+
return `${month}-${day}-${year}`;
|
|
5864
|
+
}
|
|
5865
|
+
|
|
5832
5866
|
// src/components/DateInput.tsx
|
|
5833
5867
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
5834
5868
|
var DateInput = (_a) => {
|
|
@@ -5842,7 +5876,8 @@ var DateInput = (_a) => {
|
|
|
5842
5876
|
readOnly = false,
|
|
5843
5877
|
label,
|
|
5844
5878
|
isDateAvailable,
|
|
5845
|
-
disableManualInput
|
|
5879
|
+
disableManualInput,
|
|
5880
|
+
dateInDashes = false
|
|
5846
5881
|
} = _b, props = __objRest(_b, [
|
|
5847
5882
|
"id",
|
|
5848
5883
|
"testid",
|
|
@@ -5853,7 +5888,8 @@ var DateInput = (_a) => {
|
|
|
5853
5888
|
"readOnly",
|
|
5854
5889
|
"label",
|
|
5855
5890
|
"isDateAvailable",
|
|
5856
|
-
"disableManualInput"
|
|
5891
|
+
"disableManualInput",
|
|
5892
|
+
"dateInDashes"
|
|
5857
5893
|
]);
|
|
5858
5894
|
const [visible, setVisible] = (0, import_react40.useState)(false);
|
|
5859
5895
|
const [inputValue, setInputValue] = (0, import_react40.useState)("");
|
|
@@ -5869,9 +5905,9 @@ var DateInput = (_a) => {
|
|
|
5869
5905
|
const [from, to] = [value, ""];
|
|
5870
5906
|
(0, import_react40.useEffect)(() => {
|
|
5871
5907
|
if (!isTyping) {
|
|
5872
|
-
setInputValue(formatDisplayValue(from));
|
|
5908
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5873
5909
|
}
|
|
5874
|
-
}, [from, isTyping]);
|
|
5910
|
+
}, [from, isTyping, dateInDashes]);
|
|
5875
5911
|
(0, import_react40.useLayoutEffect)(() => {
|
|
5876
5912
|
if (visible) {
|
|
5877
5913
|
updatePosition();
|
|
@@ -5934,7 +5970,7 @@ var DateInput = (_a) => {
|
|
|
5934
5970
|
const rawValue = event.target.value;
|
|
5935
5971
|
const cursorPosition = event.target.selectionStart || 0;
|
|
5936
5972
|
setIsTyping(true);
|
|
5937
|
-
const formattedValue =
|
|
5973
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
5938
5974
|
setInputValue(formattedValue);
|
|
5939
5975
|
requestAnimationFrame(() => {
|
|
5940
5976
|
if (triggerRef.current) {
|
|
@@ -5946,16 +5982,16 @@ var DateInput = (_a) => {
|
|
|
5946
5982
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
5947
5983
|
}
|
|
5948
5984
|
});
|
|
5949
|
-
const parsedDate =
|
|
5985
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
5950
5986
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5951
5987
|
onChange(parsedDate);
|
|
5952
5988
|
}
|
|
5953
5989
|
};
|
|
5954
5990
|
const handleBlur = () => {
|
|
5955
5991
|
setIsTyping(false);
|
|
5956
|
-
const parsedDate =
|
|
5992
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5957
5993
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
5958
|
-
setInputValue(formatDisplayValue(from));
|
|
5994
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5959
5995
|
}
|
|
5960
5996
|
};
|
|
5961
5997
|
const handleKeyDown = (event) => {
|
|
@@ -5963,10 +5999,11 @@ var DateInput = (_a) => {
|
|
|
5963
5999
|
const input = event.target;
|
|
5964
6000
|
const cursorPosition = input.selectionStart || 0;
|
|
5965
6001
|
const value2 = input.value;
|
|
5966
|
-
|
|
6002
|
+
const sep = dateInDashes ? "-" : "/";
|
|
6003
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
5967
6004
|
event.preventDefault();
|
|
5968
6005
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
5969
|
-
const formattedValue =
|
|
6006
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
5970
6007
|
setInputValue(formattedValue);
|
|
5971
6008
|
requestAnimationFrame(() => {
|
|
5972
6009
|
if (triggerRef.current) {
|
|
@@ -5979,7 +6016,7 @@ var DateInput = (_a) => {
|
|
|
5979
6016
|
}
|
|
5980
6017
|
}
|
|
5981
6018
|
if (event.key === "Enter") {
|
|
5982
|
-
const parsedDate =
|
|
6019
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5983
6020
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5984
6021
|
onChange(parsedDate);
|
|
5985
6022
|
setVisible(false);
|
|
@@ -6068,14 +6105,14 @@ var DateInput = (_a) => {
|
|
|
6068
6105
|
] });
|
|
6069
6106
|
};
|
|
6070
6107
|
DateInput.displayName = "DateInput";
|
|
6071
|
-
function formatDisplayValue(from) {
|
|
6108
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
6072
6109
|
if (!from) {
|
|
6073
6110
|
return "";
|
|
6074
6111
|
}
|
|
6075
6112
|
if (!isValidDate(from)) {
|
|
6076
6113
|
return "";
|
|
6077
6114
|
}
|
|
6078
|
-
return
|
|
6115
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
6079
6116
|
}
|
|
6080
6117
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6081
6118
|
0 && (module.exports = {
|
|
@@ -4428,6 +4428,62 @@ Tooltip.displayName = "Tooltip";
|
|
|
4428
4428
|
// src/components/DateInput.tsx
|
|
4429
4429
|
var import_react20 = require("react");
|
|
4430
4430
|
var import_react_dom3 = require("react-dom");
|
|
4431
|
+
|
|
4432
|
+
// src/utils/date-patch-dashes.ts
|
|
4433
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4434
|
+
const digits = value.replace(/\D/g, "");
|
|
4435
|
+
if (dateInDashes) {
|
|
4436
|
+
if (digits.length <= 4) return digits;
|
|
4437
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4438
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4439
|
+
} else {
|
|
4440
|
+
if (digits.length <= 2) return digits;
|
|
4441
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4442
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
4445
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4446
|
+
if (!value) return "";
|
|
4447
|
+
let year = "", month = "", day = "";
|
|
4448
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4449
|
+
[year, month, day] = value.split("-");
|
|
4450
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4451
|
+
[month, day, year] = value.split("-");
|
|
4452
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4453
|
+
[month, day, year] = value.split("/");
|
|
4454
|
+
} else {
|
|
4455
|
+
return value;
|
|
4456
|
+
}
|
|
4457
|
+
if (!year || !month || !day) return value;
|
|
4458
|
+
if (dateInDashes) {
|
|
4459
|
+
return `${month}-${day}-${year}`;
|
|
4460
|
+
}
|
|
4461
|
+
return `${month}/${day}/${year}`;
|
|
4462
|
+
}
|
|
4463
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4464
|
+
if (!value) return "";
|
|
4465
|
+
let year = "", month = "", day = "";
|
|
4466
|
+
if (dateInDashes) {
|
|
4467
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4468
|
+
if (match) {
|
|
4469
|
+
[, month, day, year] = match;
|
|
4470
|
+
} else {
|
|
4471
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4472
|
+
if (match) {
|
|
4473
|
+
[, year, month, day] = match;
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
} else {
|
|
4477
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4478
|
+
if (match) {
|
|
4479
|
+
[, month, day, year] = match;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
if (!year || !month || !day) return "";
|
|
4483
|
+
return `${month}-${day}-${year}`;
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
// src/components/DateInput.tsx
|
|
4431
4487
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4432
4488
|
var DateInput = (_a) => {
|
|
4433
4489
|
var _b = _a, {
|
|
@@ -4440,7 +4496,8 @@ var DateInput = (_a) => {
|
|
|
4440
4496
|
readOnly = false,
|
|
4441
4497
|
label,
|
|
4442
4498
|
isDateAvailable,
|
|
4443
|
-
disableManualInput
|
|
4499
|
+
disableManualInput,
|
|
4500
|
+
dateInDashes = false
|
|
4444
4501
|
} = _b, props = __objRest(_b, [
|
|
4445
4502
|
"id",
|
|
4446
4503
|
"testid",
|
|
@@ -4451,7 +4508,8 @@ var DateInput = (_a) => {
|
|
|
4451
4508
|
"readOnly",
|
|
4452
4509
|
"label",
|
|
4453
4510
|
"isDateAvailable",
|
|
4454
|
-
"disableManualInput"
|
|
4511
|
+
"disableManualInput",
|
|
4512
|
+
"dateInDashes"
|
|
4455
4513
|
]);
|
|
4456
4514
|
const [visible, setVisible] = (0, import_react20.useState)(false);
|
|
4457
4515
|
const [inputValue, setInputValue] = (0, import_react20.useState)("");
|
|
@@ -4467,9 +4525,9 @@ var DateInput = (_a) => {
|
|
|
4467
4525
|
const [from, to] = [value, ""];
|
|
4468
4526
|
(0, import_react20.useEffect)(() => {
|
|
4469
4527
|
if (!isTyping) {
|
|
4470
|
-
setInputValue(formatDisplayValue(from));
|
|
4528
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4471
4529
|
}
|
|
4472
|
-
}, [from, isTyping]);
|
|
4530
|
+
}, [from, isTyping, dateInDashes]);
|
|
4473
4531
|
(0, import_react20.useLayoutEffect)(() => {
|
|
4474
4532
|
if (visible) {
|
|
4475
4533
|
updatePosition();
|
|
@@ -4532,7 +4590,7 @@ var DateInput = (_a) => {
|
|
|
4532
4590
|
const rawValue = event.target.value;
|
|
4533
4591
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4534
4592
|
setIsTyping(true);
|
|
4535
|
-
const formattedValue =
|
|
4593
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4536
4594
|
setInputValue(formattedValue);
|
|
4537
4595
|
requestAnimationFrame(() => {
|
|
4538
4596
|
if (triggerRef.current) {
|
|
@@ -4544,16 +4602,16 @@ var DateInput = (_a) => {
|
|
|
4544
4602
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4545
4603
|
}
|
|
4546
4604
|
});
|
|
4547
|
-
const parsedDate =
|
|
4605
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
4548
4606
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4549
4607
|
onChange(parsedDate);
|
|
4550
4608
|
}
|
|
4551
4609
|
};
|
|
4552
4610
|
const handleBlur = () => {
|
|
4553
4611
|
setIsTyping(false);
|
|
4554
|
-
const parsedDate =
|
|
4612
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4555
4613
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
4556
|
-
setInputValue(formatDisplayValue(from));
|
|
4614
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4557
4615
|
}
|
|
4558
4616
|
};
|
|
4559
4617
|
const handleKeyDown = (event) => {
|
|
@@ -4561,10 +4619,11 @@ var DateInput = (_a) => {
|
|
|
4561
4619
|
const input = event.target;
|
|
4562
4620
|
const cursorPosition = input.selectionStart || 0;
|
|
4563
4621
|
const value2 = input.value;
|
|
4564
|
-
|
|
4622
|
+
const sep = dateInDashes ? "-" : "/";
|
|
4623
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
4565
4624
|
event.preventDefault();
|
|
4566
4625
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
4567
|
-
const formattedValue =
|
|
4626
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
4568
4627
|
setInputValue(formattedValue);
|
|
4569
4628
|
requestAnimationFrame(() => {
|
|
4570
4629
|
if (triggerRef.current) {
|
|
@@ -4577,7 +4636,7 @@ var DateInput = (_a) => {
|
|
|
4577
4636
|
}
|
|
4578
4637
|
}
|
|
4579
4638
|
if (event.key === "Enter") {
|
|
4580
|
-
const parsedDate =
|
|
4639
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
4581
4640
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
4582
4641
|
onChange(parsedDate);
|
|
4583
4642
|
setVisible(false);
|
|
@@ -4666,14 +4725,14 @@ var DateInput = (_a) => {
|
|
|
4666
4725
|
] });
|
|
4667
4726
|
};
|
|
4668
4727
|
DateInput.displayName = "DateInput";
|
|
4669
|
-
function formatDisplayValue(from) {
|
|
4728
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
4670
4729
|
if (!from) {
|
|
4671
4730
|
return "";
|
|
4672
4731
|
}
|
|
4673
4732
|
if (!isValidDate(from)) {
|
|
4674
4733
|
return "";
|
|
4675
4734
|
}
|
|
4676
|
-
return
|
|
4735
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
4677
4736
|
}
|
|
4678
4737
|
|
|
4679
4738
|
// src/components/Accordion.tsx
|