@rc-component/tree-select 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { DataEntity, IconType } from 'rc-tree/lib/interface';
2
+ import type { DataEntity, IconType } from '@rc-component/tree/lib/interface';
3
3
  import type { LegacyDataNode, SafeKey, Key } from './interface';
4
4
  interface LegacyContextProps {
5
5
  checkable: boolean | React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
2
- import type { ScrollTo } from 'rc-tree/lib/interface';
2
+ import type { ScrollTo } from '@rc-component/tree/lib/interface';
3
3
  import * as React from 'react';
4
4
  type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & {
5
5
  scrollTo: ScrollTo;
package/es/OptionList.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import { useBaseProps } from '@rc-component/select';
3
- import Tree from 'rc-tree';
4
- import { UnstableContext } from 'rc-tree';
3
+ import Tree from '@rc-component/tree';
4
+ import { UnstableContext } from '@rc-component/tree';
5
5
  import KeyCode from "@rc-component/util/es/KeyCode";
6
6
  import useMemo from "@rc-component/util/es/hooks/useMemo";
7
7
  import * as React from 'react';
@@ -42,7 +42,9 @@ const OptionList = (_, ref) => {
42
42
  onPopupScroll,
43
43
  leftMaxCount,
44
44
  leafCountOnly,
45
- valueEntities
45
+ valueEntities,
46
+ classNames: treeClassNames,
47
+ styles
46
48
  } = React.useContext(TreeSelectContext);
47
49
  const {
48
50
  checkable,
@@ -308,6 +310,8 @@ const OptionList = (_, ref) => {
308
310
  nodeDisabled
309
311
  }
310
312
  }, /*#__PURE__*/React.createElement(Tree, _extends({
313
+ classNames: treeClassNames,
314
+ styles: styles,
311
315
  ref: treeRef,
312
316
  focusable: false,
313
317
  prefixCls: `${prefixCls}-tree`,
@@ -1,6 +1,6 @@
1
1
  import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from '@rc-component/select';
2
- import type { IconType } from 'rc-tree/lib/interface';
3
- import type { ExpandAction } from 'rc-tree/lib/Tree';
2
+ import type { IconType } from '@rc-component/tree/lib/interface';
3
+ import type { ExpandAction } from '@rc-component/tree/lib/Tree';
4
4
  import * as React from 'react';
5
5
  import TreeNode from './TreeNode';
6
6
  import type { CheckedStrategy } from './utils/strategyUtil';
package/es/TreeSelect.js CHANGED
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import { BaseSelect } from '@rc-component/select';
3
3
  import useId from "@rc-component/select/es/hooks/useId";
4
- import { conductCheck } from "rc-tree/es/utils/conductUtil";
4
+ import { conductCheck } from "@rc-component/tree/es/utils/conductUtil";
5
5
  import useMergedState from "@rc-component/util/es/hooks/useMergedState";
6
6
  import * as React from 'react';
7
7
  import useCache from "./hooks/useCache";
@@ -77,6 +77,8 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
77
77
  treeMotion,
78
78
  treeTitleRender,
79
79
  onPopupScroll,
80
+ classNames: treeSelectClassNames,
81
+ styles,
80
82
  ...restProps
81
83
  } = props;
82
84
  const mergedId = useId(id);
@@ -441,9 +443,11 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
441
443
  onPopupScroll,
442
444
  leftMaxCount: maxCount === undefined ? null : maxCount - cachedDisplayValues.length,
443
445
  leafCountOnly: mergedShowCheckedStrategy === 'SHOW_CHILD' && !treeCheckStrictly && !!treeCheckable,
444
- valueEntities
446
+ valueEntities,
447
+ classNames: treeSelectClassNames,
448
+ styles
445
449
  };
446
- }, [virtual, popupMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities]);
450
+ }, [virtual, popupMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities, treeSelectClassNames, styles]);
447
451
 
448
452
  // ======================= Legacy Context =======================
