diginet-core-ui 1.3.73 → 1.3.74

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 (58) hide show
  1. package/assets/images/menu/dhr/MHRP29N0026.svg +13 -0
  2. package/assets/images/menu/dhr/MHRP29N0027.svg +14 -0
  3. package/assets/images/menu/dhr/MHRP29N0028.svg +15 -0
  4. package/components/accordion/details.js +19 -10
  5. package/components/accordion/group.js +15 -6
  6. package/components/accordion/index.js +20 -11
  7. package/components/accordion/summary.js +18 -9
  8. package/components/avatar/index.js +1 -1
  9. package/components/badge/index.js +17 -9
  10. package/components/button/icon.js +33 -25
  11. package/components/button/index.js +25 -17
  12. package/components/card/body.js +12 -4
  13. package/components/card/extra.js +12 -4
  14. package/components/card/footer.js +12 -4
  15. package/components/card/header.js +12 -4
  16. package/components/card/index.js +12 -4
  17. package/components/chip/index.js +6 -6
  18. package/components/form-control/attachment/index.js +197 -192
  19. package/components/form-control/date-picker/index.js +4 -2
  20. package/components/form-control/date-range-picker/index.js +15 -8
  21. package/components/form-control/dropdown/index.js +34 -13
  22. package/components/form-control/input-base/index.js +505 -483
  23. package/components/form-control/label/index.js +27 -21
  24. package/components/form-control/text-input/index.js +4 -1
  25. package/components/grid/Col.js +8 -7
  26. package/components/grid/Container.js +16 -15
  27. package/components/grid/Row.js +16 -15
  28. package/components/grid/index.js +17 -36
  29. package/components/image/index.js +164 -0
  30. package/components/index.js +3 -1
  31. package/components/modal/body.js +12 -9
  32. package/components/modal/footer.js +22 -11
  33. package/components/modal/header.js +25 -13
  34. package/components/modal/index.js +32 -30
  35. package/components/modal/modal.js +29 -25
  36. package/components/others/option-wrapper/index.js +5 -18
  37. package/components/paging/page-info.js +45 -33
  38. package/components/paging/page-selector2.js +45 -33
  39. package/components/popover/body.js +14 -6
  40. package/components/popover/footer.js +15 -6
  41. package/components/popover/header.js +17 -7
  42. package/components/popover/index.js +242 -109
  43. package/components/status/index.js +12 -4
  44. package/components/tab/tab-container.js +29 -27
  45. package/components/tab/tab-header.js +33 -28
  46. package/components/tab/tab-panel.js +31 -27
  47. package/components/tab/tab.js +45 -35
  48. package/components/tree-view/index.js +108 -73
  49. package/components/typography/index.js +36 -25
  50. package/icons/basic.js +248 -0
  51. package/icons/effect.js +44 -36
  52. package/package.json +1 -1
  53. package/readme.md +40 -0
  54. package/styles/general.js +23 -0
  55. package/theme/index.js +1 -1
  56. package/theme/set-theme.js +2 -1
  57. package/utils/index.js +13 -10
  58. package/utils/useMediaQuery.js +4 -2
@@ -6,8 +6,9 @@ import { createPortal } from 'react-dom';
6
6
  import PropTypes from 'prop-types';
7
7
  import { jsx, css } from '@emotion/core';
8
8
  import OptionWrapper from '../others/option-wrapper';
9
- import { borderRadius4px, displayBlock, flexCol, flexRow, overflowAuto, parseWidthHeight, positionAbsolute, positionRelative } from '../../styles/general';
9
+ import { borderRadius4px, displayBlock, flexCol, justifyBetween, overflowAuto, parseWidthHeight, positionAbsolute, positionFixed, positionRelative } from '../../styles/general';
10
10
  import theme from '../../theme/settings';
