@zohodesk/components 1.3.1 → 1.3.3

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 (55) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +18 -31
  3. package/es/Button/__tests__/Button.spec.js +134 -1
  4. package/es/DateTime/__tests__/YearView.spec.js +1 -2
  5. package/es/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -1
  6. package/es/Popup/Popup.js +16 -10
  7. package/es/Provider/IdProvider.js +1 -1
  8. package/es/Select/__tests__/Select.spec.js +1130 -4
  9. package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  10. package/es/Stencils/Stencils.js +5 -12
  11. package/es/Stencils/Stencils.module.css +11 -7
  12. package/es/Stencils/__tests__/Stencils.spec.js +9 -1
  13. package/es/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  14. package/es/Stencils/props/defaultProps.js +2 -1
  15. package/es/Stencils/props/propTypes.js +3 -2
  16. package/es/Tab/Tab.js +2 -1
  17. package/es/Tab/TabWrapper.js +2 -1
  18. package/es/Tab/Tabs.js +10 -10
  19. package/es/Tab/__tests__/TabLayout.spec.js +34 -0
  20. package/es/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  21. package/es/Tab/props/propTypes.js +2 -2
  22. package/es/Tab/utils/tabConfigs.js +18 -0
  23. package/es/Tag/__tests__/Tag.spec.js +8 -1
  24. package/es/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +40 -3
  25. package/es/VelocityAnimation/VelocityAnimationGroup/props/propTypes.js +4 -1
  26. package/es/utils/Common.js +1 -1
  27. package/lib/Button/__tests__/Button.spec.js +140 -0
  28. package/lib/DateTime/__tests__/YearView.spec.js +1 -2
  29. package/lib/MultiSelect/__tests__/AdvancedMultiSelect.spec.js +8 -0
  30. package/lib/Popup/Popup.js +16 -11
  31. package/lib/Provider/IdProvider.js +1 -0
  32. package/lib/Select/__tests__/Select.spec.js +1364 -3
  33. package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +9621 -1
  34. package/lib/Stencils/Stencils.js +5 -12
  35. package/lib/Stencils/Stencils.module.css +11 -7
  36. package/lib/Stencils/__tests__/Stencils.spec.js +11 -3
  37. package/lib/Stencils/__tests__/__snapshots__/Stencils.spec.js.snap +27 -11
  38. package/lib/Stencils/props/defaultProps.js +2 -1
  39. package/lib/Stencils/props/propTypes.js +3 -2
  40. package/lib/Tab/Tab.js +3 -1
  41. package/lib/Tab/TabWrapper.js +3 -1
  42. package/lib/Tab/Tabs.js +11 -10
  43. package/lib/Tab/__tests__/TabLayout.spec.js +41 -0
  44. package/lib/Tab/__tests__/__snapshots__/TabLayout.spec.js.snap +341 -0
  45. package/lib/Tab/props/propTypes.js +2 -2
  46. package/lib/Tab/utils/tabConfigs.js +27 -0
  47. package/lib/Tag/__tests__/Tag.spec.js +10 -2
  48. package/lib/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +80 -26
  49. package/lib/VelocityAnimation/VelocityAnimationGroup/props/propTypes.js +4 -1
  50. package/lib/utils/Common.js +1 -1
  51. package/package.json +3 -3
  52. package/react-cli.config.js +2 -2
  53. package/result.json +1 -1
  54. package/es/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
  55. package/lib/DateTime/__tests__/__snapshots__/YearView.spec.js.snap +0 -61
package/README.md CHANGED
@@ -1,37 +1,24 @@
1
1
  # DOT Style Guide
2
2
 
3
- In this Package, we Provide Some Basic Components to Build Web App
4
-
5
- - Avatar
6
- - AvatarTeam
7
- - Accordion
8
- - Animation
9
- - Button
10
- - Buttongroup
11
- - Card
12
- - CheckBox
13
- - DateTime
14
- - DropBox
15
- - Icon
16
- - Label
17
- - Layout
18
- - ListItem
19
- - MultiSelect
20
- - Popup
21
- - Radio
22
- - Responsive
23
- - Ribbon
24
- - Select
25
- - GroupSelect
26
- - Stencils
27
- - Switch
28
- - Tab
29
- - Tag
30
- - Textarea
31
- - TextBox
32
- - TextBoxIcon
33
- - Tooltip
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
+
5
+ # 1.3.3
6
+
7
+ - **Stencils**
8
+ - Added `isAnimated` prop to support Stencils without Animation.
9
+ - Added `square` shape in existing shape collection
10
+ - **TabWrapper**
11
+ - Added `vertical-reverse, row-reverse` alignment suport in align propType
34
12
 
