@trackunit/react-components 0.0.83-alpha-9c24ee877.0 → 0.0.98

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.
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Default story for legacy components.
4
+ *
5
+ *@returns {JSX.Element} Legacy Component Story
6
+ */
7
+ export declare const LegacyComponentStory: () => JSX.Element;
@@ -1,8 +1,7 @@
1
- import * as React from "react";
1
+ /// <reference types="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";
6
5
  interface BaseBadgeProps extends CommonProps {
7
6
  /**
8
7
  * The color of the badge.
@@ -13,12 +12,6 @@ interface BaseBadgeProps extends CommonProps {
13
12
  * Subtle badges have a light background color wither a darker text color.
14
13
  */
15
14
  subtle?: boolean;
16
- /**
17
- * Whether badge should be displayed as a pill or badge.
18
- * For the pill variant, numeric values above 99 will be displayed as 99+.
19
- * Badge is subtle by default.
20
- */
21
- variant?: BadgeVariant;
22
15
  /**
23
16
  * Custom classNames can be added to make adjustments where needed.
24
17
  * Example: Set a maximum width of the badge by adding the className "max-w-[your-max-width]" or similar tailwind max-w class.
@@ -26,9 +19,18 @@ interface BaseBadgeProps extends CommonProps {
26
19
  */
27
20
  className?: string;
28
21
  /**
29
- * Child nodes of the Badge.
22
+ * The count to be displayed on the badge.
23
+ */
24
+ count?: number;
25
+ /**
26
+ * The max value to be displayed in the badge.
27
+ * Any value above this will be appended with a +.
30
28
  */
31
- children?: React.ReactNode;
29
+ max?: number;
30
+ /**
31
+ * If enabled the badge is shown even if the count is 0.
32
+ */
33
+ hideZero?: boolean;
32
34
  /**
33
35
  * Size of the badge.
34
36
  */
@@ -36,14 +38,10 @@ interface BaseBadgeProps extends CommonProps {
36
38
  }
37
39
  export declare type BadgeProps = BaseBadgeProps;
38
40
  /**
39
- * The Badge component us used to display states or similar short informative text.
40
- *
41
- * _**Do use** badges to show highlighted text based on the state._
42
- *
43
- * _**Do not use** badges for regular text in places where it makes no sense to use highlighted text._
41
+ * The Badge component is used to display a notification badge with an optional number value.
44
42
  *
45
43
  * @param {BadgeProps} props - The props for the Badge component
46
44
  * @returns {JSX.Element} Badge component
47
45
  */
48
- export declare const Badge: ({ color, subtle, className, variant, dataTestId, children, size, ...rest }: BadgeProps) => JSX.Element;
46
+ export declare const Badge: ({ color, subtle, className, count, max, hideZero, dataTestId, size, ...rest }: BadgeProps) => JSX.Element | null;
49
47
  export {};
@@ -1,8 +1,9 @@
1
1
  import * as React from "react";
2
+ import { CommonProps } from "../../common";
2
3
  export interface IOptionsType {
3
4
  [key: string]: any;
4
5
  }
5
- export interface ChartProps {
6
+ export interface ChartProps extends CommonProps {
6
7
  /**
7
8
  * Option values for EChart.
8
9
  */
@@ -31,10 +32,6 @@ export interface ChartProps {
31
32
  * Event fired when mouse leaves the chart.
32
33
  */
33
34
  mouseLeaveChart?: () => void;
34
- /**
35
- * Class values to be passed to the component.
36
- */
37
- className?: string;
38
35
  /**
39
36
  * CSS styles for the chart.
40
37
  */
@@ -20,7 +20,7 @@ export interface CollapseProps extends CommonProps {
20
20
  label: React.ReactNode;
21
21
  }
22
22
  /**
23
- * The Collapse component is ued to condense non-important information.
23
+ * The Collapse component is used to condense non-important information.
24
24
  *
25
25
  * @param {CollapseProps} props - The props for the Collapse component
26
26
  * @returns {JSX.Element} Collapse component
@@ -1,17 +1,16 @@
1
1
  /// <reference types="react" />
2
- interface CopyableTextProps {
2
+ import { CommonProps } from "../../common";
3
+ export interface CopyableTextProps extends CommonProps {
3
4
  /**
4
- * The text to be displayed.
5
+ * The text shown in the ui.
6
+ * By default this is also the text that gets copied when component is clicked.
5
7
  */
6
8
  text?: string;
7
9
  /**
8
- * Alternative text to be displayed.
10
+ * Alternative text to get copied to on click.
11
+ * This text is not visible in the ui.
9
12
  */
10
13
  alternativeText?: string;
11
- /**
12
- * ID of the component to be used while testing.
13
- */
14
- dataTestId?: string;
15
14
  }
16
15
  /**
17
16
  * The CopyableText component is used where the user should have easy access to copy some information.
@@ -20,4 +19,3 @@ interface CopyableTextProps {
20
19
  * @returns {JSX.Element} CopyableText component
21
20
  */
22
21
  export declare const CopyableText: ({ text, alternativeText, dataTestId }: CopyableTextProps) => JSX.Element;
23
- export {};
@@ -20,7 +20,7 @@ export interface HeadingProps extends CommonProps {
20
20
  subtle?: boolean;
21
21
  }
22
22
  /**
23
- * The Heading component should be used for Headings.
23
+ * The Heading is used for a heading of a section (h1,h2,h3,h4).
24
24
  *
25
25
  * @param {HeadingProps} props - The props for the Heading component
26
26
  * @returns {JSX.Element} Heading component
@@ -8,22 +8,17 @@ export interface LabelProps extends CommonProps {
8
8
  /**
9
9
  * Specifies the element to which the label belongs to.
10
10
  */
11
- htmlFor: string | false;
11
+ htmlFor?: string;
12
12
  /**
13
13
  * The label value.
14
14
  */
15
- label?: React.ReactNode;
16
- /**
17
- * Description for the label.
18
- */
19
- description?: React.ReactNode;
15
+ children?: React.ReactNode;
20
16
  }
21
17
  /**
22
18
  * The Label component is used for labels for input fields.
23
- *
24
- * **Have a look at the FormGroup first**
19
+ * This component is **not used directly**, but is part of the FormGroup and Field components.
25
20
  *
26
21
  * @param {LabelProps} props - The props for the Label component
27
22
  * @returns {JSX.Element} Label component
28
23
  */
29
- export declare const Label: ({ id, htmlFor, label, description, className, dataTestId }: LabelProps) => JSX.Element;
24
+ export declare const Label: ({ id, htmlFor, children, className, dataTestId }: LabelProps) => JSX.Element;
@@ -12,7 +12,7 @@ interface PageHeadingProps {
12
12
  * Test id to be used for the component.
13
13
  */
14
14
  dataTestId?: string;
15
- badge?: string;
15
+ tag?: string;
16
16
  }
17
17
  /**
18
18
  * The PageHeading component used on pages.
@@ -20,5 +20,5 @@ interface PageHeadingProps {
20
20
  * @param {PageHeadingProps} props - The props for the PageHeading component
21
21
  * @returns {JSX.Element} PageHeading component
22
22
  */
23
- export declare const PageHeading: ({ title, subtitle, dataTestId, badge }: PageHeadingProps) => JSX.Element;
23
+ export declare const PageHeading: ({ title, subtitle, dataTestId, tag }: PageHeadingProps) => JSX.Element;
24
24
  export {};
@@ -0,0 +1,17 @@
1
+ /// <reference types="react" />
2
+ import { TagProps } from "../../Tag";
3
+ declare type TagsPropsNoRef = Omit<TagProps, "ref">;
4
+ interface TagWithWidthProps extends TagsPropsNoRef {
5
+ onWidthKnown?: ({ width }: {
6
+ width: number;
7
+ }) => void;
8
+ }
9
+ /**
10
+ * Extended Tag component with information about its own width.
11
+ * Used in the select component.
12
+ *
13
+ * @param {TagProps} props - The props for the tag component
14
+ * @returns {JSX.Element} TagWithWidth component
15
+ */
16
+ export declare const TagWithWidth: ({ onWidthKnown, children, ...rest }: TagWithWidthProps) => JSX.Element;
17
+ export {};
@@ -10,17 +10,16 @@ export interface SkeletonLinesProps extends CommonProps {
10
10
  */
11
11
  height?: number | number[] | string;
12
12
  /**
13
- * The width of each lines. Can be a number or an array of numbers or string.
13
+ * The width of each line. Can be a number or an array of numbers or string.
14
14
  */
15
15
  width?: number | number[] | string;
16
16
  /**
17
17
  * Margin of lines.
18
18
  */
19
19
  margin?: string;
20
- /**
21
- * Additional CSS classes.
22
- */
23
- className?: string;
24
20
  }
21
+ /**
22
+ * Display placeholder lines before the data gets loaded to reduce load-time frustration.
23
+ */
25
24
  export declare const SkeletonLines: import("react").MemoExoticComponent<({ margin, lines, height, width, className, dataTestId }: SkeletonLinesProps) => JSX.Element>;
26
25
  export default SkeletonLines;
@@ -3,7 +3,7 @@ import { CommonProps } from "../../common";
3
3
  interface SpacerProps extends CommonProps {
4
4
  /**
5
5
  * The minimum height of the spacer. Defaults to 1px.
6
- * Possible values are "normal"(8px), and "large" (32px). Use className prop to use custom min-height values, example: min-h-[100px].
6
+ * Possible values are "normal"(8px), and "large" (32px).
7
7
  */
8
8
  minHeight?: string;
9
9
  /**
@@ -2,25 +2,18 @@ import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  import { Colors } from "../../constants/colors";
4
4
  export declare type TagSize = "default" | "small";
5
- interface TagProps extends CommonProps {
5
+ export interface TagProps extends CommonProps {
6
6
  /**
7
- * The color of the tag
7
+ * The color of the tag.
8
8
  *
9
9
  */
10
10
  color?: Colors;
11
11
  /**
12
- * A handler for a click event triggered on x icon
13
- * if not passed then x icon won't be visible
12
+ * A handler for a click event triggered on X icon.
13
+ * If not passed then x icon won't be visible.
14
14
  *
15
15
  */
16
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
17
  /**
25
18
  * Child nodes of the tag.
26
19
  *
@@ -28,20 +21,17 @@ interface TagProps extends CommonProps {
28
21
  children?: React.ReactNode;
29
22
  /**
30
23
  * Size of the tag.
31
- *
32
24
  */
33
25
  size?: TagSize;
34
- onWidthKnown?: ({ width }: {
35
- width: number;
36
- }) => void;
37
26
  }
38
27
  /**
39
28
  * Tags allow users to enter information and filter content.
29
+ *
40
30
  * Multiple or single tags can be used to categorise items.
31
+ *
41
32
  * Use short labels for easy scanning. Use two words only if necessary to describe the status and differentiate it from other tags.
42
33
  *
43
34
  * @param {TagProps} props - The props for the tag component
44
35
  * @returns {JSX.Element} tag component
45
36
  */
46
- export declare const Tag: ({ className, dataTestId, children, size, onClose, color, onWidthKnown, ...rest }: TagProps) => JSX.Element;
47
- export {};
37
+ export declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLElement>>;
@@ -7,7 +7,13 @@ export interface TipProps extends CommonProps {
7
7
  * Child nodes to render inside the tip.
8
8
  */
9
9
  children: React.ReactNode;
10
+ /**
11
+ * The props for setting the icon on this tip.
12
+ */
10
13
  iconProps?: Partial<IconProps>;
14
+ /**
15
+ * The props for setting the tooltip on this tip.
16
+ */
11
17
  tooltipProps?: Partial<TooltipProps>;
12
18
  }
13
19
  /**
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
+ import "./Toggle.css";
3
4
  export declare type ToggleSize = "small" | "default";
4
5
  export interface ToggleProps extends CommonProps {
5
6
  /**
@@ -34,9 +35,23 @@ export interface ToggleProps extends CommonProps {
34
35
  * Name of the toggle.
35
36
  */
36
37
  name?: string;
38
+ /**
39
+ * The description of the toggle.
40
+ */
41
+ description?: string;
37
42
  /**
38
43
  * onBlur event handler.
39
44
  */
40
45
  onBlur?: React.FocusEventHandler<HTMLInputElement>;
41
46
  }
47
+ /**
48
+ * Use Toggle when you have to only enable/disable a feature.
49
+ *
50
+ * _**Do use** Toggle in forms or settings._
51
+ *
52
+ * _**Do not use** Toggle if a user can select many option from a list, use checkboxes instead of toggle._
53
+ *
54
+ * @param {ToggleProps} props - The props for the Toggle component
55
+ * @returns {JSX.Element} Toggle component
56
+ */
42
57
  export declare const Toggle: React.ForwardRefExoticComponent<ToggleProps & React.RefAttributes<HTMLInputElement>>;
@@ -17,7 +17,6 @@ export * from "./Label";
17
17
  export * from "./LegendItem";
18
18
  export * from "./Menu";
19
19
  export * from "./Modal";
20
- export * from "./MultiRowTableCell";
21
20
  export * from "./NumberField/NumberField";
22
21
  export * from "./NumberInput/NumberInput";
23
22
  export * from "./PageHeading";
package/index.css CHANGED
@@ -162,3 +162,148 @@
162
162
  disabled:hover:bg-transparent;
163
163
  }
