@occmundial/occ-atomic 3.0.0-beta.2 → 3.0.0-beta.21

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 (44) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/build/Banner/Banner.js +30 -40
  3. package/build/Banner/Banner.test.js +64 -17
  4. package/build/Banner/__snapshots__/Banner.test.js.snap +0 -28
  5. package/build/Banner/index.js +1 -6
  6. package/build/Button/__snapshots__/Button.test.js.snap +18 -20
  7. package/build/Button/styles.js +6 -8
  8. package/build/Checkbox/Checkbox.js +48 -3
  9. package/build/Checkbox/__snapshots__/Checkbox.test.js.snap +81 -49
  10. package/build/Checkbox/styles.js +91 -48
  11. package/build/Pill/Choice/Choice.js +73 -81
  12. package/build/Pill/Choice/styles.js +64 -20
  13. package/build/Pill/Group/Group.js +5 -2
  14. package/build/Pill/Group/styles.js +31 -31
  15. package/build/Pill/Pill.js +4 -3
  16. package/build/Pill/Stack/Stack.js +7 -12
  17. package/build/Pill/Stack/styles.js +43 -33
  18. package/build/Pill/__snapshots__/Pill.test.js.snap +14 -24
  19. package/build/Pill/styles.js +22 -27
  20. package/build/Radio/Radio.js +42 -6
  21. package/build/Radio/__snapshots__/Radio.test.js.snap +81 -80
  22. package/build/Radio/styles.js +93 -85
  23. package/build/SlideToggle/SlideToggle.js +38 -6
  24. package/build/SlideToggle/SlideToggle.test.js +2 -2
  25. package/build/SlideToggle/__snapshots__/SlideToggle.test.js.snap +53 -37
  26. package/build/SlideToggle/styles.js +65 -45
  27. package/build/Text/Text.js +4 -2
  28. package/build/TextField/TextField.js +7 -6
  29. package/build/TextField/__snapshots__/TextField.test.js.snap +3 -0
  30. package/build/TextField/styles.js +3 -0
  31. package/build/Tip/Tip.js +52 -95
  32. package/build/Tip/Tip.test.js +29 -6
  33. package/build/Tip/TipText/index.js +32 -0
  34. package/build/Tip/__snapshots__/Tip.test.js.snap +85 -15
  35. package/build/Tip/styles.js +80 -31
  36. package/build/Toaster/Toast/Toast.js +69 -64
  37. package/build/Toaster/Toast/styles.js +72 -46
  38. package/build/Toaster/Toaster.js +3 -2
  39. package/build/Toaster/Toaster.test.js +5 -2
  40. package/build/Toaster/__snapshots__/Toaster.test.js.snap +1 -1
  41. package/build/Toaster/styles.js +3 -3
  42. package/build/tokens/colors.json +3 -3
  43. package/package.json +4 -1
  44. package/build/Banner/styles.js +0 -41
@@ -13,6 +13,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _Text = _interopRequireDefault(require("../Text"));
15
15
 
16
+ var _Icon = _interopRequireDefault(require("../Icon"));
17
+
18
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
19
+
16
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
21
 
18
22
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -53,6 +57,7 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
53
57
  undetermined: props.undetermined
54
58
  };
55
59
  _this.toggle = _this.toggle.bind(_assertThisInitialized(_this));
60
+ _this.handleKeyUp = _this.handleKeyUp.bind(_assertThisInitialized(_this));
56
61
  return _this;
57
62
  }
58
63
 
@@ -81,6 +86,20 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
81
86
  if (onChange) onChange(value, id);
82
87
  }
83
88
  }
