@vitality-ds/components 4.3.4 → 4.4.1

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.
Files changed (74) hide show
  1. package/dist/StatusBadge/StatusBadge.js +4 -2
  2. package/dist/StatusBadge/StatusBadgeButton.js +4 -2
  3. package/dist/StatusBadge/StatusBadgeLink.js +4 -2
  4. package/dist/Switch/constants/labelDirections.js +16 -0
  5. package/dist/Switch/{constants.js → constants/size.js} +4 -5
  6. package/dist/Switch/constants/transitions.js +11 -0
  7. package/dist/Switch/index.js +16 -3
  8. package/dist/Switch/styled.js +4 -2
  9. package/dist/Switch/styles/BaseSwitch.styles.js +14 -9
  10. package/dist/Switch/styles/BaseSwitchLabel.styles.js +39 -0
  11. package/dist/Switch/styles/BaseSwitchThumb.styles.js +16 -9
  12. package/dist/components/src/StatusBadge/StatusBadge.d.ts +2 -1
  13. package/dist/components/src/StatusBadge/StatusBadge.d.ts.map +1 -1
  14. package/dist/components/src/StatusBadge/StatusBadge.js +2 -2
  15. package/dist/components/src/StatusBadge/StatusBadge.js.map +1 -1
  16. package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts +2 -1
  17. package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts.map +1 -1
  18. package/dist/components/src/StatusBadge/StatusBadgeButton.js +2 -2
  19. package/dist/components/src/StatusBadge/StatusBadgeButton.js.map +1 -1
  20. package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts +2 -1
  21. package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts.map +1 -1
  22. package/dist/components/src/StatusBadge/StatusBadgeLink.js +2 -2
  23. package/dist/components/src/StatusBadge/StatusBadgeLink.js.map +1 -1
  24. package/dist/components/src/StatusBadge/types.d.ts +5 -0
  25. package/dist/components/src/StatusBadge/types.d.ts.map +1 -1
  26. package/dist/components/src/Switch/constants/labelDirections.d.ts +7 -0
  27. package/dist/components/src/Switch/constants/labelDirections.d.ts.map +1 -0
  28. package/dist/components/src/Switch/constants/labelDirections.js +13 -0
  29. package/dist/components/src/Switch/constants/labelDirections.js.map +1 -0
  30. package/dist/components/src/Switch/constants/size.d.ts +8 -0
  31. package/dist/components/src/Switch/constants/size.d.ts.map +1 -0
  32. package/dist/components/src/Switch/{constants.js → constants/size.js} +3 -4
  33. package/dist/components/src/Switch/constants/size.js.map +1 -0
  34. package/dist/components/src/Switch/constants/transitions.d.ts +6 -0
  35. package/dist/components/src/Switch/constants/transitions.d.ts.map +1 -0
  36. package/dist/components/src/Switch/constants/transitions.js +8 -0
  37. package/dist/components/src/Switch/constants/transitions.js.map +1 -0
  38. package/dist/components/src/Switch/index.d.ts +4 -2
  39. package/dist/components/src/Switch/index.d.ts.map +1 -1
  40. package/dist/components/src/Switch/index.js +9 -4
  41. package/dist/components/src/Switch/index.js.map +1 -1
  42. package/dist/components/src/Switch/styled.d.ts +728 -0
  43. package/dist/components/src/Switch/styled.d.ts.map +1 -1
  44. package/dist/components/src/Switch/styled.js +3 -1
  45. package/dist/components/src/Switch/styled.js.map +1 -1
  46. package/dist/components/src/Switch/styles/BaseSwitch.styles.d.ts.map +1 -1
  47. package/dist/components/src/Switch/styles/BaseSwitch.styles.js +12 -9
  48. package/dist/components/src/Switch/styles/BaseSwitch.styles.js.map +1 -1
  49. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts +381 -0
  50. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts.map +1 -0
  51. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js +35 -0
  52. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js.map +1 -0
  53. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.d.ts.map +1 -1
  54. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js +12 -9
  55. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js.map +1 -1
  56. package/dist/components/src/Switch/types.d.ts +10 -0
  57. package/dist/components/src/Switch/types.d.ts.map +1 -1
  58. package/dist/esm/StatusBadge/StatusBadge.js +4 -2
  59. package/dist/esm/StatusBadge/StatusBadgeButton.js +4 -2
  60. package/dist/esm/StatusBadge/StatusBadgeLink.js +4 -2
  61. package/dist/esm/Switch/constants/labelDirections.js +10 -0
  62. package/dist/esm/Switch/constants/size.js +7 -0
  63. package/dist/esm/Switch/constants/transitions.js +5 -0
  64. package/dist/esm/Switch/index.js +17 -4
  65. package/dist/esm/Switch/styled.js +3 -1
  66. package/dist/esm/Switch/styles/BaseSwitch.styles.js +14 -9
  67. package/dist/esm/Switch/styles/BaseSwitchLabel.styles.js +33 -0
  68. package/dist/esm/Switch/styles/BaseSwitchThumb.styles.js +16 -9
  69. package/dist/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +5 -5
  71. package/dist/components/src/Switch/constants.d.ts +0 -10
  72. package/dist/components/src/Switch/constants.d.ts.map +0 -1
  73. package/dist/components/src/Switch/constants.js.map +0 -1
  74. package/dist/esm/Switch/constants.js +0 -8
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label", "icon", "importance", "severity", "css", "style", "className", "as", "onClick"];
3
+ var _excluded = ["label", "icon", "hideIcon", "importance", "severity", "css", "style", "className", "as", "onClick"];
4
4
  import React from "react";
