@canlooks/can-ui 0.0.96 → 0.0.98

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 (83) 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 +5 -1
  11. package/dist/cjs/components/menuItem/menuItem.js +1 -1
  12. package/dist/cjs/components/menuItem/menuItem.style.d.ts +2 -2
  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/popper/popper.js +26 -21
  16. package/dist/cjs/components/progress/progress.js +2 -1
  17. package/dist/cjs/components/progress/progress.style.d.ts +1 -1
  18. package/dist/cjs/components/resizable/resizable.style.d.ts +1 -1
  19. package/dist/cjs/components/segmented/segmented.style.d.ts +1 -1
  20. package/dist/cjs/components/select/select.d.ts +1 -1
  21. package/dist/cjs/components/selectionContext/selectionContext.d.ts +2 -0
  22. package/dist/cjs/components/selectionContext/selectionHook.js +2 -1
  23. package/dist/cjs/components/snackbarBase/snackbarBase.style.d.ts +1 -1
  24. package/dist/cjs/components/status/status.style.d.ts +1 -1
  25. package/dist/cjs/components/tabs/tabs.style.d.ts +4 -4
  26. package/dist/cjs/components/tag/tag.style.d.ts +2 -2
  27. package/dist/cjs/components/transfer/transfer.style.d.ts +2 -2
  28. package/dist/cjs/components/tree/tree.d.ts +2 -2
  29. package/dist/cjs/components/tree/tree.js +15 -13
  30. package/dist/cjs/components/tree/tree.style.d.ts +5 -9
  31. package/dist/cjs/components/tree/tree.style.js +96 -206
  32. package/dist/cjs/components/tree/treeDnd.d.ts +3 -7
  33. package/dist/cjs/components/tree/treeDnd.js +7 -19
  34. package/dist/cjs/components/tree/treeDnd.style.d.ts +15 -0
  35. package/dist/cjs/components/tree/treeDnd.style.js +191 -0
  36. package/dist/cjs/components/tree/treeNode.d.ts +4 -4
  37. package/dist/cjs/components/tree/treeNode.js +82 -69
  38. package/dist/cjs/components/upload/upload.style.d.ts +1 -1
  39. package/dist/cjs/utils/dnd.d.ts +11 -3
  40. package/dist/cjs/utils/dnd.js +45 -2
  41. package/dist/cjs/utils/utils.d.ts +1 -1
  42. package/dist/esm/components/accordion/accordion.style.d.ts +1 -1
  43. package/dist/esm/components/alert/alert.style.d.ts +3 -3
  44. package/dist/esm/components/button/button.style.d.ts +1 -1
  45. package/dist/esm/components/checkboxBase/checkboxBase.style.d.ts +2 -2
  46. package/dist/esm/components/clickAway/clickAway.d.ts +27 -27
  47. package/dist/esm/components/dataGrid/dataGrid.style.d.ts +1 -1
  48. package/dist/esm/components/descriptions/descriptions.style.d.ts +1 -1
  49. package/dist/esm/components/dialog/dialog.style.d.ts +3 -3
  50. package/dist/esm/components/inputBase/inputBase.style.d.ts +2 -2
  51. package/dist/esm/components/menuItem/menuItem.d.ts +5 -1
  52. package/dist/esm/components/menuItem/menuItem.js +1 -1
  53. package/dist/esm/components/menuItem/menuItem.style.d.ts +2 -2
  54. package/dist/esm/components/palette/palette.style.d.ts +1 -1
  55. package/dist/esm/components/pickerDialog/pickerDialog.style.d.ts +1 -1
  56. package/dist/esm/components/popper/popper.js +26 -21
  57. package/dist/esm/components/progress/progress.js +2 -1
  58. package/dist/esm/components/progress/progress.style.d.ts +1 -1
  59. package/dist/esm/components/resizable/resizable.style.d.ts +1 -1
  60. package/dist/esm/components/segmented/segmented.style.d.ts +1 -1
  61. package/dist/esm/components/select/select.d.ts +1 -1
  62. package/dist/esm/components/selectionContext/selectionContext.d.ts +2 -0
  63. package/dist/esm/components/selectionContext/selectionHook.js +2 -1
  64. package/dist/esm/components/snackbarBase/snackbarBase.style.d.ts +1 -1
  65. package/dist/esm/components/status/status.style.d.ts +1 -1
  66. package/dist/esm/components/tabs/tabs.style.d.ts +4 -4
  67. package/dist/esm/components/tag/tag.style.d.ts +2 -2
  68. package/dist/esm/components/transfer/transfer.style.d.ts +2 -2
  69. package/dist/esm/components/tree/tree.d.ts +2 -2
  70. package/dist/esm/components/tree/tree.js +18 -16
  71. package/dist/esm/components/tree/tree.style.d.ts +5 -9
  72. package/dist/esm/components/tree/tree.style.js +95 -206
  73. package/dist/esm/components/tree/treeDnd.d.ts +3 -7
  74. package/dist/esm/components/tree/treeDnd.js +8 -20
  75. package/dist/esm/components/tree/treeDnd.style.d.ts +15 -0
  76. package/dist/esm/components/tree/treeDnd.style.js +186 -0
  77. package/dist/esm/components/tree/treeNode.d.ts +4 -4
  78. package/dist/esm/components/tree/treeNode.js +82 -69
  79. package/dist/esm/components/upload/upload.style.d.ts +1 -1
  80. package/dist/esm/utils/dnd.d.ts +11 -3
  81. package/dist/esm/utils/dnd.js +44 -2
  82. package/dist/esm/utils/utils.d.ts +1 -1
  83. 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;
