@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.
- package/dist/StatusBadge/StatusBadge.js +4 -2
- package/dist/StatusBadge/StatusBadgeButton.js +4 -2
- package/dist/StatusBadge/StatusBadgeLink.js +4 -2
- package/dist/Switch/constants/labelDirections.js +16 -0
- package/dist/Switch/{constants.js → constants/size.js} +4 -5
- package/dist/Switch/constants/transitions.js +11 -0
- package/dist/Switch/index.js +15 -3
- package/dist/Switch/styled.js +4 -2
- package/dist/Switch/styles/BaseSwitch.styles.js +9 -4
- package/dist/Switch/styles/BaseSwitchLabel.styles.js +23 -0
- package/dist/Switch/styles/BaseSwitchThumb.styles.js +15 -8
- package/dist/components/src/Form/FormField/types.d.ts +4 -0
- package/dist/components/src/Form/FormField/types.d.ts.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadge.d.ts +2 -1
- package/dist/components/src/StatusBadge/StatusBadge.d.ts.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadge.js +2 -2
- package/dist/components/src/StatusBadge/StatusBadge.js.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts +2 -1
- package/dist/components/src/StatusBadge/StatusBadgeButton.d.ts.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadgeButton.js +2 -2
- package/dist/components/src/StatusBadge/StatusBadgeButton.js.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts +2 -1
- package/dist/components/src/StatusBadge/StatusBadgeLink.d.ts.map +1 -1
- package/dist/components/src/StatusBadge/StatusBadgeLink.js +2 -2
- package/dist/components/src/StatusBadge/StatusBadgeLink.js.map +1 -1
- package/dist/components/src/StatusBadge/types.d.ts +5 -0
- package/dist/components/src/StatusBadge/types.d.ts.map +1 -1
- package/dist/components/src/Switch/constants/labelDirections.d.ts +7 -0
- package/dist/components/src/Switch/constants/labelDirections.d.ts.map +1 -0
- package/dist/components/src/Switch/constants/labelDirections.js +13 -0
- package/dist/components/src/Switch/constants/labelDirections.js.map +1 -0
- package/dist/components/src/Switch/constants/size.d.ts +8 -0
- package/dist/components/src/Switch/constants/size.d.ts.map +1 -0
- package/dist/components/src/Switch/{constants.js → constants/size.js} +3 -4
- package/dist/components/src/Switch/constants/size.js.map +1 -0
- package/dist/components/src/Switch/constants/transitions.d.ts +6 -0
- package/dist/components/src/Switch/constants/transitions.d.ts.map +1 -0
- package/dist/components/src/Switch/constants/transitions.js +8 -0
- package/dist/components/src/Switch/constants/transitions.js.map +1 -0
- package/dist/components/src/Switch/index.d.ts +4 -2
- package/dist/components/src/Switch/index.d.ts.map +1 -1
- package/dist/components/src/Switch/index.js +9 -4
- package/dist/components/src/Switch/index.js.map +1 -1
- package/dist/components/src/Switch/styled.d.ts +713 -0
- package/dist/components/src/Switch/styled.d.ts.map +1 -1
- package/dist/components/src/Switch/styled.js +3 -1
- package/dist/components/src/Switch/styled.js.map +1 -1
- package/dist/components/src/Switch/styles/BaseSwitch.styles.d.ts.map +1 -1
- package/dist/components/src/Switch/styles/BaseSwitch.styles.js +7 -4
- package/dist/components/src/Switch/styles/BaseSwitch.styles.js.map +1 -1
- package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts +366 -0
- package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.d.ts.map +1 -0
- package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js +20 -0
- package/dist/components/src/Switch/styles/BaseSwitchLabel.styles.js.map +1 -0
- package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.d.ts.map +1 -1
- package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js +11 -8
- package/dist/components/src/Switch/styles/BaseSwitchThumb.styles.js.map +1 -1
- package/dist/components/src/Switch/types.d.ts +10 -0
- package/dist/components/src/Switch/types.d.ts.map +1 -1
- package/dist/esm/StatusBadge/StatusBadge.js +4 -2
- package/dist/esm/StatusBadge/StatusBadgeButton.js +4 -2
- package/dist/esm/StatusBadge/StatusBadgeLink.js +4 -2
- package/dist/esm/Switch/constants/labelDirections.js +10 -0
- package/dist/esm/Switch/constants/size.js +7 -0
- package/dist/esm/Switch/constants/transitions.js +5 -0
- package/dist/esm/Switch/index.js +16 -4
- package/dist/esm/Switch/styled.js +3 -1
- package/dist/esm/Switch/styles/BaseSwitch.styles.js +9 -4
- package/dist/esm/Switch/styles/BaseSwitchLabel.styles.js +17 -0
- package/dist/esm/Switch/styles/BaseSwitchThumb.styles.js +15 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/components/src/Switch/constants.d.ts +0 -10
- package/dist/components/src/Switch/constants.d.ts.map +0 -1
- package/dist/components/src/Switch/constants.js.map +0 -1
- package/dist/esm/Switch/constants.js +0 -8
package/dist/esm/Switch/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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(
|
|
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:
|
|
43
|
-
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
|
|
3
|
-
|
|
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:
|
|
8
|
-
height:
|
|
14
|
+
width: THUMB,
|
|
15
|
+
height: THUMB,
|
|
9
16
|
borderRadius: "$rounded",
|
|
10
|
-
transition: "transform ".concat(
|
|
11
|
-
transform: "translateX(".concat(
|
|
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",
|
|
22
|
+
backgroundColor: getColorScaleValueByUseCase("neutral", backgrounds.uiElement)
|
|
16
23
|
},
|
|
17
24
|
variants: {
|
|
18
25
|
checked: {
|
|
19
26
|
"true": {
|
|
20
|
-
transform: "translateX(".concat(
|
|
27
|
+
transform: "translateX(".concat(TRACK_WIDTH - THUMB - INSET_SPACING, "px)"),
|
|
21
28
|
"&[data-disabled]": {
|
|
22
29
|
backgroundColor: getColorScaleValueByUseCase("primary", text.disabled)
|
|
23
30
|
}
|