@occmundial/occ-atomic 3.0.0-beta.7 → 3.0.0-beta.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. package/CHANGELOG.md +549 -0
  2. package/build/Avatar/Avatar.js +69 -21
  3. package/build/Avatar/Avatar.test.js +15 -8
  4. package/build/Avatar/AvatarContent/AvatarContent.js +61 -21
  5. package/build/Avatar/AvatarContent/AvatarContent.test.js +4 -18
  6. package/build/Avatar/AvatarContent/__snapshots__/AvatarContent.test.js.snap +75 -15
  7. package/build/Avatar/AvatarContent/styles.js +88 -21
  8. package/build/Avatar/__snapshots__/Avatar.test.js.snap +11 -2
  9. package/build/Avatar/styles.js +18 -7
  10. package/build/Banner/Banner.js +30 -40
  11. package/build/Banner/Banner.test.js +64 -17
  12. package/build/Banner/__snapshots__/Banner.test.js.snap +0 -28
  13. package/build/Banner/index.js +1 -6
  14. package/build/Button/Button.js +1 -1
  15. package/build/Button/Button.test.js +0 -11
  16. package/build/Button/__snapshots__/Button.test.js.snap +63 -67
  17. package/build/Button/styles.js +42 -75
  18. package/build/Checkbox/Checkbox.js +48 -3
  19. package/build/Checkbox/__snapshots__/Checkbox.test.js.snap +81 -49
  20. package/build/Checkbox/styles.js +91 -48
  21. package/build/Drawer/Drawer.js +40 -0
  22. package/build/{Header/Nav/Nav.js → Drawer/index.js} +54 -39
  23. package/build/Drawer/index.test.js +52 -0
  24. package/build/Drawer/styles.js +61 -0
  25. package/build/Droplist/__snapshots__/Droplist.test.js.snap +5 -5
  26. package/build/Fab/__snapshots__/Fab.test.js.snap +2 -2
  27. package/build/Footer/Footer.js +81 -87
  28. package/build/Footer/List/List.js +89 -124
  29. package/build/Footer/List/styles.js +85 -31
  30. package/build/Footer/__snapshots__/Footer.test.js.snap +109 -59
  31. package/build/Footer/styles.js +116 -51
  32. package/build/Grid/Col/__snapshots__/Col.test.js.snap +16 -2
  33. package/build/Grid/Col/styles.js +12 -6
  34. package/build/Grid/Row/__snapshots__/Row.test.js.snap +18 -2
  35. package/build/Grid/Row/styles.js +15 -5
  36. package/build/Grid/styles.js +26 -9
  37. package/build/Menu/Menu.js +96 -0
  38. package/build/Menu/index.js +34 -0
  39. package/build/Menu/styles.js +25 -0
  40. package/build/MenuDivider/MenuDivider.js +47 -0
  41. package/build/MenuDivider/index.js +18 -0
  42. package/build/MenuDivider/styles.js +21 -0
  43. package/build/MenuItem/MenuItem.js +160 -0
  44. package/build/{Header/Menu → MenuItem}/index.js +2 -2
  45. package/build/MenuItem/styles.js +25 -0
  46. package/build/MenuItemBase/MenuItemBase.js +94 -0
  47. package/build/MenuItemBase/index.js +18 -0
  48. package/build/MenuItemBase/styles.js +57 -0
  49. package/build/MenuList/MenuList.js +71 -0
  50. package/build/{Header → MenuList}/index.js +2 -2
  51. package/build/MenuList/styles.js +54 -0
  52. package/build/MenuUser/MenuUser.js +152 -0
  53. package/build/MenuUser/index.js +18 -0
  54. package/build/MenuUser/styles.js +22 -0
  55. package/build/Modal/Modal.js +94 -66
  56. package/build/Modal/Modal.test.js +14 -7
  57. package/build/Modal/__snapshots__/Modal.test.js.snap +155 -100
  58. package/build/Modal/styles.js +165 -143
  59. package/build/NavAside/NavAside.js +54 -113
  60. package/build/NavAside/NavAside.test.js +0 -57
  61. package/build/NavAside/__snapshots__/NavAside.test.js.snap +35 -43
  62. package/build/NavAside/index.js +6 -0
  63. package/build/NavAside/styles.js +45 -63
  64. package/build/NavAvatarButton/NavAvatarButton.js +134 -0
  65. package/build/{NavIcon → NavAvatarButton}/index.js +2 -2
  66. package/build/NavAvatarButton/styles.js +33 -0
  67. package/build/NavButton/NavButton.js +73 -0
  68. package/build/{Header/Nav → NavButton}/index.js +2 -2
  69. package/build/NavButton/styles.js +79 -0
  70. package/build/NavItem/styles.js +4 -4
  71. package/build/NavTab/NavTab.js +45 -32
  72. package/build/NavTab/styles.js +59 -27
  73. package/build/NavTop/styles.js +6 -6
  74. package/build/OrderBy/OrderBy.js +2 -1
  75. package/build/Pager/Page/Page.js +11 -6
  76. package/build/Pager/Page/Page.test.js +13 -9
  77. package/build/Pager/Page/__snapshots__/Page.test.js.snap +34 -10
  78. package/build/Pager/Page/styles.js +48 -14
  79. package/build/Pager/Pager.js +144 -235
  80. package/build/Pager/Pager.test.js +81 -36
  81. package/build/Pager/__snapshots__/Pager.test.js.snap +3 -36
  82. package/build/Pager/styles.js +5 -40
  83. package/build/Pill/Choice/Choice.js +6 -4
  84. package/build/Pill/Choice/styles.js +13 -10
  85. package/build/Pill/Group/styles.js +5 -5
  86. package/build/Pill/Stack/Stack.js +2 -2
  87. package/build/Pill/Stack/styles.js +5 -8
  88. package/build/Placeholder/Placeholder.js +29 -12
  89. package/build/Placeholder/Placeholder.test.js +4 -4
  90. package/build/Placeholder/__snapshots__/Placeholder.test.js.snap +81 -38
  91. package/build/Placeholder/styles.js +86 -42
  92. package/build/Provider/MenuListProvider.js +38 -0
  93. package/build/Provider/usePrevious.js +1 -1
  94. package/build/Radio/Radio.js +22 -7
  95. package/build/Radio/__snapshots__/Radio.test.js.snap +71 -79
  96. package/build/Radio/styles.js +84 -85
  97. package/build/SlideDown/SlideDown.js +167 -169
  98. package/build/SlideDown/SlideDown.test.js +49 -44
  99. package/build/SlideDown/__snapshots__/SlideDown.test.js.snap +44 -15
  100. package/build/SlideDown/styles.js +51 -20
  101. package/build/SlideToggle/SlideToggle.js +38 -6
  102. package/build/SlideToggle/SlideToggle.test.js +2 -2
  103. package/build/SlideToggle/__snapshots__/SlideToggle.test.js.snap +53 -38
  104. package/build/SlideToggle/styles.js +64 -45
  105. package/build/Tabs/Tab/Tab.js +73 -0
  106. package/build/Tabs/Tab/index.js +34 -0
  107. package/build/Tabs/Tab/index.test.js +132 -0
  108. package/build/Tabs/Tab/styles.js +74 -0
  109. package/build/Tabs/TabContent/TabContent.js +76 -0
  110. package/build/Tabs/TabContent/index.js +34 -0
  111. package/build/Tabs/TabContent/index.test.js +68 -0
  112. package/build/Tabs/TabContent/styles.js +23 -0
  113. package/build/Tabs/TabIndicator/TabIndicator.js +158 -0
  114. package/build/Tabs/TabIndicator/index.js +34 -0
  115. package/build/Tabs/TabIndicator/styles.js +24 -0
  116. package/build/Tabs/TabList/TabList.js +108 -0
  117. package/build/Tabs/TabList/index.js +34 -0
  118. package/build/{Pager/Break → Tabs/TabList}/styles.js +3 -2
  119. package/build/Tabs/Tabs.js +74 -0
  120. package/build/Tabs/context.js +94 -0
  121. package/build/Tabs/index.js +34 -0
  122. package/build/Tabs/index.test.js +157 -0
  123. package/build/Tabs/styles.js +19 -0
  124. package/build/Tag/Tag.js +2 -2
  125. package/build/Tag/__snapshots__/Tag.test.js.snap +40 -43
  126. package/build/Tag/styles.js +76 -82
  127. package/build/Text/Text.js +2 -1
  128. package/build/TextField/TextField.js +7 -6
  129. package/build/TextField/__snapshots__/TextField.test.js.snap +3 -0
  130. package/build/TextField/styles.js +3 -0
  131. package/build/Tip/Tip.js +62 -95
  132. package/build/Tip/Tip.test.js +29 -6
  133. package/build/Tip/TipText/index.js +32 -0
  134. package/build/Tip/__snapshots__/Tip.test.js.snap +127 -15
  135. package/build/Tip/styles.js +125 -31
  136. package/build/Toaster/Toast/Toast.js +76 -64
  137. package/build/Toaster/Toast/styles.js +118 -46
  138. package/build/Toaster/Toaster.js +3 -2
  139. package/build/Toaster/Toaster.test.js +5 -2
  140. package/build/Toaster/__snapshots__/Toaster.test.js.snap +1 -1
  141. package/build/Toaster/functions.js +4 -0
  142. package/build/Toaster/styles.js +3 -3
  143. package/build/Tooltip/Tooltip.js +73 -22
  144. package/build/Tooltip/__snapshots__/Tooltip.test.js.snap +22 -6
  145. package/build/Tooltip/styles.js +32 -10
  146. package/build/index.js +33 -19
  147. package/build/plugin/babel.js +0 -2
  148. package/build/subatomic/grid.js +5 -5
  149. package/build/tokens/colors.json +94 -60
  150. package/build/tokens/shadows.json +3 -3
  151. package/package.json +5 -2
  152. package/build/Banner/styles.js +0 -41
  153. package/build/Header/Header.js +0 -163
  154. package/build/Header/Header.test.js +0 -118
  155. package/build/Header/Menu/Menu.js +0 -135
  156. package/build/Header/Menu/Menu.test.js +0 -107
  157. package/build/Header/Menu/__snapshots__/Menu.test.js.snap +0 -113
  158. package/build/Header/Menu/styles.js +0 -123
  159. package/build/Header/Nav/Nav.test.js +0 -81
  160. package/build/Header/Nav/__snapshots__/Nav.test.js.snap +0 -101
  161. package/build/Header/Nav/styles.js +0 -110
  162. package/build/Header/__snapshots__/Header.test.js.snap +0 -79
  163. package/build/Header/styles.js +0 -94
  164. package/build/NavIcon/NavIcon.js +0 -112
  165. package/build/NavIcon/styles.js +0 -81
  166. package/build/Pager/Break/Break.js +0 -27
  167. package/build/Pager/Break/Break.test.js +0 -53
  168. package/build/Pager/Break/__snapshots__/Break.test.js.snap +0 -13
  169. package/build/Pager/Break/index.js +0 -18
  170. /package/build/Button/{Loading.js → Loading/index.js} +0 -0
