@dmsi/wedgekit-react 0.0.551 → 0.0.552
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/package.json +2 -3
- package/src/brand.css +0 -125
- package/src/classNames.ts +0 -174
- package/src/components/AccessChangerTabItem.tsx +0 -71
- package/src/components/Accordion.tsx +0 -108
- package/src/components/Alert.tsx +0 -81
- package/src/components/Breadcrumbs.tsx +0 -142
- package/src/components/Button.tsx +0 -216
- package/src/components/CalendarRange.tsx +0 -628
- package/src/components/Caption.tsx +0 -144
- package/src/components/Card.tsx +0 -88
- package/src/components/Checkbox.tsx +0 -206
- package/src/components/CompactImagesPreview.tsx +0 -135
- package/src/components/ContentTab.tsx +0 -84
- package/src/components/ContentTabs.tsx +0 -136
- package/src/components/DMSiLogo.tsx +0 -33
- package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +0 -35
- package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +0 -74
- package/src/components/DataGrid/PinnedColumns.tsx +0 -183
- package/src/components/DataGrid/TableBody/LoadingCell.tsx +0 -44
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -157
- package/src/components/DataGrid/TableBody/index.tsx +0 -185
- package/src/components/DataGrid/index.tsx +0 -756
- package/src/components/DataGrid/types.ts +0 -98
- package/src/components/DataGrid/utils.tsx +0 -15
- package/src/components/DataGridCell.tsx +0 -526
- package/src/components/DataTable.tsx +0 -881
- package/src/components/DateInput.tsx +0 -306
- package/src/components/DateRangeInput.tsx +0 -758
- package/src/components/DebugJson.tsx +0 -28
- package/src/components/Display.tsx +0 -66
- package/src/components/EditingContext.tsx +0 -43
- package/src/components/EmptyCartIcon.tsx +0 -18
- package/src/components/FilterGroup.tsx +0 -264
- package/src/components/FullViewportBox.tsx +0 -19
- package/src/components/Grid.tsx +0 -97
- package/src/components/Heading.tsx +0 -72
- package/src/components/HorizontalDivider.tsx +0 -22
- package/src/components/Icon.tsx +0 -39
- package/src/components/ImagePlaceholder.tsx +0 -22
- package/src/components/Input.tsx +0 -609
- package/src/components/InputGroup.tsx +0 -59
- package/src/components/Label.tsx +0 -46
- package/src/components/Link.tsx +0 -117
- package/src/components/List.tsx +0 -18
- package/src/components/ListGroup.tsx +0 -82
- package/src/components/LiveChatComponent.tsx +0 -56
- package/src/components/LoadingScrim.tsx +0 -33
- package/src/components/LogoAgilityTopBar.tsx +0 -54
- package/src/components/LogoDMSiTopBar.tsx +0 -33
- package/src/components/LogoMillworkTopBar.tsx +0 -119
- package/src/components/MainBar.tsx +0 -91
- package/src/components/MaxViewportBox.tsx +0 -19
- package/src/components/Menu.tsx +0 -316
- package/src/components/MenuOption.tsx +0 -330
- package/src/components/MobileDataGrid/ColumnList.tsx +0 -66
- package/src/components/MobileDataGrid/ColumnSelector/index.tsx +0 -97
- package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +0 -25
- package/src/components/MobileDataGrid/GridContextProvider/index.tsx +0 -132
- package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +0 -10
- package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +0 -27
- package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +0 -138
- package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +0 -81
- package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +0 -42
- package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +0 -68
- package/src/components/MobileDataGrid/dataGridReducer.ts +0 -55
- package/src/components/MobileDataGrid/index.tsx +0 -92
- package/src/components/MobileDataGrid/types.ts +0 -4
- package/src/components/Modal.tsx +0 -312
- package/src/components/ModalButtons.tsx +0 -62
- package/src/components/ModalContent.tsx +0 -31
- package/src/components/ModalHeader.tsx +0 -78
- package/src/components/ModalScrim.tsx +0 -42
- package/src/components/NavigationTab.tsx +0 -95
- package/src/components/NavigationTabs.tsx +0 -70
- package/src/components/NestedMenu.tsx +0 -131
- package/src/components/Notification.tsx +0 -128
- package/src/components/OptionPill.tsx +0 -139
- package/src/components/OrderCheckIcon.tsx +0 -19
- package/src/components/PDFViewer/DownloadIcon.tsx +0 -25
- package/src/components/PDFViewer/PDFElement.tsx +0 -90
- package/src/components/PDFViewer/PDFNavigation.tsx +0 -68
- package/src/components/PDFViewer/PDFPage.tsx +0 -34
- package/src/components/PDFViewer/index.tsx +0 -128
- package/src/components/Pagination.tsx +0 -182
- package/src/components/Paragraph.tsx +0 -55
- package/src/components/Password.tsx +0 -62
- package/src/components/ProductImagePreview/CarouselPagination.tsx +0 -54
- package/src/components/ProductImagePreview/MobileImageCarousel.tsx +0 -226
- package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +0 -219
- package/src/components/ProductImagePreview/Thumbnail.tsx +0 -55
- package/src/components/ProductImagePreview/ZoomWindow.tsx +0 -136
- package/src/components/ProductImagePreview/index.tsx +0 -182
- package/src/components/ProductImagePreview/useProductImagePreview.ts +0 -211
- package/src/components/ProjectBar.tsx +0 -82
- package/src/components/Radio.tsx +0 -146
- package/src/components/Search.tsx +0 -152
- package/src/components/SearchResultImage/index.tsx +0 -39
- package/src/components/Select.tsx +0 -114
- package/src/components/SideMenu.tsx +0 -30
- package/src/components/SideMenuGroup.tsx +0 -95
- package/src/components/SideMenuItem.tsx +0 -109
- package/src/components/SimpleTable.tsx +0 -77
- package/src/components/SkeletonParagraph.tsx +0 -31
- package/src/components/Spinner.tsx +0 -32
- package/src/components/Stack.tsx +0 -347
- package/src/components/StatusPill.tsx +0 -59
- package/src/components/Stepper.tsx +0 -128
- package/src/components/Subheader.tsx +0 -50
- package/src/components/Surface.tsx +0 -37
- package/src/components/Swatch.tsx +0 -1341
- package/src/components/Textarea.tsx +0 -102
- package/src/components/Theme.tsx +0 -27
- package/src/components/Time.tsx +0 -460
- package/src/components/Toast.tsx +0 -268
- package/src/components/Tooltip.tsx +0 -159
- package/src/components/TopBar.tsx +0 -139
- package/src/components/Upload.tsx +0 -107
- package/src/components/WorldpayIframe.tsx +0 -7
- package/src/components/index.ts +0 -34
- package/src/components/useMenuSystem.tsx +0 -456
- package/src/components/useMounted.tsx +0 -14
- package/src/darkmode.css +0 -278
- package/src/fonts.css +0 -23
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useInfiniteScroll.tsx +0 -40
- package/src/hooks/useKeydown.ts +0 -42
- package/src/hooks/useMatchesMedia.ts +0 -18
- package/src/hooks/useTableLayout.ts +0 -106
- package/src/index.css +0 -800
- package/src/index.tsx +0 -5
- package/src/types.ts +0 -150
- package/src/utils/date.ts +0 -236
- package/src/utils/formatting.tsx +0 -81
- package/src/utils/index.ts +0 -4
- package/src/utils/mergeObjectArrays.ts +0 -18
- package/src/utils.ts +0 -24
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect, useState, useLayoutEffect } from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { InputBaseProps, InputBase } from "./Input";
|
|
4
|
-
import { CalendarRange } from "./CalendarRange";
|
|
5
|
-
import { Icon } from "./Icon";
|
|
6
|
-
import { findDocumentRoot } from "../utils";
|
|
7
|
-
import {
|
|
8
|
-
parseInputDate,
|
|
9
|
-
isValidDate,
|
|
10
|
-
formatInputValue,
|
|
11
|
-
calculateCursorPosition,
|
|
12
|
-
formatDate,
|
|
13
|
-
} from "../utils/date";
|
|
14
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
15
|
-
|
|
16
|
-
type DateInputProps = Omit<InputBaseProps, "id"> & {
|
|
17
|
-
id?: string;
|
|
18
|
-
testid?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Value in the format "YYYY-MM-DD" or empty string.
|
|
21
|
-
* When enableRangeInSingleMode is true, this should be in format "YYYY-MM-DD|YYYY-MM-DD"
|
|
22
|
-
*/
|
|
23
|
-
value: string;
|
|
24
|
-
/**
|
|
25
|
-
* Called when the date changes.
|
|
26
|
-
* For single date: receives "YYYY-MM-DD"
|
|
27
|
-
* For range: receives "YYYY-MM-DD|YYYY-MM-DD"
|
|
28
|
-
*/
|
|
29
|
-
onChange: (value: string) => void;
|
|
30
|
-
/**
|
|
31
|
-
* Optional placeholder text
|
|
32
|
-
*/
|
|
33
|
-
placeholder?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Optional disabled state
|
|
36
|
-
*/
|
|
37
|
-
disabled?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Enable range selection in single mode calendar
|
|
40
|
-
*/
|
|
41
|
-
readOnly?: boolean; // If true, input is read-only and cannot be focused
|
|
42
|
-
label?: string; // Optional label for the input
|
|
43
|
-
/**
|
|
44
|
-
* Optional to check if a day is enabled/disabled
|
|
45
|
-
* @param value The date to check for availability as a Temporal.PlainDate
|
|
46
|
-
* @returns Is date enabled/disabled
|
|
47
|
-
*/
|
|
48
|
-
isDateAvailable?: (value: Temporal.PlainDate) => boolean;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const DateInput = ({
|
|
52
|
-
id,
|
|
53
|
-
testid,
|
|
54
|
-
value,
|
|
55
|
-
onChange,
|
|
56
|
-
placeholder = "MM/DD/YYYY",
|
|
57
|
-
disabled,
|
|
58
|
-
readOnly = false,
|
|
59
|
-
label,
|
|
60
|
-
isDateAvailable,
|
|
61
|
-
...props
|
|
62
|
-
}: DateInputProps) => {
|
|
63
|
-
const [visible, setVisible] = useState(false);
|
|
64
|
-
const [inputValue, setInputValue] = useState("");
|
|
65
|
-
const [isTyping, setIsTyping] = useState(false);
|
|
66
|
-
const popoverRef = useRef<HTMLDivElement | null>(null);
|
|
67
|
-
const triggerRef = useRef<HTMLInputElement | null>(null);
|
|
68
|
-
const rootRef = useRef<HTMLDivElement | null>(null);
|
|
69
|
-
const [calendarPosition, setCalendarPosition] = useState({
|
|
70
|
-
top: 0,
|
|
71
|
-
left: 0,
|
|
72
|
-
width: 0,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Extract from and to values from the pipe-separated string when range is enabled
|
|
76
|
-
const [from, to] = [value, ""];
|
|
77
|
-
|
|
78
|
-
// Update input value when external value changes (but not when typing)
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
if (!isTyping) {
|
|
81
|
-
setInputValue(formatDisplayValue(from));
|
|
82
|
-
}
|
|
83
|
-
}, [from, isTyping]);
|
|
84
|
-
|
|
85
|
-
useLayoutEffect(() => {
|
|
86
|
-
if (visible) {
|
|
87
|
-
updatePosition();
|
|
88
|
-
}
|
|
89
|
-
}, [visible]);
|
|
90
|
-
|
|
91
|
-
const updatePosition = () => {
|
|
92
|
-
if (rootRef.current) {
|
|
93
|
-
const rect = rootRef.current.getBoundingClientRect();
|
|
94
|
-
setCalendarPosition({
|
|
95
|
-
top: rect.bottom + window.scrollY,
|
|
96
|
-
left: rect.left + window.scrollX,
|
|
97
|
-
width: rect.width,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
updatePosition();
|
|
104
|
-
|
|
105
|
-
const resizeObserver = new ResizeObserver(updatePosition);
|
|
106
|
-
if (triggerRef.current) {
|
|
107
|
-
resizeObserver.observe(triggerRef.current);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
window.addEventListener("scroll", updatePosition);
|
|
111
|
-
|
|
112
|
-
return () => {
|
|
113
|
-
resizeObserver.disconnect();
|
|
114
|
-
window.removeEventListener("scroll", updatePosition);
|
|
115
|
-
};
|
|
116
|
-
}, []);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
const handleKeyDown = (event: KeyboardEvent) => {
|
|
120
|
-
if (event.key === "Escape" && popoverRef.current) {
|
|
121
|
-
setVisible(false);
|
|
122
|
-
triggerRef.current?.blur();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
126
|
-
return () => {
|
|
127
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
133
|
-
if (
|
|
134
|
-
popoverRef.current &&
|
|
135
|
-
!popoverRef.current.contains(event.target as HTMLElement) &&
|
|
136
|
-
triggerRef.current &&
|
|
137
|
-
!triggerRef.current.contains(event.target as HTMLElement)
|
|
138
|
-
) {
|
|
139
|
-
setVisible(false);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
143
|
-
return () => {
|
|
144
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
145
|
-
};
|
|
146
|
-
}, []);
|
|
147
|
-
|
|
148
|
-
function handleDateChange(fromValue: string) {
|
|
149
|
-
// For single date selection, only pass the from value
|
|
150
|
-
onChange(fromValue);
|
|
151
|
-
setVisible(false);
|
|
152
|
-
setIsTyping(false);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const handleFocus = () => {
|
|
156
|
-
if (readOnly) return;
|
|
157
|
-
setVisible(true);
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const handleClick = () => {
|
|
161
|
-
handleFocus();
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
165
|
-
if (readOnly) return;
|
|
166
|
-
|
|
167
|
-
const rawValue = event.target.value;
|
|
168
|
-
const cursorPosition = event.target.selectionStart || 0;
|
|
169
|
-
setIsTyping(true);
|
|
170
|
-
|
|
171
|
-
// Format the input as user types (add slashes automatically)
|
|
172
|
-
const formattedValue = formatInputValue(rawValue);
|
|
173
|
-
setInputValue(formattedValue);
|
|
174
|
-
|
|
175
|
-
// Restore cursor position after formatting
|
|
176
|
-
requestAnimationFrame(() => {
|
|
177
|
-
if (triggerRef.current) {
|
|
178
|
-
const newPosition = calculateCursorPosition(
|
|
179
|
-
rawValue,
|
|
180
|
-
formattedValue,
|
|
181
|
-
cursorPosition,
|
|
182
|
-
);
|
|
183
|
-
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Try to parse and validate the date
|
|
188
|
-
const parsedDate = parseInputDate(formattedValue);
|
|
189
|
-
if (parsedDate && isValidDate(parsedDate)) {
|
|
190
|
-
onChange(parsedDate);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const handleBlur = () => {
|
|
195
|
-
setIsTyping(false);
|
|
196
|
-
// If the input is invalid, revert to the last valid value
|
|
197
|
-
const parsedDate = parseInputDate(inputValue);
|
|
198
|
-
if (!parsedDate || !isValidDate(parsedDate)) {
|
|
199
|
-
setInputValue(formatDisplayValue(from));
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
204
|
-
if (event.key === "Backspace") {
|
|
205
|
-
const input = event.target as HTMLInputElement;
|
|
206
|
-
const cursorPosition = input.selectionStart || 0;
|
|
207
|
-
const value = input.value;
|
|
208
|
-
|
|
209
|
-
// If cursor is right after a slash, move it before the slash
|
|
210
|
-
if (cursorPosition > 0 && value[cursorPosition - 1] === "/") {
|
|
211
|
-
event.preventDefault();
|
|
212
|
-
const newValue =
|
|
213
|
-
value.slice(0, cursorPosition - 2) + value.slice(cursorPosition);
|
|
214
|
-
const formattedValue = formatInputValue(newValue);
|
|
215
|
-
setInputValue(formattedValue);
|
|
216
|
-
|
|
217
|
-
// Set cursor position after the deletion
|
|
218
|
-
requestAnimationFrame(() => {
|
|
219
|
-
if (triggerRef.current) {
|
|
220
|
-
const newPosition = Math.max(0, cursorPosition - 2);
|
|
221
|
-
triggerRef.current.setSelectionRange(newPosition, newPosition);
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
setIsTyping(true);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (event.key === "Enter") {
|
|
231
|
-
const parsedDate = parseInputDate(inputValue);
|
|
232
|
-
if (parsedDate && isValidDate(parsedDate)) {
|
|
233
|
-
onChange(parsedDate);
|
|
234
|
-
setVisible(false);
|
|
235
|
-
setIsTyping(false);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<div className="relative">
|
|
242
|
-
<InputBase
|
|
243
|
-
id={id}
|
|
244
|
-
testid={testid}
|
|
245
|
-
ref={(el) => {
|
|
246
|
-
triggerRef.current = el;
|
|
247
|
-
}}
|
|
248
|
-
{...props}
|
|
249
|
-
wrapperRef={rootRef}
|
|
250
|
-
value={inputValue}
|
|
251
|
-
placeholder={placeholder}
|
|
252
|
-
disabled={disabled}
|
|
253
|
-
readOnly={readOnly}
|
|
254
|
-
after={<Icon name="calendar_month" />}
|
|
255
|
-
onFocus={handleFocus}
|
|
256
|
-
onClick={handleClick}
|
|
257
|
-
onChange={handleInputChange}
|
|
258
|
-
onBlur={handleBlur}
|
|
259
|
-
onKeyDown={handleKeyDown}
|
|
260
|
-
label={label}
|
|
261
|
-
secondaryIconColor
|
|
262
|
-
/>
|
|
263
|
-
{visible &&
|
|
264
|
-
!readOnly &&
|
|
265
|
-
createPortal(
|
|
266
|
-
<div
|
|
267
|
-
ref={(el) => {
|
|
268
|
-
popoverRef.current = el;
|
|
269
|
-
}}
|
|
270
|
-
className="absolute z-40 bg-white"
|
|
271
|
-
style={{
|
|
272
|
-
top: `${calendarPosition.top + 4}px`,
|
|
273
|
-
left: `${calendarPosition.left}px`,
|
|
274
|
-
minWidth: `${calendarPosition.width}px`,
|
|
275
|
-
}}
|
|
276
|
-
>
|
|
277
|
-
<CalendarRange
|
|
278
|
-
id={id ? `${id}-calendar` : undefined}
|
|
279
|
-
testid={testid ? `${testid}-calendar` : undefined}
|
|
280
|
-
from={from}
|
|
281
|
-
to={to || from}
|
|
282
|
-
onChange={handleDateChange}
|
|
283
|
-
cardStyle
|
|
284
|
-
mode="single"
|
|
285
|
-
disableRange
|
|
286
|
-
isDateAvailable={isDateAvailable}
|
|
287
|
-
/>
|
|
288
|
-
</div>,
|
|
289
|
-
findDocumentRoot(popoverRef.current),
|
|
290
|
-
)}
|
|
291
|
-
</div>
|
|
292
|
-
);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
DateInput.displayName = "DateInput";
|
|
296
|
-
|
|
297
|
-
function formatDisplayValue(from?: string): string {
|
|
298
|
-
if (!from) {
|
|
299
|
-
return "";
|
|
300
|
-
}
|
|
301
|
-
if (!isValidDate(from)) {
|
|
302
|
-
return "";
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return formatDate(from);
|
|
306
|
-
}
|