diginet-core-ui 1.3.78 → 1.3.79

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 (209) hide show
  1. package/components/accordion/details.js +2 -6
  2. package/components/accordion/group.js +2 -9
  3. package/components/accordion/index.js +2 -15
  4. package/components/accordion/summary.js +4 -27
  5. package/components/alert/index.js +98 -137
  6. package/components/alert/notify.js +97 -166
  7. package/components/avatar/index.js +4 -63
  8. package/components/badge/index.js +7 -34
  9. package/components/button/icon.js +120 -186
  10. package/components/button/index.js +136 -205
  11. package/components/button/more.js +0 -12
  12. package/components/button/ripple-effect.js +46 -44
  13. package/components/card/body.js +2 -7
  14. package/components/card/extra.js +2 -7
  15. package/components/card/footer.js +2 -7
  16. package/components/card/header.js +2 -7
  17. package/components/card/index.js +2 -22
  18. package/components/chart/Pie/Circle.js +0 -1
  19. package/components/chart/Pie/Sector.js +0 -17
  20. package/components/chart/Pie/Sectors.js +0 -10
  21. package/components/chart/Pie/index.js +4 -36
  22. package/components/chart/Pie-v2/Circle.js +0 -1
  23. package/components/chart/Pie-v2/Sector.js +0 -13
  24. package/components/chart/Pie-v2/Sectors.js +0 -20
  25. package/components/chart/Pie-v2/index.js +11 -38
  26. package/components/chart/bar/Axis.js +0 -12
  27. package/components/chart/bar/Bar.js +13 -35
  28. package/components/chart/bar/Grid.js +0 -18
  29. package/components/chart/bar/Labels.js +0 -18
  30. package/components/chart/bar/Points.js +0 -17
  31. package/components/chart/bar/index.js +6 -26
  32. package/components/chart/bar-v2/Axis.js +0 -12
  33. package/components/chart/bar-v2/Bar.js +15 -36
  34. package/components/chart/bar-v2/Grid.js +0 -18
  35. package/components/chart/bar-v2/Labels.js +0 -18
  36. package/components/chart/bar-v2/Points.js +0 -17
  37. package/components/chart/bar-v2/index.js +6 -26
  38. package/components/chart/line/Axis.js +4 -16
  39. package/components/chart/line/Grid.js +2 -19
  40. package/components/chart/line/Labels.js +0 -18
  41. package/components/chart/line/Path.js +23 -33
  42. package/components/chart/line/Point.js +6 -40
  43. package/components/chart/line/Title.js +0 -3
  44. package/components/chart/line/index.js +12 -35
  45. package/components/chart/line-v2/Axis.js +0 -13
  46. package/components/chart/line-v2/Grid.js +0 -18
  47. package/components/chart/line-v2/Labels.js +0 -18
  48. package/components/chart/line-v2/Path.js +23 -33
  49. package/components/chart/line-v2/Point.js +6 -35
  50. package/components/chart/line-v2/Title.js +0 -3
  51. package/components/chart/line-v2/index.js +12 -30
  52. package/components/check-text/index.js +0 -8
  53. package/components/check-text/interview-confirmation.js +0 -7
  54. package/components/check-text/interview-status.js +0 -7
  55. package/components/chip/attach.js +4 -17
  56. package/components/chip/index.js +6 -33
  57. package/components/collapse/index.js +0 -13
  58. package/components/divider/index.js +0 -8
  59. package/components/form-control/attachment/index.js +24 -202
  60. package/components/form-control/calendar/function.js +40 -94
  61. package/components/form-control/calendar/index.js +5 -30
  62. package/components/form-control/calendar/range.js +11 -28
  63. package/components/form-control/checkbox/index.js +4 -37
  64. package/components/form-control/control/index.js +3 -13
  65. package/components/form-control/date-picker/index-old.js +18 -0
  66. package/components/form-control/date-picker/index.js +23 -99
  67. package/components/form-control/date-range-picker/index.js +86 -221
  68. package/components/form-control/dropdown/index.js +72 -289
  69. package/components/form-control/dropdown-box/index.js +6 -35
  70. package/components/form-control/form/index.js +0 -2
  71. package/components/form-control/form-group/index.js +1 -6
  72. package/components/form-control/helper-text/index.js +2 -9
  73. package/components/form-control/input-base/index.js +218 -399
  74. package/components/form-control/label/index.js +2 -12
  75. package/components/form-control/money-input/index.js +43 -132
  76. package/components/form-control/number-input/index.js +15 -113
  77. package/components/form-control/number-input/index2.js +78 -119
  78. package/components/form-control/phone-input/index.js +16 -78
  79. package/components/form-control/radio/index.js +4 -23
  80. package/components/form-control/text-input/index.js +33 -256
  81. package/components/form-control/time-picker/index.js +14 -71
  82. package/components/form-control/time-picker/swiper.js +21 -73
  83. package/components/form-control/toggle/index.js +4 -19
  84. package/components/form-view/helper-text.js +2 -2
  85. package/components/form-view/index.js +0 -14
  86. package/components/form-view/input.js +2 -13
  87. package/components/form-view/label.js +0 -2
  88. package/components/grid/Col.js +2 -15
  89. package/components/grid/Container.js +2 -21
  90. package/components/grid/Row.js +2 -21
  91. package/components/grid/index.js +2 -43
  92. package/components/image/index.js +2 -22
  93. package/components/index.js +62 -31
  94. package/components/list/list-item-action.js +0 -9
  95. package/components/list/list-item-icon.js +0 -9
  96. package/components/list/list-item-text.js +0 -5
  97. package/components/list/list-item.js +0 -11
  98. package/components/list/list.js +0 -13
  99. package/components/list/sub-header.js +0 -4
  100. package/components/modal/body.js +2 -6
  101. package/components/modal/footer.js +2 -11
  102. package/components/modal/header.js +2 -12
  103. package/components/modal/index.js +2 -10
  104. package/components/modal/modal.js +11 -52
  105. package/components/others/extra/index.js +3 -10
  106. package/components/others/import/index.js +0 -7
  107. package/components/others/option-wrapper/index.js +4 -7
  108. package/components/others/scrollbar/index.js +0 -3
  109. package/components/paging/page-info.js +39 -101
  110. package/components/paging/page-selector.js +7 -35
  111. package/components/paging/page-selector2.js +35 -74
  112. package/components/paper/index.js +0 -11
  113. package/components/popover/body.js +2 -6
  114. package/components/popover/footer.js +2 -11
  115. package/components/popover/header.js +2 -7
  116. package/components/popover/index.js +39 -123
  117. package/components/popup/danger_popup.js +0 -19
  118. package/components/popup/index.js +2 -48
  119. package/components/popup/proposals_popup.js +10 -49
  120. package/components/popup/v2/index.js +0 -31
  121. package/components/progress/circular.js +19 -81
  122. package/components/progress/linear.js +4 -20
  123. package/components/rating/index.js +0 -24
  124. package/components/slider/slider-container.js +3 -40
  125. package/components/slider/slider-item.js +10 -25
  126. package/components/status/index.js +2 -16
  127. package/components/tab/tab-container.js +2 -16
  128. package/components/tab/tab-header.js +4 -24
  129. package/components/tab/tab-panel.js +4 -16
  130. package/components/tab/tab.js +4 -28
  131. package/components/tooltip/index.js +12 -97
  132. package/components/tooltip/portal.js +0 -2
  133. package/components/transfer/index.js +22 -67
  134. package/components/tree-view/index.js +62 -202
  135. package/components/typography/index.js +3 -31
  136. package/global/index.js +0 -8
  137. package/icons/basic.js +0 -48
  138. package/icons/effect.js +17 -29
  139. package/icons/general/clock/clock.js +0 -2
  140. package/icons/general/color-handler/background.js +0 -2
  141. package/icons/general/color-handler/text.js +0 -2
  142. package/icons/general/emoji/emoji.js +0 -2
  143. package/icons/general/font-properties/bold.js +0 -2
  144. package/icons/general/font-properties/font-family.js +0 -2
  145. package/icons/general/font-properties/font-size.js +0 -2
  146. package/icons/general/font-properties/italic.js +0 -2
  147. package/icons/general/font-properties/underline.js +0 -2
  148. package/icons/general/hyperlink/hyperlink.js +0 -2
  149. package/icons/general/indent/decrease.js +0 -2
  150. package/icons/general/indent/increase.js +0 -2
  151. package/icons/general/list/bullets.js +0 -2
  152. package/icons/general/list/numbering.js +0 -2
  153. package/icons/general/picture/picture.js +0 -2
  154. package/icons/general/steps/redo.js +0 -2
  155. package/icons/general/steps/undo.js +0 -2
  156. package/icons/general/text-align/center.js +0 -2
  157. package/icons/general/text-align/justify.js +0 -2
  158. package/icons/general/text-align/left.js +0 -2
  159. package/icons/general/text-align/right.js +0 -2
  160. package/icons/menu/dhr.js +2 -1
  161. package/icons/menu/index.js +2 -2
  162. package/icons/menu/v2/index.js +0 -10
  163. package/package.json +1 -1
  164. package/readme.md +11 -1
  165. package/styles/animation.js +15 -58
  166. package/styles/color-helper.js +24 -54
  167. package/styles/colors.js +17 -9
  168. package/styles/general.js +6 -2
  169. package/styles/typography.js +4 -4
  170. package/styles/utils.js +2 -2
  171. package/theme/createBreakpoints.js +7 -18
  172. package/theme/make-styles.js +2 -5
  173. package/theme/set-theme.js +3 -6
  174. package/theme/settings.js +3 -2
  175. package/theme/theme-provider.js +0 -1
  176. package/utils/array/array.js +14 -23
  177. package/utils/classNames.js +0 -5
  178. package/utils/console.js +0 -6
  179. package/utils/date.js +13 -82
  180. package/utils/error/error.js +1 -9
  181. package/utils/error/errors.js +1 -48
  182. package/utils/getFileType.js +0 -9
  183. package/utils/handleBreakpoints.js +0 -5
  184. package/utils/intersectionObserver.js +0 -5
  185. package/utils/iterator.js +0 -9
  186. package/utils/map-parent.js +3 -10
  187. package/utils/object/extend.js +0 -10
  188. package/utils/object/object.js +12 -11
  189. package/utils/parseHTML.js +0 -1
  190. package/utils/promisify.js +0 -5
  191. package/utils/randomString.js +0 -7
  192. package/utils/remove-unicode.js +0 -1
  193. package/utils/render-portal.js +1 -9
  194. package/utils/renderHTML.js +4 -6
  195. package/utils/renderIcon.js +4 -14
  196. package/utils/sb-template.js +6 -5
  197. package/utils/string/capitalize.js +0 -1
  198. package/utils/string/capitalizeSentenceCase.js +0 -2
  199. package/utils/string/string.js +0 -13
  200. package/utils/type.js +0 -21
  201. package/utils/updatePosition.js +4 -5
  202. package/utils/useDelayUnmount.js +0 -4
  203. package/utils/useElementSize.js +9 -3
  204. package/utils/useEventListener.js +12 -6
  205. package/utils/useInput.js +0 -6
  206. package/utils/useMediaQuery.js +8 -10
  207. package/utils/useOnClickOutside.js +0 -2
  208. package/utils/usePortal.js +3 -10
  209. package/utils/validate.js +6 -20
