@trackunit/react-components 0.0.54 → 0.0.56-abo-fuel-consumption-rest-api.1

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.
@@ -2,18 +2,7 @@ import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  import { Colors } from "../../constants/colors";
4
4
  export declare type BadgeSize = "default" | "large";
5
- declare type BadgeVariant = "badge" | "pill" | "tag";
6
- interface TagProps extends BaseBadgeProps {
7
- /**
8
- * The name of the variant.
9
- */
10
- variant: "tag";
11
- /**
12
- * A handler for a click event triggered on x icon
13
- * if not passed then x icon won't be visible
14
- */
15
- onClose?: () => void;
16
- }
5
+ declare type BadgeVariant = "badge" | "pill";
17
6
  interface BaseBadgeProps extends CommonProps {
18
7
  /**
19
8
  * The color of the badge.
@@ -25,9 +14,8 @@ interface BaseBadgeProps extends CommonProps {
25
14
  */
26
15
  subtle?: boolean;
27
16
  /**
28
- * Whether badge should be displayed as a pill, tag or badge.
17
+ * Whether badge should be displayed as a pill or badge.
29
18
  * For the pill variant, numeric values above 99 will be displayed as 99+.
30
- * Tag will display x icon if you provide onClose handler.
31
19
  * Badge is subtle by default.
32
20
  */
33
21
  variant?: BadgeVariant;
@@ -46,7 +34,7 @@ interface BaseBadgeProps extends CommonProps {
46
34
  */
47
35
  size?: BadgeSize;
48
36
  }
49
- export declare type BadgeProps = BaseBadgeProps | TagProps;
37
+ export declare type BadgeProps = BaseBadgeProps;
50
38
  /**
51
39
  * The Badge component us used to display states or similar short informative text.
52
40
  *
@@ -33,6 +33,12 @@ export interface IconProps extends CommonProps {
33
33
  */
34
34
  fillColor?: string;
35
35
  forwardedRef?: React.RefObject<HTMLSpanElement>;
36
+ /**
37
+ * Custom styles object used to override existing styles or add some extra styling
38
+ *
39
+ * @memberof IconProps
40
+ */
41
+ style?: Record<string, string>;
36
42
  }
37
43
  /**
38
44
  * The Icon component is ued to display an Icon.
@@ -40,4 +46,4 @@ export interface IconProps extends CommonProps {
40
46
  * @param {IconProps} props - The props for the Icon component
41
47
  * @returns {JSX.Element} Icon component
42
48
  */
43
- export declare const Icon: ({ name, size, className, dataTestId, color, onClick, fillColor, type, forwardedRef, }: IconProps) => JSX.Element | null;
49
+ export declare const Icon: ({ name, size, className, dataTestId, color, onClick, fillColor, type, style, forwardedRef, }: IconProps) => JSX.Element | null;
@@ -0,0 +1,44 @@
1
+ import * as React from "react";
2
+ import { CommonProps } from "../../common/CommonProps";
3
+ import { Colors } from "../../constants/colors";
4
+ export declare type TagSize = "default" | "small";
5
+ interface TagProps extends CommonProps {
6
+ /**
7
+ * The color of the tag
8
+ *
9
+ */
10
+ color?: Colors;
11
+ /**
12
+ * A handler for a click event triggered on x icon
13
+ * if not passed then x icon won't be visible
14
+ *
15
+ */
16
+ onClose?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
17
+ /**
18
+ * Custom classNames can be added to make adjustments where needed.
19
+ * Example: Set a maximum width of the badge by adding the className "max-w-[your-max-width]" or similar tailwind max-w class.
20
+ * This will make the badge truncate the text if it is too long.
21
+ *
22
+ */
23
+ className?: string;
24
+ /**
25
+ * Child nodes of the tag.
26
+ *
27
+ */
28
+ children?: React.ReactNode;
29
+ /**
30
+ * Size of the tag.
31
+ *
32
+ */
33
+ size?: TagSize;
34
+ }
35
+ /**
36
+ * Tags allow users to enter information and filter content.
37
+ * Multiple or single tags can be used to categorise items.
38
+ * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
39
+ *
40
+ * @param {TagProps} props - The props for the tag component
41
+ * @returns {JSX.Element} tag component
42
+ */
43
+ export declare const Tag: ({ className, dataTestId, children, size, onClose, color, ...rest }: TagProps) => JSX.Element;
44
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./Tag";
@@ -28,6 +28,7 @@ export * from "./Select";
28
28
  export * from "./SkeletonLines";
