@trackunit/react-components 0.0.138 → 0.0.142

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.
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
- export declare type AlertIntent = "info" | "warning" | "danger" | "success";
3
+ import { IntentColors } from "../../constants";
4
4
  export declare type AlertActionType = "primary" | "secondary";
5
5
  export declare type AlertAction = {
6
6
  label: string;
@@ -13,10 +13,10 @@ export interface AlertProps extends CommonProps {
13
13
  */
14
14
  children: React.ReactNode;
15
15
  /**
16
- * Intent of the alert component.
16
+ * Color of the alert component.
17
17
  *
18
18
  */
19
- intent?: AlertIntent;
19
+ color?: IntentColors;
20
20
  /**
21
21
  * Title of the alert component.
22
22
  */
@@ -50,4 +50,4 @@ export interface AlertProps extends CommonProps {
50
50
  * @param {AlertProps} props - The props for the Alert component
51
51
  * @returns {JSX.Element} Alert component
52
52
  */
53
- export declare const Alert: ({ intent, title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, inline, }: AlertProps) => JSX.Element;
53
+ export declare const Alert: ({ color, title, className, children, primaryAction, secondaryAction, onClose, dataTestId, autoScroll, inline, }: AlertProps) => JSX.Element;
@@ -1,14 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import { Matcher } from "react-day-picker";
3
3
  import { Size } from "../../common";
4
- import { ButtonIntent } from "../buttons";
4
+ import { ButtonColor } from "../buttons";
5
5
  import { PopoverPlacement } from "../Popover";
6
6
  export interface DayPickerPopoverProps {
7
7
  disabledDays?: Matcher | Matcher[] | undefined;
8
8
  className?: string;
9
9
  onDaySelect: (day: Date) => void;
10
10
  selectedDay?: Date;
11
- intent?: ButtonIntent;
11
+ color?: ButtonColor;
12
12
  size?: Size;
13
13
  placement?: PopoverPlacement;
14
14
  buttonContent: JSX.Element;
@@ -20,4 +20,4 @@ export interface DayPickerPopoverProps {
20
20
  * @param {DayPickerPopoverProps} props - The props for the DayPickerPopover component
21
21
  * @returns {JSX.Element} DayPickerPopover component
22
22
  */
23
- export declare const DayPickerPopover: ({ disabledDays, className, selectedDay, onDaySelect, intent, placement, size, buttonContent, language, }: DayPickerPopoverProps) => JSX.Element;
23
+ export declare const DayPickerPopover: ({ disabledDays, className, selectedDay, onDaySelect, color, placement, size, buttonContent, language, }: DayPickerPopoverProps) => JSX.Element;
@@ -12,7 +12,7 @@ export interface FormGroupProps extends CommonProps {
12
12
  /**
13
13
  * A string to display under the input element to help the user understand the input.
14
14
  */
15
- helpText?: string;
15
+ helpText?: string | null;
16
16
  /**
17
17
  * An addon element to render to the right under the input element.
18
18
  * Used for displaying maxLength etc.
@@ -9,7 +9,7 @@ interface PromptProps {
9
9
  * @param {boolean} when -
10
10
  * @returns {void} void
11
11
  */
12
- export declare function usePrompt(message: string, when?: boolean): void;
12
+ export declare const usePrompt: (message: string, when?: boolean) => void;
13
13
  /**
14
14
  * The Prompt function.
15
15
  *
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { GroupBase } from "react-select";
3
- import { SelectProps } from "./Select";
3
+ import { SelectProps } from "./useSelect";
4
4
  interface CreateableSelectProps<Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> extends SelectProps<Option, IsAsync, IsMulti, Group> {
5
5
  /**
6
6
  * To hide the label.
@@ -34,5 +34,5 @@ export declare type SelectSize = "small" | "default";
34
34
  * @param {CreateableSelectProps} props - The props for the CreatableSelect component
35
35
  * @returns {JSX.Element} CreatableSelect component
36
36
  */
37
- export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ dataTestId, id, label, hideLabel, description, error, info, isInvalid, maxMenuHeight, components, disabled, async, value, onChange, isMulti, classNamePrefix, isLoading, options, onMenuOpen, styles, ...props }: CreateableSelectProps<Option, IsAsync, IsMulti, Group>) => JSX.Element;
37
+ export declare const CreatableSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: CreateableSelectProps<Option, IsAsync, IsMulti, Group>) => JSX.Element;
38
38
  export {};
@@ -1,130 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { GroupBase, OptionsOrGroups, Props } from "react-select";
3
- import { CommonProps } from "../../common";
2
+ import { GroupBase } from "react-select";
3
+ import { SelectProps } from "./useSelect";
4
4
  export interface SelectOption {
5
5
  label: string;
6
6
  value: string;
7
7
  }
8
- export interface AsyncSelect<Option, Group extends GroupBase<Option> = GroupBase<Option>> {
9
- loadOptions: (input: string) => void | Promise<OptionsOrGroups<Option, Group>>;
10
- defaultOptions: OptionsOrGroups<Option, Group> | undefined;
11
- cacheOptions: boolean;
12
- }
13
- export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
14
- /**
15
- * An React element to render before the text in the select.
16
- * This is typically used to render an icon.
17
- *
18
- *
19
- * @memberof SelectProps
20
- */
21
- prefix?: JSX.Element;
22
- /**
23
- * An string to render in field when there is no value selected.
24
- * Can be used as a description, example or a hint.
25
- *
26
- *
27
- * @memberof SelectProps
28
- */
29
- placeholder?: string;
30
- /**
31
- * An boolean flag to disable field
32
- *
33
- *
34
- * @memberof SelectProps
35
- */
36
- disabled?: boolean;
37
- /**
38
- * An field id
39
- *
40
- *
41
- * @memberof SelectProps
42
- */
43
- id?: string;
44
- /**
45
- * An boolean flag to set select into async mode
46
- * This is typically used when data is fetched after render
47
- *
48
- *
49
- * @memberof SelectProps
50
- */
51
- async?: AsyncSelect<Option, GroupType>;
52
- /**
53
- * A custom icon to be used as a dropdown indicator
54
- * This is typically used during style customization
55
- *
56
- *
57
- * @memberof SelectProps
58
- */
59
- dropdownIcon?: JSX.Element;
60
- /**
61
- * A label to be used as a aria-label
62
- * This is typically used for accessibility
63
- *
64
- *
65
- * @memberof SelectProps
66
- */
67
- label?: string;
68
- /**
69
- * A number of pixels to limit maximal length of the select menu list
70
- *
71
- *
72
- * @memberof SelectProps
73
- */
74
- maxMenuHeight?: number;
75
- /**
76
- * A boolean prop to set select into invalid mode
77
- * typically used when selected value is not compliant with field requirement
78
- * ex if it breaks validation rules
79
- *
80
- *
81
- * @memberof SelectProps
82
- */
83
- hasError?: boolean;
84
- /**
85
- * A boolean flag to display loading indicator
86
- *
87
- *
88
- * @memberof SelectProps
89
- */
90
- isLoading?: boolean;
91
- /**
92
- * A number value to limit amount of visible tags for selected options
93
- *
94
- *
95
- * @memberof SelectProps
96
- */
97
- maxSelectedDisplayCount?: number;
98
- /**
99
- * A custom handler for menu open event
100
- * use if you want to trigger custom logic or fetch data
101
- *
102
- *
103
- * @memberof SelectProps
104
- */
105
- onMenuOpen?: () => void;
106
- /**
107
- * A flag to allow user to clear value once selected
108
- * default value is true
109
- *
110
- *
111
- * @memberof SelectProps
112
- */
113
- isClearable?: boolean;
114
- /**
115
- * A flag to allow user to filter option list by key from the text input
116
- *
117
- *
118
- * @memberof SelectProps
119
- */
120
- isSearchable?: boolean;
121
- /**
122
- * A flag to set select into async mode
123
- *
124
- * @memberof SelectProps
125
- */
126
- isAsync?: IsAsync;
127
- }
128
8
  /**
129
9
  * Selects are input components used to choose a value from a set.
130
10
  *
@@ -132,6 +12,6 @@ export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends bo
132
12
  * @returns {JSX.Element} Select component
133
13
  */
134
14
  export declare const Select: {
135
- <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ id, className, dataTestId, prefix, async, dropdownIcon, maxMenuHeight, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix, onMenuOpen, onMenuClose, maxSelectedDisplayCount, isClearable, isSearchable, onMenuScrollToBottom, styles, filterOption, onInputChange, ...props }: SelectProps<Option, IsAsync, IsMulti, Group>): JSX.Element;
15
+ <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: SelectProps<Option, IsAsync, IsMulti, Group>): JSX.Element;
136
16
  displayName: string;