@@ -5,90 +5,109 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- var _icons = _interopRequireDefault(require("../subatomic/icons"));
9
-
10
8
  var _spacing = _interopRequireDefault(require("../tokens/spacing.json"));
11
9
 
12
10
  var _colors = _interopRequireDefault(require("../tokens/colors.json"));
13
11
 
14
12
  var _shadows = _interopRequireDefault(require("../tokens/shadows.json"));
15
13
 
14
+ var _borderRadius = _interopRequireDefault(require("../tokens/borderRadius.json"));
15
+
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
17
 
18
- var toggle = _colors["default"]["switch"],
19
- icon = _colors["default"].icon;
18
+ var toggle = _colors["default"]["switch"];
19
+ var transition = 'all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s';
20
+ var contentHeight = 48;
21
+ var toggleWidth = 52;
22
+ var toggleHeight = 32;
23
+ var sliderSize = 24;
20
24
  var _default = {
21
25
  cont: {
22
- paddingTop: _spacing["default"]['size-2'],
23
- paddingBottom: _spacing["default"]['size-2'],
24
26
  boxSizing: 'border-box',
25
27
  display: 'flex',
26
- alignItems: 'start',
28
+ alignItems: 'flex-start',
27
29
  cursor: 'pointer',
28
30
  outline: 0,
29
- '&:hover $switch$checked, &:active $switch$checked': {
30
- background: toggle['selected']['bg']['hover']
31
+ '&:hover $switch $switchBg, &:active $switch $switchBg': {
32
+ background: toggle.unselected.bg.hover
31
33
  },
32
- '&:focus $switch$checked': {
33
- boxShadow: _shadows["default"]['focus-bright-blue'],
34
- background: toggle['selected']['bg']['default']
34
+ '&:focus-visible $switch': {
35
+ boxShadow: _shadows["default"]['focus-indigo']
35
36
  },
36
- '&:hover $switch:not($checked), &:active $switch:not($checked)': {
37
- background: toggle['unselected']['bg']['hover']
37
+ '&:hover $switch$checked $switchBg, &:active $switch$checked $switchBg': {
38
+ background: toggle.selected.bg.hover
38
39
  },
39
- '&:focus $switch:not($checked)': {
40
- background: toggle['unselected']['bg']['default'],
41
- boxShadow: _shadows["default"]['focus-indigo']
40
+ '&:active $switch $switchBg': {
41
+ boxShadow: "inset 0 0 0 2px ".concat(_colors["default"]["switch"].border["default"])
42
+ },
43
+ '&:focus-visible $switch$checked': {
44
+ boxShadow: _shadows["default"]['focus-bright-blue']
42
45
  }
43
46
  },
47
+ switchWrap: {
48
+ width: toggleWidth,
49
+ height: contentHeight,
50
+ display: 'flex',
51
+ alignItems: 'center',
52
+ flexShrink: 0
53
+ },
44
54
  "switch": {
45
55
  position: 'relative',
46
56
  display: 'inline-block',
47
- width: 38,
57
+ width: toggleWidth,
58
+ height: toggleHeight,
48
59
  flexShrink: 0,
49
- height: _spacing["default"]['size-5'],
50
- background: toggle['unselected']['bg']['default'],
51
- borderRadius: 34,
52
- transition: '0.3s all'
60
+ borderRadius: _borderRadius["default"]['br-full'],
61
+ transition: transition
62
+ },
63
+ switchBg: {
64
+ width: toggleWidth,
65
+ height: toggleHeight,
66
+ background: toggle.unselected.bg["default"],
67
+ boxShadow: "inset 0 0 0 1px ".concat(_colors["default"]["switch"].border["default"]),
68
+ borderRadius: _borderRadius["default"]['br-full'],
69
+ transition: transition
53
70
  },
54
71
  checked: {
55
- background: toggle['selected']['bg']['default'],
56
- '& $slider': {
57
- left: 16
72
+ '& $switchBg': {
73
+ background: toggle.selected.bg["default"]
58
74
  },
59
- '& $icon': {
60
- background: _icons["default"].base(_icons["default"].check.icon([icon.brand.bold]))
75
+ '& $slider': {
76
+ left: "calc(100% - 28px)"
61
77
  }
62
78
  },
63
79
  slider: {
64
80
  position: 'absolute',
65
- cursor: 'pointer',
66
- top: 2,
67
- left: 2,
68
- width: 20,
69
- height: 20,
81
+ top: '50%',
82
+ transform: 'translateY(-50%)',
83
+ left: 4,
84
+ width: sliderSize,
85
+ height: sliderSize,
70
86
  borderRadius: '50%',
71
- background: toggle['bg']['default'],
72
- transition: '0.3s all'
87
+ background: toggle.bg["default"],
88
+ transition: transition
73
89
  },
74
90
  icon: {
75
- width: '100%',
76
- height: '100%',
77
- display: 'block',
78
- background: _icons["default"].base(_icons["default"].cross.icon([icon.brand.disabled])),
79
- transition: '0.3s all'
91
+ margin: 4
80
92
  },
81
93
  disabled: {
82
- '& $switch': {
83
- background: toggle['bg']['disabled']
84
- },
85
- '& $icon': {
86
- background: _icons["default"].base(_icons["default"].cross.icon([icon["default"].disabled]))
94
+ '& $switch $switchBg': {
95
+ boxShadow: "inset 0 0 0 1px ".concat(_colors["default"]["switch"].border.disabled),
96
+ background: toggle.bg.disabled
87
97
  },
88
98
  pointerEvents: 'none'
89
99
  },
100
+ labelWrap: {
101
+ minHeight: contentHeight,
102
+ display: 'flex',
103
+ alignItems: 'center',
104
+ paddingTop: _spacing["default"]['size-1'],
105
+ paddingBottom: _spacing["default"]['size-1'],
106
+ overflow: 'hidden'
107
+ },
90
108
  label: {
91
- marginLeft: _spacing["default"]['size-2']
109
+ marginLeft: _spacing["default"]['size-3'],
110
+ cursor: 'pointer'
92
111
  }
93
112
  };
94
113
  exports["default"] = _default;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _Icon = _interopRequireDefault(require("../../Icon"));
13
+
14
+ var _context = require("../context");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+
18
+ function Tab(props) {
19
+ var _useTabsContext = (0, _context.useTabsContext)(),
20
+ currentValue = _useTabsContext.currentValue,
21
+ setCurrentValue = _useTabsContext.setCurrentValue;
22
+
23
+ var title = props.title,
24
+ size = props.size,
25
+ counter = props.counter,
26
+ icon = props.icon,
27
+ testId = props.testId,
28
+ value = props.value,
29
+ disabled = props.disabled,
30
+ classes = props.classes;
31
+ var iconSize = size === 'small' ? 16 : 24;
32
+
33
+ var onClickHandler = function onClickHandler() {
34
+ if (!disabled) {
35
+ setCurrentValue(value);
36
+ }
37
+ };
38
+
39
+ return /*#__PURE__*/_react["default"].createElement("button", {
40
+ role: "tab",
41
+ onClick: onClickHandler,
42
+ disabled: disabled,
43
+ className: "".concat(classes.button, " ").concat(classes[size]).concat(value === currentValue && !disabled ? " ".concat(classes.selected) : '').concat(!disabled ? " ".concat(classes.enabled) : " ".concat(classes.disabled)),
44
+ type: "button",
45
+ id: "tab-".concat(value),
46
+ tabIndex: value === currentValue ? 0 : -1,
47
+ "data-testid": testId,
48
+ "aria-controls": "tabpanel-".concat(value)
49
+ }, icon ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
50
+ width: iconSize,
51
+ height: iconSize,
52
+ iconName: icon,
53
+ className: "".concat(classes.icon).concat(value === currentValue && !disabled ? " ".concat(classes.iconSelected) : '').concat(disabled ? " ".concat(classes.iconDisabled) : ''),
54
+ transition: "all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s"
55
+ }) : '', title, counter ? /*#__PURE__*/_react["default"].createElement("span", null, counter) : '');
56
+ }
57
+
58
+ Tab.defaultProps = {
59
+ size: 'large'
60
+ };
61
+ Tab.propTypes = {
62
+ title: _propTypes["default"].string.isRequired,
63
+ classes: _propTypes["default"].object.isRequired,
64
+ size: _propTypes["default"].oneOf(['large', 'medium', 'small']),
65
+ onClick: _propTypes["default"].func,
66
+ value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
67
+ icon: _propTypes["default"].string,
68
+ counter: _propTypes["default"].string,
69
+ disabled: _propTypes["default"].bool,
70
+ testId: _propTypes["default"].string
71
+ };
72
+ var _default = Tab;
73
+ exports["default"] = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _reactJss = _interopRequireDefault(require("react-jss"));
9
+
10
+ var _Tab = _interopRequireDefault(require("./Tab"));
11
+
12
+ var _styles = _interopRequireDefault(require("./styles"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+
22
+ 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; }
23
+
24
+ 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; }
25
+
26
+ var StyledTab = (0, _reactJss["default"])(_styles["default"])(_Tab["default"]); // eslint-disable-next-line
27
+
28
+ var _Tab$propTypes = _Tab["default"].propTypes,
29
+ classes = _Tab$propTypes.classes,
30
+ propTypes = _objectWithoutProperties(_Tab$propTypes, ["classes"]);
31
+
32
+ StyledTab.propTypes = _objectSpread(_objectSpread({}, propTypes), StyledTab.propTypes);
33
+ var _default = StyledTab;
34
+ exports["default"] = _default;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _enzyme = require("enzyme");
6
+
7
+ var _ = _interopRequireDefault(require("./"));
8
+
9
+ var _styles = _interopRequireDefault(require("./styles"));
10
+
11
+ var _context = require("../context");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+
15
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+
17
+ var reduceClasses = function reduceClasses(prev, curr) {
18
+ return Object.assign({}, prev, _defineProperty({}, curr, curr));
19
+ };
20
+
21
+ var classes = Object.keys(_styles["default"]).reduce(reduceClasses, {});
22
+ describe('Tab', function () {
23
+ it('should throw an error', function () {
24
+ expect(function () {
25
+ return (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
26
+ title: "Tab title",
27
+ classes: classes,
28
+ testId: "tab-test"
29
+ }));
30
+ }).toThrow('useTabsContext must be used within a TabsProvider');
31
+ });
32
+ it('should render', function () {
33
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
34
+ title: "Tab title",
35
+ classes: classes,
36
+ testId: "tab-test"
37
+ })));
38
+ expect(wrapper.find({
39
+ 'data-testid': 'tab-test'
40
+ }).length).toBe(1);
41
+ expect(wrapper.find({
42
+ 'data-testid': 'tab-test'
43
+ }).text()).toEqual('Tab title');
44
+ });
45
+ it('should render large size', function () {
46
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
47
+ title: "Tab title",
48
+ classes: classes,
49
+ testId: "tab-test",
50
+ size: "large"
51
+ })));
52
+ expect(wrapper.find({
53
+ 'data-testid': 'tab-test'
54
+ }).length).toBe(1);
55
+ expect(wrapper.find({
56
+ 'data-testid': 'tab-test'
57
+ }).prop('className')).toContain('large');
58
+ });
59
+ it('should render medium size', function () {
60
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
61
+ title: "Tab title",
62
+ classes: classes,
63
+ testId: "tab-test",
64
+ size: "medium"
65
+ })));
66
+ expect(wrapper.find({
67
+ 'data-testid': 'tab-test'
68
+ }).length).toBe(1);
69
+ expect(wrapper.find({
70
+ 'data-testid': 'tab-test'
71
+ }).prop('className')).toContain('medium');
72
+ });
73
+ it('should render small size', function () {
74
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
75
+ title: "Tab title",
76
+ classes: classes,
77
+ testId: "tab-test",
78
+ size: "small"
79
+ })));
80
+ expect(wrapper.find({
81
+ 'data-testid': 'tab-test'
82
+ }).length).toBe(1);
83
+ expect(wrapper.find({
84
+ 'data-testid': 'tab-test'
85
+ }).prop('className')).toContain('small');
86
+ });
87
+ it('should render with icon', function () {
88
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
89
+ title: "Tab title",
90
+ classes: classes,
91
+ testId: "tab-test",
92
+ icon: "search"
93
+ })));
94
+ var tab = wrapper.find({
95
+ 'data-testid': 'tab-test'
96
+ });
97
+ expect(tab.length).toBe(1);
98
+ var icon = tab.children().at(0).name();
99
+ expect(icon).toBe('Jss(Icon)');
100
+ });
101
+ it('should render with counter', function () {
102
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
103
+ title: "Tab title",
104
+ classes: classes,
105
+ testId: "tab-test",
106
+ counter: "12"
107
+ })));
108
+ var tab = wrapper.find({
109
+ 'data-testid': 'tab-test'
110
+ });
111
+ expect(tab.length).toBe(1);
112
+ var counter = tab.children().at(tab.children().length - 1);
113
+ expect(counter.text()).toBe('12');
114
+ });
115
+ it('should be disabled', function () {
116
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
117
+ title: "Tab title",
118
+ testId: "tab-test",
119
+ icon: "search",
120
+ counter: "12",
121
+ disabled: true
122
+ })));
123
+ var tab = wrapper.find({
124
+ 'data-testid': 'tab-test'
125
+ });
126
+ expect(tab.length).toBe(1);
127
+ expect(tab.prop('disabled')).toEqual(true);
128
+ expect(tab.prop('className')).toContain('disabled');
129
+ var icon = tab.children().at(0);
130
+ expect(icon.prop('className')).toContain('iconDisabled');
131
+ });
132
+ });
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _colors = _interopRequireDefault(require("../../tokens/colors.json"));
9
+
10
+ var _spacing = _interopRequireDefault(require("../../tokens/spacing.json"));
11
+
12
+ var _fonts = _interopRequireDefault(require("../../tokens/fonts.json"));
13
+
14
+ var _styles = require("../../Text/styles");
15
+
16
+ var _shadows = _interopRequireDefault(require("../../tokens/shadows.json"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
20
+ var _default = {
21
+ button: {
22
+ display: 'flex',
23
+ flexDirection: 'row',
24
+ gap: _spacing["default"]['size-2'],
25
+ background: 'transparent',
26
+ border: 0,
27
+ transition: 'all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s',
28
+ whiteSpace: 'nowrap',
29
+ alignItems: 'center'
30
+ },
31
+ enabled: {
32
+ color: _colors["default"].text.corp.secondary,
33
+ cursor: 'pointer',
34
+ '&:hover': {
35
+ color: _colors["default"].text.corp.primary,
36
+ '& $icon': {
37
+ fill: _colors["default"].icon["default"].bold
38
+ }
39
+ },
40
+ '&:focus-visible': {
41
+ outline: 'none',
42
+ boxShadow: "inset ".concat(_shadows["default"]['focus-bright-blue'])
43
+ }
44
+ },
45
+ small: {
46
+ font: (0, _styles.parseFontValue)(_fonts["default"]['button-small']),
47
+ padding: [_spacing["default"]['size-3'], _spacing["default"]['size-4']]
48
+ },
49
+ medium: {
50
+ font: (0, _styles.parseFontValue)(_fonts["default"]['button-medium']),
51
+ padding: [_spacing["default"]['size-3'], _spacing["default"]['size-5']]
52
+ },
53
+ large: {
54
+ font: (0, _styles.parseFontValue)(_fonts["default"]['button-large']),
55
+ padding: [_spacing["default"]['size-4'], _spacing["default"]['size-7']]
56
+ },
57
+ selected: {
58
+ color: _colors["default"].text.corp.primary
59
+ },
60
+ disabled: {
61
+ color: _colors["default"].text.corp.disabled,
62
+ cursor: 'default'
63
+ },
64
+ icon: {
65
+ fill: _colors["default"].icon["default"]["default"]
66
+ },
67
+ iconDisabled: {
68
+ fill: _colors["default"].icon["default"].disabled
69
+ },
70
+ iconSelected: {
71
+ fill: _colors["default"].icon["default"].bold
72
+ }
73
+ };
74
+ exports["default"] = _default;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _context = require("../context");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
+
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
+
24
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
+
26
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
+
28
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
+
30
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
31
+
32
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
+
34
+ function TabContent(props) {
35
+ var _useState = (0, _react.useState)(false),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ show = _useState2[0],
38
+ setShow = _useState2[1];
39
+
40
+ var _useTabsContext = (0, _context.useTabsContext)(),
41
+ currentValue = _useTabsContext.currentValue;
42
+
43
+ var children = props.children,
44
+ value = props.value,
45
+ testId = props.testId,
46
+ classes = props.classes;
47
+ (0, _react.useEffect)(function () {
48
+ var timeout = setTimeout(function () {
49
+ return setShow(currentValue === value);
50
+ }, 150);
51
+ return function () {
52
+ return clearTimeout(timeout);
53
+ };
54
+ }, [currentValue, value]);
55
+ return /*#__PURE__*/_react["default"].createElement("div", {
56
+ className: "".concat(classes.container).concat(currentValue !== value ? " ".concat(classes.hide) : ''),
57
+ "data-testid": testId,
58
+ role: "tabpanel",
59
+ id: "tabpanel-".concat(value),
60
+ "aria-labelledby": "tab-".concat(value)
61
+ }, /*#__PURE__*/_react["default"].createElement("div", {
62
+ style: {
63
+ opacity: show ? 1 : 0,
64
+ transition: 'all cubic-bezier(0.25,0.46,0.45,0.94) 0.2s'
65
+ }
66
+ }, children));
67
+ }
68
+
69
+ TabContent.propTypes = {
70
+ value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]).isRequired,
71
+ classes: _propTypes["default"].object.isRequired,
72
+ children: _propTypes["default"].node.isRequired,
73
+ testId: _propTypes["default"].string
74
+ };
75
+ var _default = TabContent;
76
+ exports["default"] = _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _reactJss = _interopRequireDefault(require("react-jss"));
9
+
10
+ var _TabContent = _interopRequireDefault(require("./TabContent"));
11
+
12
+ var _styles = _interopRequireDefault(require("./styles"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
19
+
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+
22
+ 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; }
23
+
24
+ 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; }
25
+
26
+ var StyledTabContent = (0, _reactJss["default"])(_styles["default"])(_TabContent["default"]); // eslint-disable-next-line
27
+
28
+ var _TabContent$propTypes = _TabContent["default"].propTypes,
29
+ classes = _TabContent$propTypes.classes,
30
+ propTypes = _objectWithoutProperties(_TabContent$propTypes, ["classes"]);
31
+
32
+ StyledTabContent.propTypes = _objectSpread(_objectSpread({}, propTypes), StyledTabContent.propTypes);
33
+ var _default = StyledTabContent;
34
+ exports["default"] = _default;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _enzyme = require("enzyme");
6
+
7
+ var _ = _interopRequireDefault(require("./"));
8
+
9
+ var _styles = _interopRequireDefault(require("./styles"));
10
+
11
+ var _context = require("../context");
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+
15
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+
17
+ var reduceClasses = function reduceClasses(prev, curr) {
18
+ return Object.assign({}, prev, _defineProperty({}, curr, curr));
19
+ };
20
+
21
+ var classes = Object.keys(_styles["default"]).reduce(reduceClasses, {});
22
+ describe('Tab', function () {
23
+ it('should throw an error', function () {
24
+ expect(function () {
25
+ return (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_["default"], {
26
+ classes: classes,
27
+ value: 1,
28
+ testId: "tab-content-1"
29
+ }, "Tab Content"));
30
+ }).toThrow('useTabsContext must be used within a TabsProvider');
31
+ });
32
+ it('should render', function () {
33
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
34
+ classes: classes,
35
+ value: 0,
36
+ testId: "tab-content-1"
37
+ }, "Tab Content")));
38
+ var tabContent = wrapper.find({
39
+ 'data-testid': 'tab-content-1'
40
+ });
41
+ expect(tabContent.length).toBe(1);
42
+ expect(tabContent.children().at(0).text()).toEqual('Tab Content');
43
+ });
44
+ it('should be visible', function () {
45
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
46
+ classes: classes,
47
+ value: 0,
48
+ testId: "tab-content-1"
49
+ }, "Tab Content")));
50
+ var tabContent = wrapper.find({
51
+ 'data-testid': 'tab-content-1'
52
+ });
53
+ expect(tabContent.length).toBe(1);
54
+ expect(tabContent.prop('className')).not.toContain('hide');
55
+ });
56
+ it('should be hide', function () {
57
+ var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(_context.TabsProviderUncontrolled, null, /*#__PURE__*/_react["default"].createElement(_["default"], {
58
+ classes: classes,
59
+ value: 1,
60
+ testId: "tab-content-1"
61
+ }, "Tab Content")));
62
+ var tabContent = wrapper.find({
63
+ 'data-testid': 'tab-content-1'
64
+ });
65
+ expect(tabContent.length).toBe(1);
66
+ expect(tabContent.prop('className')).toContain('hide');
67
+ });
68
+ });