@dxos/plugin-navtree 0.7.5-main.499c70c → 0.7.5-main.6a330ac

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 (127) hide show
  1. package/dist/lib/browser/app-graph-builder-BL7LRXCM.mjs +44 -0
  2. package/dist/lib/browser/app-graph-builder-BL7LRXCM.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-AOAGODQB.mjs +15 -0
  4. package/dist/lib/browser/chunk-AOAGODQB.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-GXNOX2XZ.mjs +1262 -0
  6. package/dist/lib/browser/chunk-GXNOX2XZ.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-VAXG4OAG.mjs → chunk-KOXMEAOS.mjs} +3 -3
  8. package/dist/lib/browser/{chunk-VAXG4OAG.mjs.map → chunk-KOXMEAOS.mjs.map} +3 -3
  9. package/dist/lib/browser/index.mjs +108 -1199
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/intent-resolver-U25VBFH3.mjs +47 -0
  12. package/dist/lib/browser/intent-resolver-U25VBFH3.mjs.map +7 -0
  13. package/dist/lib/browser/keyboard-MUBRTPI5.mjs +46 -0
  14. package/dist/lib/browser/keyboard-MUBRTPI5.mjs.map +7 -0
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/react-surface-SG4QBA2U.mjs +57 -0
  17. package/dist/lib/browser/react-surface-SG4QBA2U.mjs.map +7 -0
  18. package/dist/lib/browser/state-IEFQTUPG.mjs +108 -0
  19. package/dist/lib/browser/state-IEFQTUPG.mjs.map +7 -0
  20. package/dist/types/src/NavTreePlugin.d.ts +1 -3
  21. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  23. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/capabilities.d.ts +18 -0
  25. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +251 -0
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  28. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  29. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/keyboard.d.ts +4 -0
  31. package/dist/types/src/capabilities/keyboard.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  33. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/state.d.ts +17 -0
  35. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  36. package/dist/types/src/components/CommandsDialog.d.ts +1 -2
  37. package/dist/types/src/components/CommandsDialog.d.ts.map +1 -1
  38. package/dist/types/src/components/CommandsTrigger.d.ts +1 -2
  39. package/dist/types/src/components/CommandsTrigger.d.ts.map +1 -1
  40. package/dist/types/src/components/HaloButton.d.ts +1 -2
  41. package/dist/types/src/components/HaloButton.d.ts.map +1 -1
  42. package/dist/types/src/components/HaloButton.stories.d.ts +1 -2
  43. package/dist/types/src/components/HaloButton.stories.d.ts.map +1 -1
  44. package/dist/types/src/components/L0Menu.d.ts +8 -0
  45. package/dist/types/src/components/L0Menu.d.ts.map +1 -0
  46. package/dist/types/src/components/L1Panels.d.ts +13 -0
  47. package/dist/types/src/components/L1Panels.d.ts.map +1 -0
  48. package/dist/types/src/components/NavTree.d.ts +2 -22
  49. package/dist/types/src/components/NavTree.d.ts.map +1 -1
  50. package/dist/types/src/components/NavTree.stories.d.ts +2 -2
  51. package/dist/types/src/components/NavTree.stories.d.ts.map +1 -1
  52. package/dist/types/src/components/NavTreeContainer.d.ts +4 -3
  53. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  54. package/dist/types/src/components/NavTreeContext.d.ts +4 -0
  55. package/dist/types/src/components/NavTreeContext.d.ts.map +1 -0
  56. package/dist/types/src/components/NavTreeItemAction.d.ts +6 -10
  57. package/dist/types/src/components/NavTreeItemAction.d.ts.map +1 -1
  58. package/dist/types/src/components/NavTreeItemAction.stories.d.ts +2 -7
  59. package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +1 -1
  60. package/dist/types/src/components/NavTreeItemColumns.d.ts +4 -0
  61. package/dist/types/src/components/NavTreeItemColumns.d.ts.map +1 -0
  62. package/dist/types/src/components/NotchStart.d.ts +1 -2
  63. package/dist/types/src/components/NotchStart.d.ts.map +1 -1
  64. package/dist/types/src/components/index.d.ts +3 -0
  65. package/dist/types/src/components/index.d.ts.map +1 -1
  66. package/dist/types/src/components/types.d.ts +26 -0
  67. package/dist/types/src/components/types.d.ts.map +1 -0
  68. package/dist/types/src/events.d.ts +4 -0
  69. package/dist/types/src/events.d.ts.map +1 -0
  70. package/dist/types/src/experimental/Tree.d.ts +8 -8
  71. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  72. package/dist/types/src/experimental/Tree.stories.d.ts +2 -3
  73. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  74. package/dist/types/src/hooks.d.ts +3 -0
  75. package/dist/types/src/hooks.d.ts.map +1 -0
  76. package/dist/types/src/index.d.ts +3 -2
  77. package/dist/types/src/index.d.ts.map +1 -1
  78. package/dist/types/src/meta.d.ts +1 -2
  79. package/dist/types/src/meta.d.ts.map +1 -1
  80. package/dist/types/src/stories/Graph.stories.d.ts +2 -2
  81. package/dist/types/src/stories/Graph.stories.d.ts.map +1 -1
  82. package/dist/types/src/stories/StorybookNavTree.d.ts +3 -0
  83. package/dist/types/src/stories/StorybookNavTree.d.ts.map +1 -0
  84. package/dist/types/src/translations.d.ts +0 -7
  85. package/dist/types/src/translations.d.ts.map +1 -1
  86. package/dist/types/src/types.d.ts +3 -2
  87. package/dist/types/src/types.d.ts.map +1 -1
  88. package/dist/types/src/util.d.ts +9 -0
  89. package/dist/types/src/util.d.ts.map +1 -1
  90. package/dist/types/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +34 -39
  92. package/src/NavTreePlugin.tsx +67 -291
  93. package/src/capabilities/app-graph-builder.ts +42 -0
  94. package/src/capabilities/capabilities.ts +19 -0
  95. package/src/capabilities/index.ts +13 -0
  96. package/src/capabilities/intent-resolver.ts +36 -0
  97. package/src/capabilities/keyboard.ts +54 -0
  98. package/src/capabilities/react-surface.tsx +56 -0
  99. package/src/capabilities/state.ts +97 -0
  100. package/src/components/CommandsDialog.tsx +3 -4
  101. package/src/components/CommandsTrigger.tsx +7 -5
  102. package/src/components/L0Menu.tsx +332 -0
  103. package/src/components/L1Panels.tsx +119 -0
  104. package/src/components/NavTree.stories.tsx +6 -6
  105. package/src/components/NavTree.tsx +26 -124
  106. package/src/components/NavTreeContainer.tsx +114 -45
  107. package/src/components/NavTreeContext.tsx +13 -0
  108. package/src/components/NavTreeItemAction.stories.tsx +0 -2
  109. package/src/components/NavTreeItemAction.tsx +58 -316
  110. package/src/components/NavTreeItemColumns.tsx +71 -0
  111. package/src/components/NotchStart.tsx +6 -5
  112. package/src/components/index.ts +3 -0
  113. package/src/components/types.ts +35 -0
  114. package/src/events.ts +11 -0
  115. package/src/hooks.ts +21 -0
  116. package/src/index.ts +3 -4
  117. package/src/meta.ts +1 -1
  118. package/src/stories/Graph.stories.tsx +6 -5
  119. package/src/stories/StorybookNavTree.tsx +63 -0
  120. package/src/translations.ts +0 -7
  121. package/src/types.ts +3 -2
  122. package/src/util.ts +56 -2
  123. package/dist/lib/browser/meta.mjs +0 -13
  124. package/dist/lib/browser/meta.mjs.map +0 -7
  125. package/dist/types/src/components/NavTreeFooter.d.ts +0 -6
  126. package/dist/types/src/components/NavTreeFooter.d.ts.map +0 -1
  127. package/src/components/NavTreeFooter.tsx +0 -159