@@ -1,5 +1,4 @@
1
1
  /** @jsxRuntime classic */
2
-
3
2
  /** @jsx jsx */
4
3
  import React, { memo, useState, useEffect, useMemo, useRef, forwardRef, useImperativeHandle } from 'react';
5
4
  import { createPortal } from 'react-dom';
@@ -22,7 +21,6 @@ const {
22
21
  zIndex: zIndexCORE
23
22
  } = theme;
24
23
  const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
25
-
26
24
  const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
27
25
  if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
28
26
  translate.left = -6;
@@ -41,30 +39,25 @@ const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
41
39
  return 'top';
42
40
  }
43
41
  };
44
-
45
42
  const calPosition = (position, originBounding) => {
46
43
  const {
47
44
  width,
48
45
  height
49
46
  } = originBounding;
50
-
51
47
  switch (position) {
52
48
  case 'bottom':
53
49
  case 'right':
54
50
  {
55
51
  return [height, width];
56
52
  }
57
-
58
53
  case 'center':
59
54
  {
60
55
  return [height / 2, width / 2];
61
56
  }
62
-
63
57
  default:
64
58
  return [0, 0];
65
59
  }
66
60
  };
67
-
68
61
  const getDirectionPopover = direction => {
69
62
  switch (direction) {
70
63
  case 'center':
@@ -78,7 +71,6 @@ const getDirectionPopover = direction => {
78
71
  horizontal: 'center'
79
72
  }
80
73
  };
81
-
82
74
  case 'top':
83
75
  return {
84
76
  anchorOrigin: {
@@ -90,7 +82,6 @@ const getDirectionPopover = direction => {
90
82
  horizontal: 'center'
91
83
  }
92
84
  };
93
-
94
85
  case 'left':
95
86
  return {
96
87
  anchorOrigin: {
@@ -102,7 +93,6 @@ const getDirectionPopover = direction => {
102
93
  horizontal: 'right'
103
94
  }
104
95
  };
105
-
106
96
  case 'right':
107
97
  return {
108
98
  anchorOrigin: {
@@ -114,7 +104,6 @@ const getDirectionPopover = direction => {
114
104
  horizontal: 'left'
115
105
  }
116
106
  };
117
-
118
107
  default:
119
108
  return {
120
109
  anchorOrigin: {
@@ -128,7 +117,6 @@ const getDirectionPopover = direction => {
128
117
  };
129
118
  }
130
119
  };
131
-
132
120
  const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
133
121
  action = {},
134
122
  anchor,
@@ -156,25 +144,18 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
156
144
  const arrowRef = useRef(null);
157
145
  const [openState, setOpenState] = useState(open);
158
146
  const [element, setElement] = useState(null);
159
-
160
147
  const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
161
-
162
148
  const _PopoverContainerCSS = PopoverContainerCSS(bgColor, width, height);
163
-
164
149
  const _PopoverArrowCSS = PopoverArrowCSS(bgColor);
165
-
166
150
  const arrowSize = arrow ? 6 : 0;
167
-
168
151
  if (direction) {
169
152
  const directionObject = getDirectionPopover(direction);
170
153
  anchorOrigin = directionObject.anchorOrigin;
171
154
  transformOrigin = directionObject.transformOrigin;
172
155
  }
173
-
174
156
  const onOpenPopover = () => {
175
157
  if (!openState) setOpenState(true);
176
158
  };
177
-
178
159
  const onClosePopover = () => {
179
160
  if (openState) {
180
161
  if (ref.current) ref.current.style.opacity = 0;
@@ -182,116 +163,96 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
182
163
  setOpenState(false);
183
164
  }
184
165
  };
185
-
186
166
  const pressESCHandler = event => {
187
167
  if (event.key === 'Escape') {
188
168
  onClosePopover();
189
169
  }
190
170
  };
191
-
192
171
  const onClickOutside = event => {
193
172
  var _anchor2, _anchor3, _anchor3$current, _anchor4, _ref$current, _ref$current2, _ref$current2$parentN;
194
-
195
173
  if (!ref.current) {
196
174
  document.removeEventListener('click', onClickOutside);
197
175
  return;
198
176
  }
199
-
200
177
  const _anchor = ((_anchor2 = anchor) === null || _anchor2 === void 0 ? void 0 : _anchor2.element) || ((_anchor3 = anchor) === null || _anchor3 === void 0 ? void 0 : (_anchor3$current = _anchor3.current) === null || _anchor3$current === void 0 ? void 0 : _anchor3$current.element) || ((_anchor4 = anchor) === null || _anchor4 === void 0 ? void 0 : _anchor4.current) || anchor;
201
-
202
178
  if (clickOutsideToClose && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains((event === null || event === void 0 ? void 0 : event.toElement) || (event === null || event === void 0 ? void 0 : event.target))) && (!fullScreen || (_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && (_ref$current2$parentN = _ref$current2.parentNode) !== null && _ref$current2$parentN !== void 0 && _ref$current2$parentN.contains(event === null || event === void 0 ? void 0 : event.target)) && !(_anchor !== null && _anchor !== void 0 && _anchor.contains((event === null || event === void 0 ? void 0 : event.toElement) || (event === null || event === void 0 ? void 0 : event.target))) && openState) {
203
179
  onClosePopover();
204
180
  }
205
181
  };
206
-
207
182
  const updatePositionPopover = (el = null, cb) => {
208
183
  var _window, _window2, _anchor6, _anchorRect, _anchorRect2, _anchor7, _anchorRect3, _anchorRect4, _anchorRect5, _anchorRect6, _anchorRect7, _anchorRect8, _anchorRect9, _anchorRect10, _anchorRect11, _anchorRect12, _newDirectionObject, _newDirectionObject$t, _transformOrigin, _newDirectionObject2, _newDirectionObject2$, _transformOrigin2;
209
-
210
184
  setElement(el instanceof Element ? el : null);
211
-
212
185
  if (!ref.current) {
213
186
  window.removeEventListener('resize', updatePositionPopover);
214
187
  return;
215
188
  }
216
-
217
189
  let top = 0,
218
- left = 0,
219
- vertical = 0,
220
- verticalCenter = 0,
221
- horizontal = 0,
222
- horizontalCenter = 0,
223
- arrowPosition = {},
224
- translate = {
225
- left: 0,
226
- top: 0
227
- },
228
- anchorRect = null,
229
- aPosition = '',
230
- newDirectionObject = null;
231
-
190
+ left = 0,
191
+ vertical = 0,
192
+ verticalCenter = 0,
193
+ horizontal = 0,
194
+ horizontalCenter = 0,
195
+ arrowPosition = {},
196
+ translate = {
197
+ left: 0,
198
+ top: 0
199
+ },
200
+ anchorRect = null,
201
+ aPosition = '',
202
+ newDirectionObject = null;
232
203
  if (transformOrigin === 'center') {
233
204
  transformOrigin = {
234
205
  vertical: 'center',
235
206
  horizontal: 'center'
236
207
  };
237
208
  }
238
-
239
209
  if (element || anchor) {
240
210
  if (element) anchor = element;else if (anchor && !(anchor instanceof Element)) {
241
211
  var _anchor5, _anchor$current;
242
-
243
212
  anchor = ((_anchor5 = anchor) === null || _anchor5 === void 0 ? void 0 : _anchor5.element) || ((_anchor$current = anchor.current) === null || _anchor$current === void 0 ? void 0 : _anchor$current.element) || anchor.current;
244
213
  }
245
214
  if (!anchor) return;
246
-
247
215
  if (arrow && anchorOrigin.vertical !== anchorOrigin.horizontal && transformOrigin.vertical !== transformOrigin.horizontal) {
248
216
  aPosition = getArrowPosition(anchorOrigin, transformOrigin, translate);
249
217
  }
250
-
251
218
  anchorRect = anchor.getBoundingClientRect();
252
219
  vertical = anchorRect.y + calPosition(anchorOrigin.vertical, anchorRect)[0] - translate.top;
253
220
  verticalCenter = anchorRect.y + calPosition('center', anchorRect)[0];
254
221
  horizontal = anchorRect.x + calPosition(anchorOrigin.horizontal, anchorRect)[1] - translate.left;
255
222
  horizontalCenter = anchorRect.x + calPosition('center', anchorRect)[1];
256
- } // Calculate element positioning
257
-
223
+ }
258
224
 
225
+ // Calculate element positioning
259
226
  const containerWindow = {
260
227
  width: ((_window = window) === null || _window === void 0 ? void 0 : _window.innerWidth) || 0,
261
228
  height: ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.innerHeight) || 0
262
229
  };
263
230
  const popoverHeight = ref.current.offsetHeight;
264
231
  const popoverWidth = ref.current.offsetWidth;
265
-
266
232
  switch (transformOrigin.vertical) {
267
233
  case 'center':
268
234
  top = vertical - popoverHeight / 2;
269
235
  break;
270
-
271
236
  case 'bottom':
272
237
  top = vertical - popoverHeight;
273
238
  break;
274
-
275
239
  default:
276
240
  top = vertical;
277
241
  break;
278
242
  }
279
-
280
243
  switch (transformOrigin.horizontal) {
281
244
  case 'center':
282
245
  left = horizontal - popoverWidth / 2;
283
246
  break;
284
-
285
247
  case 'right':
286
248
  left = horizontal - popoverWidth;
287
249
  break;
288
-
289
250
  default:
290
251
  left = horizontal;
291
252
  break;
292
- } // Variables for check if needs shifting
293
-
253
+ }
294
254
 
255
+ // Variables for check if needs shifting
295
256
  const heightThreshold = containerWindow.height - marginThreshold;
296
257
  const widthThreshold = containerWindow.width - marginThreshold;
297
258
  const bottomOfAnchor = top + ((_anchor6 = anchor) === null || _anchor6 === void 0 ? void 0 : _anchor6.offsetHeight);
@@ -301,8 +262,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
301
262
  const rightOfAnchor = left + ((_anchor7 = anchor) === null || _anchor7 === void 0 ? void 0 : _anchor7.offsetWidth);
302
263
  const leftPos = ((_anchorRect3 = anchorRect) === null || _anchorRect3 === void 0 ? void 0 : _anchorRect3.right) + arrowSize;
303
264
  const horizontalCenterPos = horizontalCenter - popoverWidth / 2;
304
- const rightPos = ((_anchorRect4 = anchorRect) === null || _anchorRect4 === void 0 ? void 0 : _anchorRect4.left) - (popoverWidth + arrowSize); // Check if the vertical axis needs shifting
265
+ const rightPos = ((_anchorRect4 = anchorRect) === null || _anchorRect4 === void 0 ? void 0 : _anchorRect4.left) - (popoverWidth + arrowSize);
305
266
 
267
+ // Check if the vertical axis needs shifting
306
268
  if (top < marginThreshold) {
307
269
  if (topPos > heightThreshold) {
308
270
  top = verticalCenterPos;
@@ -323,9 +285,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
323
285
  newDirectionObject = getDirectionPopover('top');
324
286
  aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
325
287
  }
326
- } // Check if the horizontal axis needs shifting
327
-
288
+ }
328
289
 
290
+ // Check if the horizontal axis needs shifting
329
291
  if (left < marginThreshold) {
330
292
  if (leftPos > widthThreshold) {
331
293
  left = horizontalCenterPos;
@@ -346,58 +308,46 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
346
308
  newDirectionObject = getDirectionPopover('left');
347
309
  aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
348
310
  }
349
- } // Valid mean popover not at top-left, top-right, bottom-left, bottom-right
350
-
311
+ }
351
312
 
