@zohodesk/dot 1.0.0-temp-198.3.3 → 1.0.0-temp-199

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 (120) hide show
  1. package/.cli/propValidation_report.html +1 -1
  2. package/README.md +39 -0
  3. package/assets/Appearance/dark/mode/Dot_DarkMode.module.css +1 -0
  4. package/assets/Appearance/light/mode/Dot_LightMode.module.css +1 -0
  5. package/assets/Appearance/pureDark/mode/Dot_PureDarkMode.module.css +1 -0
  6. package/es/ActionButton/ActionButton.module.css +192 -192
  7. package/es/AlphabeticList/AlphabeticList.module.css +57 -57
  8. package/es/AttachmentViewer/AttachmentImage.js +68 -32
  9. package/es/AttachmentViewer/AttachmentViewer.js +120 -41
  10. package/es/AttachmentViewer/AttachmentViewer.module.css +364 -352
  11. package/es/AttachmentViewer/__tests__/AttachmentImage.spec.js +63 -13
  12. package/es/AttachmentViewer/__tests__/__snapshots__/AttachmentImage.spec.js.snap +9 -5
  13. package/es/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +16 -117
  14. package/es/AttachmentViewer/props/defaultProps.js +5 -1
  15. package/es/AttachmentViewer/props/propTypes.js +7 -3
  16. package/es/AttachmentViewer/utils.js +49 -0
  17. package/es/ChannelIcon/ChannelIcon.module.css +225 -225
  18. package/es/FormAction/FormAction.module.css +100 -100
  19. package/es/IconButton/IconButton.module.css +22 -22
  20. package/es/Image/Image.js +6 -2
  21. package/es/Image/props/propTypes.js +3 -1
  22. package/es/TagWithIcon/TagWithIcon.module.css +66 -66
  23. package/es/avatar/AvatarIcon/AvatarIcon.module.css +58 -58
  24. package/es/emptystate/CommonEmptyState/CommonEmptyState.module.css +92 -92
  25. package/es/form/fields/CurrencyField/CurrencyField.js +2 -1
  26. package/es/form/fields/TextEditor/TextEditor.js +64 -64
  27. package/es/form/fields/TextEditor/TextEditor.module.css +73 -61
  28. package/es/form/fields/TextEditor/__tests__/__snapshots__/TextEditor.spec.js.snap +1 -1
  29. package/es/form/fields/TextEditor/props/defaultProps.js +4 -1
  30. package/es/form/fields/TextEditor/props/propTypes.js +10 -3
  31. package/es/form/fields/ValidationMessage/ValidationMessage.module.css +27 -27
  32. package/es/layout/SubtabLayout/SubtabLayout.module.css +164 -164
  33. package/es/list/Comment/Comment.module.css +29 -29
  34. package/es/list/Dot/Dot.module.css +15 -15
  35. package/es/list/ListLayout/ListLayout.module.css +79 -79
  36. package/es/list/Subject/Subject.module.css +34 -34
  37. package/es/list/Thread/Thread.module.css +42 -42
  38. package/es/list/status/StatusDropdown/StatusDropdown.js +8 -2
  39. package/es/list/status/StatusDropdown/__tests__/StatusDropdown.spec.js +16 -0
  40. package/es/list/status/StatusDropdown/__tests__/__snapshots__/StatusDropdown.spec.js.snap +14 -0
  41. package/es/list/status/StatusDropdown/props/propTypes.js +2 -0
  42. package/es/lookup/header/Search/LookupSearch.module.css +26 -26
  43. package/es/lookup/header/Search/Search.js +55 -38
  44. package/es/lookup/header/Search/props/defaultProps.js +2 -1
  45. package/es/lookup/header/Search/props/propTypes.js +5 -1
  46. package/es/utils/editorUtils.js +6 -6
  47. package/es/v1/AttachmentViewer/AttachmentImage.js +44 -23
  48. package/es/v1/AttachmentViewer/AttachmentViewer.js +120 -41
  49. package/es/v1/AttachmentViewer/props/propTypes.js +7 -3
  50. package/es/v1/Image/Image.js +6 -2
  51. package/es/v1/Image/props/propTypes.js +3 -1
  52. package/es/v1/form/fields/CurrencyField/CurrencyField.js +2 -1
  53. package/es/v1/form/fields/TextEditor/TextEditor.js +63 -64
  54. package/es/v1/form/fields/TextEditor/props/defaultProps.js +4 -1
  55. package/es/v1/form/fields/TextEditor/props/propTypes.js +10 -3
  56. package/es/v1/list/status/StatusDropdown/StatusDropdown.js +8 -2
  57. package/es/v1/list/status/StatusDropdown/props/propTypes.js +2 -0
  58. package/es/v1/utils/editorUtils.js +6 -6
  59. package/es/version2/GlobalNotification/GlobalNotification.module.css +177 -177
  60. package/es/version2/lookup/AlertHeader/css/AlertHeaderNew.module.css +87 -87
  61. package/es/version2/notification/DesktopNotificationHeader/DesktopNotificationHeader.module.css +132 -132
  62. package/lib/ActionButton/ActionButton.module.css +192 -192
  63. package/lib/AlphabeticList/AlphabeticList.module.css +57 -57
  64. package/lib/AttachmentViewer/AttachmentImage.js +74 -36
  65. package/lib/AttachmentViewer/AttachmentViewer.js +151 -70
  66. package/lib/AttachmentViewer/AttachmentViewer.module.css +364 -352
  67. package/lib/AttachmentViewer/__tests__/AttachmentImage.spec.js +64 -13
  68. package/lib/AttachmentViewer/__tests__/__snapshots__/AttachmentImage.spec.js.snap +9 -5
  69. package/lib/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +16 -117
  70. package/lib/AttachmentViewer/props/defaultProps.js +5 -1
  71. package/lib/AttachmentViewer/props/propTypes.js +7 -3
  72. package/lib/AttachmentViewer/utils.js +60 -1
  73. package/lib/ChannelIcon/ChannelIcon.module.css +225 -225
  74. package/lib/FormAction/FormAction.module.css +100 -100
  75. package/lib/IconButton/IconButton.module.css +22 -22
  76. package/lib/Image/Image.js +6 -2
  77. package/lib/Image/props/propTypes.js +3 -1
  78. package/lib/TagWithIcon/TagWithIcon.module.css +66 -66
  79. package/lib/avatar/AvatarIcon/AvatarIcon.module.css +58 -58
  80. package/lib/emptystate/CommonEmptyState/CommonEmptyState.module.css +92 -92
  81. package/lib/form/fields/CurrencyField/CurrencyField.js +2 -1
  82. package/lib/form/fields/TextEditor/TextEditor.js +74 -74
  83. package/lib/form/fields/TextEditor/TextEditor.module.css +73 -61
  84. package/lib/form/fields/TextEditor/__tests__/__snapshots__/TextEditor.spec.js.snap +1 -1
  85. package/lib/form/fields/TextEditor/props/defaultProps.js +4 -1
  86. package/lib/form/fields/TextEditor/props/propTypes.js +10 -3
  87. package/lib/form/fields/ValidationMessage/ValidationMessage.module.css +27 -27
  88. package/lib/layout/SubtabLayout/SubtabLayout.module.css +164 -164
  89. package/lib/list/Comment/Comment.module.css +29 -29
  90. package/lib/list/Dot/Dot.module.css +15 -15
  91. package/lib/list/ListLayout/ListLayout.module.css +79 -79
  92. package/lib/list/Subject/Subject.module.css +34 -34
  93. package/lib/list/Thread/Thread.module.css +42 -42
  94. package/lib/list/status/StatusDropdown/StatusDropdown.js +8 -2
  95. package/lib/list/status/StatusDropdown/__tests__/StatusDropdown.spec.js +14 -0
  96. package/lib/list/status/StatusDropdown/__tests__/__snapshots__/StatusDropdown.spec.js.snap +14 -0
  97. package/lib/list/status/StatusDropdown/props/propTypes.js +1 -1
  98. package/lib/lookup/header/Search/LookupSearch.module.css +26 -26
  99. package/lib/lookup/header/Search/Search.js +73 -64
  100. package/lib/lookup/header/Search/props/defaultProps.js +2 -1
  101. package/lib/lookup/header/Search/props/propTypes.js +9 -3
  102. package/lib/utils/editorUtils.js +6 -5
  103. package/lib/v1/AttachmentViewer/AttachmentImage.js +52 -24
  104. package/lib/v1/AttachmentViewer/AttachmentViewer.js +151 -70
  105. package/lib/v1/AttachmentViewer/props/propTypes.js +7 -3
  106. package/lib/v1/Image/Image.js +6 -2
  107. package/lib/v1/Image/props/propTypes.js +3 -1
  108. package/lib/v1/form/fields/CurrencyField/CurrencyField.js +2 -1
  109. package/lib/v1/form/fields/TextEditor/TextEditor.js +73 -74
  110. package/lib/v1/form/fields/TextEditor/props/defaultProps.js +4 -1
  111. package/lib/v1/form/fields/TextEditor/props/propTypes.js +10 -3
  112. package/lib/v1/list/status/StatusDropdown/StatusDropdown.js +8 -2
  113. package/lib/v1/list/status/StatusDropdown/props/propTypes.js +1 -1
  114. package/lib/v1/utils/editorUtils.js +6 -5
  115. package/lib/version2/GlobalNotification/GlobalNotification.module.css +177 -177
  116. package/lib/version2/lookup/AlertHeader/css/AlertHeaderNew.module.css +87 -87
  117. package/lib/version2/notification/DesktopNotificationHeader/DesktopNotificationHeader.module.css +132 -132
  118. package/package.json +6 -6
  119. package/result.json +1 -1
  120. package/unittest/index.html +6 -2
