@trackunit/react-components 0.0.122 → 0.0.124

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.
@@ -9,3 +9,4 @@ export interface CommonProps {
9
9
  dataTestId?: string;
10
10
  }
11
11
  export declare type Density = "none" | "compact" | "comfortable" | "spacious" | "auto";
12
+ export declare type Size = "small" | "medium" | "large";
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  import { Colors } from "../../constants/colors";
4
- export declare type BadgeSize = "default" | "large";
4
+ export declare type BadgeSize = "medium" | "large";
5
5
  interface BaseBadgeProps extends CommonProps {
6
6
  /**
7
7
  * The color of the badge.
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common";
3
3
  declare type FilteredInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "prefix" | "suffix">;
4
- declare type FieldSize = "small" | "default";
4
+ declare type FieldSize = "small" | "medium";
5
5
  export interface BaseInputProps extends FilteredInputProps, CommonProps {
6
6
  /**
7
7
  * An React element to render before the text in the input.
@@ -58,6 +58,10 @@ export interface ChartProps extends CommonProps {
58
58
  * Type of rendered used. Either "svg" or "canvas".
59
59
  */
60
60
  renderer?: "svg" | "canvas";
61
+ /**
62
+ * Value used to find element by `data-testid` attribute.
63
+ */
64
+ dataTestId?: string;
61
65
  }
62
66
  /**
63
67
  * The Chart component is a wrapper component for ECharts.
@@ -69,4 +73,4 @@ export interface ChartProps extends CommonProps {
69
73
  * @param {ChartProps} props - The props for the Chart component
70
74
  * @returns {JSX.Element} Chart component
71
75
  */
72
- export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, merge, loadingOption, timezoneLabel, renderer, }: ChartProps) => JSX.Element;
76
+ export declare const Chart: ({ options, showLoading, className, style, onChartReady, onClick, onDataZoom, onBrush, onBrushSelected, mouseLeaveChart, merge, loadingOption, timezoneLabel, renderer, dataTestId, }: ChartProps) => JSX.Element;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { Matcher } from "react-day-picker";
3
- import { ButtonIntent, ButtonSize } from "../buttons";
3
+ import { Size } from "../../common";
4
+ import { ButtonIntent } from "../buttons";
4
5
  import { PopoverPlacement } from "../Popover";
