@dxos/app-framework 0.3.10-main.4cae50a → 0.3.10-main.4f6becb
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 +30 -214
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +42 -221
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +8 -11
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/settings.d.ts +6 -5
- package/dist/types/src/plugins/common/settings.d.ts.map +1 -1
- package/dist/types/src/plugins/index.d.ts +0 -1
- package/dist/types/src/plugins/index.d.ts.map +1 -1
- package/package.json +9 -16
- package/src/plugins/common/layout.ts +1 -6
- package/src/plugins/common/settings.ts +11 -5
- package/src/plugins/index.ts +0 -1
- package/tsconfig.json +0 -15
- package/dist/types/src/plugins/components/CommandsDialog.d.ts +0 -5
- package/dist/types/src/plugins/components/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/plugins/components/SettingsDialog.d.ts +0 -2
- package/dist/types/src/plugins/components/SettingsDialog.d.ts.map +0 -1
- package/dist/types/src/plugins/components/SettingsValue.d.ts +0 -8
- package/dist/types/src/plugins/components/SettingsValue.d.ts.map +0 -1
- package/dist/types/src/plugins/components/index.d.ts +0 -4
- package/dist/types/src/plugins/components/index.d.ts.map +0 -1
- package/src/plugins/components/CommandsDialog.tsx +0 -100
- package/src/plugins/components/SettingsDialog.tsx +0 -98
- package/src/plugins/components/SettingsValue.tsx +0 -36
- package/src/plugins/components/index.ts +0 -7
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
|
2
|
-
type SettingValueProps = {
|
|
3
|
-
label: string;
|
|
4
|
-
description?: JSX.Element;
|
|
5
|
-
};
|
|
6
|
-
export declare const SettingsValue: ({ label, description, children }: PropsWithChildren<SettingValueProps>) => JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=SettingsValue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsValue.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/components/SettingsValue.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAItD,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,aAAa,qCAAsC,kBAAkB,iBAAiB,CAAC,gBAsBnG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { DotOutline } from '@phosphor-icons/react';
|
|
6
|
-
import React, { useMemo, useRef } from 'react';
|
|
7
|
-
|
|
8
|
-
import { type Action, type Graph, type Label } from '@dxos/app-graph';
|
|
9
|
-
import { Keyboard, keySymbols } from '@dxos/keyboard';
|
|
10
|
-
import { Button, Dialog, useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { SearchList } from '@dxos/react-ui-searchlist';
|
|
12
|
-
import { descriptionText, getSize, mx } from '@dxos/react-ui-theme';
|
|
13
|
-
|
|
14
|
-
export const CommandsDialogContent = ({ graph }: { graph?: Graph }) => {
|
|
15
|
-
const { t } = useTranslation('os');
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Factor out.
|
|
18
|
-
// TODO(burdon): How to access all translations across plugins?
|
|
19
|
-
const toString = (label: Label) => (Array.isArray(label) ? t(...label) : label);
|
|
20
|
-
|
|
21
|
-
// Traverse graph.
|
|
22
|
-
// TODO(burdon): Factor out commonality with shortcut dialog.
|
|
23
|
-
const actions = useMemo(() => {
|
|
24
|
-
// TODO(burdon): Get from navtree (not keyboard).
|
|
25
|
-
const current = Keyboard.singleton.getCurrentContext();
|
|
26
|
-
const actionMap = new Set<string>();
|
|
27
|
-
const actions: Action[] = [];
|
|
28
|
-
graph?.traverse({
|
|
29
|
-
visitor: (node, path) => {
|
|
30
|
-
if (current.startsWith(path.join('/'))) {
|
|
31
|
-
node.actions.forEach((action) => {
|
|
32
|
-
if (!actionMap.has(action.id)) {
|
|
33
|
-
actionMap.add(action.id);
|
|
34
|
-
actions.push(action);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
actions.sort(({ label: a }, { label: b }) => {
|
|
42
|
-
return toString(a)?.toLowerCase().localeCompare(toString(b)?.toLowerCase());
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// console.log(JSON.stringify(actions, undefined, 2));
|
|
46
|
-
return actions;
|
|
47
|
-
}, [graph]);
|
|
48
|
-
|
|
49
|
-
// TODO(burdon): Remove.
|
|
50
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<Dialog.Content classNames={['md:max-is-[30rem] overflow-hidden']}>
|
|
54
|
-
<Dialog.Title>{t('commands dialog title', { ns: 'os' })}</Dialog.Title>
|
|
55
|
-
|
|
56
|
-
{/* TODO(burdon): BUG: Overscrolls container. */}
|
|
57
|
-
<SearchList.Root label={t('commandlist input placeholder')} classNames='flex flex-col grow overflow-hidden my-2'>
|
|
58
|
-
<SearchList.Input placeholder={t('commandlist input placeholder')} classNames={mx('px-1 my-2')} />
|
|
59
|
-
<SearchList.Content classNames={['max-bs-[30rem] overflow-auto']}>
|
|
60
|
-
{actions?.map((action) => {
|
|
61
|
-
const label = toString(action.label);
|
|
62
|
-
const Icon = action.icon ?? DotOutline;
|
|
63
|
-
return (
|
|
64
|
-
<SearchList.Item
|
|
65
|
-
value={label}
|
|
66
|
-
key={action.id}
|
|
67
|
-
onSelect={() => {
|
|
68
|
-
if (action.properties.disabled) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// TODO(burdon): Remove hack to close dialog (via hook?)
|
|
73
|
-
buttonRef.current?.click();
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
void action.invoke();
|
|
76
|
-
});
|
|
77
|
-
}}
|
|
78
|
-
classNames='flex items-center gap-2'
|
|
79
|
-
disabled={action.properties.disabled}
|
|
80
|
-
{...(action.properties?.testId && { 'data-testid': action.properties.testId })}
|
|
81
|
-
>
|
|
82
|
-
<Icon className={mx(getSize(4), 'shrink-0', !action.icon && 'invisible')} />
|
|
83
|
-
<span className='grow truncate'>{label}</span>
|
|
84
|
-
{action.keyBinding && (
|
|
85
|
-
<span className={mx('shrink-0', descriptionText)}>{keySymbols(action.keyBinding).join('')}</span>
|
|
86
|
-
)}
|
|
87
|
-
</SearchList.Item>
|
|
88
|
-
);
|
|
89
|
-
})}
|
|
90
|
-
</SearchList.Content>
|
|
91
|
-
</SearchList.Root>
|
|
92
|
-
|
|
93
|
-
<Dialog.Close asChild>
|
|
94
|
-
<Button ref={buttonRef} variant='primary' classNames='mbs-2'>
|
|
95
|
-
{t('close label', { ns: 'os' })}
|
|
96
|
-
</Button>
|
|
97
|
-
</Dialog.Close>
|
|
98
|
-
</Dialog.Content>
|
|
99
|
-
);
|
|
100
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Button, Dialog, List, ListItem, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import { ghostHover, ghostSelected, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
import { type Plugin, usePlugins } from '../PluginHost';
|
|
11
|
-
import { Surface } from '../SurfacePlugin';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Move into separate plugin.
|
|
14
|
-
export const SettingsDialogContent = () => {
|
|
15
|
-
const { t } = useTranslation('os');
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Store preview tab.
|
|
18
|
-
const [plugin, setPlugin] = useState<string>('dxos.org/plugin/registry');
|
|
19
|
-
const { plugins, enabled } = usePlugins();
|
|
20
|
-
|
|
21
|
-
const core = [
|
|
22
|
-
'dxos.org/plugin/layout',
|
|
23
|
-
'dxos.org/plugin/client',
|
|
24
|
-
'dxos.org/plugin/space',
|
|
25
|
-
'dxos.org/plugin/registry',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const filteredPlugins = enabled
|
|
29
|
-
.map((id) => plugins.find((plugin) => plugin.meta.id === id))
|
|
30
|
-
.filter((plugin) => (plugin?.provides as any)?.settings)
|
|
31
|
-
.map((plugin) => plugin!.meta)
|
|
32
|
-
.sort(({ name: a }, { name: b }) => a?.localeCompare(b ?? '') ?? 0);
|
|
33
|
-
|
|
34
|
-
// TODO(burdon): Common treatment for dialogs (e.g., shrink height to fit, mobile, etc.)
|
|
35
|
-
return (
|
|
36
|
-
<Dialog.Content classNames={['h-full md:max-is-[40rem] overflow-hidden']}>
|
|
37
|
-
<Dialog.Title>{t('settings dialog title', { ns: 'os' })}</Dialog.Title>
|
|
38
|
-
|
|
39
|
-
<div className='flex grow mlb-4 overflow-hidden'>
|
|
40
|
-
<div className={mx('flex flex-col w-[200px] space-y-4 pr-4 border-r overflow-y-auto', groupBorder)}>
|
|
41
|
-
<PluginList
|
|
42
|
-
title='Options'
|
|
43
|
-
plugins={core.map((id) => plugins.find((p) => p.meta.id === id)!.meta)}
|
|
44
|
-
selected={plugin}
|
|
45
|
-
onSelect={(plugin) => setPlugin(plugin)}
|
|
46
|
-
/>
|
|
47
|
-
|
|
48
|
-
<PluginList
|
|
49
|
-
title='Plugins'
|
|
50
|
-
plugins={filteredPlugins}
|
|
51
|
-
selected={plugin}
|
|
52
|
-
onSelect={(plugin) => setPlugin(plugin)}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<div className={mx('flex flex-col w-full md:px-4 divide-y overflow-y-auto', groupBorder)}>
|
|
57
|
-
<Surface role='settings' data={{ plugin }} />
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<Dialog.Close asChild>
|
|
62
|
-
<Button variant='primary' classNames='mbs-2' autoFocus>
|
|
63
|
-
{t('done label', { ns: 'os' })}
|
|
64
|
-
</Button>
|
|
65
|
-
</Dialog.Close>
|
|
66
|
-
</Dialog.Content>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const PluginList = ({
|
|
71
|
-
title,
|
|
72
|
-
plugins,
|
|
73
|
-
selected,
|
|
74
|
-
onSelect,
|
|
75
|
-
}: {
|
|
76
|
-
title: string;
|
|
77
|
-
plugins: Plugin['meta'][];
|
|
78
|
-
selected?: string;
|
|
79
|
-
onSelect: (plugin: string) => void;
|
|
80
|
-
}) => {
|
|
81
|
-
return (
|
|
82
|
-
<div role='none'>
|
|
83
|
-
<h2 className='my-1 px-2 text-sm text-neutral-500'>{title}</h2>
|
|
84
|
-
<List selectable>
|
|
85
|
-
{plugins.map((plugin) => (
|
|
86
|
-
<ListItem.Root
|
|
87
|
-
key={plugin.id}
|
|
88
|
-
onClick={() => onSelect(plugin.id)}
|
|
89
|
-
selected={plugin.id === selected}
|
|
90
|
-
classNames={['px-2 rounded', plugin.id === selected && ghostSelected, ghostHover]}
|
|
91
|
-
>
|
|
92
|
-
<ListItem.Heading classNames={['flex w-full items-center cursor-pointer']}>{plugin.name}</ListItem.Heading>
|
|
93
|
-
</ListItem.Root>
|
|
94
|
-
))}
|
|
95
|
-
</List>
|
|
96
|
-
</div>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type PropsWithChildren } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Input } from '@dxos/react-ui';
|
|
8
|
-
|
|
9
|
-
type SettingValueProps = {
|
|
10
|
-
label: string;
|
|
11
|
-
description?: JSX.Element;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const SettingsValue = ({ label, description, children }: PropsWithChildren<SettingValueProps>) => {
|
|
15
|
-
return (
|
|
16
|
-
<div role='none' className='flex w-full gap-4 py-1'>
|
|
17
|
-
<Input.Root>
|
|
18
|
-
<div role='none' className='flex flex-col w-full'>
|
|
19
|
-
{/* TODO(burdon): Consistent height for controls (e.g., Select, Textbox, and Checkbox are all different). */}
|
|
20
|
-
<Input.Label classNames='flex min-h-[40px] items-center'>{label}</Input.Label>
|
|
21
|
-
{description && (
|
|
22
|
-
<Input.DescriptionAndValidation classNames='mbs-0.5'>
|
|
23
|
-
<Input.Description>{description}</Input.Description>
|
|
24
|
-
</Input.DescriptionAndValidation>
|
|
25
|
-
)}
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<div role='none'>
|
|
29
|
-
<div role='none' className='flex min-h-[40px] items-center'>
|
|
30
|
-
{children}
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</Input.Root>
|
|
34
|
-
</div>
|
|
35
|
-
);
|
|
36
|
-
};
|