@dmsi/wedgekit-react 0.0.160 → 0.0.162
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/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/HorizontalDivider.js +8 -3
- 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/Radio.js +133 -5
- package/dist/components/Time.cjs +1 -1
- package/dist/components/Time.js +1 -1
- package/dist/components/WorldpayIframe.js +6 -3
- package/dist/components/index.cjs +29 -1041
- package/dist/components/index.js +3 -19
- package/dist/index.css +0 -6
- 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/index.ts +0 -1
- package/src/utils/date.ts +65 -35
- package/src/utils.ts +1 -1
- package/dist/chunk-BATIOCXB.js +0 -138
- package/dist/chunk-EPQLWHCL.js +0 -11
- package/dist/chunk-NT2ZKA4W.js +0 -266
- package/dist/chunk-RUTYNLKS.js +0 -112
- package/dist/chunk-WFGKIR5A.js +0 -9
- package/dist/components/PaymentOnAccountModal.cjs +0 -2381
- package/dist/components/PaymentOnAccountModal.js +0 -35
- package/dist/components/SelectPaymentMethod.cjs +0 -1355
- package/dist/components/SelectPaymentMethod.js +0 -22
- package/src/components/PaymentOnAccountModal.tsx +0 -121
- package/src/components/SelectPaymentMethod.tsx +0 -315
package/dist/components/index.js
CHANGED
|
@@ -4,21 +4,6 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
Select
|
|
6
6
|
} from "../chunk-XH65MD2C.js";
|
|
7
|
-
import {
|
|
8
|
-
PaymentOnAccountModal
|
|
9
|
-
} from "../chunk-RUTYNLKS.js";
|
|
10
|
-
import "../chunk-NT2ZKA4W.js";
|
|
11
|
-
import "../chunk-WFGKIR5A.js";
|
|
12
|
-
import "../chunk-BATIOCXB.js";
|
|
13
|
-
import "../chunk-5GOJRLQO.js";
|
|
14
|
-
import "../chunk-4RJKB7LC.js";
|
|
15
|
-
import "../chunk-C4JGTH6G.js";
|
|
16
|
-
import "../chunk-SYEJVSE4.js";
|
|
17
|
-
import "../chunk-R7ELP5C5.js";
|
|
18
|
-
import "../chunk-ZFOANBWG.js";
|
|
19
|
-
import "../chunk-PLMGI5K5.js";
|
|
20
|
-
import "../chunk-AZ7LVLOK.js";
|
|
21
|
-
import "../chunk-EPQLWHCL.js";
|
|
22
7
|
import {
|
|
23
8
|
Checkbox
|
|
24
9
|
} from "../chunk-WFQEE2OO.js";
|
|
@@ -27,10 +12,10 @@ import {
|
|
|
27
12
|
DataGridCell,
|
|
28
13
|
DragAlongCell,
|
|
29
14
|
DraggableCellHeader
|
|
30
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-SBSHZ327.js";
|
|
31
16
|
import {
|
|
32
17
|
Menu
|
|
33
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-RLK4TBXR.js";
|
|
34
19
|
import "../chunk-5GUW4DUY.js";
|
|
35
20
|
import {
|
|
36
21
|
MenuOption
|
|
@@ -38,7 +23,7 @@ import {
|
|
|
38
23
|
import {
|
|
39
24
|
useInfiniteScroll
|
|
40
25
|
} from "../chunk-WNQ53SVY.js";
|
|
41
|
-
import "../chunk-
|
|
26
|
+
import "../chunk-6LN6QT6M.js";
|
|
42
27
|
import {
|
|
43
28
|
Search
|
|
44
29
|
} from "../chunk-PMBEIP24.js";
|
|
@@ -1124,7 +1109,6 @@ export {
|
|
|
1124
1109
|
Menu,
|
|
1125
1110
|
MenuOption,
|
|
1126
1111
|
Paragraph,
|
|
1127
|
-
PaymentOnAccountModal,
|
|
1128
1112
|
Search,
|
|
1129
1113
|
Select,
|
|
1130
1114
|
Subheader,
|
package/dist/index.css
CHANGED
|
@@ -1872,9 +1872,6 @@
|
|
|
1872
1872
|
.py-\[calc\(var\(--spacing-mobile-component-padding\)_\+_3px\)\] {
|
|
1873
1873
|
padding-block: calc(var(--spacing-mobile-component-padding) + 3px);
|
|
1874
1874
|
}
|
|
1875
|
-
.py-desktop-component-padding {
|
|
1876
|
-
padding-block: var(--spacing-desktop-component-padding);
|
|
1877
|
-
}
|
|
1878
1875
|
.py-mobile-component-gap {
|
|
1879
1876
|
padding-block: var(--spacing-mobile-component-gap);
|
|
1880
1877
|
}
|
|
@@ -1893,9 +1890,6 @@
|
|
|
1893
1890
|
.pt-\[7px\] {
|
|
1894
1891
|
padding-top: 7px;
|
|
1895
1892
|
}
|
|
1896
|
-
.pr-desktop-component-padding {
|
|
1897
|
-
padding-right: var(--spacing-desktop-component-padding);
|
|
1898
|
-
}
|
|
1899
1893
|
.pb-2 {
|
|
1900
1894
|
padding-bottom: calc(var(--spacing) * 2);
|
|
1901
1895
|
}
|
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/components/index.ts
CHANGED
|
@@ -18,6 +18,5 @@ export { MenuOption } from "./MenuOption";
|
|
|
18
18
|
export { Search } from "./Search";
|
|
19
19
|
export { Tooltip } from "./Tooltip";
|
|
20
20
|
export { Input } from "./Input";
|
|
21
|
-
export { PaymentOnAccountModal } from "./PaymentOnAccountModal";
|
|
22
21
|
export { Accordion } from "./Accordion";
|
|
23
22
|
export { Card } from "./Card";
|
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;
|
package/dist/chunk-BATIOCXB.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Paragraph
|
|
3
|
-
} from "./chunk-HVI3CL7Y.js";
|
|
4
|
-
import {
|
|
5
|
-
baseTransition,
|
|
6
|
-
componentGap
|
|
7
|
-
} from "./chunk-RDLEIAQU.js";
|
|
8
|
-
import {
|
|
9
|
-
__objRest,
|
|
10
|
-
__spreadValues
|
|
11
|
-
} from "./chunk-ORMEWXMH.js";
|
|
12
|
-
|
|
13
|
-
// src/components/Radio.tsx
|
|
14
|
-
import clsx from "clsx";
|
|
15
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
-
var Radio = (_a) => {
|
|
17
|
-
var _b = _a, {
|
|
18
|
-
className,
|
|
19
|
-
label,
|
|
20
|
-
error,
|
|
21
|
-
disabled,
|
|
22
|
-
checked,
|
|
23
|
-
readOnly,
|
|
24
|
-
id,
|
|
25
|
-
testid
|
|
26
|
-
} = _b, props = __objRest(_b, [
|
|
27
|
-
"className",
|
|
28
|
-
"label",
|
|
29
|
-
"error",
|
|
30
|
-
"disabled",
|
|
31
|
-
"checked",
|
|
32
|
-
"readOnly",
|
|
33
|
-
"id",
|
|
34
|
-
"testid"
|
|
35
|
-
]);
|
|
36
|
-
const radioId = id;
|
|
37
|
-
const paragraphColor = disabled ? "text-primary-disabled" : error ? "text-primary-error" : "text-primary-normal";
|
|
38
|
-
const defaultClassName = clsx(
|
|
39
|
-
!error && !disabled && "border-border-primary-normal peer-hover:border-border-action-hover peer-hover:bg-background-action-secondary-hover peer-focus:border-border-action-hover peer-focus:bg-background-action-secondary-hover peer-active:border-border-action-active peer-active:bg-background-action-secondary-active peer-checked:border-0 peer-checked:bg-background-action-secondary-hover"
|
|
40
|
-
);
|
|
41
|
-
const errorClassName = clsx(
|
|
42
|
-
error && !disabled && "border-border-action-critical-normal peer-hover:border-border-action-critical-hover peer-hover:bg-background-action-critical-secondary-hover peer-focus:border-border-action-critical-hover peer-focus:bg-background-action-critical-secondary-hover peer-active:border-border-action-critical-active peer-active:bg-background-action-secondary-active peer-checked:bg-background-action-critical-secondary-hover peer-checked:border-0 "
|
|
43
|
-
);
|
|
44
|
-
const disabledClassName = clsx(
|
|
45
|
-
disabled && "peer-disabled:bg-background-action-secondary-disabled peer-disabled:border-border-primary-normal peer-checked:border-0"
|
|
46
|
-
);
|
|
47
|
-
const readonlyClassName = clsx(
|
|
48
|
-
readOnly && "peer-read-only:bg-background-action-secondary-disabled peer-read-only:border-border-primary-normal peer-checked:border-0"
|
|
49
|
-
);
|
|
50
|
-
return /* @__PURE__ */ jsxs(
|
|
51
|
-
"label",
|
|
52
|
-
{
|
|
53
|
-
htmlFor: radioId,
|
|
54
|
-
className: clsx(
|
|
55
|
-
"flex items-center",
|
|
56
|
-
componentGap,
|
|
57
|
-
disabled ? "cursor-default" : "cursor-pointer",
|
|
58
|
-
className
|
|
59
|
-
),
|
|
60
|
-
children: [
|
|
61
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
62
|
-
/* @__PURE__ */ jsx(
|
|
63
|
-
"input",
|
|
64
|
-
__spreadValues({
|
|
65
|
-
id: radioId,
|
|
66
|
-
"data-testid": testid,
|
|
67
|
-
type: "radio",
|
|
68
|
-
className: "sr-only peer",
|
|
69
|
-
disabled,
|
|
70
|
-
checked,
|
|
71
|
-
readOnly
|
|
72
|
-
}, props)
|
|
73
|
-
),
|
|
74
|
-
/* @__PURE__ */ jsx(
|
|
75
|
-
"div",
|
|
76
|
-
{
|
|
77
|
-
className: clsx(
|
|
78
|
-
"size-6 rounded-full border flex items-center justify-center",
|
|
79
|
-
baseTransition,
|
|
80
|
-
defaultClassName,
|
|
81
|
-
errorClassName,
|
|
82
|
-
disabledClassName,
|
|
83
|
-
readonlyClassName
|
|
84
|
-
),
|
|
85
|
-
children: checked && /* @__PURE__ */ jsx(
|
|
86
|
-
RadioIcon,
|
|
87
|
-
{
|
|
88
|
-
className: clsx(
|
|
89
|
-
"transition-colors",
|
|
90
|
-
!error && !disabled && "text-icon-on-action-secondary-normal hover:text-icon-on-action-secondary-hover active:text-icon-on-action-secondary-active peer-hover:text-icon-on-action-secondary-hover peer-focus:text-icon-on-action-secondary-hover peer-active:text-icon-on-action-secondary-active",
|
|
91
|
-
error && !disabled && "text-icon-action-critical-secondary-normal hover:text-icon-action-critical-secondary-hover active:text-icon-action-critical-secondary-active peer-hover:text-icon-action-critical-secondary-hover peer-focus:text-icon-action-critical-secondary-hover peer-active:text-icon-action-critical-secondary-active",
|
|
92
|
-
disabled && "text-icon-on-action-secondary-disabled",
|
|
93
|
-
readOnly && "text-icon-on-action-secondary-disabled"
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
)
|
|
99
|
-
] }),
|
|
100
|
-
label && /* @__PURE__ */ jsx(Paragraph, { id: radioId ? `${radioId}-label` : void 0, testid: testid ? `${testid}-label` : void 0, padded: true, color: paragraphColor, children: label })
|
|
101
|
-
]
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
Radio.displayName = "Radio";
|
|
106
|
-
var RadioIcon = ({ className }) => {
|
|
107
|
-
return /* @__PURE__ */ jsxs(
|
|
108
|
-
"svg",
|
|
109
|
-
{
|
|
110
|
-
className,
|
|
111
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
112
|
-
width: "24",
|
|
113
|
-
height: "24",
|
|
114
|
-
viewBox: "0 0 24 24",
|
|
115
|
-
fill: "none",
|
|
116
|
-
children: [
|
|
117
|
-
/* @__PURE__ */ jsx(
|
|
118
|
-
"rect",
|
|
119
|
-
{
|
|
120
|
-
x: "1",
|
|
121
|
-
y: "1",
|
|
122
|
-
width: "22",
|
|
123
|
-
height: "22",
|
|
124
|
-
rx: "11",
|
|
125
|
-
stroke: "currentColor",
|
|
126
|
-
strokeWidth: "2"
|
|
127
|
-
}
|
|
128
|
-
),
|
|
129
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "8", fill: "currentColor" })
|
|
130
|
-
]
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
RadioIcon.displayName = "RadioIcon";
|
|
135
|
-
|
|
136
|
-
export {
|
|
137
|
-
Radio
|
|
138
|
-
};
|
package/dist/chunk-EPQLWHCL.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// src/components/HorizontalDivider.tsx
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
function HorizontalDivider({ id, testid, hideOnMobile }) {
|
|
5
|
-
const hideOnMobileStyle = clsx(hideOnMobile && "hidden desktop:block");
|
|
6
|
-
return /* @__PURE__ */ jsx("hr", { id, "data-testid": testid, className: clsx("w-full border-t border-border-primary-normal", hideOnMobileStyle) });
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
HorizontalDivider
|
|
11
|
-
};
|