313
+ // Valid mean popover not at top-left, top-right, bottom-left, bottom-right
352
314
  const validVerticalArrow = left >= ((_anchorRect5 = anchorRect) === null || _anchorRect5 === void 0 ? void 0 : _anchorRect5.left) + ((_anchorRect6 = anchorRect) === null || _anchorRect6 === void 0 ? void 0 : _anchorRect6.width) / 2 - popoverWidth && left <= ((_anchorRect7 = anchorRect) === null || _anchorRect7 === void 0 ? void 0 : _anchorRect7.right) - ((_anchorRect8 = anchorRect) === null || _anchorRect8 === void 0 ? void 0 : _anchorRect8.width) / 2 + popoverWidth;
353
- const validHorizontalArrow = top >= ((_anchorRect9 = anchorRect) === null || _anchorRect9 === void 0 ? void 0 : _anchorRect9.top) + ((_anchorRect10 = anchorRect) === null || _anchorRect10 === void 0 ? void 0 : _anchorRect10.height) / 2 - popoverHeight && top <= ((_anchorRect11 = anchorRect) === null || _anchorRect11 === void 0 ? void 0 : _anchorRect11.bottom) - ((_anchorRect12 = anchorRect) === null || _anchorRect12 === void 0 ? void 0 : _anchorRect12.height) / 2; // Get arrow's position
315
+ const validHorizontalArrow = top >= ((_anchorRect9 = anchorRect) === null || _anchorRect9 === void 0 ? void 0 : _anchorRect9.top) + ((_anchorRect10 = anchorRect) === null || _anchorRect10 === void 0 ? void 0 : _anchorRect10.height) / 2 - popoverHeight && top <= ((_anchorRect11 = anchorRect) === null || _anchorRect11 === void 0 ? void 0 : _anchorRect11.bottom) - ((_anchorRect12 = anchorRect) === null || _anchorRect12 === void 0 ? void 0 : _anchorRect12.height) / 2;
354
316
 
