diginet-core-ui 1.3.86-beta.1 → 1.3.87-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/avatar/index.js +10 -12
- package/components/form-control/input-base/index.js +5 -5
- package/components/form-control/number-input/index2.js +19 -17
- package/components/popover/index.js +22 -16
- package/components/popup/v2/index.js +41 -36
- package/components/typography/index.js +21 -13
- package/global/index.js +2 -2
- package/package.json +1 -1
- package/readme.md +4 -0
- package/styles/general.js +16 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
4
|
import AvatarDefault from "../../assets/avatar/default.svg";
|
|
5
|
-
import { ButtonIcon, Image, ModalSample,
|
|
5
|
+
import { ButtonIcon, Image, ModalSample, Notify, Popover, Typography } from "./..";
|
|
6
6
|
import OptionWrapper from "../others/option-wrapper";
|
|
7
7
|
import { getGlobal } from "../../global";
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
@@ -66,7 +66,7 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
66
|
const ref = useRef(null);
|
|
67
67
|
const inputRef = useRef(null);
|
|
68
68
|
const avatarRef = useRef(null);
|
|
69
|
-
const
|
|
69
|
+
const notifyRef = useRef(null);
|
|
70
70
|
const [viewAvatar, setViewAvatar] = useState(false);
|
|
71
71
|
const [viewMoreInfo, setViewMoreInfo] = useState(false);
|
|
72
72
|
const [srcState, setSrcState] = useState(src);
|
|
@@ -89,16 +89,12 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
89
89
|
const reader = new FileReader();
|
|
90
90
|
if (!checkFileType(file.type, matchType)) {
|
|
91
91
|
input.target.value = '';
|
|
92
|
-
|
|
93
|
-
description: wrongTypeError
|
|
94
|
-
});
|
|
92
|
+
notifyRef.current.instance.show(wrongTypeError);
|
|
95
93
|
return;
|
|
96
94
|
}
|
|
97
95
|
if (+maxSize && file.size > maxSize * 1024 ** 2) {
|
|
98
96
|
input.target.value = '';
|
|
99
|
-
|
|
100
|
-
description: maxSizeError
|
|
101
|
-
});
|
|
97
|
+
notifyRef.current.instance.show(maxSizeError);
|
|
102
98
|
return;
|
|
103
99
|
}
|
|
104
100
|
reader.onload = e => {
|
|
@@ -237,10 +233,12 @@ const Avatar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
237
233
|
direction: direction
|
|
238
234
|
}, jsx("div", {
|
|
239
235
|
css: MoreInfoCSS
|
|
240
|
-
}, typeof data === 'function' ? data() : renderData())) : null,
|
|
241
|
-
ref:
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
}, typeof data === 'function' ? data() : renderData())) : null, jsx(Notify, {
|
|
237
|
+
ref: notifyRef,
|
|
238
|
+
progressing: true,
|
|
239
|
+
autoDisappear: true,
|
|
240
|
+
color: 'danger'
|
|
241
|
+
}));
|
|
244
242
|
}, [actionIconHeight, actionIconWidth, allowEdit, clearAble, data, defaultSrc, direction, disabled, height, hoverAble, lazyLoading, matchType, maxSize, maxSizeError, outlined, readOnly, width, srcState, viewAvatar, viewMoreInfo]);
|
|
245
243
|
}));
|
|
246
244
|
const ActionIconCSS = actionIconWidth => css`
|
|
@@ -134,7 +134,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
134
134
|
const defaultHeight = 24;
|
|
135
135
|
if (valueProp !== undefined) {
|
|
136
136
|
valueArray.current.push(valueProp);
|
|
137
|
-
|
|
137
|
+
inputRef.current.value = valueProp;
|
|
138
138
|
if (multiline && !/\d+/.test(rows)) {
|
|
139
139
|
inputRef.current.style.height = 0;
|
|
140
140
|
inputRef.current.style.height = Math.max(defaultHeight, inputRef.current.scrollHeight) + 'px';
|
|
@@ -155,7 +155,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
155
155
|
/* End handler */
|
|
156
156
|
|
|
157
157
|
useImperativeHandle(reference, () => {
|
|
158
|
-
const currentRef =
|
|
158
|
+
const currentRef = inputRef.current || {};
|
|
159
159
|
const _instance = {
|
|
160
160
|
...action
|
|
161
161
|
}; // methods
|
|
@@ -170,14 +170,14 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
170
170
|
styleInputBase.current = style;
|
|
171
171
|
};
|
|
172
172
|
const dynamicWidth = e => {
|
|
173
|
-
if (!autoWidth || !
|
|
174
|
-
if (!canvas || !styleInputBase.current || !
|
|
173
|
+
if (!autoWidth || !inputRef.current) return;
|
|
174
|
+
if (!canvas || !styleInputBase.current || !inputRef.current) return;
|
|
175
175
|
const context = canvas.getContext('2d');
|
|
176
176
|
context.font = styleInputBase.current.font;
|
|
177
177
|
const {
|
|
178
178
|
width
|
|
179
179
|
} = context.measureText(e.target.value);
|
|
180
|
-
|
|
180
|
+
inputRef.current.style.width = `${Math.max(width, widthInit.current)}px`;
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
/* Start component */
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
4
|
import { HelperText, InputBase, Label } from "../..";
|
|
7
5
|
import locale from "../../../locale";
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { cursorNotAllowed, displayBlock, mgb, positionRelative } from "../../../styles/general";
|
|
10
9
|
import { classNames, onValidate, refType as ref } from "../../../utils";
|
|
11
|
-
const {
|
|
12
|
-
spacing
|
|
13
|
-
} = useTheme();
|
|
14
10
|
const regexValidNumber = /[^0-9.,-]/g;
|
|
15
11
|
const regexNumber = /[^0-9]/g;
|
|
16
12
|
const regexThousandNumber = /(\d)(?=(\d{3})+\b)/g;
|
|
@@ -33,7 +29,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
33
29
|
fixedDecimalDigit,
|
|
34
30
|
helperTextProps,
|
|
35
31
|
inputProps,
|
|
36
|
-
inputRef,
|
|
32
|
+
inputRef: inputRefProp,
|
|
37
33
|
inputStyle,
|
|
38
34
|
label,
|
|
39
35
|
labelProps,
|
|
@@ -58,10 +54,12 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
58
54
|
value: valueProps,
|
|
59
55
|
viewType
|
|
60
56
|
}, reference) => {
|
|
61
|
-
|
|
57
|
+
if (!reference) reference = useRef(null);
|
|
58
|
+
if (!inputRefProp) inputRefProp = useRef(null);
|
|
62
59
|
const pos = useRef(null);
|
|
63
60
|
const ref = useRef(null);
|
|
64
61
|
const globalRef = useRef({});
|
|
62
|
+
const inputRef = useRef(null);
|
|
65
63
|
const [value, setValue] = useState(defaultValue);
|
|
66
64
|
const isError = !!error;
|
|
67
65
|
|
|
@@ -77,7 +75,6 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
77
75
|
} else {
|
|
78
76
|
thousandSymbol = '';
|
|
79
77
|
}
|
|
80
|
-
const validateResult = validates && onValidate(value, validates, true);
|
|
81
78
|
if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
82
79
|
|
|
83
80
|
/**
|
|
@@ -238,6 +235,7 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
238
235
|
}
|
|
239
236
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
240
237
|
};
|
|
238
|
+
const validateResult = validates && onValidate(Number(convertMoneyToNumber(value) || 0), validates, true);
|
|
241
239
|
useEffect(() => {
|
|
242
240
|
inputRef.current.value = value !== null && value !== void 0 ? value : null;
|
|
243
241
|
|
|
@@ -270,12 +268,16 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
270
268
|
css: NumberInputRoot,
|
|
271
269
|
className: classNames('DGN-UI-NumberInput', className, disabled && 'disabled'),
|
|
272
270
|
style: style
|
|
273
|
-
},
|
|
271
|
+
}, label ? jsx(Label, {
|
|
274
272
|
required: required,
|
|
275
273
|
disabled: disabled,
|
|
276
274
|
...labelProps
|
|
277
|
-
}, label), jsx(InputBase, {
|
|
278
|
-
inputRef:
|
|
275
|
+
}, label) : null, jsx(InputBase, {
|
|
276
|
+
inputRef: refs => {
|
|
277
|
+
if (!refs) return;
|
|
278
|
+
inputRef.current = refs;
|
|
279
|
+
typeof inputRefProp === 'function' ? inputRefProp(refs) : inputRefProp.current = refs;
|
|
280
|
+
},
|
|
279
281
|
viewType: viewType,
|
|
280
282
|
defaultValue: defaultValue,
|
|
281
283
|
value: value,
|
|
@@ -306,18 +308,18 @@ const NumberInput = /*#__PURE__*/forwardRef(({
|
|
|
306
308
|
target
|
|
307
309
|
});
|
|
308
310
|
}
|
|
309
|
-
}), isError
|
|
311
|
+
}), isError ? jsx(HelperText, {
|
|
310
312
|
...helperTextProps,
|
|
311
313
|
disabled: disabled
|
|
312
|
-
}, error), !isError && validateResult
|
|
314
|
+
}, error) : null, !isError && validateResult ? jsx(HelperText, {
|
|
313
315
|
...helperTextProps,
|
|
314
316
|
disabled: disabled
|
|
315
|
-
}, validateResult));
|
|
317
|
+
}, validateResult) : null);
|
|
316
318
|
});
|
|
317
319
|
const NumberInputRoot = css`
|
|
318
320
|
${displayBlock};
|
|
319
321
|
${positionRelative};
|
|
320
|
-
|
|
322
|
+
${mgb([5])};
|
|
321
323
|
&.disabled {
|
|
322
324
|
${cursorNotAllowed};
|
|
323
325
|
}
|
|
@@ -5,7 +5,7 @@ import OptionWrapper from "../others/option-wrapper";
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
|
-
import { borderRadius4px,
|
|
8
|
+
import { bgColor, borderRadius4px, displayFlex, displayNone, flexCol, inset, justifyBetween, overflowAuto, parseMaxWidthHeight, parseMinWidthHeight, parseWidthHeight, pointerEventsInherit, pointerEventsNone, positionAbsolute, positionFixed, positionRelative } from "../../styles/general";
|
|
9
9
|
import { useTheme } from "../../theme";
|
|
10
10
|
import { classNames, isMobile, refType as ref } from "../../utils";
|
|
11
11
|
const {
|
|
@@ -139,6 +139,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
139
139
|
width,
|
|
140
140
|
zIndex
|
|
141
141
|
}, reference) => {
|
|
142
|
+
if (!reference) reference = useRef(null);
|
|
142
143
|
if (isMobile.any() && trigger === 'hover') trigger = 'click';
|
|
143
144
|
const ref = useRef(null);
|
|
144
145
|
const arrowRef = useRef(null);
|
|
@@ -193,7 +194,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
193
194
|
verticalCenter = 0,
|
|
194
195
|
horizontal = 0,
|
|
195
196
|
horizontalCenter = 0,
|
|
196
|
-
arrowPosition = {
|
|
197
|
+
arrowPosition = {
|
|
198
|
+
display: 'block'
|
|
199
|
+
},
|
|
197
200
|
translate = {
|
|
198
201
|
left: 0,
|
|
199
202
|
top: 0
|
|
@@ -401,8 +404,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
401
404
|
}, [open]);
|
|
402
405
|
useEffect(() => {
|
|
403
406
|
if (openState && ref.current) {
|
|
404
|
-
|
|
405
|
-
|
|
407
|
+
if (document.body.style.overflow !== 'hidden') {
|
|
408
|
+
overflow.current = document.body.style.overflow; // store overflow of <body /> before open
|
|
409
|
+
document.body.style.overflow = 'hidden';
|
|
410
|
+
}
|
|
406
411
|
// Position's anchor
|
|
407
412
|
updatePositionPopover();
|
|
408
413
|
|
|
@@ -483,10 +488,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
483
488
|
ref: ref,
|
|
484
489
|
style: style,
|
|
485
490
|
className: classNames('DGN-UI-Popover-Container', className)
|
|
486
|
-
}, children), arrow
|
|
491
|
+
}, children), arrow ? jsx("span", {
|
|
487
492
|
ref: arrowRef,
|
|
488
493
|
css: _PopoverArrowCSS
|
|
489
|
-
}));
|
|
494
|
+
}) : null);
|
|
490
495
|
return /*#__PURE__*/createPortal(node, document.body);
|
|
491
496
|
}
|
|
492
497
|
return null;
|
|
@@ -495,28 +500,29 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
495
500
|
}));
|
|
496
501
|
const PortalPopoverCSS = (zIndex, fullScreen) => css`
|
|
497
502
|
${positionFixed};
|
|
503
|
+
${fullScreen ? pointerEventsInherit : pointerEventsNone};
|
|
504
|
+
${inset(0)};
|
|
498
505
|
z-index: ${zIndex};
|
|
499
|
-
pointer-events: ${fullScreen ? 'initial' : 'none'};
|
|
500
|
-
inset: 0;
|
|
501
506
|
`;
|
|
502
|
-
const PopoverContainerCSS = (
|
|
507
|
+
const PopoverContainerCSS = (bgCl, width, height) => css`
|
|
508
|
+
${displayFlex};
|
|
503
509
|
${flexCol};
|
|
504
510
|
${positionRelative};
|
|
505
511
|
${justifyBetween};
|
|
506
512
|
${overflowAuto};
|
|
507
513
|
${borderRadius4px};
|
|
508
514
|
${paragraph1};
|
|
515
|
+
${pointerEventsInherit};
|
|
509
516
|
${parseWidthHeight(width, height)};
|
|
510
517
|
${parseMinWidthHeight(spacing([4]))};
|
|
511
518
|
${parseMaxWidthHeight(`calc(100% - ${spacing([8])})`)};
|
|
519
|
+
${bgColor(bgCl)};
|
|
512
520
|
transition: opacity 0.3s ease;
|
|
513
|
-
pointer-events: initial;
|
|
514
521
|
opacity: 0;
|
|
515
|
-
background-color: ${bgColor};
|
|
516
522
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
517
523
|
`;
|
|
518
524
|
const PopoverArrowCSS = bgColor => css`
|
|
519
|
-
${
|
|
525
|
+
${displayNone};
|
|
520
526
|
${positionAbsolute};
|
|
521
527
|
${parseWidthHeight(0)};
|
|
522
528
|
border-left: 6px solid transparent;
|
|
@@ -546,10 +552,6 @@ Popover.defaultProps = {
|
|
|
546
552
|
zIndex: zIndexCORE(1)
|
|
547
553
|
};
|
|
548
554
|
Popover.propTypes = {
|
|
549
|
-
/** If `true`, the component is shown. */
|
|
550
|
-
open: PropTypes.bool,
|
|
551
|
-
/** Trigger mode of the component. Will not work when use with `open` prop. */
|
|
552
|
-
trigger: PropTypes.oneOf(['click', 'hover', 'focus']),
|
|
553
555
|
/** An HTML element, or a function that returns one. It's used to set the position of the popover. */
|
|
554
556
|
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node, ref]),
|
|
555
557
|
/**
|
|
@@ -586,6 +588,8 @@ Popover.propTypes = {
|
|
|
586
588
|
marginThreshold: PropTypes.number,
|
|
587
589
|
/** Callback fired when the component requests to be closed. */
|
|
588
590
|
onClose: PropTypes.func,
|
|
591
|
+
/** If `true`, the component is shown. */
|
|
592
|
+
open: PropTypes.bool,
|
|
589
593
|
/** If `true`, hitting escape will close component. */
|
|
590
594
|
pressESCToClose: PropTypes.bool,
|
|
591
595
|
/** Style inline of component. */
|
|
@@ -598,6 +602,8 @@ Popover.propTypes = {
|
|
|
598
602
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
599
603
|
vertical: PropTypes.oneOf(['bottom', 'center', 'top'])
|
|
600
604
|
}),
|
|
605
|
+
/** Trigger mode of the component. Will not work when use with `open` prop. */
|
|
606
|
+
trigger: PropTypes.oneOf(['click', 'hover', 'focus']),
|
|
601
607
|
/** Width of the component. */
|
|
602
608
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
603
609
|
/** Config z-index of the component. */
|
|
@@ -8,7 +8,7 @@ import { forwardRef, Fragment, memo, useCallback, useEffect, useImperativeHandle
|
|
|
8
8
|
import { createPortal } from 'react-dom';
|
|
9
9
|
import { animations } from "../../../styles/animation";
|
|
10
10
|
import { hexToRGBA } from "../../../styles/color-helper";
|
|
11
|
-
import {
|
|
11
|
+
import { bgColor, border, borderRadius, borderRadius50, boxBorder, breakWord, cursorPointer, displayBlock, displayFlex, flexCol, flexRow, inset, itemsCenter, justifyCenter, justifyEnd, mg, mgb, mgr, mgt, overflowAuto, overflowHidden, parseHeight, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pd, positionFixed, positionRelative, textEllipsis, truncate, z } from "../../../styles/general";
|
|
12
12
|
import { useTheme } from "../../../theme";
|
|
13
13
|
import { classNames, refType as ref, useDelayUnmount } from "../../../utils";
|
|
14
14
|
const {
|
|
@@ -26,9 +26,7 @@ const {
|
|
|
26
26
|
'scrollbar-tabbar': fillScrollbarTabbar,
|
|
27
27
|
hover: fillHover
|
|
28
28
|
}
|
|
29
|
-
}
|
|
30
|
-
spacing,
|
|
31
|
-
zIndex: zIndexCORE
|
|
29
|
+
}
|
|
32
30
|
} = useTheme();
|
|
33
31
|
const colorMap = new Map([['yesno', semanticInfo], ['success', semanticSuccess], ['warning', semanticWarning], ['danger', semanticDanger], ['info', semanticInfo]]);
|
|
34
32
|
const titleMap = new Map([['yesno', 'notify'], ['success', 'confirm'], ['warning', 'warning'], ['danger', 'error'], ['info', 'notify']]);
|
|
@@ -57,6 +55,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
57
55
|
yesText,
|
|
58
56
|
...props
|
|
59
57
|
}, reference) => {
|
|
58
|
+
if (!reference) reference = useRef(null);
|
|
60
59
|
const ref = useRef(null);
|
|
61
60
|
const statusAction = useRef('');
|
|
62
61
|
const [openState, setOpenState] = useState(open);
|
|
@@ -86,14 +85,14 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
85
|
};
|
|
87
86
|
const popup = jsx(Fragment, null, PopupHeaderView(newProps.title, newProps.type), jsx("div", {
|
|
88
87
|
className: 'DGN-UI-Popup-Body'
|
|
89
|
-
}, newProps.icon !== false
|
|
88
|
+
}, newProps.icon !== false ? jsx("div", {
|
|
90
89
|
className: 'DGN-UI-Popup-Body-Icon'
|
|
91
90
|
}, jsx(Icon, {
|
|
92
91
|
name: newProps.icon === true ? iconMap.get(newProps.type) : newProps.icon,
|
|
93
92
|
width: 40,
|
|
94
93
|
height: 40,
|
|
95
94
|
color: colorMap.get(newProps.type)
|
|
96
|
-
})), jsx("div", {
|
|
95
|
+
})) : null, jsx("div", {
|
|
97
96
|
className: 'DGN-UI-Popup-Body-Description'
|
|
98
97
|
}, jsx(Typography, {
|
|
99
98
|
type: 'p2'
|
|
@@ -174,28 +173,28 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
174
173
|
const PopupBodyView = (icon, type, subtitle, description) => {
|
|
175
174
|
return jsx("div", {
|
|
176
175
|
className: 'DGN-UI-Popup-Body'
|
|
177
|
-
}, icon !== false
|
|
176
|
+
}, icon !== false ? jsx("div", {
|
|
178
177
|
className: 'DGN-UI-Popup-Body-Icon'
|
|
179
178
|
}, jsx(Icon, {
|
|
180
179
|
name: icon === true ? iconMap.get(type) : icon,
|
|
181
180
|
width: 40,
|
|
182
181
|
height: 40,
|
|
183
182
|
color: colorMap.get(type)
|
|
184
|
-
})), jsx("div", {
|
|
183
|
+
})) : null, jsx("div", {
|
|
185
184
|
className: 'DGN-UI-Popup-Body-Description'
|
|
186
185
|
}, jsx(Typography, {
|
|
187
186
|
type: 'p2'
|
|
188
|
-
}, subtitle
|
|
187
|
+
}, subtitle ? jsx(Typography, {
|
|
189
188
|
className: 'DGN-UI-Popup-Body-Subtitle',
|
|
190
189
|
fullWidth: true
|
|
191
|
-
}, subtitle), jsx(Typography, {
|
|
190
|
+
}, subtitle) : null, jsx(Typography, {
|
|
192
191
|
ref: onRefChange,
|
|
193
192
|
type: 'p2',
|
|
194
193
|
className: 'DGN-UI-Popup-Body-Detail'
|
|
195
|
-
}, description),
|
|
194
|
+
}, description), subtitle && descriptionLines > 1 || descriptionLines > 3 ? jsx("span", {
|
|
196
195
|
className: 'DGN-More-Action',
|
|
197
196
|
onClick: () => setShowMoreDescription(!showMoreDescription)
|
|
198
|
-
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore')))));
|
|
197
|
+
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore')) : null)));
|
|
199
198
|
};
|
|
200
199
|
const PopupActionView = (onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText) => {
|
|
201
200
|
return onConfirm || onCancel || type === 'yesno' ? jsx("div", {
|
|
@@ -226,29 +225,29 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
226
225
|
style: style,
|
|
227
226
|
className: classNames('DGN-UI-Portal DGN-UI-Popup-Portal', className)
|
|
228
227
|
}, jsx("div", {
|
|
229
|
-
className:
|
|
228
|
+
className: classNames('DGN-UI-Popup', openState ? 'DGN-Show' : 'DGN-Hide'),
|
|
230
229
|
...props
|
|
231
230
|
}, custom ? custom : jsx(Fragment, null, PopupHeaderView(title, type), PopupBodyView(icon, type, subtitle, description), PopupActionView(onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText)))), document.body);
|
|
232
231
|
}));
|
|
233
232
|
const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescription, descriptionLines) => css`
|
|
233
|
+
${displayFlex};
|
|
234
234
|
${flexRow};
|
|
235
235
|
${positionFixed};
|
|
236
236
|
${justifyCenter};
|
|
237
237
|
${breakWord};
|
|
238
238
|
${parseWidthHeight('100%')};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
background-color: rgba(21, 26, 48, 0.5);
|
|
243
|
-
z-index: ${zIndexCORE(2)};
|
|
239
|
+
${inset(0)};
|
|
240
|
+
${bgColor('rgba(21, 26, 48, 0.5)')}
|
|
241
|
+
${z(2)};
|
|
244
242
|
.DGN-UI-Popup {
|
|
243
|
+
${displayFlex};
|
|
245
244
|
${flexCol};
|
|
246
|
-
${borderRadius4px};
|
|
247
245
|
${boxBorder};
|
|
246
|
+
${borderRadius(4)};
|
|
248
247
|
${parseWidthHeight(width, 'fit-content')};
|
|
249
248
|
${parseMaxWidthHeight('80%')};
|
|
249
|
+
${bgColor(systemWhite)};
|
|
250
250
|
margin: ${isNaN(top) ? top : top + 'px'} auto auto;
|
|
251
|
-
background-color: ${systemWhite};
|
|
252
251
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
253
252
|
&.DGN-Show {
|
|
254
253
|
animation: ${fadeInDown} 0.2s ease;
|
|
@@ -258,40 +257,43 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
258
257
|
animation-fill-mode: forwards;
|
|
259
258
|
}
|
|
260
259
|
.DGN-UI-Popup-Header {
|
|
260
|
+
${displayFlex};
|
|
261
261
|
${flexRow};
|
|
262
262
|
${itemsCenter};
|
|
263
263
|
${parseMinHeight(40)};
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
${pd([0, 2, 0, 4])};
|
|
265
|
+
${borderRadius('4px 4px 0px 0px')};
|
|
266
266
|
.DGN-UI-Popup-Header-Title {
|
|
267
|
+
${displayFlex};
|
|
267
268
|
${flexRow};
|
|
268
269
|
${truncate};
|
|
269
270
|
${parseWidth('calc(100% - 24px)')};
|
|
270
271
|
}
|
|
271
272
|
color: ${colorMap.get(type)};
|
|
272
|
-
|
|
273
|
+
${bgColor(hexToRGBA(colorMap.get(type), 0.15))};
|
|
273
274
|
}
|
|
274
275
|
.DGN-UI-Popup-Body {
|
|
276
|
+
${displayFlex};
|
|
275
277
|
${flexRow};
|
|
276
278
|
${positionRelative};
|
|
277
279
|
${overflowAuto};
|
|
280
|
+
${pd([4])};
|
|
278
281
|
flex: 1 1 auto;
|
|
279
|
-
padding: ${spacing([4])};
|
|
280
282
|
&::-webkit-scrollbar {
|
|
281
|
-
${
|
|
283
|
+
${borderRadius(4)};
|
|
282
284
|
${parseWidth(24)};
|
|
283
285
|
background-color: ${systemWhite} !important;
|
|
284
286
|
}
|
|
285
287
|
&::-webkit-scrollbar-thumb {
|
|
286
288
|
${border(8, 'transparent')};
|
|
287
|
-
|
|
289
|
+
${borderRadius(24)};
|
|
288
290
|
mix-blend-mode: normal;
|
|
289
291
|
background-color: ${fillScrollbarTabbar} !important;
|
|
290
292
|
background-clip: content-box;
|
|
291
293
|
}
|
|
292
294
|
&::-webkit-scrollbar-thumb:hover {
|
|
293
295
|
${border(8, 'transparent')};
|
|
294
|
-
|
|
296
|
+
${borderRadius(24)};
|
|
295
297
|
mix-blend-mode: normal;
|
|
296
298
|
background-color: ${fillHover} !important;
|
|
297
299
|
background-clip: content-box;
|
|
@@ -300,20 +302,21 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
300
302
|
${displayBlock};
|
|
301
303
|
${borderRadius50};
|
|
302
304
|
${parseWidth(40)};
|
|
303
|
-
|
|
305
|
+
${mgr([4])};
|
|
304
306
|
}
|
|
305
307
|
.DGN-UI-Popup-Body-Description {
|
|
308
|
+
${displayFlex};
|
|
306
309
|
${flexRow};
|
|
307
310
|
${positionRelative};
|
|
308
311
|
${itemsCenter};
|
|
309
312
|
${parseMinHeight(40)};
|
|
310
313
|
${parseHeight('max-content')};
|
|
311
314
|
.DGN-UI-Popup-Body-Subtitle {
|
|
312
|
-
|
|
315
|
+
${mgb([(description === null || description === void 0 ? void 0 : description.length) > 0 ? 2 : 0])};
|
|
313
316
|
}
|
|
314
317
|
.DGN-UI-Popup-Body-Detail {
|
|
315
318
|
${overflowHidden};
|
|
316
|
-
|
|
319
|
+
${textEllipsis};
|
|
317
320
|
display: -webkit-box;
|
|
318
321
|
-webkit-line-clamp: ${showMoreDescription ? 'none' : subtitle && descriptionLines > 1 ? 1 : descriptionLines > 3 ? 3 : 'none'};
|
|
319
322
|
-webkit-box-orient: vertical;
|
|
@@ -321,23 +324,24 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
321
324
|
.DGN-More-Action {
|
|
322
325
|
${displayBlock};
|
|
323
326
|
${cursorPointer};
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
${parseWidth('fit-content')};
|
|
328
|
+
${mgt([4])};
|
|
329
|
+
${mgb([type === 'yesno' ? 0 : 2])};
|
|
327
330
|
text-decoration: underline;
|
|
328
331
|
color: ${semanticInfo};
|
|
329
332
|
}
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
335
|
.DGN-UI-Popup-Action {
|
|
336
|
+
${displayFlex};
|
|
333
337
|
${flexRow};
|
|
334
338
|
${justifyEnd};
|
|
335
|
-
|
|
339
|
+
${pd([2, 4, 4, 4])};
|
|
336
340
|
.DGN-UI-Button {
|
|
337
341
|
${parseMinWidth(80)};
|
|
338
|
-
|
|
342
|
+
${mg(0)};
|
|
339
343
|
&.filled {
|
|
340
|
-
|
|
344
|
+
${mgr([2])};
|
|
341
345
|
}
|
|
342
346
|
}
|
|
343
347
|
}
|
|
@@ -345,6 +349,7 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
345
349
|
`;
|
|
346
350
|
Popup.defaultProps = {
|
|
347
351
|
className: '',
|
|
352
|
+
description: '',
|
|
348
353
|
icon: true,
|
|
349
354
|
open: false,
|
|
350
355
|
pressESCToClose: false,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Popover } from "./..";
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { forwardRef, Fragment, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
|
-
import {
|
|
7
|
-
import { breakAll, breakWord, cursorPointer, displayBlock, displayInlineBlock, overflowHidden, pointerEventsNone, positionRelative, textCapitalize, textCenter, textUppercase } from "../../styles/general";
|
|
7
|
+
import { breakAll, breakWord, cursorPointer, displayBlock, displayInlineBlock, italic, overflowHidden, parseHeight, parseMaxWidth, pd, pointerEventsNone, positionRelative, textCapitalize, textCenter, textLineThrough, textLowercase, textunderline, textUppercase, whiteSpaceBreakSpaces } from "../../styles/general";
|
|
8
8
|
import { useColor as colors, useTheme, useTypography as typography } from "../../theme";
|
|
9
9
|
import { classNames, renderHTML } from "../../utils";
|
|
10
10
|
const {
|
|
@@ -22,10 +22,10 @@ const {
|
|
|
22
22
|
},
|
|
23
23
|
typography: {
|
|
24
24
|
paragraph1
|
|
25
|
-
}
|
|
26
|
-
spacing
|
|
25
|
+
}
|
|
27
26
|
} = useTheme();
|
|
28
27
|
const colorMap = new Map([['default', textMain], ['secondary', systemRest]]);
|
|
28
|
+
const formatMap = new Map([['capitalize', textCapitalize], ['uppercase', textUppercase], ['lowercase', textLowercase], ['italic', italic], ['line-through', textLineThrough], ['underline', textunderline]]);
|
|
29
29
|
const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
|
|
30
30
|
const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
31
31
|
action = {},
|
|
@@ -34,8 +34,10 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
34
34
|
children,
|
|
35
35
|
className,
|
|
36
36
|
color,
|
|
37
|
+
format,
|
|
37
38
|
fullWidth,
|
|
38
39
|
hoverTooltip,
|
|
40
|
+
italic,
|
|
39
41
|
lineClamp,
|
|
40
42
|
mapping,
|
|
41
43
|
onClick,
|
|
@@ -45,9 +47,14 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
45
47
|
...props
|
|
46
48
|
}, reference) => {
|
|
47
49
|
var _ref$current;
|
|
50
|
+
if (!reference) reference = useRef(null);
|
|
48
51
|
const ref = useRef(null);
|
|
52
|
+
const formatCSS = [];
|
|
53
|
+
format.forEach(item => {
|
|
54
|
+
formatCSS.push(formatMap.get(item));
|
|
55
|
+
});
|
|
49
56
|
const [openTooltip, setOpenTooltip] = useState(false);
|
|
50
|
-
const _TextRootCSS = TextRootCSS(color, type, lineClamp, onClick, hoverTooltip);
|
|
57
|
+
const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip), ...formatCSS];
|
|
51
58
|
const showTooltip = () => {
|
|
52
59
|
if (!hoverTooltip) return;
|
|
53
60
|
if (isTextClamped(ref.current)) {
|
|
@@ -94,7 +101,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
94
101
|
onClick: onClick,
|
|
95
102
|
...props
|
|
96
103
|
}), renderTooltip);
|
|
97
|
-
}, [capitalize, center, children, className, color, fullWidth, hoverTooltip, lineClamp, mapping, onClick, tooltipDirection, type, uppercase,
|
|
104
|
+
}, [capitalize, center, children, className, color, format, fullWidth, hoverTooltip, italic, lineClamp, mapping, onClick, props, tooltipDirection, type, uppercase, openTooltip]);
|
|
98
105
|
}));
|
|
99
106
|
const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
|
|
100
107
|
${displayInlineBlock};
|
|
@@ -102,12 +109,10 @@ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
|
|
|
102
109
|
${paragraph1};
|
|
103
110
|
${onClick && cursorPointer};
|
|
104
111
|
${hoverTooltip && lineClamp === 1 ? breakAll : breakWord};
|
|
105
|
-
|
|
112
|
+
${whiteSpaceBreakSpaces};
|
|
106
113
|
color: ${colorMap.get(color) || colors[color] || color};
|
|
107
|
-
max-
|
|
108
|
-
|
|
109
|
-
${typography[type]};
|
|
110
|
-
}
|
|
114
|
+
${parseMaxWidth('max-content')};
|
|
115
|
+
${typography[type]};
|
|
111
116
|
&.DGN-Typography-center {
|
|
112
117
|
${textCenter};
|
|
113
118
|
}
|
|
@@ -134,13 +139,14 @@ const PopoverCSS = css`
|
|
|
134
139
|
`;
|
|
135
140
|
const PopoverContentCSS = css`
|
|
136
141
|
color: ${textTooltip};
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
${pd([1, 1.5])};
|
|
143
|
+
${parseHeight('fit-content')};
|
|
139
144
|
`;
|
|
140
145
|
Typography.defaultProps = {
|
|
141
146
|
center: false,
|
|
142
147
|
className: '',
|
|
143
148
|
color: 'default',
|
|
149
|
+
format: [],
|
|
144
150
|
fullWidth: true,
|
|
145
151
|
hoverTooltip: false,
|
|
146
152
|
mapping: 'span',
|
|
@@ -171,6 +177,8 @@ Typography.propTypes = {
|
|
|
171
177
|
className: PropTypes.string,
|
|
172
178
|
/** Color of text ['primary', 'secondary', 'success', 'warning', 'danger', 'info', '#hex', rgb(#,#,#)]. */
|
|
173
179
|
color: PropTypes.string,
|
|
180
|
+
/** Option to make the text bold, italic, capitalize or underline. */
|
|
181
|
+
format: PropTypes.arrayOf(PropTypes.oneOf(['capitalize', 'uppercase', 'lowercase', 'italic', 'line-through', 'underline'])),
|
|
174
182
|
/** If `true`, the component will take up the full width of its container. */
|
|
175
183
|
fullWidth: PropTypes.bool,
|
|
176
184
|
/** If `true`, hover will show tooltip when text clamped. */
|
package/global/index.js
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,10 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.87
|
|
42
|
+
- \[Added\]: Icon – Upload, Workflow
|
|
43
|
+
- \[Fixed\]: InputBase – Fix not run when inputRef is function
|
|
44
|
+
|
|
41
45
|
## 1.3.86
|
|
42
46
|
- \[Changed\]: Icon – Optimize code
|
|
43
47
|
- \[Fixed\]: Dropdown – Fix bug cannot select multiple after search
|
package/styles/general.js
CHANGED
|
@@ -176,6 +176,9 @@ const insetY = vl => css`
|
|
|
176
176
|
top: ${parseCSSValue(vl)};
|
|
177
177
|
bottom: ${parseCSSValue(vl)};
|
|
178
178
|
`;
|
|
179
|
+
const italic = css`
|
|
180
|
+
font-style: italic;
|
|
181
|
+
`;
|
|
179
182
|
const itemsCenter = css`
|
|
180
183
|
align-items: center;
|
|
181
184
|
`;
|
|
@@ -318,6 +321,9 @@ const parseWidthHeight = (width, height = width) => css`
|
|
|
318
321
|
const pointerEventsAuto = css`
|
|
319
322
|
pointer-events: auto;
|
|
320
323
|
`;
|
|
324
|
+
const pointerEventsInherit = css`
|
|
325
|
+
pointer-events: inherit;
|
|
326
|
+
`;
|
|
321
327
|
const pointerEventsNone = css`
|
|
322
328
|
pointer-events: none;
|
|
323
329
|
`;
|
|
@@ -357,9 +363,18 @@ const textEllipsis = css`
|
|
|
357
363
|
const textLeft = css`
|
|
358
364
|
text-align: left;
|
|
359
365
|
`;
|
|
366
|
+
const textLineThrough = css`
|
|
367
|
+
text-decoration: line-through;
|
|
368
|
+
`;
|
|
369
|
+
const textLowercase = css`
|
|
370
|
+
text-transform: lowercase;
|
|
371
|
+
`;
|
|
360
372
|
const textRight = css`
|
|
361
373
|
text-align: right;
|
|
362
374
|
`;
|
|
375
|
+
const textunderline = css`
|
|
376
|
+
text-decoration: underline;
|
|
377
|
+
`;
|
|
363
378
|
const textUppercase = css`
|
|
364
379
|
text-transform: uppercase;
|
|
365
380
|
`;
|
|
@@ -383,4 +398,4 @@ const whiteSpacePreWrap = css`
|
|
|
383
398
|
const z = vl => css`
|
|
384
399
|
z-index: ${zIndex(vl)};
|
|
385
400
|
`;
|
|
386
|
-
export { bgColor, bgCurrent, bgTransparent, border, borderNone, borderRadius, borderRadius100, borderRadius4px, borderRadius50, boxBorder, boxContent, breakAll, breakWord, cursorDefault, cursorInherit, cursorMove, cursorNoDrop, cursorNotAllowed, cursorPointer, cursorText, displayBlock, displayFlex, displayInlineBlock, displayInlineFlex, displayNone, flexCol, flexColReverse, shadowNone, flexNowrap, flexRow, flexRowReverse, flexShrink, flexShrink0, flexWrap, flexWrapReverse, floatLeft, floatNone, floatRight, gap, gapX, gapY, inset, insetX, insetY, itemsCenter, itemsEnd, itemsStart, justifyAround, justifyBetween, justifyCenter, justifyEnd, justifyEvenly, justifyStart, mg, mgb, mgl, mgr, mgt, mgx, mgy, noBorder, noBoxShadow, noMargin, noPadding, objectContain, objectCover, objectFill, objectNone, order, outlineNone, overflowAuto, overflowHidden, pd, pdb, pdl, pdr, pdt, pdx, pdy, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidth, parseWidthHeight, pointerEventsAuto, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, positionSticky, selfCenter, selfEnd, selfStart, textCapitalize, textCenter, textCurrent, textEllipsis, textLeft, textRight, textUppercase, truncate, userSelectNone, whiteSpaceBreakSpaces, whiteSpaceNoWrap, whiteSpacePreWrap, z };
|
|
401
|
+
export { bgColor, bgCurrent, bgTransparent, border, borderNone, borderRadius, borderRadius100, borderRadius4px, borderRadius50, boxBorder, boxContent, breakAll, breakWord, cursorDefault, cursorInherit, cursorMove, cursorNoDrop, cursorNotAllowed, cursorPointer, cursorText, displayBlock, displayFlex, displayInlineBlock, displayInlineFlex, displayNone, flexCol, flexColReverse, shadowNone, flexNowrap, flexRow, flexRowReverse, flexShrink, flexShrink0, flexWrap, flexWrapReverse, floatLeft, floatNone, floatRight, gap, gapX, gapY, inset, insetX, insetY, italic, itemsCenter, itemsEnd, itemsStart, justifyAround, justifyBetween, justifyCenter, justifyEnd, justifyEvenly, justifyStart, mg, mgb, mgl, mgr, mgt, mgx, mgy, noBorder, noBoxShadow, noMargin, noPadding, objectContain, objectCover, objectFill, objectNone, order, outlineNone, overflowAuto, overflowHidden, pd, pdb, pdl, pdr, pdt, pdx, pdy, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidth, parseWidthHeight, pointerEventsAuto, pointerEventsInherit, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, positionSticky, selfCenter, selfEnd, selfStart, textCapitalize, textCenter, textCurrent, textEllipsis, textLeft, textLineThrough, textLowercase, textRight, textunderline, textUppercase, truncate, userSelectNone, whiteSpaceBreakSpaces, whiteSpaceNoWrap, whiteSpacePreWrap, z };
|