@vitality-ds/components 4.3.4-alpha.0 → 4.4.0

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 (76) 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 +15 -3
  8. package/dist/Switch/styled.js +4 -2
  9. package/dist/Switch/styles/BaseSwitch.styles.js +9 -4
  10. package/dist/Switch/styles/BaseSwitchLabel.styles.js +23 -0
  11. package/dist/Switch/styles/BaseSwitchThumb.styles.js +15 -8
  12. package/dist/components/src/Form/FormField/types.d.ts +4 -0
  13. package/dist/components/src/Form/FormField/types.d.ts.map +1 -1
  14. package/dist/components/src/StatusBadge/StatusBadge.d.ts +2 -1
  15. package/dist/components/src/StatusBadge/StatusBadge.d.ts.map +1 -1
  16. package/dist/components/src/StatusBadge/StatusBadge.js +2 -2
  17. package/dist/components/src/StatusBadge/StatusBadge.js.map +1 -1
  18. package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts +2 -1
  19. package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts.map +1 -1
  20. package/dist/components/src/StatusBadge/StatusBadgeButton.js +2 -2
  21. package/dist/components/src/StatusBadge/StatusBadgeButton.js.map +1 -1
  22. package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts +2 -1
  23. package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts.map +1 -1
  24. package/dist/components/src/StatusBadge/StatusBadgeLink.js +2 -2
  25. package/dist/components/src/StatusBadge/StatusBadgeLink.js.map +1 -1
  26. package/dist/components/src/StatusBadge/types.d.ts +5 -0
  27. package/dist/components/src/StatusBadge/types.d.ts.map +1 -1
  28. package/dist/components/src/Switch/constants/labelDirections.d.ts +7 -0
  29. package/dist/components/src/Switch/constants/labelDirections.d.ts.map +1 -0
  30. package/dist/components/src/Switch/constants/labelDirections.js +13 -0
  31. package/dist/components/src/Switch/constants/labelDirections.js.map +1 -0
  32. package/dist/components/src/Switch/constants/size.d.ts +8 -0
  33. package/dist/components/src/Switch/constants/size.d.ts.map +1 -0
  34. package/dist/components/src/Switch/{constants.js → constants/size.js} +3 -4
  35. package/dist/components/src/Switch/constants/size.js.map +1 -0
  36. package/dist/components/src/Switch/constants/transitions.d.ts +6 -0
  37. package/dist/components/src/Switch/constants/transitions.d.ts.map +1 -0
  38. package/dist/components/src/Switch/constants/transitions.js +8 -0
  39. package/dist/components/src/Switch/constants/transitions.js.map +1 -0
  40. package/dist/components/src/Switch/index.d.ts +4 -2
  41. package/dist/components/src/Switch/index.d.ts.map +1 -1
  42. package/dist/components/src/Switch/index.js +9 -4
  43. package/dist/components/src/Switch/index.js.map +1 -1
  44. package/dist/components/src/Switch/styled.d.ts +713 -0
  45. package/dist/components/src/Switch/styled.d.ts.map +1 -1
  46. package/dist/components/src/Switch/styled.js +3 -1
  47. package/dist/components/src/Switch/styled.js.map +1 -1
  48. package/dist/components/src/Switch/styles/BaseSwitch.styles.d.ts.map +1 -1
  49. package/dist/components/src/Switch/styles/BaseSwitch.styles.js +7 -4
  50. package/dist/components/src/Switch/styles/BaseSwitch.styles.js.map +1 -1
  51. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts +366 -0
  52. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts.map +1 -0
  53. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js +20 -0
  54. package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js.map +1 -0
  55. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.d.ts.map +1 -1
  56. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js +11 -8
  57. package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js.map +1 -1
  58. package/dist/components/src/Switch/types.d.ts +10 -0
  59. package/dist/components/src/Switch/types.d.ts.map +1 -1
  60. package/dist/esm/StatusBadge/StatusBadge.js +4 -2
  61. package/dist/esm/StatusBadge/StatusBadgeButton.js +4 -2
  62. package/dist/esm/StatusBadge/StatusBadgeLink.js +4 -2
  63. package/dist/esm/Switch/constants/labelDirections.js +10 -0
  64. package/dist/esm/Switch/constants/size.js +7 -0
  65. package/dist/esm/Switch/constants/transitions.js +5 -0
  66. package/dist/esm/Switch/index.js +16 -4
  67. package/dist/esm/Switch/styled.js +3 -1
  68. package/dist/esm/Switch/styles/BaseSwitch.styles.js +9 -4
  69. package/dist/esm/Switch/styles/BaseSwitchLabel.styles.js +17 -0
  70. package/dist/esm/Switch/styles/BaseSwitchThumb.styles.js +15 -8
  71. package/dist/tsconfig.tsbuildinfo +1 -1
  72. package/package.json +5 -5
  73. package/dist/components/src/Switch/constants.d.ts +0 -10
  74. package/dist/components/src/Switch/constants.d.ts.map +0 -1
  75. package/dist/components/src/Switch/constants.js.map +0 -1
  76. package/dist/esm/Switch/constants.js +0 -8
@@ -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,18 @@ 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
+ disabled: disabled,
36
+ htmlFor: id
37
+ }, label), /*#__PURE__*/React.createElement(BaseSwitch, _extends({
26
38
  defaultChecked: defaultChecked,
27
39
  required: required,
28
40
  name: name,
@@ -34,7 +46,7 @@ var Switch = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
34
46
  ref: forwardedRef
35
47
  }, restProps), /*#__PURE__*/React.createElement(BaseSwitchThumb, {
36
48
  checked: checked
37
- }), checked ? /*#__PURE__*/React.createElement(Done, iconProps) : /*#__PURE__*/React.createElement(Close, iconProps));
49
+ }), checked ? /*#__PURE__*/React.createElement(Done, iconProps) : /*#__PURE__*/React.createElement(Close, iconProps)));
38
50
  });
39
51
  Switch.displayName = "Switch";
40
52
  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",
@@ -39,8 +44,8 @@ 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: {
@@ -0,0 +1,17 @@
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
+ variants: {
10
+ disabled: {
11
+ "true": {
12
+ cursor: "not-allowed",
13
+ color: getColorScaleValueByUseCase("neutral", text.disabled)
14
+ }
15
+ }
16
+ }
17
+ });
@@ -1,23 +1,30 @@
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
29
  backgroundColor: getColorScaleValueByUseCase("primary", text.disabled)
23
30
  }