diginet-core-ui 1.3.66 → 1.3.67

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.
Files changed (46) hide show
  1. package/assets/storybook/avatar01.svg +9 -0
  2. package/assets/storybook/cover01.svg +9 -0
  3. package/components/accordion/css.js +6 -6
  4. package/components/accordion/details.js +13 -18
  5. package/components/accordion/group.js +16 -17
  6. package/components/accordion/index.js +17 -22
  7. package/components/accordion/summary.js +55 -32
  8. package/components/avatar/index.js +23 -28
  9. package/components/badge/index.js +9 -14
  10. package/components/button/icon.js +25 -30
  11. package/components/button/index.js +275 -280
  12. package/components/card/body.js +47 -0
  13. package/components/card/extra.js +47 -0
  14. package/components/card/footer.js +47 -0
  15. package/components/card/header.js +50 -0
  16. package/components/card/index.js +175 -37
  17. package/components/chart/Pie-v2/Sector.js +2 -2
  18. package/components/chip/attach.js +5 -5
  19. package/components/form-control/attachment/index.js +26 -24
  20. package/components/form-control/calendar/function.js +133 -123
  21. package/components/form-control/calendar/index.js +16 -16
  22. package/components/form-control/dropdown/index.js +71 -10
  23. package/components/form-control/helper-text/index.js +8 -3
  24. package/components/form-control/number-input/index.js +11 -11
  25. package/components/form-control/phone-input/index.js +7 -7
  26. package/components/grid/Container.js +110 -0
  27. package/components/grid/Row.js +1 -1
  28. package/components/grid/index.js +35 -5
  29. package/components/index.js +7 -2
  30. package/components/others/option-wrapper/index.js +21 -27
  31. package/components/paging/page-info.js +31 -40
  32. package/components/popover/index.js +29 -27
  33. package/components/progress/circular.js +12 -12
  34. package/components/transfer/index.js +3 -3
  35. package/components/tree-view/index.js +10 -6
  36. package/icons/basic.js +120 -0
  37. package/icons/effect.js +4 -9
  38. package/package.json +1 -1
  39. package/readme.md +14 -0
  40. package/styles/color-helper.js +103 -103
  41. package/styles/utils.js +17 -5
  42. package/utils/error/error.js +2 -2
  43. package/utils/renderIcon.js +5 -5
  44. package/components/card/body-card.js +0 -65
  45. package/components/card/card.js +0 -125
  46. package/components/card/context.js +0 -6
