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
package/dist/identity.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { c as require_ListCache, d as require_MapCache } from './get.js';
|
|
2
|
+
import { d as require_Map } from './isLength.js';
|
|
3
|
+
import { f as require_root } from './tree.js';
|
|
4
|
+
|
|
5
|
+
var _stackClear;
|
|
6
|
+
var hasRequired_stackClear;
|
|
7
|
+
|
|
8
|
+
function require_stackClear () {
|
|
9
|
+
if (hasRequired_stackClear) return _stackClear;
|
|
10
|
+
hasRequired_stackClear = 1;
|
|
11
|
+
var ListCache = require_ListCache();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Removes all key-value entries from the stack.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
* @name clear
|
|
18
|
+
* @memberOf Stack
|
|
19
|
+
*/
|
|
20
|
+
function stackClear() {
|
|
21
|
+
this.__data__ = new ListCache;
|
|
22
|
+
this.size = 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_stackClear = stackClear;
|
|
26
|
+
return _stackClear;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Removes `key` and its value from the stack.
|
|
31
|
+
*
|
|
32
|
+
* @private
|
|
33
|
+
* @name delete
|
|
34
|
+
* @memberOf Stack
|
|
35
|
+
* @param {string} key The key of the value to remove.
|
|
36
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
var _stackDelete;
|
|
40
|
+
var hasRequired_stackDelete;
|
|
41
|
+
|
|
42
|
+
function require_stackDelete () {
|
|
43
|
+
if (hasRequired_stackDelete) return _stackDelete;
|
|
44
|
+
hasRequired_stackDelete = 1;
|
|
45
|
+
function stackDelete(key) {
|
|
46
|
+
var data = this.__data__,
|
|
47
|
+
result = data['delete'](key);
|
|
48
|
+
|
|
49
|
+
this.size = data.size;
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_stackDelete = stackDelete;
|
|
54
|
+
return _stackDelete;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Gets the stack value for `key`.
|
|
59
|
+
*
|
|
60
|
+
* @private
|
|
61
|
+
* @name get
|
|
62
|
+
* @memberOf Stack
|
|
63
|
+
* @param {string} key The key of the value to get.
|
|
64
|
+
* @returns {*} Returns the entry value.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
var _stackGet;
|
|
68
|
+
var hasRequired_stackGet;
|
|
69
|
+
|
|
70
|
+
function require_stackGet () {
|
|
71
|
+
if (hasRequired_stackGet) return _stackGet;
|
|
72
|
+
hasRequired_stackGet = 1;
|
|
73
|
+
function stackGet(key) {
|
|
74
|
+
return this.__data__.get(key);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_stackGet = stackGet;
|
|
78
|
+
return _stackGet;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Checks if a stack value for `key` exists.
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
* @name has
|
|
86
|
+
* @memberOf Stack
|
|
87
|
+
* @param {string} key The key of the entry to check.
|
|
88
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
var _stackHas;
|
|
92
|
+
var hasRequired_stackHas;
|
|
93
|
+
|
|
94
|
+
function require_stackHas () {
|
|
95
|
+
if (hasRequired_stackHas) return _stackHas;
|
|
96
|
+
hasRequired_stackHas = 1;
|
|
97
|
+
function stackHas(key) {
|
|
98
|
+
return this.__data__.has(key);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_stackHas = stackHas;
|
|
102
|
+
return _stackHas;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var _stackSet;
|
|
106
|
+
var hasRequired_stackSet;
|
|
107
|
+
|
|
108
|
+
function require_stackSet () {
|
|
109
|
+
if (hasRequired_stackSet) return _stackSet;
|
|
110
|
+
hasRequired_stackSet = 1;
|
|
111
|
+
var ListCache = require_ListCache(),
|
|
112
|
+
Map = require_Map(),
|
|
113
|
+
MapCache = require_MapCache();
|
|
114
|
+
|
|
115
|
+
/** Used as the size to enable large array optimizations. */
|
|
116
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Sets the stack `key` to `value`.
|
|
120
|
+
*
|
|
121
|
+
* @private
|
|
122
|
+
* @name set
|
|
123
|
+
* @memberOf Stack
|
|
124
|
+
* @param {string} key The key of the value to set.
|
|
125
|
+
* @param {*} value The value to set.
|
|
126
|
+
* @returns {Object} Returns the stack cache instance.
|
|
127
|
+
*/
|
|
128
|
+
function stackSet(key, value) {
|
|
129
|
+
var data = this.__data__;
|
|
130
|
+
if (data instanceof ListCache) {
|
|
131
|
+
var pairs = data.__data__;
|
|
132
|
+
if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
|
133
|
+
pairs.push([key, value]);
|
|
134
|
+
this.size = ++data.size;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
data = this.__data__ = new MapCache(pairs);
|
|
138
|
+
}
|
|
139
|
+
data.set(key, value);
|
|
140
|
+
this.size = data.size;
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
_stackSet = stackSet;
|
|
145
|
+
return _stackSet;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var _Stack;
|
|
149
|
+
var hasRequired_Stack;
|
|
150
|
+
|
|
151
|
+
function require_Stack () {
|
|
152
|
+
if (hasRequired_Stack) return _Stack;
|
|
153
|
+
hasRequired_Stack = 1;
|
|
154
|
+
var ListCache = require_ListCache(),
|
|
155
|
+
stackClear = require_stackClear(),
|
|
156
|
+
stackDelete = require_stackDelete(),
|
|
157
|
+
stackGet = require_stackGet(),
|
|
158
|
+
stackHas = require_stackHas(),
|
|
159
|
+
stackSet = require_stackSet();
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Creates a stack cache object to store key-value pairs.
|
|
163
|
+
*
|
|
164
|
+
* @private
|
|
165
|
+
* @constructor
|
|
166
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
167
|
+
*/
|
|
168
|
+
function Stack(entries) {
|
|
169
|
+
var data = this.__data__ = new ListCache(entries);
|
|
170
|
+
this.size = data.size;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Add methods to `Stack`.
|
|
174
|
+
Stack.prototype.clear = stackClear;
|
|
175
|
+
Stack.prototype['delete'] = stackDelete;
|
|
176
|
+
Stack.prototype.get = stackGet;
|
|
177
|
+
Stack.prototype.has = stackHas;
|
|
178
|
+
Stack.prototype.set = stackSet;
|
|
179
|
+
|
|
180
|
+
_Stack = Stack;
|
|
181
|
+
return _Stack;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var _Uint8Array;
|
|
185
|
+
var hasRequired_Uint8Array;
|
|
186
|
+
|
|
187
|
+
function require_Uint8Array () {
|
|
188
|
+
if (hasRequired_Uint8Array) return _Uint8Array;
|
|
189
|
+
hasRequired_Uint8Array = 1;
|
|
190
|
+
var root = require_root();
|
|
191
|
+
|
|
192
|
+
/** Built-in value references. */
|
|
193
|
+
var Uint8Array = root.Uint8Array;
|
|
194
|
+
|
|
195
|
+
_Uint8Array = Uint8Array;
|
|
196
|
+
return _Uint8Array;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* This method returns the first argument it receives.
|
|
201
|
+
*
|
|
202
|
+
* @static
|
|
203
|
+
* @since 0.1.0
|
|
204
|
+
* @memberOf _
|
|
205
|
+
* @category Util
|
|
206
|
+
* @param {*} value Any value.
|
|
207
|
+
* @returns {*} Returns `value`.
|
|
208
|
+
* @example
|
|
209
|
+
*
|
|
210
|
+
* var object = { 'a': 1 };
|
|
211
|
+
*
|
|
212
|
+
* console.log(_.identity(object) === object);
|
|
213
|
+
* // => true
|
|
214
|
+
*/
|
|
215
|
+
|
|
216
|
+
var identity_1;
|
|
217
|
+
var hasRequiredIdentity;
|
|
218
|
+
|
|
219
|
+
function requireIdentity () {
|
|
220
|
+
if (hasRequiredIdentity) return identity_1;
|
|
221
|
+
hasRequiredIdentity = 1;
|
|
222
|
+
function identity(value) {
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
identity_1 = identity;
|
|
227
|
+
return identity_1;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { require_Stack as a, requireIdentity as b, require_Uint8Array as r };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { r as raf, a as addEventListenerWrap, p as polyfill } from './menu.js';
|
|
3
|
+
import { c as classNames, C as ConfigConsumer } from './config-provider.js';
|
|
4
|
+
import { o as omit } from './input.js';
|
|
5
|
+
import { R as ResizeObserver } from './index2.js';
|
|
6
|
+
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
|
|
9
|
+
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."); }
|
|
10
|
+
|
|
11
|
+
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); }
|
|
12
|
+
|
|
13
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
14
|
+
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
function throttleByAnimationFrame(fn) {
|
|
19
|
+
var requestId;
|
|
20
|
+
|
|
21
|
+
var later = function later(args) {
|
|
22
|
+
return function () {
|
|
23
|
+
requestId = null;
|
|
24
|
+
fn.apply(void 0, _toConsumableArray(args));
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var throttled = function throttled() {
|
|
29
|
+
if (requestId == null) {
|
|
30
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
31
|
+
args[_key] = arguments[_key];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
requestId = raf(later(args));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
throttled.cancel = function () {
|
|
39
|
+
return raf.cancel(requestId);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return throttled;
|
|
43
|
+
}
|
|
44
|
+
function throttleByAnimationFrameDecorator() {
|
|
45
|
+
// eslint-disable-next-line func-names
|
|
46
|
+
return function (target, key, descriptor) {
|
|
47
|
+
var fn = descriptor.value;
|
|
48
|
+
var definingProperty = false;
|
|
49
|
+
return {
|
|
50
|
+
configurable: true,
|
|
51
|
+
get: function get() {
|
|
52
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
53
|
+
if (definingProperty || this === target.prototype || this.hasOwnProperty(key)) {
|
|
54
|
+
return fn;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var boundFn = throttleByAnimationFrame(fn.bind(this));
|
|
58
|
+
definingProperty = true;
|
|
59
|
+
Object.defineProperty(this, key, {
|
|
60
|
+
value: boundFn,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true
|
|
63
|
+
});
|
|
64
|
+
definingProperty = false;
|
|
65
|
+
return boundFn;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getTargetRect(target) {
|
|
72
|
+
return target !== window ? target.getBoundingClientRect() : {
|
|
73
|
+
top: 0,
|
|
74
|
+
bottom: window.innerHeight
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getFixedTop(placeholderReact, targetRect, offsetTop) {
|
|
78
|
+
if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {
|
|
79
|
+
return offsetTop + targetRect.top;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
function getFixedBottom(placeholderReact, targetRect, offsetBottom) {
|
|
85
|
+
if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {
|
|
86
|
+
var targetBottomOffset = window.innerHeight - targetRect.bottom;
|
|
87
|
+
return offsetBottom + targetBottomOffset;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return undefined;
|
|
91
|
+
} // ======================== Observer ========================
|
|
92
|
+
|
|
93
|
+
var TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];
|
|
94
|
+
var observerEntities = [];
|
|
95
|
+
function addObserveTarget(target, affix) {
|
|
96
|
+
if (!target) return;
|
|
97
|
+
var entity = observerEntities.find(function (item) {
|
|
98
|
+
return item.target === target;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (entity) {
|
|
102
|
+
entity.affixList.push(affix);
|
|
103
|
+
} else {
|
|
104
|
+
entity = {
|
|
105
|
+
target: target,
|
|
106
|
+
affixList: [affix],
|
|
107
|
+
eventHandlers: {}
|
|
108
|
+
};
|
|
109
|
+
observerEntities.push(entity); // Add listener
|
|
110
|
+
|
|
111
|
+
TRIGGER_EVENTS.forEach(function (eventName) {
|
|
112
|
+
entity.eventHandlers[eventName] = addEventListenerWrap(target, eventName, function () {
|
|
113
|
+
entity.affixList.forEach(function (targetAffix) {
|
|
114
|
+
targetAffix.lazyUpdatePosition();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function removeObserveTarget(affix) {
|
|
121
|
+
var observerEntity = observerEntities.find(function (oriObserverEntity) {
|
|
122
|
+
var hasAffix = oriObserverEntity.affixList.some(function (item) {
|
|
123
|
+
return item === affix;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
if (hasAffix) {
|
|
127
|
+
oriObserverEntity.affixList = oriObserverEntity.affixList.filter(function (item) {
|
|
128
|
+
return item !== affix;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return hasAffix;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (observerEntity && observerEntity.affixList.length === 0) {
|
|
136
|
+
observerEntities = observerEntities.filter(function (item) {
|
|
137
|
+
return item !== observerEntity;
|
|
138
|
+
}); // Remove listener
|
|
139
|
+
|
|
140
|
+
TRIGGER_EVENTS.forEach(function (eventName) {
|
|
141
|
+
var handler = observerEntity.eventHandlers[eventName];
|
|
142
|
+
|
|
143
|
+
if (handler && handler.remove) {
|
|
144
|
+
handler.remove();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
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); }
|
|
151
|
+
|
|
152
|
+
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; }
|
|
153
|
+
|
|
154
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
155
|
+
|
|
156
|
+
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); } }
|
|
157
|
+
|
|
158
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
|
|
159
|
+
|
|
160
|
+
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); }
|
|
161
|
+
|
|
162
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
163
|
+
|
|
164
|
+
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); }; }
|
|
165
|
+
|
|
166
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
167
|
+
|
|
168
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
169
|
+
|
|
170
|
+
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; } }
|
|
171
|
+
|
|
172
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
173
|
+
|
|
174
|
+
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); }
|
|
175
|
+
|
|
176
|
+
var __decorate = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
177
|
+
var c = arguments.length,
|
|
178
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
179
|
+
d;
|
|
180
|
+
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
|
|
181
|
+
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
182
|
+
}
|
|
183
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function getDefaultTarget() {
|
|
187
|
+
return typeof window !== 'undefined' ? window : null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var AffixStatus;
|
|
191
|
+
|
|
192
|
+
(function (AffixStatus) {
|
|
193
|
+
AffixStatus[AffixStatus["None"] = 0] = "None";
|
|
194
|
+
AffixStatus[AffixStatus["Prepare"] = 1] = "Prepare";
|
|
195
|
+
})(AffixStatus || (AffixStatus = {}));
|
|
196
|
+
|
|
197
|
+
var Affix = /*#__PURE__*/function (_React$Component) {
|
|
198
|
+
_inherits(Affix, _React$Component);
|
|
199
|
+
|
|
200
|
+
var _super = _createSuper(Affix);
|
|
201
|
+
|
|
202
|
+
function Affix() {
|
|
203
|
+
var _this;
|
|
204
|
+
|
|
205
|
+
_classCallCheck(this, Affix);
|
|
206
|
+
|
|
207
|
+
_this = _super.apply(this, arguments);
|
|
208
|
+
_this.state = {
|
|
209
|
+
status: AffixStatus.None,
|
|
210
|
+
lastAffix: false,
|
|
211
|
+
prevTarget: null
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
_this.getOffsetTop = function () {
|
|
215
|
+
var _this$props = _this.props,
|
|
216
|
+
offset = _this$props.offset,
|
|
217
|
+
offsetBottom = _this$props.offsetBottom;
|
|
218
|
+
var offsetTop = _this.props.offsetTop;
|
|
219
|
+
|
|
220
|
+
if (typeof offsetTop === 'undefined') {
|
|
221
|
+
offsetTop = offset;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (offsetBottom === undefined && offsetTop === undefined) {
|
|
225
|
+
offsetTop = 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return offsetTop;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
_this.getOffsetBottom = function () {
|
|
232
|
+
return _this.props.offsetBottom;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
_this.savePlaceholderNode = function (node) {
|
|
236
|
+
_this.placeholderNode = node;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
_this.saveFixedNode = function (node) {
|
|
240
|
+
_this.fixedNode = node;
|
|
241
|
+
}; // =================== Measure ===================
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
_this.measure = function () {
|
|
245
|
+
var _this$state = _this.state,
|
|
246
|
+
status = _this$state.status,
|
|
247
|
+
lastAffix = _this$state.lastAffix;
|
|
248
|
+
var _this$props2 = _this.props,
|
|
249
|
+
target = _this$props2.target,
|
|
250
|
+
onChange = _this$props2.onChange;
|
|
251
|
+
|
|
252
|
+
if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !target) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
var offsetTop = _this.getOffsetTop();
|
|
257
|
+
|
|
258
|
+
var offsetBottom = _this.getOffsetBottom();
|
|
259
|
+
|
|
260
|
+
var targetNode = target();
|
|
261
|
+
|
|
262
|
+
if (!targetNode) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
var newState = {
|
|
267
|
+
status: AffixStatus.None
|
|
268
|
+
};
|
|
269
|
+
var targetRect = getTargetRect(targetNode);
|
|
270
|
+
var placeholderReact = getTargetRect(_this.placeholderNode);
|
|
271
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
|
272
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
|
273
|
+
|
|
274
|
+
if (fixedTop !== undefined) {
|
|
275
|
+
newState.affixStyle = {
|
|
276
|
+
position: 'fixed',
|
|
277
|
+
top: fixedTop,
|
|
278
|
+
width: placeholderReact.width,
|
|
279
|
+
height: placeholderReact.height
|
|
280
|
+
};
|
|
281
|
+
newState.placeholderStyle = {
|
|
282
|
+
width: placeholderReact.width,
|
|
283
|
+
height: placeholderReact.height
|
|
284
|
+
};
|
|
285
|
+
} else if (fixedBottom !== undefined) {
|
|
286
|
+
newState.affixStyle = {
|
|
287
|
+
position: 'fixed',
|
|
288
|
+
bottom: fixedBottom,
|
|
289
|
+
width: placeholderReact.width,
|
|
290
|
+
height: placeholderReact.height
|
|
291
|
+
};
|
|
292
|
+
newState.placeholderStyle = {
|
|
293
|
+
width: placeholderReact.width,
|
|
294
|
+
height: placeholderReact.height
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
newState.lastAffix = !!newState.affixStyle;
|
|
299
|
+
|
|
300
|
+
if (onChange && lastAffix !== newState.lastAffix) {
|
|
301
|
+
onChange(newState.lastAffix);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
_this.setState(newState);
|
|
305
|
+
}; // @ts-ignore TS6133
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
_this.prepareMeasure = function () {
|
|
309
|
+
// event param is used before. Keep compatible ts define here.
|
|
310
|
+
_this.setState({
|
|
311
|
+
status: AffixStatus.Prepare,
|
|
312
|
+
affixStyle: undefined,
|
|
313
|
+
placeholderStyle: undefined
|
|
314
|
+
}); // Test if `updatePosition` called
|
|
315
|
+
}; // =================== Render ===================
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
_this.renderAffix = function (_ref) {
|
|
319
|
+
var getPrefixCls = _ref.getPrefixCls;
|
|
320
|
+
var _this$state2 = _this.state,
|
|
321
|
+
affixStyle = _this$state2.affixStyle,
|
|
322
|
+
placeholderStyle = _this$state2.placeholderStyle;
|
|
323
|
+
var _this$props3 = _this.props,
|
|
324
|
+
prefixCls = _this$props3.prefixCls,
|
|
325
|
+
children = _this$props3.children;
|
|
326
|
+
var className = classNames(_defineProperty({}, getPrefixCls('affix', prefixCls), affixStyle));
|
|
327
|
+
var props = omit(_this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange']); // Omit this since `onTestUpdatePosition` only works on test.
|
|
328
|
+
|
|
329
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
330
|
+
onResize: function onResize() {
|
|
331
|
+
_this.updatePosition();
|
|
332
|
+
}
|
|
333
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
|
334
|
+
ref: _this.savePlaceholderNode
|
|
335
|
+
}), affixStyle && /*#__PURE__*/React.createElement("div", {
|
|
336
|
+
style: placeholderStyle,
|
|
337
|
+
"aria-hidden": "true"
|
|
338
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
339
|
+
className: className,
|
|
340
|
+
ref: _this.saveFixedNode,
|
|
341
|
+
style: affixStyle
|
|
342
|
+
}, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
343
|
+
onResize: function onResize() {
|
|
344
|
+
_this.updatePosition();
|
|
345
|
+
}
|
|
346
|
+
}, children))));
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
return _this;
|
|
350
|
+
} // Event handler
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
_createClass(Affix, [{
|
|
354
|
+
key: "componentDidMount",
|
|
355
|
+
value: function componentDidMount() {
|
|
356
|
+
var _this2 = this;
|
|
357
|
+
|
|
358
|
+
var target = this.props.target;
|
|
359
|
+
|
|
360
|
+
if (target) {
|
|
361
|
+
// [Legacy] Wait for parent component ref has its value.
|
|
362
|
+
// We should use target as directly element instead of function which makes element check hard.
|
|
363
|
+
this.timeout = setTimeout(function () {
|
|
364
|
+
addObserveTarget(target(), _this2); // Mock Event object.
|
|
365
|
+
|
|
366
|
+
_this2.updatePosition();
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}, {
|
|
371
|
+
key: "componentDidUpdate",
|
|
372
|
+
value: function componentDidUpdate(prevProps) {
|
|
373
|
+
var prevTarget = this.state.prevTarget;
|
|
374
|
+
var target = this.props.target;
|
|
375
|
+
var newTarget = null;
|
|
376
|
+
|
|
377
|
+
if (target) {
|
|
378
|
+
newTarget = target() || null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (prevTarget !== newTarget) {
|
|
382
|
+
removeObserveTarget(this);
|
|
383
|
+
|
|
384
|
+
if (newTarget) {
|
|
385
|
+
addObserveTarget(newTarget, this); // Mock Event object.
|
|
386
|
+
|
|
387
|
+
this.updatePosition();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
this.setState({
|
|
391
|
+
prevTarget: newTarget
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {
|
|
396
|
+
this.updatePosition();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
this.measure();
|
|
400
|
+
}
|
|
401
|
+
}, {
|
|
402
|
+
key: "componentWillUnmount",
|
|
403
|
+
value: function componentWillUnmount() {
|
|
404
|
+
clearTimeout(this.timeout);
|
|
405
|
+
removeObserveTarget(this);
|
|
406
|
+
this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683
|
|
407
|
+
|
|
408
|
+
this.lazyUpdatePosition.cancel();
|
|
409
|
+
} // Handle realign logic
|
|
410
|
+
|
|
411
|
+
}, {
|
|
412
|
+
key: "updatePosition",
|
|
413
|
+
value: function updatePosition() {
|
|
414
|
+
this.prepareMeasure();
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
key: "lazyUpdatePosition",
|
|
418
|
+
value: function lazyUpdatePosition() {
|
|
419
|
+
var target = this.props.target;
|
|
420
|
+
var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth
|
|
421
|
+
|
|
422
|
+
if (target && affixStyle) {
|
|
423
|
+
var offsetTop = this.getOffsetTop();
|
|
424
|
+
var offsetBottom = this.getOffsetBottom();
|
|
425
|
+
var targetNode = target();
|
|
426
|
+
|
|
427
|
+
if (targetNode && this.placeholderNode) {
|
|
428
|
+
var targetRect = getTargetRect(targetNode);
|
|
429
|
+
var placeholderReact = getTargetRect(this.placeholderNode);
|
|
430
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
|
431
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
|
432
|
+
|
|
433
|
+
if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
} // Directly call prepare measure since it's already throttled.
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
this.prepareMeasure();
|
|
441
|
+
}
|
|
442
|
+
}, {
|
|
443
|
+
key: "render",
|
|
444
|
+
value: function render() {
|
|
445
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderAffix);
|
|
446
|
+
}
|
|
447
|
+
}]);
|
|
448
|
+
|
|
449
|
+
return Affix;
|
|
450
|
+
}(React.Component);
|
|
451
|
+
|
|
452
|
+
Affix.defaultProps = {
|
|
453
|
+
target: getDefaultTarget
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "updatePosition", null);
|
|
457
|
+
|
|
458
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "lazyUpdatePosition", null);
|
|
459
|
+
|
|
460
|
+
polyfill(Affix);
|
|
461
|
+
|
|
462
|
+
export { Affix as A };
|