449
453
  const legacyContext = React.useMemo(() => ({
@@ -474,7 +478,18 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
474
478
  }, /*#__PURE__*/React.createElement(BaseSelect, _extends({
475
479
  ref: ref
476
480
  }, restProps, {
481
+ classNames: {
482
+ prefix: treeSelectClassNames?.prefix,
483
+ suffix: treeSelectClassNames?.suffix,
484
+ input: treeSelectClassNames?.input
485
+ },
486
+ styles: {
487
+ prefix: styles?.prefix,
488
+ suffix: styles?.suffix,
489
+ input: styles?.input
490
+ }
477
491
  // >>> MISC
492
+ ,
478
493
  id: mergedId,
479
494
  prefixCls: prefixCls,
480
495
  mode: mergedMultiple ? 'multiple' : undefined
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
- import type { ExpandAction } from 'rc-tree/lib/Tree';
2
+ import type { ExpandAction } from '@rc-component/tree/lib/Tree';
3
3
  import type { DataNode, FieldNames, Key } from './interface';
4
4
  import type useDataEntities from './hooks/useDataEntities';
5
+ export type SemanticName = 'item' | 'itemTitle' | 'input' | 'prefix' | 'suffix';
5
6
  export interface TreeSelectContextProps {
6
7
  virtual?: boolean;
7
8
  popupMatchSelectWidth?: boolean | number;
@@ -20,6 +21,8 @@ export interface TreeSelectContextProps {
20
21
  /** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */
21
22
  leafCountOnly: boolean;
22
23
  valueEntities: ReturnType<typeof useDataEntities>['valueEntities'];
24
+ styles?: Partial<Record<SemanticName, React.CSSProperties>>;
25
+ classNames?: Partial<Record<SemanticName, string>>;
23
26
  }
24
27
  declare const TreeSelectContext: React.Context<TreeSelectContextProps>;
25
28
  export default TreeSelectContext;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { DataEntity } from 'rc-tree/lib/interface';
2
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
3
3
  import type { LabeledValueType, SafeKey } from '../interface';
4
4
  declare const useCheckedKeys: (rawLabeledValues: LabeledValueType[], rawHalfCheckedValues: LabeledValueType[], treeConduction: boolean, keyEntities: Record<SafeKey, DataEntity>) => React.Key[][];
5
5
  export default useCheckedKeys;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { conductCheck } from "rc-tree/es/utils/conductUtil";
2
+ import { conductCheck } from "@rc-component/tree/es/utils/conductUtil";
3
3
  const useCheckedKeys = (rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) => {
4
4
  return React.useMemo(() => {
5
5
  const extractValues = values => values.map(({
@@ -1,4 +1,4 @@
1
- import type { DataEntity } from 'rc-tree/lib/interface';
1
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
2
2
  import type { SafeKey, FieldNames } from '../interface';
3
3
  declare const _default: (treeData: any, fieldNames: FieldNames) => {
4
4
  valueEntities: Map<SafeKey, DataEntity>;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { convertDataToEntities } from "rc-tree/es/utils/treeUtil";
2
+ import { convertDataToEntities } from "@rc-component/tree/es/utils/treeUtil";
3
3
  import warning from "@rc-component/util/es/warning";
4
4
  import { isNil } from "../utils/valueUtil";
5
5
  export default ((treeData, fieldNames) => React.useMemo(() => {
package/es/interface.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type * as React from 'react';
2
- import type { SafeKey, Key, DataNode as TreeDataNode } from 'rc-tree/lib/interface';
2
+ import type { SafeKey, Key, DataNode as TreeDataNode } from '@rc-component/tree/lib/interface';
3
3
  export type { SafeKey, Key };
4
4
  export interface DataNode extends Record<string, any>, Omit<TreeDataNode, 'key' | 'children'> {
5
5
  key?: Key;
@@ -1,4 +1,4 @@
1
- import type { DataEntity } from 'rc-tree/lib/interface';
1
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
2
2
  import type { SafeKey, FieldNames } from '../interface';
3
3
  export declare const SHOW_ALL = "SHOW_ALL";
4
4
  export declare const SHOW_PARENT = "SHOW_PARENT";
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { DataEntity, IconType } from 'rc-tree/lib/interface';
2
+ import type { DataEntity, IconType } from '@rc-component/tree/lib/interface';
3
3
  import type { LegacyDataNode, SafeKey, Key } from './interface';
4
4
  interface LegacyContextProps {
5
5
  checkable: boolean | React.ReactNode;
@@ -1,5 +1,5 @@
1
1
  import type { RefOptionListProps } from '@rc-component/select/lib/OptionList';
2
- import type { ScrollTo } from 'rc-tree/lib/interface';
2
+ import type { ScrollTo } from '@rc-component/tree/lib/interface';
3
3
  import * as React from 'react';
4
4
  type ReviseRefOptionListProps = Omit<RefOptionListProps, 'scrollTo'> & {
5
5
  scrollTo: ScrollTo;
package/lib/OptionList.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _select = require("@rc-component/select");
8
- var _rcTree = _interopRequireWildcard(require("rc-tree"));
8
+ var _tree = _interopRequireWildcard(require("@rc-component/tree"));
9
9
  var _KeyCode = _interopRequireDefault(require("@rc-component/util/lib/KeyCode"));
10
10
  var _useMemo = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMemo"));
11
11
  var React = _interopRequireWildcard(require("react"));
@@ -50,7 +50,9 @@ const OptionList = (_, ref) => {
50
50
  onPopupScroll,
51
51
  leftMaxCount,
52
52
  leafCountOnly,
53
- valueEntities
53
+ valueEntities,
54
+ classNames: treeClassNames,
55
+ styles
54
56
  } = React.useContext(_TreeSelectContext.default);
55
57
  const {
56
58
  checkable,
@@ -311,11 +313,13 @@ const OptionList = (_, ref) => {
311
313
  }, activeEntity && open && /*#__PURE__*/React.createElement("span", {
312
314
  style: HIDDEN_STYLE,
313
315
  "aria-live": "assertive"
314
- }, activeEntity.node.value), /*#__PURE__*/React.createElement(_rcTree.UnstableContext.Provider, {
316
+ }, activeEntity.node.value), /*#__PURE__*/React.createElement(_tree.UnstableContext.Provider, {
315
317
  value: {
316
318
  nodeDisabled
317
319
  }
318
- }, /*#__PURE__*/React.createElement(_rcTree.default, _extends({
320
+ }, /*#__PURE__*/React.createElement(_tree.default, _extends({
321
+ classNames: treeClassNames,
322
+ styles: styles,
319
323
  ref: treeRef,
320
324
  focusable: false,
321
325
  prefixCls: `${prefixCls}-tree`,
@@ -1,6 +1,6 @@
1
1
  import type { BaseSelectPropsWithoutPrivate, BaseSelectRef } from '@rc-component/select';
2
- import type { IconType } from 'rc-tree/lib/interface';
3
- import type { ExpandAction } from 'rc-tree/lib/Tree';
2
+ import type { IconType } from '@rc-component/tree/lib/interface';
3
+ import type { ExpandAction } from '@rc-component/tree/lib/Tree';
4
4
  import * as React from 'react';
5
5
  import TreeNode from './TreeNode';
6
6
  import type { CheckedStrategy } from './utils/strategyUtil';
package/lib/TreeSelect.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _select = require("@rc-component/select");
8
8
  var _useId = _interopRequireDefault(require("@rc-component/select/lib/hooks/useId"));
9
- var _conductUtil = require("rc-tree/lib/utils/conductUtil");
9
+ var _conductUtil = require("@rc-component/tree/lib/utils/conductUtil");
10
10
  var _useMergedState = _interopRequireDefault(require("@rc-component/util/lib/hooks/useMergedState"));
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _useCache = _interopRequireDefault(require("./hooks/useCache"));
@@ -86,6 +86,8 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
86
86
  treeMotion,
87
87
  treeTitleRender,
88
88
  onPopupScroll,
89
+ classNames: treeSelectClassNames,
90
+ styles,
89
91
  ...restProps
90
92
  } = props;
91
93
  const mergedId = (0, _useId.default)(id);
@@ -450,9 +452,11 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
450
452
  onPopupScroll,
451
453
  leftMaxCount: maxCount === undefined ? null : maxCount - cachedDisplayValues.length,
452
454
  leafCountOnly: mergedShowCheckedStrategy === 'SHOW_CHILD' && !treeCheckStrictly && !!treeCheckable,
453
- valueEntities
455
+ valueEntities,
456
+ classNames: treeSelectClassNames,
457
+ styles
454
458
  };
455
- }, [virtual, popupMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities]);
459
+ }, [virtual, popupMatchSelectWidth, listHeight, listItemHeight, listItemScrollOffset, filteredTreeData, mergedFieldNames, onOptionSelect, treeExpandAction, treeTitleRender, onPopupScroll, maxCount, cachedDisplayValues.length, mergedShowCheckedStrategy, treeCheckStrictly, treeCheckable, valueEntities, treeSelectClassNames, styles]);
456
460
 
457
461
  // ======================= Legacy Context =======================
458
462
  const legacyContext = React.useMemo(() => ({
@@ -483,7 +487,18 @@ const TreeSelect = /*#__PURE__*/React.forwardRef((props, ref) => {
483
487
  }, /*#__PURE__*/React.createElement(_select.BaseSelect, _extends({
484
488
  ref: ref
485
489
  }, restProps, {
490
+ classNames: {
491
+ prefix: treeSelectClassNames?.prefix,
492
+ suffix: treeSelectClassNames?.suffix,
493
+ input: treeSelectClassNames?.input
494
+ },
495
+ styles: {
496
+ prefix: styles?.prefix,
497
+ suffix: styles?.suffix,
498
+ input: styles?.input
499
+ }
486
500
  // >>> MISC
501
+ ,
487
502
  id: mergedId,
488
503
  prefixCls: prefixCls,
489
504
  mode: mergedMultiple ? 'multiple' : undefined
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
- import type { ExpandAction } from 'rc-tree/lib/Tree';
2
+ import type { ExpandAction } from '@rc-component/tree/lib/Tree';
3
3
  import type { DataNode, FieldNames, Key } from './interface';
4
4
  import type useDataEntities from './hooks/useDataEntities';
5
+ export type SemanticName = 'item' | 'itemTitle' | 'input' | 'prefix' | 'suffix';
5
6
  export interface TreeSelectContextProps {
6
7
  virtual?: boolean;
7
8
  popupMatchSelectWidth?: boolean | number;
@@ -20,6 +21,8 @@ export interface TreeSelectContextProps {
20
21
  /** When `true`, only take leaf node as count, or take all as count with `maxCount` limitation */
21
22
  leafCountOnly: boolean;
22
23
  valueEntities: ReturnType<typeof useDataEntities>['valueEntities'];
24
+ styles?: Partial<Record<SemanticName, React.CSSProperties>>;
25
+ classNames?: Partial<Record<SemanticName, string>>;
23
26
  }
24
27
  declare const TreeSelectContext: React.Context<TreeSelectContextProps>;
25
28
  export default TreeSelectContext;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { DataEntity } from 'rc-tree/lib/interface';
2
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
3
3
  import type { LabeledValueType, SafeKey } from '../interface';
4
4
  declare const useCheckedKeys: (rawLabeledValues: LabeledValueType[], rawHalfCheckedValues: LabeledValueType[], treeConduction: boolean, keyEntities: Record<SafeKey, DataEntity>) => React.Key[][];
5
5
  export default useCheckedKeys;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _conductUtil = require("rc-tree/lib/utils/conductUtil");
8
+ var _conductUtil = require("@rc-component/tree/lib/utils/conductUtil");
9
9
  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); }
10
10
  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; }
11
11
  const useCheckedKeys = (rawLabeledValues, rawHalfCheckedValues, treeConduction, keyEntities) => {
@@ -1,4 +1,4 @@
1
- import type { DataEntity } from 'rc-tree/lib/interface';
1
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
2
2
  import type { SafeKey, FieldNames } from '../interface';
3
3
  declare const _default: (treeData: any, fieldNames: FieldNames) => {
4
4
  valueEntities: Map<SafeKey, DataEntity>;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- var _treeUtil = require("rc-tree/lib/utils/treeUtil");
8
+ var _treeUtil = require("@rc-component/tree/lib/utils/treeUtil");
9
9
  var _warning = _interopRequireDefault(require("@rc-component/util/lib/warning"));
10
10
  var _valueUtil = require("../utils/valueUtil");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,5 +1,5 @@
1
1
  import type * as React from 'react';
2
- import type { SafeKey, Key, DataNode as TreeDataNode } from 'rc-tree/lib/interface';
2
+ import type { SafeKey, Key, DataNode as TreeDataNode } from '@rc-component/tree/lib/interface';
3
3
  export type { SafeKey, Key };
4
4
  export interface DataNode extends Record<string, any>, Omit<TreeDataNode, 'key' | 'children'> {
5
5
  key?: Key;
@@ -1,4 +1,4 @@
1
- import type { DataEntity } from 'rc-tree/lib/interface';
1
+ import type { DataEntity } from '@rc-component/tree/lib/interface';
2
2
  import type { SafeKey, FieldNames } from '../interface';
3
3
  export declare const SHOW_ALL = "SHOW_ALL";
4
4
  export declare const SHOW_PARENT = "SHOW_PARENT";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/tree-select",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "tree-select ui component for react",
5
5
  "keywords": [
6
6
  "react",
@@ -45,8 +45,8 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "classnames": "2.x",
48
- "@rc-component/select": "~1.0.0",
49
- "rc-tree": "~5.13.1",
48
+ "@rc-component/select": "~1.0.2",
49
+ "@rc-component/tree": "~1.0.1",
50
50
  "@rc-component/util": "^1.2.1"
51
51
  },
52
52
  "devDependencies": {
@@ -74,7 +74,7 @@
74
74
  "husky": "^9.1.6",
75
75
  "lint-staged": "^15.2.10",
76
76
  "prettier": "^3.3.3",
77
- "rc-dialog": "^9.6.0",
77
+ "@rc-component/dialog": "^1.2.0",
78
78
  "rc-field-form": "^2.4.0",
79
79
  "rc-test": "^7.1.1",
80
80
  "rc-virtual-list": "^3.14.8",