diginet-core-ui 1.3.82 → 1.3.83-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/badge/index.js +86 -75
- package/components/form-control/attachment/index.js +5 -1
- package/components/form-control/input-base/index.js +20 -20
- package/components/form-control/label/index.js +9 -8
- package/components/grid/Col.js +5 -2
- package/components/grid/Container.js +2 -2
- package/components/grid/Row.js +2 -2
- package/components/grid/index.js +14 -9
- package/components/paging/page-info.js +42 -49
- package/components/popover/index.js +1 -1
- package/components/tab/tab.js +1 -1
- package/components/typography/index.js +1 -1
- package/icons/effect.js +57 -59
- package/icons/menu/v2/index.js +40 -16
- package/package.json +62 -31
- package/readme.md +6 -0
- package/utils/index.js +9 -8
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Icon } from "./..";
|
|
6
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { alignCenter, borderBox, borderRadius4px, flexRow, flexWrap, inlineFlex, justifyCenter, pointerEventsNone, positionAbsolute, positionRelative } from "../../styles/general";
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
paragraph1,
|
|
13
|
-
paragraph2,
|
|
14
|
-
paragraph3
|
|
15
|
-
} = typography;
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
+
import { alignCenter, borderBox, borderRadius4px, flexRow, flexWrap, inlineFlex, justifyCenter, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative } from "../../styles/general";
|
|
9
|
+
import { useColor as colors, useTheme } from "../../theme";
|
|
10
|
+
import { classNames, refType as ref } from "../../utils";
|
|
16
11
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
12
|
+
colors: {
|
|
13
|
+
system: {
|
|
14
|
+
rest: systemRest,
|
|
15
|
+
white: systemWhite
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
typography: {
|
|
19
|
+
paragraph1,
|
|
20
|
+
paragraph2,
|
|
21
|
+
paragraph3
|
|
22
|
+
},
|
|
23
|
+
spacing
|
|
24
|
+
} = useTheme();
|
|
25
|
+
const colorMap = new Map([['default', systemRest]]);
|
|
23
26
|
const iconSizeMap = new Map([['medium', 24], ['large', 32], ['giant', 40]]);
|
|
24
27
|
const dotSizeMap = new Map([['medium', 8], ['large', 10], ['giant', 12]]);
|
|
25
28
|
const dotIndentMap = new Map([['medium', 4], ['large', 2]]);
|
|
@@ -70,28 +73,30 @@ const calDotPos = (anchorOrigin, contentDirection, dotSize, hasContent, size) =>
|
|
|
70
73
|
const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
71
74
|
action = {},
|
|
72
75
|
anchorOrigin,
|
|
73
|
-
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
color,
|
|
74
79
|
content,
|
|
80
|
+
contentDirection,
|
|
81
|
+
iconProps,
|
|
82
|
+
id,
|
|
83
|
+
invisible,
|
|
75
84
|
max,
|
|
76
85
|
name,
|
|
77
|
-
|
|
86
|
+
showZero,
|
|
78
87
|
size,
|
|
79
|
-
className,
|
|
80
88
|
style,
|
|
81
|
-
showZero,
|
|
82
|
-
invisible,
|
|
83
|
-
children,
|
|
84
|
-
iconProps,
|
|
85
89
|
...props
|
|
86
90
|
}, reference) => {
|
|
91
|
+
if (!reference) reference = useRef(null);
|
|
87
92
|
const ref = useRef(null);
|
|
88
93
|
const typographySize = typographySizeMap.get(size);
|
|
89
94
|
const iconSize = iconSizeMap.get(size);
|
|
90
95
|
const dotSize = content || content === 0 && showZero ? dotSizeMap.get(size) + 8 : dotSizeMap.get(size);
|
|
91
96
|
const dotColor = colors[color] || colorMap.get(color) || color;
|
|
92
97
|
const dotPos = calDotPos(anchorOrigin, !children && name ? 'right' : contentDirection, dotSize, content || content === 0, size);
|
|
93
|
-
const _BadgeNumberCSS = BadgeNumberCSS(typographySize, children, name, dotSize, dotColor
|
|
94
|
-
const _BadgeRootCSS = BadgeRootCSS(children, name, dotPos, _BadgeNumberCSS);
|
|
98
|
+
const _BadgeNumberCSS = BadgeNumberCSS(typographySize, children, name, dotSize, dotColor);
|
|
99
|
+
const _BadgeRootCSS = BadgeRootCSS(children, name, dotPos, _BadgeNumberCSS.name);
|
|
95
100
|
useImperativeHandle(reference, () => {
|
|
96
101
|
const currentRef = ref.current || {};
|
|
97
102
|
currentRef.element = ref.current;
|
|
@@ -106,28 +111,30 @@ const Badge = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
106
111
|
let node = children;
|
|
107
112
|
if (!node && name) {
|
|
108
113
|
node = jsx(Icon, {
|
|
114
|
+
viewBox: true,
|
|
109
115
|
name: name,
|
|
110
116
|
width: iconSize,
|
|
111
117
|
height: iconSize,
|
|
112
|
-
|
|
118
|
+
color: 'currentColor',
|
|
113
119
|
...iconProps
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
122
|
return jsx("div", {
|
|
117
123
|
css: _BadgeRootCSS,
|
|
118
124
|
ref: ref,
|
|
119
|
-
|
|
125
|
+
id: id,
|
|
126
|
+
className: classNames('DGN-UI-Badge', className),
|
|
120
127
|
style: style,
|
|
121
128
|
...props
|
|
122
129
|
}, jsx("span", {
|
|
123
130
|
className: 'DGN-UI-Badge-Children'
|
|
124
|
-
}, node), content !== undefined && jsx("span", {
|
|
131
|
+
}, node), content !== undefined && !invisible ? jsx("span", {
|
|
125
132
|
css: _BadgeNumberCSS,
|
|
126
133
|
className: 'DGN-UI-Badge-Dot'
|
|
127
|
-
}, max && content > max ? max + '+' : content === 0 && !showZero ? null : content));
|
|
128
|
-
}, [anchorOrigin,
|
|
134
|
+
}, max && content > max ? max + '+' : content === 0 && !showZero ? null : content) : null);
|
|
135
|
+
}, [anchorOrigin, children, className, color, content, contentDirection, iconProps, id, invisible, max, name, showZero, size, style, props]);
|
|
129
136
|
}));
|
|
130
|
-
const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor
|
|
137
|
+
const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor) => css`
|
|
131
138
|
${typographySize};
|
|
132
139
|
${flexRow};
|
|
133
140
|
${alignCenter};
|
|
@@ -136,84 +143,88 @@ const BadgeNumberCSS = (typographySize, children, name, dotSize, dotColor, invis
|
|
|
136
143
|
${borderBox};
|
|
137
144
|
${pointerEventsNone};
|
|
138
145
|
${children || name ? positionAbsolute : positionRelative};
|
|
139
|
-
color: ${
|
|
140
|
-
|
|
141
|
-
min-width: ${dotSize}px;
|
|
146
|
+
color: ${systemWhite};
|
|
147
|
+
${parseMinWidthHeight(dotSize)};
|
|
142
148
|
background-color: ${dotColor};
|
|
143
149
|
border-radius: ${dotSize / 2}px;
|
|
144
|
-
padding: 0
|
|
145
|
-
transition: transform 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
146
|
-
${invisible && 'transform: scale(0) translate(50%, -50%);'};
|
|
150
|
+
padding: ${spacing([0, 1])};
|
|
147
151
|
`;
|
|
148
|
-
const BadgeRootCSS = (children, name, dotPos,
|
|
152
|
+
const BadgeRootCSS = (children, name, dotPos, BadgeNumberCSSName) => css`
|
|
149
153
|
${inlineFlex};
|
|
150
154
|
${alignCenter};
|
|
151
155
|
${justifyCenter};
|
|
152
156
|
${positionRelative};
|
|
153
157
|
${borderBox};
|
|
154
158
|
${borderRadius4px};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
min-width: max-content;
|
|
160
|
-
.css-${_BadgeNumberCSS.name} {
|
|
161
|
-
${(children || name) && dotPos}
|
|
159
|
+
${parseWidthHeight('max-content')};
|
|
160
|
+
${parseMinWidthHeight('max-content')};
|
|
161
|
+
.css-${BadgeNumberCSSName} {
|
|
162
|
+
${(children || name) && dotPos};
|
|
162
163
|
}
|
|
163
164
|
`;
|
|
164
165
|
Badge.defaultProps = {
|
|
165
|
-
color: 'default',
|
|
166
|
-
size: 'medium',
|
|
167
166
|
anchorOrigin: {
|
|
168
167
|
vertical: 'top',
|
|
169
168
|
horizontal: 'right'
|
|
170
169
|
},
|
|
170
|
+
className: '',
|
|
171
|
+
color: 'default',
|
|
171
172
|
content: null,
|
|
172
|
-
max: 99,
|
|
173
173
|
contentDirection: 'left',
|
|
174
|
-
showZero: false,
|
|
175
174
|
invisible: false,
|
|
176
|
-
|
|
175
|
+
max: 99,
|
|
176
|
+
showZero: false,
|
|
177
|
+
size: 'medium',
|
|
177
178
|
style: {}
|
|
178
179
|
};
|
|
179
180
|
Badge.propTypes = {
|
|
181
|
+
/** The anchor of the badge. */
|
|
180
182
|
anchorOrigin: PropTypes.shape({
|
|
181
183
|
horizontal: PropTypes.oneOf(['left', 'right']),
|
|
182
184
|
vertical: PropTypes.oneOf(['top', 'bottom'])
|
|
183
185
|
}),
|
|
184
|
-
/**
|
|
186
|
+
/** The badge will be added relative to this node. */
|
|
187
|
+
children: PropTypes.node,
|
|
188
|
+
/** Class for component. */
|
|
189
|
+
className: PropTypes.string,
|
|
190
|
+
/** The color of the component. */
|
|
191
|
+
color: PropTypes.oneOfType([PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']), PropTypes.string]),
|
|
192
|
+
/** The content rendered within the badge. */
|
|
185
193
|
content: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
186
|
-
/**
|
|
187
|
-
max: PropTypes.number,
|
|
188
|
-
/** used to fill background for button */
|
|
194
|
+
/** Direction of content within the badge */
|
|
189
195
|
contentDirection: PropTypes.oneOf(['left', 'right']),
|
|
190
|
-
/**
|
|
191
|
-
|
|
192
|
-
/**
|
|
196
|
+
/** If `true`, the badge is invisible */
|
|
197
|
+
invisible: PropTypes.bool,
|
|
198
|
+
/** Max count to show. */
|
|
199
|
+
max: PropTypes.number,
|
|
200
|
+
/** Prop name of [ButtonIcon](https://core.diginet.com.vn/ui/?path=/docs/buttonicon) components. */
|
|
193
201
|
name: PropTypes.string,
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
/**
|
|
202
|
+
/** Controls whether the badge is hidden when `content` is zero. */
|
|
203
|
+
showZero: PropTypes.bool,
|
|
204
|
+
/** Size of the components.
|
|
197
205
|
*
|
|
198
206
|
* * medium (dot 8px, typography p3)
|
|
199
207
|
* * large (button 10px, typography p2)
|
|
200
208
|
* * giant (button 12px, typography p1)
|
|
201
209
|
* */
|
|
202
210
|
size: PropTypes.oneOf(['medium', 'large', 'giant']),
|
|
203
|
-
/**
|
|
204
|
-
showZero: PropTypes.bool,
|
|
205
|
-
/** If true, the badge is invisible */
|
|
206
|
-
invisible: PropTypes.bool,
|
|
207
|
-
/** className of component */
|
|
208
|
-
className: PropTypes.string,
|
|
209
|
-
/** style inline of component */
|
|
211
|
+
/** Style inline of component. */
|
|
210
212
|
style: PropTypes.object,
|
|
211
|
-
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
/**
|
|
214
|
+
* ref methods (ref.current.instance.*method*)
|
|
215
|
+
*
|
|
216
|
+
* * option(): Gets all UI component properties
|
|
217
|
+
* * Returns value - object
|
|
218
|
+
* * option(optionName): Gets the value of a single property
|
|
219
|
+
* * @param {optionName} - string
|
|
220
|
+
* * Returns value - any
|
|
221
|
+
* * option(optionName, optionValue): Updates the value of a single property
|
|
222
|
+
* * @param {optionName} - string
|
|
223
|
+
* * @param {optionValue} - any
|
|
224
|
+
* * option(options): Updates the values of several properties
|
|
225
|
+
* * @param {options} - object
|
|
226
|
+
*/
|
|
227
|
+
reference: ref
|
|
217
228
|
};
|
|
218
229
|
export { Badge };
|
|
219
230
|
export default OptionWrapper(Badge);
|
|
@@ -1078,6 +1078,8 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1078
1078
|
title: "",
|
|
1079
1079
|
onDrop: onDropInput,
|
|
1080
1080
|
onDragLeave: onDropInput,
|
|
1081
|
+
onClick: e => e.target.value = null // Fix not fire onChange when select same file
|
|
1082
|
+
,
|
|
1081
1083
|
...inputProps
|
|
1082
1084
|
})), [inputProps]);
|
|
1083
1085
|
const AttachedView = useMemo(() => jsx(ScrollBar, {
|
|
@@ -1438,12 +1440,14 @@ Attachment.defaultProps = {
|
|
|
1438
1440
|
maxFile: Infinity,
|
|
1439
1441
|
multiple: true,
|
|
1440
1442
|
readOnly: false,
|
|
1443
|
+
style: {},
|
|
1441
1444
|
uploadErrorInfo: {
|
|
1442
1445
|
maxFile: getGlobal(['errorDefault', 'maxFile']),
|
|
1443
1446
|
maxSize: getGlobal(['errorDefault', 'maxSize']),
|
|
1444
1447
|
fileType: getGlobal(['errorDefault', 'fileType']),
|
|
1445
1448
|
existingFile: getGlobal(['errorDefault', 'existingFile'])
|
|
1446
|
-
}
|
|
1449
|
+
},
|
|
1450
|
+
viewType: 'detail'
|
|
1447
1451
|
};
|
|
1448
1452
|
Attachment.propTypes = {
|
|
1449
1453
|
/** File types that can be accepted. */
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Icon, Typography } from "../..";
|
|
7
5
|
import { getGlobal } from "../../../global";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
+
import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, displayBlock, flexRow, outlineNone, parseHeight, parseMinHeight, parseMinWidthHeight, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative } from "../../../styles/general";
|
|
9
|
+
import { useColor as colors, useTheme } from "../../../theme";
|
|
10
|
+
import { classNames, refType as ref, useInput } from "../../../utils";
|
|
13
11
|
const {
|
|
14
12
|
colors: {
|
|
15
13
|
system: {
|
|
@@ -77,6 +75,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
77
75
|
viewType,
|
|
78
76
|
...props
|
|
79
77
|
}, reference) => {
|
|
78
|
+
if (!reference) reference = useRef(null);
|
|
80
79
|
if (!autoWidth && inputProps !== null && inputProps !== void 0 && inputProps.autoWidth) autoWidth = inputProps.autoWidth;
|
|
81
80
|
const _onChange = e => {
|
|
82
81
|
onChange && onChange(e);
|
|
@@ -94,7 +93,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
93
|
const widthInit = useRef(null);
|
|
95
94
|
const isEnabled = !readOnly && !disabled;
|
|
96
95
|
const _InputBaseCSS = InputBaseCSS(readOnly, status);
|
|
97
|
-
const _SingleLineCSS = SingleLineCSS(autoWidth);
|
|
96
|
+
const _SingleLineCSS = SingleLineCSS(autoWidth, readOnly);
|
|
98
97
|
const _InputCSS = InputCSS(autoWidth, isEnabled, hoverTooltip);
|
|
99
98
|
const _TypoCSS = TypoCSS(disabled);
|
|
100
99
|
const _TextAreaCSS = TextAreaCSS(resize, readOnly);
|
|
@@ -406,20 +405,22 @@ const InputBaseCSS = (readOnly, status) => css`
|
|
|
406
405
|
}`}
|
|
407
406
|
& + .DGN-UI-HelperText {
|
|
408
407
|
${positionAbsolute};
|
|
409
|
-
|
|
408
|
+
${parseMinHeight(16)};
|
|
410
409
|
top: 100%;
|
|
411
410
|
}
|
|
412
411
|
`;
|
|
413
|
-
const SingleLineCSS = autoWidth => css`
|
|
412
|
+
const SingleLineCSS = (autoWidth, readOnly) => css`
|
|
414
413
|
${parseWidthHeight(autoWidth ? 'max-content' : 'auto', 'max-content')}
|
|
415
414
|
${alignCenter};
|
|
416
415
|
flex: 1 1 auto;
|
|
417
416
|
&:focus-within {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
417
|
+
${!readOnly && `
|
|
418
|
+
border-bottom-color: ${semanticInfo};
|
|
419
|
+
&::after {
|
|
420
|
+
border-bottom-color: inherit;
|
|
421
|
+
transform: scaleX(1);
|
|
422
|
+
}
|
|
423
|
+
`}
|
|
423
424
|
}
|
|
424
425
|
&.outlined {
|
|
425
426
|
${parseHeight(40)};
|
|
@@ -432,7 +433,7 @@ const InputCSS = (autoWidth, isEnabled, hoverTooltip) => css`
|
|
|
432
433
|
${outlineNone};
|
|
433
434
|
transition: all 0.1s;
|
|
434
435
|
color: ${textMain};
|
|
435
|
-
|
|
436
|
+
${backgroundTransparent};
|
|
436
437
|
padding-top: 0;
|
|
437
438
|
padding-bottom: 0;
|
|
438
439
|
${paragraph1};
|
|
@@ -493,9 +494,8 @@ const TextAreaCSS = (resize, readOnly) => css`
|
|
|
493
494
|
${positionRelative};
|
|
494
495
|
${borderBox};
|
|
495
496
|
${parseWidth('100%')};
|
|
497
|
+
${parseMinWidthHeight('max-content')};
|
|
496
498
|
color: ${textMain};
|
|
497
|
-
min-height: max-content;
|
|
498
|
-
min-width: max-content;
|
|
499
499
|
background-color: transparent;
|
|
500
500
|
padding: ${spacing(0.5, 0)};
|
|
501
501
|
overflow-y: auto;
|
|
@@ -5,7 +5,7 @@ import { Typography } from "../..";
|
|
|
5
5
|
import OptionWrapper from "../../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
-
import { flexRow, typographyTypes } from "../../../styles/general";
|
|
8
|
+
import { flexRow, parseMinHeight, typographyTypes } from "../../../styles/general";
|
|
9
9
|
import { useTheme } from "../../../theme";
|
|
10
10
|
import { classNames } from "../../../utils";
|
|
11
11
|
const {
|
|
@@ -33,6 +33,7 @@ const Label = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
33
33
|
type,
|
|
34
34
|
...props
|
|
35
35
|
}, reference) => {
|
|
36
|
+
if (!reference) reference = useRef(null);
|
|
36
37
|
const ref = useRef(null);
|
|
37
38
|
useImperativeHandle(reference, () => {
|
|
38
39
|
const currentRef = ref.current || {};
|
|
@@ -71,19 +72,19 @@ const LabelContainerCSS = css`
|
|
|
71
72
|
}
|
|
72
73
|
`;
|
|
73
74
|
const LabelRootCSS = css`
|
|
74
|
-
|
|
75
|
+
${parseMinHeight(16)};
|
|
75
76
|
margin: 0;
|
|
76
77
|
word-break: break-all;
|
|
77
78
|
`;
|
|
78
79
|
Label.defaultProps = {
|
|
79
|
-
|
|
80
|
+
children: '',
|
|
81
|
+
className: '',
|
|
80
82
|
color: normal_label,
|
|
81
|
-
lineClamp: 1,
|
|
82
|
-
required: false,
|
|
83
83
|
disabled: false,
|
|
84
|
+
lineClamp: 1,
|
|
84
85
|
readOnly: false,
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
required: false,
|
|
87
|
+
type: 'h6'
|
|
87
88
|
};
|
|
88
89
|
Label.propTypes = {
|
|
89
90
|
/** The content of the component. */
|
|
@@ -99,7 +100,7 @@ Label.propTypes = {
|
|
|
99
100
|
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
100
101
|
color: PropTypes.string,
|
|
101
102
|
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
102
|
-
lineClamp: PropTypes.number,
|
|
103
|
+
lineClamp: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
|
|
103
104
|
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
|
104
105
|
hoverTooltip: PropTypes.bool,
|
|
105
106
|
/** Consult [Typography's](https://core.diginet.com.vn/ui/?path=/docs/typography) documents. */
|
package/components/grid/Col.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { jsx } from '@emotion/core';
|
|
5
|
-
import
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
6
5
|
import { makeStyles } from "../../theme";
|
|
7
6
|
import { classNames } from "../../utils";
|
|
7
|
+
import Grid from '.';
|
|
8
8
|
const useStyles = makeStyles({
|
|
9
9
|
customCol: {
|
|
10
10
|
'& .DGN-UI-Control': {
|
|
@@ -45,6 +45,7 @@ Col.defaultProps = {
|
|
|
45
45
|
md: false,
|
|
46
46
|
sm: false,
|
|
47
47
|
style: {},
|
|
48
|
+
verticalAlign: 'auto',
|
|
48
49
|
wrap: 'wrap',
|
|
49
50
|
xl: false,
|
|
50
51
|
xs: true,
|
|
@@ -67,6 +68,8 @@ Col.propTypes = {
|
|
|
67
68
|
sm: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number, PropTypes.bool]),
|
|
68
69
|
/** Style inline of component. */
|
|
69
70
|
style: PropTypes.object,
|
|
71
|
+
/** Self-align of the grid item. */
|
|
72
|
+
verticalAlign: PropTypes.oneOf(['auto', 'start', 'center', 'end']),
|
|
70
73
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
71
74
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
72
75
|
/** 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. */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { jsx } from '@emotion/core';
|
|
5
|
-
import
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
6
5
|
import { classNames } from "../../utils";
|
|
6
|
+
import Grid from '.';
|
|
7
7
|
const checkChildren = children => {
|
|
8
8
|
if (!children) return false;
|
|
9
9
|
if (Array.isArray(children)) {
|
package/components/grid/Row.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
3
|
import { jsx } from '@emotion/core';
|
|
5
|
-
import
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
6
5
|
import { classNames } from "../../utils";
|
|
6
|
+
import Grid from '.';
|
|
7
7
|
const checkChildren = children => {
|
|
8
8
|
if (!children) return false;
|
|
9
9
|
if (Array.isArray(children)) {
|
package/components/grid/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
6
|
-
import GridContext from "./context";
|
|
7
|
-
import theme from "../../theme/settings";
|
|
8
|
-
import { breakpointKeys } from "../../theme/createBreakpoints";
|
|
5
|
+
import { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef } from 'react';
|
|
9
6
|
import { borderBox } from "../../styles/general";
|
|
7
|
+
import { useTheme } from "../../theme";
|
|
8
|
+
import { breakpointKeys } from "../../theme/createBreakpoints";
|
|
10
9
|
import { classNames, handleBreakpoints } from "../../utils";
|
|
10
|
+
import GridContext from "./context";
|
|
11
11
|
const {
|
|
12
12
|
breakpoints: themeBreakpoints,
|
|
13
13
|
spacing: themeSpacing
|
|
14
|
-
} =
|
|
14
|
+
} = useTheme();
|
|
15
15
|
const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
16
|
action = {},
|
|
17
17
|
children,
|
|
@@ -30,6 +30,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
30
30
|
spacing,
|
|
31
31
|
style,
|
|
32
32
|
topSpacing: topSpacingProp,
|
|
33
|
+
verticalAlign,
|
|
33
34
|
wrap,
|
|
34
35
|
xl,
|
|
35
36
|
xs,
|
|
@@ -42,7 +43,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
42
43
|
const topSpacing = topSpacingProp !== null && topSpacingProp !== void 0 ? topSpacingProp : rowSpacing;
|
|
43
44
|
const leftSpacing = leftSpacingProp !== null && leftSpacingProp !== void 0 ? leftSpacingProp : columnSpacing;
|
|
44
45
|
const ref = useRef(null);
|
|
45
|
-
const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap);
|
|
46
|
+
const _GridCSS = GridCSS(direction, zeroMinWidth, container, item, wrap, verticalAlign);
|
|
46
47
|
const _GridSpacingCSS = GridSpacingCSS(rowSpacing, columnSpacing, topSpacing, leftSpacing);
|
|
47
48
|
const _HandleGridCSS = HandleGridCSS([xs, sm, md, lg, xl], columns);
|
|
48
49
|
useImperativeHandle(reference, () => {
|
|
@@ -65,7 +66,7 @@ const Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
65
66
|
}, jsx(GridContext.Provider, {
|
|
66
67
|
value: columns
|
|
67
68
|
}, children));
|
|
68
|
-
}, [columns, columnSpacing, leftSpacing, rowSpacing, topSpacing, children, className, container, direction, id, item, lg, md, sm, spacing, style, wrap, xl, xs, zeroMinWidth]);
|
|
69
|
+
}, [columns, columnSpacing, leftSpacing, rowSpacing, topSpacing, children, className, container, direction, id, item, lg, md, sm, spacing, style, verticalAlign, wrap, xl, xs, zeroMinWidth]);
|
|
69
70
|
}));
|
|
70
71
|
const getOffset = val => {
|
|
71
72
|
const parse = parseFloat(val);
|
|
@@ -108,7 +109,7 @@ const handleGrid = (size, value, columns) => {
|
|
|
108
109
|
${css}
|
|
109
110
|
}`;
|
|
110
111
|
};
|
|
111
|
-
const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
|
|
112
|
+
const GridCSS = (direction, zeroMinWidth, container, item, wrap, verticalAlign) => css`
|
|
112
113
|
${borderBox};
|
|
113
114
|
${container && `
|
|
114
115
|
display: flex;
|
|
@@ -117,6 +118,7 @@ const GridCSS = (direction, zeroMinWidth, container, item, wrap) => css`
|
|
|
117
118
|
`};
|
|
118
119
|
${item && `
|
|
119
120
|
margin: 0;
|
|
121
|
+
align-self: ${verticalAlign}
|
|
120
122
|
`};
|
|
121
123
|
${zeroMinWidth && `min-width: 0;`}
|
|
122
124
|
${handleBreakpoints(direction, propValue => {
|
|
@@ -182,6 +184,7 @@ Grid.defaultProps = {
|
|
|
182
184
|
sm: false,
|
|
183
185
|
spacing: 0,
|
|
184
186
|
style: {},
|
|
187
|
+
verticalAlign: 'auto',
|
|
185
188
|
wrap: 'wrap',
|
|
186
189
|
xl: false,
|
|
187
190
|
xs: false,
|
|
@@ -218,6 +221,8 @@ Grid.propTypes = {
|
|
|
218
221
|
spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
219
222
|
/** Defines the vertical space of `container` components. */
|
|
220
223
|
topSpacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
|
|
224
|
+
/** Self-align of the grid item. */
|
|
225
|
+
verticalAlign: PropTypes.oneOf(['auto', 'start', 'center', 'end']),
|
|
221
226
|
/** Defines the flex-wrap style property. It's applied for all screen sizes. */
|
|
222
227
|
wrap: PropTypes.oneOf(['nowrap', 'wrap-reverse', 'wrap']),
|
|
223
228
|
/** 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. */
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { ButtonIcon, Divider, Dropdown, NumberInput, Typography } from "./..";
|
|
6
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
7
|
-
import { ButtonIcon, NumberInput, Dropdown, Typography, Divider } from "../";
|
|
8
6
|
import { getGlobal } from "../../global";
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { alignCenter, borderBox, cursorPointer, flexRow, justifyCenter, noPadding, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, textCenter, whiteSpaceNoWrap } from "../../styles/general";
|
|
10
|
+
import { useTheme } from "../../theme";
|
|
11
|
+
import { classNames, refType as ref } from "../../utils";
|
|
11
12
|
const {
|
|
12
13
|
colors: {
|
|
13
14
|
system: {
|
|
14
|
-
active,
|
|
15
|
-
white
|
|
15
|
+
active: systemActive,
|
|
16
|
+
white: systemWhite
|
|
16
17
|
},
|
|
17
18
|
line: {
|
|
18
|
-
system,
|
|
19
|
-
category
|
|
19
|
+
system: lineSystem,
|
|
20
|
+
category: lineCategory
|
|
20
21
|
},
|
|
21
22
|
text: {
|
|
22
|
-
main
|
|
23
|
+
main: textMain
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
26
|
typography: {
|
|
26
27
|
paragraph2
|
|
27
28
|
},
|
|
28
29
|
spacing
|
|
29
|
-
} =
|
|
30
|
+
} = useTheme();
|
|
30
31
|
const getLastPage = (totalItems, itemsPerPage) => {
|
|
31
32
|
let _lastPage = 0;
|
|
32
33
|
if (totalItems && totalItems >= 0 && itemsPerPage && itemsPerPage > 0) {
|
|
@@ -53,7 +54,8 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
53
54
|
totalItems,
|
|
54
55
|
typeShort
|
|
55
56
|
}, reference) => {
|
|
56
|
-
|
|
57
|
+
if (!reference) reference = useRef(null);
|
|
58
|
+
const ref = useRef(null);
|
|
57
59
|
const timer = useRef(null);
|
|
58
60
|
const currentPageRef = useRef(null);
|
|
59
61
|
const numberRef = useRef(null);
|
|
@@ -66,8 +68,6 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
68
|
const [disableNextState, setDisableNextState] = useState(!(totalItems > itemsPerPage));
|
|
67
69
|
const [inputPageValue, setInputPageValue] = useState(currentPage);
|
|
68
70
|
const _pagingInfoCSS = pagingInfoCSS(bgColor, typeShort);
|
|
69
|
-
// const _dynamicWidthCSS = dynamicWidthCSS(currentPageState.toString()?.length || 3);
|
|
70
|
-
|
|
71
71
|
const _onChangePage = async ({
|
|
72
72
|
page,
|
|
73
73
|
e,
|
|
@@ -139,9 +139,6 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
setItemsPerPageState(per);
|
|
142
|
-
// currentPageRef.current = 0;
|
|
143
|
-
// setCurrentPageState(0);
|
|
144
|
-
// setInputPageValue(0);
|
|
145
142
|
_onChangePage({
|
|
146
143
|
page: 0
|
|
147
144
|
});
|
|
@@ -253,13 +250,13 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
253
250
|
// getBoundingClientRect includes margin => phải trừ đi margin
|
|
254
251
|
const style = window.getComputedStyle(child) || child.currentStyle;
|
|
255
252
|
const margin = parseInt((style === null || style === void 0 ? void 0 : style.marginLeft) || 0) + parseInt((style === null || style === void 0 ? void 0 : style.marginRight) || 0);
|
|
256
|
-
if (infoChild.right - margin >= infoParent.
|
|
253
|
+
if (infoChild.right - margin >= infoParent.right) {
|
|
257
254
|
child.style.opacity = 0;
|
|
258
255
|
child.style.setProperty('display', 'none', 'important');
|
|
259
256
|
} else {
|
|
260
257
|
child.style.opacity = 1;
|
|
261
258
|
}
|
|
262
|
-
return infoChild.right >= infoParent.
|
|
259
|
+
return infoChild.right >= infoParent.right;
|
|
263
260
|
});
|
|
264
261
|
};
|
|
265
262
|
const setWithNumber = useCallback((totalRefs = totalRef, numberRefs = numberRef) => {
|
|
@@ -297,12 +294,12 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
297
294
|
listPerPageData = [...new Map(listPerPageData.map(v => [JSON.stringify(v), v])).values()];
|
|
298
295
|
listPerPageData.sort((a, b) => a.id - b.id);
|
|
299
296
|
const showPaging = checkShowPaging();
|
|
300
|
-
return showPaging
|
|
297
|
+
return showPaging ? jsx("div", {
|
|
301
298
|
ref: ref,
|
|
302
299
|
css: _pagingInfoCSS,
|
|
303
300
|
id: id,
|
|
304
301
|
style: style,
|
|
305
|
-
className:
|
|
302
|
+
className: classNames('DGN-UI-PagingInfo', className)
|
|
306
303
|
}, jsx(ButtonIcon, {
|
|
307
304
|
circular: true,
|
|
308
305
|
viewType: 'ghost',
|
|
@@ -360,15 +357,15 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
360
357
|
placeholder: '',
|
|
361
358
|
max: lastPage,
|
|
362
359
|
onKeyDown: checkKeyPress,
|
|
363
|
-
onChange:
|
|
360
|
+
onChange: onTypePaging
|
|
364
361
|
}), "/", jsx(Typography, {
|
|
365
362
|
ref: refs => {
|
|
366
363
|
totalRef.current = refs;
|
|
367
364
|
setWithNumber(refs, null);
|
|
368
365
|
},
|
|
369
366
|
css: css`
|
|
370
|
-
|
|
371
|
-
|
|
367
|
+
${whiteSpaceNoWrap}
|
|
368
|
+
`,
|
|
372
369
|
type: 'p2'
|
|
373
370
|
}, lastPage)), jsx(ButtonIcon, {
|
|
374
371
|
circular: true,
|
|
@@ -415,7 +412,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
415
412
|
}, typeShort ? jsx(Divider, {
|
|
416
413
|
direction: 'vertical',
|
|
417
414
|
height: 24,
|
|
418
|
-
color:
|
|
415
|
+
color: lineCategory
|
|
419
416
|
}) : getGlobal('lineNumber'), jsx(Dropdown, {
|
|
420
417
|
allowSearch: false,
|
|
421
418
|
viewType: 'underlined',
|
|
@@ -429,7 +426,7 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
429
426
|
readOnly: true
|
|
430
427
|
},
|
|
431
428
|
dropdownItemStyle: {
|
|
432
|
-
color:
|
|
429
|
+
color: systemActive
|
|
433
430
|
}
|
|
434
431
|
})), jsx(Typography, {
|
|
435
432
|
type: 'p2',
|
|
@@ -438,9 +435,9 @@ const PagingInfo = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
438
435
|
}, typeShort ? jsx(Divider, {
|
|
439
436
|
direction: 'vertical',
|
|
440
437
|
height: 24,
|
|
441
|
-
color:
|
|
442
|
-
}) : getGlobal('total') + ':', totalItemsState));
|
|
443
|
-
}, [
|
|
438
|
+
color: lineCategory
|
|
439
|
+
}) : getGlobal('total') + ':', totalItemsState)) : null;
|
|
440
|
+
}, [bgColor, className, hideWithPage, style, typeShort, currentPageState, disableNextState, disablePrevState, inputPageValue, itemsPerPageState, listPerPageState, totalItemsState]);
|
|
444
441
|
}));
|
|
445
442
|
const ViewNumberInput = css`
|
|
446
443
|
${flexRow};
|
|
@@ -454,11 +451,11 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
454
451
|
${alignCenter};
|
|
455
452
|
${paragraph2};
|
|
456
453
|
${borderBox};
|
|
457
|
-
${parseHeight(40)}
|
|
458
|
-
border-top: solid 1px ${
|
|
454
|
+
${parseHeight(40)};
|
|
455
|
+
border-top: solid 1px ${lineSystem};
|
|
459
456
|
padding: ${spacing([1, 0])};
|
|
460
457
|
background-color: ${bgColor};
|
|
461
|
-
color: ${
|
|
458
|
+
color: ${textMain};
|
|
462
459
|
.inputPage {
|
|
463
460
|
${textCenter};
|
|
464
461
|
margin: ${spacing([0, 0.5])};
|
|
@@ -467,7 +464,7 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
467
464
|
input {
|
|
468
465
|
${paragraph2};
|
|
469
466
|
${textCenter};
|
|
470
|
-
color: ${
|
|
467
|
+
color: ${systemActive};
|
|
471
468
|
text-align: left;
|
|
472
469
|
}
|
|
473
470
|
}
|
|
@@ -485,9 +482,9 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
485
482
|
.DGN-UI-Dropdown {
|
|
486
483
|
margin-left: ${`${spacing(typeShort ? [0] : [2])}`};
|
|
487
484
|
margin-bottom: 0;
|
|
488
|
-
|
|
485
|
+
${parseMinWidth(52)};
|
|
489
486
|
.DGN-UI-Dropdown-Form {
|
|
490
|
-
|
|
487
|
+
${parseMinHeight(24)};
|
|
491
488
|
padding: 0;
|
|
492
489
|
input,
|
|
493
490
|
span {
|
|
@@ -496,14 +493,12 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
496
493
|
${cursorPointer};
|
|
497
494
|
}
|
|
498
495
|
.DGN-UI-Dropdown-Icon {
|
|
499
|
-
margin-left:
|
|
496
|
+
margin-left: ${spacing([1.5])};
|
|
500
497
|
div,
|
|
501
498
|
span,
|
|
502
499
|
svg {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
height: 20px;
|
|
506
|
-
min-height: 20px;
|
|
500
|
+
${parseWidthHeight(20)};
|
|
501
|
+
${parseMinWidthHeight(20)};
|
|
507
502
|
}
|
|
508
503
|
}
|
|
509
504
|
}
|
|
@@ -518,14 +513,14 @@ const pagingInfoCSS = (bgColor, typeShort) => css`
|
|
|
518
513
|
}
|
|
519
514
|
`;
|
|
520
515
|
PagingInfo.defaultProps = {
|
|
521
|
-
|
|
522
|
-
bgColor: white,
|
|
523
|
-
style: {},
|
|
516
|
+
bgColor: systemWhite,
|
|
524
517
|
className: '',
|
|
525
|
-
totalItems: 0,
|
|
526
518
|
currentPage: 0,
|
|
519
|
+
hideWithPage: 'none',
|
|
527
520
|
listPerPage: [10, 15, 20, 30, 50],
|
|
528
|
-
|
|
521
|
+
style: {},
|
|
522
|
+
totalItems: 0,
|
|
523
|
+
typeShort: false
|
|
529
524
|
};
|
|
530
525
|
PagingInfo.propTypes = {
|
|
531
526
|
/** Background color for component. */
|
|
@@ -578,9 +573,7 @@ PagingInfo.propTypes = {
|
|
|
578
573
|
* * setTotalItems(items): Set total items
|
|
579
574
|
* * @param {items} - number
|
|
580
575
|
*/
|
|
581
|
-
reference:
|
|
582
|
-
current: PropTypes.instanceOf(Element)
|
|
583
|
-
})])
|
|
576
|
+
reference: ref
|
|
584
577
|
};
|
|
585
578
|
export { PagingInfo };
|
|
586
579
|
export default OptionWrapper(PagingInfo);
|
|
@@ -182,7 +182,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
182
182
|
};
|
|
183
183
|
const updatePositionPopover = (el = null, cb) => {
|
|
184
184
|
var _window, _window2, _anchor6, _anchorRect, _anchorRect2, _anchor7, _anchorRect3, _anchorRect4, _anchorRect5, _anchorRect6, _anchorRect7, _anchorRect8, _anchorRect9, _anchorRect10, _anchorRect11, _anchorRect12, _newDirectionObject, _newDirectionObject$t, _transformOrigin, _newDirectionObject2, _newDirectionObject2$, _transformOrigin2;
|
|
185
|
-
|
|
185
|
+
if (el instanceof Element) setElement(el);
|
|
186
186
|
if (!ref.current) {
|
|
187
187
|
window.removeEventListener('resize', updatePositionPopover);
|
|
188
188
|
return;
|
package/components/tab/tab.js
CHANGED
|
@@ -102,7 +102,7 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
102
102
|
css: _IndicatorCSS,
|
|
103
103
|
className: 'Indicator'
|
|
104
104
|
}));
|
|
105
|
-
}, [children, className, color, disabled, endIcon, index, label, level, onClick, props, startIcon, style, isVertical, tabIndexState]);
|
|
105
|
+
}, [children, className, color, disabled, endIcon, index, label, labelProps, level, onClick, props, startIcon, style, isVertical, tabIndexState]);
|
|
106
106
|
}));
|
|
107
107
|
const TabButtonCSS = (color, isVertical) => css`
|
|
108
108
|
${flexRow};
|
|
@@ -176,7 +176,7 @@ Typography.propTypes = {
|
|
|
176
176
|
/** If `true`, hover will show tooltip when text clamped. */
|
|
177
177
|
hoverTooltip: PropTypes.bool,
|
|
178
178
|
/** The line-clamp property truncates text at a specific number of lines. */
|
|
179
|
-
lineClamp: PropTypes.number,
|
|
179
|
+
lineClamp: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])]),
|
|
180
180
|
/** The component used for the root node. Either a string to use a HTML element or a component. */
|
|
181
181
|
mapping: PropTypes.string,
|
|
182
182
|
/** Callback fired when the component is clicked. */
|
package/icons/effect.js
CHANGED
|
@@ -1,50 +1,37 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
6
4
|
import OptionWrapper from "../components/others/option-wrapper";
|
|
7
|
-
import
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
|
+
import { alignCenter, borderBox, flexRow, justifyCenter, outlineNone, parseMinWidthHeight, parseWidthHeight, userSelectNone } from "../styles/general";
|
|
8
|
+
import { useColor as colors, useTheme } from "../theme";
|
|
9
|
+
import { capitalize, classNames, refType as ref } from "../utils";
|
|
8
10
|
import * as Icons from "./basic";
|
|
9
|
-
import { capitalize } from "../utils";
|
|
10
|
-
import { alignCenter, borderBox, flexRow, justifyCenter, outlineNone, userSelectNone } from "../styles/general";
|
|
11
11
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
colors: {
|
|
13
|
+
system: {
|
|
14
|
+
rest: systemRest
|
|
15
|
+
}
|
|
14
16
|
}
|
|
15
|
-
} =
|
|
17
|
+
} = useTheme();
|
|
16
18
|
const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
17
19
|
action = {},
|
|
18
|
-
name,
|
|
19
20
|
className,
|
|
20
|
-
style,
|
|
21
21
|
color,
|
|
22
|
-
width,
|
|
23
22
|
height,
|
|
24
|
-
|
|
23
|
+
id,
|
|
24
|
+
name,
|
|
25
25
|
onClick,
|
|
26
|
+
style,
|
|
27
|
+
viewBox,
|
|
28
|
+
width,
|
|
26
29
|
...props
|
|
27
30
|
}, reference) => {
|
|
31
|
+
if (!reference) reference = useRef(null);
|
|
28
32
|
const ref = useRef(null);
|
|
29
|
-
const
|
|
30
|
-
|
|
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
|
-
`;
|
|
41
|
-
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
|
-
`;
|
|
33
|
+
const _IconCSS = IconCSS(width, height);
|
|
34
|
+
const _NotFoundIconCSS = NotFoundIconCSS(width);
|
|
48
35
|
useImperativeHandle(reference, () => {
|
|
49
36
|
const currentRef = ref.current || {};
|
|
50
37
|
currentRef.element = ref.current;
|
|
@@ -68,48 +55,61 @@ const Icon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
68
55
|
});
|
|
69
56
|
} else {
|
|
70
57
|
node = jsx("span", {
|
|
71
|
-
css:
|
|
58
|
+
css: _NotFoundIconCSS
|
|
72
59
|
});
|
|
73
60
|
}
|
|
74
61
|
return jsx("span", {
|
|
75
|
-
|
|
76
|
-
style: style,
|
|
77
|
-
css: IconCss,
|
|
62
|
+
css: _IconCSS,
|
|
78
63
|
ref: ref,
|
|
64
|
+
id: id,
|
|
65
|
+
className: classNames('DGN-UI-Icon', className),
|
|
66
|
+
style: style,
|
|
79
67
|
onClick: onClick,
|
|
80
68
|
...props
|
|
81
69
|
}, node);
|
|
82
|
-
}, [
|
|
70
|
+
}, [className, color, height, id, name, onClick, style, viewBox, width, props]);
|
|
83
71
|
}));
|
|
72
|
+
const IconCSS = (width = 24, height = 24) => css`
|
|
73
|
+
${flexRow};
|
|
74
|
+
${justifyCenter};
|
|
75
|
+
${alignCenter};
|
|
76
|
+
${borderBox};
|
|
77
|
+
${outlineNone};
|
|
78
|
+
${userSelectNone};
|
|
79
|
+
${parseWidthHeight('max-content')};
|
|
80
|
+
${parseMinWidthHeight(width, height)};
|
|
81
|
+
`;
|
|
82
|
+
const NotFoundIconCSS = (width = 24) => css`
|
|
83
|
+
${flexRow};
|
|
84
|
+
${borderBox};
|
|
85
|
+
${parseWidthHeight(width)};
|
|
86
|
+
border: 1px dashed ${systemRest};
|
|
87
|
+
`;
|
|
84
88
|
Icon.defaultProps = {
|
|
85
89
|
className: '',
|
|
86
|
-
style: {},
|
|
87
90
|
color: 'dark6',
|
|
91
|
+
height: 24,
|
|
92
|
+
style: {},
|
|
88
93
|
viewBox: true,
|
|
89
|
-
width: 24
|
|
90
|
-
height: 24
|
|
94
|
+
width: 24
|
|
91
95
|
};
|
|
92
96
|
Icon.propTypes = {
|
|
93
|
-
/**
|
|
94
|
-
name: PropTypes.string.isRequired,
|
|
95
|
-
/** color of icon<br />
|
|
96
|
-
* default: #7F828E
|
|
97
|
-
*/
|
|
98
|
-
color: PropTypes.string,
|
|
99
|
-
/** className of icon in icons store */
|
|
97
|
+
/** Class for component. */
|
|
100
98
|
className: PropTypes.string,
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
105
|
-
/** the height of icon */
|
|
99
|
+
/** The color of the component. */
|
|
100
|
+
color: PropTypes.string,
|
|
101
|
+
/** Height of the component. */
|
|
106
102
|
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
107
|
-
/**
|
|
103
|
+
/** Name of icon in [Basic Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic) */
|
|
104
|
+
name: PropTypes.string.isRequired,
|
|
105
|
+
/** Style inline of component. */
|
|
106
|
+
style: PropTypes.object,
|
|
107
|
+
/** If `true`, component have view box. */
|
|
108
108
|
viewBox: PropTypes.bool,
|
|
109
|
-
/**
|
|
110
|
-
|
|
109
|
+
/** Width of the component. */
|
|
110
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
111
111
|
/**
|
|
112
|
-
* ref methods
|
|
112
|
+
* ref methods (ref.current.instance.*method*)
|
|
113
113
|
*
|
|
114
114
|
* * option(): Gets all UI component properties
|
|
115
115
|
* * Returns value - object
|
|
@@ -122,9 +122,7 @@ Icon.propTypes = {
|
|
|
122
122
|
* * option(options): Updates the values of several properties
|
|
123
123
|
* * @param {options} - object
|
|
124
124
|
*/
|
|
125
|
-
reference:
|
|
126
|
-
current: PropTypes.instanceOf(Element)
|
|
127
|
-
})])
|
|
125
|
+
reference: ref
|
|
128
126
|
};
|
|
129
127
|
export { Icon };
|
|
130
128
|
export default OptionWrapper(Icon);
|
package/icons/menu/v2/index.js
CHANGED
|
@@ -2,18 +2,32 @@
|
|
|
2
2
|
/* eslint-disable no-empty */
|
|
3
3
|
/** @jsxRuntime classic */
|
|
4
4
|
/** @jsx jsx */
|
|
5
|
-
import { memo, forwardRef, useRef, useMemo } from 'react';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
5
|
import { jsx } from '@emotion/core';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
+
import { classNames } from "../../../utils";
|
|
8
9
|
const IconMenu = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
9
|
-
|
|
10
|
+
action,
|
|
11
|
+
className,
|
|
12
|
+
height,
|
|
13
|
+
id,
|
|
10
14
|
name,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
style,
|
|
16
|
+
type,
|
|
17
|
+
width
|
|
18
|
+
}, reference) => {
|
|
19
|
+
if (!reference) reference = useRef(null);
|
|
20
|
+
const ref = useRef(null);
|
|
21
|
+
useImperativeHandle(reference, () => {
|
|
22
|
+
const currentRef = ref.current || {};
|
|
23
|
+
currentRef.element = ref.current;
|
|
24
|
+
const _instance = {
|
|
25
|
+
...action
|
|
26
|
+
}; // methods
|
|
27
|
+
_instance.__proto__ = {}; // hidden methods
|
|
28
|
+
currentRef.instance = _instance;
|
|
29
|
+
return currentRef;
|
|
30
|
+
});
|
|
17
31
|
const getResourceImage = fileName => {
|
|
18
32
|
let icon = require("../../../assets/images/menu/dhr/Default.svg");
|
|
19
33
|
try {
|
|
@@ -22,26 +36,36 @@ const IconMenu = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
22
36
|
return icon;
|
|
23
37
|
};
|
|
24
38
|
return useMemo(() => jsx("img", {
|
|
39
|
+
ref: ref,
|
|
40
|
+
id: id,
|
|
41
|
+
className: classNames('DGN-UI-IconMenu', className),
|
|
42
|
+
style: style,
|
|
25
43
|
src: getResourceImage(name + '.svg'),
|
|
26
44
|
width: width,
|
|
27
45
|
height: height,
|
|
28
|
-
alt:
|
|
29
|
-
}), [
|
|
46
|
+
alt: name
|
|
47
|
+
}), [className, height, id, name, style, type, width]);
|
|
30
48
|
}));
|
|
31
49
|
IconMenu.defaultProps = {
|
|
50
|
+
className: '',
|
|
51
|
+
height: '100%',
|
|
32
52
|
name: 'Default',
|
|
33
53
|
type: 'dhr',
|
|
34
54
|
width: '100%',
|
|
35
|
-
|
|
55
|
+
style: {}
|
|
36
56
|
};
|
|
37
57
|
IconMenu.propTypes = {
|
|
38
|
-
/**
|
|
39
|
-
|
|
58
|
+
/** Class for component. */
|
|
59
|
+
className: PropTypes.string,
|
|
60
|
+
/** Height of icon. */
|
|
61
|
+
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
40
62
|
/** Name of icon. */
|
|
41
63
|
name: PropTypes.string,
|
|
64
|
+
/** Menu type (DHR || ERP || BEM). */
|
|
65
|
+
type: PropTypes.oneOf(['dhr', 'erp', 'bem']),
|
|
42
66
|
/** Width of icon. */
|
|
43
67
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
44
|
-
/**
|
|
45
|
-
|
|
68
|
+
/** Style inline of component. */
|
|
69
|
+
style: PropTypes.object
|
|
46
70
|
};
|
|
47
71
|
export default IconMenu;
|
package/package.json
CHANGED
|
@@ -1,42 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginet-core-ui",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "
|
|
5
|
-
"homepage": "https://diginet.com.vn",
|
|
3
|
+
"version": "1.3.83-beta.1",
|
|
4
|
+
"description": "",
|
|
6
5
|
"main": "index.js",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start
|
|
9
|
-
"start": "
|
|
10
|
-
"build": "
|
|
11
|
-
"
|
|
12
|
-
"
|
|
8
|
+
"start": "npm-run-all --parallel start-sb eslint-test",
|
|
9
|
+
"start-sb": "start-storybook -p 9050",
|
|
10
|
+
"build-storybook": "build-storybook -c .storybook -s src",
|
|
11
|
+
"build": "run-script-os",
|
|
12
|
+
"build:windows": "rimraf dist && mkdirp dist/components && npm run compile && sass --style=compressed src/scss:dist/css && xcopy src\\\\assets dist\\\\assets\\ /e /y",
|
|
13
|
+
"build:darwin:linux:default": "rm -rf dist && npm run compile && sass --style=compressed src/scss:dist/css && cp -rf src/assets dist/assets",
|
|
14
|
+
"compile": "babel src --out-dir dist --ignore **/*.stories.js",
|
|
15
|
+
"pack": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm pack",
|
|
16
|
+
"production-keep-version": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish",
|
|
17
|
+
"beta": "npm run build && cp *.md dist/ && cp package.json dist/ && cd dist && npm publish --tag beta",
|
|
18
|
+
"production": "npm run build && cp *.md dist/ && npm run version:bump --silent && npm run version:add --silent && cd dist && npm publish",
|
|
19
|
+
"version:add": "run-script-os",
|
|
20
|
+
"version:add:windows": "cat package.json.tmp | sed \"s/0.0.0/%npm_package_version%/g\" > dist/package.json",
|
|
21
|
+
"version:add:darwin:linux:default": "VERSION=$(npm run version:extract --silent) && cat package.json.tmp | sed \"s/0.0.0/${VERSION}/g\" > dist/package.json",
|
|
22
|
+
"version:bump": "npm version patch --no-git-tag-version --silent",
|
|
23
|
+
"version:extract": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'",
|
|
24
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
25
|
+
"lint": "eslint --fix --config .eslintrc.js \"**/*.js\"",
|
|
26
|
+
"eslint-test": "onchange \"src/**/*.{js,jsx,json}\" -- eslint . --fix",
|
|
27
|
+
"test-storybook": "test-storybook --url http://localhost:9050"
|
|
13
28
|
},
|
|
14
29
|
"dependencies": {
|
|
15
30
|
"@emotion/core": "^10.0.35",
|
|
31
|
+
"babel-plugin-module-resolver": "^4.1.0",
|
|
16
32
|
"prop-types": "^15.7.2"
|
|
17
33
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
34
|
+
"lint-staged": {
|
|
35
|
+
"*/**/*.{js,jsx,json}": [
|
|
36
|
+
"prettier --write",
|
|
37
|
+
"git add"
|
|
38
|
+
]
|
|
21
39
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/cli": "^7.14.3",
|
|
42
|
+
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
43
|
+
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
|
|
44
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
45
|
+
"@babel/plugin-proposal-optional-chaining": "^7.14.2",
|
|
46
|
+
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
47
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
|
|
48
|
+
"@babel/preset-react": "^7.13.13",
|
|
49
|
+
"@storybook/addon-actions": "6.2.9",
|
|
50
|
+
"@storybook/addon-essentials": "6.2.9",
|
|
51
|
+
"@storybook/addon-links": "6.2.9",
|
|
52
|
+
"@storybook/addon-postcss": "^2.0.0",
|
|
53
|
+
"@storybook/react": "6.2.9",
|
|
54
|
+
"@storybook/test-runner": "^0.7.1",
|
|
55
|
+
"autoprefixer": "^10.3.1",
|
|
56
|
+
"babel-loader": "^8.2.2",
|
|
57
|
+
"eslint": "^8.4.1",
|
|
58
|
+
"eslint-plugin-react": "^7.27.1",
|
|
59
|
+
"eslint-plugin-regex": "^1.10.0",
|
|
60
|
+
"husky": "^7.0.4",
|
|
61
|
+
"jest": "^27.5.1",
|
|
62
|
+
"lint-staged": "^12.1.2",
|
|
63
|
+
"mkdirp": "^1.0.4",
|
|
64
|
+
"npm-run-all": "^4.1.5",
|
|
65
|
+
"onchange": "^7.1.0",
|
|
66
|
+
"postcss-flexbugs-fixes": "^5.0.2",
|
|
67
|
+
"react": "^17.0.1",
|
|
68
|
+
"react-dom": "^17.0.1",
|
|
69
|
+
"rimraf": "^3.0.2",
|
|
70
|
+
"run-script-os": "^1.1.6",
|
|
71
|
+
"sass": "^1.37.0"
|
|
72
|
+
}
|
|
42
73
|
}
|
package/readme.md
CHANGED
|
@@ -38,6 +38,12 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.83
|
|
42
|
+
- \[Changed\]: IconMenu – Add prop className, style
|
|
43
|
+
- \[Changed\]: Grid – Add prop verticalAlign
|
|
44
|
+
- \[Changed\]: Label– Add lineClamp auto
|
|
45
|
+
- \[Fixed\]: Popover – Fix bug not save last position of anchor
|
|
46
|
+
|
|
41
47
|
## 1.3.82
|
|
42
48
|
- \[Fixed\]: CircularProgress – Fix transform rotate wrong inside flex column
|
|
43
49
|
|
package/utils/index.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import * as utils from '.';
|
|
2
|
-
export
|
|
2
|
+
export { default as capitalize } from "./string/capitalize";
|
|
3
|
+
export { default as capitalizeSentenceCase } from "./string/capitalizeSentenceCase";
|
|
3
4
|
export { default as classNames } from "./classNames";
|
|
4
|
-
export * from "./date";
|
|
5
5
|
export { default as date } from "./date";
|
|
6
6
|
export { default as getFileType } from "./getFileType";
|
|
7
7
|
export { default as handleBreakpoints } from "./handleBreakpoints";
|
|
8
8
|
export { default as isMobile } from "./isMobile";
|
|
9
9
|
export { default as mapParent } from "./map-parent";
|
|
10
|
+
export { default as onValidate } from "./validate";
|
|
10
11
|
export { default as parseTextToHTML } from "./parseHTML";
|
|
11
12
|
export { default as promisify } from "./promisify";
|
|
12
13
|
export { default as randomString } from "./randomString";
|
|
13
14
|
export { default as refType } from "./refType";
|
|
14
15
|
export { default as removeUnicode } from "./remove-unicode";
|
|
15
|
-
export * from "./render-portal";
|
|
16
16
|
export { default as renderHTML } from "./renderHTML";
|
|
17
17
|
export { default as renderIcon } from "./renderIcon";
|
|
18
|
-
export * from "./sb-template";
|
|
19
18
|
export { default as SbTemplate } from "./sb-template";
|
|
20
|
-
export { default as capitalize } from "./string/capitalize";
|
|
21
|
-
export { default as capitalizeSentenceCase } from "./string/capitalizeSentenceCase";
|
|
22
|
-
export * from "./string/string";
|
|
23
19
|
export { default as updatePosition } from "./updatePosition";
|
|
24
20
|
export { default as useDelayUnmount } from "./useDelayUnmount";
|
|
21
|
+
export { default as useInput } from "./useInput";
|
|
25
22
|
export { default as useMediaQuery } from "./useMediaQuery";
|
|
26
23
|
export { default as useOnClickOutside } from "./useOnClickOutside";
|
|
27
24
|
export { default as usePortal } from "./usePortal";
|
|
25
|
+
export * from "./array/array";
|
|
26
|
+
export * from "./date";
|
|
27
|
+
export * from "./render-portal";
|
|
28
|
+
export * from "./sb-template";
|
|
29
|
+
export * from "./string/string";
|
|
28
30
|
export * from "./validate";
|
|
29
|
-
export { default as onValidate } from "./validate";
|
|
30
31
|
export default utils;
|