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.
- package/assets/storybook/avatar01.svg +9 -0
- package/assets/storybook/cover01.svg +9 -0
- package/components/accordion/css.js +6 -6
- package/components/accordion/details.js +13 -18
- package/components/accordion/group.js +16 -17
- package/components/accordion/index.js +17 -22
- package/components/accordion/summary.js +55 -32
- package/components/avatar/index.js +23 -28
- package/components/badge/index.js +9 -14
- package/components/button/icon.js +25 -30
- package/components/button/index.js +275 -280
- package/components/card/body.js +47 -0
- package/components/card/extra.js +47 -0
- package/components/card/footer.js +47 -0
- package/components/card/header.js +50 -0
- package/components/card/index.js +175 -37
- package/components/chart/Pie-v2/Sector.js +2 -2
- package/components/chip/attach.js +5 -5
- package/components/form-control/attachment/index.js +26 -24
- package/components/form-control/calendar/function.js +133 -123
- package/components/form-control/calendar/index.js +16 -16
- package/components/form-control/dropdown/index.js +71 -10
- package/components/form-control/helper-text/index.js +8 -3
- package/components/form-control/number-input/index.js +11 -11
- package/components/form-control/phone-input/index.js +7 -7
- package/components/grid/Container.js +110 -0
- package/components/grid/Row.js +1 -1
- package/components/grid/index.js +35 -5
- package/components/index.js +7 -2
- package/components/others/option-wrapper/index.js +21 -27
- package/components/paging/page-info.js +31 -40
- package/components/popover/index.js +29 -27
- package/components/progress/circular.js +12 -12
- package/components/transfer/index.js +3 -3
- package/components/tree-view/index.js +10 -6
- package/icons/basic.js +120 -0
- package/icons/effect.js +4 -9
- package/package.json +1 -1
- package/readme.md +14 -0
- package/styles/color-helper.js +103 -103
- package/styles/utils.js +17 -5
- package/utils/error/error.js +2 -2
- package/utils/renderIcon.js +5 -5
- package/components/card/body-card.js +0 -65
- package/components/card/card.js +0 -125
- package/components/card/context.js +0 -6
|
@@ -28,7 +28,8 @@ const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
28
|
className,
|
|
29
29
|
style,
|
|
30
30
|
children,
|
|
31
|
-
id
|
|
31
|
+
id,
|
|
32
|
+
...props
|
|
32
33
|
}, ref) => {
|
|
33
34
|
const color = colorMap.get(status);
|
|
34
35
|
return jsx(Typography, {
|
|
@@ -40,7 +41,8 @@ const HelperText = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
40
41
|
css: HelperTextRootCSS,
|
|
41
42
|
className: ['DGN-UI-HelperText', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
42
43
|
style: style,
|
|
43
|
-
lineClamp: 1
|
|
44
|
+
lineClamp: 1,
|
|
45
|
+
...props
|
|
44
46
|
}, typeof children === 'boolean' ? getGlobal('thisFieldIsRequired') : children);
|
|
45
47
|
}));
|
|
46
48
|
const HelperTextRootCSS = css`
|
|
@@ -67,6 +69,9 @@ HelperText.propTypes = {
|
|
|
67
69
|
style: PropTypes.object,
|
|
68
70
|
|
|
69
71
|
/** Content to display in component. */
|
|
70
|
-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
72
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
73
|
+
|
|
74
|
+
/** [Props](https://core.diginet.com.vn/ui/?path=/docs/typography) of Typography */
|
|
75
|
+
props: PropTypes.any
|
|
71
76
|
};
|
|
72
77
|
export default HelperText;
|
|
@@ -578,23 +578,23 @@ NumberInput.propTypes = {
|
|
|
578
578
|
/** style inline of input in NumberInput component */
|
|
579
579
|
inputStyle: PropTypes.object,
|
|
580
580
|
|
|
581
|
-
/**
|
|
582
|
-
* the format to display value<br/>
|
|
583
|
-
* * function: value => function(value)<br/>
|
|
584
|
-
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
585
|
-
* #: integer part digit<br/>
|
|
586
|
-
* . / '_': separator symbol<br/>
|
|
587
|
-
* %: decimal digit, '2%' === '%%'
|
|
581
|
+
/**
|
|
582
|
+
* the format to display value<br/>
|
|
583
|
+
* * function: value => function(value)<br/>
|
|
584
|
+
* * string: Example: '#.###', '# ###', '#.### 2%', '#.### %%'<br/>
|
|
585
|
+
* #: integer part digit<br/>
|
|
586
|
+
* . / '_': separator symbol<br/>
|
|
587
|
+
* %: decimal digit, '2%' === '%%'
|
|
588
588
|
*/
|
|
589
589
|
format: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
590
590
|
|
|
591
591
|
/** The function to get ref of NumberInput component */
|
|
592
592
|
refs: PropTypes.func,
|
|
593
593
|
|
|
594
|
-
/** validation value, argument can:<br/>
|
|
595
|
-
* * string: the validation rule. Example required.<br/>
|
|
596
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
597
|
-
* * array: the validation rule list, insist object/string
|
|
594
|
+
/** validation value, argument can:<br/>
|
|
595
|
+
* * string: the validation rule. Example required.<br/>
|
|
596
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
597
|
+
* * array: the validation rule list, insist object/string
|
|
598
598
|
*/
|
|
599
599
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
600
600
|
|
|
@@ -396,13 +396,13 @@ PhoneInput.propTypes = {
|
|
|
396
396
|
/** on input function */
|
|
397
397
|
onInput: PropTypes.func,
|
|
398
398
|
|
|
399
|
-
/**
|
|
400
|
-
* on change function. Return a object, example:<br/>
|
|
401
|
-
* {<br/>
|
|
402
|
-
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
403
|
-
* value: 0123456789<br/>
|
|
404
|
-
* countryCode: 84<br/>
|
|
405
|
-
* }
|
|
399
|
+
/**
|
|
400
|
+
* on change function. Return a object, example:<br/>
|
|
401
|
+
* {<br/>
|
|
402
|
+
* target: {value: "(+84) 123 456 789", ...}<br/>
|
|
403
|
+
* value: 0123456789<br/>
|
|
404
|
+
* countryCode: 84<br/>
|
|
405
|
+
* }
|
|
406
406
|
*/
|
|
407
407
|
onChange: PropTypes.func,
|
|
408
408
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** @jsxRuntime classic */
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { jsx } from '@emotion/core';
|
|
6
|
+
import Grid from '.';
|
|
7
|
+
|
|
8
|
+
const checkChildren = children => {
|
|
9
|
+
if (!children) return false;
|
|
10
|
+
|
|
11
|
+
if (Array.isArray(children)) {
|
|
12
|
+
return !children.every(v => v === false);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const Container = props => {
|
|
19
|
+
const {
|
|
20
|
+
className,
|
|
21
|
+
children
|
|
22
|
+
} = props;
|
|
23
|
+
return checkChildren(children) ? jsx(Grid, { ...props,
|
|
24
|
+
className: ['DGN-UI-Container', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
25
|
+
container: true
|
|
26
|
+
}) : null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
Container.defaultProps = {
|
|
30
|
+
style: {},
|
|
31
|
+
className: '',
|
|
32
|
+
columns: 12,
|
|
33
|
+
lg: false,
|
|
34
|
+
md: false,
|
|
35
|
+
sm: false,
|
|
36
|
+
xl: false,
|
|
37
|
+
xs: false,
|
|
38
|
+
zeroMinWidth: false,
|
|
39
|
+
spacing: 0,
|
|
40
|
+
direction: 'row',
|
|
41
|
+
wrap: 'wrap',
|
|
42
|
+
columnSpacing: {
|
|
43
|
+
xs: 4,
|
|
44
|
+
sm: 4,
|
|
45
|
+
md: 4,
|
|
46
|
+
lg: 4,
|
|
47
|
+
xl: 6
|
|
48
|
+
},
|
|
49
|
+
rowSpacing: {
|
|
50
|
+
xs: 4,
|
|
51
|
+
sm: 4,
|
|
52
|
+
md: 4,
|
|
53
|
+
lg: 4,
|
|
54
|
+
xl: 4
|
|
55
|
+
},
|
|
56
|
+
topSpacing: {
|
|
57
|
+
xs: 2,
|
|
58
|
+
sm: 2,
|
|
59
|
+
md: 2,
|
|
60
|
+
lg: 2,
|
|
61
|
+
xl: 2
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
Container.propTypes = {
|
|
65
|
+
/** The content of the component. */
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
|
|
68
|
+
/** Style inline of component. */
|
|
69
|
+
style: PropTypes.object,
|
|
70
|
+
|
|
71
|
+
/** Class for component. */
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
|
|
74
|
+
/** The number of columns. */
|
|
75
|
+
columns: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.number, PropTypes.object]),
|
|
76
|
+
|
|
77
|
+
/** Defines the horizontal space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
78
|
+
columnSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
79
|
+
|
|
80
|
+
/** Defines the `flex-direction` style property. It is applied for all screen sizes. */
|
|
81
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
|
|
82
|
+
|
|
83
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
84
|
+
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
85
|
+
|
|
86
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `md` breakpoint and wider screens if not overridden. */
|
|
87
|
+
md: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
88
|
+
|
|
89
|
+
/** Defines the vertical space between the type `Col` components. It overrides the value of the `spacing` prop. */
|
|
90
|
+
rowSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
91
|
+
|
|
92
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `sm` breakpoint and wider screens if not overridden. */
|
|
93
|
+
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
94
|
+
|
|
95
|
+
/** Defines the space between the type `Col` components */
|
|
96
|
+
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
97
|
+
|
|
98
|
+
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
99
|
+
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
100
|
+
|
|
101
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `xl` breakpoint and wider screens if not overridden. */
|
|
102
|
+
xl: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
103
|
+
|
|
104
|
+
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. */
|
|
105
|
+
xs: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
106
|
+
|
|
107
|
+
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
108
|
+
zeroMinWidth: PropTypes.bool
|
|
109
|
+
};
|
|
110
|
+
export default Container;
|
package/components/grid/Row.js
CHANGED
package/components/grid/index.js
CHANGED
|
@@ -22,11 +22,13 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
22
22
|
container,
|
|
23
23
|
direction,
|
|
24
24
|
item,
|
|
25
|
+
leftSpacing: leftSpacingProp,
|
|
25
26
|
lg,
|
|
26
27
|
md,
|
|
27
28
|
rowSpacing: rowSpacingProp,
|
|
28
29
|
sm,
|
|
29
30
|
spacing,
|
|
31
|
+
topSpacing: topSpacingProp,
|
|
30
32
|
wrap,
|
|
31
33
|
xl,
|
|
32
34
|
xs,
|
|
@@ -36,11 +38,13 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
36
38
|
const rowSpacing = rowSpacingProp || spacing;
|
|
37
39
|
const columnSpacing = columnSpacingProp || spacing;
|
|
38
40
|
const columns = container ? columnsProp : columnsContext;
|
|
41
|
+
const topSpacing = topSpacingProp || rowSpacing;
|
|
42
|
+
const leftSpacing = leftSpacingProp || columnSpacing;
|
|
39
43
|
const ref = useRef(null);
|
|
40
44
|
|
|
41
45
|
const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
|
|
42
46
|
|
|
43
|
-
const _GridSpacingCSS = GridSpacingCSS(rowSpacing, columnSpacing);
|
|
47
|
+
const _GridSpacingCSS = GridSpacingCSS(rowSpacing, columnSpacing, topSpacing, leftSpacing);
|
|
44
48
|
|
|
45
49
|
const _HandleGridCSS = HandleGridCSS([xs, sm, md, lg, xl], columns);
|
|
46
50
|
|
|
@@ -63,7 +67,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
63
67
|
}, jsx(GridContext.Provider, {
|
|
64
68
|
value: columns
|
|
65
69
|
}, children));
|
|
66
|
-
}, [id, container, item, direction, wrap, rowSpacing, columnSpacing, xs, sm, md, lg, xl, spacing, zeroMinWidth, className, columns, children]);
|
|
70
|
+
}, [id, container, item, direction, leftSpacing, wrap, rowSpacing, columnSpacing, xs, sm, md, lg, xl, spacing, topSpacing, zeroMinWidth, className, columns, children]);
|
|
67
71
|
}));
|
|
68
72
|
|
|
69
73
|
const getOffset = val => {
|
|
@@ -151,19 +155,40 @@ const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
|
|
|
151
155
|
})};
|
|
152
156
|
`;
|
|
153
157
|
|
|
154
|
-
const GridSpacingCSS = (rowSpacing, columnSpacing) => css`
|
|
155
|
-
${
|
|
158
|
+
const GridSpacingCSS = (rowSpacing, columnSpacing, topSpacing, leftSpacing) => css`
|
|
159
|
+
${topSpacing && handleBreakpoints(topSpacing, propValue => {
|
|
156
160
|
const spacing = typeof propValue === 'number' ? themeSpacing(propValue) : propValue;
|
|
157
161
|
|
|
158
162
|
if (spacing !== '0px') {
|
|
159
163
|
return `
|
|
160
164
|
margin-top: -${getOffset(spacing)};
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return '';
|
|
169
|
+
})};
|
|
170
|
+
${rowSpacing && handleBreakpoints(rowSpacing, propValue => {
|
|
171
|
+
const spacing = typeof propValue === 'number' ? themeSpacing(propValue) : propValue;
|
|
172
|
+
|
|
173
|
+
if (spacing !== '0px') {
|
|
174
|
+
return `
|
|
161
175
|
& > .DGN-UI-Grid-item {
|
|
162
176
|
padding-top: ${getOffset(spacing)};
|
|
163
177
|
}
|
|
164
178
|
`;
|
|
165
179
|
}
|
|
166
180
|
|
|
181
|
+
return '';
|
|
182
|
+
})};
|
|
183
|
+
${leftSpacing && handleBreakpoints(leftSpacing, propValue => {
|
|
184
|
+
const spacing = typeof propValue === 'number' ? themeSpacing(propValue) : propValue;
|
|
185
|
+
|
|
186
|
+
if (spacing !== '0px') {
|
|
187
|
+
return `
|
|
188
|
+
margin-left: -${getOffset(spacing)};
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
|
|
167
192
|
return '';
|
|
168
193
|
})};
|
|
169
194
|
${columnSpacing && handleBreakpoints(columnSpacing, propValue => {
|
|
@@ -172,7 +197,6 @@ const GridSpacingCSS = (rowSpacing, columnSpacing) => css`
|
|
|
172
197
|
if (spacing !== '0px') {
|
|
173
198
|
return `
|
|
174
199
|
width: calc(100% + ${getOffset(spacing)});
|
|
175
|
-
margin-left: -${getOffset(spacing)};
|
|
176
200
|
& > .DGN-UI-Grid-item {
|
|
177
201
|
padding-left: ${getOffset(spacing)};
|
|
178
202
|
}
|
|
@@ -230,6 +254,9 @@ Grid.propTypes = {
|
|
|
230
254
|
/** If `true`, the component will have the flex *item* behavior. You should be wrapping *items* with a *container*. */
|
|
231
255
|
item: PropTypes.bool,
|
|
232
256
|
|
|
257
|
+
/** Defines the horizontal space of `container` components. */
|
|
258
|
+
leftSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
259
|
+
|
|
233
260
|
/** If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the `lg` breakpoint and wider screens if not overridden. */
|
|
234
261
|
lg: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
235
262
|
|
|
@@ -245,6 +272,9 @@ Grid.propTypes = {
|
|
|
245
272
|
/** Defines the space between the type `item` components. It can only be used on a type `container` component. */
|
|
246
273
|
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
247
274
|
|
|
275
|
+
/** Defines the vertical space of `container` components. */
|
|
276
|
+
topSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
277
|
+
|
|
248
278
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
249
279
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
250
280
|
|
package/components/index.js
CHANGED
|
@@ -22,7 +22,11 @@ export { default as Badge } from './badge'; // BUTTON
|
|
|
22
22
|
export { default as Button } from './button';
|
|
23
23
|
export { default as ButtonIcon } from './button/icon'; // CARD
|
|
24
24
|
|
|
25
|
-
export { default as
|
|
25
|
+
export { default as Card } from './card';
|
|
26
|
+
export { default as CardHeader } from './card/header';
|
|
27
|
+
export { default as CardBody } from './card/body';
|
|
28
|
+
export { default as CardFooter } from './card/footer';
|
|
29
|
+
export { default as CardExtra } from './card/extra'; // CHART
|
|
26
30
|
|
|
27
31
|
export { default as PieChart } from './chart/Pie';
|
|
28
32
|
export { default as ColumnChart } from './chart/bar';
|
|
@@ -57,7 +61,8 @@ export { default as Toggle } from './form-control/toggle'; // Grid
|
|
|
57
61
|
|
|
58
62
|
export { default as Grid } from './grid';
|
|
59
63
|
export { default as Row } from './grid/Row';
|
|
60
|
-
export { default as Col } from './grid/Col';
|
|
64
|
+
export { default as Col } from './grid/Col';
|
|
65
|
+
export { default as Container } from './grid/Container'; //Icon
|
|
61
66
|
|
|
62
67
|
export { default as Icon } from '../icons/index'; // List
|
|
63
68
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { useRef,
|
|
4
|
+
import { useRef, useState, forwardRef, useImperativeHandle, useEffect } from 'react';
|
|
5
5
|
import { jsx } from '@emotion/core';
|
|
6
6
|
|
|
7
7
|
const OptionWrapper = WrappedComponent => {
|
|
@@ -10,17 +10,15 @@ const OptionWrapper = WrappedComponent => {
|
|
|
10
10
|
ref = useRef(null);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const [options, setOptions] = useState(
|
|
13
|
+
const [options, setOptions] = useState({});
|
|
14
14
|
const componentRef = useRef(null);
|
|
15
15
|
|
|
16
16
|
const option = (option, optionValue) => {
|
|
17
17
|
if (typeof option === 'undefined') {
|
|
18
|
-
return
|
|
18
|
+
return props;
|
|
19
19
|
} else if (typeof option === 'string') {
|
|
20
|
-
if (typeof optionValue === 'undefined') return
|
|
21
|
-
|
|
22
|
-
[option]: optionValue
|
|
23
|
-
}
|
|
20
|
+
if (typeof optionValue === 'undefined') return props[option];else setOptions({
|
|
21
|
+
[option]: optionValue
|
|
24
22
|
});
|
|
25
23
|
} else if (typeof option === 'object') {
|
|
26
24
|
setOptions({ ...options,
|
|
@@ -29,26 +27,22 @@ const OptionWrapper = WrappedComponent => {
|
|
|
29
27
|
}
|
|
30
28
|
};
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}; // methods
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
useEffect(() => setOptions({ ...options,
|
|
49
|
-
...props
|
|
50
|
-
}), [props]);
|
|
51
|
-
return jsx(WrappedComponent, { ...options,
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
setOptions({});
|
|
32
|
+
}, [props]);
|
|
33
|
+
useImperativeHandle(ref, () => ({ ...componentRef.current,
|
|
34
|
+
instance: { ...componentRef.current.instance,
|
|
35
|
+
option
|
|
36
|
+
} // const currentRef = componentRef.current || {};
|
|
37
|
+
// const _instance = { ...componentRef.current.instance, option }; // methods
|
|
38
|
+
// _instance.__proto__ = { ...componentRef.current.instance?.__proto__ }; // hidden methods
|
|
39
|
+
// currentRef.instance = _instance;
|
|
40
|
+
// console.log('currentRef', currentRef.instance);
|
|
41
|
+
// return currentRef;
|
|
42
|
+
|
|
43
|
+
}));
|
|
44
|
+
return jsx(WrappedComponent, { ...props,
|
|
45
|
+
...options,
|
|
52
46
|
ref: componentRef
|
|
53
47
|
});
|
|
54
48
|
});
|
|
@@ -187,26 +187,17 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
187
187
|
useEffect(() => {
|
|
188
188
|
setListPerPageState(listPerPage);
|
|
189
189
|
}, [listPerPage]);
|
|
190
|
-
useImperativeHandle(reference, () => {
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
useImperativeHandle(reference, () => ({
|
|
191
|
+
element: ref.current,
|
|
192
|
+
instance: {
|
|
193
193
|
onChangePage: page => _onChangePage(page),
|
|
194
194
|
onChangePerPage: per => _onChangePerPage(per),
|
|
195
195
|
setTotalItems: items => setTotalItemsState(items)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
currentRef.onChangePage = page => _onChangePage(page);
|
|
203
|
-
|
|
204
|
-
currentRef.onChangePerPage = per => _onChangePerPage(per);
|
|
205
|
-
|
|
206
|
-
currentRef.setTotalItems = items => setTotalItemsState(items);
|
|
207
|
-
|
|
208
|
-
return currentRef;
|
|
209
|
-
});
|
|
196
|
+
},
|
|
197
|
+
onChangePage: page => _onChangePage(page),
|
|
198
|
+
onChangePerPage: per => _onChangePerPage(per),
|
|
199
|
+
setTotalItems: items => setTotalItemsState(items)
|
|
200
|
+
}));
|
|
210
201
|
return useMemo(() => {
|
|
211
202
|
const lastPage = getLastPage(totalItemsState, itemsPerPageState);
|
|
212
203
|
let listPerPageData = !listPerPageState.includes(itemsPerPageState) ? [{
|
|
@@ -414,23 +405,23 @@ PagingInfo.propTypes = {
|
|
|
414
405
|
/** Callback fired when quantity on per page changed. */
|
|
415
406
|
onChangePerPage: PropTypes.func,
|
|
416
407
|
|
|
417
|
-
/**
|
|
418
|
-
* Callback fired when page number is changing.
|
|
419
|
-
*
|
|
420
|
-
* * prevPage: Page before changed
|
|
421
|
-
* * newPage: Page after changed
|
|
422
|
-
* * cancel(value): Function cancel change page
|
|
423
|
-
* * @param {value} - bool
|
|
408
|
+
/**
|
|
409
|
+
* Callback fired when page number is changing.
|
|
410
|
+
*
|
|
411
|
+
* * prevPage: Page before changed
|
|
412
|
+
* * newPage: Page after changed
|
|
413
|
+
* * cancel(value): Function cancel change page
|
|
414
|
+
* * @param {value} - bool
|
|
424
415
|
*/
|
|
425
416
|
onChangingPage: PropTypes.func,
|
|
426
417
|
|
|
427
|
-
/**
|
|
428
|
-
* Callback fired when quantity on item per page is changing.
|
|
429
|
-
*
|
|
430
|
-
* * prevPerPage: Items per page before changed
|
|
431
|
-
* * newPerPage: Items per page after changed
|
|
432
|
-
* * cancel(value): Function cancel change items per page
|
|
433
|
-
* * @param {value} - bool
|
|
418
|
+
/**
|
|
419
|
+
* Callback fired when quantity on item per page is changing.
|
|
420
|
+
*
|
|
421
|
+
* * prevPerPage: Items per page before changed
|
|
422
|
+
* * newPerPage: Items per page after changed
|
|
423
|
+
* * cancel(value): Function cancel change items per page
|
|
424
|
+
* * @param {value} - bool
|
|
434
425
|
*/
|
|
435
426
|
onChangingPerPage: PropTypes.func,
|
|
436
427
|
|
|
@@ -443,15 +434,15 @@ PagingInfo.propTypes = {
|
|
|
443
434
|
/** Compact type for mobile. */
|
|
444
435
|
typeShort: PropTypes.bool,
|
|
445
436
|
|
|
446
|
-
/**
|
|
447
|
-
* ref methods (ref.current.instance.*method*)
|
|
448
|
-
*
|
|
449
|
-
* * onChangePage(page): Change page number
|
|
450
|
-
* * @param {page} - number
|
|
451
|
-
* * onChangePerPage(per): Change quantity on per page
|
|
452
|
-
* * @param {per} - number
|
|
453
|
-
* * setTotalItems(items): Set total items
|
|
454
|
-
* * @param {items} - number
|
|
437
|
+
/**
|
|
438
|
+
* ref methods (ref.current.instance.*method*)
|
|
439
|
+
*
|
|
440
|
+
* * onChangePage(page): Change page number
|
|
441
|
+
* * @param {page} - number
|
|
442
|
+
* * onChangePerPage(per): Change quantity on per page
|
|
443
|
+
* * @param {per} - number
|
|
444
|
+
* * setTotalItems(items): Set total items
|
|
445
|
+
* * @param {items} - number
|
|
455
446
|
*/
|
|
456
447
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
457
448
|
current: PropTypes.instanceOf(Element)
|
|
@@ -209,8 +209,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
if (element || anchor) {
|
|
212
|
-
if (element) anchor = element;else if (anchor
|
|
213
|
-
|
|
212
|
+
if (element) anchor = element;else if (anchor && !(anchor instanceof Element)) {
|
|
213
|
+
var _anchor4, _anchor$current;
|
|
214
|
+
|
|
215
|
+
anchor = ((_anchor4 = anchor) === null || _anchor4 === void 0 ? void 0 : _anchor4.element) || ((_anchor$current = anchor.current) === null || _anchor$current === void 0 ? void 0 : _anchor$current.element) || anchor.current;
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
if (anchorOrigin === 'center') {
|
|
@@ -322,9 +324,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
322
324
|
};
|
|
323
325
|
}, []);
|
|
324
326
|
useEffect(() => {
|
|
325
|
-
var
|
|
327
|
+
var _anchor5, _anchor6;
|
|
326
328
|
|
|
327
|
-
const anchorEl = ((
|
|
329
|
+
const anchorEl = ((_anchor5 = anchor) === null || _anchor5 === void 0 ? void 0 : _anchor5.element) || ((_anchor6 = anchor) === null || _anchor6 === void 0 ? void 0 : _anchor6.current) || anchor;
|
|
328
330
|
const eventArr = eventMap.get(trigger) || [];
|
|
329
331
|
|
|
330
332
|
if (anchorEl && open === undefined && (eventArr === null || eventArr === void 0 ? void 0 : eventArr.length) > 0) {
|
|
@@ -378,9 +380,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
378
380
|
}));
|
|
379
381
|
|
|
380
382
|
const renderAnchor = () => {
|
|
381
|
-
var
|
|
383
|
+
var _anchor7;
|
|
382
384
|
|
|
383
|
-
if (!((
|
|
385
|
+
if (!((_anchor7 = anchor) !== null && _anchor7 !== void 0 && _anchor7.type)) return null;
|
|
384
386
|
const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
|
|
385
387
|
// onClick: () => {
|
|
386
388
|
// setOpenState(true);
|
|
@@ -486,9 +488,9 @@ Popover.propTypes = {
|
|
|
486
488
|
/** An HTML element, or a function that returns one. It's used to set the position of the popover. */
|
|
487
489
|
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node]),
|
|
488
490
|
|
|
489
|
-
/**
|
|
490
|
-
* This is the point on the anchor where the popover's anchor will attach to.
|
|
491
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
491
|
+
/**
|
|
492
|
+
* This is the point on the anchor where the popover's anchor will attach to.
|
|
493
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
492
494
|
*/
|
|
493
495
|
anchorOrigin: PropTypes.shape({
|
|
494
496
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
@@ -507,14 +509,14 @@ Popover.propTypes = {
|
|
|
507
509
|
/** If `true`, click outside will close component. */
|
|
508
510
|
clickOutsideToClose: PropTypes.bool,
|
|
509
511
|
|
|
510
|
-
/**
|
|
511
|
-
* Direction when Popover shown.
|
|
512
|
-
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
513
|
-
*
|
|
514
|
-
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
515
|
-
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
516
|
-
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
517
|
-
* * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
512
|
+
/**
|
|
513
|
+
* Direction when Popover shown.
|
|
514
|
+
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
515
|
+
*
|
|
516
|
+
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
517
|
+
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
518
|
+
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
519
|
+
* * right: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
518
520
|
*/
|
|
519
521
|
direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
|
|
520
522
|
|
|
@@ -530,9 +532,9 @@ Popover.propTypes = {
|
|
|
530
532
|
/** Style inline of component. */
|
|
531
533
|
style: PropTypes.object,
|
|
532
534
|
|
|
533
|
-
/**
|
|
534
|
-
* This is the point on the popover which will attach to the anchor's origin.
|
|
535
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
535
|
+
/**
|
|
536
|
+
* This is the point on the popover which will attach to the anchor's origin.
|
|
537
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
536
538
|
*/
|
|
537
539
|
transformOrigin: PropTypes.shape({
|
|
538
540
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
@@ -545,13 +547,13 @@ Popover.propTypes = {
|
|
|
545
547
|
/** Config z-index of the component. */
|
|
546
548
|
zIndex: PropTypes.number,
|
|
547
549
|
|
|
548
|
-
/**
|
|
549
|
-
* ref methods (ref.current.instance.*method*)
|
|
550
|
-
*
|
|
551
|
-
* * show: Show popover
|
|
552
|
-
* * close: Close popover
|
|
553
|
-
* * setPosition(element): Set position of popover
|
|
554
|
-
* * @param {element} - element
|
|
550
|
+
/**
|
|
551
|
+
* ref methods (ref.current.instance.*method*)
|
|
552
|
+
*
|
|
553
|
+
* * show: Show popover
|
|
554
|
+
* * close: Close popover
|
|
555
|
+
* * setPosition(element): Set position of popover
|
|
556
|
+
* * @param {element} - element
|
|
555
557
|
*/
|
|
556
558
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
557
559
|
current: PropTypes.instanceOf(Element)
|