@trackunit/react-date-and-time-components 1.13.29 → 1.13.33
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
CHANGED
|
@@ -544,7 +544,7 @@ const isTemporalDirection = (direction) => {
|
|
|
544
544
|
/**
|
|
545
545
|
* Day range select component.
|
|
546
546
|
*/
|
|
547
|
-
const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection = undefined, initialDateRangeOptions, showDateRangeSearch = true, showCustomDateRangeOption = true, timezone, maxDaysInRange, size = "medium", fullWidth = false, actionButton, }) => {
|
|
547
|
+
const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection = undefined, initialDateRangeOptions, showDateRangeSearch = true, showCustomDateRangeOption = true, timezone, maxDaysInRange, size = "medium", fullWidth = false, actionButton, popoverPlacement = "bottom-start", }) => {
|
|
548
548
|
const [t] = useTranslation();
|
|
549
549
|
const parseTemporalPeriodFromText = useParseTemporalPeriodFromText();
|
|
550
550
|
const filterTemporalPeriodsInRange = useFilterTemporalPeriodsInRange();
|
|
@@ -638,7 +638,7 @@ const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, select
|
|
|
638
638
|
setSelectedRange(_selectedDateRange);
|
|
639
639
|
onRangeSelect(_selectedDateRange);
|
|
640
640
|
}, [onRangeSelect, handleReset]);
|
|
641
|
-
return (jsxRuntime.jsxs(reactComponents.Popover, { onOpenStateChange: state => !state && setIsCustomDateRangeOpen(false), placement:
|
|
641
|
+
return (jsxRuntime.jsxs(reactComponents.Popover, { onOpenStateChange: state => !state && setIsCustomDateRangeOpen(false), placement: popoverPlacement, children: [jsxRuntime.jsx(reactComponents.PopoverTrigger, { children: !actionButton ? (jsxRuntime.jsx(reactComponents.Button, { className: cvaTriggerButton({ active: !!selectedDateRange, className }), "data-testid": dataTestId, disabled: disabled, fullWidth: fullWidth, prefix: jsxRuntime.jsx(reactComponents.Icon, { ariaLabel: t("input.icon.tooltip.calendar"), color: disabled ? "neutral" : selectedDateRange ? "primary" : undefined, name: "Calendar", size: size === "large" ? "medium" : "small" }), size: size, variant: "secondary", children: popoverTriggerLabel ?? t("trigger.selectDateRange") })) : (jsxRuntime.jsx("div", { children: actionButton })) }), jsxRuntime.jsx(reactComponents.PopoverContent, { "data-testid": dataTestId ? `${dataTestId}-popover-content` : undefined, children: closeMenu => {
|
|
642
642
|
return !isCustomDateRangeOpen ? (jsxRuntime.jsxs(reactComponents.MenuList, { className: "min-w-[280px]", children: [jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [showDateRangeSearch ? (jsxRuntime.jsx(reactFormComponents.Search, { className: "w-full", "data-testid": dataTestId ? `${dataTestId}-search-input` : undefined, onChange: event => handleDateRangeSearch(event.target.value), onClear: () => handleDateRangeSearch(""), placeholder: allowedDirection === "last"
|
|
643
643
|
? t("input.placeholder.customRange.last")
|
|
644
644
|
: t("input.placeholder.customRange.next"), value: dateRangeSearchValue })) : null, jsxRuntime.jsx(reactComponents.Button, { className: "ml-auto", "data-testid": dataTestId ? `${dataTestId}-reset-button` : undefined, disabled: !selectedDateRange, onClick: handleReset, size: "small", variant: "ghost", children: t("layout.actions.reset") })] }), jsxRuntime.jsx("hr", { className: "my-1 border-neutral-200", role: "separator" }), jsxRuntime.jsx(DayRangeSelectOptions, { "data-testid": dataTestId ? `${dataTestId}-options` : undefined, onSelect: value => handleOptionsSelect(value, closeMenu), selectedDateRange: currentSelectedRange, temporalPeriods: temporalPeriods }), showCustomDateRangeOption ? (jsxRuntime.jsxs("section", { children: [jsxRuntime.jsx(reactComponents.MenuDivider, {}), jsxRuntime.jsx(reactComponents.MenuItem, { "data-testid": dataTestId ? `${dataTestId}-custom-range` : undefined, label: t("trigger.customRange"), onClick: () => setIsCustomDateRangeOpen(true), selected: isCustomDateRangeSelected, suffix: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [isCustomDateRangeSelected ? jsxRuntime.jsx(reactComponents.Icon, { color: "primary", name: "Check", size: "small" }) : null, jsxRuntime.jsx(reactComponents.Icon, { name: "ChevronRight", size: "small" })] }) })] })) : null] })) : (jsxRuntime.jsx(reactComponents.Card, { children: jsxRuntime.jsx(DayRangePicker, { cancelButtonLabel: t("layout.actions.back"), disabledDays: customDateRangeDisabledDays, language: "en", onClose: () => setIsCustomDateRangeOpen(false), onRangeSelect: dateRange => handleCustomDateRangeSelect(dateRange
|
|
@@ -887,7 +887,7 @@ const renderChildren = (children) => {
|
|
|
887
887
|
if (!children) {
|
|
888
888
|
return null;
|
|
889
889
|
}
|
|
890
|
-
return jsxRuntime.jsx("div", { className: "mt-0.5 content-center text-sm
|
|
890
|
+
return jsxRuntime.jsx("div", { className: "mt-0.5 content-center text-sm", children: children });
|
|
891
891
|
};
|
|
892
892
|
const renderActionButton = (actionButton) => {
|
|
893
893
|
if (!actionButton) {
|
package/index.esm.js
CHANGED
|
@@ -542,7 +542,7 @@ const isTemporalDirection = (direction) => {
|
|
|
542
542
|
/**
|
|
543
543
|
* Day range select component.
|
|
544
544
|
*/
|
|
545
|
-
const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection = undefined, initialDateRangeOptions, showDateRangeSearch = true, showCustomDateRangeOption = true, timezone, maxDaysInRange, size = "medium", fullWidth = false, actionButton, }) => {
|
|
545
|
+
const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection = undefined, initialDateRangeOptions, showDateRangeSearch = true, showCustomDateRangeOption = true, timezone, maxDaysInRange, size = "medium", fullWidth = false, actionButton, popoverPlacement = "bottom-start", }) => {
|
|
546
546
|
const [t] = useTranslation();
|
|
547
547
|
const parseTemporalPeriodFromText = useParseTemporalPeriodFromText();
|
|
548
548
|
const filterTemporalPeriodsInRange = useFilterTemporalPeriodsInRange();
|
|
@@ -636,7 +636,7 @@ const DayRangeSelect = ({ className, "data-testid": dataTestId, disabled, select
|
|
|
636
636
|
setSelectedRange(_selectedDateRange);
|
|
637
637
|
onRangeSelect(_selectedDateRange);
|
|
638
638
|
}, [onRangeSelect, handleReset]);
|
|
639
|
-
return (jsxs(Popover, { onOpenStateChange: state => !state && setIsCustomDateRangeOpen(false), placement:
|
|
639
|
+
return (jsxs(Popover, { onOpenStateChange: state => !state && setIsCustomDateRangeOpen(false), placement: popoverPlacement, children: [jsx(PopoverTrigger, { children: !actionButton ? (jsx(Button, { className: cvaTriggerButton({ active: !!selectedDateRange, className }), "data-testid": dataTestId, disabled: disabled, fullWidth: fullWidth, prefix: jsx(Icon, { ariaLabel: t("input.icon.tooltip.calendar"), color: disabled ? "neutral" : selectedDateRange ? "primary" : undefined, name: "Calendar", size: size === "large" ? "medium" : "small" }), size: size, variant: "secondary", children: popoverTriggerLabel ?? t("trigger.selectDateRange") })) : (jsx("div", { children: actionButton })) }), jsx(PopoverContent, { "data-testid": dataTestId ? `${dataTestId}-popover-content` : undefined, children: closeMenu => {
|
|
640
640
|
return !isCustomDateRangeOpen ? (jsxs(MenuList, { className: "min-w-[280px]", children: [jsxs("div", { className: "flex flex-col gap-1", children: [showDateRangeSearch ? (jsx(Search, { className: "w-full", "data-testid": dataTestId ? `${dataTestId}-search-input` : undefined, onChange: event => handleDateRangeSearch(event.target.value), onClear: () => handleDateRangeSearch(""), placeholder: allowedDirection === "last"
|
|
641
641
|
? t("input.placeholder.customRange.last")
|
|
642
642
|
: t("input.placeholder.customRange.next"), value: dateRangeSearchValue })) : null, jsx(Button, { className: "ml-auto", "data-testid": dataTestId ? `${dataTestId}-reset-button` : undefined, disabled: !selectedDateRange, onClick: handleReset, size: "small", variant: "ghost", children: t("layout.actions.reset") })] }), jsx("hr", { className: "my-1 border-neutral-200", role: "separator" }), jsx(DayRangeSelectOptions, { "data-testid": dataTestId ? `${dataTestId}-options` : undefined, onSelect: value => handleOptionsSelect(value, closeMenu), selectedDateRange: currentSelectedRange, temporalPeriods: temporalPeriods }), showCustomDateRangeOption ? (jsxs("section", { children: [jsx(MenuDivider, {}), jsx(MenuItem, { "data-testid": dataTestId ? `${dataTestId}-custom-range` : undefined, label: t("trigger.customRange"), onClick: () => setIsCustomDateRangeOpen(true), selected: isCustomDateRangeSelected, suffix: jsxs(Fragment, { children: [isCustomDateRangeSelected ? jsx(Icon, { color: "primary", name: "Check", size: "small" }) : null, jsx(Icon, { name: "ChevronRight", size: "small" })] }) })] })) : null] })) : (jsx(Card, { children: jsx(DayRangePicker, { cancelButtonLabel: t("layout.actions.back"), disabledDays: customDateRangeDisabledDays, language: "en", onClose: () => setIsCustomDateRangeOpen(false), onRangeSelect: dateRange => handleCustomDateRangeSelect(dateRange
|
|
@@ -885,7 +885,7 @@ const renderChildren = (children) => {
|
|
|
885
885
|
if (!children) {
|
|
886
886
|
return null;
|
|
887
887
|
}
|
|
888
|
-
return jsx("div", { className: "mt-0.5 content-center text-sm
|
|
888
|
+
return jsx("div", { className: "mt-0.5 content-center text-sm", children: children });
|
|
889
889
|
};
|
|
890
890
|
const renderActionButton = (actionButton) => {
|
|
891
891
|
if (!actionButton) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-date-and-time-components",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.33",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
|
-
"@trackunit/react-components": "1.14.
|
|
12
|
-
"@trackunit/date-and-time-utils": "1.10.
|
|
13
|
-
"@trackunit/react-date-and-time-hooks": "1.10.
|
|
14
|
-
"@trackunit/css-class-variance-utilities": "1.10.
|
|
15
|
-
"@trackunit/ui-icons": "1.10.
|
|
16
|
-
"@trackunit/shared-utils": "1.12.
|
|
17
|
-
"@trackunit/i18n-library-translation": "1.10.
|
|
18
|
-
"@trackunit/react-form-components": "1.11.
|
|
11
|
+
"@trackunit/react-components": "1.14.29",
|
|
12
|
+
"@trackunit/date-and-time-utils": "1.10.23",
|
|
13
|
+
"@trackunit/react-date-and-time-hooks": "1.10.31",
|
|
14
|
+
"@trackunit/css-class-variance-utilities": "1.10.23",
|
|
15
|
+
"@trackunit/ui-icons": "1.10.23",
|
|
16
|
+
"@trackunit/shared-utils": "1.12.23",
|
|
17
|
+
"@trackunit/i18n-library-translation": "1.10.25",
|
|
18
|
+
"@trackunit/react-form-components": "1.11.29",
|
|
19
19
|
"string-ts": "^2.0.0",
|
|
20
20
|
"tailwind-merge": "^2.0.0",
|
|
21
21
|
"react-calendar": "^6.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateRange } from "@trackunit/date-and-time-utils";
|
|
2
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { CommonProps, PopoverPlacement } from "@trackunit/react-components";
|
|
3
3
|
import { Size } from "@trackunit/shared-utils";
|
|
4
4
|
import { ReactElement } from "react";
|
|
5
5
|
import { DayRangePickerProps } from "../DayPicker/DayRangePicker";
|
|
@@ -56,8 +56,14 @@ export type DayRangeSelectProps = CommonProps & {
|
|
|
56
56
|
* If provided, this button replaces the default trigger button of the component.
|
|
57
57
|
*/
|
|
58
58
|
actionButton?: ReactElement;
|
|
59
|
+
/**
|
|
60
|
+
* The placement of the popover menu relative to the trigger button.
|
|
61
|
+
*
|
|
62
|
+
* @default "bottom-start"
|
|
63
|
+
*/
|
|
64
|
+
popoverPlacement?: PopoverPlacement;
|
|
59
65
|
};
|
|
60
66
|
/**
|
|
61
67
|
* Day range select component.
|
|
62
68
|
*/
|
|
63
|
-
export declare const DayRangeSelect: ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection, initialDateRangeOptions, showDateRangeSearch, showCustomDateRangeOption, timezone, maxDaysInRange, size, fullWidth, actionButton, }: DayRangeSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
export declare const DayRangeSelect: ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection, initialDateRangeOptions, showDateRangeSearch, showCustomDateRangeOption, timezone, maxDaysInRange, size, fullWidth, actionButton, popoverPlacement, }: DayRangeSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { DayRangeSelectProps } from "./DayRangeSelect";
|
|
|
5
5
|
type Story = StoryObj<typeof meta>;
|
|
6
6
|
declare const meta: {
|
|
7
7
|
title: string;
|
|
8
|
-
component: ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection, initialDateRangeOptions, showDateRangeSearch, showCustomDateRangeOption, timezone, maxDaysInRange, size, fullWidth, actionButton, }: DayRangeSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
component: ({ className, "data-testid": dataTestId, disabled, selectedDateRange, onRangeSelect, allowedDirection, initialDateRangeOptions, showDateRangeSearch, showCustomDateRangeOption, timezone, maxDaysInRange, size, fullWidth, actionButton, popoverPlacement, }: DayRangeSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
tags: string[];
|
|
10
10
|
parameters: {
|
|
11
11
|
docs: {
|
|
@@ -30,6 +30,7 @@ declare const meta: {
|
|
|
30
30
|
size?: import("@trackunit/shared-utils").Size | undefined;
|
|
31
31
|
fullWidth?: boolean | undefined;
|
|
32
32
|
actionButton?: ReactElement | undefined;
|
|
33
|
+
popoverPlacement?: import("@trackunit/react-components").PopoverPlacement | undefined;
|
|
33
34
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
34
35
|
};
|
|
35
36
|
export default meta;
|