5
6
  export interface DayPickerPopoverProps {
6
7
  disabledDays?: Matcher | Matcher[] | undefined;
@@ -8,7 +9,7 @@ export interface DayPickerPopoverProps {
8
9
  onDaySelect: (day: Date) => void;
9
10
  selectedDay?: Date;
10
11
  intent?: ButtonIntent;
11
- size?: ButtonSize;
12
+ size?: Size;
12
13
  placement?: PopoverPlacement;
13
14
  buttonContent: JSX.Element;
14
15
  language: string;
@@ -1,6 +1,6 @@
1
1
  import { HeroIconName, TrackunitIconName } from "@trackunit/ui-icons";
2
2
  import * as React from "react";
3
- import { CommonProps } from "../../common/CommonProps";
3
+ import { CommonProps, Size } from "../../common/CommonProps";
4
4
  import { Colors } from "../../constants/colors";
5
5
  export interface IconProps extends CommonProps {
6
6
  /**
@@ -16,14 +16,14 @@ export interface IconProps extends CommonProps {
16
16
  color?: Colors;
17
17
  /**
18
18
  * The size of the icon.
19
- * Small = 16x16px, Normal = 20x20px, Large = 24x24px.
19
+ * Small = 16x16px, medium = 20x20px, Large = 24x24px.
20
20
  * Default value is Large.
21
21
  * If a custom size is needed, set it in the className.
22
22
  */
23
- size?: "small" | "normal" | "large";
23
+ size?: Size;
24
24
  /**
25
25
  * Select if the icon should be rendered as solid or outline.
26
- * Default value depends on the Size prop, small == solid, normal == solid, large == outline.
26
+ * Default value depends on the Size prop, small == solid, medium == solid, large == outline.
27
27
  * Trackunit icons might not support both outline and Solid.
28
28
  */
29
29
  type?: "solid" | "outline";
@@ -8,7 +8,7 @@ export interface SelectOption {
8
8
  value: string;
9
9
  options?: SelectOption[];
10
10
  }
11
- export declare type SelectSize = "small" | "default";
11
+ export declare type SelectSize = "small" | "medium";
12
12
  export interface ISelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
13
13
  /**
14
14
  * Label to be displayed.
@@ -1,11 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { CommonProps } from "../../common/CommonProps";
3
- export declare type SpinnerSize = "small" | "regular" | "large";
2
+ import { CommonProps, Size } from "../../common/CommonProps";
4
3
  export interface SpinnerProps extends CommonProps {
5
4
  /**
6
5
  * Defines the size of the spinner.
7
6
  */
8
- size?: SpinnerSize;
7
+ size?: Size;
9
8
  /**
10
9
  * When true, the spinner will be centered in the parent element using css grid.
11
10
  */
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  import { Colors } from "../../constants/colors";
4
- export declare type TagSize = "default" | "small";
4
+ export declare type TagSize = "small" | "medium";
5
5
  export interface TagProps extends CommonProps {
6
6
  /**
7
7
  * The color of the tag.
@@ -1,9 +1,8 @@
1
1
  import * as React from "react";
2
- import { CommonProps } from "../../common/CommonProps";
2
+ import { CommonProps, Size } from "../../common/CommonProps";
3
3
  export declare type TextType = "p" | "span" | "div";
4
- export declare type TextSize = "small" | "default" | "large";
5
4
  export declare type TextAlign = "left" | "center" | "right";
6
- export declare type TextWeight = "default" | "thick" | "bold";
5
+ export declare type TextWeight = "normal" | "thick" | "bold";
7
6
  export interface TextProps extends CommonProps {
8
7
  /**
9
8
  * Child nodes.
@@ -14,15 +13,15 @@ export interface TextProps extends CommonProps {
14
13
  */
15
14
  type?: TextType;
16
15
  /**
17
- * Size of element. Values can be "default", "small", or "large".
16
+ * Size of element. Values can be "small", "medium", or "large".
18
17
  */
19
- size?: TextSize;
18
+ size?: Size;
20
19
  /**
21
20
  * Alignment of the text. Values can be "left", "center", or "right".
22
21
  */
23
22
  align?: TextAlign;
24
23
  /**
25
- * Weight of the text. Values can be "default", "thick", or "bold".
24
+ * Weight of the text. Values can be "normal", "thick", or "bold".
26
25
  */
27
26
  weight?: TextWeight;
28
27
  /**
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  import "./Toggle.css";
4
- export declare type ToggleSize = "small" | "default";
4
+ export declare type ToggleSize = "small" | "medium";
5
5
  export interface ToggleProps extends CommonProps {
6
6
  /**
7
7
  * ID of the toggle.
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
- import { ButtonCommonProps, ButtonIntent, ButtonSize, ButtonType, ButtonVariant } from "../shared/ButtonProps";
2
+ import { Size } from "../../../common";
3
+ import { ButtonCommonProps, ButtonIntent, ButtonType, ButtonVariant } from "../shared/ButtonProps";
3
4
  export interface StyledButtonProps {
4
5
  $variant: ButtonVariant;
5
- $size: ButtonSize;
6
+ $size: Size;
6
7
  $square: boolean;
7
8
  $intent: ButtonIntent;
8
9
  $fullWidth: boolean;
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
+ import { Size } from "../../../common";
2
3
  import "../shared/Button.css";
3
- import { ButtonCommonProps, ButtonSize } from "../shared/ButtonProps";
4
+ import { ButtonCommonProps } from "../shared/ButtonProps";
4
5
  export interface IconButtonProps extends ButtonCommonProps {
5
6
  /**
6
7
  * The icon to display.
@@ -19,6 +20,6 @@ export interface IconButtonProps extends ButtonCommonProps {
19
20
  /**
20
21
  * The size of the button. Defaults to "small".
21
22
  */
22
- size?: ButtonSize;
23
+ size?: Size;
23
24
  }
24
25
  export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -1,9 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { CommonProps } from "../../../common/CommonProps";
2
+ import { CommonProps, Size } from "../../../common/CommonProps";
3
3
  export declare type ButtonVariant = "filled" | "transparent";
4
4
  export declare type ButtonIntent = "primary" | "secondary" | "danger" | "warning" | "tertiary";
5
5
  export declare type ButtonType = "button" | "submit";
6
- export declare type ButtonSize = "small" | "normal" | "large";
7
6
  export interface ButtonCommonProps extends CommonProps {
8
7
  onClick?: (event: React.MouseEvent<HTMLElement>) => void;
9
8
  /**
@@ -29,7 +28,7 @@ export interface ButtonCommonProps extends CommonProps {
29
28
  /**
30
29
  * The size of the button.
31
30
  */
32
- size?: ButtonSize;
31
+ size?: Size;
33
32
  /**
34
33
  * The link to be used for the button.
35
34
  */
@@ -1,8 +1,9 @@
1
- import { ButtonIntent, ButtonSize, ButtonVariant } from "./ButtonProps";
1
+ import { Size } from "../../../common";
2
+ import { ButtonIntent, ButtonVariant } from "./ButtonProps";
2
3
  interface ButtonProps {
3
4
  $intent: ButtonIntent;
4
5
  $variant: ButtonVariant;
5
- $size: ButtonSize;
6
+ $size: Size;
6
7
  }
7
8
  /**
8
9
  * Helper to get the needed classname from buttonProps.
package/index.css CHANGED
@@ -242,7 +242,7 @@
242
242
  transition-all;
243
243
  }
244
244
 
245
- &--default {
245
+ &--medium {
246
246
  @apply flex
247
247
  items-center
248
248
  p-1
package/index.js CHANGED
@@ -98,7 +98,7 @@ function __rest(s, e) {
98
98
 
99
99
  const Spinner = ({
100
100
  mode = "light",
101
- size = "regular",
101
+ size = "medium",
102
102
  centered = false,
103
103
  className,
104
104
  containerClassName,
@@ -129,7 +129,7 @@ const getSpinnerStyles = () => ({
129
129
  case "large":
130
130
  return tws`tu-spinner--large`;
131
131
 
132
- case "regular":
132
+ case "medium":
133
133
  default:
134
134
  return;
135
135
  }
@@ -214,7 +214,7 @@ const Button = React.forwardRef((_a, ref) => {
214
214
  intent = "primary",
215
215
  variant = "filled",
216
216
  type = "button",
217
- size = "normal",
217
+ size = "medium",
218
218
  square = false,
219
219
  dataTestId,
220
220
  title,
@@ -335,9 +335,9 @@ const activityColors = {
335
335
  const colors = Object.assign(Object.assign(Object.assign(Object.assign({}, generalColors), intentColors), criticalityColors), activityColors);
336
336
 
337
337
  const IconSizeClassMap = {
338
- small: tws`w-4`,
339
- normal: tws`w-5`,
340
- large: tws`w-6` // 24x24px
338
+ small: tws`tu-icon--small`,
339
+ medium: tws`tu-icon--medium`,
340
+ large: tws`tu-icon--large` // 24x24px
341
341
 
342
342
  };
343
343
  /**
@@ -398,72 +398,58 @@ const Icon$1 = ({
398
398
  }));
399
399
  };
400
400
  const LoadingDot = tw.span`
401
- relative
402
- aspect-square
403
-
404
- after:content-['']
405
- after:absolute
406
- after:h-2
407
- after:w-2
408
- after:bg-current
409
- after:rounded-full
410
- after:inset-1/2
411
- after:-translate-x-1/2
412
- after:-translate-y-1/2
413
- after:opacity-50
401
+ tu-loading-dot
414
402
  `;
415
403
  const Root$3 = tw.span`
416
- inline
417
- relative
418
-
404
+ tu-icon
419
405
  ${({
420
406
  $color
421
407
  }) => {
422
408
  switch ($color) {
423
409
  case colors.PRIMARY:
424
- return tws`text-primary-600`;
410
+ return tws`tu-icon--primary`;
425
411
 
426
412
  case colors.ACCENT:
427
- return tws`text-accent-600`;
413
+ return tws`tu-icon--accent`;
428
414
 
429
415
  case colors.NEUTRAL:
430
- return tws`text-neutral-600`;
416
+ return tws`tu-icon--neutral`;
431
417
 
432
418
  case colors.INFO:
433
- return tws`text-info-600`;
419
+ return tws`tu-icon--info`;
434
420
 
435
421
  case colors.SUCCESS:
436
- return tws`text-success-600`;
422
+ return tws`tu-icon--success`;
437
423
 
438
424
  case colors.WARNING:
439
- return tws`text-warning-600`;
425
+ return tws`tu-icon--warning`;
440
426
 
441
427
  case colors.DANGER:
442
- return tws`text-danger-600`;
428
+ return tws`tu-icon--danger`;
443
429
 
444
430
  case colors.GOOD:
445
- return tws`text-good-600`;
431
+ return tws`tu-icon--good`;
446
432
 
447
433
  case colors.LOW:
448
- return tws`text-low-600`;
434
+ return tws`tu-icon--low`;
449
435
 
450
436
  case colors.CRITICAL:
451
- return tws`text-critical-600`;
437
+ return tws`tu-icon--critical`;
452
438
 
453
439
  case colors.WORKING:
454
- return tws`text-working-600`;
440
+ return tws`tu-icon--working`;
455
441
 
456
442
  case colors.IDLE:
457
- return tws`text-idle-600`;
443
+ return tws`tu-icon--idle`;
458
444
 
459
445
  case colors.STOPPED:
460
- return tws`text-stopped-600`;
446
+ return tws`tu-icon--stopped`;
461
447
 
462
448
  case colors.UNKNOWN:
463
- return tws`text-unknown-600`;
449
+ return tws`tu-icon--unknown`;
464
450
 
465
451
  default:
466
- return "text-current";
452
+ return "tu-icon--default";
467
453
  }
468
454
  }}
469
455
  `;
@@ -516,9 +502,9 @@ const CustomIcon = tw(Icon$1)`
516
502
  const Text = ({
517
503
  children,
518
504
  type = "p",
519
- size = "default",
505
+ size = "medium",
520
506
  align = "left",
521
- weight = "default",
507
+ weight = "normal",
522
508
  underline = false,
523
509
  inverted = false,
524
510
  subtle = false,
@@ -664,7 +650,7 @@ const Alert = ({
664
650
  }, {
665
651
  children: title !== null && title !== void 0 ? title : children
666
652
  })), children && jsx(Description$2, Object.assign({
667
- weight: !title ? "bold" : "default",
653
+ weight: !title ? "bold" : "normal",
668
654
  "$hasTitle": !!title
669
655
  }, {
670
656
  children: children
@@ -675,7 +661,7 @@ const Alert = ({
675
661
  }, {
676
662
  children: title !== null && title !== void 0 ? title : children
677
663
  })), children && jsx(Description$2, Object.assign({
678
- weight: !title ? "bold" : "default",
664
+ weight: !title ? "bold" : "normal",
679
665
  "$hasTitle": !!title
680
666
  }, {
681
667
  children: children
@@ -816,7 +802,7 @@ const Badge = _a => {
816
802
  max,
817
803
  hideZero = false,
818
804
  dataTestId,
819
- size = "default"
805
+ size = "medium"
820
806
  } = _a;
821
807
  __rest(_a, ["color", "subtle", "className", "count", "max", "hideZero", "dataTestId", "size"]);
822
808
 
@@ -843,7 +829,7 @@ const getSizeModifierClass$1 = () => ({
843
829
  }) => {
844
830
  const sizeModifierClass = {
845
831
  large: tws`tu-badge--large`,
846
- default: ""
832
+ medium: ""
847
833
  };
848
834
  return sizeModifierClass[$size];
849
835
  };
@@ -899,7 +885,7 @@ const BaseInput = React.forwardRef((_a, ref) => {
899
885
  addonBefore,
900
886
  addonAfter,
901
887
  actions,
902
- fieldSize = "default"
888
+ fieldSize = "medium"
903
889
  } = _a,
904
890
  rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize"]);
905
891
 
@@ -1324,7 +1310,8 @@ const Chart = ({
1324
1310
  merge = true,
1325
1311
  loadingOption,
1326
1312
  timezoneLabel,
1327
- renderer = "canvas"
1313
+ renderer = "canvas",
1314
+ dataTestId
1328
1315
  }) => {
1329
1316
  var _a, _b;
1330
1317
 
@@ -1369,7 +1356,8 @@ const Chart = ({
1369
1356
  style: {
1370
1357
  height: (_a = style === null || style === void 0 ? void 0 : style.height) !== null && _a !== void 0 ? _a : "300px",
1371
1358
  width: (_b = style === null || style === void 0 ? void 0 : style.width) !== null && _b !== void 0 ? _b : "100%"
1372
- }
1359
+ },
1360
+ "data-testid": dataTestId
1373
1361
  }, {
1374
1362
  children: showLoading ? jsxs(SpinnerContainer, {
1375
1363
  children: [jsx(Spinner, {
@@ -1631,7 +1619,7 @@ const Collapse = ({
1631
1619
  size: "small",
1632
1620
  "$expanded": expanded
1633
1621
  }),
1634
- size: "normal",
1622
+ size: "medium",
1635
1623
  variant: "transparent",
1636
1624
  intent: "secondary"
1637
1625
  })]
@@ -2047,7 +2035,7 @@ const DateInput = forwardRef((_a, ref) => {
2047
2035
  suffix: jsx(Icon$1, {
2048
2036
  dataTestId: "calendar",
2049
2037
  name: "CalendarIcon",
2050
- size: "normal",
2038
+ size: "medium",
2051
2039
  type: "solid",
2052
2040
  onClick: !disabled ? onShow : undefined,
2053
2041
  forwardedRef: targetRef
@@ -2141,7 +2129,7 @@ const PopoverListItem = ({
2141
2129
  children: [prefix && jsx("div", {
2142
2130
  children: prefix
2143
2131
  }), jsx(StyledText$2, Object.assign({
2144
- weight: selected ? "bold" : "default",
2132
+ weight: selected ? "bold" : "normal",
2145
2133
  "$selected": selected
2146
2134
  }, {
2147
2135
  children: children
@@ -2318,7 +2306,7 @@ const Tip = _a => {
2318
2306
  }, {
2319
2307
  children: jsx(Icon$1, Object.assign({
2320
2308
  name: "QuestionMarkCircleIcon",
2321
- size: "normal",
2309
+ size: "medium",
2322
2310
  dataTestId: `${dataTestId}-icon`
2323
2311
  }, iconProps))
2324
2312
  }))
@@ -3156,7 +3144,7 @@ const Tag = React.forwardRef((_a, ref) => {
3156
3144
  className,
3157
3145
  dataTestId,
3158
3146
  children,
3159
- size = "default",
3147
+ size = "medium",
3160
3148
  onClose,
3161
3149
  color = "primary"
3162
3150
  } = _a;
@@ -3182,7 +3170,7 @@ const Tag = React.forwardRef((_a, ref) => {
3182
3170
  style: {
3183
3171
  "-webkit-transition": "-webkit-transform 0.150s"
3184
3172
  },
3185
- className: size === "default" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
3173
+ className: size === "medium" ? tws`tu-tag__icon` : tws`tu-tag__icon tu-tag__icon--small`
3186
3174
  })
3187
3175
  }))]
3188
3176
  }));
@@ -3193,7 +3181,7 @@ const getSizeModifierClass = () => ({
3193
3181
  $withXIcon
3194
3182
  }) => {
3195
3183
  const tagSizeModifierClass = {
3196
- default: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
3184
+ medium: $withXIcon ? tws`tu-tag--with-icon ` : tws` `,
3197
3185
  small: $withXIcon ? tws`tu-tag--small tu-tag--with-icon` : tws`tu-tag--small`
3198
3186
  };
3199
3187
  return tagSizeModifierClass[$size];
@@ -3629,7 +3617,7 @@ const useCustomComponents = components => {
3629
3617
  const CreatableSelect = _a => {
3630
3618
  var {
3631
3619
  dataTestId,
3632
- size = "default",
3620
+ size = "medium",
3633
3621
  id,
3634
3622
  label,
3635
3623
  hideLabel,
@@ -3686,7 +3674,7 @@ const CreatableSelect = _a => {
3686
3674
  const Select = _a => {
3687
3675
  var {
3688
3676
  dataTestId,
3689
- size = "default",
3677
+ size = "medium",
3690
3678
  id,
3691
3679
  label,
3692
3680
  hideLabel,
@@ -4095,7 +4083,7 @@ const Toggle = React.forwardRef(({
4095
4083
  toggled = false,
4096
4084
  onChange,
4097
4085
  disabled,
4098
- size = "default",
4086
+ size = "medium",
4099
4087
  id,
4100
4088
  tabIndex,
4101
4089
  required,
@@ -4178,7 +4166,7 @@ tu-toggle__switch-container
4178
4166
  }) => $disabled && tws`tu-toggle--disabled`};
4179
4167
  ${({
4180
4168
  $size
4181
- }) => $size === "small" ? tws`tu-toggle--small` : tws`tu-toggle--default`};
4169
+ }) => $size === "small" ? tws`tu-toggle--small` : tws`tu-toggle--medium`};
4182
4170
  ${({
4183
4171
  $toggled
4184
4172
  }) => $toggled && tws`tu-toggle--toggled`}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.122",
3
+ "version": "0.0.124",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -20,7 +20,8 @@
20
20
  "@popperjs/core": "^2.11.4",
21
21
  "history": "^5.3.0",
22
22
  "react-router-dom": "^6.2.2",
23
- "react-select": "^5.4.0"
23
+ "react-select": "^5.4.0",
24
+ "jest-canvas-mock": "^2.4.0"
24
25
  },
25
26
  "module": "./index.js",
26
27
  "main": "./index.js",