317
+ // Get arrow's position
355
318
  if (arrow && translate) {
356
319
  switch (aPosition) {
357
320
  case 'top':
358
321
  if (validVerticalArrow) {
359
322
  var _anchorRect13, _anchorRect14;
360
-
361
323
  arrowPosition.left = ((_anchorRect13 = anchorRect) === null || _anchorRect13 === void 0 ? void 0 : _anchorRect13.width) / 2 + ((_anchorRect14 = anchorRect) === null || _anchorRect14 === void 0 ? void 0 : _anchorRect14.left) - arrowSize + 'px';
362
324
  arrowPosition.top = Math.round(top) - arrowSize + 'px';
363
325
  }
364
-
365
326
  break;
366
-
367
327
  case 'bottom':
368
328
  if (validVerticalArrow) {
369
329
  var _anchorRect15, _anchorRect16;
370
-
371
330
  arrowPosition.left = ((_anchorRect15 = anchorRect) === null || _anchorRect15 === void 0 ? void 0 : _anchorRect15.width) / 2 + ((_anchorRect16 = anchorRect) === null || _anchorRect16 === void 0 ? void 0 : _anchorRect16.left) - arrowSize + 'px';
372
331
  arrowPosition.top = Math.round(top) + popoverHeight + 'px';
373
332
  }
374
-
375
333
  break;
376
-
377
334
  case 'left':
378
335
  if (validHorizontalArrow) {
379
336
  var _anchorRect17, _anchorRect18;
380
-
381
337
  arrowPosition.top = ((_anchorRect17 = anchorRect) === null || _anchorRect17 === void 0 ? void 0 : _anchorRect17.height) / 2 + ((_anchorRect18 = anchorRect) === null || _anchorRect18 === void 0 ? void 0 : _anchorRect18.top) - arrowSize / 2 + 'px';
382
338
  arrowPosition.left = Math.round(left) - 1.5 * arrowSize + 'px';
383
339
  }
384
-
385
340
  break;
386
-
387
341
  case 'right':
388
342
  if (validHorizontalArrow) {
389
343
  var _anchorRect19, _anchorRect20;
390
-
391
344
  arrowPosition.top = ((_anchorRect19 = anchorRect) === null || _anchorRect19 === void 0 ? void 0 : _anchorRect19.height) / 2 + ((_anchorRect20 = anchorRect) === null || _anchorRect20 === void 0 ? void 0 : _anchorRect20.top) - arrowSize / 2 + 'px';
392
345
  arrowPosition.left = Math.round(left) + popoverWidth - arrowSize / 2 + 'px';
393
346
  }
394
-
395
347
  break;
396
-
397
348
  default:
398
349
  break;
399
350
  }
400
-
401
351
  if (arrowRef.current) {
402
352
  Object.assign(arrowRef.current.style, arrowPosition, {
403
353
  transform: translate.transform,
@@ -405,23 +355,19 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
405
355
  });
406
356
  }
407
357
  }
