@chayns-components/core 5.0.0-beta.989 → 5.0.0-beta.990

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.
@@ -5,14 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _chaynsApi = require("chayns-api");
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
  var _styledComponents = require("styled-components");
10
10
  var _pageProvider = require("../../utils/pageProvider");
11
11
  var _ColorSchemeProvider = _interopRequireDefault(require("../color-scheme-provider/ColorSchemeProvider"));
12
12
  var _PageProvider = require("./PageProvider.styles");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
14
  const GlobalStyle = (0, _styledComponents.createGlobalStyle)`
17
15
  *, *::before, *::after {
18
16
  box-sizing: border-box;
@@ -33,13 +31,8 @@ const PageProvider = ({
33
31
  const {
34
32
  runtimeEnvironment
35
33
  } = (0, _chaynsApi.getEnvironment)();
36
- const shouldUsePadding = !shouldRemovePadding && ![4, 5, 6].includes(runtimeEnvironment);
37
- const [usableHeight, setUsableHeight] = (0, _react.useState)(0);
38
- (0, _react.useEffect)(() => {
39
- void (0, _pageProvider.getUsableHeight)(shouldRemovePadding).then(height => {
40
- setUsableHeight(height);
41
- });
42
- }, [shouldRemovePadding]);
34
+ const shouldUsePadding = !shouldRemovePadding && ![_chaynsApi.RuntimeEnviroment.IntercomPlugin, _chaynsApi.RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
35
+ const usableHeight = (0, _pageProvider.useUsableHeight)(shouldUsePadding);
43
36
  return /*#__PURE__*/_react.default.createElement(_PageProvider.StyledPageProvider, {
44
37
  className: "page-provider",
45
38
  $shouldUsePadding: shouldUsePadding,
@@ -1 +1 @@
1
- {"version":3,"file":"PageProvider.js","names":["_chaynsApi","require","_react","_interopRequireWildcard","_styledComponents","_pageProvider","_ColorSchemeProvider","_interopRequireDefault","_PageProvider","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","GlobalStyle","createGlobalStyle","PageProvider","children","color","colorMode","cssVariables","secondaryColor","siteId","style","designSettings","shouldRemovePadding","shouldUseUsableHeight","runtimeEnvironment","getEnvironment","shouldUsePadding","includes","usableHeight","setUsableHeight","useState","useEffect","getUsableHeight","then","height","createElement","StyledPageProvider","className","$shouldUsePadding","$usableHeight","undefined","displayName","_default","exports"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { getEnvironment } from 'chayns-api';\nimport React, { FC, useEffect, useState } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { getUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Whether the padding should be removed.\n */\n shouldRemovePadding?: boolean;\n /**\n * Whether the usable height should be used.\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n cssVariables = {},\n secondaryColor,\n siteId,\n style = {},\n designSettings,\n shouldRemovePadding,\n shouldUseUsableHeight,\n}) => {\n const { runtimeEnvironment } = getEnvironment();\n const shouldUsePadding =\n !shouldRemovePadding && ![4, 5, 6].includes(runtimeEnvironment as number);\n const [usableHeight, setUsableHeight] = useState(0);\n\n useEffect(() => {\n void getUsableHeight(shouldRemovePadding).then((height) => {\n setUsableHeight(height);\n });\n }, [shouldRemovePadding]);\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n siteId={siteId}\n designSettings={designSettings}\n cssVariables={cssVariables}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAGA,IAAAO,aAAA,GAAAP,OAAA;AAA2D,SAAAM,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,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,CAACJ,mBAAmB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAACK,QAAQ,CAACH,kBAA4B,CAAC;EAC7E,MAAM,CAACI,YAAY,EAAEC,eAAe,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC,CAAC;EAEnD,IAAAC,gBAAS,EAAC,MAAM;IACZ,KAAK,IAAAC,6BAAe,EAACV,mBAAmB,CAAC,CAACW,IAAI,CAAEC,MAAM,IAAK;MACvDL,eAAe,CAACK,MAAM,CAAC;IAC3B,CAAC,CAAC;EACN,CAAC,EAAE,CAACZ,mBAAmB,CAAC,CAAC;EAEzB,oBACItC,MAAA,CAAAS,OAAA,CAAA0C,aAAA,CAAC7C,aAAA,CAAA8C,kBAAkB;IACfC,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEZ,gBAAiB;IACpCa,aAAa,EAAEhB,qBAAqB,GAAGK,YAAY,GAAGY;EAAU,gBAEhExD,MAAA,CAAAS,OAAA,CAAA0C,aAAA,CAAC/C,oBAAA,CAAAK,OAAmB;IAChBsB,KAAK,EAAEA,KAAM;IACbG,cAAc,EAAEA,cAAe;IAC/BF,SAAS,EAAEA,SAAU;IACrBI,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEc,MAAM,EAAE;IAAO,CAAC,GAAGd,KAAM;IACpED,MAAM,EAAEA,MAAO;IACfE,cAAc,EAAEA,cAAe;IAC/BJ,YAAY,EAAEA;EAAa,GAE1BH,QACgB,CAAC,eACtB9B,MAAA,CAAAS,OAAA,CAAA0C,aAAA,CAACxB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDE,YAAY,CAAC4B,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAE3BoB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"PageProvider.js","names":["_chaynsApi","require","_react","_interopRequireDefault","_styledComponents","_pageProvider","_ColorSchemeProvider","_PageProvider","e","__esModule","default","GlobalStyle","createGlobalStyle","PageProvider","children","color","colorMode","cssVariables","secondaryColor","siteId","style","designSettings","shouldRemovePadding","shouldUseUsableHeight","runtimeEnvironment","getEnvironment","shouldUsePadding","RuntimeEnviroment","IntercomPlugin","PagemakerPlugin","includes","usableHeight","useUsableHeight","createElement","StyledPageProvider","className","$shouldUsePadding","$usableHeight","undefined","height","displayName","_default","exports"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { getEnvironment, RuntimeEnviroment } from 'chayns-api';\nimport React, { FC } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { useUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Whether the padding should be removed.\n */\n shouldRemovePadding?: boolean;\n /**\n * Whether the usable height should be used.\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n cssVariables = {},\n secondaryColor,\n siteId,\n style = {},\n designSettings,\n shouldRemovePadding,\n shouldUseUsableHeight,\n}) => {\n const { runtimeEnvironment } = getEnvironment();\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(\n runtimeEnvironment as number,\n );\n\n const usableHeight = useUsableHeight(shouldUsePadding);\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n siteId={siteId}\n designSettings={designSettings}\n cssVariables={cssVariables}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAGA,IAAAM,aAAA,GAAAN,OAAA;AAA2D,SAAAE,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAa3D,MAAMG,WAAW,GAAG,IAAAC,mCAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMC,YAAmC,GAAGA,CAAC;EACzCC,QAAQ;EACRC,KAAK;EACLC,SAAS;EACTC,YAAY,GAAG,CAAC,CAAC;EACjBC,cAAc;EACdC,MAAM;EACNC,KAAK,GAAG,CAAC,CAAC;EACVC,cAAc;EACdC,mBAAmB;EACnBC;AACJ,CAAC,KAAK;EACF,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,yBAAc,EAAC,CAAC;EAC/C,MAAMC,gBAAgB,GAClB,CAACJ,mBAAmB,IACpB,CAAC,CAACK,4BAAiB,CAACC,cAAc,EAAED,4BAAiB,CAACE,eAAe,EAAE,CAAC,CAAC,CAACC,QAAQ,CAC9EN,kBACJ,CAAC;EAEL,MAAMO,YAAY,GAAG,IAAAC,6BAAe,EAACN,gBAAgB,CAAC;EAEtD,oBACIxB,MAAA,CAAAQ,OAAA,CAAAuB,aAAA,CAAC1B,aAAA,CAAA2B,kBAAkB;IACfC,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAEV,gBAAiB;IACpCW,aAAa,EAAEd,qBAAqB,GAAGQ,YAAY,GAAGO;EAAU,gBAEhEpC,MAAA,CAAAQ,OAAA,CAAAuB,aAAA,CAAC3B,oBAAA,CAAAI,OAAmB;IAChBK,KAAK,EAAEA,KAAM;IACbG,cAAc,EAAEA,cAAe;IAC/BF,SAAS,EAAEA,SAAU;IACrBI,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEmB,MAAM,EAAE;IAAO,CAAC,GAAGnB,KAAM;IACpED,MAAM,EAAEA,MAAO;IACfE,cAAc,EAAEA,cAAe;IAC/BJ,YAAY,EAAEA;EAAa,GAE1BH,QACgB,CAAC,eACtBZ,MAAA,CAAAQ,OAAA,CAAAuB,aAAA,CAACtB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDE,YAAY,CAAC2B,WAAW,GAAG,cAAc;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhC,OAAA,GAE3BG,YAAY","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getUsableHeight = exports.getPagePadding = void 0;
6
+ exports.useUsableHeight = exports.getUsableHeight = exports.getPagePadding = void 0;
7
7
  var _chaynsApi = require("chayns-api");
8
8
  var _pageProvider = require("../constants/pageProvider");
9
9
  const getPagePadding = () => {
@@ -92,4 +92,28 @@ const getUsableHeight = async shouldRemovePadding => {
92
92
  return usableHeight;
93
93
  };
94
94
  exports.getUsableHeight = getUsableHeight;
95
+ const useUsableHeight = shouldRemovePadding => {
96
+ let usableHeight;
97
+ const {
98
+ bottomBarHeight,
99
+ offsetTop,
100
+ windowHeight
101
+ } = (0, _chaynsApi.useWindowMetrics)();
102
+ const {
103
+ bottom,
104
+ top
105
+ } = shouldRemovePadding ? {
106
+ bottom: 0,
107
+ top: 0
108
+ } : getPageProviderInformation();
109
+ usableHeight = windowHeight - bottom - top;
110
+ if (bottomBarHeight) {
111
+ usableHeight -= bottomBarHeight;
112
+ }
113
+ if (offsetTop) {
114
+ usableHeight -= offsetTop;
115
+ }
116
+ return usableHeight;
117
+ };
118
+ exports.useUsableHeight = useUsableHeight;
95
119
  //# sourceMappingURL=pageProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageProvider.js","names":["_chaynsApi","require","_pageProvider","getPagePadding","runtimeEnvironment","getEnvironment","includes","matchMedia","PAGE_BREAKPOINTS","desktop","matches","exports","getPageProviderInformation","padding","split","parseValue","value","parsed","parseInt","replace","Number","isNaN","length","top","right","bottom","left","vertical","horizontal","map","getUsableHeight","shouldRemovePadding","usableHeight","bottomBarHeight","offsetTop","windowHeight","getWindowMetrics"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getEnvironment, getWindowMetrics } from 'chayns-api';\nimport { PAGE_BREAKPOINTS } from '../constants/pageProvider';\n\nexport const getPagePadding = () => {\n const { runtimeEnvironment } = getEnvironment();\n\n if (typeof runtimeEnvironment === 'number' && [4, 5].includes(runtimeEnvironment)) {\n return '0';\n }\n\n if (matchMedia(PAGE_BREAKPOINTS.desktop).matches) {\n return '35px 43px 30px';\n }\n\n return '15px 10px 20px';\n};\n\ntype PaddingValues = {\n top: number;\n right: number;\n bottom: number;\n left: number;\n};\n\nconst getPageProviderInformation = (): PaddingValues => {\n const padding = getPagePadding().split(' ');\n\n const parseValue = (value: string): number => {\n const parsed = parseInt(value.replace('px', ''), 10);\n return Number.isNaN(parsed) ? 0 : parsed;\n };\n\n if (padding.length === 1) {\n const value = parseValue(padding[0] ?? '');\n return { top: value, right: value, bottom: value, left: value };\n }\n\n if (padding.length === 2) {\n const [vertical, horizontal] = padding.map(parseValue);\n return {\n top: vertical ?? 0,\n right: horizontal ?? 0,\n bottom: vertical ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 3) {\n const [top, horizontal, bottom] = padding.map(parseValue);\n return {\n top: top ?? 0,\n right: horizontal ?? 0,\n bottom: bottom ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 4) {\n const [top, right, bottom, left] = padding.map(parseValue);\n return { top: top ?? 0, right: right ?? 0, bottom: bottom ?? 0, left: left ?? 0 };\n }\n\n return { top: 0, right: 0, bottom: 0, left: 0 };\n};\n\nexport const getUsableHeight = async (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEO,MAAME,cAAc,GAAGA,CAAA,KAAM;EAChC,MAAM;IAAEC;EAAmB,CAAC,GAAG,IAAAC,yBAAc,EAAC,CAAC;EAE/C,IAAI,OAAOD,kBAAkB,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAACE,QAAQ,CAACF,kBAAkB,CAAC,EAAE;IAC/E,OAAO,GAAG;EACd;EAEA,IAAIG,UAAU,CAACC,8BAAgB,CAACC,OAAO,CAAC,CAACC,OAAO,EAAE;IAC9C,OAAO,gBAAgB;EAC3B;EAEA,OAAO,gBAAgB;AAC3B,CAAC;AAACC,OAAA,CAAAR,cAAA,GAAAA,cAAA;AASF,MAAMS,0BAA0B,GAAGA,CAAA,KAAqB;EACpD,MAAMC,OAAO,GAAGV,cAAc,CAAC,CAAC,CAACW,KAAK,CAAC,GAAG,CAAC;EAE3C,MAAMC,UAAU,GAAIC,KAAa,IAAa;IAC1C,MAAMC,MAAM,GAAGC,QAAQ,CAACF,KAAK,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;IACpD,OAAOC,MAAM,CAACC,KAAK,CAACJ,MAAM,CAAC,GAAG,CAAC,GAAGA,MAAM;EAC5C,CAAC;EA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,CAAC;EACrF;EAEA,OAAO;IAAEH,GAAG,EAAE,CAAC;IAAEC,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE,CAAC;IAAEC,IAAI,EAAE;EAAE,CAAC;AACnD,CAAC;AAEM,MAAMI,eAAe,GAAG,MAAOC,mBAA6B,IAAK;EACpE,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,2BAAgB,EAAC,CAAC;EAE7E,MAAM;IAAEX,MAAM;IAAEF;EAAI,CAAC,GAAGQ,mBAAmB,GACrC;IAAEN,MAAM,EAAE,CAAC;IAAEF,GAAG,EAAE;EAAE,CAAC,GACrBX,0BAA0B,CAAC,CAAC;EAElCoB,YAAY,GAAGG,YAAY,GAAGV,MAAM,GAAGF,GAAG;EAE1C,IAAIU,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAACrB,OAAA,CAAAmB,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"pageProvider.js","names":["_chaynsApi","require","_pageProvider","getPagePadding","runtimeEnvironment","getEnvironment","includes","matchMedia","PAGE_BREAKPOINTS","desktop","matches","exports","getPageProviderInformation","padding","split","parseValue","value","parsed","parseInt","replace","Number","isNaN","length","top","right","bottom","left","vertical","horizontal","map","getUsableHeight","shouldRemovePadding","usableHeight","bottomBarHeight","offsetTop","windowHeight","getWindowMetrics","useUsableHeight","useWindowMetrics"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getEnvironment, getWindowMetrics, useWindowMetrics } from 'chayns-api';\nimport { PAGE_BREAKPOINTS } from '../constants/pageProvider';\n\nexport const getPagePadding = () => {\n const { runtimeEnvironment } = getEnvironment();\n\n if (typeof runtimeEnvironment === 'number' && [4, 5].includes(runtimeEnvironment)) {\n return '0';\n }\n\n if (matchMedia(PAGE_BREAKPOINTS.desktop).matches) {\n return '35px 43px 30px';\n }\n\n return '15px 10px 20px';\n};\n\ntype PaddingValues = {\n top: number;\n right: number;\n bottom: number;\n left: number;\n};\n\nconst getPageProviderInformation = (): PaddingValues => {\n const padding = getPagePadding().split(' ');\n\n const parseValue = (value: string): number => {\n const parsed = parseInt(value.replace('px', ''), 10);\n return Number.isNaN(parsed) ? 0 : parsed;\n };\n\n if (padding.length === 1) {\n const value = parseValue(padding[0] ?? '');\n return { top: value, right: value, bottom: value, left: value };\n }\n\n if (padding.length === 2) {\n const [vertical, horizontal] = padding.map(parseValue);\n return {\n top: vertical ?? 0,\n right: horizontal ?? 0,\n bottom: vertical ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 3) {\n const [top, horizontal, bottom] = padding.map(parseValue);\n return {\n top: top ?? 0,\n right: horizontal ?? 0,\n bottom: bottom ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 4) {\n const [top, right, bottom, left] = padding.map(parseValue);\n return { top: top ?? 0, right: right ?? 0, bottom: bottom ?? 0, left: left ?? 0 };\n }\n\n return { top: 0, right: 0, bottom: 0, left: 0 };\n};\n\nexport const getUsableHeight = async (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = useWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHe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AAC,CAAC;EAE7E,MAAM;IAAEX,MAAM;IAAEF;EAAI,CAAC,GAAGQ,mBAAmB,GACrC;IAAEN,MAAM,EAAE,CAAC;IAAEF,GAAG,EAAE;EAAE,CAAC,GACrBX,0BAA0B,CAAC,CAAC;EAElCoB,YAAY,GAAGG,YAAY,GAAGV,MAAM,GAAGF,GAAG;EAE1C,IAAIU,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAACrB,OAAA,CAAAmB,eAAA,GAAAA,eAAA;AAEK,MAAMO,eAAe,GAAIN,mBAA6B,IAAK;EAC9D,IAAIC,YAAY;EAEhB,MAAM;IAAEC,eAAe;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAG,IAAAG,2BAAgB,EAAC,CAAC;EAEvE,MAAM;IAAEb,MAAM;IAAEF;EAAI,CAAC,GAAGQ,mBAAmB,GACrC;IAAEN,MAAM,EAAE,CAAC;IAAEF,GAAG,EAAE;EAAE,CAAC,GACrBX,0BAA0B,CAAC,CAAC;EAElCoB,YAAY,GAAGG,YAAY,GAAGV,MAAM,GAAGF,GAAG;EAE1C,IAAIU,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC;AAACrB,OAAA,CAAA0B,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { getEnvironment } from 'chayns-api';
2
- import React, { useEffect, useState } from 'react';
1
+ import { getEnvironment, RuntimeEnviroment } from 'chayns-api';
2
+ import React from 'react';
3
3
  import { createGlobalStyle } from 'styled-components';
4
- import { getUsableHeight } from '../../utils/pageProvider';
4
+ import { useUsableHeight } from '../../utils/pageProvider';
5
5
  import ColorSchemeProvider from '../color-scheme-provider/ColorSchemeProvider';
6
6
  import { StyledPageProvider } from './PageProvider.styles';
7
7
  const GlobalStyle = createGlobalStyle`
