diginet-core-ui 1.3.85-beta.5 → 1.3.86-beta.1

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.
@@ -1,20 +1,19 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import { jsx, css, keyframes } from '@emotion/core';
3
+ import { css, jsx } from '@emotion/core';
4
4
  import AvatarDefault from "../../assets/avatar/default.svg";
5
- import { ButtonIcon, ModalSample, Popover, Popup, Typography } from "./..";
5
+ import { ButtonIcon, Image, ModalSample, Popover, Popup, Typography } from "./..";
6
+ import OptionWrapper from "../others/option-wrapper";
6
7
  import { getGlobal } from "../../global";
7
8
  import PropTypes from 'prop-types';
8
9
  import { forwardRef, Fragment, isValidElement, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
9
- import { itemsCenter, borderNone, displayBlock, displayNone, flexCol, displayInlineFlex, overflowHidden, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from "../../styles/general";
10
+ import { borderNone, borderRadius, boxContent, cursorInherit, cursorPointer, displayBlock, displayFlex, displayInlineFlex, displayNone, flexCol, itemsCenter, overflowHidden, parseMinWidth, parseWidthHeight, pd, positionAbsolute, positionRelative, userSelectNone, z } from "../../styles/general";
10
11
  import { useTheme } from "../../theme";
11
- import { classNames, isMobile, randomString } from "../../utils";
12
- import { useIntersection } from "../../utils/intersectionObserver";
13
- import OptionWrapper from "../others/option-wrapper";
12
+ import { classNames, isMobile } from "../../utils";
14
13
  const {
15
14
  colors: {
16
15
  system: {
17
- white
16
+ white: systemWhite
18
17
  },
19
18
  fill: {
20
19
  tooltip: fillTooltip
@@ -22,19 +21,8 @@ const {
22
21
  text: {
23
22
  tooltip: textTooltip
24
23
  }
25
- },
26
- spacing,
27
- zIndex: zIndexCORE
24
+ }
28
25
  } = useTheme();
29
- const existed = {},
30
- urlAvatar = {};
31
- const blurKeyframe = keyframes`
32
- 0% { -webkit-filter: blur(4px);}
33
- 25% { -webkit-filter: blur(3px);}
34
- 50% { -webkit-filter: blur(2px);}
35
- 75% { -webkit-filter: blur(1px);}
36
- 100% { -webkit-filter: blur(0px);}
37
- `;
38
26
  const checkFileType = (type, matchType) => {
39
27
  if (typeof matchType === 'object' && matchType instanceof RegExp) {
40
28
  return matchType.test(type);
@@ -73,30 +61,22 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
73
61
  width,
74
62
  wrongTypeError
75
63
  }, reference) => {
64
+ if (!reference) reference = useRef(null);
76
65
  if (!defaultSrc) defaultSrc = AvatarDefault;
77
66
  const ref = useRef(null);
78
67
  const inputRef = useRef(null);
79
68
  const avatarRef = useRef(null);
80
69
  const popupRef = useRef(null);
81
- const [unique] = useState(randomString(6, {
82
- allowNumber: false,
83
- allowSymbol: false
84
- }));
85
70
  const [viewAvatar, setViewAvatar] = useState(false);
86
71
  const [viewMoreInfo, setViewMoreInfo] = useState(false);
87
72
  const [srcState, setSrcState] = useState(src);
88
- const [isInView, setIsInView] = useState(false);
89
- const [onLoaded, setOnLoaded] = useState(false);
90
- useIntersection(ref, () => {
91
- setIsInView(true);
92
- });
93
73
  const _ActionIconCSS = ActionIconCSS(actionIconWidth);
94
- const _AvatarPreviewCSS = AvatarPreviewCSS(readOnly);
95
- const _AvatarContainerCSS = AvatarContainerCSS(_AvatarPreviewCSS.name, _ActionIconCSS.name);
74
+ const _AvatarPreviewCSS = AvatarPreviewCSS(readOnly || disabled);
75
+ const _AvatarContainerCSS = AvatarContainerCSS(_ActionIconCSS.name);
96
76
  const _AvatarRootCSS = AvatarRootCSS(width, height, outlined);
97
77
  const _isMobile = isMobile.any();
98
78
  const triggerInput = e => {
99
- if (e || !existed[unique]) {
79
+ if (e || !srcState) {
100
80
  inputRef.current.click();
101
81
  } else {
102
82
  // on View
@@ -122,16 +102,13 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
122
102
  return;
123
103
  }
124
104
  reader.onload = e => {
125
- urlAvatar[unique] = e.target.result;
126
- setSrcState(urlAvatar[unique]);
127
- existed[unique] = true;
105
+ setSrcState(e.target.result);
128
106
  };
129
107
  reader.readAsDataURL(file);
130
108
  !!onChange && onChange(input);
131
109
  };
132
110
  const onRemoveAvatar = () => {
133
111
  setSrcState(null);
134
- existed[unique] = false;
135
112
  inputRef.current.value = '';
136
113
  !!onRemove && onRemove();
137
114
  };
@@ -152,32 +129,6 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
152
129
  type: 'p1'
153
130
  }, getGlobal('noDataText'));
154
131
  };
155
- const renderImage = () => {
156
- const _image = jsx(Fragment, null, !onLoaded && jsx("img", {
157
- src: defaultSrc,
158
- alt: '',
159
- style: {
160
- objectFit: 'cover'
161
- }
162
- }), jsx("img", {
163
- css: blurAnimationCSS,
164
- src: srcState,
165
- alt: srcState,
166
- style: {
167
- objectFit: 'cover'
168
- },
169
- onLoad: () => setOnLoaded(true)
170
- }));
171
- if (lazyLoading) {
172
- return isInView ? _image : jsx("img", {
173
- src: defaultSrc,
174
- alt: '',
175
- style: {
176
- objectFit: 'cover'
177
- }
178
- });
179
- } else return _image;
180
- };
181
132
  const showMoreInfo = () => {
182
133
  if (hoverAble) setViewMoreInfo(true);
183
134
  };
@@ -201,22 +152,11 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
201
152
  };
202
153
  useEffect(() => {
203
154
  if (src) {
204
- if (isInView || !lazyLoading) {
205
- inputRef.current.value = '';
206
- const img = document.createElement('img');
207
- urlAvatar[unique] = src;
208
- img.src = src;
209
- img.alt = '';
210
- img.onerror = () => {
211
- setSrcState(defaultSrc);
212
- existed[unique] = false;
213
- };
214
- img.onload = () => {
215
- setSrcState(src);
216
- existed[unique] = true;
217
- };
218
- }
155
+ setSrcState(src);
219
156
  }
157
+ return () => {
158
+ setSrcState(defaultSrc);
159
+ };
220
160
  }, [src]);
221
161
  useImperativeHandle(reference, () => {
222
162
  const currentRef = ref.current || {};
@@ -230,11 +170,9 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
230
170
  });
231
171
  return useMemo(() => {
232
172
  return jsx(Fragment, null, jsx("div", {
233
- css: _AvatarContainerCSS,
234
- ref: ref,
235
- id: unique,
236
- className: classNames(disabled && 'disabled')
173
+ css: _AvatarContainerCSS
237
174
  }, jsx("div", {
175
+ ref: ref,
238
176
  css: _AvatarRootCSS,
239
177
  className: classNames('DGN-UI-Avatar', className),
240
178
  style: style,
@@ -247,14 +185,21 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
247
185
  onChange: onChangeAvatar,
248
186
  disabled: disabled
249
187
  }), jsx("div", {
188
+ ref: avatarRef,
250
189
  css: _AvatarPreviewCSS,
251
190
  onClick: _onClick,
252
- ref: avatarRef,
253
191
  onMouseEnter: _onMouseEnter,
254
192
  onMouseLeave: _onMouseLeave,
255
193
  tabIndex: "-1",
256
194
  onBlur: closeMoreInfo
257
- }, renderImage())), allowEdit && !readOnly && !disabled && jsx("span", {
195
+ }, jsx(Image, {
196
+ circular: true,
197
+ defaultSrc: defaultSrc,
198
+ src: srcState,
199
+ width: '100%',
200
+ height: '100%',
201
+ lazyLoading: lazyLoading
202
+ }))), allowEdit && !readOnly && !disabled ? jsx("span", {
258
203
  css: _ActionIconCSS
259
204
  }, jsx(ButtonIcon, {
260
205
  viewType: 'ghost',
@@ -263,7 +208,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
263
208
  height: actionIconHeight,
264
209
  className: 'icon-edit',
265
210
  onClick: triggerInput
266
- }), clearAble && srcState && jsx(ButtonIcon, {
211
+ }), clearAble && srcState ? jsx(ButtonIcon, {
267
212
  viewType: 'ghost',
268
213
  name: 'Delete',
269
214
  width: actionIconWidth,
@@ -273,68 +218,53 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
273
218
  style: {
274
219
  marginTop: '8px'
275
220
  }
276
- }))), jsx(ModalSample, {
221
+ }) : null) : null), jsx(ModalSample, {
277
222
  open: viewAvatar,
278
223
  onClose: () => setViewAvatar(false),
279
224
  width: 'max-content'
280
- }, jsx("img", {
281
- src: urlAvatar[unique],
282
- alt: "",
283
- style: {
284
- objectFit: 'cover',
285
- maxHeight: '100%',
286
- maxWidth: '100%',
287
- margin: 'auto',
288
- display: 'block'
289
- }
290
- })), hoverAble && jsx(Popover, {
225
+ }, jsx(Image, {
226
+ defaultSrc: defaultSrc,
227
+ src: srcState,
228
+ width: '100%',
229
+ height: '100%'
230
+ })), hoverAble ? jsx(Popover, {
291
231
  arrow: true,
292
232
  open: viewMoreInfo,
293
233
  pressESCToClose: false,
294
234
  bgColor: fillTooltip,
295
235
  anchor: avatarRef,
296
236
  fullScreen: false,
297
- width: 'max-content',
298
237
  direction: direction
299
238
  }, jsx("div", {
300
239
  css: MoreInfoCSS
301
- }, typeof data === 'function' ? data() : renderData())), !disabled && !readOnly && jsx(Popup, {
240
+ }, typeof data === 'function' ? data() : renderData())) : null, !disabled && !readOnly ? jsx(Popup, {
302
241
  ref: popupRef,
303
242
  type: 'danger'
304
- }));
305
- }, [actionIconHeight, actionIconWidth, allowEdit, clearAble, data, defaultSrc, direction, disabled, height, hoverAble, lazyLoading, matchType, maxSize, maxSizeError, outlined, readOnly, width, isInView, onLoaded, srcState, viewAvatar, viewMoreInfo]);
243
+ }) : null);
244
+ }, [actionIconHeight, actionIconWidth, allowEdit, clearAble, data, defaultSrc, direction, disabled, height, hoverAble, lazyLoading, matchType, maxSize, maxSizeError, outlined, readOnly, width, srcState, viewAvatar, viewMoreInfo]);
306
245
  }));