89
+ }, {
90
+ key: "handleKeyDown",
91
+ value: function handleKeyDown(e) {
92
+ if (e.keyCode == 13 || e.keyCode == 32) {
93
+ e.preventDefault();
94
+ }
95
+ }
96
+ }, {
97
+ key: "handleKeyUp",
98
+ value: function handleKeyUp(e) {
99
+ if (e.keyCode == 13 || e.keyCode == 32) {
100
+ this.toggle();
101
+ }
102
+ }
84
103
  }, {
85
104
  key: "render",
86
105
  value: function render() {
@@ -96,11 +115,16 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
96
115
  id = _this$props2.id,
97
116
  className = _this$props2.className,
98
117
  style = _this$props2.style,
118
+ alignLeft = _this$props2.alignLeft,
99
119
  trk = _this$props2.trk,
100
120
  testId = _this$props2.testId;
101
121
  var iconClass = undetermined ? " ".concat(classes.undetermined) : value ? " ".concat(classes.active) : '';
122
+ var iconColor = disabled ? _colors["default"].icon.brand.disabled : _colors["default"].icon.inverse["default"];
102
123
  return /*#__PURE__*/_react["default"].createElement("div", _extends({
103
124
  id: id,
125
+ tabIndex: disabled ? -1 : 0,
126
+ onKeyDown: this.handleKeyDown,
127
+ onKeyUp: this.handleKeyUp,
104
128
  className: "".concat(classes.cont).concat(iconClass).concat(disabled ? " ".concat(classes.disabled) : '').concat(className ? " ".concat(className) : ''),
105
129
  onClick: this.toggle,
106
130
  style: style,
@@ -108,16 +132,34 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
108
132
  }, testId && {
109
133
  'data-value': value ? 1 : 0
110
134
  }), /*#__PURE__*/_react["default"].createElement("div", {
135
+ className: classes.checkWrap
136
+ }, /*#__PURE__*/_react["default"].createElement("div", {
111
137
  className: classes.check,
112
138
  id: trk
113
- }), label && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
139
+ }, /*#__PURE__*/_react["default"].createElement("div", {
140
+ className: classes.box
141
+ }), undetermined && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
142
+ iconName: "minus",
143
+ width: 16,
144
+ height: 16,
145
+ colors: [iconColor],
146
+ className: classes.icon
147
+ }), !undetermined && value && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
148
+ iconName: "check",
149
+ width: 16,
150
+ height: 16,
151
+ colors: [iconColor],
152
+ className: classes.icon
153
+ }))), !!(label || right) && /*#__PURE__*/_react["default"].createElement("div", {
154
+ className: classes.labelWrap
155
+ }, label && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
114
156
  tag: "label",
115
- className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '')
157
+ className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '').concat(alignLeft ? " ".concat(classes.alignLeft) : '')
116
158
  }, label), right && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
117
159
  tag: "label",
118
160
  mid: true,
119
161
  className: classes.right
120
- }, right));
162
+ }, right)));
121
163
  }
122
164
  }]);
123
165
 
