@entur/layout 3.4.1 → 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.
- package/dist/beta/cjs/Flex/Flex.cjs +105 -101
- package/dist/beta/cjs/Flex/Flex.cjs.map +1 -1
- package/dist/beta/cjs/Grid/Grid.cjs +74 -70
- package/dist/beta/cjs/Grid/Grid.cjs.map +1 -1
- package/dist/beta/cjs/Grid/GridItem.cjs +35 -31
- package/dist/beta/cjs/Grid/GridItem.cjs.map +1 -1
- package/dist/beta/cjs/index.cjs +8 -6
- package/dist/beta/cjs/index.cjs.map +1 -1
- package/dist/beta/cjs/templates/Sidebar.cjs +151 -65
- package/dist/beta/cjs/templates/Sidebar.cjs.map +1 -1
- package/dist/beta/cjs/templates/SidebarContext.cjs +10 -0
- package/dist/beta/cjs/templates/SidebarContext.cjs.map +1 -0
- package/dist/beta/cjs/templates/index.cjs.map +1 -1
- package/dist/beta/cjs/templates/portal/Portal.cjs +56 -36
- package/dist/beta/cjs/templates/portal/Portal.cjs.map +1 -1
- package/dist/beta/esm/Flex/Flex.mjs +105 -101
- package/dist/beta/esm/Flex/Flex.mjs.map +1 -1
- package/dist/beta/esm/Grid/Grid.mjs +74 -70
- package/dist/beta/esm/Grid/Grid.mjs.map +1 -1
- package/dist/beta/esm/Grid/GridItem.mjs +35 -31
- package/dist/beta/esm/Grid/GridItem.mjs.map +1 -1
- package/dist/beta/esm/index.mjs +8 -6
- package/dist/beta/esm/index.mjs.map +1 -1
- package/dist/beta/esm/templates/Sidebar.mjs +154 -68
- package/dist/beta/esm/templates/Sidebar.mjs.map +1 -1
- package/dist/beta/esm/templates/SidebarContext.mjs +10 -0
- package/dist/beta/esm/templates/SidebarContext.mjs.map +1 -0
- package/dist/beta/esm/templates/index.mjs.map +1 -1
- package/dist/beta/esm/templates/portal/Portal.mjs +57 -37
- package/dist/beta/esm/templates/portal/Portal.mjs.map +1 -1
- package/dist/beta/styles/index.css +152 -19
- package/dist/beta/types/Flex/Flex.d.ts +3 -1
- package/dist/beta/types/Grid/Grid.d.ts +3 -1
- package/dist/beta/types/Grid/GridItem.d.ts +3 -1
- package/dist/beta/types/index.d.ts +2 -2
- package/dist/beta/types/templates/Sidebar.d.ts +46 -8
- package/dist/beta/types/templates/SidebarContext.d.ts +9 -0
- package/dist/beta/types/templates/index.d.ts +3 -2
- package/dist/beta/types/templates/portal/Portal.d.ts +32 -4
- package/dist/beta/types/templates/portal/index.d.ts +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flex.mjs","sources":["../../../../src/beta/Flex/Flex.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\n\nimport './Flex.scss';\n\nexport type FlexSpacingValue = GridSpacingValue;\n\ntype FlexDirection = React.CSSProperties['flexDirection'];\ntype FlexWrap = React.CSSProperties['flexWrap'];\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\ntype FlexBasis = React.CSSProperties['flexBasis'];\ntype FlexValue = React.CSSProperties['flex'];\n\nexport type FlexOwnProps = {\n /** CSS flex-direction value (supports responsive objects)\n * @default \"row\"\n */\n direction?: FlexDirection | ResponsiveValue<FlexDirection>;\n /** CSS flex-wrap value (supports responsive objects)\n * @default \"nowrap\"\n */\n wrap?: FlexWrap | ResponsiveValue<FlexWrap>;\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 /** Spacing between flex items (supports responsive objects) */\n gap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** Vertical spacing between rows (supports responsive objects) */\n rowGap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** Horizontal spacing between columns (supports responsive objects) */\n columnGap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** CSS flex shorthand value */\n flex?: FlexValue;\n /** CSS flex-grow value */\n grow?: number;\n /** CSS flex-shrink value */\n shrink?: number;\n /** CSS flex-basis value */\n basis?: FlexBasis;\n /** CSS width value */\n width?: string;\n /** CSS height value */\n height?: string;\n /** CSS min-width value */\n minWidth?: string;\n /** CSS min-height value */\n minHeight?: string;\n /** CSS max-width value */\n maxWidth?: string;\n /** CSS max-height value */\n maxHeight?: string;\n /** HTML element or React component used to render the Flex container\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Flex container */\n children?: React.ReactNode;\n};\n\nexport type FlexProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, FlexOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Flex = <E extends React.ElementType = typeof defaultElement>({\n
|
|
1
|
+
{"version":3,"file":"Flex.mjs","sources":["../../../../src/beta/Flex/Flex.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport classNames from 'classnames';\nimport { getSpacingValue } from '../LayoutWrapper/utils';\nimport type { GridSpacingValue, ResponsiveValue } from '../LayoutWrapper/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\n\nimport './Flex.scss';\n\nexport type FlexSpacingValue = GridSpacingValue;\n\ntype FlexDirection = React.CSSProperties['flexDirection'];\ntype FlexWrap = React.CSSProperties['flexWrap'];\ntype AlignItems = React.CSSProperties['alignItems'];\ntype JustifyContent = React.CSSProperties['justifyContent'];\ntype AlignContent = React.CSSProperties['alignContent'];\ntype FlexBasis = React.CSSProperties['flexBasis'];\ntype FlexValue = React.CSSProperties['flex'];\n\nexport type FlexOwnProps = {\n /** CSS flex-direction value (supports responsive objects)\n * @default \"row\"\n */\n direction?: FlexDirection | ResponsiveValue<FlexDirection>;\n /** CSS flex-wrap value (supports responsive objects)\n * @default \"nowrap\"\n */\n wrap?: FlexWrap | ResponsiveValue<FlexWrap>;\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 /** Spacing between flex items (supports responsive objects) */\n gap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** Vertical spacing between rows (supports responsive objects) */\n rowGap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** Horizontal spacing between columns (supports responsive objects) */\n columnGap?: FlexSpacingValue | ResponsiveValue<FlexSpacingValue>;\n /** CSS flex shorthand value */\n flex?: FlexValue;\n /** CSS flex-grow value */\n grow?: number;\n /** CSS flex-shrink value */\n shrink?: number;\n /** CSS flex-basis value */\n basis?: FlexBasis;\n /** CSS width value */\n width?: string;\n /** CSS height value */\n height?: string;\n /** CSS min-width value */\n minWidth?: string;\n /** CSS min-height value */\n minHeight?: string;\n /** CSS max-width value */\n maxWidth?: string;\n /** CSS max-height value */\n maxHeight?: string;\n /** HTML element or React component used to render the Flex container\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Flex container */\n children?: React.ReactNode;\n};\n\nexport type FlexProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, FlexOwnProps>;\n\nconst defaultElement = 'div';\n\nexport const Flex = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n direction,\n wrap,\n align,\n justify,\n alignContent,\n gap,\n rowGap,\n columnGap,\n flex,\n grow,\n shrink,\n basis,\n width,\n height,\n minWidth,\n minHeight,\n maxWidth,\n maxHeight,\n as,\n className,\n children,\n style,\n ...rest\n }: FlexProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedDirection = useResponsiveValue(direction);\n const resolvedWrap = useResponsiveValue(wrap);\n const resolvedAlign = useResponsiveValue(align);\n const resolvedJustify = useResponsiveValue(justify);\n const resolvedAlignContent = useResponsiveValue(alignContent);\n const resolvedGap = useResponsiveValue(gap);\n const resolvedRowGap = useResponsiveValue(rowGap);\n const resolvedColumnGap = useResponsiveValue(columnGap);\n\n const flexStyle: React.CSSProperties = {\n ...(resolvedDirection && {\n '--flex-direction': resolvedDirection,\n }),\n ...(resolvedWrap && {\n '--flex-wrap': resolvedWrap,\n }),\n ...(resolvedAlign && {\n '--flex-align-items': resolvedAlign,\n }),\n ...(resolvedJustify && {\n '--flex-justify-content': resolvedJustify,\n }),\n ...(resolvedAlignContent && {\n '--flex-align-content': resolvedAlignContent,\n }),\n ...(resolvedGap && {\n '--flex-gap': getSpacingValue(resolvedGap, 'Flex'),\n }),\n ...(resolvedRowGap && {\n '--flex-row-gap': getSpacingValue(resolvedRowGap, 'Flex'),\n }),\n ...(resolvedColumnGap && {\n '--flex-column-gap': getSpacingValue(resolvedColumnGap, 'Flex'),\n }),\n ...(flex !== undefined && {\n '--flex': flex,\n }),\n ...(grow !== undefined && {\n '--flex-grow': grow,\n }),\n ...(shrink !== undefined && {\n '--flex-shrink': shrink,\n }),\n ...(basis !== undefined && {\n '--flex-basis': basis,\n }),\n ...(width && {\n '--flex-width': width,\n }),\n ...(height && {\n '--flex-height': height,\n }),\n ...(minWidth && {\n '--flex-min-width': minWidth,\n }),\n ...(minHeight && {\n '--flex-min-height': minHeight,\n }),\n ...(maxWidth && {\n '--flex-max-width': maxWidth,\n }),\n ...(maxHeight && {\n '--flex-max-height': maxHeight,\n }),\n ...style,\n } as React.CSSProperties;\n\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-flex', className)}\n style={flexStyle}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n"],"names":[],"mappings":";;;;;;AAyEA,MAAM,iBAAiB;AAEhB,MAAM,OAAO,MAAM;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;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,oBAAoB,mBAAmB,SAAS;AACtD,UAAM,eAAe,mBAAmB,IAAI;AAC5C,UAAM,gBAAgB,mBAAmB,KAAK;AAC9C,UAAM,kBAAkB,mBAAmB,OAAO;AAClD,UAAM,uBAAuB,mBAAmB,YAAY;AAC5D,UAAM,cAAc,mBAAmB,GAAG;AAC1C,UAAM,iBAAiB,mBAAmB,MAAM;AAChD,UAAM,oBAAoB,mBAAmB,SAAS;AAEtD,UAAM,YAAiC;AAAA,MACrC,GAAI,qBAAqB;AAAA,QACvB,oBAAoB;AAAA,MAAA;AAAA,MAEtB,GAAI,gBAAgB;AAAA,QAClB,eAAe;AAAA,MAAA;AAAA,MAEjB,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,aAAa,MAAM;AAAA,MAAA;AAAA,MAEnD,GAAI,kBAAkB;AAAA,QACpB,kBAAkB,gBAAgB,gBAAgB,MAAM;AAAA,MAAA;AAAA,MAE1D,GAAI,qBAAqB;AAAA,QACvB,qBAAqB,gBAAgB,mBAAmB,MAAM;AAAA,MAAA;AAAA,MAEhE,GAAI,SAAS,UAAa;AAAA,QACxB,UAAU;AAAA,MAAA;AAAA,MAEZ,GAAI,SAAS,UAAa;AAAA,QACxB,eAAe;AAAA,MAAA;AAAA,MAEjB,GAAI,WAAW,UAAa;AAAA,QAC1B,iBAAiB;AAAA,MAAA;AAAA,MAEnB,GAAI,UAAU,UAAa;AAAA,QACzB,gBAAgB;AAAA,MAAA;AAAA,MAElB,GAAI,SAAS;AAAA,QACX,gBAAgB;AAAA,MAAA;AAAA,MAElB,GAAI,UAAU;AAAA,QACZ,iBAAiB;AAAA,MAAA;AAAA,MAEnB,GAAI,YAAY;AAAA,QACd,oBAAoB;AAAA,MAAA;AAAA,MAEtB,GAAI,aAAa;AAAA,QACf,qBAAqB;AAAA,MAAA;AAAA,MAEvB,GAAI,YAAY;AAAA,QACd,oBAAoB;AAAA,MAAA;AAAA,MAEtB,GAAI,aAAa;AAAA,QACf,qBAAqB;AAAA,MAAA;AAAA,MAEvB,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,79 +1,83 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { getSpacingValue } from "../LayoutWrapper/utils.mjs";
|
|
3
4
|
import { useResponsiveValue } from "../LayoutWrapper/useResponsiveValue.mjs";
|
|
4
5
|
import classNames from "classnames";
|
|
5
6
|
/* empty css */
|
|
6
7
|
const defaultElement = "div";
|
|
7
|
-
const Grid = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
8
|
+
const Grid = React.forwardRef(
|
|
9
|
+
({
|
|
10
|
+
templateColumns,
|
|
11
|
+
templateRows,
|
|
12
|
+
gap = "m",
|
|
13
|
+
rowGap,
|
|
14
|
+
columnGap,
|
|
15
|
+
autoFlow = "row",
|
|
16
|
+
align,
|
|
17
|
+
justify,
|
|
18
|
+
alignContent,
|
|
19
|
+
height,
|
|
20
|
+
as,
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
style,
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const Element = as || defaultElement;
|
|
27
|
+
const resolvedTemplateColumns = useResponsiveValue(templateColumns) ?? "repeat(12, 1fr)";
|
|
28
|
+
const resolvedTemplateRows = useResponsiveValue(templateRows);
|
|
29
|
+
const resolvedGap = useResponsiveValue(gap);
|
|
30
|
+
const resolvedRowGap = useResponsiveValue(rowGap);
|
|
31
|
+
const resolvedColumnGap = useResponsiveValue(columnGap);
|
|
32
|
+
const resolvedAutoFlow = useResponsiveValue(autoFlow) ?? "row";
|
|
33
|
+
const resolvedAlign = useResponsiveValue(align);
|
|
34
|
+
const resolvedJustify = useResponsiveValue(justify);
|
|
35
|
+
const resolvedAlignContent = useResponsiveValue(alignContent);
|
|
36
|
+
const gridStyle = {
|
|
37
|
+
...resolvedTemplateColumns && {
|
|
38
|
+
"--grid-template-columns": resolvedTemplateColumns
|
|
39
|
+
},
|
|
40
|
+
...resolvedTemplateRows && {
|
|
41
|
+
"--grid-template-rows": resolvedTemplateRows
|
|
42
|
+
},
|
|
43
|
+
...resolvedAutoFlow && {
|
|
44
|
+
"--grid-auto-flow": resolvedAutoFlow
|
|
45
|
+
},
|
|
46
|
+
...resolvedAlign && {
|
|
47
|
+
"--grid-align-items": resolvedAlign
|
|
48
|
+
},
|
|
49
|
+
...resolvedJustify && {
|
|
50
|
+
"--grid-justify-content": resolvedJustify
|
|
51
|
+
},
|
|
52
|
+
...resolvedAlignContent && {
|
|
53
|
+
"--grid-align-content": resolvedAlignContent
|
|
54
|
+
},
|
|
55
|
+
...resolvedGap && {
|
|
56
|
+
"--grid-gap": getSpacingValue(resolvedGap)
|
|
57
|
+
},
|
|
58
|
+
...resolvedRowGap && {
|
|
59
|
+
"--grid-row-gap": getSpacingValue(resolvedRowGap)
|
|
60
|
+
},
|
|
61
|
+
...resolvedColumnGap && {
|
|
62
|
+
"--grid-column-gap": getSpacingValue(resolvedColumnGap)
|
|
63
|
+
},
|
|
64
|
+
...height && {
|
|
65
|
+
"--grid-height": height
|
|
66
|
+
},
|
|
67
|
+
...style
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
Element,
|
|
71
|
+
{
|
|
72
|
+
ref,
|
|
73
|
+
className: classNames("eds-layout-grid", className),
|
|
74
|
+
style: gridStyle,
|
|
75
|
+
...rest,
|
|
76
|
+
children
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
77
81
|
export {
|
|
78
82
|
Grid
|
|
79
83
|
};
|
|
@@ -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 = <E extends React.ElementType = typeof defaultElement>({\n
|
|
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 =\n useResponsiveValue(templateColumns) ?? 'repeat(12, 1fr)';\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) ?? 'row';\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,0BACJ,mBAAmB,eAAe,KAAK;AACzC,UAAM,uBAAuB,mBAAmB,YAAY;AAC5D,UAAM,cAAc,mBAAmB,GAAG;AAC1C,UAAM,iBAAiB,mBAAmB,MAAM;AAChD,UAAM,oBAAoB,mBAAmB,SAAS;AACtD,UAAM,mBAAmB,mBAAmB,QAAQ,KAAK;AACzD,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,4 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
2
3
|
import { useResponsiveValue } from "../LayoutWrapper/useResponsiveValue.mjs";
|
|
3
4
|
import classNames from "classnames";
|
|
4
5
|
/* empty css */
|
|
@@ -12,37 +13,40 @@ const formatGridSpan = (value) => {
|
|
|
12
13
|
}
|
|
13
14
|
return value;
|
|
14
15
|
};
|
|
15
|
-
const GridItem = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
16
|
+
const GridItem = React.forwardRef(
|
|
17
|
+
({
|
|
18
|
+
colSpan,
|
|
19
|
+
rowSpan = 1,
|
|
20
|
+
as,
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
style,
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const Element = as || defaultElement;
|
|
27
|
+
const resolvedColSpan = useResponsiveValue(colSpan);
|
|
28
|
+
const resolvedRowSpan = useResponsiveValue(rowSpan);
|
|
29
|
+
const itemStyle = {
|
|
30
|
+
...resolvedColSpan !== void 0 && {
|
|
31
|
+
"--grid-item-column": formatGridSpan(resolvedColSpan)
|
|
32
|
+
},
|
|
33
|
+
...resolvedRowSpan !== void 0 && {
|
|
34
|
+
"--grid-item-row": formatGridSpan(resolvedRowSpan)
|
|
35
|
+
},
|
|
36
|
+
...style
|
|
37
|
+
};
|
|
38
|
+
return /* @__PURE__ */ jsx(
|
|
39
|
+
Element,
|
|
40
|
+
{
|
|
41
|
+
ref,
|
|
42
|
+
className: classNames("eds-layout-grid-item", className),
|
|
43
|
+
style: itemStyle,
|
|
44
|
+
...rest,
|
|
45
|
+
children
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
46
50
|
export {
|
|
47
51
|
GridItem
|
|
48
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItem.mjs","sources":["../../../../src/beta/Grid/GridItem.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport type { ResponsiveValue } from '../LayoutWrapper/utils';\nimport classNames from 'classnames';\n\nimport './GridItem.scss';\n\nexport type GridItemOwnProps = {\n /** Number of columns the item should span (supports responsive objects)\n * If number: adds \"span\" prefix (e.g., 6 → \"span 6\")\n * If string: used directly (e.g., \"span 3\" or \"1 / 3\")\n */\n colSpan?: number | string | ResponsiveValue<number | string>;\n /** Number of rows the item should span (supports responsive objects)\n * @default 1\n * If number: adds \"span\" prefix (e.g., 2 → \"span 2\")\n * If string: used directly (e.g., \"span 2\" or \"1 / 3\")\n */\n rowSpan?: number | string | ResponsiveValue<number | string>;\n /** HTML element or React component used to render the Grid item\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid item */\n children?: React.ReactNode;\n};\n\nexport type GridItemProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridItemOwnProps>;\n\nconst defaultElement = 'div';\n\nconst formatGridSpan = (\n value: number | string | undefined,\n): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value === 'number') {\n return `span ${value}`;\n }\n\n return value;\n};\n\nexport const GridItem = <E extends React.ElementType = typeof defaultElement>({\n
|
|
1
|
+
{"version":3,"file":"GridItem.mjs","sources":["../../../../src/beta/Grid/GridItem.tsx"],"sourcesContent":["import React from 'react';\nimport { PolymorphicComponentProps } from '@entur/utils';\nimport { useResponsiveValue } from '../LayoutWrapper/useResponsiveValue';\nimport type { ResponsiveValue } from '../LayoutWrapper/utils';\nimport classNames from 'classnames';\n\nimport './GridItem.scss';\n\nexport type GridItemOwnProps = {\n /** Number of columns the item should span (supports responsive objects)\n * If number: adds \"span\" prefix (e.g., 6 → \"span 6\")\n * If string: used directly (e.g., \"span 3\" or \"1 / 3\")\n */\n colSpan?: number | string | ResponsiveValue<number | string>;\n /** Number of rows the item should span (supports responsive objects)\n * @default 1\n * If number: adds \"span\" prefix (e.g., 2 → \"span 2\")\n * If string: used directly (e.g., \"span 2\" or \"1 / 3\")\n */\n rowSpan?: number | string | ResponsiveValue<number | string>;\n /** HTML element or React component used to render the Grid item\n * @default \"div\"\n */\n as?: string | React.ElementType;\n /** Additional class names */\n className?: string;\n /** Content of the Grid item */\n children?: React.ReactNode;\n};\n\nexport type GridItemProps<T extends React.ElementType = typeof defaultElement> =\n PolymorphicComponentProps<T, GridItemOwnProps>;\n\nconst defaultElement = 'div';\n\nconst formatGridSpan = (\n value: number | string | undefined,\n): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n\n if (typeof value === 'number') {\n return `span ${value}`;\n }\n\n return value;\n};\n\nexport const GridItem = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n colSpan,\n rowSpan = 1,\n as,\n className,\n children,\n style,\n ...rest\n }: GridItemProps<E>,\n ref?: React.Ref<Element>,\n ): JSX.Element => {\n const Element: React.ElementType = as || defaultElement;\n\n const resolvedColSpan = useResponsiveValue(colSpan);\n const resolvedRowSpan = useResponsiveValue(rowSpan);\n\n const itemStyle: React.CSSProperties = {\n ...(resolvedColSpan !== undefined && {\n '--grid-item-column': formatGridSpan(resolvedColSpan),\n }),\n ...(resolvedRowSpan !== undefined && {\n '--grid-item-row': formatGridSpan(resolvedRowSpan),\n }),\n ...style,\n } as React.CSSProperties;\n\n return (\n <Element\n ref={ref}\n className={classNames('eds-layout-grid-item', className)}\n style={itemStyle}\n {...rest}\n >\n {children}\n </Element>\n );\n },\n);\n"],"names":[],"mappings":";;;;;AAiCA,MAAM,iBAAiB;AAEvB,MAAM,iBAAiB,CACrB,UACuB;AACvB,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,QAAQ,KAAK;AAAA,EACtB;AAEA,SAAO;AACT;AAEO,MAAM,WAAW,MAAM;AAAA,EAC5B,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACgB;AAChB,UAAM,UAA6B,MAAM;AAEzC,UAAM,kBAAkB,mBAAmB,OAAO;AAClD,UAAM,kBAAkB,mBAAmB,OAAO;AAElD,UAAM,YAAiC;AAAA,MACrC,GAAI,oBAAoB,UAAa;AAAA,QACnC,sBAAsB,eAAe,eAAe;AAAA,MAAA;AAAA,MAEtD,GAAI,oBAAoB,UAAa;AAAA,QACnC,mBAAmB,eAAe,eAAe;AAAA,MAAA;AAAA,MAEnD,GAAG;AAAA,IAAA;AAGL,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW,WAAW,wBAAwB,SAAS;AAAA,QACvD,OAAO;AAAA,QACN,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
|
package/dist/beta/esm/index.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
9
|
+
import { useSidebarCollapsed } from "./templates/SidebarContext.mjs";
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
Flex,
|
|
11
12
|
FlexSpacer,
|
|
12
|
-
|
|
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,76 +1,162 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useControllableProp } from "@entur/utils";
|
|
2
4
|
import classNames from "classnames";
|
|
5
|
+
import { RightArrowIcon, LeftArrowIcon } from "@entur/icons";
|
|
3
6
|
import { Contrast } from "../Contrast.mjs";
|
|
4
|
-
import { FlexComponent } from "../Flex/index.mjs";
|
|
5
|
-
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";
|
|
6
10
|
/* empty css */
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
11
|
+
const defaultSidebarElement = "aside";
|
|
12
|
+
const defaultSectionElement = "div";
|
|
13
|
+
const defaultNavigationElement = "nav";
|
|
14
|
+
const defaultFooterElement = "footer";
|
|
15
|
+
const SidebarLogo = React.forwardRef(
|
|
16
|
+
({ children, as, ...rest }, ref) => {
|
|
17
|
+
const Element = as || defaultSectionElement;
|
|
18
|
+
return /* @__PURE__ */ jsx(Element, { ref, ...rest, children });
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const SidebarUser = React.forwardRef(
|
|
22
|
+
({ children, as, ...rest }, ref) => {
|
|
23
|
+
const Element = as || defaultSectionElement;
|
|
24
|
+
return /* @__PURE__ */ jsx(Element, { ref, ...rest, children });
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
const SidebarData = React.forwardRef(
|
|
28
|
+
({ children, as, ...rest }, ref) => {
|
|
29
|
+
const Element = as || defaultSectionElement;
|
|
30
|
+
return /* @__PURE__ */ jsx(Element, { ref, ...rest, children });
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
const SidebarNavigation = React.forwardRef(
|
|
34
|
+
({ children, className, as, ...rest }, ref) => {
|
|
35
|
+
const Element = as || defaultNavigationElement;
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
Element,
|
|
38
|
+
{
|
|
39
|
+
ref,
|
|
40
|
+
className: classNames(
|
|
41
|
+
"eds-layout-template-sidebar__navigation",
|
|
42
|
+
className
|
|
43
|
+
),
|
|
44
|
+
...rest,
|
|
45
|
+
children
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
const SidebarFooter = React.forwardRef(
|
|
51
|
+
({ children, className, as, ...rest }, ref) => {
|
|
52
|
+
const Element = as || defaultFooterElement;
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
Element,
|
|
55
|
+
{
|
|
56
|
+
ref,
|
|
57
|
+
className: classNames("eds-layout-template-sidebar__footer", className),
|
|
58
|
+
...rest,
|
|
59
|
+
children
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
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
|
+
);
|
|
75
|
+
const SidebarRoot = React.forwardRef(
|
|
76
|
+
({
|
|
77
|
+
children,
|
|
78
|
+
className,
|
|
79
|
+
style,
|
|
80
|
+
contrast = true,
|
|
81
|
+
collapsible = false,
|
|
82
|
+
collapsed,
|
|
83
|
+
onCollapseToggle,
|
|
84
|
+
openSidebarAriaLabel = "Åpne sidemeny",
|
|
85
|
+
closeSidebarAriaLabel = "Lukk sidemeny",
|
|
86
|
+
as,
|
|
87
|
+
...rest
|
|
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
|
+
});
|
|
100
|
+
const WrapperElement = contrast ? Contrast : "div";
|
|
101
|
+
const sidebarClassNames = classNames(
|
|
102
|
+
"eds-layout-template-sidebar",
|
|
103
|
+
{
|
|
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,
|
|
63
113
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
114
|
+
ref,
|
|
115
|
+
as: as || defaultSidebarElement,
|
|
116
|
+
direction: "column",
|
|
117
|
+
gap: "m",
|
|
118
|
+
className: sidebarClassNames,
|
|
119
|
+
style,
|
|
120
|
+
...rest,
|
|
121
|
+
children
|
|
122
|
+
}
|
|
123
|
+
) });
|
|
71
124
|
}
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
] })
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
);
|
|
74
160
|
const Sidebar = Object.assign(SidebarRoot, {
|
|
75
161
|
Logo: SidebarLogo,
|
|
76
162
|
User: SidebarUser,
|