diginet-core-ui 1.3.63-beta.1 → 1.3.63-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.
@@ -175,7 +175,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
175
175
  var _inputRef$current$chi;
176
176
 
177
177
  inputRef.current.innerHTML = inputRef.current.textContent.trim();
178
- inputRef.current.contentEditable = true;
178
+ if (!allowSearch) inputRef.current.contentEditable = true;
179
179
  const caret = (_inputRef$current$chi = inputRef.current.childNodes) !== null && _inputRef$current$chi !== void 0 && _inputRef$current$chi.length ? 1 : 0;
180
180
  const range = document.createRange();
181
181
  range.setStart(inputRef.current, caret);
@@ -1202,7 +1202,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1202
1202
  inputRef.current.addEventListener('input', onChangeInput);
1203
1203
  !!onLoadMore && dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
1204
1204
  } else {
1205
- if (multiple) {
1205
+ if (multiple || allowSearch) {
1206
1206
  inputRef.current.contentEditable = false;
1207
1207
  }
1208
1208
  }
@@ -1220,7 +1220,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1220
1220
  inputRef.current.removeEventListener('click', onClickInput);
1221
1221
  inputRef.current.removeEventListener('input', onChangeInput);
1222
1222
  } else {
1223
- if (multiple) {
1223
+ if (multiple && !allowSearch) {
1224
1224
  inputRef.current.contentEditable = true;
1225
1225
  }
1226
1226
  }
@@ -1313,7 +1313,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1313
1313
  return false;
1314
1314
  }
1315
1315
  }) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
1316
- contentEditable: !disabled,
1316
+ contentEditable: !disabled && !allowSearch,
1317
1317
  style: inputStyle,
1318
1318
  ref: inputRef,
1319
1319
  css: _DropdownInputCSS,
@@ -1330,7 +1330,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1330
1330
  css: _DropdownInputCSS,
1331
1331
  type: "text",
1332
1332
  placeholder: placeholder,
