@canlooks/can-ui 0.0.96 → 0.0.97

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 (77) hide show
  1. package/dist/cjs/components/accordion/accordion.style.d.ts +1 -1
  2. package/dist/cjs/components/alert/alert.style.d.ts +3 -3
  3. package/dist/cjs/components/button/button.style.d.ts +1 -1
  4. package/dist/cjs/components/checkboxBase/checkboxBase.style.d.ts +2 -2
  5. package/dist/cjs/components/clickAway/clickAway.d.ts +27 -27
  6. package/dist/cjs/components/dataGrid/dataGrid.style.d.ts +1 -1
  7. package/dist/cjs/components/descriptions/descriptions.style.d.ts +1 -1
  8. package/dist/cjs/components/dialog/dialog.style.d.ts +3 -3
  9. package/dist/cjs/components/inputBase/inputBase.style.d.ts +2 -2
  10. package/dist/cjs/components/menuItem/menuItem.d.ts +4 -0
  11. package/dist/cjs/components/menuItem/menuItem.style.d.ts +2 -2
  12. package/dist/cjs/components/optionsBase/optionsBase.js +2 -1
  13. package/dist/cjs/components/palette/palette.style.d.ts +1 -1
  14. package/dist/cjs/components/pickerDialog/pickerDialog.style.d.ts +1 -1
  15. package/dist/cjs/components/progress/progress.js +2 -1
  16. package/dist/cjs/components/progress/progress.style.d.ts +1 -1
  17. package/dist/cjs/components/resizable/resizable.style.d.ts +1 -1
  18. package/dist/cjs/components/segmented/segmented.style.d.ts +1 -1
  19. package/dist/cjs/components/selectionContext/selectionContext.d.ts +2 -0
  20. package/dist/cjs/components/selectionContext/selectionHook.js +2 -1
  21. package/dist/cjs/components/snackbarBase/snackbarBase.style.d.ts +1 -1
  22. package/dist/cjs/components/status/status.style.d.ts +1 -1
  23. package/dist/cjs/components/tabs/tabs.style.d.ts +4 -4
  24. package/dist/cjs/components/tag/tag.style.d.ts +2 -2
  25. package/dist/cjs/components/transfer/transfer.style.d.ts +2 -2
  26. package/dist/cjs/components/tree/tree.d.ts +2 -2
  27. package/dist/cjs/components/tree/tree.js +15 -13
  28. package/dist/cjs/components/tree/tree.style.d.ts +5 -9
  29. package/dist/cjs/components/tree/tree.style.js +96 -206
  30. package/dist/cjs/components/tree/treeDnd.d.ts +3 -7
  31. package/dist/cjs/components/tree/treeDnd.js +7 -19
  32. package/dist/cjs/components/tree/treeDnd.style.d.ts +15 -0
  33. package/dist/cjs/components/tree/treeDnd.style.js +191 -0
  34. package/dist/cjs/components/tree/treeNode.d.ts +4 -4
  35. package/dist/cjs/components/tree/treeNode.js +82 -69
  36. package/dist/cjs/components/upload/upload.style.d.ts +1 -1
  37. package/dist/cjs/utils/dnd.d.ts +11 -3
  38. package/dist/cjs/utils/dnd.js +45 -2
  39. package/dist/esm/components/accordion/accordion.style.d.ts +1 -1
  40. package/dist/esm/components/alert/alert.style.d.ts +3 -3
  41. package/dist/esm/components/button/button.style.d.ts +1 -1
  42. package/dist/esm/components/checkboxBase/checkboxBase.style.d.ts +2 -2
  43. package/dist/esm/components/clickAway/clickAway.d.ts +27 -27
  44. package/dist/esm/components/dataGrid/dataGrid.style.d.ts +1 -1
  45. package/dist/esm/components/descriptions/descriptions.style.d.ts +1 -1
  46. package/dist/esm/components/dialog/dialog.style.d.ts +3 -3
  47. package/dist/esm/components/inputBase/inputBase.style.d.ts +2 -2
  48. package/dist/esm/components/menuItem/menuItem.d.ts +4 -0
  49. package/dist/esm/components/menuItem/menuItem.style.d.ts +2 -2
  50. package/dist/esm/components/optionsBase/optionsBase.js +2 -1
  51. package/dist/esm/components/palette/palette.style.d.ts +1 -1
  52. package/dist/esm/components/pickerDialog/pickerDialog.style.d.ts +1 -1
  53. package/dist/esm/components/progress/progress.js +2 -1
  54. package/dist/esm/components/progress/progress.style.d.ts +1 -1
  55. package/dist/esm/components/resizable/resizable.style.d.ts +1 -1
  56. package/dist/esm/components/segmented/segmented.style.d.ts +1 -1
  57. package/dist/esm/components/selectionContext/selectionContext.d.ts +2 -0
  58. package/dist/esm/components/selectionContext/selectionHook.js +2 -1
  59. package/dist/esm/components/snackbarBase/snackbarBase.style.d.ts +1 -1
  60. package/dist/esm/components/status/status.style.d.ts +1 -1
  61. package/dist/esm/components/tabs/tabs.style.d.ts +4 -4
  62. package/dist/esm/components/tag/tag.style.d.ts +2 -2
  63. package/dist/esm/components/transfer/transfer.style.d.ts +2 -2
  64. package/dist/esm/components/tree/tree.d.ts +2 -2
  65. package/dist/esm/components/tree/tree.js +18 -16
  66. package/dist/esm/components/tree/tree.style.d.ts +5 -9
  67. package/dist/esm/components/tree/tree.style.js +95 -206
  68. package/dist/esm/components/tree/treeDnd.d.ts +3 -7
  69. package/dist/esm/components/tree/treeDnd.js +8 -20
  70. package/dist/esm/components/tree/treeDnd.style.d.ts +15 -0
  71. package/dist/esm/components/tree/treeDnd.style.js +186 -0
  72. package/dist/esm/components/tree/treeNode.d.ts +4 -4
  73. package/dist/esm/components/tree/treeNode.js +82 -69
  74. package/dist/esm/components/upload/upload.style.d.ts +1 -1
  75. package/dist/esm/utils/dnd.d.ts +11 -3
  76. package/dist/esm/utils/dnd.js +44 -2
  77. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  export declare const classes: {
2
2
  title: string;
3
- content: string;
4
3
  prefix: string;
4
+ content: string;
5
5
  suffix: string;
6
6
  expandIcon: string;
7
7
  titleRow: string;
@@ -1,11 +1,11 @@
1
1
  import { ColorPropsValue } from '../../types';
2
2
  export declare const classes: {
3
3
  title: string;
4
- content: string;
5
- close: string;
6
4
  prefix: string;
7
- icon: string;
5
+ content: string;
8
6
  suffix: string;
7
+ icon: string;
8
+ close: string;
9
9
  description: string;
10
10
  } & {
11
11
  root: string;
@@ -1,7 +1,7 @@
1
1
  import { ColorPropsValue } from '../../types';
2
2
  export declare const classes: {
3
- content: string;
4
3
  prefix: string;
4
+ content: string;
5
5
  suffix: string;
6
6
  } & {
7
7
  root: string;
@@ -2,9 +2,9 @@ import { CheckboxBaseProps } from './checkboxBase';
2
2
  export declare const classes: {
3
3
  input: string;
4
4
  label: string;
5
- icon: string;
6
- radio: string;
7
5
  checkbox: string;
6
+ radio: string;
7
+ icon: string;
8
8
  radioChecked: string;
9
9
  indeterminate: string;
10
10
  } & {
@@ -18,26 +18,26 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
18
18
  suppressContentEditableWarning: boolean;
19
19
  suppressHydrationWarning: boolean;
20
20
  accessKey: string;
21
- autoCapitalize: "none" | (string & {}) | "off" | "on" | "sentences" | "words" | "characters";
21
+ autoCapitalize: (string & {}) | "none" | "off" | "on" | "sentences" | "words" | "characters";
22
22
  autoFocus: boolean;
23
23
  className: string;
24
- contentEditable: boolean | "true" | "inherit" | "false" | "plaintext-only";
24
+ contentEditable: boolean | "inherit" | "false" | "true" | "plaintext-only";
25
25
  contextMenu: string;
26
26
  dir: string;
27
- draggable: boolean | "true" | "false";
28
- enterKeyHint: "search" | "done" | "send" | "next" | "enter" | "go" | "previous";
27
+ draggable: boolean | "false" | "true";
28
+ enterKeyHint: "search" | "done" | "next" | "enter" | "go" | "previous" | "send";
29
29
  hidden: boolean;
30
30
  id: string;
31
31
  lang: string;
32
32
  nonce: string;
33
33
  slot: string;
34
- spellCheck: boolean | "true" | "false";
34
+ spellCheck: boolean | "false" | "true";
35
35
  style: import("react").CSSProperties;
36
36
  tabIndex: number;
37
37
  title: string;
38
- translate: "no" | "yes";
38
+ translate: "yes" | "no";
39
39
  radioGroup: string;
40
- role: "article" | "button" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "menu" | "menuitem" | "option" | "search" | "table" | "switch" | "none" | "status" | "feed" | "grid" | "heading" | "list" | "note" | "presentation" | "radio" | "slider" | "timer" | "tree" | (string & {}) | "checkbox" | "listbox" | "region" | "cell" | "row" | "listitem" | "menubar" | "progressbar" | "separator" | "tab" | "tabpanel" | "toolbar" | "tooltip" | "treeitem" | "scrollbar" | "alert" | "alertdialog" | "application" | "banner" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "directory" | "document" | "gridcell" | "group" | "log" | "marquee" | "math" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "radiogroup" | "rowgroup" | "rowheader" | "searchbox" | "spinbutton" | "tablist" | "term" | "textbox" | "treegrid";
40
+ role: "article" | "button" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "menu" | "menuitem" | "option" | "search" | "table" | "switch" | "status" | (string & {}) | "none" | "checkbox" | "listbox" | "radio" | "region" | "cell" | "grid" | "row" | "listitem" | "menubar" | "progressbar" | "separator" | "tab" | "tabpanel" | "toolbar" | "tooltip" | "treeitem" | "scrollbar" | "alert" | "alertdialog" | "application" | "banner" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "directory" | "document" | "feed" | "gridcell" | "group" | "heading" | "list" | "log" | "marquee" | "math" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "note" | "presentation" | "radiogroup" | "rowgroup" | "rowheader" | "searchbox" | "slider" | "spinbutton" | "tablist" | "term" | "textbox" | "timer" | "tree" | "treegrid";
41
41
  about: string;
42
42
  content: string;
43
43
  datatype: string;
@@ -61,7 +61,7 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
61
61
  security: string;
62
62
  unselectable: "off" | "on";
63
63
  popover: "" | "auto" | "manual";
64
- popoverTargetAction: "toggle" | "hide" | "show";
64
+ popoverTargetAction: "hide" | "show" | "toggle";
65
65
  popoverTarget: string;
66
66
  inert: boolean;
67
67
  inputMode: "text" | "search" | "none" | "tel" | "url" | "email" | "numeric" | "decimal";
@@ -69,52 +69,52 @@ export declare function ClickAway({ ref, container, eventType, onClickAway, disa
69
69
  exportparts: string;
70
70
  part: string;
71
71
  "aria-activedescendant": string;
72
- "aria-atomic": boolean | "true" | "false";
73
- "aria-autocomplete": "none" | "list" | "both" | "inline";
72
+ "aria-atomic": boolean | "false" | "true";
73
+ "aria-autocomplete": "both" | "none" | "inline" | "list";
74
74
  "aria-braillelabel": string;
75
75
  "aria-brailleroledescription": string;
76
- "aria-busy": boolean | "true" | "false";
77
- "aria-checked": boolean | "true" | "mixed" | "false";
76
+ "aria-busy": boolean | "false" | "true";
77
+ "aria-checked": boolean | "mixed" | "false" | "true";
78
78
  "aria-colcount": number;
79
79
  "aria-colindex": number;
80
80
  "aria-colindextext": string;
81
81
  "aria-colspan": number;
82
82
  "aria-controls": string;
83
- "aria-current": boolean | "time" | "true" | "location" | "page" | "false" | "step" | "date";
83
+ "aria-current": boolean | "time" | "step" | "page" | "false" | "true" | "location" | "date";
84
84
  "aria-describedby": string;
85
85
  "aria-description": string;
86
86
  "aria-details": string;
87
- "aria-disabled": boolean | "true" | "false";
88
- "aria-dropeffect": "link" | "copy" | "none" | "move" | "execute" | "popup";
87
+ "aria-disabled": boolean | "false" | "true";
88
+ "aria-dropeffect": "link" | "none" | "copy" | "move" | "execute" | "popup";
89
89
  "aria-errormessage": string;
90
- "aria-expanded": boolean | "true" | "false";
90
+ "aria-expanded": boolean | "false" | "true";
91
91
  "aria-flowto": string;
92
- "aria-grabbed": boolean | "true" | "false";
93
- "aria-haspopup": boolean | "dialog" | "menu" | "true" | "grid" | "tree" | "listbox" | "false";
94
- "aria-hidden": boolean | "true" | "false";
95
- "aria-invalid": boolean | "true" | "false" | "grammar" | "spelling";
92
+ "aria-grabbed": boolean | "false" | "true";
93
+ "aria-haspopup": boolean | "dialog" | "menu" | "listbox" | "grid" | "false" | "true" | "tree";
94
+ "aria-hidden": boolean | "false" | "true";
95
+ "aria-invalid": boolean | "false" | "true" | "grammar" | "spelling";
96
96
  "aria-keyshortcuts": string;
97
97
  "aria-label": string;
98
98
  "aria-labelledby": string;
99
99
  "aria-level": number;
100
100
  "aria-live": "off" | "assertive" | "polite";
101
- "aria-modal": boolean | "true" | "false";
102
- "aria-multiline": boolean | "true" | "false";
103
- "aria-multiselectable": boolean | "true" | "false";
101
+ "aria-modal": boolean | "false" | "true";
102
+ "aria-multiline": boolean | "false" | "true";
103
+ "aria-multiselectable": boolean | "false" | "true";
104
104
  "aria-orientation": "horizontal" | "vertical";
105
105
  "aria-owns": string;
106
106
  "aria-placeholder": string;
107
107
  "aria-posinset": number;
108
- "aria-pressed": boolean | "true" | "mixed" | "false";
109
- "aria-readonly": boolean | "true" | "false";
108
+ "aria-pressed": boolean | "mixed" | "false" | "true";
109
+ "aria-readonly": boolean | "false" | "true";
110
110
  "aria-relevant": "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
111
- "aria-required": boolean | "true" | "false";
111
+ "aria-required": boolean | "false" | "true";
112
112
  "aria-roledescription": string;
113
113
  "aria-rowcount": number;
114
114
  "aria-rowindex": number;
115
115
  "aria-rowindextext": string;
116
116
  "aria-rowspan": number;
117
- "aria-selected": boolean | "true" | "false";
117
+ "aria-selected": boolean | "false" | "true";
118
118
  "aria-setsize": number;
119
119
  "aria-sort": "none" | "ascending" | "descending" | "other";
120
120
  "aria-valuemax": number;
@@ -3,11 +3,11 @@ export declare const classes: {
3
3
  title: string;
4
4
  children: string;
5
5
  container: string;
6
+ expandable: string;
6
7
  filterForm: string;
7
8
  functionalCell: string;
8
9
  sortIcon: string;
9
10
  filterButton: string;
10
- expandable: string;
11
11
  expandableWrap: string;
12
12
  selectable: string;
13
13
  subTd: string;
@@ -2,8 +2,8 @@ export declare const classes: {
2
2
  col: string;
3
3
  label: string;
4
4
  content: string;
5
- colon: string;
6
5
  vertical: string;
6
+ colon: string;
7
7
  item: string;
8
8
  labelCol: string;
9
9
  contentCol: string;
@@ -2,12 +2,12 @@ export declare const classes: {
2
2
  body: string;
3
3
  footer: string;
4
4
  title: string;
5
- content: string;
6
- close: string;
7
5
  prefix: string;
6
+ content: string;
7
+ suffix: string;
8
8
  icon: string;
9
9
  container: string;
10
- suffix: string;
10
+ close: string;
11
11
  card: string;
12
12
  titleRow: string;
13
13
  bodyWrap: string;
@@ -1,9 +1,9 @@
1
1
  import { InputBaseProps } from './inputBase';
2
2
  export declare const classes: {
3
- content: string;
4
3
  prefix: string;
5
- clear: string;
4
+ content: string;
6
5
  suffix: string;
6
+ clear: string;
7
7
  } & {
8
8
  root: string;
9
9
  };
@@ -21,6 +21,10 @@ export interface MenuItemProps extends Omit<DivProps, 'prefix'> {
21
21
  suffix?: ReactNode;
22
22
  /** 当label不为string时,该字段会取代label用来搜索 */
23
23
  searchToken?: string;
24
+ /**
25
+ * 若指定为`true`,则弹框打开时会自动滚动到该选项,默认为`false`
26
+ */
27
+ scrollHere?: boolean;
24
28
  /** @private 内部使用,缩进的层级 */
25
29
  _level?: number;
26
30
  indent?: number;
@@ -1,10 +1,10 @@
1
1
  import { MenuItemProps } from './menuItem';
2
2
  export declare const classes: {
3
3
  children: string;
4
- content: string;
5
4
  prefix: string;
6
- checkbox: string;
5
+ content: string;
7
6
  suffix: string;
7
+ checkbox: string;
8
8
  arrow: string;
9
9
  childrenWrap: string;
10
10
  } & {
@@ -91,7 +91,8 @@ searchValue, selectedValue, onToggleSelected, ...props }) => {
91
91
  params.opt?.onPointerEnter?.(e);
92
92
  setVerticalIndex(-1);
93
93
  },
94
- children: null
94
+ children: null,
95
+ scrollHere: void 0
95
96
  });
96
97
  if (options) {
97
98
  return filteredOptions.map((opt, index) => {
@@ -2,9 +2,9 @@ export declare const classes: {
2
2
  input: string;
3
3
  main: string;
4
4
  mask: string;
5
- sliders: string;
6
5
  hue: string;
7
6
  alpha: string;
7
+ sliders: string;
8
8
  handle: string;
9
9
  slidersRow: string;
10
10
  alphaMask: string;
@@ -1,7 +1,7 @@
1
1
  export declare const classes: {
2
2
  content: string;
3
- confirm: string;
4
3
  list: string;
4
+ confirm: string;
5
5
  selectedArea: string;
6
6
  count: string;
7
7
  } & {
@@ -14,6 +14,7 @@ exports.Progress = (0, react_1.memo)(({ showInfo = true, renderInfo, color, stat
14
14
  const isColorSpecified = !!color;
15
15
  color ??= 'primary';
16
16
  const { colors: { success, error } } = (0, theme_1.useTheme)();
17
+ value = Math.max(0, Math.min(value, 100));
17
18
  const isSucceed = status === 'success' || (status !== 'error' && value === 100 && variant !== 'gauge');
18
19
  const renderInfoFn = () => {
19
20
  if (renderInfo) {
@@ -71,6 +72,6 @@ exports.Progress = (0, react_1.memo)(({ showInfo = true, renderInfo, color, stat
71
72
  : void 0
72
73
  }, children: [(0, jsx_runtime_1.jsx)("circle", { ...commonCircleProps, className: progress_style_1.classes.track, strokeDasharray: variant === 'gauge' ? strokeDasharray : void 0, strokeDashoffset: variant === 'gauge' ? strokeDasharray * gapDegree / 360 : void 0 }), (0, jsx_runtime_1.jsx)("circle", { ...commonCircleProps, ref: barRef, css: cssAnimation, className: progress_style_1.classes.bar, strokeDasharray: strokeDasharray, strokeDashoffset: variant === 'circular'
73
74
  ? strokeDasharray * (1 - value / 100)
74
- : strokeDasharray * (1 - Math.max(0, Math.min(100, value)) / 100 * (1 - gapDegree / 360)) })] }), showInfo && !indeterminate &&
75
+ : strokeDasharray * (1 - value / 100 * (1 - gapDegree / 360)) })] }), showInfo && !indeterminate &&
75
76
  (0, jsx_runtime_1.jsx)("div", { className: progress_style_1.classes.info, children: renderInfoFn() })] }) }));
76
77
  });
@@ -3,8 +3,8 @@ export declare const classes: {
3
3
  info: string;
4
4
  track: string;
5
5
  svg: string;
6
- icon: string;
7
6
  bar: string;
7
+ icon: string;
8
8
  } & {
9
9
  root: string;
10
10
  };
@@ -1,8 +1,8 @@
1
1
  import { Handle, ResizableProps } from './resizable';
2
2
  export declare const classes: {
3
+ container: string;
3
4
  corner: string;
4
5
  edge: string;
5
- container: string;
6
6
  } & {
7
7
  root: string;
8
8
  };
@@ -3,8 +3,8 @@ export declare const classes: {
3
3
  label: string;
4
4
  option: string;
5
5
  prefix: string;
6
- indicator: string;
7
6
  suffix: string;
7
+ indicator: string;
8
8
  } & {
9
9
  root: string;
10
10
  };
@@ -4,6 +4,8 @@ export interface OptionType<V extends Id = Id> extends Obj {
4
4
  children?: OptionType<V>[];
5
5
  /** @private */
6
6
  _parentId?: V;
7
+ /** @private */
8
+ _isLast?: boolean;
7
9
  }
8
10
  export type SelectionContextBaseProps<O extends OptionType<V>, V extends Id = Id> = {
9
11
  options?: O[];
@@ -33,8 +33,9 @@ function useSelection(props) {
33
33
  const map = new Map();
34
34
  const fn = (arr, parentId) => {
35
35
  // 有时arr可能不为数组,需要判断,如DataGrid组件的row.children
36
- Array.isArray(arr) && arr.forEach(item => {
36
+ Array.isArray(arr) && arr.forEach((item, i) => {
37
37
  item._parentId = parentId;
38
+ item._isLast = i === arr.length - 1;
38
39
  const id = item[props.primaryKey];
39
40
  !(0, utils_1.isUnset)(id) && map.set(id, item);
40
41
  fn(item[props.childrenKey], id);
@@ -2,8 +2,8 @@ export declare const classes: {
2
2
  text: string;
3
3
  title: string;
4
4
  content: string;
5
- close: string;
6
5
  icon: string;
6
+ close: string;
7
7
  item: string;
8
8
  titleRow: string;
9
9
  itemWrap: string;
@@ -1,7 +1,7 @@
1
1
  export declare const classes: {
2
2
  label: string;
3
- icon: string;
4
3
  dot: string;
4
+ icon: string;
5
5
  } & {
6
6
  root: string;
7
7
  };
@@ -1,14 +1,14 @@
1
1
  import { TabsProps } from './tabs';
2
2
  export declare const classes: {
3
3
  label: string;
4
- scroll: string;
5
4
  prefix: string;
5
+ suffix: string;
6
+ indicator: string;
6
7
  end: string;
7
- ellipsis: string;
8
8
  start: string;
9
+ scroll: string;
10
+ ellipsis: string;
9
11
  tab: string;
10
- indicator: string;
11
- suffix: string;
12
12
  scrollWrap: string;
13
13
  tabPrefix: string;
14
14
  tabSuffix: string;
@@ -1,9 +1,9 @@
1
1
  import { TagProps } from './tag';
2
2
  export declare const classes: {
3
- content: string;
4
- close: string;
5
3
  prefix: string;
4
+ content: string;
6
5
  suffix: string;
6
+ close: string;
7
7
  } & {
8
8
  root: string;
9
9
  };
@@ -2,11 +2,11 @@ export declare const classes: {
2
2
  info: string;
3
3
  header: string;
4
4
  title: string;
5
- list: string;
6
5
  checkbox: string;
6
+ list: string;
7
+ buttons: string;
7
8
  count: string;
8
9
  panel: string;
9
- buttons: string;
10
10
  } & {
11
11
  root: string;
12
12
  };
@@ -6,11 +6,11 @@ import { TreeNode, TreeNodeProps } from './treeNode';
6
6
  export interface NodeType<V extends Id = Id> extends Partial<Omit<TreeNodeProps, 'children'>>, Omit<OptionType<V>, 'children'> {
7
7
  children?: NodeType<V>[];
8
8
  }
9
- export type SortPlacement = 'before' | 'after';
9
+ export type SortPlacement = 'before' | 'after' | 'child';
10
10
  export type SortInfo<V extends Id = Id> = {
11
11
  source: V;
12
12
  destination: V;
13
- placement: SortPlacement | 'child';
13
+ placement: SortPlacement;
14
14
  };
15
15
  export interface TreeBaseProps<N extends NodeType<V>, V extends Id = Id> extends Omit<SelectionContextBaseProps<N, V>, 'options'>, Omit<DivProps, 'defaultValue' | 'onChange' | 'onToggle'> {
16
16
  nodes?: N[];
@@ -21,11 +21,6 @@ function useTreeContext() {
21
21
  exports.Tree = (0, react_2.memo)(({ nodes, labelKey = 'label', searchTokenKey, showLine = true, indent = 24, renderExpandIcon, multiple, showCheckbox = !!multiple, readOnly, clickLabelToExpand, defaultExpanded, expanded, onExpandedChange, sortable = false, showDragHandle = true, onSort, searchable, searchInputProps, defaultSearchValue, searchValue, onSearchChange,
22
22
  // 从SelectionContext继承来的属性
23
23
  primaryKey = 'id', childrenKey = 'children', relation = 'dependent', integration = 'shallowest', clearable, disabled, defaultValue, value, onChange, onToggle, ...props }) => {
24
- const selectionContextProps = {
25
- options: nodes, primaryKey, childrenKey, relation, integration,
26
- multiple, defaultValue, value, onChange, disabled
27
- };
28
- const containerRef = (0, react_2.useRef)(null);
29
24
  /**
30
25
  * --------------------------------------------------------------
31
26
  * 统一处理nodes与children
@@ -57,30 +52,37 @@ primaryKey = 'id', childrenKey = 'children', relation = 'dependent', integration
57
52
  defaultExpanded, expanded, onExpandedChange,
58
53
  defaultSearchValue, searchValue, onSearchChange
59
54
  });
60
- return ((0, jsx_runtime_1.jsxs)("div", { ...props, ref: (0, utils_1.cloneRef)(containerRef, props.ref), css: tree_style_1.style, className: (0, utils_1.clsx)(tree_style_1.classes.root, tree_style_1.classes.levelBlock, props.className), "data-show-line": showLine, "data-sortable": sortable, children: [searchable &&
55
+ return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: (0, tree_style_1.useStyle)({ indent }), className: (0, utils_1.clsx)(tree_style_1.classes.root, props.className), "data-show-line": showLine, children: [searchable &&
61
56
  (0, jsx_runtime_1.jsx)(input_1.Input, { className: tree_style_1.classes.search, prefix: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faMagnifyingGlass_1.faMagnifyingGlass }), placeholder: "\u641C\u7D22", value: innerSearchValue.current, ...searchInputProps, onChange: e => {
62
57
  searchInputProps?.onChange?.(e);
63
58
  setInnerSearchValue(e.target.value);
64
- } }), (0, jsx_runtime_1.jsx)(selectionContext_1.SelectionContext, { ...selectionContextProps, children: (0, jsx_runtime_1.jsx)(TreeContext, { value: (0, react_2.useMemo)(() => ({
59
+ } }), (0, jsx_runtime_1.jsx)(selectionContext_1.SelectionContext, { ...{
60
+ options: actualTreeNodes, primaryKey, childrenKey, relation, integration,
61
+ multiple, defaultValue, value, onChange, disabled
62
+ }, children: (0, jsx_runtime_1.jsx)(TreeContext, { value: (0, react_2.useMemo)(() => ({
65
63
  expandedSet, toggleExpanded, indent, renderExpandIcon, clickLabelToExpand,
66
64
  showCheckbox, readOnly, disabled
67
65
  }), [
68
66
  expandedSet, indent, renderExpandIcon, clickLabelToExpand,
69
67
  showCheckbox, readOnly, disabled
70
- ]), children: (0, jsx_runtime_1.jsx)(treeDnd_1.TreeDnd, { sortable: sortable, showDragHandle: showDragHandle, onSort: onSort, containerRef: containerRef, children: (0, react_2.useMemo)(() => {
68
+ ]), children: (0, jsx_runtime_1.jsx)(treeDnd_1.TreeDnd, { sortable: sortable, showDragHandle: showDragHandle, onSort: onSort, children: (0, react_2.useMemo)(() => {
71
69
  if (!filteredTreeData?.length) {
72
70
  return null;
73
71
  }
74
72
  const fn = (arr) => {
75
- return arr?.map(({ _parentId, ...nodeProps }, i) => {
76
- const currentValue = nodeProps[primaryKey];
73
+ return arr?.map(({ _isLast, _parentId, ...nodeProps }) => {
74
+ const currentId = nodeProps[primaryKey];
77
75
  const label = nodeProps[labelKey];
78
- return ((0, react_1.createElement)(treeNode_1.TreeNode, { ...nodeProps, key: currentValue, value: currentValue, label: typeof label === 'string' && deferredSearchValue
76
+ const children = nodeProps[childrenKey];
77
+ delete nodeProps[primaryKey];
78
+ delete nodeProps[labelKey];
79
+ delete nodeProps[childrenKey];
80
+ return ((0, react_1.createElement)(treeNode_1.TreeNode, { ...nodeProps, key: currentId, id: currentId, label: typeof label === 'string' && deferredSearchValue
79
81
  ? (0, jsx_runtime_1.jsx)(highlight_1.Highlight, { keywords: deferredSearchValue.split(' '), children: label })
80
- : label }, fn(nodeProps[childrenKey])));
82
+ : label }, fn(children)));
81
83
  });
82
84
  };
83
85
  return fn(filteredTreeData);
84
- }, [filteredTreeData]) }) }) })] }));
86
+ }, [filteredTreeData, primaryKey, labelKey, childrenKey, deferredSearchValue]) }) }) })] }));
85
87
  });
86
88
  exports.Tree.Node = treeNode_1.TreeNode;
@@ -2,20 +2,16 @@ export declare const classes: {
2
2
  label: string;
3
3
  search: string;
4
4
  prefix: string;
5
+ suffix: string;
6
+ checkbox: string;
5
7
  icon: string;
6
8
  expand: string;
7
9
  indent: string;
8
10
  node: string;
9
- checkbox: string;
10
- container: string;
11
- suffix: string;
12
11
  contentWrap: string;
13
- levelBlock: string;
14
- dragHandle: string;
15
- dragMask: string;
16
- dragMaskPrev: string;
17
- dragMaskNext: string;
18
12
  } & {
19
13
  root: string;
20
14
  };
21
- export declare const style: () => import("@emotion/react").SerializedStyles;
15
+ export declare function useStyle({ indent }: {
16
+ indent: number;
17
+ }): import("@emotion/react").SerializedStyles[];