@trackunit/react-components 1.4.46 → 1.4.48

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
@@ -808,24 +808,18 @@ const getIconName = (color) => {
808
808
  };
809
809
 
810
810
  const cvaBadge = cssClassVarianceUtilities.cvaMerge([
811
- "uppercase",
812
- "align-middle",
813
811
  "box-border",
814
812
  "whitespace-nowrap",
815
813
  "overflow-hidden",
816
814
  "text-ellipsis",
817
- "inline-block",
815
+ "inline-flex",
816
+ "items-center",
817
+ "justify-center",
818
818
  "rounded-full",
819
819
  "font-bold",
820
820
  "text-center",
821
821
  "tabular-nums",
822
- "w-min",
823
- "h-min",
824
- "min-h-[0.5rem]",
825
- "min-w-[1.5rem]",
826
822
  "text-xs",
827
- "px-1",
828
- "py-0.5",
829
823
  ], {
830
824
  variants: {
831
825
  color: {
@@ -833,7 +827,22 @@ const cvaBadge = cssClassVarianceUtilities.cvaMerge([
833
827
  danger: "bg-danger-600 text-white",
834
828
  warning: "bg-warning-600 text-white",
835
829
  },
830
+ compact: {
831
+ true: "size-2",
832
+ false: "h-fit min-h-4 w-fit min-w-4",
833
+ },
834
+ isSingleChar: {
835
+ true: "aspect-square",
836
+ false: "px-1",
837
+ },
836
838
  },
839
+ compoundVariants: [
840
+ {
841
+ isSingleChar: false,
842
+ compact: false,
843
+ className: "px-1",
844
+ },
845
+ ],
837
846
  defaultVariants: {
838
847
  color: "primary",
839
848
  },
@@ -845,12 +854,13 @@ const cvaBadge = cssClassVarianceUtilities.cvaMerge([
845
854
  * @param {BadgeProps} props - The props for the Badge component
846
855
  * @returns {ReactElement} Badge component
847
856
  */
848
- const Badge = ({ color = "primary", className, count, max, hideZero = false, dataTestId }) => {
857
+ const Badge = ({ color = "primary", compact = false, className, count, max, hideZero = false, dataTestId, }) => {
849
858
  if (hideZero && count === 0) {
850
859
  return null;
851
860
  }
852
861
  const displayedCount = count && max ? (count > max ? `${max}+` : count) : count;
853
- return (jsxRuntime.jsx("span", { className: cvaBadge({ color, className }), "data-testid": dataTestId, children: displayedCount }));
862
+ const isSingleChar = displayedCount?.toString().length === 1;
863
+ return (jsxRuntime.jsx("span", { className: cvaBadge({ color, className, compact, isSingleChar }), "data-testid": dataTestId, children: compact ? null : displayedCount }));
854
864
  };
855
865
 
856
866
  /**
@@ -3232,7 +3242,7 @@ const cvaPageHeaderContainer = cssClassVarianceUtilities.cvaMerge(["bg-white", "
3232
3242
  },
3233
3243
  });
3234
3244
  const cvaPageHeader = cssClassVarianceUtilities.cvaMerge(["box-border", "py-4", "px-6", "flex", "items-center", "gap-y-1"]);
3235
- const cvaPageHeaderHeading = cssClassVarianceUtilities.cvaMerge(["text-slate-900", "text-2xl", "font-bold", "truncate"]);
3245
+ const cvaPageHeaderHeading = cssClassVarianceUtilities.cvaMerge(["text-slate-900", "text-xl", "font-semibold", "truncate"]);
3236
3246
 
3237
3247
  const PageHeaderTitle = ({ title, dataTestId }) => {
3238
3248
  const { ref, isTextTruncated } = useIsTextTruncated();
package/index.esm.js CHANGED
@@ -806,24 +806,18 @@ const getIconName = (color) => {
806
806
  };
807
807
 
808
808
  const cvaBadge = cvaMerge([
809
- "uppercase",
810
- "align-middle",
811
809
  "box-border",
812
810
  "whitespace-nowrap",
813
811
  "overflow-hidden",
814
812
  "text-ellipsis",
815
- "inline-block",
813
+ "inline-flex",
814
+ "items-center",
815
+ "justify-center",
816
816
  "rounded-full",
817
817
  "font-bold",
818
818
  "text-center",
819
819
  "tabular-nums",
820
- "w-min",
821
- "h-min",
822
- "min-h-[0.5rem]",
823
- "min-w-[1.5rem]",
824
820
  "text-xs",
825
- "px-1",
826
- "py-0.5",
827
821
  ], {
828
822
  variants: {
829
823
  color: {
@@ -831,7 +825,22 @@ const cvaBadge = cvaMerge([
831
825
  danger: "bg-danger-600 text-white",
832
826
  warning: "bg-warning-600 text-white",
833
827
  },
828
+ compact: {
829
+ true: "size-2",
830
+ false: "h-fit min-h-4 w-fit min-w-4",
831
+ },
832
+ isSingleChar: {
833
+ true: "aspect-square",
834
+ false: "px-1",
835
+ },
834
836
  },
837
+ compoundVariants: [
838
+ {
839
+ isSingleChar: false,
840
+ compact: false,
841
+ className: "px-1",
842
+ },
843
+ ],
835
844
  defaultVariants: {
836
845
  color: "primary",
837
846
  },
@@ -843,12 +852,13 @@ const cvaBadge = cvaMerge([
843
852
  * @param {BadgeProps} props - The props for the Badge component
844
853
  * @returns {ReactElement} Badge component
845
854
  */
846
- const Badge = ({ color = "primary", className, count, max, hideZero = false, dataTestId }) => {
855
+ const Badge = ({ color = "primary", compact = false, className, count, max, hideZero = false, dataTestId, }) => {
847
856
  if (hideZero && count === 0) {
848
857
  return null;
849
858
  }
850
859
  const displayedCount = count && max ? (count > max ? `${max}+` : count) : count;
851
- return (jsx("span", { className: cvaBadge({ color, className }), "data-testid": dataTestId, children: displayedCount }));
860
+ const isSingleChar = displayedCount?.toString().length === 1;
861
+ return (jsx("span", { className: cvaBadge({ color, className, compact, isSingleChar }), "data-testid": dataTestId, children: compact ? null : displayedCount }));
852
862
  };
853
863
 
854
864
  /**
@@ -3230,7 +3240,7 @@ const cvaPageHeaderContainer = cvaMerge(["bg-white", "tu-page-header"], {
3230
3240
  },
3231
3241
  });
3232
3242
  const cvaPageHeader = cvaMerge(["box-border", "py-4", "px-6", "flex", "items-center", "gap-y-1"]);
3233
- const cvaPageHeaderHeading = cvaMerge(["text-slate-900", "text-2xl", "font-bold", "truncate"]);
3243
+ const cvaPageHeaderHeading = cvaMerge(["text-slate-900", "text-xl", "font-semibold", "truncate"]);
3234
3244
 
3235
3245
  const PageHeaderTitle = ({ title, dataTestId }) => {
3236
3246
  const { ref, isTextTruncated } = useIsTextTruncated();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -25,6 +25,10 @@ interface BaseBadgeProps extends CommonProps {
25
25
  * If enabled the badge is shown even if the count is 0.
26
26
  */
27
27
  hideZero?: boolean;
28
+ /**
29
+ * If true the badge is displayed as a small colored dot with no content
30
+ */
31
+ compact?: boolean;
28
32
  }
29
33
  export type BadgeProps = BaseBadgeProps;
30
34
  /**
@@ -33,5 +37,5 @@ export type BadgeProps = BaseBadgeProps;
33
37
  * @param {BadgeProps} props - The props for the Badge component
34
38
  * @returns {ReactElement} Badge component
35
39
  */
36
- export declare const Badge: ({ color, className, count, max, hideZero, dataTestId }: BadgeProps) => import("react/jsx-runtime").JSX.Element | null;
40
+ export declare const Badge: ({ color, compact, className, count, max, hideZero, dataTestId, }: BadgeProps) => import("react/jsx-runtime").JSX.Element | null;
37
41
  export {};
@@ -1,3 +1,5 @@
1
1
  export declare const cvaBadge: (props?: ({
2
2
  color?: "primary" | "danger" | "warning" | null | undefined;
3
+ compact?: boolean | null | undefined;
4
+ isSingleChar?: boolean | null | undefined;
3
5
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;