react-arborist 3.7.0 → 3.8.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 (86) hide show
  1. package/dist/main/components/cursor.js +1 -2
  2. package/dist/main/components/default-container.js +31 -2
  3. package/dist/main/components/default-cursor.js +1 -1
  4. package/dist/main/components/default-drag-preview.d.ts +1 -1
  5. package/dist/main/components/default-drag-preview.js +1 -1
  6. package/dist/main/components/default-row.d.ts +1 -1
  7. package/dist/main/components/default-row.js +1 -1
  8. package/dist/main/components/list-outer-element.js +1 -1
  9. package/dist/main/components/provider.d.ts +1 -1
  10. package/dist/main/components/provider.js +2 -2
  11. package/dist/main/components/provider.test.js +70 -0
  12. package/dist/main/components/row-container.d.ts +1 -1
  13. package/dist/main/components/row-container.js +2 -3
  14. package/dist/main/dnd/drag-hook.js +1 -0
  15. package/dist/main/hooks/use-validated-props.js +1 -2
  16. package/dist/main/interfaces/node-api.js +4 -1
  17. package/dist/main/interfaces/tree-api.d.ts +27 -5
  18. package/dist/main/interfaces/tree-api.js +98 -14
  19. package/dist/main/interfaces/tree-api.test.js +31 -0
  20. package/dist/main/state/drag-slice.js +1 -2
  21. package/dist/main/types/state.d.ts +1 -1
  22. package/dist/main/types/tree-props.d.ts +3 -1
  23. package/dist/module/components/cursor.js +1 -2
  24. package/dist/module/components/default-container.js +32 -3
  25. package/dist/module/components/default-cursor.js +1 -1
  26. package/dist/module/components/default-drag-preview.d.ts +1 -1
  27. package/dist/module/components/default-drag-preview.js +1 -1
  28. package/dist/module/components/default-row.d.ts +1 -1
  29. package/dist/module/components/default-row.js +1 -1
  30. package/dist/module/components/list-outer-element.js +1 -1
  31. package/dist/module/components/provider.d.ts +1 -1
  32. package/dist/module/components/provider.js +4 -4
  33. package/dist/module/components/provider.test.js +71 -1
  34. package/dist/module/components/row-container.d.ts +1 -1
  35. package/dist/module/components/row-container.js +2 -3
  36. package/dist/module/dnd/compute-drop.js +1 -1
  37. package/dist/module/dnd/drag-hook.js +1 -0
  38. package/dist/module/hooks/use-validated-props.js +1 -2
  39. package/dist/module/interfaces/node-api.js +4 -1
  40. package/dist/module/interfaces/tree-api.d.ts +27 -5
  41. package/dist/module/interfaces/tree-api.js +98 -14
  42. package/dist/module/interfaces/tree-api.test.js +31 -0
  43. package/dist/module/state/drag-slice.js +1 -2
  44. package/dist/module/types/state.d.ts +1 -1
  45. package/dist/module/types/tree-props.d.ts +3 -1
  46. package/package.json +27 -27
  47. package/src/components/cursor.tsx +1 -2
  48. package/src/components/default-container.tsx +40 -19
  49. package/src/components/default-cursor.tsx +1 -5
  50. package/src/components/default-drag-preview.tsx +3 -16
  51. package/src/components/default-node.tsx +0 -1
  52. package/src/components/default-row.tsx +2 -13
  53. package/src/components/drag-preview-container.tsx +1 -1
  54. package/src/components/list-inner-element.tsx +1 -1
  55. package/src/components/list-outer-element.tsx +2 -3
  56. package/src/components/provider.test.tsx +85 -9
  57. package/src/components/provider.tsx +8 -23
  58. package/src/components/row-container.tsx +4 -9
  59. package/src/components/tree.tsx +2 -6
  60. package/src/context.ts +2 -3
  61. package/src/data/create-index.ts +0 -1
  62. package/src/data/create-list.ts +1 -2
  63. package/src/data/create-root.ts +2 -9
  64. package/src/data/simple-tree.ts +5 -3
  65. package/src/dnd/compute-drop.ts +6 -15
  66. package/src/dnd/drag-hook.ts +1 -0
  67. package/src/dnd/measure-hover.ts +2 -6
  68. package/src/dnd/outer-drop-hook.ts +1 -1
  69. package/src/hooks/use-fresh-node.ts +0 -1
  70. package/src/hooks/use-simple-tree.ts +2 -8
  71. package/src/hooks/use-validated-props.ts +4 -8
  72. package/src/interfaces/node-api.ts +2 -2
  73. package/src/interfaces/tree-api.test.ts +35 -0
  74. package/src/interfaces/tree-api.ts +103 -36
  75. package/src/state/dnd-slice.ts +1 -1
  76. package/src/state/drag-slice.ts +2 -5
  77. package/src/state/edit-slice.ts +1 -4
  78. package/src/state/focus-slice.ts +1 -1
  79. package/src/state/open-slice.ts +2 -5
  80. package/src/state/selection-slice.ts +2 -6
  81. package/src/types/handlers.ts +1 -3
  82. package/src/types/renderers.ts +0 -1
  83. package/src/types/state.ts +1 -1
  84. package/src/types/tree-props.ts +6 -10
  85. package/src/types/utils.ts +2 -3
  86. package/src/utils.ts +5 -14