11
+ import { classNames, isMobile, refType as ref } from '../../utils';
11
12
  const {
12
13
  colors: {
13
14
  system: {
@@ -17,6 +18,7 @@ const {
17
18
  typography: {
18
19
  paragraph1
19
20
  },
21
+ spacing,
20
22
  zIndex: zIndexCORE
21
23
  } = theme;
22
24
  const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
@@ -65,6 +67,18 @@ const calPosition = (position, originBounding) => {
65
67
 
66
68
  const getDirectionPopover = direction => {
67
69
  switch (direction) {
70
+ case 'center':
71
+ return {
72
+ anchorOrigin: {
73
+ vertical: 'center',
74
+ horizontal: 'center'
75
+ },
76
+ transformOrigin: {
77
+ vertical: 'center',
78
+ horizontal: 'center'
79
+ }
80
+ };
81
+
68
82
  case 'top':
69
83
  return {
70
84
  anchorOrigin: {
@@ -116,15 +130,18 @@ const getDirectionPopover = direction => {
116
130
  };
117
131
 
118
132
  const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
133
+ action = {},
119
134
  anchor,
120
135
  anchorOrigin,
121
136
  arrow,
122
137
  bgColor,
123
138
  children,
139
+ className,
124
140
  clickOutsideToClose,
125
141
  direction,
126
142
  fullScreen,
127
143
  height,
144
+ marginThreshold,
128
145
  onClose,
129
146
  open,
130
147
  pressESCToClose,
@@ -134,24 +151,30 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
134
151
  width,
135
152
  zIndex
136
153
  }, reference) => {
154
+ if (isMobile.any() && trigger === 'hover') trigger = 'click';
137
155
  const ref = useRef(null);
156
+ const arrowRef = useRef(null);
138
157
  const [openState, setOpenState] = useState(open);
139
158
  const [element, setElement] = useState(null);
140
159
 
141
160
  const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
142
161
 
143
- const _PopoverContainerCSS = PopoverContainerCSS(width, height);
144
-
145
- const _PopoverRootCSS = PopoverRootCSS(bgColor);
162
+ const _PopoverContainerCSS = PopoverContainerCSS(bgColor, width, height);
146
163
 
147
164
  const _PopoverArrowCSS = PopoverArrowCSS(bgColor);
148
165
 
166
+ const arrowSize = arrow ? 6 : 0;
167
+
149
168
  if (direction) {
150
169
  const directionObject = getDirectionPopover(direction);
151
170
  anchorOrigin = directionObject.anchorOrigin;
152
171
  transformOrigin = directionObject.transformOrigin;
153
172
  }
154
173
 
174
+ const onOpenPopover = () => {
175
+ if (!openState) setOpenState(true);
176
+ };
177
+
155
178
  const onClosePopover = () => {
156
179
  if (openState) {
157
180
  if (ref.current) ref.current.style.opacity = 0;
@@ -167,21 +190,23 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
167
190
  };
168
191
 
169
192
  const onClickOutside = event => {
170
- var _anchor2, _anchor2$current, _anchor3, _ref$current, _ref$current2, _ref$current2$parentN;
193
+ var _anchor2, _anchor3, _anchor3$current, _anchor4, _ref$current, _ref$current2, _ref$current2$parentN;
171
194
 
172
195
  if (!ref.current) {
173
196
  document.removeEventListener('click', onClickOutside);
174
197
  return;
175
198
  }
176
199
 
177
- const _anchor = ((_anchor2 = anchor) === null || _anchor2 === void 0 ? void 0 : (_anchor2$current = _anchor2.current) === null || _anchor2$current === void 0 ? void 0 : _anchor2$current.element) || ((_anchor3 = anchor) === null || _anchor3 === void 0 ? void 0 : _anchor3.current) || anchor;
200
+ 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;
178
201
 
179
- if (clickOutsideToClose && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(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.target)) && openState) {
202
+ 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) {
180
203
  onClosePopover();
181
204
  }
182
205
  };
183
206
 
184
- const updatePositionPopover = (el = null) => {
207
+ const updatePositionPopover = (el = null, cb) => {
208
+ 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
+
185
210
  setElement(el instanceof Element ? el : null);
186
211
 
187
212
  if (!ref.current) {
@@ -192,14 +217,17 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
192
217
  let top = 0,
193
218
  left = 0,
194
219
  vertical = 0,
220
+ verticalCenter = 0,
195
221
  horizontal = 0,
222
+ horizontalCenter = 0,
196
223
  arrowPosition = {},
197
224
  translate = {
198
225
  left: 0,
199
226
  top: 0
200
227
  },
201
- anchorBounding = null,
202
- aPosition = '';
228
+ anchorRect = null,
229
+ aPosition = '',
230
+ newDirectionObject = null;
203
231
 
204
232
  if (transformOrigin === 'center') {
205
233
  transformOrigin = {
@@ -210,106 +238,194 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
210
238
 
211
239
  if (element || anchor) {
212
240
  if (element) anchor = element;else if (anchor && !(anchor instanceof Element)) {
213
- var _anchor4, _anchor$current;
241
+ var _anchor5, _anchor$current;
214
242
 
215
- anchor = ((_anchor4 = anchor) === null || _anchor4 === void 0 ? void 0 : _anchor4.element) || ((_anchor$current = anchor.current) === null || _anchor$current === void 0 ? void 0 : _anchor$current.element) || anchor.current;
216
- }
217
-
218
- if (anchorOrigin === 'center') {
219
- anchorOrigin = {
220
- vertical: 'center',
221
- horizontal: 'center'
222
- };
243
+ 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;
223
244
  }
224
245
 
225
246
  if (arrow && anchorOrigin.vertical !== anchorOrigin.horizontal && transformOrigin.vertical !== transformOrigin.horizontal) {
226
247
  aPosition = getArrowPosition(anchorOrigin, transformOrigin, translate);
227
248
  }
228
249
 
229
- anchorBounding = anchor.getBoundingClientRect();
230
- vertical = anchorBounding.y + calPosition(anchorOrigin.vertical, anchorBounding)[0] - translate.top;
231
- horizontal = anchorBounding.x + calPosition(anchorOrigin.horizontal, anchorBounding)[1] - translate.left;
232
- } // Position's transform
250
+ anchorRect = anchor.getBoundingClientRect();
251
+ vertical = anchorRect.y + calPosition(anchorOrigin.vertical, anchorRect)[0] - translate.top;
252
+ verticalCenter = anchorRect.y + calPosition('center', anchorRect)[0];
253
+ horizontal = anchorRect.x + calPosition(anchorOrigin.horizontal, anchorRect)[1] - translate.left;
254
+ horizontalCenter = anchorRect.x + calPosition('center', anchorRect)[1];
255
+ } // Calculate element positioning
233
256
 
234
257
 
235
- const offsetHeight = ref.current.offsetHeight;
236
- const offsetWidth = ref.current.offsetWidth;
258
+ const containerWindow = {
259
+ width: ((_window = window) === null || _window === void 0 ? void 0 : _window.innerWidth) || 0,
260
+ height: ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.innerHeight) || 0
261
+ };
262
+ const popoverHeight = ref.current.offsetHeight;
263
+ const popoverWidth = ref.current.offsetWidth;
237
264
 
238
265
  switch (transformOrigin.vertical) {
239
266
  case 'center':
240
- top = vertical - offsetHeight / 2;
267
+ top = vertical - popoverHeight / 2;
241
268
  break;
242
269
 
243
270
  case 'bottom':
244
- top = vertical - offsetHeight;
271
+ top = vertical - popoverHeight;
245
272
  break;
246
273
 
247
274
  default:
248
275
  top = vertical;
276
+ break;
249
277
  }
250
278
 
251
279
  switch (transformOrigin.horizontal) {
252
280
  case 'center':
253
- left = horizontal - offsetWidth / 2;
281
+ left = horizontal - popoverWidth / 2;
254
282
  break;
255
283
 
256
284
  case 'right':
257
- left = horizontal - offsetWidth;
285
+ left = horizontal - popoverWidth;
258
286
  break;
259
287
 
260
288
  default:
261
289
  left = horizontal;
262
- } // Reset position if the element overflow window screen size
290
+ break;
291
+ } // Variables for check if needs shifting
292
+
293
+
294
+ const heightThreshold = containerWindow.height - marginThreshold;
295
+ const widthThreshold = containerWindow.width - marginThreshold;
296
+ const bottomOfAnchor = top + ((_anchor6 = anchor) === null || _anchor6 === void 0 ? void 0 : _anchor6.offsetHeight);
297
+ const topPos = ((_anchorRect = anchorRect) === null || _anchorRect === void 0 ? void 0 : _anchorRect.bottom) + arrowSize;
298
+ const verticalCenterPos = verticalCenter - popoverHeight / 2;
299
+ const bottomPos = ((_anchorRect2 = anchorRect) === null || _anchorRect2 === void 0 ? void 0 : _anchorRect2.top) - (popoverHeight + arrowSize);
300
+ const rightOfAnchor = left + ((_anchor7 = anchor) === null || _anchor7 === void 0 ? void 0 : _anchor7.offsetWidth);
301
+ const leftPos = ((_anchorRect3 = anchorRect) === null || _anchorRect3 === void 0 ? void 0 : _anchorRect3.right) + arrowSize;
302
+ const horizontalCenterPos = horizontalCenter - popoverWidth / 2;
303
+ const rightPos = ((_anchorRect4 = anchorRect) === null || _anchorRect4 === void 0 ? void 0 : _anchorRect4.left) - (popoverWidth + arrowSize); // Check if the vertical axis needs shifting
304
+
305
+ if (top < marginThreshold) {
306
+ if (topPos > heightThreshold) {
307
+ top = verticalCenterPos;
308
+ newDirectionObject = getDirectionPopover('center');
309
+ aPosition = '';
310
+ } else {
311
+ top = topPos;
312
+ newDirectionObject = getDirectionPopover('bottom');
313
+ aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
314
+ }
315
+ } else if (top + popoverHeight > containerWindow.height) {
316
+ if (bottomPos < bottomOfAnchor && bottomPos < marginThreshold) {
317
+ top = verticalCenterPos;
318
+ newDirectionObject = getDirectionPopover('center');
319
+ aPosition = '';
320
+ } else {
321
+ top = bottomPos;
322
+ newDirectionObject = getDirectionPopover('top');
323
+ aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
324
+ }
325
+ } // Check if the horizontal axis needs shifting
263
326
 
264
327
 
265
- if (top < 0) {
266
- top = 0;
267
- } else if (top + offsetHeight > window.innerHeight) {
268
- top = window.innerHeight - offsetHeight;
269
- }
328
+ if (left < marginThreshold) {
329
+ if (leftPos > widthThreshold) {
330
+ left = horizontalCenterPos;
331
+ newDirectionObject = getDirectionPopover('center');
332
+ aPosition = '';
333
+ } else {
334
+ left = leftPos;
335
+ newDirectionObject = getDirectionPopover('right');
336
+ aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
337
+ }
338
+ } else if (left + popoverWidth > containerWindow.width) {
339
+ if (rightPos < rightOfAnchor && rightPos < marginThreshold) {
340
+ left = horizontalCenterPos;
341
+ newDirectionObject = getDirectionPopover('center');
342
+ aPosition = '';
343
+ } else {
344
+ left = rightPos;
345
+ newDirectionObject = getDirectionPopover('left');
346
+ aPosition = getArrowPosition(newDirectionObject.anchorOrigin, newDirectionObject.transformOrigin, translate);
347
+ }
348
+ } // Valid mean popover not at top-left, top-right, bottom-left, bottom-right
270
349
 
271
- if (left < 0) {
272
- left = 0;
273
- } else if (left + offsetWidth > window.innerWidth) {
274
- left = window.innerWidth - offsetWidth;
275
- } // Get arrow's position
276
350
 
351
+ 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;
352
+ 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
277
353
 
278
354
  if (arrow && translate) {
279
355
  switch (aPosition) {
280
356
  case 'top':
357
+ if (validVerticalArrow) {
358
+ var _anchorRect13, _anchorRect14;
359
+
360
+ 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';
361
+ arrowPosition.top = Math.round(top) - arrowSize + 'px';
362
+ }
363
+
364
+ break;
365
+
281
366
  case 'bottom':
282
- arrowPosition.left = anchorBounding.width / 2 + anchorBounding.left - left - 6 + 'px';
283
- arrowPosition[aPosition] = `-6px`;
367
+ if (validVerticalArrow) {
368
+ var _anchorRect15, _anchorRect16;
369
+
370
+ 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';
371
+ arrowPosition.top = Math.round(top) + popoverHeight + 'px';
372
+ }
373
+
284
374
  break;
285
375
 
286
376
  case 'left':
377
+ if (validHorizontalArrow) {
378
+ var _anchorRect17, _anchorRect18;
379
+
380
+ 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';
381
+ arrowPosition.left = Math.round(left) - 1.5 * arrowSize + 'px';
382
+ }
383
+
384
+ break;
385
+
287
386
  case 'right':
288
- arrowPosition.top = Math.max(4, anchorBounding.height / 2 + anchorBounding.top - top - 2 * Math.sqrt(2)) + 'px';
289
- arrowPosition[aPosition] = `-9px`;
387
+ if (validHorizontalArrow) {
388
+ var _anchorRect19, _anchorRect20;
389
+
390
+ 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';
391
+ arrowPosition.left = Math.round(left) + popoverWidth - arrowSize / 2 + 'px';
392
+ }
393
+
290
394
  break;
291
395
 
292
396
  default:
293
397
  break;
294
398
  }
295
399
 
296
- Object.assign(ref.current.querySelector(`.css-${_PopoverArrowCSS.name}`).style, arrowPosition, {
297
- transform: translate.transform
298
- });
400
+ if (arrowRef.current) {
401
+ Object.assign(arrowRef.current.style, arrowPosition, {
402
+ transform: translate.transform,
403
+ display: newDirectionObject === 'center' || !(arrowPosition !== null && arrowPosition !== void 0 && arrowPosition.top) ? 'none' : 'block'
404
+ });
405
+ }
299
406
  }
300
407
 
301
- ref.current.style.top = top + 'px';
302
- ref.current.style.left = left + 'px';
303
- ref.current.style.transformOrigin = `${transformOrigin.horizontal || 'left'} ${transformOrigin.vertical || 'top'}`;
408
+ if (top < marginThreshold) top = marginThreshold;
409
+ if (left < marginThreshold) left = marginThreshold;
410
+ const isVerticalOverFlow = left + popoverWidth > containerWindow.width;
411
+ ref.current.style.maxHeight = `calc(100% - ${spacing(8) + top}px)`;
412
+ ref.current.style.top = `${Math.round(top)}px`;
413
+
414
+ if (isVerticalOverFlow) {
415
+ ref.current.style.left = 0;
416
+ ref.current.style.margin = 'auto';
417
+ } else ref.current.style.left = `${Math.round(left)}px`;
418
+
419
+ 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'}`;
304
420
  ref.current.style.opacity = 1;
421
+ cb === null || cb === void 0 ? void 0 : cb();
305
422
  };
306
423
 
307
- const handleEventTrigger = () => {
424
+ const handleEventTrigger = e => {
308
425
  if (!openState) {
309
- setOpenState(true);
426
+ onOpenPopover();
310
427
  } else {
311
- onClose && onClose();
312
- setOpenState(false);
428
+ onClickOutside(e);
313
429
  }
314
430
  };
315
431
 
@@ -324,9 +440,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
324
440
  };
325
441
  }, []);
326
442
  useEffect(() => {
327
- var _anchor5, _anchor6;
443
+ var _anchor8, _anchor9;
328
444
 
329
- const anchorEl = ((_anchor5 = anchor) === null || _anchor5 === void 0 ? void 0 : _anchor5.element) || ((_anchor6 = anchor) === null || _anchor6 === void 0 ? void 0 : _anchor6.current) || anchor;
445
+ const anchorEl = ((_anchor8 = anchor) === null || _anchor8 === void 0 ? void 0 : _anchor8.element) || ((_anchor9 = anchor) === null || _anchor9 === void 0 ? void 0 : _anchor9.current) || anchor;
330
446
  const eventArr = eventMap.get(trigger) || [];
331
447
 
332
448
  if (anchorEl && open === undefined && (eventArr === null || eventArr === void 0 ? void 0 : eventArr.length) > 0) {
@@ -352,6 +468,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
352
468
  document.addEventListener('click', onClickOutside); // Update position popover on resize
353
469
 
354
470
  window.addEventListener('resize', updatePositionPopover);
471
+ if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
355
472
  return () => {
356
473
  if (pressESCToClose) {
357
474
  document.removeEventListener('keydown', pressESCHandler);
@@ -359,6 +476,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
359
476
 
360
477
  document.removeEventListener('click', onClickOutside);
361
478
  window.removeEventListener('resize', updatePositionPopover);
479
+ if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
362
480
  };
363
481
  } else if (!openState) {
364
482
  document.documentElement.style.overflow = 'auto';
@@ -367,28 +485,44 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
367
485
  useEffect(() => {
368
486
  clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
369
487
  }, [clickOutsideToClose]);
370
- useImperativeHandle(reference, () => ({
371
- element: ref.current,
372
- instance: {
373
- show: () => setOpenState(true),
488
+ useEffect(() => {
489
+ updatePositionPopover();
490
+ }, [children]);
491
+ useImperativeHandle(reference, () => {
492
+ const currentRef = ref.current || {};
493
+ currentRef.element = ref.current;
494
+ const _instance = {
495
+ show: el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover(),
374
496
  close: () => onClosePopover(),
375
- setPosition: el => updatePositionPopover(el)
376
- },
377
- show: () => setOpenState(true),
378
- close: () => onClosePopover(),
379
- setPosition: el => updatePositionPopover(el)
380
- }));
497
+ setPosition: el => updatePositionPopover(el),
498
+ ...action
499
+ }; // methods
500
+
501
+ _instance.__proto__ = {
502
+ hide: () => onClosePopover()
503
+ }; // hidden methods
504
+
505
+ currentRef.instance = _instance;
506
+
507
+ currentRef.show = el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
508
+
509
+ currentRef.close = onClosePopover;
510
+
511
+ currentRef.setPosition = el => updatePositionPopover(el);
512
+
513
+ return currentRef;
514
+ });
381
515
 
382
516
  const renderAnchor = () => {
383
- var _anchor7;
517
+ var _anchor10;
384
518
 
385
- if (!((_anchor7 = anchor) !== null && _anchor7 !== void 0 && _anchor7.type)) return null;
519
+ if (!((_anchor10 = anchor) !== null && _anchor10 !== void 0 && _anchor10.type)) return null;
386
520
  const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
387
- // onClick: () => {
388
- // setOpenState(true);
389
- // },
390
521
  ref: ref => {
391
522
  anchor = ref;
523
+ },
524
+ style: {
525
+ cursor: 'pointer'
392
526
  }
393
527
  });
394
528
  return AnchorTag;
@@ -402,50 +536,43 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
402
536
  }, jsx("div", {
403
537
  css: _PopoverContainerCSS,
404
538
  ref: ref,
405
- className: 'DGN-UI-Popover-Container'
406
- }, jsx("div", {
407
- css: _PopoverRootCSS,
408
539
  style: style,
409
- className: 'DGN-UI-Popover-Root'
540
+ className: classNames('DGN-UI-Popover-Container', className)
410
541
  }, children), arrow && jsx("span", {
542
+ ref: arrowRef,
411
543
  css: _PopoverArrowCSS
412
- })));
544
+ }));
413
545
  return /*#__PURE__*/createPortal(node, document.body);
414
546
  }
415
547
 
416
548
  return null;
417
- }, [openState, zIndex, fullScreen, style, arrow, children, width, height, bgColor, clickOutsideToClose]);
549
+ }, [openState, arrow, bgColor, children, className, clickOutsideToClose, fullScreen, height, style, width, zIndex]);
418
550
  return jsx(React.Fragment, null, renderAnchor(), PopoverView);
