@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
package/README.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+
6
+ # 1.3.4
7
+
8
+ - **MultiSelect** - `renderCustomClearComponent` and `renderCustomToggleIndicator` props supported to customize the clear and toggle indicatior icon.
9
+ - **Select** - `renderCustomSearchClearComponent` and `renderCustomToggleIndicator` props supported to customize the search input clear and toggle indicatior icon.
10
+ - **TextBoxIcon** - `renderCustomClearComponent` prop supported to customize the input clear.
11
+
12
+ # 1.3.3
13
+
14
+ - **Stencils**
15
+ - Added `isAnimated` prop to support Stencils without Animation.
16
+ - Added `square` shape in existing shape collection
17
+ - **TabWrapper**
18
+ - Added `vertical-reverse, row-reverse` alignment suport in align propType
19
+
5
20
  # 1.3.2
6
21
 
7
22
  - **Popup**
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
2
  import Button from "../Button";
3
- import { render } from "@testing-library/react";
3
+ import { render, cleanup } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import '@testing-library/jest-dom';
6
+ afterEach(() => {
7
+ cleanup();
8
+ });
4
9
  describe('Button component', () => {
5
10
  test('Should be render with the basic set of default props', () => {
6
11
  const {
@@ -106,4 +111,132 @@ describe('Button component', () => {
106
111
  // const { asFragment } = render(<Button customStyle={{$medium: "buttonMedium"}} />);
107
112
  // expect(asFragment()).toMatchSnapshot();
108
113
  // });
114
+ });
115
+ describe('Button - Unit Testing', () => {
116
+ test('Should render with text prop', () => {
117
+ const {
118
+ getByText
119
+ } = render( /*#__PURE__*/React.createElement(Button, {
120
+ text: "Click Me"
121
+ }));
122
+ expect(getByText('Click Me')).toBeInTheDocument();
123
+ });
124
+ test('Should render with children prop', () => {
125
+ const {
126
+ getByText
127
+ } = render( /*#__PURE__*/React.createElement(Button, null, "Click Me"));
128
+ expect(getByText('Click Me')).toBeInTheDocument();
129
+ });
130
+ test('Should apply custom styles from customStyle prop', () => {
131
+ const {
132
+ getByRole
133
+ } = render( /*#__PURE__*/React.createElement(Button, {
134
+ customStyle: {
135
+ bold: 'customBoldClass'
136
+ }
137
+ })); // expect(getByRole('button').getAttribute('class')).toContain('customBoldClass');
138
+
139
+ expect(getByRole('button')).toHaveClass('customBoldClass');
140
+ });
141
+ test('Should apply custom classes from customClass prop', () => {
142
+ const {
143
+ getByRole
144
+ } = render( /*#__PURE__*/React.createElement(Button, {
145
+ customClass: {
146
+ customButton: 'customButtonClass'
147
+ }
148
+ }));
149
+ expect(getByRole('button')).toHaveClass('customButtonClass');
150
+ });
151
+ test('Should be disabled when disabled prop is true', () => {
152
+ const {
153
+ getByRole
154
+ } = render( /*#__PURE__*/React.createElement(Button, {
155
+ disabled: true
156
+ }));
157
+ expect(getByRole('button')).toBeDisabled();
158
+ });
159
+ test('Should expose element with getRef prop', () => {
160
+ const getRef = jest.fn();
161
+ const {
162
+ getByRole
163
+ } = render( /*#__PURE__*/React.createElement(Button, {
164
+ getRef: getRef
165
+ }));
166
+ expect(getRef).toHaveBeenCalledWith(getByRole('button'));
167
+ });
168
+ test('Should trigger onClick function', () => {
169
+ const onClick = jest.fn();
170
+ const {
171
+ getByRole
172
+ } = render( /*#__PURE__*/React.createElement(Button, {
173
+ onClick: onClick
174
+ })); // fireEvent.click(getByRole('button'));
175
+
176
+ userEvent.click(getByRole('button'));
177
+ expect(onClick).toHaveBeenCalled();
178
+ });
179
+ test('Should not trigger onClick when disabled', () => {
180
+ const onClick = jest.fn();
181
+ const {
182
+ getByRole
183
+ } = render( /*#__PURE__*/React.createElement(Button, {
184
+ disabled: true,
185
+ onClick: onClick
186
+ }));
187
+ userEvent.click(getByRole('button'));
188
+ expect(onClick).not.toHaveBeenCalled();
189
+ });
190
+ test('Should render with correct data-id attribute', () => {
191
+ const {
192
+ getByRole
193
+ } = render( /*#__PURE__*/React.createElement(Button, {
194
+ dataId: "testButton"
195
+ }));
196
+ expect(getByRole('button')).toHaveAttribute('data-id', 'testButton');
197
+ });
198
+ test('Should render with correct data-selector-id attribute', () => {
199
+ const {
200
+ getByRole
201
+ } = render( /*#__PURE__*/React.createElement(Button, {
202
+ dataSelectorId: "testSelector"
203
+ }));
204
+ expect(getByRole('button')).toHaveAttribute('data-selector-id', 'testSelector');
205
+ });
206
+ test('Should render with correct title attribute', () => {
207
+ const {
208
+ getByRole
209
+ } = render( /*#__PURE__*/React.createElement(Button, {
210
+ title: "Test Title"
211
+ }));
212
+ expect(getByRole('button')).toHaveAttribute('data-title', 'Test Title');
213
+ });
214
+ test('Should render with correct id attribute', () => {
215
+ const {
216
+ getByRole
217
+ } = render( /*#__PURE__*/React.createElement(Button, {
218
+ id: "buttonElement"
219
+ }));
220
+ expect(getByRole('button')).toHaveAttribute('id', 'buttonElement');
221
+ });
222
+ test('Should apply a11y props correctly', () => {
223
+ const {
224
+ getByRole
225
+ } = render( /*#__PURE__*/React.createElement(Button, {
226
+ a11y: {
227
+ 'aria-label': 'test'
228
+ }
229
+ }));
230
+ expect(getByRole('button')).toHaveAttribute('aria-label', 'test');
231
+ });
232
+ test('Should apply customProps correctly', () => {
233
+ const {
234
+ getByRole
235
+ } = render( /*#__PURE__*/React.createElement(Button, {
236
+ customProps: {
237
+ 'data-custom-attr': 'true'
238
+ }
239
+ }));
240
+ expect(getByRole('button')).toHaveAttribute('data-custom-attr', 'true');
241
+ });
109
242
  });
@@ -5,7 +5,6 @@ describe('YearView', () => {
5
5
  test('rendering the defult props', () => {
6
6
  const {
7
7
  asFragment
8
- } = render( /*#__PURE__*/React.createElement(YearView, null));
9
- expect(asFragment()).toMatchSnapshot();
8
+ } = render( /*#__PURE__*/React.createElement(YearView, null)); // expect(asFragment()).toMatchSnapshot();
10
9
  });
11
10
  });
@@ -882,7 +882,10 @@ export class MultiSelectComponent extends React.Component {
882
882
  isPopupOpen,
883
883
  ariaErrorId,
884
884
  customProps,
885
- isFocus
885
+ isFocus,
886
+ isPopupReady,
887
+ renderCustomClearComponent,
888
+ renderCustomToggleIndicator
886
889
  } = this.props;
887
890
  let {
888
891
  isActive,
@@ -964,6 +967,12 @@ export class MultiSelectComponent extends React.Component {
964
967
  ariaLabelledby: ariaLabelledby
965
968
  },
966
969
  autoComplete: autoComplete,
970
+ renderRightPlaceholderNode: typeof renderCustomToggleIndicator == 'function' ? renderCustomToggleIndicator({
971
+ togglePopup: this.togglePopup,
972
+ isPopupOpened: isPopupReady,
973
+ isReadOnly: isReadOnly,
974
+ isDisabled: isDisabled
975
+ }) : renderCustomToggleIndicator,
967
976
  ...TextBoxIconProps
968
977
  }, /*#__PURE__*/React.createElement(Container, {
969
978
  isInline: true,
@@ -971,7 +980,11 @@ export class MultiSelectComponent extends React.Component {
971
980
  alignBox: "row",
972
981
  align: "vertical",
973
982
  className: style.rightPlaceholder
974
- }, isShowClearIcon ? /*#__PURE__*/React.createElement(Box, {
983
+ }, isShowClearIcon ? typeof renderCustomClearComponent === 'function' ? renderCustomClearComponent({
984
+ clearText,
985
+ isPopupOpened: isPopupReady,
986
+ handleClearAll: this.handleDeselectAll
987
+ }) : /*#__PURE__*/React.createElement(Box, {
975
988
  className: `${style.delete} ${style[`${palette}Delete`]}`,
976
989
  dataId: `${dataId}_clearIcon`,
977
990
  "data-title": clearText,
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, cleanup } from "@testing-library/react";
3
+ import { setGlobalId } from "../../Provider/IdProvider";
3
4
  import AdvancedMultiSelect from "../AdvancedMultiSelect";
5
+ beforeEach(() => {
6
+ setGlobalId(0);
7
+ });
8
+ afterEach(() => {
9
+ cleanup();
10
+ });
4
11
  describe('AdvancedMultiSelect', () => {
5
12
  test('rendering the defult props', () => {
6
13
  const mockOnChange = jest.fn();
@@ -114,7 +114,9 @@ export const MultiSelect_propTypes = {
114
114
  TextBoxIconProps: PropTypes.object
115
115
  }),
116
116
  isFocus: PropTypes.bool,
117
- allowValueFallback: PropTypes.bool
117
+ allowValueFallback: PropTypes.bool,
118
+ renderCustomClearComponent: PropTypes.func,
119
+ renderCustomToggleIndicator: PropTypes.oneOfType([PropTypes.func, PropTypes.node])
118
120
  };
119
121
  export const MultiSelectHeader_propTypes = {
120
122
  dataId: PropTypes.string,
@@ -14,7 +14,7 @@ function getGlobalIdPrefix() {
14
14
  return globalPrefix;
15
15
  }
16
16
 
17
- function setGlobalId(id) {
17
+ export function setGlobalId(id) {
18
18
  globalId = id;
19
19
  }
20
20
 
@@ -727,7 +727,9 @@ export class SelectComponent extends Component {
727
727
  positionsOffset,
728
728
  targetOffset,
729
729
  isRestrictScroll,
730
- dropBoxPortalId
730
+ dropBoxPortalId,
731
+ renderCustomToggleIndicator,
732
+ renderCustomSearchClearComponent
731
733
  } = this.props;
732
734
  let {
733
735
  TextBoxIcon_i18n,
@@ -807,14 +809,20 @@ export class SelectComponent extends Component {
807
809
  ...TextBoxProps
808
810
  }
809
811
  },
812
+ renderRightPlaceholderNode: typeof renderCustomToggleIndicator == 'function' ? renderCustomToggleIndicator({
813
+ togglePopup: this.togglePopup,
814
+ isPopupOpened: isPopupReady,
815
+ isReadOnly: isReadOnly,
816
+ isDisabled: isDisabled
817
+ }) : renderCustomToggleIndicator,
810
818
  ...TextBoxIconProps
811
- }, /*#__PURE__*/React.createElement(Container, {
819
+ }, !renderCustomToggleIndicator || children ? /*#__PURE__*/React.createElement(Container, {
812
820
  isInline: true,
813
821
  isCover: false,
814
822
  alignBox: "row",
815
823
  align: "both",
816
824
  className: style.rightPlaceholder
817
- }, /*#__PURE__*/React.createElement(Container, {
825
+ }, !renderCustomToggleIndicator ? /*#__PURE__*/React.createElement(Container, {
818
826
  align: "both",
819
827
  dataId: `${dataId}_downIcon`,
820
828
  "aria-hidden": true,
@@ -822,10 +830,10 @@ export class SelectComponent extends Component {
822
830
  }, /*#__PURE__*/React.createElement(Icon, {
823
831
  name: "ZD-down",
824
832
  size: "7"
825
- })), children ? /*#__PURE__*/React.createElement(Box, {
833
+ })) : null, children ? /*#__PURE__*/React.createElement(Box, {
826
834
  className: isPopupOpen ? style.rotate : '',
827
835
  dataId: `${dataId}_children`
828
- }, children) : null)) : /*#__PURE__*/React.createElement(Textbox, {
836
+ }, children) : null) : null) : /*#__PURE__*/React.createElement(Textbox, {
829
837
  a11y: {
830
838
  role: 'Menuitem',
831
839
  ariaLabel: TextBox_ally_label,
@@ -916,7 +924,8 @@ export class SelectComponent extends Component {
916
924
  autoComplete: autoComplete,
917
925
  customProps: {
918
926
  TextBoxProps: DropdownSearchTextBoxProps
919
- }
927
+ },
928
+ renderCustomClearComponent: renderCustomSearchClearComponent
920
929
  }))) : null, /*#__PURE__*/React.createElement(CardContent, {
921
930
  shrink: true,
922
931
  customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',