@@ -0,0 +1,63 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useMemo, useState } from 'react';
6
+
7
+ import { NavTree, NavTreeContext, type NavTreeContextValue, type NavTreeProps } from '../components';
8
+ import { type NavTreeItemGraphNode } from '../types';
9
+
10
+ export const StorybookNavTree = ({
11
+ getActions,
12
+ loadDescendents,
13
+ renderItemEnd,
14
+ popoverAnchorId,
15
+ getItems,
16
+ getProps,
17
+ isCurrent,
18
+ canDrop,
19
+ onSelect,
20
+ isOpen,
21
+ onOpenChange,
22
+ ...props
23
+ }: NavTreeProps & NavTreeContextValue) => {
24
+ const [tab, setTab] = useState('never');
25
+
26
+ const contextValue = useMemo(
27
+ () => ({
28
+ tab,
29
+ onTabChange: (node: NavTreeItemGraphNode) => setTab(node.id),
30
+ getActions,
31
+ loadDescendents,
32
+ renderItemEnd,
33
+ popoverAnchorId,
34
+ getItems,
35
+ getProps,
36
+ isCurrent,
37
+ isOpen,
38
+ onOpenChange,
39
+ canDrop,
40
+ onSelect,
41
+ }),
42
+ [
43
+ tab,
44
+ setTab,
45
+ getActions,
46
+ loadDescendents,
47
+ renderItemEnd,
48
+ popoverAnchorId,
49
+ getItems,
50
+ getProps,
51
+ isCurrent,
52
+ isOpen,
53
+ onOpenChange,
54
+ canDrop,
55
+ onSelect,
56
+ ],
57
+ );
58
+ return (
59
+ <NavTreeContext.Provider value={contextValue}>
60
+ <NavTree {...props} />
61
+ </NavTreeContext.Provider>
62
+ );
63
+ };
@@ -13,14 +13,7 @@ export default [
13
13
  'commands dialog title': 'Commands',
14
14
  'command list input placeholder': 'Search for commands…',
15
15
  'node actions menu invoker label': 'More options',
16
- 'warning title': 'WARNING',
17
- 'technology preview message': 'Composer is still in technology preview.',
18
- 'learn more label': 'Learn more',
19
- 'released message': 'This version released {{released}}.',
20
- 'see release label': 'See release on GitHub',
21
- 'powered by dxos message': 'Powered by <dxos>DXOS</dxos>',
22
16
  'tree item actions label': 'More actions',
23
- 'tree item searchlist input placeholder': 'Search for actions…',
24
17
  'empty branch message': ' ',
25
18
  },