@@ -0,0 +1,47 @@
1
+ /** @jsxRuntime classic */
2
+
3
+ /** @jsx jsx */
4
+ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { jsx } from '@emotion/core';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ const CardExtra = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
+ children,
10
+ className,
11
+ id,
12
+ style,
13
+ title
14
+ }, reference) => {
15
+ const ref = useRef(null);
16
+ useImperativeHandle(reference, () => ({
17
+ element: ref.current,
18
+ instance: {}
19
+ }));
20
+ return useMemo(() => {
21
+ return jsx("div", {
22
+ id: id,
23
+ ref: ref,
24
+ style: style,
25
+ className: [`DGN-UI-Card-Extra`, className].join(' ').trim().replace(/\s+/g, ' ')
26
+ }, children);
27
+ }, [children, className, id, style, title]);
28
+ }));
29
+ CardExtra.defaultProps = {
30
+ className: '',
31
+ style: {}
32
+ };
33
+ CardExtra.propTypes = {
34
+ /** The content of the component. */
35
+ children: PropTypes.node,
36
+
37
+ /** Class for component. ({container: '', header: '', body: '', footer: ''}) */
38
+ className: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
39
+
40
+ /** If `true`, will have divider between body and footer. */
41
+ style: PropTypes.object,
42
+
43
+ /** The title of the component's header. */
44
+ title: PropTypes.string
45
+ };
46
+ export { CardExtra };
47
+ export default OptionWrapper(CardExtra);
@@ -0,0 +1,47 @@
1
+ /** @jsxRuntime classic */
2
+
3
+ /** @jsx jsx */
4
+ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { jsx } from '@emotion/core';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ const CardFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
9
+ children,
10
+ className,
11
+ id,
12
+ style,
13
+ title
14
+ }, reference) => {
15
+ const ref = useRef(null);
16
+ useImperativeHandle(reference, () => ({
17
+ element: ref.current,
18
+ instance: {}
19
+ }));
20
+ return useMemo(() => {
21
+ return jsx("div", {
22
+ id: id,
23
+ ref: ref,
24
+ style: style,
25
+ className: [`DGN-UI-Card-Footer`, className].join(' ').trim().replace(/\s+/g, ' ')
26
+ }, children);
27
+ }, [children, className, id, style, title]);
28
+ }));
29
+ CardFooter.defaultProps = {
30
+ className: '',
31
+ style: {}
32
+ };
33
+ CardFooter.propTypes = {
34
+ /** The content of the component. */
35
+ children: PropTypes.node,
36
+
37
+ /** Class for component. ({container: '', header: '', body: '', footer: ''}) */
38
+ className: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
39
+
40
+ /** If `true`, will have divider between body and footer. */
41
+ style: PropTypes.object,
42
+
43
+ /** The title of the component's header. */
44
+ title: PropTypes.string
45
+ };
46
+ export { CardFooter };
47
+ export default OptionWrapper(CardFooter);
@@ -0,0 +1,50 @@
1
+ /** @jsxRuntime classic */
2
+
3
+ /** @jsx jsx */
4
+ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { jsx } from '@emotion/core';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ import Typography from '../typography';
9
+ const CardHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
10
+ children,
11
+ className,
12
+ id,
13
+ style,
14
+ title
15
+ }, reference) => {
16
+ const ref = useRef(null);
17
+ useImperativeHandle(reference, () => ({
18
+ element: ref.current,
19
+ instance: {}
20
+ }));
21
+ return useMemo(() => {
22
+ return jsx("div", {
23
+ id: id,
24
+ ref: ref,
25
+ style: style,
26
+ className: [`DGN-UI-Card-Header`, className].join(' ').trim().replace(/\s+/g, ' ')
27
+ }, children || jsx(Typography, {
28
+ type: 'h3'
29
+ }, title));
30
+ }, [children, className, id, style, title]);
31
+ }));
32
+ CardHeader.defaultProps = {
33
+ className: '',
34
+ style: {}
35
+ };
36
+ CardHeader.propTypes = {
37
+ /** The content of the component. */
38
+ children: PropTypes.node,
39
+
40
+ /** Class for component. ({container: '', header: '', body: '', footer: ''}) */
41
+ className: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
42
+
43
+ /** If `true`, will have divider between body and footer. */
44
+ style: PropTypes.object,
45
+
46
+ /** The title of the component's header. */
47
+ title: PropTypes.string
48
+ };
49
+ export { CardHeader };
50
+ export default OptionWrapper(CardHeader);
@@ -1,50 +1,188 @@
1
- /* eslint-disable react/display-name */
2
- import React, { memo, useEffect, useRef, forwardRef } from 'react';
1
+ /** @jsxRuntime classic */
2
+
3
+ /** @jsx jsx */
4
+ import { memo, useRef, useMemo, forwardRef, useImperativeHandle } from 'react';
3
5
  import PropTypes from 'prop-types';
4
- import Card from './card';
5
- import BodyCard from './body-card';
6
- const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
7
- style,
6
+ import { jsx, css } from '@emotion/core';
7
+ import OptionWrapper from '../others/option-wrapper';
8
+ import theme from '../../theme/settings';
9
+ import { borderBox, borderRadius4px, flexCol, flexRow, justifyEnd, overflowHidden, parseWidth, parseWidthHeight, positionAbsolute, positionRelative } from '../../styles/general';
10
+ import CardHeader from './header';
11
+ import { CardFooter } from './footer';
12
+ import { CardBody } from './body';
13
+ import { getColor } from '../../styles/utils';
14
+ const {
15
+ colors: {
16
+ system: {
17
+ white
18
+ },
19
+ line: {
20
+ category
21
+ }
22
+ },
23
+ spacing
24
+ } = theme;
25
+ const Card = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
26
+ body: bodyProp,
8
27
  bodyStyle,
9
- refs,
10
28
  children,
