@ndlib/component-library 1.0.1 → 1.0.3

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.
@@ -4,6 +4,7 @@ type MediaContextType = {
4
4
  breakpoint: number;
5
5
  };
6
6
  export declare const MediaSizeProvider: React.FC<PropsWithChildren<{
7
+ ssrBreakpoint?: number;
7
8
  useHydrationPatch?: boolean;
8
9
  }>>;
9
10
  export declare const useMediaQuery: () => MediaContextType;
@@ -5,8 +5,9 @@ const MediaContext = createContext({
5
5
  screenSize: -1,
6
6
  breakpoint: -1,
7
7
  });
8
- export const MediaSizeProvider = ({ useHydrationPatch, children }) => {
8
+ export const MediaSizeProvider = ({ useHydrationPatch, ssrBreakpoint: ssrBreakpointParam, children }) => {
9
9
  const [renderCount, setRenderCount] = useState(0);
10
+ const ssrBreakpoint = ssrBreakpointParam || -1;
10
11
  const theme = useTheme();
11
12
  const breakpoints = theme.breakpoints.map((bp) => parseInt(bp.slice(0, -2)), [theme]);
12
13
  const getBreakpoint = (screenSize) => {
@@ -15,7 +16,7 @@ export const MediaSizeProvider = ({ useHydrationPatch, children }) => {
15
16
  };
16
17
  const initialScreenSize = useHydrationPatch || typeof window === 'undefined' ? -1 : window.innerWidth;
17
18
  const initialBreakpoint = useHydrationPatch || typeof window === 'undefined'
18
- ? -1
19
+ ? ssrBreakpoint
19
20
  : getBreakpoint(window.innerWidth);
20
21
  const [screenSize, setScreenSize] = useState(initialScreenSize);
21
22
  const [breakpoint, setBreakpoint] = useState(initialBreakpoint);
@@ -12,6 +12,7 @@ export type UiConfig = {
12
12
  loadFonts?: boolean;
13
13
  loadGlobalStyles?: boolean;
14
14
  includeTheme?: boolean;
15
+ ssrBreakpoint?: number;
15
16
  useHydrationPatch?: boolean;
16
17
  };
17
18
  type UiProviderProps = PropsWithChildren<UiConfig>;
@@ -10,7 +10,7 @@ import { MediaSizeProvider } from './media';
10
10
  import StructuredData from '../composites/StructuredData';
11
11
  import { SnackBarProvider } from './snackBar';
12
12
  import { UniqueIdProvider } from './uniqueIds';
13
- export const UiProvider = ({ structuredData, env, components, alertsConfig, children, includeTheme = true, loadFonts, loadGlobalStyles, useHydrationPatch = true, }) => {
14
- const core = (_jsxs(EnvironmentProvider, Object.assign({ env: env }, { children: [_jsx(MediaSizeProvider, Object.assign({ useHydrationPatch: useHydrationPatch }, { children: _jsx(ComponentConfigProvider, Object.assign({ config: components || {} }, { children: _jsx(UniqueIdProvider, { children: _jsx(SnackBarProvider, { children: _jsx(DialogsProvider, { children: _jsx(AlertsProvider, Object.assign({}, alertsConfig, { children: children })) }) }) }) })) })), loadGlobalStyles && _jsx(GlobalStyles, {}), loadFonts && _jsx(FontLoader, {}), structuredData && _jsx(StructuredData, Object.assign({}, structuredData))] })));
13
+ export const UiProvider = ({ structuredData, env, components, alertsConfig, children, includeTheme = true, loadFonts, loadGlobalStyles, useHydrationPatch, ssrBreakpoint, }) => {
14
+ const core = (_jsxs(EnvironmentProvider, Object.assign({ env: env }, { children: [_jsx(MediaSizeProvider, Object.assign({ ssrBreakpoint: ssrBreakpoint, useHydrationPatch: useHydrationPatch }, { children: _jsx(ComponentConfigProvider, Object.assign({ config: components || {} }, { children: _jsx(UniqueIdProvider, { children: _jsx(SnackBarProvider, { children: _jsx(DialogsProvider, { children: _jsx(AlertsProvider, Object.assign({}, alertsConfig, { children: children })) }) }) }) })) })), loadGlobalStyles && _jsx(GlobalStyles, {}), loadFonts && _jsx(FontLoader, {}), structuredData && _jsx(StructuredData, Object.assign({}, structuredData))] })));
15
15
  return includeTheme ? _jsx(ThemeProvider, { children: core }) : core;
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [