@occmundial/occ-atomic 3.0.0-beta.11 → 3.0.0-beta.13

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [3.0.0-beta.13](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2024-06-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Add form nav behavior to SwitchToggle ([e1e74ed](https://github.com/occmundial/occ-atomic/commit/e1e74edf8306250d0ae7a723b758c9426593c295))
7
+
8
+ # [3.0.0-beta.12](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2024-06-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Add form nav behavior to checkbox ([6b2c664](https://github.com/occmundial/occ-atomic/commit/6b2c664e165bb4617dc53874be69bb9d8c8e6bc3))
14
+
1
15
  # [3.0.0-beta.11](https://github.com/occmundial/occ-atomic/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2024-06-07)
2
16
 
3
17
 
@@ -81,9 +81,19 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
81
81
  if (onChange) onChange(value, id);
82
82
  }
83
83
  }
84
+ }, {
85
+ key: "handleKeyDown",
86
+ value: function handleKeyDown(e) {
87
+ if (e.keyCode == 13 || e.keyCode == 32) {
88
+ e.preventDefault();
89
+ this.toggle();
90
+ }
91
+ }
84
92
  }, {
85
93
  key: "render",
86
94
  value: function render() {
95
+ var _this2 = this;
96
+
87
97
  var _this$state = this.state,
88
98
  value = _this$state.value,
89
99
  undetermined = _this$state.undetermined;
@@ -96,12 +106,16 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
96
106
  id = _this$props2.id,
97
107
  className = _this$props2.className,
98
108
  style = _this$props2.style,
109
+ alignLeft = _this$props2.alignLeft,
99
110
  trk = _this$props2.trk,
100
111
  testId = _this$props2.testId;
101
112
  var iconClass = undetermined ? " ".concat(classes.undetermined) : value ? " ".concat(classes.active) : '';
102
113
  return /*#__PURE__*/_react["default"].createElement("div", _extends({
103
114
  id: id,
104
- tabIndex: -1,
115
+ tabIndex: disabled ? -1 : 0,
116
+ onKeyDown: function onKeyDown(e) {
117
+ return _this2.handleKeyDown(e);
118
+ },
105
119
  className: "".concat(classes.cont).concat(iconClass).concat(disabled ? " ".concat(classes.disabled) : '').concat(className ? " ".concat(className) : ''),
106
120
  onClick: this.toggle,
107
121
  style: style,
@@ -113,7 +127,7 @@ var Checkbox = /*#__PURE__*/function (_React$Component) {
113
127
  id: trk
114
128
  }), label && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
115
129
  tag: "label",
116
- className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '')
130
+ className: "".concat(classes.label).concat(textOverflow ? " ".concat(classes.overflow) : '').concat(alignLeft ? " ".concat(classes.alignLeft) : '')
117
131
  }, label), right && /*#__PURE__*/_react["default"].createElement(_Text["default"], {
118
132
  tag: "label",
119
133
  mid: true,
@@ -149,6 +163,9 @@ Checkbox.propTypes = {
149
163
  /** Use this prop to overflow the text of the label, adding '...' and the end. */
150
164
  textOverflow: _propTypes["default"].bool,
151
165
 
166
+ /** Align the content to the left */
167
+ alignLeft: _propTypes["default"].bool,
168
+
152
169
  /** Id for catching selected element for tracking. */
153
170
  trk: _propTypes["default"].string,
154
171
  id: _propTypes["default"].string,
@@ -13,6 +13,9 @@ Object {
13
13
  "borderColor": "rgba(255,255,255,0.2)",
14
14
  },
15
15
  },
16
+ "alignLeft": Object {
17
+ "flex": "none",
18
+ },
16
19
  "check": Object {
17
20
  "&:after": Object {
18
21
  "background": "transparent",
@@ -38,6 +41,7 @@ Object {
38
41
  "position": "absolute",
39
42
  "top": "50%",
40
43
  "transform": "translate(-50%, -50%)",
44
+ "transition": "0.3s all",
41
45
  "width": 20,
42
46
  },
43
47
  "height": "24px",
@@ -110,6 +114,7 @@ Object {
110
114
  "right": Object {
111
115
  "float": "right",
112
116
  "marginLeft": "8px",
117
+ "pointerEvents": "none",
113
118
  },
114
119
  "undetermined": Object {
115
120
  "& $check:after": Object {
@@ -66,7 +66,8 @@ var _default = {
66
66
  left: '50%',
67
67
  transform: 'translate(-50%, -50%)',
68
68
  border: "1px solid ".concat(checkbox['unselected']['border']['default']),
69
- background: checkbox['unselected']['bg']['default']
69
+ background: checkbox['unselected']['bg']['default'],
70
+ transition: '0.3s all'
70
71
  },
71
72
  '&:after': {
72
73
  content: '""',
@@ -130,12 +131,16 @@ var _default = {
130
131
  },
131
132
  right: {
132
133
  marginLeft: _spacing["default"]['size-2'],
133
- "float": 'right'
134
+ "float": 'right',
135
+ pointerEvents: 'none'
134
136
  },
135
137
  overflow: {
136
138
  overflow: 'hidden',
137
139
  textOverflow: 'ellipsis',
138
140
  whiteSpace: 'nowrap'
141
+ },
142
+ alignLeft: {
143
+ flex: 'none'
139
144
  }
140
145
  };
141
146
  exports["default"] = _default;
@@ -79,9 +79,19 @@ var SlideToggle = /*#__PURE__*/function (_React$Component) {
79
79
  if (onChange) onChange(value, id);
80
80
  }
81
81
  }
82
+ }, {
83
+ key: "handleKeyDown",
84
+ value: function handleKeyDown(e) {
85
+ if (e.keyCode == 13 || e.keyCode == 32) {
86
+ e.preventDefault();
87
+ this.toggle();
88
+ }
89
+ }
82
90
  }, {
83
91
  key: "render",
84
92
  value: function render() {
93
+ var _this2 = this;
94
+
85
95
  var value = this.state.value;
86
96
  var _this$props2 = this.props,
87
97
  classes = _this$props2.classes,
@@ -95,14 +105,17 @@ var SlideToggle = /*#__PURE__*/function (_React$Component) {
95
105
  testId = _this$props2.testId;
96
106
  return /*#__PURE__*/_react["default"].createElement("div", {
97
107
  id: id,
98
- tabIndex: -1,
108
+ tabIndex: disabled ? -1 : 0,
109
+ onKeyDown: function onKeyDown(e) {
110
+ return _this2.handleKeyDown(e);
111
+ },
112
+ onClick: this.toggle,
99
113
  className: "".concat(classes.cont).concat(disabled ? " ".concat(classes.disabled) : '').concat(className ? " ".concat(className) : ''),
100
114
  style: style
101
115
  }, /*#__PURE__*/_react["default"].createElement("div", _extends({
102
116
  id: trk,
103
117
  name: name,
104
118
  className: "".concat(classes["switch"]).concat(value ? " ".concat(classes.checked) : ''),
105
- onClick: this.toggle,
106
119
  "data-testid": testId
107
120
  }, testId && {
108
121
  'data-value': value ? 1 : 0
@@ -48,7 +48,7 @@ describe("SlideToggle", function () {
48
48
  classes: classes
49
49
  }));
50
50
  expect(wrapper.find('.cont').exists()).toEqual(true);
51
- wrapper.find('.switch').simulate('click');
51
+ wrapper.simulate('click');
52
52
  expect(wrapper.find('.switch').hasClass('checked')).toEqual(true);
53
53
  });
54
54
  it('calls onChange function', function () {
@@ -57,7 +57,7 @@ describe("SlideToggle", function () {
57
57
  classes: classes,
58
58
  onChange: onChange
59
59
  }));
60
- wrapper.find('.switch').simulate('click');
60
+ wrapper.simulate('click');
61
61
  expect(onChange.mock.calls.length).toBe(1);
62
62
  });
63
63
  it('shows the label', function () {
@@ -53,12 +53,12 @@ Object {
53
53
  "width": "100%",
54
54
  },
55
55
  "label": Object {
56
+ "cursor": "pointer",
56
57
  "marginLeft": "8px",
57
58
  },
58
59
  "slider": Object {
59
60
  "background": "#fff",
60
61
  "borderRadius": "50%",
61
- "cursor": "pointer",
62
62
  "height": 20,
63
63
  "left": 2,
64
64
  "position": "absolute",
@@ -62,7 +62,6 @@ var _default = {
62
62
  },
63
63
  slider: {
64
64
  position: 'absolute',
65
- cursor: 'pointer',
66
65
  top: 2,
67
66
  left: 2,
68
67
  width: 20,
@@ -88,7 +87,8 @@ var _default = {
88
87
  pointerEvents: 'none'
89
88
  },
90
89
  label: {
91
- marginLeft: _spacing["default"]['size-2']
90
+ marginLeft: _spacing["default"]['size-2'],
91
+ cursor: 'pointer'
92
92
  }
93
93
  };
94
94
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@occmundial/occ-atomic",
3
- "version": "3.0.0-beta.11",
3
+ "version": "3.0.0-beta.13",
4
4
  "description": "Collection of shareable styled React components for OCC applications.",
5
5
  "homepage": "http://occmundial.github.io/occ-atomic",
6
6
  "main": "build/index.js",
@@ -120,5 +120,8 @@
120
120
  "roots": [
121
121
  "<rootDir>/lib/"
122
122
  ]
123
+ },
124
+ "volta": {
125
+ "node": "16.18.0"
123
126
  }
124
127
  }