bright-components 10.2.2 → 10.2.5

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.
@@ -0,0 +1,22 @@
1
+ {
2
+ "eslint.format.enable": true,
3
+ "editor.renderWhitespace": "all",
4
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint",
5
+ "editor.formatOnSave": true,
6
+ "editor.formatOnPaste": true,
7
+ "cSpell.words": [
8
+ "autobind",
9
+ "brighthr",
10
+ "cronersupplieddocuments",
11
+ "firstname",
12
+ "Formik",
13
+ "lastname",
14
+ "pathnames",
15
+ "pendo",
16
+ "previewable",
17
+ "selectall",
18
+ "tailwindcss",
19
+ "testid",
20
+ "testprops"
21
+ ]
22
+ }
@@ -5,50 +5,24 @@ exports.default = void 0;
5
5
 
6
6
  var _react = _interopRequireDefault(require("react"));
7
7
 
8
- var _reactIconBase = _interopRequireDefault(require("react-icon-base"));
9
-
10
8
  var _propTypes = require("prop-types");
11
9
 
12
- var _colors = _interopRequireDefault(require("../../../constants/colors"));
10
+ var _reactIconBase = _interopRequireDefault(require("react-icon-base"));
13
11
 
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
13
 
16
14
  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); }
17
15
 
18
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
-
20
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
-
22
- const EyeIcon = _ref => {
23
- let {
24
- size
25
- } = _ref,
26
- props = _objectWithoutProperties(_ref, ["size"]);
27
-
28
- return _react.default.createElement(_reactIconBase.default, _extends({}, props, {
29
- size: size,
30
- viewBox: "0 0 24 24"
31
- }), _react.default.createElement("rect", {
32
- transform: "translate(0)"
33
- }), _react.default.createElement("circle", {
34
- fill: props.color,
35
- cx: "5",
36
- cy: "5",
37
- r: "5",
38
- transform: "translate(7 7)"
39
- }), _react.default.createElement("path", {
40
- fill: props.color,
41
- d: "M12,20C5.089,20,.359,12.849.162,12.545a1,1,0,0,1,0-1.09C.359,11.15,5.089,4,12,4s11.641,7.15,11.838,7.455a1,1,0,0,1,0,1.09C23.641,12.849,18.911,20,12,20ZM2.23,12c1.189,1.573,4.961,6,9.77,6s8.581-4.427,9.77-6C20.581,10.427,16.809,6,12,6S3.419,10.427,2.23,12Z"
42
- }));
43
- };
16
+ const EyeIcon = props => _react.default.createElement(_reactIconBase.default, _extends({
17
+ viewBox: "0 0 32 32"
18
+ }, props), _react.default.createElement("path", {
19
+ d: "M29.769 15.36C29.519 15.06 23.562 8 16 8S2.481 15.06 2.231 15.36a1 1 0 000 1.28C2.481 16.94 8.438 24 16 24s13.519-7.06 13.769-7.36a1 1 0 000-1.28zM16 22c-5.372 0-10.05-4.336-11.647-6 1.028-1.07 3.33-3.243 6.269-4.66a6 6 0 1010.757 0c2.939 1.416 5.24 3.59 6.268 4.66-1.598 1.665-6.275 6-11.647 6z"
20
+ }));
44
21
 
45
- EyeIcon.displayName = 'EyeIcon';
46
22
  EyeIcon.propTypes = {
47
- color: _propTypes.string,
48
23
  size: _propTypes.number
49
24
  };
50
25
  EyeIcon.defaultProps = {
51
- color: _colors.default.iconColor,
52
26
  size: 40
53
27
  };
54
28
  var _default = EyeIcon;
@@ -108,10 +108,18 @@ const ResponsiveTabs = _ref => {
108
108
  } = _ref,
109
109
  rest = _objectWithoutProperties(_ref, ["tabs", "defaultIndex", "children", "autoTabWidth", "onSelected"]);
110
110
 
