@dxos/plugin-help 0.6.8-main.046e6cf
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/chunk-DI4HXWTJ.mjs +23 -0
- package/dist/lib/browser/chunk-DI4HXWTJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +551 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/meta.mjs +11 -0
- package/dist/lib/browser/meta.mjs.map +7 -0
- package/dist/types/src/HelpPlugin.d.ts +11 -0
- package/dist/types/src/HelpPlugin.d.ts.map +1 -0
- package/dist/types/src/components/HelpContextProvider/HelpContextProvider.d.ts +10 -0
- package/dist/types/src/components/HelpContextProvider/HelpContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/HelpContextProvider/HelpContextProvider.stories.d.ts +31 -0
- package/dist/types/src/components/HelpContextProvider/HelpContextProvider.stories.d.ts.map +1 -0
- package/dist/types/src/components/HelpContextProvider/index.d.ts +2 -0
- package/dist/types/src/components/HelpContextProvider/index.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/Key.d.ts +5 -0
- package/dist/types/src/components/Shortcuts/Key.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/ShortcutsDialog.d.ts +3 -0
- package/dist/types/src/components/Shortcuts/ShortcutsDialog.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/ShortcutsHints.d.ts +5 -0
- package/dist/types/src/components/Shortcuts/ShortcutsHints.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/ShortcutsList.d.ts +3 -0
- package/dist/types/src/components/Shortcuts/ShortcutsList.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/ShortcutsSection.d.ts +3 -0
- package/dist/types/src/components/Shortcuts/ShortcutsSection.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/index.d.ts +6 -0
- package/dist/types/src/components/Shortcuts/index.d.ts.map +1 -0
- package/dist/types/src/components/Shortcuts/styles.d.ts +2 -0
- package/dist/types/src/components/Shortcuts/styles.d.ts.map +1 -0
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +44 -0
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/types/src/components/Tooltip/index.d.ts +2 -0
- package/dist/types/src/components/Tooltip/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useHelp.d.ts +2 -0
- package/dist/types/src/hooks/useHelp.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +8 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +18 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +20 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/package.json +71 -0
- package/src/HelpPlugin.tsx +140 -0
- package/src/components/HelpContextProvider/HelpContextProvider.stories.tsx +112 -0
- package/src/components/HelpContextProvider/HelpContextProvider.tsx +176 -0
- package/src/components/HelpContextProvider/index.ts +5 -0
- package/src/components/Shortcuts/Key.tsx +21 -0
- package/src/components/Shortcuts/ShortcutsDialog.tsx +30 -0
- package/src/components/Shortcuts/ShortcutsHints.tsx +43 -0
- package/src/components/Shortcuts/ShortcutsList.tsx +35 -0
- package/src/components/Shortcuts/ShortcutsSection.tsx +16 -0
- package/src/components/Shortcuts/index.ts +9 -0
- package/src/components/Shortcuts/styles.ts +10 -0
- package/src/components/Tooltip/Tooltip.tsx +111 -0
- package/src/components/Tooltip/index.ts +5 -0
- package/src/components/index.ts +7 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useHelp.tsx +13 -0
- package/src/index.ts +15 -0
- package/src/meta.tsx +23 -0
- package/src/translations.ts +18 -0
- package/src/types.ts +38 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useArrowNavigationGroup, useFocusableGroup } from '@fluentui/react-tabster';
|
|
6
|
+
import { CaretLeft, CaretRight, Circle, X } from '@phosphor-icons/react';
|
|
7
|
+
import React, { forwardRef } from 'react';
|
|
8
|
+
// TODO(thure): This needed to be imported in the package.json specifically to pacify TS2742. See if this is resolved with typescript@5.5.x.
|
|
9
|
+
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
10
|
+
import _floater from 'react-floater';
|
|
11
|
+
import { type TooltipRenderProps, type Props } from 'react-joyride';
|
|
12
|
+
// TODO(thure): This needed to be imported in the package.json specifically to pacify TS2742. See if this is resolved with typescript@5.5.x.
|
|
13
|
+
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
14
|
+
import _typefest from 'type-fest';
|
|
15
|
+
|
|
16
|
+
import { Button } from '@dxos/react-ui';
|
|
17
|
+
import { getSize, mx } from '@dxos/react-ui-theme';
|
|
18
|
+
|
|
19
|
+
// https://docs.react-joyride.com/styling
|
|
20
|
+
// https://github.com/gilbarbara/react-floater
|
|
21
|
+
export const floaterProps: Props['floaterProps'] = {
|
|
22
|
+
styles: {
|
|
23
|
+
// Arrow color is set by joyride.
|
|
24
|
+
arrow: {
|
|
25
|
+
length: 8,
|
|
26
|
+
spread: 16,
|
|
27
|
+
},
|
|
28
|
+
floater: {
|
|
29
|
+
// TODO(burdon): Get tokens from theme.
|
|
30
|
+
filter: 'drop-shadow(0 0 0.75rem rgba(0, 0, 0, 0.2))',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// TODO(burdon): Add info link to docs.
|
|
36
|
+
export const Tooltip = forwardRef<HTMLDivElement, TooltipRenderProps>(
|
|
37
|
+
({ step: { title, content }, index, size, isLastStep, backProps, closeProps, primaryProps }, forwardedRef) => {
|
|
38
|
+
const arrowGroup = useArrowNavigationGroup({ axis: 'horizontal' });
|
|
39
|
+
const trapFocus = useFocusableGroup({ tabBehavior: 'limited-trap-focus' });
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className='flex flex-col is-[15rem] min-bs-[10rem] overflow-hidden rounded-md shadow-xl surface-accent fg-inverse'
|
|
44
|
+
role='tooltip'
|
|
45
|
+
data-testid='helpPlugin.tooltip'
|
|
46
|
+
data-step={index + 1}
|
|
47
|
+
{...trapFocus}
|
|
48
|
+
ref={forwardedRef}
|
|
49
|
+
>
|
|
50
|
+
<div className='flex p-2'>
|
|
51
|
+
<h2 className='grow pli-2 plb-1 text-lg font-medium fg-inverse'>{title}</h2>
|
|
52
|
+
<Button
|
|
53
|
+
density='fine'
|
|
54
|
+
variant='primary'
|
|
55
|
+
onClick={closeProps.onClick}
|
|
56
|
+
title={closeProps['aria-label']}
|
|
57
|
+
data-testid='helpPlugin.tooltip.close'
|
|
58
|
+
>
|
|
59
|
+
<X weight='bold' className={getSize(4)} />
|
|
60
|
+
</Button>
|
|
61
|
+
</div>
|
|
62
|
+
<div className='flex grow pli-4 mlb-2'>{content}</div>
|
|
63
|
+
<div className='flex p-2 items-center justify-between' {...arrowGroup}>
|
|
64
|
+
{
|
|
65
|
+
<Button
|
|
66
|
+
variant='primary'
|
|
67
|
+
onClick={backProps.onClick}
|
|
68
|
+
title={backProps['aria-label']}
|
|
69
|
+
classNames={[!(index > 0 && backProps) && 'invisible']}
|
|
70
|
+
data-testid='helpPlugin.tooltip.back'
|
|
71
|
+
>
|
|
72
|
+
<CaretLeft className={getSize(5)} />
|
|
73
|
+
</Button>
|
|
74
|
+
}
|
|
75
|
+
<div className='flex grow gap-2 justify-center'>
|
|
76
|
+
<div className='flex'>
|
|
77
|
+
{Array.from({ length: size }).map((_, i) => (
|
|
78
|
+
<Circle
|
|
79
|
+
key={i}
|
|
80
|
+
weight={index === i ? 'fill' : 'regular'}
|
|
81
|
+
className={mx(getSize(2), 'mli-1 cursor-pointer')}
|
|
82
|
+
/>
|
|
83
|
+
))}
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
{isLastStep ? (
|
|
87
|
+
<Button
|
|
88
|
+
variant='primary'
|
|
89
|
+
onClick={closeProps.onClick}
|
|
90
|
+
title={closeProps['aria-label']}
|
|
91
|
+
autoFocus
|
|
92
|
+
data-testid='helpPlugin.tooltip.finish'
|
|
93
|
+
>
|
|
94
|
+
Done
|
|
95
|
+
</Button>
|
|
96
|
+
) : (
|
|
97
|
+
<Button
|
|
98
|
+
variant='primary'
|
|
99
|
+
onClick={primaryProps.onClick}
|
|
100
|
+
title={primaryProps['aria-label']}
|
|
101
|
+
autoFocus
|
|
102
|
+
data-testid='helpPlugin.tooltip.next'
|
|
103
|
+
>
|
|
104
|
+
<CaretRight className={getSize(6)} />
|
|
105
|
+
</Button>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useContext } from 'react';
|
|
6
|
+
|
|
7
|
+
import { raise } from '@dxos/debug';
|
|
8
|
+
|
|
9
|
+
import { HelpContext } from '../types';
|
|
10
|
+
|
|
11
|
+
export const useHelp = () => {
|
|
12
|
+
return useContext(HelpContext) ?? raise(new Error('Missing HelpContext'));
|
|
13
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { HelpPlugin } from './HelpPlugin';
|
|
6
|
+
import { type Step } from './types';
|
|
7
|
+
|
|
8
|
+
export type { Step };
|
|
9
|
+
|
|
10
|
+
export * from './components';
|
|
11
|
+
export * from './hooks';
|
|
12
|
+
|
|
13
|
+
export * from './HelpPlugin';
|
|
14
|
+
|
|
15
|
+
export default HelpPlugin;
|
package/src/meta.tsx
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Info, type IconProps } from '@phosphor-icons/react';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { pluginMeta } from '@dxos/app-framework';
|
|
9
|
+
|
|
10
|
+
// TODO(burdon): Rename Guide? Help?
|
|
11
|
+
export const HELP_PLUGIN = 'dxos.org/plugin/help';
|
|
12
|
+
|
|
13
|
+
export default pluginMeta({
|
|
14
|
+
id: HELP_PLUGIN,
|
|
15
|
+
name: 'Help',
|
|
16
|
+
iconComponent: (props: IconProps) => <Info {...props} />,
|
|
17
|
+
iconSymbol: 'ph--info--regular',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const HELP_ACTION = `${HELP_PLUGIN}/action`;
|
|
21
|
+
export enum HelpAction {
|
|
22
|
+
START = `${HELP_ACTION}/start`,
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { HELP_PLUGIN } from './meta';
|
|
6
|
+
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
'en-US': {
|
|
10
|
+
[HELP_PLUGIN]: {
|
|
11
|
+
'plugin name': 'Help',
|
|
12
|
+
'open help tour': 'Show welcome tour',
|
|
13
|
+
'open shortcuts label': 'Show shortcuts',
|
|
14
|
+
'shortcuts dialog title': 'Shortcuts',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
];
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Context, createContext } from 'react';
|
|
6
|
+
import { type Step as BaseStep } from 'react-joyride';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
type Plugin,
|
|
10
|
+
type GraphBuilderProvides,
|
|
11
|
+
type IntentResolverProvides,
|
|
12
|
+
type SurfaceProvides,
|
|
13
|
+
type TranslationsProvides,
|
|
14
|
+
} from '@dxos/app-framework';
|
|
15
|
+
|
|
16
|
+
export type Step = BaseStep & {
|
|
17
|
+
before?: (context: { plugins: Plugin[]; step: Step }) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type HelpContextType = {
|
|
21
|
+
running: boolean;
|
|
22
|
+
steps: Step[];
|
|
23
|
+
setSteps: (steps: Step[]) => void;
|
|
24
|
+
setIndex: (index: number) => void;
|
|
25
|
+
start: () => void;
|
|
26
|
+
stop: () => void;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const HelpContext: Context<HelpContextType> = createContext<HelpContextType>({
|
|
30
|
+
running: false,
|
|
31
|
+
steps: [],
|
|
32
|
+
setSteps: () => {},
|
|
33
|
+
setIndex: () => {},
|
|
34
|
+
start: () => {},
|
|
35
|
+
stop: () => {},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type HelpPluginProvides = GraphBuilderProvides & IntentResolverProvides & SurfaceProvides & TranslationsProvides;
|