@dmsi/wedgekit-react 0.0.159 → 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-NRCUFAOZ.js → chunk-FCREADUH.js} +3 -3
- package/dist/{chunk-IDN3IN2A.js → chunk-M3433XEJ.js} +9 -2
- package/dist/{chunk-QFSGM4MP.js → chunk-NT2ZKA4W.js} +4 -4
- package/dist/{chunk-GG5JOFS6.js → chunk-PLMGI5K5.js} +1 -1
- package/dist/{chunk-IDSFWKOR.js → chunk-PMBEIP24.js} +1 -1
- package/dist/{chunk-LPARJM6S.js → chunk-RLK4TBXR.js} +3 -3
- package/dist/{chunk-WJ447JB5.js → chunk-SBSHZ327.js} +5 -5
- package/dist/{chunk-N7EKJEYO.js → chunk-WFLOAGEI.js} +3 -3
- package/dist/{chunk-KADNOKNW.js → chunk-XH65MD2C.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 +8 -8
- 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 +11 -11
- package/dist/components/DateRangeInput.cjs +12 -6
- package/dist/components/DateRangeInput.js +11 -11
- package/dist/components/EditingContext.cjs +1 -2
- package/dist/components/EditingContext.js +1 -2
- package/dist/components/FilterGroup.js +7 -7
- package/dist/components/Input.js +2 -2
- package/dist/components/LoadingScrim.cjs +1 -1
- package/dist/components/LoadingScrim.js +1 -1
- package/dist/components/Menu.cjs +1 -1
- package/dist/components/Menu.js +2 -2
- package/dist/components/MenuOption.js +2 -2
- package/dist/components/MobileDataGrid.cjs +7 -3
- package/dist/components/MobileDataGrid.js +10 -6
- package/dist/components/Modal.cjs +1 -1
- package/dist/components/Modal.js +3 -3
- package/dist/components/NavigationTabs.cjs +4 -4
- package/dist/components/NavigationTabs.js +4 -4
- package/dist/components/NestedMenu.js +2 -2
- package/dist/components/Notification.js +3 -3
- package/dist/components/PDFViewer.cjs +204 -43
- package/dist/components/PDFViewer.js +94 -40
- package/dist/components/Password.js +2 -2
- package/dist/components/PaymentOnAccountModal.cjs +2 -2
- package/dist/components/PaymentOnAccountModal.js +8 -8
- package/dist/components/Search.js +3 -3
- package/dist/components/Select.js +3 -3
- package/dist/components/SelectPaymentMethod.cjs +1 -1
- package/dist/components/SelectPaymentMethod.js +3 -3
- package/dist/components/Spinner.cjs +1 -1
- package/dist/components/Spinner.js +1 -1
- package/dist/components/Stepper.js +2 -2
- package/dist/components/Time.cjs +1 -1
- package/dist/components/Time.js +3 -3
- package/dist/components/Toast.js +3 -3
- package/dist/components/Upload.js +3 -3
- package/dist/components/index.cjs +2 -2
- package/dist/components/index.js +24 -24
- 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/components/PDFViewer.tsx +63 -17
- package/src/components/Spinner.tsx +1 -1
- package/src/utils/date.ts +65 -35
- package/src/utils.ts +1 -1
- package/dist/{chunk-MVGOAMTP.js → chunk-4T3DRGLF.js} +3 -3
- package/dist/{chunk-AEDEFN7A.js → chunk-FFU6FB3K.js} +3 -3
|
@@ -7,6 +7,7 @@ import { Button } from "./Button";
|
|
|
7
7
|
import { Icon } from "./Icon";
|
|
8
8
|
import { Stack } from "./Stack";
|
|
9
9
|
import { Caption } from "./Caption";
|
|
10
|
+
import { Spinner } from "./Spinner";
|
|
10
11
|
|
|
11
12
|
type PDFViewerProps = {
|
|
12
13
|
isOpen: boolean;
|
|
@@ -24,12 +25,15 @@ export function PDFViewer(props: PDFViewerProps) {
|
|
|
24
25
|
const handleDownload = useCallback(() => {
|
|
25
26
|
setIsDownloading(true);
|
|
26
27
|
const link = document.createElement("a");
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const currentPdf = encodedPdfs[currentIndex];
|
|
29
|
+
if (!currentPdf) {
|
|
30
|
+
setIsDownloading(false);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
link.href = `data:application/pdf;base64,${currentPdf.base64}`;
|
|
34
|
+
link.download = currentPdf.fileName.endsWith(".pdf")
|
|
35
|
+
? currentPdf.fileName
|
|
36
|
+
: `${currentPdf.fileName}.pdf`;
|
|
33
37
|
document.body.appendChild(link);
|
|
34
38
|
link.click();
|
|
35
39
|
document.body.removeChild(link);
|
|
@@ -46,7 +50,11 @@ export function PDFViewer(props: PDFViewerProps) {
|
|
|
46
50
|
showButtons={!!customActions}
|
|
47
51
|
customActions={customActions}
|
|
48
52
|
headerIcon={
|
|
49
|
-
<DownloadIcon
|
|
53
|
+
<DownloadIcon
|
|
54
|
+
testid={testid ? `${testid}-download-icon` : undefined}
|
|
55
|
+
onClick={handleDownload}
|
|
56
|
+
isDownloading={isDownloading}
|
|
57
|
+
/>
|
|
50
58
|
}
|
|
51
59
|
>
|
|
52
60
|
<Stack sizing="layout">
|
|
@@ -57,6 +65,7 @@ export function PDFViewer(props: PDFViewerProps) {
|
|
|
57
65
|
testid={testid ? `${testid}-${pdf.fileName}-button` : undefined}
|
|
58
66
|
variant={index === currentIndex ? "primary" : "secondary"}
|
|
59
67
|
key={`${pdf.fileName}-${index}`}
|
|
68
|
+
classNameLabel="items-center flex flex-row gap-2"
|
|
60
69
|
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
61
70
|
setCurrentIndex(index);
|
|
62
71
|
|
|
@@ -66,12 +75,13 @@ export function PDFViewer(props: PDFViewerProps) {
|
|
|
66
75
|
button.scrollIntoView({
|
|
67
76
|
behavior: "smooth",
|
|
68
77
|
block: "nearest",
|
|
69
|
-
inline: "center"
|
|
78
|
+
inline: "center",
|
|
70
79
|
});
|
|
71
80
|
});
|
|
72
81
|
}}
|
|
73
|
-
disabled={isDownloading || currentIndex === index}
|
|
82
|
+
disabled={isDownloading || currentIndex === index || !pdf.base64}
|
|
74
83
|
>
|
|
84
|
+
{!pdf.base64 && <Spinner />}
|
|
75
85
|
{pdf.fileName}
|
|
76
86
|
</Button>
|
|
77
87
|
))}
|
|
@@ -84,7 +94,7 @@ export function PDFViewer(props: PDFViewerProps) {
|
|
|
84
94
|
function DownloadIcon({
|
|
85
95
|
onClick,
|
|
86
96
|
isDownloading,
|
|
87
|
-
testid
|
|
97
|
+
testid,
|
|
88
98
|
}: {
|
|
89
99
|
onClick: () => void;
|
|
90
100
|
isDownloading?: boolean;
|
|
@@ -101,7 +111,7 @@ function DownloadIcon({
|
|
|
101
111
|
);
|
|
102
112
|
}
|
|
103
113
|
|
|
104
|
-
function PDFElement({ b64, testid }: { b64: string
|
|
114
|
+
function PDFElement({ b64, testid }: { b64: string; testid?: string }) {
|
|
105
115
|
const [page, setPage] = useState(1);
|
|
106
116
|
const canvasRef = useRef(null);
|
|
107
117
|
|
|
@@ -115,12 +125,26 @@ function PDFElement({ b64, testid }: { b64: string, testid?: string }) {
|
|
|
115
125
|
|
|
116
126
|
return (
|
|
117
127
|
<div className="flex flex-col space-y-4">
|
|
118
|
-
{pdfDocument ?
|
|
128
|
+
{pdfDocument ? (
|
|
129
|
+
<canvas
|
|
130
|
+
data-testid={testid ? `${testid}-pdf-content` : undefined}
|
|
131
|
+
ref={canvasRef}
|
|
132
|
+
/>
|
|
133
|
+
) : (
|
|
134
|
+
<div data-testid={testid ? `${testid}-pdf-loading` : undefined}>
|
|
135
|
+
Loading PDF...
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
119
138
|
{pdfDocument?.numPages && pdfDocument.numPages > 1 && (
|
|
120
|
-
<ul
|
|
139
|
+
<ul
|
|
140
|
+
className="flex flex-row justify-between items-center"
|
|
141
|
+
data-testid={testid ? `${testid}-pdf-pagination` : undefined}
|
|
142
|
+
>
|
|
121
143
|
<li className="previous">
|
|
122
144
|
<button
|
|
123
|
-
data-testid={
|
|
145
|
+
data-testid={
|
|
146
|
+
testid ? `${testid}-pdf-pagination-previous-button` : undefined
|
|
147
|
+
}
|
|
124
148
|
disabled={page === 1}
|
|
125
149
|
onClick={() => setPage(page - 1)}
|
|
126
150
|
className="not-disabled:cursor-pointer not-disabled:hover:underline "
|
|
@@ -128,12 +152,34 @@ function PDFElement({ b64, testid }: { b64: string, testid?: string }) {
|
|
|
128
152
|
<Caption>Previous</Caption>
|
|
129
153
|
</button>
|
|
130
154
|
</li>
|
|
131
|
-
<li
|
|
132
|
-
|
|
155
|
+
<li
|
|
156
|
+
data-testid={testid ? `${testid}-pdf-pagination-text` : undefined}
|
|
157
|
+
className="text-label-desktop text-text-on-action-primary-normal"
|
|
158
|
+
>
|
|
159
|
+
Page{" "}
|
|
160
|
+
<span
|
|
161
|
+
data-testid={
|
|
162
|
+
testid ? `${testid}-pdf-pagination-page-${page}` : undefined
|
|
163
|
+
}
|
|
164
|
+
>
|
|
165
|
+
{page}
|
|
166
|
+
</span>{" "}
|
|
167
|
+
of{" "}
|
|
168
|
+
<span
|
|
169
|
+
data-testid={
|
|
170
|
+
testid
|
|
171
|
+
? `${testid}-pdf-pagination-total-page-${pdfDocument!.numPages}`
|
|
172
|
+
: undefined
|
|
173
|
+
}
|
|
174
|
+
>
|
|
175
|
+
{pdfDocument!.numPages}
|
|
176
|
+
</span>
|
|
133
177
|
</li>
|
|
134
178
|
<li className="next">
|
|
135
179
|
<button
|
|
136
|
-
data-testid={
|
|
180
|
+
data-testid={
|
|
181
|
+
testid ? `${testid}-pdf-pagination-next-button` : undefined
|
|
182
|
+
}
|
|
137
183
|
disabled={page === pdfDocument!.numPages}
|
|
138
184
|
onClick={() => setPage(page + 1)}
|
|
139
185
|
className="not-disabled:cursor-pointer not-disabled:hover:underline "
|
|
@@ -15,7 +15,7 @@ export const Spinner: React.FC<SpinnerProps> = ({ size = "small", testid }) => {
|
|
|
15
15
|
viewBox="0 0 24 24"
|
|
16
16
|
xmlns="http://www.w3.org/2000/svg"
|
|
17
17
|
fill="#1D1E1E"
|
|
18
|
-
className=
|
|
18
|
+
className="animate-spin"
|
|
19
19
|
aria-label="Loading"
|
|
20
20
|
>
|
|
21
21
|
<circle cx="12" cy="4" r="2" opacity="1">
|
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;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Label
|
|
3
|
-
} from "./chunk-JWCT72WR.js";
|
|
4
1
|
import {
|
|
5
2
|
formatCurrencyDisplay,
|
|
6
3
|
formatDecimalValue,
|
|
7
4
|
getDecimalPlaceholder
|
|
8
5
|
} from "./chunk-5UH6QUFB.js";
|
|
6
|
+
import {
|
|
7
|
+
Label
|
|
8
|
+
} from "./chunk-JWCT72WR.js";
|
|
9
9
|
import {
|
|
10
10
|
Icon
|
|
11
11
|
} from "./chunk-NKUETCDA.js";
|