@dxos/plugin-navtree 0.7.2-staging.6d26b2a → 0.7.3-main.2dd075e

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.
@@ -3,18 +3,14 @@
3
3
  //
4
4
 
5
5
  import { type NodeArg } from '@dxos/app-graph';
6
- import { create, S, type ReactiveObject, TypedObject } from '@dxos/echo-schema';
6
+ import { S, TypedObject } from '@dxos/echo-schema';
7
+ import { create, type ReactiveObject } from '@dxos/live-object';
7
8
  import { faker } from '@dxos/random';
9
+ import { range } from '@dxos/util';
8
10
 
9
11
  // TODO(burdon): Reconcile with @dxos/plugin-debug, @dxos/react-ui/testing.
10
12
  // TODO(burdon): Bug when adding stale objects to space (e.g., static objects already added in previous story invocation).
11
13
 
12
- // TODO(burdon): Util.
13
- export const range = <T>(fn: (i: number) => T | undefined, length: number): T[] =>
14
- Array.from({ length })
15
- .map((_, i) => fn(i))
16
- .filter(Boolean) as T[];
17
-
18
14
  // TODO(burdon): Commit to using ECHO to generate all test data? Or convert from raw data?
19
15
  export type TestItem = { id: string; type: string } & Record<string, any>;
20
16
 
@@ -60,12 +56,13 @@ export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
60
56
 
61
57
  project: {
62
58
  createSchema: () =>
63
- class ProjectType extends TypedObject({ typename: 'dxos.test.Project', version: '0.1.0' })({
59
+ class ProjectType extends TypedObject({ typename: 'example.com/type/Project', version: '0.1.0' })({
64
60
  title: S.String,
65
61
  repo: S.String,
66
62
  status: S.String,
67
63
  priority: S.Number,
68
64
  }) {},
65
+
69
66
  createData: () => ({
70
67
  title: faker.commerce.productName(),
71
68
  repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
@@ -101,7 +98,7 @@ export class TestObjectGenerator {
101
98
  }
102
99
 
103
100
  createObjects({ types, length }: { types?: string[]; length: number }) {
104
- return range(() => this.createObject({ types }), length);
101
+ return range(length, () => this.createObject({ types }));
105
102
  }
106
103
  }
107
104
 
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import { type Node } from '@dxos/app-graph';
3
- export declare const NavBarStart: ({ activeNode, popoverAnchorId }: {
4
- activeNode: Node;
5
- popoverAnchorId?: string;
6
- }) => React.JSX.Element;
7
- //# sourceMappingURL=NavBarStart.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavBarStart.d.ts","sourceRoot":"","sources":["../../../../src/components/NavBarStart.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQtD,eAAO,MAAM,WAAW,oCAAqC;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,sBA+B1G,CAAC"}
@@ -1,46 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { Fragment } from 'react';
6
-
7
- import { getGraph, type Node } from '@dxos/app-graph';
8
- import { Popover, toLocalizedString, useTranslation } from '@dxos/react-ui';
9
- import { StackItem } from '@dxos/react-ui-stack';
10
-
11
- import { KEY_BINDING, NAVTREE_PLUGIN } from '../meta';
12
-
13
- const TREE_ITEM_MAIN_HEADING = 'TreeItemMainHeading';
14
-
15
- export const NavBarStart = ({ activeNode, popoverAnchorId }: { activeNode: Node; popoverAnchorId?: string }) => {
16
- const { t } = useTranslation(NAVTREE_PLUGIN);
17
-
18
- const ActionRoot =
19
- popoverAnchorId === `dxos.org/ui/${TREE_ITEM_MAIN_HEADING}/${activeNode.id}` ||
20
- popoverAnchorId === `dxos.org/ui/${KEY_BINDING}/${activeNode.id}`
21
- ? Popover.Anchor
22
- : Fragment;
23
-
24
- const graph = getGraph(activeNode);
25
- const actions = graph.actions(activeNode);
26
- const label = toLocalizedString(activeNode.properties?.label, t);
27
-
28
- const menuTriggerLabel = t('node actions menu invoker label');
29
-
30
- return (
31
- <>
32
- <ActionRoot>
33
- <StackItem.Sigil
34
- icon={activeNode.properties?.icon ?? 'ph--dots-three-vertical--regular'}
35
- attendableId={activeNode.id}
36
- triggerLabel={menuTriggerLabel}
37
- actions={[actions]}
38
- onAction={(action) =>
39
- typeof action.data === 'function' && action.data({ node: action as Node, caller: TREE_ITEM_MAIN_HEADING })
40
- }
41
- />
42
- </ActionRoot>
43
- <StackItem.HeadingLabel attendableId={activeNode.id}>{label}</StackItem.HeadingLabel>
44
- </>
45
- );
46
- };