11
- ...props
12
- }, ref) => {
13
- if (!ref) {
14
- ref = useRef(null);
15
- }
16
-
17
- useEffect(() => {
18
- if (refs) refs(ref);
19
- }, []);
20
- return /*#__PURE__*/React.createElement(Card, {
21
- ref: ref,
22
- style: style,
23
- ...props
24
- }, /*#__PURE__*/React.createElement(BodyCard, {
29
+ className,
30
+ dividerColor,
31
+ footer,
32
+ footerDivider,
33
+ footerStyle,
34
+ header,
35
+ headerDivider,
36
+ headerStyle,
37
+ height,
38
+ id,
39
+ style,
40
+ title,
41
+ width
42
+ }, reference) => {
43
+ const ref = useRef(null);
44
+
45
+ const _CardCSS = CardCSS(width, height, headerDivider, footerDivider, dividerColor);
46
+
47
+ useImperativeHandle(reference, () => ({
48
+ element: ref.current,
49
+ instance: {}
50
+ }));
51
+ const head = header || title ? jsx(CardHeader, {
52
+ className: (className === null || className === void 0 ? void 0 : className.header) || '',
53
+ style: headerStyle,
54
+ title: title
55
+ }, header) : null;
56
+ const foot = footer ? jsx(CardFooter, {
57
+ className: (className === null || className === void 0 ? void 0 : className.footer) || '',
58
+ style: footerStyle
59
+ }, footer) : null;
60
+ const body = bodyProp || children && (head || foot) ? jsx(CardBody, {
61
+ className: (className === null || className === void 0 ? void 0 : className.body) || '',
25
62
  style: bodyStyle
26
- }, children));
63
+ }, bodyProp || children) : null;
64
+ return useMemo(() => {
65
+ return jsx("div", {
66
+ id: id,
67
+ ref: ref,
68
+ css: _CardCSS,
69
+ style: style,
70
+ className: [`DGN-UI-Card`, (className === null || className === void 0 ? void 0 : className.container) || className].join(' ').trim().replace(/\s+/g, ' ')
71
+ }, head, body || children, foot);
72
+ }, [bodyProp, bodyStyle, children, className, dividerColor, footer, footerDivider, footerStyle, header, headerDivider, headerStyle, height, id, style, title, width]);
27
73
  }));