307
246
  const ActionIconCSS = actionIconWidth => css`
247
+ ${displayFlex};
308
248
  ${flexCol};
309
249
  ${positionAbsolute};
250
+ ${parseMinWidth(actionIconWidth)};
310
251
  right: ${-actionIconWidth}px;
311
- min-width: ${actionIconWidth}px;
312
252
  transition: opacity 0.5s;
313
253
  opacity: 0;
314
- z-index: ${zIndexCORE(2)};
254
+ ${z(2)};
315
255
  `;
316
- const AvatarPreviewCSS = readOnly => css`
256
+ const AvatarPreviewCSS = isDisabled => css`
317
257
  ${displayBlock};
318
258
  ${positionRelative};
319
259
  ${overflowHidden};
320
- width: 100%;
321
- height: 100%;
322
- border-radius: 50%;
323
- cursor: ${readOnly ? 'initial' : 'pointer'};
260
+ ${parseWidthHeight('100%')};
261
+ ${borderRadius('50%')};
262
+ ${isDisabled ? cursorInherit : cursorPointer};
324
263
  `;
325
- const AvatarContainerCSS = (AvatarPreviewCSSName, ActionIconCSSName) => css`
264
+ const AvatarContainerCSS = ActionIconCSSName => css`
326
265
  ${displayInlineFlex};
327
266
  ${positionRelative};
328
267
  ${itemsCenter};
329
- &.disabled {
330
- .css-${AvatarPreviewCSSName} {
331
- ${pointerEventsNone}
332
- cursor: inherit;
333
- }
334
- .css-${ActionIconCSSName} {
335
- display: none !important;
336
- }
337
- }
338
268
  &:hover {
339
269
  .css-${ActionIconCSSName} {
340
270
  opacity: 1;
@@ -347,25 +277,18 @@ const AvatarRootCSS = (width, height, outlined) => css`
347
277
  ${overflowHidden};
