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,1246 @@
|
|
|
1
|
+
import { n, C as ConfigConsumer, c as classNames, g as getDefaultExportFromCjs, s as withConfigConsumer, w as warning, L as LocaleReceiver, v as configConsumerProps } from '../../config-provider.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { K as KeyCode, p as polyfill, j as findDOMNode } from '../../menu.js';
|
|
4
|
+
import { t as toArray, w as warning$1 } from '../../tree.js';
|
|
5
|
+
import { o as omit, a as tupleNum } from '../../input.js';
|
|
6
|
+
import { R as ResizeObserver } from '../../index2.js';
|
|
7
|
+
import { T as TransButton } from '../../transButton.js';
|
|
8
|
+
import { w as wrapperRaf } from '../../raf.js';
|
|
9
|
+
import { I as Icon } from '../../icon.js';
|
|
10
|
+
import { T as Tooltip } from '../../index6.js';
|
|
11
|
+
import { T as TextArea } from '../../TextArea.js';
|
|
12
|
+
import { render, unmountComponentAtNode } from 'react-dom';
|
|
13
|
+
import '../../warning.js';
|
|
14
|
+
|
|
15
|
+
var isStyleSupport = function isStyleSupport(styleName) {
|
|
16
|
+
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
|
|
17
|
+
var styleNameList = Array.isArray(styleName) ? styleName : [styleName];
|
|
18
|
+
var documentElement = window.document.documentElement;
|
|
19
|
+
return styleNameList.some(function (name) {
|
|
20
|
+
return name in documentElement.style;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
isStyleSupport(['flex', 'webkitFlex', 'Flex', 'msFlex']);
|
|
28
|
+
|
|
29
|
+
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-typography {\n color: rgba(0, 0, 0, 0.65);\n}\n.ant-typography.ant-typography-secondary {\n color: rgba(0, 0, 0, 0.45);\n}\n.ant-typography.ant-typography-warning {\n color: #faad14;\n}\n.ant-typography.ant-typography-danger {\n color: #f5222d;\n}\n.ant-typography.ant-typography-disabled {\n color: rgba(0, 0, 0, 0.25);\n cursor: not-allowed;\n user-select: none;\n}\ndiv.ant-typography,\n.ant-typography p {\n margin-bottom: 1em;\n}\nh1.ant-typography,\n.ant-typography h1 {\n margin-bottom: 0.5em;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 600;\n font-size: 38px;\n line-height: 1.23;\n}\nh2.ant-typography,\n.ant-typography h2 {\n margin-bottom: 0.5em;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 600;\n font-size: 30px;\n line-height: 1.35;\n}\nh3.ant-typography,\n.ant-typography h3 {\n margin-bottom: 0.5em;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 600;\n font-size: 24px;\n line-height: 1.35;\n}\nh4.ant-typography,\n.ant-typography h4 {\n margin-bottom: 0.5em;\n color: rgba(0, 0, 0, 0.85);\n font-weight: 600;\n font-size: 20px;\n line-height: 1.4;\n}\n.ant-typography + h1.ant-typography,\n.ant-typography + h2.ant-typography,\n.ant-typography + h3.ant-typography,\n.ant-typography + h4.ant-typography {\n margin-top: 1.2em;\n}\n.ant-typography div + h1,\n.ant-typography ul + h1,\n.ant-typography li + h1,\n.ant-typography p + h1,\n.ant-typography h1 + h1,\n.ant-typography h2 + h1,\n.ant-typography h3 + h1,\n.ant-typography h4 + h1,\n.ant-typography div + h2,\n.ant-typography ul + h2,\n.ant-typography li + h2,\n.ant-typography p + h2,\n.ant-typography h1 + h2,\n.ant-typography h2 + h2,\n.ant-typography h3 + h2,\n.ant-typography h4 + h2,\n.ant-typography div + h3,\n.ant-typography ul + h3,\n.ant-typography li + h3,\n.ant-typography p + h3,\n.ant-typography h1 + h3,\n.ant-typography h2 + h3,\n.ant-typography h3 + h3,\n.ant-typography h4 + h3,\n.ant-typography div + h4,\n.ant-typography ul + h4,\n.ant-typography li + h4,\n.ant-typography p + h4,\n.ant-typography h1 + h4,\n.ant-typography h2 + h4,\n.ant-typography h3 + h4,\n.ant-typography h4 + h4 {\n margin-top: 1.2em;\n}\nspan.ant-typography-ellipsis {\n display: inline-block;\n}\n.ant-typography a {\n color: #1890ff;\n text-decoration: none;\n outline: none;\n cursor: pointer;\n transition: color 0.3s;\n}\n.ant-typography a:focus,\n.ant-typography a:hover {\n color: #40a9ff;\n}\n.ant-typography a:active {\n color: #096dd9;\n}\n.ant-typography a:active,\n.ant-typography a:hover {\n text-decoration: none;\n}\n.ant-typography a[disabled] {\n color: rgba(0, 0, 0, 0.25);\n cursor: not-allowed;\n pointer-events: none;\n}\n.ant-typography code {\n margin: 0 0.2em;\n padding: 0.2em 0.4em 0.1em;\n font-size: 85%;\n background: rgba(0, 0, 0, 0.06);\n border: 1px solid rgba(0, 0, 0, 0.06);\n border-radius: 3px;\n}\n.ant-typography mark {\n padding: 0;\n background-color: #ffe58f;\n}\n.ant-typography u,\n.ant-typography ins {\n text-decoration: underline;\n text-decoration-skip-ink: auto;\n}\n.ant-typography s,\n.ant-typography del {\n text-decoration: line-through;\n}\n.ant-typography strong {\n font-weight: 600;\n}\n.ant-typography-expand,\n.ant-typography-edit,\n.ant-typography-copy {\n color: #1890ff;\n text-decoration: none;\n outline: none;\n cursor: pointer;\n transition: color 0.3s;\n margin-left: 8px;\n}\n.ant-typography-expand:focus,\n.ant-typography-edit:focus,\n.ant-typography-copy:focus,\n.ant-typography-expand:hover,\n.ant-typography-edit:hover,\n.ant-typography-copy:hover {\n color: #40a9ff;\n}\n.ant-typography-expand:active,\n.ant-typography-edit:active,\n.ant-typography-copy:active {\n color: #096dd9;\n}\n.ant-typography-copy-success,\n.ant-typography-copy-success:hover,\n.ant-typography-copy-success:focus {\n color: #52c41a;\n}\n.ant-typography-edit-content {\n position: relative;\n}\ndiv.ant-typography-edit-content {\n left: -12px;\n margin-top: -5px;\n margin-bottom: calc(1em - 4px - 2px);\n}\n.ant-typography-edit-content-confirm {\n position: absolute;\n right: 10px;\n bottom: 8px;\n color: rgba(0, 0, 0, 0.45);\n pointer-events: none;\n}\n.ant-typography-edit-content textarea {\n -moz-transition: none;\n}\n.ant-typography ul,\n.ant-typography ol {\n margin: 0 0 1em 0;\n padding: 0;\n}\n.ant-typography ul li,\n.ant-typography ol li {\n margin: 0 0 0 20px;\n padding: 0 0 0 4px;\n}\n.ant-typography ul li {\n list-style-type: circle;\n}\n.ant-typography ul li li {\n list-style-type: disc;\n}\n.ant-typography ol li {\n list-style-type: decimal;\n}\n.ant-typography-ellipsis-single-line {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.ant-typography-ellipsis-multiple-line {\n display: -webkit-box;\n -webkit-line-clamp: 3;\n /*! autoprefixer: ignore next */\n -webkit-box-orient: vertical;\n overflow: hidden;\n}\n/*# sourceMappingURL=index.css.map */";
|
|
30
|
+
n(css,{"prepend":true});
|
|
31
|
+
|
|
32
|
+
function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
|
|
33
|
+
|
|
34
|
+
function fillRef(ref, node) {
|
|
35
|
+
if (typeof ref === 'function') {
|
|
36
|
+
ref(node);
|
|
37
|
+
} else if (_typeof$4(ref) === 'object' && ref && 'current' in ref) {
|
|
38
|
+
ref.current = node;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function composeRef() {
|
|
42
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
|
+
refs[_key] = arguments[_key];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return function (node) {
|
|
47
|
+
refs.forEach(function (ref) {
|
|
48
|
+
fillRef(ref, node);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _typeof$3(obj) { "@babel/helpers - typeof"; 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); }
|
|
54
|
+
|
|
55
|
+
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
56
|
+
|
|
57
|
+
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); } }
|
|
58
|
+
|
|
59
|
+
function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); return Constructor; }
|
|
60
|
+
|
|
61
|
+
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); }
|
|
62
|
+
|
|
63
|
+
function _setPrototypeOf$2(o, p) { _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$2(o, p); }
|
|
64
|
+
|
|
65
|
+
function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf$2(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$2(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$2(this, result); }; }
|
|
66
|
+
|
|
67
|
+
function _possibleConstructorReturn$2(self, call) { if (call && (_typeof$3(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$2(self); }
|
|
68
|
+
|
|
69
|
+
function _assertThisInitialized$2(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
70
|
+
|
|
71
|
+
function _isNativeReflectConstruct$2() { 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; } }
|
|
72
|
+
|
|
73
|
+
function _getPrototypeOf$2(o) { _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$2(o); }
|
|
74
|
+
|
|
75
|
+
function _extends$4() { _extends$4 = 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$4.apply(this, arguments); }
|
|
76
|
+
|
|
77
|
+
var __rest$3 = undefined && undefined.__rest || function (s, e) {
|
|
78
|
+
var t = {};
|
|
79
|
+
|
|
80
|
+
for (var p in s) {
|
|
81
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
85
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var Typography$1 = function Typography(_a, ref) {
|
|
91
|
+
var customizePrefixCls = _a.prefixCls,
|
|
92
|
+
_a$component = _a.component,
|
|
93
|
+
component = _a$component === void 0 ? 'article' : _a$component,
|
|
94
|
+
className = _a.className,
|
|
95
|
+
ariaLabel = _a['aria-label'],
|
|
96
|
+
setContentRef = _a.setContentRef,
|
|
97
|
+
children = _a.children,
|
|
98
|
+
restProps = __rest$3(_a, ["prefixCls", "component", "className", 'aria-label', "setContentRef", "children"]);
|
|
99
|
+
|
|
100
|
+
var mergedRef = ref;
|
|
101
|
+
|
|
102
|
+
if (setContentRef) {
|
|
103
|
+
mergedRef = composeRef(ref, setContentRef);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (_ref) {
|
|
107
|
+
var getPrefixCls = _ref.getPrefixCls;
|
|
108
|
+
var Component = component;
|
|
109
|
+
var prefixCls = getPrefixCls('typography', customizePrefixCls);
|
|
110
|
+
return /*#__PURE__*/React.createElement(Component, _extends$4({
|
|
111
|
+
className: classNames(prefixCls, className),
|
|
112
|
+
"aria-label": ariaLabel,
|
|
113
|
+
ref: mergedRef
|
|
114
|
+
}, restProps), children);
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
var RefTypography;
|
|
119
|
+
|
|
120
|
+
if (React.forwardRef) {
|
|
121
|
+
RefTypography = /*#__PURE__*/React.forwardRef(Typography$1);
|
|
122
|
+
RefTypography.displayName = 'Typography';
|
|
123
|
+
} else {
|
|
124
|
+
var TypographyWrapper = /*#__PURE__*/function (_React$Component) {
|
|
125
|
+
_inherits$2(TypographyWrapper, _React$Component);
|
|
126
|
+
|
|
127
|
+
var _super = _createSuper$2(TypographyWrapper);
|
|
128
|
+
|
|
129
|
+
function TypographyWrapper() {
|
|
130
|
+
var _this;
|
|
131
|
+
|
|
132
|
+
_classCallCheck$2(this, TypographyWrapper);
|
|
133
|
+
|
|
134
|
+
_this = _super.apply(this, arguments);
|
|
135
|
+
_this.state = {};
|
|
136
|
+
return _this;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_createClass$2(TypographyWrapper, [{
|
|
140
|
+
key: "render",
|
|
141
|
+
value: function render() {
|
|
142
|
+
return /*#__PURE__*/React.createElement(Typography$1, this.props);
|
|
143
|
+
}
|
|
144
|
+
}]);
|
|
145
|
+
|
|
146
|
+
return TypographyWrapper;
|
|
147
|
+
}(React.Component);
|
|
148
|
+
|
|
149
|
+
RefTypography = TypographyWrapper;
|
|
150
|
+
} // es default export should use const instead of let
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
var ExportTypography = RefTypography;
|
|
154
|
+
|
|
155
|
+
var toggleSelection;
|
|
156
|
+
var hasRequiredToggleSelection;
|
|
157
|
+
|
|
158
|
+
function requireToggleSelection () {
|
|
159
|
+
if (hasRequiredToggleSelection) return toggleSelection;
|
|
160
|
+
hasRequiredToggleSelection = 1;
|
|
161
|
+
toggleSelection = function () {
|
|
162
|
+
var selection = document.getSelection();
|
|
163
|
+
if (!selection.rangeCount) {
|
|
164
|
+
return function () {};
|
|
165
|
+
}
|
|
166
|
+
var active = document.activeElement;
|
|
167
|
+
|
|
168
|
+
var ranges = [];
|
|
169
|
+
for (var i = 0; i < selection.rangeCount; i++) {
|
|
170
|
+
ranges.push(selection.getRangeAt(i));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML
|
|
174
|
+
case 'INPUT':
|
|
175
|
+
case 'TEXTAREA':
|
|
176
|
+
active.blur();
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
default:
|
|
180
|
+
active = null;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
selection.removeAllRanges();
|
|
185
|
+
return function () {
|
|
186
|
+
selection.type === 'Caret' &&
|
|
187
|
+
selection.removeAllRanges();
|
|
188
|
+
|
|
189
|
+
if (!selection.rangeCount) {
|
|
190
|
+
ranges.forEach(function(range) {
|
|
191
|
+
selection.addRange(range);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
active &&
|
|
196
|
+
active.focus();
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
return toggleSelection;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
var copyToClipboard;
|
|
203
|
+
var hasRequiredCopyToClipboard;
|
|
204
|
+
|
|
205
|
+
function requireCopyToClipboard () {
|
|
206
|
+
if (hasRequiredCopyToClipboard) return copyToClipboard;
|
|
207
|
+
hasRequiredCopyToClipboard = 1;
|
|
208
|
+
|
|
209
|
+
var deselectCurrent = requireToggleSelection();
|
|
210
|
+
|
|
211
|
+
var clipboardToIE11Formatting = {
|
|
212
|
+
"text/plain": "Text",
|
|
213
|
+
"text/html": "Url",
|
|
214
|
+
"default": "Text"
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
218
|
+
|
|
219
|
+
function format(message) {
|
|
220
|
+
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
221
|
+
return message.replace(/#{\s*key\s*}/g, copyKey);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function copy(text, options) {
|
|
225
|
+
var debug,
|
|
226
|
+
message,
|
|
227
|
+
reselectPrevious,
|
|
228
|
+
range,
|
|
229
|
+
selection,
|
|
230
|
+
mark,
|
|
231
|
+
success = false;
|
|
232
|
+
if (!options) {
|
|
233
|
+
options = {};
|
|
234
|
+
}
|
|
235
|
+
debug = options.debug || false;
|
|
236
|
+
try {
|
|
237
|
+
reselectPrevious = deselectCurrent();
|
|
238
|
+
|
|
239
|
+
range = document.createRange();
|
|
240
|
+
selection = document.getSelection();
|
|
241
|
+
|
|
242
|
+
mark = document.createElement("span");
|
|
243
|
+
mark.textContent = text;
|
|
244
|
+
// avoid screen readers from reading out loud the text
|
|
245
|
+
mark.ariaHidden = "true";
|
|
246
|
+
// reset user styles for span element
|
|
247
|
+
mark.style.all = "unset";
|
|
248
|
+
// prevents scrolling to the end of the page
|
|
249
|
+
mark.style.position = "fixed";
|
|
250
|
+
mark.style.top = 0;
|
|
251
|
+
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
252
|
+
// used to preserve spaces and line breaks
|
|
253
|
+
mark.style.whiteSpace = "pre";
|
|
254
|
+
// do not inherit user-select (it may be `none`)
|
|
255
|
+
mark.style.webkitUserSelect = "text";
|
|
256
|
+
mark.style.MozUserSelect = "text";
|
|
257
|
+
mark.style.msUserSelect = "text";
|
|
258
|
+
mark.style.userSelect = "text";
|
|
259
|
+
mark.addEventListener("copy", function(e) {
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
if (options.format) {
|
|
262
|
+
e.preventDefault();
|
|
263
|
+
if (typeof e.clipboardData === "undefined") { // IE 11
|
|
264
|
+
debug && console.warn("unable to use e.clipboardData");
|
|
265
|
+
debug && console.warn("trying IE specific stuff");
|
|
266
|
+
window.clipboardData.clearData();
|
|
267
|
+
var format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
268
|
+
window.clipboardData.setData(format, text);
|
|
269
|
+
} else { // all other browsers
|
|
270
|
+
e.clipboardData.clearData();
|
|
271
|
+
e.clipboardData.setData(options.format, text);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (options.onCopy) {
|
|
275
|
+
e.preventDefault();
|
|
276
|
+
options.onCopy(e.clipboardData);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
document.body.appendChild(mark);
|
|
281
|
+
|
|
282
|
+
range.selectNodeContents(mark);
|
|
283
|
+
selection.addRange(range);
|
|
284
|
+
|
|
285
|
+
var successful = document.execCommand("copy");
|
|
286
|
+
if (!successful) {
|
|
287
|
+
throw new Error("copy command was unsuccessful");
|
|
288
|
+
}
|
|
289
|
+
success = true;
|
|
290
|
+
} catch (err) {
|
|
291
|
+
debug && console.error("unable to copy using execCommand: ", err);
|
|
292
|
+
debug && console.warn("trying IE specific stuff");
|
|
293
|
+
try {
|
|
294
|
+
window.clipboardData.setData(options.format || "text", text);
|
|
295
|
+
options.onCopy && options.onCopy(window.clipboardData);
|
|
296
|
+
success = true;
|
|
297
|
+
} catch (err) {
|
|
298
|
+
debug && console.error("unable to copy using clipboardData: ", err);
|
|
299
|
+
debug && console.error("falling back to prompt");
|
|
300
|
+
message = format("message" in options ? options.message : defaultMessage);
|
|
301
|
+
window.prompt(message, text);
|
|
302
|
+
}
|
|
303
|
+
} finally {
|
|
304
|
+
if (selection) {
|
|
305
|
+
if (typeof selection.removeRange == "function") {
|
|
306
|
+
selection.removeRange(range);
|
|
307
|
+
} else {
|
|
308
|
+
selection.removeAllRanges();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (mark) {
|
|
313
|
+
document.body.removeChild(mark);
|
|
314
|
+
}
|
|
315
|
+
reselectPrevious();
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return success;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
copyToClipboard = copy;
|
|
322
|
+
return copyToClipboard;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
var copyToClipboardExports = requireCopyToClipboard();
|
|
326
|
+
var copy = /*@__PURE__*/getDefaultExportFromCjs(copyToClipboardExports);
|
|
327
|
+
|
|
328
|
+
function _typeof$2(obj) { "@babel/helpers - typeof"; 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); }
|
|
329
|
+
|
|
330
|
+
function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
331
|
+
|
|
332
|
+
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); } }
|
|
333
|
+
|
|
334
|
+
function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
|
|
335
|
+
|
|
336
|
+
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); }
|
|
337
|
+
|
|
338
|
+
function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
|
|
339
|
+
|
|
340
|
+
function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf$1(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$1(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$1(this, result); }; }
|
|
341
|
+
|
|
342
|
+
function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
|
|
343
|
+
|
|
344
|
+
function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
345
|
+
|
|
346
|
+
function _isNativeReflectConstruct$1() { 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; } }
|
|
347
|
+
|
|
348
|
+
function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
|
|
349
|
+
|
|
350
|
+
var Editable = /*#__PURE__*/function (_React$Component) {
|
|
351
|
+
_inherits$1(Editable, _React$Component);
|
|
352
|
+
|
|
353
|
+
var _super = _createSuper$1(Editable);
|
|
354
|
+
|
|
355
|
+
function Editable() {
|
|
356
|
+
var _this;
|
|
357
|
+
|
|
358
|
+
_classCallCheck$1(this, Editable);
|
|
359
|
+
|
|
360
|
+
_this = _super.apply(this, arguments);
|
|
361
|
+
_this.inComposition = false;
|
|
362
|
+
_this.state = {
|
|
363
|
+
current: ''
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
_this.onChange = function (_ref) {
|
|
367
|
+
var value = _ref.target.value;
|
|
368
|
+
|
|
369
|
+
_this.setState({
|
|
370
|
+
current: value.replace(/[\r\n]/g, '')
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
_this.onCompositionStart = function () {
|
|
375
|
+
_this.inComposition = true;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
_this.onCompositionEnd = function () {
|
|
379
|
+
_this.inComposition = false;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
_this.onKeyDown = function (_ref2) {
|
|
383
|
+
var keyCode = _ref2.keyCode;
|
|
384
|
+
// We don't record keyCode when IME is using
|
|
385
|
+
if (_this.inComposition) return;
|
|
386
|
+
_this.lastKeyCode = keyCode;
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
_this.onKeyUp = function (_ref3) {
|
|
390
|
+
var keyCode = _ref3.keyCode,
|
|
391
|
+
ctrlKey = _ref3.ctrlKey,
|
|
392
|
+
altKey = _ref3.altKey,
|
|
393
|
+
metaKey = _ref3.metaKey,
|
|
394
|
+
shiftKey = _ref3.shiftKey;
|
|
395
|
+
var onCancel = _this.props.onCancel; // Check if it's a real key
|
|
396
|
+
|
|
397
|
+
if (_this.lastKeyCode === keyCode && !_this.inComposition && !ctrlKey && !altKey && !metaKey && !shiftKey) {
|
|
398
|
+
if (keyCode === KeyCode.ENTER) {
|
|
399
|
+
_this.confirmChange();
|
|
400
|
+
} else if (keyCode === KeyCode.ESC) {
|
|
401
|
+
onCancel();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
_this.onBlur = function () {
|
|
407
|
+
_this.confirmChange();
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
_this.confirmChange = function () {
|
|
411
|
+
var current = _this.state.current;
|
|
412
|
+
var onSave = _this.props.onSave;
|
|
413
|
+
onSave(current.trim());
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
_this.setTextarea = function (textarea) {
|
|
417
|
+
_this.textarea = textarea;
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
return _this;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
_createClass$1(Editable, [{
|
|
424
|
+
key: "componentDidMount",
|
|
425
|
+
value: function componentDidMount() {
|
|
426
|
+
if (this.textarea && this.textarea.resizableTextArea) {
|
|
427
|
+
var textArea = this.textarea.resizableTextArea.textArea;
|
|
428
|
+
textArea.focus();
|
|
429
|
+
var length = textArea.value.length;
|
|
430
|
+
textArea.setSelectionRange(length, length);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}, {
|
|
434
|
+
key: "render",
|
|
435
|
+
value: function render() {
|
|
436
|
+
var current = this.state.current;
|
|
437
|
+
var _this$props = this.props,
|
|
438
|
+
prefixCls = _this$props.prefixCls,
|
|
439
|
+
ariaLabel = _this$props['aria-label'],
|
|
440
|
+
className = _this$props.className,
|
|
441
|
+
style = _this$props.style;
|
|
442
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
443
|
+
className: classNames(prefixCls, "".concat(prefixCls, "-edit-content"), className),
|
|
444
|
+
style: style
|
|
445
|
+
}, /*#__PURE__*/React.createElement(TextArea, {
|
|
446
|
+
ref: this.setTextarea,
|
|
447
|
+
value: current,
|
|
448
|
+
onChange: this.onChange,
|
|
449
|
+
onKeyDown: this.onKeyDown,
|
|
450
|
+
onKeyUp: this.onKeyUp,
|
|
451
|
+
onCompositionStart: this.onCompositionStart,
|
|
452
|
+
onCompositionEnd: this.onCompositionEnd,
|
|
453
|
+
onBlur: this.onBlur,
|
|
454
|
+
"aria-label": ariaLabel,
|
|
455
|
+
autoSize: true
|
|
456
|
+
}), /*#__PURE__*/React.createElement(Icon, {
|
|
457
|
+
type: "enter",
|
|
458
|
+
className: "".concat(prefixCls, "-edit-content-confirm")
|
|
459
|
+
}));
|
|
460
|
+
}
|
|
461
|
+
}], [{
|
|
462
|
+
key: "getDerivedStateFromProps",
|
|
463
|
+
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
464
|
+
var prevValue = prevState.prevValue;
|
|
465
|
+
var value = nextProps.value;
|
|
466
|
+
var newState = {
|
|
467
|
+
prevValue: value
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
if (prevValue !== value) {
|
|
471
|
+
newState.current = value;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return newState;
|
|
475
|
+
}
|
|
476
|
+
}]);
|
|
477
|
+
|
|
478
|
+
return Editable;
|
|
479
|
+
}(React.Component);
|
|
480
|
+
|
|
481
|
+
polyfill(Editable);
|
|
482
|
+
|
|
483
|
+
var ELEMENT_NODE = 1;
|
|
484
|
+
var TEXT_NODE = 3;
|
|
485
|
+
var COMMENT_NODE = 8;
|
|
486
|
+
var ellipsisContainer;
|
|
487
|
+
var wrapperStyle = {
|
|
488
|
+
padding: 0,
|
|
489
|
+
margin: 0,
|
|
490
|
+
display: 'inline',
|
|
491
|
+
lineHeight: 'inherit'
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
function pxToNumber(value) {
|
|
495
|
+
if (!value) return 0;
|
|
496
|
+
var match = value.match(/^\d*(\.\d*)?/);
|
|
497
|
+
return match ? Number(match[0]) : 0;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function styleToString(style) {
|
|
501
|
+
// There are some different behavior between Firefox & Chrome.
|
|
502
|
+
// We have to handle this ourself.
|
|
503
|
+
var styleNames = Array.prototype.slice.apply(style);
|
|
504
|
+
return styleNames.map(function (name) {
|
|
505
|
+
return "".concat(name, ": ").concat(style.getPropertyValue(name), ";");
|
|
506
|
+
}).join('');
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function mergeChildren(children) {
|
|
510
|
+
var childList = [];
|
|
511
|
+
children.forEach(function (child) {
|
|
512
|
+
var prevChild = childList[childList.length - 1];
|
|
513
|
+
|
|
514
|
+
if (typeof child === 'string' && typeof prevChild === 'string') {
|
|
515
|
+
childList[childList.length - 1] += child;
|
|
516
|
+
} else {
|
|
517
|
+
childList.push(child);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
return childList;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var measure = (function (originEle, rows, content, fixedContent, ellipsisStr) {
|
|
524
|
+
if (!ellipsisContainer) {
|
|
525
|
+
ellipsisContainer = document.createElement('div');
|
|
526
|
+
ellipsisContainer.setAttribute('aria-hidden', 'true');
|
|
527
|
+
document.body.appendChild(ellipsisContainer);
|
|
528
|
+
} // Get origin style
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
var originStyle = window.getComputedStyle(originEle);
|
|
532
|
+
var originCSS = styleToString(originStyle);
|
|
533
|
+
var lineHeight = pxToNumber(originStyle.lineHeight);
|
|
534
|
+
var maxHeight = lineHeight * (rows + 1) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom); // Set shadow
|
|
535
|
+
|
|
536
|
+
ellipsisContainer.setAttribute('style', originCSS);
|
|
537
|
+
ellipsisContainer.style.position = 'fixed';
|
|
538
|
+
ellipsisContainer.style.left = '0';
|
|
539
|
+
ellipsisContainer.style.height = 'auto';
|
|
540
|
+
ellipsisContainer.style.minHeight = 'auto';
|
|
541
|
+
ellipsisContainer.style.maxHeight = 'auto';
|
|
542
|
+
ellipsisContainer.style.top = '-999999px';
|
|
543
|
+
ellipsisContainer.style.zIndex = '-1000'; // clean up css overflow
|
|
544
|
+
|
|
545
|
+
ellipsisContainer.style.textOverflow = 'clip';
|
|
546
|
+
ellipsisContainer.style.whiteSpace = 'normal';
|
|
547
|
+
ellipsisContainer.style.webkitLineClamp = 'none'; // Render in the fake container
|
|
548
|
+
|
|
549
|
+
var contentList = mergeChildren(toArray(content));
|
|
550
|
+
render( /*#__PURE__*/React.createElement("div", {
|
|
551
|
+
style: wrapperStyle
|
|
552
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
553
|
+
style: wrapperStyle
|
|
554
|
+
}, contentList), /*#__PURE__*/React.createElement("span", {
|
|
555
|
+
style: wrapperStyle
|
|
556
|
+
}, fixedContent)), ellipsisContainer); // wrap in an div for old version react
|
|
557
|
+
// Check if ellipsis in measure div is height enough for content
|
|
558
|
+
|
|
559
|
+
function inRange() {
|
|
560
|
+
return ellipsisContainer.offsetHeight < maxHeight;
|
|
561
|
+
} // Skip ellipsis if already match
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
if (inRange()) {
|
|
565
|
+
unmountComponentAtNode(ellipsisContainer);
|
|
566
|
+
return {
|
|
567
|
+
content: content,
|
|
568
|
+
text: ellipsisContainer.innerHTML,
|
|
569
|
+
ellipsis: false
|
|
570
|
+
};
|
|
571
|
+
} // We should clone the childNode since they're controlled by React and we can't reuse it without warning
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
var childNodes = Array.prototype.slice.apply(ellipsisContainer.childNodes[0].childNodes[0].cloneNode(true).childNodes).filter(function (_ref) {
|
|
575
|
+
var nodeType = _ref.nodeType;
|
|
576
|
+
return nodeType !== COMMENT_NODE;
|
|
577
|
+
});
|
|
578
|
+
var fixedNodes = Array.prototype.slice.apply(ellipsisContainer.childNodes[0].childNodes[1].cloneNode(true).childNodes);
|
|
579
|
+
unmountComponentAtNode(ellipsisContainer); // ========================= Find match ellipsis content =========================
|
|
580
|
+
|
|
581
|
+
var ellipsisChildren = [];
|
|
582
|
+
ellipsisContainer.innerHTML = ''; // Create origin content holder
|
|
583
|
+
|
|
584
|
+
var ellipsisContentHolder = document.createElement('span');
|
|
585
|
+
ellipsisContainer.appendChild(ellipsisContentHolder);
|
|
586
|
+
var ellipsisTextNode = document.createTextNode(ellipsisStr);
|
|
587
|
+
ellipsisContentHolder.appendChild(ellipsisTextNode);
|
|
588
|
+
fixedNodes.forEach(function (childNode) {
|
|
589
|
+
ellipsisContainer.appendChild(childNode);
|
|
590
|
+
}); // Append before fixed nodes
|
|
591
|
+
|
|
592
|
+
function appendChildNode(node) {
|
|
593
|
+
ellipsisContentHolder.insertBefore(node, ellipsisTextNode);
|
|
594
|
+
} // Get maximum text
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
function measureText(textNode, fullText) {
|
|
598
|
+
var startLoc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
599
|
+
var endLoc = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : fullText.length;
|
|
600
|
+
var lastSuccessLoc = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
601
|
+
var midLoc = Math.floor((startLoc + endLoc) / 2);
|
|
602
|
+
var currentText = fullText.slice(0, midLoc);
|
|
603
|
+
textNode.textContent = currentText;
|
|
604
|
+
|
|
605
|
+
if (startLoc >= endLoc - 1) {
|
|
606
|
+
// Loop when step is small
|
|
607
|
+
for (var step = endLoc; step >= startLoc; step -= 1) {
|
|
608
|
+
var currentStepText = fullText.slice(0, step);
|
|
609
|
+
textNode.textContent = currentStepText;
|
|
610
|
+
|
|
611
|
+
if (inRange()) {
|
|
612
|
+
return step === fullText.length ? {
|
|
613
|
+
finished: false,
|
|
614
|
+
reactNode: fullText
|
|
615
|
+
} : {
|
|
616
|
+
finished: true,
|
|
617
|
+
reactNode: currentStepText
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (inRange()) {
|
|
624
|
+
return measureText(textNode, fullText, midLoc, endLoc, midLoc);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
return measureText(textNode, fullText, startLoc, midLoc, lastSuccessLoc);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function measureNode(childNode, index) {
|
|
631
|
+
var type = childNode.nodeType;
|
|
632
|
+
|
|
633
|
+
if (type === ELEMENT_NODE) {
|
|
634
|
+
// We don't split element, it will keep if whole element can be displayed.
|
|
635
|
+
appendChildNode(childNode);
|
|
636
|
+
|
|
637
|
+
if (inRange()) {
|
|
638
|
+
return {
|
|
639
|
+
finished: false,
|
|
640
|
+
reactNode: contentList[index]
|
|
641
|
+
};
|
|
642
|
+
} // Clean up if can not pull in
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
ellipsisContentHolder.removeChild(childNode);
|
|
646
|
+
return {
|
|
647
|
+
finished: true,
|
|
648
|
+
reactNode: null
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (type === TEXT_NODE) {
|
|
653
|
+
var fullText = childNode.textContent || '';
|
|
654
|
+
var textNode = document.createTextNode(fullText);
|
|
655
|
+
appendChildNode(textNode);
|
|
656
|
+
return measureText(textNode, fullText);
|
|
657
|
+
} // Not handle other type of content
|
|
658
|
+
// PS: This code should not be attached after react 16
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
return {
|
|
662
|
+
finished: false,
|
|
663
|
+
reactNode: null
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
childNodes.some(function (childNode, index) {
|
|
668
|
+
var _measureNode = measureNode(childNode, index),
|
|
669
|
+
finished = _measureNode.finished,
|
|
670
|
+
reactNode = _measureNode.reactNode;
|
|
671
|
+
|
|
672
|
+
if (reactNode) {
|
|
673
|
+
ellipsisChildren.push(reactNode);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return finished;
|
|
677
|
+
});
|
|
678
|
+
return {
|
|
679
|
+
content: ellipsisChildren,
|
|
680
|
+
text: ellipsisContainer.innerHTML,
|
|
681
|
+
ellipsis: true
|
|
682
|
+
};
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
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; }
|
|
686
|
+
|
|
687
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
688
|
+
|
|
689
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
690
|
+
|
|
691
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
692
|
+
|
|
693
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
694
|
+
|
|
695
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
696
|
+
|
|
697
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
698
|
+
|
|
699
|
+
function _typeof$1(obj) { "@babel/helpers - typeof"; 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); }
|
|
700
|
+
|
|
701
|
+
function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
|
|
702
|
+
|
|
703
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
704
|
+
|
|
705
|
+
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); } }
|
|
706
|
+
|
|
707
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
708
|
+
|
|
709
|
+
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); }
|
|
710
|
+
|
|
711
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
712
|
+
|
|
713
|
+
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); }; }
|
|
714
|
+
|
|
715
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
716
|
+
|
|
717
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
718
|
+
|
|
719
|
+
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; } }
|
|
720
|
+
|
|
721
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
722
|
+
|
|
723
|
+
var __rest$2 = undefined && undefined.__rest || function (s, e) {
|
|
724
|
+
var t = {};
|
|
725
|
+
|
|
726
|
+
for (var p in s) {
|
|
727
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
731
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
732
|
+
}
|
|
733
|
+
return t;
|
|
734
|
+
};
|
|
735
|
+
var isLineClampSupport = isStyleSupport('webkitLineClamp');
|
|
736
|
+
var isTextOverflowSupport = isStyleSupport('textOverflow');
|
|
737
|
+
|
|
738
|
+
function wrapperDecorations(_ref, content) {
|
|
739
|
+
var mark = _ref.mark,
|
|
740
|
+
code = _ref.code,
|
|
741
|
+
underline = _ref.underline,
|
|
742
|
+
del = _ref["delete"],
|
|
743
|
+
strong = _ref.strong;
|
|
744
|
+
var currentContent = content;
|
|
745
|
+
|
|
746
|
+
function wrap(needed, tag) {
|
|
747
|
+
if (!needed) return;
|
|
748
|
+
currentContent = /*#__PURE__*/React.createElement(tag, {}, currentContent);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
wrap(strong, 'strong');
|
|
752
|
+
wrap(underline, 'u');
|
|
753
|
+
wrap(del, 'del');
|
|
754
|
+
wrap(code, 'code');
|
|
755
|
+
wrap(mark, 'mark');
|
|
756
|
+
return currentContent;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
var ELLIPSIS_STR = '...';
|
|
760
|
+
|
|
761
|
+
var Base = /*#__PURE__*/function (_React$Component) {
|
|
762
|
+
_inherits(Base, _React$Component);
|
|
763
|
+
|
|
764
|
+
var _super = _createSuper(Base);
|
|
765
|
+
|
|
766
|
+
function Base() {
|
|
767
|
+
var _this;
|
|
768
|
+
|
|
769
|
+
_classCallCheck(this, Base);
|
|
770
|
+
|
|
771
|
+
_this = _super.apply(this, arguments);
|
|
772
|
+
_this.state = {
|
|
773
|
+
edit: false,
|
|
774
|
+
copied: false,
|
|
775
|
+
ellipsisText: '',
|
|
776
|
+
ellipsisContent: null,
|
|
777
|
+
isEllipsis: false,
|
|
778
|
+
expanded: false,
|
|
779
|
+
clientRendered: false
|
|
780
|
+
}; // =============== Expend ===============
|
|
781
|
+
|
|
782
|
+
_this.onExpandClick = function () {
|
|
783
|
+
var _this$getEllipsis = _this.getEllipsis(),
|
|
784
|
+
onExpand = _this$getEllipsis.onExpand;
|
|
785
|
+
|
|
786
|
+
_this.setState({
|
|
787
|
+
expanded: true
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
if (onExpand) {
|
|
791
|
+
onExpand();
|
|
792
|
+
}
|
|
793
|
+
}; // ================ Edit ================
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
_this.onEditClick = function () {
|
|
797
|
+
_this.triggerEdit(true);
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
_this.onEditChange = function (value) {
|
|
801
|
+
var _this$getEditable = _this.getEditable(),
|
|
802
|
+
onChange = _this$getEditable.onChange;
|
|
803
|
+
|
|
804
|
+
if (onChange) {
|
|
805
|
+
onChange(value);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
_this.triggerEdit(false);
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
_this.onEditCancel = function () {
|
|
812
|
+
_this.triggerEdit(false);
|
|
813
|
+
}; // ================ Copy ================
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
_this.onCopyClick = function () {
|
|
817
|
+
var _this$props = _this.props,
|
|
818
|
+
children = _this$props.children,
|
|
819
|
+
copyable = _this$props.copyable;
|
|
820
|
+
|
|
821
|
+
var copyConfig = _extends$3({}, _typeof$1(copyable) === 'object' ? copyable : null);
|
|
822
|
+
|
|
823
|
+
if (copyConfig.text === undefined) {
|
|
824
|
+
copyConfig.text = String(children);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
copy(copyConfig.text || '');
|
|
828
|
+
|
|
829
|
+
_this.setState({
|
|
830
|
+
copied: true
|
|
831
|
+
}, function () {
|
|
832
|
+
if (copyConfig.onCopy) {
|
|
833
|
+
copyConfig.onCopy();
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
_this.copyId = window.setTimeout(function () {
|
|
837
|
+
_this.setState({
|
|
838
|
+
copied: false
|
|
839
|
+
});
|
|
840
|
+
}, 3000);
|
|
841
|
+
});
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
_this.setContentRef = function (node) {
|
|
845
|
+
_this.content = node;
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
_this.setEditRef = function (node) {
|
|
849
|
+
_this.editIcon = node;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
_this.triggerEdit = function (edit) {
|
|
853
|
+
var _this$getEditable2 = _this.getEditable(),
|
|
854
|
+
onStart = _this$getEditable2.onStart;
|
|
855
|
+
|
|
856
|
+
if (edit && onStart) {
|
|
857
|
+
onStart();
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
_this.setState({
|
|
861
|
+
edit: edit
|
|
862
|
+
}, function () {
|
|
863
|
+
if (!edit && _this.editIcon) {
|
|
864
|
+
_this.editIcon.focus();
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
}; // ============== Ellipsis ==============
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
_this.resizeOnNextFrame = function () {
|
|
871
|
+
wrapperRaf.cancel(_this.rafId);
|
|
872
|
+
_this.rafId = wrapperRaf(function () {
|
|
873
|
+
// Do not bind `syncEllipsis`. It need for test usage on prototype
|
|
874
|
+
_this.syncEllipsis();
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
|
|
878
|
+
return _this;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
_createClass(Base, [{
|
|
882
|
+
key: "componentDidMount",
|
|
883
|
+
value: function componentDidMount() {
|
|
884
|
+
this.setState({
|
|
885
|
+
clientRendered: true
|
|
886
|
+
});
|
|
887
|
+
this.resizeOnNextFrame();
|
|
888
|
+
}
|
|
889
|
+
}, {
|
|
890
|
+
key: "componentDidUpdate",
|
|
891
|
+
value: function componentDidUpdate(prevProps) {
|
|
892
|
+
var children = this.props.children;
|
|
893
|
+
var ellipsis = this.getEllipsis();
|
|
894
|
+
var prevEllipsis = this.getEllipsis(prevProps);
|
|
895
|
+
|
|
896
|
+
if (children !== prevProps.children || ellipsis.rows !== prevEllipsis.rows) {
|
|
897
|
+
this.resizeOnNextFrame();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}, {
|
|
901
|
+
key: "componentWillUnmount",
|
|
902
|
+
value: function componentWillUnmount() {
|
|
903
|
+
window.clearTimeout(this.copyId);
|
|
904
|
+
wrapperRaf.cancel(this.rafId);
|
|
905
|
+
}
|
|
906
|
+
}, {
|
|
907
|
+
key: "getEditable",
|
|
908
|
+
value: function getEditable(props) {
|
|
909
|
+
var edit = this.state.edit;
|
|
910
|
+
|
|
911
|
+
var _ref2 = props || this.props,
|
|
912
|
+
editable = _ref2.editable;
|
|
913
|
+
|
|
914
|
+
if (!editable) return {
|
|
915
|
+
editing: edit
|
|
916
|
+
};
|
|
917
|
+
return _extends$3({
|
|
918
|
+
editing: edit
|
|
919
|
+
}, _typeof$1(editable) === 'object' ? editable : null);
|
|
920
|
+
}
|
|
921
|
+
}, {
|
|
922
|
+
key: "getEllipsis",
|
|
923
|
+
value: function getEllipsis(props) {
|
|
924
|
+
var _ref3 = props || this.props,
|
|
925
|
+
ellipsis = _ref3.ellipsis;
|
|
926
|
+
|
|
927
|
+
if (!ellipsis) return {};
|
|
928
|
+
return _extends$3({
|
|
929
|
+
rows: 1,
|
|
930
|
+
expandable: false
|
|
931
|
+
}, _typeof$1(ellipsis) === 'object' ? ellipsis : null);
|
|
932
|
+
}
|
|
933
|
+
}, {
|
|
934
|
+
key: "canUseCSSEllipsis",
|
|
935
|
+
value: function canUseCSSEllipsis() {
|
|
936
|
+
var clientRendered = this.state.clientRendered;
|
|
937
|
+
var _this$props2 = this.props,
|
|
938
|
+
editable = _this$props2.editable,
|
|
939
|
+
copyable = _this$props2.copyable;
|
|
940
|
+
|
|
941
|
+
var _this$getEllipsis2 = this.getEllipsis(),
|
|
942
|
+
rows = _this$getEllipsis2.rows,
|
|
943
|
+
expandable = _this$getEllipsis2.expandable; // Can't use css ellipsis since we need to provide the place for button
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
if (editable || copyable || expandable || !clientRendered) {
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
if (rows === 1) {
|
|
951
|
+
return isTextOverflowSupport;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
return isLineClampSupport;
|
|
955
|
+
}
|
|
956
|
+
}, {
|
|
957
|
+
key: "syncEllipsis",
|
|
958
|
+
value: function syncEllipsis() {
|
|
959
|
+
var _this$state = this.state,
|
|
960
|
+
ellipsisText = _this$state.ellipsisText,
|
|
961
|
+
isEllipsis = _this$state.isEllipsis,
|
|
962
|
+
expanded = _this$state.expanded;
|
|
963
|
+
|
|
964
|
+
var _this$getEllipsis3 = this.getEllipsis(),
|
|
965
|
+
rows = _this$getEllipsis3.rows;
|
|
966
|
+
|
|
967
|
+
var children = this.props.children;
|
|
968
|
+
if (!rows || rows < 0 || !this.content || expanded) return; // Do not measure if css already support ellipsis
|
|
969
|
+
|
|
970
|
+
if (this.canUseCSSEllipsis()) return;
|
|
971
|
+
warning(toArray(children).every(function (child) {
|
|
972
|
+
return typeof child === 'string';
|
|
973
|
+
}));
|
|
974
|
+
|
|
975
|
+
var _measure = measure(findDOMNode(this.content), rows, children, this.renderOperations(true), ELLIPSIS_STR),
|
|
976
|
+
content = _measure.content,
|
|
977
|
+
text = _measure.text,
|
|
978
|
+
ellipsis = _measure.ellipsis;
|
|
979
|
+
|
|
980
|
+
if (ellipsisText !== text || isEllipsis !== ellipsis) {
|
|
981
|
+
this.setState({
|
|
982
|
+
ellipsisText: text,
|
|
983
|
+
ellipsisContent: content,
|
|
984
|
+
isEllipsis: ellipsis
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}, {
|
|
989
|
+
key: "renderExpand",
|
|
990
|
+
value: function renderExpand(forceRender) {
|
|
991
|
+
var _this$getEllipsis4 = this.getEllipsis(),
|
|
992
|
+
expandable = _this$getEllipsis4.expandable;
|
|
993
|
+
|
|
994
|
+
var prefixCls = this.props.prefixCls;
|
|
995
|
+
var _this$state2 = this.state,
|
|
996
|
+
expanded = _this$state2.expanded,
|
|
997
|
+
isEllipsis = _this$state2.isEllipsis;
|
|
998
|
+
if (!expandable) return null; // force render expand icon for measure usage or it will cause dead loop
|
|
999
|
+
|
|
1000
|
+
if (!forceRender && (expanded || !isEllipsis)) return null;
|
|
1001
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
1002
|
+
key: "expand",
|
|
1003
|
+
className: "".concat(prefixCls, "-expand"),
|
|
1004
|
+
onClick: this.onExpandClick,
|
|
1005
|
+
"aria-label": this.expandStr
|
|
1006
|
+
}, this.expandStr);
|
|
1007
|
+
}
|
|
1008
|
+
}, {
|
|
1009
|
+
key: "renderEdit",
|
|
1010
|
+
value: function renderEdit() {
|
|
1011
|
+
var _this$props3 = this.props,
|
|
1012
|
+
editable = _this$props3.editable,
|
|
1013
|
+
prefixCls = _this$props3.prefixCls;
|
|
1014
|
+
if (!editable) return;
|
|
1015
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
1016
|
+
key: "edit",
|
|
1017
|
+
title: this.editStr
|
|
1018
|
+
}, /*#__PURE__*/React.createElement(TransButton, {
|
|
1019
|
+
ref: this.setEditRef,
|
|
1020
|
+
className: "".concat(prefixCls, "-edit"),
|
|
1021
|
+
onClick: this.onEditClick,
|
|
1022
|
+
"aria-label": this.editStr
|
|
1023
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1024
|
+
role: "button",
|
|
1025
|
+
type: "edit"
|
|
1026
|
+
})));
|
|
1027
|
+
}
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "renderCopy",
|
|
1030
|
+
value: function renderCopy() {
|
|
1031
|
+
var copied = this.state.copied;
|
|
1032
|
+
var _this$props4 = this.props,
|
|
1033
|
+
copyable = _this$props4.copyable,
|
|
1034
|
+
prefixCls = _this$props4.prefixCls;
|
|
1035
|
+
if (!copyable) return;
|
|
1036
|
+
var title = copied ? this.copiedStr : this.copyStr;
|
|
1037
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
1038
|
+
key: "copy",
|
|
1039
|
+
title: title
|
|
1040
|
+
}, /*#__PURE__*/React.createElement(TransButton, {
|
|
1041
|
+
className: classNames("".concat(prefixCls, "-copy"), copied && "".concat(prefixCls, "-copy-success")),
|
|
1042
|
+
onClick: this.onCopyClick,
|
|
1043
|
+
"aria-label": title
|
|
1044
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
1045
|
+
role: "button",
|
|
1046
|
+
type: copied ? 'check' : 'copy'
|
|
1047
|
+
})));
|
|
1048
|
+
}
|
|
1049
|
+
}, {
|
|
1050
|
+
key: "renderEditInput",
|
|
1051
|
+
value: function renderEditInput() {
|
|
1052
|
+
var _this$props5 = this.props,
|
|
1053
|
+
children = _this$props5.children,
|
|
1054
|
+
prefixCls = _this$props5.prefixCls,
|
|
1055
|
+
className = _this$props5.className,
|
|
1056
|
+
style = _this$props5.style;
|
|
1057
|
+
return /*#__PURE__*/React.createElement(Editable, {
|
|
1058
|
+
value: typeof children === 'string' ? children : '',
|
|
1059
|
+
onSave: this.onEditChange,
|
|
1060
|
+
onCancel: this.onEditCancel,
|
|
1061
|
+
prefixCls: prefixCls,
|
|
1062
|
+
className: className,
|
|
1063
|
+
style: style
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
}, {
|
|
1067
|
+
key: "renderOperations",
|
|
1068
|
+
value: function renderOperations(forceRenderExpanded) {
|
|
1069
|
+
return [this.renderExpand(forceRenderExpanded), this.renderEdit(), this.renderCopy()].filter(function (node) {
|
|
1070
|
+
return node;
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
}, {
|
|
1074
|
+
key: "renderContent",
|
|
1075
|
+
value: function renderContent() {
|
|
1076
|
+
var _this2 = this;
|
|
1077
|
+
|
|
1078
|
+
var _this$state3 = this.state,
|
|
1079
|
+
ellipsisContent = _this$state3.ellipsisContent,
|
|
1080
|
+
isEllipsis = _this$state3.isEllipsis,
|
|
1081
|
+
expanded = _this$state3.expanded;
|
|
1082
|
+
|
|
1083
|
+
var _a = this.props,
|
|
1084
|
+
component = _a.component,
|
|
1085
|
+
children = _a.children,
|
|
1086
|
+
className = _a.className,
|
|
1087
|
+
prefixCls = _a.prefixCls,
|
|
1088
|
+
type = _a.type,
|
|
1089
|
+
disabled = _a.disabled,
|
|
1090
|
+
style = _a.style,
|
|
1091
|
+
restProps = __rest$2(_a, ["component", "children", "className", "prefixCls", "type", "disabled", "style"]);
|
|
1092
|
+
|
|
1093
|
+
var _this$getEllipsis5 = this.getEllipsis(),
|
|
1094
|
+
rows = _this$getEllipsis5.rows;
|
|
1095
|
+
|
|
1096
|
+
var textProps = omit(restProps, ['prefixCls', 'editable', 'copyable', 'ellipsis', 'mark', 'underline', 'mark', 'code', 'delete', 'underline', 'strong'].concat(_toConsumableArray(configConsumerProps)));
|
|
1097
|
+
var cssEllipsis = this.canUseCSSEllipsis();
|
|
1098
|
+
var cssTextOverflow = rows === 1 && cssEllipsis;
|
|
1099
|
+
var cssLineClamp = rows && rows > 1 && cssEllipsis;
|
|
1100
|
+
var textNode = children;
|
|
1101
|
+
var ariaLabel = null; // Only use js ellipsis when css ellipsis not support
|
|
1102
|
+
|
|
1103
|
+
if (rows && isEllipsis && !expanded && !cssEllipsis) {
|
|
1104
|
+
ariaLabel = String(children); // We move full content to outer element to avoid repeat read the content by accessibility
|
|
1105
|
+
|
|
1106
|
+
textNode = /*#__PURE__*/React.createElement("span", {
|
|
1107
|
+
title: String(children),
|
|
1108
|
+
"aria-hidden": "true"
|
|
1109
|
+
}, ellipsisContent, ELLIPSIS_STR);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
textNode = wrapperDecorations(this.props, textNode);
|
|
1113
|
+
return /*#__PURE__*/React.createElement(LocaleReceiver, {
|
|
1114
|
+
componentName: "Text"
|
|
1115
|
+
}, function (_ref4) {
|
|
1116
|
+
var _classNames;
|
|
1117
|
+
|
|
1118
|
+
var edit = _ref4.edit,
|
|
1119
|
+
copyStr = _ref4.copy,
|
|
1120
|
+
copied = _ref4.copied,
|
|
1121
|
+
expand = _ref4.expand;
|
|
1122
|
+
_this2.editStr = edit;
|
|
1123
|
+
_this2.copyStr = copyStr;
|
|
1124
|
+
_this2.copiedStr = copied;
|
|
1125
|
+
_this2.expandStr = expand;
|
|
1126
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
1127
|
+
onResize: _this2.resizeOnNextFrame,
|
|
1128
|
+
disabled: !rows
|
|
1129
|
+
}, /*#__PURE__*/React.createElement(ExportTypography, _extends$3({
|
|
1130
|
+
className: classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), type), _defineProperty(_classNames, "".concat(prefixCls, "-disabled"), disabled), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis"), rows), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis-single-line"), cssTextOverflow), _defineProperty(_classNames, "".concat(prefixCls, "-ellipsis-multiple-line"), cssLineClamp), _classNames)),
|
|
1131
|
+
style: _extends$3(_extends$3({}, style), {
|
|
1132
|
+
WebkitLineClamp: cssLineClamp ? rows : null
|
|
1133
|
+
}),
|
|
1134
|
+
component: component,
|
|
1135
|
+
ref: _this2.setContentRef,
|
|
1136
|
+
"aria-label": ariaLabel
|
|
1137
|
+
}, textProps), textNode, _this2.renderOperations()));
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
}, {
|
|
1141
|
+
key: "render",
|
|
1142
|
+
value: function render() {
|
|
1143
|
+
var _this$getEditable3 = this.getEditable(),
|
|
1144
|
+
editing = _this$getEditable3.editing;
|
|
1145
|
+
|
|
1146
|
+
if (editing) {
|
|
1147
|
+
return this.renderEditInput();
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
return this.renderContent();
|
|
1151
|
+
}
|
|
1152
|
+
}], [{
|
|
1153
|
+
key: "getDerivedStateFromProps",
|
|
1154
|
+
value: function getDerivedStateFromProps(nextProps) {
|
|
1155
|
+
return {};
|
|
1156
|
+
}
|
|
1157
|
+
}]);
|
|
1158
|
+
|
|
1159
|
+
return Base;
|
|
1160
|
+
}(React.Component);
|
|
1161
|
+
|
|
1162
|
+
Base.defaultProps = {
|
|
1163
|
+
children: ''
|
|
1164
|
+
};
|
|
1165
|
+
polyfill(Base);
|
|
1166
|
+
var Base$1 = withConfigConsumer({
|
|
1167
|
+
prefixCls: 'typography'
|
|
1168
|
+
})(Base);
|
|
1169
|
+
|
|
1170
|
+
function _extends$2() { _extends$2 = 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$2.apply(this, arguments); }
|
|
1171
|
+
|
|
1172
|
+
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); }
|
|
1173
|
+
|
|
1174
|
+
var __rest$1 = undefined && undefined.__rest || function (s, e) {
|
|
1175
|
+
var t = {};
|
|
1176
|
+
|
|
1177
|
+
for (var p in s) {
|
|
1178
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1182
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
1183
|
+
}
|
|
1184
|
+
return t;
|
|
1185
|
+
};
|
|
1186
|
+
|
|
1187
|
+
var Text = function Text(_a) {
|
|
1188
|
+
var ellipsis = _a.ellipsis,
|
|
1189
|
+
restProps = __rest$1(_a, ["ellipsis"]);
|
|
1190
|
+
|
|
1191
|
+
warning(_typeof(ellipsis) !== 'object');
|
|
1192
|
+
return /*#__PURE__*/React.createElement(Base$1, _extends$2({}, restProps, {
|
|
1193
|
+
ellipsis: !!ellipsis,
|
|
1194
|
+
component: "span"
|
|
1195
|
+
}));
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
|
|
1199
|
+
|
|
1200
|
+
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
1201
|
+
var t = {};
|
|
1202
|
+
|
|
1203
|
+
for (var p in s) {
|
|
1204
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
1208
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
1209
|
+
}
|
|
1210
|
+
return t;
|
|
1211
|
+
};
|
|
1212
|
+
var TITLE_ELE_LIST = tupleNum(1, 2, 3, 4);
|
|
1213
|
+
|
|
1214
|
+
var Title = function Title(props) {
|
|
1215
|
+
var _props$level = props.level,
|
|
1216
|
+
level = _props$level === void 0 ? 1 : _props$level,
|
|
1217
|
+
restProps = __rest(props, ["level"]);
|
|
1218
|
+
|
|
1219
|
+
var component;
|
|
1220
|
+
|
|
1221
|
+
if (TITLE_ELE_LIST.indexOf(level) !== -1) {
|
|
1222
|
+
component = "h".concat(level);
|
|
1223
|
+
} else {
|
|
1224
|
+
warning$1(false, 'Title only accept `1 | 2 | 3 | 4` as `level` value.');
|
|
1225
|
+
component = 'h1';
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
return /*#__PURE__*/React.createElement(Base$1, _extends$1({}, restProps, {
|
|
1229
|
+
component: component
|
|
1230
|
+
}));
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
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); }
|
|
1234
|
+
|
|
1235
|
+
var Paragraph = function Paragraph(props) {
|
|
1236
|
+
return /*#__PURE__*/React.createElement(Base$1, _extends({}, props, {
|
|
1237
|
+
component: "div"
|
|
1238
|
+
}));
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
var Typography = ExportTypography;
|
|
1242
|
+
Typography.Text = Text;
|
|
1243
|
+
Typography.Title = Title;
|
|
1244
|
+
Typography.Paragraph = Paragraph;
|
|
1245
|
+
|
|
1246
|
+
export { Typography as default };
|