26
19
  },
package/src/types.ts CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { type Action, type ActionLike, type Node } from '@dxos/app-graph';
6
6
  import { type Label } from '@dxos/react-ui';
7
- import { type MaybePromise } from '@dxos/util';
7
+ import { type MaybePromise, type Position } from '@dxos/util';
8
8
 
9
9
  export type NavTreeItemGraphNode = Node<
10
10
  any,
@@ -31,6 +31,7 @@ type SharedProperties = {
31
31
  label: Label;
32
32
  icon?: string;
33
33
  disabled?: boolean;
34
+ position?: Position;
34
35
  testId?: string;
35
36
  className?: string;
36
37
  headingClassName?: string;
@@ -47,7 +48,7 @@ export type ActionProperties = SharedProperties & {
47
48
  disposition?: string;
48
49
  hidden?: boolean;
49
50
  caller?: string;
50
- menuType?: 'searchList' | 'dropdown';
51
+ menuType?: 'dropdown';
51
52
  keyBinding?: string | KeyBinding;
52
53
  };
53
54
 
package/src/util.ts CHANGED
@@ -10,8 +10,9 @@ import {
10
10
  ACTION_TYPE,
11
11
  ACTION_GROUP_TYPE,
12
12
  isAction,
13
+ isActionLike,
13
14
  } from '@dxos/app-graph';
14
- import { nonNullable } from '@dxos/util';
15
+ import { isNonNullable } from '@dxos/util';
15
16
 
16
17
  import { type FlattenedActions, type NavTreeItemGraphNode } from './types';
17
18
 
@@ -94,7 +95,7 @@ export const getChildren = (
94
95
  const nextPath = [...path, node.id];
95
96
  return nextPath.includes(n.id) ? undefined : (n as NavTreeItemGraphNode);
96
97
  })
97
- .filter(nonNullable) as NavTreeItemGraphNode[];
98
+ .filter(isNonNullable) as NavTreeItemGraphNode[];
98
99
  };
99
100
 
