@entur/layout 3.4.2 → 3.5.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.
@@ -1,18 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  ;/* empty css */
4
- const index = require("./Grid/index.cjs");
5
- const index$1 = require("./Flex/index.cjs");
4
+ const index$1 = require("./Grid/index.cjs");
5
+ const index = require("./Flex/index.cjs");
6
6
  const index$2 = require("./templates/index.cjs");
7
+ const FlexSpacer = require("./Flex/FlexSpacer.cjs");
7
8
  const GridItem = require("./Grid/GridItem.cjs");
8
9
  const LayoutWrapper = require("./LayoutWrapper/LayoutWrapper.cjs");
9
10
  const useLayoutValues = require("./LayoutWrapper/useLayoutValues.cjs");
10
- const FlexSpacer = require("./Flex/FlexSpacer.cjs");
11
- exports.Grid = index.GridComponent;
12
- exports.Flex = index$1.FlexComponent;
11
+ const SidebarContext = require("./templates/SidebarContext.cjs");
12
+ exports.Grid = index$1.Grid;
13
+ exports.Flex = index.Flex;
13
14
  exports.Template = index$2.Template;
15
+ exports.FlexSpacer = FlexSpacer.FlexSpacer;
14
16
  exports.GridItem = GridItem.GridItem;
15
17
  exports.LayoutWrapper = LayoutWrapper.LayoutWrapper;
16
18
  exports.useLayoutValues = useLayoutValues.useLayoutValues;
17
- exports.FlexSpacer = FlexSpacer.FlexSpacer;
19
+ exports.useSidebarCollapsed = SidebarContext.useSidebarCollapsed;
18
20
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
+ const utils = require("@entur/utils");
5
6
  const classNames = require("classnames");
7
+ const icons = require("@entur/icons");
6
8
  const Contrast = require("../Contrast.cjs");
7
9
  const index$1 = require("../Flex/index.cjs");
8
10
  const index = require("../Grid/index.cjs");
11
+ const SidebarContext = require("./SidebarContext.cjs");
9
12
  ;/* empty css */
10
13
  const defaultSidebarElement = "aside";
11
14
  const defaultSectionElement = "div";
@@ -60,35 +63,100 @@ const SidebarFooter = React.forwardRef(
60
63
  );
61
64
  }
62
65
  );
66
+ const CollapseToggle = ({ isCollapsed, onToggle, openLabel, closeLabel }) => /* @__PURE__ */ jsxRuntime.jsx(
67
+ "button",
68
+ {
69
+ type: "button",
70
+ className: "eds-layout-template-sidebar__collapse-toggle",
71
+ onClick: onToggle,
72
+ "aria-expanded": !isCollapsed,
73
+ "aria-label": isCollapsed ? openLabel : closeLabel,
74
+ children: isCollapsed ? /* @__PURE__ */ jsxRuntime.jsx(icons.RightArrowIcon, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(icons.LeftArrowIcon, { size: 16 })
75
+ }
76
+ );
63
77
  const SidebarRoot = React.forwardRef(
64
78
  ({
65
79
  children,
66
80
  className,
67
81
  style,
68
82
  contrast = true,
83
+ collapsible = false,
84
+ collapsed,
85
+ onCollapseToggle,
86
+ openSidebarAriaLabel = "Åpne sidemeny",
87
+ closeSidebarAriaLabel = "Lukk sidemeny",
69
88
  as,
70
89
  ...rest
71
90
  }, ref) => {
91
+ const handleCollapseToggle = (value) => {
92
+ if (value === void 0 || !onCollapseToggle) {
93
+ return;
94
+ }
95
+ onCollapseToggle(value);
96
+ };
97
+ const [isCollapsed, setIsCollapsed] = utils.useControllableProp({
98
+ prop: collapsible ? collapsed : void 0,
99
+ defaultValue: false,
100
+ updater: handleCollapseToggle
101
+ });
72
102
  const WrapperElement = contrast ? Contrast.Contrast : "div";
73
- return /* @__PURE__ */ jsxRuntime.jsx(index.GridComponent.Item, { as: WrapperElement, colSpan: "1 / 2", children: /* @__PURE__ */ jsxRuntime.jsx(
74
- index$1.FlexComponent,
103
+ const sidebarClassNames = classNames(
104
+ "eds-layout-template-sidebar",
75
105
  {
76
- ref,
77
- as: as || defaultSidebarElement,
78
- direction: "column",
79
- gap: "m",
80
- className: classNames(
81
- "eds-layout-template-sidebar",
82
- {
83
- "eds-layout-template-sidebar--plain": !contrast
84
- },
85
- className
86
- ),
87
- style,
88
- ...rest,
89
- children
106
+ "eds-layout-template-sidebar--plain": !contrast,
107
+ "eds-layout-template-sidebar--collapsible": collapsible,
108
+ "eds-layout-template-sidebar--collapsed": collapsible && isCollapsed
109
+ },
110
+ className
111
+ );
112
+ if (!collapsible) {
113
+ return /* @__PURE__ */ jsxRuntime.jsx(index.Grid.Item, { as: WrapperElement, colSpan: "1 / 2", children: /* @__PURE__ */ jsxRuntime.jsx(
114
+ index$1.Flex,
115
+ {
116
+ ref,
117
+ as: as || defaultSidebarElement,
118
+ direction: "column",
119
+ gap: "m",
120
+ className: sidebarClassNames,
121
+ style,
122
+ ...rest,
123
+ children
124
+ }
125
+ ) });
126
+ }
127
+ const collapsedStyle = isCollapsed ? { ...style, "--eds-sidebar-width": "2rem" } : style;
128
+ return /* @__PURE__ */ jsxRuntime.jsx(
129
+ index.Grid.Item,
130
+ {
131
+ as: WrapperElement,
132
+ colSpan: "1 / 2",
133
+ className: "eds-layout-template-sidebar-wrapper",
134
+ children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarContext.SidebarContext.Provider, { value: { isCollapsed }, children: [
135
+ /* @__PURE__ */ jsxRuntime.jsx(
136
+ index$1.Flex,
137
+ {
138
+ ref,
139
+ as: as || defaultSidebarElement,
140
+ direction: "column",
141
+ gap: "m",
142
+ className: sidebarClassNames,
143
+ style: collapsedStyle,
144
+ ...rest,
145
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eds-layout-template-sidebar__content", children })
146
+ }
147
+ ),
148
+ /* @__PURE__ */ jsxRuntime.jsx(
149
+ CollapseToggle,
150
+ {
151
+ isCollapsed,
152
+ onToggle: () => setIsCollapsed(!isCollapsed),
153
+ openLabel: openSidebarAriaLabel,
154
+ closeLabel: closeSidebarAriaLabel
155
+ }
156
+ )
157
+ ] })
90
158
  }
91
- ) });
159
+ );
92
160
  }
93
161
  );