348
278
  ${userSelectNone};
349
279
  ${borderNone};
280
+ ${boxContent};
350
281
  ${parseWidthHeight(width, height)};
351
- border: ${typeof outlined === 'boolean' && outlined ? `1px solid ${white}` : outlined};
352
- border-radius: 50%;
353
- box-sizing: content-box;
282
+ ${borderRadius('50%')};
283
+ border: ${typeof outlined === 'boolean' && outlined ? `1px solid ${systemWhite}` : outlined};
354
284
  input {
355
285
  ${displayNone};
356
286
  }
357
- img {
358
- width: 100%;
359
- height: 100%;
360
- }
361
287
  `;
362
288
  const MoreInfoCSS = css`
363
289
  ${displayBlock};
364
290
  ${positionRelative};
365
- padding: ${spacing([2])};
366
- `;
367
- const blurAnimationCSS = css`
368
- animation: ${blurKeyframe} 1s ease;
291
+ ${pd([2])};
369
292
  `;
370
293
  Avatar.defaultProps = {
371
294
  actionIconHeight: 24,
@@ -1311,17 +1311,17 @@ Attachment.propTypes = {
1311
1311
  allowSort: PropTypes.bool,
1312
1312
  /** Class for component. */
1313
1313
  className: PropTypes.string,
1314
- /** List attachment:<br />
1315
- * [{<br />
1316
- * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1317
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1318
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1319
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1320
- * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1321
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1322
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1323
- * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1324
- * }, ...]
1314
+ /** List attachment:<br />
1315
+ * [{<br />
1316
+ * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1317
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1318
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1319
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1320
+ * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1321
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1322
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1323
+ * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1324
+ * }, ...]
1325
1325
  */
1326
1326
  data: PropTypes.array,
1327
1327
  /** The message to display when deleting files. */
@@ -1350,16 +1350,16 @@ Attachment.propTypes = {
1350
1350
  onChange: PropTypes.func,
1351
1351
  /** Download attached event, if not it will use default. */
1352
1352
  onDownload: PropTypes.func,
1353
- /**
1354
- * event when removed file(s)
1355
- *
1356
- * return data: {<br/>
1357
- * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1358
- * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1359
- * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1360
- * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1361
- * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1362
- * }
1353
+ /**
1354
+ * event when removed file(s)
1355
+ *
1356
+ * return data: {<br/>
1357
+ * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1358
+ * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1359
+ * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1360
+ * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1361
+ * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1362
+ * }
1363
1363
  */
1364
1364
  onRemove: PropTypes.func,
1365
1365
  /** View attached event, if not it will use default. */
@@ -51,7 +51,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
51
51
  hoverTooltip,
52
52
  iconStyle,
53
53
  inputProps,
54
- inputRef: inputBaseRef,
54
+ inputRef: inputRefProp,
55
55
  inputStyle,
56
56
  maxRows,
57
57
  multiline,
@@ -84,7 +84,8 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
84
84
  bind,
85
85
  value
86
86
  } = useInput(defaultValue, valueProp, _onChange, onInput, delayOnChange);
87
- if (!inputBaseRef) inputBaseRef = useRef(null);
87
+ if (!inputRefProp) inputRefProp = useRef(null);
88
+ const inputRef = useRef(null);
88
89
  const ref = useRef(null);
89
90
  const valueArray = useRef([]);
90
91
  const canvas = document.createElement('canvas');
@@ -115,28 +116,28 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
115
116
  };
116
117
  useEffect(() => {
117
118
  if (defaultValue !== undefined && defaultValue !== '') {
118
- if (multiline && !/\d+/.test(rows)) {
119
- inputBaseRef.current.style.height = 0;
120
- inputBaseRef.current.style.height = Math.max(24, inputBaseRef.current.scrollHeight) + 'px';
119
+ if (multiline && !/\d+/.test(rows) && inputRef.current) {
120
+ inputRef.current.style.height = 0;
121
+ inputRef.current.style.height = Math.max(24, inputRef.current.scrollHeight) + 'px';
121
122
  }
122
123
  }
123
124
  }, []);
124
125
  useEffect(() => {
125
- if (multiline && !/\d+/.test(rows) && !(inputBaseRef.current.value || inputBaseRef.current.value === 0)) {
126
- inputBaseRef.current.style.height = '24px';
126
+ if (multiline && !/\d+/.test(rows) && inputRef.current && !(inputRef.current.value || inputRef.current.value === 0)) {
127
+ inputRef.current.style.height = '24px';
127
128
  }
128
129
  if (autoFocus) {
129
- inputBaseRef.current.focus();
130
+ inputRef.current.focus();
130
131
  }
131
132
  }, [multiline]);
132
133
  useEffect(() => {
133
134
  const defaultHeight = 24;
134
135
  if (valueProp !== undefined) {
135
136
  valueArray.current.push(valueProp);
136
- inputBaseRef.current.value = valueProp;
137
+ inputRefProp.current.value = valueProp;
137
138
  if (multiline && !/\d+/.test(rows)) {
138
- inputBaseRef.current.style.height = 0;
139
- inputBaseRef.current.style.height = Math.max(defaultHeight, inputBaseRef.current.scrollHeight) + 'px';
139
+ inputRef.current.style.height = 0;
140
+ inputRef.current.style.height = Math.max(defaultHeight, inputRef.current.scrollHeight) + 'px';
140
141
  } else {
141
142
  dynamicWidth({
142
143
  target: {
@@ -146,15 +147,15 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
146
147
  }
147
148
  }
148
149
  return () => {
149
- if (valueProp !== undefined && multiline && !/\d+/.test(rows) && inputBaseRef.current) {
150
- inputBaseRef.current.style.height = defaultHeight + 'px';
150
+ if (valueProp !== undefined && multiline && !/\d+/.test(rows) && inputRef.current) {
151
+ inputRef.current.style.height = defaultHeight + 'px';
151
152
  }
152
153
  };
153
154
  }, [valueProp]);
154
155
  /* End handler */
155
156
 
156
157
  useImperativeHandle(reference, () => {
157
- const currentRef = inputBaseRef.current || {};
158
+ const currentRef = inputRefProp.current || {};
158
159
  const _instance = {
159
160
  ...action
160
161
  }; // methods
@@ -169,14 +170,14 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
169
170
  styleInputBase.current = style;
170
171
  };
171
172
  const dynamicWidth = e => {
172
- if (!autoWidth || !inputBaseRef.current) return;
173
- if (!canvas || !styleInputBase.current || !inputBaseRef.current) return;
173
+ if (!autoWidth || !inputRefProp.current) return;
174
+ if (!canvas || !styleInputBase.current || !inputRefProp.current) return;
174
175
  const context = canvas.getContext('2d');
175
176
  context.font = styleInputBase.current.font;
176
177
  const {
177
178
  width
178
179
  } = context.measureText(e.target.value);
179
- inputBaseRef.current.style.width = `${Math.max(width, widthInit.current)}px`;
180
+ inputRefProp.current.style.width = `${Math.max(width, widthInit.current)}px`;
180
181
  };
181
182
 
182
183
  /* Start component */
@@ -224,7 +225,11 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
224
225
  readOnly: readOnly,
225
226
  style: inputStyle || (inputProps === null || inputProps === void 0 ? void 0 : inputProps.style),
226
227
  className: classNames('DGN-UI-InputBase-Textarea', inputProps.className),
227
- ref: inputBaseRef,
228
+ ref: refs => {
229
+ if (!refs) return;
230
+ inputRef.current = refs;
231
+ typeof inputRefProp === 'function' ? inputRefProp(refs) : inputRefProp.current = refs;
232
+ },
228
233
  onKeyDown: onKeyDown,
229
234
  onKeyUp: onKeyUp,
230
235
  onInput: onInputTextArea,
@@ -249,7 +254,8 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
249
254
  className: classNames('DGN-UI-InputBase-Input', newClass, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
250
255
  ref: refs => {
251
256
  if (!refs) return;
252
- inputBaseRef.current = refs;
257
+ inputRef.current = refs;
258
+ typeof inputRefProp === 'function' ? inputRefProp(refs) : inputRefProp.current = refs;
253
259
  saveInitInfo(refs);
254
260
  },
255
261
  css: _InputCSS,
@@ -1,13 +1,12 @@
1
1
  /** @jsxRuntime classic */
2
2
  /** @jsx jsx */
3
- import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
4
- import PropTypes from 'prop-types';
5
- import { jsx, css, keyframes } from '@emotion/core';
6
- import OptionWrapper from "../others/option-wrapper";
7
- import { useIntersection } from "../../utils/intersectionObserver";
8
- import { classNames } from "../../utils";
3
+ import { css, jsx, keyframes } from '@emotion/core';
9
4
  import AvatarDefault from "../../assets/avatar/default.svg";
10
- import { itemsCenter, displayInlineFlex, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
5
+ import OptionWrapper from "../others/option-wrapper";
6
+ import PropTypes from 'prop-types';
7
+ import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
8
+ import { borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
9
+ import { classNames, useIntersection } from "../../utils";
11
10
  const blurKeyframe = keyframes`
