@arco-design/mobile-react 2.20.0 → 2.21.0
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/CHANGELOG.md +30 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/avatar/index.d.ts +1 -1
- package/cjs/avatar/index.js +1 -1
- package/cjs/badge/index.d.ts +1 -1
- package/cjs/badge/index.js +1 -1
- package/cjs/carousel/index.d.ts +1 -1
- package/cjs/carousel/index.js +1 -1
- package/cjs/cell/index.d.ts +1 -1
- package/cjs/cell/index.js +1 -1
- package/cjs/checkbox/index.d.ts +1 -1
- package/cjs/checkbox/index.js +1 -1
- package/cjs/collapse/index.d.ts +1 -1
- package/cjs/collapse/index.js +1 -1
- package/cjs/count-down/index.d.ts +1 -1
- package/cjs/count-down/index.js +1 -1
- package/cjs/date-picker/index.d.ts +1 -1
- package/cjs/date-picker/index.js +1 -1
- package/cjs/dropdown/dropdown.js +36 -20
- package/cjs/dropdown/style/css/index.css +3 -0
- package/cjs/dropdown/style/index.less +2 -0
- package/cjs/ellipsis/index.d.ts +1 -1
- package/cjs/ellipsis/index.js +1 -1
- package/cjs/image/index.d.ts +1 -1
- package/cjs/image/index.js +1 -1
- package/cjs/image-picker/index.d.ts +4 -175
- package/cjs/image-picker/index.js +41 -18
- package/cjs/image-picker/type.d.ts +174 -0
- package/cjs/image-picker/type.js +3 -0
- package/cjs/image-preview/index.d.ts +1 -1
- package/cjs/image-preview/index.js +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +9 -1
- package/cjs/input/hooks.js +49 -8
- package/cjs/input/index.d.ts +1 -1
- package/cjs/input/index.js +1 -1
- package/cjs/input/props.d.ts +8 -2
- package/cjs/notice-bar/index.d.ts +1 -1
- package/cjs/notice-bar/index.js +1 -1
- package/cjs/picker/index.d.ts +1 -1
- package/cjs/picker/index.js +1 -1
- package/cjs/picker-view/index.d.ts +1 -1
- package/cjs/picker-view/index.js +1 -1
- package/cjs/popover/index.d.ts +1 -1
- package/cjs/popover/index.js +1 -1
- package/cjs/popup-swiper/index.js +3 -2
- package/cjs/radio/index.d.ts +1 -1
- package/cjs/radio/index.js +1 -1
- package/cjs/rate/index.d.ts +1 -1
- package/cjs/rate/index.js +1 -1
- package/cjs/search-bar/association.d.ts +3 -0
- package/cjs/search-bar/association.js +92 -0
- package/cjs/search-bar/cancel-button.d.ts +10 -0
- package/cjs/search-bar/cancel-button.js +41 -0
- package/cjs/search-bar/demo/style/css/mobile.css +5 -0
- package/cjs/search-bar/demo/style/mobile.less +9 -0
- package/cjs/search-bar/highlight.d.ts +12 -0
- package/cjs/search-bar/highlight.js +77 -0
- package/cjs/search-bar/index.d.ts +13 -0
- package/cjs/search-bar/index.js +239 -0
- package/cjs/search-bar/style/css/index.css +148 -0
- package/cjs/search-bar/style/css/index.d.ts +2 -0
- package/cjs/search-bar/style/css/index.js +5 -0
- package/cjs/search-bar/style/index.d.ts +2 -0
- package/cjs/search-bar/style/index.js +5 -0
- package/cjs/search-bar/style/index.less +111 -0
- package/cjs/search-bar/type.d.ts +163 -0
- package/cjs/search-bar/type.js +3 -0
- package/cjs/slider/index.d.ts +1 -1
- package/cjs/slider/index.js +1 -1
- package/cjs/steps/index.d.ts +1 -1
- package/cjs/steps/index.js +1 -1
- package/cjs/sticky/index.d.ts +1 -1
- package/cjs/style.d.ts +2 -0
- package/cjs/style.js +4 -0
- package/cjs/swipe-action/demo/style/css/mobile.css +5 -0
- package/cjs/swipe-action/demo/style/mobile.less +9 -0
- package/cjs/swipe-action/index.d.ts +12 -0
- package/cjs/swipe-action/index.js +339 -0
- package/cjs/swipe-action/item.d.ts +11 -0
- package/cjs/swipe-action/item.js +52 -0
- package/cjs/swipe-action/style/css/index.css +88 -0
- package/cjs/swipe-action/style/css/index.d.ts +2 -0
- package/cjs/swipe-action/style/css/index.js +5 -0
- package/cjs/swipe-action/style/index.d.ts +2 -0
- package/cjs/swipe-action/style/index.js +5 -0
- package/cjs/swipe-action/style/index.less +89 -0
- package/cjs/swipe-action/type.d.ts +123 -0
- package/cjs/swipe-action/type.js +3 -0
- package/cjs/switch/index.d.ts +1 -1
- package/cjs/switch/index.js +1 -1
- package/cjs/tabs/tab-pane.js +5 -1
- package/cjs/tag/index.d.ts +1 -1
- package/cjs/tag/index.js +1 -1
- package/cjs/textarea/index.d.ts +1 -1
- package/cjs/textarea/index.js +1 -1
- package/dist/index.js +7450 -6611
- package/dist/index.min.js +6 -6
- package/dist/style.css +203 -0
- package/dist/style.min.css +1 -1
- package/esm/avatar/index.d.ts +1 -1
- package/esm/avatar/index.js +1 -1
- package/esm/badge/index.d.ts +1 -1
- package/esm/badge/index.js +1 -1
- package/esm/carousel/index.d.ts +1 -1
- package/esm/carousel/index.js +1 -1
- package/esm/cell/index.d.ts +1 -1
- package/esm/cell/index.js +1 -1
- package/esm/checkbox/index.d.ts +1 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/collapse/index.d.ts +1 -1
- package/esm/collapse/index.js +1 -1
- package/esm/count-down/index.d.ts +1 -1
- package/esm/count-down/index.js +1 -1
- package/esm/date-picker/index.d.ts +1 -1
- package/esm/date-picker/index.js +1 -1
- package/esm/dropdown/dropdown.js +36 -20
- package/esm/dropdown/style/css/index.css +3 -0
- package/esm/dropdown/style/index.less +2 -0
- package/esm/ellipsis/index.d.ts +1 -1
- package/esm/ellipsis/index.js +1 -1
- package/esm/image/index.d.ts +1 -1
- package/esm/image/index.js +1 -1
- package/esm/image-picker/index.d.ts +4 -175
- package/esm/image-picker/index.js +30 -17
- package/esm/image-picker/type.d.ts +174 -0
- package/esm/image-picker/type.js +1 -0
- package/esm/image-preview/index.d.ts +1 -1
- package/esm/image-preview/index.js +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/input/hooks.js +49 -8
- package/esm/input/index.d.ts +1 -1
- package/esm/input/index.js +1 -1
- package/esm/input/props.d.ts +8 -2
- package/esm/notice-bar/index.d.ts +1 -1
- package/esm/notice-bar/index.js +1 -1
- package/esm/picker/index.d.ts +1 -1
- package/esm/picker/index.js +1 -1
- package/esm/picker-view/index.d.ts +1 -1
- package/esm/picker-view/index.js +1 -1
- package/esm/popover/index.d.ts +1 -1
- package/esm/popover/index.js +1 -1
- package/esm/popup-swiper/index.js +3 -2
- package/esm/radio/index.d.ts +1 -1
- package/esm/radio/index.js +1 -1
- package/esm/rate/index.d.ts +1 -1
- package/esm/rate/index.js +1 -1
- package/esm/search-bar/association.d.ts +3 -0
- package/esm/search-bar/association.js +82 -0
- package/esm/search-bar/cancel-button.d.ts +10 -0
- package/esm/search-bar/cancel-button.js +30 -0
- package/esm/search-bar/demo/style/css/mobile.css +5 -0
- package/esm/search-bar/demo/style/mobile.less +9 -0
- package/esm/search-bar/highlight.d.ts +12 -0
- package/esm/search-bar/highlight.js +66 -0
- package/esm/search-bar/index.d.ts +13 -0
- package/esm/search-bar/index.js +213 -0
- package/esm/search-bar/style/css/index.css +148 -0
- package/esm/search-bar/style/css/index.d.ts +2 -0
- package/esm/search-bar/style/css/index.js +2 -0
- package/esm/search-bar/style/index.d.ts +2 -0
- package/esm/search-bar/style/index.js +2 -0
- package/esm/search-bar/style/index.less +111 -0
- package/esm/search-bar/type.d.ts +163 -0
- package/esm/search-bar/type.js +1 -0
- package/esm/slider/index.d.ts +1 -1
- package/esm/slider/index.js +1 -1
- package/esm/steps/index.d.ts +1 -1
- package/esm/steps/index.js +1 -1
- package/esm/sticky/index.d.ts +1 -1
- package/esm/style.d.ts +2 -0
- package/esm/style.js +2 -0
- package/esm/swipe-action/demo/style/css/mobile.css +5 -0
- package/esm/swipe-action/demo/style/mobile.less +9 -0
- package/esm/swipe-action/index.d.ts +12 -0
- package/esm/swipe-action/index.js +321 -0
- package/esm/swipe-action/item.d.ts +11 -0
- package/esm/swipe-action/item.js +42 -0
- package/esm/swipe-action/style/css/index.css +88 -0
- package/esm/swipe-action/style/css/index.d.ts +2 -0
- package/esm/swipe-action/style/css/index.js +2 -0
- package/esm/swipe-action/style/index.d.ts +2 -0
- package/esm/swipe-action/style/index.js +2 -0
- package/esm/swipe-action/style/index.less +89 -0
- package/esm/swipe-action/type.d.ts +123 -0
- package/esm/swipe-action/type.js +1 -0
- package/esm/switch/index.d.ts +1 -1
- package/esm/switch/index.js +1 -1
- package/esm/tabs/tab-pane.js +5 -1
- package/esm/tag/index.d.ts +1 -1
- package/esm/tag/index.js +1 -1
- package/esm/textarea/index.d.ts +1 -1
- package/esm/textarea/index.js +1 -1
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +34 -0
- package/tokens/app/arcodesign/default/index.d.ts +34 -0
- package/tokens/app/arcodesign/default/index.js +34 -0
- package/tokens/app/arcodesign/default/index.json +398 -0
- package/tokens/app/arcodesign/default/index.less +34 -0
- package/umd/avatar/index.d.ts +1 -1
- package/umd/avatar/index.js +1 -1
- package/umd/badge/index.d.ts +1 -1
- package/umd/badge/index.js +1 -1
- package/umd/carousel/index.d.ts +1 -1
- package/umd/carousel/index.js +1 -1
- package/umd/cell/index.d.ts +1 -1
- package/umd/cell/index.js +1 -1
- package/umd/checkbox/index.d.ts +1 -1
- package/umd/checkbox/index.js +1 -1
- package/umd/collapse/index.d.ts +1 -1
- package/umd/collapse/index.js +1 -1
- package/umd/count-down/index.d.ts +1 -1
- package/umd/count-down/index.js +1 -1
- package/umd/date-picker/index.d.ts +1 -1
- package/umd/date-picker/index.js +1 -1
- package/umd/dropdown/dropdown.js +36 -20
- package/umd/dropdown/style/css/index.css +3 -0
- package/umd/dropdown/style/index.less +2 -0
- package/umd/ellipsis/index.d.ts +1 -1
- package/umd/ellipsis/index.js +1 -1
- package/umd/image/index.d.ts +1 -1
- package/umd/image/index.js +1 -1
- package/umd/image-picker/index.d.ts +4 -175
- package/umd/image-picker/index.js +40 -22
- package/umd/image-picker/type.d.ts +174 -0
- package/umd/image-picker/type.js +17 -0
- package/umd/image-preview/index.d.ts +1 -1
- package/umd/image-preview/index.js +1 -1
- package/umd/index.d.ts +2 -0
- package/umd/index.js +9 -5
- package/umd/input/hooks.js +48 -7
- package/umd/input/index.d.ts +1 -1
- package/umd/input/index.js +1 -1
- package/umd/input/props.d.ts +8 -2
- package/umd/notice-bar/index.d.ts +1 -1
- package/umd/notice-bar/index.js +1 -1
- package/umd/picker/index.d.ts +1 -1
- package/umd/picker/index.js +1 -1
- package/umd/picker-view/index.d.ts +1 -1
- package/umd/picker-view/index.js +1 -1
- package/umd/popover/index.d.ts +1 -1
- package/umd/popover/index.js +1 -1
- package/umd/popup-swiper/index.js +3 -2
- package/umd/radio/index.d.ts +1 -1
- package/umd/radio/index.js +1 -1
- package/umd/rate/index.d.ts +1 -1
- package/umd/rate/index.js +1 -1
- package/umd/search-bar/association.d.ts +3 -0
- package/umd/search-bar/association.js +101 -0
- package/umd/search-bar/cancel-button.d.ts +10 -0
- package/umd/search-bar/cancel-button.js +52 -0
- package/umd/search-bar/demo/style/css/mobile.css +5 -0
- package/umd/search-bar/demo/style/mobile.less +9 -0
- package/umd/search-bar/highlight.d.ts +12 -0
- package/umd/search-bar/highlight.js +87 -0
- package/umd/search-bar/index.d.ts +13 -0
- package/umd/search-bar/index.js +235 -0
- package/umd/search-bar/style/css/index.css +148 -0
- package/umd/search-bar/style/css/index.d.ts +2 -0
- package/umd/search-bar/style/css/index.js +15 -0
- package/umd/search-bar/style/index.d.ts +2 -0
- package/umd/search-bar/style/index.js +15 -0
- package/umd/search-bar/style/index.less +111 -0
- package/umd/search-bar/type.d.ts +163 -0
- package/umd/search-bar/type.js +17 -0
- package/umd/slider/index.d.ts +1 -1
- package/umd/slider/index.js +1 -1
- package/umd/steps/index.d.ts +1 -1
- package/umd/steps/index.js +1 -1
- package/umd/sticky/index.d.ts +1 -1
- package/umd/style.d.ts +2 -0
- package/umd/style.js +4 -4
- package/umd/swipe-action/demo/style/css/mobile.css +5 -0
- package/umd/swipe-action/demo/style/mobile.less +9 -0
- package/umd/swipe-action/index.d.ts +12 -0
- package/umd/swipe-action/index.js +342 -0
- package/umd/swipe-action/item.d.ts +11 -0
- package/umd/swipe-action/item.js +62 -0
- package/umd/swipe-action/style/css/index.css +88 -0
- package/umd/swipe-action/style/css/index.d.ts +2 -0
- package/umd/swipe-action/style/css/index.js +15 -0
- package/umd/swipe-action/style/index.d.ts +2 -0
- package/umd/swipe-action/style/index.js +15 -0
- package/umd/swipe-action/style/index.less +89 -0
- package/umd/swipe-action/type.d.ts +123 -0
- package/umd/swipe-action/type.js +17 -0
- package/umd/switch/index.d.ts +1 -1
- package/umd/switch/index.js +1 -1
- package/umd/tabs/tab-pane.js +5 -1
- package/umd/tag/index.d.ts +1 -1
- package/umd/tag/index.js +1 -1
- package/umd/textarea/index.d.ts +1 -1
- package/umd/textarea/index.js +1 -1
package/cjs/radio/index.js
CHANGED
@@ -29,7 +29,7 @@ var Group = (0, _group.componentGenerator)(_radio.Radio);
|
|
29
29
|
* @en Radio button, click to switch selection when available, supports disabled state and radio option group.
|
30
30
|
* @name 单选框
|
31
31
|
* @name_en Radio
|
32
|
-
* @type
|
32
|
+
* @type 数据录入
|
33
33
|
* @type_en Data Entry
|
34
34
|
*/
|
35
35
|
|
package/cjs/rate/index.d.ts
CHANGED
package/cjs/rate/index.js
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.SearchBarAssociation = SearchBarAssociation;
|
7
|
+
|
8
|
+
var _mobileUtils = require("@arco-design/mobile-utils");
|
9
|
+
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
11
|
+
|
12
|
+
var _highlight = require("./highlight");
|
13
|
+
|
14
|
+
function SearchBarAssociation(props) {
|
15
|
+
var _cls;
|
16
|
+
|
17
|
+
var prefixCls = props.prefixCls,
|
18
|
+
_props$associationIte = props.associationItems,
|
19
|
+
associationItems = _props$associationIte === void 0 ? [] : _props$associationIte,
|
20
|
+
highlightClassName = props.highlightClassName,
|
21
|
+
_props$highlightMode = props.highlightMode,
|
22
|
+
highlightMode = _props$highlightMode === void 0 ? 'none' : _props$highlightMode,
|
23
|
+
highlightStyle = props.highlightStyle,
|
24
|
+
onAssociationClick = props.onAssociationClick,
|
25
|
+
onAssociationItemClick = props.onAssociationItemClick,
|
26
|
+
renderAssociation = props.renderAssociation,
|
27
|
+
renderAssociationItem = props.renderAssociationItem,
|
28
|
+
keyword = props.keyword,
|
29
|
+
visible = props.visible;
|
30
|
+
var searchBarAssociationPrefixCls = prefixCls + "-association";
|
31
|
+
var defaultHighlightClassName = searchBarAssociationPrefixCls + "-item-highlight";
|
32
|
+
|
33
|
+
var renderHighlightNode = function renderHighlightNode(content) {
|
34
|
+
if (!content || !keyword || highlightMode === 'none') {
|
35
|
+
return content;
|
36
|
+
}
|
37
|
+
|
38
|
+
var config = {
|
39
|
+
keyword: keyword,
|
40
|
+
content: content,
|
41
|
+
highlightClassName: highlightClassName || defaultHighlightClassName,
|
42
|
+
highlightStyle: highlightStyle
|
43
|
+
};
|
44
|
+
|
45
|
+
if (highlightMode === 'contain') {
|
46
|
+
return (0, _highlight.highlightWithContainMode)(config);
|
47
|
+
}
|
48
|
+
|
49
|
+
if (highlightMode === 'prefix') {
|
50
|
+
return (0, _highlight.highlightWithPrefixMode)(config);
|
51
|
+
}
|
52
|
+
|
53
|
+
return typeof highlightMode === 'function' ? highlightMode(content, keyword, defaultHighlightClassName) : content;
|
54
|
+
};
|
55
|
+
|
56
|
+
var renderItem = function renderItem(item, index) {
|
57
|
+
var itemContent = item.content;
|
58
|
+
var node = itemContent; // itemContent为string类型,并且开启高亮模式才去走渲染高亮内容的逻辑
|
59
|
+
// @en When `itemContent` is a string, and the highlight mode is turned on, the logic of rendering the highlighted content is performed
|
60
|
+
|
61
|
+
if (typeof itemContent === 'string' && highlightMode !== 'none') {
|
62
|
+
node = renderHighlightNode(itemContent);
|
63
|
+
}
|
64
|
+
|
65
|
+
if (renderAssociationItem) {
|
66
|
+
node = renderAssociationItem(item, index, node);
|
67
|
+
}
|
68
|
+
|
69
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
70
|
+
key: index,
|
71
|
+
className: searchBarAssociationPrefixCls + "-item",
|
72
|
+
onClick: function onClick() {
|
73
|
+
return onAssociationItemClick == null ? void 0 : onAssociationItemClick(item, index);
|
74
|
+
}
|
75
|
+
}, node);
|
76
|
+
};
|
77
|
+
|
78
|
+
var renderContent = function renderContent() {
|
79
|
+
var associationContent = associationItems.map(renderItem);
|
80
|
+
|
81
|
+
if (renderAssociation) {
|
82
|
+
return renderAssociation(associationContent);
|
83
|
+
}
|
84
|
+
|
85
|
+
return associationContent;
|
86
|
+
};
|
87
|
+
|
88
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
89
|
+
className: (0, _mobileUtils.cls)(searchBarAssociationPrefixCls, (_cls = {}, _cls[searchBarAssociationPrefixCls + "-visible"] = visible, _cls)),
|
90
|
+
onClick: onAssociationClick
|
91
|
+
}, renderContent());
|
92
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
interface CancelButtonProps {
|
3
|
+
className: string;
|
4
|
+
onCancel?: () => void;
|
5
|
+
focusing: boolean;
|
6
|
+
currentInputValue: string;
|
7
|
+
text?: string;
|
8
|
+
}
|
9
|
+
export declare function CancelButton(props: CancelButtonProps): JSX.Element | null;
|
10
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
exports.CancelButton = CancelButton;
|
5
|
+
|
6
|
+
var _mobileUtils = require("@arco-design/mobile-utils");
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
11
|
+
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
13
|
+
|
14
|
+
function CancelButton(props) {
|
15
|
+
var className = props.className,
|
16
|
+
onCancel = props.onCancel,
|
17
|
+
focusing = props.focusing,
|
18
|
+
currentInputValue = props.currentInputValue,
|
19
|
+
text = props.text;
|
20
|
+
|
21
|
+
var _useState = (0, _react.useState)(focusing || Boolean(currentInputValue)),
|
22
|
+
visible = _useState[0],
|
23
|
+
setVisible = _useState[1];
|
24
|
+
|
25
|
+
var handleClick = function handleClick() {
|
26
|
+
onCancel == null ? void 0 : onCancel(); // 如果不延迟,在聚焦切输入框有值的情况下,点击取消按钮会造成闪烁
|
27
|
+
// @en If there is no delay, when the focus cut input box has a value, clicking the cancel button will cause flickering
|
28
|
+
|
29
|
+
(0, _mobileUtils.nextTick)(function () {
|
30
|
+
setVisible(false);
|
31
|
+
});
|
32
|
+
};
|
33
|
+
|
34
|
+
(0, _react.useEffect)(function () {
|
35
|
+
setVisible(focusing || Boolean(currentInputValue));
|
36
|
+
}, [focusing, currentInputValue]);
|
37
|
+
return visible ? /*#__PURE__*/_react.default.createElement("span", {
|
38
|
+
className: className,
|
39
|
+
onClick: handleClick
|
40
|
+
}, text) : null;
|
41
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SearchBarAssociationHighlightConfig } from './type';
|
3
|
+
/**
|
4
|
+
* 高亮搜索候选项中,包含的关键字
|
5
|
+
*
|
6
|
+
*/
|
7
|
+
export declare function highlightWithContainMode(config: SearchBarAssociationHighlightConfig): React.ReactNode[];
|
8
|
+
/**
|
9
|
+
* 高亮搜索候选项和关键字的最长前缀公共字符串
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
export declare function highlightWithPrefixMode(config: SearchBarAssociationHighlightConfig): string | (string | JSX.Element)[];
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.highlightWithContainMode = highlightWithContainMode;
|
7
|
+
exports.highlightWithPrefixMode = highlightWithPrefixMode;
|
8
|
+
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
10
|
+
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
12
|
+
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
14
|
+
|
15
|
+
var _excluded = ["content", "keyword"];
|
16
|
+
|
17
|
+
function createHighlightNode(config, index) {
|
18
|
+
var keyword = config.keyword,
|
19
|
+
highlightClassName = config.highlightClassName,
|
20
|
+
highlightStyle = config.highlightStyle;
|
21
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
22
|
+
className: highlightClassName,
|
23
|
+
style: highlightStyle,
|
24
|
+
key: index
|
25
|
+
}, keyword);
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* 高亮搜索候选项中,包含的关键字
|
29
|
+
*
|
30
|
+
*/
|
31
|
+
|
32
|
+
|
33
|
+
function highlightWithContainMode(config) {
|
34
|
+
var _config$content = config.content,
|
35
|
+
content = _config$content === void 0 ? '' : _config$content,
|
36
|
+
_config$keyword = config.keyword,
|
37
|
+
keyword = _config$keyword === void 0 ? '' : _config$keyword; // 具体实现思路就是将keyword作为split的分隔符,切割content得到数组
|
38
|
+
|
39
|
+
var splitContent = content.split(keyword); // 再将高亮后的keyword节点,插空填入数组
|
40
|
+
|
41
|
+
var highlightResult = splitContent.reduce(function (prev, word, index) {
|
42
|
+
prev.push(word);
|
43
|
+
|
44
|
+
if (index !== splitContent.length - 1) {
|
45
|
+
prev.push(createHighlightNode(config, index));
|
46
|
+
}
|
47
|
+
|
48
|
+
return prev;
|
49
|
+
}, []);
|
50
|
+
return highlightResult;
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* 高亮搜索候选项和关键字的最长前缀公共字符串
|
54
|
+
*
|
55
|
+
*/
|
56
|
+
|
57
|
+
|
58
|
+
function highlightWithPrefixMode(config) {
|
59
|
+
var _config$content2 = config.content,
|
60
|
+
content = _config$content2 === void 0 ? '' : _config$content2,
|
61
|
+
_config$keyword2 = config.keyword,
|
62
|
+
keyword = _config$keyword2 === void 0 ? '' : _config$keyword2,
|
63
|
+
otherConfig = (0, _objectWithoutPropertiesLoose2.default)(config, _excluded);
|
64
|
+
var splitIndex = -1;
|
65
|
+
|
66
|
+
for (var i = 0; i < keyword.length; i++) {
|
67
|
+
if (i >= content.length || content[i] !== keyword[i]) {
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
|
71
|
+
splitIndex = i;
|
72
|
+
}
|
73
|
+
|
74
|
+
return splitIndex > -1 ? [createHighlightNode((0, _extends2.default)({}, otherConfig, {
|
75
|
+
keyword: content.substring(0, splitIndex + 1)
|
76
|
+
}), 0), content.substring(splitIndex + 1)] : content;
|
77
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { SearchAssociationBaseItem, SearchBarProps, SearchBarRef } from './type';
|
3
|
+
export { SearchBarProps, SearchBarRef, SearchAssociationHighlightMode, SearchAssociationItem, SearchAssociationShowType, SearchBarShape, } from './type';
|
4
|
+
/**
|
5
|
+
* 搜索栏组件
|
6
|
+
* @en SearchBar component
|
7
|
+
* @type 数据录入
|
8
|
+
* @type_en Data Entry
|
9
|
+
* @name 搜索栏
|
10
|
+
* @name_en SearchBar
|
11
|
+
*/
|
12
|
+
declare const SearchBar: React.ForwardRefExoticComponent<SearchBarProps<SearchAssociationBaseItem> & React.RefAttributes<SearchBarRef>>;
|
13
|
+
export default SearchBar;
|
@@ -0,0 +1,239 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.default = exports.SearchBarShape = exports.SearchBarRef = exports.SearchBarProps = exports.SearchAssociationShowType = exports.SearchAssociationItem = exports.SearchAssociationHighlightMode = void 0;
|
7
|
+
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
+
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
11
|
+
|
12
|
+
var _mobileUtils = require("@arco-design/mobile-utils");
|
13
|
+
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
15
|
+
|
16
|
+
var _contextProvider = require("../context-provider");
|
17
|
+
|
18
|
+
var _icon = require("../icon");
|
19
|
+
|
20
|
+
var _hooks = require("../input/hooks");
|
21
|
+
|
22
|
+
var _association = require("./association");
|
23
|
+
|
24
|
+
var _cancelButton = require("./cancel-button");
|
25
|
+
|
26
|
+
var _type = require("./type");
|
27
|
+
|
28
|
+
exports.SearchBarProps = _type.SearchBarProps;
|
29
|
+
exports.SearchBarRef = _type.SearchBarRef;
|
30
|
+
exports.SearchAssociationHighlightMode = _type.SearchAssociationHighlightMode;
|
31
|
+
exports.SearchAssociationItem = _type.SearchAssociationItem;
|
32
|
+
exports.SearchAssociationShowType = _type.SearchAssociationShowType;
|
33
|
+
exports.SearchBarShape = _type.SearchBarShape;
|
34
|
+
var _excluded = ["inputClass", "inputStyle", "type", "nativeProps", "id", "name", "maxLength", "placeholder", "readOnly", "onKeyUp", "onKeyPress", "disabled", "pattern", "prefix", "append", "textAlign", "actionButton", "clearable", "clearShowType", "shape", "className", "enableAssociation", "associationVisible", "associationShowType", "associationItems", "highlightClassName", "highlightMode", "highlightStyle", "onCancel", "onAssociationClick", "onAssociationItemClick", "renderAssociation", "renderAssociationItem"];
|
35
|
+
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
37
|
+
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
39
|
+
|
40
|
+
/**
|
41
|
+
* 搜索栏组件
|
42
|
+
* @en SearchBar component
|
43
|
+
* @type 数据录入
|
44
|
+
* @type_en Data Entry
|
45
|
+
* @name 搜索栏
|
46
|
+
* @name_en SearchBar
|
47
|
+
*/
|
48
|
+
var SearchBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
49
|
+
var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
|
50
|
+
prefixCls = _useContext.prefixCls,
|
51
|
+
locale = _useContext.locale;
|
52
|
+
|
53
|
+
var searchBarPrefixCls = prefixCls + "-search-bar";
|
54
|
+
var inputClass = props.inputClass,
|
55
|
+
inputStyle = props.inputStyle,
|
56
|
+
_props$type = props.type,
|
57
|
+
type = _props$type === void 0 ? 'search' : _props$type,
|
58
|
+
nativeProps = props.nativeProps,
|
59
|
+
id = props.id,
|
60
|
+
name = props.name,
|
61
|
+
maxLength = props.maxLength,
|
62
|
+
_props$placeholder = props.placeholder,
|
63
|
+
placeholder = _props$placeholder === void 0 ? locale == null ? void 0 : locale.SearchBar.placeholder : _props$placeholder,
|
64
|
+
readOnly = props.readOnly,
|
65
|
+
onKeyUp = props.onKeyUp,
|
66
|
+
onKeyPress = props.onKeyPress,
|
67
|
+
disabled = props.disabled,
|
68
|
+
pattern = props.pattern,
|
69
|
+
_props$prefix = props.prefix,
|
70
|
+
prefix = _props$prefix === void 0 ? /*#__PURE__*/_react.default.createElement(_icon.IconSearch, {
|
71
|
+
className: searchBarPrefixCls + "-search-icon"
|
72
|
+
}) : _props$prefix,
|
73
|
+
append = props.append,
|
74
|
+
_props$textAlign = props.textAlign,
|
75
|
+
textAlign = _props$textAlign === void 0 ? 'left' : _props$textAlign,
|
76
|
+
actionButton = props.actionButton,
|
77
|
+
_props$clearable = props.clearable,
|
78
|
+
clearable = _props$clearable === void 0 ? true : _props$clearable,
|
79
|
+
_props$clearShowType = props.clearShowType,
|
80
|
+
clearShowType = _props$clearShowType === void 0 ? 'value' : _props$clearShowType,
|
81
|
+
_props$shape = props.shape,
|
82
|
+
shape = _props$shape === void 0 ? 'square' : _props$shape,
|
83
|
+
className = props.className,
|
84
|
+
_props$enableAssociat = props.enableAssociation,
|
85
|
+
enableAssociation = _props$enableAssociat === void 0 ? false : _props$enableAssociat,
|
86
|
+
associationVisible = props.associationVisible,
|
87
|
+
_props$associationSho = props.associationShowType,
|
88
|
+
associationShowType = _props$associationSho === void 0 ? 'default' : _props$associationSho,
|
89
|
+
associationItems = props.associationItems,
|
90
|
+
highlightClassName = props.highlightClassName,
|
91
|
+
highlightMode = props.highlightMode,
|
92
|
+
highlightStyle = props.highlightStyle,
|
93
|
+
onCancel = props.onCancel,
|
94
|
+
onAssociationClick = props.onAssociationClick,
|
95
|
+
onAssociationItemClick = props.onAssociationItemClick,
|
96
|
+
renderAssociation = props.renderAssociation,
|
97
|
+
renderAssociationItem = props.renderAssociationItem,
|
98
|
+
inputProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
99
|
+
var inputRef = (0, _react.useRef)(null);
|
100
|
+
/**
|
101
|
+
* 格式化搜索输入框尾部要插入的内容
|
102
|
+
* @en Format the content to be inserted at the end of the search input box
|
103
|
+
*/
|
104
|
+
|
105
|
+
var formatAppendProp = function formatAppendProp(focusing, currentInputValue) {
|
106
|
+
var appendNode = null;
|
107
|
+
|
108
|
+
if (typeof append === 'function') {
|
109
|
+
appendNode = append(focusing, currentInputValue);
|
110
|
+
} else {
|
111
|
+
appendNode = append;
|
112
|
+
} // 默认情况下,在激活时或有内容时插入一个cancelBtn
|
113
|
+
// @en By default inserts a cancelBtn on activation or when there is content
|
114
|
+
|
115
|
+
|
116
|
+
var formatActionButton = typeof actionButton === 'undefined' ? /*#__PURE__*/_react.default.createElement(_cancelButton.CancelButton, {
|
117
|
+
focusing: focusing,
|
118
|
+
currentInputValue: currentInputValue,
|
119
|
+
className: searchBarPrefixCls + "-cancel-btn",
|
120
|
+
onCancel: onCancel,
|
121
|
+
text: locale == null ? void 0 : locale.SearchBar.cancelBtn
|
122
|
+
}) : actionButton;
|
123
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, appendNode, formatActionButton, enableAssociation ? /*#__PURE__*/_react.default.createElement(_association.SearchBarAssociation, {
|
124
|
+
prefixCls: searchBarPrefixCls,
|
125
|
+
keyword: currentInputValue // eslint-disable-next-line @typescript-eslint/no-use-before-define
|
126
|
+
,
|
127
|
+
visible: actualVisible,
|
128
|
+
associationItems: associationItems,
|
129
|
+
highlightClassName: highlightClassName,
|
130
|
+
highlightMode: highlightMode,
|
131
|
+
highlightStyle: highlightStyle,
|
132
|
+
onAssociationClick: onAssociationClick,
|
133
|
+
onAssociationItemClick: onAssociationItemClick,
|
134
|
+
renderAssociation: renderAssociation,
|
135
|
+
renderAssociationItem: renderAssociationItem
|
136
|
+
}) : null);
|
137
|
+
};
|
138
|
+
|
139
|
+
var _useInputLogic = (0, _hooks.useInputLogic)((0, _extends2.default)({
|
140
|
+
className: (0, _mobileUtils.cls)(className, searchBarPrefixCls + "-" + shape),
|
141
|
+
prefix: prefix,
|
142
|
+
clearable: clearable,
|
143
|
+
append: formatAppendProp,
|
144
|
+
clearShowType: clearShowType
|
145
|
+
}, inputProps), inputRef),
|
146
|
+
inputValue = _useInputLogic.inputValue,
|
147
|
+
handleChange = _useInputLogic.handleChange,
|
148
|
+
handleInput = _useInputLogic.handleInput,
|
149
|
+
handleKeyDown = _useInputLogic.handleKeyDown,
|
150
|
+
handleFocus = _useInputLogic.handleFocus,
|
151
|
+
handleBlur = _useInputLogic.handleBlur,
|
152
|
+
handleClick = _useInputLogic.handleClick,
|
153
|
+
renderWrapper = _useInputLogic.renderWrapper,
|
154
|
+
wrapRef = _useInputLogic.wrapRef;
|
155
|
+
|
156
|
+
var _useState = (0, _react.useState)(associationShowType === 'always' || (associationShowType === 'value' || associationShowType === 'default') && Boolean(inputValue)),
|
157
|
+
visible = _useState[0],
|
158
|
+
setVisible = _useState[1]; // 真实的控制搜索联想框显隐,受控模式优先生效
|
159
|
+
// @en Control the display and hide of the search association box, and the controlled mode takes effect first
|
160
|
+
|
161
|
+
|
162
|
+
var actualVisible = associationVisible != null ? associationVisible : visible;
|
163
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
164
|
+
return {
|
165
|
+
dom: wrapRef.current,
|
166
|
+
input: inputRef.current,
|
167
|
+
toggleAssociation: function toggleAssociation(newVisible) {
|
168
|
+
setVisible(newVisible != null ? newVisible : !visible);
|
169
|
+
}
|
170
|
+
};
|
171
|
+
});
|
172
|
+
/**
|
173
|
+
* 处理非受控逻辑下,搜索联想框的显隐状态
|
174
|
+
* @en Handle the display state of the search association box under uncontrolled logic
|
175
|
+
*
|
176
|
+
* @param {boolean} newVisible 新的visible
|
177
|
+
* @param {string} newValue 新的输入框值
|
178
|
+
*/
|
179
|
+
|
180
|
+
var formatSetAssociationVisible = function formatSetAssociationVisible(newVisible, newValue) {
|
181
|
+
if (associationShowType === 'always') {
|
182
|
+
setVisible(true); // 聚焦模式下,直接把visible和newVisible对齐即可
|
183
|
+
// @en In focus mode, just align visible and newVisible directly
|
184
|
+
} else if (associationShowType === 'focus') {
|
185
|
+
setVisible(newVisible); // 聚焦 + 有值模式下,需要newVisible为true和newValue.length > 0同时满足
|
186
|
+
// @en In focus + valued mode, newVisible is required to be true and newValue.length > 0 to be satisfied at the same time
|
187
|
+
} else if (associationShowType === 'default') {
|
188
|
+
setVisible(newVisible && Boolean(newValue)); // 仅有值模式下,visible需要newValue.length > 0
|
189
|
+
// @en In value-only mode, visible requires newValue.length > 0
|
190
|
+
} else if (associationShowType === 'value') {
|
191
|
+
setVisible(Boolean(newValue));
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
var handleInputFocus = function handleInputFocus(e) {
|
196
|
+
formatSetAssociationVisible(true, e.target.value);
|
197
|
+
handleFocus(e);
|
198
|
+
};
|
199
|
+
|
200
|
+
var handleInputBlur = function handleInputBlur(e) {
|
201
|
+
formatSetAssociationVisible(false, e.target.value);
|
202
|
+
handleBlur(e);
|
203
|
+
};
|
204
|
+
|
205
|
+
var handleInputChange = function handleInputChange(e) {
|
206
|
+
var newValue = e.target.value;
|
207
|
+
formatSetAssociationVisible(Boolean(newValue), newValue);
|
208
|
+
handleChange(e);
|
209
|
+
};
|
210
|
+
|
211
|
+
var renderSearchBar = function renderSearchBar() {
|
212
|
+
return renderWrapper(searchBarPrefixCls, type, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, nativeProps, {
|
213
|
+
id: id,
|
214
|
+
name: name,
|
215
|
+
maxLength: maxLength,
|
216
|
+
placeholder: placeholder,
|
217
|
+
readOnly: readOnly,
|
218
|
+
onFocus: handleInputFocus,
|
219
|
+
onBlur: handleInputBlur,
|
220
|
+
onKeyUp: onKeyUp,
|
221
|
+
onKeyPress: onKeyPress,
|
222
|
+
ref: inputRef,
|
223
|
+
className: (0, _mobileUtils.cls)(searchBarPrefixCls + "-input", inputClass, searchBarPrefixCls + "-input-" + textAlign),
|
224
|
+
style: inputStyle,
|
225
|
+
value: inputValue,
|
226
|
+
type: type,
|
227
|
+
disabled: disabled,
|
228
|
+
pattern: pattern,
|
229
|
+
onChange: handleInputChange,
|
230
|
+
onInput: handleInput,
|
231
|
+
onKeyDown: handleKeyDown,
|
232
|
+
onClick: handleClick
|
233
|
+
})));
|
234
|
+
};
|
235
|
+
|
236
|
+
return /*#__PURE__*/_react.default.createElement(_contextProvider.ContextLayout, null, renderSearchBar);
|
237
|
+
});
|
238
|
+
var _default = SearchBar;
|
239
|
+
exports.default = _default;
|