100
101
  export const getActions = (graph: Graph, node: Node): FlattenedActions => {
@@ -126,3 +127,56 @@ export const expandChildren = (graph: Graph, node: Node) => {
126
127
  export const expandActions = (graph: Graph, node: Node) => {
127
128
  return Promise.all([graph.expand(node, 'outbound', ACTION_TYPE), graph.expand(node, 'outbound', ACTION_GROUP_TYPE)]);
128
129
  };
130
+
131
+ export const l0ItemType = (item: Node<any>) => {
132
+ if (item.properties.disposition === 'collection') {
133
+ return 'collection';
134
+ } else if (isActionLike(item)) {
135
+ return 'action';
136
+ } else if (item.properties.disposition === 'navigation') {
137
+ return 'link';
138
+ } else {
139
+ return 'tab';
140
+ }
141
+ };
142
+
143
+ // Regular expression to match renderable characters
144
+ // Excludes control characters, combining marks, and other non-renderable characters
145
+ const renderableCharRegex =
146
+ /^(?![\p{Control}\p{Mark}\p{Separator}\p{Surrogate}\p{Unassigned}])[\p{L}\p{N}\p{P}\p{S}\p{Emoji}]$/u;
147
+
148
+ /**
149
+ * Returns the first two renderable characters from a string that are separated by non-word characters.
150
+ * Handles Unicode characters correctly.
151
+ *
152
+ * @param {string} label - The input string to process
153
+ * @returns {[string, string]} Array containing the two characters, or empty strings if not found
154
+ */
155
+ export const getFirstTwoRenderableChars = (label: string) => {
156
+ // Convert string to array of Unicode characters
157
+ const characters = Array.from(label);
158
+
159
+ // Keep track of found renderable characters
160
+ const result = ['', ''];
161
+ let foundFirst = false;
162
+
163
+ for (let i = 0; i < characters.length; i++) {
164
+ const char = characters[i];
165
+
166
+ if (renderableCharRegex.test(char)) {
167
+ if (!foundFirst) {
168
+ result[0] = char;
169
+ foundFirst = true;
170
+ } else {
171
+ // Check if there's at least one non-word character between the first and current char
172
+ const textBetween = characters.slice(result[0].length, i).join('');
173
+ if (/[^\p{L}\p{N}_]/u.test(textBetween)) {
174
+ result[1] = char;
175
+ break;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ return result;
182
+ };
@@ -1,13 +0,0 @@
1
- import {
2
- COMMANDS_DIALOG,
3
- KEY_BINDING,
4
- NAVTREE_PLUGIN,
5
- meta_default
6
- } from "./chunk-VAXG4OAG.mjs";
7
- export {
8
- COMMANDS_DIALOG,
9
- KEY_BINDING,
10
- NAVTREE_PLUGIN,
11
- meta_default as default
12
- };
13
- //# sourceMappingURL=meta.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { type LayoutPart } from '@dxos/app-framework';
3
- export declare const NavTreeFooter: (props: {
4
- layoutPart?: LayoutPart;
5
- }) => React.JSX.Element;
6
- //# sourceMappingURL=NavTreeFooter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavTreeFooter.d.ts","sourceRoot":"","sources":["../../../../src/components/NavTreeFooter.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,KAAK,UAAU,EAMhB,MAAM,qBAAqB,CAAC;AAwB7B,eAAO,MAAM,aAAa,UAAW;IAAE,UAAU,CAAC,EAAE,UAAU,CAAA;CAAE,sBAuH/D,CAAC"}
@@ -1,159 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { ArrowSquareOut, GearSix, Warning } from '@phosphor-icons/react';
6
- import { formatDistance } from 'date-fns/formatDistance';
7
- import React from 'react';
8
-
9
- import {
10
- type LayoutPart,
11
- SettingsAction,
12
- parseNavigationPlugin,
13
- useResolvePlugin,
14
- useIntentDispatcher,
15
- createIntent,
16
- } from '@dxos/app-framework';
17
- import { useConfig } from '@dxos/react-client';
18
- import {
19
- Button,
20
- Link,
21
- Message,
22
- Popover,
23
- Tooltip,
24
- Trans,
25
- useDefaultValue,
26
- useSidebars,
27
- useTranslation,
28
- } from '@dxos/react-ui';
29
- import { LayoutControls } from '@dxos/react-ui-stack';
30
- import { getSize, mx } from '@dxos/react-ui-theme';
31
-
32
- import { NAVTREE_PLUGIN } from '../meta';
33
-
34
- const buttonStyles = 'pli-1.5 text-xs font-normal';
35
-
36
- const repo = 'https://github.com/dxos/dxos';
37
-
38
- const VERSION_REGEX = /([\d.]+)/;
39
-
40
- export const NavTreeFooter = (props: { layoutPart?: LayoutPart }) => {
41
- const layoutPart = useDefaultValue(props.layoutPart, () => 'sidebar');
42
- const config = useConfig();
43
- const { t } = useTranslation(NAVTREE_PLUGIN);
44
- const { navigationSidebarOpen } = useSidebars(NAVTREE_PLUGIN);
45
- const { dispatchPromise: dispatch } = useIntentDispatcher();
46
- const { version, timestamp, commitHash } = config.values.runtime?.app?.build ?? {};
47
- const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
48
- const [_, v] = version?.match(VERSION_REGEX) ?? [];
49
-
50
- const releaseUrl =
51
- config.values.runtime?.app?.env?.DX_ENVIRONMENT === 'production'
52
- ? `${repo}/releases/tag/v${version}`
53
- : `${repo}/commit/${commitHash}`;
54
-
55
- const previewUrl = 'https://docs.dxos.org/composer#technology-preview';
56
-
57
- return (
58
- <div
59
- role='none'
60
- className={mx(
61
- 'flex bs-[--rail-size] pbe-[env(safe-area-inset-bottom)] box-content justify-end',
62
- layoutPart === 'complementary' && 'md:justify-end flex-row-reverse',
63
- )}
64
- >
65
- <Popover.Root>
66
- <Popover.Trigger asChild>
67
- <Button variant='ghost' classNames={buttonStyles} {...(!navigationSidebarOpen && { tabIndex: -1 })}>
68
- v{v}
69
- </Button>
70
- </Popover.Trigger>
71
- <Popover.Portal>
72
- <Popover.Content
73
- side='top'
74
- role='message'
75
- classNames='z-[12] bg-warning-500 max-is-[min(calc(100vw-16px),40ch)]'
76
- >
77
- <Message.Root valence='warning' className='rounded-be-none p-5'>
78
- <Message.Title>
79
- <Warning weight='duotone' className='inline mie-2 is-6 bs-6' />
80
- <span>{t('warning title')}</span>
81
- </Message.Title>
82
- <Message.Body>
83
- {t('technology preview message')}
84
- <br />
85
- <Link href={previewUrl} target='_blank' rel='noreferrer' variant='neutral'>
86
- {t('learn more label')}
87
- <ArrowSquareOut className='inline mis-1' weight='bold' />
88
- </Link>
89
- </Message.Body>
90
- </Message.Root>
91
- <div role='none' className='plb-4 pli-5 space-b-2 text-baseText'>
92
- {timestamp && (
93
- <p>
94
- {t('released message', {
95
- released: formatDistance(new Date(timestamp), new Date(), { addSuffix: true }),
96
- })}
97
- <br />
98
- <Link href={releaseUrl} target='_blank' rel='noreferrer' variant='neutral'>
99
- {t('see release label')}
100
- <ArrowSquareOut className='inline mis-1' weight='bold' />
101
- </Link>
102
- </p>
103
- )}
104
- <p>
105
- <Trans
106
- {...{
107
- t,
108
- i18nKey: 'powered by dxos message',
109
- components: {
110
- dxos: <Link href='https://dxos.org' target='_blank' rel='noreferrer' variant='neutral' />,
111
- },
112
- }}
113
- />
114
- </p>
115
- </div>
116
- <Popover.Arrow />
117
- </Popover.Content>
118
- </Popover.Portal>
119
- </Popover.Root>
120
-
121
- <Tooltip.Root>
122
- <Tooltip.Trigger asChild>
123
- {/* TODO(burdon): Reconcile with action created by LayoutPlugin. */}
124
- <Button
125
- variant='ghost'
126
- classNames={buttonStyles}
127
- data-testid='treeView.openSettings'
128
- data-joyride='welcome/settings'
129
- {...(!navigationSidebarOpen && { tabIndex: -1 })}
130
- onClick={() => dispatch(createIntent(SettingsAction.Open))}
131
- >
132
- <span className='sr-only'>{t('open settings label')}</span>
133
- <GearSix className={mx(getSize(5), 'rotate-90')} />
134
- </Button>
135
- </Tooltip.Trigger>
136
- <Tooltip.Portal>
137
- <Tooltip.Content classNames='z-[12]'>
138
- {t('open settings label')}
139
- <Tooltip.Arrow />
140
- </Tooltip.Content>
141
- </Tooltip.Portal>
142
- </Tooltip.Root>
143
-
144
- {/* NOTE(thure): Unpinning from the NavTree’s default position in Deck is temporarily disabled. */}
145
- {navigationPlugin?.meta.id === 'dxos.org/plugin/deck' && (
146
- <LayoutControls
147
- variant='hide-disabled'
148
- capabilities={{
149
- incrementStart: false,
150
- incrementEnd: false,
151
- }}
152
- onClick={(_type) => {
153
- // TODO(Zan): If we inmplement pinning again, we should dispatch here.
154
- }}
155
- />
156
- )}
157
- </div>
158
- );
159
- };