diginet-core-ui 1.4.23-beta.2 → 1.4.24
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/chip/index.js +69 -61
- package/components/form-control/calendar/function.js +1 -1
- package/components/form-control/date-picker/index.js +422 -143
- package/components/form-control/dropdown/index.js +632 -289
- package/components/form-control/number-input/index2.js +1 -4
- package/components/index.js +0 -1
- package/components/popover/index.js +32 -32
- package/icons/effect.js +58 -63
- package/package.json +33 -65
- package/readme.md +6 -1
- package/theme/settings.js +0 -24
- package/components/form-control/date-input/DateField.js +0 -189
- package/components/form-control/date-input/index.js +0 -301
- package/components/form-control/date-input/useControlled.js +0 -14
- package/components/form-control/date-input/useDateInputState.js +0 -132
- package/components/form-control/date-input/useIsFocused.js +0 -20
- package/components/form-control/date-input/useKeyboardInputEvent.js +0 -41
- package/components/form-control/date-input/utils.js +0 -286
- package/components/form-control/input-base/UncontrolledInputBase.js +0 -451
package/components/chip/index.js
CHANGED
|
@@ -4,12 +4,11 @@ import { css, jsx } from '@emotion/core';
|
|
|
4
4
|
import { ButtonIcon, Icon, Typography } from "./..";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
} from "../../styles/general";
|
|
7
|
+
import { hexToRGBA } from "../../styles/color-helper";
|
|
8
|
+
import { bgColor, border, boxBorder, cursorNotAllowed, displayInlineFlex, flexRow, itemsCenter, justifyCenter, overflowHidden, pointerEventsNone, positionAbsolute, positionRelative, textColor, userSelectNone } from "../../styles/general";
|
|
10
9
|
import { useTheme } from "../../theme";
|
|
11
10
|
import useThemeProps from "../../theme/utils/useThemeProps";
|
|
12
|
-
import { classNames, getProp
|
|
11
|
+
import { classNames, getProp } from "../../utils";
|
|
13
12
|
const colorMap = new Map([['default', 'system/active'], ['primary', 'system/active'], ['success', 'semantic/success'], ['warning', 'semantic/warning'], ['danger', 'semantic/danger'], ['info', 'semantic/info']]);
|
|
14
13
|
const iconSizeMap = new Map([['small', `16px`], ['medium', `20px`], ['large', `24px`]]);
|
|
15
14
|
const typographySizeMap = new Map([['small', 'p3'], ['medium', 'p2'], ['large', 'p1']]);
|
|
@@ -28,26 +27,27 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =>
|
|
|
28
27
|
name: 'Chip'
|
|
29
28
|
});
|
|
30
29
|
const {
|
|
31
|
-
|
|
32
|
-
className,
|
|
33
|
-
clearAble,
|
|
30
|
+
viewType,
|
|
34
31
|
color: colorProps,
|
|
35
|
-
|
|
36
|
-
endIcon,
|
|
32
|
+
size,
|
|
37
33
|
label,
|
|
38
|
-
|
|
34
|
+
className,
|
|
35
|
+
onRemove,
|
|
39
36
|
onClick,
|
|
40
37
|
onDbClick: onDbClickProp,
|
|
41
38
|
onDoubleClick,
|
|
42
|
-
onRemove,
|
|
43
|
-
readOnly,
|
|
44
|
-
size,
|
|
45
39
|
startIcon,
|
|
40
|
+
endIcon,
|
|
41
|
+
clearAble,
|
|
42
|
+
disabled,
|
|
43
|
+
readOnly,
|
|
44
|
+
children,
|
|
46
45
|
style,
|
|
47
|
-
|
|
46
|
+
labelProps
|
|
48
47
|
} = props;
|
|
49
48
|
const onDbClick = !onDbClickProp && onDoubleClick ? onDoubleClick : onDbClickProp;
|
|
50
49
|
const ref = useRef(null);
|
|
50
|
+
const IconRef = useRef(null);
|
|
51
51
|
let color = colorMap.get(colorProps) || colorProps;
|
|
52
52
|
color = getProp(colors, color, color);
|
|
53
53
|
const infoChip = {
|
|
@@ -64,7 +64,6 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =>
|
|
|
64
64
|
infoChip.contentColor = colorProps === 'default' && viewType === 'outlined' ? getProp(colors, 'system/rest') : infoChip === null || infoChip === void 0 ? void 0 : infoChip.contentColor;
|
|
65
65
|
infoChip.backgroundColor = colorProps === 'default' && viewType === 'filled' ? getProp(colors, 'system/rest') : infoChip === null || infoChip === void 0 ? void 0 : infoChip.backgroundColor;
|
|
66
66
|
const _ChipRootCSS = ChipRootCSS(onClick, onDbClick, infoChip, theme);
|
|
67
|
-
const _ChipIconCSS = ChipIconCSS(infoChip);
|
|
68
67
|
const onRemoveHandler = () => {
|
|
69
68
|
if (onRemove || disabled) onRemove(ref.current);
|
|
70
69
|
};
|
|
@@ -96,20 +95,20 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =>
|
|
|
96
95
|
color: 'currentColor'
|
|
97
96
|
});
|
|
98
97
|
} else return jsx("div", {
|
|
99
|
-
css:
|
|
98
|
+
css: ChipIconCSS(infoChip)
|
|
100
99
|
}, startIcon);
|
|
101
100
|
}, [startIcon, size]);
|
|
102
101
|
|
|
103
102
|
// Label
|
|
104
|
-
const labelView =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}, label);
|
|
103
|
+
const labelView = useMemo(() => {
|
|
104
|
+
return jsx(Typography, {
|
|
105
|
+
css: ChipLabelCSS,
|
|
106
|
+
type: infoChip.typographySize,
|
|
107
|
+
color: 'inherit',
|
|
108
|
+
lineClamp: 1,
|
|
109
|
+
...labelProps
|
|
110
|
+
}, label);
|
|
111
|
+
}, [label, size, startIcon, endIcon, clearAble]);
|
|
113
112
|
|
|
114
113
|
// End Icon
|
|
115
114
|
const endIconView = useMemo(() => {
|
|
@@ -119,10 +118,12 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =>
|
|
|
119
118
|
name: node,
|
|
120
119
|
width: infoChip.iconSize,
|
|
121
120
|
height: infoChip.iconSize,
|
|
122
|
-
color: infoChip.contentColor
|
|
121
|
+
color: infoChip.contentColor,
|
|
122
|
+
viewBox: true
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
return clearAble ? jsx(ButtonIcon, {
|
|
126
|
+
ref: IconRef,
|
|
126
127
|
className: 'end-icon',
|
|
127
128
|
viewType: 'ghost',
|
|
128
129
|
name: 'Close',
|
|
@@ -130,29 +131,29 @@ const Chip = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference) =>
|
|
|
130
131
|
height: infoChip.iconSize,
|
|
131
132
|
color: infoChip.contentColor,
|
|
132
133
|
disabled: disabled,
|
|
134
|
+
viewBox: true,
|
|
133
135
|
onClick: onRemoveHandler
|
|
134
136
|
}) : node && jsx("div", {
|
|
135
|
-
css:
|
|
136
|
-
className: 'end-icon ' + size
|
|
137
|
+
css: ChipIconCSS(infoChip),
|
|
138
|
+
className: 'end-icon ' + size,
|
|
139
|
+
ref: IconRef
|
|
137
140
|
}, node);
|
|
138
141
|
}, [clearAble, viewType, color, endIcon, size, disabled, onRemove]);
|
|
139
142
|
return jsx("div", {
|
|
140
143
|
css: _ChipRootCSS,
|
|
141
144
|
ref: ref,
|
|
142
|
-
className: classNames('DGN-UI-Chip', className, disabled && 'chip--disabled', readOnly && 'chip--readOnly', viewType === 'filled' && 'chip--filled'),
|
|
145
|
+
className: classNames(['DGN-UI-Chip', className, disabled && 'chip--disabled', readOnly && 'chip--readOnly', viewType === 'filled' && 'chip--filled']),
|
|
143
146
|
style: style,
|
|
144
147
|
onClick: _onClick,
|
|
145
148
|
onDoubleClick: _onDbClick
|
|
146
149
|
}, !!startIcon && startIconView, !!label && labelView, (!!endIcon || !!clearAble) && endIconView, children);
|
|
147
150
|
}));
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// `;
|
|
155
|
-
|
|
151
|
+
const ChipLabelCSS = css`
|
|
152
|
+
${flexRow};
|
|
153
|
+
${itemsCenter};
|
|
154
|
+
${positionRelative};
|
|
155
|
+
${userSelectNone};
|
|
156
|
+
`;
|
|
156
157
|
const ChipRootCSS = (onClick, onDbClick, info, {
|
|
157
158
|
colors,
|
|
158
159
|
spacing
|
|
@@ -166,20 +167,21 @@ const ChipRootCSS = (onClick, onDbClick, info, {
|
|
|
166
167
|
padding: ${info === null || info === void 0 ? void 0 : info.paddingSize};
|
|
167
168
|
${textColor(info === null || info === void 0 ? void 0 : info.contentColor)};
|
|
168
169
|
${bgColor(info === null || info === void 0 ? void 0 : info.backgroundColor)};
|
|
169
|
-
border-radius: ${spacing(
|
|
170
|
+
border-radius: ${spacing(4)}px;
|
|
170
171
|
cursor: ${onClick || onDbClick ? 'pointer' : 'unset'};
|
|
171
172
|
height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
|
|
172
173
|
min-height: ${info === null || info === void 0 ? void 0 : info.minHeightSize};
|
|
173
|
-
gap: ${spacing(
|
|
174
|
+
gap: ${spacing()}px;
|
|
174
175
|
&.chip--filled {
|
|
175
176
|
&:not(.chip--disabled):not(.chip--readOnly) {
|
|
176
177
|
&::after {
|
|
177
|
-
border-radius: ${spacing(
|
|
178
|
+
border-radius: ${spacing(4)}px;
|
|
178
179
|
${positionAbsolute};
|
|
179
180
|
top: 0;
|
|
180
181
|
left: 0;
|
|
181
182
|
content: '';
|
|
182
|
-
|
|
183
|
+
width: 100%;
|
|
184
|
+
height: 100%;
|
|
183
185
|
${pointerEventsNone};
|
|
184
186
|
}
|
|
185
187
|
&:hover::after,
|
|
@@ -225,9 +227,12 @@ const ChipIconCSS = info => css`
|
|
|
225
227
|
${positionRelative};
|
|
226
228
|
${boxBorder};
|
|
227
229
|
${overflowHidden};
|
|
228
|
-
${
|
|
229
|
-
${
|
|
230
|
-
${
|
|
230
|
+
width: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
231
|
+
min-width: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
232
|
+
max-width: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
233
|
+
height: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
234
|
+
min-height: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
235
|
+
max-height: ${info === null || info === void 0 ? void 0 : info.iconSize};
|
|
231
236
|
`;
|
|
232
237
|
|
|
233
238
|
// Chip.defaultProps = {
|
|
@@ -237,39 +242,42 @@ const ChipIconCSS = info => css`
|
|
|
237
242
|
// };
|
|
238
243
|
|
|
239
244
|
Chip.propTypes = {
|
|
240
|
-
/**
|
|
245
|
+
/** content to display in Chip */
|
|
241
246
|
label: PropTypes.string,
|
|
242
|
-
/**
|
|
247
|
+
/** class of Chip element */
|
|
243
248
|
className: PropTypes.string,
|
|
244
|
-
/**
|
|
249
|
+
/** max length content to display was allowed */
|
|
250
|
+
/** style inline of component */
|
|
245
251
|
style: PropTypes.object,
|
|
246
|
-
/**
|
|
252
|
+
/** the icon display at head of Chip */
|
|
247
253
|
startIcon: PropTypes.any,
|
|
248
|
-
/**
|
|
254
|
+
/** the icon display at last of Chip */
|
|
249
255
|
endIcon: PropTypes.any,
|
|
250
|
-
/**
|
|
256
|
+
/** type of chip */
|
|
251
257
|
viewType: PropTypes.oneOf(['ghost', 'outlined', 'filled']),
|
|
252
|
-
/**
|
|
258
|
+
/** color for text or background of Chip */
|
|
253
259
|
color: PropTypes.oneOfType([PropTypes.oneOf(['default', 'primary', 'info', 'success', 'warning', 'danger']), PropTypes.string]),
|
|
254
|
-
/**
|
|
260
|
+
/** size of Chip */
|
|
255
261
|
size: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
256
|
-
/**
|
|
262
|
+
/** show clear icon if true */
|
|
257
263
|
clearAble: PropTypes.bool,
|
|
258
|
-
/**
|
|
264
|
+
/** prevent all event and change color if true */
|
|
259
265
|
disabled: PropTypes.bool,
|
|
260
|
-
/**
|
|
266
|
+
/** prevent all event if true */
|
|
261
267
|
readOnly: PropTypes.bool,
|
|
262
|
-
/**
|
|
268
|
+
/** the function to get ref of Chip */
|
|
269
|
+
refs: PropTypes.func,
|
|
270
|
+
/** the function will run after remove chip */
|
|
263
271
|
onRemove: PropTypes.func,
|
|
264
|
-
/**
|
|
272
|
+
/** the function will run when click on chip */
|
|
265
273
|
onClick: PropTypes.func,
|
|
266
|
-
/**
|
|
274
|
+
/** the function will run when double click on chip */
|
|
267
275
|
onDbClick: PropTypes.func,
|
|
268
|
-
/**
|
|
276
|
+
/** like onDbClick (priority onDbClick) */
|
|
269
277
|
onDoubleClick: PropTypes.func,
|
|
270
|
-
/**
|
|
278
|
+
/** content to display on Chip (the same to label) */
|
|
271
279
|
children: PropTypes.node,
|
|
272
|
-
/**
|
|
280
|
+
/** props for Typography of label */
|
|
273
281
|
labelProps: PropTypes.object
|
|
274
282
|
};
|
|
275
283
|
export default Chip;
|
|
@@ -655,7 +655,7 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
|
|
|
655
655
|
color: 'primary',
|
|
656
656
|
type: 'h3',
|
|
657
657
|
ref: refs.content,
|
|
658
|
-
format: ['
|
|
658
|
+
format: ['lowercase']
|
|
659
659
|
}))), jsx("div", {
|
|
660
660
|
className: className.navigator.around
|
|
661
661
|
}, jsx(ButtonIcon, {
|