@trackunit/react-components 0.0.99 → 0.0.102

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.
@@ -16,19 +16,19 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
16
16
  */
17
17
  suffix?: React.ReactNode;
18
18
  /**
19
- * An React element to render in a seperate container before the text in the input.
19
+ * An React element to render in a separate container before the text in the input.
20
20
  * This is typically used to render text.
21
21
  * For icons, please concider using the prefix prop.
22
22
  */
23
23
  addonBefore?: React.ReactNode;
24
24
  /**
25
- * An React element to render in a seperate container after the text in the input.
25
+ * An React element to render in a separate container after the text in the input.
26
26
  * This is typically used to render text.
27
27
  * For icons, please concider using the suffix prop.
28
28
  */
29
29
  addonAfter?: React.ReactNode;
30
30
  /**
31
- * An ReactNode to render at the end of the input field befire the addonAfter.
31
+ * An ReactNode to render at the end of the input field before the addonAfter.
32
32
  * Mainly meant for the icon button actions for special input types.
33
33
  */
34
34
  actions?: React.ReactNode;
@@ -38,7 +38,7 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
38
38
  */
39
39
  fieldSize?: FieldSize;
40
40
  /**
41
- * If ture the field is rendered in its invalid state.
41
+ * If true the field is rendered in its invalid state.
42
42
  */
43
43
  isInvalid?: boolean;
44
44
  /**
@@ -3,10 +3,6 @@ import { CommonProps } from "../../common/CommonProps";
3
3
  export declare const ROLE_CARD = "region";
4
4
  declare type Overflow = "visible" | "hidden" | "scroll" | "auto";
5
5
  export interface CardProps extends CommonProps {
6
- children?: React.ReactNode;
7
- onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
8
- onMouseEnter?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
9
- onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
10
6
  /**
11
7
  * Whether the card should have full height or not.
12
8
  */
@@ -16,15 +12,31 @@ export interface CardProps extends CommonProps {
16
12
  */
17
13
  overflow?: Overflow;
18
14
  /**
15
+ * The css grid area to place the card.
19
16
  *
20
17
  * @deprecated Use tailwind based grid layouts instead.
21
- * @memberof CardProps
22
18
  */
23
19
  gridArea?: string;
20
+ /**
21
+ * Children to show in the card
22
+ */
23
+ children?: React.ReactNode;
24
+ /**
25
+ * A Click handler function
26
+ */
27
+ onClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
28
+ /**
29
+ * A MouseEnter handler function
30
+ */
31
+ onMouseEnter?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
32
+ /**
33
+ * A MouseLEave handler function
34
+ */
35
+ onMouseLeave?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
24
36
  }
25
37
  /**
26
- * The Card component is a container for ui elements.
27
- * Is also used for modals etc.
38
+ * The Card component is a container for ui elements, and is the main component of the modal.
39
+ * To get the most out of the Card use it in combination with the CardHeader, CardBody and CardFooter.
28
40
  *
29
41
  * @param {CardProps} props - The props for the Card component
30
42
  * @returns {JSX.Element} Card component
@@ -1,13 +1,23 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps, Density } from "../../common/CommonProps";
3
3
  declare type Overflow = "visible" | "hidden" | "scroll" | "auto" | "inherit";
4
- interface CardContentProps extends CommonProps {
4
+ export interface CardBodyProps extends CommonProps {
5
+ /**
6
+ * Tells the body how to handle overflowing elements.
7
+ * Directly mapped to the overflow css property.
8
+ */
5
9
  overflow?: Overflow;
10
+ /**
11
+ * Sets gap, padding and margin.
12
+ */
6
13
  density?: Density;
7
14
  /**
8
15
  * Set gap to be 0px (not preferable)
9
16
  */
10
17
  disableGap?: boolean;
18
+ /**
19
+ * Child elements to render in the body
20
+ */
11
21
  children: React.ReactNode | null;
12
22
  }
13
23
  /**
@@ -15,8 +25,8 @@ interface CardContentProps extends CommonProps {
15
25
  *
16
26
  * @summary For applying padding and gap to a Card.
17
27
  * @description The padding must live here, and not on the Card itself, as to not inset the scrollbar in case of overflow
18
- * @param {CardContentProps} props - The props for the CardBody component
28
+ * @param {CardBodyProps} props - The props for the CardBody component
19
29
  * @returns {JSX.Element} CardBody component
20
30
  */
21
- export declare const CardBody: ({ density, overflow, children, dataTestId, className, disableGap, }: CardContentProps) => JSX.Element;
31
+ export declare const CardBody: ({ density, overflow, children, dataTestId, className, disableGap, }: CardBodyProps) => JSX.Element;
22
32
  export {};
