@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.
Files changed (34) hide show
  1. package/dist/{chunk-T7NSOCGM.js → chunk-IUJIB7Y2.js} +71 -16
  2. package/dist/components/CalendarRange.cjs +72 -33
  3. package/dist/components/CalendarRange.js +1 -1
  4. package/dist/components/ContentTabs.cjs +3 -3
  5. package/dist/components/ContentTabs.js +3 -3
  6. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +70 -33
  7. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +1 -1
  8. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +70 -33
  9. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +1 -1
  10. package/dist/components/DataGrid/PinnedColumns.cjs +70 -33
  11. package/dist/components/DataGrid/PinnedColumns.js +1 -1
  12. package/dist/components/DataGrid/TableBody/LoadingCell.cjs +70 -33
  13. package/dist/components/DataGrid/TableBody/LoadingCell.js +1 -1
  14. package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +70 -33
  15. package/dist/components/DataGrid/TableBody/TableBodyRow.js +1 -1
  16. package/dist/components/DataGrid/TableBody/index.cjs +70 -33
  17. package/dist/components/DataGrid/TableBody/index.js +1 -1
  18. package/dist/components/DataGrid/index.cjs +70 -33
  19. package/dist/components/DataGrid/index.js +1 -1
  20. package/dist/components/DataGrid/utils.cjs +70 -33
  21. package/dist/components/DataGrid/utils.js +1 -1
  22. package/dist/components/DateInput.cjs +70 -33
  23. package/dist/components/DateInput.js +1 -1
  24. package/dist/components/DateRangeInput.cjs +72 -13
  25. package/dist/components/DateRangeInput.js +1 -1
  26. package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +70 -33
  27. package/dist/components/MobileDataGrid/ColumnSelector/index.js +1 -1
  28. package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +70 -33
  29. package/dist/components/MobileDataGrid/MobileDataGridHeader.js +1 -1
  30. package/dist/components/MobileDataGrid/index.cjs +70 -33
  31. package/dist/components/MobileDataGrid/index.js +1 -1
  32. package/dist/components/index.cjs +70 -33
  33. package/dist/components/index.js +1 -1
  34. package/package.json +1 -1
@@ -510,30 +510,10 @@ function formatCurrencyDisplay(value) {
510
510
  }
511
511
 
512
512
  // src/utils/date.ts
513
- function parseInputDate(input) {
514
- const match = input.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
515
- if (!match) {
516
- return null;
517
- }
518
- const [, month, day, year] = match;
519
- const paddedMonth = month.padStart(2, "0");
520
- const paddedDay = day.padStart(2, "0");
521
- return `${year}-${paddedMonth}-${paddedDay}`;
522
- }
523
513
  function isValidDate(dateString) {
524
514
  const date = new Date(dateString);
525
515
  return date instanceof Date && !isNaN(date.getTime()) && dateString === date.toISOString().split("T")[0];
526
516
  }
527
- function formatInputValue(value) {
528
- const digits = value.replace(/\D/g, "");
529
- if (digits.length < 2) {
530
- return digits;
531
- }
532
- if (digits.length >= 4) {
533
- return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
534
- }
535
- return `${digits.slice(0, 2)}/${digits.slice(2)}`;
536
- }
537
517
  function isDigit(character) {
538
518
  return /\d/.test(character);
539
519
  }
@@ -4914,6 +4894,60 @@ function CalendarPane({
4914
4894
  ] }, month.name + month.year);
4915
4895
  }
4916
4896
 
