@trackunit/react-components 0.0.1-alpha-59a0a75488.0

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.
Files changed (143) hide show
  1. package/README.md +22 -0
  2. package/common/CommonProps.d.ts +12 -0
  3. package/common/LegacyComponentStory.d.ts +7 -0
  4. package/common/StorybookProps.d.ts +6 -0
  5. package/common/index.d.ts +3 -0
  6. package/common/useContainerProps.d.ts +16 -0
  7. package/components/ActionButton/ActionButton.d.ts +30 -0
  8. package/components/ActionButton/index.d.ts +1 -0
  9. package/components/Alert/Alert.d.ts +53 -0
  10. package/components/Alert/index.d.ts +1 -0
  11. package/components/Badge/Badge.d.ts +47 -0
  12. package/components/Badge/index.d.ts +1 -0
  13. package/components/BaseInput/BaseInput.d.ts +62 -0
  14. package/components/BaseInput/index.d.ts +1 -0
  15. package/components/Card/Card.d.ts +45 -0
  16. package/components/Card/CardBody.d.ts +32 -0
  17. package/components/Card/CardFooter.d.ts +21 -0
  18. package/components/Card/CardHeader.d.ts +43 -0
  19. package/components/Card/DensityContainer.d.ts +30 -0
  20. package/components/Card/index.d.ts +5 -0
  21. package/components/Chart/Chart.d.ts +81 -0
  22. package/components/Chart/index.d.ts +1 -0
  23. package/components/Checkbox/CheckIcon.d.ts +12 -0
  24. package/components/Checkbox/Checkbox.d.ts +40 -0
  25. package/components/Checkbox/IndeterminateIcon.d.ts +10 -0
  26. package/components/Checkbox/index.d.ts +1 -0
  27. package/components/Collapse/Collapse.d.ts +28 -0
  28. package/components/Collapse/index.d.ts +1 -0
  29. package/components/CopyableText/CopyableText.d.ts +21 -0
  30. package/components/CopyableText/index.d.ts +1 -0
  31. package/components/DateField/DateField.d.ts +19 -0
  32. package/components/DateInput/DateInput.d.ts +28 -0
  33. package/components/DayPicker/DayPicker.d.ts +28 -0
  34. package/components/DayPicker/DayPickerPopover.d.ts +23 -0
  35. package/components/DayPicker/DayRangePicker.d.ts +18 -0
  36. package/components/DayPicker/index.d.ts +21 -0
  37. package/components/DayPicker/useLocale.d.ts +8 -0
  38. package/components/EmailInput/EmailInput.d.ts +20 -0
  39. package/components/FormGroup/FormGroup.d.ts +38 -0
  40. package/components/Heading/Heading.d.ts +28 -0
  41. package/components/Heading/index.d.ts +1 -0
  42. package/components/Icon/Icon.d.ts +51 -0
  43. package/components/Indicator/Indicator.d.ts +42 -0
  44. package/components/Indicator/index.d.ts +1 -0
  45. package/components/Label/Label.d.ts +34 -0
  46. package/components/Label/index.d.ts +1 -0
  47. package/components/LegendItem/LegendItem.d.ts +17 -0
  48. package/components/LegendItem/index.d.ts +1 -0
  49. package/components/Menu/MenuItem.d.ts +58 -0
  50. package/components/Menu/MenuList.d.ts +34 -0
  51. package/components/Menu/index.d.ts +2 -0
  52. package/components/Modal/Modal.d.ts +32 -0
  53. package/components/Modal/ModalBackdrop.d.ts +13 -0
  54. package/components/Modal/index.d.ts +3 -0
  55. package/components/Modal/useModal.d.ts +21 -0
  56. package/components/NumberField/NumberField.d.ts +19 -0
  57. package/components/NumberInput/NumberInput.d.ts +12 -0
  58. package/components/PageHeader/PageHeader.d.ts +47 -0
  59. package/components/PageHeader/index.d.ts +1 -0
  60. package/components/Pagination/Pagination.d.ts +71 -0
  61. package/components/PhoneInput/PhoneInput.d.ts +20 -0
  62. package/components/Popover/AnimatedPopover.d.ts +43 -0
  63. package/components/Popover/PopoverList.d.ts +12 -0
  64. package/components/Popover/PopoverListItem.d.ts +30 -0
  65. package/components/Popover/PopoverTitle.d.ts +20 -0
  66. package/components/Popover/index.d.ts +5 -0
  67. package/components/Popover/usePopover.d.ts +42 -0
  68. package/components/Prompt/Prompt.d.ts +20 -0
  69. package/components/Prompt/index.d.ts +1 -0
  70. package/components/RadioGroup/RadioGroup.d.ts +57 -0
  71. package/components/RadioGroup/RadioGroupContext.d.ts +11 -0
  72. package/components/RadioGroup/RadioItem.d.ts +24 -0
  73. package/components/RadioGroup/index.d.ts +2 -0
  74. package/components/SectionHeader/SectionHeader.d.ts +24 -0
  75. package/components/SectionHeader/index.d.ts +1 -0
  76. package/components/Select/CreatableSelect.d.ts +38 -0
  77. package/components/Select/FieldContainer.d.ts +20 -0
  78. package/components/Select/Select.d.ts +18 -0
  79. package/components/Select/SelectMenuItem/SelectMenuItem.d.ts +49 -0
  80. package/components/Select/TagWithWidth.d.ts +17 -0
  81. package/components/Select/TagsContainer.d.ts +45 -0
  82. package/components/Select/index.d.ts +7 -0
  83. package/components/Select/shared.d.ts +15 -0
  84. package/components/Select/useCustomComponents.d.ts +19 -0
  85. package/components/Select/useCustomStyles.d.ts +14 -0
  86. package/components/Select/useSelect.d.ts +143 -0
  87. package/components/SkeletonLines/SkeletonLines.d.ts +25 -0
  88. package/components/SkeletonLines/index.d.ts +1 -0
  89. package/components/Spacer/Spacer.d.ts +20 -0
  90. package/components/Spacer/index.d.ts +1 -0
  91. package/components/Spinner/Spinner.d.ts +37 -0
  92. package/components/Spinner/index.d.ts +1 -0
  93. package/components/Tag/Tag.d.ts +39 -0
  94. package/components/Tag/index.d.ts +1 -0
  95. package/components/Text/Text.d.ts +58 -0
  96. package/components/Text/index.d.ts +1 -0
  97. package/components/TextArea/TextArea.d.ts +30 -0
  98. package/components/TextArea/index.d.ts +1 -0
  99. package/components/TextAreaField/TextAreaField.d.ts +19 -0
  100. package/components/TextAreaField/index.d.ts +1 -0
  101. package/components/TextField/TextField.d.ts +24 -0
  102. package/components/TextField/TextLenghtIndicator.d.ts +19 -0
  103. package/components/TextField/index.d.ts +1 -0
  104. package/components/TextInput/TextInput.d.ts +12 -0
  105. package/components/Timeline/Timeline.d.ts +30 -0
  106. package/components/Tip/Tip.d.ts +34 -0
  107. package/components/Tip/index.d.ts +1 -0
  108. package/components/Toggle/Toggle.d.ts +57 -0
  109. package/components/Toggle/index.d.ts +1 -0
  110. package/components/Tooltip/Tooltip.d.ts +48 -0
  111. package/components/Tooltip/index.d.ts +1 -0
  112. package/components/ValueBar/ValueBar.d.ts +44 -0
  113. package/components/ValueBar/ValueBarHelper.d.ts +35 -0
  114. package/components/ValueBar/ValueBarTypes.d.ts +9 -0
  115. package/components/ValueBar/index.d.ts +3 -0
  116. package/components/buttons/Button/Button.d.ts +48 -0
  117. package/components/buttons/IconButton/IconButton.d.ts +25 -0
  118. package/components/buttons/StarButton/StarButton.d.ts +13 -0
  119. package/components/buttons/index.d.ts +4 -0
  120. package/components/buttons/shared/ButtonProps.d.ts +40 -0
  121. package/components/buttons/shared/helpers.d.ts +20 -0
  122. package/components/index.d.ts +44 -0
  123. package/components/theme/DefaultTheme.d.ts +2 -0
  124. package/components/theme/index.d.ts +1 -0
  125. package/hooks/index.d.ts +3 -0
  126. package/hooks/useDebounce.d.ts +8 -0
  127. package/hooks/useLocalStorage.d.ts +9 -0
  128. package/hooks/useTimeout.d.ts +15 -0
  129. package/index.css +488 -0
  130. package/index.d.ts +4 -0
  131. package/index.js +5553 -0
  132. package/layout/helper/MinTopFullContentLayout.d.ts +18 -0
  133. package/layout/index.d.ts +7 -0
  134. package/layout/responsive/FilterListMapLayout.d.ts +22 -0
  135. package/layout/responsive/FullWidthRepeatingLayout.d.ts +19 -0
  136. package/layout/responsive/GridArea.d.ts +13 -0
  137. package/layout/responsive/IntrinsicallyResponsiveGrid.d.ts +30 -0
  138. package/layout/responsive/TitleNavContentLayout.d.ts +12 -0
  139. package/layout/responsive/TwoColumnLayout.d.ts +12 -0
  140. package/package.json +31 -0
  141. package/test-config/jest.setup.d.ts +1 -0
  142. package/test-utils/hooks.d.ts +4 -0
  143. package/test-utils/test-utils.d.ts +5 -0
