@trackunit/react-components 0.0.138 → 0.0.139

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;
@@ -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
 
package/index.js CHANGED
@@ -164,7 +164,7 @@ const Container$9 = tw.div`
164
164
  */
165
165
 
166
166
  const getStyles = () => ({
167
- $intent,
167
+ $color,
168
168
  $variant
169
169
  }) => {
170
170
  const styles = {
@@ -183,7 +183,7 @@ const getStyles = () => ({
183
183
  warning: tws`tu-button--transparent tu-button--transparent-warning`
184
184
  }
185
185
  };
186
- return styles[$variant][$intent];
186
+ return styles[$variant][$color];
187
187
  };
188
188
  /**
189
189
  * Helper to get the needed classname for padding.
@@ -223,7 +223,7 @@ const Button = React.forwardRef((_a, ref) => {
223
223
  fullWidth = false,
224
224
  prefix,
225
225
  suffix,
226
- intent = "primary",
226
+ color = "primary",
227
227
  variant = "filled",
228
228
  type = "button",
229
229
  size = "medium",
@@ -234,7 +234,7 @@ const Button = React.forwardRef((_a, ref) => {
234
234
  tabIndex,
235
235
  renderAs = "button"
236
236
  } = _a,
237
- rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "intent", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
237
+ rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "color", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs"]);
238
238
 
239
239
  return jsxs(StyledButton$1, Object.assign({
240
240
  "$as": renderAs,
@@ -242,7 +242,7 @@ const Button = React.forwardRef((_a, ref) => {
242
242
  disabled: disabled || loading,
243
243
  type: type,
244
244
  className: className,
245
- "$intent": intent,
245
+ "$color": color,
246
246
  "$fullWidth": fullWidth,
247
247
  "$variant": variant,
248
248
  "$size": size,
@@ -313,6 +313,7 @@ const IconContainer$2 = tw.div`
313
313
  */
314
314
  const generalColors = {
315
315
  PRIMARY: "primary",
316
+ SECONDARY: "secondary",
316
317
  ACCENT: "accent",
317
318
  NEUTRAL: "neutral"
318
319
  };
@@ -443,6 +444,9 @@ const Root$4 = tw.span`
443
444
  case colors.PRIMARY:
444
445
  return tws`tu-icon--primary`;
445
446
 
447
+ case colors.SECONDARY:
448
+ return tws`tu-icon--secondary`;
449
+
446
450
  case colors.ACCENT:
447
451
  return tws`tu-icon--accent`;
448
452
 
@@ -535,7 +539,7 @@ const ActionButton = ({
535
539
  children: jsx(StyledIconButton, {
536
540
  dataTestId: "testIconButtonId",
537
541
  size: "small",
538
- intent: "tertiary",
542
+ color: "tertiary",
539
543
  icon: jsx(Icon$1, {
540
544
  size: "small",
541
545
  name: getIconName()
@@ -688,7 +692,7 @@ const StyledText$4 = tw.text`
688
692
  */
689
693
 
