@ucloud-fe/react-components 1.2.19 → 1.3.2
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/CHANGELOG.md +39 -0
- package/dist/icon.min.js +1 -1
- package/dist/main.min.js +4 -4
- package/index.d.ts +46 -41
- package/lib/__index.js +4 -0
- package/lib/components/AutoComplete/AutoComplete.d.ts +1 -1
- package/lib/components/AutoComplete/AutoComplete.js +1 -1
- package/lib/components/Calendar/Calendar.d.ts +4 -2
- package/lib/components/Calendar/Calendar.js +21 -11
- package/lib/components/Calendar/Month.d.ts +3 -28
- package/lib/components/Calendar/Month.js +3 -11
- package/lib/components/Cascader/Cascade.d.ts +24 -0
- package/lib/components/Cascader/Cascade.js +280 -0
- package/lib/components/Cascader/CascadeContext.d.ts +7 -0
- package/lib/components/Cascader/CascadeContext.js +20 -0
- package/lib/components/Cascader/Cascader.d.ts +41 -0
- package/lib/components/Cascader/Cascader.js +359 -0
- package/lib/components/Cascader/Item.d.ts +14 -0
- package/lib/components/Cascader/Item.js +97 -0
- package/lib/components/Cascader/Items.d.ts +11 -0
- package/lib/components/Cascader/Items.js +175 -0
- package/lib/components/Cascader/index.d.ts +2 -0
- package/lib/components/Cascader/index.js +13 -0
- package/lib/components/Cascader/interface.d.ts +12 -0
- package/lib/components/Cascader/interface.js +5 -0
- package/lib/components/Cascader/locale/en_US.js +11 -0
- package/lib/components/Cascader/locale/zh_CN.d.ts +5 -0
- package/lib/components/Cascader/locale/zh_CN.js +11 -0
- package/lib/components/Cascader/style/cascade.d.ts +15 -0
- package/lib/components/Cascader/style/cascade.js +55 -0
- package/lib/components/Cascader/style/index.d.ts +11 -0
- package/lib/components/Cascader/style/index.js +49 -0
- package/lib/components/Compact/Compact.js +6 -18
- package/lib/components/DatePicker/DatePicker.js +9 -3
- package/lib/components/DatePicker/Footer.d.ts +1 -1
- package/lib/components/DatePicker/Footer.js +3 -27
- package/lib/components/DatePicker/Month.js +2 -1
- package/lib/components/DatePicker/RangePicker.js +18 -10
- package/lib/components/DatePicker/style/index.d.ts +10 -5
- package/lib/components/DatePicker/style/index.js +30 -21
- package/lib/components/Input/Input.js +21 -18
- package/lib/components/LocaleProvider/LocaleProvider.js +1 -1
- package/lib/components/LocaleProvider/locale/en_US.js +5 -2
- package/lib/components/LocaleProvider/locale/zh_CN.js +5 -2
- package/lib/components/LocaleProvider/localeConsumerDecorator.js +1 -1
- package/lib/components/LocaleProvider/{locale/runtime.d.ts → runtime.d.ts} +1 -1
- package/lib/components/LocaleProvider/{locale/runtime.js → runtime.js} +0 -0
- package/lib/components/LocaleProvider/useLocale.js +1 -1
- package/lib/components/Message/Message.js +17 -24
- package/lib/components/Message/method.js +22 -4
- package/lib/components/Modal/Modal.js +12 -4
- package/lib/components/Modal/method.js +131 -57
- package/lib/components/Notice/Notice.js +15 -20
- package/lib/components/NumberInput/style/index.js +5 -5
- package/lib/components/Select/Select.js +7 -19
- package/lib/components/Table/Table.js +1 -6
- package/lib/components/TimePicker/TimePicker.js +2 -2
- package/lib/components/TimePicker/style/index.d.ts +3 -0
- package/lib/components/TimePicker/style/index.js +29 -7
- package/lib/components/Transfer/Transfer.js +4 -3
- package/lib/components/Transfer/locale/en_US.js +3 -1
- package/lib/components/Transfer/locale/zh_CN.js +3 -1
- package/lib/components/Upload/Upload.js +3 -2
- package/lib/hooks/useSearch.d.ts +23 -0
- package/lib/hooks/useSearch.js +387 -0
- package/lib/index.js +5 -1
- package/lib/sharedComponents/Search/Highlight.d.ts +4 -2
- package/lib/sharedComponents/Search/Highlight.js +1 -24
- package/lib/sharedComponents/Search/Search.d.ts +3 -3
- package/lib/sharedComponents/Search/Search.js +6 -21
- package/lib/sharedComponents/Search/SearchInput.d.ts +4 -0
- package/lib/sharedComponents/Search/SearchInput.js +51 -0
- package/lib/sharedComponents/Search/index.d.ts +2 -1
- package/lib/sharedComponents/Search/index.js +8 -0
- package/lib/sharedComponents/Search/style.d.ts +3 -0
- package/lib/sharedComponents/Search/style.js +15 -4
- package/lib/sharedComponents/VirtualScrollList.d.ts +7 -0
- package/lib/sharedComponents/VirtualScrollList.js +68 -0
- package/lib/utils/attrs.d.ts +5 -0
- package/lib/utils/attrs.js +39 -0
- package/lib/utils/deprecatedLog.d.ts +1 -1
- package/lib/utils/deprecatedLog.js +8 -1
- package/lib/utils/wait.d.ts +2 -0
- package/lib/utils/wait.js +23 -0
- package/lib/utils/warning.d.ts +4 -2
- package/lib/utils/warning.js +19 -4
- package/package.json +1 -1
- package/lib/sharedComponents/Search/useSearch.d.ts +0 -10
- package/lib/sharedComponents/Search/useSearch.js +0 -122
package/index.d.ts
CHANGED
|
@@ -6,6 +6,48 @@ type Override<T1, T2> = Omit<T1, keyof T2> & T2;
|
|
|
6
6
|
// base type
|
|
7
7
|
export type SizeType = 'sm' | 'md' | 'lg';
|
|
8
8
|
|
|
9
|
+
// ThemeProvider
|
|
10
|
+
interface ThemeProviderProps {
|
|
11
|
+
theme: any;
|
|
12
|
+
}
|
|
13
|
+
export declare class ThemeProvider extends Component<ThemeProviderProps> {}
|
|
14
|
+
|
|
15
|
+
export { default as Tree } from './lib/components/Tree';
|
|
16
|
+
|
|
17
|
+
export { default as Cascader } from './lib/components/Cascader';
|
|
18
|
+
|
|
19
|
+
export { default as Link } from './lib/components/Link';
|
|
20
|
+
|
|
21
|
+
export { default as AutoComplete } from './lib/components/AutoComplete';
|
|
22
|
+
|
|
23
|
+
export { default as Switch } from './lib/components/Switch';
|
|
24
|
+
|
|
25
|
+
export { default as Tabs } from './lib/components/Tabs';
|
|
26
|
+
|
|
27
|
+
export { default as Input } from './lib/components/Input';
|
|
28
|
+
import Input from './lib/components/Input';
|
|
29
|
+
|
|
30
|
+
export { default as Checkbox } from './lib/components/Checkbox';
|
|
31
|
+
|
|
32
|
+
export { default as Menu } from './lib/components/Menu';
|
|
33
|
+
|
|
34
|
+
export { default as Collapse } from './lib/components/Collapse';
|
|
35
|
+
|
|
36
|
+
export { default as ActionList } from './lib/components/ActionList';
|
|
37
|
+
import ActionList from './lib/components/ActionList';
|
|
38
|
+
|
|
39
|
+
export { default as Tooltip } from './lib/components/Tooltip';
|
|
40
|
+
|
|
41
|
+
export { default as PopConfirm } from './lib/components/PopConfirm';
|
|
42
|
+
|
|
43
|
+
export { default as ConfigProvider } from './lib/components/ConfigProvider';
|
|
44
|
+
|
|
45
|
+
export { default as Icon } from './lib/components/Icon';
|
|
46
|
+
|
|
47
|
+
export { default as Select } from './lib/components/Select';
|
|
48
|
+
|
|
49
|
+
export { default as Breadcrumb } from './lib/components/Breadcrumb';
|
|
50
|
+
|
|
9
51
|
// Button
|
|
10
52
|
import { ButtonProps } from './lib/components/Button/Button';
|
|
11
53
|
export { default as Button } from './lib/components/Button';
|
|
@@ -266,10 +308,11 @@ export declare class ZForm extends Component<ZFormProps> {
|
|
|
266
308
|
}
|
|
267
309
|
|
|
268
310
|
// Transfer
|
|
311
|
+
type TransferSearch = (searchValue: string, item: any) => boolean;
|
|
269
312
|
interface TransferSource {
|
|
270
313
|
title?: ReactNode;
|
|
271
314
|
footer?: ReactNode;
|
|
272
|
-
search?: boolean |
|
|
315
|
+
search?: boolean | TransferSearch;
|
|
273
316
|
disabled?: boolean;
|
|
274
317
|
}
|
|
275
318
|
export type TransferProps = Override<
|
|
@@ -281,7 +324,7 @@ export type TransferProps = Override<
|
|
|
281
324
|
defaultSelectedKeys?: string[];
|
|
282
325
|
onChange?: (keys: string[]) => void;
|
|
283
326
|
disabled?: boolean;
|
|
284
|
-
search?: boolean |
|
|
327
|
+
search?: boolean | TransferSearch;
|
|
285
328
|
source?: TransferSource;
|
|
286
329
|
target?: TransferSource;
|
|
287
330
|
}
|
|
@@ -593,7 +636,7 @@ interface TableExpandedRowContentProps extends HTMLAttributes<HTMLDivElement> {}
|
|
|
593
636
|
declare class TableExpandedRowContent extends Component<TableExpandedRowContentProps> {}
|
|
594
637
|
export declare class Table extends Component<TableProps> {
|
|
595
638
|
static ColumnConfigButton: typeof TableColumnConfigButton;
|
|
596
|
-
static SearchInput: typeof
|
|
639
|
+
static SearchInput: typeof Input['Search'];
|
|
597
640
|
static ActionList: typeof ActionList;
|
|
598
641
|
static ExpandedRowContent: typeof TableExpandedRowContent;
|
|
599
642
|
static getColumnConfigFromLocalStorage: typeof Function;
|
|
@@ -768,41 +811,3 @@ interface LocaleProviderProps {
|
|
|
768
811
|
locale?: any;
|
|
769
812
|
}
|
|
770
813
|
export declare class LocaleProvider extends Component<LocaleProviderProps> {}
|
|
771
|
-
|
|
772
|
-
// ThemeProvider
|
|
773
|
-
interface ThemeProviderProps {
|
|
774
|
-
theme: any;
|
|
775
|
-
}
|
|
776
|
-
export declare class ThemeProvider extends Component<ThemeProviderProps> {}
|
|
777
|
-
|
|
778
|
-
export { default as Tree } from './lib/components/Tree';
|
|
779
|
-
|
|
780
|
-
export { default as Link } from './lib/components/Link';
|
|
781
|
-
|
|
782
|
-
export { default as AutoComplete } from './lib/components/AutoComplete';
|
|
783
|
-
|
|
784
|
-
export { default as Switch } from './lib/components/Switch';
|
|
785
|
-
|
|
786
|
-
export { default as Tabs } from './lib/components/Tabs';
|
|
787
|
-
|
|
788
|
-
export { default as Input } from './lib/components/Input';
|
|
789
|
-
|
|
790
|
-
export { default as Checkbox } from './lib/components/Checkbox';
|
|
791
|
-
|
|
792
|
-
export { default as Menu } from './lib/components/Menu';
|
|
793
|
-
|
|
794
|
-
export { default as Collapse } from './lib/components/Collapse';
|
|
795
|
-
|
|
796
|
-
export { default as ActionList } from './lib/components/ActionList';
|
|
797
|
-
|
|
798
|
-
export { default as Tooltip } from './lib/components/Tooltip';
|
|
799
|
-
|
|
800
|
-
export { default as PopConfirm } from './lib/components/PopConfirm';
|
|
801
|
-
|
|
802
|
-
export { default as ConfigProvider } from './lib/components/ConfigProvider';
|
|
803
|
-
|
|
804
|
-
export { default as Icon } from './lib/components/Icon';
|
|
805
|
-
|
|
806
|
-
export { default as Select } from './lib/components/Select';
|
|
807
|
-
|
|
808
|
-
export { default as Breadcrumb } from './lib/components/Breadcrumb';
|
package/lib/__index.js
CHANGED
|
@@ -31,6 +31,10 @@ import * as CardAll from './components/Card/';
|
|
|
31
31
|
const Card = Object.assign(CardAll.default, CardAll);
|
|
32
32
|
export { Card };
|
|
33
33
|
|
|
34
|
+
import * as CascaderAll from './components/Cascader/';
|
|
35
|
+
const Cascader = Object.assign(CascaderAll.default, CascaderAll);
|
|
36
|
+
export { Cascader };
|
|
37
|
+
|
|
34
38
|
import * as CheckboxAll from './components/Checkbox/';
|
|
35
39
|
const Checkbox = Object.assign(CheckboxAll.default, CheckboxAll);
|
|
36
40
|
export { Checkbox };
|
|
@@ -159,7 +159,7 @@ AutoComplete.propTypes = {
|
|
|
159
159
|
options: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
160
160
|
value: _propTypes.default.string.isRequired,
|
|
161
161
|
label: _propTypes.default.node
|
|
162
|
-
}))
|
|
162
|
+
})),
|
|
163
163
|
value: _propTypes.default.string,
|
|
164
164
|
defaultValue: _propTypes.default.string,
|
|
165
165
|
onChange: _propTypes.default.func,
|
|
@@ -3,7 +3,7 @@ import { Moment } from 'moment';
|
|
|
3
3
|
import { TDate } from '@z-r/calendar/types/interface';
|
|
4
4
|
import { Rules } from './utils';
|
|
5
5
|
import LOCALE from './locale/zh_CN';
|
|
6
|
-
interface CalendarProps {
|
|
6
|
+
export interface CalendarProps {
|
|
7
7
|
/** 当前值,受控 */
|
|
8
8
|
value?: TDate | null;
|
|
9
9
|
/** 默认值,非受控 */
|
|
@@ -23,8 +23,10 @@ interface CalendarProps {
|
|
|
23
23
|
*/
|
|
24
24
|
boxShadow?: boolean;
|
|
25
25
|
};
|
|
26
|
+
/** 类型 */
|
|
27
|
+
type?: 'date' | 'month';
|
|
26
28
|
/** @ignore */
|
|
27
29
|
locale?: typeof LOCALE;
|
|
28
30
|
}
|
|
29
|
-
declare const _default: React.MemoExoticComponent<({
|
|
31
|
+
declare const _default: React.MemoExoticComponent<({ type, ...props }: CalendarProps) => JSX.Element>;
|
|
30
32
|
export default _default;
|
|
@@ -11,10 +11,10 @@ exports.default = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
14
|
var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck"));
|
|
17
15
|
|
|
16
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
|
+
|
|
18
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -29,43 +29,45 @@ var _HeaderSwitcher = _interopRequireDefault(require("./HeaderSwitcher"));
|
|
|
29
29
|
|
|
30
30
|
var _zh_CN = _interopRequireDefault(require("./locale/zh_CN"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _Month = _interopRequireDefault(require("./Month"));
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _this2 = void 0;
|
|
35
|
+
|
|
36
|
+
var _excluded = ["onSelect", "onChange", "rules", "locale"],
|
|
37
|
+
_excluded2 = ["type"];
|
|
35
38
|
|
|
36
39
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
40
|
|
|
38
41
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
42
|
|
|
40
|
-
var
|
|
41
|
-
var
|
|
43
|
+
var DateCalendar = /*#__PURE__*/_react.default.memo(function DateCalendar(_ref) {
|
|
44
|
+
var _this = this;
|
|
42
45
|
|
|
43
|
-
(0, _newArrowCheck2.default)(this, _this);
|
|
44
46
|
var onSelect = _ref.onSelect,
|
|
45
47
|
onChange = _ref.onChange,
|
|
46
48
|
rules = _ref.rules,
|
|
47
49
|
_locale = _ref.locale,
|
|
48
50
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
49
51
|
var disabledRule = (0, _react.useMemo)(function () {
|
|
50
|
-
(0, _newArrowCheck2.default)(this,
|
|
52
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
51
53
|
return (0, _utils.getDisabledRule)(rules);
|
|
52
54
|
}.bind(this), [rules]);
|
|
53
55
|
var handleChange = (0, _react.useCallback)(function (v) {
|
|
54
|
-
(0, _newArrowCheck2.default)(this,
|
|
56
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
55
57
|
v = (0, _utils.getValidDate)(v, rules);
|
|
56
58
|
onChange && onChange(v);
|
|
57
59
|
onSelect && onSelect(v);
|
|
58
60
|
}.bind(this), [onChange, onSelect, rules]);
|
|
59
61
|
var locale = (0, _useLocale.default)(_zh_CN.default, 'Calendar', _locale);
|
|
60
62
|
var calendarLocale = (0, _react.useMemo)(function () {
|
|
61
|
-
(0, _newArrowCheck2.default)(this,
|
|
63
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
62
64
|
return {
|
|
63
65
|
months: locale.months,
|
|
64
66
|
weekdays: locale.weekdays
|
|
65
67
|
};
|
|
66
68
|
}.bind(this), [locale.months, locale.weekdays]);
|
|
67
69
|
var renderHeaderSwitcher = (0, _react.useCallback)(function (props) {
|
|
68
|
-
(0, _newArrowCheck2.default)(this,
|
|
70
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
69
71
|
return /*#__PURE__*/_react.default.createElement(_HeaderSwitcher.default, (0, _extends2.default)({}, props, {
|
|
70
72
|
locale: locale
|
|
71
73
|
}));
|
|
@@ -79,6 +81,13 @@ var Calendar = function Calendar(_ref) {
|
|
|
79
81
|
HeaderSwitcher: renderHeaderSwitcher
|
|
80
82
|
}
|
|
81
83
|
}, rest));
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
var Calendar = function Calendar(_ref2) {
|
|
87
|
+
(0, _newArrowCheck2.default)(this, _this2);
|
|
88
|
+
var type = _ref2.type,
|
|
89
|
+
props = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
|
90
|
+
return type === 'month' ? /*#__PURE__*/_react.default.createElement(_Month.default, props) : /*#__PURE__*/_react.default.createElement(DateCalendar, props);
|
|
82
91
|
}.bind(void 0);
|
|
83
92
|
|
|
84
93
|
Calendar.propTypes = {
|
|
@@ -87,6 +96,7 @@ Calendar.propTypes = {
|
|
|
87
96
|
customStyle: _propTypes.default.shape({
|
|
88
97
|
boxShadow: _propTypes.default.bool
|
|
89
98
|
}),
|
|
99
|
+
type: _propTypes.default.oneOf(['date', 'month']),
|
|
90
100
|
locale: _propTypes.default.any
|
|
91
101
|
};
|
|
92
102
|
|
|
@@ -1,30 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import LOCALE from './locale/zh_CN';
|
|
6
|
-
interface MonthProps {
|
|
7
|
-
/** 当前值,受控 */
|
|
8
|
-
value?: TDate | null;
|
|
9
|
-
/** 默认值,非受控 */
|
|
10
|
-
defaultValue?: TDate | null;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated 使用 onChange 来替换
|
|
13
|
-
*/
|
|
14
|
-
onSelect?: (t: Moment) => void;
|
|
15
|
-
/** 选中变化回调 */
|
|
16
|
-
onChange?: (t: Moment) => void;
|
|
17
|
-
/** 自定义规则 */
|
|
18
|
-
rules?: Rules;
|
|
19
|
-
/** 自定义样式 */
|
|
20
|
-
customStyle?: {
|
|
21
|
-
/**
|
|
22
|
-
* 外层阴影,为 false 时隐藏
|
|
23
|
-
*/
|
|
24
|
-
boxShadow?: boolean;
|
|
25
|
-
};
|
|
26
|
-
/** @ignore */
|
|
27
|
-
locale?: typeof LOCALE;
|
|
28
|
-
}
|
|
29
|
-
declare const _default: React.MemoExoticComponent<({ onSelect, onChange, rules, locale: _locale, ...rest }: MonthProps & Omit<React.HTMLAttributes<HTMLDivElement>, keyof MonthProps>) => JSX.Element>;
|
|
2
|
+
import { Override } from '../../type';
|
|
3
|
+
import { CalendarProps } from './Calendar';
|
|
4
|
+
declare const _default: React.MemoExoticComponent<({ onSelect, onChange, rules, locale: _locale, ...rest }: Override<React.HTMLAttributes<HTMLDivElement>, CalendarProps>) => JSX.Element>;
|
|
30
5
|
export default _default;
|
|
@@ -15,8 +15,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
15
15
|
|
|
16
16
|
var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck"));
|
|
17
17
|
|
|
18
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
-
|
|
20
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
19
|
|
|
22
20
|
var _useLocale = _interopRequireDefault(require("../../components/LocaleProvider/useLocale"));
|
|
@@ -37,6 +35,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
37
35
|
|
|
38
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated 请使用 ```<Calendar type='month' />``` 替换
|
|
40
|
+
*/
|
|
40
41
|
var Month = function Month(_ref) {
|
|
41
42
|
var _this2 = this;
|
|
42
43
|
|
|
@@ -81,15 +82,6 @@ var Month = function Month(_ref) {
|
|
|
81
82
|
}, rest));
|
|
82
83
|
}.bind(void 0);
|
|
83
84
|
|
|
84
|
-
Month.propTypes = {
|
|
85
|
-
onSelect: _propTypes.default.func,
|
|
86
|
-
onChange: _propTypes.default.func,
|
|
87
|
-
customStyle: _propTypes.default.shape({
|
|
88
|
-
boxShadow: _propTypes.default.bool
|
|
89
|
-
}),
|
|
90
|
-
locale: _propTypes.default.any
|
|
91
|
-
};
|
|
92
|
-
|
|
93
85
|
var _default = /*#__PURE__*/(0, _react.memo)(Month);
|
|
94
86
|
|
|
95
87
|
exports.default = _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
import { CascadeData, Key, LoadData } from './interface';
|
|
4
|
+
declare const Wrapper: ({ onChange, onExpand, children }: {
|
|
5
|
+
onChange?: ((value: Key[]) => void) | undefined;
|
|
6
|
+
onExpand?: ((expandedValue: Key[]) => void) | undefined;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}) => JSX.Element;
|
|
9
|
+
declare type SharedProps = Pick<ArgsType<typeof Wrapper>[0], 'onChange' | 'onExpand'>;
|
|
10
|
+
declare const CascadeSearchResult: React.NamedExoticComponent<{
|
|
11
|
+
dataSource?: CascadeData[] | undefined;
|
|
12
|
+
value?: string[] | undefined;
|
|
13
|
+
loading?: boolean | undefined;
|
|
14
|
+
empty?: boolean | undefined;
|
|
15
|
+
error?: Error | undefined;
|
|
16
|
+
} & SharedProps>;
|
|
17
|
+
declare const _default: React.MemoExoticComponent<({ dataSource, value, onChange, expandedValue, onExpand, loadData }: {
|
|
18
|
+
dataSource?: CascadeData[] | undefined;
|
|
19
|
+
value?: string[] | undefined;
|
|
20
|
+
expandedValue: string[];
|
|
21
|
+
loadData?: LoadData | undefined;
|
|
22
|
+
} & SharedProps) => JSX.Element>;
|
|
23
|
+
export default _default;
|
|
24
|
+
export { CascadeSearchResult };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.CascadeSearchResult = exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
14
|
+
var _newArrowCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/newArrowCheck"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _useLocale = _interopRequireDefault(require("../../components/LocaleProvider/useLocale"));
|
|
19
|
+
|
|
20
|
+
var _Loading = _interopRequireDefault(require("../../components/Loading"));
|
|
21
|
+
|
|
22
|
+
var _Notice = _interopRequireDefault(require("../../components/Notice"));
|
|
23
|
+
|
|
24
|
+
var _VirtualScrollList = _interopRequireDefault(require("../../sharedComponents/VirtualScrollList"));
|
|
25
|
+
|
|
26
|
+
var _cascade = require("./style/cascade");
|
|
27
|
+
|
|
28
|
+
var _Items = _interopRequireDefault(require("./Items"));
|
|
29
|
+
|
|
30
|
+
var _Item = _interopRequireDefault(require("./Item"));
|
|
31
|
+
|
|
32
|
+
var _CascadeContext = _interopRequireDefault(require("./CascadeContext"));
|
|
33
|
+
|
|
34
|
+
var _zh_CN = _interopRequireDefault(require("./locale/zh_CN"));
|
|
35
|
+
|
|
36
|
+
var _this = void 0;
|
|
37
|
+
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
|
|
42
|
+
var getExpandedItems = function getExpandedItems(dataSource, expandedValue) {
|
|
43
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
44
|
+
if (!dataSource) return [];
|
|
45
|
+
var tmpItems = dataSource;
|
|
46
|
+
var tmpParents = [];
|
|
47
|
+
var expandedItems = [{
|
|
48
|
+
items: dataSource,
|
|
49
|
+
parents: [].concat(tmpParents)
|
|
50
|
+
}];
|
|
51
|
+
if (!(expandedValue !== null && expandedValue !== void 0 && expandedValue.length)) return expandedItems;
|
|
52
|
+
|
|
53
|
+
var _loop = function _loop(i) {
|
|
54
|
+
var _this2 = this;
|
|
55
|
+
|
|
56
|
+
var expandedKey = expandedValue[i];
|
|
57
|
+
|
|
58
|
+
if (!tmpItems) {
|
|
59
|
+
console.error("ExpandedValue: ".concat(expandedValue, " is invalid."));
|
|
60
|
+
return "break";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var item = tmpItems.find(function (item) {
|
|
64
|
+
(0, _newArrowCheck2.default)(this, _this2);
|
|
65
|
+
return item.key === expandedKey;
|
|
66
|
+
}.bind(this));
|
|
67
|
+
|
|
68
|
+
if (!item) {
|
|
69
|
+
console.error("ExpandedValue: ".concat(expandedValue, " is invalid."));
|
|
70
|
+
return "break";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
tmpItems = item.children;
|
|
74
|
+
tmpParents.push(item);
|
|
75
|
+
expandedItems.push({
|
|
76
|
+
items: item.children,
|
|
77
|
+
parents: [].concat(tmpParents)
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
for (var i = 0; i < expandedValue.length; i++) {
|
|
82
|
+
var _ret = _loop(i);
|
|
83
|
+
|
|
84
|
+
if (_ret === "break") break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return expandedItems;
|
|
88
|
+
}.bind(void 0);
|
|
89
|
+
|
|
90
|
+
var flat = function flat() {
|
|
91
|
+
var _this3 = this;
|
|
92
|
+
|
|
93
|
+
var dataSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
94
|
+
var value = arguments.length > 1 ? arguments[1] : undefined;
|
|
95
|
+
var result = [];
|
|
96
|
+
|
|
97
|
+
var isKeyEqual = function isKeyEqual(key, match) {
|
|
98
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
99
|
+
return key != null && key === match;
|
|
100
|
+
}.bind(this);
|
|
101
|
+
|
|
102
|
+
var _run = function run(group, parents, parentDisabled, parentSelected) {
|
|
103
|
+
var _this4 = this;
|
|
104
|
+
|
|
105
|
+
(0, _newArrowCheck2.default)(this, _this3);
|
|
106
|
+
group.forEach(function (item) {
|
|
107
|
+
(0, _newArrowCheck2.default)(this, _this4);
|
|
108
|
+
var children = item.children,
|
|
109
|
+
isParent = item.isParent,
|
|
110
|
+
key = item.key;
|
|
111
|
+
|
|
112
|
+
if (children) {
|
|
113
|
+
_run(children, [].concat((0, _toConsumableArray2.default)(parents), [item]), parentDisabled || !!item.disabled, parentSelected && isKeyEqual(key, value === null || value === void 0 ? void 0 : value[parents.length]));
|
|
114
|
+
} else if (isParent) {
|
|
115
|
+
return;
|
|
116
|
+
} else {
|
|
117
|
+
result.push({
|
|
118
|
+
item: item,
|
|
119
|
+
parents: parents,
|
|
120
|
+
parentDisabled: parentDisabled,
|
|
121
|
+
selected: parentSelected && isKeyEqual(key, value === null || value === void 0 ? void 0 : value[value.length - 1])
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}.bind(this));
|
|
125
|
+
}.bind(this);
|
|
126
|
+
|
|
127
|
+
_run(dataSource, [], false, true);
|
|
128
|
+
|
|
129
|
+
return result;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var Wrapper = function Wrapper(_ref) {
|
|
133
|
+
var _this5 = this;
|
|
134
|
+
|
|
135
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
136
|
+
var onChange = _ref.onChange,
|
|
137
|
+
onExpand = _ref.onExpand,
|
|
138
|
+
children = _ref.children;
|
|
139
|
+
var expandItem = (0, _react.useCallback)(function (expandedKeys) {
|
|
140
|
+
(0, _newArrowCheck2.default)(this, _this5);
|
|
141
|
+
onExpand === null || onExpand === void 0 ? void 0 : onExpand(expandedKeys);
|
|
142
|
+
}.bind(this), [onExpand]);
|
|
143
|
+
var selectItem = (0, _react.useCallback)(function (selectedKeys) {
|
|
144
|
+
(0, _newArrowCheck2.default)(this, _this5);
|
|
145
|
+
var parentKeys = selectedKeys.slice(0, selectedKeys.length - 1);
|
|
146
|
+
onExpand === null || onExpand === void 0 ? void 0 : onExpand(parentKeys);
|
|
147
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(selectedKeys);
|
|
148
|
+
}.bind(this), [onChange, onExpand]);
|
|
149
|
+
return /*#__PURE__*/_react.default.createElement(_CascadeContext.default.Provider, {
|
|
150
|
+
value: {
|
|
151
|
+
expandItem: expandItem,
|
|
152
|
+
selectItem: selectItem
|
|
153
|
+
}
|
|
154
|
+
}, /*#__PURE__*/_react.default.createElement(_cascade.SCascade, null, children));
|
|
155
|
+
}.bind(void 0);
|
|
156
|
+
|
|
157
|
+
var Cascade = function Cascade(_ref2) {
|
|
158
|
+
var _this6 = this;
|
|
159
|
+
|
|
160
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
161
|
+
var dataSource = _ref2.dataSource,
|
|
162
|
+
value = _ref2.value,
|
|
163
|
+
onChange = _ref2.onChange,
|
|
164
|
+
expandedValue = _ref2.expandedValue,
|
|
165
|
+
onExpand = _ref2.onExpand,
|
|
166
|
+
loadData = _ref2.loadData;
|
|
167
|
+
var locale = (0, _useLocale.default)(_zh_CN.default, 'Cascader');
|
|
168
|
+
var expandedItems = (0, _react.useMemo)(function () {
|
|
169
|
+
(0, _newArrowCheck2.default)(this, _this6);
|
|
170
|
+
return getExpandedItems(dataSource, expandedValue);
|
|
171
|
+
}.bind(this), [dataSource, expandedValue]);
|
|
172
|
+
|
|
173
|
+
if (!(dataSource !== null && dataSource !== void 0 && dataSource.length)) {
|
|
174
|
+
return /*#__PURE__*/_react.default.createElement(_cascade.SCascade, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
175
|
+
className: _cascade.emptyCls
|
|
176
|
+
}, locale.emptyTip));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
180
|
+
onChange: onChange,
|
|
181
|
+
onExpand: onExpand
|
|
182
|
+
}, expandedItems.map(function (_ref3, index) {
|
|
183
|
+
var _this7 = this;
|
|
184
|
+
|
|
185
|
+
(0, _newArrowCheck2.default)(this, _this6);
|
|
186
|
+
var items = _ref3.items,
|
|
187
|
+
parents = _ref3.parents;
|
|
188
|
+
return [index > 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
+
className: _cascade.dividerCls,
|
|
190
|
+
key: "divider-".concat(index)
|
|
191
|
+
}) : null, /*#__PURE__*/_react.default.createElement(_Items.default, {
|
|
192
|
+
key: index == 0 ? '__root-items__' : expandedValue === null || expandedValue === void 0 ? void 0 : expandedValue[index - 1],
|
|
193
|
+
items: items,
|
|
194
|
+
selectedKey: value === null || value === void 0 ? void 0 : value[index],
|
|
195
|
+
expandedKey: expandedValue === null || expandedValue === void 0 ? void 0 : expandedValue[index],
|
|
196
|
+
parents: parents,
|
|
197
|
+
disabled: parents.some(function (parent) {
|
|
198
|
+
(0, _newArrowCheck2.default)(this, _this7);
|
|
199
|
+
return parent.disabled;
|
|
200
|
+
}.bind(this)),
|
|
201
|
+
loadData: loadData
|
|
202
|
+
})];
|
|
203
|
+
}.bind(this)));
|
|
204
|
+
}.bind(void 0);
|
|
205
|
+
|
|
206
|
+
var KeyFragment = function KeyFragment(_ref4) {
|
|
207
|
+
(0, _newArrowCheck2.default)(this, _this);
|
|
208
|
+
var children = _ref4.children;
|
|
209
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
210
|
+
}.bind(void 0);
|
|
211
|
+
|
|
212
|
+
var CascadeSearchResult = /*#__PURE__*/_react.default.memo(function CascadeSearchResult(_ref5) {
|
|
213
|
+
var _this8 = this;
|
|
214
|
+
|
|
215
|
+
var dataSource = _ref5.dataSource,
|
|
216
|
+
value = _ref5.value,
|
|
217
|
+
loading = _ref5.loading,
|
|
218
|
+
empty = _ref5.empty,
|
|
219
|
+
error = _ref5.error,
|
|
220
|
+
onChange = _ref5.onChange,
|
|
221
|
+
onExpand = _ref5.onExpand;
|
|
222
|
+
var items = (0, _react.useMemo)(function () {
|
|
223
|
+
(0, _newArrowCheck2.default)(this, _this8);
|
|
224
|
+
return flat(dataSource, value);
|
|
225
|
+
}.bind(this), [dataSource, value]);
|
|
226
|
+
var locale = (0, _useLocale.default)(_zh_CN.default, 'Cascader');
|
|
227
|
+
var renderItems = (0, _react.useMemo)(function () {
|
|
228
|
+
var _this9 = this;
|
|
229
|
+
|
|
230
|
+
(0, _newArrowCheck2.default)(this, _this8);
|
|
231
|
+
return items.map(function (_ref6) {
|
|
232
|
+
var _this10 = this;
|
|
233
|
+
|
|
234
|
+
(0, _newArrowCheck2.default)(this, _this9);
|
|
235
|
+
var item = _ref6.item,
|
|
236
|
+
parents = _ref6.parents,
|
|
237
|
+
parentDisabled = _ref6.parentDisabled,
|
|
238
|
+
selected = _ref6.selected;
|
|
239
|
+
var value = item.key,
|
|
240
|
+
itemDisabled = item.disabled;
|
|
241
|
+
var finalDisabled = parentDisabled || itemDisabled;
|
|
242
|
+
var finalTitle = [].concat((0, _toConsumableArray2.default)(parents), [item]).map(function (item, index) {
|
|
243
|
+
(0, _newArrowCheck2.default)(this, _this10);
|
|
244
|
+
return [index === 0 ? null : '/', /*#__PURE__*/_react.default.createElement(KeyFragment, {
|
|
245
|
+
key: index
|
|
246
|
+
}, item.title)];
|
|
247
|
+
}.bind(this));
|
|
248
|
+
return /*#__PURE__*/_react.default.createElement(_Item.default, {
|
|
249
|
+
key: value,
|
|
250
|
+
value: value,
|
|
251
|
+
title: finalTitle,
|
|
252
|
+
selected: selected,
|
|
253
|
+
disabled: finalDisabled,
|
|
254
|
+
parents: parents
|
|
255
|
+
});
|
|
256
|
+
}.bind(this));
|
|
257
|
+
}.bind(this), [items]);
|
|
258
|
+
return /*#__PURE__*/_react.default.createElement(_Loading.default, {
|
|
259
|
+
loading: loading
|
|
260
|
+
}, /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
261
|
+
onChange: onChange,
|
|
262
|
+
onExpand: onExpand
|
|
263
|
+
}, error ? /*#__PURE__*/_react.default.createElement("div", {
|
|
264
|
+
className: _cascade.errorCls
|
|
265
|
+
}, /*#__PURE__*/_react.default.createElement(_Notice.default, {
|
|
266
|
+
styleType: "error",
|
|
267
|
+
closable: false
|
|
268
|
+
}, error.message)) : empty ? /*#__PURE__*/_react.default.createElement("div", {
|
|
269
|
+
className: _cascade.emptyCls
|
|
270
|
+
}, locale.emptyTip) : /*#__PURE__*/_react.default.createElement(_VirtualScrollList.default, {
|
|
271
|
+
height: 180,
|
|
272
|
+
className: _cascade.itemsCls
|
|
273
|
+
}, renderItems)));
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
exports.CascadeSearchResult = CascadeSearchResult;
|
|
277
|
+
|
|
278
|
+
var _default = /*#__PURE__*/_react.default.memo(Cascade);
|
|
279
|
+
|
|
280
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _noop = _interopRequireDefault(require("../../utils/noop"));
|
|
13
|
+
|
|
14
|
+
var CascadeContext = /*#__PURE__*/_react.default.createContext({
|
|
15
|
+
expandItem: _noop.default,
|
|
16
|
+
selectItem: _noop.default
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _default = CascadeContext;
|
|
20
|
+
exports.default = _default;
|