@linagora/twake-mui 14.3.0 → 15.0.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/components/ActionsMenu/Actions/favorites.d.ts +2 -1
  3. package/dist/components/ActionsMenu/types.d.ts +0 -6
  4. package/dist/components/Avatar/Avatar.stories.d.ts +1 -1
  5. package/dist/components/Avatar/Avatar.stories.js +1 -1
  6. package/dist/components/Avatar/index.d.ts +1 -1
  7. package/dist/components/Avatar/index.js +1 -1
  8. package/dist/components/Button/index.d.ts +1 -1
  9. package/dist/components/Button/index.js +1 -1
  10. package/dist/components/ColorList/index.js +1 -1
  11. package/dist/components/ContactPopover/AttendeeInfo.js +1 -1
  12. package/dist/components/ContactPopover/ContactPopover.stories.d.ts +1 -1
  13. package/dist/components/ContactPopover/ContactPopover.stories.js +1 -1
  14. package/dist/components/ContactPopover/index.d.ts +1 -1
  15. package/dist/components/ContactPopover/index.js +1 -1
  16. package/dist/components/ListItem/ListItem.stories.js +1 -1
  17. package/dist/components/PointerAlert/PointerAlert.stories.js +2 -11
  18. package/dist/components/SearchBar/SearchBar.stories.d.ts +1 -1
  19. package/dist/components/SearchBar/SearchBar.stories.js +1 -1
  20. package/dist/components/SearchBar/index.d.ts +1 -1
  21. package/dist/components/SearchBar/index.js +1 -1
  22. package/dist/components/Switch/Switch.stories.d.ts +1 -1
  23. package/dist/components/Switch/Switch.stories.js +1 -1
  24. package/dist/components/Switch/index.d.ts +1 -1
  25. package/dist/components/Switch/index.js +1 -1
  26. package/dist/components/Tabs/Tabs.stories.d.ts +1 -1
  27. package/dist/components/Tabs/Tabs.stories.js +1 -1
  28. package/dist/components/Tabs/index.d.ts +1 -1
  29. package/dist/components/Tabs/index.js +1 -1
  30. package/dist/index.d.ts +12 -8
  31. package/dist/index.js +9 -7
  32. package/dist/providers/AlertProvider/AlertProvider.stories.d.ts +9 -0
  33. package/dist/providers/AlertProvider/AlertProvider.stories.js +57 -0
  34. package/dist/providers/AlertProvider/index.d.ts +6 -0
  35. package/dist/providers/AlertProvider/index.js +25 -0
  36. package/dist/providers/AlertProvider/useAlert.d.ts +17 -0
  37. package/dist/providers/AlertProvider/useAlert.js +9 -0
  38. package/dist/stories/Button.stories.d.ts +1 -1
  39. package/dist/stories/Button.stories.js +1 -1
  40. package/dist/stories/ThemePlayground.stories.js +1 -1
  41. package/package.json +1 -1
  42. /package/dist/{components → providers}/ThemeProvider/index.d.ts +0 -0
  43. /package/dist/{components → providers}/ThemeProvider/index.js +0 -0
  44. /package/dist/{components → providers}/ThemeProvider/types.d.ts +0 -0
  45. /package/dist/{components → providers}/ThemeProvider/types.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ # @linagora/twake-mui [15.0.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@14.4.0...@linagora/twake-mui@15.0.0) (2026-10-19)