111
- const [index, setIndex] = (0, _react.useState)(defaultIndex || 0);
111
+ const tabs = tabsProp || _react.default.Children.map(children, child => {
112
+ return child && child.props && child.props.name ? {
113
+ name: child.props.name,
114
+ counter: child.props.counter
115
+ } : null;
116
+ });
117
+
118
+ const [index, setIndex] = (0, _react.useState)(defaultIndex < tabs.length ? defaultIndex : 0);
119
+
120
+ const onSelectChange = (event, _tabs) => {
121
+ const names = _tabs.map(tab => tab.name);
112
122
 
113
- const onSelectChange = (event, tabs) => {
114
- const names = tabs.map(tab => tab.name);
115
123
  const newIndex = names.indexOf(event.target.value);
116
124
  setIndex(newIndex);
117
125
  };
@@ -120,13 +128,6 @@ const ResponsiveTabs = _ref => {
120
128
  setIndex(newIndex);
121
129
  };
122
130
 
123
- const tabs = tabsProp || _react.default.Children.map(children, child => {
124
- return child && child.props && child.props.name ? {
125
- name: child.props.name,
126
- counter: child.props.counter
127
- } : null;
128
- });
129
-
130
131
  const DesktopTabList = autoTabWidth ? AutoWidthTabList : StyledTabList;
131
132
  return _react.default.createElement(_Tabs.default, _extends({
132
133
  selectedIndex: index
@@ -151,7 +152,7 @@ const ResponsiveTabs = _ref => {
151
152
  onSelected(i);
152
153
  }
153
154
  },
154
- value: tabs[index].name
155
+ value: tabs == null ? void 0 : tabs[index].name
155
156
  }, tabs.map(_ref3 => {
156
157
  let {
157
158
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bright-components",
3
- "version": "10.2.2",
3
+ "version": "10.2.5",
4
4
  "private": false,
5
5
  "main": "./dist",
6
6
  "repository": {
@@ -2,4 +2,4 @@ Eye example
2
2
 
3
3
  ```js
4
4
  <EyeIcon />
5
- ```
5
+ ```
@@ -1,33 +1,18 @@
1
1
  import React from 'react';
2
+ import { number } from 'prop-types';
2
3
  import IconBase from 'react-icon-base';
3
- import { string, number } from 'prop-types';
4
- import colors from 'constants/colors';
5
4
 
6
- const EyeIcon = ({ size, ...props }) => (
7
- <IconBase {...props} size={size} viewBox="0 0 24 24">
8
- <rect transform="translate(0)" />
9
- <circle
10
- fill={props.color}
11
- cx="5"
12
- cy="5"
13
- r="5"
14
- transform="translate(7 7)"
15
- />
16
- <path
17
- fill={props.color}
18
- d="M12,20C5.089,20,.359,12.849.162,12.545a1,1,0,0,1,0-1.09C.359,11.15,5.089,4,12,4s11.641,7.15,11.838,7.455a1,1,0,0,1,0,1.09C23.641,12.849,18.911,20,12,20ZM2.23,12c1.189,1.573,4.961,6,9.77,6s8.581-4.427,9.77-6C20.581,10.427,16.809,6,12,6S3.419,10.427,2.23,12Z"
19
- />
5
+ const EyeIcon = props => (
6
+ <IconBase viewBox="0 0 32 32" {...props}>
7
+ <path d="M29.769 15.36C29.519 15.06 23.562 8 16 8S2.481 15.06 2.231 15.36a1 1 0 000 1.28C2.481 16.94 8.438 24 16 24s13.519-7.06 13.769-7.36a1 1 0 000-1.28zM16 22c-5.372 0-10.05-4.336-11.647-6 1.028-1.07 3.33-3.243 6.269-4.66a6 6 0 1010.757 0c2.939 1.416 5.24 3.59 6.268 4.66-1.598 1.665-6.275 6-11.647 6z" />
20
8
  </IconBase>
21
9
  );
22
- EyeIcon.displayName = 'EyeIcon';
23
10
 
24
11
  EyeIcon.propTypes = {
25
- color: string,
26
12
  size: number
27
13
  };
28
14
 
29
15
  EyeIcon.defaultProps = {
30
- color: colors.iconColor,
31
16
  size: 40
32
17
  };
33
18
 
@@ -94,18 +94,6 @@ const ResponsiveTabs = ({
94
94
  onSelected,
95
95
  ...rest
96
96
  }) => {
97
- const [index, setIndex] = useState(defaultIndex || 0);
98
-
99
- const onSelectChange = (event, tabs) => {
100
- const names = tabs.map(tab => tab.name);
101
- const newIndex = names.indexOf(event.target.value);
102
- setIndex(newIndex);
103
- };
104
-
105
- const onSelect = newIndex => {
106
- setIndex(newIndex);
107
- };
108
-
109
97
  const tabs =
110
98
  tabsProp ||
111
99
  React.Children.map(children, child => {
@@ -117,6 +105,20 @@ const ResponsiveTabs = ({
117
105
  : null;
118
106
  });
119
107
 
108
+ const [index, setIndex] = useState(
109
+ defaultIndex < tabs.length ? defaultIndex : 0
110
+ );
111
+
112
+ const onSelectChange = (event, _tabs) => {
113
+ const names = _tabs.map(tab => tab.name);
114
+ const newIndex = names.indexOf(event.target.value);
115
+ setIndex(newIndex);
116
+ };
117
+
118
+ const onSelect = newIndex => {
119
+ setIndex(newIndex);
120
+ };
121
+
120
122
  const DesktopTabList = autoTabWidth ? AutoWidthTabList : StyledTabList;
121
123
 
122
124
  return (
@@ -140,7 +142,7 @@ const ResponsiveTabs = ({
140
142
  onSelected(i);
141
143
  }
142
144
  }}
143
- value={tabs[index].name}
145
+ value={tabs?.[index].name}
144
146
  >
145
147
  {tabs.map(({ name, counter = null }) => (
146
148
  <Option key={name} value={name}>
@@ -7,6 +7,20 @@ import ResponsiveTabs from '.';
7
7
  jest.mock('react-ga');
8
8
 
9
9
  describe('<ResponsiveTabs />', () => {
10
+ it('should handle when defaultIndex is larger than the amount of tabs', () => {
11
+ const { getByRole, getAllByRole } = render(
12
+ <ResponsiveTabs defaultIndex={3}>
13
+ <TabPanel name="One">One</TabPanel>
14
+ <TabPanel name="Two">Two</TabPanel>
15
+ </ResponsiveTabs>
16
+ );
17
+
18
+ expect(getByRole('combobox')).toBeInTheDocument();
19
+ expect(getAllByRole('option')).toHaveLength(2);
20
+
21
+ // doesn't throw an error is good
22
+ });
23
+
10
24
  it('should render a dropdown for selecting tabs on mobile', () => {
11
25
  const { getByRole, getAllByRole } = render(
12
26
  <ResponsiveTabs>
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
-
6
- var _react = _interopRequireDefault(require("react"));
7
-
8
- var _propTypes = require("prop-types");
9
-
10
- var _reactIconBase = _interopRequireDefault(require("react-icon-base"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- 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); }
15
-
16
- const VisibleIcon = props => _react.default.createElement(_reactIconBase.default, _extends({
17
- viewBox: "0 0 32 32"
18
- }, props), _react.default.createElement("path", {
19
- d: "M29.769 15.36C29.519 15.06 23.562 8 16 8S2.481 15.06 2.231 15.36a1 1 0 000 1.28C2.481 16.94 8.438 24 16 24s13.519-7.06 13.769-7.36a1 1 0 000-1.28zM16 22c-5.372 0-10.05-4.336-11.647-6 1.028-1.07 3.33-3.243 6.269-4.66a6 6 0 1010.757 0c2.939 1.416 5.24 3.59 6.268 4.66-1.598 1.665-6.275 6-11.647 6z"
20
- }));
21
-
22
- VisibleIcon.propTypes = {
23
- size: _propTypes.number
24
- };
25
- VisibleIcon.defaultProps = {
26
- size: 40
27
- };
28
- var _default = VisibleIcon;
29
- exports.default = _default;
@@ -1,5 +0,0 @@
1
- Visible example
2
-
3
- ```js
4
- <VisibleIcon />
5
- ```
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { number } from 'prop-types';
3
- import IconBase from 'react-icon-base';
4
-
5
- const VisibleIcon = props => (
6
- <IconBase viewBox="0 0 32 32" {...props}>
7
- <path d="M29.769 15.36C29.519 15.06 23.562 8 16 8S2.481 15.06 2.231 15.36a1 1 0 000 1.28C2.481 16.94 8.438 24 16 24s13.519-7.06 13.769-7.36a1 1 0 000-1.28zM16 22c-5.372 0-10.05-4.336-11.647-6 1.028-1.07 3.33-3.243 6.269-4.66a6 6 0 1010.757 0c2.939 1.416 5.24 3.59 6.268 4.66-1.598 1.665-6.275 6-11.647 6z" />
8
- </IconBase>
9
- );
10
-
11
- VisibleIcon.propTypes = {
12
- size: number
13
- };
14
-
15
- VisibleIcon.defaultProps = {
16
- size: 40
17
- };
18
-
19
- export default VisibleIcon;