@linagora/twake-mui 14.3.0 → 14.4.0
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/CHANGELOG.md +7 -0
- package/dist/components/ActionsMenu/Actions/favorites.d.ts +2 -1
- package/dist/components/ActionsMenu/types.d.ts +0 -6
- package/dist/components/PointerAlert/PointerAlert.stories.js +2 -11
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -1
- package/dist/providers/AlertProvider/AlertProvider.stories.d.ts +9 -0
- package/dist/providers/AlertProvider/AlertProvider.stories.js +57 -0
- package/dist/providers/AlertProvider/index.d.ts +6 -0
- package/dist/providers/AlertProvider/index.js +25 -0
- package/dist/providers/AlertProvider/useAlert.d.ts +17 -0
- package/dist/providers/AlertProvider/useAlert.js +9 -0
- package/dist/stories/ThemePlayground.stories.js +1 -1
- package/package.json +1 -1
- /package/dist/{components → providers}/ThemeProvider/index.d.ts +0 -0
- /package/dist/{components → providers}/ThemeProvider/index.js +0 -0
- /package/dist/{components → providers}/ThemeProvider/types.d.ts +0 -0
- /package/dist/{components → providers}/ThemeProvider/types.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# @linagora/twake-mui [14.4.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@14.3.0...@linagora/twake-mui@14.4.0) (2026-10-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **twake-mui:** Migrate AlertProvider from cozy-ui ([9abdc95](https://github.com/linagora/twake-ui/commit/9abdc95037d43d96d2cdcc5c498567f0e065d018))
|
|
7
|
+
|
|
1
8
|
# @linagora/twake-mui [14.3.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@14.2.0...@linagora/twake-mui@14.3.0) (2026-10-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ShowAlert } from '../../../providers/AlertProvider/useAlert';
|
|
2
|
+
import { Action, ActionDocument } from '../types';
|
|
2
3
|
export interface FavoritesActionOptions {
|
|
3
4
|
client: {
|
|
4
5
|
save: (doc: ActionDocument) => Promise<unknown>;
|
|
@@ -57,12 +57,6 @@ export interface Action<Options extends object = ActionCallbackOptions> {
|
|
|
57
57
|
/** An action keyed by its name, as built by `makeActions` */
|
|
58
58
|
export type ActionObject = Record<string, Action>;
|
|
59
59
|
export type ActionFactory<FactoryOptions extends object = object> = (options: FactoryOptions) => Action;
|
|
60
|
-
export interface ShowAlertOptions {
|
|
61
|
-
message: string;
|
|
62
|
-
severity: 'success' | 'error' | 'info' | 'warning';
|
|
63
|
-
variant?: 'filled' | 'outlined' | 'standard';
|
|
64
|
-
}
|
|
65
|
-
export type ShowAlert = (options: ShowAlertOptions) => void;
|
|
66
60
|
export interface WebLinkOptions {
|
|
67
61
|
slug: string;
|
|
68
62
|
cozyUrl: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import {
|
|
2
|
+
import { Download, Icon } from '@linagora/twake-icons';
|
|
3
3
|
import { AlertTitle, Button, Stack, Typography } from '@mui/material';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PointerAlert from './index';
|
|
@@ -39,8 +39,7 @@ const meta = {
|
|
|
39
39
|
control: 'select',
|
|
40
40
|
options: severities,
|
|
41
41
|
description: 'Overrides the colour taken from `severity`'
|
|
42
|
-
}
|
|
43
|
-
square: { control: 'boolean' }
|
|
42
|
+
}
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
45
|
export default meta;
|
|
@@ -73,14 +72,6 @@ export const Screenshot = {
|
|
|
73
72
|
React.createElement(PointerAlert, { severity: "primary" },
|
|
74
73
|
React.createElement(AlertTitle, null, "This is the title"),
|
|
75
74
|
text),
|
|
76
|
-
React.createElement(PointerAlert, { severity: "primary", color: "warning" },
|
|
77
|
-
"Colour overridden: ",
|
|
78
|
-
text),
|
|
79
|
-
React.createElement(PointerAlert, { severity: "primary", icon: React.createElement(Icon, { icon: DeviceLaptop, color: "var(--twake-palette-error-main)", size: 32 }) }, text),
|
|
80
|
-
React.createElement(PointerAlert, { severity: "primary", icon: false }, text),
|
|
81
|
-
React.createElement(PointerAlert, { severity: "primary", square: true },
|
|
82
|
-
"Square: ",
|
|
83
|
-
text),
|
|
84
75
|
React.createElement(PointerAlert, { severity: "primary", onClose: () => console.log('closed') }, text),
|
|
85
76
|
React.createElement(PointerAlert, { severity: "primary", action: React.createElement(React.Fragment, null,
|
|
86
77
|
downloadAction,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { default as Autocomplete } from '@mui/material/Autocomplete';
|
|
|
5
5
|
export { makePalette } from './lib/makePalette';
|
|
6
6
|
export { theme } from './lib/theme';
|
|
7
7
|
export { radius } from './lib/radius';
|
|
8
|
-
export { TwakeMuiThemeProvider } from './
|
|
8
|
+
export { TwakeMuiThemeProvider } from './providers/ThemeProvider';
|
|
9
9
|
export { default as ActionsBar } from './components/ActionsBar';
|
|
10
10
|
export { default as ActionsMenu } from './components/ActionsMenu';
|
|
11
11
|
export { default as ActionsMenuWrapper } from './components/ActionsMenu/ActionsMenuWrapper';
|
|
@@ -57,6 +57,10 @@ export { default as LoadMore } from './components/LoadMore';
|
|
|
57
57
|
export { default as Markdown } from './components/Markdown';
|
|
58
58
|
export { default as MidEllipsis } from './components/MidEllipsis';
|
|
59
59
|
export { default as PointerAlert } from './components/PointerAlert';
|
|
60
|
+
export type { AlertProviderProps } from './providers/AlertProvider';
|
|
61
|
+
export type { AlertContextValue, ShowAlert, ShowAlertOptions } from './providers/AlertProvider/useAlert';
|
|
62
|
+
export { default as AlertProvider } from './providers/AlertProvider';
|
|
63
|
+
export { useAlert } from './providers/AlertProvider/useAlert';
|
|
60
64
|
export { default as ProgressionBanner } from './components/ProgressionBanner';
|
|
61
65
|
export { Tabs, default as TabsDefault } from './components/Tabs';
|
|
62
66
|
export { Switch, default as SwitchDefault } from './components/Switch';
|
|
@@ -92,7 +96,7 @@ export type { ActionsMenuItemProps } from './components/ActionsMenu/ActionsMenuI
|
|
|
92
96
|
export type { ActionsMenuMobileHeaderProps } from './components/ActionsMenu/ActionsMenuMobileHeader';
|
|
93
97
|
export type { ActionsMenuButtonProps } from './components/ActionsMenu/ActionsMenuButton';
|
|
94
98
|
export type { ActionsItemsProps } from './components/ActionsMenu/ActionsItems';
|
|
95
|
-
export type { Action, ActionCallbackOptions, ActionComponent, ActionComponentProps, ActionComponentSlotProps, ActionDocument, ActionFactory, ActionObject, ActionTranslate, GenerateWebLink,
|
|
99
|
+
export type { Action, ActionCallbackOptions, ActionComponent, ActionComponentProps, ActionComponentSlotProps, ActionDocument, ActionFactory, ActionObject, ActionTranslate, GenerateWebLink, WebLinkActionOptions, WebLinkClient, WebLinkOptions } from './components/ActionsMenu/types';
|
|
96
100
|
export type { MakeActionComponentOptions, MakeActionOptions } from './components/ActionsMenu/Actions/makeAction';
|
|
97
101
|
export type { AppWebLinkOptions, FetchBlobFileById, MakePdfBlobOptions } from './components/ActionsMenu/Actions/helpers';
|
|
98
102
|
export type { WrapTextToLinesOptions, PdfCursor, PushNewPageIfNeededOptions, DrawWrappedTextOptions } from './components/ActionsMenu/Actions/pdfHelpers';
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { makePalette } from './lib/makePalette';
|
|
|
8
8
|
export { theme } from './lib/theme';
|
|
9
9
|
export { radius } from './lib/radius';
|
|
10
10
|
// COMPONENTS & HELPERS
|
|
11
|
-
export { TwakeMuiThemeProvider } from './
|
|
11
|
+
export { TwakeMuiThemeProvider } from './providers/ThemeProvider';
|
|
12
12
|
export { default as ActionsBar } from './components/ActionsBar';
|
|
13
13
|
export { default as ActionsMenu } from './components/ActionsMenu';
|
|
14
14
|
export { default as ActionsMenuWrapper } from './components/ActionsMenu/ActionsMenuWrapper';
|
|
@@ -60,6 +60,8 @@ export { default as LoadMore } from './components/LoadMore';
|
|
|
60
60
|
export { default as Markdown } from './components/Markdown';
|
|
61
61
|
export { default as MidEllipsis } from './components/MidEllipsis';
|
|
62
62
|
export { default as PointerAlert } from './components/PointerAlert';
|
|
63
|
+
export { default as AlertProvider } from './providers/AlertProvider';
|
|
64
|
+
export { useAlert } from './providers/AlertProvider/useAlert';
|
|
63
65
|
export { default as ProgressionBanner } from './components/ProgressionBanner';
|
|
64
66
|
export { Tabs, default as TabsDefault } from './components/Tabs';
|
|
65
67
|
export { Switch, default as SwitchDefault } from './components/Switch';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { ShowAlertOptions } from './useAlert';
|
|
3
|
+
interface StoryArgs extends ShowAlertOptions {
|
|
4
|
+
closable: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const meta: Meta<StoryArgs>;
|
|
7
|
+
export default meta;
|
|
8
|
+
type Story = StoryObj<typeof meta>;
|
|
9
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Button } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import AlertProvider from './index';
|
|
4
|
+
import { useAlert } from './useAlert';
|
|
5
|
+
const severities = [
|
|
6
|
+
'primary',
|
|
7
|
+
'secondary',
|
|
8
|
+
'success',
|
|
9
|
+
'error',
|
|
10
|
+
'warning',
|
|
11
|
+
'info'
|
|
12
|
+
];
|
|
13
|
+
const variants = ['filled', 'standard', 'outlined'];
|
|
14
|
+
const makeOptions = ({ closable, ...options }) => closable ? options : { ...options, onClose: undefined };
|
|
15
|
+
const meta = {
|
|
16
|
+
title: 'AlertProvider',
|
|
17
|
+
parameters: { layout: 'centered' },
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
argTypes: {
|
|
20
|
+
message: { control: 'text' },
|
|
21
|
+
title: { control: 'text' },
|
|
22
|
+
severity: { control: 'select', options: severities },
|
|
23
|
+
variant: { control: 'select', options: variants },
|
|
24
|
+
icon: {
|
|
25
|
+
control: 'select',
|
|
26
|
+
options: ['default', 'none'],
|
|
27
|
+
mapping: { default: undefined, none: false }
|
|
28
|
+
},
|
|
29
|
+
duration: {
|
|
30
|
+
control: 'number',
|
|
31
|
+
description: 'Milliseconds before the alert hides, `null` to keep it open'
|
|
32
|
+
},
|
|
33
|
+
noTimeOut: { control: 'boolean' },
|
|
34
|
+
noClickAway: { control: 'boolean' },
|
|
35
|
+
closable: {
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
description: 'Story only: passes `onClose: undefined` when off'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export default meta;
|
|
42
|
+
const ShowAlertButton = ({ args }) => {
|
|
43
|
+
const { showAlert } = useAlert();
|
|
44
|
+
return (React.createElement(Button, { onClick: () => showAlert(makeOptions(args)) }, "Show alert"));
|
|
45
|
+
};
|
|
46
|
+
export const Default = {
|
|
47
|
+
args: {
|
|
48
|
+
message: 'Alert message',
|
|
49
|
+
severity: 'success',
|
|
50
|
+
variant: 'filled',
|
|
51
|
+
noTimeOut: false,
|
|
52
|
+
noClickAway: false,
|
|
53
|
+
closable: true
|
|
54
|
+
},
|
|
55
|
+
render: args => (React.createElement(AlertProvider, null,
|
|
56
|
+
React.createElement(ShowAlertButton, { args: args })))
|
|
57
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Alert, AlertTitle, Snackbar } from '@mui/material';
|
|
2
|
+
import React, { useMemo, useState } from 'react';
|
|
3
|
+
import { AlertContext } from './useAlert';
|
|
4
|
+
const AlertProvider = ({ children }) => {
|
|
5
|
+
const [state, setState] = useState({ message: '', open: false });
|
|
6
|
+
const { open, message, title, duration, noTimeOut, noClickAway, ...alertProps } = state;
|
|
7
|
+
const value = useMemo(() => ({
|
|
8
|
+
showAlert: (options) => setState({ ...options, open: true })
|
|
9
|
+
}), []);
|
|
10
|
+
const close = () => setState(current => ({ ...current, open: false }));
|
|
11
|
+
const handleSnackbarClose = (_event, reason) => {
|
|
12
|
+
if (reason === 'clickaway' && noClickAway)
|
|
13
|
+
return;
|
|
14
|
+
if (reason === 'timeout' && noTimeOut)
|
|
15
|
+
return;
|
|
16
|
+
close();
|
|
17
|
+
};
|
|
18
|
+
return (React.createElement(AlertContext.Provider, { value: value },
|
|
19
|
+
children,
|
|
20
|
+
React.createElement(Snackbar, { open: open, autoHideDuration: duration, onClose: handleSnackbarClose },
|
|
21
|
+
React.createElement(Alert, { variant: "filled", elevation: 6, onClose: close, ...alertProps },
|
|
22
|
+
title && React.createElement(AlertTitle, null, title),
|
|
23
|
+
message))));
|
|
24
|
+
};
|
|
25
|
+
export default AlertProvider;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AlertProps } from '@mui/material';
|
|
2
|
+
export interface ShowAlertOptions extends Omit<AlertProps, 'title'> {
|
|
3
|
+
message: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Milliseconds before the alert hides, `null` to keep it open */
|
|
6
|
+
duration?: number | null;
|
|
7
|
+
/** Ignores the timeout set by `duration` */
|
|
8
|
+
noTimeOut?: boolean;
|
|
9
|
+
/** Keeps the alert open on a click outside of it */
|
|
10
|
+
noClickAway?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type ShowAlert = (options: ShowAlertOptions) => void;
|
|
13
|
+
export interface AlertContextValue {
|
|
14
|
+
showAlert: ShowAlert;
|
|
15
|
+
}
|
|
16
|
+
export declare const AlertContext: import("react").Context<AlertContextValue | null>;
|
|
17
|
+
export declare const useAlert: () => AlertContextValue;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
export const AlertContext = createContext(null);
|
|
3
|
+
export const useAlert = () => {
|
|
4
|
+
const context = useContext(AlertContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('useAlert must be used within a AlertProvider');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button, Stack, Chip } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { TwakeMuiThemeProvider } from '../components/ThemeProvider';
|
|
4
3
|
import { makePalette } from '../lib/makePalette';
|
|
4
|
+
import { TwakeMuiThemeProvider } from '../providers/ThemeProvider';
|
|
5
5
|
const CUSTOM_PALETTE = {
|
|
6
6
|
Primary: {
|
|
7
7
|
50: '#FFF9F6',
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|