@linagora/twake-mui 14.2.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 +14 -0
- package/dist/components/ActionsMenu/Actions/favorites.d.ts +2 -1
- package/dist/components/ActionsMenu/types.d.ts +0 -6
- package/dist/components/PasswordField/PasswordField.stories.d.ts +7 -0
- package/dist/components/PasswordField/PasswordField.stories.js +43 -0
- package/dist/components/PasswordField/index.d.ts +6 -0
- package/dist/components/PasswordField/index.js +28 -0
- package/dist/components/PasswordField/locales/de.json +6 -0
- package/dist/components/PasswordField/locales/en.json +6 -0
- package/dist/components/PasswordField/locales/es.json +6 -0
- package/dist/components/PasswordField/locales/fr.json +6 -0
- package/dist/components/PasswordField/locales/it.json +6 -0
- package/dist/components/PasswordField/locales/ru.json +6 -0
- package/dist/components/PasswordField/locales/vi.json +6 -0
- package/dist/components/PointerAlert/PointerAlert.stories.js +2 -11
- package/dist/index.d.ts +8 -2
- package/dist/index.js +4 -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,17 @@
|
|
|
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
|
+
|
|
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)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **twake-mui:** Migrate PasswordField from cozy-ui ([5d39ddd](https://github.com/linagora/twake-ui/commit/5d39ddd8c7616e82c9f6c89cabe1a53b6b553864))
|
|
14
|
+
|
|
1
15
|
# @linagora/twake-mui [14.2.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@14.1.0...@linagora/twake-mui@14.2.0) (2026-10-15)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TextField } from '@mui/material';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
3
|
+
declare const meta: Meta<typeof TextField>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Screenshot: Story;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Stack } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PasswordField from './index';
|
|
4
|
+
// TextFieldProps is a union, which Storybook cannot infer args from
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'PasswordField',
|
|
7
|
+
component: PasswordField,
|
|
8
|
+
parameters: { layout: 'centered' },
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: {
|
|
11
|
+
label: { control: 'text' },
|
|
12
|
+
placeholder: { control: 'text' },
|
|
13
|
+
helperText: { control: 'text' },
|
|
14
|
+
size: { control: 'select', options: ['small', 'medium'] },
|
|
15
|
+
disabled: { control: 'boolean' },
|
|
16
|
+
error: { control: 'boolean' },
|
|
17
|
+
fullWidth: { control: 'boolean' }
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
export const Default = {
|
|
22
|
+
args: {
|
|
23
|
+
defaultValue: 'Cl4ude€st1Nu@ge'
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const Row = ({ title, children }) => (React.createElement("section", null,
|
|
27
|
+
React.createElement("h3", { style: { marginBottom: '12px' } }, title),
|
|
28
|
+
React.createElement(Stack, { direction: "row", spacing: 2, useFlexGap: true, sx: { flexWrap: 'wrap' } }, children)));
|
|
29
|
+
// Visual Regression - Combined view for Argos testing
|
|
30
|
+
export const Screenshot = {
|
|
31
|
+
tags: ['argos'],
|
|
32
|
+
render: () => (React.createElement(Stack, { spacing: 4 },
|
|
33
|
+
React.createElement(Row, { title: "Default" },
|
|
34
|
+
React.createElement(PasswordField, { defaultValue: "Cl4ude\u20ACst1Nu@ge" }),
|
|
35
|
+
React.createElement(PasswordField, { label: "Password", defaultValue: "Cl4ude\u20ACst1Nu@ge" }),
|
|
36
|
+
React.createElement(PasswordField, { label: "Password" })),
|
|
37
|
+
React.createElement(Row, { title: "Sizes" },
|
|
38
|
+
React.createElement(PasswordField, { size: "small", defaultValue: "Cl4ude\u20ACst1Nu@ge" }),
|
|
39
|
+
React.createElement(PasswordField, { size: "medium", defaultValue: "Cl4ude\u20ACst1Nu@ge" })),
|
|
40
|
+
React.createElement(Row, { title: "States" },
|
|
41
|
+
React.createElement(PasswordField, { label: "Disabled", disabled: true, defaultValue: "Cl4ude\u20ACst1Nu@ge" }),
|
|
42
|
+
React.createElement(PasswordField, { label: "Error", error: true, helperText: "Wrong password", defaultValue: "Cl4ude\u20ACst1Nu@ge" }))))
|
|
43
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type PasswordFieldProps = TextFieldProps;
|
|
4
|
+
/** Password field with a button to show or hide its value */
|
|
5
|
+
declare const PasswordField: ({ slotProps, ...props }: PasswordFieldProps) => React.ReactElement;
|
|
6
|
+
export default PasswordField;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Eye, EyeClosed, Icon } from '@linagora/twake-icons';
|
|
2
|
+
import { IconButton, InputAdornment, TextField } from '@mui/material';
|
|
3
|
+
import { mergeSlotProps } from '@mui/material/utils';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { useExtendI18n, useI18n } from 'twake-i18n';
|
|
6
|
+
import de from './locales/de.json';
|
|
7
|
+
import en from './locales/en.json';
|
|
8
|
+
import es from './locales/es.json';
|
|
9
|
+
import fr from './locales/fr.json';
|
|
10
|
+
import it from './locales/it.json';
|
|
11
|
+
import ru from './locales/ru.json';
|
|
12
|
+
import vi from './locales/vi.json';
|
|
13
|
+
const locales = { de, en, es, fr, it, ru, vi };
|
|
14
|
+
/** Password field with a button to show or hide its value */
|
|
15
|
+
const PasswordField = ({ slotProps, ...props }) => {
|
|
16
|
+
useExtendI18n(locales);
|
|
17
|
+
const { t } = useI18n();
|
|
18
|
+
const [hidden, setHidden] = useState(true);
|
|
19
|
+
return (React.createElement(TextField, { type: hidden ? 'password' : 'text', ...props, slotProps: {
|
|
20
|
+
...slotProps,
|
|
21
|
+
input: mergeSlotProps(slotProps?.input, {
|
|
22
|
+
endAdornment: (React.createElement(InputAdornment, { position: "end" },
|
|
23
|
+
React.createElement(IconButton, { "aria-label": hidden ? t('PasswordField.show') : t('PasswordField.hide'), disabled: props.disabled, onClick: () => setHidden(current => !current), edge: "end" },
|
|
24
|
+
React.createElement(Icon, { icon: hidden ? Eye : EyeClosed }))))
|
|
25
|
+
})
|
|
26
|
+
} }));
|
|
27
|
+
};
|
|
28
|
+
export default PasswordField;
|
|
@@ -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';
|
|
@@ -72,6 +76,7 @@ export { NavIcon } from './components/NavIcon';
|
|
|
72
76
|
export { default as NavText } from './components/NavText';
|
|
73
77
|
export { NavDesktopLimiter } from './components/NavDesktopLimiter';
|
|
74
78
|
export { NavDesktopDropdown } from './components/NavDesktopDropdown';
|
|
79
|
+
export { default as PasswordField } from './components/PasswordField';
|
|
75
80
|
export { nameToColor, supportedColors, getInitials } from './components/Avatar/helpers';
|
|
76
81
|
export { COLORS } from './components/ColorList/helpers';
|
|
77
82
|
export { default as AccordionExpandIcon } from './components/AccordionExpandIcon';
|
|
@@ -91,7 +96,7 @@ export type { ActionsMenuItemProps } from './components/ActionsMenu/ActionsMenuI
|
|
|
91
96
|
export type { ActionsMenuMobileHeaderProps } from './components/ActionsMenu/ActionsMenuMobileHeader';
|
|
92
97
|
export type { ActionsMenuButtonProps } from './components/ActionsMenu/ActionsMenuButton';
|
|
93
98
|
export type { ActionsItemsProps } from './components/ActionsMenu/ActionsItems';
|
|
94
|
-
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';
|
|
95
100
|
export type { MakeActionComponentOptions, MakeActionOptions } from './components/ActionsMenu/Actions/makeAction';
|
|
96
101
|
export type { AppWebLinkOptions, FetchBlobFileById, MakePdfBlobOptions } from './components/ActionsMenu/Actions/helpers';
|
|
97
102
|
export type { WrapTextToLinesOptions, PdfCursor, PushNewPageIfNeededOptions, DrawWrappedTextOptions } from './components/ActionsMenu/Actions/pdfHelpers';
|
|
@@ -149,6 +154,7 @@ export type { NavDropdownProps } from './components/NavLink/NavDropdown';
|
|
|
149
154
|
export type { NavIconProps } from './components/NavIcon';
|
|
150
155
|
export type { NavTextProps } from './components/NavText';
|
|
151
156
|
export type { NavDesktopLimiterProps } from './components/NavDesktopLimiter';
|
|
157
|
+
export type { PasswordFieldProps } from './components/PasswordField';
|
|
152
158
|
export type { NavDesktopDropdownProps } from './components/NavDesktopDropdown';
|
|
153
159
|
export type { VirtualizedTableProps, VirtualizedTableColumn, VirtualizedTableRow } from './components/VirtualizedTable';
|
|
154
160
|
export type { Breakpoints } from './hooks/useBreakpoints';
|
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';
|
|
@@ -75,6 +77,7 @@ export { NavIcon } from './components/NavIcon';
|
|
|
75
77
|
export { default as NavText } from './components/NavText';
|
|
76
78
|
export { NavDesktopLimiter } from './components/NavDesktopLimiter';
|
|
77
79
|
export { NavDesktopDropdown } from './components/NavDesktopDropdown';
|
|
80
|
+
export { default as PasswordField } from './components/PasswordField';
|
|
78
81
|
export { nameToColor, supportedColors, getInitials } from './components/Avatar/helpers';
|
|
79
82
|
export { COLORS } from './components/ColorList/helpers';
|
|
80
83
|
export { default as AccordionExpandIcon } from './components/AccordionExpandIcon';
|
|
@@ -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
|