5
5
  import StatusBadgeIcon from "./components/StatusBadgeIcon";
6
6
  import { getIcon } from "./logic";
@@ -8,6 +8,8 @@ import { BaseStatusBadgeButton } from "./styled";
8
8
  var StatusBadgeButton = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
9
9
  var label = _ref.label,
10
10
  icon = _ref.icon,
11
+ _ref$hideIcon = _ref.hideIcon,
12
+ hideIcon = _ref$hideIcon === void 0 ? false : _ref$hideIcon,
11
13
  _ref$importance = _ref.importance,
12
14
  importance = _ref$importance === void 0 ? "normal" : _ref$importance,
13
15
  _ref$severity = _ref.severity,
@@ -24,7 +26,7 @@ var StatusBadgeButton = /*#__PURE__*/React.forwardRef(function (_ref, forwardedR
24
26
  ref: forwardedRef,
25
27
  importance: importance,
26
28
  severity: severity
27
- }, restProps), /*#__PURE__*/React.createElement(StatusBadgeIcon, null, icon || getIcon(severity)), label);
29
+ }, restProps), !hideIcon && /*#__PURE__*/React.createElement(StatusBadgeIcon, null, icon || getIcon(severity)), label);
28
30
  });
29
31
  StatusBadgeButton.displayName = "StatusBadgeButton";
30
32
  export default StatusBadgeButton;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["label", "icon", "importance", "severity", "css", "style", "className", "as", "href", "target"];
3
+ var _excluded = ["label", "icon", "hideIcon", "importance", "severity", "css", "style", "className", "as", "href", "target"];
4
4
  import React from "react";
5
5
  import StatusBadgeIcon from "./components/StatusBadgeIcon";
6
6
  import { getIcon } from "./logic";
@@ -8,6 +8,8 @@ import { BaseStatusBadgeLink } from "./styled";
8
8
  var StatusBadgeLink = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
9
9
  var label = _ref.label,
10
10
  icon = _ref.icon,
11
+ _ref$hideIcon = _ref.hideIcon,
12
+ hideIcon = _ref$hideIcon === void 0 ? false : _ref$hideIcon,
11
13
  _ref$importance = _ref.importance,
12
14
  importance = _ref$importance === void 0 ? "normal" : _ref$importance,
13
15
  _ref$severity = _ref.severity,