419
551
  }));
420
552
 
421
553
  const PortalPopoverCSS = (zIndex, fullScreen) => css`
422
- ${positionAbsolute};
554
+ ${positionFixed};
423
555
  z-index: ${zIndex};
424
556
  pointer-events: ${fullScreen ? 'initial' : 'none'};
425
557
  inset: 0;
426
558
  `;
427
559
 
428
- const PopoverContainerCSS = (width, height) => css`
429
- ${flexRow};
430
- ${positionAbsolute};
431
- ${parseWidthHeight(width, height)};
432
- max-width: 100%;
433
- max-height: 100%;
434
- z-index: ${zIndexCORE()};
435
- transition: opacity 0.3s ease;
436
- pointer-events: initial;
437
- opacity: 0;
438
- `;
439
-
440
- const PopoverRootCSS = bgColor => css`
560
+ const PopoverContainerCSS = (bgColor, width, height) => css`
441
561
  ${flexCol};
442
562
  ${positionRelative};
563
+ ${justifyBetween};
443
564
  ${overflowAuto};
444
565
  ${borderRadius4px};
445
566
  ${paragraph1};
567
+ ${parseWidthHeight(width, height)};
568
+ min-width: ${spacing([4])};
569
+ min-height: ${spacing([4])};
570
+ max-width: calc(100% - ${spacing([8])});
571
+ max-height: calc(100% - ${spacing([8])});
572
+ transition: opacity 0.3s ease;
573
+ pointer-events: initial;
574
+ opacity: 0;
446
575
  background-color: ${bgColor};