@@ -29,4 +33,4 @@ export interface MenuItemProps extends Omit<DivProps, 'prefix'> {
29
33
  expanded?: boolean;
30
34
  onExpandedChange?(expanded: boolean): void;
31
35
  }
32
- export declare const MenuItem: React.MemoExoticComponent<({ value, size, color, emphasized, selected, focused, disabled, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, _level, indent, expandIcon, defaultExpanded, expanded, onExpandedChange, ...props }: MenuItemProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
36
+ export declare const MenuItem: React.MemoExoticComponent<({ value, size, color, emphasized, selected, focused, disabled, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, scrollHere, _level, indent, expandIcon, defaultExpanded, expanded, onExpandedChange, ...props }: MenuItemProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -11,7 +11,7 @@ const menu_1 = require("../menu");
11
11
  const transitionBase_1 = require("../transitionBase");
12
12
  const icon_1 = require("../icon");
13
13
  const faChevronDown_1 = require("@fortawesome/free-solid-svg-icons/faChevronDown");
14
- exports.MenuItem = (0, react_1.memo)(({ value, size, color = 'primary', emphasized = false, selected, focused = false, disabled = false, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, _level = 0, indent, expandIcon, defaultExpanded = false, expanded, onExpandedChange, ...props }) => {
14
+ exports.MenuItem = (0, react_1.memo)(({ value, size, color = 'primary', emphasized = false, selected, focused = false, disabled = false, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, scrollHere, _level = 0, indent, expandIcon, defaultExpanded = false, expanded, onExpandedChange, ...props }) => {
15
15
  const context = (0, menu_1.useMenuContext)();
16
16
  size ??= context.size;
17
17
  showCheckbox ??= context.showCheckbox;
@@ -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
  } & {
@@ -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
  } & {
@@ -360,51 +360,54 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
360
360
  const hoverable = triggersSet.has('hover');
361
361
  const enterTimeout = (0, react_1.useRef)(void 0);
362
362
  const leaveTimeout = (0, react_1.useRef)(void 0);
363
- const hoverStack = (0, react_1.useRef)(0);
364
- const pointerEnter = () => {
365
- if (hoverStack.current++) {
366
- return;
367
- }
363
+ const isOvering = (0, react_1.useRef)(false);
364
+ const pointerEnterFn = (0, react_1.useCallback)(() => {
368
365
  clearTimeout(leaveTimeout.current);
369
366
  mouseEnterDelay
370
367
  ? enterTimeout.current = setTimeout(() => setInnerOpen(true), mouseEnterDelay)
371
368
  : setInnerOpen(true);
372
- };
373
- const pointerLeave = () => {
374
- if (--hoverStack.current) {
375
- return;
376
- }
369
+ }, [mouseEnterDelay]);
370
+ const pointerLeaveFn = (0, react_1.useCallback)(() => {
377
371
  clearTimeout(enterTimeout.current);
378
372
  mouseLeaveDelay
379
373
  ? leaveTimeout.current = setTimeout(() => setInnerOpen(false), mouseLeaveDelay)
380
374
  : setInnerOpen(false);
381
- };
382
- // 绑定锚点元素
375
+ }, [mouseLeaveDelay]);
383
376
  (0, react_1.useEffect)(() => {
384
377
  if (!hoverable) {
385
378
  return;
386
379
  }
380
+ const pointerOver = (e) => {
381
+ if (!isOvering.current && e.target === anchorRef.current) {
382
+ isOvering.current = true;
383
+ pointerEnterFn();
384
+ }
385
+ };
386
+ const pointerLeave = () => {
387
+ isOvering.current = false;
388
+ pointerLeaveFn();
389
+ };
387
390
  const anchorEl = anchorRef.current;
388
- anchorEl.addEventListener('pointerenter', pointerEnter);
391
+ anchorEl.addEventListener('pointerover', pointerOver);
389
392
  anchorEl.addEventListener('pointerleave', pointerLeave);
390
393
  return () => {
391
- anchorEl.removeEventListener('pointerenter', pointerEnter);
394
+ anchorEl.removeEventListener('pointerover', pointerOver);
392
395
  anchorEl.removeEventListener('pointerleave', pointerLeave);
393
396
  };
394
- }, [hoverable]);
397
+ }, []);
395
398
  // 绑定弹框元素,鼠标移入弹框也要保持弹框打开
396
399
  (0, react_1.useEffect)(() => {
397
400
  if (!hoverable || !innerPopperRef.current) {
398
401
  return;
399
402
  }
400
403
  const popperEl = innerPopperRef.current;
401
- popperEl.addEventListener('pointerenter', pointerEnter);
402
- popperEl.addEventListener('pointerleave', pointerLeave);
404
+ popperEl.addEventListener('pointerenter', pointerEnterFn);
405
+ popperEl.addEventListener('pointerleave', pointerLeaveFn);
403
406
  return () => {
404
- popperEl.removeEventListener('pointerenter', pointerEnter);
405
- popperEl.removeEventListener('pointerleave', pointerLeave);
407
+ popperEl.removeEventListener('pointerenter', pointerEnterFn);
408
+ popperEl.removeEventListener('pointerleave', pointerLeaveFn);
406
409
  };
407
- }, [innerOpen.current]);
410
+ }, [innerOpen.current, mouseLeaveDelay]);
408
411
  /**
409
412
  * focus相关
410
413
  */
@@ -513,7 +516,9 @@ function Popper({ ref, popperRef, anchorElement, container = document.body, effe
513
516
  }), [innerOpen.current, autoClose]);
514
517
  const childRef = (0, react_1.useCallback)((0, utils_1.cloneRef)(children?.props.ref, anchorRef, ref), [children?.props.ref, ref]);
515
518
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, react_1.isValidElement)(children)
516
- ? (0, react_1.cloneElement)(children, { ref: childRef })
519
+ ? (0, react_1.cloneElement)(children, {
520
+ ref: childRef
521
+ })
517
522
  : children, renderedOnce.current && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(clickAway_1.ClickAway, { disabled: !clickable && !enterable && !contextMenuable,
518
523
  // 右键菜单点击anchor需要关闭弹框
519
524
  targets: () => contextMenuEvent.current ? null : anchorRef.current, onClickAway: onClickAway, children: (0, jsx_runtime_1.jsx)("div", { ...props, ref: innerPopperRef, css: popper_style_1.style, className: (0, utils_1.clsx)(popper_style_1.classes.root, props.className), style: {
@@ -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
  };
@@ -32,4 +32,4 @@ export declare const Select: {
32
32
  <O extends MenuOptionType, V extends Id = Id>(props: SelectProps<O, V>): ReactElement;
33
33
  Option: typeof MenuItem;
34
34
  };
35
- export declare const Option: import("react").MemoExoticComponent<({ value, size, color, emphasized, selected, focused, disabled, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, _level, indent, expandIcon, defaultExpanded, expanded, onExpandedChange, ...props }: import("../menuItem").MenuItemProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
35
+ export declare const Option: import("react").MemoExoticComponent<({ value, size, color, emphasized, selected, focused, disabled, showCheckbox, checkboxProps, ellipsis, prefix, label, suffix, searchToken, scrollHere, _level, indent, expandIcon, defaultExpanded, expanded, onExpandedChange, ...props }: import("../menuItem").MenuItemProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
@@ -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[];