antd-mobile 5.37.1 → 5.38.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/2x/README.md +2 -2
- package/2x/bundle/antd-mobile.cjs.development.js +2276 -1113
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +2279 -1116
- package/2x/bundle/antd-mobile.es.js +7914 -7141
- package/2x/bundle/antd-mobile.umd.development.js +2276 -1113
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/bundle/css-vars-patch.css +42 -0
- package/2x/bundle/style.css +142 -4
- package/2x/cjs/components/calendar-picker-view/calendar-picker-view.d.ts +1 -1
- package/2x/cjs/components/calendar-picker-view/calendar-picker-view.js +31 -10
- package/2x/cjs/components/card/card.css +1 -0
- package/2x/cjs/components/card/card.d.ts +2 -1
- package/2x/cjs/components/card/card.js +7 -3
- package/2x/cjs/components/card/card.patch.css +8 -0
- package/2x/cjs/components/date-picker/date-picker-quarter-utils.d.ts +7 -0
- package/2x/cjs/components/date-picker/date-picker-quarter-utils.js +77 -0
- package/2x/cjs/components/date-picker/date-picker-utils.d.ts +3 -2
- package/2x/cjs/components/date-picker/date-picker-utils.js +7 -0
- package/2x/cjs/components/ellipsis/ellipsis.css +1 -0
- package/2x/cjs/components/ellipsis/ellipsis.d.ts +1 -1
- package/2x/cjs/components/ellipsis/ellipsis.js +28 -124
- package/2x/cjs/components/ellipsis/useMeasure.d.ts +2 -0
- package/2x/cjs/components/ellipsis/useMeasure.js +108 -0
- package/2x/cjs/components/ellipsis/~ellipsis.d.ts +15 -0
- package/2x/cjs/components/ellipsis/~ellipsis.js +161 -0
- package/2x/cjs/components/image-uploader/image-uploader.js +2 -2
- package/2x/cjs/components/input/input.d.ts +2 -2
- package/2x/cjs/components/input/input.js +1 -0
- package/2x/cjs/components/notice-bar/notice-bar.css +30 -4
- package/2x/cjs/components/notice-bar/notice-bar.d.ts +5 -1
- package/2x/cjs/components/notice-bar/notice-bar.js +7 -3
- package/2x/cjs/components/search-bar/search-bar.d.ts +2 -2
- package/2x/cjs/components/search-bar/search-bar.js +1 -0
- package/2x/cjs/components/segmented/index.d.ts +4 -0
- package/2x/cjs/components/segmented/index.js +10 -0
- package/2x/cjs/components/segmented/segmented.css +113 -0
- package/2x/cjs/components/segmented/segmented.d.ts +21 -0
- package/2x/cjs/components/segmented/segmented.js +57 -0
- package/2x/cjs/components/segmented/segmented.patch.css +41 -0
- package/2x/cjs/components/tab-bar/tab-bar.d.ts +1 -0
- package/2x/cjs/components/tab-bar/tab-bar.js +2 -0
- package/2x/cjs/components/tabs/tabs.js +1 -1
- package/2x/cjs/components/toast/methods.js +9 -3
- package/2x/cjs/global/css-vars-patch.css +42 -0
- package/2x/cjs/index.d.ts +2 -0
- package/2x/cjs/index.js +7 -0
- package/2x/cjs/locales/cnr-ME.d.ts +139 -0
- package/2x/cjs/locales/cnr-ME.js +149 -0
- package/2x/cjs/locales/hr-HR.d.ts +139 -0
- package/2x/cjs/locales/hr-HR.js +149 -0
- package/2x/cjs/locales/kk-KZ.js +6 -6
- package/2x/cjs/locales/sr-RS.d.ts +139 -0
- package/2x/cjs/locales/sr-RS.js +149 -0
- package/2x/cjs/utils/render-imperatively.d.ts +1 -0
- package/2x/cjs/utils/render-imperatively.js +6 -3
- package/2x/es/components/calendar-picker-view/calendar-picker-view.d.ts +1 -1
- package/2x/es/components/calendar-picker-view/calendar-picker-view.js +32 -11
- package/2x/es/components/card/card.css +1 -0
- package/2x/es/components/card/card.d.ts +2 -1
- package/2x/es/components/card/card.js +7 -3
- package/2x/es/components/card/card.patch.css +8 -0
- package/2x/es/components/date-picker/date-picker-quarter-utils.d.ts +7 -0
- package/2x/es/components/date-picker/date-picker-quarter-utils.js +68 -0
- package/2x/es/components/date-picker/date-picker-utils.d.ts +3 -2
- package/2x/es/components/date-picker/date-picker-utils.js +7 -0
- package/2x/es/components/ellipsis/ellipsis.css +1 -0
- package/2x/es/components/ellipsis/ellipsis.d.ts +1 -1
- package/2x/es/components/ellipsis/ellipsis.js +28 -122
- package/2x/es/components/ellipsis/useMeasure.d.ts +2 -0
- package/2x/es/components/ellipsis/useMeasure.js +101 -0
- package/2x/es/components/ellipsis/~ellipsis.d.ts +15 -0
- package/2x/es/components/ellipsis/~ellipsis.js +151 -0
- package/2x/es/components/image-uploader/image-uploader.js +2 -2
- package/2x/es/components/input/input.d.ts +2 -2
- package/2x/es/components/input/input.js +1 -0
- package/2x/es/components/notice-bar/notice-bar.css +30 -4
- package/2x/es/components/notice-bar/notice-bar.d.ts +5 -1
- package/2x/es/components/notice-bar/notice-bar.js +7 -3
- package/2x/es/components/search-bar/search-bar.d.ts +2 -2
- package/2x/es/components/search-bar/search-bar.js +1 -0
- package/2x/es/components/segmented/index.d.ts +4 -0
- package/2x/es/components/segmented/index.js +3 -0
- package/2x/es/components/segmented/segmented.css +113 -0
- package/2x/es/components/segmented/segmented.d.ts +21 -0
- package/2x/es/components/segmented/segmented.js +48 -0
- package/2x/es/components/segmented/segmented.patch.css +41 -0
- package/2x/es/components/tab-bar/tab-bar.d.ts +1 -0
- package/2x/es/components/tab-bar/tab-bar.js +2 -0
- package/2x/es/components/tabs/tabs.js +1 -1
- package/2x/es/components/toast/methods.js +9 -3
- package/2x/es/global/css-vars-patch.css +42 -0
- package/2x/es/index.d.ts +2 -0
- package/2x/es/index.js +1 -0
- package/2x/es/locales/cnr-ME.d.ts +139 -0
- package/2x/es/locales/cnr-ME.js +142 -0
- package/2x/es/locales/hr-HR.d.ts +139 -0
- package/2x/es/locales/hr-HR.js +142 -0
- package/2x/es/locales/kk-KZ.js +6 -6
- package/2x/es/locales/sr-RS.d.ts +139 -0
- package/2x/es/locales/sr-RS.js +142 -0
- package/2x/es/utils/render-imperatively.d.ts +1 -0
- package/2x/es/utils/render-imperatively.js +6 -3
- package/2x/package.json +3 -2
- package/README.md +2 -2
- package/bundle/antd-mobile.cjs.development.js +2276 -1113
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +2279 -1116
- package/bundle/antd-mobile.es.js +7914 -7141
- package/bundle/antd-mobile.umd.development.js +2276 -1113
- package/bundle/antd-mobile.umd.js +7 -7
- package/bundle/css-vars-patch.css +32 -0
- package/bundle/style.css +1 -1
- package/cjs/components/calendar-picker-view/calendar-picker-view.d.ts +1 -1
- package/cjs/components/calendar-picker-view/calendar-picker-view.js +31 -10
- package/cjs/components/card/card.css +1 -0
- package/cjs/components/card/card.d.ts +2 -1
- package/cjs/components/card/card.js +7 -3
- package/cjs/components/card/card.patch.css +6 -0
- package/cjs/components/date-picker/date-picker-quarter-utils.d.ts +7 -0
- package/cjs/components/date-picker/date-picker-quarter-utils.js +77 -0
- package/cjs/components/date-picker/date-picker-utils.d.ts +3 -2
- package/cjs/components/date-picker/date-picker-utils.js +7 -0
- package/cjs/components/ellipsis/ellipsis.css +1 -0
- package/cjs/components/ellipsis/ellipsis.d.ts +1 -1
- package/cjs/components/ellipsis/ellipsis.js +28 -124
- package/cjs/components/ellipsis/useMeasure.d.ts +2 -0
- package/cjs/components/ellipsis/useMeasure.js +108 -0
- package/cjs/components/ellipsis/~ellipsis.d.ts +15 -0
- package/cjs/components/ellipsis/~ellipsis.js +161 -0
- package/cjs/components/image-uploader/image-uploader.js +2 -2
- package/cjs/components/input/input.d.ts +2 -2
- package/cjs/components/input/input.js +1 -0
- package/cjs/components/notice-bar/notice-bar.css +25 -4
- package/cjs/components/notice-bar/notice-bar.d.ts +5 -1
- package/cjs/components/notice-bar/notice-bar.js +7 -3
- package/cjs/components/search-bar/search-bar.d.ts +2 -2
- package/cjs/components/search-bar/search-bar.js +1 -0
- package/cjs/components/segmented/index.d.ts +4 -0
- package/cjs/components/segmented/index.js +10 -0
- package/cjs/components/segmented/segmented.css +97 -0
- package/cjs/components/segmented/segmented.d.ts +21 -0
- package/cjs/components/segmented/segmented.js +57 -0
- package/cjs/components/segmented/segmented.patch.css +32 -0
- package/cjs/components/tab-bar/tab-bar.d.ts +1 -0
- package/cjs/components/tab-bar/tab-bar.js +2 -0
- package/cjs/components/tabs/tabs.js +1 -1
- package/cjs/components/toast/methods.js +9 -3
- package/cjs/global/css-vars-patch.css +32 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +7 -0
- package/cjs/locales/cnr-ME.d.ts +139 -0
- package/cjs/locales/cnr-ME.js +149 -0
- package/cjs/locales/hr-HR.d.ts +139 -0
- package/cjs/locales/hr-HR.js +149 -0
- package/cjs/locales/kk-KZ.js +6 -6
- package/cjs/locales/sr-RS.d.ts +139 -0
- package/cjs/locales/sr-RS.js +149 -0
- package/cjs/utils/render-imperatively.d.ts +1 -0
- package/cjs/utils/render-imperatively.js +6 -3
- package/es/components/calendar-picker-view/calendar-picker-view.d.ts +1 -1
- package/es/components/calendar-picker-view/calendar-picker-view.js +32 -11
- package/es/components/card/card.css +1 -0
- package/es/components/card/card.d.ts +2 -1
- package/es/components/card/card.js +7 -3
- package/es/components/card/card.patch.css +6 -0
- package/es/components/date-picker/date-picker-quarter-utils.d.ts +7 -0
- package/es/components/date-picker/date-picker-quarter-utils.js +68 -0
- package/es/components/date-picker/date-picker-utils.d.ts +3 -2
- package/es/components/date-picker/date-picker-utils.js +7 -0
- package/es/components/ellipsis/ellipsis.css +1 -0
- package/es/components/ellipsis/ellipsis.d.ts +1 -1
- package/es/components/ellipsis/ellipsis.js +28 -122
- package/es/components/ellipsis/useMeasure.d.ts +2 -0
- package/es/components/ellipsis/useMeasure.js +101 -0
- package/es/components/ellipsis/~ellipsis.d.ts +15 -0
- package/es/components/ellipsis/~ellipsis.js +151 -0
- package/es/components/image-uploader/image-uploader.js +2 -2
- package/es/components/input/input.d.ts +2 -2
- package/es/components/input/input.js +1 -0
- package/es/components/notice-bar/notice-bar.css +25 -4
- package/es/components/notice-bar/notice-bar.d.ts +5 -1
- package/es/components/notice-bar/notice-bar.js +7 -3
- package/es/components/search-bar/search-bar.d.ts +2 -2
- package/es/components/search-bar/search-bar.js +1 -0
- package/es/components/segmented/index.d.ts +4 -0
- package/es/components/segmented/index.js +3 -0
- package/es/components/segmented/segmented.css +97 -0
- package/es/components/segmented/segmented.d.ts +21 -0
- package/es/components/segmented/segmented.js +48 -0
- package/es/components/segmented/segmented.patch.css +32 -0
- package/es/components/tab-bar/tab-bar.d.ts +1 -0
- package/es/components/tab-bar/tab-bar.js +2 -0
- package/es/components/tabs/tabs.js +1 -1
- package/es/components/toast/methods.js +9 -3
- package/es/global/css-vars-patch.css +32 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/locales/cnr-ME.d.ts +139 -0
- package/es/locales/cnr-ME.js +142 -0
- package/es/locales/hr-HR.d.ts +139 -0
- package/es/locales/hr-HR.js +142 -0
- package/es/locales/kk-KZ.js +6 -6
- package/es/locales/sr-RS.d.ts +139 -0
- package/es/locales/sr-RS.js +142 -0
- package/es/utils/render-imperatively.d.ts +1 -0
- package/es/utils/render-imperatively.js +6 -3
- package/package.json +3 -2
- package/umd/antd-mobile.js +1 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import runes from 'runes2';
|
|
3
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
3
|
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
6
|
-
import {
|
|
4
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
7
5
|
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
6
|
+
import useMeasure from './useMeasure';
|
|
8
7
|
const classPrefix = `adm-ellipsis`;
|
|
9
8
|
const defaultProps = {
|
|
10
9
|
direction: 'end',
|
|
@@ -18,134 +17,41 @@ const defaultProps = {
|
|
|
18
17
|
};
|
|
19
18
|
export const Ellipsis = p => {
|
|
20
19
|
const props = mergeProps(defaultProps, p);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
root.style.display = 'block';
|
|
37
|
-
const originStyle = window.getComputedStyle(root);
|
|
38
|
-
const container = document.createElement('div');
|
|
39
|
-
const styleNames = Array.prototype.slice.apply(originStyle);
|
|
40
|
-
styleNames.forEach(name => {
|
|
41
|
-
container.style.setProperty(name, originStyle.getPropertyValue(name));
|
|
42
|
-
});
|
|
43
|
-
root.style.display = originDisplay;
|
|
44
|
-
container.style.height = 'auto';
|
|
45
|
-
container.style.minHeight = 'auto';
|
|
46
|
-
container.style.maxHeight = 'auto';
|
|
47
|
-
container.style.textOverflow = 'clip';
|
|
48
|
-
container.style.webkitLineClamp = 'unset';
|
|
49
|
-
container.style.display = 'block';
|
|
50
|
-
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
51
|
-
const maxHeight = Math.floor(lineHeight * (props.rows + 0.5) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));
|
|
52
|
-
container.innerText = props.content;
|
|
53
|
-
document.body.appendChild(container);
|
|
54
|
-
if (container.offsetHeight <= maxHeight) {
|
|
55
|
-
setExceeded(false);
|
|
56
|
-
} else {
|
|
57
|
-
setExceeded(true);
|
|
58
|
-
const end = props.content.length;
|
|
59
|
-
const collapseEl = typeof props.collapseText === 'string' ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
60
|
-
const expandEl = typeof props.expandText === 'string' ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
|
|
61
|
-
const actionText = expanded ? collapseEl : expandEl;
|
|
62
|
-
function check(left, right) {
|
|
63
|
-
if (right - left <= 1) {
|
|
64
|
-
if (props.direction === 'end') {
|
|
65
|
-
return {
|
|
66
|
-
leading: getSubString(0, left) + '...'
|
|
67
|
-
};
|
|
68
|
-
} else {
|
|
69
|
-
return {
|
|
70
|
-
tailing: '...' + getSubString(right, end)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const middle = Math.round((left + right) / 2);
|
|
75
|
-
if (props.direction === 'end') {
|
|
76
|
-
container.innerHTML = getSubString(0, middle) + '...' + actionText;
|
|
77
|
-
} else {
|
|
78
|
-
container.innerHTML = actionText + '...' + getSubString(middle, end);
|
|
79
|
-
}
|
|
80
|
-
if (container.offsetHeight <= maxHeight) {
|
|
81
|
-
if (props.direction === 'end') {
|
|
82
|
-
return check(middle, right);
|
|
83
|
-
} else {
|
|
84
|
-
return check(left, middle);
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
if (props.direction === 'end') {
|
|
88
|
-
return check(left, middle);
|
|
89
|
-
} else {
|
|
90
|
-
return check(middle, right);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function checkMiddle(leftPart, rightPart) {
|
|
95
|
-
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
|
96
|
-
return {
|
|
97
|
-
leading: getSubString(0, leftPart[0]) + '...',
|
|
98
|
-
tailing: '...' + getSubString(rightPart[1], end)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
|
102
|
-
const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
|
103
|
-
container.innerHTML = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
|
|
104
|
-
if (container.offsetHeight <= maxHeight) {
|
|
105
|
-
return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
|
106
|
-
} else {
|
|
107
|
-
return checkMiddle([leftPart[0], leftPartMiddle], [rightPartMiddle, rightPart[1]]);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
const middle = Math.floor((0 + end) / 2);
|
|
111
|
-
const ellipsised = props.direction === 'middle' ? checkMiddle([0, middle], [middle, end]) : check(0, end);
|
|
112
|
-
setEllipsised(ellipsised);
|
|
113
|
-
}
|
|
114
|
-
document.body.removeChild(container);
|
|
115
|
-
}
|
|
116
|
-
useResizeEffect(calcEllipsised, rootRef);
|
|
117
|
-
useIsomorphicLayoutEffect(() => {
|
|
118
|
-
calcEllipsised();
|
|
119
|
-
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
120
|
-
const expandActionElement = !!props.expandText && withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
|
|
121
|
-
ref: expandElRef,
|
|
20
|
+
const {
|
|
21
|
+
content,
|
|
22
|
+
direction,
|
|
23
|
+
rows,
|
|
24
|
+
expandText,
|
|
25
|
+
collapseText,
|
|
26
|
+
stopPropagationForActionButtons,
|
|
27
|
+
onContentClick,
|
|
28
|
+
defaultExpanded
|
|
29
|
+
} = props;
|
|
30
|
+
// ============================ Refs ============================
|
|
31
|
+
const rootRef = React.useRef(null);
|
|
32
|
+
// ========================== Expanded ==========================
|
|
33
|
+
const [expanded, setExpanded] = React.useState(defaultExpanded);
|
|
34
|
+
const expandNode = expandText ? withStopPropagation(stopPropagationForActionButtons, React.createElement("a", {
|
|
122
35
|
onClick: () => {
|
|
123
36
|
setExpanded(true);
|
|
124
37
|
}
|
|
125
|
-
},
|
|
126
|
-
const
|
|
127
|
-
ref: collapseElRef,
|
|
38
|
+
}, expandText)) : null;
|
|
39
|
+
const collapseNode = collapseText ? withStopPropagation(stopPropagationForActionButtons, React.createElement("a", {
|
|
128
40
|
onClick: () => {
|
|
129
41
|
setExpanded(false);
|
|
130
42
|
}
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
43
|
+
}, collapseText)) : null;
|
|
44
|
+
// ========================== Ellipsis ==========================
|
|
45
|
+
const [measureNodes, forceResize] = useMeasure(rootRef, content, rows, direction, expanded, expandNode, collapseNode);
|
|
46
|
+
useResizeEffect(forceResize, rootRef);
|
|
47
|
+
// =========================== Render ===========================
|
|
137
48
|
return withNativeProps(props, React.createElement("div", {
|
|
138
49
|
ref: rootRef,
|
|
139
50
|
className: classPrefix,
|
|
140
51
|
onClick: e => {
|
|
141
52
|
if (e.target === e.currentTarget) {
|
|
142
|
-
|
|
53
|
+
onContentClick(e);
|
|
143
54
|
}
|
|
144
55
|
}
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
function pxToNumber(value) {
|
|
148
|
-
if (!value) return 0;
|
|
149
|
-
const match = value.match(/^\d*(\.\d*)?/);
|
|
150
|
-
return match ? Number(match[0]) : 0;
|
|
151
|
-
}
|
|
56
|
+
}, measureNodes));
|
|
57
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default function useMeasure(containerRef: React.RefObject<HTMLDivElement>, content: string, rows: number, direction: 'start' | 'end' | 'middle', expanded: boolean, expandNode: React.ReactElement | null, collapseNode: React.ReactElement | null): readonly [React.JSX.Element, () => void];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useEvent } from 'rc-util';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import runes from 'runes2';
|
|
4
|
+
const ELLIPSIS_TEXT = '...';
|
|
5
|
+
const measureStyle = {
|
|
6
|
+
visibility: 'hidden',
|
|
7
|
+
whiteSpace: 'inherit',
|
|
8
|
+
lineHeight: 'inherit',
|
|
9
|
+
fontSize: 'inherit'
|
|
10
|
+
};
|
|
11
|
+
export default function useMeasure(containerRef, content, rows, direction, expanded, expandNode, collapseNode) {
|
|
12
|
+
const contentChars = React.useMemo(() => runes(content), [content]);
|
|
13
|
+
const [maxHeight, setMaxHeight] = React.useState(0);
|
|
14
|
+
const [walkingIndexes, setWalkingIndexes] = React.useState([0, 0]);
|
|
15
|
+
const midIndex = Math.ceil((walkingIndexes[0] + walkingIndexes[1]) / 2);
|
|
16
|
+
const [status, setStatus] = React.useState(100 /* STABLE_NO_ELLIPSIS */);
|
|
17
|
+
// ============================ Refs ============================
|
|
18
|
+
const singleRowMeasureRef = React.useRef(null);
|
|
19
|
+
const fullMeasureRef = React.useRef(null);
|
|
20
|
+
const midMeasureRef = React.useRef(null);
|
|
21
|
+
const startMeasure = useEvent(() => {
|
|
22
|
+
setStatus(1 /* PREPARE */);
|
|
23
|
+
setWalkingIndexes([0, direction === 'middle' ? Math.ceil(contentChars.length / 2) : contentChars.length]);
|
|
24
|
+
});
|
|
25
|
+
// Initialize
|
|
26
|
+
React.useLayoutEffect(() => {
|
|
27
|
+
startMeasure();
|
|
28
|
+
}, [contentChars, rows]);
|
|
29
|
+
// Measure element height
|
|
30
|
+
React.useLayoutEffect(() => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if (status === 1 /* PREPARE */) {
|
|
33
|
+
const fullMeasureHeight = ((_a = fullMeasureRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
|
|
34
|
+
const singleRowMeasureHeight = ((_b = singleRowMeasureRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0;
|
|
35
|
+
const rowMeasureHeight = singleRowMeasureHeight * rows;
|
|
36
|
+
if (fullMeasureHeight <= rowMeasureHeight) {
|
|
37
|
+
setStatus(100 /* STABLE_NO_ELLIPSIS */);
|
|
38
|
+
} else {
|
|
39
|
+
setMaxHeight(rowMeasureHeight);
|
|
40
|
+
setStatus(2 /* MEASURE_WALKING */);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}, [status]);
|
|
44
|
+
// Walking measure
|
|
45
|
+
React.useLayoutEffect(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (status === 2 /* MEASURE_WALKING */) {
|
|
48
|
+
const diff = walkingIndexes[1] - walkingIndexes[0];
|
|
49
|
+
const midHeight = ((_a = midMeasureRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
|
|
50
|
+
if (diff > 1) {
|
|
51
|
+
if (midHeight > maxHeight) {
|
|
52
|
+
setWalkingIndexes([walkingIndexes[0], midIndex]);
|
|
53
|
+
} else {
|
|
54
|
+
setWalkingIndexes([midIndex, walkingIndexes[1]]);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
if (midHeight > maxHeight) {
|
|
58
|
+
setWalkingIndexes([walkingIndexes[0], walkingIndexes[0]]);
|
|
59
|
+
} else {
|
|
60
|
+
setWalkingIndexes([walkingIndexes[1], walkingIndexes[1]]);
|
|
61
|
+
}
|
|
62
|
+
setStatus(99 /* STABLE_ELLIPSIS */);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [status, walkingIndexes]);
|
|
66
|
+
// =========================== Render ===========================
|
|
67
|
+
/** Render by cut index */
|
|
68
|
+
const renderContent = index => {
|
|
69
|
+
const prefixContent = contentChars.slice(0, index);
|
|
70
|
+
const suffixContent = contentChars.slice(contentChars.length - index);
|
|
71
|
+
return React.createElement(React.Fragment, null, direction === 'start' && React.createElement(React.Fragment, null, expandNode, ELLIPSIS_TEXT), direction !== 'start' && prefixContent.join(''), direction === 'middle' && React.createElement(React.Fragment, null, ELLIPSIS_TEXT, expandNode, ELLIPSIS_TEXT), direction !== 'end' && suffixContent.join(''), direction === 'end' && React.createElement(React.Fragment, null, ELLIPSIS_TEXT, expandNode));
|
|
72
|
+
};
|
|
73
|
+
const finalContent = React.useMemo(() => {
|
|
74
|
+
if (expanded || status === 100 /* STABLE_NO_ELLIPSIS */) {
|
|
75
|
+
return React.createElement(React.Fragment, {
|
|
76
|
+
key: 'display'
|
|
77
|
+
}, content, status === 99 /* STABLE_ELLIPSIS */ && collapseNode);
|
|
78
|
+
}
|
|
79
|
+
if (status === 99 /* STABLE_ELLIPSIS */) {
|
|
80
|
+
return renderContent(midIndex);
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}, [expanded, status, content, collapseNode, midIndex]);
|
|
84
|
+
const allNodes = React.createElement(React.Fragment, null, status === 1 /* PREPARE */ && React.createElement("div", {
|
|
85
|
+
key: 'full',
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
ref: fullMeasureRef,
|
|
88
|
+
style: measureStyle
|
|
89
|
+
}, content, expandNode), status === 1 /* PREPARE */ && React.createElement("div", {
|
|
90
|
+
key: 'stable',
|
|
91
|
+
"aria-hidden": true,
|
|
92
|
+
ref: singleRowMeasureRef,
|
|
93
|
+
style: measureStyle
|
|
94
|
+
}, '\u00A0'), status === 2 /* MEASURE_WALKING */ && React.createElement("div", {
|
|
95
|
+
key: 'walking-mid',
|
|
96
|
+
"aria-hidden": true,
|
|
97
|
+
ref: midMeasureRef,
|
|
98
|
+
style: measureStyle
|
|
99
|
+
}, renderContent(midIndex)), finalContent);
|
|
100
|
+
return [allNodes, startMeasure];
|
|
101
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FC, ReactNode } from 'react';
|
|
3
|
+
import { NativeProps } from '../../utils/native-props';
|
|
4
|
+
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
5
|
+
export declare type EllipsisProps = {
|
|
6
|
+
content: string;
|
|
7
|
+
direction?: 'start' | 'end' | 'middle';
|
|
8
|
+
rows?: number;
|
|
9
|
+
expandText?: ReactNode;
|
|
10
|
+
collapseText?: ReactNode;
|
|
11
|
+
stopPropagationForActionButtons?: PropagationEvent[];
|
|
12
|
+
onContentClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
13
|
+
defaultExpanded?: boolean;
|
|
14
|
+
} & NativeProps;
|
|
15
|
+
export declare const Ellipsis: FC<EllipsisProps>;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import runes from 'runes2';
|
|
3
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
5
|
+
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
6
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
7
|
+
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
8
|
+
const classPrefix = `adm-ellipsis`;
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
direction: 'end',
|
|
11
|
+
rows: 1,
|
|
12
|
+
expandText: '',
|
|
13
|
+
content: '',
|
|
14
|
+
collapseText: '',
|
|
15
|
+
stopPropagationForActionButtons: [],
|
|
16
|
+
onContentClick: () => {},
|
|
17
|
+
defaultExpanded: false
|
|
18
|
+
};
|
|
19
|
+
export const Ellipsis = p => {
|
|
20
|
+
const props = mergeProps(defaultProps, p);
|
|
21
|
+
const rootRef = useRef(null);
|
|
22
|
+
const expandElRef = useRef(null);
|
|
23
|
+
const collapseElRef = useRef(null);
|
|
24
|
+
const [ellipsised, setEllipsised] = useState({});
|
|
25
|
+
const [expanded, setExpanded] = useState(props.defaultExpanded);
|
|
26
|
+
const [exceeded, setExceeded] = useState(false);
|
|
27
|
+
const chars = useMemo(() => runes(props.content), [props.content]);
|
|
28
|
+
function getSubString(start, end) {
|
|
29
|
+
return chars.slice(start, end).join('');
|
|
30
|
+
}
|
|
31
|
+
function calcEllipsised() {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const root = rootRef.current;
|
|
34
|
+
if (!root) return;
|
|
35
|
+
const originDisplay = root.style.display;
|
|
36
|
+
root.style.display = 'block';
|
|
37
|
+
const originStyle = window.getComputedStyle(root);
|
|
38
|
+
const container = document.createElement('div');
|
|
39
|
+
const styleNames = Array.prototype.slice.apply(originStyle);
|
|
40
|
+
styleNames.forEach(name => {
|
|
41
|
+
container.style.setProperty(name, originStyle.getPropertyValue(name));
|
|
42
|
+
});
|
|
43
|
+
root.style.display = originDisplay;
|
|
44
|
+
container.style.height = 'auto';
|
|
45
|
+
container.style.minHeight = 'auto';
|
|
46
|
+
container.style.maxHeight = 'auto';
|
|
47
|
+
container.style.textOverflow = 'clip';
|
|
48
|
+
container.style.webkitLineClamp = 'unset';
|
|
49
|
+
container.style.display = 'block';
|
|
50
|
+
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
51
|
+
const maxHeight = Math.floor(lineHeight * (props.rows + 0.5) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom));
|
|
52
|
+
container.innerText = props.content;
|
|
53
|
+
document.body.appendChild(container);
|
|
54
|
+
if (container.offsetHeight <= maxHeight) {
|
|
55
|
+
setExceeded(false);
|
|
56
|
+
} else {
|
|
57
|
+
setExceeded(true);
|
|
58
|
+
const end = props.content.length;
|
|
59
|
+
const collapseEl = typeof props.collapseText === 'string' ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
60
|
+
const expandEl = typeof props.expandText === 'string' ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
|
|
61
|
+
const actionText = expanded ? collapseEl : expandEl;
|
|
62
|
+
function check(left, right) {
|
|
63
|
+
if (right - left <= 1) {
|
|
64
|
+
if (props.direction === 'end') {
|
|
65
|
+
return {
|
|
66
|
+
leading: getSubString(0, left) + '...'
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
return {
|
|
70
|
+
tailing: '...' + getSubString(right, end)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const middle = Math.round((left + right) / 2);
|
|
75
|
+
if (props.direction === 'end') {
|
|
76
|
+
container.innerHTML = getSubString(0, middle) + '...' + actionText;
|
|
77
|
+
} else {
|
|
78
|
+
container.innerHTML = actionText + '...' + getSubString(middle, end);
|
|
79
|
+
}
|
|
80
|
+
if (container.offsetHeight <= maxHeight) {
|
|
81
|
+
if (props.direction === 'end') {
|
|
82
|
+
return check(middle, right);
|
|
83
|
+
} else {
|
|
84
|
+
return check(left, middle);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
if (props.direction === 'end') {
|
|
88
|
+
return check(left, middle);
|
|
89
|
+
} else {
|
|
90
|
+
return check(middle, right);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function checkMiddle(leftPart, rightPart) {
|
|
95
|
+
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
|
96
|
+
return {
|
|
97
|
+
leading: getSubString(0, leftPart[0]) + '...',
|
|
98
|
+
tailing: '...' + getSubString(rightPart[1], end)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
|
102
|
+
const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
|
103
|
+
container.innerHTML = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
|
|
104
|
+
if (container.offsetHeight <= maxHeight) {
|
|
105
|
+
return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
|
106
|
+
} else {
|
|
107
|
+
return checkMiddle([leftPart[0], leftPartMiddle], [rightPartMiddle, rightPart[1]]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const middle = Math.floor((0 + end) / 2);
|
|
111
|
+
const ellipsised = props.direction === 'middle' ? checkMiddle([0, middle], [middle, end]) : check(0, end);
|
|
112
|
+
setEllipsised(ellipsised);
|
|
113
|
+
}
|
|
114
|
+
document.body.removeChild(container);
|
|
115
|
+
}
|
|
116
|
+
useResizeEffect(calcEllipsised, rootRef);
|
|
117
|
+
useIsomorphicLayoutEffect(() => {
|
|
118
|
+
calcEllipsised();
|
|
119
|
+
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
120
|
+
const expandActionElement = !!props.expandText && withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
|
|
121
|
+
ref: expandElRef,
|
|
122
|
+
onClick: () => {
|
|
123
|
+
setExpanded(true);
|
|
124
|
+
}
|
|
125
|
+
}, props.expandText));
|
|
126
|
+
const collapseActionElement = !!props.collapseText && withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
|
|
127
|
+
ref: collapseElRef,
|
|
128
|
+
onClick: () => {
|
|
129
|
+
setExpanded(false);
|
|
130
|
+
}
|
|
131
|
+
}, props.collapseText));
|
|
132
|
+
const renderContent = () => {
|
|
133
|
+
if (!exceeded) return props.content;
|
|
134
|
+
if (expanded) return React.createElement(React.Fragment, null, props.content, collapseActionElement);
|
|
135
|
+
return React.createElement(React.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
|
|
136
|
+
};
|
|
137
|
+
return withNativeProps(props, React.createElement("div", {
|
|
138
|
+
ref: rootRef,
|
|
139
|
+
className: classPrefix,
|
|
140
|
+
onClick: e => {
|
|
141
|
+
if (e.target === e.currentTarget) {
|
|
142
|
+
props.onContentClick(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, renderContent()));
|
|
146
|
+
};
|
|
147
|
+
function pxToNumber(value) {
|
|
148
|
+
if (!value) return 0;
|
|
149
|
+
const match = value.match(/^\d*(\.\d*)?/);
|
|
150
|
+
return match ? Number(match[0]) : 0;
|
|
151
|
+
}
|
|
@@ -218,14 +218,14 @@ export const ImageUploader = forwardRef((p, ref) => {
|
|
|
218
218
|
}, React.createElement("span", {
|
|
219
219
|
className: `${classPrefix}-upload-button-icon`
|
|
220
220
|
}, React.createElement(AddOutline, null))), !props.disableUpload && React.createElement("input", {
|
|
221
|
+
"aria-label": locale.ImageUploader.upload,
|
|
221
222
|
ref: inputRef,
|
|
222
223
|
capture: props.capture,
|
|
223
224
|
accept: props.accept,
|
|
224
225
|
multiple: props.multiple,
|
|
225
226
|
type: 'file',
|
|
226
227
|
className: `${classPrefix}-input`,
|
|
227
|
-
onChange: onChange
|
|
228
|
-
"aria-hidden": true
|
|
228
|
+
onChange: onChange
|
|
229
229
|
})));
|
|
230
230
|
useImperativeHandle(ref, () => ({
|
|
231
231
|
get nativeElement() {
|
|
@@ -4,7 +4,7 @@ declare type NativeInputProps = React.DetailedHTMLProps<React.InputHTMLAttribute
|
|
|
4
4
|
declare type AriaProps = {
|
|
5
5
|
role?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id' | 'placeholder' | 'readOnly' | 'disabled' | 'enterKeyHint'> & {
|
|
7
|
+
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'onPaste' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id' | 'placeholder' | 'readOnly' | 'disabled' | 'enterKeyHint'> & {
|
|
8
8
|
value?: string;
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
onChange?: (val: string) => void;
|
|
@@ -22,7 +22,7 @@ export declare type InputRef = {
|
|
|
22
22
|
blur: () => void;
|
|
23
23
|
nativeElement: HTMLInputElement | null;
|
|
24
24
|
};
|
|
25
|
-
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "placeholder" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "readOnly" | "autoComplete" | "enterKeyHint" | "maxLength" | "minLength"> & {
|
|
25
|
+
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "placeholder" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "readOnly" | "autoComplete" | "enterKeyHint" | "maxLength" | "minLength"> & {
|
|
26
26
|
value?: string | undefined;
|
|
27
27
|
defaultValue?: string | undefined;
|
|
28
28
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -87,6 +87,7 @@ export const Input = forwardRef((props, ref) => {
|
|
|
87
87
|
checkValue();
|
|
88
88
|
(_a = mergedProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
89
89
|
},
|
|
90
|
+
onPaste: mergedProps.onPaste,
|
|
90
91
|
id: mergedProps.id,
|
|
91
92
|
placeholder: mergedProps.placeholder,
|
|
92
93
|
disabled: mergedProps.disabled,
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
--font-size: var(--adm-font-size-7);
|
|
6
6
|
--icon-font-size: var(--adm-font-size-10);
|
|
7
7
|
--height: 40px;
|
|
8
|
+
--adm-notice-bar-border-radius: 4px;
|
|
9
|
+
--adm-notice-bar-border-width: 1px;
|
|
8
10
|
height: var(--height);
|
|
9
11
|
box-sizing: border-box;
|
|
10
12
|
font-size: var(--font-size);
|
|
@@ -12,9 +14,9 @@
|
|
|
12
14
|
display: flex;
|
|
13
15
|
align-items: center;
|
|
14
16
|
justify-content: space-between;
|
|
15
|
-
border: solid
|
|
16
|
-
border-left:
|
|
17
|
-
border-right:
|
|
17
|
+
border: solid var(--adm-notice-bar-border-width) var(--border-color);
|
|
18
|
+
border-left-width: 0;
|
|
19
|
+
border-right-width: 0;
|
|
18
20
|
background-color: var(--background-color);
|
|
19
21
|
color: var(--text-color);
|
|
20
22
|
}
|
|
@@ -29,13 +31,18 @@
|
|
|
29
31
|
.adm-notice-bar.adm-notice-bar-error {
|
|
30
32
|
--background-color: var(--adm-color-danger);
|
|
31
33
|
--border-color: #d9281e;
|
|
32
|
-
--text-color: #
|
|
34
|
+
--text-color: #fff;
|
|
33
35
|
}
|
|
34
36
|
.adm-notice-bar.adm-notice-bar-info {
|
|
35
37
|
--background-color: #d0e4ff;
|
|
36
38
|
--border-color: #bcd8ff;
|
|
37
39
|
--text-color: var(--adm-color-primary);
|
|
38
40
|
}
|
|
41
|
+
.adm-notice-bar.adm-notice-bar-success {
|
|
42
|
+
--background-color: #d1fff0;
|
|
43
|
+
--border-color: #a8f0d8;
|
|
44
|
+
--text-color: var(--adm-color-success);
|
|
45
|
+
}
|
|
39
46
|
.adm-notice-bar .adm-notice-bar-left {
|
|
40
47
|
flex-shrink: 0;
|
|
41
48
|
margin-right: 8px;
|
|
@@ -79,3 +86,17 @@
|
|
|
79
86
|
padding-bottom: 8px;
|
|
80
87
|
line-height: 22px;
|
|
81
88
|
}
|
|
89
|
+
.adm-notice-bar-neutral {
|
|
90
|
+
border-radius: var(--adm-notice-bar-border-radius);
|
|
91
|
+
}
|
|
92
|
+
.adm-notice-bar-rounded {
|
|
93
|
+
border-radius: 1000px;
|
|
94
|
+
}
|
|
95
|
+
.adm-notice-bar-bordered {
|
|
96
|
+
border-left-width: var(--adm-notice-bar-border-width);
|
|
97
|
+
border-right-width: var(--adm-notice-bar-border-width);
|
|
98
|
+
}
|
|
99
|
+
.adm-notice-bar-without-border {
|
|
100
|
+
border-top-width: 0;
|
|
101
|
+
border-bottom-width: 0;
|
|
102
|
+
}
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
export declare type NoticeBarProps = {
|
|
5
5
|
/** The type of the NoticeBar */
|
|
6
|
-
color?: 'default' | 'alert' | 'error' | 'info';
|
|
6
|
+
color?: 'default' | 'alert' | 'error' | 'success' | 'info';
|
|
7
7
|
/** TDelay to start scrolling, unit ms */
|
|
8
8
|
delay?: number;
|
|
9
9
|
/** Scroll speed, unit px/s */
|
|
@@ -24,5 +24,9 @@ export declare type NoticeBarProps = {
|
|
|
24
24
|
icon?: ReactNode;
|
|
25
25
|
/** Whether to display multiple lines */
|
|
26
26
|
wrap?: boolean;
|
|
27
|
+
/** Block shape */
|
|
28
|
+
shape?: 'rectangular' | 'neutral' | 'rounded';
|
|
29
|
+
/** Border visibility */
|
|
30
|
+
bordered?: 'block' | boolean;
|
|
27
31
|
} & NativeProps<'--background-color' | '--border-color' | '--text-color' | '--font-size' | '--icon-font-size' | '--height'>;
|
|
28
32
|
export declare const NoticeBar: React.NamedExoticComponent<NoticeBarProps>;
|
|
@@ -13,7 +13,9 @@ const defaultProps = {
|
|
|
13
13
|
delay: 2000,
|
|
14
14
|
speed: 50,
|
|
15
15
|
icon: React.createElement(SoundOutline, null),
|
|
16
|
-
wrap: false
|
|
16
|
+
wrap: false,
|
|
17
|
+
shape: 'rectangular',
|
|
18
|
+
bordered: 'block'
|
|
17
19
|
};
|
|
18
20
|
export const NoticeBar = memo(props => {
|
|
19
21
|
const {
|
|
@@ -69,8 +71,10 @@ export const NoticeBar = memo(props => {
|
|
|
69
71
|
});
|
|
70
72
|
if (!visible) return null;
|
|
71
73
|
return withNativeProps(mergedProps, React.createElement("div", {
|
|
72
|
-
className: classNames(classPrefix, `${classPrefix}-${mergedProps.color}`, {
|
|
73
|
-
[`${classPrefix}-wrap`]: mergedProps.wrap
|
|
74
|
+
className: classNames(classPrefix, `${classPrefix}-${mergedProps.color}`, `${classPrefix}-${mergedProps.shape}`, {
|
|
75
|
+
[`${classPrefix}-wrap`]: mergedProps.wrap,
|
|
76
|
+
[`${classPrefix}-bordered`]: mergedProps.bordered === true,
|
|
77
|
+
[`${classPrefix}-without-border`]: mergedProps.bordered === false
|
|
74
78
|
}),
|
|
75
79
|
onClick: mergedProps.onClick
|
|
76
80
|
}, mergedProps.icon && React.createElement("span", {
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
import { InputProps, InputRef } from '../input';
|
|
5
5
|
export declare type SearchBarRef = InputRef;
|
|
6
|
-
export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'onClear' | 'onCompositionStart' | 'onCompositionEnd'> & {
|
|
6
|
+
export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'onClear' | 'onCompositionStart' | 'onCompositionEnd' | 'autoFocus'> & {
|
|
7
7
|
value?: string;
|
|
8
8
|
defaultValue?: string;
|
|
9
9
|
maxLength?: number;
|
|
@@ -22,7 +22,7 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
|
|
|
22
22
|
onChange?: (val: string) => void;
|
|
23
23
|
onCancel?: () => void;
|
|
24
24
|
} & NativeProps<'--background' | '--border-radius' | '--placeholder-color' | '--height' | '--padding-left'>;
|
|
25
|
-
export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps, "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onClear"> & {
|
|
25
|
+
export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps, "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoFocus" | "onClear"> & {
|
|
26
26
|
value?: string | undefined;
|
|
27
27
|
defaultValue?: string | undefined;
|
|
28
28
|
maxLength?: number | undefined;
|
|
@@ -87,6 +87,7 @@ export const SearchBar = forwardRef((props, ref) => {
|
|
|
87
87
|
value: value,
|
|
88
88
|
onChange: setValue,
|
|
89
89
|
maxLength: mergedProps.maxLength,
|
|
90
|
+
autoFocus: mergedProps.autoFocus,
|
|
90
91
|
placeholder: mergedProps.placeholder,
|
|
91
92
|
clearable: mergedProps.clearable,
|
|
92
93
|
onlyShowClearWhenFocus: mergedProps.onlyShowClearWhenFocus,
|