@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
|
}
|
|
@@ -4880,6 +4860,60 @@ function CalendarPane({
|
|
|
4880
4860
|
] }, month.name + month.year);
|
|
4881
4861
|
}
|
|
4882
4862
|
|
|
4863
|
+
// src/utils/date-patch-dashes.ts
|
|
4864
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
4865
|
+
const digits = value.replace(/\D/g, "");
|
|
4866
|
+
if (dateInDashes) {
|
|
4867
|
+
if (digits.length <= 4) return digits;
|
|
4868
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
4869
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
4870
|
+
} else {
|
|
4871
|
+
if (digits.length <= 2) return digits;
|
|
4872
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
4873
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
4877
|
+
if (!value) return "";
|
|
4878
|
+
let year = "", month = "", day = "";
|
|
4879
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
4880
|
+
[year, month, day] = value.split("-");
|
|
4881
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
4882
|
+
[month, day, year] = value.split("-");
|
|
4883
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
4884
|
+
[month, day, year] = value.split("/");
|
|
4885
|
+
} else {
|
|
4886
|
+
return value;
|
|
4887
|
+
}
|
|
4888
|
+
if (!year || !month || !day) return value;
|
|
4889
|
+
if (dateInDashes) {
|
|
4890
|
+
return `${month}-${day}-${year}`;
|
|
4891
|
+
}
|
|
4892
|
+
return `${month}/${day}/${year}`;
|
|
4893
|
+
}
|
|
4894
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
4895
|
+
if (!value) return "";
|
|
4896
|
+
let year = "", month = "", day = "";
|
|
4897
|
+
if (dateInDashes) {
|
|
4898
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
4899
|
+
if (match) {
|
|
4900
|
+
[, month, day, year] = match;
|
|
4901
|
+
} else {
|
|
4902
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
4903
|
+
if (match) {
|
|
4904
|
+
[, year, month, day] = match;
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
} else {
|
|
4908
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
4909
|
+
if (match) {
|
|
4910
|
+
[, month, day, year] = match;
|
|
4911
|
+
}
|
|
4912
|
+
}
|
|
4913
|
+
if (!year || !month || !day) return "";
|
|
4914
|
+
return `${month}-${day}-${year}`;
|
|
4915
|
+
}
|
|
4916
|
+
|
|
4883
4917
|
// src/components/DateInput.tsx
|
|
4884
4918
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4885
4919
|
var DateInput = (_a) => {
|
|
@@ -4893,7 +4927,8 @@ var DateInput = (_a) => {
|
|
|
4893
4927
|
readOnly = false,
|
|
4894
4928
|
label,
|
|
4895
4929
|
isDateAvailable,
|
|
4896
|
-
disableManualInput
|
|
4930
|
+
disableManualInput,
|
|
4931
|
+
dateInDashes = false
|
|
4897
4932
|
} = _b, props = __objRest(_b, [
|
|
4898
4933
|
"id",
|
|
4899
4934
|
"testid",
|
|
@@ -4904,7 +4939,8 @@ var DateInput = (_a) => {
|
|
|
4904
4939
|
"readOnly",
|
|
4905
4940
|
"label",
|
|
4906
4941
|
"isDateAvailable",
|
|
4907
|
-
"disableManualInput"
|
|
4942
|
+
"disableManualInput",
|
|
4943
|
+
"dateInDashes"
|
|
4908
4944
|
]);
|
|
4909
4945
|
const [visible, setVisible] = (0, import_react21.useState)(false);
|
|
4910
4946
|
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
@@ -4920,9 +4956,9 @@ var DateInput = (_a) => {
|
|
|
4920
4956
|
const [from, to] = [value, ""];
|
|
4921
4957
|
(0, import_react21.useEffect)(() => {
|
|
4922
4958
|
if (!isTyping) {
|
|
4923
|
-
setInputValue(formatDisplayValue(from));
|
|
4959
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
4924
4960
|
}
|
|
4925
|
-
}, [from, isTyping]);
|
|
4961
|
+
}, [from, isTyping, dateInDashes]);
|
|
4926
4962
|
(0, import_react21.useLayoutEffect)(() => {
|
|
4927
4963
|
if (visible) {
|
|
4928
4964
|
updatePosition();
|
|
@@ -4985,7 +5021,7 @@ var DateInput = (_a) => {
|
|
|
4985
5021
|
const rawValue = event.target.value;
|
|
4986
5022
|
const cursorPosition = event.target.selectionStart || 0;
|
|
4987
5023
|
setIsTyping(true);
|
|
4988
|
-
const formattedValue =
|
|
5024
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
4989
5025
|
setInputValue(formattedValue);
|
|
4990
5026
|
requestAnimationFrame(() => {
|
|
4991
5027
|
if (triggerRef.current) {
|
|
@@ -4997,16 +5033,16 @@ var DateInput = (_a) => {
|
|
|
4997
5033
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
4998
5034
|
}
|
|
4999
5035
|
});
|
|
5000
|
-
const parsedDate =
|
|
5036
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
5001
5037
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5002
5038
|
onChange(parsedDate);
|
|
5003
5039
|
}
|
|
5004
5040
|
};
|
|
5005
5041
|
const handleBlur = () => {
|
|
5006
5042
|
setIsTyping(false);
|
|
5007
|
-
const parsedDate =
|
|
5043
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5008
5044
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
5009
|
-
setInputValue(formatDisplayValue(from));
|
|
5045
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5010
5046
|
}
|
|
5011
5047
|
};
|
|
5012
5048
|
const handleKeyDown = (event) => {
|
|
@@ -5014,10 +5050,11 @@ var DateInput = (_a) => {
|
|
|
5014
5050
|
const input = event.target;
|
|
5015
5051
|
const cursorPosition = input.selectionStart || 0;
|
|
5016
5052
|
const value2 = input.value;
|
|
5017
|
-
|
|
5053
|
+
const sep = dateInDashes ? "-" : "/";
|
|
5054
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
5018
5055
|
event.preventDefault();
|
|
5019
5056
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
5020
|
-
const formattedValue =
|
|
5057
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
5021
5058
|
setInputValue(formattedValue);
|
|
5022
5059
|
requestAnimationFrame(() => {
|
|
5023
5060
|
if (triggerRef.current) {
|
|
@@ -5030,7 +5067,7 @@ var DateInput = (_a) => {
|
|
|
5030
5067
|
}
|
|
5031
5068
|
}
|
|
5032
5069
|
if (event.key === "Enter") {
|
|
5033
|
-
const parsedDate =
|
|
5070
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5034
5071
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5035
5072
|
onChange(parsedDate);
|
|
5036
5073
|
setVisible(false);
|
|
@@ -5119,14 +5156,14 @@ var DateInput = (_a) => {
|
|
|
5119
5156
|
] });
|
|
5120
5157
|
};
|
|
5121
5158
|
DateInput.displayName = "DateInput";
|
|
5122
|
-
function formatDisplayValue(from) {
|
|
5159
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5123
5160
|
if (!from) {
|
|
5124
5161
|
return "";
|
|
5125
5162
|
}
|
|
5126
5163
|
if (!isValidDate(from)) {
|
|
5127
5164
|
return "";
|
|
5128
5165
|
}
|
|
5129
|
-
return
|
|
5166
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5130
5167
|
}
|
|
5131
5168
|
|
|
5132
5169
|
// src/components/Accordion.tsx
|
|
@@ -907,30 +907,10 @@ function formatCurrencyDisplay(value) {
|
|
|
907
907
|
}
|
|
908
908
|
|
|
909
909
|
// src/utils/date.ts
|
|
910
|
-
function parseInputDate(input) {
|
|
911
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
912
|
-
if (!match) {
|
|
913
|
-
return null;
|
|
914
|
-
}
|
|
915
|
-
const [, month, day, year] = match;
|
|
916
|
-
const paddedMonth = month.padStart(2, "0");
|
|
917
|
-
const paddedDay = day.padStart(2, "0");
|
|
918
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
919
|
-
}
|
|
920
910
|
function isValidDate(dateString) {
|
|
921
911
|
const date = new Date(dateString);
|
|
922
912
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
923
913
|
}
|
|
924
|
-
function formatInputValue(value) {
|
|
925
|
-
const digits = value.replace(/\D/g, "");
|
|
926
|
-
if (digits.length < 2) {
|
|
927
|
-
return digits;
|
|
928
|
-
}
|
|
929
|
-
if (digits.length >= 4) {
|
|
930
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
931
|
-
}
|
|
932
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
933
|
-
}
|
|
934
914
|
function isDigit(character) {
|
|
935
915
|
return /\d/.test(character);
|
|
936
916
|
}
|
|
@@ -5187,6 +5167,60 @@ function CalendarPane({
|
|
|
5187
5167
|
] }, month.name + month.year);
|
|
5188
5168
|
}
|
|
5189
5169
|
|
|
5170
|
+
// src/utils/date-patch-dashes.ts
|
|
5171
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
5172
|
+
const digits = value.replace(/\D/g, "");
|
|
5173
|
+
if (dateInDashes) {
|
|
5174
|
+
if (digits.length <= 4) return digits;
|
|
5175
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
5176
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
5177
|
+
} else {
|
|
5178
|
+
if (digits.length <= 2) return digits;
|
|
5179
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
5180
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
5184
|
+
if (!value) return "";
|
|
5185
|
+
let year = "", month = "", day = "";
|
|
5186
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
5187
|
+
[year, month, day] = value.split("-");
|
|
5188
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
5189
|
+
[month, day, year] = value.split("-");
|
|
5190
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
5191
|
+
[month, day, year] = value.split("/");
|
|
5192
|
+
} else {
|
|
5193
|
+
return value;
|
|
5194
|
+
}
|
|
5195
|
+
if (!year || !month || !day) return value;
|
|
5196
|
+
if (dateInDashes) {
|
|
5197
|
+
return `${month}-${day}-${year}`;
|
|
5198
|
+
}
|
|
5199
|
+
return `${month}/${day}/${year}`;
|
|
5200
|
+
}
|
|
5201
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
5202
|
+
if (!value) return "";
|
|
5203
|
+
let year = "", month = "", day = "";
|
|
5204
|
+
if (dateInDashes) {
|
|
5205
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
5206
|
+
if (match) {
|
|
5207
|
+
[, month, day, year] = match;
|
|
5208
|
+
} else {
|
|
5209
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
5210
|
+
if (match) {
|
|
5211
|
+
[, year, month, day] = match;
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
} else {
|
|
5215
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
5216
|
+
if (match) {
|
|
5217
|
+
[, month, day, year] = match;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
if (!year || !month || !day) return "";
|
|
5221
|
+
return `${month}-${day}-${year}`;
|
|
5222
|
+
}
|
|
5223
|
+
|
|
5190
5224
|
// src/components/DateInput.tsx
|
|
5191
5225
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5192
5226
|
var DateInput = (_a) => {
|
|
@@ -5200,7 +5234,8 @@ var DateInput = (_a) => {
|
|
|
5200
5234
|
readOnly = false,
|
|
5201
5235
|
label,
|
|
5202
5236
|
isDateAvailable,
|
|
5203
|
-
disableManualInput
|
|
5237
|
+
disableManualInput,
|
|
5238
|
+
dateInDashes = false
|
|
5204
5239
|
} = _b, props = __objRest(_b, [
|
|
5205
5240
|
"id",
|
|
5206
5241
|
"testid",
|
|
@@ -5211,7 +5246,8 @@ var DateInput = (_a) => {
|
|
|
5211
5246
|
"readOnly",
|
|
5212
5247
|
"label",
|
|
5213
5248
|
"isDateAvailable",
|
|
5214
|
-
"disableManualInput"
|
|
5249
|
+
"disableManualInput",
|
|
5250
|
+
"dateInDashes"
|
|
5215
5251
|
]);
|
|
5216
5252
|
const [visible, setVisible] = (0, import_react21.useState)(false);
|
|
5217
5253
|
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
@@ -5227,9 +5263,9 @@ var DateInput = (_a) => {
|
|
|
5227
5263
|
const [from, to] = [value, ""];
|
|
5228
5264
|
(0, import_react21.useEffect)(() => {
|
|
5229
5265
|
if (!isTyping) {
|
|
5230
|
-
setInputValue(formatDisplayValue(from));
|
|
5266
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5231
5267
|
}
|
|
5232
|
-
}, [from, isTyping]);
|
|
5268
|
+
}, [from, isTyping, dateInDashes]);
|
|
5233
5269
|
(0, import_react21.useLayoutEffect)(() => {
|
|
5234
5270
|
if (visible) {
|
|
5235
5271
|
updatePosition();
|
|
@@ -5292,7 +5328,7 @@ var DateInput = (_a) => {
|
|
|
5292
5328
|
const rawValue = event.target.value;
|
|
5293
5329
|
const cursorPosition = event.target.selectionStart || 0;
|
|
5294
5330
|
setIsTyping(true);
|
|
5295
|
-
const formattedValue =
|
|
5331
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
5296
5332
|
setInputValue(formattedValue);
|
|
5297
5333
|
requestAnimationFrame(() => {
|
|
5298
5334
|
if (triggerRef.current) {
|
|
@@ -5304,16 +5340,16 @@ var DateInput = (_a) => {
|
|
|
5304
5340
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
5305
5341
|
}
|
|
5306
5342
|
});
|
|
5307
|
-
const parsedDate =
|
|
5343
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
5308
5344
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5309
5345
|
onChange(parsedDate);
|
|
5310
5346
|
}
|
|
5311
5347
|
};
|
|
5312
5348
|
const handleBlur = () => {
|
|
5313
5349
|
setIsTyping(false);
|
|
5314
|
-
const parsedDate =
|
|
5350
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5315
5351
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
5316
|
-
setInputValue(formatDisplayValue(from));
|
|
5352
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5317
5353
|
}
|
|
5318
5354
|
};
|
|
5319
5355
|
const handleKeyDown = (event) => {
|
|
@@ -5321,10 +5357,11 @@ var DateInput = (_a) => {
|
|
|
5321
5357
|
const input = event.target;
|
|
5322
5358
|
const cursorPosition = input.selectionStart || 0;
|
|
5323
5359
|
const value2 = input.value;
|
|
5324
|
-
|
|
5360
|
+
const sep = dateInDashes ? "-" : "/";
|
|
5361
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
5325
5362
|
event.preventDefault();
|
|
5326
5363
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
5327
|
-
const formattedValue =
|
|
5364
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
5328
5365
|
setInputValue(formattedValue);
|
|
5329
5366
|
requestAnimationFrame(() => {
|
|
5330
5367
|
if (triggerRef.current) {
|
|
@@ -5337,7 +5374,7 @@ var DateInput = (_a) => {
|
|
|
5337
5374
|
}
|
|
5338
5375
|
}
|
|
5339
5376
|
if (event.key === "Enter") {
|
|
5340
|
-
const parsedDate =
|
|
5377
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5341
5378
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5342
5379
|
onChange(parsedDate);
|
|
5343
5380
|
setVisible(false);
|
|
@@ -5426,14 +5463,14 @@ var DateInput = (_a) => {
|
|
|
5426
5463
|
] });
|
|
5427
5464
|
};
|
|
5428
5465
|
DateInput.displayName = "DateInput";
|
|
5429
|
-
function formatDisplayValue(from) {
|
|
5466
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5430
5467
|
if (!from) {
|
|
5431
5468
|
return "";
|
|
5432
5469
|
}
|
|
5433
5470
|
if (!isValidDate(from)) {
|
|
5434
5471
|
return "";
|
|
5435
5472
|
}
|
|
5436
|
-
return
|
|
5473
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5437
5474
|
}
|
|
5438
5475
|
|
|
5439
5476
|
// src/components/Accordion.tsx
|
|
@@ -907,30 +907,10 @@ function formatCurrencyDisplay(value) {
|
|
|
907
907
|
}
|
|
908
908
|
|
|
909
909
|
// src/utils/date.ts
|
|
910
|
-
function parseInputDate(input) {
|
|
911
|
-
const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
912
|
-
if (!match) {
|
|
913
|
-
return null;
|
|
914
|
-
}
|
|
915
|
-
const [, month, day, year] = match;
|
|
916
|
-
const paddedMonth = month.padStart(2, "0");
|
|
917
|
-
const paddedDay = day.padStart(2, "0");
|
|
918
|
-
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
919
|
-
}
|
|
920
910
|
function isValidDate(dateString) {
|
|
921
911
|
const date = new Date(dateString);
|
|
922
912
|
return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
|
|
923
913
|
}
|
|
924
|
-
function formatInputValue(value) {
|
|
925
|
-
const digits = value.replace(/\D/g, "");
|
|
926
|
-
if (digits.length < 2) {
|
|
927
|
-
return digits;
|
|
928
|
-
}
|
|
929
|
-
if (digits.length >= 4) {
|
|
930
|
-
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
931
|
-
}
|
|
932
|
-
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
933
|
-
}
|
|
934
914
|
function isDigit(character) {
|
|
935
915
|
return /\d/.test(character);
|
|
936
916
|
}
|
|
@@ -5187,6 +5167,60 @@ function CalendarPane({
|
|
|
5187
5167
|
] }, month.name + month.year);
|
|
5188
5168
|
}
|
|
5189
5169
|
|
|
5170
|
+
// src/utils/date-patch-dashes.ts
|
|
5171
|
+
function formatInputValueWithDashes(value, dateInDashes) {
|
|
5172
|
+
const digits = value.replace(/\D/g, "");
|
|
5173
|
+
if (dateInDashes) {
|
|
5174
|
+
if (digits.length <= 4) return digits;
|
|
5175
|
+
if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
|
5176
|
+
return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
|
|
5177
|
+
} else {
|
|
5178
|
+
if (digits.length <= 2) return digits;
|
|
5179
|
+
if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
5180
|
+
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
function formatDateWithDashes(value, dateInDashes) {
|
|
5184
|
+
if (!value) return "";
|
|
5185
|
+
let year = "", month = "", day = "";
|
|
5186
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
5187
|
+
[year, month, day] = value.split("-");
|
|
5188
|
+
} else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
|
|
5189
|
+
[month, day, year] = value.split("-");
|
|
5190
|
+
} else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
|
|
5191
|
+
[month, day, year] = value.split("/");
|
|
5192
|
+
} else {
|
|
5193
|
+
return value;
|
|
5194
|
+
}
|
|
5195
|
+
if (!year || !month || !day) return value;
|
|
5196
|
+
if (dateInDashes) {
|
|
5197
|
+
return `${month}-${day}-${year}`;
|
|
5198
|
+
}
|
|
5199
|
+
return `${month}/${day}/${year}`;
|
|
5200
|
+
}
|
|
5201
|
+
function parseInputDateWithDashes(value, dateInDashes) {
|
|
5202
|
+
if (!value) return "";
|
|
5203
|
+
let year = "", month = "", day = "";
|
|
5204
|
+
if (dateInDashes) {
|
|
5205
|
+
let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
|
|
5206
|
+
if (match) {
|
|
5207
|
+
[, month, day, year] = match;
|
|
5208
|
+
} else {
|
|
5209
|
+
match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
5210
|
+
if (match) {
|
|
5211
|
+
[, year, month, day] = match;
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
} else {
|
|
5215
|
+
const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
|
|
5216
|
+
if (match) {
|
|
5217
|
+
[, month, day, year] = match;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
if (!year || !month || !day) return "";
|
|
5221
|
+
return `${month}-${day}-${year}`;
|
|
5222
|
+
}
|
|
5223
|
+
|
|
5190
5224
|
// src/components/DateInput.tsx
|
|
5191
5225
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5192
5226
|
var DateInput = (_a) => {
|
|
@@ -5200,7 +5234,8 @@ var DateInput = (_a) => {
|
|
|
5200
5234
|
readOnly = false,
|
|
5201
5235
|
label,
|
|
5202
5236
|
isDateAvailable,
|
|
5203
|
-
disableManualInput
|
|
5237
|
+
disableManualInput,
|
|
5238
|
+
dateInDashes = false
|
|
5204
5239
|
} = _b, props = __objRest(_b, [
|
|
5205
5240
|
"id",
|
|
5206
5241
|
"testid",
|
|
@@ -5211,7 +5246,8 @@ var DateInput = (_a) => {
|
|
|
5211
5246
|
"readOnly",
|
|
5212
5247
|
"label",
|
|
5213
5248
|
"isDateAvailable",
|
|
5214
|
-
"disableManualInput"
|
|
5249
|
+
"disableManualInput",
|
|
5250
|
+
"dateInDashes"
|
|
5215
5251
|
]);
|
|
5216
5252
|
const [visible, setVisible] = (0, import_react21.useState)(false);
|
|
5217
5253
|
const [inputValue, setInputValue] = (0, import_react21.useState)("");
|
|
@@ -5227,9 +5263,9 @@ var DateInput = (_a) => {
|
|
|
5227
5263
|
const [from, to] = [value, ""];
|
|
5228
5264
|
(0, import_react21.useEffect)(() => {
|
|
5229
5265
|
if (!isTyping) {
|
|
5230
|
-
setInputValue(formatDisplayValue(from));
|
|
5266
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5231
5267
|
}
|
|
5232
|
-
}, [from, isTyping]);
|
|
5268
|
+
}, [from, isTyping, dateInDashes]);
|
|
5233
5269
|
(0, import_react21.useLayoutEffect)(() => {
|
|
5234
5270
|
if (visible) {
|
|
5235
5271
|
updatePosition();
|
|
@@ -5292,7 +5328,7 @@ var DateInput = (_a) => {
|
|
|
5292
5328
|
const rawValue = event.target.value;
|
|
5293
5329
|
const cursorPosition = event.target.selectionStart || 0;
|
|
5294
5330
|
setIsTyping(true);
|
|
5295
|
-
const formattedValue =
|
|
5331
|
+
const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
|
|
5296
5332
|
setInputValue(formattedValue);
|
|
5297
5333
|
requestAnimationFrame(() => {
|
|
5298
5334
|
if (triggerRef.current) {
|
|
@@ -5304,16 +5340,16 @@ var DateInput = (_a) => {
|
|
|
5304
5340
|
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
5305
5341
|
}
|
|
5306
5342
|
});
|
|
5307
|
-
const parsedDate =
|
|
5343
|
+
const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
|
|
5308
5344
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5309
5345
|
onChange(parsedDate);
|
|
5310
5346
|
}
|
|
5311
5347
|
};
|
|
5312
5348
|
const handleBlur = () => {
|
|
5313
5349
|
setIsTyping(false);
|
|
5314
|
-
const parsedDate =
|
|
5350
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5315
5351
|
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
5316
|
-
setInputValue(formatDisplayValue(from));
|
|
5352
|
+
setInputValue(formatDisplayValue(from, dateInDashes));
|
|
5317
5353
|
}
|
|
5318
5354
|
};
|
|
5319
5355
|
const handleKeyDown = (event) => {
|
|
@@ -5321,10 +5357,11 @@ var DateInput = (_a) => {
|
|
|
5321
5357
|
const input = event.target;
|
|
5322
5358
|
const cursorPosition = input.selectionStart || 0;
|
|
5323
5359
|
const value2 = input.value;
|
|
5324
|
-
|
|
5360
|
+
const sep = dateInDashes ? "-" : "/";
|
|
5361
|
+
if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
|
|
5325
5362
|
event.preventDefault();
|
|
5326
5363
|
const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
|
|
5327
|
-
const formattedValue =
|
|
5364
|
+
const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
|
|
5328
5365
|
setInputValue(formattedValue);
|
|
5329
5366
|
requestAnimationFrame(() => {
|
|
5330
5367
|
if (triggerRef.current) {
|
|
@@ -5337,7 +5374,7 @@ var DateInput = (_a) => {
|
|
|
5337
5374
|
}
|
|
5338
5375
|
}
|
|
5339
5376
|
if (event.key === "Enter") {
|
|
5340
|
-
const parsedDate =
|
|
5377
|
+
const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
|
|
5341
5378
|
if (parsedDate && isValidDate(parsedDate)) {
|
|
5342
5379
|
onChange(parsedDate);
|
|
5343
5380
|
setVisible(false);
|
|
@@ -5426,14 +5463,14 @@ var DateInput = (_a) => {
|
|
|
5426
5463
|
] });
|
|
5427
5464
|
};
|
|
5428
5465
|
DateInput.displayName = "DateInput";
|
|
5429
|
-
function formatDisplayValue(from) {
|
|
5466
|
+
function formatDisplayValue(from, dateInDashes) {
|
|
5430
5467
|
if (!from) {
|
|
5431
5468
|
return "";
|
|
5432
5469
|
}
|
|
5433
5470
|
if (!isValidDate(from)) {
|
|
5434
5471
|
return "";
|
|
5435
5472
|
}
|
|
5436
|
-
return
|
|
5473
|
+
return formatDateWithDashes(from, dateInDashes);
|
|
5437
5474
|
}
|
|
5438
5475
|
|
|
5439
5476
|
// src/components/Accordion.tsx
|