@@ -26,7 +28,7 @@ var StatusBadgeLink = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef
26
28
  ref: forwardedRef,
27
29
  importance: importance,
28
30
  severity: severity
29
- }, restProps), /*#__PURE__*/React.createElement(StatusBadgeIcon, null, icon || getIcon(severity)), label);
31
+ }, restProps), !hideIcon && /*#__PURE__*/React.createElement(StatusBadgeIcon, null, icon || getIcon(severity)), label);
30
32
  });
31
33
  StatusBadgeLink.displayName = "StatusBadgeLink";
32
34
  export default StatusBadgeLink;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Below values relate to direction property of the
3
+ */
4
+ var LABEL_DIRECTIONS = {
5
+ top: "vertical",
6
+ bottom: "verticalReverse",
7
+ left: "horizontal",
8
+ right: "horizontalReverse"
9
+ };
10
+ export default LABEL_DIRECTIONS;
@@ -0,0 +1,7 @@
1
+ var SIZE = {
2
+ INSET_SPACING: 2,
3
+ THUMB: 16,
4
+ TRACK_WIDTH: 40,
5
+ TRACK_HEIGHT: 20
6
+ };
7
+ export default SIZE;
@@ -0,0 +1,5 @@
1
+ var TRANSITION = {
2
+ DURATION_MS: 250,
3
+ TIMING_FUNCTION: "cubic-bezier(0.22, 1, 0.36, 1)"
4
+ };
5
+ export default TRANSITION;
@@ -1,9 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["defaultChecked", "required", "name", "value", "id", "checked", "onCheckedChange", "disabled", "style", "className", "as", "css"];
3
+ var _excluded = ["defaultChecked", "required", "name", "value", "id", "checked", "onCheckedChange", "disabled", "style", "className", "as", "css", "labelPosition", "label"];
4
4
  import { Close, Done } from "@vitality-ds/icons";
5
5
  import React from "react";
6
- import { BaseSwitch, BaseSwitchThumb } from "./styled";
6
+ import Stack from "../Stack";
7
+ import LABEL_DIRECTIONS from "./constants/labelDirections";
8
+ import { BaseSwitch, BaseSwitchLabel, BaseSwitchThumb } from "./styled";
7
9
  var iconProps = {
8
10
  color: "inherit",
9
11
  size: "inherit"
@@ -21,8 +23,19 @@ var Switch = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
21
23
  className = _ref.className,
22
24
  as = _ref.as,
23
25
  css = _ref.css,
26
+ _ref$labelPosition = _ref.labelPosition,
27
+ labelPosition = _ref$labelPosition === void 0 ? "left" : _ref$labelPosition,
28
+ label = _ref.label,
24
29
  restProps = _objectWithoutProperties(_ref, _excluded);
25
- return /*#__PURE__*/React.createElement(BaseSwitch, _extends({
30
+ var direction = LABEL_DIRECTIONS[labelPosition];
31
+ return /*#__PURE__*/React.createElement(Stack, {
32
+ direction: direction,
33
+ align: "center"
34
+ }, label && /*#__PURE__*/React.createElement(BaseSwitchLabel, {
35
+ direction: labelPosition,
36
+ disabled: disabled,
37
+ htmlFor: id
38
+ }, label), /*#__PURE__*/React.createElement(BaseSwitch, _extends({
26
39
  defaultChecked: defaultChecked,
27
40
  required: required,
28
41
  name: name,
@@ -34,7 +47,7 @@ var Switch = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
34
47
  ref: forwardedRef
35
48
  }, restProps), /*#__PURE__*/React.createElement(BaseSwitchThumb, {
36
49
  checked: checked
37
- }), checked ? /*#__PURE__*/React.createElement(Done, iconProps) : /*#__PURE__*/React.createElement(Close, iconProps));
50
+ }), checked ? /*#__PURE__*/React.createElement(Done, iconProps) : /*#__PURE__*/React.createElement(Close, iconProps)));
38
51
  });
39
52
  Switch.displayName = "Switch";
