@headless-tree/core 0.0.0-20250915162508 → 0.0.0-20250916205935

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.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # @headless-tree/core
2
2
 
3
- ## 0.0.0-20250915162508
3
+ ## 0.0.0-20250916205935
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 72e714b: all NPM deployments will now publish with provenance
8
+ - 6693986: fixed an issue where async data loaders cause calling `item.getItemData()` outside of the component calling `useTree()` to cause a React warning log (#158)
8
9
  - 7a7424f: fixed incorrect exports definition in package.json for require/cjs imports (#161)
9
10
  - 215ab4b: add a new symbol that can be used in hotkey configurations "metaorcontrol" that will trigger if either any windows control key or mac meta key is pressed (#141)
10
11
  - 51b0dea: Added `isUnorderedDragTarget` as alternative to `isDragTarget` for easier detection of drag type
package/dist/index.js CHANGED
@@ -1169,7 +1169,7 @@ var asyncDataLoaderFeature = {
1169
1169
  return dataRef.current.itemData[itemId];
1170
1170
  }
1171
1171
  if (!tree.getState().loadingItemData.includes(itemId) && !skipFetch) {
1172
- loadItemData(tree, itemId);
1172
+ setTimeout(() => loadItemData(tree, itemId));
1173
1173
  }
1174
1174
  return (_b = (_a = config.createLoadingItemData) == null ? void 0 : _a.call(config)) != null ? _b : null;
1175
1175
  },
@@ -1181,7 +1181,7 @@ var asyncDataLoaderFeature = {
1181
1181
  if (tree.getState().loadingItemChildrens.includes(itemId) || skipFetch) {
1182
1182
  return [];
1183
1183
  }
1184
- loadChildrenIds(tree, itemId);
1184
+ setTimeout(() => loadChildrenIds(tree, itemId));
1185
1185
  return [];
1186
1186
  }
1187
1187
  },
package/dist/index.mjs CHANGED
@@ -1125,7 +1125,7 @@ var asyncDataLoaderFeature = {
1125
1125
  return dataRef.current.itemData[itemId];
1126
1126
  }
1127
1127
  if (!tree.getState().loadingItemData.includes(itemId) && !skipFetch) {
1128
- loadItemData(tree, itemId);
1128
+ setTimeout(() => loadItemData(tree, itemId));
1129
1129
  }
1130
1130
  return (_b = (_a = config.createLoadingItemData) == null ? void 0 : _a.call(config)) != null ? _b : null;
1131
1131
  },
@@ -1137,7 +1137,7 @@ var asyncDataLoaderFeature = {
1137
1137
  if (tree.getState().loadingItemChildrens.includes(itemId) || skipFetch) {
1138
1138
  return [];
1139
1139
  }
1140
- loadChildrenIds(tree, itemId);
1140
+ setTimeout(() => loadChildrenIds(tree, itemId));
1141
1141
  return [];
1142
1142
  }
1143
1143
  },
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "checkbox",
14
14
  "hook"
15
15
  ],
16
- "version": "0.0.0-20250915162508",
16
+ "version": "0.0.0-20250916205935",
17
17
  "main": "dist/index.d.ts",
18
18
  "module": "dist/index.mjs",
19
19
  "types": "dist/index.d.mts",
@@ -46,6 +46,7 @@ describe("core-feature/selections", () => {
46
46
  );
47
47
  const setLoadingItemData = tree.mockedHandler("setLoadingItemData");
48
48
  tree.do.selectItem("x12");
49
+ await tree.do.awaitNextTick();
49
50
  expect(setLoadingItemChildrens).toHaveBeenCalledWith(["x12"]);
50
51
  expect(setLoadingItemData).not.toHaveBeenCalled();
51
52
  await tree.resolveAsyncVisibleItems();
@@ -118,7 +118,7 @@ export const asyncDataLoaderFeature: FeatureImplementation = {
118
118
  }
119
119
 
120
120
  if (!tree.getState().loadingItemData.includes(itemId) && !skipFetch) {
121
- loadItemData(tree, itemId);
121
+ setTimeout(() => loadItemData(tree, itemId));
122
122
  }
123
123
 
124
124
  return config.createLoadingItemData?.() ?? null;
@@ -134,7 +134,7 @@ export const asyncDataLoaderFeature: FeatureImplementation = {
134
134
  return [];
135
135
  }
136
136
 
137
- loadChildrenIds(tree, itemId);
137
+ setTimeout(() => loadChildrenIds(tree, itemId));
138
138
 
139
139
  return [];
140
140
  },
@@ -135,4 +135,10 @@ export class TestTreeDo<T> {
135
135
  "function called with inconsistent parameters",
136
136
  ).toBeOneOf([0, 1]);
137
137
  }
138
+
139
+ async awaitNextTick() {
140
+ await new Promise((r) => {
141
+ setTimeout(r);
142
+ });
143
+ }
138
144
  }
@@ -87,10 +87,9 @@ export class TestTree<T = string> {
87
87
 
88
88
  static async resolveAsyncLoaders() {
89
89
  do {
90
+ await vi.advanceTimersToNextTimerAsync();
90
91
  TestTree.asyncLoaderResolvers.shift()?.();
91
- await new Promise<void>((r) => {
92
- setTimeout(r);
93
- });
92
+ await vi.advanceTimersToNextTimerAsync();
94
93
  } while (TestTree.asyncLoaderResolvers.length);
95
94
  }
96
95