diginet-core-ui 1.3.69-beta.6 → 1.3.69-beta.7

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.
@@ -51,6 +51,7 @@ const checkFileType = (type, matchType) => {
51
51
  };
52
52
 
53
53
  const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
54
+ action = {},
54
55
  src,
55
56
  defaultSrc,
56
57
  outlined,
@@ -241,10 +242,17 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
241
242
  }
242
243
  }
243
244
  }, [src]);
244
- useImperativeHandle(reference, () => ({
245
- element: ref.current,
246
- instance: {}
247
- }));
245
+ useImperativeHandle(reference, () => {
246
+ const currentRef = ref.current || {};
247
+ currentRef.element = ref.current;
248
+ const _instance = { ...action
249
+ }; // methods
250
+
251
+ _instance.__proto__ = {}; // hidden methods
252
+
253
+ currentRef.instance = _instance;
254
+ return currentRef;
255
+ });
248
256
  return useMemo(() => {
249
257
  return jsx(Fragment, null, jsx("div", {
250
258
  css: _AvatarContainerCSS,
@@ -72,6 +72,7 @@ const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) =>
72
72
  };
73
73
 
74
74
  const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
75
+ action = {},
75
76
  anchorOrigin,
76
77
  contentDirection,
77
78
  content,
@@ -98,10 +99,17 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
98
99
 
99
100
  const _BadgeRootCSS = BadgeRootCSS(children, name, dotPos, _BadgeNumberCSS);
100
101
 
101
- useImperativeHandle(reference, () => ({
102
- element: ref.current,
103
- instance: {}
104
- }));
102
+ useImperativeHandle(reference, () => {
103
+ const currentRef = ref.current || {};
104
+ currentRef.element = ref.current;
105
+ const _instance = { ...action
106
+ }; // methods
107
+
108
+ _instance.__proto__ = {}; // hidden methods
109
+
110
+ currentRef.instance = _instance;
111
+ return currentRef;
112
+ });
105
113
  return useMemo(() => {
106
114
  let node = children;
107
115
 
@@ -71,6 +71,7 @@ const renderIconLoading = iconSize => {
71
71
  };
72
72
 
73
73
  const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
74
+ action = {},
74
75
  viewType,
75
76
  color,
76
77
  size,
@@ -104,10 +105,17 @@ const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
104
105
 
105
106
  const _ButtonRootCSS = ButtonRootCSS(circular, size, width, _width, height, _height, buttonSize, iconSize, colorHover, color, _color, name);
106
107
 
107
- useImperativeHandle(reference, () => ({
108
- element: ref.current,
109
- instance: {}
110
- }));
108
+ useImperativeHandle(reference, () => {
109
+ const currentRef = ref.current || {};
110
+ currentRef.element = ref.current;
111
+ const _instance = { ...action
112
+ }; // methods
113
+
114
+ _instance.__proto__ = {}; // hidden methods
115
+
116
+ currentRef.instance = _instance;
117
+ return currentRef;
118
+ });
111
119
 
112
120
  const _onClick = event => {
113
121
  event.persist();
@@ -99,6 +99,7 @@ const alphaArr = {
99
99
  };
100
100
  const alphaLoading = 0.2;
101
101
  const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
102
+ action = {},
102
103
  children,
103
104
  className,
104
105
  color,
@@ -130,10 +131,17 @@ const Button = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
130
131
 
131
132
  const _ButtonRoot = ButtonRoot(viewType, size, paddingSize, minHeightSize, minHeightSizeLink, outlinedPaddingSize, endIcon, label, iconMarginSize, startIcon, iconSize, color);
132
133
 
133
- useImperativeHandle(reference, () => ({
134
- element: ref.current,
135
- instance: {}
136
- }));
134
+ useImperativeHandle(reference, () => {
135
+ const currentRef = ref.current || {};
136
+ currentRef.element = ref.current;
137
+ const _instance = { ...action
138
+ }; // methods
139
+
140
+ _instance.__proto__ = {}; // hidden methods
141
+
142
+ currentRef.instance = _instance;
143
+ return currentRef;
144
+ });
137
145
  const StartIcon = useMemo(() => {
138
146
  let node = startIcon;
139
147
 
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
8
  const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
+ action = {},
9
10
  children,
10
11
  className,
11
12
  id,
@@ -13,10 +14,17 @@ const CardBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
13
14
  title
14
15
  }, reference) => {
15
16
  const ref = useRef(null);
16
- useImperativeHandle(reference, () => ({
17
- element: ref.current,
18
- instance: {}
19
- }));
17
+ useImperativeHandle(reference, () => {
18
+ const currentRef = ref.current || {};
19
+ currentRef.element = ref.current;
20
+ const _instance = { ...action
21
+ }; // methods
22
+
23
+ _instance.__proto__ = {}; // hidden methods
24
+
25
+ currentRef.instance = _instance;
26
+ return currentRef;
27
+ });
20
28
  return useMemo(() => {
21
29
  return jsx("div", {
22
30
  id: id,
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
8
  const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
+ action = {},
9
10
  children,
10
11
  className,
11
12
  id,
@@ -13,10 +14,17 @@ const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
13
14
  title
14
15
  }, reference) => {
15
16
  const ref = useRef(null);
16
- useImperativeHandle(reference, () => ({
17
- element: ref.current,
18
- instance: {}
19
- }));
17
+ useImperativeHandle(reference, () => {
18
+ const currentRef = ref.current || {};
19
+ currentRef.element = ref.current;
20
+ const _instance = { ...action
21
+ }; // methods
22
+
23
+ _instance.__proto__ = {}; // hidden methods
24
+
25
+ currentRef.instance = _instance;
26
+ return currentRef;
27
+ });
20
28
  return useMemo(() => {
21
29
  return jsx("div", {
22
30
  id: id,
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
8
  const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
+ action = {},
9
10
  children,
10
11
  className,
11
12
  id,
@@ -13,10 +14,17 @@ const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
13
14
  title
14
15
  }, reference) => {
15
16
  const ref = useRef(null);
16
- useImperativeHandle(reference, () => ({
17
- element: ref.current,
18
- instance: {}
19
- }));
17
+ useImperativeHandle(reference, () => {
18
+ const currentRef = ref.current || {};
19
+ currentRef.element = ref.current;
20
+ const _instance = { ...action
21
+ }; // methods
22
+
23
+ _instance.__proto__ = {}; // hidden methods
24
+
25
+ currentRef.instance = _instance;
26
+ return currentRef;
27
+ });
20
28
  return useMemo(() => {
21
29
  return jsx("div", {
22
30
  id: id,
@@ -7,6 +7,7 @@ import { jsx } from '@emotion/core';
7
7
  import OptionWrapper from '../others/option-wrapper';
8
8
  import Typography from '../typography';
9
9
  const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
10
+ action = {},
10
11
  children,
11
12
  className,
12
13
  id,
@@ -14,10 +15,17 @@ const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
14
15
  title
15
16
  }, reference) => {
16
17
  const ref = useRef(null);
17
- useImperativeHandle(reference, () => ({
18
- element: ref.current,
19
- instance: {}
20
- }));
18
+ useImperativeHandle(reference, () => {
19
+ const currentRef = ref.current || {};
20
+ currentRef.element = ref.current;
21
+ const _instance = { ...action
22
+ }; // methods
23
+
24
+ _instance.__proto__ = {}; // hidden methods
25
+
26
+ currentRef.instance = _instance;
27
+ return currentRef;
28
+ });
21
29
  return useMemo(() => {
22
30
  return jsx("div", {
23
31
  id: id,
@@ -23,6 +23,7 @@ const {
23
23
  spacing
24
24
  } = theme;
25
25
  const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
26
+ action = {},
26
27
  body: bodyProp,
27
28
  bodyStyle,
28
29
  children,
@@ -44,10 +45,17 @@ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
44
45
 
45
46
  const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor);
46
47
 
47
- useImperativeHandle(reference, () => ({
48
- element: ref.current,
49
- instance: {}
50
- }));
48
+ useImperativeHandle(reference, () => {
49
+ const currentRef = ref.current || {};
50
+ currentRef.element = ref.current;
51
+ const _instance = { ...action
52
+ }; // methods
53
+
54
+ _instance.__proto__ = {}; // hidden methods
55
+
56
+ currentRef.instance = _instance;
57
+ return currentRef;
58
+ });
51
59
  const head = header || title ? jsx(CardHeader, {
52
60
  className: (className === null || className === void 0 ? void 0 : className.header) || '',
53
61
  style: headerStyle,
@@ -22,6 +22,7 @@ const {
22
22
  }
23
23
  } = theme;
24
24
  const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
25
+ action = {},
25
26
  disabled,
26
27
  readOnly,
27
28
  required,
@@ -35,10 +36,17 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
35
36
  ...props
36
37
  }, reference) => {
37
38
  const ref = useRef(null);
38
- useImperativeHandle(reference, () => ({
39
- element: ref.current,
40
- instance: {}
41
- }));
39
+ useImperativeHandle(reference, () => {
40
+ const currentRef = ref.current || {};
41
+ currentRef.element = ref.current;
42
+ const _instance = { ...action
43
+ }; // methods
44
+
45
+ _instance.__proto__ = {}; // hidden methods
46
+
47
+ currentRef.instance = _instance;
48
+ return currentRef;
49
+ });
42
50
  return useMemo(() => jsx("div", {
43
51
  css: LabelContainerCSS,
44
52
  className: 'DGN-UI-Label-Container'
@@ -5,49 +5,48 @@ import { memo, useEffect, useRef, forwardRef, useState, useImperativeHandle } fr
5
5
  import PropTypes from 'prop-types';
6
6
  import { jsx, css } from '@emotion/core';
7
7
  import { ButtonIcon, CircularProgress as Circular, HelperText, InputBase, Label } from '../../';
8
- import { renderIcon, onValidate } from '../../../utils';
8
+ import { renderIcon, onValidate, refType as ref } from '../../../utils';
9
9
  import { cursorNotAllowed, displayBlock, flexRow, positionRelative } from '../../../styles/general';
10
10
  const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
11
- type,
12
- viewType,
13
- required,
14
- loading,
15
- autoIncreaseBot,
11
+ autoComplete,
12
+ autoFocus,
13
+ autoWidth,
16
14
  className,
17
- label,
18
15
  defaultValue,
19
- value: valueProp,
20
- placeholder,
21
- startIcon,
16
+ disabled,
22
17
  endIcon,
23
- startIconProps,
24
18
  endIconProps,
25
- status,
19
+ error,
26
20
  icon,
27
- autoComplete,
28
- autoFocus,
29
- disabled,
30
- readOnly,
31
- multiline,
32
- onConfirm,
33
- rows,
34
- maxRows,
35
- style,
36
21
  iconStyle,
37
- inputRef,
38
22
  inputProps,
23
+ inputRef,
39
24
  inputStyle,
25
+ label,
40
26
  labelProps,
41
- error,
42
- onChange,
27
+ loading,
28
+ maxRows,
29
+ multiline,
43
30
  onBlur,
31
+ onChange,
32
+ onConfirm,
44
33
  onFocus,
45
34
  onInput,
46
35
  onKeyDown,
47
36
  onKeyUp,
48
37
  onPaste,
38
+ placeholder,
39
+ readOnly,
40
+ required,
41
+ rows,
42
+ startIcon,
43
+ startIconProps,
44
+ status,
45
+ style,
46
+ type,
49
47
  validates,
50
- autoWidth,
48
+ value: valueProp,
49
+ viewType,
51
50
  ...props
52
51
  }, reference) => {
53
52
  const ref = useRef(null);
@@ -60,39 +59,9 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
60
59
  let currentValue = '';
61
60
  const [value, setValue] = useState(valueProp || defaultValue);
62
61
  const isError = !!error;
63
- /* Start styled */
64
-
65
- const TextInputRoot = css`
66
- ${displayBlock};
67
- ${positionRelative};
68
- margin-bottom: 20px;
69
- &.disabled {
70
- ${cursorNotAllowed};
71
- }
72
- `;
73
- const TextInputIcon = css`
74
- ${flexRow};
75
- color: inherit;
76
- .edit-icon-pen {
77
- ${flexRow};
78
- }
79
- .edit-icon-confirm {
80
- display: none;
81
- }
82
- .edit-icon-clear {
83
- display: none;
84
- margin-left: 12px;
85
- }
86
- .circular {
87
- display: none;
88
- }
89
- `;
90
- /* End styled */
91
-
92
62
  /* Start handler */
93
63
 
94
64
  const onMouseDownHandler = () => {
95
- // ref.current.querySelector(`.css-${TextInputBox.name}`).style.backgroundColor = 'transparent';
96
65
  inputRef.current.style.backgroundColor = 'transparent';
97
66
  };
98
67
 
@@ -186,33 +155,6 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
186
155
  }
187
156
  };
188
157
  }, [type, multiline]);
189
- useEffect(() => {
190
- if (error && !value && value !== 0) {
191
- ref.current.classList.add('danger');
192
-
193
- if (autoIncreaseBot) {
194
- const helperTextNode = ref.current.querySelector('.DGN-UI-HelperText');
195
-
196
- if (helperTextNode) {
197
- if (helperTextNode.offsetHeight > 20) {
198
- ref.current.style.marginBottom = helperTextNode.offsetHeight + 4 + 'px';
199
- }
200
- }
201
- }
202
-
203
- return () => {
204
- if (ref.current) {
205
- ref.current.classList.remove('danger');
206
- ref.current.style.marginBottom = null;
207
- }
208
- };
209
- }
210
- }, [error, value]);
211
- useEffect(() => {
212
- if (placeholder !== undefined && inputRef.current) {
213
- inputRef.current.placeholder = placeholder;
214
- }
215
- }, [placeholder]);
216
158
  useEffect(() => {
217
159
  if (!inputRef.current) return;
218
160
  inputRef.current.readOnly = !!readOnly;
@@ -341,139 +283,160 @@ const TextInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
341
283
  disabled: disabled
342
284
  }, validateResult));
343
285
  }));
286
+ const TextInputRoot = css`
287
+ ${displayBlock};
288
+ ${positionRelative};
289
+ margin-bottom: 20px;
290
+ &.disabled {
291
+ ${cursorNotAllowed};
292
+ }
293
+ `;
294
+ const TextInputIcon = css`
295
+ ${flexRow};
296
+ color: inherit;
297
+ .edit-icon-pen {
298
+ ${flexRow};
299
+ }
300
+ .edit-icon-confirm {
301
+ display: none;
302
+ }
303
+ .edit-icon-clear {
304
+ display: none;
305
+ margin-left: 12px;
306
+ }
307
+ .circular {
308
+ display: none;
309
+ }
310
+ `;
344
311
  TextInput.defaultProps = {
345
- type: 'text',
346
- viewType: 'underlined',
347
- label: '',
312
+ autoComplete: 'off',
313
+ autoFocus: false,
314
+ autoWidth: false,
348
315
  className: '',
349
316
  defaultValue: '',
350
- status: 'default',
317
+ disabled: false,
351
318
  error: '',
352
- autoComplete: 'off',
353
- required: false,
319
+ iconStyle: {},
320
+ label: '',
354
321
  loading: false,
355
- autoFocus: false,
356
- autoIncreaseBot: false,
357
- disabled: false,
358
- readOnly: false,
359
322
  multiline: false,
360
- iconStyle: {},
361
- autoWidth: false
323
+ readOnly: false,
324
+ required: false,
325
+ status: 'default',
326
+ type: 'text',
327
+ viewType: 'underlined'
362
328
  };
363
329
  TextInput.propTypes = {
364
- /** type of input */
365
- type: PropTypes.oneOf(['inform', 'edit', 'quickEdit', 'text', 'number', 'password']),
330
+ /** This prop helps users to fill forms faster, especially on mobile devices. The name can be confusing, as it's more like an autofill. You can learn more about it [following the specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill). */
331
+ autoComplete: PropTypes.string,
366
332
 
367
- /** the type of border you want to display */
368
- viewType: PropTypes.oneOf(['underlined', 'outlined']),
333
+ /** If `true`, the input element is focused during the first mount. */
334
+ autoFocus: PropTypes.bool,
369
335
 
370
- /** label for input */
371
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
336
+ /** If `true`, the width of the component will automatically be set according to the contents inside the input, don't run with multiline = true */
337
+ autoWidth: PropTypes.bool,
372
338
 
373
- /** class for input */
339
+ /** Class for component. */
374
340
  className: PropTypes.string,
375
341
 
376
- /** default value is displayed for first render */
342
+ /** The default value. Use when the component is not controlled. */
377
343
  defaultValue: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
378
344
 
379
- /** the displayed value for each change */
380
- value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
345
+ /** If `true`, the component is disabled.*/
346
+ disabled: PropTypes.bool,
381
347
 
382
- /** hints for input */
383
- placeholder: PropTypes.string,
348
+ /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the right of input. */
349
+ endIcon: PropTypes.any,
384
350
 
385
- /** status type to display color for input (only available for type is inform) */
386
- status: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
351
+ /** Props of end icon in InputBase component. */
352
+ endIconProps: PropTypes.object,
387
353
 
388
- /** error for input */
354
+ /** Error displayed below input. */
389
355
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
390
356
 
391
- /** the number of rows of textarea */
392
- rows: PropTypes.number,
357
+ /** Icon element display in the end of input (only use for type is inform, if not, use startIcon instead). */
358
+ icon: PropTypes.any,
393
359
 
394
- /** the maximum of rows of textarea */
395
- maxRows: PropTypes.number,
360
+ /** Style inline of icon. */
361
+ iconStyle: PropTypes.object,
396
362
 
397
- /** type auto complete of input (like new-password) */
398
- autoComplete: PropTypes.string,
363
+ /** [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes) applied to the input element. */
364
+ inputProps: PropTypes.object,
399
365
 
400
- /** prevent all event if true, hide all icon */
401
- disabled: PropTypes.bool,
366
+ /** Pass a ref to the input element. */
367
+ inputRef: ref,
402
368
 
403
- /** prevent all event if true */
404
- readOnly: PropTypes.bool,
369
+ /** Style inline of input element. */
370
+ inputStyle: PropTypes.object,
405
371
 
406
- /** auto focus after first render */
407
- autoFocus: PropTypes.bool,
372
+ /** The label of the component. */
373
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
408
374
 
409
- /** auto increase margin-bottom if error too long */
410
- autoIncreaseBot: PropTypes.bool,
375
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
376
+ labelProps: PropTypes.object,
411
377
 
412
- /** At least one character is required */
413
- required: PropTypes.bool,
378
+ /** Maximum number of rows to display when multiline option is set to true. */
379
+ maxRows: PropTypes.number,
414
380
 
415
- /** icon element display in the right of input (only use for type is inform, if not, use startIcon instead) */
416
- icon: PropTypes.any,
381
+ /** If `true`, a textarea element is rendered. */
382
+ multiline: PropTypes.bool,
417
383
 
418
- /** icon element display in the left of input */
419
- startIcon: PropTypes.any,
384
+ /** Callback fired when the input is blurred. */
385
+ onBlur: PropTypes.func,
420
386
 
421
- /** icon element display in the right of input */
422
- endIcon: PropTypes.any,
387
+ /** Callback fired when the value is changed. */
388
+ onChange: PropTypes.func,
423
389
 
424
- /** props of start icon in InputBase component */
425
- startIconProps: PropTypes.object,
390
+ /** Callback fired when the input is focused. */
391
+ onFocus: PropTypes.func,
426
392
 
427
- /** props of end icon in InputBase component */
428
- endIconProps: PropTypes.object,
393
+ /** Callback fired when input. */
394
+ onInput: PropTypes.func,
429
395
 
430
- /** style inline for icon */
431
- iconStyle: PropTypes.object,
396
+ /** Callback fired when pressing a key. */
397
+ onKeyDown: PropTypes.func,
432
398
 
433
- /** style inline for dropdown */
434
- style: PropTypes.object,
399
+ /** Callback fired when releases a key. */
400
+ onKeyUp: PropTypes.func,
435
401
 
436
- /** props of input in TextInput component */
437
- inputProps: PropTypes.object,
402
+ /** The short hint displayed in the input before the user enters a value. */
403
+ placeholder: PropTypes.string,
438
404
 
439
- /** style inline of input in TextInput component */
440
- inputStyle: PropTypes.object,
405
+ /** If `true`, the component is readOnly. */
406
+ readOnly: PropTypes.bool,
441
407
 
442
- /** any props of label in TextInput component */
443
- labelProps: PropTypes.object,
408
+ /** If `true`, the input element is required. */
409
+ required: PropTypes.bool,
444
410
 
445
- /** on key down function */
446
- onKeyDown: PropTypes.func,
411
+ /** Number of rows to display when multiline option is set to true. */
412
+ rows: PropTypes.number,
447
413
 
448
- /** on key up function */
449
- onKeyUp: PropTypes.func,
414
+ /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed to the left of input. */
415
+ startIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
450
416
 
451
- /** on input function */
452
- onInput: PropTypes.func,
417
+ /** Props of start icon in InputBase component. */
418
+ startIconProps: PropTypes.object,
453
419
 
454
- /** on change function */
455
- onChange: PropTypes.func,
420
+ /** Status type to display color for input. */
421
+ status: PropTypes.oneOf(['default', 'warning', 'success', 'danger']),
456
422
 
457
- /** on blur function */
458
- onBlur: PropTypes.func,
423
+ /** Style inline of component. */
424
+ style: PropTypes.object,
459
425
 
460
- /** on focus function */
461
- onFocus: PropTypes.func,
426
+ /** Type of the input element. It should be [a valid HTML5 input type](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Form_%3Cinput%3E_types). */
427
+ type: PropTypes.oneOf(['inform', 'edit', 'quickEdit', 'text', 'number', 'password']),
462
428
 
463
- /** validation value, argument can:<br/>
464
- * * string: the validation rule. Example required.<br/>
465
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
466
- * * array: the validation rule list, insist object/string
429
+ /** Validation value, argument can:<br/>
430
+ * * string: the validation rule. Example required.<br/>
431
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
432
+ * * array: the validation rule list, insist object/string
467
433
  */
468
434
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
469
435
 
470
- /** inputRef of TextInput component */
471
- inputRef: PropTypes.any,
472
-
473
- /** autoWidth of TextInput component, don't run with multiline = true */
474
- autoWidth: PropTypes.bool,
436
+ /** The value of the input element, required for a controlled component. */
437
+ value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
475
438
 
476
- /** If `true`, a textarea element is rendered. */
477
- multiline: PropTypes.bool
439
+ /** The variant to use. */
440
+ viewType: PropTypes.oneOf(['underlined', 'outlined'])
478
441
  };
479
442
  export default TextInput;
@@ -1,17 +1,12 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
- import { useRef, useState, forwardRef, useImperativeHandle, useEffect } from 'react';
4
+ import { useState, forwardRef, useEffect } from 'react';
5
5
  import { jsx } from '@emotion/core';
6
6
 
7
7
  const OptionWrapper = WrappedComponent => {
8
8
  return /*#__PURE__*/forwardRef((props, ref) => {
9
- if (!ref) {
10
- ref = useRef(null);
11
- }
12
-
13
9
  const [options, setOptions] = useState({});
14
- const componentRef = useRef(null);
15
10
 
16
11
  const option = (option, optionValue) => {
17
12
  if (typeof option === 'undefined') {
@@ -30,14 +25,12 @@ const OptionWrapper = WrappedComponent => {
30
25
  useEffect(() => {
31
26
  setOptions({});
32
27
  }, [props]);
33
- useImperativeHandle(ref, () => ({ ...componentRef.current,
34
- instance: { ...componentRef.current.instance,
35
- option
36
- }
37
- }), [componentRef]);
38
28
  return jsx(WrappedComponent, { ...props,
39
29
  ...options,
40
- ref: componentRef
30
+ action: {
31
+ option
32
+ },
33
+ ref: ref
41
34
  });
42
35
  });
43
36
  };
@@ -42,6 +42,7 @@ const getLastPage = (totalItems, itemsPerPage) => {
42
42
 
43
43
  const delayOnInput = getGlobal('delayOnInput');
44
44
  const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
45
+ action = {},
45
46
  bgColor,
46
47
  className,
47
48
  currentPage,
@@ -213,23 +214,34 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
213
214
  changeBy: 'itemsPerPage'
214
215
  });
215
216
  }, [itemsPerPageState]);
216
- useImperativeHandle(reference, () => ({
217
- element: ref.current,
218
- instance: {
217
+ useImperativeHandle(reference, () => {
218
+ const currentRef = ref.current || {};
219
+ currentRef.element = ref.current;
220
+ const _instance = {
219
221
  onChangePage: page => _onChangePage({
220
222
  page: page,
221
223
  changeBy: 'ref'
222
224
  }),
223
225
  onChangePerPage: per => _onChangePerPage(per),
224
- setTotalItems: items => setTotalItemsState(items)
225
- },
226
- onChangePage: page => _onChangePage({
226
+ setTotalItems: items => setTotalItemsState(items),
227
+ ...action
228
+ }; // methods
229
+
230
+ _instance.__proto__ = {}; // hidden methods
231
+
232
+ currentRef.instance = _instance;
233
+
234
+ currentRef.onChangePage = page => _onChangePage({
227
235
  page: page,
228
236
  changeBy: 'ref'
229
- }),
230
- onChangePerPage: per => _onChangePerPage(per),
231
- setTotalItems: items => setTotalItemsState(items)
232
- }));
237
+ });
238
+
239
+ currentRef.onChangePerPage = per => _onChangePerPage(per);
240
+
241
+ currentRef.setTotalItems = items => setTotalItemsState(items);
242
+
243
+ return currentRef;
244
+ });
233
245
 
234
246
  const updateSize = () => {
235
247
  if (timer.current) {
@@ -38,6 +38,7 @@ const getLastPage = (totalItems, itemsPerPage) => {
38
38
 
39
39
  const delayOnInput = getGlobal('delayOnInput');
40
40
  const PagingSelector = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
+ action = {},
41
42
  className,
42
43
  currentPage,
43
44
  hideEllipsis,
@@ -172,23 +173,34 @@ const PagingSelector = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
172
173
  changeBy: 'itemsPerPage'
173
174
  });
174
175
  }, [itemsPerPageState]);
175
- useImperativeHandle(reference, () => ({
176
- element: ref.current,
177
- instance: {
176
+ useImperativeHandle(reference, () => {
177
+ const currentRef = ref.current || {};
178
+ currentRef.element = ref.current;
179
+ const _instance = {
178
180
  onChangePage: page => _onChangePage({
179
181
  page: page,
180
182
  changeBy: 'ref'
181
183
  }),
182
184
  onChangePerPage: per => _onChangePerPage(per),
183
- setTotalItems: items => setTotalItemsState(items)
184
- },
185
- onChangePage: page => _onChangePage({
185
+ setTotalItems: items => setTotalItemsState(items),
186
+ ...action
187
+ }; // methods
188
+
189
+ _instance.__proto__ = {}; // hidden methods
190
+
191
+ currentRef.instance = _instance;
192
+
193
+ currentRef.onChangePage = page => _onChangePage({
186
194
  page: page,
187
195
  changeBy: 'ref'
188
- }),
189
- onChangePerPage: per => _onChangePerPage(per),
190
- setTotalItems: items => setTotalItemsState(items)
191
- }));
196
+ });
197
+
198
+ currentRef.onChangePerPage = per => _onChangePerPage(per);
199
+
200
+ currentRef.setTotalItems = items => setTotalItemsState(items);
201
+
202
+ return currentRef;
203
+ });
192
204
 
193
205
  const renderButton = (key, page, isSelected, customDisplay) => {
194
206
  if (page >= lastPage || page < 0) return;
@@ -17,16 +17,24 @@ const {
17
17
  spacing
18
18
  } = theme;
19
19
  const PopoverBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
20
+ action = {},
20
21
  children,
21
22
  className,
22
23
  id,
23
24
  style
24
25
  }, reference) => {
25
26
  const ref = useRef(null);
26
- useImperativeHandle(reference, () => ({
27
- element: ref.current,
28
- instance: {}
29
- }));
27
+ useImperativeHandle(reference, () => {
28
+ const currentRef = ref.current || {};
29
+ currentRef.element = ref.current;
30
+ const _instance = { ...action
31
+ }; // methods
32
+
33
+ _instance.__proto__ = {}; // hidden methods
34
+
35
+ currentRef.instance = _instance;
36
+ return currentRef;
37
+ });
30
38
  return useMemo(() => jsx("div", {
31
39
  css: PopoverBodyCSS,
32
40
  ref: ref,
@@ -16,6 +16,7 @@ const {
16
16
  spacing
17
17
  } = theme;
18
18
  const PopoverFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
19
+ action = {},
19
20
  boxShadow,
20
21
  children,
21
22
  className,
@@ -26,10 +27,17 @@ const PopoverFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
26
27
 
27
28
  const _PopoverFooterCSS = PopoverFooterCSS(boxShadow);
28
29
 
29
- useImperativeHandle(reference, () => ({
30
- element: ref.current,
31
- instance: {}
32
- }));
30
+ useImperativeHandle(reference, () => {
31
+ const currentRef = ref.current || {};
32
+ currentRef.element = ref.current;
33
+ const _instance = { ...action
34
+ }; // methods
35
+
36
+ _instance.__proto__ = {}; // hidden methods
37
+
38
+ currentRef.instance = _instance;
39
+ return currentRef;
40
+ });
33
41
  return useMemo(() => jsx("div", {
34
42
  css: _PopoverFooterCSS,
35
43
  ref: ref,
@@ -17,6 +17,7 @@ const {
17
17
  spacing
18
18
  } = theme;
19
19
  const PopoverHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
20
+ action = {},
20
21
  children,
21
22
  className,
22
23
  id,
@@ -24,10 +25,17 @@ const PopoverHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
24
25
  title
25
26
  }, reference) => {
26
27
  const ref = useRef(null);
27
- useImperativeHandle(reference, () => ({
28
- element: ref.current,
29
- instance: {}
30
- }));
28
+ useImperativeHandle(reference, () => {
29
+ const currentRef = ref.current || {};
30
+ currentRef.element = ref.current;
31
+ const _instance = { ...action
32
+ }; // methods
33
+
34
+ _instance.__proto__ = {}; // hidden methods
35
+
36
+ currentRef.instance = _instance;
37
+ return currentRef;
38
+ });
31
39
  return useMemo(() => jsx("div", {
32
40
  css: PopoverHeaderCSS,
33
41
  ref: ref,
@@ -130,6 +130,7 @@ const getDirectionPopover = direction => {
130
130
  };
131
131
 
132
132
  const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
133
+ action = {},
133
134
  anchor,
134
135
  anchorOrigin,
135
136
  arrow,
@@ -450,20 +451,30 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
450
451
  useEffect(() => {
451
452
  clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
452
453
  }, [clickOutsideToClose]);
453
- useImperativeHandle(reference, () => ({
454
- element: ref.current,
455
- instance: {
454
+ useImperativeHandle(reference, () => {
455
+ const currentRef = ref.current || {};
456
+ currentRef.element = ref.current;
457
+ const _instance = {
456
458
  show: el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover(),
457
459
  close: () => onClosePopover(),
458
460
  setPosition: el => updatePositionPopover(el),
459
- __proto__: {
460
- hide: () => onClosePopover()
461
- }
462
- },
463
- show: el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover(),
464
- close: () => onClosePopover(),
465
- setPosition: el => updatePositionPopover(el)
466
- }), [ref, openState, onClose]);
461
+ ...action
462
+ }; // methods
463
+
464
+ _instance.__proto__ = {
465
+ hide: () => onClosePopover()
466
+ }; // hidden methods
467
+
468
+ currentRef.instance = _instance;
469
+
470
+ currentRef.show = el => !openState && el ? updatePositionPopover(el, onOpenPopover()) : onOpenPopover();
471
+
472
+ currentRef.close = onClosePopover;
473
+
474
+ currentRef.setPosition = el => updatePositionPopover(el);
475
+
476
+ return currentRef;
477
+ });
467
478
 
468
479
  const renderAnchor = () => {
469
480
  var _anchor10;
@@ -31,6 +31,7 @@ const iconSizeMap = new Map([['small', '16px'], ['medium', '20px'], ['large', '2
31
31
  const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
32
32
  const filledPaddingSizeMap = new Map([['small', '2px 8px'], ['medium', '2px 12px'], ['large', '2px 12px']]);
33
33
  const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
34
+ action = {},
34
35
  className,
35
36
  color,
36
37
  icon,
@@ -50,10 +51,17 @@ const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
50
51
 
51
52
  const _StatusRoot = StatusRoot(iconSize, _color, size, outlinedPaddingSize);
52
53
 
53
- useImperativeHandle(reference, () => ({
54
- element: ref.current,
55
- instance: {}
56
- }));
54
+ useImperativeHandle(reference, () => {
55
+ const currentRef = ref.current || {};
56
+ currentRef.element = ref.current;
57
+ const _instance = { ...action
58
+ }; // methods
59
+
60
+ _instance.__proto__ = {}; // hidden methods
61
+
62
+ currentRef.instance = _instance;
63
+ return currentRef;
64
+ });
57
65
  const StatusIcon = typeof icon === 'string' ? jsx(Icon, {
58
66
  name: icon,
59
67
  width: iconSize,
package/icons/effect.js CHANGED
@@ -15,6 +15,7 @@ const {
15
15
  }
16
16
  } = colors;
17
17
  const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
18
+ action = {},
18
19
  name,
19
20
  className,
20
21
  style,
@@ -27,28 +28,35 @@ const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
27
28
  }, reference) => {
28
29
  const ref = useRef(null);
29
30
  const IconCss = css`
30
- ${flexRow};
31
- ${justifyCenter};
32
- ${alignCenter};
33
- ${borderBox};
34
- ${outlineNone};
35
- ${userSelectNone};
36
- width: max-content;
37
- height: max-content;
38
- min-width: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
39
- min-height: ${width ? isNaN(height) ? height : height + 'px' : '24px'};
40
- `;
31
+ ${flexRow};
32
+ ${justifyCenter};
33
+ ${alignCenter};
34
+ ${borderBox};
35
+ ${outlineNone};
36
+ ${userSelectNone};
37
+ width: max-content;
38
+ height: max-content;
39
+ min-width: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
40
+ min-height: ${width ? isNaN(height) ? height : height + 'px' : '24px'};
41
+ `;
41
42
  const NotFoundIcon = css`
42
- ${flexRow};
43
- ${borderBox};
44
- width: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
45
- height: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
46
- border: 1px dashed ${rest};
47
- `;
48
- useImperativeHandle(reference, () => ({
49
- element: ref.current,
50
- instance: {}
51
- }));
43
+ ${flexRow};
44
+ ${borderBox};
45
+ width: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
46
+ height: ${width ? isNaN(width) ? width : width + 'px' : '24px'};
47
+ border: 1px dashed ${rest};
48
+ `;
49
+ useImperativeHandle(reference, () => {
50
+ const currentRef = ref.current || {};
51
+ currentRef.element = ref.current;
52
+ const _instance = { ...action
53
+ }; // methods
54
+
55
+ _instance.__proto__ = {}; // hidden methods
56
+
57
+ currentRef.instance = _instance;
58
+ return currentRef;
59
+ });
52
60
  return useMemo(() => {
53
61
  if (!name) return null;
54
62
  let node = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.69-beta.6",
3
+ "version": "1.3.69-beta.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",