antd3-esm 1.0.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/LICENSE +21 -0
- package/dist/Checkbox.js +164 -0
- package/dist/CommonMixin.js +816 -0
- package/dist/Divider.js +646 -0
- package/dist/Notification.js +279 -0
- package/dist/Pagination.js +1106 -0
- package/dist/PortalWrapper.js +347 -0
- package/dist/RowContext.js +5 -0
- package/dist/Sider.js +533 -0
- package/dist/TextArea.js +432 -0
- package/dist/_arrayMap.js +68 -0
- package/dist/_assignValue.js +95 -0
- package/dist/_copyArray.js +31 -0
- package/dist/_hasPath.js +53 -0
- package/dist/_overArg.js +437 -0
- package/dist/_stringToArray.js +136 -0
- package/dist/antd/es/affix.js +12 -0
- package/dist/antd/es/alert.js +5 -0
- package/dist/antd/es/anchor.js +466 -0
- package/dist/antd/es/auto-complete.js +5 -0
- package/dist/antd/es/avatar.js +5 -0
- package/dist/antd/es/back-top.js +5 -0
- package/dist/antd/es/badge.js +5 -0
- package/dist/antd/es/breadcrumb.js +18 -0
- package/dist/antd/es/button.js +12 -0
- package/dist/antd/es/calendar.js +953 -0
- package/dist/antd/es/card.js +5 -0
- package/dist/antd/es/carousel.js +5 -0
- package/dist/antd/es/cascader.js +1275 -0
- package/dist/antd/es/checkbox.js +11 -0
- package/dist/antd/es/col.js +4 -0
- package/dist/antd/es/collapse.js +688 -0
- package/dist/antd/es/comment.js +5 -0
- package/dist/antd/es/config-provider.js +2 -0
- package/dist/antd/es/date-picker.js +4322 -0
- package/dist/antd/es/descriptions.js +342 -0
- package/dist/antd/es/divider.js +53 -0
- package/dist/antd/es/drawer.js +1115 -0
- package/dist/antd/es/dropdown.js +14 -0
- package/dist/antd/es/empty.js +6 -0
- package/dist/antd/es/form.js +5008 -0
- package/dist/antd/es/grid.js +13 -0
- package/dist/antd/es/icon.js +6 -0
- package/dist/antd/es/input-number.js +5 -0
- package/dist/antd/es/input.js +16 -0
- package/dist/antd/es/layout.js +14 -0
- package/dist/antd/es/list.js +5 -0
- package/dist/antd/es/locale/ar_EG.js +102 -0
- package/dist/antd/es/locale/bg_BG.js +98 -0
- package/dist/antd/es/locale/ca_ES.js +96 -0
- package/dist/antd/es/locale/cs_CZ.js +96 -0
- package/dist/antd/es/locale/da_DK.js +98 -0
- package/dist/antd/es/locale/de_DE.js +98 -0
- package/dist/antd/es/locale/default.js +2 -0
- package/dist/antd/es/locale/el_GR.js +98 -0
- package/dist/antd/es/locale/en_GB.js +98 -0
- package/dist/antd/es/locale/en_US.js +2 -0
- package/dist/antd/es/locale/es_ES.js +114 -0
- package/dist/antd/es/locale/et_EE.js +98 -0
- package/dist/antd/es/locale/fa_IR.js +98 -0
- package/dist/antd/es/locale/fi_FI.js +99 -0
- package/dist/antd/es/locale/fr_BE.js +102 -0
- package/dist/antd/es/locale/fr_FR.js +102 -0
- package/dist/antd/es/locale/ga_IE.js +99 -0
- package/dist/antd/es/locale/he_IL.js +99 -0
- package/dist/antd/es/locale/hi_IN.js +107 -0
- package/dist/antd/es/locale/hr_HR.js +113 -0
- package/dist/antd/es/locale/hu_HU.js +99 -0
- package/dist/antd/es/locale/hy_AM.js +109 -0
- package/dist/antd/es/locale/id_ID.js +101 -0
- package/dist/antd/es/locale/is_IS.js +98 -0
- package/dist/antd/es/locale/it_IT.js +111 -0
- package/dist/antd/es/locale/ja_JP.js +96 -0
- package/dist/antd/es/locale/kn_IN.js +107 -0
- package/dist/antd/es/locale/ko_KR.js +98 -0
- package/dist/antd/es/locale/ku_IQ.js +98 -0
- package/dist/antd/es/locale/lv_LV.js +98 -0
- package/dist/antd/es/locale/mk_MK.js +113 -0
- package/dist/antd/es/locale/mn_MN.js +99 -0
- package/dist/antd/es/locale/ms_MY.js +118 -0
- package/dist/antd/es/locale/nb_NO.js +97 -0
- package/dist/antd/es/locale/ne_NP.js +44 -0
- package/dist/antd/es/locale/nl_BE.js +98 -0
- package/dist/antd/es/locale/nl_NL.js +117 -0
- package/dist/antd/es/locale/pl_PL.js +98 -0
- package/dist/antd/es/locale/pt_BR.js +104 -0
- package/dist/antd/es/locale/pt_PT.js +127 -0
- package/dist/antd/es/locale/ro_RO.js +118 -0
- package/dist/antd/es/locale/ru_RU.js +110 -0
- package/dist/antd/es/locale/sk_SK.js +118 -0
- package/dist/antd/es/locale/sl_SI.js +96 -0
- package/dist/antd/es/locale/sr_RS.js +97 -0
- package/dist/antd/es/locale/sv_SE.js +101 -0
- package/dist/antd/es/locale/ta_IN.js +119 -0
- package/dist/antd/es/locale/th_TH.js +117 -0
- package/dist/antd/es/locale/tr_TR.js +112 -0
- package/dist/antd/es/locale/uk_UA.js +97 -0
- package/dist/antd/es/locale/vi_VN.js +99 -0
- package/dist/antd/es/locale/zh_CN.js +104 -0
- package/dist/antd/es/locale/zh_TW.js +100 -0
- package/dist/antd/es/locale-provider.js +6 -0
- package/dist/antd/es/mention.js +23215 -0
- package/dist/antd/es/mentions.js +961 -0
- package/dist/antd/es/menu.js +5 -0
- package/dist/antd/es/message.js +161 -0
- package/dist/antd/es/modal.js +885 -0
- package/dist/antd/es/notification.js +216 -0
- package/dist/antd/es/page-header.js +350 -0
- package/dist/antd/es/pagination.js +15 -0
- package/dist/antd/es/popconfirm.js +215 -0
- package/dist/antd/es/popover.js +5 -0
- package/dist/antd/es/progress.js +10 -0
- package/dist/antd/es/radio.js +10 -0
- package/dist/antd/es/rate.js +5 -0
- package/dist/antd/es/result.js +828 -0
- package/dist/antd/es/row.js +9 -0
- package/dist/antd/es/select.js +5 -0
- package/dist/antd/es/skeleton.js +370 -0
- package/dist/antd/es/slider.js +5 -0
- package/dist/antd/es/spin.js +11 -0
- package/dist/antd/es/statistic.js +650 -0
- package/dist/antd/es/steps.js +5 -0
- package/dist/antd/es/style.js +5 -0
- package/dist/antd/es/switch.js +5 -0
- package/dist/antd/es/table.js +7057 -0
- package/dist/antd/es/tabs.js +5 -0
- package/dist/antd/es/tag.js +12 -0
- package/dist/antd/es/time-picker.js +10 -0
- package/dist/antd/es/timeline.js +206 -0
- package/dist/antd/es/tooltip.js +9 -0
- package/dist/antd/es/transfer.js +2508 -0
- package/dist/antd/es/tree-select.js +5 -0
- package/dist/antd/es/tree.js +10 -0
- package/dist/antd/es/typography.js +1246 -0
- package/dist/antd/es/upload.js +3418 -0
- package/dist/antd/es/version.js +7 -0
- package/dist/col.js +142 -0
- package/dist/config-provider.js +6949 -0
- package/dist/dropdown.js +442 -0
- package/dist/get.js +1043 -0
- package/dist/icon.js +6138 -0
- package/dist/identity.js +230 -0
- package/dist/index.js +462 -0
- package/dist/index10.js +478 -0
- package/dist/index11.js +232 -0
- package/dist/index12.js +2766 -0
- package/dist/index13.js +422 -0
- package/dist/index14.js +283 -0
- package/dist/index15.js +1755 -0
- package/dist/index2.js +374 -0
- package/dist/index3.js +407 -0
- package/dist/index4.js +522 -0
- package/dist/index5.js +601 -0
- package/dist/index6.js +601 -0
- package/dist/index7.js +364 -0
- package/dist/index8.js +436 -0
- package/dist/index9.js +130 -0
- package/dist/input.js +475 -0
- package/dist/isLength.js +402 -0
- package/dist/keys.js +292 -0
- package/dist/menu.js +8138 -0
- package/dist/progress.js +852 -0
- package/dist/raf.js +34 -0
- package/dist/responsiveObserve.js +444 -0
- package/dist/row.js +173 -0
- package/dist/scrollTo.js +66 -0
- package/dist/toInteger.js +123 -0
- package/dist/toString.js +84 -0
- package/dist/transButton.js +121 -0
- package/dist/tree.js +3017 -0
- package/dist/warning.js +55 -0
- package/dist/wave.js +230 -0
- package/dist/zh_CN.js +17 -0
- package/package.json +160 -0
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import { n, h as createReactContext, c as classNames, C as ConfigConsumer } from '../../config-provider.js';
|
|
2
|
+
import { o as omit$1 } from '../../input.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { b as Trigger, K as KeyCode, p as polyfill } from '../../menu.js';
|
|
5
|
+
import { t as toArray } from '../../tree.js';
|
|
6
|
+
import { a as Menu, c as connected } from '../../Divider.js';
|
|
7
|
+
import { S as Spin } from '../../index11.js';
|
|
8
|
+
import '../../icon.js';
|
|
9
|
+
import 'react-dom';
|
|
10
|
+
import '../../index5.js';
|
|
11
|
+
|
|
12
|
+
var css = "/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */\n/* stylelint-disable no-duplicate-selectors */\n/* stylelint-disable */\n/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */\n.ant-mentions {\n box-sizing: border-box;\n margin: 0;\n font-variant: tabular-nums;\n list-style: none;\n font-feature-settings: 'tnum';\n width: 100%;\n height: 32px;\n padding: 4px 11px;\n color: rgba(0, 0, 0, 0.65);\n font-size: 14px;\n background-color: #fff;\n background-image: none;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n transition: all 0.3s;\n position: relative;\n display: inline-block;\n height: auto;\n padding: 0;\n overflow: hidden;\n line-height: 1.5;\n white-space: pre-wrap;\n vertical-align: bottom;\n}\n.ant-mentions::-moz-placeholder {\n color: #bfbfbf;\n opacity: 1;\n}\n.ant-mentions:-ms-input-placeholder {\n color: #bfbfbf;\n}\n.ant-mentions::-webkit-input-placeholder {\n color: #bfbfbf;\n}\n.ant-mentions:placeholder-shown {\n text-overflow: ellipsis;\n}\n.ant-mentions:hover {\n border-color: #40a9ff;\n border-right-width: 1px !important;\n}\n.ant-mentions:focus {\n border-color: #40a9ff;\n border-right-width: 1px !important;\n outline: 0;\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);\n}\n.ant-mentions-disabled {\n color: rgba(0, 0, 0, 0.25);\n background-color: #f5f5f5;\n cursor: not-allowed;\n opacity: 1;\n}\n.ant-mentions-disabled:hover {\n border-color: #d9d9d9;\n border-right-width: 1px !important;\n}\n.ant-mentions[disabled] {\n color: rgba(0, 0, 0, 0.25);\n background-color: #f5f5f5;\n cursor: not-allowed;\n opacity: 1;\n}\n.ant-mentions[disabled]:hover {\n border-color: #d9d9d9;\n border-right-width: 1px !important;\n}\ntextarea.ant-mentions {\n max-width: 100%;\n height: auto;\n min-height: 32px;\n line-height: 1.5;\n vertical-align: bottom;\n transition: all 0.3s, height 0s;\n}\n.ant-mentions-lg {\n height: 40px;\n padding: 6px 11px;\n font-size: 16px;\n}\n.ant-mentions-sm {\n height: 24px;\n padding: 1px 7px;\n}\n.ant-mentions-disabled > textarea {\n color: rgba(0, 0, 0, 0.25);\n background-color: #f5f5f5;\n cursor: not-allowed;\n opacity: 1;\n}\n.ant-mentions-disabled > textarea:hover {\n border-color: #d9d9d9;\n border-right-width: 1px !important;\n}\n.ant-mentions-focused {\n border-color: #40a9ff;\n border-right-width: 1px !important;\n outline: 0;\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);\n}\n.ant-mentions > textarea,\n.ant-mentions-measure {\n min-height: 30px;\n margin: 0;\n padding: 4px 11px;\n overflow: inherit;\n overflow-x: hidden;\n overflow-y: auto;\n font-weight: inherit;\n font-size: inherit;\n font-family: inherit;\n font-style: inherit;\n font-variant: inherit;\n font-size-adjust: inherit;\n font-stretch: inherit;\n line-height: inherit;\n direction: inherit;\n letter-spacing: inherit;\n white-space: inherit;\n text-align: inherit;\n vertical-align: top;\n word-wrap: break-word;\n word-break: inherit;\n tab-size: inherit;\n}\n.ant-mentions > textarea {\n width: 100%;\n border: none;\n outline: none;\n resize: none;\n}\n.ant-mentions > textarea::-moz-placeholder {\n color: #bfbfbf;\n opacity: 1;\n}\n.ant-mentions > textarea:-ms-input-placeholder {\n color: #bfbfbf;\n}\n.ant-mentions > textarea::-webkit-input-placeholder {\n color: #bfbfbf;\n}\n.ant-mentions > textarea:placeholder-shown {\n text-overflow: ellipsis;\n}\n.ant-mentions > textarea:read-only {\n cursor: default;\n}\n.ant-mentions-measure {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: -1;\n color: transparent;\n pointer-events: none;\n}\n.ant-mentions-measure > span {\n display: inline-block;\n min-height: 1em;\n}\n.ant-mentions-dropdown {\n margin: 0;\n padding: 0;\n color: rgba(0, 0, 0, 0.65);\n font-variant: tabular-nums;\n line-height: 1.5;\n list-style: none;\n font-feature-settings: 'tnum';\n position: absolute;\n top: -9999px;\n left: -9999px;\n z-index: 1050;\n box-sizing: border-box;\n font-size: 14px;\n font-variant: initial;\n background-color: #fff;\n border-radius: 4px;\n outline: none;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n}\n.ant-mentions-dropdown-hidden {\n display: none;\n}\n.ant-mentions-dropdown-menu {\n max-height: 250px;\n margin-bottom: 0;\n padding-left: 0;\n overflow: auto;\n list-style: none;\n outline: none;\n}\n.ant-mentions-dropdown-menu-item {\n position: relative;\n display: block;\n min-width: 100px;\n padding: 5px 12px;\n overflow: hidden;\n color: rgba(0, 0, 0, 0.65);\n font-weight: normal;\n line-height: 22px;\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: pointer;\n transition: background 0.3s ease;\n}\n.ant-mentions-dropdown-menu-item:hover {\n background-color: #e6f7ff;\n}\n.ant-mentions-dropdown-menu-item:first-child {\n border-radius: 4px 4px 0 0;\n}\n.ant-mentions-dropdown-menu-item:last-child {\n border-radius: 0 0 4px 4px;\n}\n.ant-mentions-dropdown-menu-item-disabled {\n color: rgba(0, 0, 0, 0.25);\n cursor: not-allowed;\n}\n.ant-mentions-dropdown-menu-item-disabled:hover {\n color: rgba(0, 0, 0, 0.25);\n background-color: #fff;\n cursor: not-allowed;\n}\n.ant-mentions-dropdown-menu-item-selected {\n color: rgba(0, 0, 0, 0.65);\n font-weight: 600;\n background-color: #fafafa;\n}\n.ant-mentions-dropdown-menu-item-active {\n background-color: #e6f7ff;\n}\n/*# sourceMappingURL=index.css.map */";
|
|
13
|
+
n(css,{"prepend":true});
|
|
14
|
+
|
|
15
|
+
/* tslint:disable: no-object-literal-type-assertion */
|
|
16
|
+
|
|
17
|
+
var MentionsContext = createReactContext(null);
|
|
18
|
+
var MentionsContextProvider = MentionsContext.Provider;
|
|
19
|
+
var MentionsContextConsumer = MentionsContext.Consumer;
|
|
20
|
+
|
|
21
|
+
function _typeof$3(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
|
|
22
|
+
|
|
23
|
+
function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
24
|
+
|
|
25
|
+
function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
26
|
+
|
|
27
|
+
function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); return Constructor; }
|
|
28
|
+
|
|
29
|
+
function _possibleConstructorReturn$3(self, call) { if (call && (_typeof$3(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$3(self); }
|
|
30
|
+
|
|
31
|
+
function _assertThisInitialized$3(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
|
+
|
|
33
|
+
function _getPrototypeOf$3(o) { _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$3(o); }
|
|
34
|
+
|
|
35
|
+
function _inherits$3(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$3(subClass, superClass); }
|
|
36
|
+
|
|
37
|
+
function _setPrototypeOf$3(o, p) { _setPrototypeOf$3 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$3(o, p); }
|
|
38
|
+
/**
|
|
39
|
+
* We only use Menu to display the candidate.
|
|
40
|
+
* The focus is controlled by textarea to make accessibility easy.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
var DropdownMenu =
|
|
44
|
+
/*#__PURE__*/
|
|
45
|
+
function (_React$Component) {
|
|
46
|
+
_inherits$3(DropdownMenu, _React$Component);
|
|
47
|
+
|
|
48
|
+
function DropdownMenu() {
|
|
49
|
+
var _this;
|
|
50
|
+
|
|
51
|
+
_classCallCheck$3(this, DropdownMenu);
|
|
52
|
+
|
|
53
|
+
_this = _possibleConstructorReturn$3(this, _getPrototypeOf$3(DropdownMenu).apply(this, arguments));
|
|
54
|
+
|
|
55
|
+
_this.renderDropdown = function (_ref) {
|
|
56
|
+
var notFoundContent = _ref.notFoundContent,
|
|
57
|
+
activeIndex = _ref.activeIndex,
|
|
58
|
+
setActiveIndex = _ref.setActiveIndex,
|
|
59
|
+
selectOption = _ref.selectOption,
|
|
60
|
+
onFocus = _ref.onFocus,
|
|
61
|
+
onBlur = _ref.onBlur;
|
|
62
|
+
var _this$props = _this.props,
|
|
63
|
+
prefixCls = _this$props.prefixCls,
|
|
64
|
+
options = _this$props.options;
|
|
65
|
+
var activeOption = options[activeIndex] || {};
|
|
66
|
+
return React.createElement(Menu, {
|
|
67
|
+
prefixCls: "".concat(prefixCls, "-menu"),
|
|
68
|
+
activeKey: activeOption.value,
|
|
69
|
+
onSelect: function onSelect(_ref2) {
|
|
70
|
+
var key = _ref2.key;
|
|
71
|
+
var option = options.find(function (_ref3) {
|
|
72
|
+
var value = _ref3.value;
|
|
73
|
+
return value === key;
|
|
74
|
+
});
|
|
75
|
+
selectOption(option);
|
|
76
|
+
},
|
|
77
|
+
onFocus: onFocus,
|
|
78
|
+
onBlur: onBlur
|
|
79
|
+
}, options.map(function (option, index) {
|
|
80
|
+
var value = option.value,
|
|
81
|
+
disabled = option.disabled,
|
|
82
|
+
children = option.children,
|
|
83
|
+
className = option.className,
|
|
84
|
+
style = option.style;
|
|
85
|
+
return React.createElement(connected, {
|
|
86
|
+
key: value,
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
className: className,
|
|
89
|
+
style: style,
|
|
90
|
+
onMouseEnter: function onMouseEnter() {
|
|
91
|
+
setActiveIndex(index);
|
|
92
|
+
}
|
|
93
|
+
}, children);
|
|
94
|
+
}), !options.length && React.createElement(connected, {
|
|
95
|
+
disabled: true
|
|
96
|
+
}, notFoundContent));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return _this;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
_createClass$3(DropdownMenu, [{
|
|
103
|
+
key: "render",
|
|
104
|
+
value: function render() {
|
|
105
|
+
return React.createElement(MentionsContextConsumer, null, this.renderDropdown);
|
|
106
|
+
}
|
|
107
|
+
}]);
|
|
108
|
+
|
|
109
|
+
return DropdownMenu;
|
|
110
|
+
}(React.Component);
|
|
111
|
+
|
|
112
|
+
function _typeof$2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
|
|
113
|
+
|
|
114
|
+
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
115
|
+
|
|
116
|
+
function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
117
|
+
|
|
118
|
+
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); return Constructor; }
|
|
119
|
+
|
|
120
|
+
function _possibleConstructorReturn$2(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$2(self); }
|
|
121
|
+
|
|
122
|
+
function _assertThisInitialized$2(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
123
|
+
|
|
124
|
+
function _getPrototypeOf$2(o) { _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$2(o); }
|
|
125
|
+
|
|
126
|
+
function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$2(subClass, superClass); }
|
|
127
|
+
|
|
128
|
+
function _setPrototypeOf$2(o, p) { _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$2(o, p); }
|
|
129
|
+
var BUILT_IN_PLACEMENTS = {
|
|
130
|
+
bottomRight: {
|
|
131
|
+
points: ['tl', 'br'],
|
|
132
|
+
offset: [0, 4],
|
|
133
|
+
overflow: {
|
|
134
|
+
adjustX: 0,
|
|
135
|
+
adjustY: 1
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
topRight: {
|
|
139
|
+
points: ['bl', 'tr'],
|
|
140
|
+
offset: [0, -4],
|
|
141
|
+
overflow: {
|
|
142
|
+
adjustX: 0,
|
|
143
|
+
adjustY: 1
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
var KeywordTrigger =
|
|
149
|
+
/*#__PURE__*/
|
|
150
|
+
function (_React$Component) {
|
|
151
|
+
_inherits$2(KeywordTrigger, _React$Component);
|
|
152
|
+
|
|
153
|
+
function KeywordTrigger() {
|
|
154
|
+
var _this;
|
|
155
|
+
|
|
156
|
+
_classCallCheck$2(this, KeywordTrigger);
|
|
157
|
+
|
|
158
|
+
_this = _possibleConstructorReturn$2(this, _getPrototypeOf$2(KeywordTrigger).apply(this, arguments));
|
|
159
|
+
|
|
160
|
+
_this.getDropdownPrefix = function () {
|
|
161
|
+
return "".concat(_this.props.prefixCls, "-dropdown");
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
_this.getDropdownElement = function () {
|
|
165
|
+
var options = _this.props.options;
|
|
166
|
+
return React.createElement(DropdownMenu, {
|
|
167
|
+
prefixCls: _this.getDropdownPrefix(),
|
|
168
|
+
options: options
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return _this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_createClass$2(KeywordTrigger, [{
|
|
176
|
+
key: "render",
|
|
177
|
+
value: function render() {
|
|
178
|
+
var _this$props = this.props,
|
|
179
|
+
children = _this$props.children,
|
|
180
|
+
visible = _this$props.visible,
|
|
181
|
+
placement = _this$props.placement,
|
|
182
|
+
transitionName = _this$props.transitionName,
|
|
183
|
+
getPopupContainer = _this$props.getPopupContainer;
|
|
184
|
+
var popupElement = this.getDropdownElement();
|
|
185
|
+
return React.createElement(Trigger, {
|
|
186
|
+
prefixCls: this.getDropdownPrefix(),
|
|
187
|
+
popupVisible: visible,
|
|
188
|
+
popup: popupElement,
|
|
189
|
+
popupPlacement: placement === 'top' ? 'topRight' : 'bottomRight',
|
|
190
|
+
popupTransitionName: transitionName,
|
|
191
|
+
builtinPlacements: BUILT_IN_PLACEMENTS,
|
|
192
|
+
getPopupContainer: getPopupContainer
|
|
193
|
+
}, children);
|
|
194
|
+
}
|
|
195
|
+
}]);
|
|
196
|
+
|
|
197
|
+
return KeywordTrigger;
|
|
198
|
+
}(React.Component);
|
|
199
|
+
|
|
200
|
+
var Option$1 = function Option() {
|
|
201
|
+
return null;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
205
|
+
|
|
206
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
207
|
+
|
|
208
|
+
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
209
|
+
|
|
210
|
+
var omit = function omit(obj) {
|
|
211
|
+
var clone = _objectSpread({}, obj);
|
|
212
|
+
|
|
213
|
+
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
214
|
+
keys[_key - 1] = arguments[_key];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
keys.forEach(function (key) {
|
|
218
|
+
delete clone[key];
|
|
219
|
+
});
|
|
220
|
+
return clone;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Cut input selection into 2 part and return text before selection start
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
function getBeforeSelectionText(input) {
|
|
227
|
+
var selectionStart = input.selectionStart;
|
|
228
|
+
return input.value.slice(0, selectionStart);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Find the last match prefix index
|
|
232
|
+
*/
|
|
233
|
+
|
|
234
|
+
function getLastMeasureIndex(text) {
|
|
235
|
+
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
236
|
+
var prefixList = Array.isArray(prefix) ? prefix : [prefix];
|
|
237
|
+
return prefixList.reduce(function (lastMatch, prefixStr) {
|
|
238
|
+
var lastIndex = text.lastIndexOf(prefixStr);
|
|
239
|
+
|
|
240
|
+
if (lastIndex > lastMatch.location) {
|
|
241
|
+
return {
|
|
242
|
+
location: lastIndex,
|
|
243
|
+
prefix: prefixStr
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return lastMatch;
|
|
248
|
+
}, {
|
|
249
|
+
location: -1,
|
|
250
|
+
prefix: ''
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function lower(char) {
|
|
255
|
+
return (char || '').toLowerCase();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function reduceText(text, targetText, split) {
|
|
259
|
+
var firstChar = text[0];
|
|
260
|
+
|
|
261
|
+
if (!firstChar || firstChar === split) {
|
|
262
|
+
return text;
|
|
263
|
+
} // Reuse rest text as it can
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
var restText = text;
|
|
267
|
+
var targetTextLen = targetText.length;
|
|
268
|
+
|
|
269
|
+
for (var i = 0; i < targetTextLen; i += 1) {
|
|
270
|
+
if (lower(restText[i]) !== lower(targetText[i])) {
|
|
271
|
+
restText = restText.slice(i);
|
|
272
|
+
break;
|
|
273
|
+
} else if (i === targetTextLen - 1) {
|
|
274
|
+
restText = restText.slice(targetTextLen);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return restText;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Paint targetText into current text:
|
|
282
|
+
* text: little@litest
|
|
283
|
+
* targetText: light
|
|
284
|
+
* => little @light test
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
function replaceWithMeasure(text, measureConfig) {
|
|
289
|
+
var measureLocation = measureConfig.measureLocation,
|
|
290
|
+
prefix = measureConfig.prefix,
|
|
291
|
+
targetText = measureConfig.targetText,
|
|
292
|
+
selectionStart = measureConfig.selectionStart,
|
|
293
|
+
split = measureConfig.split; // Before text will append one space if have other text
|
|
294
|
+
|
|
295
|
+
var beforeMeasureText = text.slice(0, measureLocation);
|
|
296
|
+
|
|
297
|
+
if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {
|
|
298
|
+
beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (beforeMeasureText) {
|
|
302
|
+
beforeMeasureText = "".concat(beforeMeasureText).concat(split);
|
|
303
|
+
} // Cut duplicate string with current targetText
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);
|
|
307
|
+
|
|
308
|
+
if (restText.slice(0, split.length) === split) {
|
|
309
|
+
restText = restText.slice(split.length);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var connectedStartText = "".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);
|
|
313
|
+
return {
|
|
314
|
+
text: "".concat(connectedStartText).concat(restText),
|
|
315
|
+
selectionLocation: connectedStartText.length
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function setInputSelection(input, location) {
|
|
319
|
+
input.setSelectionRange(location, location);
|
|
320
|
+
/**
|
|
321
|
+
* Reset caret into view.
|
|
322
|
+
* Since this function always called by user control, it's safe to focus element.
|
|
323
|
+
*/
|
|
324
|
+
|
|
325
|
+
input.blur();
|
|
326
|
+
input.focus();
|
|
327
|
+
}
|
|
328
|
+
function validateSearch(text, props) {
|
|
329
|
+
var split = props.split;
|
|
330
|
+
return !split || text.indexOf(split) === -1;
|
|
331
|
+
}
|
|
332
|
+
function filterOption(input, _ref) {
|
|
333
|
+
var _ref$value = _ref.value,
|
|
334
|
+
value = _ref$value === void 0 ? '' : _ref$value;
|
|
335
|
+
var lowerCase = input.toLowerCase();
|
|
336
|
+
return value.toLowerCase().indexOf(lowerCase) !== -1;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function _typeof$1(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
340
|
+
|
|
341
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
342
|
+
|
|
343
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
344
|
+
|
|
345
|
+
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
346
|
+
|
|
347
|
+
function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
348
|
+
|
|
349
|
+
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
350
|
+
|
|
351
|
+
function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
|
|
352
|
+
|
|
353
|
+
function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
354
|
+
|
|
355
|
+
function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
|
|
356
|
+
|
|
357
|
+
function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
|
|
358
|
+
|
|
359
|
+
function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
|
|
360
|
+
|
|
361
|
+
var Mentions$1 =
|
|
362
|
+
/*#__PURE__*/
|
|
363
|
+
function (_React$Component) {
|
|
364
|
+
_inherits$1(Mentions, _React$Component);
|
|
365
|
+
|
|
366
|
+
function Mentions(props) {
|
|
367
|
+
var _this;
|
|
368
|
+
|
|
369
|
+
_classCallCheck$1(this, Mentions);
|
|
370
|
+
|
|
371
|
+
_this = _possibleConstructorReturn$1(this, _getPrototypeOf$1(Mentions).call(this, props));
|
|
372
|
+
_this.focusId = undefined;
|
|
373
|
+
|
|
374
|
+
_this.triggerChange = function (value) {
|
|
375
|
+
var onChange = _this.props.onChange;
|
|
376
|
+
|
|
377
|
+
if (!('value' in _this.props)) {
|
|
378
|
+
_this.setState({
|
|
379
|
+
value: value
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (onChange) {
|
|
384
|
+
onChange(value);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
_this.onChange = function (_ref) {
|
|
389
|
+
var value = _ref.target.value;
|
|
390
|
+
|
|
391
|
+
_this.triggerChange(value);
|
|
392
|
+
}; // Check if hit the measure keyword
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
_this.onKeyDown = function (event) {
|
|
396
|
+
var which = event.which;
|
|
397
|
+
var _this$state = _this.state,
|
|
398
|
+
activeIndex = _this$state.activeIndex,
|
|
399
|
+
measuring = _this$state.measuring; // Skip if not measuring
|
|
400
|
+
|
|
401
|
+
if (!measuring) {
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (which === KeyCode.UP || which === KeyCode.DOWN) {
|
|
406
|
+
// Control arrow function
|
|
407
|
+
var optionLen = _this.getOptions().length;
|
|
408
|
+
|
|
409
|
+
var offset = which === KeyCode.UP ? -1 : 1;
|
|
410
|
+
var newActiveIndex = (activeIndex + offset + optionLen) % optionLen;
|
|
411
|
+
|
|
412
|
+
_this.setState({
|
|
413
|
+
activeIndex: newActiveIndex
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
event.preventDefault();
|
|
417
|
+
} else if (which === KeyCode.ESC) {
|
|
418
|
+
_this.stopMeasure();
|
|
419
|
+
} else if (which === KeyCode.ENTER) {
|
|
420
|
+
// Measure hit
|
|
421
|
+
var option = _this.getOptions()[activeIndex];
|
|
422
|
+
|
|
423
|
+
_this.selectOption(option);
|
|
424
|
+
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* When to start measure:
|
|
430
|
+
* 1. When user press `prefix`
|
|
431
|
+
* 2. When measureText !== prevMeasureText
|
|
432
|
+
* - If measure hit
|
|
433
|
+
* - If measuring
|
|
434
|
+
*
|
|
435
|
+
* When to stop measure:
|
|
436
|
+
* 1. Selection is out of range
|
|
437
|
+
* 2. Contains `space`
|
|
438
|
+
* 3. ESC or select one
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
_this.onKeyUp = function (event) {
|
|
443
|
+
var key = event.key,
|
|
444
|
+
which = event.which;
|
|
445
|
+
var _this$state2 = _this.state,
|
|
446
|
+
prevMeasureText = _this$state2.measureText,
|
|
447
|
+
measuring = _this$state2.measuring;
|
|
448
|
+
var _this$props = _this.props,
|
|
449
|
+
_this$props$prefix = _this$props.prefix,
|
|
450
|
+
prefix = _this$props$prefix === void 0 ? '' : _this$props$prefix,
|
|
451
|
+
onSearch = _this$props.onSearch,
|
|
452
|
+
validateSearch = _this$props.validateSearch;
|
|
453
|
+
var target = event.target;
|
|
454
|
+
var selectionStartText = getBeforeSelectionText(target);
|
|
455
|
+
|
|
456
|
+
var _getLastMeasureIndex = getLastMeasureIndex(selectionStartText, prefix),
|
|
457
|
+
measureIndex = _getLastMeasureIndex.location,
|
|
458
|
+
measurePrefix = _getLastMeasureIndex.prefix; // Skip if match the white key list
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (measureIndex !== -1) {
|
|
466
|
+
var measureText = selectionStartText.slice(measureIndex + measurePrefix.length);
|
|
467
|
+
var validateMeasure = validateSearch(measureText, _this.props);
|
|
468
|
+
var matchOption = !!_this.getOptions(measureText).length;
|
|
469
|
+
|
|
470
|
+
if (validateMeasure) {
|
|
471
|
+
if (key === measurePrefix || measuring || measureText !== prevMeasureText && matchOption) {
|
|
472
|
+
_this.startMeasure(measureText, measurePrefix, measureIndex);
|
|
473
|
+
}
|
|
474
|
+
} else if (measuring) {
|
|
475
|
+
// Stop if measureText is invalidate
|
|
476
|
+
_this.stopMeasure();
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* We will trigger `onSearch` to developer since they may use for async update.
|
|
480
|
+
* If met `space` means user finished searching.
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
if (onSearch && validateMeasure) {
|
|
485
|
+
onSearch(measureText, measurePrefix);
|
|
486
|
+
}
|
|
487
|
+
} else if (measuring) {
|
|
488
|
+
_this.stopMeasure();
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
_this.onInputFocus = function (event) {
|
|
493
|
+
_this.onFocus(event);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
_this.onInputBlur = function (event) {
|
|
497
|
+
_this.onBlur(event);
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
_this.onDropdownFocus = function () {
|
|
501
|
+
_this.onFocus();
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
_this.onDropdownBlur = function () {
|
|
505
|
+
_this.onBlur();
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
_this.onFocus = function (event) {
|
|
509
|
+
window.clearTimeout(_this.focusId);
|
|
510
|
+
var isFocus = _this.state.isFocus;
|
|
511
|
+
var onFocus = _this.props.onFocus;
|
|
512
|
+
|
|
513
|
+
if (!isFocus && event && onFocus) {
|
|
514
|
+
onFocus(event);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
_this.setState({
|
|
518
|
+
isFocus: true
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
_this.onBlur = function (event) {
|
|
523
|
+
_this.focusId = window.setTimeout(function () {
|
|
524
|
+
var onBlur = _this.props.onBlur;
|
|
525
|
+
|
|
526
|
+
_this.setState({
|
|
527
|
+
isFocus: false
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
_this.stopMeasure();
|
|
531
|
+
|
|
532
|
+
if (onBlur) {
|
|
533
|
+
onBlur(event);
|
|
534
|
+
}
|
|
535
|
+
}, 0);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
_this.selectOption = function (option) {
|
|
539
|
+
var _this$state3 = _this.state,
|
|
540
|
+
value = _this$state3.value,
|
|
541
|
+
measureLocation = _this$state3.measureLocation,
|
|
542
|
+
measurePrefix = _this$state3.measurePrefix;
|
|
543
|
+
var _this$props2 = _this.props,
|
|
544
|
+
split = _this$props2.split,
|
|
545
|
+
onSelect = _this$props2.onSelect;
|
|
546
|
+
var _option$value = option.value,
|
|
547
|
+
mentionValue = _option$value === void 0 ? '' : _option$value;
|
|
548
|
+
|
|
549
|
+
var _replaceWithMeasure = replaceWithMeasure(value, {
|
|
550
|
+
measureLocation: measureLocation,
|
|
551
|
+
targetText: mentionValue,
|
|
552
|
+
prefix: measurePrefix,
|
|
553
|
+
selectionStart: _this.textarea.selectionStart,
|
|
554
|
+
split: split
|
|
555
|
+
}),
|
|
556
|
+
text = _replaceWithMeasure.text,
|
|
557
|
+
selectionLocation = _replaceWithMeasure.selectionLocation;
|
|
558
|
+
|
|
559
|
+
_this.triggerChange(text);
|
|
560
|
+
|
|
561
|
+
_this.stopMeasure(function () {
|
|
562
|
+
// We need restore the selection position
|
|
563
|
+
setInputSelection(_this.textarea, selectionLocation);
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
if (onSelect) {
|
|
567
|
+
onSelect(option, measurePrefix);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
_this.setActiveIndex = function (activeIndex) {
|
|
572
|
+
_this.setState({
|
|
573
|
+
activeIndex: activeIndex
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
_this.setTextAreaRef = function (element) {
|
|
578
|
+
_this.textarea = element;
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
_this.setMeasureRef = function (element) {
|
|
582
|
+
_this.measure = element;
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
_this.getOptions = function (measureText) {
|
|
586
|
+
var targetMeasureText = measureText || _this.state.measureText || '';
|
|
587
|
+
var _this$props3 = _this.props,
|
|
588
|
+
children = _this$props3.children,
|
|
589
|
+
filterOption = _this$props3.filterOption;
|
|
590
|
+
var list = toArray(children).map(function (_ref2) {
|
|
591
|
+
var props = _ref2.props;
|
|
592
|
+
return props;
|
|
593
|
+
}).filter(function (option) {
|
|
594
|
+
/** Return all result if `filterOption` is false. */
|
|
595
|
+
if (filterOption === false) {
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
return filterOption(targetMeasureText, option);
|
|
600
|
+
});
|
|
601
|
+
return list;
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
_this.state = {
|
|
605
|
+
value: props.defaultValue || props.value || '',
|
|
606
|
+
measuring: false,
|
|
607
|
+
measureLocation: 0,
|
|
608
|
+
measureText: null,
|
|
609
|
+
measurePrefix: '',
|
|
610
|
+
activeIndex: 0,
|
|
611
|
+
isFocus: false
|
|
612
|
+
};
|
|
613
|
+
return _this;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
_createClass$1(Mentions, [{
|
|
617
|
+
key: "componentDidUpdate",
|
|
618
|
+
value: function componentDidUpdate() {
|
|
619
|
+
var measuring = this.state.measuring; // Sync measure div top with textarea for rc-trigger usage
|
|
620
|
+
|
|
621
|
+
if (measuring) {
|
|
622
|
+
this.measure.scrollTop = this.textarea.scrollTop;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}, {
|
|
626
|
+
key: "startMeasure",
|
|
627
|
+
value: function startMeasure(measureText, measurePrefix, measureLocation) {
|
|
628
|
+
this.setState({
|
|
629
|
+
measuring: true,
|
|
630
|
+
measureText: measureText,
|
|
631
|
+
measurePrefix: measurePrefix,
|
|
632
|
+
measureLocation: measureLocation,
|
|
633
|
+
activeIndex: 0
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}, {
|
|
637
|
+
key: "stopMeasure",
|
|
638
|
+
value: function stopMeasure(callback) {
|
|
639
|
+
this.setState({
|
|
640
|
+
measuring: false,
|
|
641
|
+
measureLocation: 0,
|
|
642
|
+
measureText: null
|
|
643
|
+
}, callback);
|
|
644
|
+
}
|
|
645
|
+
}, {
|
|
646
|
+
key: "focus",
|
|
647
|
+
value: function focus() {
|
|
648
|
+
this.textarea.focus();
|
|
649
|
+
}
|
|
650
|
+
}, {
|
|
651
|
+
key: "blur",
|
|
652
|
+
value: function blur() {
|
|
653
|
+
this.textarea.blur();
|
|
654
|
+
}
|
|
655
|
+
}, {
|
|
656
|
+
key: "render",
|
|
657
|
+
value: function render() {
|
|
658
|
+
var _this$state4 = this.state,
|
|
659
|
+
value = _this$state4.value,
|
|
660
|
+
measureLocation = _this$state4.measureLocation,
|
|
661
|
+
measurePrefix = _this$state4.measurePrefix,
|
|
662
|
+
measuring = _this$state4.measuring,
|
|
663
|
+
activeIndex = _this$state4.activeIndex;
|
|
664
|
+
|
|
665
|
+
var _this$props4 = this.props,
|
|
666
|
+
prefixCls = _this$props4.prefixCls,
|
|
667
|
+
placement = _this$props4.placement,
|
|
668
|
+
transitionName = _this$props4.transitionName,
|
|
669
|
+
className = _this$props4.className,
|
|
670
|
+
style = _this$props4.style,
|
|
671
|
+
autoFocus = _this$props4.autoFocus,
|
|
672
|
+
notFoundContent = _this$props4.notFoundContent,
|
|
673
|
+
getPopupContainer = _this$props4.getPopupContainer,
|
|
674
|
+
restProps = _objectWithoutProperties(_this$props4, ["prefixCls", "placement", "transitionName", "className", "style", "autoFocus", "notFoundContent", "getPopupContainer"]);
|
|
675
|
+
|
|
676
|
+
var inputProps = omit(restProps, 'value', 'defaultValue', 'prefix', 'split', 'children', 'validateSearch', 'filterOption', 'onSelect', 'onSearch');
|
|
677
|
+
var options = measuring ? this.getOptions() : [];
|
|
678
|
+
return React.createElement("div", {
|
|
679
|
+
className: classNames(prefixCls, className),
|
|
680
|
+
style: style
|
|
681
|
+
}, React.createElement("textarea", Object.assign({
|
|
682
|
+
autoFocus: autoFocus,
|
|
683
|
+
ref: this.setTextAreaRef,
|
|
684
|
+
value: value
|
|
685
|
+
}, inputProps, {
|
|
686
|
+
onChange: this.onChange,
|
|
687
|
+
onKeyDown: this.onKeyDown,
|
|
688
|
+
onKeyUp: this.onKeyUp,
|
|
689
|
+
onFocus: this.onInputFocus,
|
|
690
|
+
onBlur: this.onInputBlur
|
|
691
|
+
})), measuring && React.createElement("div", {
|
|
692
|
+
ref: this.setMeasureRef,
|
|
693
|
+
className: "".concat(prefixCls, "-measure")
|
|
694
|
+
}, value.slice(0, measureLocation), React.createElement(MentionsContextProvider, {
|
|
695
|
+
value: {
|
|
696
|
+
notFoundContent: notFoundContent,
|
|
697
|
+
activeIndex: activeIndex,
|
|
698
|
+
setActiveIndex: this.setActiveIndex,
|
|
699
|
+
selectOption: this.selectOption,
|
|
700
|
+
onFocus: this.onDropdownFocus,
|
|
701
|
+
onBlur: this.onDropdownBlur
|
|
702
|
+
}
|
|
703
|
+
}, React.createElement(KeywordTrigger, {
|
|
704
|
+
prefixCls: prefixCls,
|
|
705
|
+
transitionName: transitionName,
|
|
706
|
+
placement: placement,
|
|
707
|
+
options: options,
|
|
708
|
+
visible: true,
|
|
709
|
+
getPopupContainer: getPopupContainer
|
|
710
|
+
}, React.createElement("span", null, measurePrefix))), value.slice(measureLocation + measurePrefix.length)));
|
|
711
|
+
}
|
|
712
|
+
}], [{
|
|
713
|
+
key: "getDerivedStateFromProps",
|
|
714
|
+
value: function getDerivedStateFromProps(props, prevState) {
|
|
715
|
+
var newState = {};
|
|
716
|
+
|
|
717
|
+
if ('value' in props && props.value !== prevState.value) {
|
|
718
|
+
newState.value = props.value || '';
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
return newState;
|
|
722
|
+
}
|
|
723
|
+
}]);
|
|
724
|
+
|
|
725
|
+
return Mentions;
|
|
726
|
+
}(React.Component);
|
|
727
|
+
|
|
728
|
+
Mentions$1.Option = Option$1;
|
|
729
|
+
Mentions$1.defaultProps = {
|
|
730
|
+
prefixCls: 'rc-mentions',
|
|
731
|
+
prefix: '@',
|
|
732
|
+
split: ' ',
|
|
733
|
+
validateSearch: validateSearch,
|
|
734
|
+
filterOption: filterOption,
|
|
735
|
+
notFoundContent: 'Not Found',
|
|
736
|
+
rows: 1
|
|
737
|
+
};
|
|
738
|
+
polyfill(Mentions$1);
|
|
739
|
+
|
|
740
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
741
|
+
|
|
742
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
743
|
+
|
|
744
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
745
|
+
|
|
746
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
747
|
+
|
|
748
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
749
|
+
|
|
750
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
|
|
751
|
+
|
|
752
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
753
|
+
|
|
754
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
755
|
+
|
|
756
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
757
|
+
|
|
758
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
759
|
+
|
|
760
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
761
|
+
|
|
762
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
763
|
+
|
|
764
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
765
|
+
|
|
766
|
+
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
767
|
+
var t = {};
|
|
768
|
+
|
|
769
|
+
for (var p in s) {
|
|
770
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
774
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
775
|
+
}
|
|
776
|
+
return t;
|
|
777
|
+
};
|
|
778
|
+
var Option = Mentions$1.Option;
|
|
779
|
+
|
|
780
|
+
function loadingFilterOption() {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
var Mentions = /*#__PURE__*/function (_React$Component) {
|
|
785
|
+
_inherits(Mentions, _React$Component);
|
|
786
|
+
|
|
787
|
+
var _super = _createSuper(Mentions);
|
|
788
|
+
|
|
789
|
+
function Mentions() {
|
|
790
|
+
var _this;
|
|
791
|
+
|
|
792
|
+
_classCallCheck(this, Mentions);
|
|
793
|
+
|
|
794
|
+
_this = _super.apply(this, arguments);
|
|
795
|
+
_this.state = {
|
|
796
|
+
focused: false
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
_this.onFocus = function () {
|
|
800
|
+
var onFocus = _this.props.onFocus;
|
|
801
|
+
|
|
802
|
+
if (onFocus) {
|
|
803
|
+
onFocus.apply(void 0, arguments);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
_this.setState({
|
|
807
|
+
focused: true
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
_this.onBlur = function () {
|
|
812
|
+
var onBlur = _this.props.onBlur;
|
|
813
|
+
|
|
814
|
+
if (onBlur) {
|
|
815
|
+
onBlur.apply(void 0, arguments);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
_this.setState({
|
|
819
|
+
focused: false
|
|
820
|
+
});
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
_this.getOptions = function () {
|
|
824
|
+
var _this$props = _this.props,
|
|
825
|
+
children = _this$props.children,
|
|
826
|
+
loading = _this$props.loading;
|
|
827
|
+
|
|
828
|
+
if (loading) {
|
|
829
|
+
return /*#__PURE__*/React.createElement(Option, {
|
|
830
|
+
value: "ANTD_SEARCHING",
|
|
831
|
+
disabled: true
|
|
832
|
+
}, /*#__PURE__*/React.createElement(Spin, {
|
|
833
|
+
size: "small"
|
|
834
|
+
}));
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
return children;
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
_this.getFilterOption = function () {
|
|
841
|
+
var _this$props2 = _this.props,
|
|
842
|
+
filterOption = _this$props2.filterOption,
|
|
843
|
+
loading = _this$props2.loading;
|
|
844
|
+
|
|
845
|
+
if (loading) {
|
|
846
|
+
return loadingFilterOption;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
return filterOption;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
_this.saveMentions = function (node) {
|
|
853
|
+
_this.rcMentions = node;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
_this.renderMentions = function (_ref) {
|
|
857
|
+
var _classNames;
|
|
858
|
+
|
|
859
|
+
var getPrefixCls = _ref.getPrefixCls,
|
|
860
|
+
renderEmpty = _ref.renderEmpty;
|
|
861
|
+
var focused = _this.state.focused;
|
|
862
|
+
|
|
863
|
+
var _a = _this.props,
|
|
864
|
+
customizePrefixCls = _a.prefixCls,
|
|
865
|
+
className = _a.className,
|
|
866
|
+
disabled = _a.disabled,
|
|
867
|
+
restProps = __rest(_a, ["prefixCls", "className", "disabled"]);
|
|
868
|
+
|
|
869
|
+
var prefixCls = getPrefixCls('mentions', customizePrefixCls);
|
|
870
|
+
var mentionsProps = omit$1(restProps, ['loading']);
|
|
871
|
+
var mergedClassName = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-focused"), focused), _classNames));
|
|
872
|
+
return /*#__PURE__*/React.createElement(Mentions$1, _extends({
|
|
873
|
+
prefixCls: prefixCls,
|
|
874
|
+
notFoundContent: _this.getNotFoundContent(renderEmpty),
|
|
875
|
+
className: mergedClassName,
|
|
876
|
+
disabled: disabled
|
|
877
|
+
}, mentionsProps, {
|
|
878
|
+
filterOption: _this.getFilterOption(),
|
|
879
|
+
onFocus: _this.onFocus,
|
|
880
|
+
onBlur: _this.onBlur,
|
|
881
|
+
ref: _this.saveMentions
|
|
882
|
+
}), _this.getOptions());
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
return _this;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
_createClass(Mentions, [{
|
|
889
|
+
key: "getNotFoundContent",
|
|
890
|
+
value: function getNotFoundContent(renderEmpty) {
|
|
891
|
+
var notFoundContent = this.props.notFoundContent;
|
|
892
|
+
|
|
893
|
+
if (notFoundContent !== undefined) {
|
|
894
|
+
return notFoundContent;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return renderEmpty('Select');
|
|
898
|
+
}
|
|
899
|
+
}, {
|
|
900
|
+
key: "focus",
|
|
901
|
+
value: function focus() {
|
|
902
|
+
this.rcMentions.focus();
|
|
903
|
+
}
|
|
904
|
+
}, {
|
|
905
|
+
key: "blur",
|
|
906
|
+
value: function blur() {
|
|
907
|
+
this.rcMentions.blur();
|
|
908
|
+
}
|
|
909
|
+
}, {
|
|
910
|
+
key: "render",
|
|
911
|
+
value: function render() {
|
|
912
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderMentions);
|
|
913
|
+
}
|
|
914
|
+
}]);
|
|
915
|
+
|
|
916
|
+
return Mentions;
|
|
917
|
+
}(React.Component);
|
|
918
|
+
|
|
919
|
+
Mentions.Option = Option;
|
|
920
|
+
|
|
921
|
+
Mentions.getMentions = function () {
|
|
922
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
923
|
+
var config = arguments.length > 1 ? arguments[1] : undefined;
|
|
924
|
+
|
|
925
|
+
var _ref2 = config || {},
|
|
926
|
+
_ref2$prefix = _ref2.prefix,
|
|
927
|
+
prefix = _ref2$prefix === void 0 ? '@' : _ref2$prefix,
|
|
928
|
+
_ref2$split = _ref2.split,
|
|
929
|
+
split = _ref2$split === void 0 ? ' ' : _ref2$split;
|
|
930
|
+
|
|
931
|
+
var prefixList = Array.isArray(prefix) ? prefix : [prefix];
|
|
932
|
+
return value.split(split).map(function () {
|
|
933
|
+
var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
934
|
+
var hitPrefix = null;
|
|
935
|
+
prefixList.some(function (prefixStr) {
|
|
936
|
+
var startStr = str.slice(0, prefixStr.length);
|
|
937
|
+
|
|
938
|
+
if (startStr === prefixStr) {
|
|
939
|
+
hitPrefix = prefixStr;
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
return false;
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
if (hitPrefix !== null) {
|
|
947
|
+
return {
|
|
948
|
+
prefix: hitPrefix,
|
|
949
|
+
value: str.slice(hitPrefix.length)
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
return null;
|
|
954
|
+
}).filter(function (entity) {
|
|
955
|
+
return !!entity && !!entity.value;
|
|
956
|
+
});
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
polyfill(Mentions);
|
|
960
|
+
|
|
961
|
+
export { Mentions as default };
|