408
-
409
358
  if (top < marginThreshold) top = marginThreshold;
410
359
  if (left < marginThreshold) left = marginThreshold;
411
360
  const isVerticalOverFlow = left + popoverWidth > containerWindow.width;
412
361
  ref.current.style.maxHeight = `calc(100% - ${spacing(8) + top}px)`;
413
362
  ref.current.style.top = `${Math.round(top)}px`;
414
-
415
363
  if (isVerticalOverFlow) {
416
364
  ref.current.style.left = 0;
417
365
  ref.current.style.margin = 'auto';
418
366
  } else ref.current.style.left = `${Math.round(left)}px`;
419
-
420
367
  ref.current.style.transformOrigin = `${((_newDirectionObject = newDirectionObject) === null || _newDirectionObject === void 0 ? void 0 : (_newDirectionObject$t = _newDirectionObject.transformOrigin) === null || _newDirectionObject$t === void 0 ? void 0 : _newDirectionObject$t.horizontal) || ((_transformOrigin = transformOrigin) === null || _transformOrigin === void 0 ? void 0 : _transformOrigin.horizontal) || 'left'} ${((_newDirectionObject2 = newDirectionObject) === null || _newDirectionObject2 === void 0 ? void 0 : (_newDirectionObject2$ = _newDirectionObject2.transformOrigin) === null || _newDirectionObject2$ === void 0 ? void 0 : _newDirectionObject2$.vertical) || ((_transformOrigin2 = transformOrigin) === null || _transformOrigin2 === void 0 ? void 0 : _transformOrigin2.vertical) || 'top'}`;
