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.
- package/assets/images/menu/dhr/MHRP29N0026.svg +13 -0
- package/assets/images/menu/dhr/MHRP29N0027.svg +14 -0
- package/assets/images/menu/dhr/MHRP29N0028.svg +15 -0
- package/components/accordion/details.js +19 -10
- package/components/accordion/group.js +15 -6
- package/components/accordion/index.js +20 -11
- package/components/accordion/summary.js +18 -9
- package/components/avatar/index.js +1 -1
- package/components/badge/index.js +17 -9
- package/components/button/icon.js +33 -25
- package/components/button/index.js +25 -17
- package/components/card/body.js +12 -4
- package/components/card/extra.js +12 -4
- package/components/card/footer.js +12 -4
- package/components/card/header.js +12 -4
- package/components/card/index.js +12 -4
- package/components/chip/index.js +6 -6
- package/components/form-control/attachment/index.js +197 -192
- package/components/form-control/date-picker/index.js +4 -2
- package/components/form-control/date-range-picker/index.js +15 -8
- package/components/form-control/dropdown/index.js +34 -13
- package/components/form-control/input-base/index.js +505 -483
- package/components/form-control/label/index.js +27 -21
- package/components/form-control/text-input/index.js +4 -1
- package/components/grid/Col.js +8 -7
- package/components/grid/Container.js +16 -15
- package/components/grid/Row.js +16 -15
- package/components/grid/index.js +17 -36
- package/components/image/index.js +164 -0
- package/components/index.js +3 -1
- package/components/modal/body.js +12 -9
- package/components/modal/footer.js +22 -11
- package/components/modal/header.js +25 -13
- package/components/modal/index.js +32 -30
- package/components/modal/modal.js +29 -25
- package/components/others/option-wrapper/index.js +5 -18
- package/components/paging/page-info.js +45 -33
- package/components/paging/page-selector2.js +45 -33
- package/components/popover/body.js +14 -6
- package/components/popover/footer.js +15 -6
- package/components/popover/header.js +17 -7
- package/components/popover/index.js +242 -109
- package/components/status/index.js +12 -4
- package/components/tab/tab-container.js +29 -27
- package/components/tab/tab-header.js +33 -28
- package/components/tab/tab-panel.js +31 -27
- package/components/tab/tab.js +45 -35
- package/components/tree-view/index.js +108 -73
- package/components/typography/index.js +36 -25
- package/icons/basic.js +248 -0
- package/icons/effect.js +44 -36
- package/package.json +1 -1
- package/readme.md +40 -0
- package/styles/general.js +23 -0
- package/theme/index.js +1 -1
- package/theme/set-theme.js +2 -1
- package/utils/index.js +13 -10
- 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,
|
|
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,
|
|
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 : (
|
|
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
|
-
|
|
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
|
|
241
|
+
var _anchor5, _anchor$current;
|
|
214
242
|
|
|
215
|
-
anchor = ((
|
|
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
|
-
|
|
230
|
-
vertical =
|
|
231
|
-
|
|
232
|
-
|
|
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
|
|
236
|
-
|
|
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 -
|
|
267
|
+
top = vertical - popoverHeight / 2;
|
|
241
268
|
break;
|
|
242
269
|
|
|
243
270
|
case 'bottom':
|
|
244
|
-
top = vertical -
|
|
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 -
|
|
281
|
+
left = horizontal - popoverWidth / 2;
|
|
254
282
|
break;
|
|
255
283
|
|
|
256
284
|
case 'right':
|
|
257
|
-
left = horizontal -
|
|
285
|
+
left = horizontal - popoverWidth;
|
|
258
286
|
break;
|
|
259
287
|
|
|
260
288
|
default:
|
|
261
289
|
left = horizontal;
|
|
262
|
-
|
|
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 (
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
283
|
-
|
|
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
|
-
|
|
289
|
-
|
|
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
|
-
|
|
297
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
426
|
+
onOpenPopover();
|
|
310
427
|
} else {
|
|
311
|
-
|
|
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
|
|
443
|
+
var _anchor8, _anchor9;
|
|
328
444
|
|
|
329
|
-
const anchorEl = ((
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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
|
|
517
|
+
var _anchor10;
|
|
384
518
|
|
|
385
|
-
if (!((
|
|
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-
|
|
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,
|
|
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
|
-
${
|
|
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
|
-
|
|
479
|
-
|
|
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
|
|
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
|
-
* *
|
|
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:
|
|
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
|
-
|
|
55
|
-
|
|
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,
|