@zohodesk/dot 1.0.0-temp-226.1 → 1.0.0-temp-227

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 (110) hide show
  1. package/README.md +10 -0
  2. package/es/DotProvider/hooks/useDotProvider.js +3 -3
  3. package/es/DotProvider/libraryChunks/themes/component/blue/Blue_Dark_Component.js +2 -0
  4. package/es/DotProvider/libraryChunks/themes/component/blue/Blue_Light_Component.js +2 -0
  5. package/es/DotProvider/libraryChunks/themes/component/blue/Blue_PureDark_Component.js +2 -0
  6. package/es/DotProvider/libraryChunks/themes/component/green/Green_Dark_Component.js +2 -0
  7. package/es/DotProvider/libraryChunks/themes/component/green/Green_Light_Component.js +2 -0
  8. package/es/DotProvider/libraryChunks/themes/component/green/Green_PureDark_Component.js +2 -0
  9. package/es/DotProvider/libraryChunks/themes/component/orange/Orange_Dark_Component.js +2 -0
  10. package/es/DotProvider/libraryChunks/themes/component/orange/Orange_Light_Component.js +2 -0
  11. package/es/DotProvider/libraryChunks/themes/component/orange/Orange_PureDark_Component.js +2 -0
  12. package/es/DotProvider/libraryChunks/themes/component/red/Red_Dark_Component.js +2 -0
  13. package/es/DotProvider/libraryChunks/themes/component/red/Red_Light_Component.js +2 -0
  14. package/es/DotProvider/libraryChunks/themes/component/red/Red_PureDark_Component.js +2 -0
  15. package/es/DotProvider/libraryChunks/themes/component/yellow/Yellow_Dark_Component.js +2 -0
  16. package/es/DotProvider/libraryChunks/themes/component/yellow/Yellow_Light_Component.js +2 -0
  17. package/es/DotProvider/libraryChunks/themes/component/yellow/Yellow_PureDark_Component.js +2 -0
  18. package/es/DotProvider/utils/constants.js +1 -2
  19. package/es/DotProvider/utils/themeAppearanceAssetsConfig.js +1 -15
  20. package/es/DotProvider/utils/themeColorAssetsConfig.js +1 -73
  21. package/es/list/Comment/Comment.module.css +29 -29
  22. package/es/list/Dot/Dot.module.css +15 -15
  23. package/es/list/ListLayout/ListLayout.module.css +79 -79
  24. package/es/lookup/Lookup/Lookup.js +6 -4
  25. package/es/lookup/Lookup/__tests__/Lookup.spec.js +101 -4
  26. package/es/lookup/Lookup/__tests__/__snapshots__/Lookup.spec.js.snap +223 -2
  27. package/es/lookup/Lookup/props/propTypes.js +6 -1
  28. package/es/lookup/header/ModuleHeader/ModuleHeader.js +12 -5
  29. package/es/lookup/header/ModuleHeader/__tests__/ModuleHeader.spec.js +87 -3
  30. package/es/lookup/header/ModuleHeader/props/defaultProps.js +2 -0
  31. package/es/lookup/header/ModuleHeader/props/propTypes.js +6 -0
  32. package/es/version2/lookup/AlertHeader/AlertHeader.js +19 -9
  33. package/es/version2/lookup/AlertHeader/__tests__/AlertHeader.spec.js +122 -3
  34. package/es/version2/lookup/AlertHeader/__tests__/__snapshots__/AlertHeader.spec.js.snap +1728 -3
  35. package/es/version2/lookup/AlertHeader/css/cssJSLogic.js +6 -1
  36. package/es/version2/lookup/AlertHeader/props/defaultProps.js +2 -0
  37. package/es/version2/lookup/AlertHeader/props/propTypes.js +10 -0
  38. package/lib/DotProvider/hooks/useDotProvider.js +3 -3
  39. package/lib/DotProvider/libraryChunks/themes/component/blue/Blue_Dark_Component.js +4 -0
  40. package/lib/DotProvider/libraryChunks/themes/component/blue/Blue_Light_Component.js +4 -0
  41. package/lib/DotProvider/libraryChunks/themes/component/blue/Blue_PureDark_Component.js +4 -0
  42. package/lib/DotProvider/libraryChunks/themes/component/green/Green_Dark_Component.js +4 -0
  43. package/lib/DotProvider/libraryChunks/themes/component/green/Green_Light_Component.js +4 -0
  44. package/lib/DotProvider/libraryChunks/themes/component/green/Green_PureDark_Component.js +4 -0
  45. package/lib/DotProvider/libraryChunks/themes/component/orange/Orange_Dark_Component.js +4 -0
  46. package/lib/DotProvider/libraryChunks/themes/component/orange/Orange_Light_Component.js +4 -0
  47. package/lib/DotProvider/libraryChunks/themes/component/orange/Orange_PureDark_Component.js +4 -0
  48. package/lib/DotProvider/libraryChunks/themes/component/red/Red_Dark_Component.js +4 -0
  49. package/lib/DotProvider/libraryChunks/themes/component/red/Red_Light_Component.js +4 -0
  50. package/lib/DotProvider/libraryChunks/themes/component/red/Red_PureDark_Component.js +4 -0
  51. package/lib/DotProvider/libraryChunks/themes/component/yellow/Yellow_Dark_Component.js +4 -0
  52. package/lib/DotProvider/libraryChunks/themes/component/yellow/Yellow_Light_Component.js +4 -0
  53. package/lib/DotProvider/libraryChunks/themes/component/yellow/Yellow_PureDark_Component.js +4 -0
  54. package/lib/DotProvider/utils/constants.js +2 -4
  55. package/lib/DotProvider/utils/themeAppearanceAssetsConfig.js +2 -17
  56. package/lib/DotProvider/utils/themeColorAssetsConfig.js +2 -77
  57. package/lib/list/Comment/Comment.module.css +29 -29
  58. package/lib/list/Dot/Dot.module.css +15 -15
  59. package/lib/list/ListLayout/ListLayout.module.css +79 -79
  60. package/lib/lookup/Lookup/Lookup.js +6 -4
  61. package/lib/lookup/Lookup/__tests__/Lookup.spec.js +101 -4
  62. package/lib/lookup/Lookup/__tests__/__snapshots__/Lookup.spec.js.snap +223 -2
  63. package/lib/lookup/Lookup/props/propTypes.js +8 -1
  64. package/lib/lookup/header/ModuleHeader/ModuleHeader.js +13 -5
  65. package/lib/lookup/header/ModuleHeader/__tests__/ModuleHeader.spec.js +86 -2
  66. package/lib/lookup/header/ModuleHeader/props/defaultProps.js +2 -0
  67. package/lib/lookup/header/ModuleHeader/props/propTypes.js +6 -0
  68. package/lib/version2/lookup/AlertHeader/AlertHeader.js +19 -8
  69. package/lib/version2/lookup/AlertHeader/__tests__/AlertHeader.spec.js +121 -2
  70. package/lib/version2/lookup/AlertHeader/__tests__/__snapshots__/AlertHeader.spec.js.snap +1728 -3
  71. package/lib/version2/lookup/AlertHeader/css/cssJSLogic.js +4 -2
  72. package/lib/version2/lookup/AlertHeader/props/defaultProps.js +2 -0
  73. package/lib/version2/lookup/AlertHeader/props/propTypes.js +10 -0
  74. package/package.json +6 -6
  75. package/es/DotProvider/libraryChunks/appearance/variables/Dark_Variables.js +0 -1
  76. package/es/DotProvider/libraryChunks/appearance/variables/Light_Variables.js +0 -1
  77. package/es/DotProvider/libraryChunks/appearance/variables/PureDark_Variables.js +0 -1
  78. package/es/DotProvider/libraryChunks/themes/variables/blue/Blue_Dark_Variables.js +0 -2
  79. package/es/DotProvider/libraryChunks/themes/variables/blue/Blue_Light_Variables.js +0 -2
  80. package/es/DotProvider/libraryChunks/themes/variables/blue/Blue_PureDark_Variables.js +0 -2
  81. package/es/DotProvider/libraryChunks/themes/variables/green/Green_Dark_Variables.js +0 -2
  82. package/es/DotProvider/libraryChunks/themes/variables/green/Green_Light_Variables.js +0 -2
  83. package/es/DotProvider/libraryChunks/themes/variables/green/Green_PureDark_Variables.js +0 -2
  84. package/es/DotProvider/libraryChunks/themes/variables/orange/Orange_Dark_Variables.js +0 -2
  85. package/es/DotProvider/libraryChunks/themes/variables/orange/Orange_Light_Variables.js +0 -2
  86. package/es/DotProvider/libraryChunks/themes/variables/orange/Orange_PureDark_Variables.js +0 -2
  87. package/es/DotProvider/libraryChunks/themes/variables/red/Red_Dark_Variables.js +0 -2
  88. package/es/DotProvider/libraryChunks/themes/variables/red/Red_Light_Variables.js +0 -2
  89. package/es/DotProvider/libraryChunks/themes/variables/red/Red_PureDark_Variables.js +0 -2
  90. package/es/DotProvider/libraryChunks/themes/variables/yellow/Yellow_Dark_Variables.js +0 -2
  91. package/es/DotProvider/libraryChunks/themes/variables/yellow/Yellow_Light_Variables.js +0 -2
  92. package/es/DotProvider/libraryChunks/themes/variables/yellow/Yellow_PureDark_Variables.js +0 -2
  93. package/lib/DotProvider/libraryChunks/appearance/variables/Dark_Variables.js +0 -3
  94. package/lib/DotProvider/libraryChunks/appearance/variables/Light_Variables.js +0 -3
  95. package/lib/DotProvider/libraryChunks/appearance/variables/PureDark_Variables.js +0 -3
  96. package/lib/DotProvider/libraryChunks/themes/variables/blue/Blue_Dark_Variables.js +0 -5
  97. package/lib/DotProvider/libraryChunks/themes/variables/blue/Blue_Light_Variables.js +0 -5
  98. package/lib/DotProvider/libraryChunks/themes/variables/blue/Blue_PureDark_Variables.js +0 -5
  99. package/lib/DotProvider/libraryChunks/themes/variables/green/Green_Dark_Variables.js +0 -5
  100. package/lib/DotProvider/libraryChunks/themes/variables/green/Green_Light_Variables.js +0 -5
  101. package/lib/DotProvider/libraryChunks/themes/variables/green/Green_PureDark_Variables.js +0 -5
  102. package/lib/DotProvider/libraryChunks/themes/variables/orange/Orange_Dark_Variables.js +0 -5
  103. package/lib/DotProvider/libraryChunks/themes/variables/orange/Orange_Light_Variables.js +0 -5
  104. package/lib/DotProvider/libraryChunks/themes/variables/orange/Orange_PureDark_Variables.js +0 -5
  105. package/lib/DotProvider/libraryChunks/themes/variables/red/Red_Dark_Variables.js +0 -5
  106. package/lib/DotProvider/libraryChunks/themes/variables/red/Red_Light_Variables.js +0 -5
  107. package/lib/DotProvider/libraryChunks/themes/variables/red/Red_PureDark_Variables.js +0 -5
  108. package/lib/DotProvider/libraryChunks/themes/variables/yellow/Yellow_Dark_Variables.js +0 -5
  109. package/lib/DotProvider/libraryChunks/themes/variables/yellow/Yellow_Light_Variables.js +0 -5
  110. package/lib/DotProvider/libraryChunks/themes/variables/yellow/Yellow_PureDark_Variables.js +0 -5
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Lookup rendering isActive is true 1`] = `
3
+ exports[`Lookup snapshot - Render with a11y attributes 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
6
  class="container index5 snow"
@@ -17,4 +17,225 @@ exports[`Lookup rendering isActive is true 1`] = `
17
17
  </DocumentFragment>
18
18
  `;
19
19
 
20
- exports[`Lookup rendering the defult props 1`] = `<DocumentFragment />`;
20
+ exports[`Lookup snapshot - Render with childAnimationName=expand 1`] = `
21
+ <DocumentFragment>
22
+ <div
23
+ class="container index5 snow"
24
+ data-drag-parent="true"
25
+ style="z-index: 4;"
26
+ >
27
+ <div
28
+ class="flex cover rowdir hCenter"
29
+ data-id="reactFreezeLayer"
30
+ data-selector-id="container"
31
+ data-test-id="reactFreezeLayer"
32
+ />
33
+ </div>
34
+ </DocumentFragment>
35
+ `;
36
+
37
+ exports[`Lookup snapshot - Render with children 1`] = `
38
+ <DocumentFragment>
39
+ <div
40
+ class="container index5 snow"
41
+ data-drag-parent="true"
42
+ style="z-index: 4;"
43
+ >
44
+ <div
45
+ class="flex cover rowdir hCenter"
46
+ data-id="reactFreezeLayer"
47
+ data-selector-id="container"
48
+ data-test-id="reactFreezeLayer"
49
+ />
50
+ </div>
51
+ </DocumentFragment>
52
+ `;
53
+
54
+ exports[`Lookup snapshot - Render with custom classes 1`] = `
55
+ <DocumentFragment>
56
+ <div
57
+ class="container lookup-freeze-layer index5 snow"
58
+ data-drag-parent="true"
59
+ style="z-index: 4;"
60
+ >
61
+ <div
62
+ class="flex cover rowdir hCenter"
63
+ data-id="reactFreezeLayer"
64
+ data-selector-id="container"
65
+ data-test-id="reactFreezeLayer"
66
+ />
67
+ </div>
68
+ </DocumentFragment>
69
+ `;
70
+
71
+ exports[`Lookup snapshot - Render with customProps 1`] = `
72
+ <DocumentFragment>
73
+ <div
74
+ class="container index5 plain"
75
+ data-drag-parent="true"
76
+ style="z-index: 4;"
77
+ >
78
+ <div
79
+ class="flex cover rowdir hCenter"
80
+ data-id="reactFreezeLayer"
81
+ data-selector-id="container"
82
+ data-test-id="reactFreezeLayer"
83
+ />
84
+ </div>
85
+ </DocumentFragment>
86
+ `;
87
+
88
+ exports[`Lookup snapshot - Render with dataId 1`] = `
89
+ <DocumentFragment>
90
+ <div
91
+ class="container index5 snow"
92
+ data-drag-parent="true"
93
+ style="z-index: 4;"
94
+ >
95
+ <div
96
+ class="flex cover rowdir hCenter"
97
+ data-id="reactFreezeLayer"
98
+ data-selector-id="container"
99
+ data-test-id="reactFreezeLayer"
100
+ />
101
+ </div>
102
+ </DocumentFragment>
103
+ `;
104
+
105
+ exports[`Lookup snapshot - Render with default props 1`] = `<DocumentFragment />`;
106
+
107
+ exports[`Lookup snapshot - Render with htmlId 1`] = `
108
+ <DocumentFragment>
109
+ <div
110
+ class="container index5 snow"
111
+ data-drag-parent="true"
112
+ style="z-index: 4;"
113
+ >
114
+ <div
115
+ class="flex cover rowdir hCenter"
116
+ data-id="reactFreezeLayer"
117
+ data-selector-id="container"
118
+ data-test-id="reactFreezeLayer"
119
+ />
120
+ </div>
121
+ </DocumentFragment>
122
+ `;
123
+
124
+ exports[`Lookup snapshot - Render with isActive=true 1`] = `
125
+ <DocumentFragment>
126
+ <div
127
+ class="container index5 snow"
128
+ data-drag-parent="true"
129
+ style="z-index: 4;"
130
+ >
131
+ <div
132
+ class="flex cover rowdir hCenter"
133
+ data-id="reactFreezeLayer"
134
+ data-selector-id="container"
135
+ data-test-id="reactFreezeLayer"
136
+ />
137
+ </div>
138
+ </DocumentFragment>
139
+ `;
140
+
141
+ exports[`Lookup snapshot - Render with isMinHeight=true 1`] = `
142
+ <DocumentFragment>
143
+ <div
144
+ class="container index5 snow"
145
+ data-drag-parent="true"
146
+ style="z-index: 4;"
147
+ >
148
+ <div
149
+ class="flex cover rowdir hCenter"
150
+ data-id="reactFreezeLayer"
151
+ data-selector-id="container"
152
+ data-test-id="reactFreezeLayer"
153
+ />
154
+ </div>
155
+ </DocumentFragment>
156
+ `;
157
+
158
+ exports[`Lookup snapshot - Render with size=full 1`] = `
159
+ <DocumentFragment>
160
+ <div
161
+ class="container index5 snow"
162
+ data-drag-parent="true"
163
+ style="z-index: 4;"
164
+ >
165
+ <div
166
+ class="flex cover rowdir hCenter"
167
+ data-id="reactFreezeLayer"
168
+ data-selector-id="container"
169
+ data-test-id="reactFreezeLayer"
170
+ />
171
+ </div>
172
+ </DocumentFragment>
173
+ `;
174
+
175
+ exports[`Lookup snapshot - Render with size=large 1`] = `
176
+ <DocumentFragment>
177
+ <div
178
+ class="container index5 snow"
179
+ data-drag-parent="true"
180
+ style="z-index: 4;"
181
+ >
182
+ <div
183
+ class="flex cover rowdir hCenter"
184
+ data-id="reactFreezeLayer"
185
+ data-selector-id="container"
186
+ data-test-id="reactFreezeLayer"
187
+ />
188
+ </div>
189
+ </DocumentFragment>
190
+ `;
191
+
192
+ exports[`Lookup snapshot - Render with size=small 1`] = `
193
+ <DocumentFragment>
194
+ <div
195
+ class="container index5 snow"
196
+ data-drag-parent="true"
197
+ style="z-index: 4;"
198
+ >
199
+ <div
200
+ class="flex cover rowdir hCenter"
201
+ data-id="reactFreezeLayer"
202
+ data-selector-id="container"
203
+ data-test-id="reactFreezeLayer"
204
+ />
205
+ </div>
206
+ </DocumentFragment>
207
+ `;
208
+
209
+ exports[`Lookup snapshot - Render with size=xlarge 1`] = `
210
+ <DocumentFragment>
211
+ <div
212
+ class="container index5 snow"
213
+ data-drag-parent="true"
214
+ style="z-index: 4;"
215
+ >
216
+ <div
217
+ class="flex cover rowdir hCenter"
218
+ data-id="reactFreezeLayer"
219
+ data-selector-id="container"
220
+ data-test-id="reactFreezeLayer"
221
+ />
222
+ </div>
223
+ </DocumentFragment>
224
+ `;
225
+
226
+ exports[`Lookup snapshot - Render with size=xmedium 1`] = `
227
+ <DocumentFragment>
228
+ <div
229
+ class="container index5 snow"
230
+ data-drag-parent="true"
231
+ style="z-index: 4;"
232
+ >
233
+ <div
234
+ class="flex cover rowdir hCenter"
235
+ data-id="reactFreezeLayer"
236
+ data-selector-id="container"
237
+ data-test-id="reactFreezeLayer"
238
+ />
239
+ </div>
240
+ </DocumentFragment>
241
+ `;
@@ -1,4 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
+ import FocusScopePropTypes from '@zohodesk/a11y/es/FocusScope/props/propTypes';
3
+ import FreezeLayerPropTypes from "../../../FreezeLayer/props/propTypes";
2
4
  export const propTypes = {
3
5
  children: PropTypes.node,
4
6
  customClass: PropTypes.string,
@@ -15,7 +17,10 @@ export const propTypes = {
15
17
  onKeyDown: PropTypes.func,
16
18
  childAnimationName: PropTypes.oneOf(['expand', 'flyDown']),
17
19
  needFocusScope: PropTypes.bool,
18
- customProps: PropTypes.object,
20
+ customProps: PropTypes.shape({
21
+ focusScopeProps: PropTypes.shape(FocusScopePropTypes),
22
+ freezeLayerProps: PropTypes.shape(FreezeLayerPropTypes)
23
+ }),
19
24
  forwardRef: PropTypes.object,
20
25
  onClick: PropTypes.func,
21
26
  onClose: PropTypes.func,
@@ -32,31 +32,38 @@ function ModuleHeader(props) {
32
32
  closeTitle,
33
33
  onSearchKeyDown,
34
34
  palette,
35
+ isDraggable,
35
36
  dragBoundaryLimit,
36
37
  children,
38
+ customClass,
37
39
  childNearTitle
38
40
  } = props;
39
41
  const dragRef = useRef(null); //dragRef
40
42
 
41
43
  useDragger({
42
- isActive: true,
44
+ isActive: isDraggable,
43
45
  ChildRef: dragRef,
44
46
  boundaryLimit: dragBoundaryLimit
45
47
  }); //custom Hook
46
48
 
49
+ const {
50
+ container: customContainerClass = '',
51
+ title: customTitleClass = '',
52
+ close: customCloseClass = ''
53
+ } = customClass;
47
54
  return /*#__PURE__*/React.createElement(Container, {
48
55
  align: "vertical",
49
56
  alignBox: "row",
50
- className: `${commonStyle.container} ${commonStyle[`${palette}`]}`,
57
+ className: `${commonStyle.container} ${commonStyle[`${palette}`]} ${customContainerClass}`,
51
58
  isCover: false,
52
59
  wrap: "wrap",
53
60
  dataId: dataId,
54
- "data-drag-hook": "true",
61
+ "data-drag-hook": isDraggable ? 'true' : 'false',
55
62
  eleRef: dragRef
56
63
  }, childNearTitle ? childNearTitle : '', /*#__PURE__*/React.createElement(Box, {
57
64
  flexible: true
58
65
  }, /*#__PURE__*/React.createElement("div", {
59
- className: commonStyle.title
66
+ className: `${commonStyle.title} ${customTitleClass}`
60
67
  }, /*#__PURE__*/React.createElement(Title, {
61
68
  text: title
62
69
  })), miniDescription && /*#__PURE__*/React.createElement("div", {
@@ -73,7 +80,7 @@ function ModuleHeader(props) {
73
80
  getRef: getSearchBoxRef,
74
81
  onKeyDown: onSearchKeyDown
75
82
  })), children ? children : '', onLookupClose ? /*#__PURE__*/React.createElement("div", {
76
- className: commonStyle.closeContainer
83
+ className: `${commonStyle.closeContainer} ${customCloseClass}`
77
84
  }, /*#__PURE__*/React.createElement(Close, {
78
85
  dataId: "close",
79
86
  onClose: onLookupClose,
@@ -1,11 +1,95 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, cleanup } from '@testing-library/react';
3
3
  import ModuleHeader from "../ModuleHeader";
4
- describe('ModuleHeader', () => {
5
- test('rendering the defult props', () => {
4
+ const PALETTE_VALUES = ['default', 'white'];
5
+ afterEach(() => {
6
+ cleanup();
7
+ });
8
+ describe('ModuleHeader snapshot - ', () => {
9
+ test('Render with default props', () => {
6
10
  const {
7
11
  asFragment
8
12
  } = render( /*#__PURE__*/React.createElement(ModuleHeader, null));
9
13
  expect(asFragment()).toMatchSnapshot();
10
14
  });
15
+ test.each(PALETTE_VALUES)('Render with palette=%s', palette => {
16
+ const {
17
+ asFragment
18
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
19
+ palette: palette
20
+ }));
21
+ expect(asFragment()).toMatchSnapshot();
22
+ });
23
+ test('Render with needSearch=true', () => {
24
+ const {
25
+ asFragment
26
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
27
+ needSearch: true
28
+ }));
29
+ expect(asFragment()).toMatchSnapshot();
30
+ });
31
+ test('Render with isDraggable=false', () => {
32
+ const {
33
+ asFragment
34
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
35
+ isDraggable: false
36
+ }));
37
+ expect(asFragment()).toMatchSnapshot();
38
+ });
39
+ test('Render with onLookupClose', () => {
40
+ const {
41
+ asFragment
42
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
43
+ onLookupClose: jest.fn()
44
+ }));
45
+ expect(asFragment()).toMatchSnapshot();
46
+ });
47
+ test('Render with miniDescription', () => {
48
+ const {
49
+ asFragment
50
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
51
+ miniDescription: "A brief description"
52
+ }));
53
+ expect(asFragment()).toMatchSnapshot();
54
+ });
55
+ test('Render with customClass', () => {
56
+ const {
57
+ asFragment
58
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
59
+ onLookupClose: jest.fn(),
60
+ title: "Header Title",
61
+ customClass: {
62
+ container: 'custom-container',
63
+ title: 'custom-title',
64
+ close: 'custom-close'
65
+ }
66
+ }));
67
+ expect(asFragment()).toMatchSnapshot();
68
+ });
69
+ test('Render with children', () => {
70
+ const {
71
+ asFragment
72
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
73
+ title: "Header Title"
74
+ }, /*#__PURE__*/React.createElement("div", null, "Child content")));
75
+ expect(asFragment()).toMatchSnapshot();
76
+ });
77
+ test('Render with childNearTitle', () => {
78
+ const {
79
+ asFragment
80
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
81
+ title: "Header Title",
82
+ childNearTitle: /*#__PURE__*/React.createElement("span", null, "Near title")
83
+ }));
84
+ expect(asFragment()).toMatchSnapshot();
85
+ });
86
+ test('Render with dataId', () => {
87
+ const {
88
+ asFragment
89
+ } = render( /*#__PURE__*/React.createElement(ModuleHeader, {
90
+ title: "Header Title",
91
+ dataId: "module-header-dataId"
92
+ }));
93
+ expect(asFragment()).toMatchSnapshot();
94
+ });
11
95
  });
@@ -1,5 +1,7 @@
1
1
  export const defaultProps = {
2
2
  palette: 'default',
3
+ customClass: {},
4
+ isDraggable: true,
3
5
  dragBoundaryLimit: {
4
6
  top: 0,
5
7
  left: 50,
@@ -16,5 +16,11 @@ export const propTypes = {
16
16
  palette: PropTypes.oneOf(['default', 'white']),
17
17
  children: PropTypes.any,
18
18
  childNearTitle: PropTypes.any,
19
+ customClass: PropTypes.shape({
20
+ container: PropTypes.string,
21
+ title: PropTypes.string,
22
+ close: PropTypes.string
23
+ }),
24
+ isDraggable: PropTypes.bool,
19
25
  dragBoundaryLimit: PropTypes.object
20
26
  };
@@ -6,7 +6,7 @@ import AlertIcons from "../../alertIcons/AlertIcons"; //CSS
6
6
 
7
7
  import style from "./css/AlertHeaderNew.module.css";
8
8
  import cssJSLogic from "./css/cssJSLogic";
9
- import { mergeStyle } from '@zohodesk/utils'; //customHooks
9
+ import { mergeStyle, isRenderable, renderNode } from '@zohodesk/utils'; //customHooks
10
10
 
11
11
  import useDragger from "../../../Hooks/Dragger/useDragger"; //Props
12
12
 
@@ -23,10 +23,20 @@ export default function AlertHeader(props) {
23
23
  dataId,
24
24
  type,
25
25
  htmlId,
26
+ isDraggable,
27
+ customClass,
28
+ renderCustomIcon,
29
+ renderSecondaryContent,
30
+ renderRightActions,
26
31
  customStyle,
27
32
  dragBoundaryLimit
28
33
  } = props;
29
34
  const finalStyle = mergeStyle(style, customStyle);
35
+ const {
36
+ title: titleClass = '',
37
+ iconContainer: iconContainerClass = '',
38
+ close: closeClass = ''
39
+ } = customClass;
30
40
  const {
31
41
  alertHeaderContainerClass
32
42
  } = cssJSLogic({
@@ -36,7 +46,7 @@ export default function AlertHeader(props) {
36
46
  const dragRef = useRef(null); //dragRef
37
47
 
38
48
  useDragger({
39
- isActive: true,
49
+ isActive: isDraggable,
40
50
  ChildRef: dragRef,
41
51
  boundaryLimit: dragBoundaryLimit
42
52
  }); //custom Hook
@@ -47,26 +57,26 @@ export default function AlertHeader(props) {
47
57
  className: `${alertHeaderContainerClass}`,
48
58
  isCover: false,
49
59
  wrap: "wrap",
50
- "data-drag-hook": "true",
60
+ "data-drag-hook": isDraggable ? 'true' : 'false',
51
61
  eleRef: dragRef
52
- }, needIcon && /*#__PURE__*/React.createElement("div", {
53
- className: finalStyle.iconContainer
62
+ }, needIcon && !isRenderable(renderCustomIcon) ? /*#__PURE__*/React.createElement("div", {
63
+ className: `${finalStyle.iconContainer} ${iconContainerClass}`
54
64
  }, /*#__PURE__*/React.createElement(AlertIcons, {
55
65
  type: type
56
- })), (title || children) && /*#__PURE__*/React.createElement(Box, {
66
+ })) : renderNode(renderCustomIcon), (title || children) && /*#__PURE__*/React.createElement(Box, {
57
67
  flexible: true
58
68
  }, /*#__PURE__*/React.createElement(Container, {
59
69
  alignBox: "row",
60
70
  wrap: breakChildren ? 'wrap' : null
61
71
  }, title && /*#__PURE__*/React.createElement(Box, {
62
- className: finalStyle.title,
72
+ className: `${finalStyle.title} ${titleClass}`,
63
73
  shrink: true,
64
74
  id: htmlId
65
75
  }, title), children && /*#__PURE__*/React.createElement(Box, {
66
76
  adjust: true,
67
77
  flexible: true
68
- }, children))), onClose && /*#__PURE__*/React.createElement(Box, {
69
- className: style.close
78
+ }, children)), renderNode(renderSecondaryContent)), renderNode(renderRightActions), onClose && /*#__PURE__*/React.createElement(Box, {
79
+ className: `${style.close} ${closeClass}`
70
80
  }, /*#__PURE__*/React.createElement(AlertClose, {
71
81
  onClose: onClose,
72
82
  dataTitle: closeTitle,
@@ -1,11 +1,130 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
2
+ import { render, cleanup } from '@testing-library/react';
3
3
  import AlertHeader from "../AlertHeader";
4
- describe('AlertHeader', () => {
5
- test('rendering the defult props', () => {
4
+ const TYPE_VALUES = ['success', 'error', 'warning', 'info', 'notification'];
5
+ afterEach(() => {
6
+ cleanup();
7
+ });
8
+ describe('AlertHeader snapshot - ', () => {
9
+ test('Render with default props', () => {
6
10
  const {
7
11
  asFragment
8
12
  } = render( /*#__PURE__*/React.createElement(AlertHeader, null));
9
13
  expect(asFragment()).toMatchSnapshot();
10
14
  });
15
+ test.each(TYPE_VALUES)('Render with type=%s', type => {
16
+ const {
17
+ asFragment
18
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
19
+ title: "Alert Title",
20
+ type: type
21
+ }));
22
+ expect(asFragment()).toMatchSnapshot();
23
+ });
24
+ test('Render with needIcon=false', () => {
25
+ const {
26
+ asFragment
27
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
28
+ title: "Alert Title",
29
+ needIcon: false
30
+ }));
31
+ expect(asFragment()).toMatchSnapshot();
32
+ });
33
+ test('Render with breakChildren=true', () => {
34
+ const {
35
+ asFragment
36
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
37
+ title: "Alert Title",
38
+ breakChildren: true
39
+ }));
40
+ expect(asFragment()).toMatchSnapshot();
41
+ });
42
+ test('Render with onClose', () => {
43
+ const {
44
+ asFragment
45
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
46
+ title: "Alert Title",
47
+ onClose: () => {}
48
+ }));
49
+ expect(asFragment()).toMatchSnapshot();
50
+ });
51
+ test('Render with title', () => {
52
+ const {
53
+ asFragment
54
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
55
+ title: "Alert Title"
56
+ }));
57
+ expect(asFragment()).toMatchSnapshot();
58
+ });
59
+ test('Render with isDraggable=false', () => {
60
+ const {
61
+ asFragment
62
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
63
+ title: "Alert Title",
64
+ isDraggable: false
65
+ }));
66
+ expect(asFragment()).toMatchSnapshot();
67
+ });
68
+ test('Render with children', () => {
69
+ const {
70
+ asFragment
71
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
72
+ title: "Alert Title"
73
+ }, /*#__PURE__*/React.createElement("span", null, "Child content")));
74
+ expect(asFragment()).toMatchSnapshot();
75
+ });
76
+ test('Render with customClass', () => {
77
+ const {
78
+ asFragment
79
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
80
+ title: "Alert Title",
81
+ onClose: () => {},
82
+ customClass: {
83
+ title: 'custom-title-class',
84
+ iconContainer: 'custom-icon-class',
85
+ close: 'custom-close-class'
86
+ }
87
+ }));
88
+ expect(asFragment()).toMatchSnapshot();
89
+ });
90
+ test('Render with renderCustomIcon', () => {
91
+ const {
92
+ asFragment
93
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
94
+ title: "Alert Title",
95
+ renderCustomIcon: /*#__PURE__*/React.createElement("span", null, "Custom Icon")
96
+ }));
97
+ expect(asFragment()).toMatchSnapshot();
98
+ });
99
+ test('Render with renderSecondaryContent', () => {
100
+ const {
101
+ asFragment
102
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
103
+ title: "Alert Title",
104
+ renderSecondaryContent: /*#__PURE__*/React.createElement("span", null, "Secondary")
105
+ }));
106
+ expect(asFragment()).toMatchSnapshot();
107
+ });
108
+ test('Render with renderRightActions', () => {
109
+ const {
110
+ asFragment
111
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
112
+ title: "Alert Title",
113
+ renderRightActions: /*#__PURE__*/React.createElement("button", {
114
+ type: "button"
115
+ }, "Action")
116
+ }));
117
+ expect(asFragment()).toMatchSnapshot();
118
+ });
119
+ test('Render with dataId and htmlId', () => {
120
+ const {
121
+ asFragment
122
+ } = render( /*#__PURE__*/React.createElement(AlertHeader, {
123
+ title: "Alert Title",
124
+ htmlId: "alert-header-title",
125
+ dataId: "alert-header",
126
+ onClose: () => {}
127
+ }));
128
+ expect(asFragment()).toMatchSnapshot();
129
+ });
11
130
  });