@apdesign/web-react 1.4.2 → 1.5.0
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/arco-icon.min.js +1 -1
- package/dist/arco.development.js +8 -8
- package/dist/arco.min.js +3 -3
- package/es/Button/index.d.ts +3 -3
- package/es/Select/select.js +39 -8
- package/es/TreeSelect/hook/useStateValue.d.ts +1 -0
- package/es/TreeSelect/hook/useStateValue.js +1 -1
- package/es/TreeSelect/tree-list.js +3 -2
- package/es/TreeSelect/tree-select.js +33 -9
- package/es/Typography/base.d.ts +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/locale/en-US.d.ts +1 -0
- package/es/locale/en-US.js +1 -0
- package/es/locale/zh-CN.d.ts +1 -0
- package/es/locale/zh-CN.js +1 -0
- package/lib/Select/select.js +38 -7
- package/lib/TreeSelect/hook/useStateValue.d.ts +1 -0
- package/lib/TreeSelect/hook/useStateValue.js +3 -2
- package/lib/TreeSelect/tree-list.js +3 -2
- package/lib/TreeSelect/tree-select.js +31 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/locale/en-US.d.ts +1 -0
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/zh-CN.d.ts +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/package.json +1 -1
package/es/Button/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import Group from './group';
|
|
3
3
|
import { ButtonProps } from './interface';
|
|
4
4
|
declare const ButtonComponent: React.ForwardRefExoticComponent<Partial<{
|
|
5
|
-
htmlType?: "button" | "
|
|
6
|
-
} & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "
|
|
5
|
+
htmlType?: "button" | "reset" | "submit";
|
|
6
|
+
} & import("./interface").BaseButtonProps & Omit<React.ButtonHTMLAttributes<any>, "className" | "onClick" | "type"> & {
|
|
7
7
|
href: string;
|
|
8
8
|
target?: string;
|
|
9
9
|
anchorProps?: React.HTMLProps<HTMLAnchorElement>;
|
|
10
|
-
} & Omit<React.AnchorHTMLAttributes<any>, "className" | "
|
|
10
|
+
} & Omit<React.AnchorHTMLAttributes<any>, "className" | "onClick" | "type">> & React.RefAttributes<unknown>> & {
|
|
11
11
|
__BYTE_BUTTON: boolean;
|
|
12
12
|
Group: typeof Group;
|
|
13
13
|
};
|
package/es/Select/select.js
CHANGED
|
@@ -46,6 +46,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
46
46
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
47
47
|
};
|
|
48
48
|
import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, } from 'react';
|
|
49
|
+
import isEqualWith from 'lodash/isEqualWith';
|
|
49
50
|
import cs from '../_util/classNames';
|
|
50
51
|
import { ArrowUp, ArrowDown, Enter, Esc, Tab } from '../_util/keycode';
|
|
51
52
|
import Trigger from '../Trigger';
|
|
@@ -62,7 +63,7 @@ import { ConfigContext } from '../ConfigProvider';
|
|
|
62
63
|
import useMergeValue from '../_util/hooks/useMergeValue';
|
|
63
64
|
import omit from '../_util/omit';
|
|
64
65
|
import useMergeProps from '../_util/hooks/useMergeProps';
|
|
65
|
-
import { Button } from '../index';
|
|
66
|
+
import { Button, Checkbox } from '../index';
|
|
66
67
|
import useId from '../_util/hooks/useId';
|
|
67
68
|
// 用户创建中的option的origin标识
|
|
68
69
|
var USER_CREATING_OPTION_ORIGIN = 'userCreatingOption';
|
|
@@ -212,7 +213,6 @@ function Select(baseProps, ref) {
|
|
|
212
213
|
}
|
|
213
214
|
else if (Array.isArray(value)) {
|
|
214
215
|
setValue(value.length === 0 ? undefined : value[0]);
|
|
215
|
-
setProxyValue(value.length === 0 ? undefined : value[0]);
|
|
216
216
|
}
|
|
217
217
|
}, [isMultipleMode, value]);
|
|
218
218
|
useEffect(function () {
|
|
@@ -457,7 +457,8 @@ function Select(baseProps, ref) {
|
|
|
457
457
|
if (isMultipleMode) {
|
|
458
458
|
checkOption(optionValue, value.indexOf(optionValue) === -1 ? 'add' : 'remove');
|
|
459
459
|
// 点击一个选项时,清空输入框内容
|
|
460
|
-
if (!
|
|
460
|
+
if (!isMultipleQuickSelectMode &&
|
|
461
|
+
(!isObject(showSearch) || !showSearch.retainInputValueWhileSelect)) {
|
|
461
462
|
tryUpdateInputValue('', 'optionChecked');
|
|
462
463
|
}
|
|
463
464
|
}
|
|
@@ -511,6 +512,35 @@ function Select(baseProps, ref) {
|
|
|
511
512
|
},
|
|
512
513
|
],
|
|
513
514
|
]));
|
|
515
|
+
// 全选
|
|
516
|
+
var checked = Array.isArray(stateProxyValue) &&
|
|
517
|
+
childrenList.length &&
|
|
518
|
+
childrenList.every(function (child) { return stateProxyValue.includes(child.props.value); });
|
|
519
|
+
var selectAllCheckBoxProps = isMultipleQuickSelectMode && Array.isArray(stateProxyValue)
|
|
520
|
+
? {
|
|
521
|
+
disabled: childrenList.length === 0,
|
|
522
|
+
checked: checked,
|
|
523
|
+
indeterminate: !checked &&
|
|
524
|
+
childrenList.length &&
|
|
525
|
+
childrenList.some(function (child) { return stateProxyValue.includes(child.props.value); }),
|
|
526
|
+
onChange: function (value) {
|
|
527
|
+
if (value) {
|
|
528
|
+
setProxyValue(function (prev) { return __spreadArray(__spreadArray([], __read(prev.filter(function (i) {
|
|
529
|
+
return !childrenList.some(function (child) { return isEqualWith(i, child.props.value); });
|
|
530
|
+
})), false), __read(childrenList.map(function (child) { return child.props.value; })), false); });
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
setProxyValue(function (prev) {
|
|
534
|
+
return ((prev === null || prev === void 0 ? void 0 : prev.filter(function (v) {
|
|
535
|
+
return !childrenList.some(function (child) { return isEqualWith(v, child.props.value); });
|
|
536
|
+
})) || []);
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
}
|
|
541
|
+
: {
|
|
542
|
+
style: { display: 'none' },
|
|
543
|
+
};
|
|
514
544
|
var renderPopup = function () {
|
|
515
545
|
var _a;
|
|
516
546
|
var _b, _c, _d, _e;
|
|
@@ -561,13 +591,14 @@ function Select(baseProps, ref) {
|
|
|
561
591
|
}),
|
|
562
592
|
isMultipleQuickSelectMode && (React.createElement("div", { style: {
|
|
563
593
|
display: 'flex',
|
|
564
|
-
justifyContent: '
|
|
565
|
-
|
|
566
|
-
padding: '8px 16px 4px',
|
|
594
|
+
justifyContent: 'space-between',
|
|
595
|
+
padding: '8px 16px 4px 8px',
|
|
567
596
|
borderTop: '1px solid var(--color-fill-3)',
|
|
568
597
|
} },
|
|
569
|
-
React.createElement(
|
|
570
|
-
React.createElement(
|
|
598
|
+
React.createElement(Checkbox, __assign({}, selectAllCheckBoxProps), "\u5168\u9009"),
|
|
599
|
+
React.createElement("div", { style: { display: 'flex', gap: 12 } },
|
|
600
|
+
React.createElement(Button, { size: "mini", onClick: cancelCheck }, (_d = locale.Select) === null || _d === void 0 ? void 0 : _d.cancelText),
|
|
601
|
+
React.createElement(Button, { type: "primary", size: "mini", onClick: confirmCheck }, (_e = locale.Select) === null || _e === void 0 ? void 0 : _e.okText)))))) : null;
|
|
571
602
|
// Avoid drop-down box jitter when user is creating a selection
|
|
572
603
|
var isUserCreating = allowCreate && inputValue;
|
|
573
604
|
// Dropdown-placeholder when there is no options
|
|
@@ -11,6 +11,7 @@ export interface TreeSelectState {
|
|
|
11
11
|
searchKeys: string[];
|
|
12
12
|
}
|
|
13
13
|
export declare const parseValue: (v: valueType, key2nodeProps: any, valueMap?: LabelValue[]) => LabelValue[];
|
|
14
|
+
export declare const getInitCheckKeys: (keys: string[], key2nodeProps: KeyCacheType, indeterminateKeys: any, props: TreeSelectProps) => string[];
|
|
14
15
|
declare const useStateValue: (props: TreeSelectProps, key2nodeProps: KeyCacheType, indeterminateKeys: MutableRefObject<string[]>) => [LabelValue[], (v: LabelValue[], extra: {
|
|
15
16
|
trigger?: NodeProps;
|
|
16
17
|
checked?: boolean;
|
|
@@ -63,7 +63,7 @@ export var parseValue = function (v, key2nodeProps, valueMap) {
|
|
|
63
63
|
return result;
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
var getInitCheckKeys = function (keys, key2nodeProps, indeterminateKeys, props) {
|
|
66
|
+
export var getInitCheckKeys = function (keys, key2nodeProps, indeterminateKeys, props) {
|
|
67
67
|
if (!props.treeCheckStrictly) {
|
|
68
68
|
var _a = getCheckedKeysByInitKeys(keys, key2nodeProps), allCheckedKeys = _a.checkedKeys, halfKeys = _a.indeterminateKeys;
|
|
69
69
|
var checkedKeys_1 = allCheckedKeys;
|
|
@@ -159,8 +159,9 @@ function TreeList(props, ref) {
|
|
|
159
159
|
var checkedKeys;
|
|
160
160
|
var getAllCheckedKeys = function (node, keys) {
|
|
161
161
|
if (keys === void 0) { keys = []; }
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
var children = node.childrenData || node.children;
|
|
163
|
+
if (Array.isArray(children) && children.length) {
|
|
164
|
+
children.forEach(function (child) {
|
|
164
165
|
getAllCheckedKeys(child, keys);
|
|
165
166
|
});
|
|
166
167
|
}
|
|
@@ -72,13 +72,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
72
72
|
};
|
|
73
73
|
import React, { forwardRef, useContext, useEffect, useRef, useState, useImperativeHandle, useMemo, useCallback, } from 'react';
|
|
74
74
|
import debounce from 'lodash/debounce';
|
|
75
|
-
import useStateValue, { parseValue } from './hook/useStateValue';
|
|
75
|
+
import useStateValue, { getInitCheckKeys, parseValue } from './hook/useStateValue';
|
|
76
76
|
import { normalizeValueToArray } from './utils';
|
|
77
77
|
import { isArray, isFunction, isNullOrUndefined, isObject } from '../_util/is';
|
|
78
78
|
import Trigger from '../Trigger';
|
|
79
79
|
import Tree from '../Tree';
|
|
80
80
|
import { ConfigContext } from '../ConfigProvider';
|
|
81
|
-
import { getAllCheckedKeysByCheck } from '../Tree/util';
|
|
81
|
+
import { getAllCheckedKeysByCheck, getCheckedKeysByInitKeys } from '../Tree/util';
|
|
82
82
|
import SelectView from '../_class/select-view';
|
|
83
83
|
import { DefaultFieldNames, } from './interface';
|
|
84
84
|
import useTreeData from './hook/useTreeData';
|
|
@@ -90,6 +90,7 @@ import useMergeProps from '../_util/hooks/useMergeProps';
|
|
|
90
90
|
import useIsFirstRender from '../_util/hooks/useIsFirstRender';
|
|
91
91
|
import useId from '../_util/hooks/useId';
|
|
92
92
|
import Button from '../Button';
|
|
93
|
+
import Checkbox from '../Checkbox';
|
|
93
94
|
function isEmptyValue(value) {
|
|
94
95
|
return (!value ||
|
|
95
96
|
(isArray(value) && value.length === 0) ||
|
|
@@ -308,6 +309,30 @@ var TreeSelect = function (baseProps, ref) {
|
|
|
308
309
|
var tryUpdateSelectValue = function (value) {
|
|
309
310
|
setValue(value, {});
|
|
310
311
|
};
|
|
312
|
+
var getSelectAllCheckBoxProps = useCallback(function () {
|
|
313
|
+
if (!isMultipleQuickSelectMode || props.treeCheckStrictly) {
|
|
314
|
+
return {
|
|
315
|
+
style: { display: 'none' },
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
var allCheckedKeys = getCheckedKeysByInitKeys(normalizeValueToArray(value), key2nodeProps).checkedKeys;
|
|
319
|
+
var rootKeys = treeData.map(function (item) { return item.key; });
|
|
320
|
+
var checked = rootKeys.every(function (key) { return allCheckedKeys.includes(key); });
|
|
321
|
+
var indeterminate = !checked && value.length && rootKeys.some(function (key) { return !allCheckedKeys.includes(key); });
|
|
322
|
+
return {
|
|
323
|
+
disabled: treeData.length === 0,
|
|
324
|
+
checked: checked,
|
|
325
|
+
indeterminate: indeterminate,
|
|
326
|
+
onChange: function (val) {
|
|
327
|
+
if (val) {
|
|
328
|
+
setValue(getInitCheckKeys(normalizeValueToArray(rootKeys), key2nodeProps, indeterminateKeys, props).map(function (x) { return ({ label: x, value: x }); }), {});
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
setValue([], {});
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
}, [isMultipleQuickSelectMode, value, treeData]);
|
|
311
336
|
var renderView = function (eleView) {
|
|
312
337
|
return (React.createElement(Trigger, __assign({ autoAlignPopupWidth: false, autoAlignPopupMinWidth: true, ref: triggerRef, classNames: "slideDynamicOrigin", trigger: "click", position: "bl", getPopupContainer: props.getPopupContainer, popupAlign: triggerPopupAlign, unmountOnExit: props.unmountOnExit }, props.triggerProps, { className: cs(prefixCls + "-trigger", props.triggerProps && props.triggerProps.className), popup: function () {
|
|
313
338
|
var _a;
|
|
@@ -323,15 +348,14 @@ var TreeSelect = function (baseProps, ref) {
|
|
|
323
348
|
React.createElement("div", { style: {
|
|
324
349
|
flex: 'none',
|
|
325
350
|
display: 'flex',
|
|
326
|
-
justifyContent: '
|
|
327
|
-
|
|
328
|
-
padding: '8px 16px 4px',
|
|
351
|
+
justifyContent: 'space-between',
|
|
352
|
+
padding: '8px 16px 4px 8px',
|
|
329
353
|
borderTop: '1px solid var(--color-fill-3)',
|
|
330
354
|
} },
|
|
331
|
-
React.createElement(
|
|
332
|
-
React.createElement(
|
|
333
|
-
|
|
334
|
-
|
|
355
|
+
React.createElement(Checkbox, __assign({}, getSelectAllCheckBoxProps()), "\u5168\u9009"),
|
|
356
|
+
React.createElement("div", { style: { display: 'flex', gap: 12 } },
|
|
357
|
+
React.createElement(Button, { size: "mini", onClick: cancelCheck }, (_b = locale.Select) === null || _b === void 0 ? void 0 : _b.cancelText),
|
|
358
|
+
React.createElement(Button, { type: "primary", size: "mini", onClick: confirmCheck }, (_c = locale.Select) === null || _c === void 0 ? void 0 : _c.okText))))) : (treeListDom);
|
|
335
359
|
var wrapStyle = isMultipleQuickSelectMode
|
|
336
360
|
? {
|
|
337
361
|
overflow: 'hidden',
|
package/es/Typography/base.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TypographyParagraphProps, TypographyTitleProps } from './interface';
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<TypographyParagraphProps & TypographyTitleProps & import("./interface").CommonProps & {
|
|
4
|
-
componentType: "
|
|
4
|
+
componentType: "Text" | "Title" | "Paragraph";
|
|
5
5
|
} & React.RefAttributes<unknown>>;
|
|
6
6
|
export default _default;
|
package/es/index.d.ts
CHANGED
|
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
|
|
|
139
139
|
export { default as Watermark } from './Watermark';
|
|
140
140
|
export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
|
|
141
141
|
export { default as Image } from './Image';
|
|
142
|
-
export declare const version = "1.
|
|
142
|
+
export declare const version = "1.5.0";
|
package/es/index.js
CHANGED
package/es/locale/en-US.d.ts
CHANGED
package/es/locale/en-US.js
CHANGED
package/es/locale/zh-CN.d.ts
CHANGED
package/es/locale/zh-CN.js
CHANGED
package/lib/Select/select.js
CHANGED
|
@@ -70,6 +70,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
70
70
|
};
|
|
71
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
72
|
var react_1 = __importStar(require("react"));
|
|
73
|
+
var isEqualWith_1 = __importDefault(require("lodash/isEqualWith"));
|
|
73
74
|
var classNames_1 = __importDefault(require("../_util/classNames"));
|
|
74
75
|
var keycode_1 = require("../_util/keycode");
|
|
75
76
|
var Trigger_1 = __importDefault(require("../Trigger"));
|
|
@@ -236,7 +237,6 @@ function Select(baseProps, ref) {
|
|
|
236
237
|
}
|
|
237
238
|
else if (Array.isArray(value)) {
|
|
238
239
|
setValue(value.length === 0 ? undefined : value[0]);
|
|
239
|
-
setProxyValue(value.length === 0 ? undefined : value[0]);
|
|
240
240
|
}
|
|
241
241
|
}, [isMultipleMode, value]);
|
|
242
242
|
(0, react_1.useEffect)(function () {
|
|
@@ -481,7 +481,8 @@ function Select(baseProps, ref) {
|
|
|
481
481
|
if (isMultipleMode) {
|
|
482
482
|
checkOption(optionValue, value.indexOf(optionValue) === -1 ? 'add' : 'remove');
|
|
483
483
|
// 点击一个选项时,清空输入框内容
|
|
484
|
-
if (!
|
|
484
|
+
if (!isMultipleQuickSelectMode &&
|
|
485
|
+
(!(0, is_1.isObject)(showSearch) || !showSearch.retainInputValueWhileSelect)) {
|
|
485
486
|
tryUpdateInputValue('', 'optionChecked');
|
|
486
487
|
}
|
|
487
488
|
}
|
|
@@ -535,6 +536,35 @@ function Select(baseProps, ref) {
|
|
|
535
536
|
},
|
|
536
537
|
],
|
|
537
538
|
]));
|
|
539
|
+
// 全选
|
|
540
|
+
var checked = Array.isArray(stateProxyValue) &&
|
|
541
|
+
childrenList.length &&
|
|
542
|
+
childrenList.every(function (child) { return stateProxyValue.includes(child.props.value); });
|
|
543
|
+
var selectAllCheckBoxProps = isMultipleQuickSelectMode && Array.isArray(stateProxyValue)
|
|
544
|
+
? {
|
|
545
|
+
disabled: childrenList.length === 0,
|
|
546
|
+
checked: checked,
|
|
547
|
+
indeterminate: !checked &&
|
|
548
|
+
childrenList.length &&
|
|
549
|
+
childrenList.some(function (child) { return stateProxyValue.includes(child.props.value); }),
|
|
550
|
+
onChange: function (value) {
|
|
551
|
+
if (value) {
|
|
552
|
+
setProxyValue(function (prev) { return __spreadArray(__spreadArray([], __read(prev.filter(function (i) {
|
|
553
|
+
return !childrenList.some(function (child) { return (0, isEqualWith_1.default)(i, child.props.value); });
|
|
554
|
+
})), false), __read(childrenList.map(function (child) { return child.props.value; })), false); });
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
setProxyValue(function (prev) {
|
|
558
|
+
return ((prev === null || prev === void 0 ? void 0 : prev.filter(function (v) {
|
|
559
|
+
return !childrenList.some(function (child) { return (0, isEqualWith_1.default)(v, child.props.value); });
|
|
560
|
+
})) || []);
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
}
|
|
565
|
+
: {
|
|
566
|
+
style: { display: 'none' },
|
|
567
|
+
};
|
|
538
568
|
var renderPopup = function () {
|
|
539
569
|
var _a;
|
|
540
570
|
var _b, _c, _d, _e;
|
|
@@ -585,13 +615,14 @@ function Select(baseProps, ref) {
|
|
|
585
615
|
}),
|
|
586
616
|
isMultipleQuickSelectMode && (react_1.default.createElement("div", { style: {
|
|
587
617
|
display: 'flex',
|
|
588
|
-
justifyContent: '
|
|
589
|
-
|
|
590
|
-
padding: '8px 16px 4px',
|
|
618
|
+
justifyContent: 'space-between',
|
|
619
|
+
padding: '8px 16px 4px 8px',
|
|
591
620
|
borderTop: '1px solid var(--color-fill-3)',
|
|
592
621
|
} },
|
|
593
|
-
react_1.default.createElement(index_1.
|
|
594
|
-
react_1.default.createElement(
|
|
622
|
+
react_1.default.createElement(index_1.Checkbox, __assign({}, selectAllCheckBoxProps), "\u5168\u9009"),
|
|
623
|
+
react_1.default.createElement("div", { style: { display: 'flex', gap: 12 } },
|
|
624
|
+
react_1.default.createElement(index_1.Button, { size: "mini", onClick: cancelCheck }, (_d = locale.Select) === null || _d === void 0 ? void 0 : _d.cancelText),
|
|
625
|
+
react_1.default.createElement(index_1.Button, { type: "primary", size: "mini", onClick: confirmCheck }, (_e = locale.Select) === null || _e === void 0 ? void 0 : _e.okText)))))) : null;
|
|
595
626
|
// Avoid drop-down box jitter when user is creating a selection
|
|
596
627
|
var isUserCreating = allowCreate && inputValue;
|
|
597
628
|
// Dropdown-placeholder when there is no options
|
|
@@ -11,6 +11,7 @@ export interface TreeSelectState {
|
|
|
11
11
|
searchKeys: string[];
|
|
12
12
|
}
|
|
13
13
|
export declare const parseValue: (v: valueType, key2nodeProps: any, valueMap?: LabelValue[]) => LabelValue[];
|
|
14
|
+
export declare const getInitCheckKeys: (keys: string[], key2nodeProps: KeyCacheType, indeterminateKeys: any, props: TreeSelectProps) => string[];
|
|
14
15
|
declare const useStateValue: (props: TreeSelectProps, key2nodeProps: KeyCacheType, indeterminateKeys: MutableRefObject<string[]>) => [LabelValue[], (v: LabelValue[], extra: {
|
|
15
16
|
trigger?: NodeProps;
|
|
16
17
|
checked?: boolean;
|
|
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.parseValue = void 0;
|
|
42
|
+
exports.getInitCheckKeys = exports.parseValue = void 0;
|
|
43
43
|
var react_1 = require("react");
|
|
44
44
|
var isEqualWith_1 = __importDefault(require("lodash/isEqualWith"));
|
|
45
45
|
var utils_1 = require("../utils");
|
|
@@ -96,6 +96,7 @@ var getInitCheckKeys = function (keys, key2nodeProps, indeterminateKeys, props)
|
|
|
96
96
|
indeterminateKeys.current = [];
|
|
97
97
|
return keys;
|
|
98
98
|
};
|
|
99
|
+
exports.getInitCheckKeys = getInitCheckKeys;
|
|
99
100
|
var useStateValue = function (props, key2nodeProps, indeterminateKeys) {
|
|
100
101
|
var multiple = props.multiple || props.treeCheckable;
|
|
101
102
|
var isMultipleQuickSelectMode = multiple && props.isQuickSingleSelectMode;
|
|
@@ -103,7 +104,7 @@ var useStateValue = function (props, key2nodeProps, indeterminateKeys) {
|
|
|
103
104
|
var calcValue = function () {
|
|
104
105
|
var propsValue = props.value || props.defaultValue || [];
|
|
105
106
|
if (props.treeCheckable) {
|
|
106
|
-
var initCheckedKeys = getInitCheckKeys((0, utils_1.normalizeValueToArray)(propsValue), key2nodeProps, indeterminateKeys, props);
|
|
107
|
+
var initCheckedKeys = (0, exports.getInitCheckKeys)((0, utils_1.normalizeValueToArray)(propsValue), key2nodeProps, indeterminateKeys, props);
|
|
107
108
|
var parsedPropValue = (0, exports.parseValue)(propsValue, key2nodeProps, valueCopy.current);
|
|
108
109
|
var parsedCheckedValue = (0, exports.parseValue)(initCheckedKeys, key2nodeProps, parsedPropValue);
|
|
109
110
|
return parsedCheckedValue;
|
|
@@ -183,8 +183,9 @@ function TreeList(props, ref) {
|
|
|
183
183
|
var checkedKeys;
|
|
184
184
|
var getAllCheckedKeys = function (node, keys) {
|
|
185
185
|
if (keys === void 0) { keys = []; }
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
var children = node.childrenData || node.children;
|
|
187
|
+
if (Array.isArray(children) && children.length) {
|
|
188
|
+
children.forEach(function (child) {
|
|
188
189
|
getAllCheckedKeys(child, keys);
|
|
189
190
|
});
|
|
190
191
|
}
|
|
@@ -114,6 +114,7 @@ var useMergeProps_1 = __importDefault(require("../_util/hooks/useMergeProps"));
|
|
|
114
114
|
var useIsFirstRender_1 = __importDefault(require("../_util/hooks/useIsFirstRender"));
|
|
115
115
|
var useId_1 = __importDefault(require("../_util/hooks/useId"));
|
|
116
116
|
var Button_1 = __importDefault(require("../Button"));
|
|
117
|
+
var Checkbox_1 = __importDefault(require("../Checkbox"));
|
|
117
118
|
function isEmptyValue(value) {
|
|
118
119
|
return (!value ||
|
|
119
120
|
((0, is_1.isArray)(value) && value.length === 0) ||
|
|
@@ -332,6 +333,30 @@ var TreeSelect = function (baseProps, ref) {
|
|
|
332
333
|
var tryUpdateSelectValue = function (value) {
|
|
333
334
|
setValue(value, {});
|
|
334
335
|
};
|
|
336
|
+
var getSelectAllCheckBoxProps = (0, react_1.useCallback)(function () {
|
|
337
|
+
if (!isMultipleQuickSelectMode || props.treeCheckStrictly) {
|
|
338
|
+
return {
|
|
339
|
+
style: { display: 'none' },
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
var allCheckedKeys = (0, util_1.getCheckedKeysByInitKeys)((0, utils_1.normalizeValueToArray)(value), key2nodeProps).checkedKeys;
|
|
343
|
+
var rootKeys = treeData.map(function (item) { return item.key; });
|
|
344
|
+
var checked = rootKeys.every(function (key) { return allCheckedKeys.includes(key); });
|
|
345
|
+
var indeterminate = !checked && value.length && rootKeys.some(function (key) { return !allCheckedKeys.includes(key); });
|
|
346
|
+
return {
|
|
347
|
+
disabled: treeData.length === 0,
|
|
348
|
+
checked: checked,
|
|
349
|
+
indeterminate: indeterminate,
|
|
350
|
+
onChange: function (val) {
|
|
351
|
+
if (val) {
|
|
352
|
+
setValue((0, useStateValue_1.getInitCheckKeys)((0, utils_1.normalizeValueToArray)(rootKeys), key2nodeProps, indeterminateKeys, props).map(function (x) { return ({ label: x, value: x }); }), {});
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
setValue([], {});
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
}, [isMultipleQuickSelectMode, value, treeData]);
|
|
335
360
|
var renderView = function (eleView) {
|
|
336
361
|
return (react_1.default.createElement(Trigger_1.default, __assign({ autoAlignPopupWidth: false, autoAlignPopupMinWidth: true, ref: triggerRef, classNames: "slideDynamicOrigin", trigger: "click", position: "bl", getPopupContainer: props.getPopupContainer, popupAlign: triggerPopupAlign, unmountOnExit: props.unmountOnExit }, props.triggerProps, { className: (0, classNames_1.default)(prefixCls + "-trigger", props.triggerProps && props.triggerProps.className), popup: function () {
|
|
337
362
|
var _a;
|
|
@@ -347,15 +372,14 @@ var TreeSelect = function (baseProps, ref) {
|
|
|
347
372
|
react_1.default.createElement("div", { style: {
|
|
348
373
|
flex: 'none',
|
|
349
374
|
display: 'flex',
|
|
350
|
-
justifyContent: '
|
|
351
|
-
|
|
352
|
-
padding: '8px 16px 4px',
|
|
375
|
+
justifyContent: 'space-between',
|
|
376
|
+
padding: '8px 16px 4px 8px',
|
|
353
377
|
borderTop: '1px solid var(--color-fill-3)',
|
|
354
378
|
} },
|
|
355
|
-
react_1.default.createElement(
|
|
356
|
-
react_1.default.createElement(
|
|
357
|
-
|
|
358
|
-
|
|
379
|
+
react_1.default.createElement(Checkbox_1.default, __assign({}, getSelectAllCheckBoxProps()), "\u5168\u9009"),
|
|
380
|
+
react_1.default.createElement("div", { style: { display: 'flex', gap: 12 } },
|
|
381
|
+
react_1.default.createElement(Button_1.default, { size: "mini", onClick: cancelCheck }, (_b = locale.Select) === null || _b === void 0 ? void 0 : _b.cancelText),
|
|
382
|
+
react_1.default.createElement(Button_1.default, { type: "primary", size: "mini", onClick: confirmCheck }, (_c = locale.Select) === null || _c === void 0 ? void 0 : _c.okText))))) : (treeListDom);
|
|
359
383
|
var wrapStyle = isMultipleQuickSelectMode
|
|
360
384
|
? {
|
|
361
385
|
overflow: 'hidden',
|
package/lib/index.d.ts
CHANGED
|
@@ -139,4 +139,4 @@ export type { WatermarkProps } from './Watermark/interface';
|
|
|
139
139
|
export { default as Watermark } from './Watermark';
|
|
140
140
|
export type { ImageProps, ImagePreviewProps, ImagePreviewActionProps, ImagePreviewGroupProps } from './Image/interface';
|
|
141
141
|
export { default as Image } from './Image';
|
|
142
|
-
export declare const version = "1.
|
|
142
|
+
export declare const version = "1.5.0";
|
package/lib/index.js
CHANGED
|
@@ -147,4 +147,4 @@ var Watermark_1 = require("./Watermark");
|
|
|
147
147
|
Object.defineProperty(exports, "Watermark", { enumerable: true, get: function () { return __importDefault(Watermark_1).default; } });
|
|
148
148
|
var Image_1 = require("./Image");
|
|
149
149
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(Image_1).default; } });
|
|
150
|
-
exports.version = '1.
|
|
150
|
+
exports.version = '1.5.0';
|
package/lib/locale/en-US.d.ts
CHANGED
package/lib/locale/en-US.js
CHANGED
package/lib/locale/zh-CN.d.ts
CHANGED
package/lib/locale/zh-CN.js
CHANGED