@rc-component/tree-select 1.0.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.
Files changed (137) hide show
  1. package/LICENSE.md +22 -0
  2. package/README.md +140 -0
  3. package/assets/icons.png +0 -0
  4. package/assets/index.less +2 -0
  5. package/assets/loading.gif +0 -0
  6. package/assets/minus.gif +0 -0
  7. package/assets/select.less +3 -0
  8. package/assets/tree.less +3 -0
  9. package/dist/223.90c7e648.async.js +3 -0
  10. package/dist/338.a2a48f3b.async.js +15 -0
  11. package/dist/338.e8c51481.chunk.css +5 -0
  12. package/dist/404.html +20 -0
  13. package/dist/439.67bede3f.async.js +137 -0
  14. package/dist/929.df8dd03f.async.js +32 -0
  15. package/dist/demo/basic/index.html +20 -0
  16. package/dist/demo/big-data/index.html +20 -0
  17. package/dist/demo/controlled/index.html +20 -0
  18. package/dist/demo/custom-icons/index.html +20 -0
  19. package/dist/demo/debug/index.html +20 -0
  20. package/dist/demo/disable/index.html +20 -0
  21. package/dist/demo/dynamic/index.html +20 -0
  22. package/dist/demo/field-names/index.html +20 -0
  23. package/dist/demo/filter/index.html +20 -0
  24. package/dist/demo/form/index.html +20 -0
  25. package/dist/demo/mutiple-with-max-count/index.html +20 -0
  26. package/dist/demo/tree-node-label-prop/index.html +20 -0
  27. package/dist/demo/width/index.html +20 -0
  28. package/dist/demos.f221b577.async.js +1 -0
  29. package/dist/docs__demo__basic.md.bcb0edb7.async.js +1 -0
  30. package/dist/docs__demo__big-data.md.8783cd6b.async.js +1 -0
  31. package/dist/docs__demo__controlled.md.e65ef7d7.async.js +1 -0
  32. package/dist/docs__demo__custom-icons.md.d53bf2f9.async.js +1 -0
  33. package/dist/docs__demo__debug.md.099ad226.async.js +1 -0
  34. package/dist/docs__demo__disable.md.6ba57652.async.js +1 -0
  35. package/dist/docs__demo__dynamic.md.f7559890.async.js +1 -0
  36. package/dist/docs__demo__fieldNames.md.16131d9f.async.js +1 -0
  37. package/dist/docs__demo__filter.md.02527db4.async.js +1 -0
  38. package/dist/docs__demo__form.md.6b77dffe.async.js +1 -0
  39. package/dist/docs__demo__mutiple-with-maxCount.md.7268d4ad.async.js +1 -0
  40. package/dist/docs__demo__treeNodeLabelProp.md.24709916.async.js +1 -0
  41. package/dist/docs__demo__width.md.24bfecd6.async.js +1 -0
  42. package/dist/docs__index.md.a6e45331.async.js +1 -0
  43. package/dist/dumi__tmp-production__dumi__theme__ContextWrapper.f56a0670.async.js +1 -0
  44. package/dist/index.html +20 -0
  45. package/dist/meta__docs.255fc42b.chunk.css +1 -0
  46. package/dist/meta__docs.dbf04b66.async.js +3359 -0
  47. package/dist/nm__dumi__dist__client__pages__404.8b85f2d9.chunk.css +1 -0
  48. package/dist/nm__dumi__dist__client__pages__404.ca2add38.async.js +1 -0
  49. package/dist/nm__dumi__dist__client__pages__Demo__index.29e9ef8f.async.js +1 -0
  50. package/dist/nm__dumi__dist__client__pages__Demo__index.578aa5c0.chunk.css +1 -0
  51. package/dist/nm__dumi__theme-default__layouts__DocLayout__index.8ed833d7.async.js +1 -0
  52. package/dist/preload_helper.d41c4da0.js +1 -0
  53. package/dist/umi.4f47b921.js +124 -0
  54. package/dist/umi.8faca2de.css +1 -0
  55. package/dist/~demos/:id/index.html +20 -0
  56. package/dist/~demos/docs-demo-basic-demo-basic/index.html +20 -0
  57. package/dist/~demos/docs-demo-big-data-demo-big-data/index.html +20 -0
  58. package/dist/~demos/docs-demo-controlled-demo-controlled/index.html +20 -0
  59. package/dist/~demos/docs-demo-custom-icons-demo-custom-icons/index.html +20 -0
  60. package/dist/~demos/docs-demo-debug-demo-debug/index.html +20 -0
  61. package/dist/~demos/docs-demo-disable-demo-disable/index.html +20 -0
  62. package/dist/~demos/docs-demo-dynamic-demo-dynamic/index.html +20 -0
  63. package/dist/~demos/docs-demo-field-names-demo-fieldnames/index.html +20 -0
  64. package/dist/~demos/docs-demo-filter-demo-filter/index.html +20 -0
  65. package/dist/~demos/docs-demo-form-demo-form/index.html +20 -0
  66. package/dist/~demos/docs-demo-mutiple-with-max-count-demo-mutiple-with-maxcount/index.html +20 -0
  67. package/dist/~demos/docs-demo-tree-node-label-prop-demo-treenodelabelprop/index.html +20 -0
  68. package/dist/~demos/docs-demo-width-demo-width/index.html +20 -0
  69. package/es/LegacyContext.d.ts +24 -0
  70. package/es/LegacyContext.js +3 -0
  71. package/es/OptionList.d.ts +8 -0
  72. package/es/OptionList.js +351 -0
  73. package/es/TreeNode.d.ts +9 -0
  74. package/es/TreeNode.js +5 -0
  75. package/es/TreeSelect.d.ts +65 -0
  76. package/es/TreeSelect.js +507 -0
  77. package/es/TreeSelectContext.d.ts +25 -0
  78. package/es/TreeSelectContext.js +3 -0
  79. package/es/hooks/useCache.d.ts +7 -0
  80. package/es/hooks/useCache.js +32 -0
  81. package/es/hooks/useCheckedKeys.d.ts +5 -0
  82. package/es/hooks/useCheckedKeys.js +21 -0
  83. package/es/hooks/useDataEntities.d.ts +7 -0
  84. package/es/hooks/useDataEntities.js +26 -0
  85. package/es/hooks/useFilterTreeData.d.ts +8 -0
  86. package/es/hooks/useFilterTreeData.js +33 -0
  87. package/es/hooks/useRefFunc.d.ts +5 -0
  88. package/es/hooks/useRefFunc.js +14 -0
  89. package/es/hooks/useTreeData.d.ts +7 -0
  90. package/es/hooks/useTreeData.js +52 -0
  91. package/es/index.d.ts +7 -0
  92. package/es/index.js +5 -0
  93. package/es/interface.d.ts +57 -0
  94. package/es/interface.js +1 -0
  95. package/es/utils/legacyUtil.d.ts +5 -0
  96. package/es/utils/legacyUtil.js +120 -0
  97. package/es/utils/strategyUtil.d.ts +7 -0
  98. package/es/utils/strategyUtil.js +25 -0
  99. package/es/utils/valueUtil.d.ts +11 -0
  100. package/es/utils/valueUtil.js +30 -0
  101. package/es/utils/warningPropsUtil.d.ts +5 -0
  102. package/es/utils/warningPropsUtil.js +30 -0
  103. package/lib/LegacyContext.d.ts +24 -0
  104. package/lib/LegacyContext.js +11 -0
  105. package/lib/OptionList.d.ts +8 -0
  106. package/lib/OptionList.js +359 -0
  107. package/lib/TreeNode.d.ts +9 -0
  108. package/lib/TreeNode.js +11 -0
  109. package/lib/TreeSelect.d.ts +65 -0
  110. package/lib/TreeSelect.js +516 -0
  111. package/lib/TreeSelectContext.d.ts +25 -0
  112. package/lib/TreeSelectContext.js +11 -0
  113. package/lib/hooks/useCache.d.ts +7 -0
  114. package/lib/hooks/useCache.js +41 -0
  115. package/lib/hooks/useCheckedKeys.d.ts +5 -0
  116. package/lib/hooks/useCheckedKeys.js +29 -0
  117. package/lib/hooks/useDataEntities.d.ts +7 -0
  118. package/lib/hooks/useDataEntities.js +36 -0
  119. package/lib/hooks/useFilterTreeData.d.ts +8 -0
  120. package/lib/hooks/useFilterTreeData.js +41 -0
  121. package/lib/hooks/useRefFunc.d.ts +5 -0
  122. package/lib/hooks/useRefFunc.js +21 -0
  123. package/lib/hooks/useTreeData.d.ts +7 -0
  124. package/lib/hooks/useTreeData.js +60 -0
  125. package/lib/index.d.ts +7 -0
  126. package/lib/index.js +35 -0
  127. package/lib/interface.d.ts +57 -0
  128. package/lib/interface.js +5 -0
  129. package/lib/utils/legacyUtil.d.ts +5 -0
  130. package/lib/utils/legacyUtil.js +131 -0
  131. package/lib/utils/strategyUtil.d.ts +7 -0
  132. package/lib/utils/strategyUtil.js +32 -0
  133. package/lib/utils/valueUtil.d.ts +11 -0
  134. package/lib/utils/valueUtil.js +41 -0
  135. package/lib/utils/warningPropsUtil.d.ts +5 -0
  136. package/lib/utils/warningPropsUtil.js +37 -0
  137. package/package.json +89 -0
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Same as `React.useCallback` but always return a memoized function
3
+ * but redirect to real function.
4
+ */
5
+ export default function useRefFunc<T extends (...args: any[]) => any>(callback: T): T;
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Same as `React.useCallback` but always return a memoized function
5
+ * but redirect to real function.
6
+ */
7
+ export default function useRefFunc(callback) {
8
+ const funcRef = React.useRef();
9
+ funcRef.current = callback;
10
+ const cacheFn = React.useCallback((...args) => {
11
+ return funcRef.current(...args);
12
+ }, []);
13
+ return cacheFn;
14
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import type { DataNode, SimpleModeConfig } from '../interface';
3
+ /**
4
+ * 将 `treeData` 或 `children` 转换为格式化的 `treeData`。
5
+ * 如果 `treeData` 或 `children` 没有变化,则不会重新计算。
6
+ */
7
+ export default function useTreeData(treeData: DataNode[], children: React.ReactNode, simpleMode: boolean | SimpleModeConfig): DataNode[];
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import { convertChildrenToData } from "../utils/legacyUtil";
3
+ function buildTreeStructure(nodes, config) {
4
+ const {
5
+ id,
6
+ pId,
7
+ rootPId
8
+ } = config;
9
+ const nodeMap = new Map();
10
+ const rootNodes = [];
11
+ nodes.forEach(node => {
12
+ const nodeKey = node[id];
13
+ const clonedNode = {
14
+ ...node,
15
+ key: node.key || nodeKey
16
+ };
17
+ nodeMap.set(nodeKey, clonedNode);
18
+ });
19
+ nodeMap.forEach(node => {
20
+ const parentKey = node[pId];
21
+ const parent = nodeMap.get(parentKey);
22
+ if (parent) {
23
+ parent.children = parent.children || [];
24
+ parent.children.push(node);
25
+ } else if (parentKey === rootPId || rootPId === null) {
26
+ rootNodes.push(node);
27
+ }
28
+ });
29
+ return rootNodes;
30
+ }
31
+
32
+ /**
33
+ * 将 `treeData` 或 `children` 转换为格式化的 `treeData`。
34
+ * 如果 `treeData` 或 `children` 没有变化,则不会重新计算。
35
+ */
36
+ export default function useTreeData(treeData, children, simpleMode) {
37
+ return React.useMemo(() => {
38
+ if (treeData) {
39
+ if (simpleMode) {
40
+ const config = {
41
+ id: 'id',
42
+ pId: 'pId',
43
+ rootPId: null,
44
+ ...(typeof simpleMode === 'object' ? simpleMode : {})
45
+ };
46
+ return buildTreeStructure(treeData, config);
47
+ }
48
+ return treeData;
49
+ }
50
+ return convertChildrenToData(children);
51
+ }, [children, simpleMode, treeData]);
52
+ }
package/es/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import TreeSelect from './TreeSelect';
2
+ import type { TreeSelectProps } from './TreeSelect';
3
+ import TreeNode from './TreeNode';
4
+ import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from './utils/strategyUtil';
5
+ export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT };
6
+ export type { TreeSelectProps };
7
+ export default TreeSelect;
package/es/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import TreeSelect from "./TreeSelect";
2
+ import TreeNode from "./TreeNode";
3
+ import { SHOW_ALL, SHOW_CHILD, SHOW_PARENT } from "./utils/strategyUtil";
4
+ export { TreeNode, SHOW_ALL, SHOW_CHILD, SHOW_PARENT };
5
+ export default TreeSelect;
@@ -0,0 +1,57 @@
1
+ import type * as React from 'react';
2
+ import type { SafeKey, Key, DataNode as TreeDataNode } from 'rc-tree/lib/interface';
3
+ export type { SafeKey, Key };
4
+ export interface DataNode extends Record<string, any>, Omit<TreeDataNode, 'key' | 'children'> {
5
+ key?: Key;
6
+ value?: SafeKey;
7
+ children?: DataNode[];
8
+ }
9
+ export type SelectSource = 'option' | 'selection' | 'input' | 'clear';
10
+ export interface LabeledValueType {
11
+ key?: Key;
12
+ value?: SafeKey;
13
+ label?: React.ReactNode;
14
+ /** Only works on `treeCheckStrictly` */
15
+ halfChecked?: boolean;
16
+ }
17
+ export type DefaultValueType = SafeKey | LabeledValueType | (SafeKey | LabeledValueType)[];
18
+ export interface LegacyDataNode extends DataNode {
19
+ props: any;
20
+ }
21
+ export interface FlattenDataNode {
22
+ data: DataNode;
23
+ key: Key;
24
+ value: SafeKey;
25
+ level: number;
26
+ parent?: FlattenDataNode;
27
+ }
28
+ export interface SimpleModeConfig {
29
+ id?: SafeKey;
30
+ pId?: SafeKey;
31
+ rootPId?: SafeKey;
32
+ }
33
+ /** @deprecated This is only used for legacy compatible. Not works on new code. */
34
+ export interface LegacyCheckedNode {
35
+ pos: string;
36
+ node: React.ReactElement;
37
+ children?: LegacyCheckedNode[];
38
+ }
39
+ export interface ChangeEventExtra {
40
+ /** @deprecated Please save prev value by control logic instead */
41
+ preValue: LabeledValueType[];
42
+ triggerValue: SafeKey;
43
+ /** @deprecated Use `onSelect` or `onDeselect` instead. */
44
+ selected?: boolean;
45
+ /** @deprecated Use `onSelect` or `onDeselect` instead. */
46
+ checked?: boolean;
47
+ /** @deprecated This prop not work as react node anymore. */
48
+ triggerNode: React.ReactElement;
49
+ /** @deprecated This prop not work as react node anymore. */
50
+ allCheckedNodes: LegacyCheckedNode[];
51
+ }
52
+ export interface FieldNames {
53
+ value?: string;
54
+ label?: string;
55
+ children?: string;
56
+ _title?: string[];
57
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import type { DataNode, ChangeEventExtra, SafeKey, FieldNames } from '../interface';
3
+ export declare function convertChildrenToData(nodes: React.ReactNode): DataNode[];
4
+ export declare function fillLegacyProps(dataNode: DataNode): DataNode;
5
+ export declare function fillAdditionalInfo(extra: ChangeEventExtra, triggerValue: SafeKey, checkedValues: SafeKey[], treeData: DataNode[], showPosition: boolean, fieldNames: FieldNames): void;
@@ -0,0 +1,120 @@
1
+ import * as React from 'react';
2
+ import toArray from "@rc-component/util/es/Children/toArray";
3
+ import warning from "@rc-component/util/es/warning";
4
+ import TreeNode from "../TreeNode";
5
+ export function convertChildrenToData(nodes) {
6
+ return toArray(nodes).map(node => {
7
+ if (! /*#__PURE__*/React.isValidElement(node) || !node.type) {
8
+ return null;
9
+ }
10
+ const {
11
+ key,
12
+ props: {
13
+ children,
14
+ value,
15
+ ...restProps
16
+ }
17
+ } = node;
18
+ const data = {
19
+ key,
20
+ value,
21
+ ...restProps
22
+ };
23
+ const childData = convertChildrenToData(children);
24
+ if (childData.length) {
25
+ data.children = childData;
26
+ }
27
+ return data;
28
+ }).filter(data => data);
29
+ }
30
+ export function fillLegacyProps(dataNode) {
31
+ if (!dataNode) {
32
+ return dataNode;
33
+ }
34
+ const cloneNode = {
35
+ ...dataNode
36
+ };
37
+ if (!('props' in cloneNode)) {
38
+ Object.defineProperty(cloneNode, 'props', {
39
+ get() {
40
+ warning(false, 'New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access.');
41
+ return cloneNode;
42
+ }
43
+ });
44
+ }
45
+ return cloneNode;
46
+ }
47
+ export function fillAdditionalInfo(extra, triggerValue, checkedValues, treeData, showPosition, fieldNames) {
48
+ let triggerNode = null;
49
+ let nodeList = null;
50
+ function generateMap() {
51
+ function dig(list, level = '0', parentIncluded = false) {
52
+ return list.map((option, index) => {
53
+ const pos = `${level}-${index}`;
54
+ const value = option[fieldNames.value];
55
+ const included = checkedValues.includes(value);
56
+ const children = dig(option[fieldNames.children] || [], pos, included);
57
+ const node = /*#__PURE__*/React.createElement(TreeNode, option, children.map(child => child.node));
58
+
59
+ // Link with trigger node
60
+ if (triggerValue === value) {
61
+ triggerNode = node;
62
+ }
63
+ if (included) {
64
+ const checkedNode = {
65
+ pos,
66
+ node,
67
+ children
68
+ };
69
+ if (!parentIncluded) {
70
+ nodeList.push(checkedNode);
71
+ }
72
+ return checkedNode;
73
+ }
74
+ return null;
75
+ }).filter(node => node);
76
+ }
77
+ if (!nodeList) {
78
+ nodeList = [];
79
+ dig(treeData);
80
+
81
+ // Sort to keep the checked node length
82
+ nodeList.sort(({
83
+ node: {
84
+ props: {
85
+ value: val1
86
+ }
87
+ }
88
+ }, {
89
+ node: {
90
+ props: {
91
+ value: val2
92
+ }
93
+ }
94
+ }) => {
95
+ const index1 = checkedValues.indexOf(val1);
96
+ const index2 = checkedValues.indexOf(val2);
97
+ return index1 - index2;
98
+ });
99
+ }
100
+ }
101
+ Object.defineProperty(extra, 'triggerNode', {
102
+ get() {
103
+ warning(false, '`triggerNode` is deprecated. Please consider decoupling data with node.');
104
+ generateMap();
105
+ return triggerNode;
106
+ }
107
+ });
108
+ Object.defineProperty(extra, 'allCheckedNodes', {
109
+ get() {
110
+ warning(false, '`allCheckedNodes` is deprecated. Please consider decoupling data with node.');
111
+ generateMap();
112
+ if (showPosition) {
113
+ return nodeList;
114
+ }
115
+ return nodeList.map(({
116
+ node
117
+ }) => node);
118
+ }
119
+ });
120
+ }
@@ -0,0 +1,7 @@
1
+ import type { DataEntity } from 'rc-tree/lib/interface';
2
+ import type { SafeKey, FieldNames } from '../interface';
3
+ export declare const SHOW_ALL = "SHOW_ALL";
4
+ export declare const SHOW_PARENT = "SHOW_PARENT";
5
+ export declare const SHOW_CHILD = "SHOW_CHILD";
6
+ export type CheckedStrategy = typeof SHOW_ALL | typeof SHOW_PARENT | typeof SHOW_CHILD;
7
+ export declare function formatStrategyValues(values: SafeKey[], strategy: CheckedStrategy, keyEntities: Record<SafeKey, DataEntity>, fieldNames: FieldNames): SafeKey[];
@@ -0,0 +1,25 @@
1
+ import { isCheckDisabled } from "./valueUtil";
2
+ export const SHOW_ALL = 'SHOW_ALL';
3
+ export const SHOW_PARENT = 'SHOW_PARENT';
4
+ export const SHOW_CHILD = 'SHOW_CHILD';
5
+ export function formatStrategyValues(values, strategy, keyEntities, fieldNames) {
6
+ const valueSet = new Set(values);
7
+ if (strategy === SHOW_CHILD) {
8
+ return values.filter(key => {
9
+ const entity = keyEntities[key];
10
+ return !entity || !entity.children || !entity.children.some(({
11
+ node
12
+ }) => valueSet.has(node[fieldNames.value])) || !entity.children.every(({
13
+ node
14
+ }) => isCheckDisabled(node) || valueSet.has(node[fieldNames.value]));
15
+ });
16
+ }
17
+ if (strategy === SHOW_PARENT) {
18
+ return values.filter(key => {
19
+ const entity = keyEntities[key];
20
+ const parent = entity ? entity.parent : null;
21
+ return !parent || isCheckDisabled(parent.node) || !valueSet.has(parent.key);
22
+ });
23
+ }
24
+ return values;
25
+ }
@@ -0,0 +1,11 @@
1
+ import type { DataNode, FieldNames, SafeKey } from '../interface';
2
+ export declare const toArray: <T>(value: T | T[]) => T[];
3
+ export declare const fillFieldNames: (fieldNames?: FieldNames) => {
4
+ _title: string[];
5
+ value: string;
6
+ key: string;
7
+ children: string;
8
+ };
9
+ export declare const isCheckDisabled: (node: DataNode) => boolean;
10
+ export declare const getAllKeys: (treeData: DataNode[], fieldNames: FieldNames) => SafeKey[];
11
+ export declare const isNil: (val: any) => boolean;
@@ -0,0 +1,30 @@
1
+ export const toArray = value => Array.isArray(value) ? value : value !== undefined ? [value] : [];
2
+ export const fillFieldNames = fieldNames => {
3
+ const {
4
+ label,
5
+ value,
6
+ children
7
+ } = fieldNames || {};
8
+ return {
9
+ _title: label ? [label] : ['title', 'label'],
10
+ value: value || 'value',
11
+ key: value || 'value',
12
+ children: children || 'children'
13
+ };
14
+ };
15
+ export const isCheckDisabled = node => !node || node.disabled || node.disableCheckbox || node.checkable === false;
16
+ export const getAllKeys = (treeData, fieldNames) => {
17
+ const keys = [];
18
+ const dig = list => {
19
+ list.forEach(item => {
20
+ const children = item[fieldNames.children];
21
+ if (children) {
22
+ keys.push(item[fieldNames.value]);
23
+ dig(children);
24
+ }
25
+ });
26
+ };
27
+ dig(treeData);
28
+ return keys;
29
+ };
30
+ export const isNil = val => val === null || val === undefined;
@@ -0,0 +1,5 @@
1
+ import type { TreeSelectProps } from '../TreeSelect';
2
+ declare function warningProps(props: TreeSelectProps & {
3
+ searchPlaceholder?: string;
4
+ }): void;
5
+ export default warningProps;
@@ -0,0 +1,30 @@
1
+ import warning from "@rc-component/util/es/warning";
2
+ import { toArray } from "./valueUtil";
3
+ function warningProps(props) {
4
+ const {
5
+ searchPlaceholder,
6
+ treeCheckStrictly,
7
+ treeCheckable,
8
+ labelInValue,
9
+ value,
10
+ multiple,
11
+ showCheckedStrategy,
12
+ maxCount
13
+ } = props;
14
+ warning(!searchPlaceholder, '`searchPlaceholder` has been removed.');
15
+ if (treeCheckStrictly && labelInValue === false) {
16
+ warning(false, '`treeCheckStrictly` will force set `labelInValue` to `true`.');
17
+ }
18
+ if (labelInValue || treeCheckStrictly) {
19
+ warning(toArray(value).every(val => val && typeof val === 'object' && 'value' in val), 'Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead.');
20
+ }
21
+ if (treeCheckStrictly || multiple || treeCheckable) {
22
+ warning(!value || Array.isArray(value), '`value` should be an array when `TreeSelect` is checkable or multiple.');
23
+ } else {
24
+ warning(!Array.isArray(value), '`value` should not be array when `TreeSelect` is single mode.');
25
+ }
26
+ if (maxCount && (showCheckedStrategy === 'SHOW_ALL' && !treeCheckStrictly || showCheckedStrategy === 'SHOW_PARENT')) {
27
+ warning(false, '`maxCount` not work with `showCheckedStrategy=SHOW_ALL` (when `treeCheckStrictly=false`) or `showCheckedStrategy=SHOW_PARENT`.');
28
+ }
29
+ }
30
+ export default warningProps;
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import type { DataEntity, IconType } from 'rc-tree/lib/interface';
3
+ import type { LegacyDataNode, SafeKey, Key } from './interface';
4
+ interface LegacyContextProps {
5
+ checkable: boolean | React.ReactNode;
6
+ checkedKeys: Key[];
7
+ halfCheckedKeys: Key[];
8
+ treeExpandedKeys: Key[];
9
+ treeDefaultExpandedKeys: Key[];
10
+ onTreeExpand: (keys: Key[]) => void;
11
+ treeDefaultExpandAll: boolean;
12
+ treeIcon: IconType;
13
+ showTreeIcon: boolean;
14
+ switcherIcon: IconType;
15
+ treeLine: boolean;
16
+ treeNodeFilterProp: string;
17
+ treeLoadedKeys: Key[];
18
+ treeMotion: any;
19
+ loadData: (treeNode: LegacyDataNode) => Promise<unknown>;
20
+ onTreeLoad: (loadedKeys: Key[]) => void;
21
+ keyEntities: Record<SafeKey, DataEntity<any>>;
22
+ }
23
+ declare const LegacySelectContext: React.Context<LegacyContextProps>;
24
+ export default LegacySelectContext;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const LegacySelectContext = /*#__PURE__*/React.createContext(null);
11
+ var _default = exports.default = LegacySelectContext;
@@ -0,0 +1,8 @@
1
+ import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
2
+ import type { ScrollTo } from 'rc-tree/lib/interface';
3
+ import * as React from 'react';
4
+ type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & {
5
+ scrollTo: ScrollTo;
6
+ };
7
+ declare const RefOptionList: React.ForwardRefExoticComponent<React.RefAttributes<ReviseRefOptionListProps>>;
8
+ export default RefOptionList;