diginet-core-ui 1.3.36 → 1.3.37
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/MHRM29N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRP39N0018.svg +11 -0
- package/components/alert/index.js +115 -103
- package/components/alert/notify.js +0 -2
- package/components/avatar/index.js +19 -19
- package/components/chip/index.js +13 -10
- package/components/form-control/attachment/index.js +21 -20
- package/components/form-control/dropdown/index.js +132 -78
- package/components/modal/header.js +63 -65
- package/components/modal/modal.js +84 -130
- package/components/popover/index.js +21 -21
- package/components/slider/slider-item.js +65 -25
- package/icons/basic.js +75 -408
- package/package.json +1 -1
- package/readme.md +14 -0
- package/styles/general.js +33 -5
- package/theme/settings.js +3 -2
|
@@ -1,129 +1,65 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useState, useRef, forwardRef, useEffect, useMemo } from 'react';
|
|
4
|
+
import { memo, useState, useRef, forwardRef, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import { jsx, css
|
|
7
|
+
import { jsx, css } from '@emotion/core';
|
|
8
8
|
import ModalContext from './context';
|
|
9
|
+
import { animations } from '../../styles/animation';
|
|
9
10
|
import { typography } from '../../styles/typography';
|
|
11
|
+
import { borderBox, borderRadius4px, flexCol, flexRow, justifyCenter, parseWidth, positionFixed, positionRelative } from '../../styles/general';
|
|
12
|
+
import { color as colors } from '../../styles/colors';
|
|
13
|
+
const {
|
|
14
|
+
paragraph1
|
|
15
|
+
} = typography;
|
|
16
|
+
const {
|
|
17
|
+
system: {
|
|
18
|
+
white
|
|
19
|
+
}
|
|
20
|
+
} = colors;
|
|
21
|
+
const fadeInDown = animations.fadeInDown;
|
|
10
22
|
const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
23
|
open,
|
|
12
|
-
type,
|
|
13
|
-
title,
|
|
14
24
|
moveable,
|
|
15
25
|
dragAnyWhere,
|
|
16
26
|
moveOutScreen,
|
|
17
27
|
style,
|
|
18
|
-
top,
|
|
19
28
|
zIndex,
|
|
20
29
|
pressESCToClose,
|
|
21
30
|
darkTheme,
|
|
22
31
|
autoFocus,
|
|
23
|
-
refs,
|
|
24
32
|
onClose,
|
|
25
|
-
onConfirm,
|
|
26
|
-
onCancel,
|
|
27
33
|
children,
|
|
28
34
|
width,
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
ref = useRef(null);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
+
alignment
|
|
36
|
+
}, reference) => {
|
|
37
|
+
const ref = useRef(null);
|
|
35
38
|
const modalBoxRef = useRef(null);
|
|
36
39
|
const [openState, setOpenState] = useState(open);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
height: 100vh;
|
|
42
|
-
background-color: ${darkTheme ? 'rgba(21, 26, 48, 0.5)' : 'transparent'};
|
|
43
|
-
top: 0;
|
|
44
|
-
left: 0;
|
|
45
|
-
justify-content: center;
|
|
46
|
-
align-items: ${top ? 'inherit' : 'center'};
|
|
47
|
-
padding-top: ${top ? isNaN(top) ? top : top + 'px' : 0};
|
|
48
|
-
opacity: 0;
|
|
49
|
-
transition: opacity 0.3s ease;
|
|
50
|
-
z-index: ${zIndex};
|
|
51
|
-
`;
|
|
52
|
-
const fadeInDown = keyframes`
|
|
53
|
-
0% {
|
|
54
|
-
opacity: 0;
|
|
55
|
-
-webkit-transform: translate3d(0, -30px, 0);
|
|
56
|
-
transform: translate3d(0, -30px, 0);
|
|
57
|
-
}
|
|
58
|
-
to {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
-webkit-transform: translateZ(0);
|
|
61
|
-
transform: translateZ(0);
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
const fadeOutUp = keyframes`
|
|
65
|
-
0% {
|
|
66
|
-
opacity: 1;
|
|
67
|
-
}
|
|
68
|
-
to {
|
|
69
|
-
opacity: 0;
|
|
70
|
-
-webkit-transform: translate3d(0, -30px, 0);
|
|
71
|
-
transform: translate3d(0, -30px, 0);
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
const ModalBox = css`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
position: relative;
|
|
78
|
-
background-color: white;
|
|
79
|
-
${typography.paragraph1};
|
|
80
|
-
height: max-content;
|
|
81
|
-
max-height: calc(100% - ${isNaN(top) ? top : +top + 'px'});
|
|
82
|
-
min-width: 150px;
|
|
83
|
-
max-width: 90%;
|
|
84
|
-
/* min-height: 152px; */
|
|
85
|
-
margin: 0 auto;
|
|
86
|
-
border-radius: 4px;
|
|
87
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
88
|
-
box-sizing: border-box;
|
|
89
|
-
-webkit-box-orient: vertical;
|
|
90
|
-
-webkit-box-direction: normal;
|
|
91
|
-
width: ${isNaN(width) ? width : width + 'px'};
|
|
92
|
-
animation: ${fadeOutUp} 0.2s ease;
|
|
93
|
-
animation-fill-mode: forwards;
|
|
94
|
-
cursor: ${moveable && dragAnyWhere ? 'move' : 'initial'};
|
|
95
|
-
&.show {
|
|
96
|
-
display: flex !important;
|
|
97
|
-
animation: ${fadeInDown} 0.2s ease;
|
|
98
|
-
}
|
|
99
|
-
`;
|
|
40
|
+
|
|
41
|
+
const _ModalContainerCSS = ModalContainerCSS(zIndex, alignment, darkTheme);
|
|
42
|
+
|
|
43
|
+
const _ModalBoxCSS = ModalBoxCSS(width, moveable, dragAnyWhere);
|
|
100
44
|
|
|
101
45
|
const onShowModal = () => {
|
|
102
46
|
setOpenState(true);
|
|
103
47
|
};
|
|
104
48
|
|
|
105
49
|
const onCloseModal = () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
setOpenState(false);
|
|
109
|
-
}, 500);
|
|
110
|
-
}
|
|
50
|
+
onClose && onClose();
|
|
51
|
+
setOpenState(false);
|
|
111
52
|
|
|
112
53
|
if (pressESCToClose) {
|
|
113
54
|
document.removeEventListener('keydown', pressESCHandler);
|
|
114
55
|
}
|
|
115
|
-
|
|
116
|
-
if (ref.current) {
|
|
117
|
-
ref.current.style.opacity = null;
|
|
118
|
-
ref.current.firstChild.classList.remove('show');
|
|
119
|
-
}
|
|
120
56
|
};
|
|
121
57
|
|
|
122
58
|
const pressESCHandler = event => {
|
|
123
59
|
if (event.key === 'Escape') {
|
|
124
60
|
const modals = document.querySelectorAll('.DGN-UI-Portal');
|
|
125
61
|
|
|
126
|
-
if (modals
|
|
62
|
+
if ((modals === null || modals === void 0 ? void 0 : modals.length) > 1 && Array.from(modals)[modals.length - 1] && !Array.from(modals)[modals.length - 1].contains(ref.current)) {
|
|
127
63
|
return;
|
|
128
64
|
}
|
|
129
65
|
|
|
@@ -187,30 +123,11 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
187
123
|
};
|
|
188
124
|
|
|
189
125
|
useEffect(() => {
|
|
190
|
-
|
|
191
|
-
setOpenState(open);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return () => {
|
|
195
|
-
if (open && ref.current) {
|
|
196
|
-
setTimeout(() => {
|
|
197
|
-
setOpenState(!open);
|
|
198
|
-
}, 500);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
126
|
+
setOpenState(open);
|
|
201
127
|
}, [open]);
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
return () => {
|
|
204
|
-
if (pressESCToClose) {
|
|
205
|
-
document.removeEventListener('keydown', pressESCHandler);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
}, []);
|
|
209
128
|
useEffect(() => {
|
|
210
129
|
if (openState) {
|
|
211
130
|
if (ref.current) {
|
|
212
|
-
ref.current.style.opacity = 1;
|
|
213
|
-
ref.current.firstChild.classList.add('show');
|
|
214
131
|
const modals = document.querySelectorAll('.DGN-UI-Modal');
|
|
215
132
|
|
|
216
133
|
if (!darkTheme && modals && modals.length > 1) {
|
|
@@ -225,18 +142,25 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
225
142
|
}
|
|
226
143
|
}
|
|
227
144
|
|
|
228
|
-
document.
|
|
145
|
+
document.documentElement.style.overflow = 'hidden'; // Allow press ESC to close popup
|
|
229
146
|
|
|
230
147
|
if (pressESCToClose) {
|
|
231
148
|
document.addEventListener('keydown', pressESCHandler);
|
|
232
149
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
document.body.style.overflow = null;
|
|
236
|
-
};
|
|
150
|
+
} else {
|
|
151
|
+
document.documentElement.style.overflow = null;
|
|
237
152
|
}
|
|
238
153
|
}, [openState]);
|
|
239
|
-
|
|
154
|
+
useImperativeHandle(reference, () => {
|
|
155
|
+
const currentRef = ref.current || {};
|
|
156
|
+
const _instance = {}; // methods
|
|
157
|
+
|
|
158
|
+
_instance.__proto__ = {}; // hidden methods
|
|
159
|
+
|
|
160
|
+
currentRef.instance = _instance;
|
|
161
|
+
return currentRef;
|
|
162
|
+
});
|
|
163
|
+
return useMemo(() => {
|
|
240
164
|
if (openState) {
|
|
241
165
|
const node = jsx("div", {
|
|
242
166
|
className: 'DGN-UI-Portal DGN-UI-Modal',
|
|
@@ -246,13 +170,14 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
246
170
|
inset: 0
|
|
247
171
|
}
|
|
248
172
|
}, jsx("div", {
|
|
249
|
-
css:
|
|
173
|
+
css: _ModalContainerCSS,
|
|
174
|
+
className: 'DGN-UI-Modal-Container',
|
|
250
175
|
ref: ref
|
|
251
176
|
}, jsx("div", {
|
|
252
|
-
css:
|
|
177
|
+
css: _ModalBoxCSS,
|
|
253
178
|
ref: modalBoxRef,
|
|
254
|
-
...props,
|
|
255
179
|
onMouseDown: moveable && dragAnyWhere ? dragMouseDown : null,
|
|
180
|
+
className: 'DGN-UI-Modal-Box',
|
|
256
181
|
style: style
|
|
257
182
|
}, jsx(ModalContext.Provider, {
|
|
258
183
|
value: {
|
|
@@ -265,9 +190,44 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
265
190
|
}
|
|
266
191
|
|
|
267
192
|
return null;
|
|
268
|
-
});
|
|
269
|
-
return ModalView;
|
|
193
|
+
}, [moveable, dragAnyWhere, style, children, openState]);
|
|
270
194
|
}));
|
|
195
|
+
|
|
196
|
+
const ModalContainerCSS = (zIndex, alignment, darkTheme) => css`
|
|
197
|
+
${flexRow};
|
|
198
|
+
${positionFixed};
|
|
199
|
+
${justifyCenter};
|
|
200
|
+
z-index: ${zIndex};
|
|
201
|
+
align-items: ${alignment === 'top' ? 'inherit' : 'center'};
|
|
202
|
+
padding-top: ${alignment === 'top' ? '12px' : 0};
|
|
203
|
+
background-color: ${darkTheme ? 'rgba(21, 26, 48, 0.5)' : 'transparent'};
|
|
204
|
+
width: 100%;
|
|
205
|
+
height: 100vh;
|
|
206
|
+
top: 0;
|
|
207
|
+
left: 0;
|
|
208
|
+
`;
|
|
209
|
+
|
|
210
|
+
const ModalBoxCSS = (width, moveable, dragAnyWhere) => css`
|
|
211
|
+
${paragraph1};
|
|
212
|
+
${flexCol};
|
|
213
|
+
${positionRelative};
|
|
214
|
+
${borderRadius4px}
|
|
215
|
+
${borderBox};
|
|
216
|
+
${parseWidth(width)}
|
|
217
|
+
cursor: ${moveable && dragAnyWhere ? 'move' : 'initial'};
|
|
218
|
+
max-height: calc(100% - 12px);
|
|
219
|
+
height: max-content;
|
|
220
|
+
background-color: ${white};
|
|
221
|
+
min-width: 150px;
|
|
222
|
+
max-width: 90%;
|
|
223
|
+
margin: 0 auto;
|
|
224
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
225
|
+
-webkit-box-orient: vertical;
|
|
226
|
+
-webkit-box-direction: normal;
|
|
227
|
+
animation: ${fadeInDown} 0.2s ease;
|
|
228
|
+
animation-fill-mode: forwards;
|
|
229
|
+
`;
|
|
230
|
+
|
|
271
231
|
Modal.defaultProps = {
|
|
272
232
|
darkTheme: true,
|
|
273
233
|
open: false,
|
|
@@ -276,11 +236,14 @@ Modal.defaultProps = {
|
|
|
276
236
|
dragAnyWhere: false,
|
|
277
237
|
moveOutScreen: false,
|
|
278
238
|
autoFocus: true,
|
|
279
|
-
|
|
239
|
+
alignment: 'top',
|
|
280
240
|
width: '80%',
|
|
281
241
|
zIndex: 9000
|
|
282
242
|
};
|
|
283
243
|
Modal.propTypes = {
|
|
244
|
+
/** Set the position on the component. */
|
|
245
|
+
alignment: PropTypes.oneOf(['top', 'center']),
|
|
246
|
+
|
|
284
247
|
/** park a good colored background under the modal box if true */
|
|
285
248
|
darkTheme: PropTypes.bool,
|
|
286
249
|
|
|
@@ -305,25 +268,16 @@ Modal.propTypes = {
|
|
|
305
268
|
/** z-index style of Modal */
|
|
306
269
|
zIndex: PropTypes.number,
|
|
307
270
|
|
|
308
|
-
/** customize the vertical position of the screen, if not set, the modal will be fixed in the middle of the screen */
|
|
309
|
-
top: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
310
|
-
|
|
311
271
|
/** width of the modal */
|
|
312
272
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
313
273
|
|
|
314
274
|
/** customize style inline */
|
|
315
275
|
style: PropTypes.object,
|
|
316
276
|
|
|
317
|
-
/** get modal ref by function */
|
|
318
|
-
refs: PropTypes.func,
|
|
319
|
-
|
|
320
277
|
/** the function to run when close modal */
|
|
321
278
|
onClose: PropTypes.func,
|
|
322
279
|
|
|
323
280
|
/** child content in body */
|
|
324
|
-
children: PropTypes.node
|
|
325
|
-
|
|
326
|
-
/** any props else */
|
|
327
|
-
props: PropTypes.any
|
|
281
|
+
children: PropTypes.node
|
|
328
282
|
};
|
|
329
283
|
export default Modal;
|
|
@@ -437,32 +437,32 @@ Popover.propTypes = {
|
|
|
437
437
|
/** An HTML element, or a function that returns one. It's used to set the position of the popover. */
|
|
438
438
|
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object]),
|
|
439
439
|
|
|
440
|
-
/**
|
|
441
|
-
* This is the point on the anchor where the popover's anchor will attach to.
|
|
442
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
440
|
+
/**
|
|
441
|
+
* This is the point on the anchor where the popover's anchor will attach to.
|
|
442
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
443
443
|
*/
|
|
444
444
|
anchorOrigin: PropTypes.shape({
|
|
445
445
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
446
446
|
vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
|
|
447
447
|
}),
|
|
448
448
|
|
|
449
|
-
/**
|
|
450
|
-
* This is the point on the popover which will attach to the anchor's origin.
|
|
451
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
449
|
+
/**
|
|
450
|
+
* This is the point on the popover which will attach to the anchor's origin.
|
|
451
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
452
452
|
*/
|
|
453
453
|
transformOrigin: PropTypes.shape({
|
|
454
454
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
455
455
|
vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
|
|
456
456
|
}),
|
|
457
457
|
|
|
458
|
-
/**
|
|
459
|
-
* Direction when Popover shown.
|
|
460
|
-
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
461
|
-
*
|
|
462
|
-
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
463
|
-
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
464
|
-
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
465
|
-
* * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
458
|
+
/**
|
|
459
|
+
* Direction when Popover shown.
|
|
460
|
+
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
461
|
+
*
|
|
462
|
+
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
463
|
+
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
464
|
+
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
465
|
+
* * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
466
466
|
*/
|
|
467
467
|
direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
|
|
468
468
|
|
|
@@ -481,13 +481,13 @@ Popover.propTypes = {
|
|
|
481
481
|
/** The content of the component. */
|
|
482
482
|
children: PropTypes.node,
|
|
483
483
|
|
|
484
|
-
/**
|
|
485
|
-
* ref methods (ref.current.instance.*method*)
|
|
486
|
-
*
|
|
487
|
-
* * show: Show popover
|
|
488
|
-
* * close: Close popover
|
|
489
|
-
* * setPosition(element): Set position of popover
|
|
490
|
-
* * @param {element} - element
|
|
484
|
+
/**
|
|
485
|
+
* ref methods (ref.current.instance.*method*)
|
|
486
|
+
*
|
|
487
|
+
* * show: Show popover
|
|
488
|
+
* * close: Close popover
|
|
489
|
+
* * setPosition(element): Set position of popover
|
|
490
|
+
* * @param {element} - element
|
|
491
491
|
*/
|
|
492
492
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
493
493
|
current: PropTypes.instanceOf(Element)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { forwardRef, memo, useRef } from 'react';
|
|
4
|
+
import { forwardRef, memo, useEffect, useState, useRef } from 'react';
|
|
5
5
|
import { jsx, css, keyframes } from '@emotion/core';
|
|
6
6
|
import { randomString, getFileType } from '../../utils';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import { IndeterminateCircularProgress } from '../progress/circular';
|
|
8
9
|
const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
10
|
active,
|
|
10
11
|
animation,
|
|
@@ -23,6 +24,8 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
23
24
|
itemContainer: 'DGN-UI-Slider-item-container-' + Id,
|
|
24
25
|
video: 'DGN-UI-Slider-video' + Id
|
|
25
26
|
};
|
|
27
|
+
const [iframeTimeoutId, setIframeTimeoutId] = useState(null);
|
|
28
|
+
const iframeRef = useRef(null);
|
|
26
29
|
/**@reference */
|
|
27
30
|
|
|
28
31
|
if (!ref) ref = useRef(null);
|
|
@@ -40,29 +43,35 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
40
43
|
};
|
|
41
44
|
const styles = {
|
|
42
45
|
itemContainer: css`
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
display: none;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
height: 100%;
|
|
49
|
+
width: 100%;
|
|
50
|
+
&.item-animation {
|
|
51
|
+
animation: ${anime.fade} 1s;
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
51
54
|
frame: css`
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
display: block;
|
|
56
|
+
height: 100%;
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
width: 100%;
|
|
60
|
+
`,
|
|
58
61
|
image: css`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
display: block;
|
|
63
|
+
height: auto;
|
|
64
|
+
margin: auto;
|
|
65
|
+
max-height: 100%;
|
|
66
|
+
max-width: 100%;
|
|
67
|
+
width: auto;
|
|
68
|
+
`,
|
|
69
|
+
loading: css`
|
|
70
|
+
position: absolute;
|
|
71
|
+
top: 50%;
|
|
72
|
+
left: 50%;
|
|
73
|
+
transform: translate(-50%, -50%);
|
|
74
|
+
`
|
|
66
75
|
};
|
|
67
76
|
/**@function */
|
|
68
77
|
|
|
@@ -115,11 +124,14 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
115
124
|
case 'pdf':
|
|
116
125
|
{
|
|
117
126
|
return jsx("iframe", { ...props,
|
|
127
|
+
ref: iframeRef,
|
|
118
128
|
className: IDs.frame,
|
|
119
129
|
css: styles.frame,
|
|
120
130
|
frameBorder: 0,
|
|
121
|
-
src:
|
|
122
|
-
title: fileName
|
|
131
|
+
src: getIframeLink(),
|
|
132
|
+
title: fileName,
|
|
133
|
+
onLoad: iframeLoaded,
|
|
134
|
+
onError: updateIframeSrc
|
|
123
135
|
});
|
|
124
136
|
}
|
|
125
137
|
|
|
@@ -161,12 +173,40 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
161
173
|
}
|
|
162
174
|
};
|
|
163
175
|
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
const fileType = getFileType(url, undefined, false);
|
|
178
|
+
|
|
179
|
+
if (fileType === 'pdf') {
|
|
180
|
+
const intervalId = setInterval(updateIframeSrc, 2000);
|
|
181
|
+
setIframeTimeoutId(intervalId);
|
|
182
|
+
}
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
function iframeLoaded() {
|
|
186
|
+
clearInterval(iframeTimeoutId);
|
|
187
|
+
setIframeTimeoutId(null);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getIframeLink() {
|
|
191
|
+
return `https://docs.google.com/gview?url=${url}&embedded=true`;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function updateIframeSrc() {
|
|
195
|
+
if (iframeRef.current) {
|
|
196
|
+
iframeRef.current.src = getIframeLink();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
164
200
|
return jsx("div", {
|
|
165
201
|
className: [IDs.itemContainer, active ? 'active' : '', animation ? 'item-animation' : ''].join(' '),
|
|
166
202
|
css: styles.itemContainer,
|
|
167
203
|
id: IDs.itemContainer,
|
|
168
204
|
ref: ref
|
|
169
|
-
},
|
|
205
|
+
}, iframeTimeoutId && getFileType(url, undefined, false) === 'pdf' && jsx("div", {
|
|
206
|
+
css: styles.loading
|
|
207
|
+
}, jsx(IndeterminateCircularProgress, {
|
|
208
|
+
size: 'xs'
|
|
209
|
+
})), getViewer(url, getFileType(url, undefined, false)));
|
|
170
210
|
}));
|
|
171
211
|
SliderItem.defaultProps = {
|
|
172
212
|
active: false,
|