1333
- disabled: disabled
1333
+ disabled: disabled || allowSearch
1334
1334
  })), jsx("div", {
1335
1335
  ref: iconRef,
1336
1336
  css: _IconCSS,
@@ -1752,7 +1752,7 @@ Dropdown.defaultProps = {
1752
1752
  readOnly: false,
1753
1753
  required: false,
1754
1754
  multiple: false,
1755
- allowSearch: false,
1755
+ allowSearch: true,
1756
1756
  inputProps: {},
1757
1757
  formStyle: {},
1758
1758
  dataSource: [],
@@ -79,13 +79,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
79
79
  const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
80
80
 
81
81
  if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
82
- /**
83
- * Convert number to format money
84
- * @param vl {number} - value
85
- * @type {function(*): number}
86
- * @return {string}
87
- * @example 1200300.123 => 1,200,300.123
88
- * @example 1200300,123 => 1.200.300,123
82
+ /**
83
+ * Convert number to format money
84
+ * @param vl {number} - value
85
+ * @type {function(*): number}
86
+ * @return {string}
87
+ * @example 1200300.123 => 1,200,300.123
88
+ * @example 1200300,123 => 1.200.300,123
89
89
  */
90
90
 
91
91
  const parseNumberToMoney = useCallback((vl, isNumber) => {
@@ -119,13 +119,13 @@ const NumberInput = /*#__PURE__*/forwardRef(({
119
119
 
120
120
  return number;
121
121
  }, [decimalSymbol, max, value]);
122
- /**
123
- * Convert money to format number
124
- * @param vl {string} - value
125
- * @type {function(*): number}
126
- * @return {number}
127
- * @example 1,200,300.123 => 1200300.123
128
- * @example 1.200.300,123 => 1200300.123
122
+ /**
123
+ * Convert money to format number
124
+ * @param vl {string} - value
125
+ * @type {function(*): number}
126
+ * @return {number}
127
+ * @example 1,200,300.123 => 1200300.123
128
+ * @example 1.200.300,123 => 1200300.123
129
129
  */
130
130
 
131
131
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
@@ -397,10 +397,10 @@ NumberInput.propTypes = {
397
397
  /** style inline of input in NumberInput component */
398
398
  inputStyle: PropTypes.object,
399
399
 
400
- /** validation value, argument can:<br/>
401
- * * string: the validation rule. Example required.<br/>
402
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
403
- * * array: the validation rule list, insist object/string
400
+ /** validation value, argument can:<br/>
401
+ * * string: the validation rule. Example required.<br/>
402
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
403
+ * * array: the validation rule list, insist object/string
404
404
  */
405
405
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
406
406
 
@@ -496,10 +496,10 @@ TextInput.propTypes = {
496
496
  /** on focus function */
497
497
  onFocus: PropTypes.func,
498
498
 
499
- /** validation value, argument can:<br/>
500
- * * string: the validation rule. Example required.<br/>
501
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
502
- * * array: the validation rule list, insist object/string
499
+ /** validation value, argument can:<br/>
500
+ * * string: the validation rule. Example required.<br/>
501
+ * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
502
+ * * array: the validation rule list, insist object/string
503
503
  */
504
504
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
505
505
 
@@ -586,23 +586,23 @@ PagingInfo.propTypes = {
586
586
  /** Callback fired when quantity on per page changed. */
587
587
  onChangePerPage: PropTypes.func,
588
588
 
589
- /**
590
- * Callback fired when page number is changing.
591
- *
592
- * * prevPage: Page before changed
593
- * * newPage: Page after changed
594
- * * cancel(value): Function cancel change page
595
- * * @param {value} - bool
589
+ /**
590
+ * Callback fired when page number is changing.
591
+ *
592
+ * * prevPage: Page before changed
593
+ * * newPage: Page after changed
594
+ * * cancel(value): Function cancel change page
595
+ * * @param {value} - bool
596
596
  */
597
597
  onChangingPage: PropTypes.func,
598
598
 
599
- /**
600
- * Callback fired when quantity on item per page is changing.
601
- *
602
- * * prevPerPage: Items per page before changed
603
- * * newPerPage: Items per page after changed
604
- * * cancel(value): Function cancel change items per page
605
- * * @param {value} - bool
599
+ /**
600
+ * Callback fired when quantity on item per page is changing.
601
+ *
602
+ * * prevPerPage: Items per page before changed
603
+ * * newPerPage: Items per page after changed
604
+ * * cancel(value): Function cancel change items per page
605
+ * * @param {value} - bool
606
606
  */
607
607
  onChangingPerPage: PropTypes.func,
608
608
 
@@ -615,15 +615,15 @@ PagingInfo.propTypes = {
615
615
  /** Compact type for mobile. */
616
616
  typeShort: PropTypes.bool,
617
617
 
618
- /**
619
- * ref methods (ref.current.instance.*method*)
620
- *
621
- * * onChangePage(page): Change page number
622
- * * @param {page} - number
623
- * * onChangePerPage(per): Change quantity on per page
624
- * * @param {per} - number
625
- * * setTotalItems(items): Set total items
626
- * * @param {items} - number
618
+ /**
619
+ * ref methods (ref.current.instance.*method*)
620
+ *
621
+ * * onChangePage(page): Change page number
622
+ * * @param {page} - number
623
+ * * onChangePerPage(per): Change quantity on per page
624
+ * * @param {per} - number
625
+ * * setTotalItems(items): Set total items
626
+ * * @param {items} - number
627
627
  */
628
628
  reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
629
629
  current: PropTypes.instanceOf(Element)
@@ -1,103 +1,105 @@
1
1
  /** @jsxRuntime classic */
2
2
 
3
3
  /** @jsx jsx */
4
- import { memo, useMemo, forwardRef, useRef } from 'react';
4
+ import { css, jsx } from '@emotion/core';
5
5
  import PropTypes from 'prop-types';
6
- import { jsx, css } from '@emotion/core';
6
+ import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
7
7
  import { Typography } from '../';
8
8
  import Icon from '../../icons';
9
- import { alignCenter, backgroundTransparent, borderBox, inlineFlex, justifyCenter } from '../../styles/general';
10
- import { color as colors } from '../../styles/colors';
9
+ import { alignCenter, backgroundTransparent, borderBox, flexRow } from '../../styles/general';
10
+ import theme from '../../theme/settings';
11
+ import OptionWrapper from '../others/option-wrapper';
11
12
  const {
12
- system: {
13
- active,
14
- rest
15
- },
16
- semantic: {
17
- success,
18
- warning,
19
- danger,
20
- info
21
- },
22
- fill: {
23
- sidebar
13
+ colors: {
14
+ system: {
15
+ active,
16
+ rest
17
+ },
18
+ semantic: {
19
+ success,
20
+ warning,
21
+ danger,
22
+ info
23
+ },
24
+ fill: {
25
+ sidebar
26
+ }
24
27
  }
25
- } = colors;
28
+ } = theme;
26
29
  const colorMap = new Map([['default', rest], ['primary', active], ['success', success], ['warning', warning], ['danger', danger], ['info', info]]);
27
30
  const iconSizeMap = new Map([['small', '16px'], ['medium', '20px'], ['large', '24px']]);
28
31
  const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
29
- const filledPaddingSizeMap = new Map([['small', '0px 8px'], ['medium', '0px 12px'], ['large', '0px 16px']]);
32
+ const filledPaddingSizeMap = new Map([['small', '2px 8px'], ['medium', '2px 12px'], ['large', '2px 12px']]);
30
33
  const Status = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
31
- style,
32
- viewType,
33
- size,
34
+ className,
35
+ color,
34
36
  icon,
37
+ size,
35
38
  text,
36
- color,
37
- className,
38
- ...props
39
- }, ref) => {
40
- if (!ref) {
41
- ref = useRef(null);
42
- }
43
-
39
+ viewType,
40
+ id,
41
+ style
42
+ }, reference) => {
43
+ const ref = useRef(null);
44
44
  const outlinedPaddingSize = filledPaddingSizeMap.get(size);
45
45
 
46
- const _color = colorMap.get(color);
46
+ const _color = colorMap.get(color) || color || rest;
47
47
 
48
48
  const iconSize = iconSizeMap.get(size);
49
49
  const typographySize = typographySizeMap.get(size);
50
- const StatusRoot = css`
51
- ${inlineFlex}
52
- ${alignCenter}
53
- ${justifyCenter}
54
- ${backgroundTransparent}
55
- ${borderBox}
56
- min-height: ${iconSize};
57
- margin: 0 5px;
58
- color: ${_color || color || rest};
59
- &.filled {
60
- color: ${sidebar};
61
- background-color: ${_color || color || rest};
62
- border-radius: 12px;
63
- &.${size} {
64
- padding: ${outlinedPaddingSize}
65
- }
66
- }
67
- `;
68
- const TextCSS = css`
69
- white-space: nowrap;
70
- `;
71
- const StatusText = useMemo(() => jsx(Typography, {
50
+
51
+ const _StatusRoot = StatusRoot(iconSize, _color, size, outlinedPaddingSize);
52
+
53
+ useImperativeHandle(reference, () => ({
54
+ element: ref.current,
55
+ instance: {}
56
+ }));
57
+ const StatusIcon = typeof icon === 'string' ? jsx(Icon, {
58
+ name: icon,
59
+ width: iconSize,
60
+ height: iconSize,
61
+ color: 'currentColor',
62
+ viewBox: true
63
+ }) : icon;
64
+ const StatusText = jsx(Typography, {
72
65
  css: TextCSS,
73
66
  type: typographySize,
74
67
  color: 'inherit'
75
- }, text), [text, size]);
76
- const StatusIcon = useMemo(() => {
77
- let node = icon;
68
+ }, text);
69
+ return useMemo(() => {
70
+ return jsx("div", {
71
+ css: _StatusRoot,
72
+ ref: ref,
73
+ id: id,
74
+ style: style,
75
+ className: ['DGN-UI-Status', viewType, size, className].join(' ').trim().replace(/\s+/g, ' ')
76
+ }, StatusIcon, StatusText);
77
+ }, [className, color, icon, size, text, viewType, id, style]);
78
+ }));
78
79
 
79
- if (typeof node === 'string') {
80
- node = jsx(Icon, {
81
- name: node,
82
- width: iconSize,
83
- height: iconSize,
84
- color: 'currentColor',
85
- viewBox: true
86
- });
80
+ const StatusRoot = (iconSize, color, size, outlinedPaddingSize) => css`
81
+ ${flexRow};
82
+ ${alignCenter};
83
+ ${backgroundTransparent};
84
+ ${borderBox};
85
+ gap: ${size === 'small' ? '2px' : '4px'};
86
+ min-height: ${iconSize};
87
+ color: ${color};
88
+ &.filled {
89
+ color: ${sidebar};
90
+ background-color: ${color};
91
+ border-radius: 12px;
92
+ &.${size} {
93
+ padding: ${outlinedPaddingSize};
94
+ }
87
95
  }
96
+ `;
88
97
 
89
- return node;
90
- }, [icon]);
91
- return jsx("div", {
92
- css: StatusRoot,
93
- style: style,
94
- className: ['DGN-UI-Status', viewType, size, className].join(' ').trim().replace(/\s+/g, ' '),
95
- ref: ref,
96
- ...props
97
- }, StatusIcon, StatusText);
98
- }));
98
+ const TextCSS = css`
99
+ white-space: nowrap;
100
+ `;
99
101
  Status.defaultProps = {
100
- viewType: 'default',
102
+ viewType: 'ghost',
101
103
  text: '',
102
104
  icon: '',
103
105
  size: 'medium',
@@ -105,25 +107,26 @@ Status.defaultProps = {
105
107
  style: {}
106
108
  };
107
109
  Status.propTypes = {
108
- /** type of status, has background or none */
109
- viewType: PropTypes.oneOf(['filled', 'default']),
110
+ /** Class for component. */
111
+ className: PropTypes.string,
110
112
 
111
- /** size of status */
112
- size: PropTypes.oneOf(['small', 'medium', 'large']),
113
+ /** The color of the component. */
114
+ color: PropTypes.string,
113
115
 
114
- /** content to display in status */
115
- text: PropTypes.string,
116
+ /** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic--basic) or element placed before the content. */
117
+ icon: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
116
118
 
117
- /** color of text or background */
118
- color: PropTypes.string,
119
+ /** The size of the component. */
120
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
119
121
 
120
- /** class of Status component */
121
- className: PropTypes.string,
122
+ /** The content of the component. */
123
+ text: PropTypes.string,
122
124
 
123
- /** style inline for Status */
124
- style: PropTypes.object,
125
+ /** The variant to use. */
126
+ viewType: PropTypes.oneOf(['filled', 'default', 'ghost']),
125
127
 
126
- /** icon to display before content, allow name of icons store */
127
- icon: PropTypes.any
128
+ /** Style inline of component. */
129
+ style: PropTypes.object
128
130
  };
129
- export default Status;
131
+ export { Status };
132
+ export default OptionWrapper(Status);
@@ -227,8 +227,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
227
227
  el.classList[isChecked ? 'add' : 'remove']('disabled');
228
228
 
229
229
  if (el.classList.contains('DGN-UI-Accordion')) {
230
- el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
231
- el.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild.disabled = isChecked;
230
+ el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
231
+ el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.disabled = isChecked;
232
232
  Array.from(el.childNodes).forEach(e => {
233
233
  e.classList[isChecked ? 'add' : 'remove']('treeview-disabled');
234
234
  });
@@ -248,7 +248,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
248
248
  if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
249
249
  var _node$querySelectorAl;
250
250
 
251
- const checkbox = node.firstChild.firstChild.firstChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
251
+ const checkbox = node.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild; // Trường hợp phải set về false để xét các input đã check không bao gồm node này
252
252
 
253
253
  checkbox.firstChild.checked = isChecked;
254
254
  const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length); // Nếu có ít nhất một input con được check thì phải checked cho input này
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.63-beta.1",
3
+ "version": "1.3.63-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",