4897
+ // src/utils/date-patch-dashes.ts
4898
+ function formatInputValueWithDashes(value, dateInDashes) {
4899
+ const digits = value.replace(/\D/g, "");
4900
+ if (dateInDashes) {
4901
+ if (digits.length <= 4) return digits;
4902
+ if (digits.length <= 6) return `${digits.slice(0, 4)}-${digits.slice(4)}`;
4903
+ return `${digits.slice(4, 6)}-${digits.slice(6, 8)}-${digits.slice(0, 4)}`;
4904
+ } else {
4905
+ if (digits.length <= 2) return digits;
4906
+ if (digits.length <= 4) return `${digits.slice(0, 2)}/${digits.slice(2)}`;
4907
+ return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
4908
+ }
4909
+ }
4910
+ function formatDateWithDashes(value, dateInDashes) {
4911
+ if (!value) return "";
4912
+ let year = "", month = "", day = "";
4913
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
4914
+ [year, month, day] = value.split("-");
4915
+ } else if (/^\d{2}-\d{2}-\d{4}$/.test(value)) {
4916
+ [month, day, year] = value.split("-");
4917
+ } else if (/^\d{2}\/\d{2}\/\d{4}$/.test(value)) {
4918
+ [month, day, year] = value.split("/");
4919
+ } else {
4920
+ return value;
4921
+ }
4922
+ if (!year || !month || !day) return value;
4923
+ if (dateInDashes) {
4924
+ return `${month}-${day}-${year}`;
4925
+ }
4926
+ return `${month}/${day}/${year}`;
4927
+ }
4928
+ function parseInputDateWithDashes(value, dateInDashes) {
4929
+ if (!value) return "";
4930
+ let year = "", month = "", day = "";
4931
+ if (dateInDashes) {
4932
+ let match = value.match(/^(\d{2})-(\d{2})-(\d{4})$/);
4933
+ if (match) {
4934
+ [, month, day, year] = match;
4935
+ } else {
4936
+ match = value.match(/^(\d{4})-(\d{2})-(\d{2})$/);
4937
+ if (match) {
4938
+ [, year, month, day] = match;
4939
+ }
4940
+ }
4941
+ } else {
4942
+ const match = value.match(/^(\d{2})\/(\d{2})\/(\d{4})$/);
4943
+ if (match) {
4944
+ [, month, day, year] = match;
4945
+ }
4946
+ }
4947
+ if (!year || !month || !day) return "";
4948
+ return `${month}-${day}-${year}`;
4949
+ }
4950
+
4917
4951
  // src/components/DateInput.tsx
4918
4952
  var import_jsx_runtime25 = require("react/jsx-runtime");
