@trackunit/react-date-and-time-components 1.27.0 → 1.27.2
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/index.cjs.js +26 -12
- package/index.esm.js +26 -12
- package/package.json +9 -9
- package/src/DayPicker/DayPicker.d.ts +3 -3
- package/src/DayPicker/DayRangePicker.d.ts +3 -3
- package/src/Timeline/Timeline.d.ts +3 -3
- package/src/Timeline/TimelineElement.d.ts +3 -3
- package/src/dateTime/DateTime.d.ts +3 -3
package/index.cjs.js
CHANGED
|
@@ -124,7 +124,7 @@ const MS_PER_HOUR = 60 * 60 * 1000;
|
|
|
124
124
|
* ```
|
|
125
125
|
* @param {DateTimeProps} props - The props for the DateTime component
|
|
126
126
|
*/
|
|
127
|
-
const DateTime = ({ value, format, className, fromNow = false, withTitle = false, titleFormat, timezone, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
127
|
+
const DateTime = ({ value, format, className, style, fromNow = false, withTitle = false, titleFormat, timezone, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
128
128
|
const { t } = useTranslation();
|
|
129
129
|
const locale = reactDateAndTimeHooks.useLocale();
|
|
130
130
|
const nowDate = react.useMemo(() => new Date(), []);
|
|
@@ -141,7 +141,7 @@ const DateTime = ({ value, format, className, fromNow = false, withTitle = false
|
|
|
141
141
|
const dateValue = react.useMemo(() => {
|
|
142
142
|
return fromNow ? getTimeSince(date, nowDate) : newDateTime;
|
|
143
143
|
}, [date, fromNow, getTimeSince, newDateTime, nowDate]);
|
|
144
|
-
return (jsxRuntime.jsx("time", { ...rest, className: className || subtle ? tailwindMerge.twMerge(subtle ? "text-neutral-600" : undefined, className) : undefined, "data-testid": dataTestId, dateTime: newDateTime, ref: ref, title: titleDateTime, children: dateValue }));
|
|
144
|
+
return (jsxRuntime.jsx("time", { ...rest, className: className || subtle ? tailwindMerge.twMerge(subtle ? "text-neutral-600" : undefined, className) : undefined, "data-testid": dataTestId, dateTime: newDateTime, ref: ref, style: style, title: titleDateTime, children: dateValue }));
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
/**
|
|
@@ -202,10 +202,10 @@ const useCalculateDateRange = () => {
|
|
|
202
202
|
* @param {DayPickerProps} props - The props for the DayPicker component
|
|
203
203
|
* @returns {ReactElement} DayPicker component
|
|
204
204
|
*/
|
|
205
|
-
const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className, "data-testid": dataTestId, ref, }) => {
|
|
205
|
+
const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className, style, "data-testid": dataTestId, ref, }) => {
|
|
206
206
|
const { subtract } = reactDateAndTimeHooks.useDateAndTime();
|
|
207
207
|
const calculateDateRange = useCalculateDateRange();
|
|
208
|
-
return (jsxRuntime.jsx("div", { "data-testid": dataTestId, ref: ref, children: jsxRuntime.jsx(Calendar, { activeStartDate: selectedDay ?? undefined, allowPartialRange: true, className: tailwindMerge.twMerge("custom-day-picker", "range-picker", className, "p-0"), locale: language, onChange: value => {
|
|
208
|
+
return (jsxRuntime.jsx("div", { "data-testid": dataTestId, ref: ref, style: style, children: jsxRuntime.jsx(Calendar, { activeStartDate: selectedDay ?? undefined, allowPartialRange: true, className: tailwindMerge.twMerge("custom-day-picker", "range-picker", className, "p-0"), locale: language, onChange: value => {
|
|
209
209
|
if (value) {
|
|
210
210
|
onDaySelect?.(value);
|
|
211
211
|
}
|
|
@@ -266,7 +266,7 @@ const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className
|
|
|
266
266
|
* @param {DayRangePickerProps} props - The props for the DayRangePicker component
|
|
267
267
|
* @returns {ReactElement} DayRangePicker component
|
|
268
268
|
*/
|
|
269
|
-
const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }) => {
|
|
269
|
+
const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, style, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }) => {
|
|
270
270
|
const [newRange, setNewRange] = react.useState(selectedDays ?? { start: undefined, end: undefined });
|
|
271
271
|
const [t] = useTranslation();
|
|
272
272
|
const { subtract } = reactDateAndTimeHooks.useDateAndTime();
|
|
@@ -308,7 +308,7 @@ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testi
|
|
|
308
308
|
onClose();
|
|
309
309
|
}
|
|
310
310
|
}, [onRangeSelect, newRange, onClose]);
|
|
311
|
-
return (jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex", "w-min", "flex-col", "overflow-hidden", "rounded-md", "border", "border-neutral-300", "bg-white", className), "data-testid": dataTestId, ref: ref, children: [jsxRuntime.jsx(Calendar, { allowPartialRange: true, className: tailwindMerge.twMerge("custom-day-picker", "range-picker", classNameCalendar), locale: language, onChange: value => {
|
|
311
|
+
return (jsxRuntime.jsxs("div", { className: tailwindMerge.twMerge("flex", "w-min", "flex-col", "overflow-hidden", "rounded-md", "border", "border-neutral-300", "bg-white", className), "data-testid": dataTestId, ref: ref, style: style, children: [jsxRuntime.jsx(Calendar, { allowPartialRange: true, className: tailwindMerge.twMerge("custom-day-picker", "range-picker", classNameCalendar), locale: language, onChange: value => {
|
|
312
312
|
if (Array.isArray(value) && value[0] && value[1]) {
|
|
313
313
|
handleOnRangeSelect({ start: value[0], end: value[1] });
|
|
314
314
|
}
|
|
@@ -871,8 +871,10 @@ const ITEMS_PER_PAGE = 20;
|
|
|
871
871
|
* @param {TimelineProps} props - The props for the Timeline component
|
|
872
872
|
* @returns {ReactElement} Timeline component
|
|
873
873
|
*/
|
|
874
|
-
const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }) => {
|
|
874
|
+
const Timeline = ({ className, style, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }) => {
|
|
875
875
|
const ref = react.useRef(null);
|
|
876
|
+
const loadMoreAnimationFrameRef = react.useRef(null);
|
|
877
|
+
const loadMoreTimeoutRef = react.useRef(null);
|
|
876
878
|
const [isOpen, setIsOpen] = react.useState(false);
|
|
877
879
|
const [visibleCount, setVisibleCount] = react.useState(ITEMS_PER_PAGE);
|
|
878
880
|
const [isLoadingMore, setIsLoadingMore] = react.useState(false);
|
|
@@ -893,17 +895,29 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
893
895
|
ref.current.style.maxHeight = isOpen ? `${ref.current.scrollHeight}px` : "0px";
|
|
894
896
|
}
|
|
895
897
|
}, [isOpen, visibleCount]);
|
|
898
|
+
react.useEffect(() => {
|
|
899
|
+
return () => {
|
|
900
|
+
if (loadMoreAnimationFrameRef.current !== null) {
|
|
901
|
+
cancelAnimationFrame(loadMoreAnimationFrameRef.current);
|
|
902
|
+
}
|
|
903
|
+
if (loadMoreTimeoutRef.current !== null) {
|
|
904
|
+
clearTimeout(loadMoreTimeoutRef.current);
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
}, []);
|
|
896
908
|
const loadMoreItems = react.useCallback(() => {
|
|
897
909
|
if (isLoadingMore || visibleCount >= middleChildren.length) {
|
|
898
910
|
return;
|
|
899
911
|
}
|
|
900
912
|
setIsLoadingMore(true);
|
|
901
913
|
// Use requestAnimationFrame to avoid layout thrashing
|
|
902
|
-
requestAnimationFrame(() => {
|
|
914
|
+
loadMoreAnimationFrameRef.current = requestAnimationFrame(() => {
|
|
915
|
+
loadMoreAnimationFrameRef.current = null;
|
|
903
916
|
const scrollPos = ref.current?.scrollTop ?? 0;
|
|
904
917
|
setVisibleCount(prev => Math.min(prev + ITEMS_PER_PAGE, middleChildren.length));
|
|
905
918
|
// After state update, preserve scroll position
|
|
906
|
-
setTimeout(() => {
|
|
919
|
+
loadMoreTimeoutRef.current = setTimeout(() => {
|
|
920
|
+
loadMoreTimeoutRef.current = null;
|
|
907
921
|
if (ref.current) {
|
|
908
922
|
ref.current.scrollTop = scrollPos;
|
|
909
923
|
}
|
|
@@ -936,7 +950,7 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
936
950
|
const { date, dateRange, showTime } = dateHeader;
|
|
937
951
|
return (jsxRuntime.jsx("div", { className: "pb-4", "data-testid": "timeline-date-header", children: date ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(reactComponents.Text, { size: "medium", type: "span", weight: "thick", children: formatDate(date, { selectFormat: !showTime ? "dateOnly" : undefined }) }), jsxRuntime.jsx(reactComponents.Text, { className: "text-neutral-500", size: "medium", type: "span", weight: "thick", children: ` (${dateAndTimeUtils.timeSinceAuto(date, new Date(), undefined, locale)})` })] })) : (jsxRuntime.jsx(reactComponents.Text, { className: "pr-1", size: "medium", type: "span", weight: "thick", children: formatRange(dateRange, { dateStyle: !showTime ? "medium" : undefined }) })) }));
|
|
938
952
|
}, [dateHeader, formatDate, formatRange, customHeader, locale]);
|
|
939
|
-
return (jsxRuntime.jsxs("div", { className: className, "data-testid": dataTestId, ref: refProp, children: [renderDateHeader(), customHeader !== undefined && customHeader !== null ? jsxRuntime.jsx("div", { className: "text-sm font-semibold", children: customHeader }) : null, toggleButton && middleChildren.length > 0 ? (jsxRuntime.jsxs("div", { children: [firstChild, middleChildren.length > 0 ? renderToggleButton() : null, jsxRuntime.jsxs("div", { "aria-hidden": !isOpen, className: "overflow-hidden overflow-y-auto transition-all duration-300", ref: ref, children: [jsxRuntime.jsx("div", {}), visibleMiddleChildren, isOpen && visibleCount < middleChildren.length ? (jsxRuntime.jsx("div", { className: "flex justify-center py-2", onClick: e => {
|
|
953
|
+
return (jsxRuntime.jsxs("div", { className: className, "data-testid": dataTestId, ref: refProp, style: style, children: [renderDateHeader(), customHeader !== undefined && customHeader !== null ? (jsxRuntime.jsx("div", { className: "text-sm font-semibold", children: customHeader })) : null, toggleButton && middleChildren.length > 0 ? (jsxRuntime.jsxs("div", { children: [firstChild, middleChildren.length > 0 ? renderToggleButton() : null, jsxRuntime.jsxs("div", { "aria-hidden": !isOpen, className: "overflow-hidden overflow-y-auto transition-all duration-300", ref: ref, children: [jsxRuntime.jsx("div", {}), visibleMiddleChildren, isOpen && visibleCount < middleChildren.length ? (jsxRuntime.jsx("div", { className: "flex justify-center py-2", onClick: e => {
|
|
940
954
|
e.stopPropagation(); // Prevent parent handlers from firing
|
|
941
955
|
loadMoreItems();
|
|
942
956
|
}, children: jsxRuntime.jsx(reactComponents.Text, { className: "cursor-pointer text-neutral-500 hover:text-neutral-600", "data-testid": "load-more-text", size: "small", type: "span", children: t("timeline.loadMore") }) })) : null, jsxRuntime.jsx("div", {})] }), lastChild] })) : (jsxRuntime.jsx("div", { children: children }))] }));
|
|
@@ -949,7 +963,7 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
949
963
|
* @param {TimeLineElementProps} props the props
|
|
950
964
|
* @returns {ReactElement} component
|
|
951
965
|
*/
|
|
952
|
-
const TimelineElement = ({ date, children, className, "data-testid": dataTestId = "timeline-element", header, onClick, actionButton, selected = false, customDot, lineStyle = "solid", hoverBehavior = false, }) => {
|
|
966
|
+
const TimelineElement = ({ date, children, className, style, "data-testid": dataTestId = "timeline-element", header, onClick, actionButton, selected = false, customDot, lineStyle = "solid", hoverBehavior = false, }) => {
|
|
953
967
|
const [isHovered, setIsHovered] = react.useState(false);
|
|
954
968
|
const { formatDate } = reactDateAndTimeHooks.useDateAndTime();
|
|
955
969
|
const locale = reactDateAndTimeHooks.useLocale();
|
|
@@ -964,7 +978,7 @@ const TimelineElement = ({ date, children, className, "data-testid": dataTestId
|
|
|
964
978
|
setIsHovered(false);
|
|
965
979
|
}
|
|
966
980
|
};
|
|
967
|
-
return (jsxRuntime.jsxs("div", { className: cvaTimelineElement({ className, selected, hoverBehavior }), "data-date": date, "data-testid": dataTestId, onClick: onClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [renderDate(formattedDate, locale), jsxRuntime.jsxs("div", { className: cvaDotWrapper(), children: [renderDot(customDot, isHovered, selected), jsxRuntime.jsx("div", { className: cvaLine({ lineStyle }) })] }), jsxRuntime.jsxs("div", { className: "pb-2 pt-2", children: [renderHeader(header, dataTestId), renderChildren(children), renderActionButton(actionButton)] })] }));
|
|
981
|
+
return (jsxRuntime.jsxs("div", { className: cvaTimelineElement({ className, selected, hoverBehavior }), "data-date": date, "data-testid": dataTestId, onClick: onClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: style, children: [renderDate(formattedDate, locale), jsxRuntime.jsxs("div", { className: cvaDotWrapper(), children: [renderDot(customDot, isHovered, selected), jsxRuntime.jsx("div", { className: cvaLine({ lineStyle }) })] }), jsxRuntime.jsxs("div", { className: "pb-2 pt-2", children: [renderHeader(header, dataTestId), renderChildren(children), renderActionButton(actionButton)] })] }));
|
|
968
982
|
};
|
|
969
983
|
const renderDate = (formattedDate, locale) => {
|
|
970
984
|
if (!formattedDate) {
|
package/index.esm.js
CHANGED
|
@@ -122,7 +122,7 @@ const MS_PER_HOUR = 60 * 60 * 1000;
|
|
|
122
122
|
* ```
|
|
123
123
|
* @param {DateTimeProps} props - The props for the DateTime component
|
|
124
124
|
*/
|
|
125
|
-
const DateTime = ({ value, format, className, fromNow = false, withTitle = false, titleFormat, timezone, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
125
|
+
const DateTime = ({ value, format, className, style, fromNow = false, withTitle = false, titleFormat, timezone, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
126
126
|
const { t } = useTranslation();
|
|
127
127
|
const locale = useLocale();
|
|
128
128
|
const nowDate = useMemo(() => new Date(), []);
|
|
@@ -139,7 +139,7 @@ const DateTime = ({ value, format, className, fromNow = false, withTitle = false
|
|
|
139
139
|
const dateValue = useMemo(() => {
|
|
140
140
|
return fromNow ? getTimeSince(date, nowDate) : newDateTime;
|
|
141
141
|
}, [date, fromNow, getTimeSince, newDateTime, nowDate]);
|
|
142
|
-
return (jsx("time", { ...rest, className: className || subtle ? twMerge(subtle ? "text-neutral-600" : undefined, className) : undefined, "data-testid": dataTestId, dateTime: newDateTime, ref: ref, title: titleDateTime, children: dateValue }));
|
|
142
|
+
return (jsx("time", { ...rest, className: className || subtle ? twMerge(subtle ? "text-neutral-600" : undefined, className) : undefined, "data-testid": dataTestId, dateTime: newDateTime, ref: ref, style: style, title: titleDateTime, children: dateValue }));
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
/**
|
|
@@ -200,10 +200,10 @@ const useCalculateDateRange = () => {
|
|
|
200
200
|
* @param {DayPickerProps} props - The props for the DayPicker component
|
|
201
201
|
* @returns {ReactElement} DayPicker component
|
|
202
202
|
*/
|
|
203
|
-
const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className, "data-testid": dataTestId, ref, }) => {
|
|
203
|
+
const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className, style, "data-testid": dataTestId, ref, }) => {
|
|
204
204
|
const { subtract } = useDateAndTime();
|
|
205
205
|
const calculateDateRange = useCalculateDateRange();
|
|
206
|
-
return (jsx("div", { "data-testid": dataTestId, ref: ref, children: jsx(Calendar, { activeStartDate: selectedDay ?? undefined, allowPartialRange: true, className: twMerge("custom-day-picker", "range-picker", className, "p-0"), locale: language, onChange: value => {
|
|
206
|
+
return (jsx("div", { "data-testid": dataTestId, ref: ref, style: style, children: jsx(Calendar, { activeStartDate: selectedDay ?? undefined, allowPartialRange: true, className: twMerge("custom-day-picker", "range-picker", className, "p-0"), locale: language, onChange: value => {
|
|
207
207
|
if (value) {
|
|
208
208
|
onDaySelect?.(value);
|
|
209
209
|
}
|
|
@@ -264,7 +264,7 @@ const DayPicker = ({ onDaySelect, disabledDays, selectedDay, language, className
|
|
|
264
264
|
* @param {DayRangePickerProps} props - The props for the DayRangePicker component
|
|
265
265
|
* @returns {ReactElement} DayRangePicker component
|
|
266
266
|
*/
|
|
267
|
-
const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }) => {
|
|
267
|
+
const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, style, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }) => {
|
|
268
268
|
const [newRange, setNewRange] = useState(selectedDays ?? { start: undefined, end: undefined });
|
|
269
269
|
const [t] = useTranslation();
|
|
270
270
|
const { subtract } = useDateAndTime();
|
|
@@ -306,7 +306,7 @@ const DayRangePicker = ({ onRangeSelect, selectedDays, disabledDays, "data-testi
|
|
|
306
306
|
onClose();
|
|
307
307
|
}
|
|
308
308
|
}, [onRangeSelect, newRange, onClose]);
|
|
309
|
-
return (jsxs("div", { className: twMerge("flex", "w-min", "flex-col", "overflow-hidden", "rounded-md", "border", "border-neutral-300", "bg-white", className), "data-testid": dataTestId, ref: ref, children: [jsx(Calendar, { allowPartialRange: true, className: twMerge("custom-day-picker", "range-picker", classNameCalendar), locale: language, onChange: value => {
|
|
309
|
+
return (jsxs("div", { className: twMerge("flex", "w-min", "flex-col", "overflow-hidden", "rounded-md", "border", "border-neutral-300", "bg-white", className), "data-testid": dataTestId, ref: ref, style: style, children: [jsx(Calendar, { allowPartialRange: true, className: twMerge("custom-day-picker", "range-picker", classNameCalendar), locale: language, onChange: value => {
|
|
310
310
|
if (Array.isArray(value) && value[0] && value[1]) {
|
|
311
311
|
handleOnRangeSelect({ start: value[0], end: value[1] });
|
|
312
312
|
}
|
|
@@ -869,8 +869,10 @@ const ITEMS_PER_PAGE = 20;
|
|
|
869
869
|
* @param {TimelineProps} props - The props for the Timeline component
|
|
870
870
|
* @returns {ReactElement} Timeline component
|
|
871
871
|
*/
|
|
872
|
-
const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }) => {
|
|
872
|
+
const Timeline = ({ className, style, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }) => {
|
|
873
873
|
const ref = useRef(null);
|
|
874
|
+
const loadMoreAnimationFrameRef = useRef(null);
|
|
875
|
+
const loadMoreTimeoutRef = useRef(null);
|
|
874
876
|
const [isOpen, setIsOpen] = useState(false);
|
|
875
877
|
const [visibleCount, setVisibleCount] = useState(ITEMS_PER_PAGE);
|
|
876
878
|
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
@@ -891,17 +893,29 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
891
893
|
ref.current.style.maxHeight = isOpen ? `${ref.current.scrollHeight}px` : "0px";
|
|
892
894
|
}
|
|
893
895
|
}, [isOpen, visibleCount]);
|
|
896
|
+
useEffect(() => {
|
|
897
|
+
return () => {
|
|
898
|
+
if (loadMoreAnimationFrameRef.current !== null) {
|
|
899
|
+
cancelAnimationFrame(loadMoreAnimationFrameRef.current);
|
|
900
|
+
}
|
|
901
|
+
if (loadMoreTimeoutRef.current !== null) {
|
|
902
|
+
clearTimeout(loadMoreTimeoutRef.current);
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
}, []);
|
|
894
906
|
const loadMoreItems = useCallback(() => {
|
|
895
907
|
if (isLoadingMore || visibleCount >= middleChildren.length) {
|
|
896
908
|
return;
|
|
897
909
|
}
|
|
898
910
|
setIsLoadingMore(true);
|
|
899
911
|
// Use requestAnimationFrame to avoid layout thrashing
|
|
900
|
-
requestAnimationFrame(() => {
|
|
912
|
+
loadMoreAnimationFrameRef.current = requestAnimationFrame(() => {
|
|
913
|
+
loadMoreAnimationFrameRef.current = null;
|
|
901
914
|
const scrollPos = ref.current?.scrollTop ?? 0;
|
|
902
915
|
setVisibleCount(prev => Math.min(prev + ITEMS_PER_PAGE, middleChildren.length));
|
|
903
916
|
// After state update, preserve scroll position
|
|
904
|
-
setTimeout(() => {
|
|
917
|
+
loadMoreTimeoutRef.current = setTimeout(() => {
|
|
918
|
+
loadMoreTimeoutRef.current = null;
|
|
905
919
|
if (ref.current) {
|
|
906
920
|
ref.current.scrollTop = scrollPos;
|
|
907
921
|
}
|
|
@@ -934,7 +948,7 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
934
948
|
const { date, dateRange, showTime } = dateHeader;
|
|
935
949
|
return (jsx("div", { className: "pb-4", "data-testid": "timeline-date-header", children: date ? (jsxs(Fragment, { children: [jsx(Text, { size: "medium", type: "span", weight: "thick", children: formatDate(date, { selectFormat: !showTime ? "dateOnly" : undefined }) }), jsx(Text, { className: "text-neutral-500", size: "medium", type: "span", weight: "thick", children: ` (${timeSinceAuto(date, new Date(), undefined, locale)})` })] })) : (jsx(Text, { className: "pr-1", size: "medium", type: "span", weight: "thick", children: formatRange(dateRange, { dateStyle: !showTime ? "medium" : undefined }) })) }));
|
|
936
950
|
}, [dateHeader, formatDate, formatRange, customHeader, locale]);
|
|
937
|
-
return (jsxs("div", { className: className, "data-testid": dataTestId, ref: refProp, children: [renderDateHeader(), customHeader !== undefined && customHeader !== null ? jsx("div", { className: "text-sm font-semibold", children: customHeader }) : null, toggleButton && middleChildren.length > 0 ? (jsxs("div", { children: [firstChild, middleChildren.length > 0 ? renderToggleButton() : null, jsxs("div", { "aria-hidden": !isOpen, className: "overflow-hidden overflow-y-auto transition-all duration-300", ref: ref, children: [jsx("div", {}), visibleMiddleChildren, isOpen && visibleCount < middleChildren.length ? (jsx("div", { className: "flex justify-center py-2", onClick: e => {
|
|
951
|
+
return (jsxs("div", { className: className, "data-testid": dataTestId, ref: refProp, style: style, children: [renderDateHeader(), customHeader !== undefined && customHeader !== null ? (jsx("div", { className: "text-sm font-semibold", children: customHeader })) : null, toggleButton && middleChildren.length > 0 ? (jsxs("div", { children: [firstChild, middleChildren.length > 0 ? renderToggleButton() : null, jsxs("div", { "aria-hidden": !isOpen, className: "overflow-hidden overflow-y-auto transition-all duration-300", ref: ref, children: [jsx("div", {}), visibleMiddleChildren, isOpen && visibleCount < middleChildren.length ? (jsx("div", { className: "flex justify-center py-2", onClick: e => {
|
|
938
952
|
e.stopPropagation(); // Prevent parent handlers from firing
|
|
939
953
|
loadMoreItems();
|
|
940
954
|
}, children: jsx(Text, { className: "cursor-pointer text-neutral-500 hover:text-neutral-600", "data-testid": "load-more-text", size: "small", type: "span", children: t("timeline.loadMore") }) })) : null, jsx("div", {})] }), lastChild] })) : (jsx("div", { children: children }))] }));
|
|
@@ -947,7 +961,7 @@ const Timeline = ({ className, "data-testid": dataTestId, children, dateHeader,
|
|
|
947
961
|
* @param {TimeLineElementProps} props the props
|
|
948
962
|
* @returns {ReactElement} component
|
|
949
963
|
*/
|
|
950
|
-
const TimelineElement = ({ date, children, className, "data-testid": dataTestId = "timeline-element", header, onClick, actionButton, selected = false, customDot, lineStyle = "solid", hoverBehavior = false, }) => {
|
|
964
|
+
const TimelineElement = ({ date, children, className, style, "data-testid": dataTestId = "timeline-element", header, onClick, actionButton, selected = false, customDot, lineStyle = "solid", hoverBehavior = false, }) => {
|
|
951
965
|
const [isHovered, setIsHovered] = useState(false);
|
|
952
966
|
const { formatDate } = useDateAndTime();
|
|
953
967
|
const locale = useLocale();
|
|
@@ -962,7 +976,7 @@ const TimelineElement = ({ date, children, className, "data-testid": dataTestId
|
|
|
962
976
|
setIsHovered(false);
|
|
963
977
|
}
|
|
964
978
|
};
|
|
965
|
-
return (jsxs("div", { className: cvaTimelineElement({ className, selected, hoverBehavior }), "data-date": date, "data-testid": dataTestId, onClick: onClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, children: [renderDate(formattedDate, locale), jsxs("div", { className: cvaDotWrapper(), children: [renderDot(customDot, isHovered, selected), jsx("div", { className: cvaLine({ lineStyle }) })] }), jsxs("div", { className: "pb-2 pt-2", children: [renderHeader(header, dataTestId), renderChildren(children), renderActionButton(actionButton)] })] }));
|
|
979
|
+
return (jsxs("div", { className: cvaTimelineElement({ className, selected, hoverBehavior }), "data-date": date, "data-testid": dataTestId, onClick: onClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, style: style, children: [renderDate(formattedDate, locale), jsxs("div", { className: cvaDotWrapper(), children: [renderDot(customDot, isHovered, selected), jsx("div", { className: cvaLine({ lineStyle }) })] }), jsxs("div", { className: "pb-2 pt-2", children: [renderHeader(header, dataTestId), renderChildren(children), renderActionButton(actionButton)] })] }));
|
|
966
980
|
};
|
|
967
981
|
const renderDate = (formattedDate, locale) => {
|
|
968
982
|
if (!formattedDate) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-date-and-time-components",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.2",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-components": "1.24.
|
|
11
|
-
"@trackunit/date-and-time-utils": "1.13.
|
|
12
|
-
"@trackunit/react-date-and-time-hooks": "1.24.
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
14
|
-
"@trackunit/ui-icons": "1.13.
|
|
15
|
-
"@trackunit/shared-utils": "1.15.
|
|
16
|
-
"@trackunit/i18n-library-translation": "1.21.
|
|
17
|
-
"@trackunit/react-form-components": "1.25.
|
|
10
|
+
"@trackunit/react-components": "1.24.1",
|
|
11
|
+
"@trackunit/date-and-time-utils": "1.13.1",
|
|
12
|
+
"@trackunit/react-date-and-time-hooks": "1.24.1",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.13.1",
|
|
14
|
+
"@trackunit/ui-icons": "1.13.1",
|
|
15
|
+
"@trackunit/shared-utils": "1.15.1",
|
|
16
|
+
"@trackunit/i18n-library-translation": "1.21.1",
|
|
17
|
+
"@trackunit/react-form-components": "1.25.2",
|
|
18
18
|
"string-ts": "^2.0.0",
|
|
19
19
|
"tailwind-merge": "^2.0.0",
|
|
20
20
|
"react-calendar": "^6.0.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
3
|
export type FurtherBackThanDays = {
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export type DisabledDaysMatcher = ((date: Date) => boolean) | {
|
|
|
10
10
|
before?: Date;
|
|
11
11
|
after?: Date;
|
|
12
12
|
} | Array<Date> | FurtherBackThanDays;
|
|
13
|
-
export interface DayPickerProps extends CommonProps, Refable<HTMLDivElement
|
|
13
|
+
export interface DayPickerProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
14
14
|
/**
|
|
15
15
|
* A callback function for when a date is selected
|
|
16
16
|
*/
|
|
@@ -34,4 +34,4 @@ export interface DayPickerProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
34
34
|
* @param {DayPickerProps} props - The props for the DayPicker component
|
|
35
35
|
* @returns {ReactElement} DayPicker component
|
|
36
36
|
*/
|
|
37
|
-
export declare const DayPicker: ({ onDaySelect, disabledDays, selectedDay, language, className, "data-testid": dataTestId, ref, }: DayPickerProps) => ReactElement;
|
|
37
|
+
export declare const DayPicker: ({ onDaySelect, disabledDays, selectedDay, language, className, style, "data-testid": dataTestId, ref, }: DayPickerProps) => ReactElement;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { DateRange } from "@trackunit/date-and-time-utils";
|
|
3
3
|
import { ReactElement } from "react";
|
|
4
4
|
import { TimeZone } from "../TimeZone";
|
|
5
5
|
import { DisabledDaysMatcher } from "./DayPicker";
|
|
6
|
-
export interface DayRangePickerProps extends CommonProps, Refable<HTMLDivElement
|
|
6
|
+
export interface DayRangePickerProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
7
7
|
/**
|
|
8
8
|
* A callback function for when a range is selected
|
|
9
9
|
*/
|
|
@@ -64,4 +64,4 @@ export interface DayRangePickerProps extends CommonProps, Refable<HTMLDivElement
|
|
|
64
64
|
* @param {DayRangePickerProps} props - The props for the DayRangePicker component
|
|
65
65
|
* @returns {ReactElement} DayRangePicker component
|
|
66
66
|
*/
|
|
67
|
-
export declare const DayRangePicker: ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }: DayRangePickerProps) => ReactElement;
|
|
67
|
+
export declare const DayRangePicker: ({ onRangeSelect, selectedDays, disabledDays, "data-testid": dataTestId, language, className, style, classNameCalendar, timezone, cancelButtonLabel, onClose, ref, }: DayRangePickerProps) => ReactElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateRange } from "@trackunit/date-and-time-utils";
|
|
2
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
export interface TimelineProps extends CommonProps, Refable<HTMLDivElement
|
|
4
|
+
export interface TimelineProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
toggleButton?: {
|
|
7
7
|
expandedLabel: string;
|
|
@@ -25,4 +25,4 @@ export interface TimelineProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
25
25
|
* @param {TimelineProps} props - The props for the Timeline component
|
|
26
26
|
* @returns {ReactElement} Timeline component
|
|
27
27
|
*/
|
|
28
|
-
export declare const Timeline: ({ className, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }: TimelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const Timeline: ({ className, style, "data-testid": dataTestId, children, dateHeader, customHeader, toggleButton, ref: refProp, }: TimelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CommonProps, IconColors } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, IconColors, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { IconName } from "@trackunit/ui-icons";
|
|
3
3
|
import { MouseEvent, ReactNode } from "react";
|
|
4
|
-
interface TimeLineElementProps extends CommonProps {
|
|
4
|
+
interface TimeLineElementProps extends CommonProps, Styleable {
|
|
5
5
|
date?: Date;
|
|
6
6
|
header?: ReactNode;
|
|
7
7
|
children?: ReactNode;
|
|
@@ -26,5 +26,5 @@ interface TimeLineElementProps extends CommonProps {
|
|
|
26
26
|
* @param {TimeLineElementProps} props the props
|
|
27
27
|
* @returns {ReactElement} component
|
|
28
28
|
*/
|
|
29
|
-
export declare const TimelineElement: ({ date, children, className, "data-testid": dataTestId, header, onClick, actionButton, selected, customDot, lineStyle, hoverBehavior, }: TimeLineElementProps) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const TimelineElement: ({ date, children, className, style, "data-testid": dataTestId, header, onClick, actionButton, selected, customDot, lineStyle, hoverBehavior, }: TimeLineElementProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
30
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TemporalFormat } from "@trackunit/date-and-time-utils";
|
|
2
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
3
3
|
import { TimeZone } from "../TimeZone";
|
|
4
|
-
export interface DateTimeProps extends CommonProps, Refable<HTMLTimeElement
|
|
4
|
+
export interface DateTimeProps extends CommonProps, Refable<HTMLTimeElement>, Styleable {
|
|
5
5
|
/**
|
|
6
6
|
* The date/time value to display. Accepts a `Date` object, an ISO 8601 string, or a Unix timestamp in milliseconds.
|
|
7
7
|
* When `null` or `undefined`, the current date/time is used.
|
|
@@ -71,4 +71,4 @@ export declare const MS_PER_HOUR: number;
|
|
|
71
71
|
* ```
|
|
72
72
|
* @param {DateTimeProps} props - The props for the DateTime component
|
|
73
73
|
*/
|
|
74
|
-
export declare const DateTime: ({ value, format, className, fromNow, withTitle, titleFormat, timezone, "data-testid": dataTestId, subtle, ref, ...rest }: DateTimeProps) => import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
export declare const DateTime: ({ value, format, className, style, fromNow, withTitle, titleFormat, timezone, "data-testid": dataTestId, subtle, ref, ...rest }: DateTimeProps) => import("react/jsx-runtime").JSX.Element;
|