@entur/layout 3.5.0 → 3.6.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/dist/beta/cjs/Grid/Grid.cjs +2 -2
- package/dist/beta/cjs/Grid/Grid.cjs.map +1 -1
- package/dist/beta/cjs/LayoutWrapper/LayoutWrapper.cjs.map +1 -1
- package/dist/beta/cjs/LayoutWrapper/useLayoutValues.cjs.map +1 -1
- package/dist/beta/cjs/index.cjs +0 -2
- package/dist/beta/cjs/index.cjs.map +1 -1
- package/dist/beta/cjs/templates/Sidebar.cjs +45 -51
- package/dist/beta/cjs/templates/Sidebar.cjs.map +1 -1
- package/dist/beta/cjs/templates/index.cjs.map +1 -1
- package/dist/beta/cjs/templates/portal/Portal.cjs +0 -1
- package/dist/beta/cjs/templates/portal/Portal.cjs.map +1 -1
- package/dist/beta/esm/Grid/Grid.mjs +2 -2
- package/dist/beta/esm/Grid/Grid.mjs.map +1 -1
- package/dist/beta/esm/LayoutWrapper/LayoutWrapper.mjs.map +1 -1
- package/dist/beta/esm/LayoutWrapper/useLayoutValues.mjs.map +1 -1
- package/dist/beta/esm/index.mjs +1 -3
- package/dist/beta/esm/index.mjs.map +1 -1
- package/dist/beta/esm/templates/Sidebar.mjs +45 -51
- package/dist/beta/esm/templates/Sidebar.mjs.map +1 -1
- package/dist/beta/esm/templates/index.mjs.map +1 -1
- package/dist/beta/esm/templates/portal/Portal.mjs +0 -1
- package/dist/beta/esm/templates/portal/Portal.mjs.map +1 -1
- package/dist/beta/styles/index.css +32 -15
- package/dist/beta/types/index.d.ts +1 -1
- package/dist/beta/types/templates/Sidebar.d.ts +3 -4
- package/dist/beta/types/templates/index.d.ts +0 -1
- package/dist/layout.cjs.js.map +1 -1
- package/dist/layout.esm.js.map +1 -1
- package/package.json +7 -9
- package/dist/beta/cjs/Contrast.cjs +0 -21
- package/dist/beta/cjs/Contrast.cjs.map +0 -1
- package/dist/beta/cjs/templates/SidebarContext.cjs +0 -10
- package/dist/beta/cjs/templates/SidebarContext.cjs.map +0 -1
- package/dist/beta/esm/Contrast.mjs +0 -21
- package/dist/beta/esm/Contrast.mjs.map +0 -1
- package/dist/beta/esm/templates/SidebarContext.mjs +0 -10
- package/dist/beta/esm/templates/SidebarContext.mjs.map +0 -1
- package/dist/beta/types/templates/SidebarContext.d.ts +0 -9
|
@@ -26,12 +26,12 @@ const Grid = React.forwardRef(
|
|
|
26
26
|
...rest
|
|
27
27
|
}, ref) => {
|
|
28
28
|
const Element = as || defaultElement;
|
|
29
|
-
const resolvedTemplateColumns = useResponsiveValue.useResponsiveValue(templateColumns)
|
|
29
|
+
const resolvedTemplateColumns = useResponsiveValue.useResponsiveValue(templateColumns);
|
|
30
30
|
const resolvedTemplateRows = useResponsiveValue.useResponsiveValue(templateRows);
|
|
31
31
|
const resolvedGap = useResponsiveValue.useResponsiveValue(gap);
|
|
32
32
|
const resolvedRowGap = useResponsiveValue.useResponsiveValue(rowGap);
|
|
33
33
|
const resolvedColumnGap = useResponsiveValue.useResponsiveValue(columnGap);
|
|
34
|
-
const resolvedAutoFlow = useResponsiveValue.useResponsiveValue(autoFlow)
|
|
34
|
+
const resolvedAutoFlow = useResponsiveValue.useResponsiveValue(autoFlow);
|
|
35
35
|
const resolvedAlign = useResponsiveValue.useResponsiveValue(align);
|
|
36
36
|
const resolvedJustify = useResponsiveValue.useResponsiveValue(justify);
|
|
37
37
|
const resolvedAlignContent = useResponsiveValue.useResponsiveValue(alignContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.cjs","sources":["../../../../src/beta/Grid/Grid.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport classNames from 'classnames';\n\nimport './Grid.scss';\n\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\n\nexport type GridOwnProps = {\n /** CSS grid-template-columns value (supports responsive objects)\n * @default \"repeat(12, 1fr)\"\n */\n templateColumns?: string | ResponsiveValue<string>;\n /** Spacing between grid items (supports responsive objects)\n * @default \"m\"\n */\n gap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Vertical spacing between grid rows (supports responsive objects) */\n rowGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Horizontal spacing between grid columns (supports responsive objects) */\n columnGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** CSS grid-template-rows value (supports responsive objects) */\n templateRows?: string | ResponsiveValue<string>;\n /** CSS grid-auto-flow value (supports responsive objects)\n * @default \"row\"\n */\n autoFlow?:\n | 'row'\n | 'column'\n | 'dense'\n | 'row dense'\n | 'column dense'\n | ResponsiveValue<\n 'row' | 'column' | 'dense' | 'row dense' | 'column dense'\n >;\n /** CSS align-items value (supports responsive objects) */\n align?: AlignItems | ResponsiveValue<AlignItems>;\n /** CSS justify-content value (supports responsive objects) */\n justify?: JustifyContent | ResponsiveValue<JustifyContent>;\n /** CSS align-content value (supports responsive objects) */\n alignContent?: AlignContent | ResponsiveValue<AlignContent>;\n /** The height of the grid container */\n height?: string;\n /** HTML element or React component used to render the Grid\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid container */\n children?: React.ReactNode;\n};\n\nexport type GridProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Grid = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n templateColumns,\n templateRows,\n gap = 'm',\n rowGap,\n columnGap,\n autoFlow = 'row',\n align,\n justify,\n alignContent,\n height,\n as,\n className,\n children,\n style,\n ...rest\n }: GridProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedTemplateColumns
|
|
1
|
+
{"version":3,"file":"Grid.cjs","sources":["../../../../src/beta/Grid/Grid.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport classNames from 'classnames';\n\nimport './Grid.scss';\n\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\n\nexport type GridOwnProps = {\n /** CSS grid-template-columns value (supports responsive objects)\n * @default \"repeat(12, 1fr)\"\n */\n templateColumns?: string | ResponsiveValue<string>;\n /** Spacing between grid items (supports responsive objects)\n * @default \"m\"\n */\n gap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Vertical spacing between grid rows (supports responsive objects) */\n rowGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Horizontal spacing between grid columns (supports responsive objects) */\n columnGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** CSS grid-template-rows value (supports responsive objects) */\n templateRows?: string | ResponsiveValue<string>;\n /** CSS grid-auto-flow value (supports responsive objects)\n * @default \"row\"\n */\n autoFlow?:\n | 'row'\n | 'column'\n | 'dense'\n | 'row dense'\n | 'column dense'\n | ResponsiveValue<\n 'row' | 'column' | 'dense' | 'row dense' | 'column dense'\n >;\n /** CSS align-items value (supports responsive objects) */\n align?: AlignItems | ResponsiveValue<AlignItems>;\n /** CSS justify-content value (supports responsive objects) */\n justify?: JustifyContent | ResponsiveValue<JustifyContent>;\n /** CSS align-content value (supports responsive objects) */\n alignContent?: AlignContent | ResponsiveValue<AlignContent>;\n /** The height of the grid container */\n height?: string;\n /** HTML element or React component used to render the Grid\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid container */\n children?: React.ReactNode;\n};\n\nexport type GridProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Grid = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n templateColumns,\n templateRows,\n gap = 'm',\n rowGap,\n columnGap,\n autoFlow = 'row',\n align,\n justify,\n alignContent,\n height,\n as,\n className,\n children,\n style,\n ...rest\n }: GridProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedTemplateColumns = useResponsiveValue(templateColumns);\n const resolvedTemplateRows = useResponsiveValue(templateRows);\n const resolvedGap = useResponsiveValue(gap);\n const resolvedRowGap = useResponsiveValue(rowGap);\n const resolvedColumnGap = useResponsiveValue(columnGap);\n const resolvedAutoFlow = useResponsiveValue(autoFlow);\n const resolvedAlign = useResponsiveValue(align);\n const resolvedJustify = useResponsiveValue(justify);\n const resolvedAlignContent = useResponsiveValue(alignContent);\n\n const gridStyle: React.CSSProperties = {\n ...(resolvedTemplateColumns && {\n '--grid-template-columns': resolvedTemplateColumns,\n }),\n ...(resolvedTemplateRows && {\n '--grid-template-rows': resolvedTemplateRows,\n }),\n ...(resolvedAutoFlow && {\n '--grid-auto-flow': resolvedAutoFlow,\n }),\n ...(resolvedAlign && {\n '--grid-align-items': resolvedAlign,\n }),\n ...(resolvedJustify && {\n '--grid-justify-content': resolvedJustify,\n }),\n ...(resolvedAlignContent && {\n '--grid-align-content': resolvedAlignContent,\n }),\n ...(resolvedGap && {\n '--grid-gap': getSpacingValue(resolvedGap),\n }),\n ...(resolvedRowGap && {\n '--grid-row-gap': getSpacingValue(resolvedRowGap),\n }),\n ...(resolvedColumnGap && {\n '--grid-column-gap': getSpacingValue(resolvedColumnGap),\n }),\n ...(height && {\n '--grid-height': height,\n }),\n ...style,\n } as React.CSSProperties;\n\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-grid', className)}\n style={gridStyle}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n"],"names":["useResponsiveValue","getSpacingValue","jsx"],"mappings":";;;;;;;;AA6DA,MAAM,iBAAiB;AAEhB,MAAM,OAAO,MAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACgB;AAChB,UAAM,UAA6B,MAAM;AAEzC,UAAM,0BAA0BA,mBAAAA,mBAAmB,eAAe;AAClE,UAAM,uBAAuBA,mBAAAA,mBAAmB,YAAY;AAC5D,UAAM,cAAcA,mBAAAA,mBAAmB,GAAG;AAC1C,UAAM,iBAAiBA,mBAAAA,mBAAmB,MAAM;AAChD,UAAM,oBAAoBA,mBAAAA,mBAAmB,SAAS;AACtD,UAAM,mBAAmBA,mBAAAA,mBAAmB,QAAQ;AACpD,UAAM,gBAAgBA,mBAAAA,mBAAmB,KAAK;AAC9C,UAAM,kBAAkBA,mBAAAA,mBAAmB,OAAO;AAClD,UAAM,uBAAuBA,mBAAAA,mBAAmB,YAAY;AAE5D,UAAM,YAAiC;AAAA,MACrC,GAAI,2BAA2B;AAAA,QAC7B,2BAA2B;AAAA,MAAA;AAAA,MAE7B,GAAI,wBAAwB;AAAA,QAC1B,wBAAwB;AAAA,MAAA;AAAA,MAE1B,GAAI,oBAAoB;AAAA,QACtB,oBAAoB;AAAA,MAAA;AAAA,MAEtB,GAAI,iBAAiB;AAAA,QACnB,sBAAsB;AAAA,MAAA;AAAA,MAExB,GAAI,mBAAmB;AAAA,QACrB,0BAA0B;AAAA,MAAA;AAAA,MAE5B,GAAI,wBAAwB;AAAA,QAC1B,wBAAwB;AAAA,MAAA;AAAA,MAE1B,GAAI,eAAe;AAAA,QACjB,cAAcC,MAAAA,gBAAgB,WAAW;AAAA,MAAA;AAAA,MAE3C,GAAI,kBAAkB;AAAA,QACpB,kBAAkBA,MAAAA,gBAAgB,cAAc;AAAA,MAAA;AAAA,MAElD,GAAI,qBAAqB;AAAA,QACvB,qBAAqBA,MAAAA,gBAAgB,iBAAiB;AAAA,MAAA;AAAA,MAExD,GAAI,UAAU;AAAA,QACZ,iBAAiB;AAAA,MAAA;AAAA,MAEnB,GAAG;AAAA,IAAA;AAGL,WACEC,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW,WAAW,mBAAmB,SAAS;AAAA,QAClD,OAAO;AAAA,QACN,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutWrapper.cjs","sources":["../../../../src/beta/LayoutWrapper/LayoutWrapper.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"LayoutWrapper.cjs","sources":["../../../../src/beta/LayoutWrapper/LayoutWrapper.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react';\nimport { type Breakpoints, DEFAULT_BREAKPOINTS } from './utils';\n\nexport type LayoutValues = {\n breakpoints: Breakpoints;\n};\n\nconst LayoutContext = createContext<LayoutValues | null>(null);\n\nexport type LayoutWrapperProps = {\n /** Custom breakpoint values to override defaults */\n breakpoints?: Partial<Breakpoints>;\n /** Children components that can use layout values */\n children: React.ReactNode;\n};\n\nexport const LayoutWrapper = ({\n breakpoints: customBreakpoints,\n children,\n}: LayoutWrapperProps): JSX.Element => {\n const breakpoints = useMemo<Breakpoints>(\n () => ({\n ...DEFAULT_BREAKPOINTS,\n ...customBreakpoints,\n }),\n [customBreakpoints],\n );\n\n const layoutValues = useMemo<LayoutValues>(\n () => ({\n breakpoints,\n }),\n [breakpoints],\n );\n\n return (\n <LayoutContext.Provider value={layoutValues}>\n {children}\n </LayoutContext.Provider>\n );\n};\n\nexport const useLayoutContext = (): LayoutValues | null => {\n return useContext(LayoutContext);\n};\n"],"names":["createContext","useMemo","DEFAULT_BREAKPOINTS","useContext"],"mappings":";;;;;AAOA,MAAM,gBAAgBA,MAAAA,cAAmC,IAAI;AAStD,MAAM,gBAAgB,CAAC;AAAA,EAC5B,aAAa;AAAA,EACb;AACF,MAAuC;AACrC,QAAM,cAAcC,MAAAA;AAAAA,IAClB,OAAO;AAAA,MACL,GAAGC,MAAAA;AAAAA,MACH,GAAG;AAAA,IAAA;AAAA,IAEL,CAAC,iBAAiB;AAAA,EAAA;AAGpB,QAAM,eAAeD,MAAAA;AAAAA,IACnB,OAAO;AAAA,MACL;AAAA,IAAA;AAAA,IAEF,CAAC,WAAW;AAAA,EAAA;AAGd,wCACG,cAAc,UAAd,EAAuB,OAAO,cAC5B,UACH;AAEJ;AAEO,MAAM,mBAAmB,MAA2B;AACzD,SAAOE,MAAAA,WAAW,aAAa;AACjC;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutValues.cjs","sources":["../../../../src/beta/LayoutWrapper/useLayoutValues.ts"],"sourcesContent":["import { DEFAULT_BREAKPOINTS } from './utils';\nimport {
|
|
1
|
+
{"version":3,"file":"useLayoutValues.cjs","sources":["../../../../src/beta/LayoutWrapper/useLayoutValues.ts"],"sourcesContent":["import { DEFAULT_BREAKPOINTS } from './utils';\nimport { type LayoutValues, useLayoutContext } from './LayoutWrapper';\n\nexport const useLayoutValues = (): LayoutValues => {\n const context = useLayoutContext();\n\n if (context) {\n return context;\n }\n\n return {\n breakpoints: DEFAULT_BREAKPOINTS,\n };\n};\n"],"names":["useLayoutContext","DEFAULT_BREAKPOINTS"],"mappings":";;;;AAGO,MAAM,kBAAkB,MAAoB;AACjD,QAAM,UAAUA,cAAAA,iBAAA;AAEhB,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,aAAaC,MAAAA;AAAAA,EAAA;AAEjB;;"}
|
package/dist/beta/cjs/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ const FlexSpacer = require("./Flex/FlexSpacer.cjs");
|
|
|
8
8
|
const GridItem = require("./Grid/GridItem.cjs");
|
|
9
9
|
const LayoutWrapper = require("./LayoutWrapper/LayoutWrapper.cjs");
|
|
10
10
|
const useLayoutValues = require("./LayoutWrapper/useLayoutValues.cjs");
|
|
11
|
-
const SidebarContext = require("./templates/SidebarContext.cjs");
|
|
12
11
|
exports.Grid = index$1.Grid;
|
|
13
12
|
exports.Flex = index.Flex;
|
|
14
13
|
exports.Template = index$2.Template;
|
|
@@ -16,5 +15,4 @@ exports.FlexSpacer = FlexSpacer.FlexSpacer;
|
|
|
16
15
|
exports.GridItem = GridItem.GridItem;
|
|
17
16
|
exports.LayoutWrapper = LayoutWrapper.LayoutWrapper;
|
|
18
17
|
exports.useLayoutValues = useLayoutValues.useLayoutValues;
|
|
19
|
-
exports.useSidebarCollapsed = SidebarContext.useSidebarCollapsed;
|
|
20
18
|
//# 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,13 +2,10 @@
|
|
|
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");
|
|
6
5
|
const classNames = require("classnames");
|
|
7
6
|
const icons = require("@entur/icons");
|
|
8
|
-
const Contrast = require("../Contrast.cjs");
|
|
9
7
|
const index$1 = require("../Flex/index.cjs");
|
|
10
8
|
const index = require("../Grid/index.cjs");
|
|
11
|
-
const SidebarContext = require("./SidebarContext.cjs");
|
|
12
9
|
;/* empty css */
|
|
13
10
|
const defaultSidebarElement = "aside";
|
|
14
11
|
const defaultSectionElement = "div";
|
|
@@ -28,8 +25,17 @@ const SidebarUser = React.forwardRef(
|
|
|
28
25
|
);
|
|
29
26
|
const SidebarData = React.forwardRef(
|
|
30
27
|
({ children, as, ...rest }, ref) => {
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
29
|
+
index$1.Flex,
|
|
30
|
+
{
|
|
31
|
+
ref,
|
|
32
|
+
as: as || defaultSectionElement,
|
|
33
|
+
direction: "column",
|
|
34
|
+
gap: "s",
|
|
35
|
+
...rest,
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
33
39
|
}
|
|
34
40
|
);
|
|
35
41
|
const SidebarNavigation = React.forwardRef(
|
|
@@ -80,7 +86,6 @@ const SidebarRoot = React.forwardRef(
|
|
|
80
86
|
className,
|
|
81
87
|
style,
|
|
82
88
|
contrast = true,
|
|
83
|
-
collapsible = false,
|
|
84
89
|
collapsed,
|
|
85
90
|
onCollapseToggle,
|
|
86
91
|
openSidebarAriaLabel = "Åpne sidemeny",
|
|
@@ -88,18 +93,8 @@ const SidebarRoot = React.forwardRef(
|
|
|
88
93
|
as,
|
|
89
94
|
...rest
|
|
90
95
|
}, ref) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
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
|
-
});
|
|
102
|
-
const WrapperElement = contrast ? Contrast.Contrast : "div";
|
|
96
|
+
const collapsible = collapsed !== void 0;
|
|
97
|
+
const isCollapsed = collapsed ?? false;
|
|
103
98
|
const sidebarClassNames = classNames(
|
|
104
99
|
"eds-layout-template-sidebar",
|
|
105
100
|
{
|
|
@@ -109,8 +104,15 @@ const SidebarRoot = React.forwardRef(
|
|
|
109
104
|
},
|
|
110
105
|
className
|
|
111
106
|
);
|
|
107
|
+
const wrapperClassNames = classNames(
|
|
108
|
+
"eds-layout-template-sidebar-wrapper",
|
|
109
|
+
{
|
|
110
|
+
"eds-contrast": contrast,
|
|
111
|
+
"eds-layout-template-sidebar-wrapper--collapsible": collapsible
|
|
112
|
+
}
|
|
113
|
+
);
|
|
112
114
|
if (!collapsible) {
|
|
113
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Grid.Item, {
|
|
115
|
+
return /* @__PURE__ */ jsxRuntime.jsx(index.Grid.Item, { className: wrapperClassNames, colSpan: "1 / 2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
114
116
|
index$1.Flex,
|
|
115
117
|
{
|
|
116
118
|
ref,
|
|
@@ -125,38 +127,30 @@ const SidebarRoot = React.forwardRef(
|
|
|
125
127
|
) });
|
|
126
128
|
}
|
|
127
129
|
const collapsedStyle = isCollapsed ? { ...style, "--eds-sidebar-width": "2rem" } : style;
|
|
128
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
onToggle: () => setIsCollapsed(!isCollapsed),
|
|
153
|
-
openLabel: openSidebarAriaLabel,
|
|
154
|
-
closeLabel: closeSidebarAriaLabel
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
] })
|
|
158
|
-
}
|
|
159
|
-
);
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(index.Grid.Item, { className: wrapperClassNames, colSpan: "1 / 2", children: [
|
|
131
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
132
|
+
index$1.Flex,
|
|
133
|
+
{
|
|
134
|
+
ref,
|
|
135
|
+
as: as || defaultSidebarElement,
|
|
136
|
+
direction: "column",
|
|
137
|
+
gap: "m",
|
|
138
|
+
className: sidebarClassNames,
|
|
139
|
+
style: collapsedStyle,
|
|
140
|
+
...rest,
|
|
141
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "eds-layout-template-sidebar__content", children })
|
|
142
|
+
}
|
|
143
|
+
),
|
|
144
|
+
onCollapseToggle && /* @__PURE__ */ jsxRuntime.jsx(
|
|
145
|
+
CollapseToggle,
|
|
146
|
+
{
|
|
147
|
+
isCollapsed,
|
|
148
|
+
onToggle: () => onCollapseToggle(!isCollapsed),
|
|
149
|
+
openLabel: openSidebarAriaLabel,
|
|
150
|
+
closeLabel: closeSidebarAriaLabel
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] });
|
|
160
154
|
}
|
|
161
155
|
);
|
|
162
156
|
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 { 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","LeftAr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A,UACV,KAAI;AAAA,UACJ,WAAW;AAAA,UACX;AAAA,UACC,GAAG;AAAA,UAEH;AAAA,QAAA;AAAA,MAAA,GAEL;AAAA,IAEJ;AAEA,UAAM,iBAAiB,cAClB,EAAE,GAAG,OAAO,uBAAuB,WACpC;AAEJ,WACEN,2BAAAA;AAAAA,MAACK,MAAAA,KAAK;AAAA,MAAL;AAAA,QACC,IAAI;AAAA,QACJ,SAAQ;AAAA,QACR,WAAU;AAAA,QAEV,0CAACE,eAAAA,eAAe,UAAf,EAAwB,OAAO,EAAE,eAChC,UAAA;AAAA,UAAAP,2BAAAA;AAAAA,YAACM,QAAAA;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,UAAAN,2BAAAA,IAAC,OAAA,EAAI,WAAU,wCACZ,SAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,UAEFA,2BAAAA;AAAAA,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;;"}
|
|
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 { LeftArrowIcon, RightArrowIcon } from '@entur/icons';\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 /** Controlled collapsed state. When provided, the sidebar becomes\n * collapsible and a toggle button is rendered. */\n collapsed?: boolean;\n /** Callback when the collapse toggle is clicked */\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 return (\n <Flex\n ref={ref}\n as={as || defaultSectionElement}\n direction=\"column\"\n gap=\"s\"\n {...rest}\n >\n {children}\n </Flex>\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 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 collapsible = collapsed !== undefined;\n const isCollapsed = collapsed ?? false;\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 const wrapperClassNames = classNames(\n 'eds-layout-template-sidebar-wrapper',\n {\n 'eds-contrast': contrast,\n 'eds-layout-template-sidebar-wrapper--collapsible': collapsible,\n },\n );\n\n if (!collapsible) {\n return (\n <Grid.Item className={wrapperClassNames} 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 className={wrapperClassNames} colSpan=\"1 / 2\">\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\">{children}</div>\n </Flex>\n {onCollapseToggle && (\n <CollapseToggle\n isCollapsed={isCollapsed}\n onToggle={() => onCollapseToggle(!isCollapsed)}\n openLabel={openSidebarAriaLabel}\n closeLabel={closeSidebarAriaLabel}\n />\n )}\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","Flex","RightArrowIcon","LeftArrowIcon","Grid"],"mappings":";;;;;;;;;AAmCA,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,WACEA,2BAAAA;AAAAA,MAACC,QAAAA;AAAAA,MAAA;AAAA,QACC;AAAA,QACA,IAAI,MAAM;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QACH,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEA,MAAM,oBAAoB,MAAM;AAAA,EAC9B,CACE,EAAE,UAAU,WAAW,IAAI,GAAG,KAAA,GAC9B,QACG;AACH,UAAM,UAA6B,MAAM;AACzC,WACED,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QA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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
|
|
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 +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
|
|
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 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,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;;"}
|
|
@@ -24,12 +24,12 @@ const Grid = React.forwardRef(
|
|
|
24
24
|
...rest
|
|
25
25
|
}, ref) => {
|
|
26
26
|
const Element = as || defaultElement;
|
|
27
|
-
const resolvedTemplateColumns = useResponsiveValue(templateColumns)
|
|
27
|
+
const resolvedTemplateColumns = useResponsiveValue(templateColumns);
|
|
28
28
|
const resolvedTemplateRows = useResponsiveValue(templateRows);
|
|
29
29
|
const resolvedGap = useResponsiveValue(gap);
|
|
30
30
|
const resolvedRowGap = useResponsiveValue(rowGap);
|
|
31
31
|
const resolvedColumnGap = useResponsiveValue(columnGap);
|
|
32
|
-
const resolvedAutoFlow = useResponsiveValue(autoFlow)
|
|
32
|
+
const resolvedAutoFlow = useResponsiveValue(autoFlow);
|
|
33
33
|
const resolvedAlign = useResponsiveValue(align);
|
|
34
34
|
const resolvedJustify = useResponsiveValue(justify);
|
|
35
35
|
const resolvedAlignContent = useResponsiveValue(alignContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.mjs","sources":["../../../../src/beta/Grid/Grid.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport classNames from 'classnames';\n\nimport './Grid.scss';\n\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\n\nexport type GridOwnProps = {\n /** CSS grid-template-columns value (supports responsive objects)\n * @default \"repeat(12, 1fr)\"\n */\n templateColumns?: string | ResponsiveValue<string>;\n /** Spacing between grid items (supports responsive objects)\n * @default \"m\"\n */\n gap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Vertical spacing between grid rows (supports responsive objects) */\n rowGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Horizontal spacing between grid columns (supports responsive objects) */\n columnGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** CSS grid-template-rows value (supports responsive objects) */\n templateRows?: string | ResponsiveValue<string>;\n /** CSS grid-auto-flow value (supports responsive objects)\n * @default \"row\"\n */\n autoFlow?:\n | 'row'\n | 'column'\n | 'dense'\n | 'row dense'\n | 'column dense'\n | ResponsiveValue<\n 'row' | 'column' | 'dense' | 'row dense' | 'column dense'\n >;\n /** CSS align-items value (supports responsive objects) */\n align?: AlignItems | ResponsiveValue<AlignItems>;\n /** CSS justify-content value (supports responsive objects) */\n justify?: JustifyContent | ResponsiveValue<JustifyContent>;\n /** CSS align-content value (supports responsive objects) */\n alignContent?: AlignContent | ResponsiveValue<AlignContent>;\n /** The height of the grid container */\n height?: string;\n /** HTML element or React component used to render the Grid\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid container */\n children?: React.ReactNode;\n};\n\nexport type GridProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Grid = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n templateColumns,\n templateRows,\n gap = 'm',\n rowGap,\n columnGap,\n autoFlow = 'row',\n align,\n justify,\n alignContent,\n height,\n as,\n className,\n children,\n style,\n ...rest\n }: GridProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedTemplateColumns
|
|
1
|
+
{"version":3,"file":"Grid.mjs","sources":["../../../../src/beta/Grid/Grid.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport classNames from 'classnames';\n\nimport './Grid.scss';\n\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\n\nexport type GridOwnProps = {\n /** CSS grid-template-columns value (supports responsive objects)\n * @default \"repeat(12, 1fr)\"\n */\n templateColumns?: string | ResponsiveValue<string>;\n /** Spacing between grid items (supports responsive objects)\n * @default \"m\"\n */\n gap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Vertical spacing between grid rows (supports responsive objects) */\n rowGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** Horizontal spacing between grid columns (supports responsive objects) */\n columnGap?: GridSpacingValue | ResponsiveValue<GridSpacingValue>;\n /** CSS grid-template-rows value (supports responsive objects) */\n templateRows?: string | ResponsiveValue<string>;\n /** CSS grid-auto-flow value (supports responsive objects)\n * @default \"row\"\n */\n autoFlow?:\n | 'row'\n | 'column'\n | 'dense'\n | 'row dense'\n | 'column dense'\n | ResponsiveValue<\n 'row' | 'column' | 'dense' | 'row dense' | 'column dense'\n >;\n /** CSS align-items value (supports responsive objects) */\n align?: AlignItems | ResponsiveValue<AlignItems>;\n /** CSS justify-content value (supports responsive objects) */\n justify?: JustifyContent | ResponsiveValue<JustifyContent>;\n /** CSS align-content value (supports responsive objects) */\n alignContent?: AlignContent | ResponsiveValue<AlignContent>;\n /** The height of the grid container */\n height?: string;\n /** HTML element or React component used to render the Grid\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid container */\n children?: React.ReactNode;\n};\n\nexport type GridProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Grid = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n templateColumns,\n templateRows,\n gap = 'm',\n rowGap,\n columnGap,\n autoFlow = 'row',\n align,\n justify,\n alignContent,\n height,\n as,\n className,\n children,\n style,\n ...rest\n }: GridProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedTemplateColumns = useResponsiveValue(templateColumns);\n const resolvedTemplateRows = useResponsiveValue(templateRows);\n const resolvedGap = useResponsiveValue(gap);\n const resolvedRowGap = useResponsiveValue(rowGap);\n const resolvedColumnGap = useResponsiveValue(columnGap);\n const resolvedAutoFlow = useResponsiveValue(autoFlow);\n const resolvedAlign = useResponsiveValue(align);\n const resolvedJustify = useResponsiveValue(justify);\n const resolvedAlignContent = useResponsiveValue(alignContent);\n\n const gridStyle: React.CSSProperties = {\n ...(resolvedTemplateColumns && {\n '--grid-template-columns': resolvedTemplateColumns,\n }),\n ...(resolvedTemplateRows && {\n '--grid-template-rows': resolvedTemplateRows,\n }),\n ...(resolvedAutoFlow && {\n '--grid-auto-flow': resolvedAutoFlow,\n }),\n ...(resolvedAlign && {\n '--grid-align-items': resolvedAlign,\n }),\n ...(resolvedJustify && {\n '--grid-justify-content': resolvedJustify,\n }),\n ...(resolvedAlignContent && {\n '--grid-align-content': resolvedAlignContent,\n }),\n ...(resolvedGap && {\n '--grid-gap': getSpacingValue(resolvedGap),\n }),\n ...(resolvedRowGap && {\n '--grid-row-gap': getSpacingValue(resolvedRowGap),\n }),\n ...(resolvedColumnGap && {\n '--grid-column-gap': getSpacingValue(resolvedColumnGap),\n }),\n ...(height && {\n '--grid-height': height,\n }),\n ...style,\n } as React.CSSProperties;\n\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-grid', className)}\n style={gridStyle}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;AA6DA,MAAM,iBAAiB;AAEhB,MAAM,OAAO,MAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACgB;AAChB,UAAM,UAA6B,MAAM;AAEzC,UAAM,0BAA0B,mBAAmB,eAAe;AAClE,UAAM,uBAAuB,mBAAmB,YAAY;AAC5D,UAAM,cAAc,mBAAmB,GAAG;AAC1C,UAAM,iBAAiB,mBAAmB,MAAM;AAChD,UAAM,oBAAoB,mBAAmB,SAAS;AACtD,UAAM,mBAAmB,mBAAmB,QAAQ;AACpD,UAAM,gBAAgB,mBAAmB,KAAK;AAC9C,UAAM,kBAAkB,mBAAmB,OAAO;AAClD,UAAM,uBAAuB,mBAAmB,YAAY;AAE5D,UAAM,YAAiC;AAAA,MACrC,GAAI,2BAA2B;AAAA,QAC7B,2BAA2B;AAAA,MAAA;AAAA,MAE7B,GAAI,wBAAwB;AAAA,QAC1B,wBAAwB;AAAA,MAAA;AAAA,MAE1B,GAAI,oBAAoB;AAAA,QACtB,oBAAoB;AAAA,MAAA;AAAA,MAEtB,GAAI,iBAAiB;AAAA,QACnB,sBAAsB;AAAA,MAAA;AAAA,MAExB,GAAI,mBAAmB;AAAA,QACrB,0BAA0B;AAAA,MAAA;AAAA,MAE5B,GAAI,wBAAwB;AAAA,QAC1B,wBAAwB;AAAA,MAAA;AAAA,MAE1B,GAAI,eAAe;AAAA,QACjB,cAAc,gBAAgB,WAAW;AAAA,MAAA;AAAA,MAE3C,GAAI,kBAAkB;AAAA,QACpB,kBAAkB,gBAAgB,cAAc;AAAA,MAAA;AAAA,MAElD,GAAI,qBAAqB;AAAA,QACvB,qBAAqB,gBAAgB,iBAAiB;AAAA,MAAA;AAAA,MAExD,GAAI,UAAU;AAAA,QACZ,iBAAiB;AAAA,MAAA;AAAA,MAEnB,GAAG;AAAA,IAAA;AAGL,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW,WAAW,mBAAmB,SAAS;AAAA,QAClD,OAAO;AAAA,QACN,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutWrapper.mjs","sources":["../../../../src/beta/LayoutWrapper/LayoutWrapper.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"LayoutWrapper.mjs","sources":["../../../../src/beta/LayoutWrapper/LayoutWrapper.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react';\nimport { type Breakpoints, DEFAULT_BREAKPOINTS } from './utils';\n\nexport type LayoutValues = {\n breakpoints: Breakpoints;\n};\n\nconst LayoutContext = createContext<LayoutValues | null>(null);\n\nexport type LayoutWrapperProps = {\n /** Custom breakpoint values to override defaults */\n breakpoints?: Partial<Breakpoints>;\n /** Children components that can use layout values */\n children: React.ReactNode;\n};\n\nexport const LayoutWrapper = ({\n breakpoints: customBreakpoints,\n children,\n}: LayoutWrapperProps): JSX.Element => {\n const breakpoints = useMemo<Breakpoints>(\n () => ({\n ...DEFAULT_BREAKPOINTS,\n ...customBreakpoints,\n }),\n [customBreakpoints],\n );\n\n const layoutValues = useMemo<LayoutValues>(\n () => ({\n breakpoints,\n }),\n [breakpoints],\n );\n\n return (\n <LayoutContext.Provider value={layoutValues}>\n {children}\n </LayoutContext.Provider>\n );\n};\n\nexport const useLayoutContext = (): LayoutValues | null => {\n return useContext(LayoutContext);\n};\n"],"names":[],"mappings":";;;AAOA,MAAM,gBAAgB,cAAmC,IAAI;AAStD,MAAM,gBAAgB,CAAC;AAAA,EAC5B,aAAa;AAAA,EACb;AACF,MAAuC;AACrC,QAAM,cAAc;AAAA,IAClB,OAAO;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,IAAA;AAAA,IAEL,CAAC,iBAAiB;AAAA,EAAA;AAGpB,QAAM,eAAe;AAAA,IACnB,OAAO;AAAA,MACL;AAAA,IAAA;AAAA,IAEF,CAAC,WAAW;AAAA,EAAA;AAGd,6BACG,cAAc,UAAd,EAAuB,OAAO,cAC5B,UACH;AAEJ;AAEO,MAAM,mBAAmB,MAA2B;AACzD,SAAO,WAAW,aAAa;AACjC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutValues.mjs","sources":["../../../../src/beta/LayoutWrapper/useLayoutValues.ts"],"sourcesContent":["import { DEFAULT_BREAKPOINTS } from './utils';\nimport {
|
|
1
|
+
{"version":3,"file":"useLayoutValues.mjs","sources":["../../../../src/beta/LayoutWrapper/useLayoutValues.ts"],"sourcesContent":["import { DEFAULT_BREAKPOINTS } from './utils';\nimport { type LayoutValues, useLayoutContext } from './LayoutWrapper';\n\nexport const useLayoutValues = (): LayoutValues => {\n const context = useLayoutContext();\n\n if (context) {\n return context;\n }\n\n return {\n breakpoints: DEFAULT_BREAKPOINTS,\n };\n};\n"],"names":[],"mappings":";;AAGO,MAAM,kBAAkB,MAAoB;AACjD,QAAM,UAAU,iBAAA;AAEhB,MAAI,SAAS;AACX,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,aAAa;AAAA,EAAA;AAEjB;"}
|
package/dist/beta/esm/index.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { FlexSpacer } from "./Flex/FlexSpacer.mjs";
|
|
|
6
6
|
import { GridItem } from "./Grid/GridItem.mjs";
|
|
7
7
|
import { LayoutWrapper } from "./LayoutWrapper/LayoutWrapper.mjs";
|
|
8
8
|
import { useLayoutValues } from "./LayoutWrapper/useLayoutValues.mjs";
|
|
9
|
-
import { useSidebarCollapsed } from "./templates/SidebarContext.mjs";
|
|
10
9
|
export {
|
|
11
10
|
Flex,
|
|
12
11
|
FlexSpacer,
|
|
@@ -14,7 +13,6 @@ export {
|
|
|
14
13
|
GridItem,
|
|
15
14
|
LayoutWrapper,
|
|
16
15
|
Template,
|
|
17
|
-
useLayoutValues
|
|
18
|
-
useSidebarCollapsed
|
|
16
|
+
useLayoutValues
|
|
19
17
|
};
|
|
20
18
|
//# 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,12 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { useControllableProp } from "@entur/utils";
|
|
4
3
|
import classNames from "classnames";
|
|
5
4
|
import { RightArrowIcon, LeftArrowIcon } from "@entur/icons";
|
|
6
|
-
import { Contrast } from "../Contrast.mjs";
|
|
7
5
|
import { Flex as FlexComponent } from "../Flex/index.mjs";
|
|
8
6
|
import { Grid as GridComponent } from "../Grid/index.mjs";
|
|
9
|
-
import { SidebarContext } from "./SidebarContext.mjs";
|
|
10
7
|
/* empty css */
|
|
11
8
|
const defaultSidebarElement = "aside";
|
|
12
9
|
const defaultSectionElement = "div";
|
|
@@ -26,8 +23,17 @@ const SidebarUser = React.forwardRef(
|
|
|
26
23
|
);
|
|
27
24
|
const SidebarData = React.forwardRef(
|
|
28
25
|
({ children, as, ...rest }, ref) => {
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
FlexComponent,
|
|
28
|
+
{
|
|
29
|
+
ref,
|
|
30
|
+
as: as || defaultSectionElement,
|
|
31
|
+
direction: "column",
|
|
32
|
+
gap: "s",
|
|
33
|
+
...rest,
|
|
34
|
+
children
|
|
35
|
+
}
|
|
36
|
+
);
|
|
31
37
|
}
|
|
32
38
|
);
|
|
33
39
|
const SidebarNavigation = React.forwardRef(
|
|
@@ -78,7 +84,6 @@ const SidebarRoot = React.forwardRef(
|
|
|
78
84
|
className,
|
|
79
85
|
style,
|
|
80
86
|
contrast = true,
|
|
81
|
-
collapsible = false,
|
|
82
87
|
collapsed,
|
|
83
88
|
onCollapseToggle,
|
|
84
89
|
openSidebarAriaLabel = "Åpne sidemeny",
|
|
@@ -86,18 +91,8 @@ const SidebarRoot = React.forwardRef(
|
|
|
86
91
|
as,
|
|
87
92
|
...rest
|
|
88
93
|
}, ref) => {
|
|
89
|
-
const
|
|
90
|
-
|
|
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
|
-
});
|
|
100
|
-
const WrapperElement = contrast ? Contrast : "div";
|
|
94
|
+
const collapsible = collapsed !== void 0;
|
|
95
|
+
const isCollapsed = collapsed ?? false;
|
|
101
96
|
const sidebarClassNames = classNames(
|
|
102
97
|
"eds-layout-template-sidebar",
|
|
103
98
|
{
|
|
@@ -107,8 +102,15 @@ const SidebarRoot = React.forwardRef(
|
|
|
107
102
|
},
|
|
108
103
|
className
|
|
109
104
|
);
|
|
105
|
+
const wrapperClassNames = classNames(
|
|
106
|
+
"eds-layout-template-sidebar-wrapper",
|
|
107
|
+
{
|
|
108
|
+
"eds-contrast": contrast,
|
|
109
|
+
"eds-layout-template-sidebar-wrapper--collapsible": collapsible
|
|
110
|
+
}
|
|
111
|
+
);
|
|
110
112
|
if (!collapsible) {
|
|
111
|
-
return /* @__PURE__ */ jsx(GridComponent.Item, {
|
|
113
|
+
return /* @__PURE__ */ jsx(GridComponent.Item, { className: wrapperClassNames, colSpan: "1 / 2", children: /* @__PURE__ */ jsx(
|
|
112
114
|
FlexComponent,
|
|
113
115
|
{
|
|
114
116
|
ref,
|
|
@@ -123,38 +125,30 @@ const SidebarRoot = React.forwardRef(
|
|
|
123
125
|
) });
|
|
124
126
|
}
|
|
125
127
|
const collapsedStyle = isCollapsed ? { ...style, "--eds-sidebar-width": "2rem" } : style;
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
onToggle: () => setIsCollapsed(!isCollapsed),
|
|
151
|
-
openLabel: openSidebarAriaLabel,
|
|
152
|
-
closeLabel: closeSidebarAriaLabel
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
] })
|
|
156
|
-
}
|
|
157
|
-
);
|
|
128
|
+
return /* @__PURE__ */ jsxs(GridComponent.Item, { className: wrapperClassNames, colSpan: "1 / 2", children: [
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
FlexComponent,
|
|
131
|
+
{
|
|
132
|
+
ref,
|
|
133
|
+
as: as || defaultSidebarElement,
|
|
134
|
+
direction: "column",
|
|
135
|
+
gap: "m",
|
|
136
|
+
className: sidebarClassNames,
|
|
137
|
+
style: collapsedStyle,
|
|
138
|
+
...rest,
|
|
139
|
+
children: /* @__PURE__ */ jsx("div", { className: "eds-layout-template-sidebar__content", children })
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
onCollapseToggle && /* @__PURE__ */ jsx(
|
|
143
|
+
CollapseToggle,
|
|
144
|
+
{
|
|
145
|
+
isCollapsed,
|
|
146
|
+
onToggle: () => onCollapseToggle(!isCollapsed),
|
|
147
|
+
openLabel: openSidebarAriaLabel,
|
|
148
|
+
closeLabel: closeSidebarAriaLabel
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] });
|
|
158
152
|
}
|
|
159
153
|
);
|
|
160
154
|
const Sidebar = Object.assign(SidebarRoot, {
|