28
- Popup.defaultProps = {
29
- title: ''
74
+
75
+ const CardCSS = (width, height, headerDivider, footerDivider, dividerColor) => css`
76
+ ${flexCol};
77
+ ${positionRelative};
78
+ ${borderBox};
79
+ ${borderRadius4px};
80
+ ${overflowHidden}
81
+ ${parseWidthHeight(width || spacing([64.5]), height || 'max-content')};
82
+ ${parseWidth(width)};
83
+ background: ${white};
84
+ .DGN-UI-Card-Header {
85
+ ${flexRow};
86
+ ${positionRelative};
87
+ ${borderBox};
88
+ order: 1;
89
+ padding: ${spacing([4])};
90
+ &:after {
91
+ ${positionAbsolute};
92
+ content: '';
93
+ left: 0;
94
+ right: 0;
95
+ bottom: 0;
96
+ margin: ${spacing([0, 4])};
97
+ border-bottom: ${headerDivider ? `1px solid ${getColor(dividerColor)}` : 'none'};
98
+ }
99
+ }
100
+ .DGN-UI-Card-Body {
101
+ ${flexCol};
102
+ ${positionRelative};
103
+ ${borderBox};
104
+ order: 2;
105
+ padding: ${headerDivider ? spacing([4]) : spacing([0, 4, 4])};
106
+ }
107
+ .DGN-UI-Card-Footer {
108
+ ${flexRow};
109
+ ${justifyEnd};
110
+ ${positionRelative};
111
+ ${borderBox};
112
+ order: 3;
113
+ padding: ${footerDivider ? spacing([4]) : spacing([0, 4, 4])};
114
+ &:before {
115
+ ${positionAbsolute};
116
+ content: '';
117
+ left: 0;
118
+ right: 0;
119
+ top: 0;
120
+ margin: ${spacing([0, 4])};
121
+ border-top: ${footerDivider ? `1px solid ${getColor(dividerColor)}` : 'none'};
122
+ }
123
+ }
124
+ .DGN-UI-Card-Extra {
125
+ ${flexCol};
126
+ ${positionRelative};
127
+ ${borderBox};
128
+ }
129
+ `;
130
+
131
+ Card.defaultProps = {
132
+ bodyStyle: {},
133
+ className: '',
134
+ dividerColor: category,
135
+ footerDivider: false,
136
+ footerStyle: {},
137
+ headerDivider: true,
138
+ headerStyle: {},
139
+ style: {}
30
140
  };
31
- Popup.propTypes = {
32
- /** customize style inline */
33
- style: PropTypes.object,
141
+ Card.propTypes = {
142
+ /** The content of the component's body. */
143
+ body: PropTypes.node,
34
144
 
35
- /** custom style inline for body */
145
+ /** The content of the component's body. */
36
146
  bodyStyle: PropTypes.object,
37
147
 
38
- /** get card ref by function */
39
- refs: PropTypes.func,
148
+ /** The content of the component. */
149
+ children: PropTypes.node,
40
150
 
41
- /** title for header */
42
- title: PropTypes.node,
151
+ /** Class for component. ({container: '', header: '', body: '', footer: ''}) */
152
+ className: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
43
153
 
44
- /** child content in body */
45
- children: PropTypes.node,
154
+ /** Color of divider. */
155
+ dividerColor: PropTypes.string,
156
+
157
+ /** The content of the component's footer. */
158
+ footer: PropTypes.node,
159
+
160
+ /** If `true`, will have divider between body and footer. */
161
+ footerDivider: PropTypes.bool,
162
+
163
+ /** Style inline of component's footer. */
164
+ footerStyle: PropTypes.object,
165
+
166
+ /** The content of the component's header. */
167
+ header: PropTypes.node,
168
+
169
+ /** If `true`, will have divider between header and body. */
170
+ headerDivider: PropTypes.bool,
171
+
172
+ /** Style inline of component's header. */
173
+ headerStyle: PropTypes.object,
174
+
175
+ /** Height of the component. */
176
+ height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
177
+
178
+ /** Style inline of component. */
179
+ style: PropTypes.object,
180
+
181
+ /** The title of the component's header. */
182
+ title: PropTypes.string,
46
183
 
47
- /** any props else */
48
- props: PropTypes.any
184
+ /** Width of the component. */
185
+ width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
49
186
  };
50
- export default Popup;
187
+ export { Card };
188
+ export default OptionWrapper(Card);
@@ -94,8 +94,8 @@ Sector.propTypes = {
94
94
  onTouchEnd: PropTypes.func,
95
95
  onTouchStart: PropTypes.func,
96
96
 
97
- /** function displays selected items by custom, example:<br/>
98
- * renderItem={(data, index) => index + ' - ' + data.name}<br/>
97
+ /** function displays selected items by custom, example:<br/>
98
+ * renderItem={(data, index) => index + ' - ' + data.name}<br/>
99
99
  */
100
100
  renderSelectedItem: PropTypes.func,
101
101
  path: PropTypes.string.isRequired,
@@ -156,11 +156,11 @@ const AttachChip = /*#__PURE__*/memo(({
156
156
  }))), attachView);
157
157
  });
