@entur/layout 3.6.1 → 3.7.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 +2 -2
- package/dist/beta/cjs/Flex/Flex.cjs.map +1 -1
- package/dist/beta/cjs/Flex/FlexSpacer.cjs.map +1 -1
- package/dist/beta/cjs/Grid/Grid.cjs +2 -2
- package/dist/beta/cjs/Grid/Grid.cjs.map +1 -1
- package/dist/beta/cjs/Grid/GridItem.cjs +1 -1
- package/dist/beta/cjs/Grid/GridItem.cjs.map +1 -1
- package/dist/beta/cjs/Grid/index.cjs.map +1 -1
- package/dist/beta/cjs/{LayoutWrapper/LayoutWrapper.cjs → LayoutProvider/LayoutProvider.cjs} +3 -3
- package/dist/beta/cjs/LayoutProvider/LayoutProvider.cjs.map +1 -0
- package/dist/beta/cjs/{LayoutWrapper → LayoutProvider}/useLayoutValues.cjs +2 -2
- package/dist/beta/cjs/LayoutProvider/useLayoutValues.cjs.map +1 -0
- package/dist/beta/cjs/{LayoutWrapper → LayoutProvider}/useResponsiveValue.cjs +12 -8
- package/dist/beta/cjs/LayoutProvider/useResponsiveValue.cjs.map +1 -0
- package/dist/beta/cjs/{LayoutWrapper → LayoutProvider}/utils.cjs +3 -3
- package/dist/beta/cjs/LayoutProvider/utils.cjs.map +1 -0
- package/dist/beta/cjs/index.cjs +3 -3
- package/dist/beta/cjs/templates/Sidebar.cjs +64 -48
- package/dist/beta/cjs/templates/Sidebar.cjs.map +1 -1
- package/dist/beta/cjs/templates/portal/Portal.cjs +44 -35
- package/dist/beta/cjs/templates/portal/Portal.cjs.map +1 -1
- package/dist/beta/esm/Flex/Flex.mjs +2 -2
- package/dist/beta/esm/Flex/Flex.mjs.map +1 -1
- package/dist/beta/esm/Flex/FlexSpacer.mjs.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/Grid/GridItem.mjs +1 -1
- package/dist/beta/esm/Grid/GridItem.mjs.map +1 -1
- package/dist/beta/esm/Grid/index.mjs.map +1 -1
- package/dist/beta/esm/{LayoutWrapper/LayoutWrapper.mjs → LayoutProvider/LayoutProvider.mjs} +3 -3
- package/dist/beta/esm/LayoutProvider/LayoutProvider.mjs.map +1 -0
- package/dist/beta/esm/{LayoutWrapper → LayoutProvider}/useLayoutValues.mjs +1 -1
- package/dist/beta/esm/LayoutProvider/useLayoutValues.mjs.map +1 -0
- package/dist/beta/esm/{LayoutWrapper → LayoutProvider}/useResponsiveValue.mjs +12 -8
- package/dist/beta/esm/LayoutProvider/useResponsiveValue.mjs.map +1 -0
- package/dist/beta/esm/{LayoutWrapper → LayoutProvider}/utils.mjs +3 -3
- package/dist/beta/esm/LayoutProvider/utils.mjs.map +1 -0
- package/dist/beta/esm/index.mjs +3 -3
- package/dist/beta/esm/templates/Sidebar.mjs +64 -48
- package/dist/beta/esm/templates/Sidebar.mjs.map +1 -1
- package/dist/beta/esm/templates/portal/Portal.mjs +44 -35
- package/dist/beta/esm/templates/portal/Portal.mjs.map +1 -1
- package/dist/beta/styles/index.css +22 -1
- package/dist/beta/types/Flex/Flex.d.ts +7 -4
- package/dist/beta/types/Flex/FlexSpacer.d.ts +4 -1
- package/dist/beta/types/Grid/Grid.d.ts +7 -4
- package/dist/beta/types/Grid/GridItem.d.ts +7 -4
- package/dist/beta/types/Grid/index.d.ts +1 -3
- package/dist/beta/types/LayoutProvider/LayoutProvider.d.ts +28 -0
- package/dist/beta/types/{LayoutWrapper → LayoutProvider}/index.d.ts +2 -2
- package/dist/beta/types/{LayoutWrapper → LayoutProvider}/useLayoutValues.d.ts +1 -1
- package/dist/beta/types/{LayoutWrapper → LayoutProvider}/utils.d.ts +15 -4
- package/dist/beta/types/index.d.ts +2 -1
- package/dist/beta/types/templates/Sidebar.d.ts +19 -18
- package/dist/beta/types/templates/portal/Portal.d.ts +21 -9
- package/package.json +7 -7
- package/dist/beta/cjs/LayoutWrapper/LayoutWrapper.cjs.map +0 -1
- package/dist/beta/cjs/LayoutWrapper/useLayoutValues.cjs.map +0 -1
- package/dist/beta/cjs/LayoutWrapper/useResponsiveValue.cjs.map +0 -1
- package/dist/beta/cjs/LayoutWrapper/utils.cjs.map +0 -1
- package/dist/beta/esm/LayoutWrapper/LayoutWrapper.mjs.map +0 -1
- package/dist/beta/esm/LayoutWrapper/useLayoutValues.mjs.map +0 -1
- package/dist/beta/esm/LayoutWrapper/useResponsiveValue.mjs.map +0 -1
- package/dist/beta/esm/LayoutWrapper/utils.mjs.map +0 -1
- package/dist/beta/types/LayoutWrapper/LayoutWrapper.d.ts +0 -13
- /package/dist/beta/types/{LayoutWrapper → LayoutProvider}/useResponsiveValue.d.ts +0 -0
|
@@ -8,51 +8,60 @@ const defaultStatusBarElement = "div";
|
|
|
8
8
|
const defaultPortalMainElement = "main";
|
|
9
9
|
const PortalRoot = React.forwardRef(
|
|
10
10
|
({ children, className, style, as, ...rest }, ref) => {
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
return (
|
|
12
|
+
// @ts-expect-error generic prop forwarding through polymorphic Grid
|
|
13
|
+
/* @__PURE__ */ jsx(
|
|
14
|
+
GridComponent,
|
|
15
|
+
{
|
|
16
|
+
ref,
|
|
17
|
+
as,
|
|
18
|
+
gap: "none",
|
|
19
|
+
columnGap: "m",
|
|
20
|
+
className: classNames("eds-layout-template-portal", className),
|
|
21
|
+
style,
|
|
22
|
+
...rest,
|
|
23
|
+
children
|
|
24
|
+
}
|
|
25
|
+
)
|
|
23
26
|
);
|
|
24
27
|
}
|
|
25
28
|
);
|
|
26
29
|
const PortalStatusBar = React.forwardRef(
|
|
27
30
|
({ children, className, as, ...rest }, ref) => {
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
className
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
return (
|
|
32
|
+
// @ts-expect-error generic prop forwarding through polymorphic Grid.Item
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
GridComponent.Item,
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
as: as || defaultStatusBarElement,
|
|
38
|
+
className: classNames(
|
|
39
|
+
"eds-layout-template-portal__status-bar",
|
|
40
|
+
className
|
|
41
|
+
),
|
|
42
|
+
...rest,
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
)
|
|
40
46
|
);
|
|
41
47
|
}
|
|
42
48
|
);
|
|
43
49
|
const PortalMain = React.forwardRef(
|
|
44
50
|
({ children, className, style, as, ...rest }, ref) => {
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
return (
|
|
52
|
+
// @ts-expect-error generic prop forwarding through polymorphic Grid.Item
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
GridComponent.Item,
|
|
55
|
+
{
|
|
56
|
+
ref,
|
|
57
|
+
as: as || defaultPortalMainElement,
|
|
58
|
+
colSpan: "2 / -1",
|
|
59
|
+
className: classNames("eds-layout-template-portal__main", className),
|
|
60
|
+
style,
|
|
61
|
+
...rest,
|
|
62
|
+
children
|
|
63
|
+
}
|
|
64
|
+
)
|
|
56
65
|
);
|
|
57
66
|
}
|
|
58
67
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.mjs","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":["Grid"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Portal.mjs","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 /** Content of the portal layout */\n children?: React.ReactNode;\n};\n\ntype PortalStatusBarOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n /** Content of the status bar */\n children?: React.ReactNode;\n};\n\ntype PortalMainOwnProps = {\n className?: string;\n style?: React.CSSProperties;\n /** Main content area */\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\ntype PortalRootComponent = (<E extends React.ElementType = typeof Grid>(\n props: PortalProps<E> & { ref?: React.Ref<Element> },\n) => React.ReactElement | null) & { displayName?: string };\n\ntype PortalStatusBarComponent = (<\n E extends React.ElementType = typeof defaultStatusBarElement,\n>(\n props: PortalStatusBarProps<E> & { ref?: React.Ref<Element> },\n) => React.ReactElement | null) & { displayName?: string };\n\ntype PortalMainComponent = (<\n E extends React.ElementType = typeof defaultPortalMainElement,\n>(\n props: PortalMainProps<E> & { ref?: React.Ref<Element> },\n) => React.ReactElement | null) & { displayName?: string };\n\nconst PortalRoot: PortalRootComponent = 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 // @ts-expect-error generic prop forwarding through polymorphic Grid\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: PortalStatusBarComponent = 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 // @ts-expect-error generic prop forwarding through polymorphic Grid.Item\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: PortalMainComponent = 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 // @ts-expect-error generic prop forwarding through polymorphic Grid.Item\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":["Grid"],"mappings":";;;;;;AA4BA,MAAM,0BAA0B;AAChC,MAAM,2BAA2B;AA6BjC,MAAM,aAAkC,MAAM;AAAA,EAC5C,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH;AAAA;AAAA,MAEE;AAAA,QAACA;AAAAA,QAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA,KAAI;AAAA,UACJ,WAAU;AAAA,UACV,WAAW,WAAW,8BAA8B,SAAS;AAAA,UAC7D;AAAA,UACC,GAAG;AAAA,UAEH;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAGP;AACF;AAEA,MAAM,kBAA4C,MAAM;AAAA,EACtD,CACE,EAAE,UAAU,WAAW,IAAI,GAAG,KAAA,GAC9B,QACG;AACH;AAAA;AAAA,MAEE;AAAA,QAACA,cAAK;AAAA,QAAL;AAAA,UACC;AAAA,UACA,IAAI,MAAM;AAAA,UACV,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UAAA;AAAA,UAED,GAAG;AAAA,UAEH;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAGP;AACF;AAEA,MAAM,aAAkC,MAAM;AAAA,EAC5C,CACE,EAAE,UAAU,WAAW,OAAO,IAAI,GAAG,KAAA,GACrC,QACG;AACH;AAAA;AAAA,MAEE;AAAA,QAACA,cAAK;AAAA,QAAL;AAAA,UACC;AAAA,UACA,IAAI,MAAM;AAAA,UACV,SAAQ;AAAA,UACR,WAAW,WAAW,oCAAoC,SAAS;AAAA,UACnE;AAAA,UACC,GAAG;AAAA,UAEH;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAGP;AACF;AAQO,MAAM,SAA0B,OAAO,OAAO,YAAY;AAAA,EAC/D,WAAW;AAAA,EACX;AAAA,EACA,MAAM;AACR,CAAC;AAED,OAAO,cAAc;AACrB,OAAO,UAAU,cAAc;AAC/B,OAAO,KAAK,cAAc;"}
|
|
@@ -106,7 +106,28 @@
|
|
|
106
106
|
--grid-item-row:initial;
|
|
107
107
|
grid-column:var(--grid-item-column);
|
|
108
108
|
grid-row:var(--grid-item-row);
|
|
109
|
-
}
|
|
109
|
+
}.eds-layout-flex{
|
|
110
|
+
--flex-display:initial;
|
|
111
|
+
--flex-direction:initial;
|
|
112
|
+
--flex-wrap:initial;
|
|
113
|
+
--flex-align-items:initial;
|
|
114
|
+
--flex-justify-content:initial;
|
|
115
|
+
--flex-align-content:initial;
|
|
116
|
+
--flex-gap:initial;
|
|
117
|
+
--flex-row-gap:initial;
|
|
118
|
+
--flex-column-gap:initial;
|
|
119
|
+
--flex:initial;
|
|
120
|
+
--flex-grow:initial;
|
|
121
|
+
--flex-shrink:initial;
|
|
122
|
+
--flex-basis:initial;
|
|
123
|
+
--flex-width:initial;
|
|
124
|
+
--flex-height:initial;
|
|
125
|
+
--flex-min-width:initial;
|
|
126
|
+
--flex-min-height:initial;
|
|
127
|
+
--flex-max-width:initial;
|
|
128
|
+
--flex-max-height:initial;
|
|
129
|
+
}
|
|
130
|
+
:where(.eds-layout-flex){
|
|
110
131
|
display:-webkit-box;
|
|
111
132
|
display:-webkit-flex;
|
|
112
133
|
display:-moz-box;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { PolymorphicComponentProps } from '@entur/utils';
|
|
3
|
-
import { GridSpacingValue, ResponsiveValue } from '../
|
|
3
|
+
import { GridSpacingValue, ResponsiveValue } from '../LayoutProvider/utils';
|
|
4
4
|
export type FlexSpacingValue = GridSpacingValue;
|
|
5
5
|
type FlexDirection = React.CSSProperties['flexDirection'];
|
|
6
6
|
type FlexWrap = React.CSSProperties['flexWrap'];
|
|
@@ -60,8 +60,11 @@ export type FlexOwnProps = {
|
|
|
60
60
|
children?: React.ReactNode;
|
|
61
61
|
};
|
|
62
62
|
export type FlexProps<T extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<T, FlexOwnProps>;
|
|
63
|
+
export type FlexComponent = (<E extends React.ElementType = typeof defaultElement>(props: FlexProps<E> & {
|
|
64
|
+
ref?: React.Ref<Element>;
|
|
65
|
+
}) => React.ReactElement | null) & {
|
|
66
|
+
displayName?: string;
|
|
67
|
+
};
|
|
63
68
|
declare const defaultElement = "div";
|
|
64
|
-
export declare const Flex:
|
|
65
|
-
as?: React.ElementType<any> | undefined;
|
|
66
|
-
} & Omit<Omit<any, "ref">, keyof FlexOwnProps>, "ref"> & React.RefAttributes<Element>>;
|
|
69
|
+
export declare const Flex: FlexComponent;
|
|
67
70
|
export {};
|
|
@@ -11,6 +11,9 @@ export type FlexSpacerOwnProps = {
|
|
|
11
11
|
children?: never;
|
|
12
12
|
};
|
|
13
13
|
export type FlexSpacerProps<T extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<T, FlexSpacerOwnProps>;
|
|
14
|
+
export type FlexSpacerComponent = (<E extends React.ElementType = typeof defaultElement>(props: FlexSpacerProps<E>) => React.ReactElement | null) & {
|
|
15
|
+
displayName?: string;
|
|
16
|
+
};
|
|
14
17
|
declare const defaultElement = "div";
|
|
15
|
-
export declare const FlexSpacer:
|
|
18
|
+
export declare const FlexSpacer: FlexSpacerComponent;
|
|
16
19
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { PolymorphicComponentProps } from '@entur/utils';
|
|
3
|
-
import { GridSpacingValue, ResponsiveValue } from '../
|
|
3
|
+
import { GridSpacingValue, ResponsiveValue } from '../LayoutProvider/utils';
|
|
4
4
|
type AlignItems = React.CSSProperties['alignItems'];
|
|
5
5
|
type JustifyContent = React.CSSProperties['justifyContent'];
|
|
6
6
|
type AlignContent = React.CSSProperties['alignContent'];
|
|
@@ -41,8 +41,11 @@ export type GridOwnProps = {
|
|
|
41
41
|
children?: React.ReactNode;
|
|
42
42
|
};
|
|
43
43
|
export type GridProps<T extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<T, GridOwnProps>;
|
|
44
|
+
export type GridComponent = (<E extends React.ElementType = typeof defaultElement>(props: GridProps<E> & {
|
|
45
|
+
ref?: React.Ref<Element>;
|
|
46
|
+
}) => React.ReactElement | null) & {
|
|
47
|
+
displayName?: string;
|
|
48
|
+
};
|
|
44
49
|
declare const defaultElement = "div";
|
|
45
|
-
export declare const Grid:
|
|
46
|
-
as?: React.ElementType<any> | undefined;
|
|
47
|
-
} & Omit<Omit<any, "ref">, keyof GridOwnProps>, "ref"> & React.RefAttributes<Element>>;
|
|
50
|
+
export declare const Grid: GridComponent;
|
|
48
51
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { PolymorphicComponentProps } from '@entur/utils';
|
|
3
|
-
import { ResponsiveValue } from '../
|
|
3
|
+
import { ResponsiveValue } from '../LayoutProvider/utils';
|
|
4
4
|
export type GridItemOwnProps = {
|
|
5
5
|
/** Number of columns the item should span (supports responsive objects)
|
|
6
6
|
* If number: adds "span" prefix (e.g., 6 → "span 6")
|
|
@@ -23,8 +23,11 @@ export type GridItemOwnProps = {
|
|
|
23
23
|
children?: React.ReactNode;
|
|
24
24
|
};
|
|
25
25
|
export type GridItemProps<T extends React.ElementType = typeof defaultElement> = PolymorphicComponentProps<T, GridItemOwnProps>;
|
|
26
|
+
export type GridItemComponent = (<E extends React.ElementType = typeof defaultElement>(props: GridItemProps<E> & {
|
|
27
|
+
ref?: React.Ref<Element>;
|
|
28
|
+
}) => React.ReactElement | null) & {
|
|
29
|
+
displayName?: string;
|
|
30
|
+
};
|
|
26
31
|
declare const defaultElement = "div";
|
|
27
|
-
export declare const GridItem:
|
|
28
|
-
as?: React.ElementType<any> | undefined;
|
|
29
|
-
} & Omit<Omit<any, "ref">, keyof GridItemOwnProps>, "ref"> & React.RefAttributes<Element>>;
|
|
32
|
+
export declare const GridItem: GridItemComponent;
|
|
30
33
|
export {};
|
|
@@ -22,8 +22,6 @@ type Grid = typeof GridParent & {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const GridComponent: Grid;
|
|
24
24
|
export type { GridProps, GridOwnProps } from './Grid';
|
|
25
|
-
export type { GridSpacingValue, ResponsiveValue } from '../
|
|
25
|
+
export type { GridSpacingValue, ResponsiveValue, } from '../LayoutProvider/utils';
|
|
26
26
|
export type { GridItemProps, GridItemOwnProps } from './GridItem';
|
|
27
27
|
export { GridComponent as Grid, GridItem };
|
|
28
|
-
export { LayoutWrapper } from '../LayoutWrapper/LayoutWrapper';
|
|
29
|
-
export { useLayoutValues } from '../LayoutWrapper/useLayoutValues';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Breakpoints } from './utils';
|
|
3
|
+
export type LayoutValues = {
|
|
4
|
+
breakpoints: Breakpoints;
|
|
5
|
+
};
|
|
6
|
+
export type LayoutProviderProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Custom breakpoint values (in px) to override the defaults.
|
|
9
|
+
*
|
|
10
|
+
* Breakpoints are **min-width** based: a breakpoint activates when the
|
|
11
|
+
* viewport is at least that wide and stays active until the next breakpoint.
|
|
12
|
+
*
|
|
13
|
+
* Default values:
|
|
14
|
+
* - `s`: 0px — always active below `m` (not configurable)
|
|
15
|
+
* - `m`: 800px — active from 800px up to (but not including) `lg`
|
|
16
|
+
* - `lg`: 1200px — active from 1200px up to (but not including) `xl`
|
|
17
|
+
* - `xl`: 1400px — active from 1400px and above
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <LayoutProvider breakpoints={{ m: 600, lg: 1024, xl: 1280 }}>
|
|
21
|
+
* ...
|
|
22
|
+
* </LayoutProvider>
|
|
23
|
+
*/
|
|
24
|
+
breakpoints?: Partial<Breakpoints>;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
export declare const LayoutProvider: ({ breakpoints: customBreakpoints, children, }: LayoutProviderProps) => JSX.Element;
|
|
28
|
+
export declare const useLayoutContext: () => LayoutValues | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LayoutProvider } from './LayoutProvider';
|
|
2
2
|
export { useLayoutValues } from './useLayoutValues';
|
|
3
3
|
export { useResponsiveValue } from './useResponsiveValue';
|
|
4
|
-
export type { LayoutValues,
|
|
4
|
+
export type { LayoutValues, LayoutProviderProps } from './LayoutProvider';
|
|
5
5
|
export type { Breakpoints, GridSpacingValue, ResponsiveValue } from './utils';
|
|
6
6
|
export { DEFAULT_BREAKPOINTS, getSpacingValue } from './utils';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LayoutValues } from './
|
|
1
|
+
import { LayoutValues } from './LayoutProvider';
|
|
2
2
|
export declare const useLayoutValues: () => LayoutValues;
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
declare const VALID_SPACING_VALUES: readonly ["2xs", "xs", "s", "s-m", "m", "m-l", "l", "xl", "2xl", "3xl", "4xl", "5xl", "6xl", "7xl", "8xl", "9xl", "10xl", "11xl", "none"];
|
|
2
2
|
export type GridSpacingValue = (typeof VALID_SPACING_VALUES)[number];
|
|
3
3
|
export type ResponsiveValue<T> = T | {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
s?: T;
|
|
5
|
+
m?: T;
|
|
6
6
|
lg?: T;
|
|
7
|
+
xl?: T;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Configurable min-width breakpoints (in px).
|
|
11
|
+
*
|
|
12
|
+
* `s` is always 0 and is not configurable — it is the base (mobile-first)
|
|
13
|
+
* fallback that activates below `m`.
|
|
14
|
+
*
|
|
15
|
+
* - `m`: activates at this width and above (default: 800px)
|
|
16
|
+
* - `lg`: activates at this width and above (default: 1200px)
|
|
17
|
+
* - `xl`: activates at this width and above (default: 1400px)
|
|
18
|
+
*/
|
|
8
19
|
export type Breakpoints = {
|
|
9
|
-
|
|
10
|
-
md: number;
|
|
20
|
+
m: number;
|
|
11
21
|
lg: number;
|
|
22
|
+
xl: number;
|
|
12
23
|
};
|
|
13
24
|
export declare const DEFAULT_BREAKPOINTS: Breakpoints;
|
|
14
25
|
export declare const getSpacingValue: (spacing: GridSpacingValue | undefined, componentName?: string) => string | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { Grid, GridItem } from './Grid';
|
|
2
|
-
export {
|
|
2
|
+
export { LayoutProvider, useLayoutValues } from './LayoutProvider';
|
|
3
|
+
export type { LayoutProviderProps } from './LayoutProvider';
|
|
3
4
|
export { Flex, FlexSpacer } from './Flex';
|
|
4
5
|
export { Template } from './templates';
|
|
5
6
|
export type { GridProps, GridOwnProps, GridItemProps, GridItemOwnProps, GridSpacingValue, ResponsiveValue, } from './Grid';
|
|
@@ -18,6 +18,7 @@ type SidebarOwnProps = {
|
|
|
18
18
|
closeSidebarAriaLabel?: string;
|
|
19
19
|
className?: string;
|
|
20
20
|
style?: React.CSSProperties;
|
|
21
|
+
/** Content of the sidebar */
|
|
21
22
|
children?: React.ReactNode;
|
|
22
23
|
};
|
|
23
24
|
type SidebarSectionOwnProps = {
|
|
@@ -27,26 +28,26 @@ type SidebarSectionOwnProps = {
|
|
|
27
28
|
};
|
|
28
29
|
declare const defaultSidebarElement = "aside";
|
|
29
30
|
declare const defaultSectionElement = "div";
|
|
31
|
+
declare const defaultNavigationElement = "nav";
|
|
32
|
+
declare const defaultFooterElement = "footer";
|
|
30
33
|
export type SidebarProps<T extends React.ElementType = typeof defaultSidebarElement> = PolymorphicComponentProps<T, SidebarOwnProps>;
|
|
31
34
|
export type SidebarSectionProps<T extends React.ElementType = typeof defaultSectionElement> = PolymorphicComponentProps<T, SidebarSectionOwnProps>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
declare const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
declare const SidebarRoot:
|
|
48
|
-
as?: React.ElementType<any> | undefined;
|
|
49
|
-
} & Omit<Omit<any, "ref">, "as" | keyof SidebarOwnProps>, "ref"> & React.RefAttributes<Element>>;
|
|
35
|
+
type SidebarRootComponent = (<E extends React.ElementType = typeof defaultSidebarElement>(props: SidebarProps<E> & {
|
|
36
|
+
ref?: React.Ref<Element>;
|
|
37
|
+
}) => React.ReactElement | null) & {
|
|
38
|
+
displayName?: string;
|
|
39
|
+
};
|
|
40
|
+
type SidebarSectionComponent<Default extends React.ElementType = typeof defaultSectionElement> = (<E extends React.ElementType = Default>(props: SidebarSectionProps<E> & {
|
|
41
|
+
ref?: React.Ref<Element>;
|
|
42
|
+
}) => React.ReactElement | null) & {
|
|
43
|
+
displayName?: string;
|
|
44
|
+
};
|
|
45
|
+
declare const SidebarLogo: SidebarSectionComponent;
|
|
46
|
+
declare const SidebarUser: SidebarSectionComponent;
|
|
47
|
+
declare const SidebarData: SidebarSectionComponent;
|
|
48
|
+
declare const SidebarNavigation: SidebarSectionComponent<typeof defaultNavigationElement>;
|
|
49
|
+
declare const SidebarFooter: SidebarSectionComponent<typeof defaultFooterElement>;
|
|
50
|
+
declare const SidebarRoot: SidebarRootComponent;
|
|
50
51
|
export type SidebarComponent = typeof SidebarRoot & {
|
|
51
52
|
Logo: typeof SidebarLogo;
|
|
52
53
|
User: typeof SidebarUser;
|
|
@@ -5,16 +5,19 @@ import { SidebarComponent } from '../Sidebar';
|
|
|
5
5
|
type PortalOwnProps = {
|
|
6
6
|
className?: string;
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
|
+
/** Content of the portal layout */
|
|
8
9
|
children?: React.ReactNode;
|
|
9
10
|
};
|
|
10
11
|
type PortalStatusBarOwnProps = {
|
|
11
12
|
className?: string;
|
|
12
13
|
style?: React.CSSProperties;
|
|
14
|
+
/** Content of the status bar */
|
|
13
15
|
children?: React.ReactNode;
|
|
14
16
|
};
|
|
15
17
|
type PortalMainOwnProps = {
|
|
16
18
|
className?: string;
|
|
17
19
|
style?: React.CSSProperties;
|
|
20
|
+
/** Main content area */
|
|
18
21
|
children?: React.ReactNode;
|
|
19
22
|
};
|
|
20
23
|
declare const defaultStatusBarElement = "div";
|
|
@@ -22,15 +25,24 @@ declare const defaultPortalMainElement = "main";
|
|
|
22
25
|
export type PortalProps<T extends React.ElementType = typeof Grid> = PolymorphicComponentProps<T, PortalOwnProps>;
|
|
23
26
|
export type PortalStatusBarProps<T extends React.ElementType = typeof defaultStatusBarElement> = PolymorphicComponentProps<T, PortalStatusBarOwnProps>;
|
|
24
27
|
export type PortalMainProps<T extends React.ElementType = typeof defaultPortalMainElement> = PolymorphicComponentProps<T, PortalMainOwnProps>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
type PortalRootComponent = (<E extends React.ElementType = typeof Grid>(props: PortalProps<E> & {
|
|
29
|
+
ref?: React.Ref<Element>;
|
|
30
|
+
}) => React.ReactElement | null) & {
|
|
31
|
+
displayName?: string;
|
|
32
|
+
};
|
|
33
|
+
type PortalStatusBarComponent = (<E extends React.ElementType = typeof defaultStatusBarElement>(props: PortalStatusBarProps<E> & {
|
|
34
|
+
ref?: React.Ref<Element>;
|
|
35
|
+
}) => React.ReactElement | null) & {
|
|
36
|
+
displayName?: string;
|
|
37
|
+
};
|
|
38
|
+
type PortalMainComponent = (<E extends React.ElementType = typeof defaultPortalMainElement>(props: PortalMainProps<E> & {
|
|
39
|
+
ref?: React.Ref<Element>;
|
|
40
|
+
}) => React.ReactElement | null) & {
|
|
41
|
+
displayName?: string;
|
|
42
|
+
};
|
|
43
|
+
declare const PortalRoot: PortalRootComponent;
|
|
44
|
+
declare const PortalStatusBar: PortalStatusBarComponent;
|
|
45
|
+
declare const PortalMain: PortalMainComponent;
|
|
34
46
|
export type PortalComponent = typeof PortalRoot & {
|
|
35
47
|
StatusBar: typeof PortalStatusBar;
|
|
36
48
|
Sidebar: SidebarComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/layout",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/layout.cjs.js",
|
|
6
6
|
"module": "dist/layout.esm.js",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"react-dom": ">=16.8.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@entur/icons": "^8.4.
|
|
54
|
-
"@entur/tokens": "^3.22.
|
|
55
|
-
"@entur/typography": "^2.1.
|
|
56
|
-
"@entur/utils": "^0.13.
|
|
53
|
+
"@entur/icons": "^8.4.6",
|
|
54
|
+
"@entur/tokens": "^3.22.5",
|
|
55
|
+
"@entur/typography": "^2.1.7",
|
|
56
|
+
"@entur/utils": "^0.13.4",
|
|
57
57
|
"classnames": "^2.5.1"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"jest-environment-jsdom": "^29.0.0",
|
|
66
66
|
"ts-jest": "^29.0.0",
|
|
67
67
|
"typescript": "^5.9.2",
|
|
68
|
-
"vite": "^7.
|
|
68
|
+
"vite": "^7.3.2",
|
|
69
69
|
"vite-plugin-dts": "^4.5.4"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0c3904649cb7f504f1d7bd832dfcc64f7fe5c123"
|
|
72
72
|
}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveValue.cjs","sources":["../../../../src/beta/LayoutWrapper/useResponsiveValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useLayoutValues } from './useLayoutValues';\nimport type { ResponsiveValue } from './utils';\n\nconst isResponsiveObject = <T>(\n value: ResponsiveValue<T>,\n): value is { sm?: T; md?: T; lg?: T } => {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n ('sm' in value || 'md' in value || 'lg' in value)\n );\n};\n\nconst getCurrentBreakpoint = (\n breakpoints: { sm: number; md: number; lg: number },\n windowWidth: number,\n): 'sm' | 'md' | 'lg' => {\n if (windowWidth >= breakpoints.lg) {\n return 'lg';\n }\n if (windowWidth >= breakpoints.md) {\n return 'md';\n }\n return 'sm';\n};\n\nexport const useResponsiveValue = <T>(\n value: ResponsiveValue<T> | undefined,\n): T | undefined => {\n const { breakpoints } = useLayoutValues();\n const [currentBreakpoint, setCurrentBreakpoint] = useState<\n 'sm' | 'md' | 'lg'\n >(() => {\n if (typeof window === 'undefined') {\n return 'sm';\n }\n return getCurrentBreakpoint(breakpoints, window.innerWidth);\n });\n\n useEffect(() => {\n if (\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return;\n }\n\n const updateBreakpoint = () => {\n setCurrentBreakpoint(\n getCurrentBreakpoint(breakpoints, window.innerWidth),\n );\n };\n\n const mediaQueries = [\n window.matchMedia(`(min-width: ${breakpoints.md}px)`),\n window.matchMedia(`(min-width: ${breakpoints.lg}px)`),\n ];\n\n updateBreakpoint();\n\n const handleChange = () => {\n updateBreakpoint();\n };\n\n mediaQueries.forEach(mq => {\n if (mq.addEventListener) {\n mq.addEventListener('change', handleChange);\n } else {\n mq.addListener(handleChange);\n }\n });\n\n return () => {\n mediaQueries.forEach(mq => {\n if (mq.removeEventListener) {\n mq.removeEventListener('change', handleChange);\n } else {\n mq.removeListener(handleChange);\n }\n });\n };\n }, [breakpoints]);\n\n if (!value) {\n return undefined;\n }\n\n if (!isResponsiveObject(value)) {\n return value;\n }\n\n const responsiveValue = value[currentBreakpoint];\n if (responsiveValue !== undefined) {\n return responsiveValue;\n }\n\n const fallbackOrder: Array<'lg' | 'md' | 'sm'> =\n currentBreakpoint === 'lg'\n ? ['lg', 'md', 'sm']\n : currentBreakpoint === 'md'\n ? ['md', 'sm']\n : ['sm'];\n\n for (const bp of fallbackOrder) {\n if (value[bp] !== undefined) {\n return value[bp];\n }\n }\n\n return undefined;\n};\n"],"names":["useLayoutValues","useState","useEffect"],"mappings":";;;;AAIA,MAAM,qBAAqB,CACzB,UACwC;AACxC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,MACnB,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAE/C;AAEA,MAAM,uBAAuB,CAC3B,aACA,gBACuB;AACvB,MAAI,eAAe,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACA,MAAI,eAAe,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAChC,UACkB;AAClB,QAAM,EAAE,YAAA,IAAgBA,gCAAA;AACxB,QAAM,CAAC,mBAAmB,oBAAoB,IAAIC,MAAAA,SAEhD,MAAM;AACN,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,WAAO,qBAAqB,aAAa,OAAO,UAAU;AAAA,EAC5D,CAAC;AAEDC,QAAAA,UAAU,MAAM;AACd,QACE,OAAO,WAAW,eAClB,OAAO,OAAO,eAAe,YAC7B;AACA;AAAA,IACF;AAEA,UAAM,mBAAmB,MAAM;AAC7B;AAAA,QACE,qBAAqB,aAAa,OAAO,UAAU;AAAA,MAAA;AAAA,IAEvD;AAEA,UAAM,eAAe;AAAA,MACnB,OAAO,WAAW,eAAe,YAAY,EAAE,KAAK;AAAA,MACpD,OAAO,WAAW,eAAe,YAAY,EAAE,KAAK;AAAA,IAAA;AAGtD,qBAAA;AAEA,UAAM,eAAe,MAAM;AACzB,uBAAA;AAAA,IACF;AAEA,iBAAa,QAAQ,CAAA,OAAM;AACzB,UAAI,GAAG,kBAAkB;AACvB,WAAG,iBAAiB,UAAU,YAAY;AAAA,MAC5C,OAAO;AACL,WAAG,YAAY,YAAY;AAAA,MAC7B;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,mBAAa,QAAQ,CAAA,OAAM;AACzB,YAAI,GAAG,qBAAqB;AAC1B,aAAG,oBAAoB,UAAU,YAAY;AAAA,QAC/C,OAAO;AACL,aAAG,eAAe,YAAY;AAAA,QAChC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,mBAAmB,KAAK,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,MAAM,iBAAiB;AAC/C,MAAI,oBAAoB,QAAW;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,gBACJ,sBAAsB,OAClB,CAAC,MAAM,MAAM,IAAI,IACjB,sBAAsB,OACtB,CAAC,MAAM,IAAI,IACX,CAAC,IAAI;AAEX,aAAW,MAAM,eAAe;AAC9B,QAAI,MAAM,EAAE,MAAM,QAAW;AAC3B,aAAO,MAAM,EAAE;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../../../src/beta/LayoutWrapper/utils.ts"],"sourcesContent":["const VALID_SPACING_VALUES = [\n '2xs',\n 'xs',\n 's',\n 's-m',\n 'm',\n 'm-l',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n '7xl',\n '8xl',\n '9xl',\n '10xl',\n '11xl',\n 'none',\n] as const;\n\nexport type GridSpacingValue = (typeof VALID_SPACING_VALUES)[number];\n\nexport type ResponsiveValue<T> =\n | T\n | {\n sm?: T;\n md?: T;\n lg?: T;\n };\n\nexport type Breakpoints = {\n sm: number;\n md: number;\n lg: number;\n};\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = {\n sm: 0,\n md: 800,\n lg: 1200,\n};\n\nconst isValidSpacingValue = (value: unknown): value is GridSpacingValue => {\n return (\n typeof value === 'string' &&\n VALID_SPACING_VALUES.includes(value as GridSpacingValue)\n );\n};\n\nexport const getSpacingValue = (\n spacing: GridSpacingValue | undefined,\n componentName = 'Grid',\n): string | undefined => {\n if (!spacing) return undefined;\n if (spacing === 'none') return '0';\n\n if (!isValidSpacingValue(spacing)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Invalid ${componentName} spacing value: \"${spacing}\". Valid values are: ${VALID_SPACING_VALUES.join(\n ', ',\n )}. Falling back to undefined.`,\n );\n }\n return undefined;\n }\n\n return `var(--${spacing})`;\n};\n"],"names":[],"mappings":";;AAAA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAkBO,MAAM,sBAAmC;AAAA,EAC9C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,sBAAsB,CAAC,UAA8C;AACzE,SACE,OAAO,UAAU,YACjB,qBAAqB,SAAS,KAAyB;AAE3D;AAEO,MAAM,kBAAkB,CAC7B,SACA,gBAAgB,WACO;AACvB,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,YAAY,OAAQ,QAAO;AAE/B,MAAI,CAAC,oBAAoB,OAAO,GAAG;AACjC,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,cAAQ;AAAA,QACN,WAAW,aAAa,oBAAoB,OAAO,wBAAwB,qBAAqB;AAAA,UAC9F;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IAEL;AACA,WAAO;AAAA,EACT;AAEA,SAAO,SAAS,OAAO;AACzB;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveValue.mjs","sources":["../../../../src/beta/LayoutWrapper/useResponsiveValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport { useLayoutValues } from './useLayoutValues';\nimport type { ResponsiveValue } from './utils';\n\nconst isResponsiveObject = <T>(\n value: ResponsiveValue<T>,\n): value is { sm?: T; md?: T; lg?: T } => {\n return (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n ('sm' in value || 'md' in value || 'lg' in value)\n );\n};\n\nconst getCurrentBreakpoint = (\n breakpoints: { sm: number; md: number; lg: number },\n windowWidth: number,\n): 'sm' | 'md' | 'lg' => {\n if (windowWidth >= breakpoints.lg) {\n return 'lg';\n }\n if (windowWidth >= breakpoints.md) {\n return 'md';\n }\n return 'sm';\n};\n\nexport const useResponsiveValue = <T>(\n value: ResponsiveValue<T> | undefined,\n): T | undefined => {\n const { breakpoints } = useLayoutValues();\n const [currentBreakpoint, setCurrentBreakpoint] = useState<\n 'sm' | 'md' | 'lg'\n >(() => {\n if (typeof window === 'undefined') {\n return 'sm';\n }\n return getCurrentBreakpoint(breakpoints, window.innerWidth);\n });\n\n useEffect(() => {\n if (\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return;\n }\n\n const updateBreakpoint = () => {\n setCurrentBreakpoint(\n getCurrentBreakpoint(breakpoints, window.innerWidth),\n );\n };\n\n const mediaQueries = [\n window.matchMedia(`(min-width: ${breakpoints.md}px)`),\n window.matchMedia(`(min-width: ${breakpoints.lg}px)`),\n ];\n\n updateBreakpoint();\n\n const handleChange = () => {\n updateBreakpoint();\n };\n\n mediaQueries.forEach(mq => {\n if (mq.addEventListener) {\n mq.addEventListener('change', handleChange);\n } else {\n mq.addListener(handleChange);\n }\n });\n\n return () => {\n mediaQueries.forEach(mq => {\n if (mq.removeEventListener) {\n mq.removeEventListener('change', handleChange);\n } else {\n mq.removeListener(handleChange);\n }\n });\n };\n }, [breakpoints]);\n\n if (!value) {\n return undefined;\n }\n\n if (!isResponsiveObject(value)) {\n return value;\n }\n\n const responsiveValue = value[currentBreakpoint];\n if (responsiveValue !== undefined) {\n return responsiveValue;\n }\n\n const fallbackOrder: Array<'lg' | 'md' | 'sm'> =\n currentBreakpoint === 'lg'\n ? ['lg', 'md', 'sm']\n : currentBreakpoint === 'md'\n ? ['md', 'sm']\n : ['sm'];\n\n for (const bp of fallbackOrder) {\n if (value[bp] !== undefined) {\n return value[bp];\n }\n }\n\n return undefined;\n};\n"],"names":[],"mappings":";;AAIA,MAAM,qBAAqB,CACzB,UACwC;AACxC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,CAAC,MAAM,QAAQ,KAAK,MACnB,QAAQ,SAAS,QAAQ,SAAS,QAAQ;AAE/C;AAEA,MAAM,uBAAuB,CAC3B,aACA,gBACuB;AACvB,MAAI,eAAe,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACA,MAAI,eAAe,YAAY,IAAI;AACjC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,MAAM,qBAAqB,CAChC,UACkB;AAClB,QAAM,EAAE,YAAA,IAAgB,gBAAA;AACxB,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAEhD,MAAM;AACN,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACT;AACA,WAAO,qBAAqB,aAAa,OAAO,UAAU;AAAA,EAC5D,CAAC;AAED,YAAU,MAAM;AACd,QACE,OAAO,WAAW,eAClB,OAAO,OAAO,eAAe,YAC7B;AACA;AAAA,IACF;AAEA,UAAM,mBAAmB,MAAM;AAC7B;AAAA,QACE,qBAAqB,aAAa,OAAO,UAAU;AAAA,MAAA;AAAA,IAEvD;AAEA,UAAM,eAAe;AAAA,MACnB,OAAO,WAAW,eAAe,YAAY,EAAE,KAAK;AAAA,MACpD,OAAO,WAAW,eAAe,YAAY,EAAE,KAAK;AAAA,IAAA;AAGtD,qBAAA;AAEA,UAAM,eAAe,MAAM;AACzB,uBAAA;AAAA,IACF;AAEA,iBAAa,QAAQ,CAAA,OAAM;AACzB,UAAI,GAAG,kBAAkB;AACvB,WAAG,iBAAiB,UAAU,YAAY;AAAA,MAC5C,OAAO;AACL,WAAG,YAAY,YAAY;AAAA,MAC7B;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,mBAAa,QAAQ,CAAA,OAAM;AACzB,YAAI,GAAG,qBAAqB;AAC1B,aAAG,oBAAoB,UAAU,YAAY;AAAA,QAC/C,OAAO;AACL,aAAG,eAAe,YAAY;AAAA,QAChC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,mBAAmB,KAAK,GAAG;AAC9B,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,MAAM,iBAAiB;AAC/C,MAAI,oBAAoB,QAAW;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,gBACJ,sBAAsB,OAClB,CAAC,MAAM,MAAM,IAAI,IACjB,sBAAsB,OACtB,CAAC,MAAM,IAAI,IACX,CAAC,IAAI;AAEX,aAAW,MAAM,eAAe;AAC9B,QAAI,MAAM,EAAE,MAAM,QAAW;AAC3B,aAAO,MAAM,EAAE;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../../../src/beta/LayoutWrapper/utils.ts"],"sourcesContent":["const VALID_SPACING_VALUES = [\n '2xs',\n 'xs',\n 's',\n 's-m',\n 'm',\n 'm-l',\n 'l',\n 'xl',\n '2xl',\n '3xl',\n '4xl',\n '5xl',\n '6xl',\n '7xl',\n '8xl',\n '9xl',\n '10xl',\n '11xl',\n 'none',\n] as const;\n\nexport type GridSpacingValue = (typeof VALID_SPACING_VALUES)[number];\n\nexport type ResponsiveValue<T> =\n | T\n | {\n sm?: T;\n md?: T;\n lg?: T;\n };\n\nexport type Breakpoints = {\n sm: number;\n md: number;\n lg: number;\n};\n\nexport const DEFAULT_BREAKPOINTS: Breakpoints = {\n sm: 0,\n md: 800,\n lg: 1200,\n};\n\nconst isValidSpacingValue = (value: unknown): value is GridSpacingValue => {\n return (\n typeof value === 'string' &&\n VALID_SPACING_VALUES.includes(value as GridSpacingValue)\n );\n};\n\nexport const getSpacingValue = (\n spacing: GridSpacingValue | undefined,\n componentName = 'Grid',\n): string | undefined => {\n if (!spacing) return undefined;\n if (spacing === 'none') return '0';\n\n if (!isValidSpacingValue(spacing)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Invalid ${componentName} spacing value: \"${spacing}\". Valid values are: ${VALID_SPACING_VALUES.join(\n ', ',\n )}. Falling back to undefined.`,\n );\n }\n return undefined;\n }\n\n return `var(--${spacing})`;\n};\n"],"names":[],"mappings":"AAAA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAkBO,MAAM,sBAAmC;AAAA,EAC9C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,sBAAsB,CAAC,UAA8C;AACzE,SACE,OAAO,UAAU,YACjB,qBAAqB,SAAS,KAAyB;AAE3D;AAEO,MAAM,kBAAkB,CAC7B,SACA,gBAAgB,WACO;AACvB,MAAI,CAAC,QAAS,QAAO;AACrB,MAAI,YAAY,OAAQ,QAAO;AAE/B,MAAI,CAAC,oBAAoB,OAAO,GAAG;AACjC,QAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,cAAQ;AAAA,QACN,WAAW,aAAa,oBAAoB,OAAO,wBAAwB,qBAAqB;AAAA,UAC9F;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IAEL;AACA,WAAO;AAAA,EACT;AAEA,SAAO,SAAS,OAAO;AACzB;"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { Breakpoints } from './utils';
|
|
3
|
-
export type LayoutValues = {
|
|
4
|
-
breakpoints: Breakpoints;
|
|
5
|
-
};
|
|
6
|
-
export type LayoutWrapperProps = {
|
|
7
|
-
/** Custom breakpoint values to override defaults */
|
|
8
|
-
breakpoints?: Partial<Breakpoints>;
|
|
9
|
-
/** Children components that can use layout values */
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
};
|
|
12
|
-
export declare const LayoutWrapper: ({ breakpoints: customBreakpoints, children, }: LayoutWrapperProps) => JSX.Element;
|
|
13
|
-
export declare const useLayoutContext: () => LayoutValues | null;
|
|
File without changes
|