diginet-core-ui 1.3.42-beta.9 → 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.
@@ -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
  };
@@ -1419,7 +1419,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1419
1419
  }, error), [error, disabled, errorStyle]);
1420
1420
  const dropdownComp = useMemo(() => {
1421
1421
  return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1422
- }, [openState]);
1422
+ }, [openState, dataSource]);
1423
1423
  /* End component */
1424
1424
 
1425
1425
  return jsx(Fragment, null, jsx("div", {
@@ -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: [],
@@ -1822,14 +1821,14 @@ Dropdown.propTypes = {
1822
1821
  /** display this icon if not found the icon follow iconExpr */
1823
1822
  iconDefault: PropTypes.string,
1824
1823
 
1825
- /** field name used for icon display<br/>
1826
- * Example:<br/>
1827
- * &nbsp;&nbsp;string: 'icon'<br/>
1828
- * &nbsp;&nbsp;object: {<br/>
1829
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1830
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1831
- * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1832
- * &nbsp;&nbsp;}
1824
+ /** field name used for icon display<br/>
1825
+ * Example:<br/>
1826
+ * &nbsp;&nbsp;string: 'icon'<br/>
1827
+ * &nbsp;&nbsp;object: {<br/>
1828
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: 'icon',<br/>
1829
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prefix: 'https://imglink.com',<br/>
1830
+ * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;suffix: '.jpg'<br/>
1831
+ * &nbsp;&nbsp;}
1833
1832
  */
1834
1833
  iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1835
1834
  key: PropTypes.string,
@@ -1847,9 +1846,9 @@ Dropdown.propTypes = {
1847
1846
  /** field name used for text display in input */
1848
1847
  keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1849
1848
 
1850
- /** field name used for text display<br/>
1851
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1852
- * Note: don't use 'id - name', return undefined
1849
+ /** field name used for text display<br/>
1850
+ * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1851
+ * Note: don't use 'id - name', return undefined
1853
1852
  */
1854
1853
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1855
1854
 
@@ -1859,9 +1858,9 @@ Dropdown.propTypes = {
1859
1858
  /** the field name used for the returned result */
1860
1859
  valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1861
1860
 
1862
- /**
1863
- * duration wait enter search content on search<br/>
1864
- * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1861
+ /**
1862
+ * duration wait enter search content on search<br/>
1863
+ * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1865
1864
  */
1866
1865
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1867
1866
 
@@ -1928,19 +1927,19 @@ Dropdown.propTypes = {
1928
1927
  /** The array of elements that appear in the dropdown */
1929
1928
  dataSource: PropTypes.array,
1930
1929
 
1931
- /** function displays items by custom<br/>
1932
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1933
- * --> such as: displayExpr={'name - role'}
1930
+ /** function displays items by custom<br/>
1931
+ * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1932
+ * --> such as: displayExpr={'name - role'}
1934
1933
  */
1935
1934
  renderItem: PropTypes.func,
1936
1935
 
1937
- /** function displays selected items by custom, example:<br/>
1938
- * renderItem={(data, index) => index + ' - ' + data.name}<br/>
1936
+ /** function displays selected items by custom, example:<br/>
1937
+ * renderItem={(data, index) => index + ' - ' + data.name}<br/>
1939
1938
  */
1940
1939
  renderSelectedItem: PropTypes.func,
1941
1940
 
1942
- /** the function will run when entering input<br/>
1943
- * if undefined: the filter function will run (default)
1941
+ /** the function will run when entering input<br/>
1942
+ * if undefined: the filter function will run (default)
1944
1943
  */
1945
1944
  onInput: PropTypes.func,
1946
1945
 
@@ -1959,19 +1958,19 @@ Dropdown.propTypes = {
1959
1958
  /** the contents in Dropdown box (Exp: TreeView) */
1960
1959
  children: PropTypes.node,
1961
1960
 
1962
- /**
1963
- * ref methods
1964
- *
1965
- * how to get component element? ref.current
1966
- *
1967
- * how to call method? ref.current.instance.{method}
1968
- *
1969
- * * showDropdown(): Show dropdown
1970
- * * closeDropdown(): Close dropdown
1971
- * * onClear(): Clear selected value
1972
- * * setPreviousValue(): Set value to previous value
1973
- * * setValue(value): Set value of dropdown
1974
- * * @param {value} - string || number || array
1961
+ /**
1962
+ * ref methods
1963
+ *
1964
+ * how to get component element? ref.current
1965
+ *
1966
+ * how to call method? ref.current.instance.{method}
1967
+ *
1968
+ * * showDropdown(): Show dropdown
1969
+ * * closeDropdown(): Close dropdown
1970
+ * * onClear(): Clear selected value
1971
+ * * setPreviousValue(): Set value to previous value
1972
+ * * setValue(value): Set value of dropdown
1973
+ * * @param {value} - string || number || array
1975
1974
  */
1976
1975
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1977
1976
  current: PropTypes.instanceOf(Element)
@@ -153,7 +153,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
153
153
  style: style
154
154
  }, label ? jsx(Label, { ...labelProps
155
155
  }, label) : null, jsx(InputBase, { ...inputProps,
156
- className: open && 'dropdown-focus',
156
+ className: open ? 'dropdown-focus' : '',
157
157
  style: inputStyle,
158
158
  viewType: viewType,
159
159
  inputRef: inputRef,
@@ -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
- useImperativeHandle(reference, () => ref.current);
48
- /**@style */
49
-
50
- const styles = {
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
- /**@memo */
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
- size: 'tiny',
294
- color: 'primary',
230
+ color: white,
295
231
  name: 'ArrowLeft',
296
- style: styles.icon
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
- size: 'tiny',
305
- color: 'primary',
241
+ color: white,
306
242
  name: 'ArrowRight',
307
- style: styles.icon
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: styles.navigation,
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: styles.navigationList,
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: styles.container,
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
- /** index of the active item */
361
+ /** Index of the active item. */
338
362
  active: PropTypes.number,
339
363
 
340
- /** enable/disable the animation when change active item */
364
+ /** Enable/disable the animation when change active item. */
341
365
  animation: PropTypes.bool,
342
366
 
343
- /** time to slider auto change (s) */
367
+ /** Time to slider auto change (s). */
344
368
  autoChangeTime: PropTypes.number,
345
369
 
346
- /** element or node to display on slider without data */
370
+ /** Element or node to display on slider without data. */
347
371
  children: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
348
372
 
349
- /** className of the slider container */
373
+ /** Class for component. */
350
374
  className: PropTypes.string,
351
375
 
352
- /** data to display on slider */
376
+ /** Data to display on slider. */
353
377
  data: PropTypes.array,
354
378
 
355
- /** show/hide the navigation bar */
379
+ /** Show/hide the navigation bar. */
356
380
  onShowNavigation: PropTypes.bool,
357
381
 
358
- /** style of the component, style-inline - the highest priority */
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, keyframes } from '@emotion/core';
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
- }, ref) => {
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 [iframeTimeoutId, setIframeTimeoutId] = useState(null);
50
+ const ref = useRef(null);
28
51
  const iframeRef = useRef(null);
29
- /**@reference */
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: styles.image,
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: styles.frame,
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: styles.frame,
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: styles.frame,
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: styles.frame,
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
- function iframeLoaded() {
139
+ const iframeLoaded = () => {
184
140
  clearInterval(iframeTimeoutId);
185
141
  setIframeTimeoutId(null);
186
- }
142
+ };
187
143
 
188
- function getIframeLink() {
144
+ const getIframeLink = () => {
189
145
  return `https://docs.google.com/gview?url=${url}&embedded=true`;
190
- }
146
+ };
191
147
 
192
- function updateIframeSrc() {
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: styles.itemContainer,
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: styles.loading
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.42-beta.9",
3
+ "version": "1.3.43-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,52 +38,68 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.43
42
+ - \[Added\]: MenuIcon – MHRM00N0002, MHRM39N0018, MHRM39N0019, MHRM00N0003, MHRM00N0004 , MHRM13N0002, MHRM13N0003, MHRM29N0004
43
+ - \[Changed\]: Checkbox - Add labelProps
44
+ - \[Changed\]: PagingInfo - Add case listPerPage not include itemsPerPage
45
+ - \[Changed\]: PagingInfo - Update design typeShort (Design update)
46
+ - \[Changed\]: Tab - Update vertical tab (Design update)
47
+ - \[Changed\]: Checkbox - Fix spacing & Update UI with New Design
48
+ - \[Changed\]: Toggle - Add props readOnly - update UI with new design
49
+ - \[Changed\]: Label - Reuse props of Typography component
50
+ - \[Changed\]: TextInput - Change logic showing error
51
+ - \[Fixed\]: TextInput - Optimize code, manage with hook useState
52
+ - \[Fixed\]: InputBase - Optimize code, manage with hook useState
53
+ - \[Fixed\]: DropdownBox - Change onChangeInput, delayOnInput according to new InputBase; Fix warning className
54
+ - \[Fixed\]: FormGroup - Fix bug css
55
+ - \[Fixed\]: NumberInput - Fix case VIE keyboard
56
+
41
57
  ## 1.3.42
42
- \[Added\]: Icon - MoneyHistory, Calculate, ShoppingCart
58
+ - \[Added\]: Icon - MoneyHistory, Calculate, ShoppingCart
43
59
 
44
60
  ## 1.3.41
45
- \[Fixed\]: DropdownBox - Fix zIndex
61
+ - \[Fixed\]: DropdownBox - Fix zIndex
46
62
 
47
63
  ## 1.3.40
48
- \[Fixed\]: Slider - Fix bug can't view https file
49
- \[Fixed\]: Typography - Fix word-wrap css
50
- \[Fixed\]: Slider - Fix bug not showing pdf file with blob url
64
+ - \[Fixed\]: Slider - Fix bug can't view https file
65
+ - \[Fixed\]: Typography - Fix word-wrap css
66
+ - \[Fixed\]: Slider - Fix bug not showing pdf file with blob url
51
67
 
52
68
  ## 1.3.39
53
- \[Added\]: MenuIcon - MHRM29N0003
69
+ - \[Added\]: MenuIcon - MHRM29N0003
54
70
 
55
71
  ## 1.3.38
56
- \[Added\]: System - Phát triển chuẩn zIndex
57
- \[Changed\]: NumberInput - Phát triển lại component NumberInput
58
- \[Fixed\]: Accordion - Fix bug Accordion auto expand when render; Add prop style, id; Fix css
59
- \[Fixed\]: Radio - Fix spacing & Update UI with New Design
60
- \[Fixed\]: Toggle - Fix Toggle when label is line-break, Update style Toggle with new Design
61
- \[Fixed\]: Divider - Fix width, height Divider
72
+ - \[Added\]: System - Phát triển chuẩn zIndex
73
+ - \[Changed\]: NumberInput - Phát triển lại component NumberInput
74
+ - \[Fixed\]: Accordion - Fix bug Accordion auto expand when render; Add prop style, id; Fix css
75
+ - \[Fixed\]: Radio - Fix spacing & Update UI with New Design
76
+ - \[Fixed\]: Toggle - Fix Toggle when label is line-break, Update style Toggle with new Design
77
+ - \[Fixed\]: Divider - Fix width, height Divider
62
78
 
63
79
  ## 1.3.37
64
- \[Added\]: Icon – EditNote, Payment
65
- \[Added\]: MenuIcon - MHRM29N0002
66
- \[Changed\]: Alert - Add white background behind opacity background color
67
- \[Changed\]: Tech - Add storybook for Colors
68
- \[Changed\]: Attachment - Add ref method openFileDialog
69
- \[Changed\]: Modal - Change position of Modal from center to top; Add prop alignment
70
- \[Changed\]: Icon - Remove duplicate icons
71
- \[Changed\]: Icon – Pdf, Word, Sheet
72
- \[Fixed\]: Slider - Fix bug not showing pdf file
73
- \[Fixed\]: Chip - Fix bug show wrong startIcon
74
- \[Fixed\]: ModalHeader - Fix css; Add prop showClose
75
- \[Fixed\]: Dropdown - Change error logic; Remove pointerEvent, userSelect when disabled; Add ref method setValue; Fix css disabled; Add prop onClosed
80
+ - \[Added\]: Icon – EditNote, Payment
81
+ - \[Added\]: MenuIcon - MHRM29N0002
82
+ - \[Changed\]: Alert - Add white background behind opacity background color
83
+ - \[Changed\]: Tech - Add storybook for Colors
84
+ - \[Changed\]: Attachment - Add ref method openFileDialog
85
+ - \[Changed\]: Modal - Change position of Modal from center to top; Add prop alignment
86
+ - \[Changed\]: Icon - Remove duplicate icons
87
+ - \[Changed\]: Icon – Pdf, Word, Sheet
88
+ - \[Fixed\]: Slider - Fix bug not showing pdf file
89
+ - \[Fixed\]: Chip - Fix bug show wrong startIcon
90
+ - \[Fixed\]: ModalHeader - Fix css; Add prop showClose
91
+ - \[Fixed\]: Dropdown - Change error logic; Remove pointerEvent, userSelect when disabled; Add ref method setValue; Fix css disabled; Add prop onClosed
76
92
 
77
93
  ## 1.3.36
78
- \[Added\]: MenuIcon - W05F0013N0000, MHRP39N0017, MHRM09N0005, MHRM13N0001
79
- \[Changed\]: Attachment - Add prop domain, isStripDomain
80
- \[Changed\]: Tooltip - Add className
81
- \[Changed\]: Avatar - Add Add lazyLoading
82
- \[Changed\]: Popover - Change transition; Add prop direction; Add description on storybook
83
- \[Changed\]: TECH - Hide unused components on storybook
84
- \[Changed\]: Typography - Add prop showTooltip to show tooltip when content is clamped
85
- \[Changed\]: DropdownBox - Add endIcon
86
- \[Fixed\]: Tooltip - Fix bug not show tooltip; Optimize code
94
+ - \[Added\]: MenuIcon - W05F0013N0000, MHRP39N0017, MHRM09N0005, MHRM13N0001
95
+ - \[Changed\]: Attachment - Add prop domain, isStripDomain
96
+ - \[Changed\]: Tooltip - Add className
97
+ - \[Changed\]: Avatar - Add Add lazyLoading
98
+ - \[Changed\]: Popover - Change transition; Add prop direction; Add description on storybook
99
+ - \[Changed\]: TECH - Hide unused components on storybook
100
+ - \[Changed\]: Typography - Add prop showTooltip to show tooltip when content is clamped
101
+ - \[Changed\]: DropdownBox - Add endIcon
102
+ - \[Fixed\]: Tooltip - Fix bug not show tooltip; Optimize code
87
103
 
88
104
  ## 1.3.35
89
105
  - \[Added\]: Icon - AssignmentTurnedIn, DGNProducts