@@ -148,6 +190,9 @@ Checkbox.propTypes = {
148
190
  /** Use this prop to overflow the text of the label, adding '...' and the end. */
149
191
  textOverflow: _propTypes["default"].bool,
150
192
 
193
+ /** Align the content to the left */
194
+ alignLeft: _propTypes["default"].bool,
195
+
151
196
  /** Id for catching selected element for tracking. */
152
197
  trk: _propTypes["default"].string,
153
198
  id: _propTypes["default"].string,
@@ -5,68 +5,103 @@ exports[`Checkbox matches the snapshot 1`] = `ShallowWrapper {}`;
5
5
  exports[`Checkbox styles matches the snapshot 1`] = `
6
6
  Object {
7
7
  "active": Object {
8
- "& $check:after": Object {
9
- "background": Array [
10
- "url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJCQkgdmlld0JveD0iMCAwIDI0IDI0IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgoJCTxwYXRoIGZpbGw9IiMwODNjYWUiIGQ9Ik0xOC4zLDcuM2wxLjQsMS40bC04LjcsOWMtMC40LDAuNC0xLDAuNC0xLjQsMC4xbC00LjMtMy42bDEuMy0xLjVsMy42LDNDMTAuMiwxNS42LDE4LjMsNy4zLDE4LjMsNy4zeiIvPgoJCTwvc3ZnPg==)",
11
- "!important",
12
- ],
8
+ "& $check $box": Object {
9
+ "background": "#0059CD",
10
+ "boxShadow": "inset 0 0 0 1px rgba(255,255,255,0.2)",
13
11
  },
14
12
  },
13
+ "alignLeft": Object {
14
+ "flex": "none",
15
+ },
16
+ "box": Object {
17
+ "background": "#fff",
18
+ "borderRadius": "4px",
19
+ "boxShadow": "inset 0 0 0 1px #D3D4DC",
20
+ "gridColumnStart": 1,
21
+ "gridRowStart": 1,
22
+ "height": 20,
23
+ "transition": "all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s",
24
+ "width": 20,
25
+ },
15
26
  "check": Object {
16
- "&:after": Object {
17
- "background": "transparent",
18
- "content": "\\"\\"",
19
- "height": 18,
20
- "left": "50%",
21
- "marginTop": -1,
22
- "position": "absolute",
23
- "top": "50%",
24
- "transform": "translate(-50%, -50%)",
25
- "transition": "0.3s all",
26
- "width": 18,
27
- },
28
- "&:before": Object {
29
- "background": "#ffffff",
30
- "border": "1px solid #dddddd",
31
- "borderRadius": 4,
32
- "content": "\\"\\"",
33
- "height": 16,
34
- "left": "50%",
35
- "position": "absolute",
36
- "top": "50%",
37
- "transform": "translate(-50%, -50%)",
38
- "width": 16,
39
- },
40
- "height": 24,
41
- "position": "relative",
42
- "width": 24,
27
+ "alignItems": "center",
28
+ "borderRadius": "4px",
29
+ "display": "grid",
30
+ "height": 20,
31
+ "justifyContent": "center",
32
+ "transition": "all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s",
33
+ "width": 20,
34
+ },
35
+ "checkWrap": Object {
36
+ "alignItems": "center",
37
+ "display": "flex",
38
+ "flexShrink": 0,
39
+ "height": 48,
40
+ "justifyContent": "center",
41
+ "width": 52,
43
42
  },
44
43
  "cont": Object {
44
+ "&$active, &$undetermined": Object {
45
+ "&:active $check $box": Object {
46
+ "background": "#083CAE",
47
+ "boxShadow": "inset 0 0 0 2px rgba(255,255,255,0.2)",
48
+ },
49
+ "&:hover $check $box": Object {
50
+ "background": "#083CAE",
51
+ "boxShadow": "inset 0 0 0 1px rgba(255,255,255,0.2)",
52
+ },
53
+ },
54
+ "&:active $check $box": Object {
55
+ "boxShadow": "inset 0 0 0 2px #6C6F89",
56
+ },
45
57
  "&:after": Object {
46
58
  "clear": "both",
47
59
  "content": "\\"\\"",
48
60
  "display": "table",
49
61
  },
50
- "&:hover $check:after": Object {
51
- "background": "url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJCQkgdmlld0JveD0iMCAwIDI0IDI0IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyNCAyNDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgoJCTxwYXRoIGZpbGw9IiNkZGRkZGQiIGQ9Ik0xOC4zLDcuM2wxLjQsMS40bC04LjcsOWMtMC40LDAuNC0xLDAuNC0xLjQsMC4xbC00LjMtMy42bDEuMy0xLjVsMy42LDNDMTAuMiwxNS42LDE4LjMsNy4zLDE4LjMsNy4zeiIvPgoJCTwvc3ZnPg==)",
62
+ "&:focus-visible $check": Object {
63
+ "boxShadow": "0 0 0 8px rgba(0,110,255,0.3)",
64
+ },
65
+ "&:hover $check $box": Object {
66
+ "boxShadow": "inset 0 0 0 1px #6C6F89",
52
67
  },
53
- "alignItems": "start",
68
+ "alignItems": "flex-start",
54
69
  "boxSizing": "border-box",
55
70
  "cursor": "pointer",
56
71
  "display": "flex",
57
72
  "outline": "0",
58
- "paddingBottom": 8,
59
- "paddingTop": 8,
60
73
  },
61
74
  "disabled": Object {
62
- "opacity": 0.4,
75
+ "& $check $box": Object {
76
+ "background": "#EDEDF1",
77
+ "boxShadow": "inset 0 0 0 1px #D3D4DC",
78
+ },
79
+ "&$active, &$undetermined": Object {
80
+ "& $check $box": Object {
81
+ "background": "hsl(221 91.2% 35.7% / 0.1)",
82
+ "boxShadow": "inset 0 0 0 1px rgba(255,255,255,0.2)",
83
+ },
84
+ },
63
85
  "pointerEvents": "none",
64
86
  },
87
+ "icon": Object {
88
+ "gridColumnStart": 1,
89
+ "gridRowStart": 1,
90
+ "margin": 2,
91
+ },
65
92
  "label": Object {
66
93
  "cursor": "pointer",
67
- "flex": "1",
68
- "float": "left",
69
- "marginLeft": 8,
94
+ "flex": 1,
95
+ "marginLeft": "12px",
96
+ },
97
+ "labelWrap": Object {
98
+ "alignItems": "center",
99
+ "display": "flex",
100
+ "flex": 1,
101
+ "minHeight": 48,
102
+ "overflow": "hidden",
103
+ "paddingBottom": "4px",
104
+ "paddingTop": "4px",
70
105
  },
71
106
  "overflow": Object {
72
107
  "overflow": "hidden",
@@ -74,16 +109,13 @@ Object {
74
109
  "whiteSpace": "nowrap",
75
110
  },
76
111
  "right": Object {
77
- "float": "right",
78
- "marginLeft": 8,
112
+ "marginLeft": "8px",
113
+ "pointerEvents": "none",
79
114
  },
80
115
  "undetermined": Object {
81
- "& $check:after": Object {
82
- "background": Array [
83
- "url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgogICAgICAgICAgICB2aWV3Qm94PSIwIDAgMjQgMjQiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDI0IDI0OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CiAgICAgICAgPHBvbHlnb24gcG9pbnRzPSI1LjMsMTMuMyA1LjMsMTAuNyAxOC43LDEwLjcgMTguNywxMy4zICIgZmlsbD0iIzA4M2NhZSIgLz4KICAgICAgICA8L3N2Zz4=)",
84
- "!important",
85
- ],
86
- "marginTop": 0,
116
+ "& $check $box": Object {
117
+ "background": "#0059CD",
118
+ "boxShadow": "inset 0 0 0 1px rgba(255,255,255,0.2)",
87
119
  },
88
120
  },
89
121
  }
@@ -5,23 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
8
+ var _spacing = _interopRequireDefault(require("../tokens/spacing.json"));
9
9
 
10
- var _spacing = _interopRequireDefault(require("../subatomic/spacing"));
10
+ var _shadows = _interopRequireDefault(require("../tokens/shadows.json"));
11
11
 
12
- var _icons = _interopRequireDefault(require("../subatomic/icons"));
12
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
13
13
 
14
- var _iconSizes = _interopRequireDefault(require("../subatomic/iconSizes"));
14
+ var _borderRadius = _interopRequireDefault(require("../tokens/borderRadius.json"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
17
 
18
+ var checkbox = _colors["default"].checkbox;
19
+ var transition = 'all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s';
20
+ var contentHeight = 48;
21
+ var checkboxWidth = 52;
22
+ var checkSize = 20;
18
23
  var _default = {
19
24
  cont: {
20
- paddingTop: _spacing["default"].tiny,
21
- paddingBottom: _spacing["default"].tiny,
22
25
  boxSizing: 'border-box',
23
26
  display: 'flex',
24
- alignItems: 'start',
27
+ alignItems: 'flex-start',
25
28
  cursor: 'pointer',
26
29
  outline: '0',
27
30
  '&:after': {
@@ -29,68 +32,108 @@ var _default = {
29
32
  display: 'table',
30
33
  clear: 'both'
31
34
  },
32
- '&:hover $check:after': {
33
- background: _icons["default"].base(_icons["default"].check.icon([_colors["default"].grey200]))
35
+ '&:focus-visible $check': {
36
+ boxShadow: _shadows["default"]['focus-bright-blue']
37
+ },
38
+ '&:hover $check $box': {
39
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.unselected.border.hover)
40
+ },
41
+ '&:active $check $box': {
42
+ boxShadow: "inset 0 0 0 2px ".concat(checkbox.unselected.border.hover)
43
+ },
44
+ '&$active, &$undetermined': {
45
+ '&:hover $check $box': {
46
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.selected.border["default"]),
47
+ background: checkbox.selected.bg.hover
48
+ },
49
+ '&:active $check $box': {
50
+ boxShadow: "inset 0 0 0 2px ".concat(checkbox.selected.border["default"]),
51
+ background: checkbox.selected.bg.hover
52
+ }
34
53
  }
35
54
  },
55
+ checkWrap: {
56
+ width: checkboxWidth,
57
+ height: contentHeight,
58
+ display: 'flex',
59
+ alignItems: 'center',
60
+ justifyContent: 'center',
61
+ flexShrink: 0
62
+ },
36
63
  check: {
37
- width: _spacing["default"].base,
38
- height: _spacing["default"].base,
39
- position: 'relative',
40
- '&:before': {
41
- content: '""',
42
- width: _spacing["default"].small,
43
- height: _spacing["default"].small,
44
- borderRadius: 4,
45
- position: 'absolute',
46
- top: '50%',
47
- left: '50%',
48
- transform: 'translate(-50%, -50%)',
49
- border: "1px solid ".concat(_colors["default"].grey200),
50
- background: _colors["default"].bgWhite
51
- },
52
- '&:after': {
53
- content: '""',
54
- width: _iconSizes["default"].small,
55
- height: _iconSizes["default"].small,
56
- marginTop: -1,
57
- position: 'absolute',
58
- top: '50%',
59
- left: '50%',
60
- transform: 'translate(-50%, -50%)',
61
- transition: '0.3s all',
62
- background: 'transparent'
63
- }
64
+ width: checkSize,
65
+ height: checkSize,
66
+ borderRadius: _borderRadius["default"]['br-xs'],
67
+ transition: transition,
68
+ display: 'grid',
69
+ alignItems: 'center',
70
+ justifyContent: 'center'
71
+ },
72
+ box: {
73
+ width: checkSize,
74
+ height: checkSize,
75
+ borderRadius: _borderRadius["default"]['br-xs'],
76
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.unselected.border["default"]),
77
+ background: checkbox['unselected']['bg']['default'],
78
+ transition: transition,
79
+ gridRowStart: 1,
80
+ gridColumnStart: 1
81
+ },
82
+ icon: {
83
+ gridRowStart: 1,
84
+ gridColumnStart: 1,
85
+ margin: 2
64
86
  },
65
87
  active: {
66
- '& $check:after': {
67
- background: [_icons["default"].base(_icons["default"].check.icon([_colors["default"].prim])), '!important']
88
+ '& $check $box': {
89
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.selected.border["default"]),
90
+ background: checkbox.selected.bg["default"]
68
91
  }
69
92
  },
70
93
  undetermined: {
71
- '& $check:after': {
72
- background: [_icons["default"].base(_icons["default"].minus.icon([_colors["default"].prim])), '!important'],
73
- marginTop: 0
94
+ '& $check $box': {
95
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.selected.border["default"]),
96
+ background: checkbox.selected.bg["default"]
74
97
  }
75
98
  },
76
99
  disabled: {
77
- opacity: 0.4,
78
- pointerEvents: 'none'
100
+ pointerEvents: 'none',
101
+ '& $check $box': {
102
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.unselected.border["default"]),
103
+ background: checkbox.unselected.bg.disabled
104
+ },
105
+ '&$active, &$undetermined': {
106
+ '& $check $box': {
107
+ boxShadow: "inset 0 0 0 1px ".concat(checkbox.selected.border["default"]),
108
+ background: checkbox.selected.bg.disabled
109
+ }
110
+ }
111
+ },
112
+ labelWrap: {
113
+ minHeight: contentHeight,
114
+ display: 'flex',
115
+ alignItems: 'center',
116
+ paddingTop: _spacing["default"]['size-1'],
117
+ paddingBottom: _spacing["default"]['size-1'],
118
+ overflow: 'hidden',
119
+ flex: 1
79
120
  },
80
121
  label: {
81
- marginLeft: _spacing["default"].tiny,
122
+ marginLeft: _spacing["default"]['size-3'],
82
123
  cursor: 'pointer',
83
- "float": 'left',
84
- flex: '1'
124
+ flex: 1
85
125
  },
86
126
  right: {
87
- marginLeft: _spacing["default"].tiny,
88
- "float": 'right'
127
+ marginLeft: _spacing["default"]['size-2'],
128
+ pointerEvents: 'none'
89
129
  },
90
130
  overflow: {
91
131
  overflow: 'hidden',
92
132
  textOverflow: 'ellipsis',
93
133
  whiteSpace: 'nowrap'
134
+ },
135
+ alignLeft: {
136
+ flex: 'none'
94
137
  }
95
138
  };
96
139
  exports["default"] = _default;
@@ -7,103 +7,95 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _Icon = _interopRequireDefault(require("../../Icon"));
15
15
 
16
- var _Text = _interopRequireDefault(require("../../Text"));
17
-
18
- var _colors = _interopRequireDefault(require("../../subatomic/colors"));
19
-
20
- var _iconSizes = _interopRequireDefault(require("../../subatomic/iconSizes"));
16
+ var _colors = _interopRequireDefault(require("../../tokens/colors.json"));
21
17
 
22
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
19
 
24
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
-
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
-
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
-
30
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
-
32
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
-
34
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
-
36
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
37
-
38
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
-
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
41
21
 
42
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
23
 
44
- var Choice = /*#__PURE__*/function (_React$Component) {
45
- _inherits(Choice, _React$Component);
24
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
46
25
 
47
- var _super = _createSuper(Choice);
48
-
49
- function Choice(props) {
50
- var _this;
26
+ var getStylesByStatus = function getStylesByStatus(selected, disabled) {
27
+ if (selected) {
28
+ if (disabled) {
29
+ return {
30
+ iconColor: _colors["default"].icon.inverse.disabled,
31
+ button: 'selectedDisabled',
32
+ text: 'textSelectedDisabled'
33
+ };
34
+ }
51
35
 
52
- _classCallCheck(this, Choice);
36
+ return {
37
+ iconColor: _colors["default"].icon.inverse["default"],
38
+ button: 'selected',
39
+ text: 'textSelected'
40
+ };
41
+ }
53
42
 
54
- _this = _super.call(this, props);
55
- _this.handleOnClick = _this.handleOnClick.bind(_assertThisInitialized(_this));
56
- return _this;
43
+ if (disabled) {
44
+ return {
45
+ iconColor: _colors["default"].icon.brand.disabled,
46
+ button: 'disabled',
47
+ text: 'textDisabled'
48
+ };
57
49
  }
58
50
 
59
- _createClass(Choice, [{
60
- key: "handleOnClick",
61
- value: function handleOnClick() {
62
- var _this$props = this.props,
63
- id = _this$props.id,
64
- onClick = _this$props.onClick;
65
- if (onClick) onClick(id);
66
- }
67
- }, {
68
- key: "render",
69
- value: function render() {
70
- var _this$props2 = this.props,
71
- classes = _this$props2.classes,
72
- children = _this$props2.children,
73
- selected = _this$props2.selected,
74
- disabled = _this$props2.disabled,
75
- idPrefix = _this$props2.idPrefix,
76
- testId = _this$props2.testId,
77
- leftIcon = _this$props2.leftIcon,
78
- rightIcon = _this$props2.rightIcon,
79
- id = _this$props2.id;
80
- var iconColor = disabled ? _colors["default"].grey200 : selected ? _colors["default"].prim : _colors["default"].grey900;
81
- return /*#__PURE__*/_react["default"].createElement("button", {
82
- className: "".concat(classes.pill).concat(selected ? " ".concat(classes.selected) : disabled ? " ".concat(classes.disabled) : ''),
83
- onClick: this.handleOnClick,
84
- id: idPrefix ? "".concat(idPrefix).concat(id) : null,
85
- "data-testid": testId ? "".concat(testId).concat(id) : null
86
- }, leftIcon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
87
- iconName: leftIcon,
88
- colors: [iconColor],
89
- width: _iconSizes["default"].small,
90
- height: _iconSizes["default"].small
91
- }), children && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
92
- tag: "span",
93
- className: classes.text,
94
- primary: selected,
95
- disabled: disabled
96
- }, children), rightIcon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
97
- iconName: rightIcon,
98
- colors: [iconColor],
99
- width: _iconSizes["default"].small,
100
- height: _iconSizes["default"].small
101
- }));
102
- }
103
- }]);
51
+ return {
52
+ iconColor: _colors["default"].icon.brand["default"],
53
+ button: 'enabled',
54
+ text: 'textEnabled'
55
+ };
56
+ };
104
57
 
105
- return Choice;
106
- }(_react["default"].Component);
58
+ var Choice = function Choice(props) {
59
+ var classes = props.classes,
60
+ children = props.children,
61
+ selected = props.selected,
62
+ disabled = props.disabled,
63
+ idPrefix = props.idPrefix,
64
+ testId = props.testId,
65
+ leftIcon = props.leftIcon,
66
+ rightIcon = props.rightIcon,
67
+ onClick = props.onClick,
68
+ id = props.id;
69
+ var handleOnClick = (0, _react.useCallback)(function () {
70
+ return onClick(id);
71
+ }, [onClick, id]);
72
+ var conditionedStyles = (0, _react.useMemo)(function () {
73
+ return getStylesByStatus(!!selected, !!disabled);
74
+ }, [selected, disabled]);
75
+ return /*#__PURE__*/_react["default"].createElement("button", _extends({
76
+ className: "".concat(classes.pill, " ").concat(classes[conditionedStyles.button])
77
+ }, onClick && {
78
+ onClick: handleOnClick
79
+ }, {
80
+ disabled: disabled,
81
+ id: idPrefix ? "".concat(idPrefix).concat(id) : null,
82
+ "data-testid": testId ? "".concat(testId).concat(id) : null
83
+ }), leftIcon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
84
+ iconName: leftIcon,
85
+ colors: [conditionedStyles.iconColor],
86
+ className: classes.leftIcon,
87
+ width: 16,
88
+ height: 16
89
+ }), children && /*#__PURE__*/_react["default"].createElement("span", {
90
+ className: "".concat(classes.text, " ").concat(classes[conditionedStyles.text])
91
+ }, children), rightIcon && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
92
+ iconName: rightIcon,
93
+ colors: [conditionedStyles.iconColor],
94
+ className: classes.rightIcon,
95
+ width: 16,
96
+ height: 16
97
+ }));
98
+ };
107
99
 
108
100
  Choice.propTypes = {
109
101
  classes: _propTypes["default"].object.isRequired,