4919
4953
  var DateInput = (_a) => {
@@ -4927,7 +4961,8 @@ var DateInput = (_a) => {
4927
4961
  readOnly = false,
4928
4962
  label,
4929
4963
  isDateAvailable,
4930
- disableManualInput
4964
+ disableManualInput,
4965
+ dateInDashes = false
4931
4966
  } = _b, props = __objRest(_b, [
4932
4967
  "id",
4933
4968
  "testid",
@@ -4938,7 +4973,8 @@ var DateInput = (_a) => {
4938
4973
  "readOnly",
4939
4974
  "label",
4940
4975
  "isDateAvailable",
4941
- "disableManualInput"
4976
+ "disableManualInput",
4977
+ "dateInDashes"
4942
4978
  ]);
4943
4979
  const [visible, setVisible] = (0, import_react21.useState)(false);
4944
4980
  const [inputValue, setInputValue] = (0, import_react21.useState)("");
@@ -4954,9 +4990,9 @@ var DateInput = (_a) => {
4954
4990
  const [from, to] = [value, ""];
4955
4991
  (0, import_react21.useEffect)(() => {
4956
4992
  if (!isTyping) {
4957
- setInputValue(formatDisplayValue(from));
4993
+ setInputValue(formatDisplayValue(from, dateInDashes));
4958
4994
  }
4959
- }, [from, isTyping]);
4995
+ }, [from, isTyping, dateInDashes]);
4960
4996
  (0, import_react21.useLayoutEffect)(() => {
4961
4997
  if (visible) {
4962
4998
  updatePosition();
@@ -5019,7 +5055,7 @@ var DateInput = (_a) => {
5019
5055
  const rawValue = event.target.value;
5020
5056
  const cursorPosition = event.target.selectionStart || 0;
5021
5057
  setIsTyping(true);
5022
- const formattedValue = formatInputValue(rawValue);
5058
+ const formattedValue = formatInputValueWithDashes(rawValue, dateInDashes);
5023
5059
  setInputValue(formattedValue);
5024
5060
  requestAnimationFrame(() => {
5025
5061
  if (triggerRef.current) {
@@ -5031,16 +5067,16 @@ var DateInput = (_a) => {
5031
5067
  triggerRef.current.setSelectionRange(newPosition, newPosition);
5032
5068
  }
5033
5069
  });
5034
- const parsedDate = parseInputDate(formattedValue);
5070
+ const parsedDate = parseInputDateWithDashes(formattedValue, dateInDashes);
5035
5071
  if (parsedDate && isValidDate(parsedDate)) {
5036
5072
  onChange(parsedDate);
5037
5073
  }
5038
5074
  };
5039
5075
  const handleBlur = () => {
5040
5076
  setIsTyping(false);
5041
- const parsedDate = parseInputDate(inputValue);
5077
+ const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
5042
5078
  if (!parsedDate || !isValidDate(parsedDate)) {
5043
- setInputValue(formatDisplayValue(from));
5079
+ setInputValue(formatDisplayValue(from, dateInDashes));
5044
5080
  }
5045
5081
  };
5046
5082
  const handleKeyDown = (event) => {
@@ -5048,10 +5084,11 @@ var DateInput = (_a) => {
5048
5084
  const input = event.target;
5049
5085
  const cursorPosition = input.selectionStart || 0;
5050
5086
  const value2 = input.value;
5051
- if (cursorPosition > 0 && value2[cursorPosition - 1] === "/") {
5087
+ const sep = dateInDashes ? "-" : "/";
5088
+ if (cursorPosition > 0 && value2[cursorPosition - 1] === sep) {
5052
5089
  event.preventDefault();
5053
5090
  const newValue = value2.slice(0, cursorPosition - 2) + value2.slice(cursorPosition);
5054
- const formattedValue = formatInputValue(newValue);
5091
+ const formattedValue = formatInputValueWithDashes(newValue, dateInDashes);
5055
5092
  setInputValue(formattedValue);
5056
5093
  requestAnimationFrame(() => {
5057
5094
  if (triggerRef.current) {
@@ -5064,7 +5101,7 @@ var DateInput = (_a) => {
5064
5101
  }
5065
5102
  }
5066
5103
  if (event.key === "Enter") {
5067
- const parsedDate = parseInputDate(inputValue);
5104
+ const parsedDate = parseInputDateWithDashes(inputValue, dateInDashes);
5068
5105
  if (parsedDate && isValidDate(parsedDate)) {
5069
5106
  onChange(parsedDate);
5070
5107
  setVisible(false);
@@ -5153,14 +5190,14 @@ var DateInput = (_a) => {
5153
5190
  ] });
5154
5191
  };
5155
5192
  DateInput.displayName = "DateInput";
5156
- function formatDisplayValue(from) {
5193
+ function formatDisplayValue(from, dateInDashes) {
5157
5194
  if (!from) {
5158
5195
  return "";
5159
5196
  }
5160
5197
  if (!isValidDate(from)) {
5161
5198
  return "";
5162
5199
  }
5163
- return formatDate(from);
5200
+ return formatDateWithDashes(from, dateInDashes);
5164
5201
  }
5165
5202
 
5166
5203
  // src/components/Accordion.tsx
@@ -2,7 +2,7 @@ import {
2
2
  DataGrid,
3
3
  DateInput,
4
4
  MobileDataGrid
5
- } from "../chunk-T7NSOCGM.js";
5
+ } from "../chunk-IUJIB7Y2.js";
6
6
  import "../chunk-WJJB7IJZ.js";
7
7
  import "../chunk-Q4YDNW7N.js";
8
8
  import "../chunk-M7INAUAJ.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.853",
4
+ "version": "0.0.855",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",