40
53
  export default Switch;
@@ -1,6 +1,8 @@
1
1
  import { Root as SwitchPrimitiveRoot, Thumb as SwitchPrimitiveThumb } from "@radix-ui/react-switch";
2
2
  import { styled } from "@vitality-ds/system";
3
3
  import baseSwitchStyles from "./styles/BaseSwitch.styles";
4
+ import baseSwitchLabelStyles from "./styles/BaseSwitchLabel.styles";
4
5
  import baseSwitchThumbStyles from "./styles/BaseSwitchThumb.styles";
5
6
  export var BaseSwitchThumb = styled(SwitchPrimitiveThumb, baseSwitchThumbStyles);
6
- export var BaseSwitch = styled(SwitchPrimitiveRoot, baseSwitchStyles);
7
+ export var BaseSwitch = styled(SwitchPrimitiveRoot, baseSwitchStyles);
8
+ export var BaseSwitchLabel = styled("label", baseSwitchLabelStyles);
@@ -1,8 +1,13 @@
1
1
  import { colorUseCases, css, getColorScaleValueByUseCase } from "@vitality-ds/system";
2
- import CONFIG from "../constants";
2
+ import SIZE from "../constants/size";
3
+ import TRANSITION from "../constants/transitions";
3
4
  var text = colorUseCases.text,
4
5
  backgrounds = colorUseCases.backgrounds,
5
6
  borders = colorUseCases.borders;