12
11
  0% { -webkit-filter: blur(4px);}
13
12
  25% { -webkit-filter: blur(3px);}
@@ -29,6 +28,7 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
29
28
  style,
30
29
  width
31
30
  }, reference) => {
31
+ if (!reference) reference = useRef(null);
32
32
  if (!defaultSrc) defaultSrc = AvatarDefault;
33
33
  const ref = useRef(null);
34
34
  const [srcState, setSrcState] = useState(src);
@@ -53,6 +53,9 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
53
53
  };
54
54
  }
55
55
  }
56
+ return () => {
57
+ setSrcState(defaultSrc);
58
+ };
56
59
  }, [src]);
57
60
  useImperativeHandle(reference, () => {
58
61
  const currentRef = ref.current || {};
@@ -66,21 +69,16 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
66
69
  });
67
70
  const renderImage = () => {
68
71
  const defaultImage = jsx("img", {
72
+ css: objectCover,
69
73
  src: defaultSrc,
70
74
  alt: '',
71
- style: {
72
- objectFit: 'cover'
73
- },
74
75
  width: width,
75
76
  height: height
76
77
  });
77
78
  const image = jsx(Fragment, null, !onLoaded && defaultImage, jsx("img", {
78
- css: blurAnimationCSS,
79
+ css: [blurAnimationCSS, objectCover],
79
80
  src: srcState,
80
81
  alt: alt || srcState,
81
- style: {
82
- objectFit: 'cover'
83
- },
84
82
  onLoad: () => setOnLoaded(true),
85
83
  width: width,
86
84
  height: height
@@ -105,7 +103,7 @@ const ImageCSS = (width, height, circular) => css`
105
103
  ${itemsCenter};
106
104
  ${overflowHidden};
107
105
  ${parseWidthHeight(width, height)};
108
- ${circular && `border-radius: 50%`};
106
+ ${circular && borderRadius('50%')};
109
107
  `;
110
108
  const blurAnimationCSS = css`
111
109
  animation: ${blurKeyframe} 1s ease;
package/icons/basic.js CHANGED
@@ -4056,6 +4056,34 @@ export const Update = /*#__PURE__*/memo(({
4056
4056
  fill: colors[color] || color
4057
4057
  }));
4058
4058
  });
4059
+ export const Upload = /*#__PURE__*/memo(({
4060
+ width,
4061
+ height,
4062
+ color = '#7F828E',
4063
+ viewBox = false
4064
+ }) => {
4065
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
4066
+ width: width || 24,
4067
+ height: height || 24,
4068
+ viewBox: "0 0 24 24",
4069
+ fill: "none"
4070
+ }, /*#__PURE__*/React.createElement("path", {
4071
+ fillRule: "evenodd",
4072
+ clipRule: "evenodd",
4073
+ d: "M15 10V16H9V10H5L12 3L19 10H15ZM19 20V18H5V20H19Z",
4074
+ fill: colors[color] || color
4075
+ })) : /*#__PURE__*/React.createElement("svg", {
4076
+ width: width || 14,
4077
+ height: height || 17,
4078
+ viewBox: "0 0 14 17",
4079
+ fill: "none"
4080
+ }, /*#__PURE__*/React.createElement("path", {
4081
+ fillRule: "evenodd",
4082
+ clipRule: "evenodd",
4083
+ d: "M10 7V13H4V7H0L7 0L14 7H10ZM14 17V15H0V17H14Z",
4084
+ fill: colors[color] || color
4085
+ }));
4086
+ });
4059
4087
  export const Palette = /*#__PURE__*/memo(({
4060
4088
  width,
4061
4089
  height,
@@ -6077,6 +6105,54 @@ export const Website = /*#__PURE__*/memo(({
6077
6105
  fill: colors[color] || color
6078
6106
  }));
6079
6107
  });
6108
+ export const Workflow = /*#__PURE__*/memo(({
6109
+ width,
6110
+ height,
6111
+ color = '#7F828E',
6112
+ viewBox = false
6113
+ }) => {
6114
+ return viewBox ? /*#__PURE__*/React.createElement("svg", {
6115
+ width: width || 24,
6116
+ height: height || 24,
6117
+ viewBox: "0 0 24 24",
6118
+ fill: "none"
6119
+ }, /*#__PURE__*/React.createElement("path", {
6120
+ fillRule: "evenodd",
6121
+ clipRule: "evenodd",
6122
+ d: "M8 5L5 8L5 6H2V4H5L5 2L8 5Z",
6123
+ fill: colors[color] || color
6124
+ }), /*#__PURE__*/React.createElement("path", {
6125
+ fillRule: "evenodd",
6126
+ clipRule: "evenodd",
6127
+ d: "M22 19L19 22L19 20H16V18H19L19 16L22 19Z",
6128
+ fill: colors[color] || color
6129
+ }), /*#__PURE__*/React.createElement("path", {
6130
+ fillRule: "evenodd",
6131
+ clipRule: "evenodd",
6132
+ d: "M14.8293 6C14.4175 7.16519 13.3062 8 12 8C10.3431 8 9 6.65685 9 5C9 3.34315 10.3431 2 12 2C13.3062 2 14.4175 2.83481 14.8293 4L18 4L20 4V6V9.17071C21.1652 9.58254 22 10.6938 22 12C22 13.6569 20.6569 15 19 15C17.6938 15 16.5825 14.1652 16.1707 13H7.82929C7.52801 13.8524 6.85241 14.528 6 14.8293L6 18H9.17071C9.58254 16.8348 10.6938 16 12 16C13.6569 16 15 17.3431 15 19C15 20.6569 13.6569 22 12 22C10.6938 22 9.58254 21.1652 9.17071 20H6H4V18L4 14.8293C2.83481 14.4175 2 13.3062 2 12C2 10.3431 3.34315 9 5 9C6.30622 9 7.41746 9.83481 7.82929 11H16.1707C16.472 10.1476 17.1476 9.47199 18 9.17071V6H14.8293Z",
6133
+ fill: colors[color] || color
6134
+ })) : /*#__PURE__*/React.createElement("svg", {
6135
+ width: width || 20,
6136
+ height: height || 20,
6137
+ viewBox: "0 0 20 20",
6138
+ fill: "none"
6139
+ }, /*#__PURE__*/React.createElement("path", {
6140
+ fillRule: "evenodd",
6141
+ clipRule: "evenodd",
6142
+ d: "M6 3L3 6L3 4H0V2H3L3 0L6 3Z",
6143
+ fill: colors[color] || color
6144
+ }), /*#__PURE__*/React.createElement("path", {
6145
+ fillRule: "evenodd",
6146
+ clipRule: "evenodd",
6147
+ d: "M20 17L17 20L17 18H14V16H17L17 14L20 17Z",
6148
+ fill: colors[color] || color
6149
+ }), /*#__PURE__*/React.createElement("path", {
6150
+ fillRule: "evenodd",
6151
+ clipRule: "evenodd",
6152
+ d: "M12.8293 4C12.4175 5.16519 11.3062 6 10 6C8.34315 6 7 4.65685 7 3C7 1.34315 8.34315 0 10 0C11.3062 0 12.4175 0.834808 12.8293 2L16 2L18 2V4V7.17071C19.1652 7.58254 20 8.69378 20 10C20 11.6569 18.6569 13 17 13C15.6938 13 14.5825 12.1652 14.1707 11H5.82929C5.52801 11.8524 4.85241 12.528 4 12.8293L4 16H7.17071C7.58254 14.8348 8.69378 14 10 14C11.6569 14 13 15.3431 13 17C13 18.6569 11.6569 20 10 20C8.69378 20 7.58254 19.1652 7.17071 18H4H2V16L2 12.8293C0.834808 12.4175 0 11.3062 0 10C0 8.34315 1.34315 7 3 7C4.30622 7 5.41746 7.83481 5.82929 9H14.1707C14.472 8.14759 15.1476 7.47199 16 7.17071V4H12.8293Z",
6153
+ fill: colors[color] || color
6154
+ }));
6155
+ });
6080
6156
  export const Write = /*#__PURE__*/memo(({
6081
6157
  width,
6082
6158
  height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.85-beta.5",
3
+ "version": "1.3.86-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",
package/readme.md CHANGED
@@ -38,6 +38,12 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.3.86
42
+ - \[Changed\]: Icon – Optimize code
43
+ - \[Fixed\]: Dropdown – Fix bug cannot select multiple after search
44
+ - \[Fixed\]: InputBase – Fix endIconProps not work when endIcon is string
45
+ - \[Fixed\]: Attachment – Fix not show Button Attachment when disabled, readOnly; Update design
46
+
41
47
  ## 1.3.85
42
48
  - \[Fixed\]: Attachment – Fix not fire onChange when select same file
43
49
  - \[Fixed\]: PagingInfo – Fix responsive auto hide element wrong
package/utils/index.js CHANGED
@@ -19,6 +19,7 @@ export { default as SbTemplate } from "./sb-template";
19
19
  export { default as updatePosition } from "./updatePosition";
20
20
  export { default as useDelayUnmount } from "./useDelayUnmount";
21
21
  export { default as useInput } from "./useInput";
22
+ export { default as useIntersection } from "./intersectionObserver";
22
23
  export { default as useMediaQuery } from "./useMediaQuery";
23
24
  export { default as useOnClickOutside } from "./useOnClickOutside";
24
25
  export { default as usePortal } from "./usePortal";
@@ -22,7 +22,7 @@ const getIntersectionObserver = () => {
22
22
  }
23
23
  return observer;
24
24
  };
25
- export const useIntersection = (elem, callback) => {
25
+ const useIntersection = (elem, callback) => {
26
26
  useEffect(() => {
27
27
  let target = elem.current;
28
28
  let observer = getIntersectionObserver();
@@ -33,4 +33,5 @@ export const useIntersection = (elem, callback) => {
33
33
  observer.unobserve(target);
34
34
  };
35
35
  }, []);
36
- };
36
+ };
37
+ export default useIntersection;