diginet-core-ui 1.3.43-beta.1 → 1.3.43-beta.2
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.
|
@@ -316,11 +316,11 @@ Checkbox.propTypes = {
|
|
|
316
316
|
/** The function will run to return a true or false value of Radio Component */
|
|
317
317
|
onChange: PropTypes.func,
|
|
318
318
|
|
|
319
|
-
/**
|
|
320
|
-
* ref methods
|
|
321
|
-
*
|
|
322
|
-
* * setChecked: Set check for input
|
|
323
|
-
* * getChecked: Get check of input
|
|
319
|
+
/**
|
|
320
|
+
* ref methods
|
|
321
|
+
*
|
|
322
|
+
* * setChecked: Set check for input
|
|
323
|
+
* * getChecked: Get check of input
|
|
324
324
|
*/
|
|
325
325
|
ref: PropTypes.any
|
|
326
326
|
};
|
|
@@ -895,7 +895,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
|
|
898
|
-
if (closeAfterSelect) {
|
|
898
|
+
if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
|
|
899
899
|
closeDropdown();
|
|
900
900
|
}
|
|
901
901
|
};
|
|
@@ -1782,7 +1782,6 @@ Dropdown.defaultProps = {
|
|
|
1782
1782
|
multiple: false,
|
|
1783
1783
|
allowSearch: false,
|
|
1784
1784
|
selectBox: false,
|
|
1785
|
-
closeAfterSelect: true,
|
|
1786
1785
|
inputProps: {},
|
|
1787
1786
|
formStyle: {},
|
|
1788
1787
|
dataSource: [],
|
|
@@ -5,9 +5,34 @@ import { css, jsx } from '@emotion/core';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { ButtonIcon } from '..';
|
|
8
|
-
import theme from '../../theme/settings';
|
|
9
8
|
import { randomString } from '../../utils';
|
|
10
9
|
import SliderItem from './slider-item';
|
|
10
|
+
import { color as colors } from '../../styles/colors';
|
|
11
|
+
import { alignCenter, backgroundTransparent, borderBox, cursorPointer, displayNone, flexCol, flexRow, justifyCenter, overflowHidden, positionAbsolute, positionRelative, userSelectNone } from '../../styles/general';
|
|
12
|
+
const {
|
|
13
|
+
system: {
|
|
14
|
+
active,
|
|
15
|
+
rest,
|
|
16
|
+
white
|
|
17
|
+
},
|
|
18
|
+
fill: {
|
|
19
|
+
pressed: fillPressed
|
|
20
|
+
}
|
|
21
|
+
} = colors;
|
|
22
|
+
const styles = {
|
|
23
|
+
iconLeft: {
|
|
24
|
+
left: 0,
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: '50%',
|
|
27
|
+
transform: 'translate(0, -50%)'
|
|
28
|
+
},
|
|
29
|
+
iconRight: {
|
|
30
|
+
right: 0,
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
top: '50%',
|
|
33
|
+
transform: 'translate(0, -50%)'
|
|
34
|
+
}
|
|
35
|
+
};
|
|
11
36
|
const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
12
37
|
animation,
|
|
13
38
|
active,
|
|
@@ -16,10 +41,8 @@ const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
16
41
|
className,
|
|
17
42
|
data,
|
|
18
43
|
onShowNavigation,
|
|
19
|
-
style
|
|
20
|
-
...props
|
|
44
|
+
style
|
|
21
45
|
}, reference) => {
|
|
22
|
-
/**@property */
|
|
23
46
|
let autoChange;
|
|
24
47
|
let currentItemIndex = 0;
|
|
25
48
|
const Id = randomString(7, {
|
|
@@ -36,107 +59,16 @@ const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
36
59
|
navigationItem: 'DGN-UI-Slider-navigation-item',
|
|
37
60
|
slideContainer: 'DGN-UI-Slider-slide-container'
|
|
38
61
|
};
|
|
39
|
-
/**@reference */
|
|
40
|
-
|
|
41
62
|
const ref = useRef(null);
|
|
42
63
|
const slideContainerRef = useRef(null);
|
|
43
64
|
const navigationRef = useRef(null);
|
|
44
65
|
const navigationListRef = useRef(null);
|
|
45
66
|
const iconLeftRef = useRef(null);
|
|
46
67
|
const iconRightRef = useRef(null);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
container: css`
|
|
52
|
-
* {
|
|
53
|
-
box-sizing: border-box;
|
|
54
|
-
margin : 0;
|
|
55
|
-
padding : 0;
|
|
56
|
-
}
|
|
57
|
-
align-items : center;
|
|
58
|
-
background-color: transparent;
|
|
59
|
-
display : flex;
|
|
60
|
-
flex-direction : column;
|
|
61
|
-
height : 100%;
|
|
62
|
-
justify-items : center;
|
|
63
|
-
position : relative;
|
|
64
|
-
resize : both;
|
|
65
|
-
.${IDs.icon} {
|
|
66
|
-
opacity: 0;
|
|
67
|
-
&.${IDs.iconLeft} {
|
|
68
|
-
cursor : pointer;
|
|
69
|
-
display : none;
|
|
70
|
-
height : 95%;
|
|
71
|
-
left : 5%;
|
|
72
|
-
position: absolute;
|
|
73
|
-
width : 15%;
|
|
74
|
-
}
|
|
75
|
-
&.${IDs.iconRight} {
|
|
76
|
-
cursor : pointer;
|
|
77
|
-
display : none;
|
|
78
|
-
height : 95%;
|
|
79
|
-
position: absolute;
|
|
80
|
-
right : 5%;
|
|
81
|
-
width : 15%;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
.${IDs.slideContainer} {
|
|
85
|
-
background-color: transparent;
|
|
86
|
-
height : 95%;
|
|
87
|
-
margin : 0 auto;
|
|
88
|
-
overflow : hidden;
|
|
89
|
-
position : relative;
|
|
90
|
-
width : 100%;
|
|
91
|
-
}
|
|
92
|
-
&:hover {
|
|
93
|
-
.${IDs.icon} {
|
|
94
|
-
opacity: 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`,
|
|
98
|
-
icon: {
|
|
99
|
-
left: '50%',
|
|
100
|
-
position: 'absolute',
|
|
101
|
-
top: '50%',
|
|
102
|
-
transform: 'translate(-50%, -50%)'
|
|
103
|
-
},
|
|
104
|
-
navigation: css`
|
|
105
|
-
background-color: ${theme.colors.white};
|
|
106
|
-
display : none;
|
|
107
|
-
height : 5%;
|
|
108
|
-
position : relative;
|
|
109
|
-
width : 100%;
|
|
110
|
-
&.navigation-hidden {
|
|
111
|
-
display: none;
|
|
112
|
-
}
|
|
113
|
-
`,
|
|
114
|
-
navigationList: css`
|
|
115
|
-
display : flex;
|
|
116
|
-
flex-direction: row;
|
|
117
|
-
left : 50%;
|
|
118
|
-
position : absolute;
|
|
119
|
-
top : 50%;
|
|
120
|
-
transform : translate(-50%, -50%);
|
|
121
|
-
.${IDs.navigationItem} {
|
|
122
|
-
background-color: ${theme.colors.secondary};
|
|
123
|
-
border-radius : 50%;
|
|
124
|
-
cursor : pointer;
|
|
125
|
-
height : 12px;
|
|
126
|
-
margin : 0 6px;
|
|
127
|
-
position : relative;
|
|
128
|
-
width : 12px;
|
|
129
|
-
:hover:not(.item-focused) {
|
|
130
|
-
background-color: ${theme.colors.info};
|
|
131
|
-
box-shadow : 0px 0px 4px 3px rgba(0, 0, 0, 0.25);
|
|
132
|
-
}
|
|
133
|
-
&.item-focused {
|
|
134
|
-
background-color: ${theme.colors.primary};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`
|
|
138
|
-
};
|
|
139
|
-
/**@function */
|
|
68
|
+
|
|
69
|
+
const _containerCSS = containerCSS(IDs);
|
|
70
|
+
|
|
71
|
+
const _navigationListCSS = navigationListCSS(IDs);
|
|
140
72
|
|
|
141
73
|
const removeClass = (className, selector) => {
|
|
142
74
|
const array = document.querySelectorAll(`.${selector}`) || document.querySelectorAll(selector);
|
|
@@ -221,8 +153,6 @@ const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
221
153
|
});
|
|
222
154
|
});
|
|
223
155
|
};
|
|
224
|
-
/**@flow */
|
|
225
|
-
|
|
226
156
|
|
|
227
157
|
useEffect(() => {
|
|
228
158
|
if (!slideContainerRef.current || !navigationRef.current || !iconLeftRef.current || !iconRightRef.current) return;
|
|
@@ -269,8 +199,15 @@ const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
269
199
|
}
|
|
270
200
|
};
|
|
271
201
|
}, [autoChangeTime, children, data]);
|
|
272
|
-
|
|
202
|
+
useImperativeHandle(reference, () => {
|
|
203
|
+
const currentRef = ref.current || {};
|
|
204
|
+
const _instance = {}; // methods
|
|
273
205
|
|
|
206
|
+
_instance.__proto__ = {}; // hidden methods
|
|
207
|
+
|
|
208
|
+
currentRef.instance = _instance;
|
|
209
|
+
return currentRef;
|
|
210
|
+
});
|
|
274
211
|
const Slider = useMemo(() => jsx("div", {
|
|
275
212
|
className: IDs.slideContainer,
|
|
276
213
|
ref: slideContainerRef
|
|
@@ -285,77 +222,164 @@ const SliderContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
285
222
|
});
|
|
286
223
|
})), [animation, autoChangeTime, children, data]);
|
|
287
224
|
const IconLeft = useMemo(() => jsx("span", {
|
|
288
|
-
className: [IDs.icon, IDs.iconLeft].join(' '),
|
|
225
|
+
className: [IDs.icon, IDs.iconLeft].join(' ').trim().replace(/\s+/g, ' '),
|
|
289
226
|
ref: iconLeftRef
|
|
290
227
|
}, jsx(ButtonIcon, {
|
|
291
228
|
circular: true,
|
|
292
229
|
viewType: 'filled',
|
|
293
|
-
|
|
294
|
-
color: 'primary',
|
|
230
|
+
color: white,
|
|
295
231
|
name: 'ArrowLeft',
|
|
296
|
-
style: styles.
|
|
232
|
+
style: styles.iconLeft,
|
|
233
|
+
viewBox: false
|
|
297
234
|
})), [children, data]);
|
|
298
235
|
const IconRight = useMemo(() => jsx("span", {
|
|
299
|
-
className: [IDs.icon, IDs.iconRight].join(' '),
|
|
236
|
+
className: [IDs.icon, IDs.iconRight].join(' ').trim().replace(/\s+/g, ' '),
|
|
300
237
|
ref: iconRightRef
|
|
301
238
|
}, jsx(ButtonIcon, {
|
|
302
239
|
circular: true,
|
|
303
240
|
viewType: 'filled',
|
|
304
|
-
|
|
305
|
-
color: 'primary',
|
|
241
|
+
color: white,
|
|
306
242
|
name: 'ArrowRight',
|
|
307
|
-
style: styles.
|
|
243
|
+
style: styles.iconRight,
|
|
244
|
+
viewBox: false
|
|
308
245
|
})), [children, data]);
|
|
309
246
|
const Navigation = useMemo(() => jsx("div", {
|
|
310
|
-
className: [IDs.navigation, onShowNavigation && 'navigation-hidden'].join(' '),
|
|
311
|
-
css:
|
|
247
|
+
className: [IDs.navigation, onShowNavigation && 'navigation-hidden'].join(' ').trim().replace(/\s+/g, ' '),
|
|
248
|
+
css: navigationCSS,
|
|
312
249
|
id: IDs.navigation,
|
|
313
250
|
ref: navigationRef
|
|
314
251
|
}, jsx("div", {
|
|
315
|
-
css:
|
|
252
|
+
css: _navigationListCSS,
|
|
316
253
|
className: IDs.navigationList,
|
|
317
254
|
id: IDs.navigationList,
|
|
318
255
|
ref: navigationListRef
|
|
319
256
|
})), [animation, autoChangeTime, children, data, onShowNavigation]);
|
|
320
257
|
return jsx("div", {
|
|
321
|
-
css:
|
|
322
|
-
className: [IDs.container, className].join(' '),
|
|
258
|
+
css: _containerCSS,
|
|
259
|
+
className: [IDs.container, className].join(' ').trim().replace(/\s+/g, ' '),
|
|
323
260
|
id: IDs.container,
|
|
324
261
|
style: style,
|
|
325
|
-
ref: ref
|
|
326
|
-
...props
|
|
262
|
+
ref: ref
|
|
327
263
|
}, Slider, IconLeft, IconRight, Navigation);
|
|
328
264
|
}));
|
|
265
|
+
|
|
266
|
+
const containerCSS = IDs => css`
|
|
267
|
+
* {
|
|
268
|
+
${borderBox};
|
|
269
|
+
margin: 0;
|
|
270
|
+
padding: 0;
|
|
271
|
+
}
|
|
272
|
+
${flexCol};
|
|
273
|
+
${alignCenter};
|
|
274
|
+
${justifyCenter};
|
|
275
|
+
${positionRelative};
|
|
276
|
+
${backgroundTransparent};
|
|
277
|
+
height: 100%;
|
|
278
|
+
resize: both;
|
|
279
|
+
.${IDs.icon} {
|
|
280
|
+
opacity: 0;
|
|
281
|
+
&.${IDs.iconLeft} {
|
|
282
|
+
${displayNone};
|
|
283
|
+
${cursorPointer};
|
|
284
|
+
${userSelectNone};
|
|
285
|
+
${positionAbsolute};
|
|
286
|
+
height: 100%;
|
|
287
|
+
left: 0;
|
|
288
|
+
margin-left: 16px;
|
|
289
|
+
width: 15%;
|
|
290
|
+
}
|
|
291
|
+
&.${IDs.iconRight} {
|
|
292
|
+
${displayNone};
|
|
293
|
+
${cursorPointer};
|
|
294
|
+
${userSelectNone};
|
|
295
|
+
${positionAbsolute};
|
|
296
|
+
height: 100%;
|
|
297
|
+
right: 0;
|
|
298
|
+
margin-right: 16px;
|
|
299
|
+
width: 15%;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
.${IDs.slideContainer} {
|
|
303
|
+
${overflowHidden};
|
|
304
|
+
${positionRelative};
|
|
305
|
+
${backgroundTransparent};
|
|
306
|
+
height: 95%;
|
|
307
|
+
margin: 0 auto;
|
|
308
|
+
width: 100%;
|
|
309
|
+
}
|
|
310
|
+
&:hover {
|
|
311
|
+
.${IDs.icon} {
|
|
312
|
+
opacity: 1;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
`;
|
|
316
|
+
|
|
317
|
+
const navigationCSS = css`
|
|
318
|
+
${displayNone};
|
|
319
|
+
${positionRelative};
|
|
320
|
+
background-color: ${white};
|
|
321
|
+
height: 5%;
|
|
322
|
+
width: 100%;
|
|
323
|
+
&.navigation-hidden {
|
|
324
|
+
${displayNone};
|
|
325
|
+
}
|
|
326
|
+
`;
|
|
327
|
+
|
|
328
|
+
const navigationListCSS = IDs => css`
|
|
329
|
+
${flexRow};
|
|
330
|
+
${positionAbsolute};
|
|
331
|
+
left: 50%;
|
|
332
|
+
top: 50%;
|
|
333
|
+
transform: translate(-50%, 14px);
|
|
334
|
+
.${IDs.navigationItem} {
|
|
335
|
+
${cursorPointer};
|
|
336
|
+
${positionRelative};
|
|
337
|
+
background-color: ${rest};
|
|
338
|
+
border-radius: 50%;
|
|
339
|
+
height: 12px;
|
|
340
|
+
margin: 0 6px;
|
|
341
|
+
width: 12px;
|
|
342
|
+
:hover:not(.item-focused) {
|
|
343
|
+
background-color: ${fillPressed};
|
|
344
|
+
}
|
|
345
|
+
&.item-focused {
|
|
346
|
+
background-color: ${active};
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
`;
|
|
350
|
+
|
|
329
351
|
SliderContainer.defaultProps = {
|
|
330
352
|
animation: true,
|
|
331
353
|
autoChangeTime: 0,
|
|
332
354
|
children: null,
|
|
333
355
|
data: [],
|
|
334
|
-
onShowNavigation: true
|
|
356
|
+
onShowNavigation: true,
|
|
357
|
+
className: '',
|
|
358
|
+
style: {}
|
|
335
359
|
};
|
|
336
360
|
SliderContainer.propTypes = {
|
|
337
|
-
/**
|
|
361
|
+
/** Index of the active item. */
|
|
338
362
|
active: PropTypes.number,
|
|
339
363
|
|
|
340
|
-
/**
|
|
364
|
+
/** Enable/disable the animation when change active item. */
|
|
341
365
|
animation: PropTypes.bool,
|
|
342
366
|
|
|
343
|
-
/**
|
|
367
|
+
/** Time to slider auto change (s). */
|
|
344
368
|
autoChangeTime: PropTypes.number,
|
|
345
369
|
|
|
346
|
-
/**
|
|
370
|
+
/** Element or node to display on slider without data. */
|
|
347
371
|
children: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
|
|
348
372
|
|
|
349
|
-
/**
|
|
373
|
+
/** Class for component. */
|
|
350
374
|
className: PropTypes.string,
|
|
351
375
|
|
|
352
|
-
/**
|
|
376
|
+
/** Data to display on slider. */
|
|
353
377
|
data: PropTypes.array,
|
|
354
378
|
|
|
355
|
-
/**
|
|
379
|
+
/** Show/hide the navigation bar. */
|
|
356
380
|
onShowNavigation: PropTypes.bool,
|
|
357
381
|
|
|
358
|
-
/**
|
|
382
|
+
/** Style inline of component. */
|
|
359
383
|
style: PropTypes.object
|
|
360
384
|
};
|
|
361
385
|
export default SliderContainer;
|
|
@@ -1,19 +1,42 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { forwardRef, memo, useEffect, useState, useRef } from 'react';
|
|
5
|
-
import { jsx, css
|
|
4
|
+
import { forwardRef, memo, useEffect, useState, useRef, useImperativeHandle } from 'react';
|
|
5
|
+
import { jsx, css } from '@emotion/core';
|
|
6
6
|
import { randomString, getFileType } from '../../utils';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { IndeterminateCircularProgress } from '../progress/circular';
|
|
9
|
+
import { animations } from '../../styles/animation';
|
|
10
|
+
import { displayBlock, displayNone, justifyCenter, positionAbsolute } from '../../styles/general';
|
|
11
|
+
const fadeIn = animations.fadeIn;
|
|
12
|
+
const regex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/g;
|
|
13
|
+
const googleDriveRegex = /(http(s)?:\/\/.)?(drive\.google\.com\/file\/d\/)/;
|
|
14
|
+
const googleDocsRegex = /(http(s)?:\/\/.)?(docs\.google\.com\/fileview\?)/;
|
|
15
|
+
|
|
16
|
+
const checkURL = link => {
|
|
17
|
+
const res = regex.test(link);
|
|
18
|
+
|
|
19
|
+
if (res) {
|
|
20
|
+
if (googleDriveRegex.test(link)) {
|
|
21
|
+
const id = link.split('/')[0] === 'drive.google.com' ? link.split('/')[3] : link.split('/')[5];
|
|
22
|
+
return `https://docs.google.com/viewer?srcid=${id}&pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (googleDocsRegex.test(link)) {
|
|
26
|
+
return `https://docs.google.com/viewer?srcid=${link.split('=')[1]}&pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return link;
|
|
31
|
+
};
|
|
32
|
+
|
|
9
33
|
const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
10
34
|
active,
|
|
11
35
|
animation,
|
|
12
36
|
fileName,
|
|
13
37
|
url,
|
|
14
38
|
...props
|
|
15
|
-
},
|
|
16
|
-
/**@property */
|
|
39
|
+
}, reference) => {
|
|
17
40
|
const Id = randomString(7, {
|
|
18
41
|
allowSymbol: false,
|
|
19
42
|
allowNumber: false
|
|
@@ -24,77 +47,9 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
24
47
|
itemContainer: 'DGN-UI-Slider-item-container-' + Id,
|
|
25
48
|
video: 'DGN-UI-Slider-video' + Id
|
|
26
49
|
};
|
|
27
|
-
const
|
|
50
|
+
const ref = useRef(null);
|
|
28
51
|
const iframeRef = useRef(null);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!ref) ref = useRef(null);
|
|
32
|
-
/**@style */
|
|
33
|
-
|
|
34
|
-
const anime = {
|
|
35
|
-
fade: keyframes`
|
|
36
|
-
from {
|
|
37
|
-
opacity: 0.4;
|
|
38
|
-
}
|
|
39
|
-
to {
|
|
40
|
-
opacity: 1;
|
|
41
|
-
}
|
|
42
|
-
`
|
|
43
|
-
};
|
|
44
|
-
const styles = {
|
|
45
|
-
itemContainer: css`
|
|
46
|
-
display: none;
|
|
47
|
-
justify-content: center;
|
|
48
|
-
height: 100%;
|
|
49
|
-
width: 100%;
|
|
50
|
-
&.item-animation {
|
|
51
|
-
animation: ${anime.fade} 1s;
|
|
52
|
-
}
|
|
53
|
-
`,
|
|
54
|
-
frame: css`
|
|
55
|
-
display: block;
|
|
56
|
-
height: 85vh;
|
|
57
|
-
margin: 0;
|
|
58
|
-
padding: 0;
|
|
59
|
-
width: 100%;
|
|
60
|
-
`,
|
|
61
|
-
image: css`
|
|
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
|
-
`
|
|
75
|
-
};
|
|
76
|
-
/**@function */
|
|
77
|
-
|
|
78
|
-
const regex = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g;
|
|
79
|
-
const googleDriveRegex = /(http(s)?:\/\/.)?(drive\.google\.com\/file\/d\/)/;
|
|
80
|
-
const googleDocsRegex = /(http(s)?:\/\/.)?(docs\.google\.com\/fileview\?)/;
|
|
81
|
-
|
|
82
|
-
const checkURL = link => {
|
|
83
|
-
const res = regex.test(link);
|
|
84
|
-
|
|
85
|
-
if (res) {
|
|
86
|
-
if (googleDriveRegex.test(link)) {
|
|
87
|
-
const id = link.split('/')[0] === 'drive.google.com' ? link.split('/')[3] : link.split('/')[5];
|
|
88
|
-
return `https://docs.google.com/viewer?srcid=${id}&pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (googleDocsRegex.test(link)) {
|
|
92
|
-
return `https://docs.google.com/viewer?srcid=${link.split('=')[1]}&pid=explorer&efh=false&a=v&chrome=false&embedded=true`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return link;
|
|
97
|
-
};
|
|
52
|
+
const [iframeTimeoutId, setIframeTimeoutId] = useState(null);
|
|
98
53
|
|
|
99
54
|
const getViewer = (filePath, fileType) => {
|
|
100
55
|
switch (fileType) {
|
|
@@ -102,8 +57,9 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
102
57
|
{
|
|
103
58
|
return jsx("img", { ...props,
|
|
104
59
|
className: IDs.image,
|
|
105
|
-
css:
|
|
106
|
-
src: filePath
|
|
60
|
+
css: imageCSS,
|
|
61
|
+
src: filePath,
|
|
62
|
+
alt: ''
|
|
107
63
|
});
|
|
108
64
|
}
|
|
109
65
|
|
|
@@ -112,7 +68,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
112
68
|
{
|
|
113
69
|
return jsx("iframe", { ...props,
|
|
114
70
|
className: IDs.frame,
|
|
115
|
-
css:
|
|
71
|
+
css: frameCSS,
|
|
116
72
|
frameBorder: 0,
|
|
117
73
|
src: `https://view.officeapps.live.com/op/view.aspx?src=${filePath}`,
|
|
118
74
|
title: fileName
|
|
@@ -124,7 +80,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
124
80
|
return jsx("iframe", { ...props,
|
|
125
81
|
ref: iframeRef,
|
|
126
82
|
className: IDs.frame,
|
|
127
|
-
css:
|
|
83
|
+
css: frameCSS,
|
|
128
84
|
frameBorder: 0,
|
|
129
85
|
src: getIframeLink(),
|
|
130
86
|
title: fileName,
|
|
@@ -151,7 +107,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
151
107
|
{
|
|
152
108
|
return jsx("iframe", { ...props,
|
|
153
109
|
className: IDs.frame,
|
|
154
|
-
css:
|
|
110
|
+
css: frameCSS,
|
|
155
111
|
frameBorder: 0,
|
|
156
112
|
src: checkURL(filePath),
|
|
157
113
|
title: fileName
|
|
@@ -162,7 +118,7 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
162
118
|
{
|
|
163
119
|
return jsx("iframe", { ...props,
|
|
164
120
|
className: IDs.frame,
|
|
165
|
-
css:
|
|
121
|
+
css: frameCSS,
|
|
166
122
|
frameBorder: 0,
|
|
167
123
|
src: filePath,
|
|
168
124
|
title: fileName
|
|
@@ -180,32 +136,71 @@ const SliderItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
180
136
|
}
|
|
181
137
|
}, []);
|
|
182
138
|
|
|
183
|
-
|
|
139
|
+
const iframeLoaded = () => {
|
|
184
140
|
clearInterval(iframeTimeoutId);
|
|
185
141
|
setIframeTimeoutId(null);
|
|
186
|
-
}
|
|
142
|
+
};
|
|
187
143
|
|
|
188
|
-
|
|
144
|
+
const getIframeLink = () => {
|
|
189
145
|
return `https://docs.google.com/gview?url=${url}&embedded=true`;
|
|
190
|
-
}
|
|
146
|
+
};
|
|
191
147
|
|
|
192
|
-
|
|
148
|
+
const updateIframeSrc = () => {
|
|
193
149
|
if (iframeRef.current) {
|
|
194
150
|
iframeRef.current.src = getIframeLink();
|
|
195
151
|
}
|
|
196
|
-
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
useImperativeHandle(reference, () => {
|
|
155
|
+
const currentRef = ref.current || {};
|
|
156
|
+
const _instance = {}; // methods
|
|
197
157
|
|
|
158
|
+
_instance.__proto__ = {}; // hidden methods
|
|
159
|
+
|
|
160
|
+
currentRef.instance = _instance;
|
|
161
|
+
return currentRef;
|
|
162
|
+
});
|
|
198
163
|
return jsx("div", {
|
|
199
|
-
className: [IDs.itemContainer, active ? 'active' : '', animation ? 'item-animation' : ''].join(' '),
|
|
200
|
-
css:
|
|
164
|
+
className: [IDs.itemContainer, active ? 'active' : '', animation ? 'item-animation' : ''].join(' ').trim().replace(/\s+/g, ' '),
|
|
165
|
+
css: itemContainerCSS,
|
|
201
166
|
id: IDs.itemContainer,
|
|
202
167
|
ref: ref
|
|
203
168
|
}, iframeTimeoutId && getFileType(url, undefined, false) === 'pdf' && jsx("div", {
|
|
204
|
-
css:
|
|
169
|
+
css: loadingCSS
|
|
205
170
|
}, jsx(IndeterminateCircularProgress, {
|
|
206
171
|
size: 'xs'
|
|
207
172
|
})), getViewer(url, getFileType(url, undefined, false)));
|
|
208
173
|
}));
|
|
174
|
+
const itemContainerCSS = css`
|
|
175
|
+
${displayNone};
|
|
176
|
+
${justifyCenter};
|
|
177
|
+
height: 100%;
|
|
178
|
+
width: 100%;
|
|
179
|
+
&.item-animation {
|
|
180
|
+
animation: ${fadeIn} 1s;
|
|
181
|
+
}
|
|
182
|
+
`;
|
|
183
|
+
const frameCSS = css`
|
|
184
|
+
${displayBlock};
|
|
185
|
+
height: 85vh;
|
|
186
|
+
margin: 0;
|
|
187
|
+
padding: 0;
|
|
188
|
+
width: 100%;
|
|
189
|
+
`;
|
|
190
|
+
const imageCSS = css`
|
|
191
|
+
${displayBlock};
|
|
192
|
+
height: auto;
|
|
193
|
+
margin: auto;
|
|
194
|
+
max-height: 100%;
|
|
195
|
+
max-width: 100%;
|
|
196
|
+
width: auto;
|
|
197
|
+
`;
|
|
198
|
+
const loadingCSS = css`
|
|
199
|
+
${positionAbsolute};
|
|
200
|
+
top: 50%;
|
|
201
|
+
left: 50%;
|
|
202
|
+
transform: translate(-50%, -50%);
|
|
203
|
+
`;
|
|
209
204
|
SliderItem.defaultProps = {
|
|
210
205
|
active: false,
|
|
211
206
|
animation: true
|