@headless-tree/core 0.0.0-20250630160730 → 0.0.0-20250716233347

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,6 +1,12 @@
1
1
  # @headless-tree/core
2
2
 
3
- ## 0.0.0-20250630160730
3
+ ## 0.0.0-20250716233347
4
+
5
+ ### Patch Changes
6
+
7
+ - b413f74: Fix `aria-posinset` and `aria-level` to be 1-based indexing
8
+
9
+ ## 1.2.1
4
10
 
5
11
  ### Patch Changes
6
12
 
@@ -12,9 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.syncDataLoaderFeature = void 0;
13
13
  const utils_1 = require("../../utils");
14
14
  const errors_1 = require("../../utilities/errors");
15
+ const undefErrorMessage = "sync dataLoader returned undefined";
15
16
  const promiseErrorMessage = "sync dataLoader returned promise";
16
17
  const unpromise = (data) => {
17
- if (!data || (typeof data === "object" && "then" in data)) {
18
+ if (!data) {
19
+ throw (0, errors_1.throwError)(undefErrorMessage);
20
+ }
21
+ if (typeof data === "object" && "then" in data) {
18
22
  throw (0, errors_1.throwError)(promiseErrorMessage);
19
23
  }
20
24
  return data;
@@ -107,7 +107,7 @@ exports.treeFeature = {
107
107
  getKey: ({ itemId }) => itemId, // TODO apply to all stories to use
108
108
  getProps: ({ item, prev }) => {
109
109
  const itemMeta = item.getItemMeta();
110
- return Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev()), { ref: item.registerElement, role: "treeitem", "aria-setsize": itemMeta.setSize, "aria-posinset": itemMeta.posInSet, "aria-selected": "false", "aria-label": item.getItemName(), "aria-level": itemMeta.level, tabIndex: item.isFocused() ? 0 : -1, onClick: (e) => {
110
+ return Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev()), { ref: item.registerElement, role: "treeitem", "aria-setsize": itemMeta.setSize, "aria-posinset": itemMeta.posInSet + 1, "aria-selected": "false", "aria-label": item.getItemName(), "aria-level": itemMeta.level + 1, tabIndex: item.isFocused() ? 0 : -1, onClick: (e) => {
111
111
  item.setFocused();
112
112
  item.primaryAction();
113
113
  if (e.ctrlKey || e.shiftKey || e.metaKey) {
@@ -9,9 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { makeStateUpdater } from "../../utils";
11
11
  import { throwError } from "../../utilities/errors";
12
+ const undefErrorMessage = "sync dataLoader returned undefined";
12
13
  const promiseErrorMessage = "sync dataLoader returned promise";
13
14
  const unpromise = (data) => {
14
- if (!data || (typeof data === "object" && "then" in data)) {
15
+ if (!data) {
16
+ throw throwError(undefErrorMessage);
17
+ }
18
+ if (typeof data === "object" && "then" in data) {
15
19
  throw throwError(promiseErrorMessage);
16
20
  }
17
21
  return data;
@@ -104,7 +104,7 @@ export const treeFeature = {
104
104
  getKey: ({ itemId }) => itemId, // TODO apply to all stories to use
105
105
  getProps: ({ item, prev }) => {
106
106
  const itemMeta = item.getItemMeta();
107
- return Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev()), { ref: item.registerElement, role: "treeitem", "aria-setsize": itemMeta.setSize, "aria-posinset": itemMeta.posInSet, "aria-selected": "false", "aria-label": item.getItemName(), "aria-level": itemMeta.level, tabIndex: item.isFocused() ? 0 : -1, onClick: (e) => {
107
+ return Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev()), { ref: item.registerElement, role: "treeitem", "aria-setsize": itemMeta.setSize, "aria-posinset": itemMeta.posInSet + 1, "aria-selected": "false", "aria-label": item.getItemName(), "aria-level": itemMeta.level + 1, tabIndex: item.isFocused() ? 0 : -1, onClick: (e) => {
108
108
  item.setFocused();
109
109
  item.primaryAction();
110
110
  if (e.ctrlKey || e.shiftKey || e.metaKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@headless-tree/core",
3
- "version": "0.0.0-20250630160730",
3
+ "version": "0.0.0-20250716233347",
4
4
  "main": "lib/cjs/index.js",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/esm/index.d.ts",
@@ -2,9 +2,13 @@ import { FeatureImplementation } from "../../types/core";
2
2
  import { makeStateUpdater } from "../../utils";
3
3
  import { throwError } from "../../utilities/errors";
4
4
 
5
+ const undefErrorMessage = "sync dataLoader returned undefined";
5
6
  const promiseErrorMessage = "sync dataLoader returned promise";
6
7
  const unpromise = <T>(data: T | Promise<T>): T => {
7
- if (!data || (typeof data === "object" && "then" in data)) {
8
+ if (!data) {
9
+ throw throwError(undefErrorMessage);
10
+ }
11
+ if (typeof data === "object" && "then" in data) {
8
12
  throw throwError(promiseErrorMessage);
9
13
  }
10
14
  return data;
@@ -139,10 +139,10 @@ export const treeFeature: FeatureImplementation<any> = {
139
139
  ref: item.registerElement,
140
140
  role: "treeitem",
141
141
  "aria-setsize": itemMeta.setSize,
142
- "aria-posinset": itemMeta.posInSet,
142
+ "aria-posinset": itemMeta.posInSet + 1,
143
143
  "aria-selected": "false",
144
144
  "aria-label": item.getItemName(),
145
- "aria-level": itemMeta.level,
145
+ "aria-level": itemMeta.level + 1,
146
146
  tabIndex: item.isFocused() ? 0 : -1,
147
147
  onClick: (e: MouseEvent) => {
148
148
  item.setFocused();
@@ -235,8 +235,8 @@ describe("core-feature/selections", () => {
235
235
  it("generates item props for random item", () => {
236
236
  expect(tree.instance.getItemInstance("x2").getProps()).toEqual({
237
237
  "aria-label": "x2",
238
- "aria-level": 0,
239
- "aria-posinset": 1,
238
+ "aria-level": 1,
239
+ "aria-posinset": 2,
240
240
  "aria-selected": "false",
241
241
  "aria-setsize": 4,
242
242
  onClick: expect.any(Function),
@@ -249,8 +249,8 @@ describe("core-feature/selections", () => {
249
249
  it("generates item props for focused", () => {
250
250
  expect(tree.instance.getItemInstance("x1").getProps()).toEqual({
251
251
  "aria-label": "x1",
252
- "aria-level": 0,
253
- "aria-posinset": 0,
252
+ "aria-level": 1,
253
+ "aria-posinset": 1,
254
254
  "aria-selected": "false",
255
255
  "aria-setsize": 4,
256
256
  onClick: expect.any(Function),