@zohodesk/components 1.3.2 → 1.3.4

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 (61) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +15 -0
  3. package/es/Button/__tests__/Button.spec.js +134 -1
  4. package/es/DateTime/__tests__/YearView.spec.js +1 -2
  5. package/es/MultiSelect/MultiSelect.js +15 -2
  6. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -1
  7. package/es/MultiSelect/props/propTypes.js +3 -1
  8. package/es/Provider/IdProvider.js +1 -1
  9. package/es/Select/Select.js +15 -6
  10. package/es/Select/__tests__/Select.spec.js +1130 -4
  11. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  12. package/es/Select/props/propTypes.js +3 -1
  13. package/es/Stencils/Stencils.js +5 -12
  14. package/es/Stencils/Stencils.module.css +11 -7
  15. package/es/Stencils/__tests__/Stencils.spec.js +9 -1
  16. package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  17. package/es/Stencils/props/defaultProps.js +2 -1
  18. package/es/Stencils/props/propTypes.js +3 -2
  19. package/es/Tab/Tab.js +2 -1
  20. package/es/Tab/TabWrapper.js +2 -1
  21. package/es/Tab/Tabs.js +10 -10
  22. package/es/Tab/__tests__/TabLayout.spec.js +34 -0
  23. package/es/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  24. package/es/Tab/props/propTypes.js +2 -2
  25. package/es/Tab/utils/tabConfigs.js +18 -0
  26. package/es/Tag/__tests__/Tag.spec.js +8 -1
  27. package/es/TextBoxIcon/TextBoxIcon.js +6 -2
  28. package/es/TextBoxIcon/props/propTypes.js +2 -1
  29. package/es/utils/Common.js +1 -1
  30. package/lib/Button/__tests__/Button.spec.js +140 -0
  31. package/lib/DateTime/__tests__/YearView.spec.js +1 -2
  32. package/lib/MultiSelect/MultiSelect.js +16 -3
  33. package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -0
  34. package/lib/MultiSelect/props/propTypes.js +3 -1
  35. package/lib/Provider/IdProvider.js +1 -0
  36. package/lib/Select/Select.js +16 -7
  37. package/lib/Select/__tests__/Select.spec.js +1364 -3
  38. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  39. package/lib/Select/props/propTypes.js +3 -1
  40. package/lib/Stencils/Stencils.js +5 -12
  41. package/lib/Stencils/Stencils.module.css +11 -7
  42. package/lib/Stencils/__tests__/Stencils.spec.js +11 -3
  43. package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  44. package/lib/Stencils/props/defaultProps.js +2 -1
  45. package/lib/Stencils/props/propTypes.js +3 -2
  46. package/lib/Tab/Tab.js +3 -1
  47. package/lib/Tab/TabWrapper.js +3 -1
  48. package/lib/Tab/Tabs.js +11 -10
  49. package/lib/Tab/__tests__/TabLayout.spec.js +41 -0
  50. package/lib/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  51. package/lib/Tab/props/propTypes.js +2 -2
  52. package/lib/Tab/utils/tabConfigs.js +27 -0
  53. package/lib/Tag/__tests__/Tag.spec.js +10 -2
  54. package/lib/TextBoxIcon/TextBoxIcon.js +6 -2
  55. package/lib/TextBoxIcon/props/propTypes.js +2 -1
  56. package/lib/utils/Common.js +1 -1
  57. package/package.json +1 -1
  58. package/react-cli.config.js +2 -2
  59. package/result.json +1 -1
  60. package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
  61. package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
@@ -94,7 +94,9 @@ export const Select_propTypes = {
94
94
  targetOffset: PropTypes.object,
95
95
  isRestrictScroll: PropTypes.bool,
96
96
  dropBoxPortalId: PropTypes.string,
97
- allowValueFallback: PropTypes.bool
97
+ allowValueFallback: PropTypes.bool,
98
+ renderCustomToggleIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
99
+ renderCustomSearchClearComponent: PropTypes.func
98
100
  };
99
101
  export const GroupSelect_propTypes = {
100
102
  groupedOptions: PropTypes.arrayOf(PropTypes.shape({
@@ -10,22 +10,15 @@ export default class Stencils extends React.PureComponent {
10
10
  shape,
11
11
  size,
12
12
  palette,
13
- customClass
13
+ customClass,
14
+ isAnimated
14
15
  } = this.props;
15
- size = shape === 'rect' ? style[size] : style[`c${size}`];
16
- shape = shape === 'rect' ? style.rectangular : style.circle;
16
+ size = shape === 'rect' ? style[size] : style[`size_${size}`];
17
17
  return /*#__PURE__*/React.createElement("div", {
18
- className: `${style.container} ${shape} ${size} ${style[palette]} ${customClass}`
18
+ className: `${style.container} ${isAnimated ? style.animate : ''} ${style[shape]} ${size} ${style[palette]} ${customClass}`
19
19
  });
20
20
  }
21
21
 
22
22
  }
23
23
  Stencils.propTypes = propTypes;
24
- Stencils.defaultProps = defaultProps; // if (__DOCS__) {
25
- // Stencils.docs = {
26
- // componentGroup: 'Atom',
27
- // folderName: 'Style Guide',
28
- // description: ' ',
29
- // external: true
30
- // };
31
- // }
24
+ Stencils.defaultProps = defaultProps;
@@ -13,14 +13,14 @@
13
13
  .stencil {
14
14
  background-size: 800px 1px;
15
15
  }
16
- [dir=ltr] .stencil {
16
+ [dir=ltr] .animate{
17
17
  animation-name: placeHolderShimmer-ltr ;
18
18
  animation-fill-mode: forwards;
19
19
  animation-iteration-count: infinite;
20
20
  animation-duration: var(--zd_transition10);
21
21
  animation-timing-function: linear;
22
22
  }
23
- [dir=rtl] .stencil {
23
+ [dir=rtl] .animate{
24
24
  animation-name: placeHolderShimmer-rtl ;
25
25
  animation-fill-mode: forwards;
26
26
  animation-iteration-count: infinite;
@@ -46,7 +46,7 @@
46
46
  }
47
47
  }
48
48
 
49
- .rectangular {
49
+ .rect {
50
50
  composes: stencil;
51
51
  --stencil_height: var(--zd_size9);
52
52
  --stencil_border_radius: 5px;
@@ -81,16 +81,20 @@
81
81
  composes: stencil;
82
82
  --stencil_border_radius: 50%;
83
83
  }
84
- .clarge {
84
+ .square {
85
+ composes: stencil;
86
+ --stencil_border_radius: 4px;
87
+ }
88
+ .size_large {
85
89
  --stencil_width: var(--zd_size42);
86
90
  --stencil_height: var(--zd_size42);
87
91
  }
88
- .cmedium,
89
- .cdefault {
92
+ .size_medium,
93
+ .size_default {
90
94
  --stencil_width: var(--zd_size30);
91
95
  --stencil_height: var(--zd_size30);
92
96
  }
93
- .csmall {
97
+ .size_small {
94
98
  --stencil_width: var(--zd_size20);
95
99
  --stencil_height: var(--zd_size20);
96
100
  }
@@ -17,7 +17,7 @@ describe('Stencils', () => {
17
17
  }));
18
18
  expect(asFragment()).toMatchSnapshot();
19
19
  });
20
- const shape = ['rect', 'circle'];
20
+ const shape = ['rect', 'circle', 'square'];
21
21
  test.each(shape)('rendering the shape of- %s', shape => {
22
22
  const {
23
23
  asFragment
@@ -35,6 +35,14 @@ describe('Stencils', () => {
35
35
  }));
36
36
  expect(asFragment()).toMatchSnapshot();
37
37
  });
38
+ test('rendering without animation', () => {
39
+ const {
40
+ asFragment
41
+ } = render( /*#__PURE__*/React.createElement(Stencils, {
42
+ isAnimated: false
43
+ }));
44
+ expect(asFragment()).toMatchSnapshot();
45
+ });
38
46
  test('rendering the customClass', () => {
39
47
  const {
40
48
  asFragment
@@ -3,7 +3,7 @@
3
3
  exports[`Stencils rendering the customClass 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="container rectangular medium primary StencilsCustomClass"
6
+ class="container animate rect medium primary StencilsCustomClass"
7
7
  />
8
8
  </DocumentFragment>
9
9
  `;
@@ -11,7 +11,7 @@ exports[`Stencils rendering the customClass 1`] = `
11
11
  exports[`Stencils rendering the defult props 1`] = `
12
12
  <DocumentFragment>
13
13
  <div
14
- class="container rectangular medium primary "
14
+ class="container animate rect medium primary "
15
15
  />
16
16
  </DocumentFragment>
17
17
  `;
@@ -19,7 +19,7 @@ exports[`Stencils rendering the defult props 1`] = `
19
19
  exports[`Stencils rendering the palette of- dark 1`] = `
20
20
  <DocumentFragment>
21
21
  <div
22
- class="container rectangular medium dark "
22
+ class="container animate rect medium dark "
23
23
  />
24
24
  </DocumentFragment>
25
25
  `;
@@ -27,7 +27,7 @@ exports[`Stencils rendering the palette of- dark 1`] = `
27
27
  exports[`Stencils rendering the palette of- primary 1`] = `
28
28
  <DocumentFragment>
29
29
  <div
30
- class="container rectangular medium primary "
30
+ class="container animate rect medium primary "
31
31
  />
32
32
  </DocumentFragment>
33
33
  `;
@@ -35,7 +35,7 @@ exports[`Stencils rendering the palette of- primary 1`] = `
35
35
  exports[`Stencils rendering the palette of- secondary 1`] = `
36
36
  <DocumentFragment>
37
37
  <div
38
- class="container rectangular medium secondary "
38
+ class="container animate rect medium secondary "
39
39
  />
40
40
  </DocumentFragment>
41
41
  `;
@@ -43,7 +43,7 @@ exports[`Stencils rendering the palette of- secondary 1`] = `
43
43
  exports[`Stencils rendering the shape of- circle 1`] = `
44
44
  <DocumentFragment>
45
45
  <div
46
- class="container circle cmedium primary "
46
+ class="container animate circle size_medium primary "
47
47
  />
48
48
  </DocumentFragment>
49
49
  `;
@@ -51,7 +51,15 @@ exports[`Stencils rendering the shape of- circle 1`] = `
51
51
  exports[`Stencils rendering the shape of- rect 1`] = `
52
52
  <DocumentFragment>
53
53
  <div
54
- class="container rectangular medium primary "
54
+ class="container animate rect medium primary "
55
+ />
56
+ </DocumentFragment>
57
+ `;
58
+
59
+ exports[`Stencils rendering the shape of- square 1`] = `
60
+ <DocumentFragment>
61
+ <div
62
+ class="container animate square size_medium primary "
55
63
  />
56
64
  </DocumentFragment>
57
65
  `;
@@ -59,7 +67,7 @@ exports[`Stencils rendering the shape of- rect 1`] = `
59
67
  exports[`Stencils rendering the size of- default 1`] = `
60
68
  <DocumentFragment>
61
69
  <div
62
- class="container rectangular default primary "
70
+ class="container animate rect default primary "
63
71
  />
64
72
  </DocumentFragment>
65
73
  `;
@@ -67,7 +75,7 @@ exports[`Stencils rendering the size of- default 1`] = `
67
75
  exports[`Stencils rendering the size of- large 1`] = `
68
76
  <DocumentFragment>
69
77
  <div
70
- class="container rectangular large primary "
78
+ class="container animate rect large primary "
71
79
  />
72
80
  </DocumentFragment>
73
81
  `;
@@ -75,7 +83,7 @@ exports[`Stencils rendering the size of- large 1`] = `
75
83
  exports[`Stencils rendering the size of- medium 1`] = `
76
84
  <DocumentFragment>
77
85
  <div
78
- class="container rectangular medium primary "
86
+ class="container animate rect medium primary "
79
87
  />
80
88
  </DocumentFragment>
81
89
  `;
@@ -83,7 +91,15 @@ exports[`Stencils rendering the size of- medium 1`] = `
83
91
  exports[`Stencils rendering the size of- small 1`] = `
84
92
  <DocumentFragment>
85
93
  <div
86
- class="container rectangular small primary "
94
+ class="container animate rect small primary "
95
+ />
96
+ </DocumentFragment>
97
+ `;
98
+
99
+ exports[`Stencils rendering without animation 1`] = `
100
+ <DocumentFragment>
101
+ <div
102
+ class="container rect medium primary "
87
103
  />
88
104
  </DocumentFragment>
89
105
  `;
@@ -2,5 +2,6 @@ export const defaultProps = {
2
2
  palette: 'primary',
3
3
  shape: 'rect',
4
4
  size: 'medium',
5
- customClass: ''
5
+ customClass: '',
6
+ isAnimated: true
6
7
  };
@@ -1,7 +1,8 @@
1
1
  import PropTypes from 'prop-types';
2
2
  export const propTypes = {
3
3
  palette: PropTypes.oneOf(['primary', 'secondary', 'dark']),
4
- shape: PropTypes.oneOf(['rect', 'circle']),
4
+ shape: PropTypes.oneOf(['rect', 'circle', 'square']),
5
5
  size: PropTypes.oneOf(['small', 'medium', 'large', 'default']),
6
- customClass: PropTypes.string
6
+ customClass: PropTypes.string,
7
+ isAnimated: PropTypes.bool
7
8
  };
package/es/Tab/Tab.js CHANGED
@@ -6,6 +6,7 @@ import { Tab_defaultProps } from "./props/defaultProps";
6
6
  import { Tab_propTypes } from "./props/propTypes";
7
7
  import { Box, Container } from "../Layout";
8
8
  import { cs } from "../utils/Common";
9
+ import { TAB_DIRECTION_MAPPING } from "./utils/tabConfigs";
9
10
  import styles from "./Tab.module.css";
10
11
  const tabTypes = {
11
12
  alpha: {
@@ -67,7 +68,7 @@ export default function Tab(_ref) {
67
68
  let activeWithAppearance = cs([styles[styleContent.active], needBorder && !isAnimate && styles[`${styleContent.active}_border`]]);
68
69
  let activeClasses = cs([needAppearance && activeWithAppearance, activeClass]);
69
70
  let inActiveClasses = needAppearance && cs([styles[styleContent.tab], tabTypes[type] && styles[`${`${type}Hover`}`]]);
70
- let tabClass = cs([styles.tab, align === 'vertical' ? styles.vertical : styles.horizontal, isDisabled && styles.disabled, needBorder && !isAnimate && needAppearance && styles.border, isActive ? activeClasses : inActiveClasses, className]);
71
+ let tabClass = cs([styles.tab, TAB_DIRECTION_MAPPING[align] === 'column' ? styles.vertical : styles.horizontal, isDisabled && styles.disabled, needBorder && !isAnimate && needAppearance && styles.border, isActive ? activeClasses : inActiveClasses, className]);
71
72
  return /*#__PURE__*/React.createElement(Box, {
72
73
  tourId: tourId,
73
74
  tagName: isLink ? 'a' : 'div',
@@ -2,6 +2,7 @@ import React, { useState, useCallback } from 'react';
2
2
  import { TabWrapper_defaultProps } from "./props/defaultProps";
3
3
  import { TabWrapper_propTypes } from "./props/propTypes";
4
4
  import { Container } from "../Layout";
5
+ import { TAB_ALIGN_MAPPING } from "./utils/tabConfigs";
5
6
 
6
7
  function TabWrapper(_ref) {
7
8
  let {
@@ -28,7 +29,7 @@ function TabWrapper(_ref) {
28
29
  onSelect && onSelect(id);
29
30
  }, [hookToDisableInternalState, onSelect]);
30
31
  return /*#__PURE__*/React.createElement(Container, {
31
- alignBox: align === 'vertical' ? 'column' : 'row',
32
+ alignBox: TAB_ALIGN_MAPPING[align],
32
33
  dataId: dataId,
33
34
  dataSelectorId: dataSelectorId
34
35
  }, React.Children.map(children, child => {
package/es/Tab/Tabs.js CHANGED
@@ -22,6 +22,7 @@ import Popup from "../Popup/Popup";
22
22
  import TextBoxIcon from "../TextBoxIcon/TextBoxIcon";
23
23
  import ResponsiveDropBox from "../ResponsiveDropBox/ResponsiveDropBox";
24
24
  import { ResponsiveReceiver } from "../Responsive/CustomResponsive";
25
+ import { TAB_DIRECTION_MAPPING, TAB_POPUP_POSITION_MAPPING } from "./utils/tabConfigs";
25
26
  import btnstyle from "../semantic/Button/semanticButton.module.css";
26
27
 
27
28
  class Tabs extends React.Component {
@@ -118,7 +119,7 @@ class Tabs extends React.Component {
118
119
  align
119
120
  } = this.props;
120
121
  let newDim = `${remConvert(totalDimension)}rem`;
121
- align === 'vertical' ? this[selectedTab].style.maxWidth = newDim : this[selectedTab].style.maxHeight = newDim;
122
+ TAB_DIRECTION_MAPPING[align] === 'column' ? this[selectedTab].style.maxWidth = newDim : this[selectedTab].style.maxHeight = newDim;
122
123
  }
123
124
  }
124
125
 
@@ -126,7 +127,7 @@ class Tabs extends React.Component {
126
127
  let {
127
128
  align
128
129
  } = this.props;
129
- return align === 'vertical' ? this.highlight.offsetLeft : this.highlight.offsetTop;
130
+ return TAB_DIRECTION_MAPPING[align] === 'column' ? this.highlight.offsetLeft : this.highlight.offsetTop;
130
131
  }
131
132
 
132
133
  componentDidUpdate(prevProps) {
@@ -199,12 +200,12 @@ class Tabs extends React.Component {
199
200
  if (tabActive) {
200
201
  let position, dimension;
201
202
 
202
- if (align === 'vertical') {
203
+ if (TAB_DIRECTION_MAPPING[align] === 'column') {
203
204
  position = tabActive.offsetLeft;
204
205
  dimension = tabActive.offsetWidth;
205
206
  node.style.transform = `translateX(${remConvert(position - highlightInitialDimension)}rem)`;
206
207
  node.style.width = `${remConvert(dimension)}rem`;
207
- } else if (align === 'horizontal') {
208
+ } else if (TAB_DIRECTION_MAPPING[align] === 'row') {
208
209
  position = tabActive.offsetTop;
209
210
  dimension = tabActive.offsetHeight;
210
211
  node.style.transform = `translateY(${remConvert(position - highlightInitialDimension)}rem)`;
@@ -402,8 +403,7 @@ class Tabs extends React.Component {
402
403
  removeClose
403
404
  } = this.props;
404
405
  removeClose && removeClose(e);
405
- let popupPosition = align === 'vertical' ? 'bottomLeft' : 'rightTop';
406
- boxPosition = boxPosition ? boxPosition : popupPosition;
406
+ boxPosition = boxPosition ? boxPosition : TAB_POPUP_POSITION_MAPPING[align];
407
407
  togglePopup(e, boxPosition);
408
408
  }
409
409
 
@@ -527,7 +527,7 @@ class Tabs extends React.Component {
527
527
  MoreButtonProps = {},
528
528
  TextBoxIconProps = {}
529
529
  } = customProps;
530
- let popupClass = align === 'vertical' ? tabsStyle[position] ? tabsStyle[position] : '' : '';
530
+ let popupClass = TAB_DIRECTION_MAPPING[align] === 'column' ? tabsStyle[position] ? tabsStyle[position] : '' : '';
531
531
  const moreTabsListItems = this.handleFilterSuggestions({
532
532
  moreTabs
533
533
  });
@@ -695,17 +695,17 @@ class Tabs extends React.Component {
695
695
  className: containerClass,
696
696
  dataSelectorId: dataSelectorId
697
697
  }, /*#__PURE__*/React.createElement(Container, {
698
- alignBox: align === 'vertical' ? 'row' : 'column',
698
+ alignBox: TAB_DIRECTION_MAPPING[align] === 'column' ? 'row' : 'column',
699
699
  className: tabsClass,
700
700
  style: style
701
701
  }, /*#__PURE__*/React.createElement(Box, {
702
702
  eleRef: this.getTabsRef,
703
703
  flexible: true
704
704
  }, renderVirtualTabs && /*#__PURE__*/React.createElement(Container, {
705
- alignBox: align === 'vertical' ? 'row' : 'column',
705
+ alignBox: TAB_DIRECTION_MAPPING[align] === 'column' ? 'row' : 'column',
706
706
  className: tabsStyle.hidden
707
707
  }, this.renderTabs(children, [], true)), /*#__PURE__*/React.createElement(Container, {
708
- alignBox: align === 'vertical' ? 'row' : 'column'
708
+ alignBox: TAB_DIRECTION_MAPPING[align] === 'column' ? 'row' : 'column'
709
709
  }, this.renderTabs(mainTabs, moreTabs, false))), otherTabs.length ? /*#__PURE__*/React.createElement(Box, null, otherTabs) : null, isAnimate && needTabBorder && needAppearance && /*#__PURE__*/React.createElement("div", {
710
710
  className: hlClass,
711
711
  ref: this.getHighlightRef,
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import { TabWrapper, Tabs, Tab, TabContentWrapper, TabContent } from "../index";
4
+ describe('TabWrapper', () => {
5
+ const alignments = ['vertical', 'horizontal', 'vertical-reverse', 'horizontal-reverse'];
6
+ test.each(alignments)('rendering the align prop of - %s', alignments => {
7
+ const {
8
+ asFragment
9
+ } = render( /*#__PURE__*/React.createElement(TabWrapper, {
10
+ type: "alpha",
11
+ align: alignments,
12
+ defaultTab: "page1"
13
+ }, /*#__PURE__*/React.createElement(Tabs, null, /*#__PURE__*/React.createElement(Tab, {
14
+ id: "page1",
15
+ text: "Page 1"
16
+ }), /*#__PURE__*/React.createElement(Tab, {
17
+ id: "page2",
18
+ text: "Page 2"
19
+ }), /*#__PURE__*/React.createElement(Tab, {
20
+ id: "page3",
21
+ text: "Page 3"
22
+ })), /*#__PURE__*/React.createElement(TabContentWrapper, null, /*#__PURE__*/React.createElement(TabContent, {
23
+ id: "page1",
24
+ text: "Page 1"
25
+ }, /*#__PURE__*/React.createElement("div", null, "Page 1 Content")), /*#__PURE__*/React.createElement(TabContent, {
26
+ id: "page2",
27
+ text: "Page 2"
28
+ }, /*#__PURE__*/React.createElement("div", null, "Page 2 Content")), /*#__PURE__*/React.createElement(TabContent, {
29
+ id: "page3",
30
+ text: "Page 3"
31
+ }, /*#__PURE__*/React.createElement("div", null, "Page 3 Content")))));
32
+ expect(asFragment()).toMatchSnapshot();
33
+ });
34
+ });