@linagora/twake-mui 9.0.0 → 9.1.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 CHANGED
@@ -1,3 +1,10 @@
1
+ # @linagora/twake-mui [9.1.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@9.0.0...@linagora/twake-mui@9.1.0) (2026-09-22)
2
+
3
+
4
+ ### Features
5
+
6
+ * **twake-mui:** Migrate Layout from cozy-ui ([fdcb499](https://github.com/linagora/twake-ui/commit/fdcb499c9790e4b8fc7aaaa12087a8eebf250d42))
7
+
1
8
  # @linagora/twake-mui [9.0.0](https://github.com/linagora/twake-ui/compare/@linagora/twake-mui@8.0.0...@linagora/twake-mui@9.0.0) (2026-09-21)
2
9
 
3
10
 
@@ -1,12 +1,19 @@
1
- import { ButtonProps as MuiButtonProps } from '@mui/material';
1
+ import { ButtonProps as MuiButtonProps, ButtonTypeMap as MuiButtonTypeMap } from '@mui/material';
2
+ import { OverridableComponent, OverrideProps } from '@mui/material/OverridableComponent';
2
3
  import React from 'react';
3
4
  declare const legacyVariants: {
4
5
  readonly primary: "contained";
5
6
  readonly secondary: "outlined";
6
7
  };
7
8
  type LegacyVariant = keyof typeof legacyVariants;
8
- export interface ButtonProps extends Omit<MuiButtonProps, 'variant'> {
9
- variant?: MuiButtonProps['variant'] | LegacyVariant;
9
+ export interface ButtonTypeMap<AdditionalProps = object, RootComponent extends React.ElementType = 'button'> {
10
+ props: AdditionalProps & Omit<MuiButtonTypeMap['props'], 'variant'> & {
11
+ variant?: MuiButtonProps['variant'] | LegacyVariant;
12
+ };
13
+ defaultComponent: RootComponent;
10
14
  }
11
- export declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
15
+ export type ButtonProps<RootComponent extends React.ElementType = 'button', AdditionalProps = object> = OverrideProps<ButtonTypeMap<AdditionalProps, RootComponent>, RootComponent>;
16
+ export declare const Button: OverridableComponent<ButtonTypeMap> & {
17
+ displayName?: string;
18
+ };
12
19
  export default Button;
@@ -0,0 +1,7 @@
1
+ import { SxProps } from '@mui/material';
2
+ import { Theme } from '@mui/material/styles';
3
+ import React from 'react';
4
+ export interface ContentProps extends React.ComponentPropsWithoutRef<'div'> {
5
+ sx?: SxProps<Theme>;
6
+ }
7
+ export declare const Content: (props: ContentProps) => React.ReactElement;
@@ -0,0 +1,29 @@
1
+ import { styled } from '@mui/material/styles';
2
+ import React, { useContext } from 'react';
3
+ import { LayoutContext } from './Layout';
4
+ const ContentRoot = styled('div', {
5
+ shouldForwardProp: prop => prop !== 'monoColumn'
6
+ })(({ theme }) => ({
7
+ position: 'relative',
8
+ display: 'flex',
9
+ flexDirection: 'column',
10
+ flex: '1 1 auto',
11
+ boxSizing: 'border-box',
12
+ overflow: 'hidden auto',
13
+ backgroundColor: theme.vars.palette.background.paper,
14
+ height: '100%',
15
+ variants: [
16
+ {
17
+ props: { monoColumn: false },
18
+ style: {
19
+ margin: '16px 16px 16px 0',
20
+ borderRadius: 16,
21
+ [theme.breakpoints.down('lg')]: { margin: 0, borderRadius: 0 }
22
+ }
23
+ }
24
+ ]
25
+ }));
26
+ export const Content = (props) => {
27
+ const { monoColumn } = useContext(LayoutContext);
28
+ return React.createElement(ContentRoot, { role: "main", monoColumn: monoColumn, ...props });
29
+ };
@@ -0,0 +1,21 @@
1
+ import { SxProps } from '@mui/material';
2
+ import { CSSObject, Theme } from '@mui/material/styles';
3
+ import React from 'react';
4
+ interface LayoutContextValue {
5
+ monoColumn: boolean;
6
+ withTopBar: boolean;
7
+ }
8
+ export declare const LayoutContext: React.Context<LayoutContextValue>;
9
+ export interface TwoPanesProps {
10
+ monoColumn?: boolean;
11
+ }
12
+ export declare const twoPanes: (theme: Theme) => CSSObject;
13
+ export interface LayoutProps extends React.ComponentPropsWithoutRef<'div'> {
14
+ sx?: SxProps<Theme>;
15
+ /** Used to add/remove top spacing when using with or without a topbar */
16
+ withTopBar?: boolean;
17
+ /** Should be true if no sidebar in the app */
18
+ monoColumn?: boolean;
19
+ }
20
+ export declare const Layout: ({ children, withTopBar, monoColumn, ...props }: LayoutProps) => React.ReactElement;
21
+ export {};
@@ -0,0 +1,31 @@
1
+ import { styled } from '@mui/material/styles';
2
+ import React, { createContext, useMemo } from 'react';
3
+ import { SIDEBAR_MOBILE_HEIGHT } from '../Sidebar';
4
+ export const LayoutContext = createContext({
5
+ monoColumn: false,
6
+ withTopBar: true
7
+ });
8
+ export const twoPanes = (theme) => ({
9
+ backgroundColor: theme.vars.palette.background.default,
10
+ [theme.breakpoints.down('lg')]: {
11
+ height: `calc(100vh - var(${SIDEBAR_MOBILE_HEIGHT}, 0px))`,
12
+ backgroundColor: 'transparent'
13
+ }
14
+ });
15
+ const LayoutRoot = styled('div', {
16
+ shouldForwardProp: prop => prop !== 'monoColumn'
17
+ })(({ theme }) => ({
18
+ boxSizing: 'border-box',
19
+ display: 'flex',
20
+ maxWidth: '100%',
21
+ width: '100%',
22
+ height: '100%',
23
+ backgroundColor: theme.vars.palette.background.paper,
24
+ color: theme.vars.palette.text.primary,
25
+ variants: [{ props: { monoColumn: false }, style: twoPanes(theme) }]
26
+ }));
27
+ export const Layout = ({ children, withTopBar = true, monoColumn = false, ...props }) => {
28
+ const value = useMemo(() => ({ monoColumn, withTopBar }), [monoColumn, withTopBar]);
29
+ return (React.createElement(LayoutContext.Provider, { value: value },
30
+ React.createElement(LayoutRoot, { monoColumn: monoColumn, ...props }, children)));
31
+ };
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { Layout } from './index';
3
+ declare const meta: Meta<typeof Layout>;
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,89 @@
1
+ import { Check, Download, Warn } from '@linagora/twake-icons';
2
+ import { Box, Typography } from '@mui/material';
3
+ import React, { useState } from 'react';
4
+ import { Content, Layout, Main } from './index';
5
+ import { Nav } from '../Nav';
6
+ import { NavDesktopDropdown } from '../NavDesktopDropdown';
7
+ import { NavDesktopLimiter } from '../NavDesktopLimiter';
8
+ import { NavIcon } from '../NavIcon';
9
+ import { NavItem } from '../NavItem';
10
+ import { NavLink } from '../NavLink';
11
+ import { NavText } from '../NavText';
12
+ import { Sidebar } from '../Sidebar';
13
+ const paragraph = 'Ada Lovelace was an English mathematician chiefly known for her work on Charles Babbage’s proposed mechanical general-purpose computer, the Analytical Engine. She was the first to recognise that the machine had applications beyond pure calculation.';
14
+ const TopBar = () => (React.createElement(Box, { id: "coz-bar", role: "banner", sx: theme => ({
15
+ display: 'flex',
16
+ alignItems: 'center',
17
+ px: 2,
18
+ minHeight: 48,
19
+ width: '100%',
20
+ boxSizing: 'border-box',
21
+ backgroundColor: theme.vars.palette.background.paper,
22
+ borderBottom: `1px solid ${theme.vars.palette.divider}`,
23
+ position: 'fixed',
24
+ top: 0,
25
+ right: 0,
26
+ zIndex: theme.zIndex.appBar,
27
+ [theme.breakpoints.up('lg')]: { position: 'relative' }
28
+ }) }, "Fake TopBar"));
29
+ const LayoutDemo = ({ monoColumn = false, withTopBar = true, ...props }) => {
30
+ const [active, setActive] = useState(['Section 1', 'Subsection 1']);
31
+ const makeProps = (route) => ({
32
+ selected: active.slice(0, route.length).join('/') === route.join('/'),
33
+ onClick: () => setActive(route)
34
+ });
35
+ return (React.createElement(Box, { sx: { height: '100vh', display: 'flex', flexDirection: 'column' } },
36
+ withTopBar && React.createElement(TopBar, null),
37
+ React.createElement(Box, { role: "application", sx: { flex: '1 1 auto', minHeight: 0 } },
38
+ React.createElement(Layout, { monoColumn: monoColumn, withTopBar: withTopBar, ...props },
39
+ !monoColumn && (React.createElement(Sidebar, null,
40
+ React.createElement(Nav, null,
41
+ React.createElement(NavItem, null,
42
+ React.createElement(NavLink, { ...makeProps(['Section 1']) },
43
+ React.createElement(NavIcon, { icon: Warn }),
44
+ React.createElement(NavText, null, "Section 1"))),
45
+ React.createElement(NavDesktopLimiter, null, Array.from(Array(10).keys()).map(i => (React.createElement(NavItem, { secondary: true, key: i },
46
+ React.createElement(NavLink, { ...makeProps(['Section 1', `Subsection ${i}`]) },
47
+ React.createElement(NavText, null,
48
+ "Subsection ",
49
+ i)))))),
50
+ React.createElement(NavItem, null,
51
+ React.createElement(NavLink, { ...makeProps(['Section 2']) },
52
+ React.createElement(NavIcon, { icon: Check }),
53
+ React.createElement(NavText, null, "Section 2"))),
54
+ React.createElement(NavItem, null,
55
+ React.createElement(NavLink, { ...makeProps(['Section 3']) },
56
+ React.createElement(NavIcon, { icon: Download }),
57
+ React.createElement(NavText, null, "Section 3"))),
58
+ React.createElement(NavDesktopDropdown, { label: "Section 4" }, Array.from(Array(6).keys()).map(i => (React.createElement(NavItem, { secondary: true, key: i },
59
+ React.createElement(NavLink, { ...makeProps(['Section 4', `Subsection ${i}`]) },
60
+ React.createElement(NavText, null,
61
+ "Subsection ",
62
+ i))))))))),
63
+ React.createElement(Main, null,
64
+ React.createElement(Content, { sx: { p: 2 } },
65
+ React.createElement(Typography, { variant: "h5" }, active.join(' / ')),
66
+ React.createElement("p", null, "---Start---"),
67
+ Array.from(Array(6).keys()).map(i => (React.createElement("p", { key: i }, paragraph))),
68
+ React.createElement("p", null, "---END---")))))));
69
+ };
70
+ const meta = {
71
+ title: 'Layout',
72
+ component: Layout,
73
+ parameters: { layout: 'fullscreen' },
74
+ tags: ['autodocs'],
75
+ argTypes: {
76
+ monoColumn: { control: 'boolean' },
77
+ withTopBar: { control: 'boolean' }
78
+ },
79
+ render: args => React.createElement(LayoutDemo, { ...args })
80
+ };
81
+ export default meta;
82
+ export const Default = {
83
+ args: { monoColumn: false, withTopBar: true }
84
+ };
85
+ // Visual Regression - Combined view for Argos testing
86
+ export const Screenshot = {
87
+ tags: ['argos'],
88
+ args: { monoColumn: false, withTopBar: true }
89
+ };
@@ -0,0 +1,7 @@
1
+ import { SxProps } from '@mui/material';
2
+ import { Theme } from '@mui/material/styles';
3
+ import React from 'react';
4
+ export interface MainProps extends React.ComponentPropsWithoutRef<'main'> {
5
+ sx?: SxProps<Theme>;
6
+ }
7
+ export declare const Main: (props: MainProps) => React.ReactElement;
@@ -0,0 +1,37 @@
1
+ import { styled } from '@mui/material/styles';
2
+ import React, { useContext } from 'react';
3
+ import { LayoutContext, twoPanes } from './Layout';
4
+ /** Height of the top bar, which is out of the Layout but overlaps it */
5
+ const TOP_BAR_HEIGHT = 48;
6
+ const MainRoot = styled('main', {
7
+ shouldForwardProp: prop => prop !== 'monoColumn' && prop !== 'withTopBar'
8
+ })(({ theme }) => ({
9
+ display: 'flex',
10
+ flexDirection: 'column',
11
+ position: 'relative',
12
+ flex: '1 1 auto',
13
+ boxSizing: 'border-box',
14
+ overflow: 'hidden',
15
+ height: '100%',
16
+ variants: [
17
+ { props: { monoColumn: false }, style: twoPanes(theme) },
18
+ {
19
+ props: { withTopBar: true },
20
+ style: {
21
+ [theme.breakpoints.down('lg')]: {
22
+ '&::before': {
23
+ content: '""',
24
+ display: 'block',
25
+ height: TOP_BAR_HEIGHT,
26
+ width: '100%',
27
+ backgroundColor: theme.vars.palette.background.paper
28
+ }
29
+ }
30
+ }
31
+ }
32
+ ]
33
+ }));
34
+ export const Main = (props) => {
35
+ const { monoColumn, withTopBar } = useContext(LayoutContext);
36
+ return React.createElement(MainRoot, { monoColumn: monoColumn, withTopBar: withTopBar, ...props });
37
+ };
@@ -0,0 +1,6 @@
1
+ export { Layout } from './Layout';
2
+ export { Main } from './Main';
3
+ export { Content } from './Content';
4
+ export type { LayoutProps } from './Layout';
5
+ export type { MainProps } from './Main';
6
+ export type { ContentProps } from './Content';
@@ -0,0 +1,3 @@
1
+ export { Layout } from './Layout';
2
+ export { Main } from './Main';
3
+ export { Content } from './Content';
@@ -1,6 +1,7 @@
1
1
  import { SxProps } from '@mui/material';
2
2
  import { Theme } from '@mui/material/styles';
3
3
  import React from 'react';
4
+ export declare const SIDEBAR_MOBILE_HEIGHT = "--sidebarHeight";
4
5
  export interface SidebarProps extends React.ComponentPropsWithoutRef<'aside'> {
5
6
  sx?: SxProps<Theme>;
6
7
  }
@@ -1,5 +1,9 @@
1
+ import { GlobalStyles } from '@mui/material';
1
2
  import { styled } from '@mui/material/styles';
2
- export const Sidebar = styled('aside')(({ theme }) => ({
3
+ import React from 'react';
4
+ export const SIDEBAR_MOBILE_HEIGHT = '--sidebarHeight';
5
+ const makeSidebarHeightCSSVar = (React.createElement(GlobalStyles, { styles: { ':root': { [SIDEBAR_MOBILE_HEIGHT]: '52px' } } }));
6
+ const SidebarRoot = styled('aside')(({ theme }) => ({
3
7
  width: 236,
4
8
  flex: '0 0 auto',
5
9
  display: 'flex',
@@ -12,10 +16,13 @@ export const Sidebar = styled('aside')(({ theme }) => ({
12
16
  bottom: 0,
13
17
  left: 0,
14
18
  width: '100%',
15
- height: 52,
19
+ height: `var(${SIDEBAR_MOBILE_HEIGHT})`,
16
20
  boxSizing: 'content-box',
17
21
  display: 'block',
18
22
  borderTop: `1px solid ${theme.vars.palette.divider}`,
19
23
  zIndex: theme.zIndex.appBar
20
24
  }
21
25
  }));
26
+ export const Sidebar = props => (React.createElement(React.Fragment, null,
27
+ makeSidebarHeightCSSVar,
28
+ React.createElement(SidebarRoot, { ...props })));
package/dist/index.d.ts CHANGED
@@ -12,7 +12,8 @@ export { default as Chip } from './components/Chip';
12
12
  export { Dialog, default as DialogDefault } from './components/Dialog';
13
13
  export { Tabs, default as TabsDefault } from './components/Tabs';
14
14
  export { Switch, default as SwitchDefault } from './components/Switch';
15
- export { Sidebar } from './components/Sidebar';
15
+ export { Sidebar, SIDEBAR_MOBILE_HEIGHT } from './components/Sidebar';
16
+ export { Layout, Main, Content } from './components/Layout';
16
17
  export { Nav } from './components/Nav';
17
18
  export { NavItem } from './components/NavItem';
18
19
  export { NavLink } from './components/NavLink';
@@ -32,6 +33,7 @@ export type { DialogProps, DialogSize } from './components/Dialog';
32
33
  export type { TabsProps } from './components/Tabs';
33
34
  export type { SwitchProps } from './components/Switch';
34
35
  export type { SidebarProps } from './components/Sidebar';
36
+ export type { LayoutProps, MainProps, ContentProps } from './components/Layout';
35
37
  export type { NavProps } from './components/Nav';
36
38
  export type { NavItemProps } from './components/NavItem';
37
39
  export type { NavLinkProps } from './components/NavLink';
package/dist/index.js CHANGED
@@ -15,7 +15,8 @@ export { default as Chip } from './components/Chip';
15
15
  export { Dialog, default as DialogDefault } from './components/Dialog';
16
16
  export { Tabs, default as TabsDefault } from './components/Tabs';
17
17
  export { Switch, default as SwitchDefault } from './components/Switch';
18
- export { Sidebar } from './components/Sidebar';
18
+ export { Sidebar, SIDEBAR_MOBILE_HEIGHT } from './components/Sidebar';
19
+ export { Layout, Main, Content } from './components/Layout';
19
20
  export { Nav } from './components/Nav';
20
21
  export { NavItem } from './components/NavItem';
21
22
  export { NavLink } from './components/NavLink';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linagora/twake-mui",
3
3
  "type": "module",
4
- "version": "9.0.0",
4
+ "version": "9.1.0",
5
5
  "description": "MUI v9 theme system for Twake applications",
6
6
  "author": "Twake",
7
7
  "license": "MIT",