@@ -1,43 +1,43 @@
1
- .varClass {
2
- --icon_color: var(--zdt_thread_iconText);
3
- }
4
- .container {
5
- composes: varClass;
6
- position: relative;
7
- color: var(--icon_color);
8
- cursor: pointer;
9
- }
10
- .container:hover {
11
- --icon_color: var(--zdt_thread_hover_iconText);
12
- }
13
- .count {
14
- font-size: var(--zd_font_size9) ;
15
- }
16
- .align_left .count {
17
- position: absolute;
18
- line-height: normal;
19
- top: var(--zd_size3) ;
20
- }
21
- [dir=ltr] .align_left .count {
22
- text-align: left;
23
- left: var(--zd_size8) ;
24
- }
25
- [dir=rtl] .align_left .count {
26
- text-align: right;
27
- right: var(--zd_size8) ;
28
- }
29
- .align_right {
30
- composes: dInflex alignFend from '~@zohodesk/components/lib/common/common.module.css';
31
- }
32
- .align_right .count {
33
- position: relative;
34
- bottom: var(--zd_size2) ;
35
- }
36
- [dir=ltr] .align_right .count {
37
- right: var(--zd_size5) ;
38
- float: right;
39
- }
40
- [dir=rtl] .align_right .count {
41
- left: var(--zd_size5) ;
42
- float: left;
1
+ .varClass {
2
+ --icon_color: var(--zdt_thread_iconText);
3
+ }
4
+ .container {
5
+ composes: varClass;
6
+ position: relative;
7
+ color: var(--icon_color);
8
+ cursor: pointer;
9
+ }
10
+ .container:hover {
11
+ --icon_color: var(--zdt_thread_hover_iconText);
12
+ }
13
+ .count {
14
+ font-size: var(--zd_font_size9) ;
15
+ }
16
+ .align_left .count {
17
+ position: absolute;
18
+ line-height: normal;
19
+ top: var(--zd_size3) ;
20
+ }
21
+ [dir=ltr] .align_left .count {
22
+ text-align: left;
23
+ left: var(--zd_size8) ;
24
+ }
25
+ [dir=rtl] .align_left .count {
26
+ text-align: right;
27
+ right: var(--zd_size8) ;
28
+ }
29
+ .align_right {
30
+ composes: dInflex alignFend from '~@zohodesk/components/lib/common/common.module.css';
31
+ }
32
+ .align_right .count {
33
+ position: relative;
34
+ bottom: var(--zd_size2) ;
35
+ }
36
+ [dir=ltr] .align_right .count {
37
+ right: var(--zd_size5) ;
38
+ float: right;
39
+ }
40
+ [dir=rtl] .align_right .count {
41
+ left: var(--zd_size5) ;
42
+ float: left;
43
43
  }
@@ -176,6 +176,8 @@ export class StatusDropdown extends React.Component {
176
176
  isRestrictScroll,
177
177
  positionsOffset,
178
178
  targetOffset,
179
+ renderTargetElement,
180
+ renderFooterElement,
179
181
  a11y = {}
180
182
  } = this.props;
181
183
  const {
@@ -193,7 +195,11 @@ export class StatusDropdown extends React.Component {
193
195
  className: style.posRel,
194
196
  onMouseEnter: showOnHover && !isDisabled && !isReadOnly && isEditable ? this.handleTogglePopup : undefined,
195
197
  onMouseLeave: showOnHover && !isDisabled && !isReadOnly && isEditable ? this.handleTogglePopup : undefined
196
- }, /*#__PURE__*/React.createElement(Container, {
198
+ }, renderTargetElement ? renderTargetElement({
199
+ handleTogglePopup: this.handleTogglePopup,
200
+ isPopupOpen,
201
+ getTargetRef
202
+ }) : /*#__PURE__*/React.createElement(Container, {
197
203
  tagName: "button",
198
204
  alignBox: "row",
199
205
  className: `${style.container} ${containerClass} ${btnStyle.buttonReset}`,
@@ -333,7 +339,7 @@ export class StatusDropdown extends React.Component {
333
339
  getEmptyState: this.emptySearchSVG
334
340
  }) : /*#__PURE__*/React.createElement("div", {
335
341
  className: style.loader
336
- }, /*#__PURE__*/React.createElement(Loader, null)))));
342
+ }, /*#__PURE__*/React.createElement(Loader, null))), renderFooterElement ? renderFooterElement : null));
337
343
  }) : null);
