@datalayer/core 0.0.16 → 0.0.18
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/README.md +9 -13
- package/lib/client/auth/AuthenticationManager.d.ts +95 -0
- package/lib/client/auth/AuthenticationManager.js +214 -0
- package/lib/client/auth/index.d.ts +8 -0
- package/lib/client/auth/index.js +17 -0
- package/lib/client/auth/storage.d.ts +154 -0
- package/lib/client/auth/storage.js +447 -0
- package/lib/client/auth/strategies.d.ts +54 -0
- package/lib/client/auth/strategies.js +238 -0
- package/lib/client/auth/types.d.ts +151 -0
- package/lib/{examples/index.js → client/auth/types.js} +4 -2
- package/lib/client/base.d.ts +3 -0
- package/lib/client/base.js +9 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +2 -0
- package/lib/components/auth/Login.d.ts +40 -0
- package/lib/components/auth/Login.js +173 -0
- package/lib/components/auth/Login.stories.d.ts +54 -0
- package/lib/components/auth/Login.stories.js +104 -0
- package/lib/components/auth/LoginToken.d.ts +16 -0
- package/lib/components/auth/LoginToken.js +63 -0
- package/lib/components/auth/index.d.ts +5 -0
- package/lib/components/auth/index.js +16 -0
- package/lib/components/avatars/BoringAvatar.d.ts +6 -15
- package/lib/components/avatars/BoringAvatar.js +30 -34
- package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
- package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
- package/lib/components/avatars/UserProfileAvatar.js +3 -8
- package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
- package/lib/components/buttons/DownloadCSVButton.js +1 -5
- package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
- package/lib/components/buttons/DownloadJsonButton.js +1 -7
- package/lib/components/buttons/UploadButton.d.ts +1 -4
- package/lib/components/buttons/UploadButton.js +3 -7
- package/lib/components/chat/ChatComponent.d.ts +4 -0
- package/lib/components/chat/ChatComponent.js +143 -0
- package/lib/components/chat/MessagePart.d.ts +11 -0
- package/lib/components/chat/MessagePart.js +23 -0
- package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
- package/lib/components/chat/display/DynamicToolPart.js +5 -0
- package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
- package/lib/components/chat/display/ReasoningPart.js +58 -0
- package/lib/components/chat/display/TextPart.d.ts +9 -0
- package/lib/components/chat/display/TextPart.js +93 -0
- package/lib/components/chat/display/ToolPart.d.ts +6 -0
- package/lib/components/chat/display/ToolPart.js +148 -0
- package/lib/components/chat/display/index.d.ts +4 -0
- package/lib/components/chat/display/index.js +13 -0
- package/lib/components/chat/handler.d.ts +8 -0
- package/lib/components/chat/handler.js +43 -0
- package/lib/components/chat/index.d.ts +4 -0
- package/lib/components/chat/index.js +13 -0
- package/lib/components/display/CenteredSpinner.d.ts +1 -4
- package/lib/components/display/CenteredSpinner.js +1 -5
- package/lib/components/display/HorizontalCenter.d.ts +1 -4
- package/lib/components/display/HorizontalCenter.js +1 -5
- package/lib/components/flashes/FlashClosable.d.ts +1 -4
- package/lib/components/flashes/FlashClosable.js +1 -5
- package/lib/components/flashes/FlashDisclaimer.js +1 -1
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +2 -1
- package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
- package/lib/components/notebooks/JupyterNotebook.js +1 -5
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
- package/lib/config/Configuration.js +1 -1
- package/lib/examples/CellExample.js +11 -47
- package/lib/examples/lexical-theme.css +436 -0
- package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
- package/lib/hooks/useAIJupyterChat.d.ts +36 -0
- package/lib/hooks/useAIJupyterChat.js +53 -0
- package/lib/hooks/useBackdrop.d.ts +4 -4
- package/lib/hooks/useBackdrop.js +5 -9
- package/lib/hooks/useCache.d.ts +5 -1
- package/lib/hooks/useCache.js +126 -58
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +26 -0
- package/lib/hooks/useScreenshot.d.ts +3 -5
- package/lib/hooks/useScreenshot.js +1 -8
- package/lib/hooks/useUpload.js +29 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -4
- package/lib/models/Outbound.d.ts +2 -0
- package/lib/models/Outbound.js +3 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/state/substates/IAMState.js +15 -6
- package/lib/stateful/index.d.ts +0 -1
- package/lib/stateful/index.js +0 -1
- package/lib/stateful/runtimes/actions.d.ts +1 -1
- package/lib/stateful/runtimes/actions.js +1 -1
- package/lib/theme/DatalayerTheme.d.ts +2 -2
- package/lib/theme/DatalayerTheme.js +4 -4
- package/lib/theme/DatalayerThemeProvider.js +2 -2
- package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
- package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
- package/lib/tools/adapters/agui/index.d.ts +10 -0
- package/lib/tools/adapters/agui/index.js +19 -0
- package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
- package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/notebookHooks.js +61 -0
- package/lib/tools/index.d.ts +6 -0
- package/lib/tools/index.js +18 -0
- package/lib/types.d.ts +5 -0
- package/lib/types.js +5 -0
- package/lib/utils/cli/index.d.ts +4 -0
- package/lib/utils/cli/index.js +13 -0
- package/lib/utils/cli/query.d.ts +6 -0
- package/lib/utils/cli/query.js +26 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +62 -5
- package/style/base.css +4 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
- package/lib/examples/DatalayerNotebookExample.js +0 -75
- package/lib/examples/NativeNavigationExample.d.ts +0 -8
- package/lib/examples/NativeNavigationExample.js +0 -97
- package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
- package/lib/examples/NotebookMutationsKernel.js +0 -115
- package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
- package/lib/examples/NotebookMutationsServiceManager.js +0 -107
- package/lib/examples/ReactRouterExample.d.ts +0 -6
- package/lib/examples/ReactRouterExample.js +0 -175
- package/lib/examples/example-selector.d.ts +0 -22
- package/lib/examples/example-selector.js +0 -45
- package/lib/examples/index.d.ts +0 -2
- package/lib/examples/main.d.ts +0 -1
- package/lib/examples/main.js +0 -153
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
/**
|
|
3
|
+
* Login component provides a comprehensive authentication interface with multiple methods:
|
|
4
|
+
* - Email/password authentication
|
|
5
|
+
* - OAuth (GitHub, LinkedIn)
|
|
6
|
+
* - Direct token input
|
|
7
|
+
*
|
|
8
|
+
* The component includes form validation, loading states, and error handling.
|
|
9
|
+
*/
|
|
10
|
+
declare const meta: {
|
|
11
|
+
title: string;
|
|
12
|
+
component: (props: import("./Login").ILoginProps) => JSX.Element;
|
|
13
|
+
parameters: {
|
|
14
|
+
layout: string;
|
|
15
|
+
};
|
|
16
|
+
decorators: ((Story: import("storybook/internal/csf").PartialStoryFn<import("@storybook/react").ReactRenderer, {
|
|
17
|
+
heading?: string | undefined;
|
|
18
|
+
homeRoute: string;
|
|
19
|
+
loginRoute?: string | undefined;
|
|
20
|
+
joinRoute?: string | undefined;
|
|
21
|
+
joinConfirmRoute?: string | undefined;
|
|
22
|
+
passwordRoute?: string | undefined;
|
|
23
|
+
showEmailLogin?: boolean | undefined;
|
|
24
|
+
showGitHubLogin?: boolean | undefined;
|
|
25
|
+
showTokenLogin?: boolean | undefined;
|
|
26
|
+
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
27
|
+
tags: string[];
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
type Story = StoryObj<typeof meta>;
|
|
31
|
+
/**
|
|
32
|
+
* Default login form with all authentication methods enabled
|
|
33
|
+
*/
|
|
34
|
+
export declare const Default: Story;
|
|
35
|
+
/**
|
|
36
|
+
* Login form with only email/password authentication
|
|
37
|
+
*/
|
|
38
|
+
export declare const EmailOnly: Story;
|
|
39
|
+
/**
|
|
40
|
+
* Login form with only OAuth authentication
|
|
41
|
+
*/
|
|
42
|
+
export declare const OAuthOnly: Story;
|
|
43
|
+
/**
|
|
44
|
+
* Login form with only token authentication
|
|
45
|
+
*/
|
|
46
|
+
export declare const TokenOnly: Story;
|
|
47
|
+
/**
|
|
48
|
+
* Login form with custom heading
|
|
49
|
+
*/
|
|
50
|
+
export declare const CustomHeading: Story;
|
|
51
|
+
/**
|
|
52
|
+
* Login form with all authentication methods including password reset link
|
|
53
|
+
*/
|
|
54
|
+
export declare const WithPasswordReset: Story;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
4
|
+
import { queryClient } from '../../utils/cli/query';
|
|
5
|
+
import { Login } from './Login';
|
|
6
|
+
/**
|
|
7
|
+
* Login component provides a comprehensive authentication interface with multiple methods:
|
|
8
|
+
* - Email/password authentication
|
|
9
|
+
* - OAuth (GitHub, LinkedIn)
|
|
10
|
+
* - Direct token input
|
|
11
|
+
*
|
|
12
|
+
* The component includes form validation, loading states, and error handling.
|
|
13
|
+
*/
|
|
14
|
+
const meta = {
|
|
15
|
+
title: 'Components/Auth/Login',
|
|
16
|
+
component: Login,
|
|
17
|
+
parameters: {
|
|
18
|
+
layout: 'fullscreen',
|
|
19
|
+
},
|
|
20
|
+
decorators: [
|
|
21
|
+
Story => (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(BrowserRouter, { children: _jsx(Story, {}) }) })),
|
|
22
|
+
],
|
|
23
|
+
tags: ['autodocs'],
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
/**
|
|
27
|
+
* Default login form with all authentication methods enabled
|
|
28
|
+
*/
|
|
29
|
+
export const Default = {
|
|
30
|
+
args: {
|
|
31
|
+
heading: 'Login to Datalayer',
|
|
32
|
+
homeRoute: '/home',
|
|
33
|
+
loginRoute: '/login',
|
|
34
|
+
showEmailLogin: true,
|
|
35
|
+
showGitHubLogin: true,
|
|
36
|
+
showTokenLogin: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Login form with only email/password authentication
|
|
41
|
+
*/
|
|
42
|
+
export const EmailOnly = {
|
|
43
|
+
args: {
|
|
44
|
+
heading: 'Login to Datalayer',
|
|
45
|
+
homeRoute: '/home',
|
|
46
|
+
loginRoute: '/login',
|
|
47
|
+
showEmailLogin: true,
|
|
48
|
+
showGitHubLogin: false,
|
|
49
|
+
showTokenLogin: false,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Login form with only OAuth authentication
|
|
54
|
+
*/
|
|
55
|
+
export const OAuthOnly = {
|
|
56
|
+
args: {
|
|
57
|
+
heading: 'Login to Datalayer',
|
|
58
|
+
homeRoute: '/home',
|
|
59
|
+
loginRoute: '/login',
|
|
60
|
+
showEmailLogin: false,
|
|
61
|
+
showGitHubLogin: true,
|
|
62
|
+
showTokenLogin: false,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Login form with only token authentication
|
|
67
|
+
*/
|
|
68
|
+
export const TokenOnly = {
|
|
69
|
+
args: {
|
|
70
|
+
heading: 'Login to Datalayer',
|
|
71
|
+
homeRoute: '/home',
|
|
72
|
+
loginRoute: '/login',
|
|
73
|
+
showEmailLogin: false,
|
|
74
|
+
showGitHubLogin: false,
|
|
75
|
+
showTokenLogin: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Login form with custom heading
|
|
80
|
+
*/
|
|
81
|
+
export const CustomHeading = {
|
|
82
|
+
args: {
|
|
83
|
+
heading: 'Welcome Back!',
|
|
84
|
+
homeRoute: '/home',
|
|
85
|
+
loginRoute: '/login',
|
|
86
|
+
showEmailLogin: true,
|
|
87
|
+
showGitHubLogin: true,
|
|
88
|
+
showTokenLogin: true,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Login form with all authentication methods including password reset link
|
|
93
|
+
*/
|
|
94
|
+
export const WithPasswordReset = {
|
|
95
|
+
args: {
|
|
96
|
+
heading: 'Login to Datalayer',
|
|
97
|
+
homeRoute: '/home',
|
|
98
|
+
loginRoute: '/login',
|
|
99
|
+
passwordRoute: '/password-reset',
|
|
100
|
+
showEmailLogin: true,
|
|
101
|
+
showGitHubLogin: true,
|
|
102
|
+
showTokenLogin: true,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ILoginTokenProps {
|
|
2
|
+
/**
|
|
3
|
+
* Home page route to navigate to after successful login
|
|
4
|
+
*/
|
|
5
|
+
homeRoute: string;
|
|
6
|
+
/**
|
|
7
|
+
* CSS style object
|
|
8
|
+
*/
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Component for token-based authentication
|
|
13
|
+
* Provides a simple button that expands to show a token input form
|
|
14
|
+
*/
|
|
15
|
+
export declare const LoginToken: (props: ILoginTokenProps) => JSX.Element;
|
|
16
|
+
export default LoginToken;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*
|
|
6
|
+
* Datalayer License
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { Button, FormControl, TextInput } from '@primer/react';
|
|
10
|
+
import { Box } from '@datalayer/primer-addons';
|
|
11
|
+
import { useIAM, useNavigate, useToast } from '../../hooks';
|
|
12
|
+
import { useIAMStore } from '../../state';
|
|
13
|
+
/**
|
|
14
|
+
* Component for token-based authentication
|
|
15
|
+
* Provides a simple button that expands to show a token input form
|
|
16
|
+
*/
|
|
17
|
+
export const LoginToken = (props) => {
|
|
18
|
+
const { homeRoute, style } = props;
|
|
19
|
+
const [showForm, setShowForm] = useState(false);
|
|
20
|
+
const [token, setToken] = useState('');
|
|
21
|
+
const [loading, setLoading] = useState(false);
|
|
22
|
+
const { loginAndNavigate } = useIAM();
|
|
23
|
+
const { logout, checkIAMToken } = useIAMStore();
|
|
24
|
+
const { enqueueToast } = useToast();
|
|
25
|
+
const navigate = useNavigate();
|
|
26
|
+
const handleLogin = async () => {
|
|
27
|
+
if (!token.trim()) {
|
|
28
|
+
enqueueToast('Please enter a valid token', { variant: 'warning' });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setLoading(true);
|
|
32
|
+
try {
|
|
33
|
+
await loginAndNavigate(token, logout, checkIAMToken, navigate, homeRoute);
|
|
34
|
+
setShowForm(false);
|
|
35
|
+
setToken('');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error('Token login failed:', error);
|
|
39
|
+
enqueueToast('Failed to authenticate with provided token', {
|
|
40
|
+
variant: 'error',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
setLoading(false);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
if (!showForm) {
|
|
48
|
+
return (_jsx(Button, { onClick: () => setShowForm(true), style: style, children: "Login with Token" }));
|
|
49
|
+
}
|
|
50
|
+
return (_jsxs(Box, { style: style, children: [_jsxs(FormControl, { children: [_jsx(FormControl.Label, { children: "Your Authentication Token" }), _jsx(TextInput, { block: true, placeholder: "Paste your authentication token here", value: token, onChange: e => setToken(e.target.value), onKeyDown: e => {
|
|
51
|
+
if (e.key === 'Enter') {
|
|
52
|
+
handleLogin();
|
|
53
|
+
}
|
|
54
|
+
else if (e.key === 'Escape') {
|
|
55
|
+
setShowForm(false);
|
|
56
|
+
setToken('');
|
|
57
|
+
}
|
|
58
|
+
} }), _jsx(FormControl.Caption, { children: "Enter your Datalayer authentication token to log in" })] }), _jsxs(Box, { mt: 3, display: "flex", justifyContent: "flex-start", children: [_jsx(Button, { variant: "primary", onClick: handleLogin, disabled: loading || !token.trim(), sx: { mr: 2 }, children: loading ? 'Authenticating...' : 'Login' }), _jsx(Button, { variant: "default", onClick: () => {
|
|
59
|
+
setShowForm(false);
|
|
60
|
+
setToken('');
|
|
61
|
+
}, children: "Cancel" })] })] }));
|
|
62
|
+
};
|
|
63
|
+
export default LoginToken;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Datalayer License
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Authentication components for Datalayer platform
|
|
12
|
+
*/
|
|
13
|
+
export * from './Login';
|
|
14
|
+
// LoginCLI is excluded from build - it's meant for CLI apps with full routing
|
|
15
|
+
// export * from './LoginCLI';
|
|
16
|
+
export * from './LoginToken';
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
type VariantType = 'marble' | 'beam' | 'pixel' | 'sunset' | 'ring' | 'bauhaus' | undefined;
|
|
2
2
|
type IBoringAvatarProps = {
|
|
3
|
-
displayName
|
|
4
|
-
variant
|
|
5
|
-
size
|
|
6
|
-
square
|
|
7
|
-
style
|
|
8
|
-
};
|
|
9
|
-
export declare const BoringAvatar: {
|
|
10
|
-
(props: IBoringAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
defaultProps: {
|
|
12
|
-
displayName: string;
|
|
13
|
-
variant: VariantType;
|
|
14
|
-
size: number;
|
|
15
|
-
square: boolean;
|
|
16
|
-
style: undefined;
|
|
17
|
-
};
|
|
3
|
+
displayName?: string;
|
|
4
|
+
variant?: VariantType;
|
|
5
|
+
size?: number;
|
|
6
|
+
square?: boolean;
|
|
7
|
+
style?: object;
|
|
18
8
|
};
|
|
9
|
+
export declare const BoringAvatar: ({ displayName, variant, size, square, style, }: IBoringAvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
10
|
export default BoringAvatar;
|
|
@@ -4,41 +4,37 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import BoringAvatars from 'boring-avatars';
|
|
7
|
-
|
|
8
|
-
const variants = [
|
|
9
|
-
"bauhaus",
|
|
10
|
-
"beam",
|
|
11
|
-
"marble",
|
|
12
|
-
"pixel",
|
|
13
|
-
"ring",
|
|
14
|
-
"sunset",
|
|
15
|
-
];
|
|
16
|
-
export const getRandomBoringAvatarVariant = () => variants[Math.floor(Math.random() * variants.length)] as VariantType;
|
|
17
|
-
*/
|
|
7
|
+
// export const getRandomBoringAvatarVariant = () => VARIANTS[Math.floor(Math.random() * VARIANTS.length)] as VariantType;
|
|
18
8
|
const getRandomBoringAvatarVariant = () => 'bauhaus';
|
|
19
9
|
const RANDOM_BORING_AVATOR_VARIANT = getRandomBoringAvatarVariant();
|
|
20
|
-
export const BoringAvatar = (
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
export const BoringAvatar = ({ displayName = '', variant, size = 40, square = false, style, }) => {
|
|
11
|
+
const resolvedVariant = variant ?? RANDOM_BORING_AVATOR_VARIANT;
|
|
12
|
+
const safeName = String(displayName ?? '');
|
|
13
|
+
try {
|
|
14
|
+
return (_jsx("span", { style: { ...(style || {}) }, children: _jsx(BoringAvatars, { size: size, name: safeName, variant: resolvedVariant, square: square, colors: [
|
|
15
|
+
'#000000',
|
|
16
|
+
'#146A7C',
|
|
17
|
+
'#16A085',
|
|
18
|
+
'#1ABC9C',
|
|
19
|
+
'#2ECC71',
|
|
20
|
+
'#59595C',
|
|
21
|
+
'#92A1C6',
|
|
22
|
+
'#C20D90',
|
|
23
|
+
'#C271B4',
|
|
24
|
+
'#F0AB3D',
|
|
25
|
+
// '#FFFFFF',
|
|
26
|
+
] }) }));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('BoringAvatar error:', error);
|
|
30
|
+
return (_jsx("span", { style: {
|
|
31
|
+
display: 'inline-block',
|
|
32
|
+
width: `${size}px`,
|
|
33
|
+
height: `${size}px`,
|
|
34
|
+
borderRadius: square ? '4px' : '50%',
|
|
35
|
+
backgroundColor: '#59595C',
|
|
36
|
+
...(style || {}),
|
|
37
|
+
} }));
|
|
38
|
+
}
|
|
43
39
|
};
|
|
44
40
|
export default BoringAvatar;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
defaultProps: {
|
|
13
|
-
displayName: string;
|
|
14
|
-
variant: "marble" | "beam" | "pixel" | "sunset" | "ring" | "bauhaus" | undefined;
|
|
15
|
-
size: number;
|
|
16
|
-
square: boolean;
|
|
17
|
-
style: undefined;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
4
|
+
component: ({ displayName, variant, size, square, style, }: {
|
|
5
|
+
displayName?: string;
|
|
6
|
+
variant?: "marble" | "beam" | "pixel" | "sunset" | "ring" | "bauhaus" | undefined;
|
|
7
|
+
size?: number;
|
|
8
|
+
square?: boolean;
|
|
9
|
+
style?: object;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
20
11
|
tags: string[];
|
|
21
12
|
parameters: {
|
|
22
13
|
layout: string;
|
|
@@ -4,10 +4,5 @@ type IUserProfileAvatarProps = {
|
|
|
4
4
|
size?: number;
|
|
5
5
|
onClick?: React.MouseEventHandler<any>;
|
|
6
6
|
};
|
|
7
|
-
export declare const UserProfileAvatar: {
|
|
8
|
-
(props: IUserProfileAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
defaultProps: {
|
|
10
|
-
size: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
7
|
+
export declare const UserProfileAvatar: ({ onClick, user, size, }: IUserProfileAvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
8
|
export default UserProfileAvatar;
|
|
@@ -7,19 +7,14 @@ import { Avatar, Link } from '@primer/react';
|
|
|
7
7
|
import { Box } from '@datalayer/primer-addons';
|
|
8
8
|
import { AvatarSkeleton } from '../../components/display';
|
|
9
9
|
import { getAvatarURL } from '../../utils';
|
|
10
|
-
const Profile = (
|
|
11
|
-
const { user, size, onClick } = props;
|
|
10
|
+
const Profile = ({ user, size = 100, onClick }) => {
|
|
12
11
|
return (_jsx(Box, { style: { width: size }, children: _jsx(Avatar
|
|
13
12
|
// square
|
|
14
13
|
, {
|
|
15
14
|
// square
|
|
16
15
|
src: getAvatarURL(user?.avatarUrl), size: size, onClick: onClick }) }));
|
|
17
16
|
};
|
|
18
|
-
export const UserProfileAvatar = (
|
|
19
|
-
|
|
20
|
-
return user ? (onClick ? (_jsx(Link, { href: "javascript: return false;", onClick: onClick, children: _jsx(Profile, { ...props }) })) : (_jsx(Profile, { ...props }))) : (_jsx(AvatarSkeleton, { size: size }));
|
|
21
|
-
};
|
|
22
|
-
UserProfileAvatar.defaultProps = {
|
|
23
|
-
size: 100,
|
|
17
|
+
export const UserProfileAvatar = ({ onClick, user, size = 100, }) => {
|
|
18
|
+
return user ? (onClick ? (_jsx(Link, { href: "javascript: return false;", onClick: onClick, children: _jsx(Profile, { user: user, size: size, onClick: onClick }) })) : (_jsx(Profile, { user: user, size: size, onClick: onClick }))) : (_jsx(AvatarSkeleton, { size: size }));
|
|
24
19
|
};
|
|
25
20
|
export default UserProfileAvatar;
|
|
@@ -2,12 +2,7 @@ import { VariantType } from './VariantType';
|
|
|
2
2
|
type IDownloadCSVButtonProps = {
|
|
3
3
|
data?: object;
|
|
4
4
|
fileName: string;
|
|
5
|
-
variant
|
|
6
|
-
};
|
|
7
|
-
export declare const DownloadCSVButton: {
|
|
8
|
-
(props: IDownloadCSVButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
defaultProps: {
|
|
10
|
-
variant: string;
|
|
11
|
-
};
|
|
5
|
+
variant?: VariantType;
|
|
12
6
|
};
|
|
7
|
+
export declare const DownloadCSVButton: ({ data, fileName, variant, }: IDownloadCSVButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
8
|
export default DownloadCSVButton;
|
|
@@ -6,11 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { Button } from '@primer/react';
|
|
7
7
|
import { DownloadIcon } from '@primer/octicons-react';
|
|
8
8
|
import { downloadCSV } from '../../utils';
|
|
9
|
-
export const DownloadCSVButton = (
|
|
10
|
-
const { data, fileName, variant } = props;
|
|
9
|
+
export const DownloadCSVButton = ({ data, fileName, variant = 'default', }) => {
|
|
11
10
|
return (_jsx(Button, { variant: variant, leadingVisual: DownloadIcon, onClick: e => downloadCSV(data, fileName), children: "Download" }));
|
|
12
11
|
};
|
|
13
|
-
DownloadCSVButton.defaultProps = {
|
|
14
|
-
variant: 'default',
|
|
15
|
-
};
|
|
16
12
|
export default DownloadCSVButton;
|
|
@@ -2,15 +2,8 @@ import { VariantType } from './VariantType';
|
|
|
2
2
|
type IDownloadJsonButtonProps = {
|
|
3
3
|
data?: object;
|
|
4
4
|
fileName: string;
|
|
5
|
-
extension
|
|
6
|
-
variant
|
|
7
|
-
};
|
|
8
|
-
export declare const DownloadJsonButton: {
|
|
9
|
-
(props: IDownloadJsonButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
defaultProps: {
|
|
11
|
-
variant: string;
|
|
12
|
-
name: string;
|
|
13
|
-
extension: string;
|
|
14
|
-
};
|
|
5
|
+
extension?: string;
|
|
6
|
+
variant?: VariantType;
|
|
15
7
|
};
|
|
8
|
+
export declare const DownloadJsonButton: ({ data, fileName, variant, extension, }: IDownloadJsonButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
9
|
export default DownloadJsonButton;
|
|
@@ -6,13 +6,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import { Button } from '@primer/react';
|
|
7
7
|
import { DownloadIcon } from '@primer/octicons-react';
|
|
8
8
|
import { downloadJson } from '../../utils';
|
|
9
|
-
export const DownloadJsonButton = (
|
|
10
|
-
const { data, fileName, variant, extension } = props;
|
|
9
|
+
export const DownloadJsonButton = ({ data, fileName, variant = 'default', extension = 'json', }) => {
|
|
11
10
|
return (_jsx(Button, { variant: variant, leadingVisual: DownloadIcon, onClick: e => downloadJson(data, fileName, extension), children: "Download" }));
|
|
12
11
|
};
|
|
13
|
-
DownloadJsonButton.defaultProps = {
|
|
14
|
-
variant: 'default',
|
|
15
|
-
name: 'data',
|
|
16
|
-
extension: 'json',
|
|
17
|
-
};
|
|
18
12
|
export default DownloadJsonButton;
|
|
@@ -30,8 +30,5 @@ export interface IUploadButtonProps extends Omit<IUploadBaseButtonProps, 'button
|
|
|
30
30
|
*/
|
|
31
31
|
variant?: VariantType;
|
|
32
32
|
}
|
|
33
|
-
export declare function UploadButton(
|
|
34
|
-
export declare namespace UploadButton {
|
|
35
|
-
var defaultProps: Partial<IUploadButtonProps>;
|
|
36
|
-
}
|
|
33
|
+
export declare function UploadButton({ label, variant, ...others }: IUploadButtonProps): JSX.Element;
|
|
37
34
|
export default UploadButton;
|
|
@@ -29,15 +29,11 @@ function UploadBaseButton(props) {
|
|
|
29
29
|
}
|
|
30
30
|
export function UploadIconButton(props) {
|
|
31
31
|
const { label, ...others } = props;
|
|
32
|
-
const factory = useMemo(() => (onClick) => (_jsx(IconButton, { "aria-label": label, icon: UploadIcon, size: "small", variant: "invisible", onClick: onClick })), []);
|
|
32
|
+
const factory = useMemo(() => (onClick) => (_jsx(IconButton, { "aria-label": label, icon: UploadIcon, size: "small", variant: "invisible", onClick: onClick })), [label]);
|
|
33
33
|
return _jsx(UploadBaseButton, { buttonFactory: factory, ...others });
|
|
34
34
|
}
|
|
35
|
-
export function UploadButton(
|
|
36
|
-
const { label, variant,
|
|
37
|
-
const factory = useMemo(() => (onClick) => (_jsx(Button, { "aria-label": label, leadingVisual: () => _jsx(UploadIcon, { fill: "white" }), size: "small", variant: variant, onClick: onClick, children: label })), []);
|
|
35
|
+
export function UploadButton({ label, variant = 'primary', ...others }) {
|
|
36
|
+
const factory = useMemo(() => (onClick) => (_jsx(Button, { "aria-label": label, leadingVisual: () => _jsx(UploadIcon, { fill: "white" }), size: "small", variant: variant, onClick: onClick, children: label })), [label, variant]);
|
|
38
37
|
return _jsx(UploadBaseButton, { buttonFactory: factory, ...others });
|
|
39
38
|
}
|
|
40
|
-
UploadButton.defaultProps = {
|
|
41
|
-
variant: 'primary',
|
|
42
|
-
};
|
|
43
39
|
export default UploadButton;
|