@@ -9,9 +9,8 @@ export type Identity = string | IdObj | null;
9
9
 
10
10
  export type BoolFunc<T> = (data: T) => boolean;
11
11
 
12
- export type ActionTypes<
13
- Actions extends { [name: string]: (...args: any[]) => AnyAction }
14
- > = ReturnType<Actions[keyof Actions]>;
12
+ export type ActionTypes<Actions extends { [name: string]: (...args: any[]) => AnyAction }> =
13
+ ReturnType<Actions[keyof Actions]>;
15
14
 
16
15
  export type SelectOptions = { multi?: boolean; contiguous?: boolean };
17
16
 
package/src/utils.ts CHANGED
@@ -49,10 +49,7 @@ export function dfs(node: NodeApi<any>, id: string): NodeApi<any> | null {
49
49
  return null;
50
50
  }
51
51
 
52
- export function walk(
53
- node: NodeApi<any>,
54
- fn: (node: NodeApi<any>) => void
55
- ): void {
52
+ export function walk(node: NodeApi<any>, fn: (node: NodeApi<any>) => void): void {
56
53
  fn(node);
57
54
  if (node.children) {
58
55
  for (let child of node.children) {
@@ -110,15 +107,12 @@ function prevItem(list: HTMLElement[], index: number) {
110
107
  function getFocusable(target: HTMLElement) {
111
108
  return Array.from(
112
109
  document.querySelectorAll(
113
- 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)'
114
- )
110
+ 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)',
111
+ ),
115
112
  ).filter((e) => e === target || !target.contains(e)) as HTMLElement[];
116
113
  }
117
114
 
118
- export function access<T = boolean>(
119
- obj: any,
120
- accessor: string | boolean | Function
121
- ): T {
115
+ export function access<T = boolean>(obj: any, accessor: string | boolean | Function): T {
122
116
  if (typeof accessor === "boolean") return accessor as unknown as T;
123
117
  if (typeof accessor === "string") return obj[accessor] as T;
124
118
  return accessor(obj) as T;
@@ -234,10 +228,7 @@ const defaultTreeLineChars: TreeLineChars = {
234
228
  * getTreeLinePrefix(node, { last: "`- ", middle: "|- ", pipe: "|", blank: " " })
235
229
  * ```
236
230
  */
237
- export function getTreeLinePrefix(
238
- node: NodeApi<any>,
239
- chars: Partial<TreeLineChars> = {}
240
- ): string {
231
+ export function getTreeLinePrefix(node: NodeApi<any>, chars: Partial<TreeLineChars> = {}): string {
241
232
  const c = { ...defaultTreeLineChars, ...chars };
242
233
  if (node.level === 0) return "";
243
234