@@ -25,13 +25,8 @@ const PageProvider = _ref => {
25
25
  const {
26
26
  runtimeEnvironment
27
27
  } = getEnvironment();
28
- const shouldUsePadding = !shouldRemovePadding && ![4, 5, 6].includes(runtimeEnvironment);
29
- const [usableHeight, setUsableHeight] = useState(0);
30
- useEffect(() => {
31
- void getUsableHeight(shouldRemovePadding).then(height => {
32
- setUsableHeight(height);
33
- });
34
- }, [shouldRemovePadding]);
28
+ const shouldUsePadding = !shouldRemovePadding && ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(runtimeEnvironment);
29
+ const usableHeight = useUsableHeight(shouldUsePadding);
35
30
  return /*#__PURE__*/React.createElement(StyledPageProvider, {
36
31
  className: "page-provider",
37
32
  $shouldUsePadding: shouldUsePadding,
@@ -1 +1 @@
1
- {"version":3,"file":"PageProvider.js","names":["getEnvironment","React","useEffect","useState","createGlobalStyle","getUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","_ref","children","color","colorMode","cssVariables","secondaryColor","siteId","style","designSettings","shouldRemovePadding","shouldUseUsableHeight","runtimeEnvironment","shouldUsePadding","includes","usableHeight","setUsableHeight","then","height","createElement","className","$shouldUsePadding","$usableHeight","undefined","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { getEnvironment } from 'chayns-api';\nimport React, { FC, useEffect, useState } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { getUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Whether the padding should be removed.\n */\n shouldRemovePadding?: boolean;\n /**\n * Whether the usable height should be used.\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n cssVariables = {},\n secondaryColor,\n siteId,\n style = {},\n designSettings,\n shouldRemovePadding,\n shouldUseUsableHeight,\n}) => {\n const { runtimeEnvironment } = getEnvironment();\n const shouldUsePadding =\n !shouldRemovePadding && ![4, 5, 6].includes(runtimeEnvironment as number);\n const [usableHeight, setUsableHeight] = useState(0);\n\n useEffect(() => {\n void getUsableHeight(shouldRemovePadding).then((height) => {\n setUsableHeight(height);\n });\n }, [shouldRemovePadding]);\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n siteId={siteId}\n designSettings={designSettings}\n cssVariables={cssVariables}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n </StyledPageProvider>\n );\n};\nPageProvider.displayName = 'PageProvider';\n\nexport default PageProvider;\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAC3C,OAAOC,KAAK,IAAQC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACtD,SAASC,iBAAiB,QAAQ,mBAAmB;AACrD,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,OAAOC,mBAAmB,MAEnB,8CAA8C;AACrD,SAASC,kBAAkB,QAAQ,uBAAuB;AAa1D,MAAMC,WAAW,GAAGJ,iBAAiB;AACrC;AACA;AACA;AACA,CAAC;AAED,MAAMK,YAAmC,GAAGC,IAAA,IAWtC;EAAA,IAXuC;IACzCC,QAAQ;IACRC,KAAK;IACLC,SAAS;IACTC,YAAY,GAAG,CAAC,CAAC;IACjBC,cAAc;IACdC,MAAM;IACNC,KAAK,GAAG,CAAC,CAAC;IACVC,cAAc;IACdC,mBAAmB;IACnBC;EACJ,CAAC,GAAAV,IAAA;EACG,MAAM;IAAEW;EAAmB,CAAC,GAAGrB,cAAc,CAAC,CAAC;EAC/C,MAAMsB,gBAAgB,GAClB,CAACH,mBAAmB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAACI,QAAQ,CAACF,kBAA4B,CAAC;EAC7E,MAAM,CAACG,YAAY,EAAEC,eAAe,CAAC,GAAGtB,QAAQ,CAAC,CAAC,CAAC;EAEnDD,SAAS,CAAC,MAAM;IACZ,KAAKG,eAAe,CAACc,mBAAmB,CAAC,CAACO,IAAI,CAAEC,MAAM,IAAK;MACvDF,eAAe,CAACE,MAAM,CAAC;IAC3B,CAAC,CAAC;EACN,CAAC,EAAE,CAACR,mBAAmB,CAAC,CAAC;EAEzB,oBACIlB,KAAA,CAAA2B,aAAA,CAACrB,kBAAkB;IACfsB,SAAS,EAAC,eAAe;IACzBC,iBAAiB,EAAER,gBAAiB;IACpCS,aAAa,EAAEX,qBAAqB,GAAGI,YAAY,GAAGQ;EAAU,gBAEhE/B,KAAA,CAAA2B,aAAA,CAACtB,mBAAmB;IAChBM,KAAK,EAAEA,KAAM;IACbG,cAAc,EAAEA,cAAe;IAC/BF,SAAS,EAAEA,SAAU;IACrBI,KAAK,EAAEG,qBAAqB,GAAG;MAAE,GAAGH,KAAK;MAAEU,MAAM,EAAE;IAAO,CAAC,GAAGV,KAAM;IACpED,MAAM,EAAEA,MAAO;IACfE,cAAc,EAAEA,cAAe;IAC/BJ,YAAY,EAAEA;EAAa,GAE1BH,QACgB,CAAC,eACtBV,KAAA,CAAA2B,aAAA,CAACpB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAACwB,WAAW,GAAG,cAAc;AAEzC,eAAexB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"PageProvider.js","names":["getEnvironment","RuntimeEnviroment","React","createGlobalStyle","useUsableHeight","ColorSchemeProvider","StyledPageProvider","GlobalStyle","PageProvider","_ref","children","color","colorMode","cssVariables","secondaryColor","siteId","style","designSettings","shouldRemovePadding","shouldUseUsableHeight","runtimeEnvironment","shouldUsePadding","IntercomPlugin","PagemakerPlugin","includes","usableHeight","createElement","className","$shouldUsePadding","$usableHeight","undefined","height","displayName"],"sources":["../../../../src/components/page-provider/PageProvider.tsx"],"sourcesContent":["import { getEnvironment, RuntimeEnviroment } from 'chayns-api';\nimport React, { FC } from 'react';\nimport { createGlobalStyle } from 'styled-components';\nimport { useUsableHeight } from '../../utils/pageProvider';\nimport ColorSchemeProvider, {\n type ColorSchemeProviderProps,\n} from '../color-scheme-provider/ColorSchemeProvider';\nimport { StyledPageProvider } from './PageProvider.styles';\n\ninterface PageProviderProps extends ColorSchemeProviderProps {\n /**\n * Whether the padding should be removed.\n */\n shouldRemovePadding?: boolean;\n /**\n * Whether the usable height should be used.\n */\n shouldUseUsableHeight?: boolean;\n}\n\nconst GlobalStyle = createGlobalStyle`\n *, *::before, *::after {\n box-sizing: border-box;\n }\n`;\n\nconst PageProvider: FC<PageProviderProps> = ({\n children,\n color,\n colorMode,\n cssVariables = {},\n secondaryColor,\n siteId,\n style = {},\n designSettings,\n shouldRemovePadding,\n shouldUseUsableHeight,\n}) => {\n const { runtimeEnvironment } = getEnvironment();\n const shouldUsePadding =\n !shouldRemovePadding &&\n ![RuntimeEnviroment.IntercomPlugin, RuntimeEnviroment.PagemakerPlugin, 6].includes(\n runtimeEnvironment as number,\n );\n\n const usableHeight = useUsableHeight(shouldUsePadding);\n\n return (\n <StyledPageProvider\n className=\"page-provider\"\n $shouldUsePadding={shouldUsePadding}\n $usableHeight={shouldUseUsableHeight ? usableHeight : undefined}\n >\n <ColorSchemeProvider\n color={color}\n secondaryColor={secondaryColor}\n colorMode={colorMode}\n style={shouldUseUsableHeight ? { ...style, height: '100%' } : style}\n siteId={siteId}\n designSettings={designSettings}\n cssVariables={cssVariables}\n >\n {children}\n </ColorSchemeProvider>\n <GlobalStyle />\n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,EAAE;IAAO,CAAC,GAAGf,KAAM;IACpED,MAAM,EAAEA,MAAO;IACfE,cAAc,EAAEA,cAAe;IAC/BJ,YAAY,EAAEA;EAAa,GAE1BH,QACgB,CAAC,eACtBR,KAAA,CAAAwB,aAAA,CAACnB,WAAW,MAAE,CACE,CAAC;AAE7B,CAAC;AACDC,YAAY,CAACwB,WAAW,GAAG,cAAc;AAEzC,eAAexB,YAAY","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { getEnvironment, getWindowMetrics } from 'chayns-api';
1
+ import { getEnvironment, getWindowMetrics, useWindowMetrics } from 'chayns-api';
2
2
  import { PAGE_BREAKPOINTS } from '../constants/pageProvider';
3
3
  export const getPagePadding = () => {
4
4
  const {
@@ -84,4 +84,27 @@ export const getUsableHeight = async shouldRemovePadding => {
84
84
  }
85
85
  return usableHeight;
86
86
  };
87
+ export const useUsableHeight = shouldRemovePadding => {
88
+ let usableHeight;
89
+ const {
90
+ bottomBarHeight,
91
+ offsetTop,
92
+ windowHeight
93
+ } = useWindowMetrics();
94
+ const {
95
+ bottom,
96
+ top
97
+ } = shouldRemovePadding ? {
98
+ bottom: 0,
99
+ top: 0
100
+ } : getPageProviderInformation();
101
+ usableHeight = windowHeight - bottom - top;
102
+ if (bottomBarHeight) {
103
+ usableHeight -= bottomBarHeight;
104
+ }
105
+ if (offsetTop) {
106
+ usableHeight -= offsetTop;
107
+ }
108
+ return usableHeight;
109
+ };
87
110
  //# sourceMappingURL=pageProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pageProvider.js","names":["getEnvironment","getWindowMetrics","PAGE_BREAKPOINTS","getPagePadding","runtimeEnvironment","includes","matchMedia","desktop","matches","getPageProviderInformation","padding","split","parseValue","value","parsed","parseInt","replace","Number","isNaN","length","top","right","bottom","left","vertical","horizontal","map","getUsableHeight","shouldRemovePadding","usableHeight","bottomBarHeight","offsetTop","windowHeight"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getEnvironment, getWindowMetrics } from 'chayns-api';\nimport { PAGE_BREAKPOINTS } from '../constants/pageProvider';\n\nexport const getPagePadding = () => {\n const { runtimeEnvironment } = getEnvironment();\n\n if (typeof runtimeEnvironment === 'number' && [4, 5].includes(runtimeEnvironment)) {\n return '0';\n }\n\n if (matchMedia(PAGE_BREAKPOINTS.desktop).matches) {\n return '35px 43px 30px';\n }\n\n return '15px 10px 20px';\n};\n\ntype PaddingValues = {\n top: number;\n right: number;\n bottom: number;\n left: number;\n};\n\nconst getPageProviderInformation = (): PaddingValues => {\n const padding = getPagePadding().split(' ');\n\n const parseValue = (value: string): number => {\n const parsed = parseInt(value.replace('px', ''), 10);\n return Number.isNaN(parsed) ? 0 : parsed;\n };\n\n if (padding.length === 1) {\n const value = parseValue(padding[0] ?? '');\n return { top: value, right: value, bottom: value, left: value };\n }\n\n if (padding.length === 2) {\n const [vertical, horizontal] = padding.map(parseValue);\n return {\n top: vertical ?? 0,\n right: horizontal ?? 0,\n bottom: vertical ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 3) {\n const [top, horizontal, bottom] = padding.map(parseValue);\n return {\n top: top ?? 0,\n right: horizontal ?? 0,\n bottom: bottom ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 4) {\n const [top, right, bottom, left] = padding.map(parseValue);\n return { top: top ?? 0, right: right ?? 0, bottom: bottom ?? 0, left: left ?? 0 };\n }\n\n return { top: 0, right: 0, bottom: 0, left: 0 };\n};\n\nexport const getUsableHeight = async (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,g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BX,0BAA0B,CAAC,CAAC;EAElCoB,YAAY,GAAGG,YAAY,GAAGV,MAAM,GAAGF,GAAG;EAE1C,IAAIU,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"pageProvider.js","names":["getEnvironment","getWindowMetrics","useWindowMetrics","PAGE_BREAKPOINTS","getPagePadding","runtimeEnvironment","includes","matchMedia","desktop","matches","getPageProviderInformation","padding","split","parseValue","value","parsed","parseInt","replace","Number","isNaN","length","top","right","bottom","left","vertical","horizontal","map","getUsableHeight","shouldRemovePadding","usableHeight","bottomBarHeight","offsetTop","windowHeight","useUsableHeight"],"sources":["../../../src/utils/pageProvider.ts"],"sourcesContent":["import { getEnvironment, getWindowMetrics, useWindowMetrics } from 'chayns-api';\nimport { PAGE_BREAKPOINTS } from '../constants/pageProvider';\n\nexport const getPagePadding = () => {\n const { runtimeEnvironment } = getEnvironment();\n\n if (typeof runtimeEnvironment === 'number' && [4, 5].includes(runtimeEnvironment)) {\n return '0';\n }\n\n if (matchMedia(PAGE_BREAKPOINTS.desktop).matches) {\n return '35px 43px 30px';\n }\n\n return '15px 10px 20px';\n};\n\ntype PaddingValues = {\n top: number;\n right: number;\n bottom: number;\n left: number;\n};\n\nconst getPageProviderInformation = (): PaddingValues => {\n const padding = getPagePadding().split(' ');\n\n const parseValue = (value: string): number => {\n const parsed = parseInt(value.replace('px', ''), 10);\n return Number.isNaN(parsed) ? 0 : parsed;\n };\n\n if (padding.length === 1) {\n const value = parseValue(padding[0] ?? '');\n return { top: value, right: value, bottom: value, left: value };\n }\n\n if (padding.length === 2) {\n const [vertical, horizontal] = padding.map(parseValue);\n return {\n top: vertical ?? 0,\n right: horizontal ?? 0,\n bottom: vertical ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 3) {\n const [top, horizontal, bottom] = padding.map(parseValue);\n return {\n top: top ?? 0,\n right: horizontal ?? 0,\n bottom: bottom ?? 0,\n left: horizontal ?? 0,\n };\n }\n\n if (padding.length === 4) {\n const [top, right, bottom, left] = padding.map(parseValue);\n return { top: top ?? 0, right: right ?? 0, bottom: bottom ?? 0, left: left ?? 0 };\n }\n\n return { top: 0, right: 0, bottom: 0, left: 0 };\n};\n\nexport const getUsableHeight = async (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = await getWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n\nexport const useUsableHeight = (shouldRemovePadding?: boolean) => {\n let usableHeight;\n\n const { bottomBarHeight, offsetTop, windowHeight } = useWindowMetrics();\n\n const { bottom, top } = shouldRemovePadding\n ? { bottom: 0, top: 0 }\n : getPageProviderInformation();\n\n usableHeight = windowHeight - bottom - top;\n\n if (bottomBarHeight) {\n usableHeight -= bottomBarHeight;\n }\n\n if (offsetTop) {\n usableHeight -= offsetTop;\n }\n\n return usableHeight;\n};\n"],"mappings":"AAAA,SAASA,cAAc,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,YAAY;AAC/E,SAASC,gBAAgB,QAAQ,2BAA2B;AAE5D,OAAO,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAChC,MAAM;IAAEC;EAAmB,CAAC,GAAGL,cAAc,CAAC,CAAC;EAE/C,IAAI,OAAOK,kBAAkB,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAACC,QAAQ,CAACD,kBAAkB,CAAC,EAAE;IAC/E,OAAO,GAAG;EACd;EAEA,IAAIE,UAAU,CAACJ,gBAAgB,CAACK,OAAO,CAAC,CAACC,OAA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,CAAC,CAAC;EAEvE,MAAM;IAAEqB,MAAM;IAAEF;EAAI,CAAC,GAAGQ,mBAAmB,GACrC;IAAEN,MAAM,EAAE,CAAC;IAAEF,GAAG,EAAE;EAAE,CAAC,GACrBX,0BAA0B,CAAC,CAAC;EAElCoB,YAAY,GAAGG,YAAY,GAAGV,MAAM,GAAGF,GAAG;EAE1C,IAAIU,eAAe,EAAE;IACjBD,YAAY,IAAIC,eAAe;EACnC;EAEA,IAAIC,SAAS,EAAE;IACXF,YAAY,IAAIE,SAAS;EAC7B;EAEA,OAAOF,YAAY;AACvB,CAAC","ignoreList":[]}
@@ -1,2 +1,3 @@
1
1
  export declare const getPagePadding: () => "0" | "35px 43px 30px" | "15px 10px 20px";
2
2
  export declare const getUsableHeight: (shouldRemovePadding?: boolean) => Promise<number>;
3
+ export declare const useUsableHeight: (shouldRemovePadding?: boolean) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.0.0-beta.989",
3
+ "version": "5.0.0-beta.990",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -87,5 +87,5 @@
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  },
90
- "gitHead": "7a6c163e7710eb59c37261dfdc224d2bd38460a4"
90
+ "gitHead": "858b5f5d16fdc59d43c6b702a7ab2f4d544ed6eb"
91
91
  }