447
- width: 100%;
448
- height: 100%;
449
576
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
450
577
  `;
451
578
 
@@ -459,34 +586,36 @@ const PopoverArrowCSS = bgColor => css`
459
586
  `;
460
587
 
461
588
  Popover.defaultProps = {
462
- clickOutsideToClose: true,
463
- pressESCToClose: true,
464
- fullScreen: false,
465
- arrow: false,
466
- width: 'max-content',
467
- height: 'max-content',
468
- bgColor: white,
469
- zIndex: zIndexCORE(1),
470
589
  anchorOrigin: {
471
590
  vertical: 'bottom',
472
591
  horizontal: 'center'
473
592
  },
593
+ arrow: false,
594
+ bgColor: white,
595
+ className: '',
596
+ clickOutsideToClose: true,
597
+ fullScreen: false,
598
+ height: 'max-content',
599
+ marginThreshold: spacing(4),
600
+ pressESCToClose: true,
601
+ style: {},
474
602
  transformOrigin: {
475
603
  vertical: 'top',
476
604
  horizontal: 'center'
477
605
  },
478
- style: {},
479
- trigger: 'click'
606
+ trigger: 'click',
607
+ width: 'max-content',
608
+ zIndex: zIndexCORE(1)
480
609
  };
481
610
  Popover.propTypes = {
482
611
  /** If `true`, the component is shown. */
483
612
  open: PropTypes.bool,
484
613
 
485
- /** Trigger mode of the component. Will not work if use with `open` prop. */
614
+ /** Trigger mode of the component. Will not work when use with `open` prop. */
486
615
  trigger: PropTypes.oneOf(['click', 'hover', 'focus']),
487
616
 
488
617
  /** An HTML element, or a function that returns one. It's used to set the position of the popover. */
489
- anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node]),
618
+ anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node, ref]),
490
619
 
491
620
  /**
492
621
  * This is the point on the anchor where the popover's anchor will attach to.
@@ -506,6 +635,9 @@ Popover.propTypes = {
506
635
  /** The content of the component. */
507
636
  children: PropTypes.node,
508
637
 
638
+ /** Class for component. */
639
+ className: PropTypes.string,
640
+
509
641
  /** If `true`, click outside will close component. */
510
642
  clickOutsideToClose: PropTypes.bool,
511
643
 
@@ -516,13 +648,16 @@ Popover.propTypes = {
516
648
  * * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
517
649
  * * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
518
650
  * * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
519
- * * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
651
+ * * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
520
652
  */
521
653
  direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
522
654
 
523
655
  /** Height of the component. */
524
656
  height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
525
657
 
658
+ /** Specifies how close to the edge of the window the popover can appear. */
659
+ marginThreshold: PropTypes.number,
660
+
526
661
  /** Callback fired when the component requests to be closed. */
527
662
  onClose: PropTypes.func,
528
663
 
@@ -555,9 +690,7 @@ Popover.propTypes = {
555
690
  * * setPosition(element): Set position of popover
556
691
  * * @param {element} - element
557
692
  */
558
- reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
559
- current: PropTypes.instanceOf(Element)
560
- })])
693
+ reference: ref
561
694
  };
562
695
  export { Popover };
563
696
  export default OptionWrapper(Popover);
@@ -31,6 +31,7 @@ const iconSizeMap = new Map([['small', '16px'], ['medium', '20px'], ['large', '2
31
31
  const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
32
32
  const filledPaddingSizeMap = new Map([['small', '2px 8px'], ['medium', '2px 12px'], ['large', '2px 12px']]);
33
33
  const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
34
+ action = {},
34
35
  className,
35
36
  color,
36
37
  icon,
@@ -50,10 +51,17 @@ const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
50
51
 
51
52
  const _StatusRoot = StatusRoot(iconSize, _color, size, outlinedPaddingSize);
52
53
 
53
- useImperativeHandle(reference, () => ({
54
- element: ref.current,
55
- instance: {}
56
- }));
54
+ useImperativeHandle(reference, () => {
55
+ const currentRef = ref.current || {};
56
+ currentRef.element = ref.current;
57
+ const _instance = { ...action
58
+ }; // methods
59
+
60
+ _instance.__proto__ = {}; // hidden methods
61
+
62
+ currentRef.instance = _instance;
63
+ return currentRef;
64
+ });
57
65
  const StatusIcon = typeof icon === 'string' ? jsx(Icon, {
58
66
  name: icon,
59
67
  width: iconSize,