@dmsi/wedgekit-react 0.0.160 → 0.0.161
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-NMVSRA5Y.js → chunk-4XA32LKR.js} +2 -3
- package/dist/{chunk-4T7F5BZZ.js → chunk-6LN6QT6M.js} +1 -1
- package/dist/{chunk-5GOJRLQO.js → chunk-FCREADUH.js} +1 -1
- package/dist/{chunk-IDN3IN2A.js → chunk-M3433XEJ.js} +9 -2
- package/dist/{chunk-YR7JUKYO.js → chunk-RLK4TBXR.js} +1 -1
- package/dist/{chunk-4NCDT5ZY.js → chunk-SBSHZ327.js} +1 -1
- package/dist/{chunk-RUTYNLKS.js → chunk-WFLOAGEI.js} +1 -1
- package/dist/components/CalendarRange.cjs +2 -3
- package/dist/components/CalendarRange.js +1 -1
- package/dist/components/DataGridCell.cjs +1 -1
- package/dist/components/DataGridCell.js +3 -3
- package/dist/components/DataTable.cjs +1 -2
- package/dist/components/DataTable.js +1 -3
- package/dist/components/DateInput.cjs +12 -6
- package/dist/components/DateInput.js +3 -3
- package/dist/components/DateRangeInput.cjs +12 -6
- package/dist/components/DateRangeInput.js +3 -3
- package/dist/components/EditingContext.cjs +1 -2
- package/dist/components/EditingContext.js +1 -2
- package/dist/components/Menu.cjs +1 -1
- package/dist/components/Menu.js +2 -2
- package/dist/components/MobileDataGrid.cjs +7 -3
- package/dist/components/MobileDataGrid.js +7 -3
- package/dist/components/Modal.cjs +1 -1
- package/dist/components/Modal.js +2 -2
- package/dist/components/NavigationTabs.cjs +4 -4
- package/dist/components/NavigationTabs.js +4 -4
- package/dist/components/PDFViewer.cjs +1 -1
- package/dist/components/PDFViewer.js +2 -2
- package/dist/components/PaymentOnAccountModal.cjs +1 -1
- package/dist/components/PaymentOnAccountModal.js +3 -3
- package/dist/components/Time.cjs +1 -1
- package/dist/components/Time.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +5 -5
- package/dist/utils/index.cjs +9 -2
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
- package/src/components/CalendarRange.tsx +15 -9
- package/src/components/DataTable.tsx +1 -3
- package/src/components/EditingContext.tsx +4 -3
- package/src/components/MobileDataGrid.tsx +12 -4
- package/src/components/NavigationTabs.tsx +1 -1
- package/src/utils/date.ts +65 -35
- package/src/utils.ts +1 -1
|
@@ -123,6 +123,7 @@ function CalendarRange({
|
|
|
123
123
|
}
|
|
124
124
|
return void 0;
|
|
125
125
|
} catch (error) {
|
|
126
|
+
console.error("Invalid date format:", d, error);
|
|
126
127
|
return Temporal.Now.plainDateISO();
|
|
127
128
|
}
|
|
128
129
|
};
|
|
@@ -224,9 +225,7 @@ function CalendarRange({
|
|
|
224
225
|
/* @__PURE__ */ jsxs(
|
|
225
226
|
"div",
|
|
226
227
|
{
|
|
227
|
-
className: clsx(
|
|
228
|
-
"flex flex-col"
|
|
229
|
-
),
|
|
228
|
+
className: clsx("flex flex-col"),
|
|
230
229
|
children: [
|
|
231
230
|
/* @__PURE__ */ jsxs(
|
|
232
231
|
"div",
|
|
@@ -8,7 +8,7 @@ function findDocumentRoot(element) {
|
|
|
8
8
|
if (!element || !(element instanceof Node)) {
|
|
9
9
|
return window.document.body;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
let currentElement = element;
|
|
12
12
|
while (currentElement && currentElement.parentNode) {
|
|
13
13
|
if (currentElement.parentNode === document) {
|
|
14
14
|
return document.body;
|
|
@@ -59,8 +59,14 @@ function findPositionAfterDigitCount(formattedValue, targetDigitCount) {
|
|
|
59
59
|
return formattedValue.length;
|
|
60
60
|
}
|
|
61
61
|
function calculateCursorPosition(originalValue, formattedValue, originalPosition) {
|
|
62
|
-
const targetDigitCount = countDigitsUpToCursor(
|
|
63
|
-
|
|
62
|
+
const targetDigitCount = countDigitsUpToCursor(
|
|
63
|
+
originalValue,
|
|
64
|
+
originalPosition
|
|
65
|
+
);
|
|
66
|
+
const newPosition = findPositionAfterDigitCount(
|
|
67
|
+
formattedValue,
|
|
68
|
+
targetDigitCount
|
|
69
|
+
);
|
|
64
70
|
return Math.min(newPosition, formattedValue.length);
|
|
65
71
|
}
|
|
66
72
|
function parseDateParts(dateString) {
|
|
@@ -105,6 +111,7 @@ function formatDate(date) {
|
|
|
105
111
|
}
|
|
106
112
|
return formatDatePartsToDisplay(year, month, day);
|
|
107
113
|
} catch (error) {
|
|
114
|
+
console.error("Error formatting date:", error);
|
|
108
115
|
return "";
|
|
109
116
|
}
|
|
110
117
|
}
|
|
@@ -336,6 +336,7 @@ function CalendarRange({
|
|
|
336
336
|
}
|
|
337
337
|
return void 0;
|
|
338
338
|
} catch (error) {
|
|
339
|
+
console.error("Invalid date format:", d, error);
|
|
339
340
|
return import_polyfill.Temporal.Now.plainDateISO();
|
|
340
341
|
}
|
|
341
342
|
};
|
|
@@ -437,9 +438,7 @@ function CalendarRange({
|
|
|
437
438
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
438
439
|
"div",
|
|
439
440
|
{
|
|
440
|
-
className: (0, import_clsx3.default)(
|
|
441
|
-
"flex flex-col"
|
|
442
|
-
),
|
|
441
|
+
className: (0, import_clsx3.default)("flex flex-col"),
|
|
443
442
|
children: [
|
|
444
443
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
445
444
|
"div",
|
|
@@ -1195,7 +1195,7 @@ function findDocumentRoot(element) {
|
|
|
1195
1195
|
if (!element || !(element instanceof Node)) {
|
|
1196
1196
|
return window.document.body;
|
|
1197
1197
|
}
|
|
1198
|
-
|
|
1198
|
+
let currentElement = element;
|
|
1199
1199
|
while (currentElement && currentElement.parentNode) {
|
|
1200
1200
|
if (currentElement.parentNode === document) {
|
|
1201
1201
|
return document.body;
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
DataGridCell,
|
|
5
5
|
DragAlongCell,
|
|
6
6
|
DraggableCellHeader
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-SBSHZ327.js";
|
|
8
|
+
import "../chunk-RLK4TBXR.js";
|
|
9
9
|
import "../chunk-5GUW4DUY.js";
|
|
10
10
|
import "../chunk-FFU6FB3K.js";
|
|
11
11
|
import "../chunk-WNQ53SVY.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-6LN6QT6M.js";
|
|
13
13
|
import "../chunk-PMBEIP24.js";
|
|
14
14
|
import "../chunk-4T3DRGLF.js";
|
|
15
15
|
import "../chunk-5UH6QUFB.js";
|
|
@@ -249,12 +249,11 @@ var columns = [
|
|
|
249
249
|
var EditingContext = (0, import_react2.createContext)({
|
|
250
250
|
data: [],
|
|
251
251
|
setValue: (row, key, value) => {
|
|
252
|
-
console.
|
|
252
|
+
console.warn("TODO: Implement setValue logic", row, key, value);
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
255
|
var EditingProvider = ({ data, children }) => {
|
|
256
256
|
const [actual, setData] = (0, import_react2.useState)(data);
|
|
257
|
-
(0, import_react2.useEffect)(() => console.log("data changed"), [actual]);
|
|
258
257
|
const context = {
|
|
259
258
|
data: actual,
|
|
260
259
|
setValue: (row, key, value) => {
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
import React, {
|
|
12
12
|
createContext,
|
|
13
13
|
useContext,
|
|
14
|
-
useEffect,
|
|
15
14
|
useState
|
|
16
15
|
} from "react";
|
|
17
16
|
import {
|
|
@@ -178,12 +177,11 @@ var columns = [
|
|
|
178
177
|
var EditingContext = createContext({
|
|
179
178
|
data: [],
|
|
180
179
|
setValue: (row, key, value) => {
|
|
181
|
-
console.
|
|
180
|
+
console.warn("TODO: Implement setValue logic", row, key, value);
|
|
182
181
|
}
|
|
183
182
|
});
|
|
184
183
|
var EditingProvider = ({ data, children }) => {
|
|
185
184
|
const [actual, setData] = useState(data);
|
|
186
|
-
useEffect(() => console.log("data changed"), [actual]);
|
|
187
185
|
const context = {
|
|
188
186
|
data: actual,
|
|
189
187
|
setValue: (row, key, value) => {
|
|
@@ -800,6 +800,7 @@ function CalendarRange({
|
|
|
800
800
|
}
|
|
801
801
|
return void 0;
|
|
802
802
|
} catch (error) {
|
|
803
|
+
console.error("Invalid date format:", d, error);
|
|
803
804
|
return import_polyfill.Temporal.Now.plainDateISO();
|
|
804
805
|
}
|
|
805
806
|
};
|
|
@@ -901,9 +902,7 @@ function CalendarRange({
|
|
|
901
902
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
902
903
|
"div",
|
|
903
904
|
{
|
|
904
|
-
className: (0, import_clsx5.default)(
|
|
905
|
-
"flex flex-col"
|
|
906
|
-
),
|
|
905
|
+
className: (0, import_clsx5.default)("flex flex-col"),
|
|
907
906
|
children: [
|
|
908
907
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
909
908
|
"div",
|
|
@@ -1030,7 +1029,7 @@ function findDocumentRoot(element) {
|
|
|
1030
1029
|
if (!element || !(element instanceof Node)) {
|
|
1031
1030
|
return window.document.body;
|
|
1032
1031
|
}
|
|
1033
|
-
|
|
1032
|
+
let currentElement = element;
|
|
1034
1033
|
while (currentElement && currentElement.parentNode) {
|
|
1035
1034
|
if (currentElement.parentNode === document) {
|
|
1036
1035
|
return document.body;
|
|
@@ -1104,8 +1103,14 @@ function findPositionAfterDigitCount(formattedValue, targetDigitCount) {
|
|
|
1104
1103
|
return formattedValue.length;
|
|
1105
1104
|
}
|
|
1106
1105
|
function calculateCursorPosition(originalValue, formattedValue, originalPosition) {
|
|
1107
|
-
const targetDigitCount = countDigitsUpToCursor(
|
|
1108
|
-
|
|
1106
|
+
const targetDigitCount = countDigitsUpToCursor(
|
|
1107
|
+
originalValue,
|
|
1108
|
+
originalPosition
|
|
1109
|
+
);
|
|
1110
|
+
const newPosition = findPositionAfterDigitCount(
|
|
1111
|
+
formattedValue,
|
|
1112
|
+
targetDigitCount
|
|
1113
|
+
);
|
|
1109
1114
|
return Math.min(newPosition, formattedValue.length);
|
|
1110
1115
|
}
|
|
1111
1116
|
function parseDateParts(dateString) {
|
|
@@ -1150,6 +1155,7 @@ function formatDate(date) {
|
|
|
1150
1155
|
}
|
|
1151
1156
|
return formatDatePartsToDisplay(year, month, day);
|
|
1152
1157
|
} catch (error) {
|
|
1158
|
+
console.error("Error formatting date:", error);
|
|
1153
1159
|
return "";
|
|
1154
1160
|
}
|
|
1155
1161
|
}
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
formatInputValue,
|
|
5
5
|
isValidDate,
|
|
6
6
|
parseInputDate
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-M3433XEJ.js";
|
|
8
8
|
import {
|
|
9
9
|
findDocumentRoot
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-6LN6QT6M.js";
|
|
11
11
|
import {
|
|
12
12
|
InputBase
|
|
13
13
|
} from "../chunk-4T3DRGLF.js";
|
|
@@ -15,7 +15,7 @@ import "../chunk-5UH6QUFB.js";
|
|
|
15
15
|
import "../chunk-JWCT72WR.js";
|
|
16
16
|
import {
|
|
17
17
|
CalendarRange
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-4XA32LKR.js";
|
|
19
19
|
import {
|
|
20
20
|
Icon
|
|
21
21
|
} from "../chunk-NKUETCDA.js";
|
|
@@ -800,6 +800,7 @@ function CalendarRange({
|
|
|
800
800
|
}
|
|
801
801
|
return void 0;
|
|
802
802
|
} catch (error) {
|
|
803
|
+
console.error("Invalid date format:", d, error);
|
|
803
804
|
return import_polyfill.Temporal.Now.plainDateISO();
|
|
804
805
|
}
|
|
805
806
|
};
|
|
@@ -901,9 +902,7 @@ function CalendarRange({
|
|
|
901
902
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
902
903
|
"div",
|
|
903
904
|
{
|
|
904
|
-
className: (0, import_clsx5.default)(
|
|
905
|
-
"flex flex-col"
|
|
906
|
-
),
|
|
905
|
+
className: (0, import_clsx5.default)("flex flex-col"),
|
|
907
906
|
children: [
|
|
908
907
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
909
908
|
"div",
|
|
@@ -1030,7 +1029,7 @@ function findDocumentRoot(element) {
|
|
|
1030
1029
|
if (!element || !(element instanceof Node)) {
|
|
1031
1030
|
return window.document.body;
|
|
1032
1031
|
}
|
|
1033
|
-
|
|
1032
|
+
let currentElement = element;
|
|
1034
1033
|
while (currentElement && currentElement.parentNode) {
|
|
1035
1034
|
if (currentElement.parentNode === document) {
|
|
1036
1035
|
return document.body;
|
|
@@ -1104,8 +1103,14 @@ function findPositionAfterDigitCount(formattedValue, targetDigitCount) {
|
|
|
1104
1103
|
return formattedValue.length;
|
|
1105
1104
|
}
|
|
1106
1105
|
function calculateCursorPosition(originalValue, formattedValue, originalPosition) {
|
|
1107
|
-
const targetDigitCount = countDigitsUpToCursor(
|
|
1108
|
-
|
|
1106
|
+
const targetDigitCount = countDigitsUpToCursor(
|
|
1107
|
+
originalValue,
|
|
1108
|
+
originalPosition
|
|
1109
|
+
);
|
|
1110
|
+
const newPosition = findPositionAfterDigitCount(
|
|
1111
|
+
formattedValue,
|
|
1112
|
+
targetDigitCount
|
|
1113
|
+
);
|
|
1109
1114
|
return Math.min(newPosition, formattedValue.length);
|
|
1110
1115
|
}
|
|
1111
1116
|
function parseDateParts(dateString) {
|
|
@@ -1150,6 +1155,7 @@ function formatDate(date) {
|
|
|
1150
1155
|
}
|
|
1151
1156
|
return formatDatePartsToDisplay(year, month, day);
|
|
1152
1157
|
} catch (error) {
|
|
1158
|
+
console.error("Error formatting date:", error);
|
|
1153
1159
|
return "";
|
|
1154
1160
|
}
|
|
1155
1161
|
}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
isValidDate,
|
|
6
6
|
isValidDateRangeOrder,
|
|
7
7
|
parseInputDate
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-M3433XEJ.js";
|
|
9
9
|
import {
|
|
10
10
|
findDocumentRoot
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-6LN6QT6M.js";
|
|
12
12
|
import {
|
|
13
13
|
InputBase
|
|
14
14
|
} from "../chunk-4T3DRGLF.js";
|
|
@@ -16,7 +16,7 @@ import "../chunk-5UH6QUFB.js";
|
|
|
16
16
|
import "../chunk-JWCT72WR.js";
|
|
17
17
|
import {
|
|
18
18
|
CalendarRange
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-4XA32LKR.js";
|
|
20
20
|
import {
|
|
21
21
|
Icon
|
|
22
22
|
} from "../chunk-NKUETCDA.js";
|
|
@@ -46,8 +46,7 @@ var import_react = require("react");
|
|
|
46
46
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
47
|
var EditingContext = (0, import_react.createContext)({
|
|
48
48
|
data: [],
|
|
49
|
-
setData: (
|
|
50
|
-
console.log(row, key, value);
|
|
49
|
+
setData: () => {
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
52
|
var EditingProvider = ({
|
|
@@ -9,8 +9,7 @@ import { createContext, useState } from "react";
|
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
var EditingContext = createContext({
|
|
11
11
|
data: [],
|
|
12
|
-
setData: (
|
|
13
|
-
console.log(row, key, value);
|
|
12
|
+
setData: () => {
|
|
14
13
|
}
|
|
15
14
|
});
|
|
16
15
|
var EditingProvider = ({
|
package/dist/components/Menu.cjs
CHANGED
|
@@ -188,7 +188,7 @@ function findDocumentRoot(element) {
|
|
|
188
188
|
if (!element || !(element instanceof Node)) {
|
|
189
189
|
return window.document.body;
|
|
190
190
|
}
|
|
191
|
-
|
|
191
|
+
let currentElement = element;
|
|
192
192
|
while (currentElement && currentElement.parentNode) {
|
|
193
193
|
if (currentElement.parentNode === document) {
|
|
194
194
|
return document.body;
|
package/dist/components/Menu.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Menu
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-RLK4TBXR.js";
|
|
5
5
|
import "../chunk-5GUW4DUY.js";
|
|
6
6
|
import "../chunk-WNQ53SVY.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-6LN6QT6M.js";
|
|
8
8
|
import "../chunk-ORMEWXMH.js";
|
|
9
9
|
export {
|
|
10
10
|
Menu
|
|
@@ -715,7 +715,11 @@ function MobileDataGrid({
|
|
|
715
715
|
}
|
|
716
716
|
);
|
|
717
717
|
}
|
|
718
|
-
function MobileDataGridHeader({
|
|
718
|
+
function MobileDataGridHeader({
|
|
719
|
+
header,
|
|
720
|
+
id,
|
|
721
|
+
testid
|
|
722
|
+
}) {
|
|
719
723
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { id, "data-testid": testid, className: "sticky top-0", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Theme, { theme: "brand", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
720
724
|
Stack,
|
|
721
725
|
{
|
|
@@ -749,7 +753,7 @@ function MobileDataGridCard({
|
|
|
749
753
|
testid: testid ? `${testid}-docs-button` : void 0,
|
|
750
754
|
iconOnly: true,
|
|
751
755
|
variant: "tertiary",
|
|
752
|
-
onClick: () => console.
|
|
756
|
+
onClick: () => console.warn("TODO: Implement Edit", data.id),
|
|
753
757
|
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "docs" })
|
|
754
758
|
}
|
|
755
759
|
),
|
|
@@ -760,7 +764,7 @@ function MobileDataGridCard({
|
|
|
760
764
|
testid: testid ? `${testid}-swap-button` : void 0,
|
|
761
765
|
iconOnly: true,
|
|
762
766
|
variant: "tertiary",
|
|
763
|
-
onClick: () => console.
|
|
767
|
+
onClick: () => console.warn("TODO: Implement Edit", data.id),
|
|
764
768
|
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "swap_vert" })
|
|
765
769
|
}
|
|
766
770
|
)
|
|
@@ -69,7 +69,11 @@ function MobileDataGrid({
|
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
|
-
function MobileDataGridHeader({
|
|
72
|
+
function MobileDataGridHeader({
|
|
73
|
+
header,
|
|
74
|
+
id,
|
|
75
|
+
testid
|
|
76
|
+
}) {
|
|
73
77
|
return /* @__PURE__ */ jsx("div", { id, "data-testid": testid, className: "sticky top-0", children: /* @__PURE__ */ jsx(Theme, { theme: "brand", children: /* @__PURE__ */ jsx(
|
|
74
78
|
Stack,
|
|
75
79
|
{
|
|
@@ -103,7 +107,7 @@ function MobileDataGridCard({
|
|
|
103
107
|
testid: testid ? `${testid}-docs-button` : void 0,
|
|
104
108
|
iconOnly: true,
|
|
105
109
|
variant: "tertiary",
|
|
106
|
-
onClick: () => console.
|
|
110
|
+
onClick: () => console.warn("TODO: Implement Edit", data.id),
|
|
107
111
|
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "docs" })
|
|
108
112
|
}
|
|
109
113
|
),
|
|
@@ -114,7 +118,7 @@ function MobileDataGridCard({
|
|
|
114
118
|
testid: testid ? `${testid}-swap-button` : void 0,
|
|
115
119
|
iconOnly: true,
|
|
116
120
|
variant: "tertiary",
|
|
117
|
-
onClick: () => console.
|
|
121
|
+
onClick: () => console.warn("TODO: Implement Edit", data.id),
|
|
118
122
|
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "swap_vert" })
|
|
119
123
|
}
|
|
120
124
|
)
|
|
@@ -584,7 +584,7 @@ function findDocumentRoot(element) {
|
|
|
584
584
|
if (!element || !(element instanceof Node)) {
|
|
585
585
|
return window.document.body;
|
|
586
586
|
}
|
|
587
|
-
|
|
587
|
+
let currentElement = element;
|
|
588
588
|
while (currentElement && currentElement.parentNode) {
|
|
589
589
|
if (currentElement.parentNode === document) {
|
|
590
590
|
return document.body;
|
package/dist/components/Modal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Modal
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-FCREADUH.js";
|
|
5
5
|
import "../chunk-4RJKB7LC.js";
|
|
6
6
|
import "../chunk-C4JGTH6G.js";
|
|
7
7
|
import "../chunk-SYEJVSE4.js";
|
|
@@ -9,7 +9,7 @@ import "../chunk-R7ELP5C5.js";
|
|
|
9
9
|
import "../chunk-ZFOANBWG.js";
|
|
10
10
|
import "../chunk-AZ7LVLOK.js";
|
|
11
11
|
import "../chunk-WNQ53SVY.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-6LN6QT6M.js";
|
|
13
13
|
import "../chunk-FKMKHLQH.js";
|
|
14
14
|
import "../chunk-NKUETCDA.js";
|
|
15
15
|
import "../chunk-RDLEIAQU.js";
|
|
@@ -463,14 +463,14 @@ var NavigationTabs = ({
|
|
|
463
463
|
onTabChange,
|
|
464
464
|
colorPrimitives = "dmsi"
|
|
465
465
|
}) => {
|
|
466
|
-
var _a, _b, _c;
|
|
467
|
-
const [selectedTab, setSelectedTab] = (0, import_react.useState)((_a = tabs[0]) == null ? void 0 : _a.id);
|
|
466
|
+
var _a, _b, _c, _d;
|
|
467
|
+
const [selectedTab, setSelectedTab] = (0, import_react.useState)((_b = (_a = tabs[0]) == null ? void 0 : _a.id) != null ? _b : "");
|
|
468
468
|
const handleTabClick = (id2) => {
|
|
469
469
|
setSelectedTab(id2);
|
|
470
470
|
onTabChange == null ? void 0 : onTabChange(id2);
|
|
471
471
|
};
|
|
472
|
-
const selectedContent = (
|
|
473
|
-
const selectedTabHasHref = (
|
|
472
|
+
const selectedContent = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.content;
|
|
473
|
+
const selectedTabHasHref = (_d = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _d.href;
|
|
474
474
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { id, "data-testid": testid, children: [
|
|
475
475
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
476
476
|
"div",
|
|
@@ -20,14 +20,14 @@ var NavigationTabs = ({
|
|
|
20
20
|
onTabChange,
|
|
21
21
|
colorPrimitives = "dmsi"
|
|
22
22
|
}) => {
|
|
23
|
-
var _a, _b, _c;
|
|
24
|
-
const [selectedTab, setSelectedTab] = useState((_a = tabs[0]) == null ? void 0 : _a.id);
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
const [selectedTab, setSelectedTab] = useState((_b = (_a = tabs[0]) == null ? void 0 : _a.id) != null ? _b : "");
|
|
25
25
|
const handleTabClick = (id2) => {
|
|
26
26
|
setSelectedTab(id2);
|
|
27
27
|
onTabChange == null ? void 0 : onTabChange(id2);
|
|
28
28
|
};
|
|
29
|
-
const selectedContent = (
|
|
30
|
-
const selectedTabHasHref = (
|
|
29
|
+
const selectedContent = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.content;
|
|
30
|
+
const selectedTabHasHref = (_d = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _d.href;
|
|
31
31
|
return /* @__PURE__ */ jsxs("div", { id, "data-testid": testid, children: [
|
|
32
32
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
33
33
|
"div",
|
|
@@ -588,7 +588,7 @@ function findDocumentRoot(element) {
|
|
|
588
588
|
if (!element || !(element instanceof Node)) {
|
|
589
589
|
return window.document.body;
|
|
590
590
|
}
|
|
591
|
-
|
|
591
|
+
let currentElement = element;
|
|
592
592
|
while (currentElement && currentElement.parentNode) {
|
|
593
593
|
if (currentElement.parentNode === document) {
|
|
594
594
|
return document.body;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
Modal
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-FCREADUH.js";
|
|
5
5
|
import "../chunk-4RJKB7LC.js";
|
|
6
6
|
import "../chunk-C4JGTH6G.js";
|
|
7
7
|
import "../chunk-SYEJVSE4.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
Caption
|
|
16
16
|
} from "../chunk-E7D24OHM.js";
|
|
17
17
|
import "../chunk-WNQ53SVY.js";
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-6LN6QT6M.js";
|
|
19
19
|
import {
|
|
20
20
|
Stack
|
|
21
21
|
} from "../chunk-N6JVLYEE.js";
|
|
@@ -586,7 +586,7 @@ function findDocumentRoot(element) {
|
|
|
586
586
|
if (!element || !(element instanceof Node)) {
|
|
587
587
|
return window.document.body;
|
|
588
588
|
}
|
|
589
|
-
|
|
589
|
+
let currentElement = element;
|
|
590
590
|
while (currentElement && currentElement.parentNode) {
|
|
591
591
|
if (currentElement.parentNode === document) {
|
|
592
592
|
return document.body;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PaymentOnAccountModal,
|
|
3
3
|
calculateSurcharge
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-WFLOAGEI.js";
|
|
5
5
|
import "../chunk-NT2ZKA4W.js";
|
|
6
6
|
import "../chunk-WFGKIR5A.js";
|
|
7
7
|
import "../chunk-BATIOCXB.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-FCREADUH.js";
|
|
9
9
|
import "../chunk-4RJKB7LC.js";
|
|
10
10
|
import "../chunk-C4JGTH6G.js";
|
|
11
11
|
import "../chunk-SYEJVSE4.js";
|
|
@@ -16,7 +16,7 @@ import "../chunk-AZ7LVLOK.js";
|
|
|
16
16
|
import "../chunk-EPQLWHCL.js";
|
|
17
17
|
import "../chunk-WFQEE2OO.js";
|
|
18
18
|
import "../chunk-WNQ53SVY.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-6LN6QT6M.js";
|
|
20
20
|
import "../chunk-4T3DRGLF.js";
|
|
21
21
|
import "../chunk-5UH6QUFB.js";
|
|
22
22
|
import "../chunk-JWCT72WR.js";
|
package/dist/components/Time.cjs
CHANGED
|
@@ -706,7 +706,7 @@ function findDocumentRoot(element) {
|
|
|
706
706
|
if (!element || !(element instanceof Node)) {
|
|
707
707
|
return window.document.body;
|
|
708
708
|
}
|
|
709
|
-
|
|
709
|
+
let currentElement = element;
|
|
710
710
|
while (currentElement && currentElement.parentNode) {
|
|
711
711
|
if (currentElement.parentNode === document) {
|
|
712
712
|
return document.body;
|
package/dist/components/Time.js
CHANGED
|
@@ -1238,7 +1238,7 @@ function findDocumentRoot(element) {
|
|
|
1238
1238
|
if (!element || !(element instanceof Node)) {
|
|
1239
1239
|
return window.document.body;
|
|
1240
1240
|
}
|
|
1241
|
-
|
|
1241
|
+
let currentElement = element;
|
|
1242
1242
|
while (currentElement && currentElement.parentNode) {
|
|
1243
1243
|
if (currentElement.parentNode === document) {
|
|
1244
1244
|
return document.body;
|
package/dist/components/index.js
CHANGED
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "../chunk-XH65MD2C.js";
|
|
7
7
|
import {
|
|
8
8
|
PaymentOnAccountModal
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-WFLOAGEI.js";
|
|
10
10
|
import "../chunk-NT2ZKA4W.js";
|
|
11
11
|
import "../chunk-WFGKIR5A.js";
|
|
12
12
|
import "../chunk-BATIOCXB.js";
|
|
13
|
-
import "../chunk-
|
|
13
|
+
import "../chunk-FCREADUH.js";
|
|
14
14
|
import "../chunk-4RJKB7LC.js";
|
|
15
15
|
import "../chunk-C4JGTH6G.js";
|
|
16
16
|
import "../chunk-SYEJVSE4.js";
|
|
@@ -27,10 +27,10 @@ import {
|
|
|
27
27
|
DataGridCell,
|
|
28
28
|
DragAlongCell,
|
|
29
29
|
DraggableCellHeader
|
|
30
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-SBSHZ327.js";
|
|
31
31
|
import {
|
|
32
32
|
Menu
|
|
33
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-RLK4TBXR.js";
|
|
34
34
|
import "../chunk-5GUW4DUY.js";
|
|
35
35
|
import {
|
|
36
36
|
MenuOption
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
import {
|
|
39
39
|
useInfiniteScroll
|
|
40
40
|
} from "../chunk-WNQ53SVY.js";
|
|
41
|
-
import "../chunk-
|
|
41
|
+
import "../chunk-6LN6QT6M.js";
|
|
42
42
|
import {
|
|
43
43
|
Search
|
|
44
44
|
} from "../chunk-PMBEIP24.js";
|
package/dist/utils/index.cjs
CHANGED
|
@@ -133,8 +133,14 @@ function findPositionAfterDigitCount(formattedValue, targetDigitCount) {
|
|
|
133
133
|
return formattedValue.length;
|
|
134
134
|
}
|
|
135
135
|
function calculateCursorPosition(originalValue, formattedValue, originalPosition) {
|
|
136
|
-
const targetDigitCount = countDigitsUpToCursor(
|
|
137
|
-
|
|
136
|
+
const targetDigitCount = countDigitsUpToCursor(
|
|
137
|
+
originalValue,
|
|
138
|
+
originalPosition
|
|
139
|
+
);
|
|
140
|
+
const newPosition = findPositionAfterDigitCount(
|
|
141
|
+
formattedValue,
|
|
142
|
+
targetDigitCount
|
|
143
|
+
);
|
|
138
144
|
return Math.min(newPosition, formattedValue.length);
|
|
139
145
|
}
|
|
140
146
|
function parseDateParts(dateString) {
|
|
@@ -179,6 +185,7 @@ function formatDate(date) {
|
|
|
179
185
|
}
|
|
180
186
|
return formatDatePartsToDisplay(year, month, day);
|
|
181
187
|
} catch (error) {
|
|
188
|
+
console.error("Error formatting date:", error);
|
|
182
189
|
return "";
|
|
183
190
|
}
|
|
184
191
|
}
|
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
2
|
import {
|
|
3
3
|
typography,
|
|
4
|
-
componentGap,
|
|
5
4
|
componentPadding,
|
|
6
5
|
layoutPaddding,
|
|
7
6
|
layoutGap,
|
|
@@ -154,7 +153,7 @@ export function CalendarRange({
|
|
|
154
153
|
if (!d) {
|
|
155
154
|
return undefined;
|
|
156
155
|
}
|
|
157
|
-
|
|
156
|
+
|
|
158
157
|
try {
|
|
159
158
|
if (typeof d === "number") {
|
|
160
159
|
return Temporal.PlainDate.from(new Date(d).toISOString().slice(0, 10));
|
|
@@ -167,6 +166,7 @@ export function CalendarRange({
|
|
|
167
166
|
return undefined;
|
|
168
167
|
} catch (error) {
|
|
169
168
|
// If parsing fails, return current date instead of throwing
|
|
169
|
+
console.error("Invalid date format:", d, error);
|
|
170
170
|
return Temporal.Now.plainDateISO();
|
|
171
171
|
}
|
|
172
172
|
};
|
|
@@ -305,9 +305,7 @@ export function CalendarRange({
|
|
|
305
305
|
<React.Fragment key={month.name + month.year}>
|
|
306
306
|
<div
|
|
307
307
|
// key={month.name + month.year}
|
|
308
|
-
className={clsx(
|
|
309
|
-
"flex flex-col",
|
|
310
|
-
)}
|
|
308
|
+
className={clsx("flex flex-col")}
|
|
311
309
|
>
|
|
312
310
|
<div
|
|
313
311
|
className={clsx(
|
|
@@ -319,7 +317,9 @@ export function CalendarRange({
|
|
|
319
317
|
{idx === 0 ? (
|
|
320
318
|
<button
|
|
321
319
|
id={id ? `${id}-prev-month-button` : undefined}
|
|
322
|
-
data-testid={
|
|
320
|
+
data-testid={
|
|
321
|
+
testid ? `${testid}-prev-month-button` : undefined
|
|
322
|
+
}
|
|
323
323
|
type="button"
|
|
324
324
|
className={clsx(
|
|
325
325
|
"flex items-center justify-center rounded-base hover:bg-action-100 active:bg-action-300 text-icon-action-primary-normal",
|
|
@@ -346,7 +346,9 @@ export function CalendarRange({
|
|
|
346
346
|
{(mode === "double" ? idx === 1 : true) ? (
|
|
347
347
|
<button
|
|
348
348
|
id={id ? `${id}-next-month-button` : undefined}
|
|
349
|
-
data-testid={
|
|
349
|
+
data-testid={
|
|
350
|
+
testid ? `${testid}-next-month-button` : undefined
|
|
351
|
+
}
|
|
350
352
|
type="button"
|
|
351
353
|
className={clsx(
|
|
352
354
|
"flex items-center justify-center rounded-base hover:bg-action-100 active:bg-action-300 text-icon-action-primary-normal",
|
|
@@ -368,7 +370,7 @@ export function CalendarRange({
|
|
|
368
370
|
className={clsx(
|
|
369
371
|
typography.caption,
|
|
370
372
|
"text-text-secondary-normal text-center",
|
|
371
|
-
"w-10"
|
|
373
|
+
"w-10",
|
|
372
374
|
)}
|
|
373
375
|
>
|
|
374
376
|
{d}
|
|
@@ -427,7 +429,11 @@ export function CalendarRange({
|
|
|
427
429
|
<DateCell
|
|
428
430
|
key={i}
|
|
429
431
|
id={id ? `${id}-date-${date.toString()}` : undefined}
|
|
430
|
-
testid={
|
|
432
|
+
testid={
|
|
433
|
+
testid
|
|
434
|
+
? `${testid}-date-${date.toString()}`
|
|
435
|
+
: undefined
|
|
436
|
+
}
|
|
431
437
|
date={date}
|
|
432
438
|
isInMonth={!!isInMonth}
|
|
433
439
|
isToday={!!isToday}
|
|
@@ -5,7 +5,6 @@ import React, {
|
|
|
5
5
|
PropsWithChildren,
|
|
6
6
|
ReactNode,
|
|
7
7
|
useContext,
|
|
8
|
-
useEffect,
|
|
9
8
|
useState,
|
|
10
9
|
} from "react";
|
|
11
10
|
|
|
@@ -218,7 +217,7 @@ const EditingContext = createContext<{
|
|
|
218
217
|
}>({
|
|
219
218
|
data: [],
|
|
220
219
|
setValue: (row: number, key: string, value: string) => {
|
|
221
|
-
console.
|
|
220
|
+
console.warn("TODO: Implement setValue logic", row, key, value);
|
|
222
221
|
},
|
|
223
222
|
});
|
|
224
223
|
|
|
@@ -226,7 +225,6 @@ type EditingProviderProps = PropsWithChildren<{ data: OrderRow[] }>;
|
|
|
226
225
|
|
|
227
226
|
export const EditingProvider = ({ data, children }: EditingProviderProps) => {
|
|
228
227
|
const [actual, setData] = useState(data);
|
|
229
|
-
useEffect(() => console.log("data changed"), [actual]);
|
|
230
228
|
const context = {
|
|
231
229
|
data: actual,
|
|
232
230
|
setValue: (row: number, key: string, value: string) => {
|
|
@@ -8,10 +8,11 @@ type EditingContextType<T> = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// TODO: Update "any" we shouldn't have this for typesafe devx
|
|
11
|
-
export const EditingContext = createContext<EditingContextType<
|
|
11
|
+
export const EditingContext = createContext<EditingContextType<unknown>>({
|
|
12
12
|
data: [],
|
|
13
|
-
setData: (row: number, key: string, value: string) => {
|
|
14
|
-
console.log(row, key, value);
|
|
13
|
+
setData: (/**row: number, key: string, value: string */) => {
|
|
14
|
+
// console.log(row, key, value);
|
|
15
|
+
// TODO: Implement setData logic
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
|
|
@@ -68,7 +68,15 @@ export function MobileDataGrid<T extends RowData>({
|
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
function MobileDataGridHeader({
|
|
71
|
+
function MobileDataGridHeader({
|
|
72
|
+
header,
|
|
73
|
+
id,
|
|
74
|
+
testid,
|
|
75
|
+
}: {
|
|
76
|
+
header: string;
|
|
77
|
+
id?: string;
|
|
78
|
+
testid?: string;
|
|
79
|
+
}) {
|
|
72
80
|
return (
|
|
73
81
|
<div id={id} data-testid={testid} className="sticky top-0">
|
|
74
82
|
<Theme theme="brand">
|
|
@@ -95,7 +103,7 @@ function MobileDataGridCard<T extends RowData>({
|
|
|
95
103
|
renderLink,
|
|
96
104
|
renderChevron,
|
|
97
105
|
id,
|
|
98
|
-
testid
|
|
106
|
+
testid,
|
|
99
107
|
}: {
|
|
100
108
|
data: T;
|
|
101
109
|
columns: MobileColumnDef<T>[];
|
|
@@ -115,7 +123,7 @@ function MobileDataGridCard<T extends RowData>({
|
|
|
115
123
|
testid={testid ? `${testid}-docs-button` : undefined}
|
|
116
124
|
iconOnly
|
|
117
125
|
variant="tertiary"
|
|
118
|
-
onClick={() => console.
|
|
126
|
+
onClick={() => console.warn("TODO: Implement Edit", data.id)}
|
|
119
127
|
leftIcon={<Icon name="docs" />}
|
|
120
128
|
></Button>
|
|
121
129
|
<Button
|
|
@@ -123,7 +131,7 @@ function MobileDataGridCard<T extends RowData>({
|
|
|
123
131
|
testid={testid ? `${testid}-swap-button` : undefined}
|
|
124
132
|
iconOnly
|
|
125
133
|
variant="tertiary"
|
|
126
|
-
onClick={() => console.
|
|
134
|
+
onClick={() => console.warn("TODO: Implement Edit", data.id)}
|
|
127
135
|
leftIcon={<Icon name="swap_vert" />}
|
|
128
136
|
></Button>
|
|
129
137
|
</Stack>
|
|
@@ -27,7 +27,7 @@ export const NavigationTabs = ({
|
|
|
27
27
|
onTabChange,
|
|
28
28
|
colorPrimitives = "dmsi",
|
|
29
29
|
}: NavigationTabsProps) => {
|
|
30
|
-
const [selectedTab, setSelectedTab] = useState<string>(tabs[0]?.id
|
|
30
|
+
const [selectedTab, setSelectedTab] = useState<string>(tabs[0]?.id ?? "");
|
|
31
31
|
|
|
32
32
|
const handleTabClick = (id: string) => {
|
|
33
33
|
setSelectedTab(id);
|
package/src/utils/date.ts
CHANGED
|
@@ -10,13 +10,13 @@ export function parseInputDate(input: string): string | null {
|
|
|
10
10
|
if (!match) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
const [, month, day, year] = match;
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
// Pad with zeros if necessary
|
|
17
17
|
const paddedMonth = month.padStart(2, "0");
|
|
18
18
|
const paddedDay = day.padStart(2, "0");
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
return `${year}-${paddedMonth}-${paddedDay}`;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -25,7 +25,11 @@ export function parseInputDate(input: string): string | null {
|
|
|
25
25
|
*/
|
|
26
26
|
export function isValidDate(dateString: string): boolean {
|
|
27
27
|
const date = new Date(dateString);
|
|
28
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
date instanceof Date &&
|
|
30
|
+
!isNaN(date.getTime()) &&
|
|
31
|
+
dateString === date.toISOString().split("T")[0]
|
|
32
|
+
);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -34,17 +38,17 @@ export function isValidDate(dateString: string): boolean {
|
|
|
34
38
|
export function formatInputValue(value: string): string {
|
|
35
39
|
// Remove all non-digits
|
|
36
40
|
const digits = value.replace(/\D/g, "");
|
|
37
|
-
|
|
41
|
+
|
|
38
42
|
// Return digits as-is if less than 2
|
|
39
43
|
if (digits.length < 2) {
|
|
40
44
|
return digits;
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
|
|
43
47
|
// Format with full MM/DD/YYYY pattern if 4 or more digits
|
|
44
48
|
if (digits.length >= 4) {
|
|
45
49
|
return `${digits.slice(0, 2)}/${digits.slice(2, 4)}/${digits.slice(4, 8)}`;
|
|
46
50
|
}
|
|
47
|
-
|
|
51
|
+
|
|
48
52
|
// Format with MM/DD pattern for 2-3 digits
|
|
49
53
|
return `${digits.slice(0, 2)}/${digits.slice(2)}`;
|
|
50
54
|
}
|
|
@@ -66,9 +70,12 @@ export function isSlash(character: string): boolean {
|
|
|
66
70
|
/**
|
|
67
71
|
* Count digits up to cursor position
|
|
68
72
|
*/
|
|
69
|
-
export function countDigitsUpToCursor(
|
|
73
|
+
export function countDigitsUpToCursor(
|
|
74
|
+
value: string,
|
|
75
|
+
cursorPosition: number,
|
|
76
|
+
): number {
|
|
70
77
|
let digitCount = 0;
|
|
71
|
-
|
|
78
|
+
|
|
72
79
|
for (let i = 0; i < cursorPosition && i < value.length; i++) {
|
|
73
80
|
if (!isDigit(value[i])) {
|
|
74
81
|
continue;
|
|
@@ -76,69 +83,84 @@ export function countDigitsUpToCursor(value: string, cursorPosition: number): nu
|
|
|
76
83
|
|
|
77
84
|
digitCount++;
|
|
78
85
|
}
|
|
79
|
-
|
|
86
|
+
|
|
80
87
|
return digitCount;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
/**
|
|
84
91
|
* Find position after specific digit count
|
|
85
92
|
*/
|
|
86
|
-
export function findPositionAfterDigitCount(
|
|
93
|
+
export function findPositionAfterDigitCount(
|
|
94
|
+
formattedValue: string,
|
|
95
|
+
targetDigitCount: number,
|
|
96
|
+
): number {
|
|
87
97
|
let currentDigitCount = 0;
|
|
88
|
-
|
|
98
|
+
|
|
89
99
|
for (let i = 0; i < formattedValue.length; i++) {
|
|
90
100
|
if (!isDigit(formattedValue[i])) {
|
|
91
101
|
continue;
|
|
92
102
|
}
|
|
93
|
-
|
|
103
|
+
|
|
94
104
|
currentDigitCount++;
|
|
95
|
-
|
|
105
|
+
|
|
96
106
|
if (currentDigitCount !== targetDigitCount) {
|
|
97
107
|
continue;
|
|
98
108
|
}
|
|
99
|
-
|
|
109
|
+
|
|
100
110
|
const positionAfterDigit = i + 1;
|
|
101
111
|
const nextCharacter = formattedValue[positionAfterDigit];
|
|
102
|
-
|
|
112
|
+
|
|
103
113
|
// Place cursor after slash if it follows the target digit
|
|
104
114
|
if (nextCharacter && isSlash(nextCharacter)) {
|
|
105
115
|
return positionAfterDigit + 1;
|
|
106
116
|
}
|
|
107
|
-
|
|
117
|
+
|
|
108
118
|
return positionAfterDigit;
|
|
109
119
|
}
|
|
110
|
-
|
|
120
|
+
|
|
111
121
|
return formattedValue.length;
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
/**
|
|
115
125
|
* Calculate cursor position after formatting
|
|
116
126
|
*/
|
|
117
|
-
export function calculateCursorPosition(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
export function calculateCursorPosition(
|
|
128
|
+
originalValue: string,
|
|
129
|
+
formattedValue: string,
|
|
130
|
+
originalPosition: number,
|
|
131
|
+
): number {
|
|
132
|
+
const targetDigitCount = countDigitsUpToCursor(
|
|
133
|
+
originalValue,
|
|
134
|
+
originalPosition,
|
|
135
|
+
);
|
|
136
|
+
const newPosition = findPositionAfterDigitCount(
|
|
137
|
+
formattedValue,
|
|
138
|
+
targetDigitCount,
|
|
139
|
+
);
|
|
140
|
+
|
|
121
141
|
return Math.min(newPosition, formattedValue.length);
|
|
122
142
|
}
|
|
123
143
|
|
|
124
144
|
/**
|
|
125
145
|
* Parse date parts from YYYY-MM-DD format
|
|
126
146
|
*/
|
|
127
|
-
export function parseDateParts(
|
|
147
|
+
export function parseDateParts(
|
|
148
|
+
dateString: string,
|
|
149
|
+
): { year: number; month: number; day: number } | null {
|
|
128
150
|
const [yearStr, monthStr, dayStr] = dateString.split("-");
|
|
129
|
-
|
|
151
|
+
|
|
130
152
|
if (!yearStr || !monthStr || !dayStr) {
|
|
131
153
|
return null;
|
|
132
154
|
}
|
|
133
|
-
|
|
155
|
+
|
|
134
156
|
const year = parseInt(yearStr, 10);
|
|
135
157
|
const month = parseInt(monthStr, 10);
|
|
136
158
|
const day = parseInt(dayStr, 10);
|
|
137
|
-
|
|
159
|
+
|
|
138
160
|
if (isNaN(year) || isNaN(month) || isNaN(day)) {
|
|
139
161
|
return null;
|
|
140
162
|
}
|
|
141
|
-
|
|
163
|
+
|
|
142
164
|
return { year, month, day };
|
|
143
165
|
}
|
|
144
166
|
|
|
@@ -158,10 +180,14 @@ export function isValidDateRange(month: number, day: number): boolean {
|
|
|
158
180
|
/**
|
|
159
181
|
* Format date parts to display format (MM/DD/YYYY)
|
|
160
182
|
*/
|
|
161
|
-
export function formatDatePartsToDisplay(
|
|
183
|
+
export function formatDatePartsToDisplay(
|
|
184
|
+
year: number,
|
|
185
|
+
month: number,
|
|
186
|
+
day: number,
|
|
187
|
+
): string {
|
|
162
188
|
const paddedMonth = month.toString().padStart(2, "0");
|
|
163
189
|
const paddedDay = day.toString().padStart(2, "0");
|
|
164
|
-
|
|
190
|
+
|
|
165
191
|
return `${paddedMonth}/${paddedDay}/${year}`;
|
|
166
192
|
}
|
|
167
193
|
|
|
@@ -172,21 +198,22 @@ export function formatDate(date: string): string {
|
|
|
172
198
|
if (!date) {
|
|
173
199
|
return "";
|
|
174
200
|
}
|
|
175
|
-
|
|
201
|
+
|
|
176
202
|
try {
|
|
177
203
|
const dateParts = parseDateParts(date);
|
|
178
204
|
if (!dateParts) {
|
|
179
205
|
return "";
|
|
180
206
|
}
|
|
181
|
-
|
|
207
|
+
|
|
182
208
|
const { year, month, day } = dateParts;
|
|
183
|
-
|
|
209
|
+
|
|
184
210
|
if (!isValidDateRange(month, day)) {
|
|
185
211
|
return "";
|
|
186
212
|
}
|
|
187
|
-
|
|
213
|
+
|
|
188
214
|
return formatDatePartsToDisplay(year, month, day);
|
|
189
215
|
} catch (error) {
|
|
216
|
+
console.error("Error formatting date:", error);
|
|
190
217
|
return "";
|
|
191
218
|
}
|
|
192
219
|
}
|
|
@@ -194,11 +221,14 @@ export function formatDate(date: string): string {
|
|
|
194
221
|
/**
|
|
195
222
|
* Validate if date range is valid (to >= from)
|
|
196
223
|
*/
|
|
197
|
-
export function isValidDateRangeOrder(
|
|
224
|
+
export function isValidDateRangeOrder(
|
|
225
|
+
fromDate: string,
|
|
226
|
+
toDate: string,
|
|
227
|
+
): boolean {
|
|
198
228
|
if (!fromDate || !toDate || !isValidDate(fromDate) || !isValidDate(toDate)) {
|
|
199
229
|
return false;
|
|
200
230
|
}
|
|
201
|
-
|
|
231
|
+
|
|
202
232
|
// Check if 'to' date is not earlier than 'from' date
|
|
203
233
|
const from = new Date(fromDate);
|
|
204
234
|
const to = new Date(toDate);
|
package/src/utils.ts
CHANGED
|
@@ -9,7 +9,7 @@ export function findDocumentRoot(
|
|
|
9
9
|
if (!element || !(element instanceof Node)) {
|
|
10
10
|
return window.document.body;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
let currentElement = element;
|
|
13
13
|
while (currentElement && currentElement.parentNode) {
|
|
14
14
|
if (currentElement.parentNode === document) {
|
|
15
15
|
return document.body;
|