@trackunit/react-components 1.7.16 → 1.7.18
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 +64 -6
- package/index.esm.js +64 -6
- package/package.json +1 -1
- package/src/components/Alert/Alert.d.ts +5 -1
- package/src/components/Alert/Alert.variants.d.ts +14 -3
package/index.cjs.js
CHANGED
|
@@ -803,23 +803,81 @@ const cvaAlert = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "gap-3"
|
|
|
803
803
|
success: ["bg-success-100", "border-success-300"],
|
|
804
804
|
info: ["bg-info-100", "border-info-300"],
|
|
805
805
|
},
|
|
806
|
+
actionsInline: {
|
|
807
|
+
true: ["flex-row", "items-center", "gap-2"],
|
|
808
|
+
false: ["flex-col", "gap-3"],
|
|
809
|
+
},
|
|
806
810
|
},
|
|
807
811
|
defaultVariants: {
|
|
808
812
|
color: "info",
|
|
813
|
+
actionsInline: false,
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
const cvaAlertActionsContainer = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2"], {
|
|
817
|
+
variants: {
|
|
818
|
+
inline: {
|
|
819
|
+
true: ["flex-row", "shrink-0"],
|
|
820
|
+
false: ["flex-row", "justify-end"],
|
|
821
|
+
},
|
|
822
|
+
actionsInline: {
|
|
823
|
+
true: ["shrink-0", "items-center"],
|
|
824
|
+
false: [],
|
|
825
|
+
},
|
|
826
|
+
},
|
|
827
|
+
defaultVariants: {
|
|
828
|
+
inline: false,
|
|
829
|
+
actionsInline: false,
|
|
809
830
|
},
|
|
810
831
|
});
|
|
811
|
-
const cvaAlertActionsContainer = cssClassVarianceUtilities.cvaMerge(["flex", "justify-end", "gap-2"]);
|
|
812
832
|
const cvaContent = cssClassVarianceUtilities.cvaMerge(["flex-grow"]);
|
|
813
833
|
const cvaAlertContentContainer = cssClassVarianceUtilities.cvaMerge(["flex", "flex-row", "h-full", "gap-2"], {
|
|
814
834
|
variants: {
|
|
815
835
|
inline: {
|
|
816
|
-
true: ["items-center"],
|
|
836
|
+
true: ["items-center", "justify-between"],
|
|
817
837
|
false: ["items-start"],
|
|
818
838
|
},
|
|
839
|
+
actionsInline: {
|
|
840
|
+
true: ["flex-grow", "items-center"],
|
|
841
|
+
false: [],
|
|
842
|
+
},
|
|
843
|
+
},
|
|
844
|
+
defaultVariants: {
|
|
845
|
+
inline: false,
|
|
846
|
+
actionsInline: false,
|
|
847
|
+
},
|
|
848
|
+
});
|
|
849
|
+
const cvaAlertCloseButtonContainer = cssClassVarianceUtilities.cvaMerge(["flex", "w-min", "shrink-0"], {
|
|
850
|
+
variants: {
|
|
851
|
+
inline: {
|
|
852
|
+
true: ["self-center"],
|
|
853
|
+
false: ["self-start"],
|
|
854
|
+
},
|
|
855
|
+
actionsInline: {
|
|
856
|
+
true: ["self-center"],
|
|
857
|
+
false: ["self-start"],
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
defaultVariants: {
|
|
861
|
+
inline: false,
|
|
862
|
+
actionsInline: false,
|
|
863
|
+
},
|
|
864
|
+
});
|
|
865
|
+
const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["shrink-0", "grid", "w-min", "flex"], {
|
|
866
|
+
variants: {
|
|
867
|
+
inline: {
|
|
868
|
+
true: ["self-center"],
|
|
869
|
+
false: ["self-start"],
|
|
870
|
+
},
|
|
871
|
+
actionsInline: {
|
|
872
|
+
true: ["self-start"],
|
|
873
|
+
false: [],
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
defaultVariants: {
|
|
877
|
+
inline: false,
|
|
878
|
+
actionsInline: false,
|
|
819
879
|
},
|
|
820
880
|
});
|
|
821
|
-
const cvaAlertCloseButtonContainer = cssClassVarianceUtilities.cvaMerge(["flex", "self-start", "w-min", "shrink-0"]);
|
|
822
|
-
const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["self-start", "shrink-0", "grid", "w-min", "hidden", "@2xs:flex"]);
|
|
823
881
|
|
|
824
882
|
/**
|
|
825
883
|
* The Alert component should be used to inform the user of important information.
|
|
@@ -827,7 +885,7 @@ const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["self-start",
|
|
|
827
885
|
* @param {AlertProps} props - The props for the Alert component
|
|
828
886
|
* @returns {ReactElement} Alert component
|
|
829
887
|
*/
|
|
830
|
-
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }) => {
|
|
888
|
+
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, actionsInline = false, }) => {
|
|
831
889
|
const ref = react.useRef(null);
|
|
832
890
|
const { isTextWrapping, ref: titleRef } = useIsTextWrapping();
|
|
833
891
|
react.useEffect(() => {
|
|
@@ -836,7 +894,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
836
894
|
ref.current?.scrollIntoView?.();
|
|
837
895
|
}
|
|
838
896
|
}, [ref, autoScroll]);
|
|
839
|
-
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer({ inline: !isTextWrapping && !children }), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer(), children: jsxRuntime.jsx(Icon, { color: color, name: getIconName(color) }) }), jsxRuntime.jsxs("div", { className: cvaContent(), children: [title ? (jsxRuntime.jsx(Text, { dataTestId: `${dataTestId}-title`, ref: titleRef, weight: "bold", children: title })) : null, children ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight:
|
|
897
|
+
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, actionsInline, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer({ inline: !isTextWrapping && !children, actionsInline }), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsxRuntime.jsx(Icon, { color: color, name: getIconName(color) }) }), jsxRuntime.jsxs("div", { className: cvaContent(), children: [title ? (jsxRuntime.jsx(Text, { dataTestId: `${dataTestId}-title`, ref: titleRef, weight: "bold", children: title })) : null, children ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: "normal", children: children })) : null] }), onClose && !actionsInline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsxRuntime.jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }), primaryAction || secondaryAction ? (jsxRuntime.jsxs("div", { className: cvaAlertActionsContainer({ actionsInline }), children: [secondaryAction ? (jsxRuntime.jsx(Button, { loading: secondaryAction.loading, onClick: secondaryAction.onClick, size: "small", variant: "ghost-neutral", children: secondaryAction.label })) : null, primaryAction ? (jsxRuntime.jsx(Button, { loading: primaryAction.loading, onClick: primaryAction.onClick, size: "small", variant: color === "danger" ? "primary-danger" : "primary", children: primaryAction.label })) : null] })) : null, onClose && actionsInline ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsxRuntime.jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }));
|
|
840
898
|
};
|
|
841
899
|
const getIconName = (color) => {
|
|
842
900
|
switch (color) {
|
package/index.esm.js
CHANGED
|
@@ -801,23 +801,81 @@ const cvaAlert = cvaMerge(["flex", "flex-col", "gap-3", "relative", "p-3", "roun
|
|
|
801
801
|
success: ["bg-success-100", "border-success-300"],
|
|
802
802
|
info: ["bg-info-100", "border-info-300"],
|
|
803
803
|
},
|
|
804
|
+
actionsInline: {
|
|
805
|
+
true: ["flex-row", "items-center", "gap-2"],
|
|
806
|
+
false: ["flex-col", "gap-3"],
|
|
807
|
+
},
|
|
804
808
|
},
|
|
805
809
|
defaultVariants: {
|
|
806
810
|
color: "info",
|
|
811
|
+
actionsInline: false,
|
|
812
|
+
},
|
|
813
|
+
});
|
|
814
|
+
const cvaAlertActionsContainer = cvaMerge(["flex", "gap-2"], {
|
|
815
|
+
variants: {
|
|
816
|
+
inline: {
|
|
817
|
+
true: ["flex-row", "shrink-0"],
|
|
818
|
+
false: ["flex-row", "justify-end"],
|
|
819
|
+
},
|
|
820
|
+
actionsInline: {
|
|
821
|
+
true: ["shrink-0", "items-center"],
|
|
822
|
+
false: [],
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
defaultVariants: {
|
|
826
|
+
inline: false,
|
|
827
|
+
actionsInline: false,
|
|
807
828
|
},
|
|
808
829
|
});
|
|
809
|
-
const cvaAlertActionsContainer = cvaMerge(["flex", "justify-end", "gap-2"]);
|
|
810
830
|
const cvaContent = cvaMerge(["flex-grow"]);
|
|
811
831
|
const cvaAlertContentContainer = cvaMerge(["flex", "flex-row", "h-full", "gap-2"], {
|
|
812
832
|
variants: {
|
|
813
833
|
inline: {
|
|
814
|
-
true: ["items-center"],
|
|
834
|
+
true: ["items-center", "justify-between"],
|
|
815
835
|
false: ["items-start"],
|
|
816
836
|
},
|
|
837
|
+
actionsInline: {
|
|
838
|
+
true: ["flex-grow", "items-center"],
|
|
839
|
+
false: [],
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
defaultVariants: {
|
|
843
|
+
inline: false,
|
|
844
|
+
actionsInline: false,
|
|
845
|
+
},
|
|
846
|
+
});
|
|
847
|
+
const cvaAlertCloseButtonContainer = cvaMerge(["flex", "w-min", "shrink-0"], {
|
|
848
|
+
variants: {
|
|
849
|
+
inline: {
|
|
850
|
+
true: ["self-center"],
|
|
851
|
+
false: ["self-start"],
|
|
852
|
+
},
|
|
853
|
+
actionsInline: {
|
|
854
|
+
true: ["self-center"],
|
|
855
|
+
false: ["self-start"],
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
defaultVariants: {
|
|
859
|
+
inline: false,
|
|
860
|
+
actionsInline: false,
|
|
861
|
+
},
|
|
862
|
+
});
|
|
863
|
+
const cvaAlertIconContainer = cvaMerge(["shrink-0", "grid", "w-min", "flex"], {
|
|
864
|
+
variants: {
|
|
865
|
+
inline: {
|
|
866
|
+
true: ["self-center"],
|
|
867
|
+
false: ["self-start"],
|
|
868
|
+
},
|
|
869
|
+
actionsInline: {
|
|
870
|
+
true: ["self-start"],
|
|
871
|
+
false: [],
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
defaultVariants: {
|
|
875
|
+
inline: false,
|
|
876
|
+
actionsInline: false,
|
|
817
877
|
},
|
|
818
878
|
});
|
|
819
|
-
const cvaAlertCloseButtonContainer = cvaMerge(["flex", "self-start", "w-min", "shrink-0"]);
|
|
820
|
-
const cvaAlertIconContainer = cvaMerge(["self-start", "shrink-0", "grid", "w-min", "hidden", "@2xs:flex"]);
|
|
821
879
|
|
|
822
880
|
/**
|
|
823
881
|
* The Alert component should be used to inform the user of important information.
|
|
@@ -825,7 +883,7 @@ const cvaAlertIconContainer = cvaMerge(["self-start", "shrink-0", "grid", "w-min
|
|
|
825
883
|
* @param {AlertProps} props - The props for the Alert component
|
|
826
884
|
* @returns {ReactElement} Alert component
|
|
827
885
|
*/
|
|
828
|
-
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }) => {
|
|
886
|
+
const Alert = ({ color = "info", title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, actionsInline = false, }) => {
|
|
829
887
|
const ref = useRef(null);
|
|
830
888
|
const { isTextWrapping, ref: titleRef } = useIsTextWrapping();
|
|
831
889
|
useEffect(() => {
|
|
@@ -834,7 +892,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
834
892
|
ref.current?.scrollIntoView?.();
|
|
835
893
|
}
|
|
836
894
|
}, [ref, autoScroll]);
|
|
837
|
-
return (jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxs("div", { className: cvaAlertContentContainer({ inline: !isTextWrapping && !children }), children: [jsx("div", { className: cvaAlertIconContainer(), children: jsx(Icon, { color: color, name: getIconName(color) }) }), jsxs("div", { className: cvaContent(), children: [title ? (jsx(Text, { dataTestId: `${dataTestId}-title`, ref: titleRef, weight: "bold", children: title })) : null, children ? (jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight:
|
|
895
|
+
return (jsxs("div", { className: cvaAlert({ color, actionsInline, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxs("div", { className: cvaAlertContentContainer({ inline: !isTextWrapping && !children, actionsInline }), children: [jsx("div", { className: cvaAlertIconContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsx(Icon, { color: color, name: getIconName(color) }) }), jsxs("div", { className: cvaContent(), children: [title ? (jsx(Text, { dataTestId: `${dataTestId}-title`, ref: titleRef, weight: "bold", children: title })) : null, children ? (jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: "normal", children: children })) : null] }), onClose && !actionsInline ? (jsx("div", { className: cvaAlertCloseButtonContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }), primaryAction || secondaryAction ? (jsxs("div", { className: cvaAlertActionsContainer({ actionsInline }), children: [secondaryAction ? (jsx(Button, { loading: secondaryAction.loading, onClick: secondaryAction.onClick, size: "small", variant: "ghost-neutral", children: secondaryAction.label })) : null, primaryAction ? (jsx(Button, { loading: primaryAction.loading, onClick: primaryAction.onClick, size: "small", variant: color === "danger" ? "primary-danger" : "primary", children: primaryAction.label })) : null] })) : null, onClose && actionsInline ? (jsx("div", { className: cvaAlertCloseButtonContainer({ inline: !isTextWrapping && !children, actionsInline }), children: jsx(IconButton, { className: "!h-5 !min-h-0 !w-5 !p-0", icon: jsx(Icon, { name: "XMark", size: "small" }), onClick: onClose, size: "small", title: "Close Alert", variant: "ghost-neutral" }) })) : null] }));
|
|
838
896
|
};
|
|
839
897
|
const getIconName = (color) => {
|
|
840
898
|
switch (color) {
|
package/package.json
CHANGED
|
@@ -39,6 +39,10 @@ export interface AlertProps extends CommonProps {
|
|
|
39
39
|
* could be used for displaying errors on long scrollable forms
|
|
40
40
|
*/
|
|
41
41
|
autoScroll?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* When true, action buttons are displayed inline with the main content instead of below it.
|
|
44
|
+
*/
|
|
45
|
+
actionsInline?: boolean;
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* The Alert component should be used to inform the user of important information.
|
|
@@ -46,4 +50,4 @@ export interface AlertProps extends CommonProps {
|
|
|
46
50
|
* @param {AlertProps} props - The props for the Alert component
|
|
47
51
|
* @returns {ReactElement} Alert component
|
|
48
52
|
*/
|
|
49
|
-
export declare const Alert: ({ color, title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, }: AlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const Alert: ({ color, title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, actionsInline, }: AlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
export declare const cvaAlert: (props?: ({
|
|
2
2
|
color?: "danger" | "warning" | "success" | "info" | null | undefined;
|
|
3
|
+
actionsInline?: boolean | null | undefined;
|
|
4
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
5
|
+
export declare const cvaAlertActionsContainer: (props?: ({
|
|
6
|
+
inline?: boolean | null | undefined;
|
|
7
|
+
actionsInline?: boolean | null | undefined;
|
|
3
8
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
|
-
export declare const cvaAlertActionsContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
5
9
|
export declare const cvaContent: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
6
10
|
export declare const cvaAlertContentContainer: (props?: ({
|
|
7
11
|
inline?: boolean | null | undefined;
|
|
12
|
+
actionsInline?: boolean | null | undefined;
|
|
13
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
14
|
+
export declare const cvaAlertCloseButtonContainer: (props?: ({
|
|
15
|
+
inline?: boolean | null | undefined;
|
|
16
|
+
actionsInline?: boolean | null | undefined;
|
|
17
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
18
|
+
export declare const cvaAlertIconContainer: (props?: ({
|
|
19
|
+
inline?: boolean | null | undefined;
|
|
20
|
+
actionsInline?: boolean | null | undefined;
|
|
8
21
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
9
|
-
export declare const cvaAlertCloseButtonContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
10
|
-
export declare const cvaAlertIconContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|