@@ -1,8 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps, Density } from "../../common/CommonProps";
3
- interface CardFooterProps extends CommonProps {
4
- children?: React.ReactNode | null;
3
+ export interface CardFooterProps extends CommonProps {
4
+ /**
5
+ * Sets gap, padding and margin.
6
+ */
5
7
  density?: Density;
8
+ /**
9
+ * Element to render in the footer
10
+ */
11
+ children?: React.ReactNode | null;
6
12
  }
7
13
  /**
8
14
  * A simple footer intended to use with Cards and Modals.
@@ -13,4 +19,3 @@ interface CardFooterProps extends CommonProps {
13
19
  * @returns {JSX.Element} CardFooter component
14
20
  */
15
21
  export declare const CardFooter: ({ dataTestId, className, children, density }: CardFooterProps) => JSX.Element;
16
- export {};
@@ -1,8 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps, Density } from "../../common/CommonProps";
3
3
  import { HeadingVariant } from "../Heading/Heading";
4
- interface CardHeaderProps extends CommonProps {
5
- /** The text to show in the modal main heading */
4
+ export interface CardHeaderProps extends CommonProps {
5
+ /**
6
+ * The text to show in the Cards main heading
7
+ */
6
8
  heading: string;
7
9
  /**
8
10
  * The variant/size of the heading.
@@ -13,12 +15,24 @@ interface CardHeaderProps extends CommonProps {
13
15
  headingVariant?: HeadingVariant;
14
16
  /** Adds an extra heading below the main heading. */
15
17
  subHeading?: string;
16
- /** Function to call when the close button is clicked */
17
- onClose?: () => void;
18
- children?: React.ReactNode | null;
18
+ /**
19
+ * Items to render next to the heading
20
+ */
19
21
  accessories?: React.ReactNode;
22
+ /**
23
+ * Sets gap, padding and margin.
24
+ */
20
25
  density?: Density;
26
+ /**
27
+ * Wether or not a seperator line should be rendered
28
+ */
21
29
  showSeparator?: boolean;
30
+ /** Function to call when the close button is clicked */
31
+ onClose?: () => void;
32
+ /**
33
+ * Children to render in the header
34
+ */
35
+ children?: React.ReactNode | null;
22
36
  }
23
37
  /**
24
38
  * Header for Cards and Modals.
@@ -27,4 +41,3 @@ interface CardHeaderProps extends CommonProps {
27
41
  * @returns {JSX.Element} CardHeader component
28
42
  */
29
43
  export declare const CardHeader: ({ heading, headingVariant, subHeading, onClose, dataTestId, className, children, accessories, density, }: CardHeaderProps) => JSX.Element;
30
- export {};
@@ -61,8 +61,11 @@ export interface ChartProps extends CommonProps {
61
61
  }
62
62
  /**
63
63
  * The Chart component is a wrapper component for ECharts.
64
+ *
64
65
  * Handles events and click functionality.
65
66
  *
67
+ * For more information see the [eCharts documentation](https://github.com/hustcc/echarts-for-react).
68
+ *
66
69
  * @param {ChartProps} props - The props for the Chart component
67
70
  * @returns {JSX.Element} Chart component
68
71
  */
@@ -13,7 +13,7 @@ export interface CopyableTextProps extends CommonProps {
13
13
  alternativeText?: string;
14
14
  }
15
15
  /**
16
- * The CopyableText component is used where the user should have easy access to copy some information.
16
+ * The CopyableText component is used where the user should have easy access to copy information.
17
17
  *
18
18
  * @param {CopyableTextProps} props - The props for the CopyableText component
19
19
  * @returns {JSX.Element} CopyableText component
@@ -1,30 +1,19 @@
1
1
  /// <reference types="react" />
2
- import { Matcher } from "react-day-picker";
3
- import { BaseInputProps } from "../BaseInput";
4
- export interface DateFieldProps extends Pick<BaseInputProps, "placeholder" | "id" | "dataTestId" | "onChange" | "readOnly"> {
2
+ import { DateInputProps } from "../DateInput/DateInput";
3
+ import { FormGroupProps } from "../FormGroup/FormGroup";
4
+ declare type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
5
+ export interface DateFieldProps extends DateInputProps, FormGroupExposedProps {
5
6
  /**
6
- * A text label to be displayed next to the indicator
7
+ * If a value is set, the field is rendered in its invalid state.
7
8
  */
8
- label?: string;
9
- /**
10
- * A text to be displayed under the input with a short description of field purpose
11
- */
12
- description?: string;
13
- /**
14
- * A default value to be displayed by a input field
15
- */
16
- defaultValue?: string;
17
- /**
18
- * A flag that can be used to disable the input, default value is false
19
- */
20
- disabled?: boolean;
21
- /**
22
- * Specification of dates not allowed to be selected - i the form of react-day-picker matcher
23
- */
24
- disabledDays?: Matcher | Matcher[] | undefined;
25
- /**
26
- * A flag that can be set to true to disallow the user to deselect a date. (if false the user can click the selected date to deselect)
27
- */
28
- preventDeselect?: boolean;
9
+ errorMessage?: string;
29
10
  }
