zmdms-webui 1.0.9 → 1.1.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/dist/es/node_modules/@babel/runtime/helpers/esm/createClass.js +2 -2
- package/dist/es/node_modules/@babel/runtime/helpers/esm/defineProperty.js +2 -2
- package/dist/es/node_modules/@babel/runtime/helpers/esm/isNativeReflectConstruct.js +5 -8
- package/dist/es/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +8 -8
- package/dist/es/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +5 -5
- package/dist/es/node_modules/antd-img-crop/dist/antd-img-crop.esm.js +64 -35
- package/dist/es/node_modules/classnames/index.js +45 -27
- package/dist/es/node_modules/rc-resize-observer/es/Collection.js +3 -2
- package/dist/es/node_modules/rc-resize-observer/es/SingleObserver/index.js +20 -8
- package/dist/es/node_modules/rc-resize-observer/es/utils/observerUtil.js +4 -1
- package/dist/es/node_modules/rc-util/es/Dom/dynamicCSS.js +9 -4
- package/dist/es/node_modules/rc-util/es/hooks/useMemo.js +12 -0
- package/dist/es/node_modules/rc-util/es/raf.js +6 -1
- package/dist/es/node_modules/rc-util/es/ref.js +16 -3
- package/dist/es/node_modules/rc-util/es/warning.js +18 -3
- package/dist/es/node_modules/react-easy-crop/index.module.js +10 -4
- package/dist/es/node_modules/react-is/cjs/react-is.development.js +80 -40
- package/dist/es/node_modules/react-is/cjs/react-is.production.min.js +7 -7
- package/dist/es/table/index.css +1 -1
- package/dist/index.dark.css +1 -1
- package/dist/index.default.css +1 -1
- package/package.json +5 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import toPropertyKey from './toPropertyKey.js';
|
|
2
2
|
|
|
3
3
|
function _defineProperties(target, props) {
|
|
4
4
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -6,7 +6,7 @@ function _defineProperties(target, props) {
|
|
|
6
6
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
7
7
|
descriptor.configurable = true;
|
|
8
8
|
if ("value" in descriptor) descriptor.writable = true;
|
|
9
|
-
Object.defineProperty(target,
|
|
9
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import toPropertyKey from './toPropertyKey.js';
|
|
2
2
|
|
|
3
3
|
function _defineProperty(obj, key, value) {
|
|
4
|
-
key =
|
|
4
|
+
key = toPropertyKey(key);
|
|
5
5
|
if (key in obj) {
|
|
6
6
|
Object.defineProperty(obj, key, {
|
|
7
7
|
value: value,
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
function _isNativeReflectConstruct() {
|
|
2
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
3
|
-
if (Reflect.construct.sham) return false;
|
|
4
|
-
if (typeof Proxy === "function") return true;
|
|
5
2
|
try {
|
|
6
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
}
|
|
3
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
4
|
+
} catch (t) {}
|
|
5
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
6
|
+
return !!t;
|
|
7
|
+
})();
|
|
11
8
|
}
|
|
12
9
|
|
|
13
10
|
export { _isNativeReflectConstruct as default };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import _typeof from './typeof.js';
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
if (
|
|
5
|
-
var
|
|
6
|
-
if (
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
9
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
10
|
}
|
|
11
|
-
return (
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export {
|
|
14
|
+
export { toPrimitive as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _typeof from './typeof.js';
|
|
2
|
-
import
|
|
2
|
+
import toPrimitive from './toPrimitive.js';
|
|
3
3
|
|
|
4
|
-
function
|
|
5
|
-
var
|
|
6
|
-
return _typeof(
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : String(i);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { toPropertyKey as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __awaiter, __rest } from '../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { version } from 'antd';
|
|
4
4
|
import AntModal from 'antd/es/modal';
|
|
@@ -176,71 +176,100 @@ const ImgCrop = forwardRef((props, cropperRef) => {
|
|
|
176
176
|
const [modalImage, setModalImage] = useState('');
|
|
177
177
|
const onCancel = useRef();
|
|
178
178
|
const onOk = useRef();
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return
|
|
179
|
+
const runBeforeUpload = useCallback(({ beforeUpload, file, resolve, reject, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
const rawFile = file;
|
|
181
|
+
if (typeof beforeUpload !== 'function') {
|
|
182
|
+
resolve(rawFile);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
// https://ant.design/components/upload-cn#api
|
|
187
|
+
// https://github.com/ant-design/ant-design/blob/master/components/upload/Upload.tsx#L152-L178
|
|
188
|
+
const result = yield beforeUpload(file, [file]);
|
|
189
|
+
if (result === false) {
|
|
190
|
+
resolve(false);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
resolve((result !== true && result) || rawFile);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
reject(err);
|
|
198
|
+
}
|
|
199
|
+
}), []);
|
|
200
|
+
const getNewBeforeUpload = useCallback((beforeUpload) => {
|
|
201
|
+
return ((file, fileList) => {
|
|
202
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
203
|
+
let processedFile = file;
|
|
184
204
|
if (typeof cb.current.beforeCrop === 'function') {
|
|
185
205
|
try {
|
|
186
206
|
const result = yield cb.current.beforeCrop(file, fileList);
|
|
207
|
+
if (result === false) {
|
|
208
|
+
return runBeforeUpload({ beforeUpload, file, resolve, reject }); // not open modal
|
|
209
|
+
}
|
|
187
210
|
if (result !== true) {
|
|
188
|
-
|
|
211
|
+
processedFile = result || file; // will open modal
|
|
189
212
|
}
|
|
190
213
|
}
|
|
191
214
|
catch (err) {
|
|
192
|
-
return resolve
|
|
215
|
+
return runBeforeUpload({ beforeUpload, file, resolve, reject }); // not open modal
|
|
193
216
|
}
|
|
194
217
|
}
|
|
195
|
-
//
|
|
218
|
+
// read file
|
|
196
219
|
const reader = new FileReader();
|
|
197
220
|
reader.addEventListener('load', () => {
|
|
198
221
|
if (typeof reader.result === 'string') {
|
|
199
222
|
setModalImage(reader.result); // open modal
|
|
200
223
|
}
|
|
201
224
|
});
|
|
202
|
-
reader.readAsDataURL(
|
|
225
|
+
reader.readAsDataURL(processedFile);
|
|
203
226
|
// on modal cancel
|
|
204
227
|
onCancel.current = () => {
|
|
205
228
|
var _a, _b;
|
|
206
229
|
setModalImage('');
|
|
207
230
|
easyCropRef.current.onReset();
|
|
208
|
-
|
|
209
|
-
(_b = (_a = cb.current).onModalCancel) === null || _b === void 0 ? void 0 : _b.call(_a)
|
|
231
|
+
let hasResolveCalled = false;
|
|
232
|
+
(_b = (_a = cb.current).onModalCancel) === null || _b === void 0 ? void 0 : _b.call(_a, (LIST_IGNORE) => {
|
|
233
|
+
resolve(LIST_IGNORE);
|
|
234
|
+
hasResolveCalled = true;
|
|
235
|
+
});
|
|
236
|
+
if (!hasResolveCalled) {
|
|
237
|
+
resolve(AntUpload.LIST_IGNORE);
|
|
238
|
+
}
|
|
210
239
|
};
|
|
211
240
|
// on modal confirm
|
|
212
241
|
onOk.current = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
242
|
setModalImage('');
|
|
214
243
|
easyCropRef.current.onReset();
|
|
215
244
|
const canvas = getCropCanvas(event.target);
|
|
216
|
-
const { type, name, uid } =
|
|
245
|
+
const { type, name, uid } = processedFile;
|
|
217
246
|
canvas.toBlob((blob) => __awaiter(void 0, void 0, void 0, function* () {
|
|
218
|
-
var _a, _b, _c, _d, _e, _f;
|
|
219
247
|
const newFile = new File([blob], name, { type });
|
|
220
248
|
Object.assign(newFile, { uid });
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
resolve(err);
|
|
236
|
-
(_f = (_e = cb.current).onModalOk) === null || _f === void 0 ? void 0 : _f.call(_e, err);
|
|
237
|
-
}
|
|
249
|
+
runBeforeUpload({
|
|
250
|
+
beforeUpload,
|
|
251
|
+
file: newFile,
|
|
252
|
+
resolve: (file) => {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
resolve(file);
|
|
255
|
+
(_b = (_a = cb.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, file);
|
|
256
|
+
},
|
|
257
|
+
reject: (err) => {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
reject(err);
|
|
260
|
+
(_b = (_a = cb.current).onModalOk) === null || _b === void 0 ? void 0 : _b.call(_a, err);
|
|
261
|
+
},
|
|
262
|
+
});
|
|
238
263
|
}), type, quality);
|
|
239
264
|
});
|
|
240
265
|
}));
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
|
|
266
|
+
});
|
|
267
|
+
}, [getCropCanvas, quality, runBeforeUpload]);
|
|
268
|
+
const getNewUpload = useCallback((children) => {
|
|
269
|
+
const upload = Array.isArray(children) ? children[0] : children;
|
|
270
|
+
const _a = upload.props, { beforeUpload, accept } = _a, restUploadProps = __rest(_a, ["beforeUpload", "accept"]);
|
|
271
|
+
return Object.assign(Object.assign({}, upload), { props: Object.assign(Object.assign({}, restUploadProps), { accept: accept || 'image/*', beforeUpload: getNewBeforeUpload(beforeUpload) }) });
|
|
272
|
+
}, [getNewBeforeUpload]);
|
|
244
273
|
/**
|
|
245
274
|
* modal
|
|
246
275
|
*/
|
|
@@ -259,7 +288,7 @@ const ImgCrop = forwardRef((props, cropperRef) => {
|
|
|
259
288
|
const isCN = lang === 'zh-CN';
|
|
260
289
|
const title = modalTitle || (isCN ? '编辑图片' : 'Edit image');
|
|
261
290
|
const resetBtnText = resetText || (isCN ? '重置' : 'Reset');
|
|
262
|
-
return (jsxs(Fragment, { children: [
|
|
291
|
+
return (jsxs(Fragment, { children: [getNewUpload(children), modalImage && (jsx(AntModal, Object.assign({}, modalProps, modalBaseProps, { [openProp]: true, title: title, onCancel: onCancel.current, onOk: onOk.current, wrapClassName: wrapClassName, maskClosable: false, destroyOnClose: true, children: jsx(EasyCrop$1, { ref: easyCropRef, cropperRef: cropperRef, zoomSlider: zoomSlider, rotationSlider: rotationSlider, aspectSlider: aspectSlider, showReset: showReset, resetBtnText: resetBtnText, modalImage: modalImage, aspect: aspect, minZoom: minZoom, maxZoom: maxZoom, cropShape: cropShape, showGrid: showGrid, cropperProps: cropperProps }) })))] }));
|
|
263
292
|
});
|
|
264
293
|
|
|
265
294
|
export { ImgCrop as default };
|
|
@@ -14,39 +14,57 @@ import { __module as classnames } from '../../_virtual/index.js';
|
|
|
14
14
|
|
|
15
15
|
var hasOwn = {}.hasOwnProperty;
|
|
16
16
|
|
|
17
|
-
function classNames() {
|
|
18
|
-
var classes =
|
|
17
|
+
function classNames () {
|
|
18
|
+
var classes = '';
|
|
19
19
|
|
|
20
20
|
for (var i = 0; i < arguments.length; i++) {
|
|
21
21
|
var arg = arguments[i];
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
var argType = typeof arg;
|
|
25
|
-
|
|
26
|
-
if (argType === 'string' || argType === 'number') {
|
|
27
|
-
classes.push(arg);
|
|
28
|
-
} else if (Array.isArray(arg)) {
|
|
29
|
-
if (arg.length) {
|
|
30
|
-
var inner = classNames.apply(null, arg);
|
|
31
|
-
if (inner) {
|
|
32
|
-
classes.push(inner);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
} else if (argType === 'object') {
|
|
36
|
-
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
37
|
-
classes.push(arg.toString());
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
for (var key in arg) {
|
|
42
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
43
|
-
classes.push(key);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
22
|
+
if (arg) {
|
|
23
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
24
|
}
|
|
47
25
|
}
|
|
48
26
|
|
|
49
|
-
return classes
|
|
27
|
+
return classes;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseValue (arg) {
|
|
31
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
32
|
+
return arg;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof arg !== 'object') {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (Array.isArray(arg)) {
|
|
40
|
+
return classNames.apply(null, arg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
44
|
+
return arg.toString();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var classes = '';
|
|
48
|
+
|
|
49
|
+
for (var key in arg) {
|
|
50
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
51
|
+
classes = appendClass(classes, key);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return classes;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function appendClass (value, newClass) {
|
|
59
|
+
if (!newClass) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (value) {
|
|
64
|
+
return value + ' ' + newClass;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return value + newClass;
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
if (module.exports) {
|
|
@@ -20,12 +20,13 @@ function Collection(_ref) {
|
|
|
20
20
|
});
|
|
21
21
|
Promise.resolve().then(function () {
|
|
22
22
|
if (currentId === resizeIdRef.current) {
|
|
23
|
-
onBatchResize === null || onBatchResize === void 0
|
|
23
|
+
onBatchResize === null || onBatchResize === void 0 || onBatchResize(resizeInfosRef.current);
|
|
24
24
|
resizeInfosRef.current = [];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
|
|
27
28
|
// Continue bubbling if parent exist
|
|
28
|
-
onCollectionResize === null || onCollectionResize === void 0
|
|
29
|
+
onCollectionResize === null || onCollectionResize === void 0 || onCollectionResize(size, element, data);
|
|
29
30
|
}, [onBatchResize, onCollectionResize]);
|
|
30
31
|
return /*#__PURE__*/React.createElement(CollectionContext.Provider, {
|
|
31
32
|
value: onResize
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _objectSpread2 from '../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
2
|
-
import
|
|
3
|
-
import * as React from 'react';
|
|
2
|
+
import _typeof from '../../../@babel/runtime/helpers/esm/typeof.js';
|
|
4
3
|
import findDOMNode from '../../../rc-util/es/Dom/findDOMNode.js';
|
|
4
|
+
import { supportRef, useComposeRef } from '../../../rc-util/es/ref.js';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { CollectionContext } from '../Collection.js';
|
|
5
7
|
import { observe, unobserve } from '../utils/observerUtil.js';
|
|
6
8
|
import DomWrapper from './DomWrapper.js';
|
|
7
|
-
import { CollectionContext } from '../Collection.js';
|
|
8
9
|
|
|
9
10
|
function SingleObserver(props, ref) {
|
|
10
11
|
var children = props.children,
|
|
@@ -12,9 +13,11 @@ function SingleObserver(props, ref) {
|
|
|
12
13
|
var elementRef = React.useRef(null);
|
|
13
14
|
var wrapperRef = React.useRef(null);
|
|
14
15
|
var onCollectionResize = React.useContext(CollectionContext);
|
|
16
|
+
|
|
15
17
|
// =========================== Children ===========================
|
|
16
18
|
var isRenderProps = typeof children === 'function';
|
|
17
19
|
var mergedChildren = isRenderProps ? children(elementRef) : children;
|
|
20
|
+
|
|
18
21
|
// ============================= Size =============================
|
|
19
22
|
var sizeRef = React.useRef({
|
|
20
23
|
width: -1,
|
|
@@ -22,21 +25,25 @@ function SingleObserver(props, ref) {
|
|
|
22
25
|
offsetWidth: -1,
|
|
23
26
|
offsetHeight: -1
|
|
24
27
|
});
|
|
28
|
+
|
|
25
29
|
// ============================= Ref ==============================
|
|
26
30
|
var canRef = !isRenderProps && /*#__PURE__*/React.isValidElement(mergedChildren) && supportRef(mergedChildren);
|
|
27
31
|
var originRef = canRef ? mergedChildren.ref : null;
|
|
28
|
-
var mergedRef =
|
|
29
|
-
return composeRef(originRef, elementRef);
|
|
30
|
-
}, [originRef, elementRef]);
|
|
32
|
+
var mergedRef = useComposeRef(originRef, elementRef);
|
|
31
33
|
var getDom = function getDom() {
|
|
32
|
-
|
|
34
|
+
var _elementRef$current;
|
|
35
|
+
return findDOMNode(elementRef.current) || (
|
|
36
|
+
// Support `nativeElement` format
|
|
37
|
+
elementRef.current && _typeof(elementRef.current) === 'object' ? findDOMNode((_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 ? void 0 : _elementRef$current.nativeElement) : null) || findDOMNode(wrapperRef.current);
|
|
33
38
|
};
|
|
34
39
|
React.useImperativeHandle(ref, function () {
|
|
35
40
|
return getDom();
|
|
36
41
|
});
|
|
42
|
+
|
|
37
43
|
// =========================== Observe ============================
|
|
38
44
|
var propsRef = React.useRef(props);
|
|
39
45
|
propsRef.current = props;
|
|
46
|
+
|
|
40
47
|
// Handler
|
|
41
48
|
var onInternalResize = React.useCallback(function (target) {
|
|
42
49
|
var _propsRef$current = propsRef.current,
|
|
@@ -47,6 +54,7 @@ function SingleObserver(props, ref) {
|
|
|
47
54
|
height = _target$getBoundingCl.height;
|
|
48
55
|
var offsetWidth = target.offsetWidth,
|
|
49
56
|
offsetHeight = target.offsetHeight;
|
|
57
|
+
|
|
50
58
|
/**
|
|
51
59
|
* Resize observer trigger when content size changed.
|
|
52
60
|
* In most case we just care about element size,
|
|
@@ -62,6 +70,7 @@ function SingleObserver(props, ref) {
|
|
|
62
70
|
offsetHeight: offsetHeight
|
|
63
71
|
};
|
|
64
72
|
sizeRef.current = size;
|
|
73
|
+
|
|
65
74
|
// IE is strange, right?
|
|
66
75
|
var mergedOffsetWidth = offsetWidth === Math.round(width) ? width : offsetWidth;
|
|
67
76
|
var mergedOffsetHeight = offsetHeight === Math.round(height) ? height : offsetHeight;
|
|
@@ -69,8 +78,9 @@ function SingleObserver(props, ref) {
|
|
|
69
78
|
offsetWidth: mergedOffsetWidth,
|
|
70
79
|
offsetHeight: mergedOffsetHeight
|
|
71
80
|
});
|
|
81
|
+
|
|
72
82
|
// Let collection know what happened
|
|
73
|
-
onCollectionResize === null || onCollectionResize === void 0
|
|
83
|
+
onCollectionResize === null || onCollectionResize === void 0 || onCollectionResize(sizeInfo, target, data);
|
|
74
84
|
if (onResize) {
|
|
75
85
|
// defer the callback but not defer to next frame
|
|
76
86
|
Promise.resolve().then(function () {
|
|
@@ -79,6 +89,7 @@ function SingleObserver(props, ref) {
|
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
}, []);
|
|
92
|
+
|
|
82
93
|
// Dynamic observe
|
|
83
94
|
React.useEffect(function () {
|
|
84
95
|
var currentElement = getDom();
|
|
@@ -89,6 +100,7 @@ function SingleObserver(props, ref) {
|
|
|
89
100
|
return unobserve(currentElement, onInternalResize);
|
|
90
101
|
};
|
|
91
102
|
}, [elementRef.current, disabled]);
|
|
103
|
+
|
|
92
104
|
// ============================ Render ============================
|
|
93
105
|
return /*#__PURE__*/React.createElement(DomWrapper, {
|
|
94
106
|
ref: wrapperRef
|
|
@@ -6,16 +6,19 @@ function onResize(entities) {
|
|
|
6
6
|
entities.forEach(function (entity) {
|
|
7
7
|
var _elementListeners$get;
|
|
8
8
|
var target = entity.target;
|
|
9
|
-
(_elementListeners$get = elementListeners.get(target)) === null || _elementListeners$get === void 0
|
|
9
|
+
(_elementListeners$get = elementListeners.get(target)) === null || _elementListeners$get === void 0 || _elementListeners$get.forEach(function (listener) {
|
|
10
10
|
return listener(target);
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
+
|
|
14
15
|
// Note: ResizeObserver polyfill not support option to measure border-box resize
|
|
15
16
|
var resizeObserver = new index(onResize);
|
|
17
|
+
|
|
16
18
|
// Dev env only
|
|
17
19
|
process.env.NODE_ENV !== 'production' ? elementListeners : null; // eslint-disable-line
|
|
18
20
|
process.env.NODE_ENV !== 'production' ? onResize : null; // eslint-disable-line
|
|
21
|
+
|
|
19
22
|
// ============================== Observe ==============================
|
|
20
23
|
function observe(element, callback) {
|
|
21
24
|
if (!elementListeners.has(element)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread2 from '../../../@babel/runtime/helpers/esm/objectSpread2.js';
|
|
1
2
|
import canUseDom from './canUseDom.js';
|
|
2
3
|
import contains from './contains.js';
|
|
3
4
|
|
|
@@ -60,7 +61,7 @@ function injectCSS(css) {
|
|
|
60
61
|
if (prepend) {
|
|
61
62
|
// If is queue `prepend`, it will prepend first style and then append rest style
|
|
62
63
|
if (isPrependQueue) {
|
|
63
|
-
var existStyle = findStyles(container).filter(function (node) {
|
|
64
|
+
var existStyle = (option.styles || findStyles(container)).filter(function (node) {
|
|
64
65
|
// Ignore style which not injected by rc-util with prepend
|
|
65
66
|
if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
|
|
66
67
|
return false;
|
|
@@ -86,7 +87,7 @@ function injectCSS(css) {
|
|
|
86
87
|
function findExistNode(key) {
|
|
87
88
|
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
88
89
|
var container = getContainer(option);
|
|
89
|
-
return findStyles(container).find(function (node) {
|
|
90
|
+
return (option.styles || findStyles(container)).find(function (node) {
|
|
90
91
|
return node.getAttribute(getMark(option)) === key;
|
|
91
92
|
});
|
|
92
93
|
}
|
|
@@ -106,8 +107,12 @@ function syncRealContainer(container, option) {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
function updateCSS(css, key) {
|
|
109
|
-
var
|
|
110
|
-
var container = getContainer(
|
|
110
|
+
var originOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
111
|
+
var container = getContainer(originOption);
|
|
112
|
+
var styles = findStyles(container);
|
|
113
|
+
var option = _objectSpread2(_objectSpread2({}, originOption), {}, {
|
|
114
|
+
styles: styles
|
|
115
|
+
});
|
|
111
116
|
|
|
112
117
|
// Sync real parent
|
|
113
118
|
syncRealContainer(container, option);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
function useMemo(getValue, condition, shouldUpdate) {
|
|
4
|
+
var cacheRef = React.useRef({});
|
|
5
|
+
if (!('value' in cacheRef.current) || shouldUpdate(cacheRef.current.condition, condition)) {
|
|
6
|
+
cacheRef.current.value = getValue();
|
|
7
|
+
cacheRef.current.condition = condition;
|
|
8
|
+
}
|
|
9
|
+
return cacheRef.current.value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { useMemo as default };
|
|
@@ -43,8 +43,13 @@ var wrapperRaf = function wrapperRaf(callback) {
|
|
|
43
43
|
};
|
|
44
44
|
wrapperRaf.cancel = function (id) {
|
|
45
45
|
var realId = rafIds.get(id);
|
|
46
|
-
cleanup(
|
|
46
|
+
cleanup(id);
|
|
47
47
|
return caf(realId);
|
|
48
48
|
};
|
|
49
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
+
wrapperRaf.ids = function () {
|
|
51
|
+
return rafIds;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
49
54
|
|
|
50
55
|
export { wrapperRaf as default };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _typeof from '../../@babel/runtime/helpers/esm/typeof.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import { r as reactIsExports } from '../../react-is/index.js';
|
|
4
|
+
import useMemo from './hooks/useMemo.js';
|
|
4
5
|
|
|
5
6
|
function fillRef(ref, node) {
|
|
6
7
|
if (typeof ref === 'function') {
|
|
@@ -29,21 +30,33 @@ function composeRef() {
|
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
32
|
}
|
|
33
|
+
function useComposeRef() {
|
|
34
|
+
for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
35
|
+
refs[_key2] = arguments[_key2];
|
|
36
|
+
}
|
|
37
|
+
return useMemo(function () {
|
|
38
|
+
return composeRef.apply(void 0, refs);
|
|
39
|
+
}, refs, function (prev, next) {
|
|
40
|
+
return prev.length !== next.length || prev.every(function (ref, i) {
|
|
41
|
+
return ref !== next[i];
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
32
45
|
function supportRef(nodeOrComponent) {
|
|
33
46
|
var _type$prototype, _nodeOrComponent$prot;
|
|
34
47
|
var type = reactIsExports.isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type;
|
|
35
48
|
|
|
36
49
|
// Function component node
|
|
37
|
-
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render)) {
|
|
50
|
+
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render) && type.$$typeof !== reactIsExports.ForwardRef) {
|
|
38
51
|
return false;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
// Class component
|
|
42
|
-
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render)) {
|
|
55
|
+
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render) && nodeOrComponent.$$typeof !== reactIsExports.ForwardRef) {
|
|
43
56
|
return false;
|
|
44
57
|
}
|
|
45
58
|
return true;
|
|
46
59
|
}
|
|
47
60
|
/* eslint-enable */
|
|
48
61
|
|
|
49
|
-
export { composeRef, fillRef, supportRef };
|
|
62
|
+
export { composeRef, fillRef, supportRef, useComposeRef };
|
|
@@ -9,8 +9,19 @@ var preWarningFns = [];
|
|
|
9
9
|
var preMessage = function preMessage(fn) {
|
|
10
10
|
preWarningFns.push(fn);
|
|
11
11
|
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Warning if condition not match.
|
|
15
|
+
* @param valid Condition
|
|
16
|
+
* @param message Warning message
|
|
17
|
+
* @example
|
|
18
|
+
* ```js
|
|
19
|
+
* warning(false, 'some error'); // print some error
|
|
20
|
+
* warning(true, 'some error'); // print nothing
|
|
21
|
+
* warning(1 === 2, 'some error'); // print some error
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
12
24
|
function warning(valid, message) {
|
|
13
|
-
// Support uglify
|
|
14
25
|
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
15
26
|
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
16
27
|
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'warning');
|
|
@@ -20,8 +31,9 @@ function warning(valid, message) {
|
|
|
20
31
|
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
34
|
+
|
|
35
|
+
/** @see Similar to {@link warning} */
|
|
23
36
|
function note(valid, message) {
|
|
24
|
-
// Support uglify
|
|
25
37
|
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
26
38
|
var finalMessage = preWarningFns.reduce(function (msg, preMessageFn) {
|
|
27
39
|
return preMessageFn(msg !== null && msg !== void 0 ? msg : '', 'note');
|
|
@@ -40,15 +52,18 @@ function call(method, valid, message) {
|
|
|
40
52
|
warned[message] = true;
|
|
41
53
|
}
|
|
42
54
|
}
|
|
55
|
+
|
|
56
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
43
57
|
function warningOnce(valid, message) {
|
|
44
58
|
call(warning, valid, message);
|
|
45
59
|
}
|
|
60
|
+
|
|
61
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
46
62
|
function noteOnce(valid, message) {
|
|
47
63
|
call(note, valid, message);
|
|
48
64
|
}
|
|
49
65
|
warningOnce.preMessage = preMessage;
|
|
50
66
|
warningOnce.resetWarned = resetWarned;
|
|
51
67
|
warningOnce.noteOnce = noteOnce;
|
|
52
|
-
/* eslint-enable */
|
|
53
68
|
|
|
54
69
|
export { call, warningOnce as default, note, noteOnce, preMessage, resetWarned, warning, warningOnce };
|