421
368
  ref.current.style.opacity = 1;
422
369
  cb === null || cb === void 0 ? void 0 : cb();
423
370
  };
424
-
425
371
  const handleEventTrigger = e => {
426
372
  if (!openState) {
427
373
  onOpenPopover();
@@ -429,23 +375,19 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
429
375
  onClickOutside(e);
430
376
  }
431
377
  };
432
-
433
378
  useEffect(() => {
434
379
  return () => {
435
380
  if (pressESCToClose) {
436
381
  document.removeEventListener('keydown', pressESCHandler);
437
382
  }
438
-
439
383
  document.removeEventListener('click', onClickOutside);
440
384
  window.removeEventListener('resize', updatePositionPopover);
441
385
  };
442
386
  }, []);
443
387
  useEffect(() => {
444
388
  var _anchor8, _anchor9;
445
-
446
389
  const anchorEl = ((_anchor8 = anchor) === null || _anchor8 === void 0 ? void 0 : _anchor8.element) || ((_anchor9 = anchor) === null || _anchor9 === void 0 ? void 0 : _anchor9.current) || anchor;
447
390
  const eventArr = eventMap.get(trigger) || [];
448
-
449
391
  if (anchorEl && open === undefined && (eventArr === null || eventArr === void 0 ? void 0 : eventArr.length) > 0) {
450
392
  eventArr.forEach(evt => anchorEl.addEventListener(evt, handleEventTrigger, false));
451
393
  return () => {
@@ -459,22 +401,22 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
459
401
  useEffect(() => {
460
402
  if (openState && ref.current) {
461
403
  // Position's anchor
462
- updatePositionPopover(); // Allow press ESC to close popup
404
+ updatePositionPopover();
463
405
 
406
+ // Allow press ESC to close popup
464
407
  if (pressESCToClose) {
465
408
  document.addEventListener('keydown', pressESCHandler);
466
- } // Click out popover to close popover
467
-
468
-
469
- document.addEventListener('click', onClickOutside); // Update position popover on resize
409
+ }
410
+ // Click out popover to close popover
411
+ document.addEventListener('click', onClickOutside);
470
412
 
413
+ // Update position popover on resize
471
414
  window.addEventListener('resize', updatePositionPopover);
472
415
  if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
473
416
  return () => {
474
417
  if (pressESCToClose) {
475
418
  document.removeEventListener('keydown', pressESCHandler);
476
419
  }
477
-
478
420
  document.removeEventListener('click', onClickOutside);
479
421
  window.removeEventListener('resize', updatePositionPopover);
480
422
  if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
@@ -493,30 +435,28 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
493
435
  const currentRef = ref.current || {};
494
436
  currentRef.element = ref.current;
495
437
  const _instance = {
496
- show: el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover(),
438
+ show: el => {
439
+ if (el) setElement(el);
440
+ !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
441
+ },
497
442
  close: () => onClosePopover(),
498
443
  setPosition: el => updatePositionPopover(el),
499
444
  ...action
500
445
  }; // methods
501
-
502
446
  _instance.__proto__ = {
503
447
  hide: () => onClosePopover()
504
448
  }; // hidden methods
505
-
506
449
  currentRef.instance = _instance;
507
-
508
- currentRef.show = el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
509
-
450
+ currentRef.show = el => {
451
+ if (el) setElement(el);
452
+ !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
453
+ };
510
454
  currentRef.close = onClosePopover;
511
-
512
455
  currentRef.setPosition = el => updatePositionPopover(el);
513
-
514
456
  return currentRef;
515
457
  });
516
-
517
458
  const renderAnchor = () => {
518
459
  var _anchor10, _anchor11, _anchor11$props;
519
-
520
460
  if (!((_anchor10 = anchor) !== null && _anchor10 !== void 0 && _anchor10.type)) return null;
521
461
  const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
522
462
  ref: ref => {
@@ -529,7 +469,6 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
529
469
  });
530
470
  return AnchorTag;
531
471
  };
532
-
533
472
  const PopoverView = useMemo(() => {
534
473
  if (openState) {
535
474
  const node = jsx("div", {
@@ -546,19 +485,16 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
546
485
  }));
547
486
  return /*#__PURE__*/createPortal(node, document.body);
548
487
  }
549
-
550
488
  return null;
551
489
  }, [openState, arrow, bgColor, children, className, clickOutsideToClose, fullScreen, height, style, width, zIndex]);
552
490
  return jsx(React.Fragment, null, renderAnchor(), PopoverView);
553
491
  }));
