diginet-core-ui 1.3.35-beta.5 → 1.3.35-beta.6
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/chip/index.js
CHANGED
|
@@ -48,6 +48,7 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
48
48
|
disabled,
|
|
49
49
|
readOnly,
|
|
50
50
|
children,
|
|
51
|
+
style,
|
|
51
52
|
...props
|
|
52
53
|
}, reference) => {
|
|
53
54
|
const ref = useRef(null);
|
|
@@ -114,7 +115,8 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
114
115
|
className: size
|
|
115
116
|
}, jsx(Typography, {
|
|
116
117
|
type: size === 'small' ? 'p2' : 'p1',
|
|
117
|
-
color: 'inherit'
|
|
118
|
+
color: 'inherit',
|
|
119
|
+
lineClamp: 1
|
|
118
120
|
}, renderLabel()));
|
|
119
121
|
}, [label, size, startIcon, endIcon, clearAble]);
|
|
120
122
|
const endIconView = useMemo(() => {
|
|
@@ -149,6 +151,7 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
149
151
|
css: ChipRootCSS(onClick, onDbClick, color),
|
|
150
152
|
ref: ref,
|
|
151
153
|
className: ['DGN-UI-Chip', size, className, color && color !== 'default' && color, color && color !== 'default' && viewType, disabled && 'chip--disabled', readOnly && 'chip--readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
154
|
+
style: style,
|
|
152
155
|
onClick: _onClick,
|
|
153
156
|
onDoubleClick: _onDbClick,
|
|
154
157
|
...props
|
|
@@ -272,6 +275,7 @@ const ChipRootCSS = (onClick, onDbClick, color) => css`
|
|
|
272
275
|
Chip.defaultProps = {
|
|
273
276
|
label: '',
|
|
274
277
|
className: '',
|
|
278
|
+
style: {},
|
|
275
279
|
viewType: 'outlined',
|
|
276
280
|
size: 'small',
|
|
277
281
|
clearAble: false
|
|
@@ -284,6 +288,9 @@ Chip.propTypes = {
|
|
|
284
288
|
className: PropTypes.string,
|
|
285
289
|
|
|
286
290
|
/** max length content to display was allowed */
|
|
291
|
+
|
|
292
|
+
/** style inline of component */
|
|
293
|
+
style: PropTypes.object,
|
|
287
294
|
maxLength: PropTypes.number,
|
|
288
295
|
|
|
289
296
|
/** the icon display at head of Chip */
|
|
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { jsx, css } from '@emotion/core';
|
|
9
9
|
import { Account } from '../../../icons';
|
|
10
10
|
import AvatarDefault from '../../../assets/avatar/default.svg';
|
|
11
|
-
import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon } from '../../';
|
|
11
|
+
import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon, Typography } from '../../';
|
|
12
12
|
import { mapParent, randomString, updatePosition } from '../../../utils';
|
|
13
13
|
import { getGlobal } from '../../../global';
|
|
14
14
|
import { color as colors } from '../../../styles/colors';
|
|
@@ -101,10 +101,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
101
101
|
formStyle,
|
|
102
102
|
labelProps,
|
|
103
103
|
errorStyle,
|
|
104
|
-
refs,
|
|
105
104
|
children,
|
|
106
105
|
dropdownItemStyle
|
|
107
|
-
},
|
|
106
|
+
}, reference) => {
|
|
108
107
|
const dropdownRef = useRef(null);
|
|
109
108
|
const timerRef = useRef(null);
|
|
110
109
|
const formRef = useRef(null);
|
|
@@ -119,7 +118,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
119
118
|
allowSymbol: false
|
|
120
119
|
}));
|
|
121
120
|
const [openState, setOpenState] = useState(false);
|
|
122
|
-
const [errorState, setErrorState] = useState(error && !valueProp && valueProp !== 0);
|
|
123
121
|
const [showClear, setShowClear] = useState(false);
|
|
124
122
|
|
|
125
123
|
const _isMobile = isMobile.any();
|
|
@@ -845,7 +843,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
845
843
|
clearAble: true,
|
|
846
844
|
onRemove: e => onRemove(e, value),
|
|
847
845
|
style: {
|
|
848
|
-
margin: '3px 0'
|
|
846
|
+
margin: '3px 0',
|
|
847
|
+
width: '100%'
|
|
849
848
|
}
|
|
850
849
|
});
|
|
851
850
|
}
|
|
@@ -1056,7 +1055,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1056
1055
|
clearAble: true,
|
|
1057
1056
|
onRemove: e => onRemove(e, value),
|
|
1058
1057
|
style: {
|
|
1059
|
-
margin: '3px 0'
|
|
1058
|
+
margin: '3px 0',
|
|
1059
|
+
width: '100%'
|
|
1060
1060
|
}
|
|
1061
1061
|
});
|
|
1062
1062
|
}
|
|
@@ -1085,8 +1085,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1085
1085
|
const icon = getIconFromData(data);
|
|
1086
1086
|
const valueWithIcon = jsx(Fragment, null, icon && jsx("div", {
|
|
1087
1087
|
css: DropdownIconCSS
|
|
1088
|
-
}, icon), jsx(
|
|
1089
|
-
|
|
1088
|
+
}, icon), jsx(Typography, {
|
|
1089
|
+
type: 'p1',
|
|
1090
|
+
lineClamp: 1,
|
|
1091
|
+
hoverTooltip: !_isMobile
|
|
1090
1092
|
}, text));
|
|
1091
1093
|
const el = document.createElement('div');
|
|
1092
1094
|
el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
|
|
@@ -1096,17 +1098,43 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1096
1098
|
}
|
|
1097
1099
|
};
|
|
1098
1100
|
|
|
1099
|
-
useImperativeHandle(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1101
|
+
useImperativeHandle(reference, () => {
|
|
1102
|
+
const currentRef = dropdownRef.current || {};
|
|
1103
|
+
const _instance = {
|
|
1104
|
+
closeDropdown: () => {
|
|
1105
|
+
closeDropdown();
|
|
1106
|
+
},
|
|
1107
|
+
showDropdown: () => {
|
|
1108
|
+
showDropdown();
|
|
1109
|
+
},
|
|
1110
|
+
onClear,
|
|
1111
|
+
setPreviousValue,
|
|
1112
|
+
setValue: value => {
|
|
1113
|
+
if (allValue[unique][allValue[unique].length - 1] !== value) {
|
|
1114
|
+
allValue[unique].push(value);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
setValueIntoInput(value);
|
|
1118
|
+
}
|
|
1119
|
+
}; // methods
|
|
1120
|
+
|
|
1121
|
+
_instance.__proto__ = {}; // hidden methods
|
|
1122
|
+
|
|
1123
|
+
currentRef.instance = _instance; // keep old method
|
|
1124
|
+
|
|
1125
|
+
currentRef.closeDropdown = () => closeDropdown();
|
|
1126
|
+
|
|
1127
|
+
currentRef.showDropdown = () => showDropdown();
|
|
1128
|
+
|
|
1129
|
+
currentRef.onClear = onClear, currentRef.setPreviousValue = setPreviousValue, currentRef.setValue = value => {
|
|
1130
|
+
if (allValue[unique][allValue[unique].length - 1] !== value) {
|
|
1131
|
+
allValue[unique].push(value);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
setValueIntoInput(value);
|
|
1135
|
+
}, currentRef.DOM = dropdownRef.current;
|
|
1136
|
+
return currentRef;
|
|
1137
|
+
});
|
|
1110
1138
|
useEffect(() => {
|
|
1111
1139
|
setShowClear(clearAble && checkHasValue(valueProp) && !disabled && !readOnly && !loading);
|
|
1112
1140
|
}, [clearAble, valueProp, disabled, readOnly, loading]);
|
|
@@ -1126,7 +1154,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1126
1154
|
};
|
|
1127
1155
|
}, [valueObjectDefault]);
|
|
1128
1156
|
useEffect(() => {
|
|
1129
|
-
!!refs && refs(dropdownRef);
|
|
1130
1157
|
allValue[unique] = [];
|
|
1131
1158
|
|
|
1132
1159
|
if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
|
|
@@ -1190,9 +1217,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1190
1217
|
};
|
|
1191
1218
|
}
|
|
1192
1219
|
}, [loading]);
|
|
1193
|
-
useEffect(() => {
|
|
1194
|
-
setErrorState(error && (!valueProp && valueProp !== 0 || (valueProp === null || valueProp === void 0 ? void 0 : valueProp.length) === 0));
|
|
1195
|
-
}, [error, valueProp]);
|
|
1196
1220
|
useEffect(() => {
|
|
1197
1221
|
if (valueProp !== undefined && (!boxRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
1198
1222
|
setValueIntoInput(valueProp);
|
|
@@ -1309,7 +1333,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1309
1333
|
className: ['DGN-UI-Dropdown-Form', openState && 'dropdown-showing'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1310
1334
|
style: formStyle
|
|
1311
1335
|
}, jsx("div", {
|
|
1312
|
-
css: _InputCSS
|
|
1336
|
+
css: _InputCSS,
|
|
1337
|
+
className: 'DGN-UI-Dropdown-Form-Input'
|
|
1313
1338
|
}, multiple ? jsx("div", { ...inputProps,
|
|
1314
1339
|
style: {
|
|
1315
1340
|
cursor: 'text',
|
|
@@ -1367,7 +1392,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1367
1392
|
disabled: disabled || readOnly
|
|
1368
1393
|
})));
|
|
1369
1394
|
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
|
|
1370
|
-
const errorComp = useMemo(() =>
|
|
1395
|
+
const errorComp = useMemo(() => error && jsx(HelperText, {
|
|
1371
1396
|
disabled: disabled,
|
|
1372
1397
|
style: {
|
|
1373
1398
|
minHeight: '16px',
|
|
@@ -1375,13 +1400,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1375
1400
|
top: '100%',
|
|
1376
1401
|
...errorStyle
|
|
1377
1402
|
}
|
|
1378
|
-
}, error), [error,
|
|
1403
|
+
}, error), [error, disabled, errorStyle]);
|
|
1379
1404
|
/* End component */
|
|
1380
1405
|
|
|
1381
1406
|
return jsx(Fragment, null, jsx("div", {
|
|
1382
1407
|
ref: dropdownRef,
|
|
1383
1408
|
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
|
|
1384
|
-
className: ['DGN-UI-Dropdown', className,
|
|
1409
|
+
className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1385
1410
|
style: style
|
|
1386
1411
|
}, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
|
|
1387
1412
|
}));
|
|
@@ -1389,7 +1414,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1389
1414
|
|
|
1390
1415
|
const InputCSS = (multiple, renderSelectedItem, clearAble) => css`
|
|
1391
1416
|
${flexRow};
|
|
1392
|
-
|
|
1417
|
+
width: 100%;
|
|
1393
1418
|
${!multiple && renderSelectedItem ? `width: calc(100% - 34px${clearAble ? ' - 18px' : ''})` : ''}
|
|
1394
1419
|
`;
|
|
1395
1420
|
|
|
@@ -1401,11 +1426,15 @@ const DropdownIconCSS = css`
|
|
|
1401
1426
|
height: inherit;
|
|
1402
1427
|
margin-right: 8px;
|
|
1403
1428
|
height: 32px;
|
|
1429
|
+
min-height: 32px;
|
|
1404
1430
|
width: 32px;
|
|
1431
|
+
min-width: 32px;
|
|
1405
1432
|
border-radius: 16px;
|
|
1406
1433
|
img {
|
|
1407
1434
|
height: 32px;
|
|
1435
|
+
min-height: 32px;
|
|
1408
1436
|
width: 32px;
|
|
1437
|
+
min-width: 32px;
|
|
1409
1438
|
object-fit: cover;
|
|
1410
1439
|
}
|
|
1411
1440
|
`;
|
|
@@ -1427,8 +1456,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1427
1456
|
${flexWrap};
|
|
1428
1457
|
${overflowHidden};
|
|
1429
1458
|
${breakWord};
|
|
1430
|
-
|
|
1431
|
-
${!multiple ? 'min-height: 24px; max-width: 100%; white-space: nowrap;' : ''}
|
|
1459
|
+
${!multiple ? 'min-height: 24px; max-width: 100%;' : ''}
|
|
1432
1460
|
&::after {
|
|
1433
1461
|
${flexRow};
|
|
1434
1462
|
${positionAbsolute};
|
|
@@ -1459,10 +1487,14 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1459
1487
|
min-width: 24px;
|
|
1460
1488
|
` : `
|
|
1461
1489
|
height: 24px;
|
|
1490
|
+
min-height: 24px;
|
|
1462
1491
|
width: 24px;
|
|
1492
|
+
min-width: 24px;
|
|
1463
1493
|
img {
|
|
1464
1494
|
height: 24px;
|
|
1495
|
+
min-height: 24px;
|
|
1465
1496
|
width: 24px;
|
|
1497
|
+
min-width: 24px;
|
|
1466
1498
|
}
|
|
1467
1499
|
`}
|
|
1468
1500
|
}
|
|
@@ -1488,7 +1520,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1488
1520
|
${alignCenter};
|
|
1489
1521
|
${positionRelative};
|
|
1490
1522
|
${borderBox};
|
|
1491
|
-
|
|
1523
|
+
width: 100%;
|
|
1492
1524
|
padding-bottom: ${multiple ? 1 : 4}px;
|
|
1493
1525
|
padding-top: ${multiple ? 1 : 4}px;
|
|
1494
1526
|
&:not(:focus-within):hover {
|
|
@@ -1543,7 +1575,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1543
1575
|
${borderRadius4px};
|
|
1544
1576
|
${borderBox};
|
|
1545
1577
|
${border(1, rest)};
|
|
1546
|
-
|
|
1578
|
+
width: 100%;
|
|
1547
1579
|
min-height: 40px;
|
|
1548
1580
|
&:not(:focus-within):hover {
|
|
1549
1581
|
background-color: ${hover};
|
|
@@ -1648,7 +1680,6 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1648
1680
|
${displayBlock};
|
|
1649
1681
|
${positionRelative};
|
|
1650
1682
|
margin-bottom: 20px;
|
|
1651
|
-
/* min-width: 150px; */
|
|
1652
1683
|
height: max-content;
|
|
1653
1684
|
&.error {
|
|
1654
1685
|
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
@@ -1663,8 +1694,6 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1663
1694
|
}
|
|
1664
1695
|
&.dgn-dropdown-loading,
|
|
1665
1696
|
&.disabled {
|
|
1666
|
-
${pointerEventsNone};
|
|
1667
|
-
${userSelectNone};
|
|
1668
1697
|
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1669
1698
|
border-color: ${systemDisabled};
|
|
1670
1699
|
.css-${IconCSS(viewType, loading, showClear).name} {
|
|
@@ -1864,9 +1893,6 @@ Dropdown.propTypes = {
|
|
|
1864
1893
|
/** The array of elements that appear in the dropdown */
|
|
1865
1894
|
dataSource: PropTypes.array,
|
|
1866
1895
|
|
|
1867
|
-
/** The function to get ref of Dropdown component */
|
|
1868
|
-
refs: PropTypes.func,
|
|
1869
|
-
|
|
1870
1896
|
/** function displays items by custom<br/>
|
|
1871
1897
|
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1872
1898
|
* --> such as: displayExpr={'name - role'}
|
|
@@ -1895,7 +1921,22 @@ Dropdown.propTypes = {
|
|
|
1895
1921
|
/** the contents in Dropdown box (Exp: TreeView) */
|
|
1896
1922
|
children: PropTypes.node,
|
|
1897
1923
|
|
|
1898
|
-
/**
|
|
1899
|
-
|
|
1924
|
+
/**
|
|
1925
|
+
* ref methods
|
|
1926
|
+
*
|
|
1927
|
+
* how to get component element? ref.current
|
|
1928
|
+
*
|
|
1929
|
+
* how to call method? ref.current.instance.{method}
|
|
1930
|
+
*
|
|
1931
|
+
* * showDropdown(): Show dropdown
|
|
1932
|
+
* * closeDropdown(): Close dropdown
|
|
1933
|
+
* * onClear(): Clear selected value
|
|
1934
|
+
* * setPreviousValue(): Set value to previous value
|
|
1935
|
+
* * setValue(value): Set value of dropdown
|
|
1936
|
+
* * @param {value} - string || number || array
|
|
1937
|
+
*/
|
|
1938
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1939
|
+
current: PropTypes.instanceOf(Element)
|
|
1940
|
+
})])
|
|
1900
1941
|
};
|
|
1901
1942
|
export default Dropdown;
|
|
@@ -194,7 +194,8 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
194
194
|
keyCode === 188 || // ,
|
|
195
195
|
(ctrlKey || metaKey) && (keyCode === 65 || keyCode === 67 || keyCode === 86) || // ctrl + A, ctrl + C, ctrl + V
|
|
196
196
|
keyCode === 46 || // key delete
|
|
197
|
-
keyCode === 189
|
|
197
|
+
keyCode === 189 || // -
|
|
198
|
+
keyCode === 9; // tab
|
|
198
199
|
// The key is delete (|| remove) and focus after the thousand digit
|
|
199
200
|
|
|
200
201
|
const removeDot = keyCode === 8 && selectionEnd - selectionStart <= 1 && value.charAt(selectionEnd - 1) === thousandSymbol; // Decimal
|
|
@@ -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,
|