158
158
  AttachChip.propTypes = {
159
- /** the file info, such as:<br/>
160
- * {<br/>
161
- * URL: https://url.com/pathname,<br/>
162
- * FileName: file.name,<br/>
163
- * }
159
+ /** the file info, such as:<br/>
160
+ * {<br/>
161
+ * URL: https://url.com/pathname,<br/>
162
+ * FileName: file.name,<br/>
163
+ * }
164
164
  */
165
165
  file: PropTypes.shape({
166
166
  URL: PropTypes.string.isRequired,
@@ -234,6 +234,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
234
234
  };
235
235
 
236
236
  const afterChangeFile = (length = 0) => {
237
+ var _sortIconRef$current;
238
+
237
239
  if (!length) {
238
240
  if (!attachmentImageRef.current.classList.contains('hint-center')) {
239
241
  attachmentImageRef.current.classList.add('hint-center');
@@ -242,11 +244,11 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
242
244
  attachmentImageRef.current.classList.remove('hint-center');
243
245
  }
244
246
 
245
- if (sortIconRef.current) {
247
+ if ((_sortIconRef$current = sortIconRef.current) !== null && _sortIconRef$current !== void 0 && _sortIconRef$current.element) {
246
248
  if (length > 1) {
247
- sortIconRef.current.style.display = null;
249
+ sortIconRef.current.element.style.display = null;
248
250
  } else {
249
- sortIconRef.current.style.display = 'none';
251
+ sortIconRef.current.element.style.display = 'none';
250
252
  }
251
253
  }
252
254
  };
@@ -1784,17 +1786,17 @@ Attachment.propTypes = {
1784
1786
  /** Class for component. */
1785
1787
  className: PropTypes.string,
1786
1788
 
1787
- /** List attachment:<br />
1788
- * [{<br />
1789
- * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1790
- * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1791
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1792
- * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1793
- * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1794
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1795
- * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1796
- * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1797
- * }, ...]
1789
+ /** List attachment:<br />
1790
+ * [{<br />
1791
+ * &nbsp;&nbsp;&nbsp;&nbsp;"AttachmentID": "ATT2U8O7YPTF1KSNCW3X",<br />
1792
+ * &nbsp;&nbsp;&nbsp;&nbsp;"URL": "https://apricot.diginet.com.vn/cdn-dev/file/8a07bee1eeff17a14eee.jpg?path=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlUGF0aCI6Ii8yMDIwLzA4LzQ0YjNhYjQ4LTMwNGQtNDQ3NC05ZDk0LWNkNGVlMDQwOGNlMy5qcGciLCJmaWxlTmFtZSI6IjhhMDdiZWUxZWVmZjE3YTE0ZWVlLmpwZyIsImZpbGVTaXplIjoyNDg4MzcsImZpbGVUeXBlIjoiaW1hZ2UvanBlZyIsImlhdCI6MTU5ODI0NDMwMiwiZXhwIjo4Nzk5ODI0NDMwMn0.fow6O5fp2z3vieA9gom5RRwQ7xxwBx9_7X2Fe8T2YI0",<br />
1793
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileName": "8a07bee1eeff17a14eee.jpg",<br />
1794
+ * &nbsp;&nbsp;&nbsp;&nbsp;"FileSize": 248837,<br />
1795
+ * &nbsp;&nbsp;&nbsp;&nbsp;"KeyID": "W39OAD3YGLCWAQKV1D6PGEKNW4RLGVTZTUWLYEVFQ2QG8AOCXW",<br />
1796
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateUserID": "LEMONADMIN",<br />
1797
+ * &nbsp;&nbsp;&nbsp;&nbsp;"CreateDate": "2020-08-24T11:54:04.307Z",<br />
1798
+ * &nbsp;&nbsp;&nbsp;&nbsp;"UserName": "Quản trị hệ thống"<br />
1799
+ * }, ...]
1798
1800
  */
1799
1801
  data: PropTypes.array,
1800
1802
 
@@ -1837,16 +1839,16 @@ Attachment.propTypes = {
1837
1839
  /** Download attached event, if not it will use default. */
1838
1840
  onDownload: PropTypes.func,
1839
1841
 
1840
- /**
1841
- * event when removed file(s)
1842
- *
1843
- * return data: {<br/>
1844
- * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1845
- * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1846
- * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1847
- * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1848
- * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1849
- * }
1842
+ /**
1843
+ * event when removed file(s)
1844
+ *
1845
+ * return data: {<br/>
1846
+ * &nbsp;&nbsp;&nbsp;&nbsp;attached: [Files] (insist old and all new files )<br/>
1847
+ * &nbsp;&nbsp;&nbsp;&nbsp;allNewAttached: [Files]<br/>
1848
+ * &nbsp;&nbsp;&nbsp;&nbsp;oldAttached: [Files]<br/>
1849
+ * &nbsp;&nbsp;&nbsp;&nbsp;removedAttached: [Files]<br/>
1850
+ * &nbsp;&nbsp;&nbsp;&nbsp;element: [NodeList (just removed)]<br/>
1851
+ * }
1850
1852
  */
1851
1853
  onRemove: PropTypes.func,
1852
1854