164
164
  }
165
+
166
+ /* CSS related to the toggle component */
167
+ .tu-toggle {
168
+ @apply rounded-full
169
+ bg-white
170
+ h-full
171
+ aspect-square
172
+ translate-x-0
173
+ transition-all;
174
+
175
+ &__wrapper {
176
+ @apply flex
177
+ items-center
178
+ p-0.5;
179
+ }
180
+
181
+ &__container {
182
+ @apply inline-block
183
+ items-center
184
+ w-fit
185
+ mr-2
186
+ active:shadow
187
+ rounded-full
188
+ cursor-pointer
189
+ focus-within:ring
190
+ focus-within:ring-offset-2
191
+ focus-within:ring-blue-700;
192
+ }
193
+
194
+ &--align-bottom {
195
+ @apply mb-7;
196
+ }
197
+
198
+ &__switch-container {
199
+ @apply flex
200
+ items-center
201
+ p-1
202
+ cursor-pointer
203
+ rounded-full
204
+ bg-slate-300
205
+ focus:bg-slate-400
206
+ hover:bg-slate-400
207
+ active:bg-slate-500;
208
+ }
209
+
210
+ &__switch {
211
+ @apply bg-white
212
+ rounded-full
213
+ h-full
214
+ w-5/12
215
+ aspect-square
216
+ translate-x-4
217
+ transition-all;
218
+ }
219
+
220
+ &--default {
221
+ @apply flex
222
+ items-center
223
+ p-1
224
+ cursor-pointer
225
+ w-9
226
+ h-5;
227
+ }
228
+
229
+ &--small {
230
+ @apply flex
231
+ items-center
232
+ p-1
233
+ cursor-pointer
234
+ w-8
235
+ h-4;
236
+
237
+ .tu-toggle__switch {
238
+ @apply w-4/12;
239
+ }
240
+ }
241
+
242
+ &--toggled {
243
+ @apply flex
244
+ items-center
245
+ p-1
246
+ cursor-pointer
247
+ bg-blue-600
248
+ focus:bg-blue-700
249
+ hover:bg-blue-700
250
+ active:bg-blue-800;
251
+ }
252
+
253
+ &--disabled {
254
+ @apply flex
255
+ items-center
256
+ p-1
257
+ cursor-not-allowed
258
+ pointer-events-none
259
+ bg-slate-200;
260
+ }
261
+
262
+ &--disabled.tu-toggle--toggled {
263
+ @apply bg-slate-400;
264
+ }
265
+
266
+ &__input {
267
+ @apply absolute
268
+ opacity-0
269
+ -z-10;
270
+ }
271
+
272
+ &__label {
273
+ @apply hover:cursor-pointer
274
+ text-base
275
+ text-slate-900
276
+ max-w-[250px]
277
+ whitespace-nowrap
278
+ overflow-hidden
279
+ text-ellipsis;
280
+
281
+ &--disabled {
282
+ @apply text-slate-400
283
+ group-hover:text-slate-400
284
+ group-active:text-slate-400;
285
+ }
286
+ }
287
+
288
+ &--align-label {
289
+ @apply inline-block;
290
+ }
291
+
292
+ &__description {
293
+ @apply text-sm
294
+ font-normal
295
+ font-sans
296
+ text-slate-500
297
+ inline-block
298
+ max-w-[150px]
299
+ whitespace-nowrap
300
+ overflow-hidden
301
+ text-ellipsis;
302
+
303
+ &--disabled {
304
+ @apply text-slate-400
305
+ group-hover:text-slate-400
306
+ group-active:text-slate-400;
307
+ }
308
+ }
309
+ }