554
-
555
492
  const PortalPopoverCSS = (zIndex, fullScreen) => css`
556
493
  ${positionFixed};
557
494
  z-index: ${zIndex};
558
495
  pointer-events: ${fullScreen ? 'initial' : 'none'};
559
496
  inset: 0;
560
497
  `;
561
-
562
498
  const PopoverContainerCSS = (bgColor, width, height) => css`
563
499
  ${flexCol};
564
500
  ${positionRelative};
@@ -577,7 +513,6 @@ const PopoverContainerCSS = (bgColor, width, height) => css`
577
513
  background-color: ${bgColor};
578
514
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
579
515
  `;
580
-
581
516
  const PopoverArrowCSS = bgColor => css`
582
517
  ${displayBlock};
583
518
  ${positionAbsolute};
@@ -586,7 +521,6 @@ const PopoverArrowCSS = bgColor => css`
586
521
  border-right: 6px solid transparent;
587
522
  border-bottom: 6px solid ${bgColor};
588
523
  `;
589
-
590
524
  Popover.defaultProps = {
591
525
  anchorOrigin: {
592
526
  vertical: 'bottom',
@@ -612,13 +546,10 @@ Popover.defaultProps = {
612
546
  Popover.propTypes = {
613
547
  /** If `true`, the component is shown. */
614
548
  open: PropTypes.bool,
615
-
616
549
  /** Trigger mode of the component. Will not work when use with `open` prop. */
617
550
  trigger: PropTypes.oneOf(['click', 'hover', 'focus']),
618
-
619
551
  /** An HTML element, or a function that returns one. It's used to set the position of the popover. */
620
552
  anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node, ref]),
621
-
622
553
  /**
623
554
  * This is the point on the anchor where the popover's anchor will attach to.
624
555
  * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
@@ -627,22 +558,16 @@ Popover.propTypes = {
627
558
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
628
559
  vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
629
560
  }),
630
-
631
561
  /** If `true`, arrow is shown. */
632
562
  arrow: PropTypes.bool,
633
-
634
563
  /** Background color of the component. */
635
564
  bgColor: PropTypes.string,
636
-
637
565
  /** The content of the component. */
638
566
  children: PropTypes.node,
639
-
640
567
  /** Class for component. */
641
568
  className: PropTypes.string,
642
-
643
569
  /** If `true`, click outside will close component. */
644
570
  clickOutsideToClose: PropTypes.bool,
645
-
646
571
  /**
647
572
  * Direction when Popover shown.
648
573
  * Note: This prop will overwrite anchorOrigin & transformOrigin.
@@ -653,22 +578,16 @@ Popover.propTypes = {
653
578
  * * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
654
579
  */
655
580
  direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
656
-
657
581
  /** Height of the component. */
658
582
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
659
-
660
583
  /** Specifies how close to the edge of the window the popover can appear. */
661
584
  marginThreshold: PropTypes.number,
662
-
663
585
  /** Callback fired when the component requests to be closed. */
664
586
  onClose: PropTypes.func,
665
-
666
587
  /** If `true`, hitting escape will close component. */
667
588
  pressESCToClose: PropTypes.bool,
668
-
669
589
  /** Style inline of component. */
670
590
  style: PropTypes.object,
671
-
672
591
  /**
673
592
  * This is the point on the popover which will attach to the anchor's origin.
674
593
  * Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
@@ -677,13 +596,10 @@ Popover.propTypes = {
677
596
  horizontal: PropTypes.oneOf(['center', 'left', 'right']),
678
597
  vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
679
598
  }),
680
-
681
599
  /** Width of the component. */
682
600
  width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
683
-
684
601
  /** Config z-index of the component. */
685
602
  zIndex: PropTypes.number,
686
-
687
603
  /**
688
604
  * ref methods (ref.current.instance.*method*)
689
605
  *
@@ -1,7 +1,5 @@
1
1
  /* eslint-disable react/prop-types */
2
-
3
2
  /** @jsxRuntime classic */
4
-
5
3
  /** @jsx jsx */
6
4
  import { memo, useEffect, useRef } from 'react';
7
5
  import PropTypes from 'prop-types';
@@ -11,7 +9,6 @@ import { Button } from '../';
11
9
  import { renderHTML } from '../../utils';
12
10
  import { Warning } from '../../icons';
13
11
  import { typography } from '../../styles/typography';
14
-
15
12
  const DangerPopup = ({
16
13
  open,
17
14
  warningText,
@@ -78,18 +75,14 @@ const DangerPopup = ({
78
75
  }
79
76
  }
80
77
  `;
81
-
82
78
  const onConfirmHandler = () => {
83
79
  if (onConfirm) onConfirm();
84
80
  };
85
-
86
81
  const onCancelHandler = () => {
87
82
  if (onCancel) onCancel();
88
83
  };
89
-
90
84
  useEffect(() => {
91
85
  let timer = null;
92
-
93
86
  if (open) {
94
87
  setTimeout(() => {
95
88
  if (popupActionRef.current) {
@@ -108,14 +101,12 @@ const DangerPopup = ({
108
101
  clearInterval(timer);
109
102
  return;
110
103
  }
111
-
112
104
  time--;
113
105
  childNode.textContent = `${confirmText} (${time}s)`;
114
106
  }, 1000);
115
107
  }
116
108
  }, 0);
117
109
  }
118
-
119
110
  return () => {
120
111
  if (open && popupActionRef.current) {
121
112
  const button = popupActionRef.current.querySelector('button.button-confirm');
@@ -127,7 +118,6 @@ const DangerPopup = ({
127
118
  childNode.textContent = confirmText;
128
119
  }, 300);
129
120
  }
130
-
131
121
  if (timer) clearInterval(timer);
132
122
  };
133
123
  }, [open]);
@@ -165,7 +155,6 @@ const DangerPopup = ({
165
155
  onClick: onCancelHandler
166
156
  }, cancelText))));
167
157
  };
168
-
169
158
  DangerPopup.defaultProps = {
170
159
  warningText: 'CẢNH BÁO NGUY HIỂM',
171
160
  warningIconColor: '#E7000F',
@@ -179,28 +168,20 @@ DangerPopup.defaultProps = {
179
168
  DangerPopup.propTypes = {
180
169
  /** the title of Popup */
181
170
  warningText: PropTypes.string,
182
-
183
171
  /** the title of Popup */
184
172
  warningIconColor: PropTypes.string,
185
-
186
173
  /** the content to description for warning title */
187
174
  warningDescription: PropTypes.string,
188
-
189
175
  /** the content to display in confirm button */
190
176
  confirmText: PropTypes.string,
191
-
192
177
  /** the content to display in cancel button */
193
178
  cancelText: PropTypes.string,
194
-
195
179
  /** the color of button when timing */
196
180
  buttonTimingColor: PropTypes.string,
197
-
198
181
  /** the period to prevent click confirm button */
199
182
  timing: PropTypes.number,
200
-
201
183
  /** the function run when click confirm button */
202
184
  onConfirm: PropTypes.func,
203
-
204
185
  /** the function run when click cancel button */
205
186
  onCancel: PropTypes.func
206
187
  };