musae 0.3.3 → 0.3.5
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/components/button/button.cjs +11 -10
- package/dist/components/button/button.mjs +7 -6
- package/dist/components/calendar/contribution.cjs +251 -0
- package/dist/components/calendar/contribution.d.ts +13 -0
- package/dist/components/calendar/contribution.mjs +249 -0
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/config/provider.cjs +2 -2
- package/dist/components/config/provider.mjs +2 -2
- package/dist/components/drawer/popup.cjs +51 -17
- package/dist/components/drawer/popup.d.ts +1 -1
- package/dist/components/drawer/popup.mjs +51 -17
- package/dist/components/fab/floatable.d.ts +1 -1
- package/dist/components/icon/icons/action/delete.cjs +20 -0
- package/dist/components/icon/icons/action/delete.d.ts +3 -0
- package/dist/components/icon/icons/action/delete.mjs +18 -0
- package/dist/components/icon/icons/action/index.cjs +7 -1
- package/dist/components/icon/icons/action/index.d.ts +5 -1
- package/dist/components/icon/icons/action/index.mjs +6 -2
- package/dist/components/icon/icons/action/three-d-rotation.cjs +28 -0
- package/dist/components/icon/icons/action/three-d-rotation.d.ts +3 -0
- package/dist/components/icon/icons/action/three-d-rotation.mjs +26 -0
- package/dist/components/icon/icons/editor/attch-file.cjs +20 -0
- package/dist/components/icon/icons/editor/attch-file.d.ts +3 -0
- package/dist/components/icon/icons/editor/attch-file.mjs +18 -0
- package/dist/components/icon/icons/editor/index.cjs +4 -1
- package/dist/components/icon/icons/editor/index.d.ts +3 -1
- package/dist/components/icon/icons/editor/index.mjs +4 -2
- package/dist/components/icon/icons/index.cjs +6 -0
- package/dist/components/icon/icons/index.mjs +3 -0
- package/dist/components/menu/hooks.d.ts +1 -2
- package/dist/components/menu/item.d.ts +2 -3
- package/dist/components/pagination/pagination.cjs +1 -1
- package/dist/components/pagination/pagination.mjs +2 -2
- package/dist/components/popover/popover.cjs +1 -1
- package/dist/components/popover/popover.mjs +1 -1
- package/dist/components/popper/dropdown.cjs +44 -19
- package/dist/components/popper/dropdown.mjs +46 -21
- package/dist/components/popper/hooks.cjs +88 -89
- package/dist/components/popper/hooks.d.ts +7 -13
- package/dist/components/popper/hooks.mjs +91 -91
- package/dist/components/rich-text-editor/plugins/controlled-state/index.cjs +1 -2
- package/dist/components/rich-text-editor/plugins/controlled-state/index.mjs +1 -2
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.cjs +5 -4
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.d.ts +3 -3
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.mjs +3 -4
- package/dist/components/rich-text-editor/rich-text-editor.cjs +5 -5
- package/dist/components/rich-text-editor/rich-text-editor.mjs +3 -3
- package/dist/components/select/utils.cjs +1 -3
- package/dist/components/select/utils.d.ts +1 -1
- package/dist/components/select/utils.mjs +2 -4
- package/dist/components/skeleton/skeleton.cjs +5 -48
- package/dist/components/skeleton/skeleton.d.ts +1 -1
- package/dist/components/skeleton/skeleton.mjs +5 -48
- package/dist/components/steps/context.d.ts +1 -1
- package/dist/components/steps/item.d.ts +1 -1
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/switch/switch.cjs +7 -6
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.mjs +8 -7
- package/dist/components/table/body.cjs +3 -1
- package/dist/components/table/body.mjs +3 -1
- package/dist/components/tabs/context.d.ts +1 -1
- package/dist/components/tabs/hooks.d.ts +2 -2
- package/dist/components/tabs/navigation.d.ts +1 -1
- package/dist/components/tabs/panels.d.ts +1 -1
- package/dist/components/tabs/tab.d.ts +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/theme/hooks.cjs +6 -6
- package/dist/components/theme/hooks.d.ts +1 -1
- package/dist/components/theme/hooks.mjs +6 -6
- package/dist/components/theme/theme-provider.cjs +12 -6
- package/dist/components/theme/theme-provider.d.ts +2 -2
- package/dist/components/theme/theme-provider.mjs +12 -6
- package/dist/components/time-picker/hooks.d.ts +1 -1
- package/dist/components/time-picker/panel.d.ts +1 -1
- package/dist/components/time-picker/time-picker.d.ts +1 -1
- package/dist/components/timeline/context.d.ts +1 -1
- package/dist/components/timeline/item.d.ts +1 -1
- package/dist/components/timeline/timeline.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/transfer/context.d.ts +1 -1
- package/dist/components/transfer/hooks.d.ts +1 -1
- package/dist/components/transfer/item.d.ts +1 -1
- package/dist/components/transfer/list.d.ts +1 -1
- package/dist/components/transfer/transfer.d.ts +1 -1
- package/dist/components/upload/upload.cjs +31 -6
- package/dist/components/upload/upload.d.ts +2 -2
- package/dist/components/upload/upload.mjs +31 -6
- package/dist/components/upload/uploadeds.cjs +119 -55
- package/dist/components/upload/uploadeds.d.ts +1 -1
- package/dist/components/upload/uploadeds.mjs +121 -57
- package/dist/components/upload/utils.cjs +9 -0
- package/dist/components/upload/utils.d.ts +6 -0
- package/dist/components/upload/utils.mjs +9 -0
- package/dist/components/visually-hidden/visually-hidden.d.ts +1 -1
- package/dist/components/waterfall/sequential.d.ts +1 -1
- package/dist/components/waterfall/waterfall.d.ts +1 -1
- package/dist/components/watermark/hooks.d.ts +1 -1
- package/dist/components/watermark/watermark.d.ts +1 -1
- package/dist/hooks/use-class-names.d.ts +1 -0
- package/dist/hooks/use-closable.cjs +0 -8
- package/dist/hooks/use-closable.mjs +0 -8
- package/dist/hooks/use-container.d.ts +1 -1
- package/dist/hooks/use-lazy-boolean.cjs +2 -2
- package/dist/hooks/use-lazy-boolean.mjs +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -0
- package/dist/locale/locales/en_US.cjs +5 -1
- package/dist/locale/locales/en_US.mjs +5 -1
- package/dist/locale/locales/zh_CN.cjs +5 -1
- package/dist/locale/locales/zh_CN.mjs +5 -1
- package/dist/styles.css +16 -7
- package/dist/types/drawer.d.ts +5 -0
- package/dist/types/element.d.ts +1 -56
- package/dist/types/form.d.ts +39 -1
- package/dist/types/locale.d.ts +6 -0
- package/dist/types/menu.d.ts +8 -3
- package/dist/types/popper.d.ts +1 -1
- package/dist/types/skeleton.d.ts +0 -7
- package/dist/{components/theme/types.d.ts → types/theme.d.ts} +1 -1
- package/dist/types/tree.d.ts +7 -2
- package/dist/{components/upload/types.d.ts → types/upload.d.ts} +59 -22
- package/dist/{components/waterfall/types.d.ts → types/waterfall.d.ts} +3 -3
- package/dist/utils/class-name.cjs +1 -1
- package/dist/utils/class-name.d.ts +3 -1
- package/dist/utils/class-name.mjs +1 -1
- package/dist/utils/colors.cjs +0 -10
- package/dist/utils/colors.d.ts +1 -4
- package/dist/utils/colors.mjs +1 -10
- package/dist/utils/component-token.cjs +1 -0
- package/dist/utils/component-token.d.ts +2 -1
- package/dist/utils/component-token.mjs +1 -0
- package/dist/utils/date.cjs +13 -0
- package/dist/utils/date.d.ts +6 -0
- package/dist/utils/date.mjs +13 -0
- package/package.json +25 -25
- package/dist/components/icon/icons/three-dimension-rotation.d.ts +0 -3
- /package/dist/{components/steps/types.d.ts → types/steps.d.ts} +0 -0
- /package/dist/{components/switch/types.d.ts → types/switch.d.ts} +0 -0
- /package/dist/{components/tabs/types.d.ts → types/tabs.d.ts} +0 -0
- /package/dist/{components/tag/types.d.ts → types/tag.d.ts} +0 -0
- /package/dist/{components/time-picker/types.d.ts → types/time-picker.d.ts} +0 -0
- /package/dist/{components/timeline/types.d.ts → types/timeline.d.ts} +0 -0
- /package/dist/{components/tooltip/types.d.ts → types/tooltip.d.ts} +0 -0
- /package/dist/{components/transfer/types.d.ts → types/transfer.d.ts} +0 -0
- /package/dist/{components/visually-hidden/types.d.ts → types/visually-hidden.d.ts} +0 -0
- /package/dist/{components/watermark/types.d.ts → types/watermark.d.ts} +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
3
|
import React, { useRef, useMemo, cloneElement } from 'react';
|
|
3
4
|
import { useEvent } from '@aiszlab/relax';
|
|
4
5
|
import { Keyboard } from '../../utils/keyboard.mjs';
|
|
5
6
|
import Uploadeds from './uploadeds.mjs';
|
|
7
|
+
import { Button } from '../button/button.mjs';
|
|
8
|
+
import { useLocale } from '../../locale/use-locale.mjs';
|
|
9
|
+
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
6
10
|
|
|
7
11
|
var Upload = function Upload(_ref) {
|
|
8
12
|
var _onClick = _ref.onClick,
|
|
@@ -10,9 +14,15 @@ var Upload = function Upload(_ref) {
|
|
|
10
14
|
multiple = _ref.multiple,
|
|
11
15
|
_children = _ref.children,
|
|
12
16
|
uploader = _ref.uploader,
|
|
13
|
-
onError = _ref.onError
|
|
17
|
+
onError = _ref.onError,
|
|
18
|
+
value = _ref.value,
|
|
19
|
+
onChange = _ref.onChange,
|
|
20
|
+
limit = _ref.limit;
|
|
14
21
|
var inputRef = useRef(null);
|
|
15
22
|
var uploadedsRef = useRef(null);
|
|
23
|
+
var _useLocale = useLocale(ComponentToken.Upload),
|
|
24
|
+
_useLocale2 = _slicedToArray(_useLocale, 1),
|
|
25
|
+
_locale = _useLocale2[0];
|
|
16
26
|
// file upload
|
|
17
27
|
var upload = useEvent(function (files) {
|
|
18
28
|
files.forEach(function (file) {
|
|
@@ -20,7 +30,7 @@ var Upload = function Upload(_ref) {
|
|
|
20
30
|
(_uploadedsRef$current = uploadedsRef.current) === null || _uploadedsRef$current === void 0 || _uploadedsRef$current.add(file);
|
|
21
31
|
});
|
|
22
32
|
});
|
|
23
|
-
var
|
|
33
|
+
var _onChange = useEvent(function (e) {
|
|
24
34
|
var files = e.target.files;
|
|
25
35
|
if (!files) return;
|
|
26
36
|
upload(Array.from(files));
|
|
@@ -43,17 +53,28 @@ var Upload = function Upload(_ref) {
|
|
|
43
53
|
upload(files);
|
|
44
54
|
};
|
|
45
55
|
var styled = {
|
|
56
|
+
upload: {
|
|
57
|
+
className: "musaex-78zum5 musaex-dt5ytf musaex-1lsrmdg"
|
|
58
|
+
},
|
|
46
59
|
input: {
|
|
47
60
|
className: "musaex-1s85apg"
|
|
48
61
|
}
|
|
49
62
|
};
|
|
50
63
|
var children = useMemo(function () {
|
|
64
|
+
if (!_children) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
66
|
+
disabled: disabled
|
|
67
|
+
}, _locale.upload);
|
|
68
|
+
}
|
|
51
69
|
// @ts-ignore
|
|
52
70
|
return /*#__PURE__*/cloneElement(_children, {
|
|
53
71
|
disabled: disabled
|
|
54
72
|
});
|
|
55
|
-
}, [_children, disabled]);
|
|
56
|
-
return /*#__PURE__*/React.createElement("div",
|
|
73
|
+
}, [_children, disabled, _locale]);
|
|
74
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: styled.upload.className,
|
|
76
|
+
style: styled.upload.style
|
|
77
|
+
}, /*#__PURE__*/React.createElement("div", _objectSpread({}, !disabled && {
|
|
57
78
|
onClick: onClick,
|
|
58
79
|
onKeyDown: onKeyDown,
|
|
59
80
|
onDrop: onDrop,
|
|
@@ -61,17 +82,21 @@ var Upload = function Upload(_ref) {
|
|
|
61
82
|
}), /*#__PURE__*/React.createElement("input", {
|
|
62
83
|
ref: inputRef,
|
|
63
84
|
type: "file",
|
|
85
|
+
value: "",
|
|
64
86
|
onClick: function onClick(e) {
|
|
65
87
|
return e.stopPropagation();
|
|
66
88
|
},
|
|
67
89
|
className: styled.input.className,
|
|
68
90
|
style: styled.input.style,
|
|
69
91
|
multiple: multiple,
|
|
70
|
-
onChange:
|
|
92
|
+
onChange: _onChange
|
|
71
93
|
}), children), /*#__PURE__*/React.createElement(Uploadeds, {
|
|
72
94
|
ref: uploadedsRef,
|
|
95
|
+
value: value,
|
|
73
96
|
uploader: uploader,
|
|
74
|
-
onError: onError
|
|
97
|
+
onError: onError,
|
|
98
|
+
onChange: onChange,
|
|
99
|
+
limit: limit
|
|
75
100
|
}));
|
|
76
101
|
};
|
|
77
102
|
|
|
@@ -1,72 +1,132 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
3
4
|
var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
|
|
4
5
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
5
6
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
7
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
8
|
var React = require('react');
|
|
9
|
+
var stylex = require('../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.cjs');
|
|
8
10
|
var relax = require('@aiszlab/relax');
|
|
11
|
+
var theme = require('../theme/theme.cjs');
|
|
12
|
+
var utils = require('./utils.cjs');
|
|
13
|
+
var path = require('@aiszlab/fuzzy/path');
|
|
9
14
|
var loading = require('../icon/icons/mock/loading.cjs');
|
|
10
|
-
var
|
|
15
|
+
var attchFile = require('../icon/icons/editor/attch-file.cjs');
|
|
16
|
+
var _delete = require('../icon/icons/action/delete.cjs');
|
|
11
17
|
|
|
18
|
+
var _excluded = ["key"];
|
|
19
|
+
var styles = {
|
|
20
|
+
item: {
|
|
21
|
+
display: "musaex-78zum5",
|
|
22
|
+
alignItems: "musaex-6s0dn4",
|
|
23
|
+
gap: "musaex-1lsrmdg",
|
|
24
|
+
$$css: true
|
|
25
|
+
}
|
|
26
|
+
};
|
|
12
27
|
var Uploadeds = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
13
28
|
var uploader = _ref.uploader,
|
|
14
|
-
onError = _ref.onError
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
onError = _ref.onError,
|
|
30
|
+
value = _ref.value,
|
|
31
|
+
onChange = _ref.onChange,
|
|
32
|
+
_ref$limit = _ref.limit,
|
|
33
|
+
limit = _ref$limit === void 0 ? Infinity : _ref$limit;
|
|
34
|
+
var _useControlledState = relax.useControlledState(value, {
|
|
35
|
+
defaultState: []
|
|
36
|
+
}),
|
|
37
|
+
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
38
|
+
values = _useControlledState2[0],
|
|
39
|
+
setValues = _useControlledState2[1];
|
|
40
|
+
var _useIdentity = relax.useIdentity(),
|
|
41
|
+
_useIdentity2 = _slicedToArray(_useIdentity, 2),
|
|
42
|
+
identity = _useIdentity2[1];
|
|
43
|
+
// convert to map, for performance
|
|
44
|
+
var items = React.useMemo(function () {
|
|
45
|
+
return values.reduce(function (prev, _item) {
|
|
46
|
+
var _isControlled = utils.isControlled(_item);
|
|
47
|
+
if (_isControlled) {
|
|
48
|
+
var _item$key;
|
|
49
|
+
var _id = (_item$key = _item.key) !== null && _item$key !== void 0 ? _item$key : _item.url;
|
|
50
|
+
prev.set(_id, {
|
|
51
|
+
key: _id,
|
|
52
|
+
status: "success",
|
|
53
|
+
url: _item.url
|
|
54
|
+
});
|
|
55
|
+
return prev;
|
|
56
|
+
}
|
|
57
|
+
prev.set(_item.key, _item);
|
|
58
|
+
return prev;
|
|
59
|
+
}, new Map());
|
|
60
|
+
}, [values]);
|
|
61
|
+
// when loading status changed
|
|
62
|
+
// use this func to set new status & callback
|
|
63
|
+
var onLoaded = relax.useEvent(function (id, status, _ref2) {
|
|
64
|
+
var url = _ref2.url,
|
|
65
|
+
error = _ref2.error;
|
|
66
|
+
if (!items.has(id)) return;
|
|
67
|
+
var _items = new Map(items);
|
|
68
|
+
var _values = Array.from(_items.set(id, _objectSpread(_objectSpread({}, _items.get(id)), {}, {
|
|
69
|
+
status: status,
|
|
70
|
+
url: url,
|
|
71
|
+
error: error
|
|
72
|
+
})).values());
|
|
73
|
+
setValues(_values);
|
|
74
|
+
// change handler
|
|
75
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
29
76
|
});
|
|
30
77
|
React.useImperativeHandle(ref, function () {
|
|
31
78
|
return {
|
|
32
79
|
add: function () {
|
|
33
80
|
var _add = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
|
|
34
|
-
var
|
|
81
|
+
var _hasUploader, _isOnlyOne, _isOverLimit, _key, _values, _url;
|
|
35
82
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
83
|
while (1) switch (_context.prev = _context.next) {
|
|
37
84
|
case 0:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
file: file,
|
|
44
|
-
status: status
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
// call request by user provided
|
|
48
|
-
if (hasUploader) {
|
|
49
|
-
_context.next = 6;
|
|
85
|
+
_hasUploader = !!uploader;
|
|
86
|
+
_isOnlyOne = limit === 1;
|
|
87
|
+
_isOverLimit = items.size >= limit; // over `limit`
|
|
88
|
+
if (!(_isOverLimit && !_isOnlyOne)) {
|
|
89
|
+
_context.next = 5;
|
|
50
90
|
break;
|
|
51
91
|
}
|
|
52
92
|
return _context.abrupt("return");
|
|
53
|
-
case
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
93
|
+
case 5:
|
|
94
|
+
// show loading in `add` trigger
|
|
95
|
+
_key = identity();
|
|
96
|
+
_values = Array.from(new Map(_isOnlyOne ? [] : items).set(_key, {
|
|
97
|
+
key: _key,
|
|
98
|
+
file: file,
|
|
99
|
+
status: _hasUploader ? "loading" : "success"
|
|
100
|
+
}).values());
|
|
101
|
+
setValues(_values);
|
|
102
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
103
|
+
// when no uploader, use original file
|
|
104
|
+
if (_hasUploader) {
|
|
63
105
|
_context.next = 11;
|
|
64
106
|
break;
|
|
65
107
|
}
|
|
66
108
|
return _context.abrupt("return");
|
|
67
109
|
case 11:
|
|
68
|
-
|
|
69
|
-
|
|
110
|
+
_context.next = 13;
|
|
111
|
+
return uploader(file)["catch"](function (error) {
|
|
112
|
+
return new Error(error.message);
|
|
113
|
+
});
|
|
114
|
+
case 13:
|
|
115
|
+
_url = _context.sent;
|
|
116
|
+
if (!(_url instanceof Error)) {
|
|
117
|
+
_context.next = 18;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
onLoaded(_key, "error", {
|
|
121
|
+
error: _url
|
|
122
|
+
});
|
|
123
|
+
onError === null || onError === void 0 || onError(_url);
|
|
124
|
+
return _context.abrupt("return");
|
|
125
|
+
case 18:
|
|
126
|
+
onLoaded(_key, "success", {
|
|
127
|
+
url: _url
|
|
128
|
+
});
|
|
129
|
+
case 19:
|
|
70
130
|
case "end":
|
|
71
131
|
return _context.stop();
|
|
72
132
|
}
|
|
@@ -79,33 +139,37 @@ var Uploadeds = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
79
139
|
}()
|
|
80
140
|
};
|
|
81
141
|
});
|
|
82
|
-
var remove = relax.useEvent(function (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
142
|
+
var remove = relax.useEvent(function (key) {
|
|
143
|
+
var _items = new Map(items);
|
|
144
|
+
_items["delete"](key);
|
|
145
|
+
var _values = Array.from(_items.values());
|
|
146
|
+
setValues(_values);
|
|
147
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
88
148
|
});
|
|
89
149
|
var styled = {
|
|
90
150
|
uploadeds: {
|
|
91
|
-
className: "musaex-78zum5 musaex-dt5ytf musaex-
|
|
151
|
+
className: "musaex-78zum5 musaex-dt5ytf musaex-1lsrmdg"
|
|
92
152
|
},
|
|
93
|
-
item:
|
|
94
|
-
|
|
153
|
+
item: stylex.default.props(styles.item, theme.typography.body.small),
|
|
154
|
+
filename: {
|
|
155
|
+
className: "musaex-98rzlu musaex-b3r6kr musaex-lyipyv"
|
|
95
156
|
}
|
|
96
157
|
};
|
|
97
158
|
return /*#__PURE__*/React.createElement("div", {
|
|
98
159
|
className: styled.uploadeds.className,
|
|
99
160
|
style: styled.uploadeds.style
|
|
100
|
-
}, Array.from(items.
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
item = _ref3
|
|
161
|
+
}, Array.from(items.values()).map(function (_ref3) {
|
|
162
|
+
var _item$file$name, _item$file, _item$url;
|
|
163
|
+
var key = _ref3.key,
|
|
164
|
+
item = _objectWithoutProperties(_ref3, _excluded);
|
|
104
165
|
return /*#__PURE__*/React.createElement("div", {
|
|
105
166
|
key: key,
|
|
106
167
|
className: styled.item.className,
|
|
107
168
|
style: styled.item.style
|
|
108
|
-
}, /*#__PURE__*/React.createElement(loading.default, null), item.
|
|
169
|
+
}, item.status === "loading" && /*#__PURE__*/React.createElement(loading.default, null), item.status !== "loading" && /*#__PURE__*/React.createElement(attchFile.default, null), /*#__PURE__*/React.createElement("span", {
|
|
170
|
+
className: styled.filename.className,
|
|
171
|
+
style: styled.filename.style
|
|
172
|
+
}, (_item$file$name = (_item$file = item.file) === null || _item$file === void 0 ? void 0 : _item$file.name) !== null && _item$file$name !== void 0 ? _item$file$name : path.leaf((_item$url = item.url) !== null && _item$url !== void 0 ? _item$url : "")), /*#__PURE__*/React.createElement(_delete.default, {
|
|
109
173
|
onClick: function onClick() {
|
|
110
174
|
return remove(key);
|
|
111
175
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { UploadedsProps, UploadedsRef } from "
|
|
2
|
+
import type { UploadedsProps, UploadedsRef } from "musae/types/upload";
|
|
3
3
|
declare const Uploadeds: React.ForwardRefExoticComponent<UploadedsProps & React.RefAttributes<UploadedsRef>>;
|
|
4
4
|
export default Uploadeds;
|
|
@@ -1,70 +1,130 @@
|
|
|
1
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
1
2
|
import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
|
|
2
3
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
3
4
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
-
import React, { forwardRef,
|
|
6
|
-
import
|
|
6
|
+
import React, { forwardRef, useMemo, useImperativeHandle } from 'react';
|
|
7
|
+
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
8
|
+
import { useControlledState, useIdentity, useEvent } from '@aiszlab/relax';
|
|
9
|
+
import { typography } from '../theme/theme.mjs';
|
|
10
|
+
import { isControlled } from './utils.mjs';
|
|
11
|
+
import { leaf } from '@aiszlab/fuzzy/path';
|
|
7
12
|
import Loading from '../icon/icons/mock/loading.mjs';
|
|
8
|
-
import
|
|
13
|
+
import AttachFile from '../icon/icons/editor/attch-file.mjs';
|
|
14
|
+
import Delete from '../icon/icons/action/delete.mjs';
|
|
9
15
|
|
|
16
|
+
var _excluded = ["key"];
|
|
17
|
+
var styles = {
|
|
18
|
+
item: {
|
|
19
|
+
display: "musaex-78zum5",
|
|
20
|
+
alignItems: "musaex-6s0dn4",
|
|
21
|
+
gap: "musaex-1lsrmdg",
|
|
22
|
+
$$css: true
|
|
23
|
+
}
|
|
24
|
+
};
|
|
10
25
|
var Uploadeds = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
11
26
|
var uploader = _ref.uploader,
|
|
12
|
-
onError = _ref.onError
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
onError = _ref.onError,
|
|
28
|
+
value = _ref.value,
|
|
29
|
+
onChange = _ref.onChange,
|
|
30
|
+
_ref$limit = _ref.limit,
|
|
31
|
+
limit = _ref$limit === void 0 ? Infinity : _ref$limit;
|
|
32
|
+
var _useControlledState = useControlledState(value, {
|
|
33
|
+
defaultState: []
|
|
34
|
+
}),
|
|
35
|
+
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
36
|
+
values = _useControlledState2[0],
|
|
37
|
+
setValues = _useControlledState2[1];
|
|
38
|
+
var _useIdentity = useIdentity(),
|
|
39
|
+
_useIdentity2 = _slicedToArray(_useIdentity, 2),
|
|
40
|
+
identity = _useIdentity2[1];
|
|
41
|
+
// convert to map, for performance
|
|
42
|
+
var items = useMemo(function () {
|
|
43
|
+
return values.reduce(function (prev, _item) {
|
|
44
|
+
var _isControlled = isControlled(_item);
|
|
45
|
+
if (_isControlled) {
|
|
46
|
+
var _item$key;
|
|
47
|
+
var _id = (_item$key = _item.key) !== null && _item$key !== void 0 ? _item$key : _item.url;
|
|
48
|
+
prev.set(_id, {
|
|
49
|
+
key: _id,
|
|
50
|
+
status: "success",
|
|
51
|
+
url: _item.url
|
|
52
|
+
});
|
|
53
|
+
return prev;
|
|
54
|
+
}
|
|
55
|
+
prev.set(_item.key, _item);
|
|
56
|
+
return prev;
|
|
57
|
+
}, new Map());
|
|
58
|
+
}, [values]);
|
|
59
|
+
// when loading status changed
|
|
60
|
+
// use this func to set new status & callback
|
|
61
|
+
var onLoaded = useEvent(function (id, status, _ref2) {
|
|
62
|
+
var url = _ref2.url,
|
|
63
|
+
error = _ref2.error;
|
|
64
|
+
if (!items.has(id)) return;
|
|
65
|
+
var _items = new Map(items);
|
|
66
|
+
var _values = Array.from(_items.set(id, _objectSpread(_objectSpread({}, _items.get(id)), {}, {
|
|
67
|
+
status: status,
|
|
68
|
+
url: url,
|
|
69
|
+
error: error
|
|
70
|
+
})).values());
|
|
71
|
+
setValues(_values);
|
|
72
|
+
// change handler
|
|
73
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
27
74
|
});
|
|
28
75
|
useImperativeHandle(ref, function () {
|
|
29
76
|
return {
|
|
30
77
|
add: function () {
|
|
31
78
|
var _add = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
|
|
32
|
-
var
|
|
79
|
+
var _hasUploader, _isOnlyOne, _isOverLimit, _key, _values, _url;
|
|
33
80
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
34
81
|
while (1) switch (_context.prev = _context.next) {
|
|
35
82
|
case 0:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
file: file,
|
|
42
|
-
status: status
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
// call request by user provided
|
|
46
|
-
if (hasUploader) {
|
|
47
|
-
_context.next = 6;
|
|
83
|
+
_hasUploader = !!uploader;
|
|
84
|
+
_isOnlyOne = limit === 1;
|
|
85
|
+
_isOverLimit = items.size >= limit; // over `limit`
|
|
86
|
+
if (!(_isOverLimit && !_isOnlyOne)) {
|
|
87
|
+
_context.next = 5;
|
|
48
88
|
break;
|
|
49
89
|
}
|
|
50
90
|
return _context.abrupt("return");
|
|
51
|
-
case
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
91
|
+
case 5:
|
|
92
|
+
// show loading in `add` trigger
|
|
93
|
+
_key = identity();
|
|
94
|
+
_values = Array.from(new Map(_isOnlyOne ? [] : items).set(_key, {
|
|
95
|
+
key: _key,
|
|
96
|
+
file: file,
|
|
97
|
+
status: _hasUploader ? "loading" : "success"
|
|
98
|
+
}).values());
|
|
99
|
+
setValues(_values);
|
|
100
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
101
|
+
// when no uploader, use original file
|
|
102
|
+
if (_hasUploader) {
|
|
61
103
|
_context.next = 11;
|
|
62
104
|
break;
|
|
63
105
|
}
|
|
64
106
|
return _context.abrupt("return");
|
|
65
107
|
case 11:
|
|
66
|
-
|
|
67
|
-
|
|
108
|
+
_context.next = 13;
|
|
109
|
+
return uploader(file)["catch"](function (error) {
|
|
110
|
+
return new Error(error.message);
|
|
111
|
+
});
|
|
112
|
+
case 13:
|
|
113
|
+
_url = _context.sent;
|
|
114
|
+
if (!(_url instanceof Error)) {
|
|
115
|
+
_context.next = 18;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
onLoaded(_key, "error", {
|
|
119
|
+
error: _url
|
|
120
|
+
});
|
|
121
|
+
onError === null || onError === void 0 || onError(_url);
|
|
122
|
+
return _context.abrupt("return");
|
|
123
|
+
case 18:
|
|
124
|
+
onLoaded(_key, "success", {
|
|
125
|
+
url: _url
|
|
126
|
+
});
|
|
127
|
+
case 19:
|
|
68
128
|
case "end":
|
|
69
129
|
return _context.stop();
|
|
70
130
|
}
|
|
@@ -77,33 +137,37 @@ var Uploadeds = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
77
137
|
}()
|
|
78
138
|
};
|
|
79
139
|
});
|
|
80
|
-
var remove = useEvent(function (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
140
|
+
var remove = useEvent(function (key) {
|
|
141
|
+
var _items = new Map(items);
|
|
142
|
+
_items["delete"](key);
|
|
143
|
+
var _values = Array.from(_items.values());
|
|
144
|
+
setValues(_values);
|
|
145
|
+
onChange === null || onChange === void 0 || onChange(_values);
|
|
86
146
|
});
|
|
87
147
|
var styled = {
|
|
88
148
|
uploadeds: {
|
|
89
|
-
className: "musaex-78zum5 musaex-dt5ytf musaex-
|
|
149
|
+
className: "musaex-78zum5 musaex-dt5ytf musaex-1lsrmdg"
|
|
90
150
|
},
|
|
91
|
-
item:
|
|
92
|
-
|
|
151
|
+
item: _stylex.props(styles.item, typography.body.small),
|
|
152
|
+
filename: {
|
|
153
|
+
className: "musaex-98rzlu musaex-b3r6kr musaex-lyipyv"
|
|
93
154
|
}
|
|
94
155
|
};
|
|
95
156
|
return /*#__PURE__*/React.createElement("div", {
|
|
96
157
|
className: styled.uploadeds.className,
|
|
97
158
|
style: styled.uploadeds.style
|
|
98
|
-
}, Array.from(items.
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
item = _ref3
|
|
159
|
+
}, Array.from(items.values()).map(function (_ref3) {
|
|
160
|
+
var _item$file$name, _item$file, _item$url;
|
|
161
|
+
var key = _ref3.key,
|
|
162
|
+
item = _objectWithoutProperties(_ref3, _excluded);
|
|
102
163
|
return /*#__PURE__*/React.createElement("div", {
|
|
103
164
|
key: key,
|
|
104
165
|
className: styled.item.className,
|
|
105
166
|
style: styled.item.style
|
|
106
|
-
}, /*#__PURE__*/React.createElement(Loading, null), item.
|
|
167
|
+
}, item.status === "loading" && /*#__PURE__*/React.createElement(Loading, null), item.status !== "loading" && /*#__PURE__*/React.createElement(AttachFile, null), /*#__PURE__*/React.createElement("span", {
|
|
168
|
+
className: styled.filename.className,
|
|
169
|
+
style: styled.filename.style
|
|
170
|
+
}, (_item$file$name = (_item$file = item.file) === null || _item$file === void 0 ? void 0 : _item$file.name) !== null && _item$file$name !== void 0 ? _item$file$name : leaf((_item$url = item.url) !== null && _item$url !== void 0 ? _item$url : "")), /*#__PURE__*/React.createElement(Delete, {
|
|
107
171
|
onClick: function onClick() {
|
|
108
172
|
return remove(key);
|
|
109
173
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { VisuallyHiddenProps } from "
|
|
2
|
+
import type { VisuallyHiddenProps } from "musae/types/visually-hidden";
|
|
3
3
|
declare const VisuallyHidden: ({ children }: VisuallyHiddenProps) => React.JSX.Element;
|
|
4
4
|
export default VisuallyHidden;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WaterfallProps } from "
|
|
1
|
+
import type { WaterfallProps } from "musae/types/waterfall";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import type { RequiredIn } from "@aiszlab/relax/types";
|
|
4
4
|
declare const Sequential: ({ children, columns, className, style, rowGap, }: RequiredIn<Omit<WaterfallProps, "sequential" | "gutter">, "children" | "columns"> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WaterfallProps } from "
|
|
1
|
+
import type { WaterfallProps } from "musae/types/waterfall";
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const Waterfall: ({ columns, gutter, children, sequential, className, style, }: WaterfallProps) => React.JSX.Element | null;
|
|
4
4
|
export default Waterfall;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { WatermarkProps } from "
|
|
2
|
+
import type { WatermarkProps } from "musae/types/watermark";
|
|
3
3
|
declare const Watermark: ({ children, mark: _mark, width, height, font: { color, fontSize, fontFamily, fontStyle, fontWeight, textAlign, }, }: WatermarkProps) => React.JSX.Element;
|
|
4
4
|
export default Watermark;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
2
1
|
var relax = require('@aiszlab/relax');
|
|
3
2
|
var React = require('react');
|
|
4
3
|
var button = require('../components/button/button.cjs');
|
|
@@ -26,18 +25,11 @@ var useClosable = function useClosable(_ref) {
|
|
|
26
25
|
// closer react element for dialog
|
|
27
26
|
var closer = React.useMemo(function () {
|
|
28
27
|
if (!triggers.has("close")) return null;
|
|
29
|
-
var styled = {
|
|
30
|
-
className: "musaex-167ikqz musaex-134unf5"
|
|
31
|
-
};
|
|
32
28
|
return /*#__PURE__*/React.createElement(button.Button, {
|
|
33
29
|
shape: "circular",
|
|
34
30
|
variant: "text",
|
|
35
31
|
prefix: /*#__PURE__*/React.createElement(close.default, null),
|
|
36
32
|
onClick: onClose,
|
|
37
|
-
className: styled.className,
|
|
38
|
-
style: _objectSpread(_objectSpread({}, styled.style), {}, {
|
|
39
|
-
position: "absolute"
|
|
40
|
-
}),
|
|
41
33
|
size: "small"
|
|
42
34
|
});
|
|
43
35
|
}, [triggers, onClose]);
|