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.
- package/components/accordion/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useEffect, useMemo, useRef, forwardRef, useState } from 'react';
|
|
5
4
|
import { createPortal } from 'react-dom';
|
|
@@ -60,7 +59,6 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
60
59
|
if (!ref) {
|
|
61
60
|
ref = useRef(null);
|
|
62
61
|
}
|
|
63
|
-
|
|
64
62
|
const [openState, setOpenState] = useState(open);
|
|
65
63
|
const [custom, setCustom] = useState(null);
|
|
66
64
|
const PopupContainer = css`
|
|
@@ -161,16 +159,13 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
161
159
|
color: ${theme.colors.secondary};
|
|
162
160
|
cursor: pointer;
|
|
163
161
|
`;
|
|
164
|
-
|
|
165
162
|
const onShowPopup = (message, options = {}, cb, autoClose = true) => {
|
|
166
163
|
if (!message && (!options || JSON.stringify(options) === '{}') && !cb) {
|
|
167
164
|
setCustom(false);
|
|
168
165
|
setOpenState(true);
|
|
169
166
|
return;
|
|
170
167
|
}
|
|
171
|
-
|
|
172
168
|
message = message || title;
|
|
173
|
-
|
|
174
169
|
if (Object.keys(options).length) {
|
|
175
170
|
type = options.type || type;
|
|
176
171
|
icon = options.icon || icon;
|
|
@@ -179,23 +174,18 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
179
174
|
yesText = options.yesText || yesText;
|
|
180
175
|
noText = options.noText || noText;
|
|
181
176
|
}
|
|
182
|
-
|
|
183
177
|
const confirmHandler = () => {
|
|
184
178
|
if (cb && typeof cb === 'function') cb(true);else onConfirmHandler();
|
|
185
|
-
|
|
186
179
|
if (autoClose) {
|
|
187
180
|
onClosePopup();
|
|
188
181
|
}
|
|
189
182
|
};
|
|
190
|
-
|
|
191
183
|
const cancelHandler = () => {
|
|
192
184
|
if (cb && typeof cb === 'function') cb(false);else onCancelHandler();
|
|
193
|
-
|
|
194
185
|
if (autoClose) {
|
|
195
186
|
onClosePopup();
|
|
196
187
|
}
|
|
197
188
|
};
|
|
198
|
-
|
|
199
189
|
const newContent = jsx("div", {
|
|
200
190
|
css: PopupContent
|
|
201
191
|
}, jsx("div", {
|
|
@@ -226,7 +216,6 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
226
216
|
setCustom(newContent);
|
|
227
217
|
setOpenState(true);
|
|
228
218
|
};
|
|
229
|
-
|
|
230
219
|
const onClosePopup = (action = false) => {
|
|
231
220
|
if (onClose && action) {
|
|
232
221
|
onClose();
|
|
@@ -237,29 +226,24 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
237
226
|
}, 300);
|
|
238
227
|
ref.current.style.opacity = null;
|
|
239
228
|
ref.current.firstChild.classList.remove('animate_fadeInDown');
|
|
240
|
-
|
|
241
229
|
if (fullScreen) {
|
|
242
230
|
document.body.style.overflow = null;
|
|
243
231
|
}
|
|
244
232
|
}
|
|
245
233
|
}
|
|
246
234
|
};
|
|
247
|
-
|
|
248
235
|
const onConfirmHandler = () => {
|
|
249
236
|
if (onConfirm) onConfirm();else setOpenState(false);
|
|
250
237
|
};
|
|
251
|
-
|
|
252
238
|
const onCancelHandler = () => {
|
|
253
239
|
if (onCancel) onCancel();else setOpenState(false);
|
|
254
240
|
};
|
|
255
|
-
|
|
256
241
|
const pressESCHandler = event => {
|
|
257
242
|
if (event.key === 'Escape') {
|
|
258
243
|
onClosePopup(custom === null);
|
|
259
244
|
document.removeEventListener('keydown', pressESCHandler);
|
|
260
245
|
}
|
|
261
246
|
};
|
|
262
|
-
|
|
263
247
|
useEffect(() => {
|
|
264
248
|
if (refs) refs(ref);
|
|
265
249
|
}, []);
|
|
@@ -281,11 +265,9 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
281
265
|
ref.current.style.display = 'flex';
|
|
282
266
|
const titleEl = ref.current.querySelector('.popup-title');
|
|
283
267
|
const iconEl = ref.current.querySelector('.popup-icon');
|
|
284
|
-
|
|
285
268
|
if (iconEl && titleEl) {
|
|
286
269
|
titleEl.style.marginRight = '32px';
|
|
287
270
|
const height = titleEl.offsetHeight;
|
|
288
|
-
|
|
289
271
|
if (height && height > 39) {
|
|
290
272
|
iconEl.style.height = '40px';
|
|
291
273
|
iconEl.style.width = '40px';
|
|
@@ -293,24 +275,21 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
293
275
|
iconEl.firstChild.style.width = '40px';
|
|
294
276
|
}
|
|
295
277
|
}
|
|
296
|
-
|
|
297
278
|
setTimeout(() => {
|
|
298
279
|
ref.current.style.opacity = 1;
|
|
299
280
|
ref.current.firstChild.classList.add('animate_fadeInDown');
|
|
300
|
-
}, 0);
|
|
281
|
+
}, 0);
|
|
301
282
|
|
|
283
|
+
// Allow press ESC to close popup
|
|
302
284
|
if (pressESCToClose) {
|
|
303
285
|
document.addEventListener('keydown', pressESCHandler);
|
|
304
286
|
}
|
|
305
|
-
|
|
306
287
|
if (autoFocusOKButton && type !== 'info' && ref.current.querySelector('button')) {
|
|
307
288
|
ref.current.querySelector('button').focus();
|
|
308
289
|
}
|
|
309
|
-
|
|
310
290
|
if (fullScreen) {
|
|
311
291
|
document.body.style.overflow = 'hidden';
|
|
312
292
|
}
|
|
313
|
-
|
|
314
293
|
return () => {
|
|
315
294
|
setCustom(null);
|
|
316
295
|
};
|
|
@@ -382,79 +361,54 @@ Popup.defaultProps = {
|
|
|
382
361
|
Popup.propTypes = {
|
|
383
362
|
/** type of Popup, corresponding to the content inside */
|
|
384
363
|
type: PropTypes.oneOf(['info', 'yes-no', 'confirm', 'custom']),
|
|
385
|
-
|
|
386
364
|
/** the icon to display before content */
|
|
387
365
|
icon: PropTypes.oneOf(['info', 'success', 'warning', 'danger']),
|
|
388
|
-
|
|
389
366
|
/** the main content to display */
|
|
390
367
|
title: PropTypes.node,
|
|
391
|
-
|
|
392
368
|
/** class of Popup component */
|
|
393
369
|
className: PropTypes.string,
|
|
394
|
-
|
|
395
370
|
/** the text to display in agree button */
|
|
396
371
|
yesText: PropTypes.string,
|
|
397
|
-
|
|
398
372
|
/** the text to display in deny button */
|
|
399
373
|
noText: PropTypes.string,
|
|
400
|
-
|
|
401
374
|
/** the text to display in confirm button */
|
|
402
375
|
confirmText: PropTypes.string,
|
|
403
|
-
|
|
404
376
|
/** the text to display in cancel button */
|
|
405
377
|
cancelText: PropTypes.string,
|
|
406
|
-
|
|
407
378
|
/** the width of Popup */
|
|
408
379
|
width: PropTypes.string,
|
|
409
|
-
|
|
410
380
|
/** display clear icon if true */
|
|
411
381
|
clearAble: PropTypes.bool,
|
|
412
|
-
|
|
413
382
|
/** show Popup if true */
|
|
414
383
|
open: PropTypes.bool,
|
|
415
|
-
|
|
416
384
|
/** allow close Popup when press ESC */
|
|
417
385
|
pressESCToClose: PropTypes.bool,
|
|
418
|
-
|
|
419
386
|
/** auto focus in OK button */
|
|
420
387
|
autoFocusOKButton: PropTypes.bool,
|
|
421
|
-
|
|
422
388
|
/** style inline for Popup container */
|
|
423
389
|
style: PropTypes.object,
|
|
424
|
-
|
|
425
390
|
/** style inline for Popup */
|
|
426
391
|
popupStyle: PropTypes.object,
|
|
427
|
-
|
|
428
392
|
/** style inline for clear icon */
|
|
429
393
|
clearIconStyle: PropTypes.object,
|
|
430
|
-
|
|
431
394
|
/** the props of confirm button */
|
|
432
395
|
confirmProps: PropTypes.object,
|
|
433
|
-
|
|
434
396
|
/** the props of cancel button */
|
|
435
397
|
cancelProps: PropTypes.object,
|
|
436
|
-
|
|
437
398
|
/** the function to get ref of Popup */
|
|
438
399
|
refs: PropTypes.func,
|
|
439
|
-
|
|
440
400
|
/** the function to get events of Popup (show/close) */
|
|
441
401
|
getPopup: PropTypes.func,
|
|
442
|
-
|
|
443
402
|
/** the function run when close Popup */
|
|
444
403
|
onClose: PropTypes.func,
|
|
445
|
-
|
|
446
404
|
/** the function run when click confirm button */
|
|
447
405
|
onConfirm: PropTypes.func,
|
|
448
|
-
|
|
449
406
|
/** the function run when click cancel button */
|
|
450
407
|
onCancel: PropTypes.func,
|
|
451
|
-
|
|
452
408
|
/** set top position for Popup */
|
|
453
409
|
top: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
454
|
-
|
|
455
410
|
/** show a dark background under the popup if true */
|
|
456
411
|
fullScreen: PropTypes.bool,
|
|
457
|
-
|
|
458
412
|
/** the full content will display in Popup if set */
|
|
459
413
|
children: PropTypes.any
|
|
460
414
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useEffect, useMemo, useRef, forwardRef } from 'react';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
@@ -40,7 +39,6 @@ const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
40
39
|
if (!ref) {
|
|
41
40
|
ref = useRef(null);
|
|
42
41
|
}
|
|
43
|
-
|
|
44
42
|
const PopupContainer = css`
|
|
45
43
|
display: flex;
|
|
46
44
|
position: fixed;
|
|
@@ -93,26 +91,21 @@ const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
93
91
|
color: '#404456' !important;
|
|
94
92
|
}
|
|
95
93
|
`;
|
|
96
|
-
|
|
97
94
|
const onClosePopup = () => {
|
|
98
95
|
if (onClose) onClose();
|
|
99
96
|
};
|
|
100
|
-
|
|
101
97
|
const onProposals = () => {
|
|
102
98
|
// eslint-disable-next-line no-undef
|
|
103
99
|
const input = PopupInputRef.current.querySelector('input');
|
|
104
|
-
|
|
105
100
|
if (/^cancel$/i.test(type)) {
|
|
106
101
|
if (onCancel) onCancel(input);
|
|
107
102
|
} else if (onConfirm) onConfirm(input);
|
|
108
103
|
};
|
|
109
|
-
|
|
110
104
|
const pressESCHandler = event => {
|
|
111
105
|
if (event.key === 'Escape') {
|
|
112
106
|
onClosePopup();
|
|
113
107
|
}
|
|
114
108
|
};
|
|
115
|
-
|
|
116
109
|
const calPosition = (position, originBounding) => {
|
|
117
110
|
switch (position) {
|
|
118
111
|
case 'bottom':
|
|
@@ -120,45 +113,41 @@ const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
120
113
|
{
|
|
121
114
|
return [originBounding.height, originBounding.width];
|
|
122
115
|
}
|
|
123
|
-
|
|
124
116
|
case 'center':
|
|
125
117
|
{
|
|
126
118
|
return [originBounding.height / 2, originBounding.width / 2];
|
|
127
119
|
}
|
|
128
|
-
|
|
129
120
|
default:
|
|
130
121
|
return [0, 0];
|
|
131
122
|
}
|
|
132
123
|
};
|
|
133
|
-
|
|
134
124
|
useEffect(() => {
|
|
135
125
|
if (refs) refs(ref);
|
|
136
126
|
}, []);
|
|
137
127
|
useEffect(() => {
|
|
138
128
|
if (open && ref.current) {
|
|
139
129
|
let top = 0,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
130
|
+
left = 0,
|
|
131
|
+
vertical = 0,
|
|
132
|
+
horizontal = 0;
|
|
143
133
|
|
|
134
|
+
// Position's anchor
|
|
144
135
|
if (anchorOrigin && anchor) {
|
|
145
136
|
if (anchor.current) {
|
|
146
137
|
anchor = anchor.current;
|
|
147
138
|
}
|
|
148
|
-
|
|
149
139
|
if (anchorOrigin === 'center') {
|
|
150
140
|
anchorOrigin = {
|
|
151
141
|
vertical: 'center',
|
|
152
142
|
horizontal: 'center'
|
|
153
143
|
};
|
|
154
144
|
}
|
|
155
|
-
|
|
156
145
|
const anchorBounding = anchor.getBoundingClientRect();
|
|
157
146
|
vertical = anchorBounding.y + calPosition(anchorOrigin.vertical, anchorBounding)[0];
|
|
158
147
|
horizontal = anchorBounding.x + calPosition(anchorOrigin.horizontal, anchorBounding)[1];
|
|
159
|
-
}
|
|
160
|
-
|
|
148
|
+
}
|
|
161
149
|
|
|
150
|
+
// Position's transform
|
|
162
151
|
if (transformOrigin) {
|
|
163
152
|
if (transformOrigin === 'center') {
|
|
164
153
|
transformOrigin = {
|
|
@@ -166,65 +155,54 @@ const ProposalsPopup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
166
155
|
horizontal: 'center'
|
|
167
156
|
};
|
|
168
157
|
}
|
|
169
|
-
|
|
170
158
|
const offsetHeight = ref.current.offsetHeight;
|
|
171
159
|
const offsetWidth = ref.current.offsetWidth;
|
|
172
|
-
|
|
173
160
|
switch (transformOrigin.vertical) {
|
|
174
161
|
case 'center':
|
|
175
162
|
top = vertical - offsetHeight / 2;
|
|
176
163
|
break;
|
|
177
|
-
|
|
178
164
|
case 'bottom':
|
|
179
165
|
top = vertical - offsetHeight;
|
|
180
166
|
break;
|
|
181
|
-
|
|
182
167
|
default:
|
|
183
168
|
top = vertical;
|
|
184
169
|
}
|
|
185
|
-
|
|
186
170
|
switch (transformOrigin.horizontal) {
|
|
187
171
|
case 'center':
|
|
188
172
|
left = horizontal - offsetWidth / 2;
|
|
189
173
|
break;
|
|
190
|
-
|
|
191
174
|
case 'right':
|
|
192
175
|
left = horizontal - offsetWidth;
|
|
193
176
|
break;
|
|
194
|
-
|
|
195
177
|
default:
|
|
196
178
|
left = horizontal;
|
|
197
|
-
}
|
|
198
|
-
|
|
179
|
+
}
|
|
199
180
|
|
|
181
|
+
// Reset position if the element overflow window screen size
|
|
200
182
|
if (top < 0) {
|
|
201
183
|
top = 0;
|
|
202
184
|
} else if (top + offsetHeight > window.innerHeight) {
|
|
203
185
|
top = window.innerHeight - offsetHeight;
|
|
204
186
|
}
|
|
205
|
-
|
|
206
187
|
if (left < 0) {
|
|
207
188
|
left = 0;
|
|
208
189
|
} else if (left + offsetWidth > window.innerWidth) {
|
|
209
190
|
left = window.innerWidth - offsetWidth;
|
|
210
191
|
}
|
|
211
|
-
|
|
212
192
|
ref.current.style.top = top + 'px';
|
|
213
193
|
ref.current.style.left = left + 'px';
|
|
214
194
|
ref.current.style.transformOrigin = `${transformOrigin.horizontal || 'left'} ${transformOrigin.vertical || 'top'}`;
|
|
215
195
|
}
|
|
196
|
+
ref.current.classList.add('open');
|
|
216
197
|
|
|
217
|
-
|
|
218
|
-
|
|
198
|
+
// Allow press ESC to close popup
|
|
219
199
|
if (pressESCToClose) {
|
|
220
200
|
document.addEventListener('keydown', pressESCHandler);
|
|
221
201
|
}
|
|
222
202
|
}
|
|
223
|
-
|
|
224
203
|
return () => {
|
|
225
204
|
if (open && ref.current) {
|
|
226
205
|
ref.current.classList.remove('open');
|
|
227
|
-
|
|
228
206
|
if (pressESCToClose) {
|
|
229
207
|
document.removeEventListener('keydown', pressESCHandler);
|
|
230
208
|
}
|
|
@@ -303,57 +281,40 @@ ProposalsPopup.defaultProps = {
|
|
|
303
281
|
ProposalsPopup.propTypes = {
|
|
304
282
|
/** type of Popup, corresponding to the button */
|
|
305
283
|
type: PropTypes.oneOf(['confirm', 'cancel']),
|
|
306
|
-
|
|
307
284
|
/** type of TextInput */
|
|
308
285
|
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
309
|
-
|
|
310
286
|
/** placeholder to display in TextInput */
|
|
311
287
|
placeholder: PropTypes.string,
|
|
312
|
-
|
|
313
288
|
/** label to display on TextInput */
|
|
314
289
|
label: PropTypes.string,
|
|
315
|
-
|
|
316
290
|
/** the content to display in button */
|
|
317
291
|
buttonText: PropTypes.string,
|
|
318
|
-
|
|
319
292
|
/** value to display in TextInput */
|
|
320
293
|
value: PropTypes.string,
|
|
321
|
-
|
|
322
294
|
/** display clear icon if true */
|
|
323
295
|
clearAble: PropTypes.bool,
|
|
324
|
-
|
|
325
296
|
/** show Popup if true */
|
|
326
297
|
open: PropTypes.bool,
|
|
327
|
-
|
|
328
298
|
/** allow close Popup when press ESC */
|
|
329
299
|
pressESCToClose: PropTypes.bool,
|
|
330
|
-
|
|
331
300
|
/** style inline for Popup container */
|
|
332
301
|
style: PropTypes.object,
|
|
333
|
-
|
|
334
302
|
/** style inline for Popup */
|
|
335
303
|
popupStyle: PropTypes.object,
|
|
336
|
-
|
|
337
304
|
/** positions are displayed under this object */
|
|
338
305
|
anchor: PropTypes.object,
|
|
339
|
-
|
|
340
306
|
/** The root is displayed according to the position of the anchor */
|
|
341
307
|
anchorOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
342
308
|
// {vertical: 'top', horizontal: 'left'}
|
|
343
|
-
|
|
344
309
|
/** Popup's native display */
|
|
345
310
|
transformOrigin: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
|
|
346
311
|
// {vertical: 'bottom', horizontal: 'right'}
|
|
347
|
-
|
|
348
312
|
/** the function to get ref of Popup */
|
|
349
313
|
refs: PropTypes.func,
|
|
350
|
-
|
|
351
314
|
/** the function run when close Popup */
|
|
352
315
|
onClose: PropTypes.func,
|
|
353
|
-
|
|
354
316
|
/** the function run when click confirm button */
|
|
355
317
|
onConfirm: PropTypes.func,
|
|
356
|
-
|
|
357
318
|
/** the function run when click cancel button */
|
|
358
319
|
onCancel: PropTypes.func
|
|
359
320
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useEffect, useRef, useState, forwardRef, useImperativeHandle, Fragment, useCallback } from 'react';
|
|
5
4
|
import { createPortal } from 'react-dom';
|
|
@@ -66,19 +65,15 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
65
|
const [showMoreDescription, setShowMoreDescription] = useState(false);
|
|
67
66
|
const [descriptionLines, setDescriptionLines] = useState(0);
|
|
68
67
|
const showPopup = useDelayUnmount(openState, 200);
|
|
69
|
-
|
|
70
68
|
const _PopupRootCSS = PopupRootCSS(width, top, type, description, subtitle, showMoreDescription, descriptionLines);
|
|
71
|
-
|
|
72
69
|
const pressESCHandler = event => {
|
|
73
70
|
if (event.key === 'Escape') {
|
|
74
71
|
onClosePopup('isClose');
|
|
75
72
|
}
|
|
76
73
|
};
|
|
77
|
-
|
|
78
74
|
const onShowPopup = (options, cb) => {
|
|
79
75
|
if (options && typeof options === 'object' && Object.keys(options).length) {
|
|
80
76
|
var _newProps$title;
|
|
81
|
-
|
|
82
77
|
const newProps = {
|
|
83
78
|
type: options.type !== undefined ? options.type : type,
|
|
84
79
|
title: options.title !== undefined ? options.title : title,
|
|
@@ -135,10 +130,8 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
135
130
|
} else {
|
|
136
131
|
setCustom(false);
|
|
137
132
|
}
|
|
138
|
-
|
|
139
133
|
setOpenState(true);
|
|
140
134
|
};
|
|
141
|
-
|
|
142
135
|
const onClosePopup = mode => {
|
|
143
136
|
if (onClose) {
|
|
144
137
|
setOpenState(false);
|
|
@@ -149,11 +142,9 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
149
142
|
}
|
|
150
143
|
}
|
|
151
144
|
};
|
|
152
|
-
|
|
153
145
|
const onRefChange = useCallback(node => {
|
|
154
146
|
if (node) {
|
|
155
147
|
setDescriptionLines(Math.round((node === null || node === void 0 ? void 0 : node.offsetHeight) / 18)); //18 is line-height of Typography p2
|
|
156
|
-
|
|
157
148
|
setShowMoreDescription(false);
|
|
158
149
|
}
|
|
159
150
|
}, []);
|
|
@@ -176,7 +167,6 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
176
167
|
action: statusAction.current
|
|
177
168
|
});
|
|
178
169
|
}
|
|
179
|
-
|
|
180
170
|
return () => {
|
|
181
171
|
document.removeEventListener('keydown', pressESCHandler);
|
|
182
172
|
};
|
|
@@ -187,9 +177,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
187
177
|
show: onShowPopup,
|
|
188
178
|
close: onClosePopup
|
|
189
179
|
}; // methods
|
|
190
|
-
|
|
191
180
|
_instance.__proto__ = {}; // hidden methods
|
|
192
|
-
|
|
193
181
|
currentRef.instance = _instance;
|
|
194
182
|
currentRef.show = onShowPopup;
|
|
195
183
|
currentRef.close = onClosePopup;
|
|
@@ -260,7 +248,6 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
260
248
|
...cancelProps
|
|
261
249
|
}))))), document.body);
|
|
262
250
|
}));
|
|
263
|
-
|
|
264
251
|
const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescription, descriptionLines) => css`
|
|
265
252
|
${flexRow};
|
|
266
253
|
${positionFixed};
|
|
@@ -376,7 +363,6 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
376
363
|
}
|
|
377
364
|
}
|
|
378
365
|
`;
|
|
379
|
-
|
|
380
366
|
Popup.defaultProps = {
|
|
381
367
|
open: false,
|
|
382
368
|
pressESCToClose: false,
|
|
@@ -390,55 +376,38 @@ Popup.defaultProps = {
|
|
|
390
376
|
Popup.propTypes = {
|
|
391
377
|
/** If `true`, the component is shown. */
|
|
392
378
|
open: PropTypes.bool,
|
|
393
|
-
|
|
394
379
|
/** [Props](https://core.diginet.com.vn/ui/?path=/story/button) applied to the cancel `Button`. */
|
|
395
380
|
cancelProps: PropTypes.object,
|
|
396
|
-
|
|
397
381
|
/** Class for component. */
|
|
398
382
|
className: PropTypes.string,
|
|
399
|
-
|
|
400
383
|
/** [Props](https://core.diginet.com.vn/ui/?path=/story/button) applied to the confirm `Button`. */
|
|
401
384
|
confirmProps: PropTypes.object,
|
|
402
|
-
|
|
403
385
|
/** Details content of the component. */
|
|
404
386
|
description: PropTypes.string,
|
|
405
|
-
|
|
406
387
|
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic) display before content. */
|
|
407
388
|
icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
408
|
-
|
|
409
389
|
/** Label of cancel button. */
|
|
410
390
|
noText: PropTypes.string,
|
|
411
|
-
|
|
412
391
|
/** Callback fired when click on cancel button. */
|
|
413
392
|
onCancel: PropTypes.func,
|
|
414
|
-
|
|
415
393
|
/** Callback fired when click on confirm button. */
|
|
416
394
|
onConfirm: PropTypes.func,
|
|
417
|
-
|
|
418
395
|
/** If `true`, hitting escape will close component. */
|
|
419
396
|
pressESCToClose: PropTypes.bool,
|
|
420
|
-
|
|
421
397
|
/** Style inline of component. */
|
|
422
398
|
style: PropTypes.object,
|
|
423
|
-
|
|
424
399
|
/** Main content of the component. */
|
|
425
400
|
subtitle: PropTypes.node,
|
|
426
|
-
|
|
427
401
|
/** Title of the component. */
|
|
428
402
|
title: PropTypes.node,
|
|
429
|
-
|
|
430
403
|
/** Top position of the component. */
|
|
431
404
|
top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
432
|
-
|
|
433
405
|
/** Type of the component. */
|
|
434
406
|
type: PropTypes.oneOf(['info', 'success', 'warning', 'danger', 'yesno']),
|
|
435
|
-
|
|
436
407
|
/** Width of the component. */
|
|
437
408
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
438
|
-
|
|
439
409
|
/** Label of confirm button. */
|
|
440
410
|
yesText: PropTypes.string,
|
|
441
|
-
|
|
442
411
|
/**
|
|
443
412
|
* ref methods
|
|
444
413
|
*
|