7
+ var DURATION_MS = TRANSITION.DURATION_MS,
8
+ TIMING_FUNCTION = TRANSITION.TIMING_FUNCTION;
9
+ var TRACK_WIDTH = SIZE.TRACK_WIDTH,
10
+ TRACK_HEIGHT = SIZE.TRACK_HEIGHT;
6
11
  export default css({
7
12
  all: "unset",
8
13
  boxSizing: "border-box",
@@ -15,7 +20,7 @@ export default css({
15
20
  lineHeight: 1,
16
21
  margin: "0",
17
22
  outline: "none",
18
- transition: "background-color ".concat(CONFIG.TRANSITION_DURATION_MS, "ms ").concat(CONFIG.TRANSITION_TIMING_FUNCTION),
23
+ transition: "background-color ".concat(DURATION_MS, "ms ").concat(TIMING_FUNCTION),
19
24
  borderRadius: "$rounded",
20
25
  position: "relative",
21
26
  cursor: "pointer",
@@ -25,7 +30,7 @@ export default css({
25
30
  cursor: "not-allowed",
26
31
  "&, &:hover": {
27
32
  backgroundColor: getColorScaleValueByUseCase("neutral", backgrounds.uiElementSolid_disabled),
28
- color: getColorScaleValueByUseCase("neutral", text.onSolidBackgrounds)
33
+ color: getColorScaleValueByUseCase("neutral", text.disabled)
29
34
  }
30
35
  },
31
36
  "&:hover": {
@@ -39,21 +44,21 @@ export default css({
39
44
  variants: {
40
45
  size: {
41
46
  "1": {
42
- width: CONFIG.TRACK_WIDTH,
43
- height: CONFIG.TRACK_HEIGHT
47
+ width: TRACK_WIDTH,
48
+ height: TRACK_HEIGHT
44
49
  }
45
50
  },
46
51
  checked: {
47
52
  "true": {
48
53
  justifyContent: "flex-start",
49
- backgroundColor: getColorScaleValueByUseCase("primary", backgrounds.uiElementSolid_active),
54
+ backgroundColor: getColorScaleValueByUseCase("primary", backgrounds.uiElementSolid),
50
55
  "&:hover": {
51
- backgroundColor: getColorScaleValueByUseCase("primary", backgrounds.uiElementSolid_hovered)
56
+ backgroundColor: getColorScaleValueByUseCase("primary", backgrounds.uiElementSolid_active)
52
57
  },
53
58
  "&[data-disabled]": {
54
59
  "&, &:hover": {
55
- backgroundColor: getColorScaleValueByUseCase("primary", backgrounds.uiElementSolid_disabled),
56
- color: getColorScaleValueByUseCase("primary", text.disabled)
60
+ backgroundColor: getColorScaleValueByUseCase("neutral", backgrounds.uiElementSolid_disabled),
61
+ color: getColorScaleValueByUseCase("neutral", text.disabled)
57
62
  }
58
63
  }
59
64
  }
@@ -0,0 +1,33 @@
1
+ import { colorUseCases, css, getColorScaleValueByUseCase } from "@vitality-ds/system";
2
+ var text = colorUseCases.text;
3
+ export default css({
4
+ fontSize: "$body",
5
+ cursor: "pointer",
6
+ whiteSpace: "pre",
7
+ textWrap: "auto",
8
+ flex: 1,
9
+ marginBottom: 0,
10
+ // Gentu global style override
11
+ variants: {
12
+ disabled: {
13
+ "true": {
14
+ cursor: "not-allowed",
15
+ color: getColorScaleValueByUseCase("neutral", text.disabled)
16
+ }
17
+ },
18
+ direction: {
19
+ top: {
20
+ textAlign: "center"
21
+ },
22
+ bottom: {
23
+ textAlign: "center"
24
+ },
25
+ left: {
26
+ textAlign: "right"
27
+ },
28
+ right: {
29
+ textAlign: "left"
30
+ }
31
+ }
32
+ }
33
+ });
@@ -1,25 +1,32 @@
1
1
  import { colorUseCases, css, getColorScaleValueByUseCase } from "@vitality-ds/system";
2
- import CONFIG from "../constants";
3
- var text = colorUseCases.text;
2
+ import SIZE from "../constants/size";
3
+ import TRANSITION from "../constants/transitions";
4
+ var text = colorUseCases.text,
5
+ backgrounds = colorUseCases.backgrounds;
6
+ var THUMB = SIZE.THUMB,
7
+ INSET_SPACING = SIZE.INSET_SPACING,
8
+ TRACK_WIDTH = SIZE.TRACK_WIDTH;
9
+ var DURATION_MS = TRANSITION.DURATION_MS,
10
+ TIMING_FUNCTION = TRANSITION.TIMING_FUNCTION;
4
11
  export default css({
5
12
  position: "absolute",
6
13
  left: 0,
7
- width: CONFIG.THUMB,
8
- height: CONFIG.THUMB,
14
+ width: THUMB,
15
+ height: THUMB,
9
16
  borderRadius: "$rounded",
10
- transition: "transform ".concat(CONFIG.TRANSITION_DURATION_MS, "ms ").concat(CONFIG.TRANSITION_TIMING_FUNCTION),
11
- transform: "translateX(".concat(CONFIG.INSET_SPACING, "px)"),
17
+ transition: "transform ".concat(DURATION_MS, "ms ").concat(TIMING_FUNCTION),
18
+ transform: "translateX(".concat(INSET_SPACING, "px)"),
12
19
  willChange: "transform",
13
20
  backgroundColor: getColorScaleValueByUseCase("neutral", text.onSolidBackgrounds),
14
21
  "&[data-disabled]": {
15
- backgroundColor: getColorScaleValueByUseCase("neutral", text.onSolidBackgrounds)
22
+ backgroundColor: getColorScaleValueByUseCase("neutral", backgrounds.uiElement)
16
23
  },
17
24
  variants: {
18
25
  checked: {
19
26
  "true": {
20
- transform: "translateX(".concat(CONFIG.TRACK_WIDTH - CONFIG.THUMB - CONFIG.INSET_SPACING, "px)"),
27
+ transform: "translateX(".concat(TRACK_WIDTH - THUMB - INSET_SPACING, "px)"),
21
28
  "&[data-disabled]": {
22
- backgroundColor: getColorScaleValueByUseCase("primary", text.disabled)
29
+ backgroundColor: getColorScaleValueByUseCase("neutral", text.disabled)
23
30
  }
24
31
  }
25
32
  }