94
162
  const Sidebar = Object.assign(SidebarRoot, {
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar.cjs","sources":["../../../../src/beta/templates/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { Contrast } from '../../Contrast';\nimport { Flex } from '../Flex';\nimport { Grid } from '../Grid';\nimport './Sidebar.scss';\n\ntype SidebarOwnProps = {\n /** Toggle contrast styling for the sidebar */\n contrast?: boolean;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype SidebarSectionOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultSidebarElement = 'aside';\nconst defaultSectionElement = 'div';\nconst defaultNavigationElement = 'nav';\nconst defaultFooterElement = 'footer';\n\nexport type SidebarProps<\n T extends React.ElementType = typeof defaultSidebarElement,\n> = PolymorphicComponentProps<T, SidebarOwnProps>;\n\nexport type SidebarSectionProps<\n T extends React.ElementType = typeof defaultSectionElement,\n> = PolymorphicComponentProps<T, SidebarSectionOwnProps>;\n\nconst SidebarLogo = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarUser = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarData = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarNavigation = React.forwardRef(\n <E extends React.ElementType = typeof defaultNavigationElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultNavigationElement;\n return (\n <Element\n ref={ref}\n className={classNames(\n 'eds-layout-template-sidebar__navigation',\n className,\n )}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarFooter = React.forwardRef(\n <E extends React.ElementType = typeof defaultFooterElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultFooterElement;\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-template-sidebar__footer', className)}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarRoot = React.forwardRef(\n <E extends React.ElementType = typeof defaultSidebarElement>(\n {\n children,\n className,\n style,\n contrast = true,\n as,\n ...rest\n }: SidebarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const WrapperElement = contrast ? Contrast : 'div';\n return (\n <Grid.Item as={WrapperElement} colSpan=\"1 / 2\">\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={classNames(\n 'eds-layout-template-sidebar',\n {\n 'eds-layout-template-sidebar--plain': !contrast,\n },\n className,\n )}\n style={style}\n {...rest}\n >\n {children}\n </Flex>\n </Grid.Item>\n );\n },\n);\n\nexport type SidebarComponent = typeof SidebarRoot & {\n Logo: typeof SidebarLogo;\n User: typeof SidebarUser;\n Data: typeof SidebarData;\n Navigation: typeof SidebarNavigation;\n Footer: typeof SidebarFooter;\n};\n\nexport const Sidebar: SidebarComponent = Object.assign(SidebarRoot, {\n Logo: SidebarLogo,\n User: SidebarUser,\n Data: SidebarData,\n Navigation: SidebarNavigation,\n Footer: SidebarFooter,\n});\n\nSidebar.displayName = 'Template.Portal.Sidebar';\nSidebar.Logo.displayName = 'Template.Portal.Sidebar.Logo';\nSidebar.User.displayName = 'Template.Portal.Sidebar.User';\nSidebar.Data.displayName = 'Template.Portal.Sidebar.Data';\nSidebar.Navigation.displayName = 'Template.Portal.Sidebar.Navigation';\nSidebar.Footer.displayName = 'Template.Portal.Sidebar.Footer';\n"],"names":["jsx","Contrast","Grid","Flex"],"mappings":";;;;;;;;;AAsBA,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,2BAA2B;AACjC,MAAM,uBAAuB;AAU7B,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,oBAAoB,MAAM;AAAA,EAC9B,CACE,EAAE,UAAU,WAAW,IAAI,GAAG,KAAA,GAC9B,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAA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;"}
1
+ {"version":3,"file":"Sidebar.cjs","sources":["../../../../src/beta/templates/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport { useControllableProp } from '@entur/utils';\nimport classNames from 'classnames';\nimport { LeftArrowIcon, RightArrowIcon } from '@entur/icons';\nimport { Contrast } from '../../Contrast';\nimport { Flex } from '../Flex';\nimport { Grid } from '../Grid';\nimport { SidebarContext } from './SidebarContext';\nimport './Sidebar.scss';\n\ntype SidebarOwnProps = {\n /** Toggle contrast styling for the sidebar */\n contrast?: boolean;\n /** Enable collapse functionality */\n collapsible?: boolean;\n /** Controlled collapsed state */\n collapsed?: boolean;\n /** Callback when the sidebar is toggled */\n onCollapseToggle?: (collapsed: boolean) => void;\n /** aria-label for the toggle button when the sidebar is collapsed\n * @default 'Åpne sidemeny'\n */\n openSidebarAriaLabel?: string;\n /** aria-label for the toggle button when the sidebar is expanded\n * @default 'Lukk sidemeny'\n */\n closeSidebarAriaLabel?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype SidebarSectionOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultSidebarElement = 'aside';\nconst defaultSectionElement = 'div';\nconst defaultNavigationElement = 'nav';\nconst defaultFooterElement = 'footer';\n\nexport type SidebarProps<\n T extends React.ElementType = typeof defaultSidebarElement,\n> = PolymorphicComponentProps<T, SidebarOwnProps>;\n\nexport type SidebarSectionProps<\n T extends React.ElementType = typeof defaultSectionElement,\n> = PolymorphicComponentProps<T, SidebarSectionOwnProps>;\n\nconst SidebarLogo = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarUser = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarData = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarNavigation = React.forwardRef(\n <E extends React.ElementType = typeof defaultNavigationElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultNavigationElement;\n return (\n <Element\n ref={ref}\n className={classNames(\n 'eds-layout-template-sidebar__navigation',\n className,\n )}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarFooter = React.forwardRef(\n <E extends React.ElementType = typeof defaultFooterElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultFooterElement;\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-template-sidebar__footer', className)}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst CollapseToggle: React.FC<{\n isCollapsed: boolean;\n onToggle: () => void;\n openLabel: string;\n closeLabel: string;\n}> = ({ isCollapsed, onToggle, openLabel, closeLabel }) => (\n <button\n type=\"button\"\n className=\"eds-layout-template-sidebar__collapse-toggle\"\n onClick={onToggle}\n aria-expanded={!isCollapsed}\n aria-label={isCollapsed ? openLabel : closeLabel}\n >\n {isCollapsed ? <RightArrowIcon size={16} /> : <LeftArrowIcon size={16} />}\n </button>\n);\n\nconst SidebarRoot = React.forwardRef(\n <E extends React.ElementType = typeof defaultSidebarElement>(\n {\n children,\n className,\n style,\n contrast = true,\n collapsible = false,\n collapsed,\n onCollapseToggle,\n openSidebarAriaLabel = 'Åpne sidemeny',\n closeSidebarAriaLabel = 'Lukk sidemeny',\n as,\n ...rest\n }: SidebarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const handleCollapseToggle: (value?: boolean) => void = value => {\n if (value === undefined || !onCollapseToggle) {\n return;\n }\n onCollapseToggle(value);\n };\n\n const [isCollapsed, setIsCollapsed] = useControllableProp({\n prop: collapsible ? collapsed : undefined,\n defaultValue: false,\n updater: handleCollapseToggle,\n });\n\n const WrapperElement = contrast ? Contrast : 'div';\n\n const sidebarClassNames = classNames(\n 'eds-layout-template-sidebar',\n {\n 'eds-layout-template-sidebar--plain': !contrast,\n 'eds-layout-template-sidebar--collapsible': collapsible,\n 'eds-layout-template-sidebar--collapsed': collapsible && isCollapsed,\n },\n className,\n );\n\n if (!collapsible) {\n return (\n <Grid.Item as={WrapperElement} colSpan=\"1 / 2\">\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={sidebarClassNames}\n style={style}\n {...rest}\n >\n {children}\n </Flex>\n </Grid.Item>\n );\n }\n\n const collapsedStyle = isCollapsed\n ? ({ ...style, '--eds-sidebar-width': '2rem' } as React.CSSProperties)\n : style;\n\n return (\n <Grid.Item\n as={WrapperElement}\n colSpan=\"1 / 2\"\n className=\"eds-layout-template-sidebar-wrapper\"\n >\n <SidebarContext.Provider value={{ isCollapsed }}>\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={sidebarClassNames}\n style={collapsedStyle}\n {...rest}\n >\n <div className=\"eds-layout-template-sidebar__content\">\n {children}\n </div>\n </Flex>\n <CollapseToggle\n isCollapsed={isCollapsed}\n onToggle={() => setIsCollapsed(!isCollapsed)}\n openLabel={openSidebarAriaLabel}\n closeLabel={closeSidebarAriaLabel}\n />\n </SidebarContext.Provider>\n </Grid.Item>\n );\n },\n);\n\nexport type SidebarComponent = typeof SidebarRoot & {\n Logo: typeof SidebarLogo;\n User: typeof SidebarUser;\n Data: typeof SidebarData;\n Navigation: typeof SidebarNavigation;\n Footer: typeof SidebarFooter;\n};\n\nexport const Sidebar: SidebarComponent = Object.assign(SidebarRoot, {\n Logo: SidebarLogo,\n User: SidebarUser,\n Data: SidebarData,\n Navigation: SidebarNavigation,\n Footer: SidebarFooter,\n});\n\nSidebar.displayName = 'Template.Portal.Sidebar';\nSidebar.Logo.displayName = 'Template.Portal.Sidebar.Logo';\nSidebar.User.displayName = 'Template.Portal.Sidebar.User';\nSidebar.Data.displayName = 'Template.Portal.Sidebar.Data';\nSidebar.Navigation.displayName = 'Template.Portal.Sidebar.Navigation';\nSidebar.Footer.displayName = 'Template.Portal.Sidebar.Footer';\n"],"names":["jsx","RightArrowIcon","LeftArrowIcon","useControllableProp","Contrast","Grid","Flex","SidebarContext"],"mappings":";;;;;;;;;;;;AAuCA,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAC9B,MAAM,2BAA2B;AACjC,MAAM,uBAAuB;AAU7B,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,cAAc,MAAM;AAAA,EACxB,CACE,EAAE,UAAU,IAAI,GAAG,KAAA,GACnB,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACEA,2BAAAA,IAAC,SAAA,EAAQ,KAAW,GAAG,MACpB,UACH;AAAA,EAEJ;AACF;AAEA,MAAM,oBAAoB,MAAM;AAAA,EAC9B,CACE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ACX,YAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACd,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAUO,MAAM,UAA4B,OAAO,OAAO,aAAa;AAAA,EAClE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ;AACV,CAAC;AAED,QAAQ,cAAc;AACtB,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,WAAW,cAAc;AACjC,QAAQ,OAAO,cAAc;;"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const React = require("react");
4
+ const SidebarContext = React.createContext({
5
+ isCollapsed: false
6
+ });
7
+ const useSidebarCollapsed = () => React.useContext(SidebarContext);
8
+ exports.SidebarContext = SidebarContext;
9
+ exports.useSidebarCollapsed = useSidebarCollapsed;
10
+ //# sourceMappingURL=SidebarContext.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarContext.cjs","sources":["../../../../src/beta/templates/SidebarContext.tsx"],"sourcesContent":["import React from 'react';\n\nexport const SidebarContext = React.createContext<{\n isCollapsed: boolean;\n}>({\n isCollapsed: false,\n});\n\n/** Hook to read the collapsed state of the nearest `Template.Portal.Sidebar`.\n * Returns `{ isCollapsed: false }` when used outside a collapsible sidebar. */\nexport const useSidebarCollapsed: () => { isCollapsed: boolean } = () =>\n React.useContext(SidebarContext);\n"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB,MAAM,cAEjC;AAAA,EACD,aAAa;AACf,CAAC;AAIM,MAAM,sBAAsD,MACjE,MAAM,WAAW,cAAc;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../../src/beta/templates/index.ts"],"sourcesContent":["import { Portal } from './portal';\nimport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n} from './portal';\nimport type {\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n} from './Sidebar';\n\nexport type TemplateComponent = {\n Portal: PortalComponent;\n};\n\nexport const Template: TemplateComponent = {\n Portal,\n};\n\nexport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n};\n"],"names":["Portal"],"mappings":";;;AAiBO,MAAM,WAA8B;AAAA,EAAA,QACzCA,OAAAA;AACF;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/beta/templates/index.ts"],"sourcesContent":["import { Portal } from './portal';\nimport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n} from './portal';\nimport type {\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n} from './Sidebar';\n\nexport { useSidebarCollapsed } from './SidebarContext';\n\nexport type TemplateComponent = {\n Portal: PortalComponent;\n};\n\nexport const Template: TemplateComponent = {\n Portal,\n};\n\nexport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n};\n"],"names":["Portal"],"mappings":";;;AAmBO,MAAM,WAA8B;AAAA,EAAA,QACzCA,OAAAA;AACF;;"}
@@ -11,7 +11,7 @@ const defaultPortalMainElement = "main";
11
11
  const PortalRoot = React.forwardRef(
12
12
  ({ children, className, style, as, ...rest }, ref) => {
13
13
  return /* @__PURE__ */ jsxRuntime.jsx(
14
- index.GridComponent,
14
+ index.Grid,
15
15
  {
16
16
  ref,
17
17
  as,
@@ -29,7 +29,7 @@ const PortalRoot = React.forwardRef(
29
29
  const PortalStatusBar = React.forwardRef(
30
30
  ({ children, className, as, ...rest }, ref) => {
31
31
  return /* @__PURE__ */ jsxRuntime.jsx(
32
- index.GridComponent.Item,
32
+ index.Grid.Item,
33
33
  {
34
34
  ref,
35
35
  as: as || defaultStatusBarElement,
@@ -46,7 +46,7 @@ const PortalStatusBar = React.forwardRef(
46
46
  const PortalMain = React.forwardRef(
47
47
  ({ children, className, style, as, ...rest }, ref) => {
48
48
  return /* @__PURE__ */ jsxRuntime.jsx(
49
- index.GridComponent.Item,
49
+ index.Grid.Item,
50
50
  {
51
51
  ref,
52
52
  as: as || defaultPortalMainElement,
@@ -1 +1 @@
1
- {"version":3,"file":"Portal.cjs","sources":["../../../../../src/beta/templates/portal/Portal.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { Grid } from '../../Grid';\nimport { Sidebar, SidebarComponent } from '../Sidebar';\nimport './Portal.scss';\n\ntype PortalOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype PortalStatusBarOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype PortalMainOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultStatusBarElement = 'div';\nconst defaultPortalMainElement = 'main';\n\nexport type PortalProps<T extends React.ElementType = typeof Grid> =\n PolymorphicComponentProps<T, PortalOwnProps>;\n\nexport type PortalStatusBarProps<\n T extends React.ElementType = typeof defaultStatusBarElement,\n> = PolymorphicComponentProps<T, PortalStatusBarOwnProps>;\n\nexport type PortalMainProps<\n T extends React.ElementType = typeof defaultPortalMainElement,\n> = PolymorphicComponentProps<T, PortalMainOwnProps>;\n\nconst PortalRoot = React.forwardRef(\n <E extends React.ElementType = typeof Grid>(\n { children, className, style, as, ...rest }: PortalProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid\n ref={ref}\n as={as}\n templateColumns=\"var(--eds-sidebar-width, min-content) minmax(0, 1fr)\"\n gap=\"none\"\n columnGap=\"m\"\n className={classNames('eds-layout-template-portal', className)}\n style={style}\n {...rest}\n >\n {children}\n </Grid>\n );\n },\n);\n\nconst PortalStatusBar = React.forwardRef(\n <E extends React.ElementType = typeof defaultStatusBarElement>(\n { children, className, as, ...rest }: PortalStatusBarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid.Item\n ref={ref}\n as={as || defaultStatusBarElement}\n className={classNames(\n 'eds-layout-template-portal__status-bar',\n className,\n )}\n {...rest}\n >\n {children}\n </Grid.Item>\n );\n },\n);\n\nconst PortalMain = React.forwardRef(\n <E extends React.ElementType = typeof defaultPortalMainElement>(\n { children, className, style, as, ...rest }: PortalMainProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid.Item\n ref={ref}\n as={as || defaultPortalMainElement}\n colSpan=\"2 / -1\"\n className={classNames('eds-layout-template-portal__main', className)}\n style={style}\n {...rest}\n >\n {children}\n </Grid.Item>\n );\n },\n);\n\nexport type PortalComponent = typeof PortalRoot & {\n StatusBar: typeof PortalStatusBar;\n Sidebar: SidebarComponent;\n Main: typeof PortalMain;\n};\n\nexport const Portal: PortalComponent = Object.assign(PortalRoot, {\n StatusBar: PortalStatusBar,\n Sidebar,\n Main: PortalMain,\n});\n\nPortal.displayName = 'Template.Portal';\nPortal.StatusBar.displayName = 'Template.Portal.StatusBar';\nPortal.Main.displayName = 'Template.Portal.Main';\n"],"names":["jsx","Grid","Sidebar"],"mappings":";;;;;;;;AAyBA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AAajC,MAAM,aAAa,MAAM;AAAA,EACvB,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH,WACEA,2BAAAA;AAAAA,MAACC,MAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,iBAAgB;AAAA,QAChB,KAAI;AAAA,QACJ,WAAU;AAAA,QACV,WAAW,WAAW,8BAA8B,SAAS;AAAA,QAC7D;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,MAAM,kBAAkB,MAAM;AAAA,EAC5B,CACE,EAAE,UAAU,WAAW,IAAI,GAAG,KAAA,GAC9B,QACG;AACH,WACED,2BAAAA;AAAAA,MAACC,MAAAA,cAAK;AAAA,MAAL;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,MAAM,aAAa,MAAM;AAAA,EACvB,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH,WACED,2BAAAA;AAAAA,MAACC,MAAAA,cAAK;AAAA,MAAL;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,SAAQ;AAAA,QACR,WAAW,WAAW,oCAAoC,SAAS;AAAA,QACnE;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAQO,MAAM,SAA0B,OAAO,OAAO,YAAY;AAAA,EAC/D,WAAW;AAAA,EAAA,SACXC,QAAAA;AAAAA,EACA,MAAM;AACR,CAAC;AAED,OAAO,cAAc;AACrB,OAAO,UAAU,cAAc;AAC/B,OAAO,KAAK,cAAc;;"}
1
+ {"version":3,"file":"Portal.cjs","sources":["../../../../../src/beta/templates/portal/Portal.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { Grid } from '../../Grid';\nimport { Sidebar, SidebarComponent } from '../Sidebar';\nimport './Portal.scss';\n\ntype PortalOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype PortalStatusBarOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype PortalMainOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultStatusBarElement = 'div';\nconst defaultPortalMainElement = 'main';\n\nexport type PortalProps<T extends React.ElementType = typeof Grid> =\n PolymorphicComponentProps<T, PortalOwnProps>;\n\nexport type PortalStatusBarProps<\n T extends React.ElementType = typeof defaultStatusBarElement,\n> = PolymorphicComponentProps<T, PortalStatusBarOwnProps>;\n\nexport type PortalMainProps<\n T extends React.ElementType = typeof defaultPortalMainElement,\n> = PolymorphicComponentProps<T, PortalMainOwnProps>;\n\nconst PortalRoot = React.forwardRef(\n <E extends React.ElementType = typeof Grid>(\n { children, className, style, as, ...rest }: PortalProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid\n ref={ref}\n as={as}\n templateColumns=\"var(--eds-sidebar-width, min-content) minmax(0, 1fr)\"\n gap=\"none\"\n columnGap=\"m\"\n className={classNames('eds-layout-template-portal', className)}\n style={style}\n {...rest}\n >\n {children}\n </Grid>\n );\n },\n);\n\nconst PortalStatusBar = React.forwardRef(\n <E extends React.ElementType = typeof defaultStatusBarElement>(\n { children, className, as, ...rest }: PortalStatusBarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid.Item\n ref={ref}\n as={as || defaultStatusBarElement}\n className={classNames(\n 'eds-layout-template-portal__status-bar',\n className,\n )}\n {...rest}\n >\n {children}\n </Grid.Item>\n );\n },\n);\n\nconst PortalMain = React.forwardRef(\n <E extends React.ElementType = typeof defaultPortalMainElement>(\n { children, className, style, as, ...rest }: PortalMainProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n return (\n <Grid.Item\n ref={ref}\n as={as || defaultPortalMainElement}\n colSpan=\"2 / -1\"\n className={classNames('eds-layout-template-portal__main', className)}\n style={style}\n {...rest}\n >\n {children}\n </Grid.Item>\n );\n },\n);\n\nexport type PortalComponent = typeof PortalRoot & {\n StatusBar: typeof PortalStatusBar;\n Sidebar: SidebarComponent;\n Main: typeof PortalMain;\n};\n\nexport const Portal: PortalComponent = Object.assign(PortalRoot, {\n StatusBar: PortalStatusBar,\n Sidebar,\n Main: PortalMain,\n});\n\nPortal.displayName = 'Template.Portal';\nPortal.StatusBar.displayName = 'Template.Portal.StatusBar';\nPortal.Main.displayName = 'Template.Portal.Main';\n"],"names":["jsx","Grid","Sidebar"],"mappings":";;;;;;;;AAyBA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AAajC,MAAM,aAAa,MAAM;AAAA,EACvB,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH,WACEA,2BAAAA;AAAAA,MAACC,MAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA,iBAAgB;AAAA,QAChB,KAAI;AAAA,QACJ,WAAU;AAAA,QACV,WAAW,WAAW,8BAA8B,SAAS;AAAA,QAC7D;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,MAAM,kBAAkB,MAAM;AAAA,EAC5B,CACE,EAAE,UAAU,WAAW,IAAI,GAAG,KAAA,GAC9B,QACG;AACH,WACED,2BAAAA;AAAAA,MAACC,MAAAA,KAAK;AAAA,MAAL;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,MAAM,aAAa,MAAM;AAAA,EACvB,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH,WACED,2BAAAA;AAAAA,MAACC,MAAAA,KAAK;AAAA,MAAL;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,SAAQ;AAAA,QACR,WAAW,WAAW,oCAAoC,SAAS;AAAA,QACnE;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAQO,MAAM,SAA0B,OAAO,OAAO,YAAY;AAAA,EAC/D,WAAW;AAAA,EAAA,SACXC,QAAAA;AAAAA,EACA,MAAM;AACR,CAAC;AAED,OAAO,cAAc;AACrB,OAAO,UAAU,cAAc;AAC/B,OAAO,KAAK,cAAc;;"}
@@ -1,18 +1,20 @@
1
1
  /* empty css */
2
- import { GridComponent } from "./Grid/index.mjs";
3
- import { FlexComponent } from "./Flex/index.mjs";
2
+ import { Grid } from "./Grid/index.mjs";
3
+ import { Flex } from "./Flex/index.mjs";
4
4
  import { Template } from "./templates/index.mjs";
5
+ import { FlexSpacer } from "./Flex/FlexSpacer.mjs";
5
6
  import { GridItem } from "./Grid/GridItem.mjs";
6
7
  import { LayoutWrapper } from "./LayoutWrapper/LayoutWrapper.mjs";
7
8
  import { useLayoutValues } from "./LayoutWrapper/useLayoutValues.mjs";
8
- import { FlexSpacer } from "./Flex/FlexSpacer.mjs";
9
+ import { useSidebarCollapsed } from "./templates/SidebarContext.mjs";
9
10
  export {
10
- FlexComponent as Flex,
11
+ Flex,
11
12
  FlexSpacer,
12
- GridComponent as Grid,
13
+ Grid,
13
14
  GridItem,
14
15
  LayoutWrapper,
15
16
  Template,
16
- useLayoutValues
17
+ useLayoutValues,
18
+ useSidebarCollapsed
17
19
  };
18
20
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -1,9 +1,12 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
+ import { useControllableProp } from "@entur/utils";
3
4
  import classNames from "classnames";
5
+ import { RightArrowIcon, LeftArrowIcon } from "@entur/icons";
4
6
  import { Contrast } from "../Contrast.mjs";
5
- import { FlexComponent } from "../Flex/index.mjs";
6
- import { GridComponent } from "../Grid/index.mjs";
7
+ import { Flex as FlexComponent } from "../Flex/index.mjs";
8
+ import { Grid as GridComponent } from "../Grid/index.mjs";
9
+ import { SidebarContext } from "./SidebarContext.mjs";
7
10
  /* empty css */
8
11
  const defaultSidebarElement = "aside";
9
12
  const defaultSectionElement = "div";
@@ -58,35 +61,100 @@ const SidebarFooter = React.forwardRef(
58
61
  );
59
62
  }
60
63
  );
64
+ const CollapseToggle = ({ isCollapsed, onToggle, openLabel, closeLabel }) => /* @__PURE__ */ jsx(
65
+ "button",
66
+ {
67
+ type: "button",
68
+ className: "eds-layout-template-sidebar__collapse-toggle",
69
+ onClick: onToggle,
70
+ "aria-expanded": !isCollapsed,
71
+ "aria-label": isCollapsed ? openLabel : closeLabel,
72
+ children: isCollapsed ? /* @__PURE__ */ jsx(RightArrowIcon, { size: 16 }) : /* @__PURE__ */ jsx(LeftArrowIcon, { size: 16 })
73
+ }
74
+ );
61
75
  const SidebarRoot = React.forwardRef(
62
76
  ({
63
77
  children,
64
78
  className,
65
79
  style,
66
80
  contrast = true,
81
+ collapsible = false,
82
+ collapsed,
83
+ onCollapseToggle,
84
+ openSidebarAriaLabel = "Åpne sidemeny",
85
+ closeSidebarAriaLabel = "Lukk sidemeny",
67
86
  as,
68
87
  ...rest
69
88
  }, ref) => {
89
+ const handleCollapseToggle = (value) => {
90
+ if (value === void 0 || !onCollapseToggle) {
91
+ return;
92
+ }
93
+ onCollapseToggle(value);
94
+ };
95
+ const [isCollapsed, setIsCollapsed] = useControllableProp({
96
+ prop: collapsible ? collapsed : void 0,
97
+ defaultValue: false,
98
+ updater: handleCollapseToggle
99
+ });
70
100
  const WrapperElement = contrast ? Contrast : "div";
71
- return /* @__PURE__ */ jsx(GridComponent.Item, { as: WrapperElement, colSpan: "1 / 2", children: /* @__PURE__ */ jsx(
72
- FlexComponent,
101
+ const sidebarClassNames = classNames(
102
+ "eds-layout-template-sidebar",
73
103
  {
74
- ref,
75
- as: as || defaultSidebarElement,
76
- direction: "column",
77
- gap: "m",
78
- className: classNames(
79
- "eds-layout-template-sidebar",
80
- {
81
- "eds-layout-template-sidebar--plain": !contrast
82
- },
83
- className
84
- ),
85
- style,
86
- ...rest,
87
- children
104
+ "eds-layout-template-sidebar--plain": !contrast,
105
+ "eds-layout-template-sidebar--collapsible": collapsible,
106
+ "eds-layout-template-sidebar--collapsed": collapsible && isCollapsed
107
+ },
108
+ className
109
+ );
110
+ if (!collapsible) {
111
+ return /* @__PURE__ */ jsx(GridComponent.Item, { as: WrapperElement, colSpan: "1 / 2", children: /* @__PURE__ */ jsx(
112
+ FlexComponent,
113
+ {
114
+ ref,
115
+ as: as || defaultSidebarElement,
116
+ direction: "column",
117
+ gap: "m",
118
+ className: sidebarClassNames,
119
+ style,
120
+ ...rest,
121
+ children
122
+ }
123
+ ) });
124
+ }
125
+ const collapsedStyle = isCollapsed ? { ...style, "--eds-sidebar-width": "2rem" } : style;
126
+ return /* @__PURE__ */ jsx(
127
+ GridComponent.Item,
128
+ {
129
+ as: WrapperElement,
130
+ colSpan: "1 / 2",
131
+ className: "eds-layout-template-sidebar-wrapper",
132
+ children: /* @__PURE__ */ jsxs(SidebarContext.Provider, { value: { isCollapsed }, children: [
133
+ /* @__PURE__ */ jsx(
134
+ FlexComponent,
135
+ {
136
+ ref,
137
+ as: as || defaultSidebarElement,
138
+ direction: "column",
139
+ gap: "m",
140
+ className: sidebarClassNames,
141
+ style: collapsedStyle,
142
+ ...rest,
143
+ children: /* @__PURE__ */ jsx("div", { className: "eds-layout-template-sidebar__content", children })
144
+ }
145
+ ),
146
+ /* @__PURE__ */ jsx(
147
+ CollapseToggle,
148
+ {
149
+ isCollapsed,
150
+ onToggle: () => setIsCollapsed(!isCollapsed),
151
+ openLabel: openSidebarAriaLabel,
152
+ closeLabel: closeSidebarAriaLabel
153
+ }
154
+ )
155
+ ] })
88
156
  }
89
- ) });
157
+ );
90
158
  }
91
159
  );
92
160
  const Sidebar = Object.assign(SidebarRoot, {
@@ -1 +1 @@
1
- {"version":3,"file":"Sidebar.mjs","sources":["../../../../src/beta/templates/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { Contrast } from '../../Contrast';\nimport { Flex } from '../Flex';\nimport { Grid } from '../Grid';\nimport './Sidebar.scss';\n\ntype SidebarOwnProps = {\n /** Toggle contrast styling for the sidebar */\n contrast?: boolean;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype SidebarSectionOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultSidebarElement = 'aside';\nconst defaultSectionElement = 'div';\nconst defaultNavigationElement = 'nav';\nconst defaultFooterElement = 'footer';\n\nexport type SidebarProps<\n T extends React.ElementType = typeof defaultSidebarElement,\n> = PolymorphicComponentProps<T, SidebarOwnProps>;\n\nexport type SidebarSectionProps<\n T extends React.ElementType = typeof defaultSectionElement,\n> = PolymorphicComponentProps<T, SidebarSectionOwnProps>;\n\nconst SidebarLogo = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarUser = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarData = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarNavigation = React.forwardRef(\n <E extends React.ElementType = typeof defaultNavigationElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultNavigationElement;\n return (\n <Element\n ref={ref}\n className={classNames(\n 'eds-layout-template-sidebar__navigation',\n className,\n )}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarFooter = React.forwardRef(\n <E extends React.ElementType = typeof defaultFooterElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultFooterElement;\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-template-sidebar__footer', className)}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarRoot = React.forwardRef(\n <E extends React.ElementType = typeof defaultSidebarElement>(\n {\n children,\n className,\n style,\n contrast = true,\n as,\n ...rest\n }: SidebarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const WrapperElement = contrast ? Contrast : 'div';\n return (\n <Grid.Item as={WrapperElement} colSpan=\"1 / 2\">\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={classNames(\n 'eds-layout-template-sidebar',\n {\n 'eds-layout-template-sidebar--plain': !contrast,\n },\n className,\n )}\n style={style}\n {...rest}\n >\n {children}\n </Flex>\n </Grid.Item>\n );\n },\n);\n\nexport type SidebarComponent = typeof SidebarRoot & {\n Logo: typeof SidebarLogo;\n User: typeof SidebarUser;\n Data: typeof SidebarData;\n Navigation: typeof SidebarNavigation;\n Footer: typeof SidebarFooter;\n};\n\nexport const Sidebar: SidebarComponent = Object.assign(SidebarRoot, {\n Logo: SidebarLogo,\n User: SidebarUser,\n Data: SidebarData,\n Navigation: SidebarNavigation,\n Footer: SidebarFooter,\n});\n\nSidebar.displayName = 'Template.Portal.Sidebar';\nSidebar.Logo.displayName = 'Template.Portal.Sidebar.Logo';\nSidebar.User.displayName = 'Template.Portal.Sidebar.User';\nSidebar.Data.displayName = 'Template.Portal.Sidebar.Data';\nSidebar.Navigation.displayName = 'Template.Portal.Sidebar.Navigation';\nSidebar.Footer.displayName = 'Template.Portal.Sidebar.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AAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,iBAAiB,WAAW,WAAW;AAC7C,+BACGA,cAAK,MAAL,EAAU,IAAI,gBAAgB,SAAQ,SACrC,UAAA;AAAA,MAACC;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QACJ,WAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE,sCAAsC,CAAC;AAAA,UAAA;AAAA,UAEzC;AAAA,QAAA;AAAA,QAEF;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA,GAEL;AAAA,EAEJ;AACF;AAUO,MAAM,UAA4B,OAAO,OAAO,aAAa;AAAA,EAClE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ;AACV,CAAC;AAED,QAAQ,cAAc;AACtB,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,WAAW,cAAc;AACjC,QAAQ,OAAO,cAAc;"}
1
+ {"version":3,"file":"Sidebar.mjs","sources":["../../../../src/beta/templates/Sidebar.tsx"],"sourcesContent":["import React from 'react';\nimport type { PolymorphicComponentProps } from '@entur/utils';\nimport { useControllableProp } from '@entur/utils';\nimport classNames from 'classnames';\nimport { LeftArrowIcon, RightArrowIcon } from '@entur/icons';\nimport { Contrast } from '../../Contrast';\nimport { Flex } from '../Flex';\nimport { Grid } from '../Grid';\nimport { SidebarContext } from './SidebarContext';\nimport './Sidebar.scss';\n\ntype SidebarOwnProps = {\n /** Toggle contrast styling for the sidebar */\n contrast?: boolean;\n /** Enable collapse functionality */\n collapsible?: boolean;\n /** Controlled collapsed state */\n collapsed?: boolean;\n /** Callback when the sidebar is toggled */\n onCollapseToggle?: (collapsed: boolean) => void;\n /** aria-label for the toggle button when the sidebar is collapsed\n * @default 'Åpne sidemeny'\n */\n openSidebarAriaLabel?: string;\n /** aria-label for the toggle button when the sidebar is expanded\n * @default 'Lukk sidemeny'\n */\n closeSidebarAriaLabel?: string;\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\ntype SidebarSectionOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n};\n\nconst defaultSidebarElement = 'aside';\nconst defaultSectionElement = 'div';\nconst defaultNavigationElement = 'nav';\nconst defaultFooterElement = 'footer';\n\nexport type SidebarProps<\n T extends React.ElementType = typeof defaultSidebarElement,\n> = PolymorphicComponentProps<T, SidebarOwnProps>;\n\nexport type SidebarSectionProps<\n T extends React.ElementType = typeof defaultSectionElement,\n> = PolymorphicComponentProps<T, SidebarSectionOwnProps>;\n\nconst SidebarLogo = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarUser = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarData = React.forwardRef(\n <E extends React.ElementType = typeof defaultSectionElement>(\n { children, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultSectionElement;\n return (\n <Element ref={ref} {...rest}>\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarNavigation = React.forwardRef(\n <E extends React.ElementType = typeof defaultNavigationElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultNavigationElement;\n return (\n <Element\n ref={ref}\n className={classNames(\n 'eds-layout-template-sidebar__navigation',\n className,\n )}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst SidebarFooter = React.forwardRef(\n <E extends React.ElementType = typeof defaultFooterElement>(\n { children, className, as, ...rest }: SidebarSectionProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const Element: React.ElementType = as || defaultFooterElement;\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-template-sidebar__footer', className)}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n\nconst CollapseToggle: React.FC<{\n isCollapsed: boolean;\n onToggle: () => void;\n openLabel: string;\n closeLabel: string;\n}> = ({ isCollapsed, onToggle, openLabel, closeLabel }) => (\n <button\n type=\"button\"\n className=\"eds-layout-template-sidebar__collapse-toggle\"\n onClick={onToggle}\n aria-expanded={!isCollapsed}\n aria-label={isCollapsed ? openLabel : closeLabel}\n >\n {isCollapsed ? <RightArrowIcon size={16} /> : <LeftArrowIcon size={16} />}\n </button>\n);\n\nconst SidebarRoot = React.forwardRef(\n <E extends React.ElementType = typeof defaultSidebarElement>(\n {\n children,\n className,\n style,\n contrast = true,\n collapsible = false,\n collapsed,\n onCollapseToggle,\n openSidebarAriaLabel = 'Åpne sidemeny',\n closeSidebarAriaLabel = 'Lukk sidemeny',\n as,\n ...rest\n }: SidebarProps<E>,\n ref?: React.Ref<Element>,\n ) => {\n const handleCollapseToggle: (value?: boolean) => void = value => {\n if (value === undefined || !onCollapseToggle) {\n return;\n }\n onCollapseToggle(value);\n };\n\n const [isCollapsed, setIsCollapsed] = useControllableProp({\n prop: collapsible ? collapsed : undefined,\n defaultValue: false,\n updater: handleCollapseToggle,\n });\n\n const WrapperElement = contrast ? Contrast : 'div';\n\n const sidebarClassNames = classNames(\n 'eds-layout-template-sidebar',\n {\n 'eds-layout-template-sidebar--plain': !contrast,\n 'eds-layout-template-sidebar--collapsible': collapsible,\n 'eds-layout-template-sidebar--collapsed': collapsible && isCollapsed,\n },\n className,\n );\n\n if (!collapsible) {\n return (\n <Grid.Item as={WrapperElement} colSpan=\"1 / 2\">\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={sidebarClassNames}\n style={style}\n {...rest}\n >\n {children}\n </Flex>\n </Grid.Item>\n );\n }\n\n const collapsedStyle = isCollapsed\n ? ({ ...style, '--eds-sidebar-width': '2rem' } as React.CSSProperties)\n : style;\n\n return (\n <Grid.Item\n as={WrapperElement}\n colSpan=\"1 / 2\"\n className=\"eds-layout-template-sidebar-wrapper\"\n >\n <SidebarContext.Provider value={{ isCollapsed }}>\n <Flex\n ref={ref}\n as={as || defaultSidebarElement}\n direction=\"column\"\n gap=\"m\"\n className={sidebarClassNames}\n style={collapsedStyle}\n {...rest}\n >\n <div className=\"eds-layout-template-sidebar__content\">\n {children}\n </div>\n </Flex>\n <CollapseToggle\n isCollapsed={isCollapsed}\n onToggle={() => setIsCollapsed(!isCollapsed)}\n openLabel={openSidebarAriaLabel}\n closeLabel={closeSidebarAriaLabel}\n />\n </SidebarContext.Provider>\n </Grid.Item>\n );\n },\n);\n\nexport type SidebarComponent = typeof SidebarRoot & {\n Logo: typeof SidebarLogo;\n User: typeof SidebarUser;\n Data: typeof SidebarData;\n Navigation: typeof SidebarNavigation;\n Footer: typeof SidebarFooter;\n};\n\nexport const Sidebar: SidebarComponent = Object.assign(SidebarRoot, {\n Logo: SidebarLogo,\n User: SidebarUser,\n Data: SidebarData,\n Navigation: SidebarNavigation,\n Footer: SidebarFooter,\n});\n\nSidebar.displayName = 'Template.Portal.Sidebar';\nSidebar.Logo.displayName = 'Template.Portal.Sidebar.Logo';\nSidebar.User.displayName = 'Template.Portal.Sidebar.User';\nSidebar.Data.displayName = 'Template.Portal.Sidebar.Data';\nSidebar.Navigation.displayName = 'Template.Portal.Sidebar.Navigation';\nSidebar.Footer.displayName = 'Template.Portal.Sidebar.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BAAiB,cAClB,EAAE,GAAG,OAAO,uBAAuB,WACpC;AAEJ,WACE;AAAA,MAACD,cAAK;AAAA,MAAL;AAAA,QACC,IAAI;AAAA,QACJ,SAAQ;AAAA,QACR,WAAU;AAAA,QAEV,+BAAC,eAAe,UAAf,EAAwB,OAAO,EAAE,eAChC,UAAA;AAAA,UAAA;AAAA,YAACC;AAAAA,YAAA;AAAA,cACC;AAAA,cACA,IAAI,MAAM;AAAA,cACV,WAAU;AAAA,cACV,KAAI;AAAA,cACJ,WAAW;AAAA,cACX,OAAO;AAAA,cACN,GAAG;AAAA,cAEJ,UAAA,oBAAC,OAAA,EAAI,WAAU,wCACZ,SAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,UAEF;AAAA,YAAC;AAAA,YAAA;AAAA,cACC;AAAA,cACA,UAAU,MAAM,eAAe,CAAC,WAAW;AAAA,cAC3C,WAAW;AAAA,cACX,YAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACd,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAUO,MAAM,UAA4B,OAAO,OAAO,aAAa;AAAA,EAClE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,QAAQ;AACV,CAAC;AAED,QAAQ,cAAc;AACtB,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,KAAK,cAAc;AAC3B,QAAQ,WAAW,cAAc;AACjC,QAAQ,OAAO,cAAc;"}
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ const SidebarContext = React.createContext({
3
+ isCollapsed: false
4
+ });
5
+ const useSidebarCollapsed = () => React.useContext(SidebarContext);
6
+ export {
7
+ SidebarContext,
8
+ useSidebarCollapsed
9
+ };
10
+ //# sourceMappingURL=SidebarContext.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidebarContext.mjs","sources":["../../../../src/beta/templates/SidebarContext.tsx"],"sourcesContent":["import React from 'react';\n\nexport const SidebarContext = React.createContext<{\n isCollapsed: boolean;\n}>({\n isCollapsed: false,\n});\n\n/** Hook to read the collapsed state of the nearest `Template.Portal.Sidebar`.\n * Returns `{ isCollapsed: false }` when used outside a collapsible sidebar. */\nexport const useSidebarCollapsed: () => { isCollapsed: boolean } = () =>\n React.useContext(SidebarContext);\n"],"names":[],"mappings":";AAEO,MAAM,iBAAiB,MAAM,cAEjC;AAAA,EACD,aAAa;AACf,CAAC;AAIM,MAAM,sBAAsD,MACjE,MAAM,WAAW,cAAc;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/beta/templates/index.ts"],"sourcesContent":["import { Portal } from './portal';\nimport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n} from './portal';\nimport type {\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n} from './Sidebar';\n\nexport type TemplateComponent = {\n Portal: PortalComponent;\n};\n\nexport const Template: TemplateComponent = {\n Portal,\n};\n\nexport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n};\n"],"names":[],"mappings":";AAiBO,MAAM,WAA8B;AAAA,EACzC;AACF;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/beta/templates/index.ts"],"sourcesContent":["import { Portal } from './portal';\nimport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n} from './portal';\nimport type {\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n} from './Sidebar';\n\nexport { useSidebarCollapsed } from './SidebarContext';\n\nexport type TemplateComponent = {\n Portal: PortalComponent;\n};\n\nexport const Template: TemplateComponent = {\n Portal,\n};\n\nexport type {\n PortalComponent,\n PortalMainProps,\n PortalProps,\n PortalStatusBarProps,\n SidebarComponent,\n SidebarProps,\n SidebarSectionProps,\n};\n"],"names":[],"mappings":";AAmBO,MAAM,WAA8B;AAAA,EACzC;AACF;"}
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import classNames from "classnames";
4
- import { GridComponent } from "../../Grid/index.mjs";
4
+ import { Grid as GridComponent } from "../../Grid/index.mjs";
5
5
  import { Sidebar } from "../Sidebar.mjs";
6
6
  /* empty css */
7
7
  const defaultStatusBarElement = "div";
@@ -164,12 +164,24 @@
164
164
  -moz-box-flex:1;
165
165
  flex:1 1 0%;
166
166
  }.eds-layout-template-sidebar{
167
- padding:1rem;
168
- padding:var(--eds-sidebar-padding, 1rem);
167
+ padding:2rem;
168
+ padding:var(--eds-sidebar-padding, 2rem);
169
169
  height:100%;
170
170
  width:20rem;
171
171
  width:var(--eds-sidebar-width, 20rem);
172
172
  }
173
+ .eds-layout-template-sidebar--collapsible{
174
+ overflow:hidden;
175
+ contain:inline-size;
176
+ -webkit-transition:width ease-in-out 0.2s;
177
+ -o-transition:width ease-in-out 0.2s;
178
+ -moz-transition:width ease-in-out 0.2s;
179
+ transition:width ease-in-out 0.2s;
180
+ }
181
+ .eds-layout-template-sidebar--collapsed{
182
+ padding:2rem 0;
183
+ padding:var(--eds-sidebar-padding, 2rem) 0;
184
+ }
173
185
 
174
186
  .eds-layout-template-sidebar--plain{
175
187
  background-color:var(--components-menu-sidenavigation-standard-background);
@@ -180,26 +192,124 @@
180
192
  -webkit-flex:1 1 auto;
181
193
  -moz-box-flex:1;
182
194
  flex:1 1 auto;
183
- margin-left:-webkit-calc(-1 * 1rem);
184
- margin-left:-moz-calc(-1 * 1rem);
185
- margin-left:calc(-1 * 1rem);
186
- margin-left:-webkit-calc(-1 * var(--eds-sidebar-padding, 1rem));
187
- margin-left:-moz-calc(-1 * var(--eds-sidebar-padding, 1rem));
188
- margin-left:calc(-1 * var(--eds-sidebar-padding, 1rem));
189
- margin-right:-webkit-calc(-1 * 1rem);
190
- margin-right:-moz-calc(-1 * 1rem);
191
- margin-right:calc(-1 * 1rem);
192
- margin-right:-webkit-calc(-1 * var(--eds-sidebar-padding, 1rem));
193
- margin-right:-moz-calc(-1 * var(--eds-sidebar-padding, 1rem));
194
- margin-right:calc(-1 * var(--eds-sidebar-padding, 1rem));
195
+ margin-left:-webkit-calc(-1 * 2rem);
196
+ margin-left:-moz-calc(-1 * 2rem);
197
+ margin-left:calc(-1 * 2rem);
198
+ margin-left:-webkit-calc(-1 * var(--eds-sidebar-padding, 2rem));
199
+ margin-left:-moz-calc(-1 * var(--eds-sidebar-padding, 2rem));
200
+ margin-left:calc(-1 * var(--eds-sidebar-padding, 2rem));
201
+ margin-right:-webkit-calc(-1 * 2rem);
202
+ margin-right:-moz-calc(-1 * 2rem);
203
+ margin-right:calc(-1 * 2rem);
204
+ margin-right:-webkit-calc(-1 * var(--eds-sidebar-padding, 2rem));
205
+ margin-right:-moz-calc(-1 * var(--eds-sidebar-padding, 2rem));
206
+ margin-right:calc(-1 * var(--eds-sidebar-padding, 2rem));
195
207
  }
196
208
 
197
209
  .eds-layout-template-sidebar__footer{
198
210
  margin-top:auto;
211
+ }
212
+
213
+ .eds-layout-template-sidebar__content{
214
+ display:-webkit-box;
215
+ display:-webkit-flex;
216
+ display:-moz-box;
217
+ display:flex;
218
+ -webkit-box-orient:vertical;
219
+ -webkit-box-direction:normal;
220
+ -webkit-flex-direction:column;
221
+ -moz-box-orient:vertical;
222
+ -moz-box-direction:normal;
223
+ flex-direction:column;
224
+ gap:var(--m);
225
+ -webkit-box-flex:1;
226
+ -webkit-flex:1 0 auto;
227
+ -moz-box-flex:1;
228
+ flex:1 0 auto;
229
+ min-width:-webkit-calc(20rem - 2 * 2rem);
230
+ min-width:-moz-calc(20rem - 2 * 2rem);
231
+ min-width:calc(20rem - 2 * 2rem);
232
+ min-width:-webkit-calc(var(--eds-sidebar-width, 20rem) - 2 * var(--eds-sidebar-padding, 2rem));
233
+ min-width:-moz-calc(var(--eds-sidebar-width, 20rem) - 2 * var(--eds-sidebar-padding, 2rem));
234
+ min-width:calc(var(--eds-sidebar-width, 20rem) - 2 * var(--eds-sidebar-padding, 2rem));
235
+ opacity:1;
236
+ -webkit-transition:opacity ease-in 0.1s 0.2s;
237
+ -o-transition:opacity ease-in 0.1s 0.2s;
238
+ -moz-transition:opacity ease-in 0.1s 0.2s;
239
+ transition:opacity ease-in 0.1s 0.2s;
240
+ }
241
+ .eds-layout-template-sidebar--collapsed .eds-layout-template-sidebar__content{
242
+ opacity:0;
243
+ visibility:hidden;
244
+ -webkit-transition:opacity ease-out 0.1s, visibility 0s 0.1s;
245
+ -o-transition:opacity ease-out 0.1s, visibility 0s 0.1s;
246
+ -moz-transition:opacity ease-out 0.1s, visibility 0s 0.1s;
247
+ transition:opacity ease-out 0.1s, visibility 0s 0.1s;
248
+ }
249
+
250
+ .eds-layout-template-sidebar-wrapper{
251
+ position:relative;
252
+ }
253
+
254
+ .eds-layout-template-sidebar__collapse-toggle{
255
+ position:absolute;
256
+ right:-1rem;
257
+ bottom:2rem;
258
+ height:2rem;
259
+ width:2rem;
260
+ -webkit-border-radius:50%;
261
+ -moz-border-radius:50%;
262
+ border-radius:50%;
263
+ border:none;
264
+ cursor:pointer;
265
+ background-color:var(--basecolors-frame-default);
266
+ color:var(--text-dark);
267
+ -webkit-box-shadow:0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.25);
268
+ -moz-box-shadow:0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.25);
269
+ box-shadow:0 0.0625rem 0.1875rem rgba(0, 0, 0, 0.25);
270
+ display:-webkit-box;
271
+ display:-webkit-flex;
272
+ display:-moz-box;
273
+ display:flex;
274
+ -webkit-box-align:center;
275
+ -webkit-align-items:center;
276
+ -moz-box-align:center;
277
+ align-items:center;
278
+ -webkit-box-pack:center;
279
+ -webkit-justify-content:center;
280
+ -moz-box-pack:center;
281
+ justify-content:center;
282
+ z-index:10;
283
+ padding:0;
284
+ }
285
+ .eds-contrast .eds-layout-template-sidebar__collapse-toggle{
286
+ background-color:var(--basecolors-frame-contrastalt);
287
+ color:var(--basecolors-text-light);
288
+ }
289
+ .eds-layout-template-sidebar__collapse-toggle svg{
290
+ margin:0;
291
+ }
292
+ .eds-layout-template-sidebar__collapse-toggle:focus-visible{
293
+ outline:2px solid #181c56;
294
+ outline-color:var(--basecolors-stroke-focus-standard);
295
+ outline-offset:0.125rem;
296
+ }
297
+ .eds-contrast .eds-layout-template-sidebar__collapse-toggle:focus-visible{
298
+ outline-color:var(--basecolors-stroke-focus-contrast);
199
299
  }.eds-layout-template-portal{
200
300
  min-height:100vh;
201
301
  width:100%;
202
302
  }
303
+ .eds-layout-template-portal:has(.eds-layout-template-sidebar--collapsible){
304
+ -webkit-transition:grid-template-columns ease-in-out 0.2s;
305
+ -o-transition:grid-template-columns ease-in-out 0.2s;
306
+ -moz-transition:grid-template-columns ease-in-out 0.2s;
307
+ transition:grid-template-columns ease-in-out 0.2s;
308
+ transition:grid-template-columns ease-in-out 0.2s, -ms-grid-columns ease-in-out 0.2s;
309
+ }
310
+ .eds-layout-template-portal:has(.eds-layout-template-sidebar--collapsed){
311
+ grid-template-columns:2rem minmax(0, 1fr);
312
+ }
203
313
  .eds-layout-template-portal:has(> .eds-layout-template-portal__status-bar){
204
314
  --grid-template-rows:auto 1fr;
205
315
  }
@@ -1,7 +1,7 @@
1
1
  export { Grid, GridItem } from './Grid';
2
2
  export { LayoutWrapper, useLayoutValues } from './LayoutWrapper';
3
3
  export { Flex, FlexSpacer } from './Flex';
4
- export { Template } from './templates';
4
+ export { Template, useSidebarCollapsed } from './templates';
5
5
  export type { GridProps, GridOwnProps, GridItemProps, GridItemOwnProps, GridSpacingValue, ResponsiveValue, } from './Grid';
6
6
  export type { FlexProps, FlexOwnProps, FlexSpacingValue, FlexSpacerProps, FlexSpacerOwnProps, } from './Flex';
7
7
  export type { PortalComponent, PortalMainProps, PortalProps, PortalStatusBarProps, SidebarComponent, SidebarProps, SidebarSectionProps, TemplateComponent, } from './templates';
@@ -3,6 +3,20 @@ import { PolymorphicComponentProps } from '@entur/utils';
3
3
  type SidebarOwnProps = {
4
4
  /** Toggle contrast styling for the sidebar */
5
5
  contrast?: boolean;
6
+ /** Enable collapse functionality */
7
+ collapsible?: boolean;
8
+ /** Controlled collapsed state */
9
+ collapsed?: boolean;
10
+ /** Callback when the sidebar is toggled */
11
+ onCollapseToggle?: (collapsed: boolean) => void;
12
+ /** aria-label for the toggle button when the sidebar is collapsed
13
+ * @default 'Åpne sidemeny'
14
+ */
15
+ openSidebarAriaLabel?: string;
16
+ /** aria-label for the toggle button when the sidebar is expanded
17
+ * @default 'Lukk sidemeny'
18
+ */
19
+ closeSidebarAriaLabel?: string;
6
20
  className?: string;
7
21
  style?: React.CSSProperties;
8
22
  children?: React.ReactNode;
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ export declare const SidebarContext: React.Context<{
3
+ isCollapsed: boolean;
4
+ }>;
5
+ /** Hook to read the collapsed state of the nearest `Template.Portal.Sidebar`.
6
+ * Returns `{ isCollapsed: false }` when used outside a collapsible sidebar. */
7
+ export declare const useSidebarCollapsed: () => {
8
+ isCollapsed: boolean;
9
+ };
@@ -1,5 +1,6 @@
1
1
  import { PortalComponent, PortalMainProps, PortalProps, PortalStatusBarProps } from './portal';
2
2
  import { SidebarComponent, SidebarProps, SidebarSectionProps } from './Sidebar';
3
+ export { useSidebarCollapsed } from './SidebarContext';
3
4
  export type TemplateComponent = {
4
5
  Portal: PortalComponent;
5
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur/layout",
3
- "version": "3.4.2",
3
+ "version": "3.5.0",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/layout.cjs.js",
6
6
  "module": "dist/layout.esm.js",
@@ -51,10 +51,10 @@
51
51
  "react-dom": ">=16.8.0"
52
52
  },
53
53
  "dependencies": {
54
- "@entur/icons": "^8.4.3",
55
- "@entur/tokens": "^3.22.2",
56
- "@entur/typography": "^2.1.4",
57
- "@entur/utils": "^0.13.1",
54
+ "@entur/icons": "^8.4.4",
55
+ "@entur/tokens": "^3.22.3",
56
+ "@entur/typography": "^2.1.5",
57
+ "@entur/utils": "^0.13.2",
58
58
  "classnames": "^2.5.1"
59
59
  },
60
60
  "devDependencies": {
@@ -70,5 +70,5 @@
70
70
  "vite": "^7.1.3",
71
71
  "vite-plugin-dts": "^4.5.4"
72
72
  },
73
- "gitHead": "ee1f35746ed0ce1e2ab24377ec9d1bb78f6fabac"
73
+ "gitHead": "9ac8be0952badd4043470e47e50992369ada2c11"
74
74
  }