29
29
  export * from "./Spacer";
30
30
  export * from "./Spinner";
31
+ export * from "./Tag";
31
32
  export * from "./Text";
32
33
  export * from "./TextArea";
33
34
  export * from "./TextField";
package/index.js CHANGED
@@ -350,6 +350,7 @@ const Icon$1 = ({
350
350
  onClick,
351
351
  fillColor,
352
352
  type,
353
+ style,
353
354
  forwardedRef
354
355
  }) => {
355
356
  const iconSizeClassName = React.useMemo(() => IconSizeClassMap[size], [size]);
@@ -381,9 +382,9 @@ const Icon$1 = ({
381
382
  children: jsx(IconComponent, {
382
383
  "data-testid": `${dataTestId}-${name}`,
383
384
  className: `${iconSizeClassName} ${colorClassNames} ${className} ${name} aspect-square`,
384
- style: fillColor ? {
385
+ style: fillColor ? Object.assign(Object.assign({}, style), {
385
386
  fill: fillColor
386
- } : {}
387
+ }) : Object.assign({}, style)
387
388
  })
388
389
  }))
389
390
  }));
@@ -514,7 +515,7 @@ const Text = ({
514
515
  className,
515
516
  dataTestId
516
517
  }) => {
517
- return jsx(StyledText$3, Object.assign({
518
+ return jsx(StyledText$4, Object.assign({
518
519
  "$as": type,
519
520
  className: className,
520
521
  "$align": align,
@@ -573,7 +574,7 @@ const getTextAlignment = () => ({
573
574
  return alignments[$align];
574
575
  };
575
576
 
576
- const StyledText$3 = tw.text`
577
+ const StyledText$4 = tw.text`
577
578
  tu-text
578
579
  ${getFontColor$1()}
579
580
  ${p => p.$italicize ? tws`tu-text--italic` : ""}
@@ -681,7 +682,7 @@ const Alert = ({
681
682
  ref: ref,
682
683
  role: "alert"
683
684
  }, {
684
- children: [jsx(IconContainer, Object.assign({
685
+ children: [jsx(IconContainer$1, Object.assign({
685
686
  "$inline": inline
686
687
  }, {
687
688
  children: getIconFromIntent()
@@ -757,7 +758,7 @@ const RightAligned = tw.div`
757
758
  alert__right-aligned
758
759
  ${p => p.$inline ? tws`alert__right-aligned--inline` : null}
759
760
  `;
760
- const IconContainer = tw.div`
761
+ const IconContainer$1 = tw.div`
761
762
  alert__icon-container
762
763
  ${p => p.$inline ? tws`alert__icon-container--inline` : null}
763
764
  `;
@@ -778,49 +779,36 @@ const Badge = _a => {
778
779
  color = "neutral",
779
780
  subtle = false,
780
781
  className,
781
- variant = "badge",
782
+ variant = "pill",
782
783
  dataTestId,
783
784
  children,
784
785
  size = "default"
785
- } = _a,
786
- rest = __rest(_a, ["color", "subtle", "className", "variant", "dataTestId", "children", "size"]);
786
+ } = _a;
787
+ __rest(_a, ["color", "subtle", "className", "variant", "dataTestId", "children", "size"]);
787
788
 
788
789
  const isPill = variant === "pill";
789
- const tagProps = rest;
790
- return jsxs(StyledText$2, Object.assign({
790
+ return jsx(StyledText$3, Object.assign({
791
791
  "$variant": variant,
792
792
  className: className,
793
793
  "$color": color,
794
794
  "$size": size,
795
795
  "$subtle": subtle ? subtle : isPill,
796
796
  "data-testid": dataTestId,
797
- "$as": "span",
798
- "$withXIcon": tagProps.onClose ? true : false
797
+ "$as": "span"
799
798
  }, {
800
- children: [isPill ? children !== undefined && children !== null ? children > 99 ? "99+" : children : "" : children, variant === "tag" && tagProps.onClose && jsx(StyledIcon, {
801
- name: "XCircleIcon",
802
- dataTestId: dataTestId + "Icon",
803
- onClick: tagProps.onClose,
804
- type: "solid",
805
- size: size === "default" ? "normal" : "large"
806
- })]
799
+ children: isPill ? children !== undefined && children !== null ? children > 99 ? "99+" : children : "" : children
807
800
  }));
808
801
  };
809
802
 
810
- const getSizeModifierClass = () => ({
803
+ const getSizeModifierClass$1 = () => ({
811
804
  $size,
812
- $variant,
813
- $withXIcon
805
+ $variant
814
806
  }) => {
815
807
  const sizeModifierClass = {
816
808
  large: tws`badge--large`,
817
809
  default: ""
818
810
  };
819
- const tagSizeModifierClass = {
820
- large: $withXIcon ? tws`tag--icon tag--icon-large` : tws`tag--icon tag--large`,
821
- default: $withXIcon ? tws`tag--icon tag--icon-small` : ""
822
- };
823
- return $variant === "tag" ? tagSizeModifierClass[$size] : sizeModifierClass[$size];
811
+ return sizeModifierClass[$size];
824
812
  };
825
813
 
826
814
  const getBadgeModifierClass = () => ({
@@ -846,15 +834,12 @@ const getBadgeModifierClass = () => ({
846
834
  return colorClasses[$color];
847
835
  };
848
836
 
849
- const StyledText$2 = tw.text`
837
+ const StyledText$3 = tw.text`
850
838
  ${p => {
851
839
  switch (p.$variant) {
852
840
  case "badge":
853
841
  return tws`badge`;
854
842
 
855
- case "tag":
856
- return tws`badge--tag`;
857
-
858
843
  case "pill":
859
844
  return tws`badge--pill`;
860
845
 
@@ -863,10 +848,7 @@ const StyledText$2 = tw.text`
863
848
  }
864
849
  }}
865
850
  ${getBadgeModifierClass()}
866
- ${getSizeModifierClass()}
867
- `;
868
- const StyledIcon = tw(Icon$1)`
869
- tag__icon
851
+ ${getSizeModifierClass$1()}
870
852
  `;
871
853
 
872
854
  /**
@@ -2086,7 +2068,7 @@ const PopoverListItem = ({
2086
2068
  }, {
2087
2069
  children: [prefix && jsx("div", {
2088
2070
  children: prefix
2089
- }), jsx(StyledText$1, Object.assign({
2071
+ }), jsx(StyledText$2, Object.assign({
2090
2072
  weight: selected ? "bold" : "default",
2091
2073
  "$selected": selected
2092
2074
  }, {
@@ -2111,7 +2093,7 @@ const PopoverListItem = ({
2111
2093
  })) : content
2112
2094
  }));
2113
2095
  };
2114
- const StyledText$1 = tw(Text)`
2096
+ const StyledText$2 = tw(Text)`
2115
2097
  ${p => p.$selected ? tws`text-primary-600` : tws`text-neutral-600`}
2116
2098
  group-hover:text-primary-500
2117
2099
  `;
@@ -2148,7 +2130,7 @@ const PopoverTitle = ({
2148
2130
  className: className,
2149
2131
  "data-testid": dataTestId
2150
2132
  }, {
2151
- children: [jsx(StyledText, Object.assign({
2133
+ children: [jsx(StyledText$1, Object.assign({
2152
2134
  type: "div",
2153
2135
  subtle: true,
2154
2136
  size: "small",
@@ -2172,7 +2154,7 @@ const Container$5 = tw.div`
2172
2154
  mb-1
2173
2155
  ` : null}
2174
2156
  `;
2175
- const StyledText = tw(Text)`
2157
+ const StyledText$1 = tw(Text)`
2176
2158
  flex-1
2177
2159
  text-neutral-500
2178
2160
  `;
@@ -3868,6 +3850,93 @@ const SkeletonLine = tw.div`
3868
3850
  `;
3869
3851
  SkeletonLines.displayName = "SkeletonLines";
3870
3852
 
3853
+ /**
3854
+ * Tags allow users to enter information and filter content.
3855
+ * Multiple or single tags can be used to categorise items.
3856
+ * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
3857
+ *
3858
+ * @param {TagProps} props - The props for the tag component
3859
+ * @returns {JSX.Element} tag component
3860
+ */
3861
+
3862
+ const Tag = _a => {
3863
+ var {
3864
+ className,
3865
+ dataTestId,
3866
+ children,
3867
+ size = "default",
3868
+ onClose,
3869
+ color = "primary"
3870
+ } = _a;
3871
+ __rest(_a, ["className", "dataTestId", "children", "size", "onClose", "color"]);
3872
+
3873
+ return jsxs(StyledText, Object.assign({
3874
+ className: className,
3875
+ "$size": size,
3876
+ "data-testid": dataTestId,
3877
+ "$as": "span",
3878
+ "$color": color,
3879
+ "$withXIcon": !!onClose
3880
+ }, {
3881
+ children: [children, onClose && jsx(IconContainer, Object.assign({
3882
+ onClick: onClose
3883
+ }, {
3884
+ children: jsx(Icon$1, {
3885
+ name: "XCircleIcon",
3886
+ dataTestId: dataTestId + "Icon",
3887
+ type: "solid",
3888
+ style: {
3889
+ "-webkit-transition": "-webkit-transform 0.150s"
3890
+ },
3891
+ className: size === "default" ? tws`tag__icon` : tws`tag__icon tag__icon--small`
3892
+ })
3893
+ }))]
3894
+ }));
3895
+ };
3896
+
3897
+ const getSizeModifierClass = () => ({
3898
+ $size,
3899
+ $withXIcon
3900
+ }) => {
3901
+ const tagSizeModifierClass = {
3902
+ default: $withXIcon ? tws`tag--withIcon ` : tws` `,
3903
+ small: $withXIcon ? tws`tag--small tag--withIcon` : tws`tag--small`
3904
+ };
3905
+ return tagSizeModifierClass[$size];
3906
+ };
3907
+
3908
+ const getColorModifierClass = () => ({
3909
+ $color
3910
+ }) => {
3911
+ const colorClasses = {
3912
+ primary: tws`tag--primary`,
3913
+ accent: tws`tag--accent`,
3914
+ success: tws`tag--success`,
3915
+ danger: tws`tag--danger`,
3916
+ warning: tws`tag--warning`,
3917
+ info: tws`tag--info`,
3918
+ neutral: tws`tag--neutral`,
3919
+ good: tws`tag--good`,
3920
+ low: tws`tag--low`,
3921
+ critical: tws`tag--critical`,
3922
+ working: tws`tag--working`,
3923
+ idle: tws`tag--idle`,
3924
+ stopped: tws`tag--stopped`,
3925
+ unknown: tws`tag--unknown`
3926
+ };
3927
+ return colorClasses[$color];
3928
+ };
3929
+
3930
+ const StyledText = tw.text`
3931
+ tag
3932
+ ${getSizeModifierClass()}
3933
+ ${getColorModifierClass()}
3934
+ `;
3935
+ const IconContainer = tw.div`
3936
+ flex
3937
+ self-center
3938
+ `;
3939
+
3871
3940
  const TextArea = React.forwardRef(({
3872
3941
  id,
3873
3942
  name,
@@ -4269,4 +4338,4 @@ const useTimeout = ({
4269
4338
  };
4270
4339
  };
4271
4340
 
4272
- export { Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiRowTableCell, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SkeletonLines, Spacer, Spinner, StarButton, Text, TextArea, TextField, TextInput, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
4341
+ export { Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuButton, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiRowTableCell, NumberField, NumberInput, PageHeading, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, Select, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text, TextArea, TextField, TextInput, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, activityColors, colors, criticalityColors, docs, generalColors, intentColors, useContainerProps, useCustomComponents, useCustomStyles, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.54",
3
+ "version": "0.0.56-abo-fuel-consumption-rest-api.1",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
- "@trackunit/css-core": "0.0.39",
8
- "@trackunit/tailwind-styled-components": "0.0.37",
7
+ "@trackunit/css-core": "0.0.40-abo-fuel-consumption-rest-api.1",
8
+ "@trackunit/tailwind-styled-components": "0.0.38-abo-fuel-consumption-rest-api.1",
9
9
  "react": "17.0.1",
10
- "@trackunit/ui-design-tokens": "0.0.36",
10
+ "@trackunit/ui-design-tokens": "0.0.37-abo-fuel-consumption-rest-api.1",
11
11
  "echarts-for-react": "^3.0.2",
12
12
  "uuid": "^8.3.2",
13
13
  "@react-spring/web": "^9.4.4",
14
14
  "react-use": "^17.3.2",
15
15
  "react-day-picker": "^8.0.3",
16
16
  "date-fns": "^2.28.0",
17
- "@trackunit/ui-icons": "0.0.36",
17
+ "@trackunit/ui-icons": "0.0.37-abo-fuel-consumption-rest-api.1",
18
18
  "react-useportal": "^1.0.16",
19
19
  "react-helmet": "^6.1.0",
20
20
  "@popperjs/core": "^2.11.4",