2
+
3
+
4
+ ### Code Refactoring
5
+
6
+ * **twake-mui:** Export Avatar as default only ([a7a138e](https://github.com/linagora/twake-ui/commit/a7a138e0cf2e731fb5eba00bc7dfdbe2c8993f0b))
7
+ * **twake-mui:** Export Button as default only ([c5ac445](https://github.com/linagora/twake-ui/commit/c5ac445f3f438e1d3f366c906067b18fd19e2ded))
8
+ * **twake-mui:** Export ContactPopover as default only ([e74ddbe](https://github.com/linagora/twake-ui/commit/e74ddbec7a0fe526d508075364cc52d586cc26db))
9
+ * **twake-mui:** Export SearchBar as default only ([34d0050](https://github.com/linagora/twake-ui/commit/34d00502da7c41edfcf841a49494b139cf977d9f))
10
+ * **twake-mui:** Export Switch as default only ([b22aebc](https://github.com/linagora/twake-ui/commit/b22aebc9809137eb8a7effb30f8dd5ed98ff97cc))
11
+ * **twake-mui:** Export Tabs as default only ([47d31fe](https://github.com/linagora/twake-ui/commit/47d31fea3c68ba104ff92f455b7ca0db47d43cab))
12
+
13
+
14
+ ### BREAKING CHANGES
15
+
16
+ * **twake-mui:** ContactPopoverDefault is no longer exported. Import
17
+ ContactPopover instead.
18
+ * **twake-mui:** SearchBarDefault is no longer exported. Import SearchBar
19
+ instead.
20
+ * **twake-mui:** SwitchDefault is no longer exported. Import Switch
21
+ instead.
22
+ * **twake-mui:** TabsDefault is no longer exported. Import Tabs
23
+ instead.
24
+ * **twake-mui:** ButtonDefault is no longer exported. Import Button
25
+ instead.
26
+ * **twake-mui:** AvatarDefault is no longer exported. Import Avatar
27
+ instead.
28
+
29
+ # @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)
30
+
31
+
32
+ ### Features
33
+
34
+ * **twake-mui:** Migrate AlertProvider from cozy-ui ([9abdc95](https://github.com/linagora/twake-ui/commit/9abdc95037d43d96d2cdcc5c498567f0e065d018))
35
+
1
36
  # @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
37
 
3
38
 
@@ -1,4 +1,5 @@
1
- import { Action, ActionDocument, ShowAlert } from '../types';
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
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Avatar } from './index';
2
+ import Avatar from './index';
3
3
  declare const meta: Meta<typeof Avatar>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
@@ -2,7 +2,7 @@ import { Icon, Link } from '@linagora/twake-icons';
2
2
  import { AvatarGroup, Stack } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { supportedColors } from './helpers';
5
- import { Avatar } from './index';
5
+ import Avatar from './index';
6
6
  const sizes = ['xs', 's', 'm', 'l', 'xl'];
7
7
  const image = 'https://i.pravatar.cc/150?img=11';
8
8
  const meta = {
@@ -10,5 +10,5 @@ export interface AvatarProps extends Omit<MuiAvatarProps, 'color'> {
10
10
  disabled?: boolean;
11
11
  display?: 'initial' | 'inline';
12
12
  }
13
- export declare const Avatar: React.FC<AvatarProps>;
13
+ declare const Avatar: React.FC<AvatarProps>;
14
14
  export default Avatar;
@@ -16,7 +16,7 @@ const StyledAvatar = styled(MuiAvatar, {
16
16
  ...(background && { background, color: '#fff' }),
17
17
  ...(textColor && { color: textColor })
18
18
  }));
19
- export const Avatar = ({ className, color, size = 'm', textColor, border, innerBorder, disabled, display = 'initial', children, ...props }) => {
19
+ const Avatar = ({ className, color, size = 'm', textColor, border, innerBorder, disabled, display = 'initial', children, ...props }) => {
20
20
  const isCustomSize = typeof size === 'number';
21
21
  const nameColor = typeof children === 'string' ? nameToColor(children) : '';
22
22
  const madeColor = color === 'none' ? '' : color || nameColor;
@@ -13,7 +13,7 @@ export interface ButtonTypeMap<AdditionalProps = object, RootComponent extends R
13
13
  defaultComponent: RootComponent;
14
14
  }
15
15
  export type ButtonProps<RootComponent extends React.ElementType = 'button', AdditionalProps = object> = OverrideProps<ButtonTypeMap<AdditionalProps, RootComponent>, RootComponent>;
16
- export declare const Button: OverridableComponent<ButtonTypeMap> & {
16
+ declare const Button: OverridableComponent<ButtonTypeMap> & {
17
17
  displayName?: string;
18
18
  };
19
19
  export default Button;
@@ -3,6 +3,6 @@ import React from 'react';
3
3
  // legacy variant names, mapped to their MUI counterpart
4
4
  const legacyVariants = { primary: 'contained', secondary: 'outlined' };
5
5
  const isLegacy = (variant) => typeof variant === 'string' && variant in legacyVariants;
6
- export const Button = React.forwardRef(({ variant, ...props }, ref) => (React.createElement(MuiButton, { ref: ref, variant: isLegacy(variant) ? legacyVariants[variant] : variant, ...props })));
6
+ const Button = React.forwardRef(({ variant, ...props }, ref) => (React.createElement(MuiButton, { ref: ref, variant: isLegacy(variant) ? legacyVariants[variant] : variant, ...props })));
7
7
  Button.displayName = 'Button';
8
8
  export default Button;
@@ -3,7 +3,7 @@ import { ButtonBase, ImageList, ImageListItem, imageListItemClasses } from '@mui
3
3
  import { styled } from '@mui/material/styles';
4
4
  import React from 'react';
5
5
  import { useBreakpoints } from '../../hooks/useBreakpoints';
6
- import { Avatar } from '../Avatar';
6
+ import Avatar from '../Avatar';
7
7
  import { COLORS } from './helpers';
8
8
  const sizes = {
9
9
  small: { avatar: 21, icon: 10, cols: 7, gap: 5 },
@@ -3,7 +3,7 @@ import { Copy } from '@linagora/twake-icons';
3
3
  import { Box, IconButton, Typography, useTheme } from '@mui/material';
4
4
  import React, { useState } from 'react';
5
5
  import { useI18n } from 'twake-i18n';
6
- import { Avatar } from '../Avatar';
6
+ import Avatar from '../Avatar';
7
7
  import { nameToColor, getInitials } from '../Avatar/helpers';
8
8
  export const AttendeeInfo = ({ name, email, onEmailCopy }) => {
9
9
  const theme = useTheme();
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { ContactPopover } from './index';
2
+ import ContactPopover from './index';
3
3
  declare const meta: Meta<typeof ContactPopover>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof ContactPopover>;
@@ -1,7 +1,7 @@
1
1
  import { Chip, Box, Typography } from '@mui/material';
2
2
  import React from 'react';
3
3
  import { screen } from 'storybook/test';
4
- import { ContactPopover } from './index';
4
+ import ContactPopover from './index';
5
5
  const meta = {
6
6
  title: 'ContactPopover',
7
7
  component: ContactPopover,
@@ -25,6 +25,6 @@ interface ContactPopoverComponent extends React.FC<ContactPopoverProps> {
25
25
  CalendarAction: typeof ContactPopoverCalendarAction;
26
26
  EmailAction: typeof ContactPopoverEmailAction;
27
27
  }
28
- export declare const ContactPopover: ContactPopoverComponent;
28
+ declare const ContactPopover: ContactPopoverComponent;
29
29
  export { ContactPopoverActions, ContactPopoverChatAction, ContactPopoverVideoAction, ContactPopoverCalendarAction, ContactPopoverEmailAction };
30
30
  export default ContactPopover;
@@ -30,7 +30,7 @@ const CloseButton = styled(IconButton)(() => ({
30
30
  top: 8,
31
31
  right: 8
32
32
  }));
33
- export const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled = false }) => {
33
+ const ContactPopover = ({ name, email, children, onEmailCopy, onClose, disabled = false }) => {
34
34
  useExtendI18n(locales);
35
35
  const [anchorEl, setAnchorEl] = useState(null);
36
36
  const openTimeoutRef = useRef(null);
@@ -2,7 +2,7 @@ import { Comment, Dots, Icon, Pen, People, Right, Trash } from '@linagora/twake-
2
2
  import { Box, Checkbox, IconButton, List, ListItemAvatar, ListItemIcon, ListItemSecondaryAction, Radio, Stack } from '@mui/material';
3
3
  import React from 'react';
4
4
  import ListItem from './index';
5
- import { Avatar } from '../Avatar';
5
+ import Avatar from '../Avatar';
6
6
  import ListItemButton from '../ListItemButton';
7
7
  import ListItemText from '../ListItemText';
8
8
  import ListSubheader from '../ListSubheader';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-console */
2
- import { DeviceLaptop, Download, Icon } from '@linagora/twake-icons';
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,
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { SearchBar } from './index';
2
+ import SearchBar from './index';
3
3
  declare const meta: Meta<typeof SearchBar>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
@@ -1,7 +1,7 @@
1
1
  import { Cloud } from '@linagora/twake-icons';
2
2
  import { Stack, Typography } from '@mui/material';
3
3
  import React from 'react';
4
- import { SearchBar } from './index';
4
+ import SearchBar from './index';
5
5
  const sizes = ['small', 'medium', 'large', 'auto'];
6
6
  const meta = {
7
7
  title: 'SearchBar',
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { SearchBarProps } from './types';
3
- export declare const SearchBar: React.ForwardRefExoticComponent<Omit<SearchBarProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
3
+ declare const SearchBar: React.ForwardRefExoticComponent<Omit<SearchBarProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
4
  export default SearchBar;
@@ -19,7 +19,7 @@ import it from './locales/it.json';
19
19
  import ru from './locales/ru.json';
20
20
  import vi from './locales/vi.json';
21
21
  const locales = { de, en, es, fr, it, ru, vi };
22
- export const SearchBar = forwardRef(({ placeholder, icon = Magnifier, size = 'small', type = 'search', label, componentsProps, disabledClear = false, disabledFocus = false, disabledHover = false, className, defaultValue = '', value, elevation = 1, disabled = false, onChange = () => { }, onClear = () => { }, onFocus = () => { }, onBlur = () => { }, ...props }, ref) => {
22
+ const SearchBar = forwardRef(({ placeholder, icon = Magnifier, size = 'small', type = 'search', label, componentsProps, disabledClear = false, disabledFocus = false, disabledHover = false, className, defaultValue = '', value, elevation = 1, disabled = false, onChange = () => { }, onClear = () => { }, onFocus = () => { }, onBlur = () => { }, ...props }, ref) => {
23
23
  useExtendI18n(locales);
24
24
  const { t } = useI18n();
25
25
  const [currentValue, setCurrentValue] = useState(defaultValue);
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Switch } from './index';
2
+ import Switch from './index';
3
3
  declare const meta: Meta<typeof Switch>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
@@ -1,7 +1,7 @@
1
1
  import { Check } from '@linagora/twake-icons';
2
2
  import { Divider, FormControlLabel, FormGroup, Stack, Typography } from '@mui/material';
3
3
  import React from 'react';
4
- import { Switch } from './index';
4
+ import Switch from './index';
5
5
  const colors = ['primary', 'secondary', 'success', 'default'];
6
6
  const meta = {
7
7
  title: 'Switch',
@@ -5,5 +5,5 @@ export interface SwitchProps extends Omit<MuiSwitchProps, 'icon' | 'checkedIcon'
5
5
  /** A twake icon drawn inside the thumb */
6
6
  icon?: IconProps['icon'];
7
7
  }
8
- export declare const Switch: React.FC<SwitchProps>;
8
+ declare const Switch: React.FC<SwitchProps>;
9
9
  export default Switch;
@@ -1,7 +1,7 @@
1
1
  import { Icon } from '@linagora/twake-icons';
2
2
  import { Switch as MuiSwitch } from '@mui/material';
3
3
  import React from 'react';
4
- export const Switch = ({ icon, ...props }) => {
4
+ const Switch = ({ icon, ...props }) => {
5
5
  const thumb = (React.createElement("span", { className: "switchThumb" }, !!icon && React.createElement(Icon, { icon: icon, size: 14 })));
6
6
  return React.createElement(MuiSwitch, { icon: thumb, checkedIcon: thumb, ...props });
7
7
  };
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Tabs } from './index';
2
+ import Tabs from './index';
3
3
  declare const meta: Meta<typeof Tabs>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
@@ -1,6 +1,6 @@
1
1
  import { Stack, Tab } from '@mui/material';
2
2
  import React from 'react';
3
- import { Tabs } from './index';
3
+ import Tabs from './index';
4
4
  const variants = ['standard', 'fullWidth', 'scrollable'];
5
5
  const meta = {
6
6
  title: 'Tabs',
@@ -6,5 +6,5 @@ export interface TabsProps extends MuiTabsProps {
6
6
  /** Pill container with the selected tab raised on a white pill */
7
7
  segmented?: boolean;
8
8
  }
9
- export declare const Tabs: React.FC<TabsProps>;
9
+ declare const Tabs: React.FC<TabsProps>;
10
10
  export default Tabs;
@@ -1,5 +1,5 @@
1
1
  import { Tabs as MuiTabs } from '@mui/material';
2
2
  import cx from 'classnames';
3
3
  import React from 'react';
4
- export const Tabs = ({ className, narrowed, segmented, ...props }) => React.createElement(MuiTabs, { className: cx(className, { narrowed, segmented }), ...props });
4
+ const Tabs = ({ className, narrowed, segmented, ...props }) => React.createElement(MuiTabs, { className: cx(className, { narrowed, segmented }), ...props });
5
5
  export default Tabs;
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 './components/ThemeProvider';
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';
@@ -31,9 +31,9 @@ export { copyToClipboard } from './components/ActionsMenu/Actions/copyToClipboar
31
31
  export { editAttribute } from './components/ActionsMenu/Actions/editAttribute';
32
32
  export { others } from './components/ActionsMenu/Actions/others';
33
33
  export { exportToText } from './components/ActionsMenu/Actions/exportToText';
34
- export { Avatar, default as AvatarDefault } from './components/Avatar';
34
+ export { default as Avatar } from './components/Avatar';
35
35
  export { default as BarTitle } from './components/BarTitle';
36
- export { Button, default as ButtonDefault } from './components/Button';
36
+ export { default as Button } from './components/Button';
37
37
  export { default as BottomSheet } from './components/BottomSheet';
38
38
  export { default as BottomSheetItem } from './components/BottomSheet/BottomSheetItem';
39
39
  export { default as BottomSheetHeader } from './components/BottomSheet/BottomSheetHeader';
@@ -41,7 +41,7 @@ export { default as BottomSheetTitle } from './components/BottomSheet/BottomShee
41
41
  export { default as Chip } from './components/Chip';
42
42
  export { default as ColorList } from './components/ColorList';
43
43
  export { Dialog, default as DialogDefault } from './components/Dialog';
44
- export { ContactPopover, default as ContactPopoverDefault } from './components/ContactPopover';
44
+ export { default as ContactPopover } from './components/ContactPopover';
45
45
  export { default as DropdownButton } from './components/DropdownButton';
46
46
  export { default as DropdownText } from './components/DropdownText';
47
47
  export { Empty, EmptySubTitle } from './components/Empty';
@@ -57,10 +57,14 @@ 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
- export { Tabs, default as TabsDefault } from './components/Tabs';
62
- export { Switch, default as SwitchDefault } from './components/Switch';
63
- export { SearchBar, default as SearchBarDefault } from './components/SearchBar';
65
+ export { default as Tabs } from './components/Tabs';
66
+ export { default as Switch } from './components/Switch';
67
+ export { default as SearchBar } from './components/SearchBar';
64
68
  export { Sidebar, SIDEBAR_MOBILE_HEIGHT } from './components/Sidebar';
65
69
  export { Layout, Main, Content } from './components/Layout';
66
70
  export { Nav } from './components/Nav';
@@ -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, ShowAlert, ShowAlertOptions, WebLinkActionOptions, WebLinkClient, WebLinkOptions } from './components/ActionsMenu/types';
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 './components/ThemeProvider';
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';
@@ -34,9 +34,9 @@ export { copyToClipboard } from './components/ActionsMenu/Actions/copyToClipboar
34
34
  export { editAttribute } from './components/ActionsMenu/Actions/editAttribute';
35
35
  export { others } from './components/ActionsMenu/Actions/others';
36
36
  export { exportToText } from './components/ActionsMenu/Actions/exportToText';
37
- export { Avatar, default as AvatarDefault } from './components/Avatar';
37
+ export { default as Avatar } from './components/Avatar';
38
38
  export { default as BarTitle } from './components/BarTitle';
39
- export { Button, default as ButtonDefault } from './components/Button';
39
+ export { default as Button } from './components/Button';
40
40
  export { default as BottomSheet } from './components/BottomSheet';
41
41
  export { default as BottomSheetItem } from './components/BottomSheet/BottomSheetItem';
42
42
  export { default as BottomSheetHeader } from './components/BottomSheet/BottomSheetHeader';
@@ -44,7 +44,7 @@ export { default as BottomSheetTitle } from './components/BottomSheet/BottomShee
44
44
  export { default as Chip } from './components/Chip';
45
45
  export { default as ColorList } from './components/ColorList';
46
46
  export { Dialog, default as DialogDefault } from './components/Dialog';
47
- export { ContactPopover, default as ContactPopoverDefault } from './components/ContactPopover';
47
+ export { default as ContactPopover } from './components/ContactPopover';
48
48
  export { default as DropdownButton } from './components/DropdownButton';
49
49
  export { default as DropdownText } from './components/DropdownText';
50
50
  export { Empty, EmptySubTitle } from './components/Empty';
@@ -60,10 +60,12 @@ 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
- export { Tabs, default as TabsDefault } from './components/Tabs';
65
- export { Switch, default as SwitchDefault } from './components/Switch';
66
- export { SearchBar, default as SearchBarDefault } from './components/SearchBar';
66
+ export { default as Tabs } from './components/Tabs';
67
+ export { default as Switch } from './components/Switch';
68
+ export { default as SearchBar } from './components/SearchBar';
67
69
  export { Sidebar, SIDEBAR_MOBILE_HEIGHT } from './components/Sidebar';
68
70
  export { Layout, Main, Content } from './components/Layout';
69
71
  export { Nav } from './components/Nav';
@@ -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,6 @@
1
+ import React, { ReactNode } from 'react';
2
+ export interface AlertProviderProps {
3
+ children?: ReactNode;
4
+ }
5
+ declare const AlertProvider: React.FC<AlertProviderProps>;
6
+ export default AlertProvider;
@@ -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,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { Button } from '../components/Button';
2
+ import Button from '../components/Button';
3
3
  declare const meta: Meta<typeof Button>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
@@ -1,7 +1,7 @@
1
1
  import { Icon, Plus, Stop } from '@linagora/twake-icons';
2
2
  import { Box, Stack } from '@mui/material';
3
3
  import React from 'react';
4
- import { Button } from '../components/Button';
4
+ import Button from '../components/Button';
5
5
  const variants = ['contained', 'outlined', 'ghost', 'text'];
6
6
  const sizes = ['small', 'medium', 'large'];
7
7
  const colors = [
@@ -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linagora/twake-mui",
3
3
  "type": "module",
4
- "version": "14.3.0",
4
+ "version": "15.0.0",
5
5
  "description": "MUI v9 theme system for Twake applications",
6
6
  "author": "Twake",
7
7
  "license": "MIT",