@@ -0,0 +1,48 @@
1
+ import * as React from "react";
2
+ import { PopoverPlacement } from "../Popover";
3
+ import { TextType } from "../Text";
4
+ export interface TooltipProps {
5
+ /**
6
+ * The text to be displayed in the tooltip.
7
+ */
8
+ label: string | React.ReactNode;
9
+ /**
10
+ * Where the tooltip should be placed.
11
+ */
12
+ placement?: PopoverPlacement;
13
+ /**
14
+ * Child nodes
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Id of test component.
19
+ */
20
+ dataTestId?: string;
21
+ /**
22
+ * Whether the tooltip is disabled or not.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * To select either "light" or "dark" mode.
27
+ */
28
+ mode?: "light" | "dark";
29
+ /**
30
+ * Offset value of the tooltip.
31
+ */
32
+ offset?: [number, number];
33
+ /**
34
+ * Additional classes to the component.
35
+ */
36
+ className?: string;
37
+ /**
38
+ * Type of content.
39
+ */
40
+ contentTextType?: TextType;
41
+ }
42
+ /**
43
+ * The Tooltip component is used to show helpful tips or contextual information to the users.
44
+ *
45
+ * @param {TooltipProps} props - The props for the Tooltip component
46
+ * @returns {JSX.Element} Tooltip component
47
+ */
48
+ export declare const Tooltip: ({ label, placement, children, dataTestId, disabled, mode, offset, className, contentTextType, }: TooltipProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Tooltip";
@@ -0,0 +1,44 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "../../common";
3
+ import { LevelColors } from "./ValueBarTypes";
4
+ export interface ValueBarProps extends CommonProps {
5
+ /**
6
+ * Value to display.
7
+ */
8
+ value: number;
9
+ /**
10
+ * Minimum value visible on the bar.
11
+ */
12
+ min?: number;
13
+ /**
14
+ * Maximum value visible on the bar.
15
+ */
16
+ max?: number;
17
+ /**
18
+ * Value unit. Visible only together with value if showValue parameter is set to true.
19
+ */
20
+ unit?: string;
21
+ /**
22
+ * Size of the tooltip
23
+ */
24
+ size?: "small" | "large";
25
+ /**
26
+ * Custom level colors. If this param is not provided then default values are used.
27
+ */
28
+ levelColors?: LevelColors;
29
+ /**
30
+ * Custom value color. If this param is not provided then default value is used.
31
+ */
32
+ valueColor?: string;
33
+ /**
34
+ * Show value with unit (if provided) on the bar in large version or after the bar in the small version.
35
+ */
36
+ showValue?: boolean;
37
+ }
38
+ /**
39
+ * ValueBar component is used to display value on a colorful bar within provided range.
40
+ *
41
+ * @param {ValueBarProps} props - The props for the ValueBar component
42
+ * @returns {JSX.Element} ValueBar component
43
+ */
44
+ export declare const ValueBar: ({ value, min, max, unit, size, levelColors, valueColor, showValue, className, dataTestId, }: ValueBarProps) => JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { LevelColors } from "./ValueBarTypes";
2
+ /**
3
+ * Helper function to get normalized score in range 0-1 used by the ValueBar
4
+ *
5
+ * @param {number} value - value for which score should be returned
6
+ * @param {number} min - min range value
7
+ * @param {number} max - max range value
8
+ * @returns {number} normalized score
9
+ */
10
+ export declare const getScore: (value: number, min: number, max: number) => number;
11
+ /**
12
+ * Helper function to get default color used by the ValueBar
13
+ *
14
+ * @param {number} score - score number for which color should be returned
15
+ * @returns {string} color value
16
+ */
17
+ export declare const getDefaultFillColor: (score: number) => string;
18
+ /**
19
+ * Helper function to get custom color used by the ValueBar
20
+ *
21
+ * @param {number} score - score number for which color should be returned
22
+ * @param {LevelColors} levelColors - custom colors and levels definitions
23
+ * @returns {string} color value
24
+ */
25
+ export declare const getFillColor: (score: number, levelColors: LevelColors) => string;
26
+ /**
27
+ * Helper function to get color used by the ValueBar
28
+ *
29
+ * @param {number} value - value for which color should be returned
30
+ * @param {number} min - min range value
31
+ * @param {number} max - max range value
32
+ * @param {LevelColors} levelColors - level colors used to coloring the bar
33
+ * @returns {JSX.Element} ValueBar component
34
+ */
35
+ export declare const getValueBarColorByValue: (value: number, min: number, max: number, levelColors: LevelColors) => string;
@@ -0,0 +1,9 @@
1
+ export interface LevelColor {
2
+ level?: number;
3
+ color: string;
4
+ }
5
+ export interface LevelColors {
6
+ low?: LevelColor;
7
+ medium?: LevelColor;
8
+ high?: LevelColor;
9
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./ValueBar";
2
+ export * from "./ValueBarTypes";
3
+ export { getValueBarColorByValue } from "./ValueBarHelper";
@@ -0,0 +1,48 @@
1
+ import * as React from "react";
2
+ import { Size } from "../../../common";
3
+ import { ButtonColor, ButtonCommonProps, ButtonType, ButtonVariant } from "../shared/ButtonProps";
4
+ export interface StyledButtonProps {
5
+ $variant: ButtonVariant;
6
+ $size: Size;
7
+ $square: boolean;
8
+ $color: ButtonColor;
9
+ $fullWidth: boolean;
10
+ }
11
+ export interface ButtonProps extends ButtonCommonProps {
12
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
13
+ /**
14
+ * Child nodes. Can be used to pass in text to be displayed on the button.
15
+ */
16
+ children?: React.ReactNode;
17
+ /**
18
+ * Whether button is fullWidth or not.
19
+ */
20
+ fullWidth?: boolean;
21
+ /**
22
+ * The button prefix.
23
+ */
24
+ prefix?: React.ReactNode;
25
+ /**
26
+ * The button suffix.
27
+ */
28
+ suffix?: React.ReactNode;
29
+ /**
30
+ * The type of the button. Values can be "submit" or "button".
31
+ */
32
+ type?: ButtonType;
33
+ /**
34
+ * The element type the button will be rendered as.
35
+ */
36
+ renderAs?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
37
+ /**
38
+ * The Id of the form to submit, for button type submit
39
+ */
40
+ form?: string;
41
+ }
42
+ /**
43
+ * Buttons allow users to perform an action when triggered.
44
+ *
45
+ * @param {ButtonProps} props - The props for the Button component
46
+ * @returns {JSX.Element} Button component
47
+ */
48
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,25 @@
1
+ import * as React from "react";
2
+ import { Size } from "../../../common";
3
+ import "../shared/Button.css";
4
+ import { ButtonCommonProps } from "../shared/ButtonProps";
5
+ export interface IconButtonProps extends ButtonCommonProps {
6
+ /**
7
+ * The icon to display.
8
+ */
9
+ icon: React.ReactNode;
10
+ /**
11
+ * Whether the button is circular or not.
12
+ */
13
+ circular?: boolean;
14
+ /**
15
+ * The element type the button will be rendered as.
16
+ *
17
+ * @memberof IconButtonProps
18
+ */
19
+ renderAs?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
20
+ /**
21
+ * The size of the button. Defaults to "small".
22
+ */
23
+ size?: Size;
24
+ }
25
+ export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ interface StarButtonProps {
3
+ starred: boolean;
4
+ onClick: (e: React.MouseEvent) => void;
5
+ }
6
+ /**
7
+ * The StarButton component is used for favorite actions or similar.
8
+ *
9
+ * @param {StarButtonProps} props - The props for the StarButton component
10
+ * @returns {JSX.Element} StarButton component
11
+ */
12
+ export declare const StarButton: ({ starred, onClick }: StarButtonProps) => JSX.Element;
13
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from "./Button/Button";
2
+ export * from "./IconButton/IconButton";
3
+ export * from "./shared/ButtonProps";
4
+ export * from "./StarButton/StarButton";
@@ -0,0 +1,40 @@
1
+ /// <reference types="react" />
2
+ import { GeneralColors, IntentColors } from "@trackunit/ui-design-tokens";
3
+ import { CommonProps, Size } from "../../../common/CommonProps";
4
+ export declare type ButtonVariant = "filled" | "transparent";
5
+ export declare type ButtonColor = Extract<GeneralColors, "primary" | "secondary"> | Extract<IntentColors, "info" | "warning" | "danger"> | "tertiary";
6
+ export declare type ButtonType = "button" | "submit";
7
+ export interface ButtonCommonProps extends CommonProps {
8
+ onClick?: (event: React.MouseEvent<HTMLElement>) => void;
9
+ /**
10
+ * Whether the button is loading.
11
+ */
12
+ loading?: boolean;
13
+ /**
14
+ * Whether the button is disabled.
15
+ */
16
+ disabled?: boolean;
17
+ /**
18
+ * Button with square aspect ratio.
19
+ */
20
+ square?: boolean;
21
+ /**
22
+ * The button's variant. Values are filled, transparent, plain.
23
+ */
24
+ color?: ButtonColor;
25
+ /**
26
+ * The variant of the button.
27
+ */
28
+ variant?: ButtonVariant;
29
+ /**
30
+ * The size of the button.
31
+ */
32
+ size?: Size;
33
+ /**
34
+ * The link to be used for the button.
35
+ */
36
+ to?: string;
37
+ title?: string;
38
+ tabIndex?: number;
39
+ role?: string;
40
+ }
@@ -0,0 +1,20 @@
1
+ import { Size } from "../../../common";
2
+ import { ButtonColor, ButtonVariant } from "./ButtonProps";
3
+ interface ButtonProps {
4
+ $color: ButtonColor;
5
+ $variant: ButtonVariant;
6
+ $size: Size;
7
+ }
8
+ /**
9
+ * Helper to get the needed classname from buttonProps.
10
+ *
11
+ * @returns {string} - Classnames for the button
12
+ */
13
+ export declare const getStyles: () => ({ $color, $variant }: ButtonProps) => any;
14
+ /**
15
+ * Helper to get the needed classname for padding.
16
+ *
17
+ * @returns {string} - The correct class for setting padding.
18
+ */
19
+ export declare const getPadding: () => ({ $size }: ButtonProps) => string;
20
+ export {};
@@ -0,0 +1,44 @@
1
+ export * from "./ActionButton";
2
+ export * from "./Alert";
3
+ export * from "./Badge";
4
+ export * from "./BaseInput";
5
+ export * from "./buttons";
6
+ export * from "./Card";
7
+ export * from "./Chart";
8
+ export * from "./Checkbox";
9
+ export * from "./Collapse";
10
+ export * from "./CopyableText";
11
+ export * from "./DateField/DateField";
12
+ export * from "./DateInput/DateInput";
13
+ export * from "./DayPicker";
14
+ export * from "./FormGroup/FormGroup";
15
+ export * from "./Heading";
16
+ export * from "./Icon/Icon";
17
+ export * from "./Indicator";
18
+ export * from "./Label";
19
+ export * from "./LegendItem";
20
+ export * from "./Menu";
21
+ export * from "./Modal";
22
+ export * from "./NumberField/NumberField";
23
+ export * from "./NumberInput/NumberInput";
24
+ export * from "./PageHeader";
25
+ export * from "./Pagination/Pagination";
26
+ export * from "./Popover";
27
+ export * from "./Prompt";
28
+ export * from "./RadioGroup";
29
+ export * from "./SectionHeader";
30
+ export * from "./Select";
31
+ export * from "./SkeletonLines";
32
+ export * from "./Spacer";
33
+ export * from "./Spinner";
34
+ export * from "./Tag";
35
+ export * from "./Text";
36
+ export * from "./TextArea";
37
+ export * from "./TextAreaField";
38
+ export * from "./TextField";
39
+ export * from "./TextInput/TextInput";
40
+ export * from "./Timeline/Timeline";
41
+ export * from "./Tip";
42
+ export * from "./Toggle";
43
+ export * from "./Tooltip";
44
+ export * from "./ValueBar";
@@ -0,0 +1,2 @@
1
+ import { Tokens } from "@trackunit/ui-design-tokens";
2
+ export declare const defaultTheme: Tokens;
@@ -0,0 +1 @@
1
+ export * from "./DefaultTheme";
@@ -0,0 +1,3 @@
1
+ export * from "./useDebounce";
2
+ export * from "./useLocalStorage";
3
+ export * from "./useTimeout";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The useDebounce hook works like useState, but adds a delay where previous values will be ignored.
3
+ *
4
+ * @param {any} value The value to set
5
+ * @param {number} delay The debounce time
6
+ * @returns {any} value The latest values received
7
+ */
8
+ export declare const useDebounce: <T>(value: T, delay?: number) => T;
@@ -0,0 +1,9 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ /**
3
+ * The useLocalStorage hook works like useState, but saves to localstorage.
4
+ *
5
+ * @param {string} key - The key the values is saved under.
6
+ * @param {string | null | undefined} initialValue - The initial value for the state/local storage item
7
+ * @returns {string | null | undefined} value
8
+ */
9
+ export declare const useLocalStorage: <TValue = string | null | undefined>(key: string, initialValue?: TValue | undefined) => [TValue | null, Dispatch<SetStateAction<TValue | null>>, () => void];
@@ -0,0 +1,15 @@
1
+ interface UseTimeoutProps {
2
+ onTimeout: () => void;
3
+ duration: number;
4
+ }
5
+ /**
6
+ * The useTimeout hook.
7
+ *
8
+ * @param {UseTimeoutProps} props The props
9
+ * @returns {{ startTimeout: () => void; stopTimeout: () => void; }} return
10
+ */
11
+ export declare const useTimeout: ({ onTimeout, duration }: UseTimeoutProps) => {
12
+ startTimeout: () => void;
13
+ stopTimeout: () => void;
14
+ };
15
+ export {};