@trackunit/react-components 0.0.164 → 0.0.166

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
+ import { IntentColors } from "@trackunit/ui-design-tokens";
1
2
  import * as React from "react";
2
3
  import { CommonProps } from "../../common/CommonProps";
3
- import { IntentColors } from "../../constants";
4
4
  export declare type AlertActionType = "primary" | "secondary";
5
5
  export declare type AlertAction = {
6
6
  label: string;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
+ import { ThemeColors } from "@trackunit/ui-design-tokens";
2
3
  import { CommonProps } from "../../common/CommonProps";
3
- import { Colors } from "../../constants/colors";
4
4
  export declare type BadgeSize = "medium" | "large";
5
5
  interface BaseBadgeProps extends CommonProps {
6
6
  /**
7
7
  * The color of the badge.
8
8
  */
9
- color?: Colors;
9
+ color?: ThemeColors;
10
10
  /**
11
11
  * Specifies whether the badge is subtle or not.
12
12
  * Subtle badges have a light background color wither a darker text color.
@@ -1,7 +1,7 @@
1
+ import { ThemeColors } from "@trackunit/ui-design-tokens";
1
2
  import { HeroIconName, TrackunitIconName } from "@trackunit/ui-icons";
2
3
  import * as React from "react";
3
4
  import { CommonProps, Size } from "../../common/CommonProps";
4
- import { Colors } from "../../constants/colors";
5
5
  export interface IconProps extends CommonProps {
6
6
  /**
7
7
  * The name of the icon to be rendered.
@@ -13,7 +13,7 @@ export interface IconProps extends CommonProps {
13
13
  * Supports any colors from the theme.
14
14
  * Custom colors can be used by setting a text color in the className.
15
15
  */
16
- color?: Colors;
16
+ color?: ThemeColors;
17
17
  /**
18
18
  * The size of the icon.
19
19
  * Small = 16x16px, medium = 20x20px, Large = 24x24px.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
+ import { ThemeColors } from "@trackunit/ui-design-tokens";
2
3
  import { CommonProps } from "../../common/CommonProps";
3
- import { Colors } from "../../constants/colors";
4
4
  export interface IndicatorProps extends CommonProps {
5
5
  /**
6
6
  * The icon to be rendered inside the indicator component
@@ -9,7 +9,7 @@ export interface IndicatorProps extends CommonProps {
9
9
  /**
10
10
  * A color token used to style the icon and the icon background
11
11
  */
12
- color?: Colors;
12
+ color?: ThemeColors;
13
13
  /**
14
14
  * A text label to be displayed next to the indicator
15
15
  */
@@ -1,13 +1,13 @@
1
+ import { ThemeColors } from "@trackunit/ui-design-tokens";
1
2
  import * as React from "react";
2
3
  import { CommonProps } from "../../common/CommonProps";
3
- import { Colors } from "../../constants/colors";
4
4
  export declare type TagSize = "small" | "medium";
5
5
  export interface TagProps extends CommonProps {
6
6
  /**
7
7
  * The color of the tag.
8
8
  *
9
9
  */
10
- color?: Colors;
10
+ color?: ThemeColors;
11
11
  /**
12
12
  * A handler for a click event triggered on X icon.
13
13
  * If not passed then x icon won't be visible.
@@ -15,13 +15,6 @@ export declare const getScore: (value: number, min: number, max: number) => numb
15
15
  * @returns {string} color value
16
16
  */
17
17
  export declare const getDefaultFillColor: (score: number) => string;
18
- /**
19
- * Helper function to get normalized color
20
- *
21
- * @param {number} levelColor - color, ex --color-green-600
22
- * @returns {string} normalized color value
23
- */
24
- export declare const getNormalizedLevelColor: (levelColor: string) => string;
25
18
  /**
26
19
  * Helper function to get custom color used by the ValueBar
27
20
  *
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
+ import { GeneralColors, IntentColors } from "@trackunit/ui-design-tokens";
2
3
  import { CommonProps, Size } from "../../../common/CommonProps";
3
- import { GeneralColors, IntentColors } from "../../../constants";
4
4
  export declare type ButtonVariant = "filled" | "transparent";
5
5
  export declare type ButtonColor = Extract<GeneralColors, "primary" | "secondary"> | Extract<IntentColors, "info" | "warning" | "danger"> | "tertiary";
6
6
  export declare type ButtonType = "button" | "submit";
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./common";
2
2
  export * from "./components";
3
- export * from "./constants";
4
3
  export * from "./hooks";
5
4
  export * from "./layout";
package/index.js CHANGED
@@ -19,7 +19,7 @@ export { default as ValueType } from 'react-select';
19
19
  import ReactAsyncCreatableSelect from 'react-select/async-creatable';
20
20
  import ReactCreatableSelect from 'react-select/creatable';
21
21
  import ReactAsyncSelect from 'react-select/async';
22
- import { getColorValue } from '@trackunit/ui-design-tokens';
22
+ import { color } from '@trackunit/ui-design-tokens';
23
23
 
24
24
  const docs = {
25
25
  source: {
@@ -303,72 +303,6 @@ const IconContainer$2 = tw.div`
303
303
  ${p => p.$size === "small" ? tws`tu-button__container--small` : null}
304
304
  `;
305
305
 
306
- /**
307
- * ? A collection of all the types and tokens related to the named colors in the default theme.
308
- */
309
-
310
- /**
311
- * The general color palette
312
- * Should be available in most if not all colored components
313
- */
314
- const generalColors = {
315
- PRIMARY: "primary",
316
- SECONDARY: "secondary",
317
- ACCENT: "accent",
318
- NEUTRAL: "neutral"
319
- };
320
- /**
321
- * The intent color palette
322
- * Should be available for most colored components such as "Button", "Alert", "Indicator", "Badge"
323
- */
324
-
325
- const intentColors = {
326
- INFO: "info",
327
- SUCCESS: "success",
328
- WARNING: "warning",
329
- DANGER: "danger"
330
- };
331
- /**
332
- * The Criticality color palette
333
- * Should be available in any component that could be used to display the criticality of an asset or event
334
- */
335
-
336
- const criticalityColors = {
337
- GOOD: "good",
338
- LOW: "low",
339
- CRITICAL: "critical"
340
- };
341
- /**
342
- * The Activity color palette
343
- * Should be available in any component that could be used to display the Activity state of an asset
344
- */
345
-
346
- const activityColors = {
347
- WORKING: "working",
348
- IDLE: "idle",
349
- STOPPED: "stopped",
350
- UNKNOWN: "unknown"
351
- };
352
- /**
353
- * The Rental status color palette
354
- * Should be available in any component that could be used to display the rental status of an asset
355
- */
356
-
357
- const rentalStatusColors = {
358
- ON_RENT: "ON_RENT",
359
- RETURNED: "RETURNED",
360
- AVAILABLE: "AVAILABLE",
361
- PICKUP_READY: "PICKUP_READY",
362
- TRANSFER: "TRANSFER",
363
- IN_REPAIR: "IN_REPAIR",
364
- OTHER_RENTAL_STATUS: "OTHER_RENTAL_STATUS"
365
- };
366
- /**
367
- * The full color palette
368
- */
369
-
370
- const colors = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, generalColors), intentColors), criticalityColors), activityColors), rentalStatusColors);
371
-
372
306
  const IconSizeClassMap = {
373
307
  small: tws`tu-icon--small`,
374
308
  medium: tws`tu-icon--medium`,
@@ -441,49 +375,49 @@ const Root$4 = tw.span`
441
375
  $color
442
376
  }) => {
443
377
  switch ($color) {
444
- case colors.PRIMARY:
378
+ case "primary":
445
379
  return tws`tu-icon--primary`;
446
380
 
447
- case colors.SECONDARY:
381
+ case "secondary":
448
382
  return tws`tu-icon--secondary`;
449
383
 
450
- case colors.ACCENT:
384
+ case "accent":
451
385
  return tws`tu-icon--accent`;
452
386
 
453
- case colors.NEUTRAL:
387
+ case "neutral":
454
388
  return tws`tu-icon--neutral`;
455
389
 
456
- case colors.INFO:
390
+ case "info":
457
391
  return tws`tu-icon--info`;
458
392
 
459
- case colors.SUCCESS:
393
+ case "success":
460
394
  return tws`tu-icon--success`;
461
395
 
462
- case colors.WARNING:
396
+ case "warning":
463
397
  return tws`tu-icon--warning`;
464
398
 
465
- case colors.DANGER:
399
+ case "danger":
466
400
  return tws`tu-icon--danger`;
467
401
 
468
- case colors.GOOD:
402
+ case "good":
469
403
  return tws`tu-icon--good`;
470
404
 
471
- case colors.LOW:
405
+ case "low":
472
406
  return tws`tu-icon--low`;
473
407
 
474
- case colors.CRITICAL:
408
+ case "critical":
475
409
  return tws`tu-icon--critical`;
476
410
 
477
- case colors.WORKING:
411
+ case "working":
478
412
  return tws`tu-icon--working`;
479
413
 
480
- case colors.IDLE:
414
+ case "idle":
481
415
  return tws`tu-icon--idle`;
482
416
 
483
- case colors.STOPPED:
417
+ case "stopped":
484
418
  return tws`tu-icon--stopped`;
485
419
 
486
- case colors.UNKNOWN:
420
+ case "unknown":
487
421
  return tws`tu-icon--unknown`;
488
422
 
489
423
  default:
@@ -2617,7 +2551,7 @@ const Indicator$1 = _a => {
2617
2551
  dataTestId,
2618
2552
  icon,
2619
2553
  label,
2620
- color = colors.UNKNOWN,
2554
+ color = "unknown",
2621
2555
  withBackground = true,
2622
2556
  withLabel = true,
2623
2557
  ping = false
@@ -2650,67 +2584,67 @@ const Container$4 = tw.div`
2650
2584
  $color
2651
2585
  }) => {
2652
2586
  switch ($color) {
2653
- case colors.PRIMARY:
2587
+ case "primary":
2654
2588
  return tws`tu-indicator--primary`;
2655
2589
 
2656
- case colors.SECONDARY:
2590
+ case "secondary":
2657
2591
  return tws`tu-indicator--secondary`;
2658
2592
 
2659
- case colors.ACCENT:
2593
+ case "accent":
2660
2594
  return tws`tu-indicator--accent`;
2661
2595
 
2662
- case colors.NEUTRAL:
2596
+ case "neutral":
2663
2597
  return tws`tu-indicator--neutral`;
2664
2598
 
2665
- case colors.INFO:
2599
+ case "info":
2666
2600
  return tws`tu-indicator--info`;
2667
2601
 
2668
- case colors.SUCCESS:
2602
+ case "success":
2669
2603
  return tws`tu-indicator--success`;
2670
2604
 
2671
- case colors.WARNING:
2605
+ case "warning":
2672
2606
  return tws`tu-indicator--warning`;
2673
2607
 
2674
- case colors.DANGER:
2608
+ case "danger":
2675
2609
  return tws`tu-indicator--danger`;
2676
2610
 
2677
- case colors.GOOD:
2611
+ case "good":
2678
2612
  return tws`tu-indicator--good`;
2679
2613
 
2680
- case colors.LOW:
2614
+ case "low":
2681
2615
  return tws`tu-indicator--low`;
2682
2616
 
2683
- case colors.CRITICAL:
2617
+ case "critical":
2684
2618
  return tws`tu-indicator--critical`;
2685
2619
 
2686
- case colors.WORKING:
2620
+ case "working":
2687
2621
  return tws`tu-indicator--working`;
2688
2622
 
2689
- case colors.IDLE:
2623
+ case "idle":
2690
2624
  return tws`tu-indicator--idle`;
2691
2625
 
2692
- case colors.STOPPED:
2626
+ case "stopped":
2693
2627
  return tws`tu-indicator--stopped`;
2694
2628
 
2695
- case colors.UNKNOWN:
2629
+ case "unknown":
2696
2630
  return tws`tu-indicator--unknown`;
2697
2631
 
2698
- case colors.ON_RENT:
2632
+ case "on_rent":
2699
2633
  return tws`tu-indicator--on-rent`;
2700
2634
 
2701
- case colors.AVAILABLE:
2635
+ case "available":
2702
2636
  return tws`tu-indicator--available`;
2703
2637
 
2704
- case colors.PICKUP_READY:
2638
+ case "pickup_ready":
2705
2639
  return tws`tu-indicator--pickup-ready`;
2706
2640
 
2707
- case colors.TRANSFER:
2641
+ case "transfer":
2708
2642
  return tws`tu-indicator--transfer`;
2709
2643
 
2710
- case colors.IN_REPAIR:
2644
+ case "in_repair":
2711
2645
  return tws`tu-indicator--in-repair`;
2712
2646
 
2713
- case colors.OTHER_RENTAL_STATUS:
2647
+ case "other_rental_status":
2714
2648
  return tws`tu-indicator--other-rental-status`;
2715
2649
 
2716
2650
  default:
@@ -4949,28 +4883,14 @@ const getScore = (value, min, max) => {
4949
4883
 
4950
4884
  const getDefaultFillColor = score => {
4951
4885
  if (score < 0.3) {
4952
- return getColorValue("--color-red-500");
4886
+ return color("DANGER", 500, "CSS");
4953
4887
  }
4954
4888
 
4955
4889
  if (score >= 0.6) {
4956
- return getColorValue("--color-green-600");
4957
- }
4958
-
4959
- return getColorValue("--color-amber-300");
4960
- };
4961
- /**
4962
- * Helper function to get normalized color
4963
- *
4964
- * @param {number} levelColor - color, ex --color-green-600
4965
- * @returns {string} normalized color value
4966
- */
4967
-
4968
- const getNormalizedLevelColor = levelColor => {
4969
- if (levelColor.startsWith("--color")) {
4970
- return getColorValue(levelColor);
4890
+ return color("SUCCESS", 600, "CSS");
4971
4891
  }
4972
4892
 
4973
- return levelColor;
4893
+ return color("WARNING", 300, "CSS");
4974
4894
  };
4975
4895
  /**
4976
4896
  * Helper function to get custom color used by the ValueBar
@@ -4984,14 +4904,14 @@ const getFillColor = (score, levelColors) => {
4984
4904
  var _a, _b;
4985
4905
 
4986
4906
  if (levelColors.low && score < (levelColors.low.level || 0)) {
4987
- return getNormalizedLevelColor(levelColors.low.color);
4907
+ return levelColors.low.color;
4988
4908
  }
4989
4909
 
4990
4910
  if (levelColors.high && score >= (levelColors.high.level || 0)) {
4991
- return getNormalizedLevelColor(levelColors.high.color);
4911
+ return levelColors.high.color;
4992
4912
  }
4993
4913
 
4994
- return getNormalizedLevelColor((_b = (_a = levelColors.medium) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : "--color-amber-300");
4914
+ return (_b = (_a = levelColors.medium) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : color("WARNING", 300);
4995
4915
  };
4996
4916
  /**
4997
4917
  * Helper function to get color used by the ValueBar
@@ -5054,7 +4974,7 @@ const ValueBar = ({
5054
4974
  "$size": size,
5055
4975
  x: `${barWidth + 2}%`,
5056
4976
  y: "11",
5057
- fill: valueColor !== null && valueColor !== void 0 ? valueColor : getColorValue("--color-neutral-400")
4977
+ fill: valueColor !== null && valueColor !== void 0 ? valueColor : color("NEUTRAL", 400, "CSS")
5058
4978
  }, {
5059
4979
  children: [Number(value.toFixed(1)), unit || ""]
5060
4980
  }))]
@@ -5446,4 +5366,4 @@ const Layout = tw.div`
5446
5366
  tu-layout-TwoColumnLayout
5447
5367
  `;
5448
5368
 
5449
- export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, activityColors, colors, criticalityColors, docs, generalColors, getOrderedOptions, getValueBarColorByValue, intentColors, isMultiValue, rentalStatusColors, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
5369
+ export { ActionButton, Alert, AnimatedPopover, Badge, BaseInput, Button, Card, CardBody, CardFooter, CardHeader, Chart, Checkbox, Collapse, CopyableText, CreatableSelect, DateField, DateInput, DayPicker, DayPickerPopover, DayRangePicker, DensityContainer, FilterListMapLayout, FormGroup, FullWidthRepeatingLayout, GridArea, Heading$1 as Heading, Icon$1 as Icon, IconButton, Indicator$1 as Indicator, IntrinsicallyResponsiveGrid, Label$2 as Label, LegendItem, MenuItem, MenuList, MinTopFullContentLayout, Modal, ModalBackdrop, MultiSelectMenuItem, NumberField, NumberInput, PageHeader, PopoverLifecycle, PopoverList, PopoverListItem, PopoverTitle, Prompt, ROLE_CARD, RadioGroup, RadioItem, SectionHeader, Select, SelectPrefix, SingleSelectMenuItem, SkeletonLines, Spacer, Spinner, StarButton, Tag, Text$1 as Text, TextArea, TextAreaField, TextField, TextInput, Timeline, TimelineElement, Tip, TitleNavContentLayout, Toggle, Tooltip, TwoColumnLayout, ValueBar, docs, getOrderedOptions, getValueBarColorByValue, isMultiValue, useContainerProps, useCustomComponents, useDebounce, useLocalStorage, useModal, usePopover, usePrompt, useTimeout };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.164",
3
+ "version": "0.0.166",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
- "@trackunit/css-core": "0.0.52",
7
+ "@trackunit/css-core": "0.0.54",
8
8
  "@trackunit/tailwind-styled-components": "0.0.46",
9
9
  "react": "17.0.2",
10
- "@trackunit/ui-design-tokens": "0.0.44",
10
+ "@trackunit/ui-design-tokens": "0.0.46",
11
11
  "echarts-for-react": "^3.0.2",
12
12
  "echarts": "^5.4.0",
13
13
  "uuid": "^8.3.2",
@@ -1,88 +0,0 @@
1
- /**
2
- * ? A collection of all the types and tokens related to the named colors in the default theme.
3
- */
4
- /**
5
- * The general color palette
6
- * Should be available in most if not all colored components
7
- */
8
- export declare const generalColors: {
9
- readonly PRIMARY: "primary";
10
- readonly SECONDARY: "secondary";
11
- readonly ACCENT: "accent";
12
- readonly NEUTRAL: "neutral";
13
- };
14
- export declare type GeneralColors = typeof colors[keyof typeof generalColors];
15
- /**
16
- * The intent color palette
17
- * Should be available for most colored components such as "Button", "Alert", "Indicator", "Badge"
18
- */
19
- export declare const intentColors: {
20
- readonly INFO: "info";
21
- readonly SUCCESS: "success";
22
- readonly WARNING: "warning";
23
- readonly DANGER: "danger";
24
- };
25
- export declare type IntentColors = typeof colors[keyof typeof intentColors];
26
- /**
27
- * The Criticality color palette
28
- * Should be available in any component that could be used to display the criticality of an asset or event
29
- */
30
- export declare const criticalityColors: {
31
- readonly GOOD: "good";
32
- readonly LOW: "low";
33
- readonly CRITICAL: "critical";
34
- };
35
- export declare type CriticalityColors = typeof colors[keyof typeof criticalityColors];
36
- /**
37
- * The Activity color palette
38
- * Should be available in any component that could be used to display the Activity state of an asset
39
- */
40
- export declare const activityColors: {
41
- readonly WORKING: "working";
42
- readonly IDLE: "idle";
43
- readonly STOPPED: "stopped";
44
- readonly UNKNOWN: "unknown";
45
- };
46
- export declare type ActivityColors = typeof colors[keyof typeof activityColors];
47
- /**
48
- * The Rental status color palette
49
- * Should be available in any component that could be used to display the rental status of an asset
50
- */
51
- export declare const rentalStatusColors: {
52
- readonly ON_RENT: "ON_RENT";
53
- readonly RETURNED: "RETURNED";
54
- readonly AVAILABLE: "AVAILABLE";
55
- readonly PICKUP_READY: "PICKUP_READY";
56
- readonly TRANSFER: "TRANSFER";
57
- readonly IN_REPAIR: "IN_REPAIR";
58
- readonly OTHER_RENTAL_STATUS: "OTHER_RENTAL_STATUS";
59
- };
60
- export declare type RentalStatusColors = typeof colors[keyof typeof rentalStatusColors];
61
- /**
62
- * The full color palette
63
- */
64
- export declare const colors: {
65
- readonly ON_RENT: "ON_RENT";
66
- readonly RETURNED: "RETURNED";
67
- readonly AVAILABLE: "AVAILABLE";
68
- readonly PICKUP_READY: "PICKUP_READY";
69
- readonly TRANSFER: "TRANSFER";
70
- readonly IN_REPAIR: "IN_REPAIR";
71
- readonly OTHER_RENTAL_STATUS: "OTHER_RENTAL_STATUS";
72
- readonly WORKING: "working";
73
- readonly IDLE: "idle";
74
- readonly STOPPED: "stopped";
75
- readonly UNKNOWN: "unknown";
76
- readonly GOOD: "good";
77
- readonly LOW: "low";
78
- readonly CRITICAL: "critical";
79
- readonly INFO: "info";
80
- readonly SUCCESS: "success";
81
- readonly WARNING: "warning";
82
- readonly DANGER: "danger";
83
- readonly PRIMARY: "primary";
84
- readonly SECONDARY: "secondary";
85
- readonly ACCENT: "accent";
86
- readonly NEUTRAL: "neutral";
87
- };
88
- export declare type Colors = typeof colors[keyof typeof colors];
@@ -1 +0,0 @@
1
- export * from "./colors";