11
+ /**
12
+ * The date field component is used for entering date values.
13
+ *
14
+ * _**Do use**_ the DateField for date input.
15
+ *
16
+ * _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
17
+ */
30
18
  export declare const DateField: import("react").ForwardRefExoticComponent<DateFieldProps & import("react").RefAttributes<HTMLInputElement>>;
19
+ export {};
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ import { Matcher } from "react-day-picker";
3
+ import { BaseInputProps } from "../BaseInput";
4
+ declare type BaseInputExposedProps = Omit<BaseInputProps, "defaultValue" | "onChange">;
5
+ export interface DateInputProps extends BaseInputExposedProps {
6
+ /**
7
+ * A default value to be displayed by a input field
8
+ */
9
+ defaultValue?: Date;
10
+ /**
11
+ * Specification of dates not allowed to be selected - i the form of react-day-picker matcher
12
+ */
13
+ disabledDays?: Matcher | Matcher[] | undefined;
14
+ /**
15
+ * A flag that can be set to true to disallow the user to deselect a date. (if false the user can click the selected date to deselect)
16
+ */
17
+ preventDeselect?: boolean;
18
+ /**
19
+ * onChange function returning the date instead of input event
20
+ */
21
+ onChange?: (date: Date) => void;
22
+ }
23
+ /**
24
+ * A wrapper around BaseInput with a pop-up day picker.
25
+ *
26
+ * NOTE: If shown with a label, please use the `DateField` component instead.
27
+ */
28
+ export declare const DateInput: import("react").ForwardRefExoticComponent<DateInputProps & import("react").RefAttributes<HTMLInputElement>>;
29
+ export {};
@@ -1,21 +1,20 @@
1
1
  /// <reference types="react" />
2
2
  import { CommonProps } from "../../common";