690
694
  const Alert = ({
691
- intent = "info",
695
+ color = "info",
692
696
  title,
693
697
  className,
694
698
  children,
@@ -701,8 +705,8 @@ const Alert = ({
701
705
  }) => {
702
706
  const ref = React.useRef();
703
707
 
704
- const getIconFromIntent = () => {
705
- switch (intent) {
708
+ const getIconFromColor = () => {
709
+ switch (color) {
706
710
  case "danger":
707
711
  return jsx(Icon$1, {
708
712
  name: "ExclamationIcon",
@@ -728,8 +732,8 @@ const Alert = ({
728
732
  }
729
733
  };
730
734
 
731
- const getButtonIntent = () => {
732
- switch (intent) {
735
+ const getButtonColor = () => {
736
+ switch (color) {
733
737
  case "danger":
734
738
  return "danger";
735
739
 
@@ -770,7 +774,7 @@ const Alert = ({
770
774
  }
771
775
  }, [ref, autoScroll]);
772
776
  return jsxs(Container$8, Object.assign({
773
- "$intent": intent,
777
+ "$color": color,
774
778
  className: className,
775
779
  "data-testid": dataTestId,
776
780
  "$inline": inline,
@@ -780,7 +784,7 @@ const Alert = ({
780
784
  children: [jsx(IconContainer$1, Object.assign({
781
785
  "$inline": inline
782
786
  }, {
783
- children: getIconFromIntent()
787
+ children: getIconFromColor()
784
788
  })), jsxs(Content$1, Object.assign({
785
789
  "$inline": inline
786
790
  }, {
@@ -793,7 +797,7 @@ const Alert = ({
793
797
  children: jsx(IconButton, {
794
798
  size: "small",
795
799
  variant: "transparent",
796
- intent: "secondary",
800
+ color: "secondary",
797
801
  onClick: onClose,
798
802
  icon: jsx(Icon$1, {
799
803
  name: "XIcon",
@@ -809,14 +813,14 @@ const Alert = ({
809
813
  children: [secondaryAction && jsx(Button, Object.assign({
810
814
  size: "small",
811
815
  variant: "transparent",
812
- intent: getButtonIntent(),
816
+ color: getButtonColor(),
813
817
  onClick: secondaryAction.onClick,
814
818
  loading: secondaryAction === null || secondaryAction === void 0 ? void 0 : secondaryAction.loading
815
819
  }, {
816
820
  children: secondaryAction.label
817
821
  })), primaryAction && jsx(Button, Object.assign({
818
822
  size: "small",
819
- intent: getButtonIntent(),
823
+ color: getButtonColor(),
820
824
  onClick: primaryAction.onClick,
821
825
  loading: primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.loading
822
826
  }, {
@@ -827,7 +831,7 @@ const Alert = ({
827
831
  children: jsx(IconButton, {
828
832
  size: "small",
829
833
  variant: "transparent",
830
- intent: "secondary",
834
+ color: "secondary",
831
835
  onClick: onClose,
832
836
  icon: jsx(Icon$1, {
833
837
  name: "XIcon",
@@ -846,7 +850,7 @@ const CloseButtonContainer = tw.div`
846
850
  `;
847
851
 
848
852
  const getBackgroundColor = () => ({
849
- $intent
853
+ $color
850
854
  }) => {
851
855
  const colors = {
852
856
  danger: tws`tu-alert--danger`,
@@ -854,7 +858,7 @@ const getBackgroundColor = () => ({
854
858
  success: tws`tu-alert--success`,
855
859
  info: tws`tu-alert--info`
856
860
  };
857
- return colors[$intent];
861
+ return colors[$color];
858
862
  };
859
863
 
860
864
  const Container$8 = tw.div`
@@ -937,6 +941,7 @@ const getBadgeModifierClass = () => ({
937
941
  }) => {
938
942
  const colorClasses = {
939
943
  primary: $subtle ? tws`tu-badge--primary-subtle` : tws`tu-badge--primary`,
944
+ secondary: $subtle ? tws`tu-badge--secondary-subtle` : tws`tu-badge--secondary`,
940
945
  accent: $subtle ? tws`tu-badge--accent-subtle` : tws`tu-badge--accent`,
941
946
  success: $subtle ? tws`tu-badge--success-subtle` : tws`tu-badge--success`,
942
947
  danger: $subtle ? tws`tu-badge--danger-subtle` : tws`tu-badge--danger`,
@@ -1365,7 +1370,7 @@ const CardHeader = ({
1365
1370
  }), onClose && jsx(IconButton, {
1366
1371
  dataTestId: "card-header-close-button",
1367
1372
  variant: "transparent",
1368
- intent: "secondary",
1373
+ color: "secondary",
1369
1374
  onClick: onClose,
1370
1375
  icon: jsx(Icon$1, {
1371
1376
  name: "XIcon",
@@ -1735,7 +1740,7 @@ const Collapse = ({
1735
1740
  }),
1736
1741
  size: "medium",
1737
1742
  variant: "transparent",
1738
- intent: "secondary"
1743
+ color: "secondary"
1739
1744
  })]
1740
1745
  })
1741
1746
  })), jsx(Collapsible, Object.assign({
@@ -2161,7 +2166,7 @@ const DateInput = forwardRef((_a, ref) => {
2161
2166
  }),
2162
2167
  actions: selectedDay && jsx(RemoveValueContainer, {
2163
2168
  children: jsx(Button, Object.assign({
2164
- intent: "tertiary",
2169
+ color: "tertiary",
2165
2170
  onClick: e => {
2166
2171
  e.preventDefault();
2167
2172
  setSelectedDay(undefined);
@@ -2537,7 +2542,7 @@ const DayPickerPopover = ({
2537
2542
  className,
2538
2543
  selectedDay,
2539
2544
  onDaySelect,
2540
- intent = "secondary",
2545
+ color = "secondary",
2541
2546
  placement = "bottom",
2542
2547
  size = "small",
2543
2548
  buttonContent,
@@ -2558,7 +2563,7 @@ const DayPickerPopover = ({
2558
2563
  });
2559
2564
  return jsxs(Fragment$1, {
2560
2565
  children: [jsx(Button, Object.assign({
2561
- intent: intent,
2566
+ color: color,
2562
2567
  size: size,
2563
2568
  className: className,
2564
2569
  prefix: jsx(Icon$1, {
@@ -2690,6 +2695,9 @@ const Container$4 = tw.div`
2690
2695
  case colors.PRIMARY:
2691
2696
  return tws`tu-indicator--primary`;
2692
2697
 
2698
+ case colors.SECONDARY:
2699
+ return tws`tu-indicator--secondary`;
2700
+
2693
2701
  case colors.ACCENT:
2694
2702
  return tws`tu-indicator--accent`;
2695
2703
 
@@ -3275,6 +3283,7 @@ const getColorModifierClass = () => ({
3275
3283
  }) => {
3276
3284
  const colorClasses = {
3277
3285
  primary: tws`tu-tag--primary`,
3286
+ secondary: tws`tu-tag--secondary`,
3278
3287
  accent: tws`tu-tag--accent`,
3279
3288
  success: tws`tu-tag--success`,
3280
3289
  danger: tws`tu-tag--danger`,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.0.138",
3
+ "version": "0.0.139",
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.49",
7
+ "@trackunit/css-core": "0.0.50",
8
8
  "@trackunit/tailwind-styled-components": "0.0.43",
9
9
  "react": "17.0.1",
10
10
  "@trackunit/ui-design-tokens": "0.0.42",