137
17
  };
@@ -12,3 +12,4 @@ export declare function isMultiValue<Option>(arg: MultiValue<Option> | SingleVal
12
12
  * @returns {OptionsOrGroups<Option, Group>} An array of ordered options with selected on top
13
13
  */
14
14
  export declare const getOrderedOptions: <Option, Group extends GroupBase<Option>>(options: OptionsOrGroups<Option, Group> | undefined, value: PropsValue<Option> | undefined) => OptionsOrGroups<Option, Group>;
15
+ export declare const SelectPrefix: import("tailwind-styled-components/dist/tailwind").TailwindComponent<"div", {}>;
@@ -0,0 +1,143 @@
1
+ import React from "react";
2
+ import { GroupBase, MenuPlacement, OptionsOrGroups, Props, StylesConfig } from "react-select";
3
+ import { SelectComponents } from "react-select/dist/declarations/src/components";
4
+ import { CommonProps } from "../../common/CommonProps";
5
+ export interface AsyncSelect<Option, Group extends GroupBase<Option> = GroupBase<Option>> {
6
+ loadOptions: (input: string) => void | Promise<OptionsOrGroups<Option, Group>>;
7
+ defaultOptions: OptionsOrGroups<Option, Group> | undefined;
8
+ cacheOptions: boolean;
9
+ }
10
+ export interface SelectProps<Option, IsAsync extends boolean, IsMulti extends boolean, GroupType extends GroupBase<Option>> extends CommonProps, Props<Option, IsMulti, GroupType> {
11
+ /**
12
+ * An React element to render before the text in the select.
13
+ * This is typically used to render an icon.
14
+ *
15
+ *
16
+ * @memberof SelectProps
17
+ */
18
+ prefix?: JSX.Element;
19
+ /**
20
+ * An string to render in field when there is no value selected.
21
+ * Can be used as a description, example or a hint.
22
+ *
23
+ *
24
+ * @memberof SelectProps
25
+ */
26
+ placeholder?: string;
27
+ /**
28
+ * An boolean flag to disable field
29
+ *
30
+ *
31
+ * @memberof SelectProps
32
+ */
33
+ disabled?: boolean;
34
+ /**
35
+ * An field id
36
+ *
37
+ *
38
+ * @memberof SelectProps
39
+ */
40
+ id?: string;
41
+ /**
42
+ * An boolean flag to set select into async mode
43
+ * This is typically used when data is fetched after render
44
+ *
45
+ *
46
+ * @memberof SelectProps
47
+ */
48
+ async?: AsyncSelect<Option, GroupType>;
49
+ /**
50
+ * A custom icon to be used as a dropdown indicator
51
+ * This is typically used during style customization
52
+ *
53
+ *
54
+ * @memberof SelectProps
55
+ */
56
+ dropdownIcon?: JSX.Element;
57
+ /**
58
+ * A label to be used as a aria-label
59
+ * This is typically used for accessibility
60
+ *
61
+ *
62
+ * @memberof SelectProps
63
+ */
64
+ label?: string;
65
+ /**
66
+ * A number of pixels to limit maximal length of the select menu list
67
+ *
68
+ *
69
+ * @memberof SelectProps
70
+ */
71
+ maxMenuHeight?: number;
72
+ /**
73
+ * A boolean prop to set select into invalid mode
74
+ * typically used when selected value is not compliant with field requirement
75
+ * ex if it breaks validation rules
76
+ *
77
+ *
78
+ * @memberof SelectProps
79
+ */
80
+ hasError?: boolean;
81
+ /**
82
+ * A boolean flag to display loading indicator
83
+ *
84
+ *
85
+ * @memberof SelectProps
86
+ */
87
+ isLoading?: boolean;
88
+ /**
89
+ * A number value to limit amount of visible tags for selected options
90
+ *
91
+ *
92
+ * @memberof SelectProps
93
+ */
94
+ maxSelectedDisplayCount?: number;
95
+ /**
96
+ * A custom handler for menu open event
97
+ * use if you want to trigger custom logic or fetch data
98
+ *
99
+ *
100
+ * @memberof SelectProps
101
+ */
102
+ onMenuOpen?: () => void;
103
+ /**
104
+ * A flag to allow user to clear value once selected
105
+ * default value is true
106
+ *
107
+ *
108
+ * @memberof SelectProps
109
+ */
110
+ isClearable?: boolean;
111
+ /**
112
+ * A flag to allow user to filter option list by key from the text input
113
+ *
114
+ *
115
+ * @memberof SelectProps
116
+ */
117
+ isSearchable?: boolean;
118
+ /**
119
+ * A flag to set select into async mode
120
+ *
121
+ * @memberof SelectProps
122
+ */
123
+ isAsync?: IsAsync;
124
+ }
125
+ interface IUseSelect<Option, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>> {
126
+ customStyles: StylesConfig<Option, IsMulti, Group>;
127
+ customComponents: Partial<SelectComponents<Option, IsMulti, Group>>;
128
+ refContainer: React.RefObject<HTMLDivElement>;
129
+ refPrefix: React.RefObject<HTMLDivElement>;
130
+ menuIsOpen: boolean;
131
+ menuPlacement: MenuPlacement;
132
+ openMenuHandler: () => Promise<void>;
133
+ closeMenuHandler: () => void;
134
+ orderedOptions: OptionsOrGroups<Option, Group>;
135
+ }
136
+ /**
137
+ * A hook used by selects to share the common code
138
+ *
139
+ * @param {SelectProps} props - The props for the Select component
140
+ * @returns {IUseSelect} Select component
141
+ */
142
+ export declare const useSelect: <Option, IsAsync extends boolean = false, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>({ id, className, dataTestId, prefix, async, dropdownIcon, maxMenuHeight, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix, onMenuOpen, onMenuClose, maxSelectedDisplayCount, isClearable, isSearchable, onMenuScrollToBottom, styles, filterOption, onInputChange, ...props }: SelectProps<Option, IsAsync, IsMulti, Group>) => IUseSelect<Option, IsMulti, Group>;
143
+ export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { LevelColors } from "./ValueBarTypes";
3
2
  import { CommonProps } from "../../common";
3
+ import { LevelColors } from "./ValueBarTypes";
4
4
  export interface ValueBarProps extends CommonProps {
5
5
  /**
6
6
  * Value to display.
@@ -41,4 +41,4 @@ export interface ValueBarProps extends CommonProps {
41
41
  * @param {ValueBarProps} props - The props for the ValueBar component
42
42
  * @returns {JSX.Element} ValueBar component
43
43
  */
44
- export declare const ValueBar: ({ value, min, max, unit, size, levelColors, valueColor, showValue, className, dataTestId }: ValueBarProps) => JSX.Element;
44
+ export declare const ValueBar: ({ value, min, max, unit, size, levelColors, valueColor, showValue, className, dataTestId, }: ValueBarProps) => JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { Size } from "../../../common";
3
- import { ButtonCommonProps, ButtonIntent, ButtonType, ButtonVariant } from "../shared/ButtonProps";
3
+ import { ButtonColor, ButtonCommonProps, ButtonType, ButtonVariant } from "../shared/ButtonProps";
4
4
  export interface StyledButtonProps {
5
5
  $variant: ButtonVariant;
6
6
  $size: Size;
7
7
  $square: boolean;
8
- $intent: ButtonIntent;
8
+ $color: ButtonColor;
9
9
  $fullWidth: boolean;
10
10
  }
11
11
  export interface ButtonProps extends ButtonCommonProps {
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { CommonProps, Size } from "../../../common/CommonProps";
3
+ import { GeneralColors, IntentColors } from "../../../constants";
3
4
  export declare type ButtonVariant = "filled" | "transparent";
4
- export declare type ButtonIntent = "primary" | "secondary" | "danger" | "warning" | "tertiary";
5
+ export declare type ButtonColor = Extract<GeneralColors, "primary" | "secondary"> | Extract<IntentColors, "info" | "warning" | "danger"> | "tertiary";
5
6
  export declare type ButtonType = "button" | "submit";
6
7
  export interface ButtonCommonProps extends CommonProps {
7
8
  onClick?: (event: React.MouseEvent<HTMLElement>) => void;
@@ -20,7 +21,7 @@ export interface ButtonCommonProps extends CommonProps {
20
21
  /**
21
22
  * The button's variant. Values are filled, transparent, plain.
22
23
  */
23
- intent?: ButtonIntent;
24
+ color?: ButtonColor;
24
25
  /**
25
26
  * The variant of the button.
26
27
  */
@@ -1,7 +1,7 @@
1
1
  import { Size } from "../../../common";
2
- import { ButtonIntent, ButtonVariant } from "./ButtonProps";
2
+ import { ButtonColor, ButtonVariant } from "./ButtonProps";
3
3
  interface ButtonProps {
4
- $intent: ButtonIntent;
4
+ $color: ButtonColor;
5
5
  $variant: ButtonVariant;
6
6
  $size: Size;
7
7
  }
@@ -10,7 +10,7 @@ interface ButtonProps {
10
10
  *
11
11
  * @returns {string} - Classnames for the button
12
12
  */
13
- export declare const getStyles: () => ({ $intent, $variant }: ButtonProps) => string;
13
+ export declare const getStyles: () => ({ $color, $variant }: ButtonProps) => any;
14
14
  /**
15
15
  * Helper to get the needed classname for padding.
16
16
  *
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export declare const generalColors: {
9
9
  readonly PRIMARY: "primary";
10
+ readonly SECONDARY: "secondary";
10
11
  readonly ACCENT: "accent";
11
12
  readonly NEUTRAL: "neutral";
12
13
  };
@@ -80,6 +81,7 @@ export declare const colors: {
80
81
  readonly WARNING: "warning";
81
82
  readonly DANGER: "danger";
82
83
  readonly PRIMARY: "primary";
84
+ readonly SECONDARY: "secondary";
83
85
  readonly ACCENT: "accent";
84
86
  readonly NEUTRAL: "neutral";
85
87
  };
package/index.css CHANGED
@@ -88,15 +88,15 @@
88
88
  }
89
89
 
90
90
  &--warning {
91
- @apply bg-orange-50
92
- text-orange-600
93
- hover:bg-orange-200
94
- hover:text-orange-800
95
- active:text-orange-700
96
- active:bg-orange-100
97
- focus:ring-orange-300
98
- disabled:bg-orange-50
99
- disabled:hover:bg-orange-50
91
+ @apply bg-warning-50
92
+ text-warning-600
93
+ hover:bg-warning-200
94
+ hover:text-warning-800
95
+ active:text-warning-700
96
+ active:bg-warning-100
97
+ focus:ring-warning-300
98
+ disabled:bg-warning-50
99
+ disabled:hover:bg-warning-50
100
100
  disabled:text-slate-400;
101
101
  }
102
102
 
@@ -146,10 +146,10 @@
146
146
  }
147
147
 
148
148
  &--transparent-warning {
149
- @apply text-orange-600
150
- active:bg-orange-500/20
151
- focus:ring-orange-300
152
- hover:bg-orange-500/10
149
+ @apply text-warning-600
150
+ active:bg-warning-500/20
151
+ focus:ring-warning-300
152
+ hover:bg-warning-500/10
153
153
  disabled:hover:bg-transparent;
154
154
  }
155
155