3
- interface SpacerProps extends CommonProps {
3
+ export interface SpacerProps extends CommonProps {
4
4
  /**
5
5
  * The minimum height of the spacer. Defaults to 1px.
6
6
  * Possible values are "normal"(8px), and "large" (32px).
7
7
  */
8
- minHeight?: string;
8
+ minHeight?: "normal" | "large";
9
9
  /**
10
10
  * The border of the spacer.
11
11
  */
12
12
  border?: boolean;
13
13
  }
14
14
  /**
15
- * The Spacer component is used for adding a bit of space.
15
+ * The Spacer component is used for adding a bit of space in the ui.
16
16
  *
17
17
  * @param {SpacerProps} props - The props for the Spacer component
18
18
  * @returns {JSX.Element} Spacer component
19
19
  */
20
20
  export declare const Spacer: ({ minHeight, border, dataTestId }: SpacerProps) => JSX.Element;
21
- export {};
@@ -25,11 +25,13 @@ export interface TagProps extends CommonProps {
25
25
  size?: TagSize;
26
26
  }
27
27
  /**
28
- * Tags allow users to enter information and filter content.
28
+ * The tag component is used to categorize elements in the ui.
29
29
  *
30
- * Multiple or single tags can be used to categorise items.
30
+ * This could be to tell the state of an asset, or label a page as Beta.
31
31
  *
32
- * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
32
+ * The tag is also used in multiselect components to show selected options.
33
+ *
34
+ * **Do:** Use short labels for easy scanning.
33
35
  *
34
36
  * @param {TagProps} props - The props for the tag component
35
37
  * @returns {JSX.Element} tag component
@@ -47,7 +47,11 @@ export interface TextProps extends CommonProps {
47
47
  underline?: boolean;
48
48
  }
49
49
  /**
50
- * The Text component.
50
+ * The Text component is used to apply Trackunit default typography styles to text.
51
+ *
52
+ * ### When to use
53
+ *
54
+ * Use Text when you want to show a text section, use Heading if you want to show a heading.
51
55
  *
52
56
  * @param {TextProps} props - The props for the Text component
53
57
  * @returns {JSX.Element} Text component
@@ -1,73 +1,16 @@
1
1
  import * as React from "react";
2
- import { CommonProps } from "../../common/CommonProps";
2
+ import { CommonProps } from "../../common";
3
3
  export declare type TextAreaResize = "none" | "vertical" | "horizontal" | "both";
4
- export interface TextAreaProps extends CommonProps {
5
- /**
6
- * ID of the text area.
7
- */
8
- id?: string;
9
- /**
10
- * Name of the text area.
11
- */
12
- name?: string;
13
- /**
14
- * Label of the text area.
15
- */
16
- label?: string;
17
- /**
18
- * Description of the text area.
19
- */
20
- description?: string;
21
- /**
22
- * Information about the text area.
23
- */
24
- info?: React.ReactNode;
25
- /**
26
- * Error message of the text area.
27
- */
28
- error?: React.ReactNode;
29
- /**
30
- * Value of the text area.
31
- */
32
- value?: React.ReactText;
33
- /**
34
- * Tab index specifies the keyboard tab order of the textarea relative to the other controls on the page.
35
- */
36
- tabIndex?: number;
37
- /**
38
- * Whether the text area is disabled or not.
39
- */
40
- disabled?: boolean;
41
- /**
42
- * Whether the text area is readonly or not.
43
- */
44
- readOnly?: boolean;
4
+ declare type FilteredInputProps = Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "prefix" | "suffix">;
5
+ export interface TextAreaProps extends FilteredInputProps, CommonProps {
45
6
  /**
46
7
  * Number of rows in the text area.
47
8
  */
48
9
  rows?: number;
49
- /**
50
- * Placeholder text for the text area.
51
- */
52
- placeholder?: string;
53
- /**
54
- * onChange handler of the text area.
55
- */
56
- onChange?: (event: React.SyntheticEvent<HTMLTextAreaElement>) => void;
57
- /**
58
- * onFocus handler of the text area.
59
- */
60
- onFocus?: (event: React.SyntheticEvent<HTMLTextAreaElement>) => void;
61
- /**
62
- * onBlur handler of the text area.
63
- */
64
- onBlur?: (event: React.SyntheticEvent<HTMLTextAreaElement>) => void;
65
- /**
66
- * Maximum length of the text area.
67
- */
68
- maxLength?: number;
69
10
  /**
70
11
  * Resize of the text area.
12
+ *
13
+ * @default "vertical"
71
14
  */
72
15
  resize?: TextAreaResize;
73
16
  /**
@@ -75,8 +18,13 @@ export interface TextAreaProps extends CommonProps {
75
18
  */
76
19
  defaultValue?: React.ReactText;
77
20
  /**
78
- * Whether the text area is required or not.
21
+ * If true the field is rendered in its invalid state.
79
22
  */
80
- required?: boolean;
23
+ isInvalid?: boolean;
81
24
  }
25
+ /**
26
+ * The TextArea is a base component, and should not be used very often.
27
+ * For most cases the TextAreaField is the correct component.
28
+ */
82
29
  export declare const TextArea: React.ForwardRefExoticComponent<TextAreaProps & React.RefAttributes<HTMLTextAreaElement>>;
30
+ export {};
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { CommonProps } from "../../common";
3
+ import { FormGroupProps } from "../FormGroup/FormGroup";
4
+ import { TextAreaProps } from "../TextArea/TextArea";
5
+ declare type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
6
+ export interface TextAreaFieldProps extends TextAreaProps, FormGroupExposedProps, CommonProps {
7
+ /**
8
+ * Set the Maximal length of the value for the input.
9
+ * Adds a TextLengthIndicator to the right of the helpText.
10
+ */
11
+ maxLength?: number;
12
+ /**
13
+ * If a value is set, the field is rendered in its invalid state.
14
+ */
15
+ errorMessage?: string;
16
+ }
17
+ export declare const TextAreaField: React.ForwardRefExoticComponent<TextAreaFieldProps & React.RefAttributes<HTMLTextAreaElement>>;
18
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./TextAreaField";
@@ -5,7 +5,7 @@ declare type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "hel
5
5
  export interface TextFieldProps extends TextInputProps, FormGroupExposedProps {
6
6
  /**
7
7
  * Set the Maximal length of the value for the input.
8
- * Adds a TextLenghtIndicator to the right of the helpText.
8
+ * Adds a TextLengthIndicator to the right of the helpText.
9
9
  */
10
10
  maxLength?: number;
11
11
  /**
@@ -7,7 +7,8 @@ export * from "./Chart";
7
7
  export * from "./Checkbox";
8
8
  export * from "./Collapse";
9
9
  export * from "./CopyableText";
10
- export * from "./DateField";
10
+ export * from "./DateField/DateField";
11
+ export * from "./DateInput/DateInput";
11
12
  export * from "./DayPicker";
12
13
  export * from "./FormGroup/FormGroup";
13
14
  export * from "./Heading";
@@ -30,6 +31,7 @@ export * from "./Spinner";
30
31
  export * from "./Tag";
31
32
  export * from "./Text";
32
33
  export * from "./TextArea";
34
+ export * from "./TextAreaField";
33
35
  export * from "./TextField";
34
36
  export * from "./TextInput/TextInput";
35
37
  export * from "./Timeline/Timeline";