@dxos/react-ui-list 0.7.5-labs.ea4b4c2 → 0.7.5-labs.f400bbc
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/dist/lib/browser/index.mjs +18 -1
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +17 -1
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +18 -1
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/List/List.d.ts +6 -6
- package/dist/types/src/components/List/ListItem.d.ts +5 -5
- package/dist/types/src/components/List/ListItem.d.ts.map +1 -1
- package/dist/types/src/components/List/ListRoot.d.ts +1 -1
- package/dist/types/src/components/List/ListRoot.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.d.ts +1 -2
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tree/TreeItem.d.ts +2 -2
- package/dist/types/src/components/Tree/TreeItem.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/path.d.ts +14 -0
- package/dist/types/src/util/path.d.ts.map +1 -0
- package/dist/types/src/util/path.test.d.ts +2 -0
- package/dist/types/src/util/path.test.d.ts.map +1 -0
- package/package.json +17 -17
- package/src/components/Tree/Tree.stories.tsx +1 -1
- package/src/components/Tree/TreeItem.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/util/index.ts +5 -0
- package/src/util/path.test.ts +24 -0
- package/src/util/path.ts +21 -0
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-list",
|
|
3
|
-
"version": "0.7.5-labs.
|
|
3
|
+
"version": "0.7.5-labs.f400bbc",
|
|
4
4
|
"description": "A list component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "DXOS.org",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./dist/types/src/index.d.ts",
|
|
@@ -26,16 +27,15 @@
|
|
|
26
27
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
|
|
27
28
|
"@preact/signals-core": "^1.6.0",
|
|
28
29
|
"@radix-ui/react-context": "1.1.1",
|
|
29
|
-
"@dxos/debug": "0.7.5-labs.
|
|
30
|
-
"@dxos/echo-schema": "0.7.5-labs.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/react-ui-
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/react-ui-
|
|
37
|
-
"@dxos/util": "0.7.5-labs.
|
|
38
|
-
"@dxos/react-ui-types": "0.7.5-labs.ea4b4c2"
|
|
30
|
+
"@dxos/debug": "0.7.5-labs.f400bbc",
|
|
31
|
+
"@dxos/echo-schema": "0.7.5-labs.f400bbc",
|
|
32
|
+
"@dxos/invariant": "0.7.5-labs.f400bbc",
|
|
33
|
+
"@dxos/live-object": "0.7.5-labs.f400bbc",
|
|
34
|
+
"@dxos/react-ui-text-tooltip": "0.7.5-labs.f400bbc",
|
|
35
|
+
"@dxos/react-ui-attention": "0.7.5-labs.f400bbc",
|
|
36
|
+
"@dxos/log": "0.7.5-labs.f400bbc",
|
|
37
|
+
"@dxos/react-ui-types": "0.7.5-labs.f400bbc",
|
|
38
|
+
"@dxos/util": "0.7.5-labs.f400bbc"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
"react": "~18.2.0",
|
|
46
46
|
"react-dom": "~18.2.0",
|
|
47
47
|
"vite": "5.4.7",
|
|
48
|
-
"@dxos/random": "0.7.5-labs.
|
|
49
|
-
"@dxos/react-ui": "0.7.5-labs.
|
|
50
|
-
"@dxos/react-ui
|
|
51
|
-
"@dxos/storybook-utils": "0.7.5-labs.
|
|
48
|
+
"@dxos/random": "0.7.5-labs.f400bbc",
|
|
49
|
+
"@dxos/react-ui-theme": "0.7.5-labs.f400bbc",
|
|
50
|
+
"@dxos/react-ui": "0.7.5-labs.f400bbc",
|
|
51
|
+
"@dxos/storybook-utils": "0.7.5-labs.f400bbc"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@phosphor-icons/react": "^2.1.5",
|
|
55
55
|
"effect": "^3.12.3",
|
|
56
56
|
"react": "~18.2.0",
|
|
57
57
|
"react-dom": "~18.2.0",
|
|
58
|
-
"@dxos/react-ui": "0.7.5-labs.
|
|
59
|
-
"@dxos/react-ui-theme": "0.7.5-labs.
|
|
58
|
+
"@dxos/react-ui": "0.7.5-labs.f400bbc",
|
|
59
|
+
"@dxos/react-ui-theme": "0.7.5-labs.f400bbc"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
@@ -12,12 +12,12 @@ import React, { useEffect } from 'react';
|
|
|
12
12
|
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
13
13
|
import { faker } from '@dxos/random';
|
|
14
14
|
import { Icon } from '@dxos/react-ui';
|
|
15
|
-
import { Path } from '@dxos/react-ui-mosaic';
|
|
16
15
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
17
16
|
|
|
18
17
|
import { Tree } from './Tree';
|
|
19
18
|
import { type TreeData } from './TreeItem';
|
|
20
19
|
import { createTree, updateState, type TestItem } from './testing';
|
|
20
|
+
import { Path } from '../../util';
|
|
21
21
|
|
|
22
22
|
faker.seed(1234);
|
|
23
23
|
|
|
@@ -218,7 +218,7 @@ export const RawTreeItem = <T = any,>({
|
|
|
218
218
|
aria-labelledby={`${id}__label`}
|
|
219
219
|
parentOf={parentOf?.join(Treegrid.PARENT_OF_SEPARATOR)}
|
|
220
220
|
classNames={mx(
|
|
221
|
-
'grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-
|
|
221
|
+
'grid grid-cols-subgrid col-[tree-row] mbs-0.5 aria-[current]:bg-groupSurface',
|
|
222
222
|
hoverableControls,
|
|
223
223
|
hoverableFocusedKeyboardControls,
|
|
224
224
|
hoverableFocusedWithinControls,
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { Path } from './path';
|
|
8
|
+
|
|
9
|
+
describe('paths', () => {
|
|
10
|
+
test('create', () => {
|
|
11
|
+
const path = Path.create('a', 'b', 'c');
|
|
12
|
+
expect(Path.first(path)).to.eq('a');
|
|
13
|
+
expect(Path.last(path)).to.eq('c');
|
|
14
|
+
|
|
15
|
+
expect(Path.hasRoot(path, 'a')).to.be.true;
|
|
16
|
+
expect(Path.hasRoot(path, 'x')).to.be.false;
|
|
17
|
+
|
|
18
|
+
expect(Path.hasChild(Path.create('a', 'b'), path)).to.be.true;
|
|
19
|
+
expect(Path.hasChild(Path.create('a'), path)).to.be.false;
|
|
20
|
+
|
|
21
|
+
expect(Path.hasDescendent(Path.create('a', 'b'), path)).to.be.true;
|
|
22
|
+
expect(Path.hasDescendent(Path.create('a'), path)).to.be.true;
|
|
23
|
+
});
|
|
24
|
+
});
|
package/src/util/path.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
const SEPARATOR = '~';
|
|
6
|
+
|
|
7
|
+
export const Path = {
|
|
8
|
+
create: (...args: string[]) => args.join(SEPARATOR),
|
|
9
|
+
|
|
10
|
+
parts: (path: string) => path.split(SEPARATOR),
|
|
11
|
+
length: (path: string) => path.split(SEPARATOR).length,
|
|
12
|
+
first: (path: string) => path.split(SEPARATOR)[0] ?? path,
|
|
13
|
+
last: (path: string) => path.split(SEPARATOR).at(-1) ?? path,
|
|
14
|
+
parent: (path: string) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
|
|
15
|
+
|
|
16
|
+
hasRoot: (path: string, id: string) => Path.first(path) === id,
|
|
17
|
+
hasChild: (path: string, compare: string) => Path.parent(compare) === path,
|
|
18
|
+
hasDescendent: (path: string, compare: string) => compare !== path && compare.startsWith(path),
|
|
19
|
+
siblings: (path: string, compare: string) => Path.parent(path) === Path.parent(compare),
|
|
20
|
+
onPath: (path: string, id: string) => Path.parts(path).includes(id),
|
|
21
|
+
};
|