338
344
  }
339
345
 
@@ -7,5 +7,21 @@ describe('StatusDropdown', () => {
7
7
  asFragment
8
8
  } = render( /*#__PURE__*/React.createElement(StatusDropdown, null));
9
9
  expect(asFragment()).toMatchSnapshot();
10
+ }), test('rendering target element', () => {
11
+ const renderTargetElement = _ref => {
12
+ let {
13
+ isPopupOpen
14
+ } = _ref;
15
+ return /*#__PURE__*/React.createElement("div", {
16
+ className: isPopupOpen ? 'popupOpened' : 'popupClosed'
17
+ }, "Target Element");
18
+ };
19
+
20
+ const {
21
+ asFragment
22
+ } = render( /*#__PURE__*/React.createElement(StatusDropdown, {
23
+ renderTargetElement: renderTargetElement
24
+ }));
25
+ expect(asFragment()).toMatchSnapshot();
10
26
  });
11
27
  });
@@ -1,5 +1,19 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`StatusDropdown rendering target element 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="posRel"
7
+ >
8
+ <div
9
+ class="popupClosed"
10
+ >
11
+ Target Element
12
+ </div>
13
+ </div>
14
+ </DocumentFragment>
15
+ `;
16
+
3
17
  exports[`StatusDropdown rendering the defult props 1`] = `
4
18
  <DocumentFragment>
5
19
  <div
@@ -54,5 +54,7 @@ export const propTypes = {
54
54
  isAbsolutePositioningNeeded: PropTypes.bool,
55
55
  isRestrictScroll: PropTypes.bool,
56
56
  positionsOffset: PropTypes.object,
57
+ renderTargetElement: PropTypes.func,
58
+ renderFooterElement: PropTypes.node,
57
59
  targetOffset: PropTypes.object
58
60
  };
@@ -1,20 +1,25 @@
1
- .searchStyle,
2
- .boxStyle {
1
+ .wrapper {
3
2
  transition: var(--zd_transition1);
4
- width: var(--zd_size96) ;
3
+ width: var(--zd_size160) ;
5
4
  height: var(--zd_size28) ;
6
5
  position: relative;
7
- }.searchStyle, .boxStyle {
8
- background: none;
9
6
  }
10
- .boxStyle {
11
- width: var(--zd_size160) ;
7
+ .boxType {
8
+ border: 1px solid transparent;
12
9
  border-radius: 4px;
13
- border: 1px solid var(--zdt_lookupsearch_boxstyle_border);
14
10
  }
15
- .searchStyle:hover, .boxStyle:hover {
11
+ .borderType {
12
+ border-bottom: 1px solid transparent;
13
+ }
14
+ .boxType, .borderType {
15
+ border-color: var(--zdt_lookupsearch_boxstyle_border);
16
+ }
17
+ .boxType:hover, .borderType:hover {
16
18
  border-color: var(--zdt_lookupsearch_boxstyle_hover_border);
17
19
  }
20
+ .boxType.active, .borderType.active {
21
+ border-color: var(--zdt_lookupsearch_boxstyle_activer_border);
22
+ }
18
23
  .focusWidth {
19
24
  width: var(--zd_size220) ;
20
25
  }
@@ -22,36 +27,31 @@
22
27
  position: relative;
23
28
  height: var(--zd_size28) ;
24
29
  cursor: pointer;
30
+ padding: 0 var(--zd_size9) ;
25
31
  }
26
32
  .drpSearchBox::after {
27
33
  content: '';
28
34
  position: absolute;
29
- top: var(--zd_size8) ;
30
- bottom: var(--zd_size8) ;
35
+ top: var(--zd_size4) ;
36
+ bottom: var(--zd_size4) ;
31
37
  }
32
38
  [dir=ltr] .drpSearchBox::after {
33
- right: calc( var(--zd_size1) * -1 ) ;
39
+ right: var(--zd_size6) ;
34
40
  border-right: 1px solid var(--zdt_lookupsearch_boxstyle_border);
35
41
  }
36
42
  [dir=rtl] .drpSearchBox::after {
37
- left: calc( var(--zd_size1) * -1 ) ;
43
+ left: var(--zd_size6) ;
38
44
  border-left: 1px solid var(--zdt_lookupsearch_boxstyle_border);
39
45
  }
40
- .inputBox, .drpSearchBox {
41
- padding: 0 var(--zd_size9) ;
42
- }
43
- [dir=ltr] .searchIconBox {
44
- padding: var(--zd_size4) 0 var(--zd_size4) var(--zd_size9) ;
46
+ [dir=ltr] .searchIcon {
47
+ padding-right: var(--zd_size8) ;
45
48
  }
46
- [dir=rtl] .searchIconBox {
47
- padding: var(--zd_size4) var(--zd_size9) var(--zd_size4) 0 ;
49
+ [dir=rtl] .searchIcon {
50
+ padding-left: var(--zd_size8) ;
48
51
  }
49
52
  .active, .boxStyle.active, .lineActive.drpSearchBox::after {
50
53
  border-color: var(--zdt_lookupsearch_boxstyle_activer_border);
51
54
  }
52
- [dir=ltr] .iconArrow {
53
- margin-left: var(--zd_size5) ;
54
- }
55
- [dir=rtl] .iconArrow {
56
- margin-right: var(--zd_size5) ;
57
- }
55
+ .iconArrow {
56
+ margin: 0 var(--zd_size6) ;
57
+ }
@@ -8,6 +8,7 @@ import { Search_propTypes, SearchUI_propTypes } from "./props/propTypes";
8
8
 
9
9
  import TextBoxIcon from '@zohodesk/components/lib/TextBoxIcon/TextBoxIcon';
10
10
  import { Container, Box } from '@zohodesk/components/lib/Layout';
11
+ import { mergeStyle } from '@zohodesk/utils';
11
12
  import { Icon } from '@zohodesk/icons';
12
13
  import ToggleDropDown from "../../../dropdown/ToggleDropDown/ToggleDropDown";
13
14
  /** * Methods ** */
@@ -16,33 +17,19 @@ import { debounce } from '@zohodesk/components/lib/utils/debounce';
16
17
  import { cancelBubblingEffect } from '@zohodesk/components/es/utils/Common';
17
18
  /** * CSS ** */
18
19
 
19
- import style from "./LookupSearch.module.css";
20
+ import defaultStyle from "./LookupSearch.module.css";
20
21
  export default class Search extends Component {
21
22
  constructor(props) {
22
23
  super(props);
23
- this.handleDropDownOpen = this.handleDropDownOpen.bind(this);
24
- this.handleDropDownClose = this.handleDropDownClose.bind(this);
25
24
  this.handleTextBoxFocus = this.handleTextBoxFocus.bind(this);
26
25
  this.handleTextBoxBlur = this.handleTextBoxBlur.bind(this);
27
26
  this.handleGetTextBoxRef = this.handleGetTextBoxRef.bind(this);
27
+ this.handleRenderChildren = this.handleRenderChildren.bind(this);
28
28
  this.state = {
29
- isFocus: false,
30
- isDropDownOpen: false
29
+ isFocus: false
31
30
  };
32
31
  }
33
32
 
34
- handleDropDownOpen() {
35
- this.setState({
36
- isDropDownOpen: true
37
- });
38
- }
39
-
40
- handleDropDownClose() {
41
- this.setState({
42
- isDropDownOpen: false
43
- });
44
- }
45
-
46
33
  handleTextBoxFocus(e) {
47
34
  const {
48
35
  onFocus
@@ -71,22 +58,45 @@ export default class Search extends Component {
71
58
  getRef && getRef(el);
72
59
  }
73
60
 
61
+ handleRenderChildren(_ref) {
62
+ let {
63
+ isActive
64
+ } = _ref;
65
+ const {
66
+ value,
67
+ selectedId,
68
+ renderChildren
69
+ } = this.props;
70
+
71
+ if (renderChildren) {
72
+ return renderChildren({
73
+ isActive,
74
+ value,
75
+ selectedId
76
+ });
77
+ }
78
+
79
+ return null;
80
+ }
81
+
74
82
  render() {
75
83
  const {
76
84
  options,
77
85
  onSelect,
78
86
  value,
79
- selectedId
87
+ selectedId,
88
+ renderChildren
80
89
  } = this.props;
81
90
  const {
82
- isFocus,
83
- isDropDownOpen
91
+ isFocus
84
92
  } = this.state;
85
93
  const searchUIExtraProps = {
86
- isFocus: isFocus || isDropDownOpen,
94
+ isFocus: isFocus,
87
95
  onFocus: this.handleTextBoxFocus,
88
96
  onBlur: this.handleTextBoxBlur,
89
- getRef: this.handleGetTextBoxRef
97
+ getRef: this.handleGetTextBoxRef,
98
+ value: value,
99
+ renderChildren: renderChildren ? this.handleRenderChildren : null
90
100
  };
91
101
  return options ? /*#__PURE__*/React.createElement(ToggleDropDown, {
92
102
  value: value,
@@ -95,9 +105,7 @@ export default class Search extends Component {
95
105
  needTick: true,
96
106
  isArrow: false,
97
107
  isToggleStateNeeded: true,
98
- selectedId: selectedId,
99
- onDropDownOpen: this.handleDropDownOpen,
100
- onDropDownClose: this.handleDropDownClose
108
+ selectedId: selectedId
101
109
  }, /*#__PURE__*/React.createElement(SearchUI, { ...this.props,
102
110
  ...searchUIExtraProps
103
111
  })) : /*#__PURE__*/React.createElement(SearchUI, { ...this.props,
@@ -171,15 +179,27 @@ class SearchUI extends Component {
171
179
  activeClass,
172
180
  isFocus,
173
181
  onFocus,
174
- onBlur
182
+ onBlur,
183
+ renderChildren,
184
+ isActive,
185
+ customStyle
175
186
  } = this.props;
187
+ const isInActiveState = isFocus || isActive;
188
+ const isFocusWidth = isFocus || searchStr || isActive;
189
+ const style = mergeStyle(defaultStyle, customStyle);
176
190
  return /*#__PURE__*/React.createElement(Container, {
177
191
  isCover: false,
178
192
  alignBox: "row",
179
193
  align: "vertical",
180
- className: `${style.searchStyle} ${isBoxed ? style.boxStyle : ''} ${isFocus ? `${style.active} ${activeClass ? activeClass : ''} ` : ''} ${searchStr || isFocus ? style.focusWidth : ''}`
181
- }, options && /*#__PURE__*/React.createElement(Container, {
182
- className: `${style.drpSearchBox} ${isFocus ? style.lineActive : ''}`,
194
+ className: `
195
+ ${style.wrapper} ${isBoxed ? style.boxType : style.borderType}
196
+ ${isInActiveState ? `${style.active} ${activeClass || ''}` : ''}
197
+ ${isFocusWidth ? style.focusWidth : ''}
198
+ `
199
+ }, renderChildren && options ? renderChildren({
200
+ isActive
201
+ }) : options ? /*#__PURE__*/React.createElement(Container, {
202
+ className: `${style.drpSearchBox} ${isInActiveState ? style.lineActive : ''}`,
183
203
  isCover: false,
184
204
  align: "vertical",
185
205
  alignBox: "row",
@@ -191,17 +211,13 @@ class SearchUI extends Component {
191
211
  name: "ZD-down",
192
212
  size: "7",
193
213
  iconClass: style.iconArrow
194
- })), isSearchIconNeed && /*#__PURE__*/React.createElement(Box, {
195
- className: style.searchIconBox
196
- }, /*#__PURE__*/React.createElement(Icon, {
214
+ })) : isSearchIconNeed ? /*#__PURE__*/React.createElement(Icon, {
197
215
  name: "ZD-search",
198
- size: "11"
199
- })), /*#__PURE__*/React.createElement(Box, {
216
+ size: "11",
217
+ iconClass: style.searchIcon
218
+ }) : null, /*#__PURE__*/React.createElement(Box, {
200
219
  flexible: true
201
220
  }, /*#__PURE__*/React.createElement(TextBoxIcon, {
202
- customClass: {
203
- customTextBox: `${isBoxed ? style.inputBox : ''}`
204
- },
205
221
  customProps: {
206
222
  TextBoxProps: {
207
223
  'data-a11y-autofocus': true
@@ -219,7 +235,8 @@ class SearchUI extends Component {
219
235
  size: "small",
220
236
  inputRef: getRef,
221
237
  onClear: this.handleClear,
222
- onClearMouseDown: cancelBubblingEffect
238
+ onClearMouseDown: cancelBubblingEffect,
239
+ needBorder: false
223
240
  })));
224
241
  }
225
242
 
@@ -1,5 +1,6 @@
1
1
  export const SearchUI_defaultProps = {
2
2
  activeClass: '',
3
3
  isBoxed: false,
4
- isSearchIconNeed: false
4
+ isSearchIconNeed: false,
5
+ isActive: false
5
6
  };
@@ -24,5 +24,9 @@ export const SearchUI_propTypes = {
24
24
  options: PropTypes.array,
25
25
  placeHolder: PropTypes.string,
26
26
  searchStr: PropTypes.string,
27
- title: PropTypes.string
27
+ title: PropTypes.string,
28
+ renderChildren: PropTypes.func,
29
+ isActive: PropTypes.bool,
30
+ renderChildren: PropTypes.func,
31
+ customStyle: PropTypes.object
28
32
  };
@@ -1,5 +1,4 @@
1
- const ATTACHMENT_FILE_NAME_SIZE_LIMIT = 200; // editorUtils
2
-
1
+ // editorUtils
3
2
  export function editorContentValidate(editorObj) {
4
3
  let content = editorObj && editorObj.getContent && editorObj.getContent() || '';
5
4
 
@@ -48,12 +47,13 @@ export function encodeForHtml(str) {
48
47
  return str;
49
48
  } // attachment
50
49
 
51
- export function isFileNameSizeInvalid(fileName) {
52
- return fileName.length > ATTACHMENT_FILE_NAME_SIZE_LIMIT;
50
+ export function isFileNameSizeInvalid(fileName, fileNameMaxCharacters) {
51
+ return fileName.length > fileNameMaxCharacters;
53
52
  }
54
- export function isImageFormat(fileName) {
53
+ export function isImageFormat(fileName, allowedFileExtensions) {
55
54
  let extension = getExtensionFromFileName(fileName);
56
- return /jpeg|jpg|png|gif|bmp|ico/i.test(extension);
55
+ const isValidExtension = allowedFileExtensions.includes(extension);
56
+ return isValidExtension;
57
57
  }
58
58
  export function getExtensionFromFileName(fileName) {
59
59
  if (fileName && fileName.indexOf('.') != -1) {
@@ -2,8 +2,11 @@
2
2
 
3
3
  /** * Libraries ** */
4
4
  import React, { useRef, useEffect, useState } from 'react';
5
+ import { useEffectCallOnlyAfterState } from '@zohodesk/hooks';
6
+ import { Container } from '@zohodesk/components/es/Layout';
5
7
  import { AttachmentImage_defaultProps } from "./props/defaultProps";
6
8
  import { AttachmentImage_propTypes } from "./props/propTypes";
9
+ import { checkImageValidity } from "../../AttachmentViewer/utils";
7
10
  import Image from "../Image/Image";
8
11
  /** * CSS ** */
9
12
 
@@ -11,48 +14,66 @@ import style from "../../AttachmentViewer/AttachmentViewer.module.css";
11
14
 
12
15
  const AttachmentImage = props => {
13
16
  const {
14
- isImage,
15
17
  onLoad,
18
+ onError,
16
19
  src,
17
20
  onClick,
18
21
  alt,
19
22
  dataId,
20
23
  id,
21
- className,
22
- isCover
24
+ customClass,
25
+ isCover,
26
+ children
23
27
  } = props;
24
- const imageEle = useRef();
28
+ const {
29
+ customImageClass = '',
30
+ customChildrenClass = ''
31
+ } = customClass;
25
32
  const [isLoading, setLoading] = useState(true);
33
+ const [isImageValid, setImageValidity] = useState(false);
26
34
 
27
- const imgLoad = () => {
28
- setLoading(false);
29
- onLoad && onLoad();
30
- };
35
+ function handleImageValidation() {
36
+ checkImageValidity(src).then(isValid => {
37
+ setImageValidity(isValid);
38
+ setLoading(false);
39
+ });
40
+ }
31
41
 
32
42
  useEffect(() => {
33
- if (isImage) {
34
- const image = imageEle.current;
35
- image.addEventListener('load', imgLoad);
36
- } else {
37
- setLoading(false);
38
- }
43
+ handleImageValidation();
39
44
  }, []);
45
+ useEffectCallOnlyAfterState(() => {
46
+ setLoading(true);
47
+ handleImageValidation();
48
+ }, [src]);
49
+
50
+ function renderImage() {
51
+ return /*#__PURE__*/React.createElement(Image, {
52
+ htmlId: id,
53
+ dataId: isImageValid ? dataId : `${dataId}_alt`,
54
+ src: src,
55
+ onClick: onClick,
56
+ className: customImageClass,
57
+ alt: alt,
58
+ isCover: isCover,
59
+ onLoad: onLoad,
60
+ onError: onError
61
+ });
62
+ }
63
+
40
64
  return /*#__PURE__*/React.createElement(React.Fragment, null, isLoading ? /*#__PURE__*/React.createElement("div", {
41
65
  className: `${style.spinLoad}`,
42
66
  "data-id": `${dataId}_loader`,
43
67
  "data-test-id": `${dataId}_loader`
44
68
  }, /*#__PURE__*/React.createElement("div", {
45
69
  className: style.loader
46
- })) : null, /*#__PURE__*/React.createElement(Image, {
70
+ })) : isImageValid ? renderImage() : children ? /*#__PURE__*/React.createElement(Container, {
71
+ align: "both",
47
72
  htmlId: id,
48
- eleRef: imageEle,
49
- dataId: dataId,
50
- src: src,
51
- onClick: onClick,
52
- className: `${isLoading ? style.hide : ''} ${className}`,
53
- alt: alt,
54
- isCover: isCover
55
- }));
73
+ dataId: `${dataId}_custom`,
74
+ className: customChildrenClass
75
+ }, children) : renderImage() //alt ui
76
+ );
56
77
  };
57
78
 
58
79
  AttachmentImage.propTypes = AttachmentImage_propTypes;