13
+ # 1.3.2
14
+
15
+ - **Popup**
16
+ - Added `scrollDebounceTime` prop to support debounce control for fixed popup scroll behavior.
17
+ - **VelocityAnimationGroup** - Added support for the following props:
18
+ - `onEnterComplete` - Callback triggered after enter animation completes.
19
+ - `onExitComplete` - Callback triggered after exit animation completes.
20
+ - `postEnterStyles` - Inline styles applied to the element once the enter animation has finished.
21
+
35
22
  # 1.3.1
36
23
 
37
24
  - **dropDownUtils** - The isObjectContainsSearchString function logic has been updated to use some instead of filter, and additional conditions have been added to prevent potential runtime issues.
@@ -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
  });
@@ -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();
package/es/Popup/Popup.js CHANGED
@@ -89,8 +89,8 @@ const Popup = function (Component) {
89
89
  this.getIsOutsideScrollBlocked = this.getIsOutsideScrollBlocked.bind(this);
90
90
  this.getNeedArrow = this.getNeedArrow.bind(this);
91
91
  this.getCustomPositionOrder = this.getCustomPositionOrder.bind(this);
92
- this.handleOpenPopupPositionChange = this.handleOpenPopupPositionChange.bind(this); // this.getScrollDebounceTime = this.getScrollDebounceTime.bind(this);
93
-
92
+ this.handleOpenPopupPositionChange = this.handleOpenPopupPositionChange.bind(this);
93
+ this.getScrollDebounceTime = this.getScrollDebounceTime.bind(this);
94
94
  this.getCloseOnScrollPopup = this.getCloseOnScrollPopup.bind(this);
95
95
  this.handleCloseLastOpenedGroup = this.handleCloseLastOpenedGroup.bind(this);
96
96
  this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
@@ -107,7 +107,6 @@ const Popup = function (Component) {
107
107
  this.updateVisibilityOnIntersection = this.updateVisibilityOnIntersection.bind(this);
108
108
  this.handleAddingScrollToUpdatePosition = this.handleAddingScrollToUpdatePosition.bind(this);
109
109
  this.handleRemovingScrollToUpdatePosition = this.handleRemovingScrollToUpdatePosition.bind(this);
110
- this.updatePositionOnScroll = this.updatePositionOnScroll.bind(this);
111
110
  this.setContainerDynamicPositioning = this.setContainerDynamicPositioning.bind(this);
112
111
  this.updatePopupState = this.updatePopupState.bind(this);
113
112
  this.handleScrollAndBlockEvents = this.handleScrollAndBlockEvents.bind(this);
@@ -122,8 +121,9 @@ const Popup = function (Component) {
122
121
  this.customPositionOrder = customPositionOrder;
123
122
  this.scrollDebounceTime = popupScrollDebounceTime;
124
123
  this.closeOnScroll = closeOnScrollPopup;
125
- this.isOutsideScrollBlock = isOutsideScrollBlock; // const { scrollDebounceTime } = this.getScrollDebounceTime(this);
126
- // this.handleScroll = debounce(this.handleScroll.bind(this), scrollDebounceTime);
124
+ this.isOutsideScrollBlock = isOutsideScrollBlock;
125
+ const scrollDebounceTime = this.getScrollDebounceTime(this);
126
+ this.updatePositionOnScroll = scrollDebounceTime > 0 ? debounce(this.updatePositionOnScroll.bind(this), scrollDebounceTime) : this.updatePositionOnScroll.bind(this); // this.handleScroll = debounce(this.handleScroll.bind(this), scrollDebounceTime);
127
127
  }
128
128
 
129
129
  componentDidMount() {
@@ -426,6 +426,7 @@ const Popup = function (Component) {
426
426
  const {
427
427
  dropElement
428
428
  } = this;
429
+ if (!dropElement) return;
429
430
 
430
431
  if (entry.isIntersecting === true) {
431
432
  this.isTargetElementVisible = true;
@@ -451,12 +452,17 @@ const Popup = function (Component) {
451
452
  needPopupArrow
452
453
  } = popup;
453
454
  return isArrow !== undefined ? isArrow : needPopupArrow;
454
- } // getScrollDebounceTime(popup) {
455
- // const { scrollDebounceTime } = popup.props;
456
- // const { scrollDebounceTime: popupScrollDebounceTime } = popup;
457
- // return scrollDebounceTime !== undefined ? scrollDebounceTime : popupScrollDebounceTime;
458
- // }
455
+ }
459
456
 
457
+ getScrollDebounceTime(popup) {
458
+ const {
459
+ scrollDebounceTime
460
+ } = popup.props;
461
+ const {
462
+ scrollDebounceTime: popupScrollDebounceTime
463
+ } = popup;
464
+ return scrollDebounceTime !== undefined ? scrollDebounceTime : popupScrollDebounceTime;
465
+ }
460
466
 
461
467
  getCloseOnScrollPopup(popup) {
462
468
  const {
@@ -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